@firela/api-types 0.0.0-canary.830b29d0 → 0.0.0-canary.84b23d91

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.
@@ -6,18 +6,12 @@ export const $CreateAccountDto = {
6
6
  path: {
7
7
  type: 'string',
8
8
  description: 'Account path (hierarchical, colon-separated)',
9
- example: 'Assets:CN:Bank:ICBC:Checking'
10
- },
11
- displayName: {
12
- type: 'string',
13
- description:
14
- 'Display name to distinguish accounts at the same path (default: "")',
15
- example: '工资卡'
9
+ example: 'Assets:CN:ICBC:Checking'
16
10
  },
17
11
  openDate: {
18
12
  format: 'date-time',
19
13
  type: 'string',
20
- description: 'Account open date',
14
+ description: 'Account open date (server defaults to today)',
21
15
  example: '2024-01-01'
22
16
  },
23
17
  currencies: {
@@ -45,26 +39,22 @@ export const $CreateAccountDto = {
45
39
  templatePath: {
46
40
  type: 'string',
47
41
  description: 'Reference to account-standards template path',
48
- example: 'Assets:CN:Bank:ICBC:Checking'
42
+ example: 'Assets:CN:Checking'
49
43
  },
50
44
  isCustom: {
51
45
  type: 'boolean',
52
46
  description: 'Whether this is a custom (user-created) account',
53
47
  default: false
54
48
  },
55
- i18nKey: {
56
- type: 'string',
57
- description: 'i18n key for display name (overrides template)',
58
- example: 'account.custom.mybank'
59
- },
60
49
  icon: {
61
50
  type: 'string',
62
51
  description: 'Icon identifier (overrides template)',
63
52
  example: 'bank-custom'
64
53
  },
65
- openMeta: {
54
+ openDirectiveMeta: {
66
55
  type: 'object',
67
- description: 'Additional metadata',
56
+ description:
57
+ 'Open directive metadata (NOT an opening-balance amount — use the opening-balance endpoint)',
68
58
  example: {
69
59
  branch: 'Downtown',
70
60
  accountNumber: '1234'
@@ -76,7 +66,7 @@ export const $CreateAccountDto = {
76
66
  example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2'
77
67
  }
78
68
  },
79
- required: ['path', 'openDate']
69
+ required: ['path']
80
70
  } as const;
81
71
 
82
72
  export const $AccountResponseDto = {
@@ -90,13 +80,7 @@ export const $AccountResponseDto = {
90
80
  path: {
91
81
  type: 'string',
92
82
  description: 'Account path (hierarchical, colon-separated)',
93
- example: 'Assets:CN:Bank:ICBC:Checking'
94
- },
95
- displayName: {
96
- type: 'string',
97
- description:
98
- 'Display name distinguishing multiple accounts at the same path',
99
- example: '工资卡'
83
+ example: 'Assets:CN:ICBC:Checking'
100
84
  },
101
85
  type: {
102
86
  type: 'string',
@@ -104,6 +88,47 @@ export const $AccountResponseDto = {
104
88
  enum: ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity'],
105
89
  example: 'Assets'
106
90
  },
91
+ assetSubClass: {
92
+ type: 'string',
93
+ description:
94
+ 'Account-level asset sub-class (product type, e.g. STOCK/DEPOSIT/CREDIT_CARD/PERSONAL_LOAN). Computed from the account path via the asset-classifier (ADR-0077). Null for non-asset accounts (Income/Expenses/Equity) or unmatched paths.',
95
+ enum: [
96
+ 'DEPOSIT',
97
+ 'CASH',
98
+ 'MONEY_MARKET_FUND',
99
+ 'STOCK',
100
+ 'ETF',
101
+ 'MUTUAL_FUND',
102
+ 'EQUITY_COMPENSATION',
103
+ 'GOVERNMENT_BOND',
104
+ 'CORPORATE_BOND',
105
+ 'BOND_FUND',
106
+ 'PRIMARY_RESIDENCE',
107
+ 'INVESTMENT_PROPERTY',
108
+ 'REIT',
109
+ 'GOLD',
110
+ 'SILVER',
111
+ 'PRECIOUS_METAL',
112
+ 'PRECIOUS_METAL_FUND',
113
+ 'COMMODITY',
114
+ 'COMMODITY_FUND',
115
+ 'CRYPTOCURRENCY',
116
+ 'RETIREMENT_ACCOUNT',
117
+ 'HEALTH_ACCOUNT',
118
+ 'EDUCATION_ACCOUNT',
119
+ 'INSURANCE',
120
+ 'PRIVATE_EQUITY',
121
+ 'HEDGE_FUND',
122
+ 'COLLECTIBLES',
123
+ 'MORTGAGE',
124
+ 'STUDENT_LOAN',
125
+ 'CREDIT_CARD',
126
+ 'PERSONAL_LOAN',
127
+ 'OTHER'
128
+ ],
129
+ nullable: true,
130
+ example: 'STOCK'
131
+ },
107
132
  status: {
108
133
  type: 'string',
109
134
  description: 'Account status',
@@ -145,26 +170,26 @@ export const $AccountResponseDto = {
145
170
  templatePath: {
146
171
  type: 'string',
147
172
  description: 'Template path reference',
148
- example: 'Assets:CN:Bank:ICBC:Checking'
173
+ example: 'Assets:CN:Checking'
149
174
  },
150
175
  isCustom: {
151
176
  type: 'boolean',
152
177
  description: 'Whether this is a custom (user-created) account',
153
178
  example: false
154
179
  },
155
- i18nKey: {
180
+ displayName: {
156
181
  type: 'string',
157
- description: 'i18n key for display name',
158
- example: 'account.assets.cn.bank.icbc.checking'
182
+ description: 'Localized display name (ADR-0114, read-time projection)',
183
+ example: 'Checking'
159
184
  },
160
185
  icon: {
161
186
  type: 'string',
162
187
  description: 'Icon identifier',
163
188
  example: 'bank-icbc'
164
189
  },
165
- openMeta: {
190
+ openDirectiveMeta: {
166
191
  type: 'object',
167
- description: 'Account metadata',
192
+ description: 'Open directive metadata (ADR-0115 Decision 9)',
168
193
  example: {
169
194
  branch: 'Downtown'
170
195
  }
@@ -192,7 +217,6 @@ export const $AccountResponseDto = {
192
217
  required: [
193
218
  'id',
194
219
  'path',
195
- 'displayName',
196
220
  'type',
197
221
  'status',
198
222
  'openDate',
@@ -225,11 +249,6 @@ export const $AccountListResponseDto = {
225
249
  export const $UpdateAccountDto = {
226
250
  type: 'object',
227
251
  properties: {
228
- displayName: {
229
- type: 'string',
230
- description: 'Display name to distinguish accounts at the same path',
231
- example: '招行工资卡'
232
- },
233
252
  currencies: {
234
253
  description: 'Allowed currencies (null = no restriction)',
235
254
  example: ['CNY', 'USD'],
@@ -251,19 +270,15 @@ export const $UpdateAccountDto = {
251
270
  'NONE'
252
271
  ]
253
272
  },
254
- i18nKey: {
255
- type: 'string',
256
- description: 'i18n key for display name',
257
- example: 'account.custom.mybank'
258
- },
259
273
  icon: {
260
274
  type: 'string',
261
275
  description: 'Icon identifier',
262
276
  example: 'bank-custom'
263
277
  },
264
- openMeta: {
278
+ openDirectiveMeta: {
265
279
  type: 'object',
266
- description: 'Additional metadata (merged with existing)',
280
+ description:
281
+ 'Open directive metadata (merged with existing; NOT an opening-balance amount)',
267
282
  example: {
268
283
  branch: 'Uptown'
269
284
  }
@@ -310,13 +325,47 @@ export const $ReopenAccountDto = {
310
325
  }
311
326
  } as const;
312
327
 
328
+ export const $CreateOpeningBalanceDto = {
329
+ type: 'object',
330
+ properties: {
331
+ amount: {
332
+ type: 'number',
333
+ description: 'Opening balance amount (non-negative)',
334
+ example: 1000
335
+ },
336
+ currency: {
337
+ type: 'string',
338
+ description: 'Currency code',
339
+ example: 'CNY'
340
+ },
341
+ date: {
342
+ format: 'date-time',
343
+ type: 'string',
344
+ description: 'Opening-balance date (defaults to now)',
345
+ example: '2024-01-01'
346
+ }
347
+ },
348
+ required: ['amount', 'currency']
349
+ } as const;
350
+
351
+ export const $OpeningBalanceResultDto = {
352
+ type: 'object',
353
+ properties: {
354
+ transactionId: {
355
+ type: 'string',
356
+ description: 'Created opening-balance transaction id.'
357
+ }
358
+ },
359
+ required: ['transactionId']
360
+ } as const;
361
+
313
362
  export const $AccountStandardResponseDto = {
314
363
  type: 'object',
315
364
  properties: {
316
365
  path: {
317
366
  type: 'string',
318
367
  description: 'Account path (hierarchical, colon-separated)',
319
- example: 'Assets:CN:Bank:ICBC:Checking'
368
+ example: 'Assets:CN:Checking'
320
369
  },
321
370
  type: {
322
371
  type: 'string',
@@ -324,11 +373,6 @@ export const $AccountStandardResponseDto = {
324
373
  enum: ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity'],
325
374
  example: 'Assets'
326
375
  },
327
- i18nKey: {
328
- type: 'string',
329
- description: 'i18n key for localized display name',
330
- example: 'account.assets.cn.bank.icbc.checking'
331
- },
332
376
  name: {
333
377
  type: 'string',
334
378
  description: 'Short localized display name',
@@ -353,7 +397,7 @@ export const $AccountStandardResponseDto = {
353
397
  example: 'bank-icbc'
354
398
  }
355
399
  },
356
- required: ['path', 'type', 'i18nKey', 'description', 'tags', 'icon']
400
+ required: ['path', 'type', 'description', 'tags', 'icon']
357
401
  } as const;
358
402
 
359
403
  export const $AccountStandardListResponseDto = {
@@ -383,18 +427,13 @@ export const $AccountStandardListResponseDto = {
383
427
  export const $TemplateMetadataDto = {
384
428
  type: 'object',
385
429
  properties: {
386
- extendable: {
387
- type: 'boolean',
388
- description: 'Whether this path can be extended',
389
- example: true
390
- },
391
430
  rootType: {
392
431
  type: 'string',
393
432
  description: 'Root account type',
394
433
  example: 'Assets'
395
434
  }
396
435
  },
397
- required: ['extendable', 'rootType']
436
+ required: ['rootType']
398
437
  } as const;
399
438
 
400
439
  export const $TemplateMetadataResponseDto = {
@@ -533,7 +572,7 @@ export const $CreatePostingDto = {
533
572
  type: 'string',
534
573
  description:
535
574
  'Account name in Beancount format (must start with uppercase, colon-separated)',
536
- example: 'Assets:Bank:Checking'
575
+ example: 'Assets:Checking'
537
576
  },
538
577
  units: {
539
578
  type: 'string',
@@ -660,13 +699,39 @@ export const $CreateTransactionDto = {
660
699
  required: ['date', 'narration', 'postings']
661
700
  } as const;
662
701
 
702
+ export const $CostDetailDto = {
703
+ type: 'object',
704
+ properties: {
705
+ number: {
706
+ type: 'string',
707
+ description: 'Per-unit cost basis (mirrors engine Cost.number)',
708
+ example: '240'
709
+ },
710
+ currency: {
711
+ type: 'string',
712
+ description: 'Cost currency',
713
+ example: 'USD'
714
+ },
715
+ date: {
716
+ type: 'string',
717
+ description: 'Lot acquisition date (ISO yyyy-mm-dd)',
718
+ example: '2024-01-15'
719
+ },
720
+ label: {
721
+ type: 'string',
722
+ description: 'Lot label',
723
+ example: 'lot-2024-01'
724
+ }
725
+ }
726
+ } as const;
727
+
663
728
  export const $PostingResponseDto = {
664
729
  type: 'object',
665
730
  properties: {
666
731
  account: {
667
732
  type: 'string',
668
733
  description: 'Account name',
669
- example: 'Assets:Bank:Checking'
734
+ example: 'Assets:Checking'
670
735
  },
671
736
  units: {
672
737
  type: 'string',
@@ -678,6 +743,15 @@ export const $PostingResponseDto = {
678
743
  type: 'string',
679
744
  description: 'Currency',
680
745
  example: 'USD'
746
+ },
747
+ cost: {
748
+ description:
749
+ 'Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.',
750
+ allOf: [
751
+ {
752
+ $ref: '#/components/schemas/CostDetailDto'
753
+ }
754
+ ]
681
755
  }
682
756
  },
683
757
  required: ['account']
@@ -1023,7 +1097,7 @@ export const $PostingDetailDto = {
1023
1097
  account: {
1024
1098
  type: 'string',
1025
1099
  description: 'Fully-qualified Beancount account path',
1026
- example: 'Assets:Bank:Checking'
1100
+ example: 'Assets:Checking'
1027
1101
  },
1028
1102
  units: {
1029
1103
  type: 'string',
@@ -1051,6 +1125,15 @@ export const $PostingDetailDto = {
1051
1125
  description: 'Cost date',
1052
1126
  example: '2024-01-15'
1053
1127
  },
1128
+ cost: {
1129
+ description:
1130
+ 'Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.',
1131
+ allOf: [
1132
+ {
1133
+ $ref: '#/components/schemas/CostDetailDto'
1134
+ }
1135
+ ]
1136
+ },
1054
1137
  priceAmount: {
1055
1138
  type: 'string',
1056
1139
  description: 'Price amount',
@@ -1203,6 +1286,77 @@ export const $TransactionDetailDto = {
1203
1286
  ]
1204
1287
  } as const;
1205
1288
 
1289
+ export const $BalanceByCurrencyDto = {
1290
+ type: 'object',
1291
+ properties: {
1292
+ currency: {
1293
+ type: 'string',
1294
+ description: 'ISO 4217 currency code',
1295
+ example: 'CNY'
1296
+ },
1297
+ balance: {
1298
+ type: 'string',
1299
+ description: 'Balance amount',
1300
+ example: '50000.00'
1301
+ }
1302
+ },
1303
+ required: ['currency', 'balance']
1304
+ } as const;
1305
+
1306
+ export const $ExchangeRateWarningDto = {
1307
+ type: 'object',
1308
+ properties: {
1309
+ type: {
1310
+ type: 'string',
1311
+ description: 'Warning type',
1312
+ example: 'MISSING_EXCHANGE_RATE'
1313
+ },
1314
+ currency: {
1315
+ type: 'string',
1316
+ description: 'Currency without exchange rate',
1317
+ example: 'EUR'
1318
+ },
1319
+ totalAmount: {
1320
+ type: 'string',
1321
+ description: 'Total amount affected',
1322
+ example: '1000.00'
1323
+ }
1324
+ },
1325
+ required: ['type', 'currency', 'totalAmount']
1326
+ } as const;
1327
+
1328
+ export const $TransactionListSummaryDto = {
1329
+ type: 'object',
1330
+ properties: {
1331
+ totalAmount: {
1332
+ type: 'string',
1333
+ description:
1334
+ 'Partial converted total in base currency (rated currencies only, raw Beancount sign). When warnings is non-empty this excludes currencies missing an FX rate; may be "0.00" if ALL non-base currencies lack a rate. Converted at the dateTo (or current) available rate.',
1335
+ example: '-6000.00'
1336
+ },
1337
+ currency: {
1338
+ type: 'string',
1339
+ description: 'Base currency (ISO 4217)',
1340
+ example: 'CNY'
1341
+ },
1342
+ balanceByCurrency: {
1343
+ description: 'Raw (unconverted) balance per currency',
1344
+ type: 'array',
1345
+ items: {
1346
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
1347
+ }
1348
+ },
1349
+ warnings: {
1350
+ description: 'Currencies missing an FX rate (omitted when empty)',
1351
+ type: 'array',
1352
+ items: {
1353
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
1354
+ }
1355
+ }
1356
+ },
1357
+ required: ['totalAmount', 'currency', 'balanceByCurrency']
1358
+ } as const;
1359
+
1206
1360
  export const $TransactionListResponseDto = {
1207
1361
  type: 'object',
1208
1362
  properties: {
@@ -1227,6 +1381,15 @@ export const $TransactionListResponseDto = {
1227
1381
  type: 'number',
1228
1382
  description: 'Number of items skipped',
1229
1383
  example: 0
1384
+ },
1385
+ summary: {
1386
+ description:
1387
+ 'Amount summary for the full filtered set (#514). Present only when the request has a single account OR category viewpoint; omitted for search-only / plain-list / dual-perspective requests.',
1388
+ allOf: [
1389
+ {
1390
+ $ref: '#/components/schemas/TransactionListSummaryDto'
1391
+ }
1392
+ ]
1230
1393
  }
1231
1394
  },
1232
1395
  required: ['data', 'total', 'limit', 'offset']
@@ -1326,7 +1489,7 @@ export const $BalanceResponseDto = {
1326
1489
  account: {
1327
1490
  type: 'string',
1328
1491
  description: 'Account name',
1329
- example: 'Assets:Bank:Checking'
1492
+ example: 'Assets:Checking'
1330
1493
  },
1331
1494
  balance: {
1332
1495
  type: 'string',
@@ -1353,7 +1516,7 @@ export const $MultiCurrencyBalanceResponseDto = {
1353
1516
  account: {
1354
1517
  type: 'string',
1355
1518
  description: 'Account name',
1356
- example: 'Assets:Bank:Checking'
1519
+ example: 'Assets:Checking'
1357
1520
  },
1358
1521
  balances: {
1359
1522
  type: 'object',
@@ -1409,7 +1572,7 @@ export const $TransactionSummaryDto = {
1409
1572
  accountName: {
1410
1573
  type: 'string',
1411
1574
  description: 'Source account name (first posting)',
1412
- example: 'Assets:Bank:Checking'
1575
+ example: 'Assets:Checking'
1413
1576
  },
1414
1577
  sourceType: {
1415
1578
  type: 'string',
@@ -1811,7 +1974,8 @@ export const $ResolveResultDto = {
1811
1974
  },
1812
1975
  resolutionId: {
1813
1976
  type: 'string',
1814
- description: 'Resolution ID for undo'
1977
+ description:
1978
+ 'Resolution ID for undo. Absent when the resolver rejected the decision (review stayed PENDING).'
1815
1979
  },
1816
1980
  canUndo: {
1817
1981
  type: 'boolean',
@@ -1829,7 +1993,7 @@ export const $ResolveResultDto = {
1829
1993
  example: 'rule_01HXK5V8N2M3P4Q5R6S7T8U9V0'
1830
1994
  }
1831
1995
  },
1832
- required: ['success', 'resolutionId', 'canUndo', 'undoDeadline']
1996
+ required: ['success']
1833
1997
  } as const;
1834
1998
 
1835
1999
  export const $UndoResultDto = {
@@ -2700,60 +2864,217 @@ export const $UpdateCommodityDto = {
2700
2864
  }
2701
2865
  } as const;
2702
2866
 
2703
- export const $CreateRecurringRuleDto = {
2867
+ export const $CreateBeanPriceDto = {
2704
2868
  type: 'object',
2705
2869
  properties: {
2706
- name: {
2707
- type: 'string',
2708
- description: 'Rule name (unique per user)',
2709
- maxLength: 100
2710
- },
2711
- icon: {
2870
+ currency: {
2712
2871
  type: 'string',
2713
- description: 'Icon emoji',
2714
- maxLength: 10
2872
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2873
+ example: 'USD'
2715
2874
  },
2716
- frequency: {
2875
+ quoteCurrency: {
2717
2876
  type: 'string',
2718
- description: 'Recurring frequency',
2719
- enum: [
2720
- 'WEEKLY',
2721
- 'BIWEEKLY',
2722
- 'MONTHLY',
2723
- 'BIMONTHLY',
2724
- 'QUARTERLY',
2725
- 'YEARLY',
2726
- 'CUSTOM'
2727
- ]
2877
+ description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
2878
+ example: 'CNY'
2728
2879
  },
2729
- expectedAmount: {
2880
+ amount: {
2730
2881
  type: 'number',
2731
- description: 'Expected amount (positive number)',
2882
+ description:
2883
+ 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
2884
+ example: 175.5,
2732
2885
  minimum: 0
2733
2886
  },
2734
- expectedDay: {
2735
- type: 'number',
2736
- description: 'Expected day of month (1-31)',
2737
- minimum: 1,
2738
- maximum: 31
2887
+ date: {
2888
+ type: 'string',
2889
+ description: 'Price date (ISO 8601 format)',
2890
+ example: '2024-11-05'
2739
2891
  },
2740
- customIntervalDays: {
2741
- type: 'number',
2742
- description: 'Custom interval in days (required for CUSTOM frequency)',
2743
- minimum: 1
2892
+ metadata: {
2893
+ type: 'object',
2894
+ description:
2895
+ 'Metadata (validated by Zod schema, max field lengths enforced)',
2896
+ example: {
2897
+ source: 'MANUAL',
2898
+ note: 'Bank valuation report',
2899
+ confidence: 0.95
2900
+ }
2901
+ }
2902
+ },
2903
+ required: ['currency', 'quoteCurrency', 'amount', 'date']
2904
+ } as const;
2905
+
2906
+ export const $PriceResponseDto = {
2907
+ type: 'object',
2908
+ properties: {
2909
+ id: {
2910
+ type: 'string',
2911
+ description: 'Unique identifier',
2912
+ example: 'uuid-123-456'
2744
2913
  },
2745
- currency: {
2914
+ userId: {
2746
2915
  type: 'string',
2747
- description: 'Currency code',
2748
- default: 'CNY',
2749
- maxLength: 10
2916
+ description: 'User ID (owner of the price)',
2917
+ example: 'user-123'
2750
2918
  },
2751
- matchPayeePattern: {
2919
+ currency: {
2752
2920
  type: 'string',
2753
- description: 'Payee matching pattern (supports wildcards)',
2754
- maxLength: 200
2921
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2922
+ example: 'BTC'
2755
2923
  },
2756
- matchAmountTolerance: {
2924
+ quoteCurrency: {
2925
+ type: 'string',
2926
+ description: 'Quote currency (pricing currency, e.g., USD, CNY)',
2927
+ example: 'USD'
2928
+ },
2929
+ amount: {
2930
+ type: 'number',
2931
+ description:
2932
+ 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
2933
+ example: 50000
2934
+ },
2935
+ date: {
2936
+ type: 'string',
2937
+ description:
2938
+ 'Price date (ISO 8601 format). Represents the date this price was valid.',
2939
+ example: '2024-01-01',
2940
+ format: 'date'
2941
+ },
2942
+ meta: {
2943
+ type: 'object',
2944
+ description:
2945
+ 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
2946
+ example: {
2947
+ source: 'MANUAL',
2948
+ note: 'User-defined price',
2949
+ confidence: 1
2950
+ }
2951
+ },
2952
+ createdAt: {
2953
+ format: 'date-time',
2954
+ type: 'string',
2955
+ description: 'Creation timestamp',
2956
+ example: '2024-11-03T10:00:00Z'
2957
+ },
2958
+ updatedAt: {
2959
+ format: 'date-time',
2960
+ type: 'string',
2961
+ description: 'Last update timestamp',
2962
+ example: '2024-11-03T10:00:00Z'
2963
+ }
2964
+ },
2965
+ required: [
2966
+ 'id',
2967
+ 'userId',
2968
+ 'currency',
2969
+ 'quoteCurrency',
2970
+ 'amount',
2971
+ 'date',
2972
+ 'meta',
2973
+ 'createdAt',
2974
+ 'updatedAt'
2975
+ ]
2976
+ } as const;
2977
+
2978
+ export const $PriceListResponseDto = {
2979
+ type: 'object',
2980
+ properties: {
2981
+ items: {
2982
+ description: 'List of prices',
2983
+ type: 'array',
2984
+ items: {
2985
+ $ref: '#/components/schemas/PriceResponseDto'
2986
+ }
2987
+ },
2988
+ total: {
2989
+ type: 'number',
2990
+ description: 'Total number of prices',
2991
+ example: 42
2992
+ }
2993
+ },
2994
+ required: ['items', 'total']
2995
+ } as const;
2996
+
2997
+ export const $UpdateBeanPriceDto = {
2998
+ type: 'object',
2999
+ properties: {
3000
+ currency: {
3001
+ type: 'string',
3002
+ description: 'Currency being priced'
3003
+ },
3004
+ quoteCurrency: {
3005
+ type: 'string',
3006
+ description: 'Quote currency (pricing currency)'
3007
+ },
3008
+ amount: {
3009
+ type: 'number',
3010
+ description: 'Price amount (MUST be >= 0 per Beancount spec)',
3011
+ minimum: 0
3012
+ },
3013
+ date: {
3014
+ type: 'string',
3015
+ description: 'Price date (ISO 8601 format)'
3016
+ },
3017
+ metadata: {
3018
+ type: 'object',
3019
+ description: 'Metadata'
3020
+ }
3021
+ }
3022
+ } as const;
3023
+
3024
+ export const $CreateRecurringRuleDto = {
3025
+ type: 'object',
3026
+ properties: {
3027
+ name: {
3028
+ type: 'string',
3029
+ description: 'Rule name (unique per user)',
3030
+ maxLength: 100
3031
+ },
3032
+ icon: {
3033
+ type: 'string',
3034
+ description: 'Icon emoji',
3035
+ maxLength: 10
3036
+ },
3037
+ frequency: {
3038
+ type: 'string',
3039
+ description: 'Recurring frequency',
3040
+ enum: [
3041
+ 'WEEKLY',
3042
+ 'BIWEEKLY',
3043
+ 'MONTHLY',
3044
+ 'BIMONTHLY',
3045
+ 'QUARTERLY',
3046
+ 'YEARLY',
3047
+ 'CUSTOM'
3048
+ ]
3049
+ },
3050
+ expectedAmount: {
3051
+ type: 'number',
3052
+ description: 'Expected amount (positive number)',
3053
+ minimum: 0
3054
+ },
3055
+ expectedDay: {
3056
+ type: 'number',
3057
+ description: 'Expected day of month (1-31)',
3058
+ minimum: 1,
3059
+ maximum: 31
3060
+ },
3061
+ customIntervalDays: {
3062
+ type: 'number',
3063
+ description: 'Custom interval in days (required for CUSTOM frequency)',
3064
+ minimum: 1
3065
+ },
3066
+ currency: {
3067
+ type: 'string',
3068
+ description: 'Currency code',
3069
+ default: 'CNY',
3070
+ maxLength: 10
3071
+ },
3072
+ matchPayeePattern: {
3073
+ type: 'string',
3074
+ description: 'Payee matching pattern (supports wildcards)',
3075
+ maxLength: 200
3076
+ },
3077
+ matchAmountTolerance: {
2757
3078
  type: 'number',
2758
3079
  description: 'Amount tolerance percentage (0-1)',
2759
3080
  default: 0.075,
@@ -3471,287 +3792,479 @@ export const $ForecastResponseDto = {
3471
3792
  ]
3472
3793
  } as const;
3473
3794
 
3474
- export const $CreateTransactionRuleDto = {
3795
+ export const $CurrencyBalanceDto = {
3475
3796
  type: 'object',
3476
3797
  properties: {
3477
- name: {
3798
+ currency: {
3478
3799
  type: 'string',
3479
- minLength: 1,
3480
- maxLength: 100
3800
+ description: 'ISO 4217 currency code',
3801
+ example: 'CNY'
3481
3802
  },
3482
- description: {
3803
+ balance: {
3483
3804
  type: 'string',
3484
- maxLength: 500
3485
- },
3486
- narrationKeywords: {
3487
- items: {
3488
- type: 'array'
3489
- },
3490
- maxItems: 50,
3491
- type: 'array'
3805
+ description: 'Balance amount',
3806
+ example: '500000.00'
3807
+ }
3808
+ },
3809
+ required: ['currency', 'balance']
3810
+ } as const;
3811
+
3812
+ export const $TimeSeriesPointDto = {
3813
+ type: 'object',
3814
+ properties: {
3815
+ date: {
3816
+ type: 'string',
3817
+ description: 'Date in YYYY-MM-DD format',
3818
+ example: '2024-06-15'
3492
3819
  },
3493
- payeeKeywords: {
3494
- items: {
3495
- type: 'array'
3496
- },
3497
- maxItems: 50,
3498
- type: 'array'
3820
+ value: {
3821
+ type: 'string',
3822
+ description: 'Value at this date (in base currency)',
3823
+ example: '500000.00'
3499
3824
  },
3500
- categoryKeywords: {
3501
- items: {
3502
- type: 'array'
3503
- },
3504
- maxItems: 50,
3505
- type: 'array'
3825
+ change: {
3826
+ type: 'object',
3827
+ description: 'Change from previous point',
3828
+ example: '5000.00'
3506
3829
  },
3507
- methodKeywords: {
3508
- items: {
3509
- type: 'array'
3510
- },
3511
- maxItems: 50,
3512
- description: 'Payment method keywords (e.g., HuaBei, YuEBao)',
3513
- type: 'array'
3830
+ assets: {
3831
+ type: 'string',
3832
+ description: 'Total assets at this date (in base currency)',
3833
+ example: '494338.00'
3514
3834
  },
3515
- categoryAccount: {
3835
+ liabilities: {
3516
3836
  type: 'string',
3517
- maxLength: 200,
3518
- description:
3519
- 'Destination account for expenses/income (e.g., Expenses:Food:Coffee)'
3837
+ description: 'Total liabilities at this date (in base currency)',
3838
+ example: '310098.00'
3520
3839
  },
3521
- matchLogic: {
3840
+ byCurrency: {
3841
+ description: 'Multi-currency breakdown for this point',
3842
+ type: 'array',
3843
+ items: {
3844
+ $ref: '#/components/schemas/CurrencyBalanceDto'
3845
+ }
3846
+ }
3847
+ },
3848
+ required: ['date', 'value']
3849
+ } as const;
3850
+
3851
+ export const $TrendSummaryDto = {
3852
+ type: 'object',
3853
+ properties: {
3854
+ startValue: {
3522
3855
  type: 'string',
3523
- enum: ['OR', 'AND'],
3524
- default: 'OR'
3856
+ description: 'Value at start of period',
3857
+ example: '450000.00'
3525
3858
  },
3526
- amountMin: {
3527
- type: 'number',
3528
- minimum: 0,
3529
- description: 'Minimum transaction amount (inclusive)'
3859
+ endValue: {
3860
+ type: 'string',
3861
+ description: 'Value at end of period',
3862
+ example: '500000.00'
3530
3863
  },
3531
- amountMax: {
3532
- type: 'number',
3533
- minimum: 0,
3534
- description: 'Maximum transaction amount (inclusive)'
3864
+ totalChange: {
3865
+ type: 'string',
3866
+ description: 'Total change over period',
3867
+ example: '50000.00'
3535
3868
  },
3536
- priority: {
3537
- type: 'number',
3538
- default: 50,
3539
- minimum: 0,
3540
- maximum: 1000
3541
- },
3542
- additionalTags: {
3543
- items: {
3544
- type: 'array'
3545
- },
3546
- maxItems: 20,
3547
- type: 'array'
3548
- },
3549
- additionalMetadata: {
3550
- type: 'object'
3551
- },
3552
- upsertByPayee: {
3553
- type: 'boolean',
3554
- description:
3555
- 'If true, update existing rule with matching payeeKeywords[0] instead of creating new rule'
3869
+ totalChangePercentage: {
3870
+ type: 'string',
3871
+ description: 'Total change percentage',
3872
+ example: '+11.11%'
3556
3873
  }
3557
3874
  },
3558
- required: ['name', 'matchLogic', 'priority']
3875
+ required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
3559
3876
  } as const;
3560
3877
 
3561
- export const $AmountRangeDto = {
3878
+ export const $MultiCurrencyPointDto = {
3562
3879
  type: 'object',
3563
3880
  properties: {
3564
- min: {
3565
- type: 'number',
3566
- description: 'Minimum amount'
3881
+ date: {
3882
+ type: 'string',
3883
+ description: 'Date in YYYY-MM-DD format',
3884
+ example: '2024-06-15'
3567
3885
  },
3568
- max: {
3569
- type: 'number',
3570
- description: 'Maximum amount'
3886
+ byCurrency: {
3887
+ description: 'Balances by currency',
3888
+ type: 'array',
3889
+ items: {
3890
+ $ref: '#/components/schemas/CurrencyBalanceDto'
3891
+ }
3571
3892
  }
3572
- }
3893
+ },
3894
+ required: ['date', 'byCurrency']
3573
3895
  } as const;
3574
3896
 
3575
- export const $TransactionRuleResponseDto = {
3897
+ export const $PortfolioTrendsResponseDto = {
3576
3898
  type: 'object',
3577
3899
  properties: {
3578
- id: {
3579
- type: 'string',
3580
- description: 'Rule ID'
3581
- },
3582
- name: {
3583
- type: 'string',
3584
- description: 'Rule name'
3585
- },
3586
- description: {
3587
- type: 'string',
3588
- description: 'Rule description'
3589
- },
3590
- narrationKeywords: {
3591
- description: 'Keywords to match in transaction narration',
3592
- type: 'array',
3593
- items: {
3594
- type: 'string'
3595
- }
3596
- },
3597
- payeeKeywords: {
3598
- description: 'Keywords to match in payee name',
3599
- type: 'array',
3600
- items: {
3601
- type: 'string'
3602
- }
3603
- },
3604
- categoryKeywords: {
3605
- description: 'Keywords to match in category',
3606
- type: 'array',
3607
- items: {
3608
- type: 'string'
3609
- }
3610
- },
3611
- methodKeywords: {
3612
- description: 'Keywords to match in payment method',
3900
+ series: {
3901
+ description: 'Time series data points',
3613
3902
  type: 'array',
3614
3903
  items: {
3615
- type: 'string'
3904
+ $ref: '#/components/schemas/TimeSeriesPointDto'
3616
3905
  }
3617
3906
  },
3618
- categoryAccount: {
3619
- type: 'string',
3620
- description: 'Destination account for categorization'
3621
- },
3622
- matchLogic: {
3623
- type: 'string',
3624
- description: 'Keyword matching logic',
3625
- enum: ['OR', 'AND'],
3626
- example: 'OR'
3627
- },
3628
- amountRange: {
3629
- description: 'Amount range for matching',
3907
+ summary: {
3908
+ description: 'Period summary',
3630
3909
  allOf: [
3631
3910
  {
3632
- $ref: '#/components/schemas/AmountRangeDto'
3911
+ $ref: '#/components/schemas/TrendSummaryDto'
3633
3912
  }
3634
3913
  ]
3635
3914
  },
3636
- priority: {
3637
- type: 'number',
3638
- description: 'Rule priority (0-1000, higher = first match)',
3639
- example: 50
3640
- },
3641
- enabled: {
3642
- type: 'boolean',
3643
- description: 'Whether the rule is enabled'
3644
- },
3645
- learningSource: {
3915
+ period: {
3646
3916
  type: 'string',
3647
- description: 'Learning source: NLP, REVIEW_CENTER, or null for manual',
3648
- enum: ['NLP', 'REVIEW_CENTER'],
3649
- nullable: true,
3650
- example: 'REVIEW_CENTER'
3917
+ description: 'Period requested',
3918
+ example: '6m'
3651
3919
  },
3652
- autoApplyEnabled: {
3653
- type: 'boolean',
3654
- description: 'Whether auto-apply is enabled for this rule'
3920
+ granularity: {
3921
+ type: 'string',
3922
+ description: 'Data granularity',
3923
+ example: 'month'
3655
3924
  },
3656
- confirmationCount: {
3657
- type: 'number',
3658
- description: 'Number of confirmations for NLP-learned rules',
3659
- example: 3
3925
+ currency: {
3926
+ type: 'string',
3927
+ description: 'Base currency for converted values',
3928
+ example: 'CNY'
3660
3929
  },
3661
- additionalTags: {
3662
- description: 'Additional tags',
3930
+ byCurrency: {
3931
+ description:
3932
+ 'Multi-currency time series (each point has currency breakdown)',
3663
3933
  type: 'array',
3664
3934
  items: {
3665
- type: 'string'
3935
+ $ref: '#/components/schemas/MultiCurrencyPointDto'
3666
3936
  }
3667
3937
  },
3668
- additionalMetadata: {
3669
- type: 'object',
3670
- description: 'Additional metadata',
3671
- additionalProperties: {
3672
- type: 'string'
3938
+ warnings: {
3939
+ description: 'Exchange rate warnings',
3940
+ type: 'array',
3941
+ items: {
3942
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
3673
3943
  }
3944
+ }
3945
+ },
3946
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
3947
+ } as const;
3948
+
3949
+ export const $CashFlowPointDto = {
3950
+ type: 'object',
3951
+ properties: {
3952
+ month: {
3953
+ type: 'string',
3954
+ description: 'Month key (YYYY-MM)',
3955
+ example: '2024-03'
3674
3956
  },
3675
- createdAt: {
3676
- format: 'date-time',
3957
+ income: {
3677
3958
  type: 'string',
3678
- description: 'Created timestamp'
3959
+ description: 'Income in base currency (absolute, converted)',
3960
+ example: '10000.00'
3679
3961
  },
3680
- updatedAt: {
3681
- format: 'date-time',
3962
+ expense: {
3682
3963
  type: 'string',
3683
- description: 'Updated timestamp'
3964
+ description: 'Expense in base currency (absolute, converted)',
3965
+ example: '5000.00'
3966
+ },
3967
+ netSavings: {
3968
+ type: 'string',
3969
+ description: 'netSavings = income − expense (savings positive)',
3970
+ example: '5000.00'
3684
3971
  }
3685
3972
  },
3686
- required: [
3687
- 'id',
3688
- 'name',
3689
- 'narrationKeywords',
3690
- 'payeeKeywords',
3691
- 'categoryKeywords',
3692
- 'methodKeywords',
3693
- 'matchLogic',
3694
- 'priority',
3695
- 'enabled',
3696
- 'autoApplyEnabled',
3697
- 'confirmationCount',
3698
- 'additionalTags',
3699
- 'createdAt',
3700
- 'updatedAt'
3701
- ]
3973
+ required: ['month', 'income', 'expense', 'netSavings']
3702
3974
  } as const;
3703
3975
 
3704
- export const $TransactionRuleListResponseDto = {
3976
+ export const $CashFlowTrendSummaryDto = {
3705
3977
  type: 'object',
3706
3978
  properties: {
3707
- data: {
3708
- type: 'array',
3709
- items: {
3710
- $ref: '#/components/schemas/TransactionRuleResponseDto'
3711
- }
3979
+ totalIncome: {
3980
+ type: 'string',
3981
+ description: 'Total income across the period',
3982
+ example: '60000.00'
3712
3983
  },
3713
- total: {
3714
- type: 'number',
3715
- description: 'Total count of rules'
3984
+ totalExpense: {
3985
+ type: 'string',
3986
+ description: 'Total expense across the period',
3987
+ example: '30000.00'
3716
3988
  },
3717
- limit: {
3718
- type: 'number',
3719
- description: 'Results per page'
3989
+ totalNetSavings: {
3990
+ type: 'string',
3991
+ description: 'income − expense across the period',
3992
+ example: '30000.00'
3720
3993
  },
3721
- offset: {
3722
- type: 'number',
3723
- description: 'Pagination offset'
3994
+ averageMonthlyNetSavings: {
3995
+ type: 'string',
3996
+ description:
3997
+ 'totalNetSavings divided by the window length (N months, incl. zero-filled)',
3998
+ example: '5000.00'
3724
3999
  }
3725
4000
  },
3726
- required: ['data', 'total', 'limit', 'offset']
4001
+ required: [
4002
+ 'totalIncome',
4003
+ 'totalExpense',
4004
+ 'totalNetSavings',
4005
+ 'averageMonthlyNetSavings'
4006
+ ]
3727
4007
  } as const;
3728
4008
 
3729
- export const $ValidateRuleDto = {
4009
+ export const $CashFlowTrendsResponseDto = {
3730
4010
  type: 'object',
3731
4011
  properties: {
3732
- name: {
4012
+ series: {
4013
+ description:
4014
+ 'Monthly cash-flow series (fixed N-month window, zero-filled)',
4015
+ type: 'array',
4016
+ items: {
4017
+ $ref: '#/components/schemas/CashFlowPointDto'
4018
+ }
4019
+ },
4020
+ summary: {
4021
+ description: 'Period totals',
4022
+ allOf: [
4023
+ {
4024
+ $ref: '#/components/schemas/CashFlowTrendSummaryDto'
4025
+ }
4026
+ ]
4027
+ },
4028
+ period: {
3733
4029
  type: 'string',
3734
- minLength: 1,
3735
- maxLength: 100
4030
+ description: 'Period requested',
4031
+ example: '6m'
3736
4032
  },
3737
- description: {
4033
+ granularity: {
3738
4034
  type: 'string',
3739
- maxLength: 500
4035
+ description: 'Data granularity (v1 returns month buckets)',
4036
+ example: 'month'
3740
4037
  },
3741
- narrationKeywords: {
3742
- items: {
3743
- type: 'array'
3744
- },
3745
- maxItems: 50,
3746
- type: 'array'
4038
+ currency: {
4039
+ type: 'string',
4040
+ description: 'Base currency for converted values',
4041
+ example: 'CNY'
3747
4042
  },
3748
- payeeKeywords: {
4043
+ warnings: {
4044
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
4045
+ type: 'array',
3749
4046
  items: {
3750
- type: 'array'
3751
- },
3752
- maxItems: 50,
3753
- type: 'array'
3754
- },
4047
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
4048
+ }
4049
+ }
4050
+ },
4051
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
4052
+ } as const;
4053
+
4054
+ export const $GenerateSnapshotBody = {
4055
+ type: 'object',
4056
+ properties: {}
4057
+ } as const;
4058
+
4059
+ export const $GenerateSnapshotResponse = {
4060
+ type: 'object',
4061
+ properties: {}
4062
+ } as const;
4063
+
4064
+ export const $BackfillSnapshotsBody = {
4065
+ type: 'object',
4066
+ properties: {}
4067
+ } as const;
4068
+
4069
+ export const $BackfillSnapshotsResponse = {
4070
+ type: 'object',
4071
+ properties: {}
4072
+ } as const;
4073
+
4074
+ export const $DeleteOwnUserDto = {
4075
+ type: 'object',
4076
+ properties: {
4077
+ accessToken: {
4078
+ type: 'string',
4079
+ description: 'Access token for user verification',
4080
+ example: 'abc123xyz'
4081
+ }
4082
+ },
4083
+ required: ['accessToken']
4084
+ } as const;
4085
+
4086
+ export const $SignupDto = {
4087
+ type: 'object',
4088
+ properties: {
4089
+ turnstileToken: {
4090
+ type: 'string',
4091
+ description:
4092
+ 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
4093
+ example: '0.abc123def456...'
4094
+ }
4095
+ }
4096
+ } as const;
4097
+
4098
+ export const $SignupResponseDto = {
4099
+ type: 'object',
4100
+ properties: {
4101
+ authToken: {
4102
+ type: 'string',
4103
+ description: 'JWT auth token',
4104
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
4105
+ },
4106
+ accessToken: {
4107
+ type: 'string',
4108
+ description: 'Auto-generated access token'
4109
+ },
4110
+ role: {
4111
+ type: 'string',
4112
+ description: 'Assigned user role',
4113
+ enum: ['USER', 'ADMIN', 'DEMO', 'INACTIVE', 'PAID', 'OPS']
4114
+ }
4115
+ },
4116
+ required: ['authToken', 'accessToken', 'role']
4117
+ } as const;
4118
+
4119
+ export const $UpdateUserSettingDto = {
4120
+ type: 'object',
4121
+ properties: {
4122
+ secId: {
4123
+ type: 'number',
4124
+ description: 'Security ID'
4125
+ },
4126
+ annualInterestRate: {
4127
+ type: 'number',
4128
+ description: 'Annual interest rate',
4129
+ example: 0.05
4130
+ },
4131
+ currency: {
4132
+ type: 'string',
4133
+ description: 'Currency code',
4134
+ example: 'USD'
4135
+ },
4136
+ baseCurrency: {
4137
+ type: 'string',
4138
+ description: 'Base currency code',
4139
+ example: 'USD'
4140
+ },
4141
+ benchmark: {
4142
+ type: 'string',
4143
+ description: 'Benchmark symbol',
4144
+ example: 'SPY'
4145
+ },
4146
+ colorScheme: {
4147
+ type: 'string',
4148
+ description: 'Color scheme',
4149
+ enum: ['DARK', 'LIGHT']
4150
+ },
4151
+ dateRange: {
4152
+ type: 'string',
4153
+ description: 'Date range filter',
4154
+ example: '1y'
4155
+ },
4156
+ emergencyFund: {
4157
+ type: 'number',
4158
+ description: 'Emergency fund amount',
4159
+ example: 10000
4160
+ },
4161
+ 'filters.accounts': {
4162
+ description: 'Account filter IDs',
4163
+ type: 'array',
4164
+ items: {
4165
+ type: 'string'
4166
+ }
4167
+ },
4168
+ 'filters.assetClasses': {
4169
+ description: 'Asset class filters',
4170
+ type: 'array',
4171
+ items: {
4172
+ type: 'string'
4173
+ }
4174
+ },
4175
+ 'filters.dataSource': {
4176
+ type: 'string',
4177
+ description: 'Data source filter'
4178
+ },
4179
+ 'filters.symbol': {
4180
+ type: 'string',
4181
+ description: 'Symbol filter'
4182
+ },
4183
+ 'filters.tags': {
4184
+ description: 'Tag filters',
4185
+ type: 'array',
4186
+ items: {
4187
+ type: 'string'
4188
+ }
4189
+ },
4190
+ isExperimentalFeatures: {
4191
+ type: 'boolean',
4192
+ description: 'Enable experimental features'
4193
+ },
4194
+ isRestrictedView: {
4195
+ type: 'boolean',
4196
+ description: 'Enable restricted view mode'
4197
+ },
4198
+ language: {
4199
+ type: 'string',
4200
+ description: 'Language code',
4201
+ example: 'en'
4202
+ },
4203
+ locale: {
4204
+ type: 'string',
4205
+ description: 'Locale code',
4206
+ example: 'en-US'
4207
+ },
4208
+ projectedTotalAmount: {
4209
+ type: 'number',
4210
+ description: 'Projected total amount',
4211
+ example: 1000000
4212
+ },
4213
+ retirementDate: {
4214
+ type: 'string',
4215
+ description: 'Retirement date in ISO 8601 format',
4216
+ example: '2050-01-01'
4217
+ },
4218
+ savingsRate: {
4219
+ type: 'number',
4220
+ description: 'Savings rate percentage',
4221
+ example: 0.2
4222
+ },
4223
+ viewMode: {
4224
+ type: 'string',
4225
+ description: 'View mode',
4226
+ enum: ['DEFAULT', 'ZEN']
4227
+ }
4228
+ }
4229
+ } as const;
4230
+
4231
+ export const $UpdatePropertyDto = {
4232
+ type: 'object',
4233
+ properties: {
4234
+ value: {
4235
+ type: 'string',
4236
+ description: 'Property value'
4237
+ }
4238
+ },
4239
+ required: ['value']
4240
+ } as const;
4241
+
4242
+ export const $CreateTransactionRuleDto = {
4243
+ type: 'object',
4244
+ properties: {
4245
+ name: {
4246
+ type: 'string',
4247
+ minLength: 1,
4248
+ maxLength: 100
4249
+ },
4250
+ description: {
4251
+ type: 'string',
4252
+ maxLength: 500
4253
+ },
4254
+ narrationKeywords: {
4255
+ items: {
4256
+ type: 'array'
4257
+ },
4258
+ maxItems: 50,
4259
+ type: 'array'
4260
+ },
4261
+ payeeKeywords: {
4262
+ items: {
4263
+ type: 'array'
4264
+ },
4265
+ maxItems: 50,
4266
+ type: 'array'
4267
+ },
3755
4268
  categoryKeywords: {
3756
4269
  items: {
3757
4270
  type: 'array'
@@ -3813,175 +4326,175 @@ export const $ValidateRuleDto = {
3813
4326
  required: ['name', 'matchLogic', 'priority']
3814
4327
  } as const;
3815
4328
 
3816
- export const $ValidateRuleResponseDto = {
4329
+ export const $AmountRangeDto = {
3817
4330
  type: 'object',
3818
4331
  properties: {
3819
- valid: {
3820
- type: 'boolean',
3821
- description: 'Whether the rule configuration is valid',
3822
- example: true
3823
- },
3824
- errors: {
3825
- description: 'List of validation errors (empty if valid)',
3826
- example: [],
3827
- items: {
3828
- type: 'array'
3829
- },
3830
- type: 'array'
4332
+ min: {
4333
+ type: 'number',
4334
+ description: 'Minimum amount'
3831
4335
  },
3832
- warnings: {
3833
- description: 'List of validation warnings (non-blocking issues)',
3834
- example: [
3835
- 'No account constraints specified - rule will match any account'
3836
- ],
3837
- items: {
3838
- type: 'array'
3839
- },
3840
- type: 'array'
4336
+ max: {
4337
+ type: 'number',
4338
+ description: 'Maximum amount'
3841
4339
  }
3842
- },
3843
- required: ['valid', 'errors', 'warnings']
4340
+ }
3844
4341
  } as const;
3845
4342
 
3846
- export const $BulkCreateRulesDto = {
4343
+ export const $TransactionRuleResponseDto = {
3847
4344
  type: 'object',
3848
4345
  properties: {
3849
- rules: {
3850
- items: {
3851
- type: 'array'
3852
- },
3853
- description: 'Array of rules to import',
3854
- type: 'array'
3855
- },
3856
- conflictStrategy: {
4346
+ id: {
3857
4347
  type: 'string',
3858
- enum: ['replace', 'skip'],
3859
- default: 'skip',
3860
- description:
3861
- 'Conflict handling strategy: skip (default) ignores duplicates, replace soft-deletes existing rule'
3862
- }
3863
- },
3864
- required: ['rules', 'conflictStrategy']
3865
- } as const;
3866
-
3867
- export const $BulkCreateRulesResponseDto = {
3868
- type: 'object',
3869
- properties: {
3870
- successCount: {
3871
- type: 'number',
3872
- description: 'Number of successfully created rules'
4348
+ description: 'Rule ID'
3873
4349
  },
3874
- failureCount: {
3875
- type: 'number',
3876
- description: 'Number of failed rules'
4350
+ name: {
4351
+ type: 'string',
4352
+ description: 'Rule name'
3877
4353
  },
3878
- errors: {
4354
+ description: {
4355
+ type: 'string',
4356
+ description: 'Rule description'
4357
+ },
4358
+ narrationKeywords: {
4359
+ description: 'Keywords to match in transaction narration',
3879
4360
  type: 'array',
3880
- description: 'Error details for failed rules',
3881
4361
  items: {
3882
- type: 'object',
3883
- properties: {
3884
- index: {
3885
- type: 'number'
3886
- },
3887
- message: {
3888
- type: 'string'
3889
- }
3890
- }
4362
+ type: 'string'
3891
4363
  }
3892
4364
  },
3893
- createdRuleIds: {
3894
- description: 'IDs of successfully created rules',
4365
+ payeeKeywords: {
4366
+ description: 'Keywords to match in payee name',
3895
4367
  type: 'array',
3896
4368
  items: {
3897
4369
  type: 'string'
3898
4370
  }
3899
- }
3900
- },
3901
- required: ['successCount', 'failureCount', 'errors', 'createdRuleIds']
3902
- } as const;
3903
-
3904
- export const $ExportRulesResponseDto = {
3905
- type: 'object',
3906
- properties: {
3907
- exportedAt: {
4371
+ },
4372
+ categoryKeywords: {
4373
+ description: 'Keywords to match in category',
4374
+ type: 'array',
4375
+ items: {
4376
+ type: 'string'
4377
+ }
4378
+ },
4379
+ methodKeywords: {
4380
+ description: 'Keywords to match in payment method',
4381
+ type: 'array',
4382
+ items: {
4383
+ type: 'string'
4384
+ }
4385
+ },
4386
+ categoryAccount: {
3908
4387
  type: 'string',
3909
- description: 'Export timestamp'
4388
+ description: 'Destination account for categorization'
3910
4389
  },
3911
- userId: {
4390
+ matchLogic: {
3912
4391
  type: 'string',
3913
- description: 'User ID'
4392
+ description: 'Keyword matching logic',
4393
+ enum: ['OR', 'AND'],
4394
+ example: 'OR'
3914
4395
  },
3915
- ruleCount: {
4396
+ amountRange: {
4397
+ description: 'Amount range for matching',
4398
+ allOf: [
4399
+ {
4400
+ $ref: '#/components/schemas/AmountRangeDto'
4401
+ }
4402
+ ]
4403
+ },
4404
+ priority: {
3916
4405
  type: 'number',
3917
- description: 'Number of exported rules'
4406
+ description: 'Rule priority (0-1000, higher = first match)',
4407
+ example: 50
3918
4408
  },
3919
- rules: {
4409
+ enabled: {
4410
+ type: 'boolean',
4411
+ description: 'Whether the rule is enabled'
4412
+ },
4413
+ learningSource: {
4414
+ type: 'string',
4415
+ description: 'Learning source: NLP, REVIEW_CENTER, or null for manual',
4416
+ enum: ['NLP', 'REVIEW_CENTER'],
4417
+ nullable: true,
4418
+ example: 'REVIEW_CENTER'
4419
+ },
4420
+ autoApplyEnabled: {
4421
+ type: 'boolean',
4422
+ description: 'Whether auto-apply is enabled for this rule'
4423
+ },
4424
+ confirmationCount: {
4425
+ type: 'number',
4426
+ description: 'Number of confirmations for NLP-learned rules',
4427
+ example: 3
4428
+ },
4429
+ additionalTags: {
4430
+ description: 'Additional tags',
3920
4431
  type: 'array',
3921
- description: 'Exported rules'
4432
+ items: {
4433
+ type: 'string'
4434
+ }
4435
+ },
4436
+ additionalMetadata: {
4437
+ type: 'object',
4438
+ description: 'Additional metadata',
4439
+ additionalProperties: {
4440
+ type: 'string'
4441
+ }
4442
+ },
4443
+ createdAt: {
4444
+ format: 'date-time',
4445
+ type: 'string',
4446
+ description: 'Created timestamp'
4447
+ },
4448
+ updatedAt: {
4449
+ format: 'date-time',
4450
+ type: 'string',
4451
+ description: 'Updated timestamp'
3922
4452
  }
3923
4453
  },
3924
- required: ['exportedAt', 'userId', 'ruleCount', 'rules']
4454
+ required: [
4455
+ 'id',
4456
+ 'name',
4457
+ 'narrationKeywords',
4458
+ 'payeeKeywords',
4459
+ 'categoryKeywords',
4460
+ 'methodKeywords',
4461
+ 'matchLogic',
4462
+ 'priority',
4463
+ 'enabled',
4464
+ 'autoApplyEnabled',
4465
+ 'confirmationCount',
4466
+ 'additionalTags',
4467
+ 'createdAt',
4468
+ 'updatedAt'
4469
+ ]
3925
4470
  } as const;
3926
4471
 
3927
- export const $RuleStatisticsResponseDto = {
4472
+ export const $TransactionRuleListResponseDto = {
3928
4473
  type: 'object',
3929
4474
  properties: {
3930
- period: {
3931
- type: 'string',
3932
- description: 'Statistics time period',
3933
- enum: ['7d', '30d', '90d']
3934
- },
3935
- totalRules: {
3936
- type: 'number',
3937
- description: 'Total number of rules'
4475
+ data: {
4476
+ type: 'array',
4477
+ items: {
4478
+ $ref: '#/components/schemas/TransactionRuleResponseDto'
4479
+ }
3938
4480
  },
3939
- rulesWithMatches: {
4481
+ total: {
3940
4482
  type: 'number',
3941
- description: 'Number of rules with at least one match'
4483
+ description: 'Total count of rules'
3942
4484
  },
3943
- totalMatches: {
4485
+ limit: {
3944
4486
  type: 'number',
3945
- description: 'Total number of matches across all rules'
4487
+ description: 'Results per page'
3946
4488
  },
3947
- averageConfidence: {
4489
+ offset: {
3948
4490
  type: 'number',
3949
- description: 'Average confidence score across all matches',
3950
- example: 0.82
3951
- },
3952
- ruleStats: {
3953
- type: 'array',
3954
- description: 'Per-rule statistics',
3955
- items: {
3956
- type: 'object',
3957
- properties: {
3958
- ruleId: {
3959
- type: 'string'
3960
- },
3961
- ruleName: {
3962
- type: 'string'
3963
- },
3964
- matchCount: {
3965
- type: 'number'
3966
- },
3967
- averageConfidence: {
3968
- type: 'number'
3969
- }
3970
- }
3971
- }
4491
+ description: 'Pagination offset'
3972
4492
  }
3973
4493
  },
3974
- required: [
3975
- 'period',
3976
- 'totalRules',
3977
- 'rulesWithMatches',
3978
- 'totalMatches',
3979
- 'averageConfidence',
3980
- 'ruleStats'
3981
- ]
4494
+ required: ['data', 'total', 'limit', 'offset']
3982
4495
  } as const;
3983
4496
 
3984
- export const $UpdateTransactionRuleDto = {
4497
+ export const $ValidateRuleDto = {
3985
4498
  type: 'object',
3986
4499
  properties: {
3987
4500
  name: {
@@ -4030,7 +4543,8 @@ export const $UpdateTransactionRuleDto = {
4030
4543
  },
4031
4544
  matchLogic: {
4032
4545
  type: 'string',
4033
- enum: ['OR', 'AND']
4546
+ enum: ['OR', 'AND'],
4547
+ default: 'OR'
4034
4548
  },
4035
4549
  amountMin: {
4036
4550
  type: 'number',
@@ -4044,13 +4558,10 @@ export const $UpdateTransactionRuleDto = {
4044
4558
  },
4045
4559
  priority: {
4046
4560
  type: 'number',
4561
+ default: 50,
4047
4562
  minimum: 0,
4048
4563
  maximum: 1000
4049
4564
  },
4050
- enabled: {
4051
- type: 'boolean',
4052
- description: 'Enable or disable the rule'
4053
- },
4054
4565
  additionalTags: {
4055
4566
  items: {
4056
4567
  type: 'array'
@@ -4060,45 +4571,302 @@ export const $UpdateTransactionRuleDto = {
4060
4571
  },
4061
4572
  additionalMetadata: {
4062
4573
  type: 'object'
4063
- }
4064
- }
4065
- } as const;
4066
-
4067
- export const $TestRuleDto = {
4068
- type: 'object',
4069
- properties: {
4070
- narration: {
4071
- type: 'string',
4072
- minLength: 1,
4073
- maxLength: 500
4074
- },
4075
- payee: {
4076
- type: 'string',
4077
- maxLength: 200
4078
- },
4079
- categoryAccount: {
4080
- type: 'string',
4081
- maxLength: 200
4082
- },
4083
- amount: {
4084
- type: 'number'
4085
4574
  },
4086
- currency: {
4087
- type: 'string',
4088
- maxLength: 10
4575
+ upsertByPayee: {
4576
+ type: 'boolean',
4577
+ description:
4578
+ 'If true, update existing rule with matching payeeKeywords[0] instead of creating new rule'
4089
4579
  }
4090
4580
  },
4091
- required: ['narration']
4581
+ required: ['name', 'matchLogic', 'priority']
4092
4582
  } as const;
4093
4583
 
4094
- export const $TestRuleResponseDto = {
4584
+ export const $ValidateRuleResponseDto = {
4095
4585
  type: 'object',
4096
4586
  properties: {
4097
- ruleId: {
4098
- type: 'string',
4099
- description: 'Rule ID that was tested'
4100
- },
4101
- matches: {
4587
+ valid: {
4588
+ type: 'boolean',
4589
+ description: 'Whether the rule configuration is valid',
4590
+ example: true
4591
+ },
4592
+ errors: {
4593
+ description: 'List of validation errors (empty if valid)',
4594
+ example: [],
4595
+ items: {
4596
+ type: 'array'
4597
+ },
4598
+ type: 'array'
4599
+ },
4600
+ warnings: {
4601
+ description: 'List of validation warnings (non-blocking issues)',
4602
+ example: [
4603
+ 'No account constraints specified - rule will match any account'
4604
+ ],
4605
+ items: {
4606
+ type: 'array'
4607
+ },
4608
+ type: 'array'
4609
+ }
4610
+ },
4611
+ required: ['valid', 'errors', 'warnings']
4612
+ } as const;
4613
+
4614
+ export const $BulkCreateRulesDto = {
4615
+ type: 'object',
4616
+ properties: {
4617
+ rules: {
4618
+ items: {
4619
+ type: 'array'
4620
+ },
4621
+ description: 'Array of rules to import',
4622
+ type: 'array'
4623
+ },
4624
+ conflictStrategy: {
4625
+ type: 'string',
4626
+ enum: ['replace', 'skip'],
4627
+ default: 'skip',
4628
+ description:
4629
+ 'Conflict handling strategy: skip (default) ignores duplicates, replace soft-deletes existing rule'
4630
+ }
4631
+ },
4632
+ required: ['rules', 'conflictStrategy']
4633
+ } as const;
4634
+
4635
+ export const $BulkCreateRulesResponseDto = {
4636
+ type: 'object',
4637
+ properties: {
4638
+ successCount: {
4639
+ type: 'number',
4640
+ description: 'Number of successfully created rules'
4641
+ },
4642
+ failureCount: {
4643
+ type: 'number',
4644
+ description: 'Number of failed rules'
4645
+ },
4646
+ errors: {
4647
+ type: 'array',
4648
+ description: 'Error details for failed rules',
4649
+ items: {
4650
+ type: 'object',
4651
+ properties: {
4652
+ index: {
4653
+ type: 'number'
4654
+ },
4655
+ message: {
4656
+ type: 'string'
4657
+ }
4658
+ }
4659
+ }
4660
+ },
4661
+ createdRuleIds: {
4662
+ description: 'IDs of successfully created rules',
4663
+ type: 'array',
4664
+ items: {
4665
+ type: 'string'
4666
+ }
4667
+ }
4668
+ },
4669
+ required: ['successCount', 'failureCount', 'errors', 'createdRuleIds']
4670
+ } as const;
4671
+
4672
+ export const $ExportRulesResponseDto = {
4673
+ type: 'object',
4674
+ properties: {
4675
+ exportedAt: {
4676
+ type: 'string',
4677
+ description: 'Export timestamp'
4678
+ },
4679
+ userId: {
4680
+ type: 'string',
4681
+ description: 'User ID'
4682
+ },
4683
+ ruleCount: {
4684
+ type: 'number',
4685
+ description: 'Number of exported rules'
4686
+ },
4687
+ rules: {
4688
+ type: 'array',
4689
+ description: 'Exported rules'
4690
+ }
4691
+ },
4692
+ required: ['exportedAt', 'userId', 'ruleCount', 'rules']
4693
+ } as const;
4694
+
4695
+ export const $RuleStatisticsResponseDto = {
4696
+ type: 'object',
4697
+ properties: {
4698
+ period: {
4699
+ type: 'string',
4700
+ description: 'Statistics time period',
4701
+ enum: ['7d', '30d', '90d']
4702
+ },
4703
+ totalRules: {
4704
+ type: 'number',
4705
+ description: 'Total number of rules'
4706
+ },
4707
+ rulesWithMatches: {
4708
+ type: 'number',
4709
+ description: 'Number of rules with at least one match'
4710
+ },
4711
+ totalMatches: {
4712
+ type: 'number',
4713
+ description: 'Total number of matches across all rules'
4714
+ },
4715
+ averageConfidence: {
4716
+ type: 'number',
4717
+ description: 'Average confidence score across all matches',
4718
+ example: 0.82
4719
+ },
4720
+ ruleStats: {
4721
+ type: 'array',
4722
+ description: 'Per-rule statistics',
4723
+ items: {
4724
+ type: 'object',
4725
+ properties: {
4726
+ ruleId: {
4727
+ type: 'string'
4728
+ },
4729
+ ruleName: {
4730
+ type: 'string'
4731
+ },
4732
+ matchCount: {
4733
+ type: 'number'
4734
+ },
4735
+ averageConfidence: {
4736
+ type: 'number'
4737
+ }
4738
+ }
4739
+ }
4740
+ }
4741
+ },
4742
+ required: [
4743
+ 'period',
4744
+ 'totalRules',
4745
+ 'rulesWithMatches',
4746
+ 'totalMatches',
4747
+ 'averageConfidence',
4748
+ 'ruleStats'
4749
+ ]
4750
+ } as const;
4751
+
4752
+ export const $UpdateTransactionRuleDto = {
4753
+ type: 'object',
4754
+ properties: {
4755
+ name: {
4756
+ type: 'string',
4757
+ minLength: 1,
4758
+ maxLength: 100
4759
+ },
4760
+ description: {
4761
+ type: 'string',
4762
+ maxLength: 500
4763
+ },
4764
+ narrationKeywords: {
4765
+ items: {
4766
+ type: 'array'
4767
+ },
4768
+ maxItems: 50,
4769
+ type: 'array'
4770
+ },
4771
+ payeeKeywords: {
4772
+ items: {
4773
+ type: 'array'
4774
+ },
4775
+ maxItems: 50,
4776
+ type: 'array'
4777
+ },
4778
+ categoryKeywords: {
4779
+ items: {
4780
+ type: 'array'
4781
+ },
4782
+ maxItems: 50,
4783
+ type: 'array'
4784
+ },
4785
+ methodKeywords: {
4786
+ items: {
4787
+ type: 'array'
4788
+ },
4789
+ maxItems: 50,
4790
+ description: 'Payment method keywords (e.g., HuaBei, YuEBao)',
4791
+ type: 'array'
4792
+ },
4793
+ categoryAccount: {
4794
+ type: 'string',
4795
+ maxLength: 200,
4796
+ description:
4797
+ 'Destination account for expenses/income (e.g., Expenses:Food:Coffee)'
4798
+ },
4799
+ matchLogic: {
4800
+ type: 'string',
4801
+ enum: ['OR', 'AND']
4802
+ },
4803
+ amountMin: {
4804
+ type: 'number',
4805
+ minimum: 0,
4806
+ description: 'Minimum transaction amount (inclusive)'
4807
+ },
4808
+ amountMax: {
4809
+ type: 'number',
4810
+ minimum: 0,
4811
+ description: 'Maximum transaction amount (inclusive)'
4812
+ },
4813
+ priority: {
4814
+ type: 'number',
4815
+ minimum: 0,
4816
+ maximum: 1000
4817
+ },
4818
+ enabled: {
4819
+ type: 'boolean',
4820
+ description: 'Enable or disable the rule'
4821
+ },
4822
+ additionalTags: {
4823
+ items: {
4824
+ type: 'array'
4825
+ },
4826
+ maxItems: 20,
4827
+ type: 'array'
4828
+ },
4829
+ additionalMetadata: {
4830
+ type: 'object'
4831
+ }
4832
+ }
4833
+ } as const;
4834
+
4835
+ export const $TestRuleDto = {
4836
+ type: 'object',
4837
+ properties: {
4838
+ narration: {
4839
+ type: 'string',
4840
+ minLength: 1,
4841
+ maxLength: 500
4842
+ },
4843
+ payee: {
4844
+ type: 'string',
4845
+ maxLength: 200
4846
+ },
4847
+ categoryAccount: {
4848
+ type: 'string',
4849
+ maxLength: 200
4850
+ },
4851
+ amount: {
4852
+ type: 'number'
4853
+ },
4854
+ currency: {
4855
+ type: 'string',
4856
+ maxLength: 10
4857
+ }
4858
+ },
4859
+ required: ['narration']
4860
+ } as const;
4861
+
4862
+ export const $TestRuleResponseDto = {
4863
+ type: 'object',
4864
+ properties: {
4865
+ ruleId: {
4866
+ type: 'string',
4867
+ description: 'Rule ID that was tested'
4868
+ },
4869
+ matches: {
4102
4870
  type: 'boolean',
4103
4871
  description: 'Whether the rule matched the test data'
4104
4872
  },
@@ -4120,151 +4888,393 @@ export const $TestRuleResponseDto = {
4120
4888
  required: ['ruleId', 'matches', 'confidence', 'matchDetails']
4121
4889
  } as const;
4122
4890
 
4123
- export const $DeleteOwnUserDto = {
4891
+ export const $CreateBeanEventDto = {
4124
4892
  type: 'object',
4125
4893
  properties: {
4126
- accessToken: {
4894
+ date: {
4127
4895
  type: 'string',
4128
- description: 'Access token for user verification',
4129
- example: 'abc123xyz'
4896
+ description: 'Life event date (ISO 8601)',
4897
+ example: '2024-03-15'
4898
+ },
4899
+ type: {
4900
+ type: 'string',
4901
+ description:
4902
+ 'Life event type (e.g., "employer", "location", "marital-status") — user-defined, no enum constraint at engine layer',
4903
+ example: 'employer'
4904
+ },
4905
+ description: {
4906
+ type: 'string',
4907
+ description:
4908
+ 'Life event description. Empty string is a VALID value (distinct from absence).',
4909
+ example: 'Acme Corp'
4910
+ },
4911
+ meta: {
4912
+ type: 'object',
4913
+ description:
4914
+ 'Product-side metadata (lives in BeanEvent.meta JSON, never in engine Event fields)',
4915
+ example: {
4916
+ note: 'Promotion'
4917
+ }
4130
4918
  }
4131
4919
  },
4132
- required: ['accessToken']
4920
+ required: ['date', 'type', 'description']
4133
4921
  } as const;
4134
4922
 
4135
- export const $SignupDto = {
4923
+ export const $EventResponseDto = {
4136
4924
  type: 'object',
4137
4925
  properties: {
4138
- turnstileToken: {
4926
+ id: {
4927
+ type: 'string',
4928
+ description: 'Unique identifier',
4929
+ example: 'uuid-123-456'
4930
+ },
4931
+ userId: {
4932
+ type: 'string',
4933
+ description: 'User ID (owner of the life event)',
4934
+ example: 'user-123'
4935
+ },
4936
+ date: {
4937
+ type: 'string',
4938
+ description: 'Life event date (ISO 8601 format)',
4939
+ example: '2024-03-15',
4940
+ format: 'date'
4941
+ },
4942
+ type: {
4139
4943
  type: 'string',
4140
4944
  description:
4141
- 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
4142
- example: '0.abc123def456...'
4945
+ 'Life event type (user-defined, e.g., "employer", "location")',
4946
+ example: 'employer'
4947
+ },
4948
+ description: {
4949
+ type: 'string',
4950
+ description:
4951
+ 'Life event description. May be an empty string (a valid value distinct from absence).',
4952
+ example: 'Acme Corp'
4953
+ },
4954
+ meta: {
4955
+ type: 'object',
4956
+ description: 'Product-side metadata (free-form JSON)',
4957
+ example: {
4958
+ note: 'Promotion'
4959
+ }
4960
+ },
4961
+ createdAt: {
4962
+ format: 'date-time',
4963
+ type: 'string',
4964
+ description: 'Creation timestamp',
4965
+ example: '2024-03-15T10:00:00Z'
4966
+ },
4967
+ updatedAt: {
4968
+ format: 'date-time',
4969
+ type: 'string',
4970
+ description:
4971
+ 'Last update timestamp. Also emitted as the ETag response header for If-Match optimistic concurrency.',
4972
+ example: '2024-03-15T10:00:00Z'
4143
4973
  }
4144
- }
4974
+ },
4975
+ required: [
4976
+ 'id',
4977
+ 'userId',
4978
+ 'date',
4979
+ 'type',
4980
+ 'description',
4981
+ 'meta',
4982
+ 'createdAt',
4983
+ 'updatedAt'
4984
+ ]
4145
4985
  } as const;
4146
4986
 
4147
- export const $UpdateUserSettingDto = {
4987
+ export const $EventListResponseDto = {
4148
4988
  type: 'object',
4149
4989
  properties: {
4150
- secId: {
4990
+ items: {
4991
+ description: 'List of life events',
4992
+ type: 'array',
4993
+ items: {
4994
+ $ref: '#/components/schemas/EventResponseDto'
4995
+ }
4996
+ },
4997
+ total: {
4151
4998
  type: 'number',
4152
- description: 'Security ID'
4999
+ description: 'Total number of life events matching the query',
5000
+ example: 42
5001
+ }
5002
+ },
5003
+ required: ['items', 'total']
5004
+ } as const;
5005
+
5006
+ export const $UpdateBeanEventDto = {
5007
+ type: 'object',
5008
+ properties: {
5009
+ date: {
5010
+ type: 'string',
5011
+ description: 'Life event date (ISO 8601)'
5012
+ },
5013
+ type: {
5014
+ type: 'string',
5015
+ description: 'Life event type (user-defined)'
5016
+ },
5017
+ description: {
5018
+ type: 'string',
5019
+ description:
5020
+ 'Life event description. Empty string is a VALID value (distinct from absence).'
5021
+ },
5022
+ meta: {
5023
+ type: 'object',
5024
+ description: 'Product-side metadata (free-form JSON)'
5025
+ }
5026
+ }
5027
+ } as const;
5028
+
5029
+ export const $OnboardingAccountDto = {
5030
+ type: 'object',
5031
+ properties: {
5032
+ path: {
5033
+ type: 'string',
5034
+ description:
5035
+ 'Account path (Assets/Liabilities only; format validated by the account service)',
5036
+ example: 'Assets:Checking'
5037
+ },
5038
+ currency: {
5039
+ type: 'string',
5040
+ description: 'ISO 4217 currency code (3 letters)',
5041
+ example: 'USD'
5042
+ },
5043
+ openingBalance: {
5044
+ type: 'string',
5045
+ description:
5046
+ 'Opening balance as a non-negative Decimal string (e.g. "1000.00")',
5047
+ example: '1000.00'
5048
+ },
5049
+ platformId: {
5050
+ type: 'string',
5051
+ description:
5052
+ 'Platform ID to bind the account to (references Platform.id); omit for unbound',
5053
+ example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2'
5054
+ }
5055
+ },
5056
+ required: ['path', 'currency']
5057
+ } as const;
5058
+
5059
+ export const $OnboardingDto = {
5060
+ type: 'object',
5061
+ properties: {
5062
+ accounts: {
5063
+ description: 'Asset/Liability accounts to register with opening balances',
5064
+ type: 'array',
5065
+ items: {
5066
+ $ref: '#/components/schemas/OnboardingAccountDto'
5067
+ }
5068
+ },
5069
+ skipAssetRegistration: {
5070
+ type: 'boolean',
5071
+ description:
5072
+ 'Skip asset registration; only bootstrap the core account set',
5073
+ default: false
5074
+ }
5075
+ }
5076
+ } as const;
5077
+
5078
+ export const $ActualBalanceDto = {
5079
+ type: 'object',
5080
+ properties: {
5081
+ amount: {
5082
+ type: 'string',
5083
+ description:
5084
+ 'Actual balance amount as a decimal string (preserves precision for tolerance inference).',
5085
+ example: '1234.56'
5086
+ },
5087
+ ccy: {
5088
+ type: 'string',
5089
+ description: 'Currency code (ISO 4217 or commodity ticker).',
5090
+ example: 'CNY'
5091
+ }
5092
+ },
5093
+ required: ['amount', 'ccy']
5094
+ } as const;
5095
+
5096
+ export const $ComputeReconciliationDto = {
5097
+ type: 'object',
5098
+ properties: {
5099
+ accountId: {
5100
+ type: 'string',
5101
+ description: 'BeanAccount id to reconcile.'
5102
+ },
5103
+ asOfDate: {
5104
+ type: 'string',
5105
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5106
+ example: '2026-07-24'
5107
+ },
5108
+ actualBalance: {
5109
+ description: 'Actual balance from the external statement.',
5110
+ allOf: [
5111
+ {
5112
+ $ref: '#/components/schemas/ActualBalanceDto'
5113
+ }
5114
+ ]
5115
+ }
5116
+ },
5117
+ required: ['accountId', 'asOfDate', 'actualBalance']
5118
+ } as const;
5119
+
5120
+ export const $ReconciliationComputeResultDto = {
5121
+ type: 'object',
5122
+ properties: {
5123
+ accountId: {
5124
+ type: 'string'
5125
+ },
5126
+ asOfDate: {
5127
+ type: 'string'
4153
5128
  },
4154
- annualInterestRate: {
4155
- type: 'number',
4156
- description: 'Annual interest rate',
4157
- example: 0.05
5129
+ bookBalance: {
5130
+ type: 'string',
5131
+ description: 'System-computed book balance (decimal string).'
4158
5132
  },
4159
- currency: {
5133
+ actualBalance: {
4160
5134
  type: 'string',
4161
- description: 'Currency code',
4162
- example: 'USD'
5135
+ description: 'User-entered actual balance (decimal string).'
4163
5136
  },
4164
- baseCurrency: {
5137
+ currency: {
5138
+ type: 'string'
5139
+ },
5140
+ diff: {
4165
5141
  type: 'string',
4166
- description: 'Base currency code',
4167
- example: 'USD'
5142
+ description: 'Diff = book − actual (decimal string).'
4168
5143
  },
4169
- benchmark: {
5144
+ tolerance: {
4170
5145
  type: 'string',
4171
- description: 'Benchmark symbol',
4172
- example: 'SPY'
5146
+ description: 'Applied tolerance (decimal string).'
4173
5147
  },
4174
- colorScheme: {
5148
+ withinTolerance: {
5149
+ type: 'boolean',
5150
+ description: 'true when |diff| ≤ tolerance.'
5151
+ },
5152
+ suggestedAction: {
4175
5153
  type: 'string',
4176
- description: 'Color scheme',
4177
- enum: ['DARK', 'LIGHT']
5154
+ enum: ['assert', 'pad'],
5155
+ description:
5156
+ 'Suggested next action: assert when within tolerance, pad otherwise.'
5157
+ }
5158
+ },
5159
+ required: [
5160
+ 'accountId',
5161
+ 'asOfDate',
5162
+ 'bookBalance',
5163
+ 'actualBalance',
5164
+ 'currency',
5165
+ 'diff',
5166
+ 'tolerance',
5167
+ 'withinTolerance',
5168
+ 'suggestedAction'
5169
+ ]
5170
+ } as const;
5171
+
5172
+ export const $AssertReconciliationDto = {
5173
+ type: 'object',
5174
+ properties: {
5175
+ accountId: {
5176
+ type: 'string',
5177
+ description: 'BeanAccount id to reconcile.'
4178
5178
  },
4179
- dateRange: {
5179
+ asOfDate: {
4180
5180
  type: 'string',
4181
- description: 'Date range filter',
4182
- example: '1y'
5181
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5182
+ example: '2026-07-24'
4183
5183
  },
4184
- emergencyFund: {
4185
- type: 'number',
4186
- description: 'Emergency fund amount',
4187
- example: 10000
5184
+ actualBalance: {
5185
+ description: 'Actual balance from the external statement.',
5186
+ allOf: [
5187
+ {
5188
+ $ref: '#/components/schemas/ActualBalanceDto'
5189
+ }
5190
+ ]
4188
5191
  },
4189
- 'filters.accounts': {
4190
- description: 'Account filter IDs',
4191
- type: 'array',
4192
- items: {
4193
- type: 'string'
4194
- }
5192
+ tolerance: {
5193
+ type: 'string',
5194
+ description:
5195
+ 'Optional explicit tolerance override. Omit to infer from amount precision (Beancount default).',
5196
+ example: '0.01'
5197
+ }
5198
+ },
5199
+ required: ['accountId', 'asOfDate', 'actualBalance']
5200
+ } as const;
5201
+
5202
+ export const $ReconciliationRecordDto = {
5203
+ type: 'object',
5204
+ properties: {
5205
+ id: {
5206
+ type: 'string'
4195
5207
  },
4196
- 'filters.assetClasses': {
4197
- description: 'Asset class filters',
4198
- type: 'array',
4199
- items: {
4200
- type: 'string'
4201
- }
5208
+ accountId: {
5209
+ type: 'string'
4202
5210
  },
4203
- 'filters.dataSource': {
4204
- type: 'string',
4205
- description: 'Data source filter'
5211
+ date: {
5212
+ type: 'string'
4206
5213
  },
4207
- 'filters.symbol': {
5214
+ amount: {
4208
5215
  type: 'string',
4209
- description: 'Symbol filter'
4210
- },
4211
- 'filters.tags': {
4212
- description: 'Tag filters',
4213
- type: 'array',
4214
- items: {
4215
- type: 'string'
4216
- }
5216
+ description: 'Asserted (actual) amount.'
4217
5217
  },
4218
- isExperimentalFeatures: {
4219
- type: 'boolean',
4220
- description: 'Enable experimental features'
5218
+ currency: {
5219
+ type: 'string'
4221
5220
  },
4222
- isRestrictedView: {
4223
- type: 'boolean',
4224
- description: 'Enable restricted view mode'
5221
+ tolerance: {
5222
+ type: 'string'
4225
5223
  },
4226
- language: {
5224
+ diffAmount: {
4227
5225
  type: 'string',
4228
- description: 'Language code',
4229
- example: 'en'
5226
+ description: 'book − actual.'
4230
5227
  },
4231
- locale: {
4232
- type: 'string',
4233
- description: 'Locale code',
4234
- example: 'en-US'
5228
+ diffCurrency: {
5229
+ type: 'string'
4235
5230
  },
4236
- projectedTotalAmount: {
4237
- type: 'number',
4238
- description: 'Projected total amount',
4239
- example: 1000000
5231
+ createdAt: {
5232
+ type: 'string'
5233
+ }
5234
+ },
5235
+ required: ['id', 'accountId', 'date', 'amount', 'currency', 'createdAt']
5236
+ } as const;
5237
+
5238
+ export const $PadReconciliationDto = {
5239
+ type: 'object',
5240
+ properties: {
5241
+ accountId: {
5242
+ type: 'string',
5243
+ description: 'BeanAccount id to reconcile.'
4240
5244
  },
4241
- retirementDate: {
5245
+ asOfDate: {
4242
5246
  type: 'string',
4243
- description: 'Retirement date in ISO 8601 format',
4244
- example: '2050-01-01'
5247
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5248
+ example: '2026-07-24'
4245
5249
  },
4246
- savingsRate: {
4247
- type: 'number',
4248
- description: 'Savings rate percentage',
4249
- example: 0.2
5250
+ actualBalance: {
5251
+ description: 'Actual balance from the external statement.',
5252
+ allOf: [
5253
+ {
5254
+ $ref: '#/components/schemas/ActualBalanceDto'
5255
+ }
5256
+ ]
4250
5257
  },
4251
- viewMode: {
5258
+ sourceAccount: {
4252
5259
  type: 'string',
4253
- description: 'View mode',
4254
- enum: ['DEFAULT', 'ZEN']
5260
+ description:
5261
+ 'Pad source account. Defaults to Equity:Opening-Balances (official Beancount convention).',
5262
+ example: 'Equity:Opening-Balances',
5263
+ default: 'Equity:Opening-Balances'
4255
5264
  }
4256
- }
5265
+ },
5266
+ required: ['accountId', 'asOfDate', 'actualBalance']
4257
5267
  } as const;
4258
5268
 
4259
- export const $UpdatePropertyDto = {
5269
+ export const $PadResultDto = {
4260
5270
  type: 'object',
4261
5271
  properties: {
4262
- value: {
5272
+ transactionId: {
4263
5273
  type: 'string',
4264
- description: 'Property value'
5274
+ description: 'Created pad adjusting transaction id.'
4265
5275
  }
4266
5276
  },
4267
- required: ['value']
5277
+ required: ['transactionId']
4268
5278
  } as const;
4269
5279
 
4270
5280
  export const $FileImportDto = {
@@ -4433,7 +5443,7 @@ export const $IdentifyResultDto = {
4433
5443
  account: {
4434
5444
  type: 'string',
4435
5445
  description: 'Default account used by this importer',
4436
- example: 'Assets:Alipay:Balance'
5446
+ example: 'Assets:CN:Alipay:Balance'
4437
5447
  },
4438
5448
  message: {
4439
5449
  type: 'string',
@@ -4450,7 +5460,7 @@ export const $MapperDefaultsDto = {
4450
5460
  sourceAccount: {
4451
5461
  type: 'string',
4452
5462
  description: 'Source account for transactions (Beancount format)',
4453
- example: 'Assets:Alipay:Balance'
5463
+ example: 'Assets:CN:Alipay:Balance'
4454
5464
  },
4455
5465
  currency: {
4456
5466
  type: 'string',
@@ -4487,7 +5497,7 @@ export const $MapperDefaultsDto = {
4487
5497
  description:
4488
5498
  'Payment method to source account mapping. Maps payment method keywords to Beancount account paths. Used by Alipay/WeChat importers to determine sourceAccount based on payment method (e.g., HuaBei, CreditCard).',
4489
5499
  example: {
4490
- HuaBei: 'Liabilities:Alipay:Huabei',
5500
+ HuaBei: 'Liabilities:CN:CreditLine',
4491
5501
  CreditCard: 'Liabilities:CreditCard'
4492
5502
  }
4493
5503
  }
@@ -4619,7 +5629,7 @@ export const $UpdateMapperDefaultsDto = {
4619
5629
  sourceAccount: {
4620
5630
  type: 'string',
4621
5631
  description: 'Source account for transactions (Beancount format)',
4622
- example: 'Assets:Alipay:Balance',
5632
+ example: 'Assets:CN:Alipay:Balance',
4623
5633
  pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4624
5634
  },
4625
5635
  currency: {
@@ -4647,7 +5657,7 @@ export const $UpdateMapperDefaultsDto = {
4647
5657
  description:
4648
5658
  'Payment method to source account mapping. Maps payment method keywords to Beancount account paths. Used by Alipay/WeChat importers to determine sourceAccount based on payment method (e.g., HuaBei, CreditCard).',
4649
5659
  example: {
4650
- HuaBei: 'Liabilities:Alipay:Huabei',
5660
+ HuaBei: 'Liabilities:CN:CreditLine',
4651
5661
  CreditCard: 'Liabilities:CreditCard'
4652
5662
  }
4653
5663
  }
@@ -4672,118 +5682,12 @@ export const $UpdateImporterConfigDto = {
4672
5682
  type: 'object',
4673
5683
  properties: {
4674
5684
  data: {
4675
- description: 'Configuration data (v1 schema)',
4676
- allOf: [
4677
- {
4678
- $ref: '#/components/schemas/UpdateConfigDataDto'
4679
- }
4680
- ]
4681
- }
4682
- }
4683
- } as const;
4684
-
4685
- export const $CreatePlatformDto = {
4686
- type: 'object',
4687
- properties: {
4688
- name: {
4689
- type: 'string',
4690
- description: 'Platform name',
4691
- example: 'Binance'
4692
- },
4693
- canonical: {
4694
- type: 'string',
4695
- description: 'Platform canonical identifier (lowercase, kebab-case)',
4696
- example: 'binance'
4697
- },
4698
- aliases: {
4699
- description: 'Platform aliases (multi-language names for lookup)',
4700
- example: ['Binance', 'Binance Exchange', 'BNB'],
4701
- type: 'array',
4702
- items: {
4703
- type: 'string'
4704
- }
4705
- },
4706
- url: {
4707
- type: 'string',
4708
- description: 'Platform URL',
4709
- example: 'https://www.binance.com'
4710
- },
4711
- type: {
4712
- type: 'string',
4713
- description: 'Platform type',
4714
- enum: [
4715
- 'BANK',
4716
- 'BROKERAGE',
4717
- 'CRYPTO_EXCHANGE',
4718
- 'PAYMENT',
4719
- 'INVESTMENT',
4720
- 'INSURANCE',
4721
- 'OTHER'
4722
- ],
4723
- example: 'CRYPTO_EXCHANGE'
4724
- },
4725
- logoUrl: {
4726
- type: 'string',
4727
- description: 'Platform logo URL',
4728
- example: 'https://example.com/logos/binance.png'
4729
- },
4730
- isActive: {
4731
- type: 'boolean',
4732
- description: 'Whether the platform is active',
4733
- default: true
4734
- }
4735
- },
4736
- required: ['name', 'canonical', 'aliases', 'url', 'type']
4737
- } as const;
4738
-
4739
- export const $UpdatePlatformDto = {
4740
- type: 'object',
4741
- properties: {
4742
- name: {
4743
- type: 'string',
4744
- description: 'Platform name',
4745
- example: 'Binance'
4746
- },
4747
- canonical: {
4748
- type: 'string',
4749
- description: 'Platform canonical identifier (lowercase, kebab-case)',
4750
- example: 'binance'
4751
- },
4752
- aliases: {
4753
- description: 'Platform aliases (multi-language names for lookup)',
4754
- example: ['Binance', 'Binance Exchange', 'BNB'],
4755
- type: 'array',
4756
- items: {
4757
- type: 'string'
4758
- }
4759
- },
4760
- url: {
4761
- type: 'string',
4762
- description: 'Platform URL',
4763
- example: 'https://www.binance.com'
4764
- },
4765
- type: {
4766
- type: 'string',
4767
- description: 'Platform type',
4768
- enum: [
4769
- 'BANK',
4770
- 'BROKERAGE',
4771
- 'CRYPTO_EXCHANGE',
4772
- 'PAYMENT',
4773
- 'INVESTMENT',
4774
- 'INSURANCE',
4775
- 'OTHER'
4776
- ],
4777
- example: 'CRYPTO_EXCHANGE'
4778
- },
4779
- logoUrl: {
4780
- type: 'string',
4781
- description: 'Platform logo URL',
4782
- example: 'https://example.com/logos/binance.png'
4783
- },
4784
- isActive: {
4785
- type: 'boolean',
4786
- description: 'Whether the platform is active'
5685
+ description: 'Configuration data (v1 schema)',
5686
+ allOf: [
5687
+ {
5688
+ $ref: '#/components/schemas/UpdateConfigDataDto'
5689
+ }
5690
+ ]
4787
5691
  }
4788
5692
  }
4789
5693
  } as const;
@@ -4794,7 +5698,7 @@ export const $ProviderSyncConfigDto = {
4794
5698
  sourceAccount: {
4795
5699
  type: 'string',
4796
5700
  description: 'Source account for the first posting',
4797
- example: 'Assets:Bank:Chase'
5701
+ example: 'Assets:US:Chase:Checking'
4798
5702
  },
4799
5703
  defaultCurrency: {
4800
5704
  type: 'string',
@@ -4815,6 +5719,12 @@ export const $ProviderSyncConfigDto = {
4815
5719
  type: 'boolean',
4816
5720
  description: 'Filter pending transactions',
4817
5721
  default: true
5722
+ },
5723
+ externalAccountId: {
5724
+ type: 'string',
5725
+ description:
5726
+ 'External account ID for per-batch providers (e.g. GoCardless). Overrides sourceAccount when an ExternalAccountLink mapping exists.',
5727
+ example: 'acc_gocardless_001'
4818
5728
  }
4819
5729
  },
4820
5730
  required: [
@@ -4934,6 +5844,94 @@ export const $SupportedProvidersResponseDto = {
4934
5844
  required: ['providers']
4935
5845
  } as const;
4936
5846
 
5847
+ export const $CreateExternalAccountLinkDto = {
5848
+ type: 'object',
5849
+ properties: {
5850
+ provider: {
5851
+ type: 'string',
5852
+ enum: [
5853
+ 'plaid',
5854
+ 'teller',
5855
+ 'truelayer',
5856
+ 'gocardless',
5857
+ 'simplefin',
5858
+ 'yodlee',
5859
+ 'beancount-direct',
5860
+ 'parsed-bill'
5861
+ ],
5862
+ example: 'plaid',
5863
+ description: 'Open Banking provider (whitelist)'
5864
+ },
5865
+ externalAccountId: {
5866
+ type: 'string',
5867
+ example: 'acc-plaid-001',
5868
+ description: 'External account ID from the provider'
5869
+ },
5870
+ beanAccountId: {
5871
+ type: 'string',
5872
+ example: '550e8400-e29b-41d4-a716-446655440000',
5873
+ description: 'Target BeanAccount ID (must belong to the JWT user)'
5874
+ }
5875
+ },
5876
+ required: ['provider', 'externalAccountId', 'beanAccountId']
5877
+ } as const;
5878
+
5879
+ export const $ExternalAccountLinkResponseDto = {
5880
+ type: 'object',
5881
+ properties: {
5882
+ id: {
5883
+ type: 'string'
5884
+ },
5885
+ provider: {
5886
+ type: 'string'
5887
+ },
5888
+ externalAccountId: {
5889
+ type: 'string'
5890
+ },
5891
+ beanAccountId: {
5892
+ type: 'string'
5893
+ },
5894
+ isActive: {
5895
+ type: 'boolean'
5896
+ },
5897
+ createdAt: {
5898
+ type: 'string'
5899
+ },
5900
+ updatedAt: {
5901
+ type: 'string'
5902
+ }
5903
+ },
5904
+ required: [
5905
+ 'id',
5906
+ 'provider',
5907
+ 'externalAccountId',
5908
+ 'beanAccountId',
5909
+ 'isActive',
5910
+ 'createdAt',
5911
+ 'updatedAt'
5912
+ ]
5913
+ } as const;
5914
+
5915
+ export const $ExternalAccountLinkListResponseDto = {
5916
+ type: 'object',
5917
+ properties: {
5918
+ items: {
5919
+ type: 'array',
5920
+ items: {
5921
+ $ref: '#/components/schemas/ExternalAccountLinkResponseDto'
5922
+ }
5923
+ },
5924
+ total: {
5925
+ type: 'number'
5926
+ },
5927
+ provider: {
5928
+ type: 'string',
5929
+ description: 'Filter by provider (query param)'
5930
+ }
5931
+ },
5932
+ required: ['items', 'total']
5933
+ } as const;
5934
+
4937
5935
  export const $ParserTelemetryReportDto = {
4938
5936
  type: 'object',
4939
5937
  properties: {}
@@ -4968,6 +5966,18 @@ export const $ProcessNlpDto = {
4968
5966
  currency: 'CNY',
4969
5967
  payee: 'Starbucks'
4970
5968
  }
5969
+ },
5970
+ selectedRuleId: {
5971
+ type: 'string',
5972
+ description:
5973
+ 'confirm_rule echo-back: rule id selected from the prior confirm_rule response (matchedRule.id or alternatives[i].ruleId). Applied directly when the session is confirming_rule — no NL re-parse.',
5974
+ example: 'rule_abc123'
5975
+ },
5976
+ selectedAccount: {
5977
+ type: 'string',
5978
+ description:
5979
+ 'confirm_account echo-back: account path selected from the prior confirm_account response (suggestedAccount, similarAccounts[i], or a typed path). Applied directly when the session is confirming_account — no NL re-parse.',
5980
+ example: 'Expenses:Food:Coffee'
4971
5981
  }
4972
5982
  },
4973
5983
  required: ['message']
@@ -5292,7 +6302,8 @@ export const $NlpAccountConfirmationDataDto = {
5292
6302
  },
5293
6303
  suggestedAccount: {
5294
6304
  type: 'string',
5295
- description: 'Suggested replacement account',
6305
+ description:
6306
+ 'Suggested replacement account (omitted when no clear candidate)',
5296
6307
  example: 'Expenses:Food:Drinks'
5297
6308
  },
5298
6309
  similarAccounts: {
@@ -5314,7 +6325,6 @@ export const $NlpAccountConfirmationDataDto = {
5314
6325
  },
5315
6326
  required: [
5316
6327
  'invalidAccount',
5317
- 'suggestedAccount',
5318
6328
  'similarAccounts',
5319
6329
  'errorMessage',
5320
6330
  'transactionContext'
@@ -5483,7 +6493,7 @@ export const $NlpSuggestedAccountDto = {
5483
6493
  account: {
5484
6494
  type: 'string',
5485
6495
  description: 'Suggested account path',
5486
- example: 'Assets:Bank:Checking'
6496
+ example: 'Assets:Checking'
5487
6497
  },
5488
6498
  confidence: {
5489
6499
  type: 'number',
@@ -5524,7 +6534,7 @@ export const $NlpDefaultAccountsDto = {
5524
6534
  asset: {
5525
6535
  type: 'string',
5526
6536
  description: 'Default asset account',
5527
- example: 'Assets:Bank:Checking'
6537
+ example: 'Assets:Checking'
5528
6538
  },
5529
6539
  expense: {
5530
6540
  type: 'string',
@@ -5564,7 +6574,8 @@ export const $NlpResponseDto = {
5564
6574
  'confirm_rule',
5565
6575
  'confirm_account',
5566
6576
  'confirm_payee',
5567
- 'cancel'
6577
+ 'cancel',
6578
+ 'aborted'
5568
6579
  ]
5569
6580
  },
5570
6581
  intent: {
@@ -5668,99 +6679,330 @@ export const $NlpResponseDto = {
5668
6679
  }
5669
6680
  ]
5670
6681
  },
5671
- ruleData: {
6682
+ ruleData: {
6683
+ description:
6684
+ 'Rule match data (when action is "confirm_rule"). Contains information about medium-confidence rule match for user confirmation.',
6685
+ allOf: [
6686
+ {
6687
+ $ref: '#/components/schemas/NlpRuleConfirmationDataDto'
6688
+ }
6689
+ ]
6690
+ },
6691
+ accountData: {
6692
+ description:
6693
+ 'Account validation data (when action is "confirm_account"). Contains information about invalid account for user correction.',
6694
+ allOf: [
6695
+ {
6696
+ $ref: '#/components/schemas/NlpAccountConfirmationDataDto'
6697
+ }
6698
+ ]
6699
+ },
6700
+ payeeData: {
6701
+ description:
6702
+ 'Payee confirmation data (when action is "confirm_payee"). Contains information about medium/low confidence payee match for user confirmation.',
6703
+ allOf: [
6704
+ {
6705
+ $ref: '#/components/schemas/NlpPayeeConfirmationDataDto'
6706
+ }
6707
+ ]
6708
+ },
6709
+ confidence: {
6710
+ type: 'number',
6711
+ description: 'Overall confidence score (0-1)',
6712
+ example: 0.85
6713
+ },
6714
+ confidenceThreshold: {
6715
+ type: 'number',
6716
+ description:
6717
+ 'Confidence threshold for automatic creation (default: 0.75). When confidence < threshold, action will be "confirm" requiring user verification.',
6718
+ example: 0.75
6719
+ },
6720
+ recurringMatch: {
6721
+ description:
6722
+ 'Recurring transaction match info (when action is "created"). Contains match details when transaction matches a pending expected transaction.',
6723
+ allOf: [
6724
+ {
6725
+ $ref: '#/components/schemas/RecurringMatchInfoDto'
6726
+ }
6727
+ ]
6728
+ },
6729
+ recurringSuggestion: {
6730
+ description:
6731
+ 'Recurring rule creation suggestion (when action is "created"). Contains suggestion to create a recurring rule based on detected patterns. Only present when no existing rule matched and similar historical transactions were found.',
6732
+ allOf: [
6733
+ {
6734
+ $ref: '#/components/schemas/RecurringSuggestionDto'
6735
+ }
6736
+ ]
6737
+ },
6738
+ suggestedAccounts: {
6739
+ description:
6740
+ 'Suggested accounts for this transaction. Contains recommended source and destination accounts based on the detected intent and rules.',
6741
+ allOf: [
6742
+ {
6743
+ $ref: '#/components/schemas/NlpSuggestedAccountsDto'
6744
+ }
6745
+ ]
6746
+ },
6747
+ defaultAccounts: {
6748
+ description:
6749
+ 'Default accounts for the user/region. These are fallback accounts used when no specific suggestion is available.',
6750
+ allOf: [
6751
+ {
6752
+ $ref: '#/components/schemas/NlpDefaultAccountsDto'
6753
+ }
6754
+ ]
6755
+ }
6756
+ },
6757
+ required: ['status', 'action']
6758
+ } as const;
6759
+
6760
+ export const $PlatformListItemDto = {
6761
+ type: 'object',
6762
+ properties: {
6763
+ id: {
6764
+ type: 'string',
6765
+ description: 'Global platform ID'
6766
+ },
6767
+ name: {
6768
+ type: 'string',
6769
+ description: 'Platform name'
6770
+ },
6771
+ url: {
6772
+ type: 'string',
6773
+ description: 'Platform URL'
6774
+ },
6775
+ type: {
6776
+ type: 'string',
6777
+ description: 'Platform type',
6778
+ enum: [
6779
+ 'BANK',
6780
+ 'BROKERAGE',
6781
+ 'CRYPTO_EXCHANGE',
6782
+ 'PAYMENT',
6783
+ 'INVESTMENT',
6784
+ 'INSURANCE',
6785
+ 'OTHER'
6786
+ ]
6787
+ },
6788
+ canonical: {
6789
+ type: 'string',
6790
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
6791
+ },
6792
+ suggestedSegment: {
6793
+ type: 'string',
6794
+ description:
6795
+ 'Suggested path segment — canonical with first char uppercased (ACC_COMP_NAME_RE)'
6796
+ },
6797
+ logoUrl: {
6798
+ type: 'string',
6799
+ description: 'Logo URL',
6800
+ nullable: true
6801
+ },
6802
+ isBound: {
6803
+ type: 'boolean',
6804
+ description: 'Whether user has accounts using this platform'
6805
+ }
6806
+ },
6807
+ required: [
6808
+ 'id',
6809
+ 'name',
6810
+ 'url',
6811
+ 'type',
6812
+ 'canonical',
6813
+ 'suggestedSegment',
6814
+ 'logoUrl',
6815
+ 'isBound'
6816
+ ]
6817
+ } as const;
6818
+
6819
+ export const $PlatformMatchResultDto = {
6820
+ type: 'object',
6821
+ properties: {
6822
+ id: {
6823
+ type: 'string',
6824
+ description: 'Global platform ID'
6825
+ },
6826
+ name: {
6827
+ type: 'string',
6828
+ description: 'Platform name (e.g., "ICBC")'
6829
+ },
6830
+ canonical: {
6831
+ type: 'string',
6832
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
6833
+ },
6834
+ type: {
6835
+ type: 'string',
6836
+ description: 'Platform type',
6837
+ enum: [
6838
+ 'BANK',
6839
+ 'BROKERAGE',
6840
+ 'CRYPTO_EXCHANGE',
6841
+ 'PAYMENT',
6842
+ 'INVESTMENT',
6843
+ 'INSURANCE',
6844
+ 'OTHER'
6845
+ ]
6846
+ },
6847
+ suggestedSegment: {
6848
+ type: 'string',
6849
+ description:
6850
+ 'Suggested path segment — canonical, already in ACCOUNT_RE format'
6851
+ },
6852
+ logoUrl: {
6853
+ type: 'string',
6854
+ description: 'Logo URL',
6855
+ nullable: true
6856
+ },
6857
+ matchType: {
6858
+ type: 'string',
6859
+ description: "How this row matched: 'exact' > 'prefix' > 'substring'",
6860
+ enum: ['exact', 'prefix', 'substring']
6861
+ }
6862
+ },
6863
+ required: [
6864
+ 'id',
6865
+ 'name',
6866
+ 'canonical',
6867
+ 'type',
6868
+ 'suggestedSegment',
6869
+ 'logoUrl',
6870
+ 'matchType'
6871
+ ]
6872
+ } as const;
6873
+
6874
+ export const $PlatformMatchResponseDto = {
6875
+ type: 'object',
6876
+ properties: {
6877
+ platforms: {
6878
+ description: 'Ranked matches, best tier first (at most 10 rows)',
6879
+ type: 'array',
6880
+ items: {
6881
+ $ref: '#/components/schemas/PlatformMatchResultDto'
6882
+ }
6883
+ },
6884
+ matchType: {
6885
+ type: 'string',
5672
6886
  description:
5673
- 'Rule match data (when action is "confirm_rule"). Contains information about medium-confidence rule match for user confirmation.',
5674
- allOf: [
5675
- {
5676
- $ref: '#/components/schemas/NlpRuleConfirmationDataDto'
5677
- }
5678
- ]
6887
+ "Overall match quality — top row's tier, or 'none' when no hits",
6888
+ enum: ['none', 'exact', 'prefix', 'substring']
5679
6889
  },
5680
- accountData: {
5681
- description:
5682
- 'Account validation data (when action is "confirm_account"). Contains information about invalid account for user correction.',
5683
- allOf: [
5684
- {
5685
- $ref: '#/components/schemas/NlpAccountConfirmationDataDto'
5686
- }
5687
- ]
6890
+ total: {
6891
+ type: 'number',
6892
+ description: 'Total matches before LIMIT (truncation transparency)'
5688
6893
  },
5689
- payeeData: {
5690
- description:
5691
- 'Payee confirmation data (when action is "confirm_payee"). Contains information about medium/low confidence payee match for user confirmation.',
5692
- allOf: [
5693
- {
5694
- $ref: '#/components/schemas/NlpPayeeConfirmationDataDto'
5695
- }
5696
- ]
6894
+ hasMore: {
6895
+ type: 'boolean',
6896
+ description: 'true when total > platforms.length (more matches exist)'
6897
+ }
6898
+ },
6899
+ required: ['platforms', 'matchType', 'total', 'hasMore']
6900
+ } as const;
6901
+
6902
+ export const $CreatePlatformDto = {
6903
+ type: 'object',
6904
+ properties: {
6905
+ name: {
6906
+ type: 'string',
6907
+ description: 'Platform name',
6908
+ example: 'Binance'
5697
6909
  },
5698
- confidence: {
5699
- type: 'number',
5700
- description: 'Overall confidence score (0-1)',
5701
- example: 0.85
6910
+ canonical: {
6911
+ type: 'string',
6912
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6913
+ example: 'binance'
5702
6914
  },
5703
- confidenceThreshold: {
5704
- type: 'number',
5705
- description:
5706
- 'Confidence threshold for automatic creation (default: 0.75). When confidence < threshold, action will be "confirm" requiring user verification.',
5707
- example: 0.75
6915
+ aliases: {
6916
+ description: 'Platform aliases (multi-language names for lookup)',
6917
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6918
+ type: 'array',
6919
+ items: {
6920
+ type: 'string'
6921
+ }
5708
6922
  },
5709
- recurringMatch: {
5710
- description:
5711
- 'Recurring transaction match info (when action is "created"). Contains match details when transaction matches a pending expected transaction.',
5712
- allOf: [
5713
- {
5714
- $ref: '#/components/schemas/RecurringMatchInfoDto'
5715
- }
5716
- ]
6923
+ url: {
6924
+ type: 'string',
6925
+ description: 'Platform URL',
6926
+ example: 'https://www.binance.com'
5717
6927
  },
5718
- recurringSuggestion: {
5719
- description:
5720
- 'Recurring rule creation suggestion (when action is "created"). Contains suggestion to create a recurring rule based on detected patterns. Only present when no existing rule matched and similar historical transactions were found.',
5721
- allOf: [
5722
- {
5723
- $ref: '#/components/schemas/RecurringSuggestionDto'
5724
- }
5725
- ]
6928
+ type: {
6929
+ type: 'string',
6930
+ description: 'Platform type',
6931
+ enum: [
6932
+ 'BANK',
6933
+ 'BROKERAGE',
6934
+ 'CRYPTO_EXCHANGE',
6935
+ 'PAYMENT',
6936
+ 'INVESTMENT',
6937
+ 'INSURANCE',
6938
+ 'OTHER'
6939
+ ],
6940
+ example: 'CRYPTO_EXCHANGE'
5726
6941
  },
5727
- suggestedAccounts: {
5728
- description:
5729
- 'Suggested accounts for this transaction. Contains recommended source and destination accounts based on the detected intent and rules.',
5730
- allOf: [
5731
- {
5732
- $ref: '#/components/schemas/NlpSuggestedAccountsDto'
5733
- }
5734
- ]
6942
+ logoUrl: {
6943
+ type: 'string',
6944
+ description: 'Platform logo URL',
6945
+ example: 'https://example.com/logos/binance.png'
5735
6946
  },
5736
- defaultAccounts: {
5737
- description:
5738
- 'Default accounts for the user/region. These are fallback accounts used when no specific suggestion is available.',
5739
- allOf: [
5740
- {
5741
- $ref: '#/components/schemas/NlpDefaultAccountsDto'
5742
- }
5743
- ]
6947
+ isActive: {
6948
+ type: 'boolean',
6949
+ description: 'Whether the platform is active',
6950
+ default: true
5744
6951
  }
5745
6952
  },
5746
- required: ['status', 'action']
6953
+ required: ['name', 'canonical', 'aliases', 'url', 'type']
5747
6954
  } as const;
5748
6955
 
5749
- export const $BalanceByCurrencyDto = {
6956
+ export const $UpdatePlatformDto = {
5750
6957
  type: 'object',
5751
6958
  properties: {
5752
- currency: {
6959
+ name: {
5753
6960
  type: 'string',
5754
- description: 'ISO 4217 currency code',
5755
- example: 'CNY'
6961
+ description: 'Platform name',
6962
+ example: 'Binance'
5756
6963
  },
5757
- balance: {
6964
+ canonical: {
5758
6965
  type: 'string',
5759
- description: 'Balance amount',
5760
- example: '50000.00'
6966
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6967
+ example: 'binance'
6968
+ },
6969
+ aliases: {
6970
+ description: 'Platform aliases (multi-language names for lookup)',
6971
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6972
+ type: 'array',
6973
+ items: {
6974
+ type: 'string'
6975
+ }
6976
+ },
6977
+ url: {
6978
+ type: 'string',
6979
+ description: 'Platform URL',
6980
+ example: 'https://www.binance.com'
6981
+ },
6982
+ type: {
6983
+ type: 'string',
6984
+ description: 'Platform type',
6985
+ enum: [
6986
+ 'BANK',
6987
+ 'BROKERAGE',
6988
+ 'CRYPTO_EXCHANGE',
6989
+ 'PAYMENT',
6990
+ 'INVESTMENT',
6991
+ 'INSURANCE',
6992
+ 'OTHER'
6993
+ ],
6994
+ example: 'CRYPTO_EXCHANGE'
6995
+ },
6996
+ logoUrl: {
6997
+ type: 'string',
6998
+ description: 'Platform logo URL',
6999
+ example: 'https://example.com/logos/binance.png'
7000
+ },
7001
+ isActive: {
7002
+ type: 'boolean',
7003
+ description: 'Whether the platform is active'
5761
7004
  }
5762
- },
5763
- required: ['currency', 'balance']
7005
+ }
5764
7006
  } as const;
5765
7007
 
5766
7008
  export const $NetWorthByCurrencyDto = {
@@ -5832,28 +7074,6 @@ export const $ConvertedNetWorthDto = {
5832
7074
  ]
5833
7075
  } as const;
5834
7076
 
5835
- export const $ExchangeRateWarningDto = {
5836
- type: 'object',
5837
- properties: {
5838
- type: {
5839
- type: 'string',
5840
- description: 'Warning type',
5841
- example: 'MISSING_EXCHANGE_RATE'
5842
- },
5843
- currency: {
5844
- type: 'string',
5845
- description: 'Currency without exchange rate',
5846
- example: 'EUR'
5847
- },
5848
- totalAmount: {
5849
- type: 'string',
5850
- description: 'Total amount affected',
5851
- example: '1000.00'
5852
- }
5853
- },
5854
- required: ['type', 'currency', 'totalAmount']
5855
- } as const;
5856
-
5857
7077
  export const $NetWorthResponseDto = {
5858
7078
  type: 'object',
5859
7079
  properties: {
@@ -5939,7 +7159,7 @@ export const $AccountItemDto = {
5939
7159
  name: {
5940
7160
  type: 'string',
5941
7161
  description: 'Full account name',
5942
- example: 'Assets:Bank:CMB:Savings'
7162
+ example: 'Assets:CN:CMB:Savings'
5943
7163
  },
5944
7164
  displayName: {
5945
7165
  type: 'string',
@@ -5955,6 +7175,12 @@ export const $AccountItemDto = {
5955
7175
  type: 'string',
5956
7176
  description: 'Currency code',
5957
7177
  example: 'CNY'
7178
+ },
7179
+ convertedBalance: {
7180
+ type: 'string',
7181
+ description:
7182
+ 'FX-converted balance in base currency; omitted when not convertible',
7183
+ example: '50000.00'
5958
7184
  }
5959
7185
  },
5960
7186
  required: ['id', 'name', 'displayName', 'balance', 'currency']
@@ -5981,11 +7207,66 @@ export const $PlatformGroupDto = {
5981
7207
  },
5982
7208
  totalBalance: {
5983
7209
  type: 'string',
5984
- description: 'Total balance across all accounts in platform',
7210
+ description: 'FX-converted total balance in base currency',
7211
+ example: '100000.00'
7212
+ },
7213
+ balanceByCurrency: {
7214
+ description: 'Raw (unconverted) balances grouped by currency',
7215
+ type: 'array',
7216
+ items: {
7217
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
7218
+ }
7219
+ },
7220
+ convertedBalance: {
7221
+ type: 'string',
7222
+ description:
7223
+ 'Converted balance in base currency (omitted when no currency is convertible)',
5985
7224
  example: '100000.00'
7225
+ },
7226
+ sharePct: {
7227
+ type: 'number',
7228
+ description:
7229
+ 'Share of the grand converted total (0-100); 0 when grand total is 0',
7230
+ example: 42.5
7231
+ }
7232
+ },
7233
+ required: [
7234
+ 'platformId',
7235
+ 'platformName',
7236
+ 'accounts',
7237
+ 'totalBalance',
7238
+ 'balanceByCurrency',
7239
+ 'sharePct'
7240
+ ]
7241
+ } as const;
7242
+
7243
+ export const $AccountExchangeRateWarningDto = {
7244
+ type: 'object',
7245
+ properties: {
7246
+ type: {
7247
+ type: 'string',
7248
+ description: 'Warning type',
7249
+ example: 'MISSING_EXCHANGE_RATE'
7250
+ },
7251
+ currency: {
7252
+ type: 'string',
7253
+ description: 'Currency without exchange rate',
7254
+ example: 'USD'
7255
+ },
7256
+ accounts: {
7257
+ description: 'Affected account paths',
7258
+ type: 'array',
7259
+ items: {
7260
+ type: 'string'
7261
+ }
7262
+ },
7263
+ totalAmount: {
7264
+ type: 'string',
7265
+ description: 'Total amount in this currency',
7266
+ example: '5000.00'
5986
7267
  }
5987
7268
  },
5988
- required: ['platformId', 'platformName', 'accounts', 'totalBalance']
7269
+ required: ['type', 'currency', 'accounts', 'totalAmount']
5989
7270
  } as const;
5990
7271
 
5991
7272
  export const $AccountsSummaryDto = {
@@ -5998,9 +7279,21 @@ export const $AccountsSummaryDto = {
5998
7279
  totalPlatforms: {
5999
7280
  type: 'number',
6000
7281
  description: 'Total number of platforms'
7282
+ },
7283
+ baseCurrency: {
7284
+ type: 'string',
7285
+ description: 'Base currency for conversion',
7286
+ example: 'CNY'
7287
+ },
7288
+ warnings: {
7289
+ description: 'Per-account exchange rate warnings',
7290
+ type: 'array',
7291
+ items: {
7292
+ $ref: '#/components/schemas/AccountExchangeRateWarningDto'
7293
+ }
6001
7294
  }
6002
7295
  },
6003
- required: ['totalAccounts', 'totalPlatforms']
7296
+ required: ['totalAccounts', 'totalPlatforms', 'baseCurrency']
6004
7297
  } as const;
6005
7298
 
6006
7299
  export const $AccountsResponseDto = {
@@ -6035,7 +7328,7 @@ export const $AccountItemWithAssetClassDto = {
6035
7328
  name: {
6036
7329
  type: 'string',
6037
7330
  description: 'Full account name',
6038
- example: 'Assets:Bank:CMB:Savings'
7331
+ example: 'Assets:CN:CMB:Savings'
6039
7332
  },
6040
7333
  displayName: {
6041
7334
  type: 'string',
@@ -6052,6 +7345,12 @@ export const $AccountItemWithAssetClassDto = {
6052
7345
  description: 'Currency code',
6053
7346
  example: 'CNY'
6054
7347
  },
7348
+ convertedBalance: {
7349
+ type: 'string',
7350
+ description:
7351
+ 'FX-converted balance in base currency; omitted when not convertible',
7352
+ example: '50000.00'
7353
+ },
6055
7354
  assetClass: {
6056
7355
  type: 'string',
6057
7356
  description: 'Asset class',
@@ -6131,35 +7430,6 @@ export const $AssetClassGroupDto = {
6131
7430
  required: ['assetClass', 'accounts', 'balanceByCurrency']
6132
7431
  } as const;
6133
7432
 
6134
- export const $AccountExchangeRateWarningDto = {
6135
- type: 'object',
6136
- properties: {
6137
- type: {
6138
- type: 'string',
6139
- description: 'Warning type',
6140
- example: 'MISSING_EXCHANGE_RATE'
6141
- },
6142
- currency: {
6143
- type: 'string',
6144
- description: 'Currency without exchange rate',
6145
- example: 'USD'
6146
- },
6147
- accounts: {
6148
- description: 'Affected account paths',
6149
- type: 'array',
6150
- items: {
6151
- type: 'string'
6152
- }
6153
- },
6154
- totalAmount: {
6155
- type: 'string',
6156
- description: 'Total amount in this currency',
6157
- example: '5000.00'
6158
- }
6159
- },
6160
- required: ['type', 'currency', 'accounts', 'totalAmount']
6161
- } as const;
6162
-
6163
7433
  export const $AssetClassSummaryDto = {
6164
7434
  type: 'object',
6165
7435
  properties: {
@@ -6233,7 +7503,7 @@ export const $HoldingAssetClassAccountSliceDto = {
6233
7503
  accountPath: {
6234
7504
  type: 'string',
6235
7505
  description: 'Full account path',
6236
- example: 'Assets:US:Investments:Brokerage'
7506
+ example: 'Assets:US:Fidelity:Brokerage'
6237
7507
  },
6238
7508
  accountCurrency: {
6239
7509
  type: 'string',
@@ -6439,614 +7709,388 @@ export const $CashFlowResponseDto = {
6439
7709
  ]
6440
7710
  } as const;
6441
7711
 
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 = {
7712
+ export const $CategoryGroupDto = {
6519
7713
  type: 'object',
6520
7714
  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: {
7715
+ category: {
6564
7716
  type: 'string',
6565
- description: 'Net held units (Decimal string)',
6566
- example: '12'
6567
- },
6568
- averageCostPerUnit: {
6569
7717
  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
- ]
7718
+ 'Functional category (account-path Group segment); regional and universal account paths merge under it',
7719
+ example: 'Food'
6604
7720
  },
6605
- unrealizedPnlBase: {
6606
- type: 'object',
7721
+ totalExpense: {
7722
+ type: 'string',
6607
7723
  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
- ]
7724
+ 'Converted total for this category in base currency (expense amount when flow=expense, income amount when flow=income)',
7725
+ example: '1200.00'
6626
7726
  },
6627
- marketFxRate: {
6628
- description: 'FX rate applied to market value',
6629
- nullable: true,
6630
- allOf: [
6631
- {
6632
- $ref: '#/components/schemas/FxRateDto'
6633
- }
6634
- ]
7727
+ sharePct: {
7728
+ type: 'number',
7729
+ description: 'Share of grand total (0-100); 0 when grand total is 0',
7730
+ example: 42.5
6635
7731
  },
6636
- pctOfInvestedAssets: {
6637
- type: 'object',
6638
- description:
6639
- 'Share of invested assets % (Decimal string); only for invested chartTokens',
6640
- nullable: true,
6641
- example: '40'
7732
+ balanceByCurrency: {
7733
+ description: 'Raw (unconverted) expense per currency',
7734
+ type: 'array',
7735
+ items: {
7736
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
7737
+ }
6642
7738
  },
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
- ]
7739
+ convertedBalance: {
7740
+ type: 'string',
7741
+ description:
7742
+ 'Converted total in base currency (omitted when FX missing for all currencies in this category)',
7743
+ example: '1200.00'
7744
+ }
7745
+ },
7746
+ required: ['category', 'totalExpense', 'sharePct', 'balanceByCurrency']
6662
7747
  } as const;
6663
7748
 
6664
- export const $HoldingPnlWarningDto = {
7749
+ export const $ExpensesByCategorySummaryDto = {
6665
7750
  type: 'object',
6666
7751
  properties: {
6667
- type: {
7752
+ totalExpense: {
6668
7753
  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
7754
+ description:
7755
+ 'Total across all categories, converted (convertible categories only); expense totals when flow=expense, income totals when flow=income',
7756
+ example: '5000.00'
6688
7757
  },
6689
- currency: {
6690
- type: 'object',
6691
- nullable: true
7758
+ categoryCount: {
7759
+ type: 'number',
7760
+ description: 'Number of categories',
7761
+ example: 8
6692
7762
  }
6693
7763
  },
6694
- required: ['type']
7764
+ required: ['totalExpense', 'categoryCount']
6695
7765
  } as const;
6696
7766
 
6697
- export const $HoldingPnlResponseDto = {
7767
+ export const $ExpensesByCategoryResponseDto = {
6698
7768
  type: 'object',
6699
7769
  properties: {
6700
- asOfDate: {
7770
+ period: {
6701
7771
  type: 'string',
6702
- example: '2026-07-08'
7772
+ description: 'Period requested',
7773
+ example: '1m'
6703
7774
  },
6704
7775
  baseCurrency: {
6705
7776
  type: 'string',
7777
+ description: 'Base currency for converted values',
6706
7778
  example: 'CNY'
6707
7779
  },
6708
- method: {
6709
- type: 'string',
7780
+ groups: {
6710
7781
  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: {
7782
+ 'Expense groups by functional category, sorted by converted total desc',
6716
7783
  type: 'array',
6717
7784
  items: {
6718
- $ref: '#/components/schemas/HoldingPnlRowDto'
7785
+ $ref: '#/components/schemas/CategoryGroupDto'
6719
7786
  }
6720
7787
  },
7788
+ summary: {
7789
+ description: 'Summary statistics',
7790
+ allOf: [
7791
+ {
7792
+ $ref: '#/components/schemas/ExpensesByCategorySummaryDto'
7793
+ }
7794
+ ]
7795
+ },
6721
7796
  warnings: {
7797
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
6722
7798
  type: 'array',
6723
7799
  items: {
6724
- $ref: '#/components/schemas/HoldingPnlWarningDto'
7800
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
6725
7801
  }
6726
7802
  }
6727
7803
  },
6728
- required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
7804
+ required: ['period', 'baseCurrency', 'groups', 'summary']
6729
7805
  } as const;
6730
7806
 
6731
- export const $CreateBeanPriceDto = {
7807
+ export const $MonetaryDto = {
6732
7808
  type: 'object',
6733
7809
  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
7810
  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
7811
+ type: 'string',
7812
+ description: 'Amount (Decimal string)',
7813
+ example: '3000'
6750
7814
  },
6751
- date: {
7815
+ currency: {
6752
7816
  type: 'string',
6753
- description: 'Price date (ISO 8601 format)',
6754
- example: '2024-11-05'
7817
+ description: 'ISO 4217 currency',
7818
+ example: 'USD'
6755
7819
  },
6756
- metadata: {
7820
+ baseCcyEquivalent: {
6757
7821
  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
- }
7822
+ description: 'Converted to user base currency (Decimal string)',
7823
+ example: '21600',
7824
+ nullable: true
6765
7825
  }
6766
7826
  },
6767
- required: ['currency', 'quoteCurrency', 'amount', 'date']
7827
+ required: ['amount', 'currency']
6768
7828
  } as const;
6769
7829
 
6770
- export const $PriceResponseDto = {
7830
+ export const $CurrentPriceDto = {
6771
7831
  type: 'object',
6772
7832
  properties: {
6773
- id: {
6774
- type: 'string',
6775
- description: 'Unique identifier',
6776
- example: 'uuid-123-456'
6777
- },
6778
- userId: {
7833
+ amount: {
6779
7834
  type: 'string',
6780
- description: 'User ID (owner of the price)',
6781
- example: 'user-123'
7835
+ description: 'Price amount (Decimal string)',
7836
+ example: '250'
6782
7837
  },
6783
7838
  currency: {
6784
7839
  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)',
7840
+ description: 'Price currency (ISO 4217)',
6791
7841
  example: 'USD'
6792
7842
  },
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
7843
  date: {
6800
7844
  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'
7845
+ description: 'Price date (ISO 8601)',
7846
+ example: '2024-06-01'
6821
7847
  },
6822
- updatedAt: {
6823
- format: 'date-time',
7848
+ source: {
6824
7849
  type: 'string',
6825
- description: 'Last update timestamp',
6826
- example: '2024-11-03T10:00:00Z'
7850
+ description: 'Price source',
7851
+ example: 'USER_OVERRIDE',
7852
+ enum: ['USER_OVERRIDE', 'OPENBB_EQUITY', 'OPENBB_CURRENCY']
6827
7853
  }
6828
7854
  },
6829
- required: [
6830
- 'id',
6831
- 'userId',
6832
- 'currency',
6833
- 'quoteCurrency',
6834
- 'amount',
6835
- 'date',
6836
- 'meta',
6837
- 'createdAt',
6838
- 'updatedAt'
6839
- ]
7855
+ required: ['amount', 'currency', 'date', 'source']
6840
7856
  } as const;
6841
7857
 
6842
- export const $PriceListResponseDto = {
7858
+ export const $FxRateDto = {
6843
7859
  type: 'object',
6844
7860
  properties: {
6845
- items: {
6846
- description: 'List of prices',
6847
- type: 'array',
6848
- items: {
6849
- $ref: '#/components/schemas/PriceResponseDto'
6850
- }
7861
+ from: {
7862
+ type: 'string',
7863
+ example: 'USD'
6851
7864
  },
6852
- total: {
6853
- type: 'number',
6854
- description: 'Total number of prices',
6855
- example: 42
7865
+ to: {
7866
+ type: 'string',
7867
+ example: 'CNY'
7868
+ },
7869
+ rate: {
7870
+ type: 'string',
7871
+ description: 'FX rate (Decimal string)',
7872
+ example: '7.2'
7873
+ },
7874
+ date: {
7875
+ type: 'string',
7876
+ description: 'Rate date (ISO 8601)',
7877
+ example: '2024-01-15'
6856
7878
  }
6857
7879
  },
6858
- required: ['items', 'total']
7880
+ required: ['from', 'to', 'rate', 'date']
6859
7881
  } as const;
6860
7882
 
6861
- export const $UpdateBeanPriceDto = {
7883
+ export const $HoldingPnlRowDto = {
6862
7884
  type: 'object',
6863
7885
  properties: {
6864
- currency: {
7886
+ accountId: {
6865
7887
  type: 'string',
6866
- description: 'Currency being priced'
7888
+ description: 'Account UUID',
7889
+ example: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
7890
+ },
7891
+ accountPath: {
7892
+ type: 'string',
7893
+ description: 'Full account path',
7894
+ example: 'Assets:US:Broker:AAPL'
7895
+ },
7896
+ accountCcy: {
7897
+ type: 'object',
7898
+ description: 'Account settlement currency (ISO 4217), from cost currency',
7899
+ nullable: true,
7900
+ example: 'USD'
7901
+ },
7902
+ brokerType: {
7903
+ type: 'object',
7904
+ description: 'Broker type derived from Platform.type',
7905
+ nullable: true,
7906
+ example: 'broker'
7907
+ },
7908
+ symbol: {
7909
+ type: 'string',
7910
+ description: 'Commodity symbol',
7911
+ example: 'AAPL'
7912
+ },
7913
+ chartToken: {
7914
+ type: 'string',
7915
+ description: 'Chart segment token (libs/common resolver)',
7916
+ example: 'equity',
7917
+ enum: ['equity', 'fund', 'bond', 'cash', 'other']
7918
+ },
7919
+ assetClass: {
7920
+ type: 'string',
7921
+ example: 'EQUITY'
7922
+ },
7923
+ assetSubClass: {
7924
+ type: 'object',
7925
+ nullable: true,
7926
+ example: 'STOCK'
7927
+ },
7928
+ units: {
7929
+ type: 'string',
7930
+ description: 'Net held units (Decimal string)',
7931
+ example: '12'
7932
+ },
7933
+ averageCostPerUnit: {
7934
+ description:
7935
+ 'Average cost per unit; null when cost currency conflicts or no cost',
7936
+ nullable: true,
7937
+ allOf: [
7938
+ {
7939
+ $ref: '#/components/schemas/MonetaryDto'
7940
+ }
7941
+ ]
7942
+ },
7943
+ costBasis: {
7944
+ description: 'Cost basis of held units',
7945
+ nullable: true,
7946
+ allOf: [
7947
+ {
7948
+ $ref: '#/components/schemas/MonetaryDto'
7949
+ }
7950
+ ]
6867
7951
  },
6868
- quoteCurrency: {
6869
- type: 'string',
6870
- description: 'Quote currency (pricing currency)'
7952
+ marketValue: {
7953
+ description: 'Market value at asOf price',
7954
+ nullable: true,
7955
+ allOf: [
7956
+ {
7957
+ $ref: '#/components/schemas/MonetaryDto'
7958
+ }
7959
+ ]
6871
7960
  },
6872
- amount: {
6873
- type: 'number',
6874
- description: 'Price amount (MUST be >= 0 per Beancount spec)',
6875
- minimum: 0
7961
+ currentPrice: {
7962
+ description: 'Price used for market value',
7963
+ nullable: true,
7964
+ allOf: [
7965
+ {
7966
+ $ref: '#/components/schemas/CurrentPriceDto'
7967
+ }
7968
+ ]
6876
7969
  },
6877
- date: {
6878
- type: 'string',
6879
- description: 'Price date (ISO 8601 format)'
7970
+ unrealizedPnlBase: {
7971
+ type: 'object',
7972
+ description:
7973
+ 'Unrealized P&L in base currency (Decimal string); null when any FX/price missing',
7974
+ nullable: true,
7975
+ example: '6000'
6880
7976
  },
6881
- metadata: {
7977
+ unrealizedPnlPct: {
6882
7978
  type: 'object',
6883
- description: 'Metadata'
6884
- }
6885
- }
6886
- } as const;
6887
-
6888
- export const $CurrencyBalanceDto = {
6889
- type: 'object',
6890
- properties: {
6891
- currency: {
6892
- type: 'string',
6893
- description: 'ISO 4217 currency code',
6894
- example: 'CNY'
7979
+ description: 'Unrealized P&L % (Decimal string)',
7980
+ nullable: true,
7981
+ example: '25'
6895
7982
  },
6896
- balance: {
6897
- type: 'string',
6898
- description: 'Balance amount',
6899
- example: '500000.00'
6900
- }
6901
- },
6902
- required: ['currency', 'balance']
6903
- } as const;
6904
-
6905
- export const $TimeSeriesPointDto = {
6906
- type: 'object',
6907
- properties: {
6908
- date: {
6909
- type: 'string',
6910
- description: 'Date in YYYY-MM-DD format',
6911
- example: '2024-06-15'
7983
+ costFxRate: {
7984
+ description: 'Historical FX rate applied to cost basis',
7985
+ nullable: true,
7986
+ allOf: [
7987
+ {
7988
+ $ref: '#/components/schemas/FxRateDto'
7989
+ }
7990
+ ]
6912
7991
  },
6913
- value: {
6914
- type: 'string',
6915
- description: 'Value at this date (in base currency)',
6916
- example: '500000.00'
7992
+ marketFxRate: {
7993
+ description: 'FX rate applied to market value',
7994
+ nullable: true,
7995
+ allOf: [
7996
+ {
7997
+ $ref: '#/components/schemas/FxRateDto'
7998
+ }
7999
+ ]
6917
8000
  },
6918
- change: {
8001
+ pctOfInvestedAssets: {
6919
8002
  type: 'object',
6920
- description: 'Change from previous point',
6921
- example: '5000.00'
8003
+ description:
8004
+ 'Share of invested assets % (Decimal string); only for invested chartTokens',
8005
+ nullable: true,
8006
+ example: '40'
6922
8007
  },
6923
- byCurrency: {
6924
- description: 'Multi-currency breakdown for this point',
6925
- type: 'array',
6926
- items: {
6927
- $ref: '#/components/schemas/CurrencyBalanceDto'
6928
- }
8008
+ realizedPnl: {
8009
+ description:
8010
+ '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',
8011
+ nullable: true,
8012
+ allOf: [
8013
+ {
8014
+ $ref: '#/components/schemas/MonetaryDto'
8015
+ }
8016
+ ]
6929
8017
  }
6930
8018
  },
6931
- required: ['date', 'value']
8019
+ required: [
8020
+ 'accountId',
8021
+ 'accountPath',
8022
+ 'symbol',
8023
+ 'chartToken',
8024
+ 'assetClass',
8025
+ 'units'
8026
+ ]
6932
8027
  } as const;
6933
8028
 
6934
- export const $TrendSummaryDto = {
8029
+ export const $HoldingPnlWarningDto = {
6935
8030
  type: 'object',
6936
8031
  properties: {
6937
- startValue: {
6938
- type: 'string',
6939
- description: 'Value at start of period',
6940
- example: '450000.00'
6941
- },
6942
- endValue: {
8032
+ type: {
6943
8033
  type: 'string',
6944
- description: 'Value at end of period',
6945
- example: '500000.00'
8034
+ description: 'Warning type',
8035
+ example: 'MISSING_COST_FX_RATE',
8036
+ enum: [
8037
+ 'MISSING_COST_FX_RATE',
8038
+ 'MISSING_MARKET_FX_RATE',
8039
+ 'MISSING_SALE_PRICE',
8040
+ 'MISSING_REALIZED_FX_RATE',
8041
+ 'OVERSOLD_LOTS',
8042
+ 'NO_PRICE',
8043
+ 'MIXED_COST_CURRENCY'
8044
+ ]
6946
8045
  },
6947
- totalChange: {
6948
- type: 'string',
6949
- description: 'Total change over period',
6950
- example: '50000.00'
8046
+ symbol: {
8047
+ type: 'object',
8048
+ nullable: true
6951
8049
  },
6952
- totalChangePercentage: {
6953
- type: 'string',
6954
- description: 'Total change percentage',
6955
- example: '+11.11%'
6956
- }
6957
- },
6958
- required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
6959
- } as const;
6960
-
6961
- export const $MultiCurrencyPointDto = {
6962
- type: 'object',
6963
- properties: {
6964
- date: {
6965
- type: 'string',
6966
- description: 'Date in YYYY-MM-DD format',
6967
- example: '2024-06-15'
8050
+ accountId: {
8051
+ type: 'object',
8052
+ nullable: true
6968
8053
  },
6969
- byCurrency: {
6970
- description: 'Balances by currency',
6971
- type: 'array',
6972
- items: {
6973
- $ref: '#/components/schemas/CurrencyBalanceDto'
6974
- }
8054
+ currency: {
8055
+ type: 'object',
8056
+ nullable: true
6975
8057
  }
6976
8058
  },
6977
- required: ['date', 'byCurrency']
8059
+ required: ['type']
6978
8060
  } as const;
6979
8061
 
6980
- export const $PortfolioTrendsResponseDto = {
8062
+ export const $HoldingPnlResponseDto = {
6981
8063
  type: 'object',
6982
8064
  properties: {
6983
- series: {
6984
- description: 'Time series data points',
6985
- type: 'array',
6986
- items: {
6987
- $ref: '#/components/schemas/TimeSeriesPointDto'
6988
- }
6989
- },
6990
- summary: {
6991
- description: 'Period summary',
6992
- allOf: [
6993
- {
6994
- $ref: '#/components/schemas/TrendSummaryDto'
6995
- }
6996
- ]
6997
- },
6998
- period: {
6999
- type: 'string',
7000
- description: 'Period requested',
7001
- example: '6m'
7002
- },
7003
- granularity: {
8065
+ asOfDate: {
7004
8066
  type: 'string',
7005
- description: 'Data granularity',
7006
- example: 'month'
8067
+ example: '2026-07-08'
7007
8068
  },
7008
- currency: {
8069
+ baseCurrency: {
7009
8070
  type: 'string',
7010
- description: 'Base currency for converted values',
7011
8071
  example: 'CNY'
7012
8072
  },
7013
- byCurrency: {
8073
+ method: {
8074
+ type: 'string',
7014
8075
  description:
7015
- 'Multi-currency time series (each point has currency breakdown)',
8076
+ 'Realized-P&L lot-matching method (FIFO or average). Unrealized cost basis remains average regardless of this value (#473).',
8077
+ enum: ['average', 'FIFO'],
8078
+ example: 'average'
8079
+ },
8080
+ rows: {
7016
8081
  type: 'array',
7017
8082
  items: {
7018
- $ref: '#/components/schemas/MultiCurrencyPointDto'
8083
+ $ref: '#/components/schemas/HoldingPnlRowDto'
7019
8084
  }
7020
8085
  },
7021
8086
  warnings: {
7022
- description: 'Exchange rate warnings',
7023
8087
  type: 'array',
7024
8088
  items: {
7025
- $ref: '#/components/schemas/ExchangeRateWarningDto'
8089
+ $ref: '#/components/schemas/HoldingPnlWarningDto'
7026
8090
  }
7027
8091
  }
7028
8092
  },
7029
- required: ['series', 'summary', 'period', 'granularity', 'currency']
7030
- } as const;
7031
-
7032
- export const $GenerateSnapshotBody = {
7033
- type: 'object',
7034
- properties: {}
7035
- } as const;
7036
-
7037
- export const $GenerateSnapshotResponse = {
7038
- type: 'object',
7039
- properties: {}
7040
- } as const;
7041
-
7042
- export const $BackfillSnapshotsBody = {
7043
- type: 'object',
7044
- properties: {}
7045
- } as const;
7046
-
7047
- export const $BackfillSnapshotsResponse = {
7048
- type: 'object',
7049
- properties: {}
8093
+ required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
7050
8094
  } as const;
7051
8095
 
7052
8096
  export const $AnonymousLoginDto = {
@@ -7059,3 +8103,15 @@ export const $AnonymousLoginDto = {
7059
8103
  },
7060
8104
  required: ['accessToken']
7061
8105
  } as const;
8106
+
8107
+ export const $AnonymousLoginResponseDto = {
8108
+ type: 'object',
8109
+ properties: {
8110
+ authToken: {
8111
+ type: 'string',
8112
+ description: 'JWT auth token',
8113
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
8114
+ }
8115
+ },
8116
+ required: ['authToken']
8117
+ } as const;