@firela/api-types 0.0.0-canary.2b7765ff → 0.0.0-canary.2d71872c

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',
@@ -145,26 +129,26 @@ export const $AccountResponseDto = {
145
129
  templatePath: {
146
130
  type: 'string',
147
131
  description: 'Template path reference',
148
- example: 'Assets:CN:Bank:ICBC:Checking'
132
+ example: 'Assets:CN:Checking'
149
133
  },
150
134
  isCustom: {
151
135
  type: 'boolean',
152
136
  description: 'Whether this is a custom (user-created) account',
153
137
  example: false
154
138
  },
155
- i18nKey: {
139
+ displayName: {
156
140
  type: 'string',
157
- description: 'i18n key for display name',
158
- example: 'account.assets.cn.bank.icbc.checking'
141
+ description: 'Localized display name (ADR-0114, read-time projection)',
142
+ example: 'Checking'
159
143
  },
160
144
  icon: {
161
145
  type: 'string',
162
146
  description: 'Icon identifier',
163
147
  example: 'bank-icbc'
164
148
  },
165
- openMeta: {
149
+ openDirectiveMeta: {
166
150
  type: 'object',
167
- description: 'Account metadata',
151
+ description: 'Open directive metadata (ADR-0115 Decision 9)',
168
152
  example: {
169
153
  branch: 'Downtown'
170
154
  }
@@ -192,7 +176,6 @@ export const $AccountResponseDto = {
192
176
  required: [
193
177
  'id',
194
178
  'path',
195
- 'displayName',
196
179
  'type',
197
180
  'status',
198
181
  'openDate',
@@ -225,11 +208,6 @@ export const $AccountListResponseDto = {
225
208
  export const $UpdateAccountDto = {
226
209
  type: 'object',
227
210
  properties: {
228
- displayName: {
229
- type: 'string',
230
- description: 'Display name to distinguish accounts at the same path',
231
- example: '招行工资卡'
232
- },
233
211
  currencies: {
234
212
  description: 'Allowed currencies (null = no restriction)',
235
213
  example: ['CNY', 'USD'],
@@ -251,19 +229,15 @@ export const $UpdateAccountDto = {
251
229
  'NONE'
252
230
  ]
253
231
  },
254
- i18nKey: {
255
- type: 'string',
256
- description: 'i18n key for display name',
257
- example: 'account.custom.mybank'
258
- },
259
232
  icon: {
260
233
  type: 'string',
261
234
  description: 'Icon identifier',
262
235
  example: 'bank-custom'
263
236
  },
264
- openMeta: {
237
+ openDirectiveMeta: {
265
238
  type: 'object',
266
- description: 'Additional metadata (merged with existing)',
239
+ description:
240
+ 'Open directive metadata (merged with existing; NOT an opening-balance amount)',
267
241
  example: {
268
242
  branch: 'Uptown'
269
243
  }
@@ -310,13 +284,47 @@ export const $ReopenAccountDto = {
310
284
  }
311
285
  } as const;
312
286
 
287
+ export const $CreateOpeningBalanceDto = {
288
+ type: 'object',
289
+ properties: {
290
+ amount: {
291
+ type: 'number',
292
+ description: 'Opening balance amount (non-negative)',
293
+ example: 1000
294
+ },
295
+ currency: {
296
+ type: 'string',
297
+ description: 'Currency code',
298
+ example: 'CNY'
299
+ },
300
+ date: {
301
+ format: 'date-time',
302
+ type: 'string',
303
+ description: 'Opening-balance date (defaults to now)',
304
+ example: '2024-01-01'
305
+ }
306
+ },
307
+ required: ['amount', 'currency']
308
+ } as const;
309
+
310
+ export const $OpeningBalanceResultDto = {
311
+ type: 'object',
312
+ properties: {
313
+ transactionId: {
314
+ type: 'string',
315
+ description: 'Created opening-balance transaction id.'
316
+ }
317
+ },
318
+ required: ['transactionId']
319
+ } as const;
320
+
313
321
  export const $AccountStandardResponseDto = {
314
322
  type: 'object',
315
323
  properties: {
316
324
  path: {
317
325
  type: 'string',
318
326
  description: 'Account path (hierarchical, colon-separated)',
319
- example: 'Assets:CN:Bank:ICBC:Checking'
327
+ example: 'Assets:CN:Checking'
320
328
  },
321
329
  type: {
322
330
  type: 'string',
@@ -324,11 +332,6 @@ export const $AccountStandardResponseDto = {
324
332
  enum: ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity'],
325
333
  example: 'Assets'
326
334
  },
327
- i18nKey: {
328
- type: 'string',
329
- description: 'i18n key for localized display name',
330
- example: 'account.assets.cn.bank.icbc.checking'
331
- },
332
335
  name: {
333
336
  type: 'string',
334
337
  description: 'Short localized display name',
@@ -353,7 +356,7 @@ export const $AccountStandardResponseDto = {
353
356
  example: 'bank-icbc'
354
357
  }
355
358
  },
356
- required: ['path', 'type', 'i18nKey', 'description', 'tags', 'icon']
359
+ required: ['path', 'type', 'description', 'tags', 'icon']
357
360
  } as const;
358
361
 
359
362
  export const $AccountStandardListResponseDto = {
@@ -383,18 +386,13 @@ export const $AccountStandardListResponseDto = {
383
386
  export const $TemplateMetadataDto = {
384
387
  type: 'object',
385
388
  properties: {
386
- extendable: {
387
- type: 'boolean',
388
- description: 'Whether this path can be extended',
389
- example: true
390
- },
391
389
  rootType: {
392
390
  type: 'string',
393
391
  description: 'Root account type',
394
392
  example: 'Assets'
395
393
  }
396
394
  },
397
- required: ['extendable', 'rootType']
395
+ required: ['rootType']
398
396
  } as const;
399
397
 
400
398
  export const $TemplateMetadataResponseDto = {
@@ -533,7 +531,7 @@ export const $CreatePostingDto = {
533
531
  type: 'string',
534
532
  description:
535
533
  'Account name in Beancount format (must start with uppercase, colon-separated)',
536
- example: 'Assets:Bank:Checking'
534
+ example: 'Assets:Checking'
537
535
  },
538
536
  units: {
539
537
  type: 'string',
@@ -660,13 +658,39 @@ export const $CreateTransactionDto = {
660
658
  required: ['date', 'narration', 'postings']
661
659
  } as const;
662
660
 
661
+ export const $CostDetailDto = {
662
+ type: 'object',
663
+ properties: {
664
+ number: {
665
+ type: 'string',
666
+ description: 'Per-unit cost basis (mirrors engine Cost.number)',
667
+ example: '240'
668
+ },
669
+ currency: {
670
+ type: 'string',
671
+ description: 'Cost currency',
672
+ example: 'USD'
673
+ },
674
+ date: {
675
+ type: 'string',
676
+ description: 'Lot acquisition date (ISO yyyy-mm-dd)',
677
+ example: '2024-01-15'
678
+ },
679
+ label: {
680
+ type: 'string',
681
+ description: 'Lot label',
682
+ example: 'lot-2024-01'
683
+ }
684
+ }
685
+ } as const;
686
+
663
687
  export const $PostingResponseDto = {
664
688
  type: 'object',
665
689
  properties: {
666
690
  account: {
667
691
  type: 'string',
668
692
  description: 'Account name',
669
- example: 'Assets:Bank:Checking'
693
+ example: 'Assets:Checking'
670
694
  },
671
695
  units: {
672
696
  type: 'string',
@@ -678,6 +702,15 @@ export const $PostingResponseDto = {
678
702
  type: 'string',
679
703
  description: 'Currency',
680
704
  example: 'USD'
705
+ },
706
+ cost: {
707
+ description:
708
+ 'Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.',
709
+ allOf: [
710
+ {
711
+ $ref: '#/components/schemas/CostDetailDto'
712
+ }
713
+ ]
681
714
  }
682
715
  },
683
716
  required: ['account']
@@ -1023,7 +1056,7 @@ export const $PostingDetailDto = {
1023
1056
  account: {
1024
1057
  type: 'string',
1025
1058
  description: 'Fully-qualified Beancount account path',
1026
- example: 'Assets:Bank:Checking'
1059
+ example: 'Assets:Checking'
1027
1060
  },
1028
1061
  units: {
1029
1062
  type: 'string',
@@ -1051,6 +1084,15 @@ export const $PostingDetailDto = {
1051
1084
  description: 'Cost date',
1052
1085
  example: '2024-01-15'
1053
1086
  },
1087
+ cost: {
1088
+ description:
1089
+ 'Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.',
1090
+ allOf: [
1091
+ {
1092
+ $ref: '#/components/schemas/CostDetailDto'
1093
+ }
1094
+ ]
1095
+ },
1054
1096
  priceAmount: {
1055
1097
  type: 'string',
1056
1098
  description: 'Price amount',
@@ -1203,6 +1245,77 @@ export const $TransactionDetailDto = {
1203
1245
  ]
1204
1246
  } as const;
1205
1247
 
1248
+ export const $BalanceByCurrencyDto = {
1249
+ type: 'object',
1250
+ properties: {
1251
+ currency: {
1252
+ type: 'string',
1253
+ description: 'ISO 4217 currency code',
1254
+ example: 'CNY'
1255
+ },
1256
+ balance: {
1257
+ type: 'string',
1258
+ description: 'Balance amount',
1259
+ example: '50000.00'
1260
+ }
1261
+ },
1262
+ required: ['currency', 'balance']
1263
+ } as const;
1264
+
1265
+ export const $ExchangeRateWarningDto = {
1266
+ type: 'object',
1267
+ properties: {
1268
+ type: {
1269
+ type: 'string',
1270
+ description: 'Warning type',
1271
+ example: 'MISSING_EXCHANGE_RATE'
1272
+ },
1273
+ currency: {
1274
+ type: 'string',
1275
+ description: 'Currency without exchange rate',
1276
+ example: 'EUR'
1277
+ },
1278
+ totalAmount: {
1279
+ type: 'string',
1280
+ description: 'Total amount affected',
1281
+ example: '1000.00'
1282
+ }
1283
+ },
1284
+ required: ['type', 'currency', 'totalAmount']
1285
+ } as const;
1286
+
1287
+ export const $TransactionListSummaryDto = {
1288
+ type: 'object',
1289
+ properties: {
1290
+ totalAmount: {
1291
+ type: 'string',
1292
+ description:
1293
+ '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.',
1294
+ example: '-6000.00'
1295
+ },
1296
+ currency: {
1297
+ type: 'string',
1298
+ description: 'Base currency (ISO 4217)',
1299
+ example: 'CNY'
1300
+ },
1301
+ balanceByCurrency: {
1302
+ description: 'Raw (unconverted) balance per currency',
1303
+ type: 'array',
1304
+ items: {
1305
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
1306
+ }
1307
+ },
1308
+ warnings: {
1309
+ description: 'Currencies missing an FX rate (omitted when empty)',
1310
+ type: 'array',
1311
+ items: {
1312
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
1313
+ }
1314
+ }
1315
+ },
1316
+ required: ['totalAmount', 'currency', 'balanceByCurrency']
1317
+ } as const;
1318
+
1206
1319
  export const $TransactionListResponseDto = {
1207
1320
  type: 'object',
1208
1321
  properties: {
@@ -1227,6 +1340,15 @@ export const $TransactionListResponseDto = {
1227
1340
  type: 'number',
1228
1341
  description: 'Number of items skipped',
1229
1342
  example: 0
1343
+ },
1344
+ summary: {
1345
+ description:
1346
+ '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.',
1347
+ allOf: [
1348
+ {
1349
+ $ref: '#/components/schemas/TransactionListSummaryDto'
1350
+ }
1351
+ ]
1230
1352
  }
1231
1353
  },
1232
1354
  required: ['data', 'total', 'limit', 'offset']
@@ -1326,7 +1448,7 @@ export const $BalanceResponseDto = {
1326
1448
  account: {
1327
1449
  type: 'string',
1328
1450
  description: 'Account name',
1329
- example: 'Assets:Bank:Checking'
1451
+ example: 'Assets:Checking'
1330
1452
  },
1331
1453
  balance: {
1332
1454
  type: 'string',
@@ -1353,7 +1475,7 @@ export const $MultiCurrencyBalanceResponseDto = {
1353
1475
  account: {
1354
1476
  type: 'string',
1355
1477
  description: 'Account name',
1356
- example: 'Assets:Bank:Checking'
1478
+ example: 'Assets:Checking'
1357
1479
  },
1358
1480
  balances: {
1359
1481
  type: 'object',
@@ -1409,7 +1531,7 @@ export const $TransactionSummaryDto = {
1409
1531
  accountName: {
1410
1532
  type: 'string',
1411
1533
  description: 'Source account name (first posting)',
1412
- example: 'Assets:Bank:Checking'
1534
+ example: 'Assets:Checking'
1413
1535
  },
1414
1536
  sourceType: {
1415
1537
  type: 'string',
@@ -1811,7 +1933,8 @@ export const $ResolveResultDto = {
1811
1933
  },
1812
1934
  resolutionId: {
1813
1935
  type: 'string',
1814
- description: 'Resolution ID for undo'
1936
+ description:
1937
+ 'Resolution ID for undo. Absent when the resolver rejected the decision (review stayed PENDING).'
1815
1938
  },
1816
1939
  canUndo: {
1817
1940
  type: 'boolean',
@@ -1829,7 +1952,7 @@ export const $ResolveResultDto = {
1829
1952
  example: 'rule_01HXK5V8N2M3P4Q5R6S7T8U9V0'
1830
1953
  }
1831
1954
  },
1832
- required: ['success', 'resolutionId', 'canUndo', 'undoDeadline']
1955
+ required: ['success']
1833
1956
  } as const;
1834
1957
 
1835
1958
  export const $UndoResultDto = {
@@ -2700,65 +2823,222 @@ export const $UpdateCommodityDto = {
2700
2823
  }
2701
2824
  } as const;
2702
2825
 
2703
- export const $CreateRecurringRuleDto = {
2826
+ export const $CreateBeanPriceDto = {
2704
2827
  type: 'object',
2705
2828
  properties: {
2706
- name: {
2707
- type: 'string',
2708
- description: 'Rule name (unique per user)',
2709
- maxLength: 100
2710
- },
2711
- icon: {
2829
+ currency: {
2712
2830
  type: 'string',
2713
- description: 'Icon emoji',
2714
- maxLength: 10
2831
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2832
+ example: 'USD'
2715
2833
  },
2716
- frequency: {
2834
+ quoteCurrency: {
2717
2835
  type: 'string',
2718
- description: 'Recurring frequency',
2719
- enum: [
2720
- 'WEEKLY',
2721
- 'BIWEEKLY',
2722
- 'MONTHLY',
2723
- 'BIMONTHLY',
2724
- 'QUARTERLY',
2725
- 'YEARLY',
2726
- 'CUSTOM'
2727
- ]
2836
+ description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
2837
+ example: 'CNY'
2728
2838
  },
2729
- expectedAmount: {
2839
+ amount: {
2730
2840
  type: 'number',
2731
- description: 'Expected amount (positive number)',
2841
+ description:
2842
+ 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
2843
+ example: 175.5,
2732
2844
  minimum: 0
2733
2845
  },
2734
- expectedDay: {
2735
- type: 'number',
2736
- description: 'Expected day of month (1-31)',
2737
- minimum: 1,
2738
- maximum: 31
2846
+ date: {
2847
+ type: 'string',
2848
+ description: 'Price date (ISO 8601 format)',
2849
+ example: '2024-11-05'
2739
2850
  },
2740
- customIntervalDays: {
2741
- type: 'number',
2742
- description: 'Custom interval in days (required for CUSTOM frequency)',
2743
- minimum: 1
2851
+ metadata: {
2852
+ type: 'object',
2853
+ description:
2854
+ 'Metadata (validated by Zod schema, max field lengths enforced)',
2855
+ example: {
2856
+ source: 'MANUAL',
2857
+ note: 'Bank valuation report',
2858
+ confidence: 0.95
2859
+ }
2860
+ }
2861
+ },
2862
+ required: ['currency', 'quoteCurrency', 'amount', 'date']
2863
+ } as const;
2864
+
2865
+ export const $PriceResponseDto = {
2866
+ type: 'object',
2867
+ properties: {
2868
+ id: {
2869
+ type: 'string',
2870
+ description: 'Unique identifier',
2871
+ example: 'uuid-123-456'
2872
+ },
2873
+ userId: {
2874
+ type: 'string',
2875
+ description: 'User ID (owner of the price)',
2876
+ example: 'user-123'
2744
2877
  },
2745
2878
  currency: {
2746
2879
  type: 'string',
2747
- description: 'Currency code',
2748
- default: 'CNY',
2749
- maxLength: 10
2880
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2881
+ example: 'BTC'
2750
2882
  },
2751
- matchPayeePattern: {
2883
+ quoteCurrency: {
2752
2884
  type: 'string',
2753
- description: 'Payee matching pattern (supports wildcards)',
2754
- maxLength: 200
2885
+ description: 'Quote currency (pricing currency, e.g., USD, CNY)',
2886
+ example: 'USD'
2755
2887
  },
2756
- matchAmountTolerance: {
2888
+ amount: {
2757
2889
  type: 'number',
2758
- description: 'Amount tolerance percentage (0-1)',
2759
- default: 0.075,
2760
- minimum: 0,
2761
- maximum: 1
2890
+ description:
2891
+ 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
2892
+ example: 50000
2893
+ },
2894
+ date: {
2895
+ type: 'string',
2896
+ description:
2897
+ 'Price date (ISO 8601 format). Represents the date this price was valid.',
2898
+ example: '2024-01-01',
2899
+ format: 'date'
2900
+ },
2901
+ meta: {
2902
+ type: 'object',
2903
+ description:
2904
+ 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
2905
+ example: {
2906
+ source: 'MANUAL',
2907
+ note: 'User-defined price',
2908
+ confidence: 1
2909
+ }
2910
+ },
2911
+ createdAt: {
2912
+ format: 'date-time',
2913
+ type: 'string',
2914
+ description: 'Creation timestamp',
2915
+ example: '2024-11-03T10:00:00Z'
2916
+ },
2917
+ updatedAt: {
2918
+ format: 'date-time',
2919
+ type: 'string',
2920
+ description: 'Last update timestamp',
2921
+ example: '2024-11-03T10:00:00Z'
2922
+ }
2923
+ },
2924
+ required: [
2925
+ 'id',
2926
+ 'userId',
2927
+ 'currency',
2928
+ 'quoteCurrency',
2929
+ 'amount',
2930
+ 'date',
2931
+ 'meta',
2932
+ 'createdAt',
2933
+ 'updatedAt'
2934
+ ]
2935
+ } as const;
2936
+
2937
+ export const $PriceListResponseDto = {
2938
+ type: 'object',
2939
+ properties: {
2940
+ items: {
2941
+ description: 'List of prices',
2942
+ type: 'array',
2943
+ items: {
2944
+ $ref: '#/components/schemas/PriceResponseDto'
2945
+ }
2946
+ },
2947
+ total: {
2948
+ type: 'number',
2949
+ description: 'Total number of prices',
2950
+ example: 42
2951
+ }
2952
+ },
2953
+ required: ['items', 'total']
2954
+ } as const;
2955
+
2956
+ export const $UpdateBeanPriceDto = {
2957
+ type: 'object',
2958
+ properties: {
2959
+ currency: {
2960
+ type: 'string',
2961
+ description: 'Currency being priced'
2962
+ },
2963
+ quoteCurrency: {
2964
+ type: 'string',
2965
+ description: 'Quote currency (pricing currency)'
2966
+ },
2967
+ amount: {
2968
+ type: 'number',
2969
+ description: 'Price amount (MUST be >= 0 per Beancount spec)',
2970
+ minimum: 0
2971
+ },
2972
+ date: {
2973
+ type: 'string',
2974
+ description: 'Price date (ISO 8601 format)'
2975
+ },
2976
+ metadata: {
2977
+ type: 'object',
2978
+ description: 'Metadata'
2979
+ }
2980
+ }
2981
+ } as const;
2982
+
2983
+ export const $CreateRecurringRuleDto = {
2984
+ type: 'object',
2985
+ properties: {
2986
+ name: {
2987
+ type: 'string',
2988
+ description: 'Rule name (unique per user)',
2989
+ maxLength: 100
2990
+ },
2991
+ icon: {
2992
+ type: 'string',
2993
+ description: 'Icon emoji',
2994
+ maxLength: 10
2995
+ },
2996
+ frequency: {
2997
+ type: 'string',
2998
+ description: 'Recurring frequency',
2999
+ enum: [
3000
+ 'WEEKLY',
3001
+ 'BIWEEKLY',
3002
+ 'MONTHLY',
3003
+ 'BIMONTHLY',
3004
+ 'QUARTERLY',
3005
+ 'YEARLY',
3006
+ 'CUSTOM'
3007
+ ]
3008
+ },
3009
+ expectedAmount: {
3010
+ type: 'number',
3011
+ description: 'Expected amount (positive number)',
3012
+ minimum: 0
3013
+ },
3014
+ expectedDay: {
3015
+ type: 'number',
3016
+ description: 'Expected day of month (1-31)',
3017
+ minimum: 1,
3018
+ maximum: 31
3019
+ },
3020
+ customIntervalDays: {
3021
+ type: 'number',
3022
+ description: 'Custom interval in days (required for CUSTOM frequency)',
3023
+ minimum: 1
3024
+ },
3025
+ currency: {
3026
+ type: 'string',
3027
+ description: 'Currency code',
3028
+ default: 'CNY',
3029
+ maxLength: 10
3030
+ },
3031
+ matchPayeePattern: {
3032
+ type: 'string',
3033
+ description: 'Payee matching pattern (supports wildcards)',
3034
+ maxLength: 200
3035
+ },
3036
+ matchAmountTolerance: {
3037
+ type: 'number',
3038
+ description: 'Amount tolerance percentage (0-1)',
3039
+ default: 0.075,
3040
+ minimum: 0,
3041
+ maximum: 1
2762
3042
  },
2763
3043
  defaultExpenseAccount: {
2764
3044
  type: 'string',
@@ -4267,103 +4547,492 @@ export const $UpdatePropertyDto = {
4267
4547
  required: ['value']
4268
4548
  } as const;
4269
4549
 
4270
- export const $FileImportDto = {
4550
+ export const $CreateBeanEventDto = {
4271
4551
  type: 'object',
4272
4552
  properties: {
4273
- file: {
4553
+ date: {
4274
4554
  type: 'string',
4275
- format: 'binary',
4276
- description: 'Bill file to import (CSV, PDF, OFX, etc.)',
4277
- example: 'alipay.csv'
4278
- }
4279
- },
4280
- required: ['file']
4281
- } as const;
4282
-
4283
- export const $ImportErrorDto = {
4284
- type: 'object',
4285
- properties: {
4286
- index: {
4287
- type: 'number',
4288
- description: 'Index of failed transaction in the file',
4289
- example: 5
4555
+ description: 'Life event date (ISO 8601)',
4556
+ example: '2024-03-15'
4290
4557
  },
4291
- error: {
4558
+ type: {
4292
4559
  type: 'string',
4293
- description: 'Error message',
4294
- example: 'Transaction does not balance: -100 USD != 0'
4560
+ description:
4561
+ 'Life event type (e.g., "employer", "location", "marital-status") user-defined, no enum constraint at engine layer',
4562
+ example: 'employer'
4563
+ },
4564
+ description: {
4565
+ type: 'string',
4566
+ description:
4567
+ 'Life event description. Empty string is a VALID value (distinct from absence).',
4568
+ example: 'Acme Corp'
4569
+ },
4570
+ meta: {
4571
+ type: 'object',
4572
+ description:
4573
+ 'Product-side metadata (lives in BeanEvent.meta JSON, never in engine Event fields)',
4574
+ example: {
4575
+ note: 'Promotion'
4576
+ }
4295
4577
  }
4296
4578
  },
4297
- required: ['index', 'error']
4579
+ required: ['date', 'type', 'description']
4298
4580
  } as const;
4299
4581
 
4300
- export const $ReviewItemPreviewDto = {
4582
+ export const $EventResponseDto = {
4301
4583
  type: 'object',
4302
4584
  properties: {
4303
- index: {
4304
- type: 'number',
4305
- description: 'Index in the import batch (for tracking)',
4306
- example: 0
4307
- },
4308
- date: {
4585
+ id: {
4309
4586
  type: 'string',
4310
- description: 'Transaction date (ISO format)',
4311
- example: '2026-03-05'
4312
- },
4313
- amount: {
4314
- type: 'number',
4315
- description: 'Transaction amount (absolute value)',
4316
- example: 99
4587
+ description: 'Unique identifier',
4588
+ example: 'uuid-123-456'
4317
4589
  },
4318
- currency: {
4590
+ userId: {
4319
4591
  type: 'string',
4320
- description: 'Currency code',
4321
- example: 'CNY'
4592
+ description: 'User ID (owner of the life event)',
4593
+ example: 'user-123'
4322
4594
  },
4323
- narration: {
4595
+ date: {
4324
4596
  type: 'string',
4325
- description: 'Transaction narration/description',
4326
- example: 'Restaurant expense'
4597
+ description: 'Life event date (ISO 8601 format)',
4598
+ example: '2024-03-15',
4599
+ format: 'date'
4327
4600
  },
4328
- payee: {
4601
+ type: {
4329
4602
  type: 'string',
4330
- description: 'Payee name',
4331
- example: 'Restaurant ABC'
4603
+ description:
4604
+ 'Life event type (user-defined, e.g., "employer", "location")',
4605
+ example: 'employer'
4332
4606
  },
4333
- category: {
4607
+ description: {
4334
4608
  type: 'string',
4335
- description: 'Inferred category from rule matching',
4336
- example: 'food'
4609
+ description:
4610
+ 'Life event description. May be an empty string (a valid value distinct from absence).',
4611
+ example: 'Acme Corp'
4337
4612
  },
4338
- confidence: {
4339
- type: 'number',
4340
- description: 'Confidence score for the match (0-1)',
4341
- example: 0.85
4613
+ meta: {
4614
+ type: 'object',
4615
+ description: 'Product-side metadata (free-form JSON)',
4616
+ example: {
4617
+ note: 'Promotion'
4618
+ }
4342
4619
  },
4343
- branchType: {
4620
+ createdAt: {
4621
+ format: 'date-time',
4344
4622
  type: 'string',
4345
- description: 'Type of branch requiring review',
4346
- enum: [
4347
- 'DUPLICATE',
4348
- 'PAYEE_MATCH',
4349
- 'RULE_MATCH',
4350
- 'ACCOUNT_VALIDATION',
4351
- 'PIPELINE_ERROR'
4352
- ],
4353
- example: 'RULE_MATCH'
4623
+ description: 'Creation timestamp',
4624
+ example: '2024-03-15T10:00:00Z'
4354
4625
  },
4355
- reasons: {
4356
- description: 'Human-readable reasons for requiring review',
4357
- example: ['Moderate confidence rule match', 'Multiple rules matched'],
4358
- type: 'array',
4359
- items: {
4360
- type: 'string'
4361
- }
4626
+ updatedAt: {
4627
+ format: 'date-time',
4628
+ type: 'string',
4629
+ description:
4630
+ 'Last update timestamp. Also emitted as the ETag response header for If-Match optimistic concurrency.',
4631
+ example: '2024-03-15T10:00:00Z'
4362
4632
  }
4363
4633
  },
4364
- required: ['index', 'date', 'narration']
4365
- } as const;
4366
-
4634
+ required: [
4635
+ 'id',
4636
+ 'userId',
4637
+ 'date',
4638
+ 'type',
4639
+ 'description',
4640
+ 'meta',
4641
+ 'createdAt',
4642
+ 'updatedAt'
4643
+ ]
4644
+ } as const;
4645
+
4646
+ export const $EventListResponseDto = {
4647
+ type: 'object',
4648
+ properties: {
4649
+ items: {
4650
+ description: 'List of life events',
4651
+ type: 'array',
4652
+ items: {
4653
+ $ref: '#/components/schemas/EventResponseDto'
4654
+ }
4655
+ },
4656
+ total: {
4657
+ type: 'number',
4658
+ description: 'Total number of life events matching the query',
4659
+ example: 42
4660
+ }
4661
+ },
4662
+ required: ['items', 'total']
4663
+ } as const;
4664
+
4665
+ export const $UpdateBeanEventDto = {
4666
+ type: 'object',
4667
+ properties: {
4668
+ date: {
4669
+ type: 'string',
4670
+ description: 'Life event date (ISO 8601)'
4671
+ },
4672
+ type: {
4673
+ type: 'string',
4674
+ description: 'Life event type (user-defined)'
4675
+ },
4676
+ description: {
4677
+ type: 'string',
4678
+ description:
4679
+ 'Life event description. Empty string is a VALID value (distinct from absence).'
4680
+ },
4681
+ meta: {
4682
+ type: 'object',
4683
+ description: 'Product-side metadata (free-form JSON)'
4684
+ }
4685
+ }
4686
+ } as const;
4687
+
4688
+ export const $OnboardingAccountDto = {
4689
+ type: 'object',
4690
+ properties: {
4691
+ path: {
4692
+ type: 'string',
4693
+ description:
4694
+ 'Account path (Assets/Liabilities only; format validated by the account service)',
4695
+ example: 'Assets:Checking'
4696
+ },
4697
+ currency: {
4698
+ type: 'string',
4699
+ description: 'ISO 4217 currency code (3 letters)',
4700
+ example: 'USD'
4701
+ },
4702
+ openingBalance: {
4703
+ type: 'string',
4704
+ description:
4705
+ 'Opening balance as a non-negative Decimal string (e.g. "1000.00")',
4706
+ example: '1000.00'
4707
+ },
4708
+ platformId: {
4709
+ type: 'string',
4710
+ description:
4711
+ 'Platform ID to bind the account to (references Platform.id); omit for unbound',
4712
+ example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2'
4713
+ }
4714
+ },
4715
+ required: ['path', 'currency']
4716
+ } as const;
4717
+
4718
+ export const $OnboardingDto = {
4719
+ type: 'object',
4720
+ properties: {
4721
+ accounts: {
4722
+ description: 'Asset/Liability accounts to register with opening balances',
4723
+ type: 'array',
4724
+ items: {
4725
+ $ref: '#/components/schemas/OnboardingAccountDto'
4726
+ }
4727
+ },
4728
+ skipAssetRegistration: {
4729
+ type: 'boolean',
4730
+ description:
4731
+ 'Skip asset registration; only bootstrap the core account set',
4732
+ default: false
4733
+ }
4734
+ }
4735
+ } as const;
4736
+
4737
+ export const $ActualBalanceDto = {
4738
+ type: 'object',
4739
+ properties: {
4740
+ amount: {
4741
+ type: 'string',
4742
+ description:
4743
+ 'Actual balance amount as a decimal string (preserves precision for tolerance inference).',
4744
+ example: '1234.56'
4745
+ },
4746
+ ccy: {
4747
+ type: 'string',
4748
+ description: 'Currency code (ISO 4217 or commodity ticker).',
4749
+ example: 'CNY'
4750
+ }
4751
+ },
4752
+ required: ['amount', 'ccy']
4753
+ } as const;
4754
+
4755
+ export const $ComputeReconciliationDto = {
4756
+ type: 'object',
4757
+ properties: {
4758
+ accountId: {
4759
+ type: 'string',
4760
+ description: 'BeanAccount id to reconcile.'
4761
+ },
4762
+ asOfDate: {
4763
+ type: 'string',
4764
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
4765
+ example: '2026-07-24'
4766
+ },
4767
+ actualBalance: {
4768
+ description: 'Actual balance from the external statement.',
4769
+ allOf: [
4770
+ {
4771
+ $ref: '#/components/schemas/ActualBalanceDto'
4772
+ }
4773
+ ]
4774
+ }
4775
+ },
4776
+ required: ['accountId', 'asOfDate', 'actualBalance']
4777
+ } as const;
4778
+
4779
+ export const $ReconciliationComputeResultDto = {
4780
+ type: 'object',
4781
+ properties: {
4782
+ accountId: {
4783
+ type: 'string'
4784
+ },
4785
+ asOfDate: {
4786
+ type: 'string'
4787
+ },
4788
+ bookBalance: {
4789
+ type: 'string',
4790
+ description: 'System-computed book balance (decimal string).'
4791
+ },
4792
+ actualBalance: {
4793
+ type: 'string',
4794
+ description: 'User-entered actual balance (decimal string).'
4795
+ },
4796
+ currency: {
4797
+ type: 'string'
4798
+ },
4799
+ diff: {
4800
+ type: 'string',
4801
+ description: 'Diff = book − actual (decimal string).'
4802
+ },
4803
+ tolerance: {
4804
+ type: 'string',
4805
+ description: 'Applied tolerance (decimal string).'
4806
+ },
4807
+ withinTolerance: {
4808
+ type: 'boolean',
4809
+ description: 'true when |diff| ≤ tolerance.'
4810
+ },
4811
+ suggestedAction: {
4812
+ type: 'string',
4813
+ enum: ['assert', 'pad'],
4814
+ description:
4815
+ 'Suggested next action: assert when within tolerance, pad otherwise.'
4816
+ }
4817
+ },
4818
+ required: [
4819
+ 'accountId',
4820
+ 'asOfDate',
4821
+ 'bookBalance',
4822
+ 'actualBalance',
4823
+ 'currency',
4824
+ 'diff',
4825
+ 'tolerance',
4826
+ 'withinTolerance',
4827
+ 'suggestedAction'
4828
+ ]
4829
+ } as const;
4830
+
4831
+ export const $AssertReconciliationDto = {
4832
+ type: 'object',
4833
+ properties: {
4834
+ accountId: {
4835
+ type: 'string',
4836
+ description: 'BeanAccount id to reconcile.'
4837
+ },
4838
+ asOfDate: {
4839
+ type: 'string',
4840
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
4841
+ example: '2026-07-24'
4842
+ },
4843
+ actualBalance: {
4844
+ description: 'Actual balance from the external statement.',
4845
+ allOf: [
4846
+ {
4847
+ $ref: '#/components/schemas/ActualBalanceDto'
4848
+ }
4849
+ ]
4850
+ },
4851
+ tolerance: {
4852
+ type: 'string',
4853
+ description:
4854
+ 'Optional explicit tolerance override. Omit to infer from amount precision (Beancount default).',
4855
+ example: '0.01'
4856
+ }
4857
+ },
4858
+ required: ['accountId', 'asOfDate', 'actualBalance']
4859
+ } as const;
4860
+
4861
+ export const $ReconciliationRecordDto = {
4862
+ type: 'object',
4863
+ properties: {
4864
+ id: {
4865
+ type: 'string'
4866
+ },
4867
+ accountId: {
4868
+ type: 'string'
4869
+ },
4870
+ date: {
4871
+ type: 'string'
4872
+ },
4873
+ amount: {
4874
+ type: 'string',
4875
+ description: 'Asserted (actual) amount.'
4876
+ },
4877
+ currency: {
4878
+ type: 'string'
4879
+ },
4880
+ tolerance: {
4881
+ type: 'string'
4882
+ },
4883
+ diffAmount: {
4884
+ type: 'string',
4885
+ description: 'book − actual.'
4886
+ },
4887
+ diffCurrency: {
4888
+ type: 'string'
4889
+ },
4890
+ createdAt: {
4891
+ type: 'string'
4892
+ }
4893
+ },
4894
+ required: ['id', 'accountId', 'date', 'amount', 'currency', 'createdAt']
4895
+ } as const;
4896
+
4897
+ export const $PadReconciliationDto = {
4898
+ type: 'object',
4899
+ properties: {
4900
+ accountId: {
4901
+ type: 'string',
4902
+ description: 'BeanAccount id to reconcile.'
4903
+ },
4904
+ asOfDate: {
4905
+ type: 'string',
4906
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
4907
+ example: '2026-07-24'
4908
+ },
4909
+ actualBalance: {
4910
+ description: 'Actual balance from the external statement.',
4911
+ allOf: [
4912
+ {
4913
+ $ref: '#/components/schemas/ActualBalanceDto'
4914
+ }
4915
+ ]
4916
+ },
4917
+ sourceAccount: {
4918
+ type: 'string',
4919
+ description:
4920
+ 'Pad source account. Defaults to Equity:Opening-Balances (official Beancount convention).',
4921
+ example: 'Equity:Opening-Balances',
4922
+ default: 'Equity:Opening-Balances'
4923
+ }
4924
+ },
4925
+ required: ['accountId', 'asOfDate', 'actualBalance']
4926
+ } as const;
4927
+
4928
+ export const $PadResultDto = {
4929
+ type: 'object',
4930
+ properties: {
4931
+ transactionId: {
4932
+ type: 'string',
4933
+ description: 'Created pad adjusting transaction id.'
4934
+ }
4935
+ },
4936
+ required: ['transactionId']
4937
+ } as const;
4938
+
4939
+ export const $FileImportDto = {
4940
+ type: 'object',
4941
+ properties: {
4942
+ file: {
4943
+ type: 'string',
4944
+ format: 'binary',
4945
+ description: 'Bill file to import (CSV, PDF, OFX, etc.)',
4946
+ example: 'alipay.csv'
4947
+ }
4948
+ },
4949
+ required: ['file']
4950
+ } as const;
4951
+
4952
+ export const $ImportErrorDto = {
4953
+ type: 'object',
4954
+ properties: {
4955
+ index: {
4956
+ type: 'number',
4957
+ description: 'Index of failed transaction in the file',
4958
+ example: 5
4959
+ },
4960
+ error: {
4961
+ type: 'string',
4962
+ description: 'Error message',
4963
+ example: 'Transaction does not balance: -100 USD != 0'
4964
+ }
4965
+ },
4966
+ required: ['index', 'error']
4967
+ } as const;
4968
+
4969
+ export const $ReviewItemPreviewDto = {
4970
+ type: 'object',
4971
+ properties: {
4972
+ index: {
4973
+ type: 'number',
4974
+ description: 'Index in the import batch (for tracking)',
4975
+ example: 0
4976
+ },
4977
+ date: {
4978
+ type: 'string',
4979
+ description: 'Transaction date (ISO format)',
4980
+ example: '2026-03-05'
4981
+ },
4982
+ amount: {
4983
+ type: 'number',
4984
+ description: 'Transaction amount (absolute value)',
4985
+ example: 99
4986
+ },
4987
+ currency: {
4988
+ type: 'string',
4989
+ description: 'Currency code',
4990
+ example: 'CNY'
4991
+ },
4992
+ narration: {
4993
+ type: 'string',
4994
+ description: 'Transaction narration/description',
4995
+ example: 'Restaurant expense'
4996
+ },
4997
+ payee: {
4998
+ type: 'string',
4999
+ description: 'Payee name',
5000
+ example: 'Restaurant ABC'
5001
+ },
5002
+ category: {
5003
+ type: 'string',
5004
+ description: 'Inferred category from rule matching',
5005
+ example: 'food'
5006
+ },
5007
+ confidence: {
5008
+ type: 'number',
5009
+ description: 'Confidence score for the match (0-1)',
5010
+ example: 0.85
5011
+ },
5012
+ branchType: {
5013
+ type: 'string',
5014
+ description: 'Type of branch requiring review',
5015
+ enum: [
5016
+ 'DUPLICATE',
5017
+ 'PAYEE_MATCH',
5018
+ 'RULE_MATCH',
5019
+ 'ACCOUNT_VALIDATION',
5020
+ 'PIPELINE_ERROR'
5021
+ ],
5022
+ example: 'RULE_MATCH'
5023
+ },
5024
+ reasons: {
5025
+ description: 'Human-readable reasons for requiring review',
5026
+ example: ['Moderate confidence rule match', 'Multiple rules matched'],
5027
+ type: 'array',
5028
+ items: {
5029
+ type: 'string'
5030
+ }
5031
+ }
5032
+ },
5033
+ required: ['index', 'date', 'narration']
5034
+ } as const;
5035
+
4367
5036
  export const $ImportResultDto = {
4368
5037
  type: 'object',
4369
5038
  properties: {
@@ -4433,7 +5102,7 @@ export const $IdentifyResultDto = {
4433
5102
  account: {
4434
5103
  type: 'string',
4435
5104
  description: 'Default account used by this importer',
4436
- example: 'Assets:Alipay:Balance'
5105
+ example: 'Assets:CN:Alipay:Balance'
4437
5106
  },
4438
5107
  message: {
4439
5108
  type: 'string',
@@ -4450,7 +5119,7 @@ export const $MapperDefaultsDto = {
4450
5119
  sourceAccount: {
4451
5120
  type: 'string',
4452
5121
  description: 'Source account for transactions (Beancount format)',
4453
- example: 'Assets:Alipay:Balance'
5122
+ example: 'Assets:CN:Alipay:Balance'
4454
5123
  },
4455
5124
  currency: {
4456
5125
  type: 'string',
@@ -4487,7 +5156,7 @@ export const $MapperDefaultsDto = {
4487
5156
  description:
4488
5157
  'Payment method to source account mapping. Maps payment method keywords to Beancount account paths. Used by Alipay/WeChat importers to determine sourceAccount based on payment method (e.g., HuaBei, CreditCard).',
4489
5158
  example: {
4490
- HuaBei: 'Liabilities:Alipay:Huabei',
5159
+ HuaBei: 'Liabilities:CN:CreditLine',
4491
5160
  CreditCard: 'Liabilities:CreditCard'
4492
5161
  }
4493
5162
  }
@@ -4608,182 +5277,76 @@ export const $ImporterConfigDto = {
4608
5277
  'version',
4609
5278
  'schema',
4610
5279
  'config',
4611
- 'createdAt',
4612
- 'updatedAt'
4613
- ]
4614
- } as const;
4615
-
4616
- export const $UpdateMapperDefaultsDto = {
4617
- type: 'object',
4618
- properties: {
4619
- sourceAccount: {
4620
- type: 'string',
4621
- description: 'Source account for transactions (Beancount format)',
4622
- example: 'Assets:Alipay:Balance',
4623
- pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4624
- },
4625
- currency: {
4626
- type: 'string',
4627
- description: 'Default currency (ISO 4217 code)',
4628
- example: 'CNY',
4629
- minLength: 3,
4630
- maxLength: 3,
4631
- pattern: '^[A-Z]{3}$'
4632
- },
4633
- expenseAccount: {
4634
- type: 'string',
4635
- description: 'Default expense account (optional)',
4636
- example: 'Expenses:Unknown',
4637
- pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4638
- },
4639
- incomeAccount: {
4640
- type: 'string',
4641
- description: 'Default income account (optional)',
4642
- example: 'Income:Unknown',
4643
- pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4644
- },
4645
- methodAccountMapping: {
4646
- type: 'object',
4647
- description:
4648
- 'Payment method to source account mapping. Maps payment method keywords to Beancount account paths. Used by Alipay/WeChat importers to determine sourceAccount based on payment method (e.g., HuaBei, CreditCard).',
4649
- example: {
4650
- HuaBei: 'Liabilities:Alipay:Huabei',
4651
- CreditCard: 'Liabilities:CreditCard'
4652
- }
4653
- }
4654
- }
4655
- } as const;
4656
-
4657
- export const $UpdateConfigDataDto = {
4658
- type: 'object',
4659
- properties: {
4660
- defaults: {
4661
- description: 'Mapper defaults configuration',
4662
- allOf: [
4663
- {
4664
- $ref: '#/components/schemas/UpdateMapperDefaultsDto'
4665
- }
4666
- ]
4667
- }
4668
- }
4669
- } as const;
4670
-
4671
- export const $UpdateImporterConfigDto = {
4672
- type: 'object',
4673
- properties: {
4674
- data: {
4675
- description: 'Configuration data (v1 schema)',
4676
- allOf: [
4677
- {
4678
- $ref: '#/components/schemas/UpdateConfigDataDto'
4679
- }
4680
- ]
4681
- }
4682
- }
4683
- } as const;
4684
-
4685
- export const $CreatePlatformDto = {
4686
- type: 'object',
4687
- properties: {
4688
- name: {
4689
- type: 'string',
4690
- description: 'Platform name',
4691
- example: 'Binance'
4692
- },
4693
- canonical: {
4694
- type: 'string',
4695
- description: 'Platform canonical identifier (lowercase, kebab-case)',
4696
- example: 'binance'
4697
- },
4698
- aliases: {
4699
- description: 'Platform aliases (multi-language names for lookup)',
4700
- example: ['Binance', 'Binance Exchange', 'BNB'],
4701
- type: 'array',
4702
- items: {
4703
- type: 'string'
4704
- }
4705
- },
4706
- url: {
4707
- type: 'string',
4708
- description: 'Platform URL',
4709
- example: 'https://www.binance.com'
4710
- },
4711
- type: {
4712
- type: 'string',
4713
- description: 'Platform type',
4714
- enum: [
4715
- 'BANK',
4716
- 'BROKERAGE',
4717
- 'CRYPTO_EXCHANGE',
4718
- 'PAYMENT',
4719
- 'INVESTMENT',
4720
- 'INSURANCE',
4721
- 'OTHER'
4722
- ],
4723
- example: 'CRYPTO_EXCHANGE'
4724
- },
4725
- logoUrl: {
4726
- type: 'string',
4727
- description: 'Platform logo URL',
4728
- example: 'https://example.com/logos/binance.png'
4729
- },
4730
- isActive: {
4731
- type: 'boolean',
4732
- description: 'Whether the platform is active',
4733
- default: true
4734
- }
4735
- },
4736
- required: ['name', 'canonical', 'aliases', 'url', 'type']
5280
+ 'createdAt',
5281
+ 'updatedAt'
5282
+ ]
4737
5283
  } as const;
4738
5284
 
4739
- export const $UpdatePlatformDto = {
5285
+ export const $UpdateMapperDefaultsDto = {
4740
5286
  type: 'object',
4741
5287
  properties: {
4742
- name: {
4743
- type: 'string',
4744
- description: 'Platform name',
4745
- example: 'Binance'
4746
- },
4747
- canonical: {
5288
+ sourceAccount: {
4748
5289
  type: 'string',
4749
- description: 'Platform canonical identifier (lowercase, kebab-case)',
4750
- example: 'binance'
4751
- },
4752
- aliases: {
4753
- description: 'Platform aliases (multi-language names for lookup)',
4754
- example: ['Binance', 'Binance Exchange', 'BNB'],
4755
- type: 'array',
4756
- items: {
4757
- type: 'string'
4758
- }
5290
+ description: 'Source account for transactions (Beancount format)',
5291
+ example: 'Assets:CN:Alipay:Balance',
5292
+ pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4759
5293
  },
4760
- url: {
5294
+ currency: {
4761
5295
  type: 'string',
4762
- description: 'Platform URL',
4763
- example: 'https://www.binance.com'
5296
+ description: 'Default currency (ISO 4217 code)',
5297
+ example: 'CNY',
5298
+ minLength: 3,
5299
+ maxLength: 3,
5300
+ pattern: '^[A-Z]{3}$'
4764
5301
  },
4765
- type: {
5302
+ expenseAccount: {
4766
5303
  type: 'string',
4767
- description: 'Platform type',
4768
- enum: [
4769
- 'BANK',
4770
- 'BROKERAGE',
4771
- 'CRYPTO_EXCHANGE',
4772
- 'PAYMENT',
4773
- 'INVESTMENT',
4774
- 'INSURANCE',
4775
- 'OTHER'
4776
- ],
4777
- example: 'CRYPTO_EXCHANGE'
5304
+ description: 'Default expense account (optional)',
5305
+ example: 'Expenses:Unknown',
5306
+ pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4778
5307
  },
4779
- logoUrl: {
5308
+ incomeAccount: {
4780
5309
  type: 'string',
4781
- description: 'Platform logo URL',
4782
- example: 'https://example.com/logos/binance.png'
5310
+ description: 'Default income account (optional)',
5311
+ example: 'Income:Unknown',
5312
+ pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4783
5313
  },
4784
- isActive: {
4785
- type: 'boolean',
4786
- description: 'Whether the platform is active'
5314
+ methodAccountMapping: {
5315
+ type: 'object',
5316
+ description:
5317
+ '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).',
5318
+ example: {
5319
+ HuaBei: 'Liabilities:CN:CreditLine',
5320
+ CreditCard: 'Liabilities:CreditCard'
5321
+ }
5322
+ }
5323
+ }
5324
+ } as const;
5325
+
5326
+ export const $UpdateConfigDataDto = {
5327
+ type: 'object',
5328
+ properties: {
5329
+ defaults: {
5330
+ description: 'Mapper defaults configuration',
5331
+ allOf: [
5332
+ {
5333
+ $ref: '#/components/schemas/UpdateMapperDefaultsDto'
5334
+ }
5335
+ ]
5336
+ }
5337
+ }
5338
+ } as const;
5339
+
5340
+ export const $UpdateImporterConfigDto = {
5341
+ type: 'object',
5342
+ properties: {
5343
+ data: {
5344
+ description: 'Configuration data (v1 schema)',
5345
+ allOf: [
5346
+ {
5347
+ $ref: '#/components/schemas/UpdateConfigDataDto'
5348
+ }
5349
+ ]
4787
5350
  }
4788
5351
  }
4789
5352
  } as const;
@@ -4794,7 +5357,7 @@ export const $ProviderSyncConfigDto = {
4794
5357
  sourceAccount: {
4795
5358
  type: 'string',
4796
5359
  description: 'Source account for the first posting',
4797
- example: 'Assets:Bank:Chase'
5360
+ example: 'Assets:US:Chase:Checking'
4798
5361
  },
4799
5362
  defaultCurrency: {
4800
5363
  type: 'string',
@@ -4815,6 +5378,12 @@ export const $ProviderSyncConfigDto = {
4815
5378
  type: 'boolean',
4816
5379
  description: 'Filter pending transactions',
4817
5380
  default: true
5381
+ },
5382
+ externalAccountId: {
5383
+ type: 'string',
5384
+ description:
5385
+ 'External account ID for per-batch providers (e.g. GoCardless). Overrides sourceAccount when an ExternalAccountLink mapping exists.',
5386
+ example: 'acc_gocardless_001'
4818
5387
  }
4819
5388
  },
4820
5389
  required: [
@@ -4934,6 +5503,94 @@ export const $SupportedProvidersResponseDto = {
4934
5503
  required: ['providers']
4935
5504
  } as const;
4936
5505
 
5506
+ export const $CreateExternalAccountLinkDto = {
5507
+ type: 'object',
5508
+ properties: {
5509
+ provider: {
5510
+ type: 'string',
5511
+ enum: [
5512
+ 'plaid',
5513
+ 'teller',
5514
+ 'truelayer',
5515
+ 'gocardless',
5516
+ 'simplefin',
5517
+ 'yodlee',
5518
+ 'beancount-direct',
5519
+ 'parsed-bill'
5520
+ ],
5521
+ example: 'plaid',
5522
+ description: 'Open Banking provider (whitelist)'
5523
+ },
5524
+ externalAccountId: {
5525
+ type: 'string',
5526
+ example: 'acc-plaid-001',
5527
+ description: 'External account ID from the provider'
5528
+ },
5529
+ beanAccountId: {
5530
+ type: 'string',
5531
+ example: '550e8400-e29b-41d4-a716-446655440000',
5532
+ description: 'Target BeanAccount ID (must belong to the JWT user)'
5533
+ }
5534
+ },
5535
+ required: ['provider', 'externalAccountId', 'beanAccountId']
5536
+ } as const;
5537
+
5538
+ export const $ExternalAccountLinkResponseDto = {
5539
+ type: 'object',
5540
+ properties: {
5541
+ id: {
5542
+ type: 'string'
5543
+ },
5544
+ provider: {
5545
+ type: 'string'
5546
+ },
5547
+ externalAccountId: {
5548
+ type: 'string'
5549
+ },
5550
+ beanAccountId: {
5551
+ type: 'string'
5552
+ },
5553
+ isActive: {
5554
+ type: 'boolean'
5555
+ },
5556
+ createdAt: {
5557
+ type: 'string'
5558
+ },
5559
+ updatedAt: {
5560
+ type: 'string'
5561
+ }
5562
+ },
5563
+ required: [
5564
+ 'id',
5565
+ 'provider',
5566
+ 'externalAccountId',
5567
+ 'beanAccountId',
5568
+ 'isActive',
5569
+ 'createdAt',
5570
+ 'updatedAt'
5571
+ ]
5572
+ } as const;
5573
+
5574
+ export const $ExternalAccountLinkListResponseDto = {
5575
+ type: 'object',
5576
+ properties: {
5577
+ items: {
5578
+ type: 'array',
5579
+ items: {
5580
+ $ref: '#/components/schemas/ExternalAccountLinkResponseDto'
5581
+ }
5582
+ },
5583
+ total: {
5584
+ type: 'number'
5585
+ },
5586
+ provider: {
5587
+ type: 'string',
5588
+ description: 'Filter by provider (query param)'
5589
+ }
5590
+ },
5591
+ required: ['items', 'total']
5592
+ } as const;
5593
+
4937
5594
  export const $ParserTelemetryReportDto = {
4938
5595
  type: 'object',
4939
5596
  properties: {}
@@ -5483,7 +6140,7 @@ export const $NlpSuggestedAccountDto = {
5483
6140
  account: {
5484
6141
  type: 'string',
5485
6142
  description: 'Suggested account path',
5486
- example: 'Assets:Bank:Checking'
6143
+ example: 'Assets:Checking'
5487
6144
  },
5488
6145
  confidence: {
5489
6146
  type: 'number',
@@ -5524,7 +6181,7 @@ export const $NlpDefaultAccountsDto = {
5524
6181
  asset: {
5525
6182
  type: 'string',
5526
6183
  description: 'Default asset account',
5527
- example: 'Assets:Bank:Checking'
6184
+ example: 'Assets:Checking'
5528
6185
  },
5529
6186
  expense: {
5530
6187
  type: 'string',
@@ -5743,24 +6400,172 @@ export const $NlpResponseDto = {
5743
6400
  ]
5744
6401
  }
5745
6402
  },
5746
- required: ['status', 'action']
6403
+ required: ['status', 'action']
6404
+ } as const;
6405
+
6406
+ export const $PlatformListItemDto = {
6407
+ type: 'object',
6408
+ properties: {
6409
+ id: {
6410
+ type: 'string',
6411
+ description: 'Global platform ID'
6412
+ },
6413
+ name: {
6414
+ type: 'string',
6415
+ description: 'Platform name'
6416
+ },
6417
+ url: {
6418
+ type: 'string',
6419
+ description: 'Platform URL'
6420
+ },
6421
+ type: {
6422
+ type: 'string',
6423
+ description: 'Platform type',
6424
+ enum: [
6425
+ 'BANK',
6426
+ 'BROKERAGE',
6427
+ 'CRYPTO_EXCHANGE',
6428
+ 'PAYMENT',
6429
+ 'INVESTMENT',
6430
+ 'INSURANCE',
6431
+ 'OTHER'
6432
+ ]
6433
+ },
6434
+ canonical: {
6435
+ type: 'string',
6436
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
6437
+ },
6438
+ suggestedSegment: {
6439
+ type: 'string',
6440
+ description:
6441
+ 'Suggested path segment — canonical with first char uppercased (ACC_COMP_NAME_RE)'
6442
+ },
6443
+ logoUrl: {
6444
+ type: 'string',
6445
+ description: 'Logo URL',
6446
+ nullable: true
6447
+ },
6448
+ isBound: {
6449
+ type: 'boolean',
6450
+ description: 'Whether user has accounts using this platform'
6451
+ }
6452
+ },
6453
+ required: [
6454
+ 'id',
6455
+ 'name',
6456
+ 'url',
6457
+ 'type',
6458
+ 'canonical',
6459
+ 'suggestedSegment',
6460
+ 'logoUrl',
6461
+ 'isBound'
6462
+ ]
6463
+ } as const;
6464
+
6465
+ export const $CreatePlatformDto = {
6466
+ type: 'object',
6467
+ properties: {
6468
+ name: {
6469
+ type: 'string',
6470
+ description: 'Platform name',
6471
+ example: 'Binance'
6472
+ },
6473
+ canonical: {
6474
+ type: 'string',
6475
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6476
+ example: 'binance'
6477
+ },
6478
+ aliases: {
6479
+ description: 'Platform aliases (multi-language names for lookup)',
6480
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6481
+ type: 'array',
6482
+ items: {
6483
+ type: 'string'
6484
+ }
6485
+ },
6486
+ url: {
6487
+ type: 'string',
6488
+ description: 'Platform URL',
6489
+ example: 'https://www.binance.com'
6490
+ },
6491
+ type: {
6492
+ type: 'string',
6493
+ description: 'Platform type',
6494
+ enum: [
6495
+ 'BANK',
6496
+ 'BROKERAGE',
6497
+ 'CRYPTO_EXCHANGE',
6498
+ 'PAYMENT',
6499
+ 'INVESTMENT',
6500
+ 'INSURANCE',
6501
+ 'OTHER'
6502
+ ],
6503
+ example: 'CRYPTO_EXCHANGE'
6504
+ },
6505
+ logoUrl: {
6506
+ type: 'string',
6507
+ description: 'Platform logo URL',
6508
+ example: 'https://example.com/logos/binance.png'
6509
+ },
6510
+ isActive: {
6511
+ type: 'boolean',
6512
+ description: 'Whether the platform is active',
6513
+ default: true
6514
+ }
6515
+ },
6516
+ required: ['name', 'canonical', 'aliases', 'url', 'type']
5747
6517
  } as const;
5748
6518
 
5749
- export const $BalanceByCurrencyDto = {
6519
+ export const $UpdatePlatformDto = {
5750
6520
  type: 'object',
5751
6521
  properties: {
5752
- currency: {
6522
+ name: {
5753
6523
  type: 'string',
5754
- description: 'ISO 4217 currency code',
5755
- example: 'CNY'
6524
+ description: 'Platform name',
6525
+ example: 'Binance'
5756
6526
  },
5757
- balance: {
6527
+ canonical: {
5758
6528
  type: 'string',
5759
- description: 'Balance amount',
5760
- example: '50000.00'
6529
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6530
+ example: 'binance'
6531
+ },
6532
+ aliases: {
6533
+ description: 'Platform aliases (multi-language names for lookup)',
6534
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6535
+ type: 'array',
6536
+ items: {
6537
+ type: 'string'
6538
+ }
6539
+ },
6540
+ url: {
6541
+ type: 'string',
6542
+ description: 'Platform URL',
6543
+ example: 'https://www.binance.com'
6544
+ },
6545
+ type: {
6546
+ type: 'string',
6547
+ description: 'Platform type',
6548
+ enum: [
6549
+ 'BANK',
6550
+ 'BROKERAGE',
6551
+ 'CRYPTO_EXCHANGE',
6552
+ 'PAYMENT',
6553
+ 'INVESTMENT',
6554
+ 'INSURANCE',
6555
+ 'OTHER'
6556
+ ],
6557
+ example: 'CRYPTO_EXCHANGE'
6558
+ },
6559
+ logoUrl: {
6560
+ type: 'string',
6561
+ description: 'Platform logo URL',
6562
+ example: 'https://example.com/logos/binance.png'
6563
+ },
6564
+ isActive: {
6565
+ type: 'boolean',
6566
+ description: 'Whether the platform is active'
5761
6567
  }
5762
- },
5763
- required: ['currency', 'balance']
6568
+ }
5764
6569
  } as const;
5765
6570
 
5766
6571
  export const $NetWorthByCurrencyDto = {
@@ -5832,28 +6637,6 @@ export const $ConvertedNetWorthDto = {
5832
6637
  ]
5833
6638
  } as const;
5834
6639
 
5835
- export const $ExchangeRateWarningDto = {
5836
- type: 'object',
5837
- properties: {
5838
- type: {
5839
- type: 'string',
5840
- description: 'Warning type',
5841
- example: 'MISSING_EXCHANGE_RATE'
5842
- },
5843
- currency: {
5844
- type: 'string',
5845
- description: 'Currency without exchange rate',
5846
- example: 'EUR'
5847
- },
5848
- totalAmount: {
5849
- type: 'string',
5850
- description: 'Total amount affected',
5851
- example: '1000.00'
5852
- }
5853
- },
5854
- required: ['type', 'currency', 'totalAmount']
5855
- } as const;
5856
-
5857
6640
  export const $NetWorthResponseDto = {
5858
6641
  type: 'object',
5859
6642
  properties: {
@@ -5939,7 +6722,7 @@ export const $AccountItemDto = {
5939
6722
  name: {
5940
6723
  type: 'string',
5941
6724
  description: 'Full account name',
5942
- example: 'Assets:Bank:CMB:Savings'
6725
+ example: 'Assets:CN:CMB:Savings'
5943
6726
  },
5944
6727
  displayName: {
5945
6728
  type: 'string',
@@ -5955,6 +6738,12 @@ export const $AccountItemDto = {
5955
6738
  type: 'string',
5956
6739
  description: 'Currency code',
5957
6740
  example: 'CNY'
6741
+ },
6742
+ convertedBalance: {
6743
+ type: 'string',
6744
+ description:
6745
+ 'FX-converted balance in base currency; omitted when not convertible',
6746
+ example: '50000.00'
5958
6747
  }
5959
6748
  },
5960
6749
  required: ['id', 'name', 'displayName', 'balance', 'currency']
@@ -5981,11 +6770,66 @@ export const $PlatformGroupDto = {
5981
6770
  },
5982
6771
  totalBalance: {
5983
6772
  type: 'string',
5984
- description: 'Total balance across all accounts in platform',
6773
+ description: 'FX-converted total balance in base currency',
6774
+ example: '100000.00'
6775
+ },
6776
+ balanceByCurrency: {
6777
+ description: 'Raw (unconverted) balances grouped by currency',
6778
+ type: 'array',
6779
+ items: {
6780
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
6781
+ }
6782
+ },
6783
+ convertedBalance: {
6784
+ type: 'string',
6785
+ description:
6786
+ 'Converted balance in base currency (omitted when no currency is convertible)',
5985
6787
  example: '100000.00'
6788
+ },
6789
+ sharePct: {
6790
+ type: 'number',
6791
+ description:
6792
+ 'Share of the grand converted total (0-100); 0 when grand total is 0',
6793
+ example: 42.5
6794
+ }
6795
+ },
6796
+ required: [
6797
+ 'platformId',
6798
+ 'platformName',
6799
+ 'accounts',
6800
+ 'totalBalance',
6801
+ 'balanceByCurrency',
6802
+ 'sharePct'
6803
+ ]
6804
+ } as const;
6805
+
6806
+ export const $AccountExchangeRateWarningDto = {
6807
+ type: 'object',
6808
+ properties: {
6809
+ type: {
6810
+ type: 'string',
6811
+ description: 'Warning type',
6812
+ example: 'MISSING_EXCHANGE_RATE'
6813
+ },
6814
+ currency: {
6815
+ type: 'string',
6816
+ description: 'Currency without exchange rate',
6817
+ example: 'USD'
6818
+ },
6819
+ accounts: {
6820
+ description: 'Affected account paths',
6821
+ type: 'array',
6822
+ items: {
6823
+ type: 'string'
6824
+ }
6825
+ },
6826
+ totalAmount: {
6827
+ type: 'string',
6828
+ description: 'Total amount in this currency',
6829
+ example: '5000.00'
5986
6830
  }
5987
6831
  },
5988
- required: ['platformId', 'platformName', 'accounts', 'totalBalance']
6832
+ required: ['type', 'currency', 'accounts', 'totalAmount']
5989
6833
  } as const;
5990
6834
 
5991
6835
  export const $AccountsSummaryDto = {
@@ -5998,9 +6842,21 @@ export const $AccountsSummaryDto = {
5998
6842
  totalPlatforms: {
5999
6843
  type: 'number',
6000
6844
  description: 'Total number of platforms'
6845
+ },
6846
+ baseCurrency: {
6847
+ type: 'string',
6848
+ description: 'Base currency for conversion',
6849
+ example: 'CNY'
6850
+ },
6851
+ warnings: {
6852
+ description: 'Per-account exchange rate warnings',
6853
+ type: 'array',
6854
+ items: {
6855
+ $ref: '#/components/schemas/AccountExchangeRateWarningDto'
6856
+ }
6001
6857
  }
6002
6858
  },
6003
- required: ['totalAccounts', 'totalPlatforms']
6859
+ required: ['totalAccounts', 'totalPlatforms', 'baseCurrency']
6004
6860
  } as const;
6005
6861
 
6006
6862
  export const $AccountsResponseDto = {
@@ -6035,7 +6891,7 @@ export const $AccountItemWithAssetClassDto = {
6035
6891
  name: {
6036
6892
  type: 'string',
6037
6893
  description: 'Full account name',
6038
- example: 'Assets:Bank:CMB:Savings'
6894
+ example: 'Assets:CN:CMB:Savings'
6039
6895
  },
6040
6896
  displayName: {
6041
6897
  type: 'string',
@@ -6052,6 +6908,12 @@ export const $AccountItemWithAssetClassDto = {
6052
6908
  description: 'Currency code',
6053
6909
  example: 'CNY'
6054
6910
  },
6911
+ convertedBalance: {
6912
+ type: 'string',
6913
+ description:
6914
+ 'FX-converted balance in base currency; omitted when not convertible',
6915
+ example: '50000.00'
6916
+ },
6055
6917
  assetClass: {
6056
6918
  type: 'string',
6057
6919
  description: 'Asset class',
@@ -6131,35 +6993,6 @@ export const $AssetClassGroupDto = {
6131
6993
  required: ['assetClass', 'accounts', 'balanceByCurrency']
6132
6994
  } as const;
6133
6995
 
6134
- export const $AccountExchangeRateWarningDto = {
6135
- type: 'object',
6136
- properties: {
6137
- type: {
6138
- type: 'string',
6139
- description: 'Warning type',
6140
- example: 'MISSING_EXCHANGE_RATE'
6141
- },
6142
- currency: {
6143
- type: 'string',
6144
- description: 'Currency without exchange rate',
6145
- example: 'USD'
6146
- },
6147
- accounts: {
6148
- description: 'Affected account paths',
6149
- type: 'array',
6150
- items: {
6151
- type: 'string'
6152
- }
6153
- },
6154
- totalAmount: {
6155
- type: 'string',
6156
- description: 'Total amount in this currency',
6157
- example: '5000.00'
6158
- }
6159
- },
6160
- required: ['type', 'currency', 'accounts', 'totalAmount']
6161
- } as const;
6162
-
6163
6996
  export const $AssetClassSummaryDto = {
6164
6997
  type: 'object',
6165
6998
  properties: {
@@ -6233,7 +7066,7 @@ export const $HoldingAssetClassAccountSliceDto = {
6233
7066
  accountPath: {
6234
7067
  type: 'string',
6235
7068
  description: 'Full account path',
6236
- example: 'Assets:US:Investments:Brokerage'
7069
+ example: 'Assets:US:Fidelity:Brokerage'
6237
7070
  },
6238
7071
  accountCurrency: {
6239
7072
  type: 'string',
@@ -6413,30 +7246,125 @@ export const $CashFlowResponseDto = {
6413
7246
  }
6414
7247
  ]
6415
7248
  },
6416
- converted: {
6417
- description: 'Converted values in base currency',
7249
+ converted: {
7250
+ description: 'Converted values in base currency',
7251
+ allOf: [
7252
+ {
7253
+ $ref: '#/components/schemas/ConvertedCashFlowDto'
7254
+ }
7255
+ ]
7256
+ },
7257
+ warnings: {
7258
+ description: 'Exchange rate warnings',
7259
+ type: 'array',
7260
+ items: {
7261
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
7262
+ }
7263
+ }
7264
+ },
7265
+ required: [
7266
+ 'period',
7267
+ 'income',
7268
+ 'expense',
7269
+ 'netSavings',
7270
+ 'savingsRate',
7271
+ 'currency'
7272
+ ]
7273
+ } as const;
7274
+
7275
+ export const $CategoryGroupDto = {
7276
+ type: 'object',
7277
+ properties: {
7278
+ category: {
7279
+ type: 'string',
7280
+ description:
7281
+ 'Functional category (account-path Group segment); regional and universal account paths merge under it',
7282
+ example: 'Food'
7283
+ },
7284
+ totalExpense: {
7285
+ type: 'string',
7286
+ description:
7287
+ 'Converted total for this category in base currency (expense amount when flow=expense, income amount when flow=income)',
7288
+ example: '1200.00'
7289
+ },
7290
+ sharePct: {
7291
+ type: 'number',
7292
+ description: 'Share of grand total (0-100); 0 when grand total is 0',
7293
+ example: 42.5
7294
+ },
7295
+ balanceByCurrency: {
7296
+ description: 'Raw (unconverted) expense per currency',
7297
+ type: 'array',
7298
+ items: {
7299
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
7300
+ }
7301
+ },
7302
+ convertedBalance: {
7303
+ type: 'string',
7304
+ description:
7305
+ 'Converted total in base currency (omitted when FX missing for all currencies in this category)',
7306
+ example: '1200.00'
7307
+ }
7308
+ },
7309
+ required: ['category', 'totalExpense', 'sharePct', 'balanceByCurrency']
7310
+ } as const;
7311
+
7312
+ export const $ExpensesByCategorySummaryDto = {
7313
+ type: 'object',
7314
+ properties: {
7315
+ totalExpense: {
7316
+ type: 'string',
7317
+ description:
7318
+ 'Total across all categories, converted (convertible categories only); expense totals when flow=expense, income totals when flow=income',
7319
+ example: '5000.00'
7320
+ },
7321
+ categoryCount: {
7322
+ type: 'number',
7323
+ description: 'Number of categories',
7324
+ example: 8
7325
+ }
7326
+ },
7327
+ required: ['totalExpense', 'categoryCount']
7328
+ } as const;
7329
+
7330
+ export const $ExpensesByCategoryResponseDto = {
7331
+ type: 'object',
7332
+ properties: {
7333
+ period: {
7334
+ type: 'string',
7335
+ description: 'Period requested',
7336
+ example: '1m'
7337
+ },
7338
+ baseCurrency: {
7339
+ type: 'string',
7340
+ description: 'Base currency for converted values',
7341
+ example: 'CNY'
7342
+ },
7343
+ groups: {
7344
+ description:
7345
+ 'Expense groups by functional category, sorted by converted total desc',
7346
+ type: 'array',
7347
+ items: {
7348
+ $ref: '#/components/schemas/CategoryGroupDto'
7349
+ }
7350
+ },
7351
+ summary: {
7352
+ description: 'Summary statistics',
6418
7353
  allOf: [
6419
7354
  {
6420
- $ref: '#/components/schemas/ConvertedCashFlowDto'
7355
+ $ref: '#/components/schemas/ExpensesByCategorySummaryDto'
6421
7356
  }
6422
7357
  ]
6423
7358
  },
6424
7359
  warnings: {
6425
- description: 'Exchange rate warnings',
7360
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
6426
7361
  type: 'array',
6427
7362
  items: {
6428
7363
  $ref: '#/components/schemas/ExchangeRateWarningDto'
6429
7364
  }
6430
7365
  }
6431
7366
  },
6432
- required: [
6433
- 'period',
6434
- 'income',
6435
- 'expense',
6436
- 'netSavings',
6437
- 'savingsRate',
6438
- 'currency'
6439
- ]
7367
+ required: ['period', 'baseCurrency', 'groups', 'summary']
6440
7368
  } as const;
6441
7369
 
6442
7370
  export const $MonetaryDto = {
@@ -6728,163 +7656,6 @@ export const $HoldingPnlResponseDto = {
6728
7656
  required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
6729
7657
  } as const;
6730
7658
 
6731
- export const $CreateBeanPriceDto = {
6732
- type: 'object',
6733
- properties: {
6734
- currency: {
6735
- type: 'string',
6736
- description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6737
- example: 'USD'
6738
- },
6739
- quoteCurrency: {
6740
- type: 'string',
6741
- description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
6742
- example: 'CNY'
6743
- },
6744
- amount: {
6745
- type: 'number',
6746
- description:
6747
- 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
6748
- example: 175.5,
6749
- minimum: 0
6750
- },
6751
- date: {
6752
- type: 'string',
6753
- description: 'Price date (ISO 8601 format)',
6754
- example: '2024-11-05'
6755
- },
6756
- metadata: {
6757
- type: 'object',
6758
- description:
6759
- 'Metadata (validated by Zod schema, max field lengths enforced)',
6760
- example: {
6761
- source: 'MANUAL',
6762
- note: 'Bank valuation report',
6763
- confidence: 0.95
6764
- }
6765
- }
6766
- },
6767
- required: ['currency', 'quoteCurrency', 'amount', 'date']
6768
- } as const;
6769
-
6770
- export const $PriceResponseDto = {
6771
- type: 'object',
6772
- properties: {
6773
- id: {
6774
- type: 'string',
6775
- description: 'Unique identifier',
6776
- example: 'uuid-123-456'
6777
- },
6778
- userId: {
6779
- type: 'string',
6780
- description: 'User ID (owner of the price)',
6781
- example: 'user-123'
6782
- },
6783
- currency: {
6784
- type: 'string',
6785
- description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6786
- example: 'BTC'
6787
- },
6788
- quoteCurrency: {
6789
- type: 'string',
6790
- description: 'Quote currency (pricing currency, e.g., USD, CNY)',
6791
- example: 'USD'
6792
- },
6793
- amount: {
6794
- type: 'number',
6795
- description:
6796
- 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
6797
- example: 50000
6798
- },
6799
- date: {
6800
- type: 'string',
6801
- description:
6802
- 'Price date (ISO 8601 format). Represents the date this price was valid.',
6803
- example: '2024-01-01',
6804
- format: 'date'
6805
- },
6806
- meta: {
6807
- type: 'object',
6808
- description:
6809
- 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
6810
- example: {
6811
- source: 'MANUAL',
6812
- note: 'User-defined price',
6813
- confidence: 1
6814
- }
6815
- },
6816
- createdAt: {
6817
- format: 'date-time',
6818
- type: 'string',
6819
- description: 'Creation timestamp',
6820
- example: '2024-11-03T10:00:00Z'
6821
- },
6822
- updatedAt: {
6823
- format: 'date-time',
6824
- type: 'string',
6825
- description: 'Last update timestamp',
6826
- example: '2024-11-03T10:00:00Z'
6827
- }
6828
- },
6829
- required: [
6830
- 'id',
6831
- 'userId',
6832
- 'currency',
6833
- 'quoteCurrency',
6834
- 'amount',
6835
- 'date',
6836
- 'meta',
6837
- 'createdAt',
6838
- 'updatedAt'
6839
- ]
6840
- } as const;
6841
-
6842
- export const $PriceListResponseDto = {
6843
- type: 'object',
6844
- properties: {
6845
- items: {
6846
- description: 'List of prices',
6847
- type: 'array',
6848
- items: {
6849
- $ref: '#/components/schemas/PriceResponseDto'
6850
- }
6851
- },
6852
- total: {
6853
- type: 'number',
6854
- description: 'Total number of prices',
6855
- example: 42
6856
- }
6857
- },
6858
- required: ['items', 'total']
6859
- } as const;
6860
-
6861
- export const $UpdateBeanPriceDto = {
6862
- type: 'object',
6863
- properties: {
6864
- currency: {
6865
- type: 'string',
6866
- description: 'Currency being priced'
6867
- },
6868
- quoteCurrency: {
6869
- type: 'string',
6870
- description: 'Quote currency (pricing currency)'
6871
- },
6872
- amount: {
6873
- type: 'number',
6874
- description: 'Price amount (MUST be >= 0 per Beancount spec)',
6875
- minimum: 0
6876
- },
6877
- date: {
6878
- type: 'string',
6879
- description: 'Price date (ISO 8601 format)'
6880
- },
6881
- metadata: {
6882
- type: 'object',
6883
- description: 'Metadata'
6884
- }
6885
- }
6886
- } as const;
6887
-
6888
7659
  export const $CurrencyBalanceDto = {
6889
7660
  type: 'object',
6890
7661
  properties: {
@@ -6920,6 +7691,16 @@ export const $TimeSeriesPointDto = {
6920
7691
  description: 'Change from previous point',
6921
7692
  example: '5000.00'
6922
7693
  },
7694
+ assets: {
7695
+ type: 'string',
7696
+ description: 'Total assets at this date (in base currency)',
7697
+ example: '494338.00'
7698
+ },
7699
+ liabilities: {
7700
+ type: 'string',
7701
+ description: 'Total liabilities at this date (in base currency)',
7702
+ example: '310098.00'
7703
+ },
6923
7704
  byCurrency: {
6924
7705
  description: 'Multi-currency breakdown for this point',
6925
7706
  type: 'array',
@@ -7029,6 +7810,111 @@ export const $PortfolioTrendsResponseDto = {
7029
7810
  required: ['series', 'summary', 'period', 'granularity', 'currency']
7030
7811
  } as const;
7031
7812
 
7813
+ export const $CashFlowPointDto = {
7814
+ type: 'object',
7815
+ properties: {
7816
+ month: {
7817
+ type: 'string',
7818
+ description: 'Month key (YYYY-MM)',
7819
+ example: '2024-03'
7820
+ },
7821
+ income: {
7822
+ type: 'string',
7823
+ description: 'Income in base currency (absolute, converted)',
7824
+ example: '10000.00'
7825
+ },
7826
+ expense: {
7827
+ type: 'string',
7828
+ description: 'Expense in base currency (absolute, converted)',
7829
+ example: '5000.00'
7830
+ },
7831
+ netSavings: {
7832
+ type: 'string',
7833
+ description: 'netSavings = income − expense (savings positive)',
7834
+ example: '5000.00'
7835
+ }
7836
+ },
7837
+ required: ['month', 'income', 'expense', 'netSavings']
7838
+ } as const;
7839
+
7840
+ export const $CashFlowTrendSummaryDto = {
7841
+ type: 'object',
7842
+ properties: {
7843
+ totalIncome: {
7844
+ type: 'string',
7845
+ description: 'Total income across the period',
7846
+ example: '60000.00'
7847
+ },
7848
+ totalExpense: {
7849
+ type: 'string',
7850
+ description: 'Total expense across the period',
7851
+ example: '30000.00'
7852
+ },
7853
+ totalNetSavings: {
7854
+ type: 'string',
7855
+ description: 'income − expense across the period',
7856
+ example: '30000.00'
7857
+ },
7858
+ averageMonthlyNetSavings: {
7859
+ type: 'string',
7860
+ description:
7861
+ 'totalNetSavings divided by the window length (N months, incl. zero-filled)',
7862
+ example: '5000.00'
7863
+ }
7864
+ },
7865
+ required: [
7866
+ 'totalIncome',
7867
+ 'totalExpense',
7868
+ 'totalNetSavings',
7869
+ 'averageMonthlyNetSavings'
7870
+ ]
7871
+ } as const;
7872
+
7873
+ export const $CashFlowTrendsResponseDto = {
7874
+ type: 'object',
7875
+ properties: {
7876
+ series: {
7877
+ description:
7878
+ 'Monthly cash-flow series (fixed N-month window, zero-filled)',
7879
+ type: 'array',
7880
+ items: {
7881
+ $ref: '#/components/schemas/CashFlowPointDto'
7882
+ }
7883
+ },
7884
+ summary: {
7885
+ description: 'Period totals',
7886
+ allOf: [
7887
+ {
7888
+ $ref: '#/components/schemas/CashFlowTrendSummaryDto'
7889
+ }
7890
+ ]
7891
+ },
7892
+ period: {
7893
+ type: 'string',
7894
+ description: 'Period requested',
7895
+ example: '6m'
7896
+ },
7897
+ granularity: {
7898
+ type: 'string',
7899
+ description: 'Data granularity (v1 returns month buckets)',
7900
+ example: 'month'
7901
+ },
7902
+ currency: {
7903
+ type: 'string',
7904
+ description: 'Base currency for converted values',
7905
+ example: 'CNY'
7906
+ },
7907
+ warnings: {
7908
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
7909
+ type: 'array',
7910
+ items: {
7911
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
7912
+ }
7913
+ }
7914
+ },
7915
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
7916
+ } as const;
7917
+
7032
7918
  export const $GenerateSnapshotBody = {
7033
7919
  type: 'object',
7034
7920
  properties: {}