@firela/api-types 0.0.0-canary.8c68ebbe → 0.0.0-canary.92035f3d

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',
@@ -692,7 +731,7 @@ export const $PostingResponseDto = {
692
731
  account: {
693
732
  type: 'string',
694
733
  description: 'Account name',
695
- example: 'Assets:Bank:Checking'
734
+ example: 'Assets:Checking'
696
735
  },
697
736
  units: {
698
737
  type: 'string',
@@ -1058,7 +1097,7 @@ export const $PostingDetailDto = {
1058
1097
  account: {
1059
1098
  type: 'string',
1060
1099
  description: 'Fully-qualified Beancount account path',
1061
- example: 'Assets:Bank:Checking'
1100
+ example: 'Assets:Checking'
1062
1101
  },
1063
1102
  units: {
1064
1103
  type: 'string',
@@ -1247,6 +1286,77 @@ export const $TransactionDetailDto = {
1247
1286
  ]
1248
1287
  } as const;
1249
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
+
1250
1360
  export const $TransactionListResponseDto = {
1251
1361
  type: 'object',
1252
1362
  properties: {
@@ -1271,6 +1381,15 @@ export const $TransactionListResponseDto = {
1271
1381
  type: 'number',
1272
1382
  description: 'Number of items skipped',
1273
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
+ ]
1274
1393
  }
1275
1394
  },
1276
1395
  required: ['data', 'total', 'limit', 'offset']
@@ -1370,7 +1489,7 @@ export const $BalanceResponseDto = {
1370
1489
  account: {
1371
1490
  type: 'string',
1372
1491
  description: 'Account name',
1373
- example: 'Assets:Bank:Checking'
1492
+ example: 'Assets:Checking'
1374
1493
  },
1375
1494
  balance: {
1376
1495
  type: 'string',
@@ -1397,7 +1516,7 @@ export const $MultiCurrencyBalanceResponseDto = {
1397
1516
  account: {
1398
1517
  type: 'string',
1399
1518
  description: 'Account name',
1400
- example: 'Assets:Bank:Checking'
1519
+ example: 'Assets:Checking'
1401
1520
  },
1402
1521
  balances: {
1403
1522
  type: 'object',
@@ -1453,7 +1572,7 @@ export const $TransactionSummaryDto = {
1453
1572
  accountName: {
1454
1573
  type: 'string',
1455
1574
  description: 'Source account name (first posting)',
1456
- example: 'Assets:Bank:Checking'
1575
+ example: 'Assets:Checking'
1457
1576
  },
1458
1577
  sourceType: {
1459
1578
  type: 'string',
@@ -2745,117 +2864,274 @@ export const $UpdateCommodityDto = {
2745
2864
  }
2746
2865
  } as const;
2747
2866
 
2748
- export const $CreateRecurringRuleDto = {
2867
+ export const $CreateBeanPriceDto = {
2749
2868
  type: 'object',
2750
2869
  properties: {
2751
- name: {
2752
- type: 'string',
2753
- description: 'Rule name (unique per user)',
2754
- maxLength: 100
2755
- },
2756
- icon: {
2757
- type: 'string',
2758
- description: 'Icon emoji',
2759
- maxLength: 10
2760
- },
2761
- frequency: {
2762
- type: 'string',
2763
- description: 'Recurring frequency',
2764
- enum: [
2765
- 'WEEKLY',
2766
- 'BIWEEKLY',
2767
- 'MONTHLY',
2768
- 'BIMONTHLY',
2769
- 'QUARTERLY',
2770
- 'YEARLY',
2771
- 'CUSTOM'
2772
- ]
2773
- },
2774
- expectedAmount: {
2775
- type: 'number',
2776
- description: 'Expected amount (positive number)',
2777
- minimum: 0
2778
- },
2779
- expectedDay: {
2780
- type: 'number',
2781
- description: 'Expected day of month (1-31)',
2782
- minimum: 1,
2783
- maximum: 31
2784
- },
2785
- customIntervalDays: {
2786
- type: 'number',
2787
- description: 'Custom interval in days (required for CUSTOM frequency)',
2788
- minimum: 1
2789
- },
2790
2870
  currency: {
2791
2871
  type: 'string',
2792
- description: 'Currency code',
2793
- default: 'CNY',
2794
- maxLength: 10
2872
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2873
+ example: 'USD'
2795
2874
  },
2796
- matchPayeePattern: {
2875
+ quoteCurrency: {
2797
2876
  type: 'string',
2798
- description: 'Payee matching pattern (supports wildcards)',
2799
- maxLength: 200
2877
+ description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
2878
+ example: 'CNY'
2800
2879
  },
2801
- matchAmountTolerance: {
2880
+ amount: {
2802
2881
  type: 'number',
2803
- description: 'Amount tolerance percentage (0-1)',
2804
- default: 0.075,
2805
- minimum: 0,
2806
- maximum: 1
2807
- },
2808
- defaultExpenseAccount: {
2809
- type: 'string',
2810
- description: 'Default expense account for auto-create',
2811
- maxLength: 200
2812
- },
2813
- defaultPaymentAccount: {
2814
- type: 'string',
2815
- description: 'Default payment account for auto-create',
2816
- maxLength: 200
2817
- },
2818
- defaultPayee: {
2819
- type: 'string',
2820
- description: 'Default payee for auto-create',
2821
- maxLength: 200
2822
- },
2823
- autoCreate: {
2824
- type: 'boolean',
2825
- description: 'Auto-create transaction when expected date arrives',
2826
- default: false
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,
2885
+ minimum: 0
2827
2886
  },
2828
- startDate: {
2887
+ date: {
2829
2888
  type: 'string',
2830
- description: 'Rule start date (ISO format)'
2889
+ description: 'Price date (ISO 8601 format)',
2890
+ example: '2024-11-05'
2831
2891
  },
2832
- endDate: {
2833
- type: 'string',
2834
- description: 'Rule end date (ISO format)'
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
+ }
2835
2901
  }
2836
2902
  },
2837
- required: [
2838
- 'name',
2839
- 'frequency',
2840
- 'expectedAmount',
2841
- 'currency',
2842
- 'matchAmountTolerance',
2843
- 'autoCreate'
2844
- ]
2903
+ required: ['currency', 'quoteCurrency', 'amount', 'date']
2845
2904
  } as const;
2846
2905
 
2847
- export const $RecurringRuleResponseDto = {
2906
+ export const $PriceResponseDto = {
2848
2907
  type: 'object',
2849
2908
  properties: {
2850
2909
  id: {
2851
2910
  type: 'string',
2852
- description: 'Rule ID'
2911
+ description: 'Unique identifier',
2912
+ example: 'uuid-123-456'
2853
2913
  },
2854
2914
  userId: {
2855
2915
  type: 'string',
2856
- description: 'User ID'
2916
+ description: 'User ID (owner of the price)',
2917
+ example: 'user-123'
2857
2918
  },
2858
- name: {
2919
+ currency: {
2920
+ type: 'string',
2921
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2922
+ example: 'BTC'
2923
+ },
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: {
3078
+ type: 'number',
3079
+ description: 'Amount tolerance percentage (0-1)',
3080
+ default: 0.075,
3081
+ minimum: 0,
3082
+ maximum: 1
3083
+ },
3084
+ defaultExpenseAccount: {
3085
+ type: 'string',
3086
+ description: 'Default expense account for auto-create',
3087
+ maxLength: 200
3088
+ },
3089
+ defaultPaymentAccount: {
3090
+ type: 'string',
3091
+ description: 'Default payment account for auto-create',
3092
+ maxLength: 200
3093
+ },
3094
+ defaultPayee: {
3095
+ type: 'string',
3096
+ description: 'Default payee for auto-create',
3097
+ maxLength: 200
3098
+ },
3099
+ autoCreate: {
3100
+ type: 'boolean',
3101
+ description: 'Auto-create transaction when expected date arrives',
3102
+ default: false
3103
+ },
3104
+ startDate: {
3105
+ type: 'string',
3106
+ description: 'Rule start date (ISO format)'
3107
+ },
3108
+ endDate: {
3109
+ type: 'string',
3110
+ description: 'Rule end date (ISO format)'
3111
+ }
3112
+ },
3113
+ required: [
3114
+ 'name',
3115
+ 'frequency',
3116
+ 'expectedAmount',
3117
+ 'currency',
3118
+ 'matchAmountTolerance',
3119
+ 'autoCreate'
3120
+ ]
3121
+ } as const;
3122
+
3123
+ export const $RecurringRuleResponseDto = {
3124
+ type: 'object',
3125
+ properties: {
3126
+ id: {
3127
+ type: 'string',
3128
+ description: 'Rule ID'
3129
+ },
3130
+ userId: {
3131
+ type: 'string',
3132
+ description: 'User ID'
3133
+ },
3134
+ name: {
2859
3135
  type: 'string',
2860
3136
  description: 'Rule name'
2861
3137
  },
@@ -3516,30 +3792,477 @@ export const $ForecastResponseDto = {
3516
3792
  ]
3517
3793
  } as const;
3518
3794
 
3519
- export const $CreateTransactionRuleDto = {
3795
+ export const $CurrencyBalanceDto = {
3520
3796
  type: 'object',
3521
3797
  properties: {
3522
- name: {
3798
+ currency: {
3523
3799
  type: 'string',
3524
- minLength: 1,
3525
- maxLength: 100
3800
+ description: 'ISO 4217 currency code',
3801
+ example: 'CNY'
3526
3802
  },
3527
- description: {
3803
+ balance: {
3528
3804
  type: 'string',
3529
- maxLength: 500
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'
3530
3819
  },
3531
- narrationKeywords: {
3532
- items: {
3533
- type: 'array'
3534
- },
3535
- maxItems: 50,
3536
- type: 'array'
3820
+ value: {
3821
+ type: 'string',
3822
+ description: 'Value at this date (in base currency)',
3823
+ example: '500000.00'
3537
3824
  },
3538
- payeeKeywords: {
3539
- items: {
3540
- type: 'array'
3541
- },
3542
- maxItems: 50,
3825
+ change: {
3826
+ type: 'object',
3827
+ description: 'Change from previous point',
3828
+ example: '5000.00'
3829
+ },
3830
+ assets: {
3831
+ type: 'string',
3832
+ description: 'Total assets at this date (in base currency)',
3833
+ example: '494338.00'
3834
+ },
3835
+ liabilities: {
3836
+ type: 'string',
3837
+ description: 'Total liabilities at this date (in base currency)',
3838
+ example: '310098.00'
3839
+ },
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: {
3855
+ type: 'string',
3856
+ description: 'Value at start of period',
3857
+ example: '450000.00'
3858
+ },
3859
+ endValue: {
3860
+ type: 'string',
3861
+ description: 'Value at end of period',
3862
+ example: '500000.00'
3863
+ },
3864
+ totalChange: {
3865
+ type: 'string',
3866
+ description: 'Total change over period',
3867
+ example: '50000.00'
3868
+ },
3869
+ totalChangePercentage: {
3870
+ type: 'string',
3871
+ description: 'Total change percentage',
3872
+ example: '+11.11%'
3873
+ }
3874
+ },
3875
+ required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
3876
+ } as const;
3877
+
3878
+ export const $MultiCurrencyPointDto = {
3879
+ type: 'object',
3880
+ properties: {
3881
+ date: {
3882
+ type: 'string',
3883
+ description: 'Date in YYYY-MM-DD format',
3884
+ example: '2024-06-15'
3885
+ },
3886
+ byCurrency: {
3887
+ description: 'Balances by currency',
3888
+ type: 'array',
3889
+ items: {
3890
+ $ref: '#/components/schemas/CurrencyBalanceDto'
3891
+ }
3892
+ }
3893
+ },
3894
+ required: ['date', 'byCurrency']
3895
+ } as const;
3896
+
3897
+ export const $PortfolioTrendsResponseDto = {
3898
+ type: 'object',
3899
+ properties: {
3900
+ series: {
3901
+ description: 'Time series data points',
3902
+ type: 'array',
3903
+ items: {
3904
+ $ref: '#/components/schemas/TimeSeriesPointDto'
3905
+ }
3906
+ },
3907
+ summary: {
3908
+ description: 'Period summary',
3909
+ allOf: [
3910
+ {
3911
+ $ref: '#/components/schemas/TrendSummaryDto'
3912
+ }
3913
+ ]
3914
+ },
3915
+ period: {
3916
+ type: 'string',
3917
+ description: 'Period requested',
3918
+ example: '6m'
3919
+ },
3920
+ granularity: {
3921
+ type: 'string',
3922
+ description: 'Data granularity',
3923
+ example: 'month'
3924
+ },
3925
+ currency: {
3926
+ type: 'string',
3927
+ description: 'Base currency for converted values',
3928
+ example: 'CNY'
3929
+ },
3930
+ byCurrency: {
3931
+ description:
3932
+ 'Multi-currency time series (each point has currency breakdown)',
3933
+ type: 'array',
3934
+ items: {
3935
+ $ref: '#/components/schemas/MultiCurrencyPointDto'
3936
+ }
3937
+ },
3938
+ warnings: {
3939
+ description: 'Exchange rate warnings',
3940
+ type: 'array',
3941
+ items: {
3942
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
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'
3956
+ },
3957
+ income: {
3958
+ type: 'string',
3959
+ description: 'Income in base currency (absolute, converted)',
3960
+ example: '10000.00'
3961
+ },
3962
+ expense: {
3963
+ type: 'string',
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'
3971
+ }
3972
+ },
3973
+ required: ['month', 'income', 'expense', 'netSavings']
3974
+ } as const;
3975
+
3976
+ export const $CashFlowTrendSummaryDto = {
3977
+ type: 'object',
3978
+ properties: {
3979
+ totalIncome: {
3980
+ type: 'string',
3981
+ description: 'Total income across the period',
3982
+ example: '60000.00'
3983
+ },
3984
+ totalExpense: {
3985
+ type: 'string',
3986
+ description: 'Total expense across the period',
3987
+ example: '30000.00'
3988
+ },
3989
+ totalNetSavings: {
3990
+ type: 'string',
3991
+ description: 'income − expense across the period',
3992
+ example: '30000.00'
3993
+ },
3994
+ averageMonthlyNetSavings: {
3995
+ type: 'string',
3996
+ description:
3997
+ 'totalNetSavings divided by the window length (N months, incl. zero-filled)',
3998
+ example: '5000.00'
3999
+ }
4000
+ },
4001
+ required: [
4002
+ 'totalIncome',
4003
+ 'totalExpense',
4004
+ 'totalNetSavings',
4005
+ 'averageMonthlyNetSavings'
4006
+ ]
4007
+ } as const;
4008
+
4009
+ export const $CashFlowTrendsResponseDto = {
4010
+ type: 'object',
4011
+ properties: {
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: {
4029
+ type: 'string',
4030
+ description: 'Period requested',
4031
+ example: '6m'
4032
+ },
4033
+ granularity: {
4034
+ type: 'string',
4035
+ description: 'Data granularity (v1 returns month buckets)',
4036
+ example: 'month'
4037
+ },
4038
+ currency: {
4039
+ type: 'string',
4040
+ description: 'Base currency for converted values',
4041
+ example: 'CNY'
4042
+ },
4043
+ warnings: {
4044
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
4045
+ type: 'array',
4046
+ items: {
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,
3543
4266
  type: 'array'
3544
4267
  },
3545
4268
  categoryKeywords: {
@@ -4133,321 +4856,425 @@ export const $TestRuleDto = {
4133
4856
  maxLength: 10
4134
4857
  }
4135
4858
  },
4136
- required: ['narration']
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: {
4870
+ type: 'boolean',
4871
+ description: 'Whether the rule matched the test data'
4872
+ },
4873
+ confidence: {
4874
+ type: 'number',
4875
+ description: 'Match confidence score (0-1)',
4876
+ example: 0.85
4877
+ },
4878
+ matchDetails: {
4879
+ type: 'object',
4880
+ description: 'Details of which fields matched',
4881
+ example: {
4882
+ narration: true,
4883
+ payee: false,
4884
+ categoryAccount: false
4885
+ }
4886
+ }
4887
+ },
4888
+ required: ['ruleId', 'matches', 'confidence', 'matchDetails']
4889
+ } as const;
4890
+
4891
+ export const $CreateBeanEventDto = {
4892
+ type: 'object',
4893
+ properties: {
4894
+ date: {
4895
+ type: 'string',
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
+ }
4918
+ }
4919
+ },
4920
+ required: ['date', 'type', 'description']
4137
4921
  } as const;
4138
4922
 
4139
- export const $TestRuleResponseDto = {
4923
+ export const $EventResponseDto = {
4140
4924
  type: 'object',
4141
4925
  properties: {
4142
- ruleId: {
4926
+ id: {
4143
4927
  type: 'string',
4144
- description: 'Rule ID that was tested'
4928
+ description: 'Unique identifier',
4929
+ example: 'uuid-123-456'
4145
4930
  },
4146
- matches: {
4147
- type: 'boolean',
4148
- description: 'Whether the rule matched the test data'
4931
+ userId: {
4932
+ type: 'string',
4933
+ description: 'User ID (owner of the life event)',
4934
+ example: 'user-123'
4149
4935
  },
4150
- confidence: {
4151
- type: 'number',
4152
- description: 'Match confidence score (0-1)',
4153
- example: 0.85
4936
+ date: {
4937
+ type: 'string',
4938
+ description: 'Life event date (ISO 8601 format)',
4939
+ example: '2024-03-15',
4940
+ format: 'date'
4154
4941
  },
4155
- matchDetails: {
4942
+ type: {
4943
+ type: 'string',
4944
+ description:
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: {
4156
4955
  type: 'object',
4157
- description: 'Details of which fields matched',
4956
+ description: 'Product-side metadata (free-form JSON)',
4158
4957
  example: {
4159
- narration: true,
4160
- payee: false,
4161
- categoryAccount: false
4958
+ note: 'Promotion'
4162
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'
4163
4973
  }
4164
4974
  },
4165
- required: ['ruleId', 'matches', 'confidence', 'matchDetails']
4975
+ required: [
4976
+ 'id',
4977
+ 'userId',
4978
+ 'date',
4979
+ 'type',
4980
+ 'description',
4981
+ 'meta',
4982
+ 'createdAt',
4983
+ 'updatedAt'
4984
+ ]
4166
4985
  } as const;
4167
4986
 
4168
- export const $DeleteOwnUserDto = {
4987
+ export const $EventListResponseDto = {
4169
4988
  type: 'object',
4170
4989
  properties: {
4171
- accessToken: {
4172
- type: 'string',
4173
- description: 'Access token for user verification',
4174
- example: 'abc123xyz'
4990
+ items: {
4991
+ description: 'List of life events',
4992
+ type: 'array',
4993
+ items: {
4994
+ $ref: '#/components/schemas/EventResponseDto'
4995
+ }
4996
+ },
4997
+ total: {
4998
+ type: 'number',
4999
+ description: 'Total number of life events matching the query',
5000
+ example: 42
4175
5001
  }
4176
5002
  },
4177
- required: ['accessToken']
5003
+ required: ['items', 'total']
4178
5004
  } as const;
4179
5005
 
4180
- export const $SignupDto = {
5006
+ export const $UpdateBeanEventDto = {
4181
5007
  type: 'object',
4182
5008
  properties: {
4183
- turnstileToken: {
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: {
4184
5018
  type: 'string',
4185
5019
  description:
4186
- 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
4187
- example: '0.abc123def456...'
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)'
4188
5025
  }
4189
5026
  }
4190
5027
  } as const;
4191
5028
 
4192
- export const $UpdateUserSettingDto = {
5029
+ export const $OnboardingAccountDto = {
4193
5030
  type: 'object',
4194
5031
  properties: {
4195
- secId: {
4196
- type: 'number',
4197
- description: 'Security ID'
4198
- },
4199
- annualInterestRate: {
4200
- type: 'number',
4201
- description: 'Annual interest rate',
4202
- example: 0.05
4203
- },
4204
- currency: {
5032
+ path: {
4205
5033
  type: 'string',
4206
- description: 'Currency code',
4207
- example: 'USD'
5034
+ description:
5035
+ 'Account path (Assets/Liabilities only; format validated by the account service)',
5036
+ example: 'Assets:Checking'
4208
5037
  },
4209
- baseCurrency: {
5038
+ currency: {
4210
5039
  type: 'string',
4211
- description: 'Base currency code',
5040
+ description: 'ISO 4217 currency code (3 letters)',
4212
5041
  example: 'USD'
4213
5042
  },
4214
- benchmark: {
4215
- type: 'string',
4216
- description: 'Benchmark symbol',
4217
- example: 'SPY'
4218
- },
4219
- colorScheme: {
5043
+ openingBalance: {
4220
5044
  type: 'string',
4221
- description: 'Color scheme',
4222
- enum: ['DARK', 'LIGHT']
5045
+ description:
5046
+ 'Opening balance as a non-negative Decimal string (e.g. "1000.00")',
5047
+ example: '1000.00'
4223
5048
  },
4224
- dateRange: {
5049
+ platformId: {
4225
5050
  type: 'string',
4226
- description: 'Date range filter',
4227
- example: '1y'
4228
- },
4229
- emergencyFund: {
4230
- type: 'number',
4231
- description: 'Emergency fund amount',
4232
- example: 10000
4233
- },
4234
- 'filters.accounts': {
4235
- description: 'Account filter IDs',
4236
- type: 'array',
4237
- items: {
4238
- type: 'string'
4239
- }
4240
- },
4241
- 'filters.assetClasses': {
4242
- description: 'Asset class filters',
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',
4243
5064
  type: 'array',
4244
5065
  items: {
4245
- type: 'string'
5066
+ $ref: '#/components/schemas/OnboardingAccountDto'
4246
5067
  }
4247
5068
  },
4248
- 'filters.dataSource': {
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: {
4249
5082
  type: 'string',
4250
- description: 'Data source filter'
5083
+ description:
5084
+ 'Actual balance amount as a decimal string (preserves precision for tolerance inference).',
5085
+ example: '1234.56'
4251
5086
  },
4252
- 'filters.symbol': {
5087
+ ccy: {
4253
5088
  type: 'string',
4254
- description: 'Symbol filter'
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.'
4255
5102
  },
4256
- 'filters.tags': {
4257
- description: 'Tag filters',
4258
- type: 'array',
4259
- items: {
4260
- type: 'string'
4261
- }
5103
+ asOfDate: {
5104
+ type: 'string',
5105
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5106
+ example: '2026-07-24'
4262
5107
  },
4263
- isExperimentalFeatures: {
4264
- type: 'boolean',
4265
- description: 'Enable experimental features'
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'
4266
5125
  },
4267
- isRestrictedView: {
4268
- type: 'boolean',
4269
- description: 'Enable restricted view mode'
5126
+ asOfDate: {
5127
+ type: 'string'
4270
5128
  },
4271
- language: {
5129
+ bookBalance: {
4272
5130
  type: 'string',
4273
- description: 'Language code',
4274
- example: 'en'
5131
+ description: 'System-computed book balance (decimal string).'
4275
5132
  },
4276
- locale: {
5133
+ actualBalance: {
4277
5134
  type: 'string',
4278
- description: 'Locale code',
4279
- example: 'en-US'
5135
+ description: 'User-entered actual balance (decimal string).'
4280
5136
  },
4281
- projectedTotalAmount: {
4282
- type: 'number',
4283
- description: 'Projected total amount',
4284
- example: 1000000
5137
+ currency: {
5138
+ type: 'string'
4285
5139
  },
4286
- retirementDate: {
5140
+ diff: {
4287
5141
  type: 'string',
4288
- description: 'Retirement date in ISO 8601 format',
4289
- example: '2050-01-01'
5142
+ description: 'Diff = book − actual (decimal string).'
4290
5143
  },
4291
- savingsRate: {
4292
- type: 'number',
4293
- description: 'Savings rate percentage',
4294
- example: 0.2
4295
- },
4296
- viewMode: {
5144
+ tolerance: {
4297
5145
  type: 'string',
4298
- description: 'View mode',
4299
- enum: ['DEFAULT', 'ZEN']
4300
- }
4301
- }
4302
- } as const;
4303
-
4304
- export const $UpdatePropertyDto = {
4305
- type: 'object',
4306
- properties: {
4307
- value: {
5146
+ description: 'Applied tolerance (decimal string).'
5147
+ },
5148
+ withinTolerance: {
5149
+ type: 'boolean',
5150
+ description: 'true when |diff| ≤ tolerance.'
5151
+ },
5152
+ suggestedAction: {
4308
5153
  type: 'string',
4309
- description: 'Property value'
5154
+ enum: ['assert', 'pad'],
5155
+ description:
5156
+ 'Suggested next action: assert when within tolerance, pad otherwise.'
4310
5157
  }
4311
5158
  },
4312
- required: ['value']
5159
+ required: [
5160
+ 'accountId',
5161
+ 'asOfDate',
5162
+ 'bookBalance',
5163
+ 'actualBalance',
5164
+ 'currency',
5165
+ 'diff',
5166
+ 'tolerance',
5167
+ 'withinTolerance',
5168
+ 'suggestedAction'
5169
+ ]
4313
5170
  } as const;
4314
5171
 
4315
- export const $CreateBeanEventDto = {
5172
+ export const $AssertReconciliationDto = {
4316
5173
  type: 'object',
4317
5174
  properties: {
4318
- date: {
5175
+ accountId: {
4319
5176
  type: 'string',
4320
- description: 'Life event date (ISO 8601)',
4321
- example: '2024-03-15'
5177
+ description: 'BeanAccount id to reconcile.'
4322
5178
  },
4323
- type: {
5179
+ asOfDate: {
4324
5180
  type: 'string',
4325
- description:
4326
- 'Life event type (e.g., "employer", "location", "marital-status") — user-defined, no enum constraint at engine layer',
4327
- example: 'employer'
5181
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5182
+ example: '2026-07-24'
4328
5183
  },
4329
- description: {
4330
- type: 'string',
4331
- description:
4332
- 'Life event description. Empty string is a VALID value (distinct from absence).',
4333
- example: 'Acme Corp'
5184
+ actualBalance: {
5185
+ description: 'Actual balance from the external statement.',
5186
+ allOf: [
5187
+ {
5188
+ $ref: '#/components/schemas/ActualBalanceDto'
5189
+ }
5190
+ ]
4334
5191
  },
4335
- meta: {
4336
- type: 'object',
5192
+ tolerance: {
5193
+ type: 'string',
4337
5194
  description:
4338
- 'Product-side metadata (lives in BeanEvent.meta JSON, never in engine Event fields)',
4339
- example: {
4340
- note: 'Promotion'
4341
- }
5195
+ 'Optional explicit tolerance override. Omit to infer from amount precision (Beancount default).',
5196
+ example: '0.01'
4342
5197
  }
4343
5198
  },
4344
- required: ['date', 'type', 'description']
5199
+ required: ['accountId', 'asOfDate', 'actualBalance']
4345
5200
  } as const;
4346
5201
 
4347
- export const $EventResponseDto = {
5202
+ export const $ReconciliationRecordDto = {
4348
5203
  type: 'object',
4349
5204
  properties: {
4350
5205
  id: {
4351
- type: 'string',
4352
- description: 'Unique identifier',
4353
- example: 'uuid-123-456'
5206
+ type: 'string'
4354
5207
  },
4355
- userId: {
4356
- type: 'string',
4357
- description: 'User ID (owner of the life event)',
4358
- example: 'user-123'
5208
+ accountId: {
5209
+ type: 'string'
4359
5210
  },
4360
5211
  date: {
4361
- type: 'string',
4362
- description: 'Life event date (ISO 8601 format)',
4363
- example: '2024-03-15',
4364
- format: 'date'
5212
+ type: 'string'
4365
5213
  },
4366
- type: {
5214
+ amount: {
4367
5215
  type: 'string',
4368
- description:
4369
- 'Life event type (user-defined, e.g., "employer", "location")',
4370
- example: 'employer'
5216
+ description: 'Asserted (actual) amount.'
4371
5217
  },
4372
- description: {
4373
- type: 'string',
4374
- description:
4375
- 'Life event description. May be an empty string (a valid value distinct from absence).',
4376
- example: 'Acme Corp'
5218
+ currency: {
5219
+ type: 'string'
4377
5220
  },
4378
- meta: {
4379
- type: 'object',
4380
- description: 'Product-side metadata (free-form JSON)',
4381
- example: {
4382
- note: 'Promotion'
4383
- }
5221
+ tolerance: {
5222
+ type: 'string'
4384
5223
  },
4385
- createdAt: {
4386
- format: 'date-time',
5224
+ diffAmount: {
4387
5225
  type: 'string',
4388
- description: 'Creation timestamp',
4389
- example: '2024-03-15T10:00:00Z'
5226
+ description: 'book − actual.'
4390
5227
  },
4391
- updatedAt: {
4392
- format: 'date-time',
4393
- type: 'string',
4394
- description:
4395
- 'Last update timestamp. Also emitted as the ETag response header for If-Match optimistic concurrency.',
4396
- example: '2024-03-15T10:00:00Z'
5228
+ diffCurrency: {
5229
+ type: 'string'
5230
+ },
5231
+ createdAt: {
5232
+ type: 'string'
4397
5233
  }
4398
5234
  },
4399
- required: [
4400
- 'id',
4401
- 'userId',
4402
- 'date',
4403
- 'type',
4404
- 'description',
4405
- 'meta',
4406
- 'createdAt',
4407
- 'updatedAt'
4408
- ]
5235
+ required: ['id', 'accountId', 'date', 'amount', 'currency', 'createdAt']
4409
5236
  } as const;
4410
5237
 
4411
- export const $EventListResponseDto = {
5238
+ export const $PadReconciliationDto = {
4412
5239
  type: 'object',
4413
5240
  properties: {
4414
- items: {
4415
- description: 'List of life events',
4416
- type: 'array',
4417
- items: {
4418
- $ref: '#/components/schemas/EventResponseDto'
4419
- }
5241
+ accountId: {
5242
+ type: 'string',
5243
+ description: 'BeanAccount id to reconcile.'
4420
5244
  },
4421
- total: {
4422
- type: 'number',
4423
- description: 'Total number of life events matching the query',
4424
- example: 42
5245
+ asOfDate: {
5246
+ type: 'string',
5247
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
5248
+ example: '2026-07-24'
5249
+ },
5250
+ actualBalance: {
5251
+ description: 'Actual balance from the external statement.',
5252
+ allOf: [
5253
+ {
5254
+ $ref: '#/components/schemas/ActualBalanceDto'
5255
+ }
5256
+ ]
5257
+ },
5258
+ sourceAccount: {
5259
+ type: 'string',
5260
+ description:
5261
+ 'Pad source account. Defaults to Equity:Opening-Balances (official Beancount convention).',
5262
+ example: 'Equity:Opening-Balances',
5263
+ default: 'Equity:Opening-Balances'
4425
5264
  }
4426
5265
  },
4427
- required: ['items', 'total']
5266
+ required: ['accountId', 'asOfDate', 'actualBalance']
4428
5267
  } as const;
4429
5268
 
4430
- export const $UpdateBeanEventDto = {
5269
+ export const $PadResultDto = {
4431
5270
  type: 'object',
4432
5271
  properties: {
4433
- date: {
4434
- type: 'string',
4435
- description: 'Life event date (ISO 8601)'
4436
- },
4437
- type: {
4438
- type: 'string',
4439
- description: 'Life event type (user-defined)'
4440
- },
4441
- description: {
5272
+ transactionId: {
4442
5273
  type: 'string',
4443
- description:
4444
- 'Life event description. Empty string is a VALID value (distinct from absence).'
4445
- },
4446
- meta: {
4447
- type: 'object',
4448
- description: 'Product-side metadata (free-form JSON)'
5274
+ description: 'Created pad adjusting transaction id.'
4449
5275
  }
4450
- }
5276
+ },
5277
+ required: ['transactionId']
4451
5278
  } as const;
4452
5279
 
4453
5280
  export const $FileImportDto = {
@@ -4616,7 +5443,7 @@ export const $IdentifyResultDto = {
4616
5443
  account: {
4617
5444
  type: 'string',
4618
5445
  description: 'Default account used by this importer',
4619
- example: 'Assets:Alipay:Balance'
5446
+ example: 'Assets:CN:Alipay:Balance'
4620
5447
  },
4621
5448
  message: {
4622
5449
  type: 'string',
@@ -4633,7 +5460,7 @@ export const $MapperDefaultsDto = {
4633
5460
  sourceAccount: {
4634
5461
  type: 'string',
4635
5462
  description: 'Source account for transactions (Beancount format)',
4636
- example: 'Assets:Alipay:Balance'
5463
+ example: 'Assets:CN:Alipay:Balance'
4637
5464
  },
4638
5465
  currency: {
4639
5466
  type: 'string',
@@ -4670,7 +5497,7 @@ export const $MapperDefaultsDto = {
4670
5497
  description:
4671
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).',
4672
5499
  example: {
4673
- HuaBei: 'Liabilities:Alipay:Huabei',
5500
+ HuaBei: 'Liabilities:CN:CreditLine',
4674
5501
  CreditCard: 'Liabilities:CreditCard'
4675
5502
  }
4676
5503
  }
@@ -4802,7 +5629,7 @@ export const $UpdateMapperDefaultsDto = {
4802
5629
  sourceAccount: {
4803
5630
  type: 'string',
4804
5631
  description: 'Source account for transactions (Beancount format)',
4805
- example: 'Assets:Alipay:Balance',
5632
+ example: 'Assets:CN:Alipay:Balance',
4806
5633
  pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4807
5634
  },
4808
5635
  currency: {
@@ -4830,7 +5657,7 @@ export const $UpdateMapperDefaultsDto = {
4830
5657
  description:
4831
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).',
4832
5659
  example: {
4833
- HuaBei: 'Liabilities:Alipay:Huabei',
5660
+ HuaBei: 'Liabilities:CN:CreditLine',
4834
5661
  CreditCard: 'Liabilities:CreditCard'
4835
5662
  }
4836
5663
  }
@@ -4844,129 +5671,23 @@ export const $UpdateConfigDataDto = {
4844
5671
  description: 'Mapper defaults configuration',
4845
5672
  allOf: [
4846
5673
  {
4847
- $ref: '#/components/schemas/UpdateMapperDefaultsDto'
4848
- }
4849
- ]
4850
- }
4851
- }
4852
- } as const;
4853
-
4854
- export const $UpdateImporterConfigDto = {
4855
- type: 'object',
4856
- properties: {
4857
- data: {
4858
- description: 'Configuration data (v1 schema)',
4859
- allOf: [
4860
- {
4861
- $ref: '#/components/schemas/UpdateConfigDataDto'
4862
- }
4863
- ]
4864
- }
4865
- }
4866
- } as const;
4867
-
4868
- export const $CreatePlatformDto = {
4869
- type: 'object',
4870
- properties: {
4871
- name: {
4872
- type: 'string',
4873
- description: 'Platform name',
4874
- example: 'Binance'
4875
- },
4876
- canonical: {
4877
- type: 'string',
4878
- description: 'Platform canonical identifier (lowercase, kebab-case)',
4879
- example: 'binance'
4880
- },
4881
- aliases: {
4882
- description: 'Platform aliases (multi-language names for lookup)',
4883
- example: ['Binance', 'Binance Exchange', 'BNB'],
4884
- type: 'array',
4885
- items: {
4886
- type: 'string'
4887
- }
4888
- },
4889
- url: {
4890
- type: 'string',
4891
- description: 'Platform URL',
4892
- example: 'https://www.binance.com'
4893
- },
4894
- type: {
4895
- type: 'string',
4896
- description: 'Platform type',
4897
- enum: [
4898
- 'BANK',
4899
- 'BROKERAGE',
4900
- 'CRYPTO_EXCHANGE',
4901
- 'PAYMENT',
4902
- 'INVESTMENT',
4903
- 'INSURANCE',
4904
- 'OTHER'
4905
- ],
4906
- example: 'CRYPTO_EXCHANGE'
4907
- },
4908
- logoUrl: {
4909
- type: 'string',
4910
- description: 'Platform logo URL',
4911
- example: 'https://example.com/logos/binance.png'
4912
- },
4913
- isActive: {
4914
- type: 'boolean',
4915
- description: 'Whether the platform is active',
4916
- default: true
4917
- }
4918
- },
4919
- required: ['name', 'canonical', 'aliases', 'url', 'type']
4920
- } as const;
4921
-
4922
- export const $UpdatePlatformDto = {
4923
- type: 'object',
4924
- properties: {
4925
- name: {
4926
- type: 'string',
4927
- description: 'Platform name',
4928
- example: 'Binance'
4929
- },
4930
- canonical: {
4931
- type: 'string',
4932
- description: 'Platform canonical identifier (lowercase, kebab-case)',
4933
- example: 'binance'
4934
- },
4935
- aliases: {
4936
- description: 'Platform aliases (multi-language names for lookup)',
4937
- example: ['Binance', 'Binance Exchange', 'BNB'],
4938
- type: 'array',
4939
- items: {
4940
- type: 'string'
4941
- }
4942
- },
4943
- url: {
4944
- type: 'string',
4945
- description: 'Platform URL',
4946
- example: 'https://www.binance.com'
4947
- },
4948
- type: {
4949
- type: 'string',
4950
- description: 'Platform type',
4951
- enum: [
4952
- 'BANK',
4953
- 'BROKERAGE',
4954
- 'CRYPTO_EXCHANGE',
4955
- 'PAYMENT',
4956
- 'INVESTMENT',
4957
- 'INSURANCE',
4958
- 'OTHER'
4959
- ],
4960
- example: 'CRYPTO_EXCHANGE'
4961
- },
4962
- logoUrl: {
4963
- type: 'string',
4964
- description: 'Platform logo URL',
4965
- example: 'https://example.com/logos/binance.png'
4966
- },
4967
- isActive: {
4968
- type: 'boolean',
4969
- description: 'Whether the platform is active'
5674
+ $ref: '#/components/schemas/UpdateMapperDefaultsDto'
5675
+ }
5676
+ ]
5677
+ }
5678
+ }
5679
+ } as const;
5680
+
5681
+ export const $UpdateImporterConfigDto = {
5682
+ type: 'object',
5683
+ properties: {
5684
+ data: {
5685
+ description: 'Configuration data (v1 schema)',
5686
+ allOf: [
5687
+ {
5688
+ $ref: '#/components/schemas/UpdateConfigDataDto'
5689
+ }
5690
+ ]
4970
5691
  }
4971
5692
  }
4972
5693
  } as const;
@@ -4977,7 +5698,7 @@ export const $ProviderSyncConfigDto = {
4977
5698
  sourceAccount: {
4978
5699
  type: 'string',
4979
5700
  description: 'Source account for the first posting',
4980
- example: 'Assets:Bank:Chase'
5701
+ example: 'Assets:US:Chase:Checking'
4981
5702
  },
4982
5703
  defaultCurrency: {
4983
5704
  type: 'string',
@@ -4998,6 +5719,12 @@ export const $ProviderSyncConfigDto = {
4998
5719
  type: 'boolean',
4999
5720
  description: 'Filter pending transactions',
5000
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'
5001
5728
  }
5002
5729
  },
5003
5730
  required: [
@@ -5117,6 +5844,94 @@ export const $SupportedProvidersResponseDto = {
5117
5844
  required: ['providers']
5118
5845
  } as const;
5119
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
+
5120
5935
  export const $ParserTelemetryReportDto = {
5121
5936
  type: 'object',
5122
5937
  properties: {}
@@ -5151,6 +5966,18 @@ export const $ProcessNlpDto = {
5151
5966
  currency: 'CNY',
5152
5967
  payee: 'Starbucks'
5153
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'
5154
5981
  }
5155
5982
  },
5156
5983
  required: ['message']
@@ -5475,7 +6302,8 @@ export const $NlpAccountConfirmationDataDto = {
5475
6302
  },
5476
6303
  suggestedAccount: {
5477
6304
  type: 'string',
5478
- description: 'Suggested replacement account',
6305
+ description:
6306
+ 'Suggested replacement account (omitted when no clear candidate)',
5479
6307
  example: 'Expenses:Food:Drinks'
5480
6308
  },
5481
6309
  similarAccounts: {
@@ -5497,7 +6325,6 @@ export const $NlpAccountConfirmationDataDto = {
5497
6325
  },
5498
6326
  required: [
5499
6327
  'invalidAccount',
5500
- 'suggestedAccount',
5501
6328
  'similarAccounts',
5502
6329
  'errorMessage',
5503
6330
  'transactionContext'
@@ -5666,11 +6493,12 @@ export const $NlpSuggestedAccountDto = {
5666
6493
  account: {
5667
6494
  type: 'string',
5668
6495
  description: 'Suggested account path',
5669
- example: 'Assets:Bank:Checking'
6496
+ example: 'Assets:Checking'
5670
6497
  },
5671
6498
  confidence: {
5672
6499
  type: 'number',
5673
- description: 'Confidence score for this suggestion (0-1)',
6500
+ description:
6501
+ 'Confidence score for this suggestion (0-1). Present = predicted (confirm/confirm_rule/confirm_account); omitted = actual persisted account (created). (#586)',
5674
6502
  example: 0.9
5675
6503
  }
5676
6504
  },
@@ -5707,7 +6535,7 @@ export const $NlpDefaultAccountsDto = {
5707
6535
  asset: {
5708
6536
  type: 'string',
5709
6537
  description: 'Default asset account',
5710
- example: 'Assets:Bank:Checking'
6538
+ example: 'Assets:Checking'
5711
6539
  },
5712
6540
  expense: {
5713
6541
  type: 'string',
@@ -5722,7 +6550,7 @@ export const $NlpDefaultAccountsDto = {
5722
6550
  liability: {
5723
6551
  type: 'string',
5724
6552
  description: 'Default liability account',
5725
- example: 'Liabilities:CreditCard'
6553
+ example: 'Liabilities:General'
5726
6554
  }
5727
6555
  },
5728
6556
  required: ['asset', 'expense', 'income', 'liability']
@@ -5747,7 +6575,8 @@ export const $NlpResponseDto = {
5747
6575
  'confirm_rule',
5748
6576
  'confirm_account',
5749
6577
  'confirm_payee',
5750
- 'cancel'
6578
+ 'cancel',
6579
+ 'aborted'
5751
6580
  ]
5752
6581
  },
5753
6582
  intent: {
@@ -5909,7 +6738,7 @@ export const $NlpResponseDto = {
5909
6738
  },
5910
6739
  suggestedAccounts: {
5911
6740
  description:
5912
- 'Suggested accounts for this transaction. Contains recommended source and destination accounts based on the detected intent and rules.',
6741
+ 'Suggested accounts for this transaction (#586). confirm/confirm_rule/confirm_account: predicted (source/destination carry confidence); created: actual persisted accounts (confidence omitted). confirm_account destination is the suggested replacement, never the invalid account.',
5913
6742
  allOf: [
5914
6743
  {
5915
6744
  $ref: '#/components/schemas/NlpSuggestedAccountsDto'
@@ -5918,7 +6747,7 @@ export const $NlpResponseDto = {
5918
6747
  },
5919
6748
  defaultAccounts: {
5920
6749
  description:
5921
- 'Default accounts for the user/region. These are fallback accounts used when no specific suggestion is available.',
6750
+ 'Default fallback accounts for the user/region (#586). v1 returns universal constants; per-user personalization is planned.',
5922
6751
  allOf: [
5923
6752
  {
5924
6753
  $ref: '#/components/schemas/NlpDefaultAccountsDto'
@@ -5926,24 +6755,255 @@ export const $NlpResponseDto = {
5926
6755
  ]
5927
6756
  }
5928
6757
  },
5929
- required: ['status', 'action']
6758
+ required: ['status', 'action']
6759
+ } as const;
6760
+
6761
+ export const $PlatformListItemDto = {
6762
+ type: 'object',
6763
+ properties: {
6764
+ id: {
6765
+ type: 'string',
6766
+ description: 'Global platform ID'
6767
+ },
6768
+ name: {
6769
+ type: 'string',
6770
+ description: 'Platform name'
6771
+ },
6772
+ url: {
6773
+ type: 'string',
6774
+ description: 'Platform URL'
6775
+ },
6776
+ type: {
6777
+ type: 'string',
6778
+ description: 'Platform type',
6779
+ enum: [
6780
+ 'BANK',
6781
+ 'BROKERAGE',
6782
+ 'CRYPTO_EXCHANGE',
6783
+ 'PAYMENT',
6784
+ 'INVESTMENT',
6785
+ 'INSURANCE',
6786
+ 'OTHER'
6787
+ ]
6788
+ },
6789
+ canonical: {
6790
+ type: 'string',
6791
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
6792
+ },
6793
+ suggestedSegment: {
6794
+ type: 'string',
6795
+ description:
6796
+ 'Suggested path segment — canonical with first char uppercased (ACC_COMP_NAME_RE)'
6797
+ },
6798
+ logoUrl: {
6799
+ type: 'string',
6800
+ description: 'Logo URL',
6801
+ nullable: true
6802
+ },
6803
+ isBound: {
6804
+ type: 'boolean',
6805
+ description: 'Whether user has accounts using this platform'
6806
+ }
6807
+ },
6808
+ required: [
6809
+ 'id',
6810
+ 'name',
6811
+ 'url',
6812
+ 'type',
6813
+ 'canonical',
6814
+ 'suggestedSegment',
6815
+ 'logoUrl',
6816
+ 'isBound'
6817
+ ]
6818
+ } as const;
6819
+
6820
+ export const $PlatformMatchResultDto = {
6821
+ type: 'object',
6822
+ properties: {
6823
+ id: {
6824
+ type: 'string',
6825
+ description: 'Global platform ID'
6826
+ },
6827
+ name: {
6828
+ type: 'string',
6829
+ description: 'Platform name (e.g., "ICBC")'
6830
+ },
6831
+ canonical: {
6832
+ type: 'string',
6833
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
6834
+ },
6835
+ type: {
6836
+ type: 'string',
6837
+ description: 'Platform type',
6838
+ enum: [
6839
+ 'BANK',
6840
+ 'BROKERAGE',
6841
+ 'CRYPTO_EXCHANGE',
6842
+ 'PAYMENT',
6843
+ 'INVESTMENT',
6844
+ 'INSURANCE',
6845
+ 'OTHER'
6846
+ ]
6847
+ },
6848
+ suggestedSegment: {
6849
+ type: 'string',
6850
+ description:
6851
+ 'Suggested path segment — canonical, already in ACCOUNT_RE format'
6852
+ },
6853
+ logoUrl: {
6854
+ type: 'string',
6855
+ description: 'Logo URL',
6856
+ nullable: true
6857
+ },
6858
+ matchType: {
6859
+ type: 'string',
6860
+ description: "How this row matched: 'exact' > 'prefix' > 'substring'",
6861
+ enum: ['exact', 'prefix', 'substring']
6862
+ }
6863
+ },
6864
+ required: [
6865
+ 'id',
6866
+ 'name',
6867
+ 'canonical',
6868
+ 'type',
6869
+ 'suggestedSegment',
6870
+ 'logoUrl',
6871
+ 'matchType'
6872
+ ]
6873
+ } as const;
6874
+
6875
+ export const $PlatformMatchResponseDto = {
6876
+ type: 'object',
6877
+ properties: {
6878
+ platforms: {
6879
+ description: 'Ranked matches, best tier first (at most 10 rows)',
6880
+ type: 'array',
6881
+ items: {
6882
+ $ref: '#/components/schemas/PlatformMatchResultDto'
6883
+ }
6884
+ },
6885
+ matchType: {
6886
+ type: 'string',
6887
+ description:
6888
+ "Overall match quality — top row's tier, or 'none' when no hits",
6889
+ enum: ['none', 'exact', 'prefix', 'substring']
6890
+ },
6891
+ total: {
6892
+ type: 'number',
6893
+ description: 'Total matches before LIMIT (truncation transparency)'
6894
+ },
6895
+ hasMore: {
6896
+ type: 'boolean',
6897
+ description: 'true when total > platforms.length (more matches exist)'
6898
+ }
6899
+ },
6900
+ required: ['platforms', 'matchType', 'total', 'hasMore']
6901
+ } as const;
6902
+
6903
+ export const $CreatePlatformDto = {
6904
+ type: 'object',
6905
+ properties: {
6906
+ name: {
6907
+ type: 'string',
6908
+ description: 'Platform name',
6909
+ example: 'Binance'
6910
+ },
6911
+ canonical: {
6912
+ type: 'string',
6913
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6914
+ example: 'binance'
6915
+ },
6916
+ aliases: {
6917
+ description: 'Platform aliases (multi-language names for lookup)',
6918
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6919
+ type: 'array',
6920
+ items: {
6921
+ type: 'string'
6922
+ }
6923
+ },
6924
+ url: {
6925
+ type: 'string',
6926
+ description: 'Platform URL',
6927
+ example: 'https://www.binance.com'
6928
+ },
6929
+ type: {
6930
+ type: 'string',
6931
+ description: 'Platform type',
6932
+ enum: [
6933
+ 'BANK',
6934
+ 'BROKERAGE',
6935
+ 'CRYPTO_EXCHANGE',
6936
+ 'PAYMENT',
6937
+ 'INVESTMENT',
6938
+ 'INSURANCE',
6939
+ 'OTHER'
6940
+ ],
6941
+ example: 'CRYPTO_EXCHANGE'
6942
+ },
6943
+ logoUrl: {
6944
+ type: 'string',
6945
+ description: 'Platform logo URL',
6946
+ example: 'https://example.com/logos/binance.png'
6947
+ },
6948
+ isActive: {
6949
+ type: 'boolean',
6950
+ description: 'Whether the platform is active',
6951
+ default: true
6952
+ }
6953
+ },
6954
+ required: ['name', 'canonical', 'aliases', 'url', 'type']
5930
6955
  } as const;
5931
6956
 
5932
- export const $BalanceByCurrencyDto = {
6957
+ export const $UpdatePlatformDto = {
5933
6958
  type: 'object',
5934
6959
  properties: {
5935
- currency: {
6960
+ name: {
5936
6961
  type: 'string',
5937
- description: 'ISO 4217 currency code',
5938
- example: 'CNY'
6962
+ description: 'Platform name',
6963
+ example: 'Binance'
5939
6964
  },
5940
- balance: {
6965
+ canonical: {
5941
6966
  type: 'string',
5942
- description: 'Balance amount',
5943
- example: '50000.00'
6967
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6968
+ example: 'binance'
6969
+ },
6970
+ aliases: {
6971
+ description: 'Platform aliases (multi-language names for lookup)',
6972
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6973
+ type: 'array',
6974
+ items: {
6975
+ type: 'string'
6976
+ }
6977
+ },
6978
+ url: {
6979
+ type: 'string',
6980
+ description: 'Platform URL',
6981
+ example: 'https://www.binance.com'
6982
+ },
6983
+ type: {
6984
+ type: 'string',
6985
+ description: 'Platform type',
6986
+ enum: [
6987
+ 'BANK',
6988
+ 'BROKERAGE',
6989
+ 'CRYPTO_EXCHANGE',
6990
+ 'PAYMENT',
6991
+ 'INVESTMENT',
6992
+ 'INSURANCE',
6993
+ 'OTHER'
6994
+ ],
6995
+ example: 'CRYPTO_EXCHANGE'
6996
+ },
6997
+ logoUrl: {
6998
+ type: 'string',
6999
+ description: 'Platform logo URL',
7000
+ example: 'https://example.com/logos/binance.png'
7001
+ },
7002
+ isActive: {
7003
+ type: 'boolean',
7004
+ description: 'Whether the platform is active'
5944
7005
  }
5945
- },
5946
- required: ['currency', 'balance']
7006
+ }
5947
7007
  } as const;
5948
7008
 
5949
7009
  export const $NetWorthByCurrencyDto = {
@@ -6015,28 +7075,6 @@ export const $ConvertedNetWorthDto = {
6015
7075
  ]
6016
7076
  } as const;
6017
7077
 
6018
- export const $ExchangeRateWarningDto = {
6019
- type: 'object',
6020
- properties: {
6021
- type: {
6022
- type: 'string',
6023
- description: 'Warning type',
6024
- example: 'MISSING_EXCHANGE_RATE'
6025
- },
6026
- currency: {
6027
- type: 'string',
6028
- description: 'Currency without exchange rate',
6029
- example: 'EUR'
6030
- },
6031
- totalAmount: {
6032
- type: 'string',
6033
- description: 'Total amount affected',
6034
- example: '1000.00'
6035
- }
6036
- },
6037
- required: ['type', 'currency', 'totalAmount']
6038
- } as const;
6039
-
6040
7078
  export const $NetWorthResponseDto = {
6041
7079
  type: 'object',
6042
7080
  properties: {
@@ -6122,7 +7160,7 @@ export const $AccountItemDto = {
6122
7160
  name: {
6123
7161
  type: 'string',
6124
7162
  description: 'Full account name',
6125
- example: 'Assets:Bank:CMB:Savings'
7163
+ example: 'Assets:CN:CMB:Savings'
6126
7164
  },
6127
7165
  displayName: {
6128
7166
  type: 'string',
@@ -6138,6 +7176,12 @@ export const $AccountItemDto = {
6138
7176
  type: 'string',
6139
7177
  description: 'Currency code',
6140
7178
  example: 'CNY'
7179
+ },
7180
+ convertedBalance: {
7181
+ type: 'string',
7182
+ description:
7183
+ 'FX-converted balance in base currency; omitted when not convertible',
7184
+ example: '50000.00'
6141
7185
  }
6142
7186
  },
6143
7187
  required: ['id', 'name', 'displayName', 'balance', 'currency']
@@ -6164,11 +7208,66 @@ export const $PlatformGroupDto = {
6164
7208
  },
6165
7209
  totalBalance: {
6166
7210
  type: 'string',
6167
- description: 'Total balance across all accounts in platform',
7211
+ description: 'FX-converted total balance in base currency',
7212
+ example: '100000.00'
7213
+ },
7214
+ balanceByCurrency: {
7215
+ description: 'Raw (unconverted) balances grouped by currency',
7216
+ type: 'array',
7217
+ items: {
7218
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
7219
+ }
7220
+ },
7221
+ convertedBalance: {
7222
+ type: 'string',
7223
+ description:
7224
+ 'Converted balance in base currency (omitted when no currency is convertible)',
6168
7225
  example: '100000.00'
7226
+ },
7227
+ sharePct: {
7228
+ type: 'number',
7229
+ description:
7230
+ 'Share of the grand converted total (0-100); 0 when grand total is 0',
7231
+ example: 42.5
7232
+ }
7233
+ },
7234
+ required: [
7235
+ 'platformId',
7236
+ 'platformName',
7237
+ 'accounts',
7238
+ 'totalBalance',
7239
+ 'balanceByCurrency',
7240
+ 'sharePct'
7241
+ ]
7242
+ } as const;
7243
+
7244
+ export const $AccountExchangeRateWarningDto = {
7245
+ type: 'object',
7246
+ properties: {
7247
+ type: {
7248
+ type: 'string',
7249
+ description: 'Warning type',
7250
+ example: 'MISSING_EXCHANGE_RATE'
7251
+ },
7252
+ currency: {
7253
+ type: 'string',
7254
+ description: 'Currency without exchange rate',
7255
+ example: 'USD'
7256
+ },
7257
+ accounts: {
7258
+ description: 'Affected account paths',
7259
+ type: 'array',
7260
+ items: {
7261
+ type: 'string'
7262
+ }
7263
+ },
7264
+ totalAmount: {
7265
+ type: 'string',
7266
+ description: 'Total amount in this currency',
7267
+ example: '5000.00'
6169
7268
  }
6170
7269
  },
6171
- required: ['platformId', 'platformName', 'accounts', 'totalBalance']
7270
+ required: ['type', 'currency', 'accounts', 'totalAmount']
6172
7271
  } as const;
6173
7272
 
6174
7273
  export const $AccountsSummaryDto = {
@@ -6181,9 +7280,21 @@ export const $AccountsSummaryDto = {
6181
7280
  totalPlatforms: {
6182
7281
  type: 'number',
6183
7282
  description: 'Total number of platforms'
7283
+ },
7284
+ baseCurrency: {
7285
+ type: 'string',
7286
+ description: 'Base currency for conversion',
7287
+ example: 'CNY'
7288
+ },
7289
+ warnings: {
7290
+ description: 'Per-account exchange rate warnings',
7291
+ type: 'array',
7292
+ items: {
7293
+ $ref: '#/components/schemas/AccountExchangeRateWarningDto'
7294
+ }
6184
7295
  }
6185
7296
  },
6186
- required: ['totalAccounts', 'totalPlatforms']
7297
+ required: ['totalAccounts', 'totalPlatforms', 'baseCurrency']
6187
7298
  } as const;
6188
7299
 
6189
7300
  export const $AccountsResponseDto = {
@@ -6218,7 +7329,7 @@ export const $AccountItemWithAssetClassDto = {
6218
7329
  name: {
6219
7330
  type: 'string',
6220
7331
  description: 'Full account name',
6221
- example: 'Assets:Bank:CMB:Savings'
7332
+ example: 'Assets:CN:CMB:Savings'
6222
7333
  },
6223
7334
  displayName: {
6224
7335
  type: 'string',
@@ -6235,6 +7346,12 @@ export const $AccountItemWithAssetClassDto = {
6235
7346
  description: 'Currency code',
6236
7347
  example: 'CNY'
6237
7348
  },
7349
+ convertedBalance: {
7350
+ type: 'string',
7351
+ description:
7352
+ 'FX-converted balance in base currency; omitted when not convertible',
7353
+ example: '50000.00'
7354
+ },
6238
7355
  assetClass: {
6239
7356
  type: 'string',
6240
7357
  description: 'Asset class',
@@ -6314,35 +7431,6 @@ export const $AssetClassGroupDto = {
6314
7431
  required: ['assetClass', 'accounts', 'balanceByCurrency']
6315
7432
  } as const;
6316
7433
 
6317
- export const $AccountExchangeRateWarningDto = {
6318
- type: 'object',
6319
- properties: {
6320
- type: {
6321
- type: 'string',
6322
- description: 'Warning type',
6323
- example: 'MISSING_EXCHANGE_RATE'
6324
- },
6325
- currency: {
6326
- type: 'string',
6327
- description: 'Currency without exchange rate',
6328
- example: 'USD'
6329
- },
6330
- accounts: {
6331
- description: 'Affected account paths',
6332
- type: 'array',
6333
- items: {
6334
- type: 'string'
6335
- }
6336
- },
6337
- totalAmount: {
6338
- type: 'string',
6339
- description: 'Total amount in this currency',
6340
- example: '5000.00'
6341
- }
6342
- },
6343
- required: ['type', 'currency', 'accounts', 'totalAmount']
6344
- } as const;
6345
-
6346
7434
  export const $AssetClassSummaryDto = {
6347
7435
  type: 'object',
6348
7436
  properties: {
@@ -6416,7 +7504,7 @@ export const $HoldingAssetClassAccountSliceDto = {
6416
7504
  accountPath: {
6417
7505
  type: 'string',
6418
7506
  description: 'Full account path',
6419
- example: 'Assets:US:Investments:Brokerage'
7507
+ example: 'Assets:US:Fidelity:Brokerage'
6420
7508
  },
6421
7509
  accountCurrency: {
6422
7510
  type: 'string',
@@ -6588,38 +7676,133 @@ export const $CashFlowResponseDto = {
6588
7676
  description: 'Base currency code',
6589
7677
  example: 'CNY'
6590
7678
  },
6591
- byCurrency: {
6592
- description: 'Cash flow grouped by original currency',
6593
- allOf: [
6594
- {
6595
- $ref: '#/components/schemas/CashFlowByCurrencyDto'
6596
- }
6597
- ]
7679
+ byCurrency: {
7680
+ description: 'Cash flow grouped by original currency',
7681
+ allOf: [
7682
+ {
7683
+ $ref: '#/components/schemas/CashFlowByCurrencyDto'
7684
+ }
7685
+ ]
7686
+ },
7687
+ converted: {
7688
+ description: 'Converted values in base currency',
7689
+ allOf: [
7690
+ {
7691
+ $ref: '#/components/schemas/ConvertedCashFlowDto'
7692
+ }
7693
+ ]
7694
+ },
7695
+ warnings: {
7696
+ description: 'Exchange rate warnings',
7697
+ type: 'array',
7698
+ items: {
7699
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
7700
+ }
7701
+ }
7702
+ },
7703
+ required: [
7704
+ 'period',
7705
+ 'income',
7706
+ 'expense',
7707
+ 'netSavings',
7708
+ 'savingsRate',
7709
+ 'currency'
7710
+ ]
7711
+ } as const;
7712
+
7713
+ export const $CategoryGroupDto = {
7714
+ type: 'object',
7715
+ properties: {
7716
+ category: {
7717
+ type: 'string',
7718
+ description:
7719
+ 'Functional category (account-path Group segment); regional and universal account paths merge under it',
7720
+ example: 'Food'
7721
+ },
7722
+ totalExpense: {
7723
+ type: 'string',
7724
+ description:
7725
+ 'Converted total for this category in base currency (expense amount when flow=expense, income amount when flow=income)',
7726
+ example: '1200.00'
7727
+ },
7728
+ sharePct: {
7729
+ type: 'number',
7730
+ description: 'Share of grand total (0-100); 0 when grand total is 0',
7731
+ example: 42.5
7732
+ },
7733
+ balanceByCurrency: {
7734
+ description: 'Raw (unconverted) expense per currency',
7735
+ type: 'array',
7736
+ items: {
7737
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
7738
+ }
7739
+ },
7740
+ convertedBalance: {
7741
+ type: 'string',
7742
+ description:
7743
+ 'Converted total in base currency (omitted when FX missing for all currencies in this category)',
7744
+ example: '1200.00'
7745
+ }
7746
+ },
7747
+ required: ['category', 'totalExpense', 'sharePct', 'balanceByCurrency']
7748
+ } as const;
7749
+
7750
+ export const $ExpensesByCategorySummaryDto = {
7751
+ type: 'object',
7752
+ properties: {
7753
+ totalExpense: {
7754
+ type: 'string',
7755
+ description:
7756
+ 'Total across all categories, converted (convertible categories only); expense totals when flow=expense, income totals when flow=income',
7757
+ example: '5000.00'
7758
+ },
7759
+ categoryCount: {
7760
+ type: 'number',
7761
+ description: 'Number of categories',
7762
+ example: 8
7763
+ }
7764
+ },
7765
+ required: ['totalExpense', 'categoryCount']
7766
+ } as const;
7767
+
7768
+ export const $ExpensesByCategoryResponseDto = {
7769
+ type: 'object',
7770
+ properties: {
7771
+ period: {
7772
+ type: 'string',
7773
+ description: 'Period requested',
7774
+ example: '1m'
7775
+ },
7776
+ baseCurrency: {
7777
+ type: 'string',
7778
+ description: 'Base currency for converted values',
7779
+ example: 'CNY'
7780
+ },
7781
+ groups: {
7782
+ description:
7783
+ 'Expense groups by functional category, sorted by converted total desc',
7784
+ type: 'array',
7785
+ items: {
7786
+ $ref: '#/components/schemas/CategoryGroupDto'
7787
+ }
6598
7788
  },
6599
- converted: {
6600
- description: 'Converted values in base currency',
7789
+ summary: {
7790
+ description: 'Summary statistics',
6601
7791
  allOf: [
6602
7792
  {
6603
- $ref: '#/components/schemas/ConvertedCashFlowDto'
7793
+ $ref: '#/components/schemas/ExpensesByCategorySummaryDto'
6604
7794
  }
6605
7795
  ]
6606
7796
  },
6607
7797
  warnings: {
6608
- description: 'Exchange rate warnings',
7798
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
6609
7799
  type: 'array',
6610
7800
  items: {
6611
7801
  $ref: '#/components/schemas/ExchangeRateWarningDto'
6612
7802
  }
6613
7803
  }
6614
7804
  },
6615
- required: [
6616
- 'period',
6617
- 'income',
6618
- 'expense',
6619
- 'netSavings',
6620
- 'savingsRate',
6621
- 'currency'
6622
- ]
7805
+ required: ['period', 'baseCurrency', 'groups', 'summary']
6623
7806
  } as const;
6624
7807
 
6625
7808
  export const $MonetaryDto = {
@@ -6836,409 +8019,243 @@ export const $HoldingPnlRowDto = {
6836
8019
  },
6837
8020
  required: [
6838
8021
  'accountId',
6839
- 'accountPath',
6840
- 'symbol',
6841
- 'chartToken',
6842
- 'assetClass',
6843
- 'units'
6844
- ]
6845
- } as const;
6846
-
6847
- export const $HoldingPnlWarningDto = {
6848
- type: 'object',
6849
- properties: {
6850
- type: {
6851
- type: 'string',
6852
- description: 'Warning type',
6853
- example: 'MISSING_COST_FX_RATE',
6854
- enum: [
6855
- 'MISSING_COST_FX_RATE',
6856
- 'MISSING_MARKET_FX_RATE',
6857
- 'MISSING_SALE_PRICE',
6858
- 'MISSING_REALIZED_FX_RATE',
6859
- 'OVERSOLD_LOTS',
6860
- 'NO_PRICE',
6861
- 'MIXED_COST_CURRENCY'
6862
- ]
6863
- },
6864
- symbol: {
6865
- type: 'object',
6866
- nullable: true
6867
- },
6868
- accountId: {
6869
- type: 'object',
6870
- nullable: true
6871
- },
6872
- currency: {
6873
- type: 'object',
6874
- nullable: true
6875
- }
6876
- },
6877
- required: ['type']
6878
- } as const;
6879
-
6880
- export const $HoldingPnlResponseDto = {
6881
- type: 'object',
6882
- properties: {
6883
- asOfDate: {
6884
- type: 'string',
6885
- example: '2026-07-08'
6886
- },
6887
- baseCurrency: {
6888
- type: 'string',
6889
- example: 'CNY'
6890
- },
6891
- method: {
6892
- type: 'string',
6893
- description:
6894
- 'Realized-P&L lot-matching method (FIFO or average). Unrealized cost basis remains average regardless of this value (#473).',
6895
- enum: ['average', 'FIFO'],
6896
- example: 'average'
6897
- },
6898
- rows: {
6899
- type: 'array',
6900
- items: {
6901
- $ref: '#/components/schemas/HoldingPnlRowDto'
6902
- }
6903
- },
6904
- warnings: {
6905
- type: 'array',
6906
- items: {
6907
- $ref: '#/components/schemas/HoldingPnlWarningDto'
6908
- }
6909
- }
6910
- },
6911
- required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
6912
- } as const;
6913
-
6914
- export const $CreateBeanPriceDto = {
6915
- type: 'object',
6916
- properties: {
6917
- currency: {
6918
- type: 'string',
6919
- description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6920
- example: 'USD'
6921
- },
6922
- quoteCurrency: {
6923
- type: 'string',
6924
- description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
6925
- example: 'CNY'
6926
- },
6927
- amount: {
6928
- type: 'number',
6929
- description:
6930
- 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
6931
- example: 175.5,
6932
- minimum: 0
6933
- },
6934
- date: {
6935
- type: 'string',
6936
- description: 'Price date (ISO 8601 format)',
6937
- example: '2024-11-05'
6938
- },
6939
- metadata: {
6940
- type: 'object',
6941
- description:
6942
- 'Metadata (validated by Zod schema, max field lengths enforced)',
6943
- example: {
6944
- source: 'MANUAL',
6945
- note: 'Bank valuation report',
6946
- confidence: 0.95
6947
- }
6948
- }
6949
- },
6950
- required: ['currency', 'quoteCurrency', 'amount', 'date']
6951
- } as const;
6952
-
6953
- export const $PriceResponseDto = {
6954
- type: 'object',
6955
- properties: {
6956
- id: {
6957
- type: 'string',
6958
- description: 'Unique identifier',
6959
- example: 'uuid-123-456'
6960
- },
6961
- userId: {
6962
- type: 'string',
6963
- description: 'User ID (owner of the price)',
6964
- example: 'user-123'
6965
- },
6966
- currency: {
6967
- type: 'string',
6968
- description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6969
- example: 'BTC'
6970
- },
6971
- quoteCurrency: {
6972
- type: 'string',
6973
- description: 'Quote currency (pricing currency, e.g., USD, CNY)',
6974
- example: 'USD'
6975
- },
6976
- amount: {
6977
- type: 'number',
6978
- description:
6979
- 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
6980
- example: 50000
6981
- },
6982
- date: {
6983
- type: 'string',
6984
- description:
6985
- 'Price date (ISO 8601 format). Represents the date this price was valid.',
6986
- example: '2024-01-01',
6987
- format: 'date'
6988
- },
6989
- meta: {
6990
- type: 'object',
6991
- description:
6992
- 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
6993
- example: {
6994
- source: 'MANUAL',
6995
- note: 'User-defined price',
6996
- confidence: 1
6997
- }
6998
- },
6999
- createdAt: {
7000
- format: 'date-time',
7001
- type: 'string',
7002
- description: 'Creation timestamp',
7003
- example: '2024-11-03T10:00:00Z'
7004
- },
7005
- updatedAt: {
7006
- format: 'date-time',
7007
- type: 'string',
7008
- description: 'Last update timestamp',
7009
- example: '2024-11-03T10:00:00Z'
7010
- }
7011
- },
7012
- required: [
7013
- 'id',
7014
- 'userId',
7015
- 'currency',
7016
- 'quoteCurrency',
7017
- 'amount',
7018
- 'date',
7019
- 'meta',
7020
- 'createdAt',
7021
- 'updatedAt'
7022
- ]
7023
- } as const;
7024
-
7025
- export const $PriceListResponseDto = {
7026
- type: 'object',
7027
- properties: {
7028
- items: {
7029
- description: 'List of prices',
7030
- type: 'array',
7031
- items: {
7032
- $ref: '#/components/schemas/PriceResponseDto'
7033
- }
7034
- },
7035
- total: {
7036
- type: 'number',
7037
- description: 'Total number of prices',
7038
- example: 42
7039
- }
7040
- },
7041
- required: ['items', 'total']
7042
- } as const;
7043
-
7044
- export const $UpdateBeanPriceDto = {
7045
- type: 'object',
7046
- properties: {
7047
- currency: {
7048
- type: 'string',
7049
- description: 'Currency being priced'
7050
- },
7051
- quoteCurrency: {
7052
- type: 'string',
7053
- description: 'Quote currency (pricing currency)'
7054
- },
7055
- amount: {
7056
- type: 'number',
7057
- description: 'Price amount (MUST be >= 0 per Beancount spec)',
7058
- minimum: 0
7059
- },
7060
- date: {
7061
- type: 'string',
7062
- description: 'Price date (ISO 8601 format)'
7063
- },
7064
- metadata: {
7065
- type: 'object',
7066
- description: 'Metadata'
7067
- }
7068
- }
8022
+ 'accountPath',
8023
+ 'symbol',
8024
+ 'chartToken',
8025
+ 'assetClass',
8026
+ 'units'
8027
+ ]
7069
8028
  } as const;
7070
8029
 
7071
- export const $CurrencyBalanceDto = {
8030
+ export const $HoldingPnlWarningDto = {
7072
8031
  type: 'object',
7073
8032
  properties: {
7074
- currency: {
8033
+ type: {
7075
8034
  type: 'string',
7076
- description: 'ISO 4217 currency code',
7077
- example: 'CNY'
8035
+ description: 'Warning type',
8036
+ example: 'MISSING_COST_FX_RATE',
8037
+ enum: [
8038
+ 'MISSING_COST_FX_RATE',
8039
+ 'MISSING_MARKET_FX_RATE',
8040
+ 'MISSING_SALE_PRICE',
8041
+ 'MISSING_REALIZED_FX_RATE',
8042
+ 'OVERSOLD_LOTS',
8043
+ 'NO_PRICE',
8044
+ 'MIXED_COST_CURRENCY'
8045
+ ]
7078
8046
  },
7079
- balance: {
7080
- type: 'string',
7081
- description: 'Balance amount',
7082
- example: '500000.00'
8047
+ symbol: {
8048
+ type: 'object',
8049
+ nullable: true
8050
+ },
8051
+ accountId: {
8052
+ type: 'object',
8053
+ nullable: true
8054
+ },
8055
+ currency: {
8056
+ type: 'object',
8057
+ nullable: true
7083
8058
  }
7084
8059
  },
7085
- required: ['currency', 'balance']
8060
+ required: ['type']
7086
8061
  } as const;
7087
8062
 
7088
- export const $TimeSeriesPointDto = {
8063
+ export const $HoldingPnlResponseDto = {
7089
8064
  type: 'object',
7090
8065
  properties: {
7091
- date: {
8066
+ asOfDate: {
7092
8067
  type: 'string',
7093
- description: 'Date in YYYY-MM-DD format',
7094
- example: '2024-06-15'
8068
+ example: '2026-07-08'
7095
8069
  },
7096
- value: {
8070
+ baseCurrency: {
7097
8071
  type: 'string',
7098
- description: 'Value at this date (in base currency)',
7099
- example: '500000.00'
8072
+ example: 'CNY'
7100
8073
  },
7101
- change: {
7102
- type: 'object',
7103
- description: 'Change from previous point',
7104
- example: '5000.00'
8074
+ method: {
8075
+ type: 'string',
8076
+ description:
8077
+ 'Realized-P&L lot-matching method (FIFO or average). Unrealized cost basis remains average regardless of this value (#473).',
8078
+ enum: ['average', 'FIFO'],
8079
+ example: 'average'
7105
8080
  },
7106
- byCurrency: {
7107
- description: 'Multi-currency breakdown for this point',
8081
+ rows: {
7108
8082
  type: 'array',
7109
8083
  items: {
7110
- $ref: '#/components/schemas/CurrencyBalanceDto'
8084
+ $ref: '#/components/schemas/HoldingPnlRowDto'
8085
+ }
8086
+ },
8087
+ warnings: {
8088
+ type: 'array',
8089
+ items: {
8090
+ $ref: '#/components/schemas/HoldingPnlWarningDto'
7111
8091
  }
7112
8092
  }
7113
8093
  },
7114
- required: ['date', 'value']
8094
+ required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
7115
8095
  } as const;
7116
8096
 
7117
- export const $TrendSummaryDto = {
8097
+ export const $AnonymousLoginDto = {
7118
8098
  type: 'object',
7119
8099
  properties: {
7120
- startValue: {
7121
- type: 'string',
7122
- description: 'Value at start of period',
7123
- example: '450000.00'
7124
- },
7125
- endValue: {
7126
- type: 'string',
7127
- description: 'Value at end of period',
7128
- example: '500000.00'
7129
- },
7130
- totalChange: {
7131
- type: 'string',
7132
- description: 'Total change over period',
7133
- example: '50000.00'
7134
- },
7135
- totalChangePercentage: {
8100
+ accessToken: {
7136
8101
  type: 'string',
7137
- description: 'Total change percentage',
7138
- example: '+11.11%'
8102
+ description: 'Access token for anonymous login'
7139
8103
  }
7140
8104
  },
7141
- required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
8105
+ required: ['accessToken']
7142
8106
  } as const;
7143
8107
 
7144
- export const $MultiCurrencyPointDto = {
8108
+ export const $AnonymousLoginResponseDto = {
7145
8109
  type: 'object',
7146
8110
  properties: {
7147
- date: {
8111
+ authToken: {
7148
8112
  type: 'string',
7149
- description: 'Date in YYYY-MM-DD format',
7150
- example: '2024-06-15'
7151
- },
7152
- byCurrency: {
7153
- description: 'Balances by currency',
7154
- type: 'array',
7155
- items: {
7156
- $ref: '#/components/schemas/CurrencyBalanceDto'
7157
- }
8113
+ description: 'JWT auth token',
8114
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
7158
8115
  }
7159
8116
  },
7160
- required: ['date', 'byCurrency']
8117
+ required: ['authToken']
7161
8118
  } as const;
7162
8119
 
7163
- export const $PortfolioTrendsResponseDto = {
8120
+ export const $SymbolSearchResultDto = {
7164
8121
  type: 'object',
7165
8122
  properties: {
7166
- series: {
7167
- description: 'Time series data points',
7168
- type: 'array',
7169
- items: {
7170
- $ref: '#/components/schemas/TimeSeriesPointDto'
7171
- }
8123
+ symbol: {
8124
+ type: 'string',
8125
+ example: 'AAPL'
7172
8126
  },
7173
- summary: {
7174
- description: 'Period summary',
7175
- allOf: [
7176
- {
7177
- $ref: '#/components/schemas/TrendSummaryDto'
7178
- }
7179
- ]
8127
+ name: {
8128
+ type: 'object',
8129
+ example: 'Apple Inc.',
8130
+ nullable: true
7180
8131
  },
7181
- period: {
7182
- type: 'string',
7183
- description: 'Period requested',
7184
- example: '6m'
8132
+ exchange: {
8133
+ type: 'object',
8134
+ example: 'US',
8135
+ nullable: true
7185
8136
  },
7186
- granularity: {
7187
- type: 'string',
7188
- description: 'Data granularity',
7189
- example: 'month'
8137
+ assetType: {
8138
+ type: 'object',
8139
+ description: 'OpenBB asset_type (e.g. stock, etf)',
8140
+ example: 'stock',
8141
+ nullable: true
7190
8142
  },
7191
- currency: {
7192
- type: 'string',
7193
- description: 'Base currency for converted values',
7194
- example: 'CNY'
8143
+ assetClass: {
8144
+ type: 'object',
8145
+ description: 'IGN asset class (region.types.ts ASSET_CLASSES)',
8146
+ example: 'EQUITY',
8147
+ nullable: true
7195
8148
  },
7196
- byCurrency: {
7197
- description:
7198
- 'Multi-currency time series (each point has currency breakdown)',
7199
- type: 'array',
7200
- items: {
7201
- $ref: '#/components/schemas/MultiCurrencyPointDto'
7202
- }
8149
+ assetSubClass: {
8150
+ type: 'object',
8151
+ description: 'IGN asset sub-class (region.types.ts ASSET_SUB_CLASSES)',
8152
+ example: 'STOCK',
8153
+ nullable: true
7203
8154
  },
7204
- warnings: {
7205
- description: 'Exchange rate warnings',
7206
- type: 'array',
7207
- items: {
7208
- $ref: '#/components/schemas/ExchangeRateWarningDto'
7209
- }
8155
+ currency: {
8156
+ type: 'object',
8157
+ description: 'Trading currency (extra_data or inferred from exchange)',
8158
+ example: 'USD',
8159
+ nullable: true
7210
8160
  }
7211
8161
  },
7212
- required: ['series', 'summary', 'period', 'granularity', 'currency']
7213
- } as const;
7214
-
7215
- export const $GenerateSnapshotBody = {
7216
- type: 'object',
7217
- properties: {}
7218
- } as const;
7219
-
7220
- export const $GenerateSnapshotResponse = {
7221
- type: 'object',
7222
- properties: {}
7223
- } as const;
7224
-
7225
- export const $BackfillSnapshotsBody = {
7226
- type: 'object',
7227
- properties: {}
7228
- } as const;
7229
-
7230
- export const $BackfillSnapshotsResponse = {
7231
- type: 'object',
7232
- properties: {}
8162
+ required: ['symbol']
7233
8163
  } as const;
7234
8164
 
7235
- export const $AnonymousLoginDto = {
8165
+ export const $SymbolQuoteDto = {
7236
8166
  type: 'object',
7237
8167
  properties: {
7238
- accessToken: {
8168
+ symbol: {
7239
8169
  type: 'string',
7240
- description: 'Access token for anonymous login'
8170
+ example: 'AAPL'
8171
+ },
8172
+ name: {
8173
+ type: 'object',
8174
+ example: 'Apple Inc.',
8175
+ nullable: true
8176
+ },
8177
+ exchange: {
8178
+ type: 'object',
8179
+ example: 'US',
8180
+ nullable: true
8181
+ },
8182
+ assetType: {
8183
+ type: 'object',
8184
+ description: 'OpenBB asset_type',
8185
+ example: 'stock',
8186
+ nullable: true
8187
+ },
8188
+ assetClass: {
8189
+ type: 'object',
8190
+ description: 'IGN asset class',
8191
+ example: 'EQUITY',
8192
+ nullable: true
8193
+ },
8194
+ assetSubClass: {
8195
+ type: 'object',
8196
+ description: 'IGN asset sub-class',
8197
+ example: 'STOCK',
8198
+ nullable: true
8199
+ },
8200
+ currency: {
8201
+ type: 'object',
8202
+ description: 'Trading currency (extra_data or inferred from exchange)',
8203
+ example: 'USD',
8204
+ nullable: true
8205
+ },
8206
+ price: {
8207
+ type: 'object',
8208
+ description: 'Latest price (Decimal string)',
8209
+ example: '189.84',
8210
+ nullable: true
8211
+ },
8212
+ priceDate: {
8213
+ type: 'object',
8214
+ description: 'Date the price was observed (ISO yyyy-MM-dd)',
8215
+ example: '2026-08-05',
8216
+ nullable: true
8217
+ },
8218
+ changePercent: {
8219
+ type: 'object',
8220
+ description:
8221
+ 'Change vs previous close, in percentage points (1.7 == 1.7%). openbb stores change_percent as a normalized decimal; this exposes percentage points for frontend convenience.',
8222
+ example: 1.7,
8223
+ nullable: true
8224
+ },
8225
+ prevClose: {
8226
+ type: 'object',
8227
+ description: 'Previous close (Decimal string)',
8228
+ nullable: true
8229
+ },
8230
+ open: {
8231
+ type: 'object',
8232
+ description: 'Day open (Decimal string)',
8233
+ nullable: true
8234
+ },
8235
+ high: {
8236
+ type: 'object',
8237
+ description: 'Day high (Decimal string)',
8238
+ nullable: true
8239
+ },
8240
+ low: {
8241
+ type: 'object',
8242
+ description: 'Day low (Decimal string)',
8243
+ nullable: true
8244
+ },
8245
+ volume: {
8246
+ type: 'object',
8247
+ description: 'Day volume (Decimal string)',
8248
+ nullable: true
8249
+ },
8250
+ yearHigh: {
8251
+ type: 'object',
8252
+ description: '52-week high (Decimal string)',
8253
+ nullable: true
8254
+ },
8255
+ yearLow: {
8256
+ type: 'object',
8257
+ description: '52-week low (Decimal string)',
8258
+ nullable: true
7241
8259
  }
7242
- },
7243
- required: ['accessToken']
8260
+ }
7244
8261
  } as const;