@firela/api-types 0.0.0-canary.8c68ebbe → 0.0.0-canary.9256c41b

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',
@@ -692,7 +690,7 @@ export const $PostingResponseDto = {
692
690
  account: {
693
691
  type: 'string',
694
692
  description: 'Account name',
695
- example: 'Assets:Bank:Checking'
693
+ example: 'Assets:Checking'
696
694
  },
697
695
  units: {
698
696
  type: 'string',
@@ -1058,7 +1056,7 @@ export const $PostingDetailDto = {
1058
1056
  account: {
1059
1057
  type: 'string',
1060
1058
  description: 'Fully-qualified Beancount account path',
1061
- example: 'Assets:Bank:Checking'
1059
+ example: 'Assets:Checking'
1062
1060
  },
1063
1061
  units: {
1064
1062
  type: 'string',
@@ -1247,6 +1245,77 @@ export const $TransactionDetailDto = {
1247
1245
  ]
1248
1246
  } as const;
1249
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
+
1250
1319
  export const $TransactionListResponseDto = {
1251
1320
  type: 'object',
1252
1321
  properties: {
@@ -1271,6 +1340,15 @@ export const $TransactionListResponseDto = {
1271
1340
  type: 'number',
1272
1341
  description: 'Number of items skipped',
1273
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
+ ]
1274
1352
  }
1275
1353
  },
1276
1354
  required: ['data', 'total', 'limit', 'offset']
@@ -1370,7 +1448,7 @@ export const $BalanceResponseDto = {
1370
1448
  account: {
1371
1449
  type: 'string',
1372
1450
  description: 'Account name',
1373
- example: 'Assets:Bank:Checking'
1451
+ example: 'Assets:Checking'
1374
1452
  },
1375
1453
  balance: {
1376
1454
  type: 'string',
@@ -1397,7 +1475,7 @@ export const $MultiCurrencyBalanceResponseDto = {
1397
1475
  account: {
1398
1476
  type: 'string',
1399
1477
  description: 'Account name',
1400
- example: 'Assets:Bank:Checking'
1478
+ example: 'Assets:Checking'
1401
1479
  },
1402
1480
  balances: {
1403
1481
  type: 'object',
@@ -1453,7 +1531,7 @@ export const $TransactionSummaryDto = {
1453
1531
  accountName: {
1454
1532
  type: 'string',
1455
1533
  description: 'Source account name (first posting)',
1456
- example: 'Assets:Bank:Checking'
1534
+ example: 'Assets:Checking'
1457
1535
  },
1458
1536
  sourceType: {
1459
1537
  type: 'string',
@@ -2745,127 +2823,284 @@ export const $UpdateCommodityDto = {
2745
2823
  }
2746
2824
  } as const;
2747
2825
 
2748
- export const $CreateRecurringRuleDto = {
2826
+ export const $CreateBeanPriceDto = {
2749
2827
  type: 'object',
2750
2828
  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
2829
  currency: {
2791
2830
  type: 'string',
2792
- description: 'Currency code',
2793
- default: 'CNY',
2794
- maxLength: 10
2831
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2832
+ example: 'USD'
2795
2833
  },
2796
- matchPayeePattern: {
2834
+ quoteCurrency: {
2797
2835
  type: 'string',
2798
- description: 'Payee matching pattern (supports wildcards)',
2799
- maxLength: 200
2836
+ description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
2837
+ example: 'CNY'
2800
2838
  },
2801
- matchAmountTolerance: {
2839
+ amount: {
2802
2840
  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
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,
2844
+ minimum: 0
2827
2845
  },
2828
- startDate: {
2846
+ date: {
2829
2847
  type: 'string',
2830
- description: 'Rule start date (ISO format)'
2848
+ description: 'Price date (ISO 8601 format)',
2849
+ example: '2024-11-05'
2831
2850
  },
2832
- endDate: {
2833
- type: 'string',
2834
- description: 'Rule end date (ISO format)'
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
+ }
2835
2860
  }
2836
2861
  },
2837
- required: [
2838
- 'name',
2839
- 'frequency',
2840
- 'expectedAmount',
2841
- 'currency',
2842
- 'matchAmountTolerance',
2843
- 'autoCreate'
2844
- ]
2862
+ required: ['currency', 'quoteCurrency', 'amount', 'date']
2845
2863
  } as const;
2846
2864
 
2847
- export const $RecurringRuleResponseDto = {
2865
+ export const $PriceResponseDto = {
2848
2866
  type: 'object',
2849
2867
  properties: {
2850
2868
  id: {
2851
2869
  type: 'string',
2852
- description: 'Rule ID'
2870
+ description: 'Unique identifier',
2871
+ example: 'uuid-123-456'
2853
2872
  },
2854
2873
  userId: {
2855
2874
  type: 'string',
2856
- description: 'User ID'
2875
+ description: 'User ID (owner of the price)',
2876
+ example: 'user-123'
2857
2877
  },
2858
- name: {
2878
+ currency: {
2859
2879
  type: 'string',
2860
- description: 'Rule name'
2861
- },
2862
- icon: {
2863
- type: 'object',
2864
- description: 'Icon emoji'
2880
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2881
+ example: 'BTC'
2865
2882
  },
2866
- frequency: {
2883
+ quoteCurrency: {
2867
2884
  type: 'string',
2868
- description: 'Recurring frequency'
2885
+ description: 'Quote currency (pricing currency, e.g., USD, CNY)',
2886
+ example: 'USD'
2887
+ },
2888
+ amount: {
2889
+ type: 'number',
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
3042
+ },
3043
+ defaultExpenseAccount: {
3044
+ type: 'string',
3045
+ description: 'Default expense account for auto-create',
3046
+ maxLength: 200
3047
+ },
3048
+ defaultPaymentAccount: {
3049
+ type: 'string',
3050
+ description: 'Default payment account for auto-create',
3051
+ maxLength: 200
3052
+ },
3053
+ defaultPayee: {
3054
+ type: 'string',
3055
+ description: 'Default payee for auto-create',
3056
+ maxLength: 200
3057
+ },
3058
+ autoCreate: {
3059
+ type: 'boolean',
3060
+ description: 'Auto-create transaction when expected date arrives',
3061
+ default: false
3062
+ },
3063
+ startDate: {
3064
+ type: 'string',
3065
+ description: 'Rule start date (ISO format)'
3066
+ },
3067
+ endDate: {
3068
+ type: 'string',
3069
+ description: 'Rule end date (ISO format)'
3070
+ }
3071
+ },
3072
+ required: [
3073
+ 'name',
3074
+ 'frequency',
3075
+ 'expectedAmount',
3076
+ 'currency',
3077
+ 'matchAmountTolerance',
3078
+ 'autoCreate'
3079
+ ]
3080
+ } as const;
3081
+
3082
+ export const $RecurringRuleResponseDto = {
3083
+ type: 'object',
3084
+ properties: {
3085
+ id: {
3086
+ type: 'string',
3087
+ description: 'Rule ID'
3088
+ },
3089
+ userId: {
3090
+ type: 'string',
3091
+ description: 'User ID'
3092
+ },
3093
+ name: {
3094
+ type: 'string',
3095
+ description: 'Rule name'
3096
+ },
3097
+ icon: {
3098
+ type: 'object',
3099
+ description: 'Icon emoji'
3100
+ },
3101
+ frequency: {
3102
+ type: 'string',
3103
+ description: 'Recurring frequency'
2869
3104
  },
2870
3105
  expectedAmount: {
2871
3106
  type: 'number',
@@ -4189,6 +4424,27 @@ export const $SignupDto = {
4189
4424
  }
4190
4425
  } as const;
4191
4426
 
4427
+ export const $SignupResponseDto = {
4428
+ type: 'object',
4429
+ properties: {
4430
+ authToken: {
4431
+ type: 'string',
4432
+ description: 'JWT auth token',
4433
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
4434
+ },
4435
+ accessToken: {
4436
+ type: 'string',
4437
+ description: 'Auto-generated access token'
4438
+ },
4439
+ role: {
4440
+ type: 'string',
4441
+ description: 'Assigned user role',
4442
+ enum: ['USER', 'ADMIN', 'DEMO', 'INACTIVE', 'PAID', 'OPS']
4443
+ }
4444
+ },
4445
+ required: ['authToken', 'accessToken', 'role']
4446
+ } as const;
4447
+
4192
4448
  export const $UpdateUserSettingDto = {
4193
4449
  type: 'object',
4194
4450
  properties: {
@@ -4450,25 +4706,276 @@ export const $UpdateBeanEventDto = {
4450
4706
  }
4451
4707
  } as const;
4452
4708
 
4453
- export const $FileImportDto = {
4709
+ export const $OnboardingAccountDto = {
4454
4710
  type: 'object',
4455
4711
  properties: {
4456
- file: {
4712
+ path: {
4457
4713
  type: 'string',
4458
- format: 'binary',
4459
- description: 'Bill file to import (CSV, PDF, OFX, etc.)',
4460
- example: 'alipay.csv'
4714
+ description:
4715
+ 'Account path (Assets/Liabilities only; format validated by the account service)',
4716
+ example: 'Assets:Checking'
4717
+ },
4718
+ currency: {
4719
+ type: 'string',
4720
+ description: 'ISO 4217 currency code (3 letters)',
4721
+ example: 'USD'
4722
+ },
4723
+ openingBalance: {
4724
+ type: 'string',
4725
+ description:
4726
+ 'Opening balance as a non-negative Decimal string (e.g. "1000.00")',
4727
+ example: '1000.00'
4728
+ },
4729
+ platformId: {
4730
+ type: 'string',
4731
+ description:
4732
+ 'Platform ID to bind the account to (references Platform.id); omit for unbound',
4733
+ example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2'
4461
4734
  }
4462
4735
  },
4463
- required: ['file']
4736
+ required: ['path', 'currency']
4464
4737
  } as const;
4465
4738
 
4466
- export const $ImportErrorDto = {
4739
+ export const $OnboardingDto = {
4467
4740
  type: 'object',
4468
4741
  properties: {
4469
- index: {
4470
- type: 'number',
4471
- description: 'Index of failed transaction in the file',
4742
+ accounts: {
4743
+ description: 'Asset/Liability accounts to register with opening balances',
4744
+ type: 'array',
4745
+ items: {
4746
+ $ref: '#/components/schemas/OnboardingAccountDto'
4747
+ }
4748
+ },
4749
+ skipAssetRegistration: {
4750
+ type: 'boolean',
4751
+ description:
4752
+ 'Skip asset registration; only bootstrap the core account set',
4753
+ default: false
4754
+ }
4755
+ }
4756
+ } as const;
4757
+
4758
+ export const $ActualBalanceDto = {
4759
+ type: 'object',
4760
+ properties: {
4761
+ amount: {
4762
+ type: 'string',
4763
+ description:
4764
+ 'Actual balance amount as a decimal string (preserves precision for tolerance inference).',
4765
+ example: '1234.56'
4766
+ },
4767
+ ccy: {
4768
+ type: 'string',
4769
+ description: 'Currency code (ISO 4217 or commodity ticker).',
4770
+ example: 'CNY'
4771
+ }
4772
+ },
4773
+ required: ['amount', 'ccy']
4774
+ } as const;
4775
+
4776
+ export const $ComputeReconciliationDto = {
4777
+ type: 'object',
4778
+ properties: {
4779
+ accountId: {
4780
+ type: 'string',
4781
+ description: 'BeanAccount id to reconcile.'
4782
+ },
4783
+ asOfDate: {
4784
+ type: 'string',
4785
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
4786
+ example: '2026-07-24'
4787
+ },
4788
+ actualBalance: {
4789
+ description: 'Actual balance from the external statement.',
4790
+ allOf: [
4791
+ {
4792
+ $ref: '#/components/schemas/ActualBalanceDto'
4793
+ }
4794
+ ]
4795
+ }
4796
+ },
4797
+ required: ['accountId', 'asOfDate', 'actualBalance']
4798
+ } as const;
4799
+
4800
+ export const $ReconciliationComputeResultDto = {
4801
+ type: 'object',
4802
+ properties: {
4803
+ accountId: {
4804
+ type: 'string'
4805
+ },
4806
+ asOfDate: {
4807
+ type: 'string'
4808
+ },
4809
+ bookBalance: {
4810
+ type: 'string',
4811
+ description: 'System-computed book balance (decimal string).'
4812
+ },
4813
+ actualBalance: {
4814
+ type: 'string',
4815
+ description: 'User-entered actual balance (decimal string).'
4816
+ },
4817
+ currency: {
4818
+ type: 'string'
4819
+ },
4820
+ diff: {
4821
+ type: 'string',
4822
+ description: 'Diff = book − actual (decimal string).'
4823
+ },
4824
+ tolerance: {
4825
+ type: 'string',
4826
+ description: 'Applied tolerance (decimal string).'
4827
+ },
4828
+ withinTolerance: {
4829
+ type: 'boolean',
4830
+ description: 'true when |diff| ≤ tolerance.'
4831
+ },
4832
+ suggestedAction: {
4833
+ type: 'string',
4834
+ enum: ['assert', 'pad'],
4835
+ description:
4836
+ 'Suggested next action: assert when within tolerance, pad otherwise.'
4837
+ }
4838
+ },
4839
+ required: [
4840
+ 'accountId',
4841
+ 'asOfDate',
4842
+ 'bookBalance',
4843
+ 'actualBalance',
4844
+ 'currency',
4845
+ 'diff',
4846
+ 'tolerance',
4847
+ 'withinTolerance',
4848
+ 'suggestedAction'
4849
+ ]
4850
+ } as const;
4851
+
4852
+ export const $AssertReconciliationDto = {
4853
+ type: 'object',
4854
+ properties: {
4855
+ accountId: {
4856
+ type: 'string',
4857
+ description: 'BeanAccount id to reconcile.'
4858
+ },
4859
+ asOfDate: {
4860
+ type: 'string',
4861
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
4862
+ example: '2026-07-24'
4863
+ },
4864
+ actualBalance: {
4865
+ description: 'Actual balance from the external statement.',
4866
+ allOf: [
4867
+ {
4868
+ $ref: '#/components/schemas/ActualBalanceDto'
4869
+ }
4870
+ ]
4871
+ },
4872
+ tolerance: {
4873
+ type: 'string',
4874
+ description:
4875
+ 'Optional explicit tolerance override. Omit to infer from amount precision (Beancount default).',
4876
+ example: '0.01'
4877
+ }
4878
+ },
4879
+ required: ['accountId', 'asOfDate', 'actualBalance']
4880
+ } as const;
4881
+
4882
+ export const $ReconciliationRecordDto = {
4883
+ type: 'object',
4884
+ properties: {
4885
+ id: {
4886
+ type: 'string'
4887
+ },
4888
+ accountId: {
4889
+ type: 'string'
4890
+ },
4891
+ date: {
4892
+ type: 'string'
4893
+ },
4894
+ amount: {
4895
+ type: 'string',
4896
+ description: 'Asserted (actual) amount.'
4897
+ },
4898
+ currency: {
4899
+ type: 'string'
4900
+ },
4901
+ tolerance: {
4902
+ type: 'string'
4903
+ },
4904
+ diffAmount: {
4905
+ type: 'string',
4906
+ description: 'book − actual.'
4907
+ },
4908
+ diffCurrency: {
4909
+ type: 'string'
4910
+ },
4911
+ createdAt: {
4912
+ type: 'string'
4913
+ }
4914
+ },
4915
+ required: ['id', 'accountId', 'date', 'amount', 'currency', 'createdAt']
4916
+ } as const;
4917
+
4918
+ export const $PadReconciliationDto = {
4919
+ type: 'object',
4920
+ properties: {
4921
+ accountId: {
4922
+ type: 'string',
4923
+ description: 'BeanAccount id to reconcile.'
4924
+ },
4925
+ asOfDate: {
4926
+ type: 'string',
4927
+ description: 'Assertion date (ISO 8601, e.g. "2026-07-24").',
4928
+ example: '2026-07-24'
4929
+ },
4930
+ actualBalance: {
4931
+ description: 'Actual balance from the external statement.',
4932
+ allOf: [
4933
+ {
4934
+ $ref: '#/components/schemas/ActualBalanceDto'
4935
+ }
4936
+ ]
4937
+ },
4938
+ sourceAccount: {
4939
+ type: 'string',
4940
+ description:
4941
+ 'Pad source account. Defaults to Equity:Opening-Balances (official Beancount convention).',
4942
+ example: 'Equity:Opening-Balances',
4943
+ default: 'Equity:Opening-Balances'
4944
+ }
4945
+ },
4946
+ required: ['accountId', 'asOfDate', 'actualBalance']
4947
+ } as const;
4948
+
4949
+ export const $PadResultDto = {
4950
+ type: 'object',
4951
+ properties: {
4952
+ transactionId: {
4953
+ type: 'string',
4954
+ description: 'Created pad adjusting transaction id.'
4955
+ }
4956
+ },
4957
+ required: ['transactionId']
4958
+ } as const;
4959
+
4960
+ export const $FileImportDto = {
4961
+ type: 'object',
4962
+ properties: {
4963
+ file: {
4964
+ type: 'string',
4965
+ format: 'binary',
4966
+ description: 'Bill file to import (CSV, PDF, OFX, etc.)',
4967
+ example: 'alipay.csv'
4968
+ }
4969
+ },
4970
+ required: ['file']
4971
+ } as const;
4972
+
4973
+ export const $ImportErrorDto = {
4974
+ type: 'object',
4975
+ properties: {
4976
+ index: {
4977
+ type: 'number',
4978
+ description: 'Index of failed transaction in the file',
4472
4979
  example: 5
4473
4980
  },
4474
4981
  error: {
@@ -4616,7 +5123,7 @@ export const $IdentifyResultDto = {
4616
5123
  account: {
4617
5124
  type: 'string',
4618
5125
  description: 'Default account used by this importer',
4619
- example: 'Assets:Alipay:Balance'
5126
+ example: 'Assets:CN:Alipay:Balance'
4620
5127
  },
4621
5128
  message: {
4622
5129
  type: 'string',
@@ -4633,7 +5140,7 @@ export const $MapperDefaultsDto = {
4633
5140
  sourceAccount: {
4634
5141
  type: 'string',
4635
5142
  description: 'Source account for transactions (Beancount format)',
4636
- example: 'Assets:Alipay:Balance'
5143
+ example: 'Assets:CN:Alipay:Balance'
4637
5144
  },
4638
5145
  currency: {
4639
5146
  type: 'string',
@@ -4670,7 +5177,7 @@ export const $MapperDefaultsDto = {
4670
5177
  description:
4671
5178
  '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
5179
  example: {
4673
- HuaBei: 'Liabilities:Alipay:Huabei',
5180
+ HuaBei: 'Liabilities:CN:CreditLine',
4674
5181
  CreditCard: 'Liabilities:CreditCard'
4675
5182
  }
4676
5183
  }
@@ -4802,7 +5309,7 @@ export const $UpdateMapperDefaultsDto = {
4802
5309
  sourceAccount: {
4803
5310
  type: 'string',
4804
5311
  description: 'Source account for transactions (Beancount format)',
4805
- example: 'Assets:Alipay:Balance',
5312
+ example: 'Assets:CN:Alipay:Balance',
4806
5313
  pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4807
5314
  },
4808
5315
  currency: {
@@ -4830,7 +5337,7 @@ export const $UpdateMapperDefaultsDto = {
4830
5337
  description:
4831
5338
  '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
5339
  example: {
4833
- HuaBei: 'Liabilities:Alipay:Huabei',
5340
+ HuaBei: 'Liabilities:CN:CreditLine',
4834
5341
  CreditCard: 'Liabilities:CreditCard'
4835
5342
  }
4836
5343
  }
@@ -4865,119 +5372,13 @@ export const $UpdateImporterConfigDto = {
4865
5372
  }
4866
5373
  } as const;
4867
5374
 
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'
4970
- }
4971
- }
4972
- } as const;
4973
-
4974
5375
  export const $ProviderSyncConfigDto = {
4975
5376
  type: 'object',
4976
5377
  properties: {
4977
5378
  sourceAccount: {
4978
5379
  type: 'string',
4979
5380
  description: 'Source account for the first posting',
4980
- example: 'Assets:Bank:Chase'
5381
+ example: 'Assets:US:Chase:Checking'
4981
5382
  },
4982
5383
  defaultCurrency: {
4983
5384
  type: 'string',
@@ -4998,6 +5399,12 @@ export const $ProviderSyncConfigDto = {
4998
5399
  type: 'boolean',
4999
5400
  description: 'Filter pending transactions',
5000
5401
  default: true
5402
+ },
5403
+ externalAccountId: {
5404
+ type: 'string',
5405
+ description:
5406
+ 'External account ID for per-batch providers (e.g. GoCardless). Overrides sourceAccount when an ExternalAccountLink mapping exists.',
5407
+ example: 'acc_gocardless_001'
5001
5408
  }
5002
5409
  },
5003
5410
  required: [
@@ -5117,6 +5524,94 @@ export const $SupportedProvidersResponseDto = {
5117
5524
  required: ['providers']
5118
5525
  } as const;
5119
5526
 
5527
+ export const $CreateExternalAccountLinkDto = {
5528
+ type: 'object',
5529
+ properties: {
5530
+ provider: {
5531
+ type: 'string',
5532
+ enum: [
5533
+ 'plaid',
5534
+ 'teller',
5535
+ 'truelayer',
5536
+ 'gocardless',
5537
+ 'simplefin',
5538
+ 'yodlee',
5539
+ 'beancount-direct',
5540
+ 'parsed-bill'
5541
+ ],
5542
+ example: 'plaid',
5543
+ description: 'Open Banking provider (whitelist)'
5544
+ },
5545
+ externalAccountId: {
5546
+ type: 'string',
5547
+ example: 'acc-plaid-001',
5548
+ description: 'External account ID from the provider'
5549
+ },
5550
+ beanAccountId: {
5551
+ type: 'string',
5552
+ example: '550e8400-e29b-41d4-a716-446655440000',
5553
+ description: 'Target BeanAccount ID (must belong to the JWT user)'
5554
+ }
5555
+ },
5556
+ required: ['provider', 'externalAccountId', 'beanAccountId']
5557
+ } as const;
5558
+
5559
+ export const $ExternalAccountLinkResponseDto = {
5560
+ type: 'object',
5561
+ properties: {
5562
+ id: {
5563
+ type: 'string'
5564
+ },
5565
+ provider: {
5566
+ type: 'string'
5567
+ },
5568
+ externalAccountId: {
5569
+ type: 'string'
5570
+ },
5571
+ beanAccountId: {
5572
+ type: 'string'
5573
+ },
5574
+ isActive: {
5575
+ type: 'boolean'
5576
+ },
5577
+ createdAt: {
5578
+ type: 'string'
5579
+ },
5580
+ updatedAt: {
5581
+ type: 'string'
5582
+ }
5583
+ },
5584
+ required: [
5585
+ 'id',
5586
+ 'provider',
5587
+ 'externalAccountId',
5588
+ 'beanAccountId',
5589
+ 'isActive',
5590
+ 'createdAt',
5591
+ 'updatedAt'
5592
+ ]
5593
+ } as const;
5594
+
5595
+ export const $ExternalAccountLinkListResponseDto = {
5596
+ type: 'object',
5597
+ properties: {
5598
+ items: {
5599
+ type: 'array',
5600
+ items: {
5601
+ $ref: '#/components/schemas/ExternalAccountLinkResponseDto'
5602
+ }
5603
+ },
5604
+ total: {
5605
+ type: 'number'
5606
+ },
5607
+ provider: {
5608
+ type: 'string',
5609
+ description: 'Filter by provider (query param)'
5610
+ }
5611
+ },
5612
+ required: ['items', 'total']
5613
+ } as const;
5614
+
5120
5615
  export const $ParserTelemetryReportDto = {
5121
5616
  type: 'object',
5122
5617
  properties: {}
@@ -5666,7 +6161,7 @@ export const $NlpSuggestedAccountDto = {
5666
6161
  account: {
5667
6162
  type: 'string',
5668
6163
  description: 'Suggested account path',
5669
- example: 'Assets:Bank:Checking'
6164
+ example: 'Assets:Checking'
5670
6165
  },
5671
6166
  confidence: {
5672
6167
  type: 'number',
@@ -5707,7 +6202,7 @@ export const $NlpDefaultAccountsDto = {
5707
6202
  asset: {
5708
6203
  type: 'string',
5709
6204
  description: 'Default asset account',
5710
- example: 'Assets:Bank:Checking'
6205
+ example: 'Assets:Checking'
5711
6206
  },
5712
6207
  expense: {
5713
6208
  type: 'string',
@@ -5926,24 +6421,255 @@ export const $NlpResponseDto = {
5926
6421
  ]
5927
6422
  }
5928
6423
  },
5929
- required: ['status', 'action']
6424
+ required: ['status', 'action']
6425
+ } as const;
6426
+
6427
+ export const $PlatformListItemDto = {
6428
+ type: 'object',
6429
+ properties: {
6430
+ id: {
6431
+ type: 'string',
6432
+ description: 'Global platform ID'
6433
+ },
6434
+ name: {
6435
+ type: 'string',
6436
+ description: 'Platform name'
6437
+ },
6438
+ url: {
6439
+ type: 'string',
6440
+ description: 'Platform URL'
6441
+ },
6442
+ type: {
6443
+ type: 'string',
6444
+ description: 'Platform type',
6445
+ enum: [
6446
+ 'BANK',
6447
+ 'BROKERAGE',
6448
+ 'CRYPTO_EXCHANGE',
6449
+ 'PAYMENT',
6450
+ 'INVESTMENT',
6451
+ 'INSURANCE',
6452
+ 'OTHER'
6453
+ ]
6454
+ },
6455
+ canonical: {
6456
+ type: 'string',
6457
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
6458
+ },
6459
+ suggestedSegment: {
6460
+ type: 'string',
6461
+ description:
6462
+ 'Suggested path segment — canonical with first char uppercased (ACC_COMP_NAME_RE)'
6463
+ },
6464
+ logoUrl: {
6465
+ type: 'string',
6466
+ description: 'Logo URL',
6467
+ nullable: true
6468
+ },
6469
+ isBound: {
6470
+ type: 'boolean',
6471
+ description: 'Whether user has accounts using this platform'
6472
+ }
6473
+ },
6474
+ required: [
6475
+ 'id',
6476
+ 'name',
6477
+ 'url',
6478
+ 'type',
6479
+ 'canonical',
6480
+ 'suggestedSegment',
6481
+ 'logoUrl',
6482
+ 'isBound'
6483
+ ]
6484
+ } as const;
6485
+
6486
+ export const $PlatformMatchResultDto = {
6487
+ type: 'object',
6488
+ properties: {
6489
+ id: {
6490
+ type: 'string',
6491
+ description: 'Global platform ID'
6492
+ },
6493
+ name: {
6494
+ type: 'string',
6495
+ description: 'Platform name (e.g., "ICBC")'
6496
+ },
6497
+ canonical: {
6498
+ type: 'string',
6499
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
6500
+ },
6501
+ type: {
6502
+ type: 'string',
6503
+ description: 'Platform type',
6504
+ enum: [
6505
+ 'BANK',
6506
+ 'BROKERAGE',
6507
+ 'CRYPTO_EXCHANGE',
6508
+ 'PAYMENT',
6509
+ 'INVESTMENT',
6510
+ 'INSURANCE',
6511
+ 'OTHER'
6512
+ ]
6513
+ },
6514
+ suggestedSegment: {
6515
+ type: 'string',
6516
+ description:
6517
+ 'Suggested path segment — canonical, already in ACCOUNT_RE format'
6518
+ },
6519
+ logoUrl: {
6520
+ type: 'string',
6521
+ description: 'Logo URL',
6522
+ nullable: true
6523
+ },
6524
+ matchType: {
6525
+ type: 'string',
6526
+ description: "How this row matched: 'exact' > 'prefix' > 'substring'",
6527
+ enum: ['exact', 'prefix', 'substring']
6528
+ }
6529
+ },
6530
+ required: [
6531
+ 'id',
6532
+ 'name',
6533
+ 'canonical',
6534
+ 'type',
6535
+ 'suggestedSegment',
6536
+ 'logoUrl',
6537
+ 'matchType'
6538
+ ]
6539
+ } as const;
6540
+
6541
+ export const $PlatformMatchResponseDto = {
6542
+ type: 'object',
6543
+ properties: {
6544
+ platforms: {
6545
+ description: 'Ranked matches, best tier first (at most 10 rows)',
6546
+ type: 'array',
6547
+ items: {
6548
+ $ref: '#/components/schemas/PlatformMatchResultDto'
6549
+ }
6550
+ },
6551
+ matchType: {
6552
+ type: 'string',
6553
+ description:
6554
+ "Overall match quality — top row's tier, or 'none' when no hits",
6555
+ enum: ['none', 'exact', 'prefix', 'substring']
6556
+ },
6557
+ total: {
6558
+ type: 'number',
6559
+ description: 'Total matches before LIMIT (truncation transparency)'
6560
+ },
6561
+ hasMore: {
6562
+ type: 'boolean',
6563
+ description: 'true when total > platforms.length (more matches exist)'
6564
+ }
6565
+ },
6566
+ required: ['platforms', 'matchType', 'total', 'hasMore']
6567
+ } as const;
6568
+
6569
+ export const $CreatePlatformDto = {
6570
+ type: 'object',
6571
+ properties: {
6572
+ name: {
6573
+ type: 'string',
6574
+ description: 'Platform name',
6575
+ example: 'Binance'
6576
+ },
6577
+ canonical: {
6578
+ type: 'string',
6579
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6580
+ example: 'binance'
6581
+ },
6582
+ aliases: {
6583
+ description: 'Platform aliases (multi-language names for lookup)',
6584
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6585
+ type: 'array',
6586
+ items: {
6587
+ type: 'string'
6588
+ }
6589
+ },
6590
+ url: {
6591
+ type: 'string',
6592
+ description: 'Platform URL',
6593
+ example: 'https://www.binance.com'
6594
+ },
6595
+ type: {
6596
+ type: 'string',
6597
+ description: 'Platform type',
6598
+ enum: [
6599
+ 'BANK',
6600
+ 'BROKERAGE',
6601
+ 'CRYPTO_EXCHANGE',
6602
+ 'PAYMENT',
6603
+ 'INVESTMENT',
6604
+ 'INSURANCE',
6605
+ 'OTHER'
6606
+ ],
6607
+ example: 'CRYPTO_EXCHANGE'
6608
+ },
6609
+ logoUrl: {
6610
+ type: 'string',
6611
+ description: 'Platform logo URL',
6612
+ example: 'https://example.com/logos/binance.png'
6613
+ },
6614
+ isActive: {
6615
+ type: 'boolean',
6616
+ description: 'Whether the platform is active',
6617
+ default: true
6618
+ }
6619
+ },
6620
+ required: ['name', 'canonical', 'aliases', 'url', 'type']
5930
6621
  } as const;
5931
6622
 
5932
- export const $BalanceByCurrencyDto = {
6623
+ export const $UpdatePlatformDto = {
5933
6624
  type: 'object',
5934
6625
  properties: {
5935
- currency: {
6626
+ name: {
5936
6627
  type: 'string',
5937
- description: 'ISO 4217 currency code',
5938
- example: 'CNY'
6628
+ description: 'Platform name',
6629
+ example: 'Binance'
5939
6630
  },
5940
- balance: {
6631
+ canonical: {
5941
6632
  type: 'string',
5942
- description: 'Balance amount',
5943
- example: '50000.00'
6633
+ description: 'Platform canonical identifier (lowercase, kebab-case)',
6634
+ example: 'binance'
6635
+ },
6636
+ aliases: {
6637
+ description: 'Platform aliases (multi-language names for lookup)',
6638
+ example: ['Binance', 'Binance Exchange', 'BNB'],
6639
+ type: 'array',
6640
+ items: {
6641
+ type: 'string'
6642
+ }
6643
+ },
6644
+ url: {
6645
+ type: 'string',
6646
+ description: 'Platform URL',
6647
+ example: 'https://www.binance.com'
6648
+ },
6649
+ type: {
6650
+ type: 'string',
6651
+ description: 'Platform type',
6652
+ enum: [
6653
+ 'BANK',
6654
+ 'BROKERAGE',
6655
+ 'CRYPTO_EXCHANGE',
6656
+ 'PAYMENT',
6657
+ 'INVESTMENT',
6658
+ 'INSURANCE',
6659
+ 'OTHER'
6660
+ ],
6661
+ example: 'CRYPTO_EXCHANGE'
6662
+ },
6663
+ logoUrl: {
6664
+ type: 'string',
6665
+ description: 'Platform logo URL',
6666
+ example: 'https://example.com/logos/binance.png'
6667
+ },
6668
+ isActive: {
6669
+ type: 'boolean',
6670
+ description: 'Whether the platform is active'
5944
6671
  }
5945
- },
5946
- required: ['currency', 'balance']
6672
+ }
5947
6673
  } as const;
5948
6674
 
5949
6675
  export const $NetWorthByCurrencyDto = {
@@ -6015,28 +6741,6 @@ export const $ConvertedNetWorthDto = {
6015
6741
  ]
6016
6742
  } as const;
6017
6743
 
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
6744
  export const $NetWorthResponseDto = {
6041
6745
  type: 'object',
6042
6746
  properties: {
@@ -6122,7 +6826,7 @@ export const $AccountItemDto = {
6122
6826
  name: {
6123
6827
  type: 'string',
6124
6828
  description: 'Full account name',
6125
- example: 'Assets:Bank:CMB:Savings'
6829
+ example: 'Assets:CN:CMB:Savings'
6126
6830
  },
6127
6831
  displayName: {
6128
6832
  type: 'string',
@@ -6138,6 +6842,12 @@ export const $AccountItemDto = {
6138
6842
  type: 'string',
6139
6843
  description: 'Currency code',
6140
6844
  example: 'CNY'
6845
+ },
6846
+ convertedBalance: {
6847
+ type: 'string',
6848
+ description:
6849
+ 'FX-converted balance in base currency; omitted when not convertible',
6850
+ example: '50000.00'
6141
6851
  }
6142
6852
  },
6143
6853
  required: ['id', 'name', 'displayName', 'balance', 'currency']
@@ -6164,11 +6874,66 @@ export const $PlatformGroupDto = {
6164
6874
  },
6165
6875
  totalBalance: {
6166
6876
  type: 'string',
6167
- description: 'Total balance across all accounts in platform',
6877
+ description: 'FX-converted total balance in base currency',
6878
+ example: '100000.00'
6879
+ },
6880
+ balanceByCurrency: {
6881
+ description: 'Raw (unconverted) balances grouped by currency',
6882
+ type: 'array',
6883
+ items: {
6884
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
6885
+ }
6886
+ },
6887
+ convertedBalance: {
6888
+ type: 'string',
6889
+ description:
6890
+ 'Converted balance in base currency (omitted when no currency is convertible)',
6168
6891
  example: '100000.00'
6892
+ },
6893
+ sharePct: {
6894
+ type: 'number',
6895
+ description:
6896
+ 'Share of the grand converted total (0-100); 0 when grand total is 0',
6897
+ example: 42.5
6898
+ }
6899
+ },
6900
+ required: [
6901
+ 'platformId',
6902
+ 'platformName',
6903
+ 'accounts',
6904
+ 'totalBalance',
6905
+ 'balanceByCurrency',
6906
+ 'sharePct'
6907
+ ]
6908
+ } as const;
6909
+
6910
+ export const $AccountExchangeRateWarningDto = {
6911
+ type: 'object',
6912
+ properties: {
6913
+ type: {
6914
+ type: 'string',
6915
+ description: 'Warning type',
6916
+ example: 'MISSING_EXCHANGE_RATE'
6917
+ },
6918
+ currency: {
6919
+ type: 'string',
6920
+ description: 'Currency without exchange rate',
6921
+ example: 'USD'
6922
+ },
6923
+ accounts: {
6924
+ description: 'Affected account paths',
6925
+ type: 'array',
6926
+ items: {
6927
+ type: 'string'
6928
+ }
6929
+ },
6930
+ totalAmount: {
6931
+ type: 'string',
6932
+ description: 'Total amount in this currency',
6933
+ example: '5000.00'
6169
6934
  }
6170
6935
  },
6171
- required: ['platformId', 'platformName', 'accounts', 'totalBalance']
6936
+ required: ['type', 'currency', 'accounts', 'totalAmount']
6172
6937
  } as const;
6173
6938
 
6174
6939
  export const $AccountsSummaryDto = {
@@ -6181,9 +6946,21 @@ export const $AccountsSummaryDto = {
6181
6946
  totalPlatforms: {
6182
6947
  type: 'number',
6183
6948
  description: 'Total number of platforms'
6949
+ },
6950
+ baseCurrency: {
6951
+ type: 'string',
6952
+ description: 'Base currency for conversion',
6953
+ example: 'CNY'
6954
+ },
6955
+ warnings: {
6956
+ description: 'Per-account exchange rate warnings',
6957
+ type: 'array',
6958
+ items: {
6959
+ $ref: '#/components/schemas/AccountExchangeRateWarningDto'
6960
+ }
6184
6961
  }
6185
6962
  },
6186
- required: ['totalAccounts', 'totalPlatforms']
6963
+ required: ['totalAccounts', 'totalPlatforms', 'baseCurrency']
6187
6964
  } as const;
6188
6965
 
6189
6966
  export const $AccountsResponseDto = {
@@ -6218,7 +6995,7 @@ export const $AccountItemWithAssetClassDto = {
6218
6995
  name: {
6219
6996
  type: 'string',
6220
6997
  description: 'Full account name',
6221
- example: 'Assets:Bank:CMB:Savings'
6998
+ example: 'Assets:CN:CMB:Savings'
6222
6999
  },
6223
7000
  displayName: {
6224
7001
  type: 'string',
@@ -6235,6 +7012,12 @@ export const $AccountItemWithAssetClassDto = {
6235
7012
  description: 'Currency code',
6236
7013
  example: 'CNY'
6237
7014
  },
7015
+ convertedBalance: {
7016
+ type: 'string',
7017
+ description:
7018
+ 'FX-converted balance in base currency; omitted when not convertible',
7019
+ example: '50000.00'
7020
+ },
6238
7021
  assetClass: {
6239
7022
  type: 'string',
6240
7023
  description: 'Asset class',
@@ -6314,35 +7097,6 @@ export const $AssetClassGroupDto = {
6314
7097
  required: ['assetClass', 'accounts', 'balanceByCurrency']
6315
7098
  } as const;
6316
7099
 
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
7100
  export const $AssetClassSummaryDto = {
6347
7101
  type: 'object',
6348
7102
  properties: {
@@ -6416,7 +7170,7 @@ export const $HoldingAssetClassAccountSliceDto = {
6416
7170
  accountPath: {
6417
7171
  type: 'string',
6418
7172
  description: 'Full account path',
6419
- example: 'Assets:US:Investments:Brokerage'
7173
+ example: 'Assets:US:Fidelity:Brokerage'
6420
7174
  },
6421
7175
  accountCurrency: {
6422
7176
  type: 'string',
@@ -6600,26 +7354,121 @@ export const $CashFlowResponseDto = {
6600
7354
  description: 'Converted values in base currency',
6601
7355
  allOf: [
6602
7356
  {
6603
- $ref: '#/components/schemas/ConvertedCashFlowDto'
7357
+ $ref: '#/components/schemas/ConvertedCashFlowDto'
7358
+ }
7359
+ ]
7360
+ },
7361
+ warnings: {
7362
+ description: 'Exchange rate warnings',
7363
+ type: 'array',
7364
+ items: {
7365
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
7366
+ }
7367
+ }
7368
+ },
7369
+ required: [
7370
+ 'period',
7371
+ 'income',
7372
+ 'expense',
7373
+ 'netSavings',
7374
+ 'savingsRate',
7375
+ 'currency'
7376
+ ]
7377
+ } as const;
7378
+
7379
+ export const $CategoryGroupDto = {
7380
+ type: 'object',
7381
+ properties: {
7382
+ category: {
7383
+ type: 'string',
7384
+ description:
7385
+ 'Functional category (account-path Group segment); regional and universal account paths merge under it',
7386
+ example: 'Food'
7387
+ },
7388
+ totalExpense: {
7389
+ type: 'string',
7390
+ description:
7391
+ 'Converted total for this category in base currency (expense amount when flow=expense, income amount when flow=income)',
7392
+ example: '1200.00'
7393
+ },
7394
+ sharePct: {
7395
+ type: 'number',
7396
+ description: 'Share of grand total (0-100); 0 when grand total is 0',
7397
+ example: 42.5
7398
+ },
7399
+ balanceByCurrency: {
7400
+ description: 'Raw (unconverted) expense per currency',
7401
+ type: 'array',
7402
+ items: {
7403
+ $ref: '#/components/schemas/BalanceByCurrencyDto'
7404
+ }
7405
+ },
7406
+ convertedBalance: {
7407
+ type: 'string',
7408
+ description:
7409
+ 'Converted total in base currency (omitted when FX missing for all currencies in this category)',
7410
+ example: '1200.00'
7411
+ }
7412
+ },
7413
+ required: ['category', 'totalExpense', 'sharePct', 'balanceByCurrency']
7414
+ } as const;
7415
+
7416
+ export const $ExpensesByCategorySummaryDto = {
7417
+ type: 'object',
7418
+ properties: {
7419
+ totalExpense: {
7420
+ type: 'string',
7421
+ description:
7422
+ 'Total across all categories, converted (convertible categories only); expense totals when flow=expense, income totals when flow=income',
7423
+ example: '5000.00'
7424
+ },
7425
+ categoryCount: {
7426
+ type: 'number',
7427
+ description: 'Number of categories',
7428
+ example: 8
7429
+ }
7430
+ },
7431
+ required: ['totalExpense', 'categoryCount']
7432
+ } as const;
7433
+
7434
+ export const $ExpensesByCategoryResponseDto = {
7435
+ type: 'object',
7436
+ properties: {
7437
+ period: {
7438
+ type: 'string',
7439
+ description: 'Period requested',
7440
+ example: '1m'
7441
+ },
7442
+ baseCurrency: {
7443
+ type: 'string',
7444
+ description: 'Base currency for converted values',
7445
+ example: 'CNY'
7446
+ },
7447
+ groups: {
7448
+ description:
7449
+ 'Expense groups by functional category, sorted by converted total desc',
7450
+ type: 'array',
7451
+ items: {
7452
+ $ref: '#/components/schemas/CategoryGroupDto'
7453
+ }
7454
+ },
7455
+ summary: {
7456
+ description: 'Summary statistics',
7457
+ allOf: [
7458
+ {
7459
+ $ref: '#/components/schemas/ExpensesByCategorySummaryDto'
6604
7460
  }
6605
7461
  ]
6606
7462
  },
6607
7463
  warnings: {
6608
- description: 'Exchange rate warnings',
7464
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
6609
7465
  type: 'array',
6610
7466
  items: {
6611
7467
  $ref: '#/components/schemas/ExchangeRateWarningDto'
6612
7468
  }
6613
7469
  }
6614
7470
  },
6615
- required: [
6616
- 'period',
6617
- 'income',
6618
- 'expense',
6619
- 'netSavings',
6620
- 'savingsRate',
6621
- 'currency'
6622
- ]
7471
+ required: ['period', 'baseCurrency', 'groups', 'summary']
6623
7472
  } as const;
6624
7473
 
6625
7474
  export const $MonetaryDto = {
@@ -6911,163 +7760,6 @@ export const $HoldingPnlResponseDto = {
6911
7760
  required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
6912
7761
  } as const;
6913
7762
 
6914
- export const $CreateBeanPriceDto = {
6915
- type: 'object',
6916
- properties: {
6917
- currency: {
6918
- type: 'string',
6919
- description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6920
- example: 'USD'
6921
- },
6922
- quoteCurrency: {
6923
- type: 'string',
6924
- description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
6925
- example: 'CNY'
6926
- },
6927
- amount: {
6928
- type: 'number',
6929
- description:
6930
- 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
6931
- example: 175.5,
6932
- minimum: 0
6933
- },
6934
- date: {
6935
- type: 'string',
6936
- description: 'Price date (ISO 8601 format)',
6937
- example: '2024-11-05'
6938
- },
6939
- metadata: {
6940
- type: 'object',
6941
- description:
6942
- 'Metadata (validated by Zod schema, max field lengths enforced)',
6943
- example: {
6944
- source: 'MANUAL',
6945
- note: 'Bank valuation report',
6946
- confidence: 0.95
6947
- }
6948
- }
6949
- },
6950
- required: ['currency', 'quoteCurrency', 'amount', 'date']
6951
- } as const;
6952
-
6953
- export const $PriceResponseDto = {
6954
- type: 'object',
6955
- properties: {
6956
- id: {
6957
- type: 'string',
6958
- description: 'Unique identifier',
6959
- example: 'uuid-123-456'
6960
- },
6961
- userId: {
6962
- type: 'string',
6963
- description: 'User ID (owner of the price)',
6964
- example: 'user-123'
6965
- },
6966
- currency: {
6967
- type: 'string',
6968
- description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6969
- example: 'BTC'
6970
- },
6971
- quoteCurrency: {
6972
- type: 'string',
6973
- description: 'Quote currency (pricing currency, e.g., USD, CNY)',
6974
- example: 'USD'
6975
- },
6976
- amount: {
6977
- type: 'number',
6978
- description:
6979
- 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
6980
- example: 50000
6981
- },
6982
- date: {
6983
- type: 'string',
6984
- description:
6985
- 'Price date (ISO 8601 format). Represents the date this price was valid.',
6986
- example: '2024-01-01',
6987
- format: 'date'
6988
- },
6989
- meta: {
6990
- type: 'object',
6991
- description:
6992
- 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
6993
- example: {
6994
- source: 'MANUAL',
6995
- note: 'User-defined price',
6996
- confidence: 1
6997
- }
6998
- },
6999
- createdAt: {
7000
- format: 'date-time',
7001
- type: 'string',
7002
- description: 'Creation timestamp',
7003
- example: '2024-11-03T10:00:00Z'
7004
- },
7005
- updatedAt: {
7006
- format: 'date-time',
7007
- type: 'string',
7008
- description: 'Last update timestamp',
7009
- example: '2024-11-03T10:00:00Z'
7010
- }
7011
- },
7012
- required: [
7013
- 'id',
7014
- 'userId',
7015
- 'currency',
7016
- 'quoteCurrency',
7017
- 'amount',
7018
- 'date',
7019
- 'meta',
7020
- 'createdAt',
7021
- 'updatedAt'
7022
- ]
7023
- } as const;
7024
-
7025
- export const $PriceListResponseDto = {
7026
- type: 'object',
7027
- properties: {
7028
- items: {
7029
- description: 'List of prices',
7030
- type: 'array',
7031
- items: {
7032
- $ref: '#/components/schemas/PriceResponseDto'
7033
- }
7034
- },
7035
- total: {
7036
- type: 'number',
7037
- description: 'Total number of prices',
7038
- example: 42
7039
- }
7040
- },
7041
- required: ['items', 'total']
7042
- } as const;
7043
-
7044
- export const $UpdateBeanPriceDto = {
7045
- type: 'object',
7046
- properties: {
7047
- currency: {
7048
- type: 'string',
7049
- description: 'Currency being priced'
7050
- },
7051
- quoteCurrency: {
7052
- type: 'string',
7053
- description: 'Quote currency (pricing currency)'
7054
- },
7055
- amount: {
7056
- type: 'number',
7057
- description: 'Price amount (MUST be >= 0 per Beancount spec)',
7058
- minimum: 0
7059
- },
7060
- date: {
7061
- type: 'string',
7062
- description: 'Price date (ISO 8601 format)'
7063
- },
7064
- metadata: {
7065
- type: 'object',
7066
- description: 'Metadata'
7067
- }
7068
- }
7069
- } as const;
7070
-
7071
7763
  export const $CurrencyBalanceDto = {
7072
7764
  type: 'object',
7073
7765
  properties: {
@@ -7103,6 +7795,16 @@ export const $TimeSeriesPointDto = {
7103
7795
  description: 'Change from previous point',
7104
7796
  example: '5000.00'
7105
7797
  },
7798
+ assets: {
7799
+ type: 'string',
7800
+ description: 'Total assets at this date (in base currency)',
7801
+ example: '494338.00'
7802
+ },
7803
+ liabilities: {
7804
+ type: 'string',
7805
+ description: 'Total liabilities at this date (in base currency)',
7806
+ example: '310098.00'
7807
+ },
7106
7808
  byCurrency: {
7107
7809
  description: 'Multi-currency breakdown for this point',
7108
7810
  type: 'array',
@@ -7212,6 +7914,111 @@ export const $PortfolioTrendsResponseDto = {
7212
7914
  required: ['series', 'summary', 'period', 'granularity', 'currency']
7213
7915
  } as const;
7214
7916
 
7917
+ export const $CashFlowPointDto = {
7918
+ type: 'object',
7919
+ properties: {
7920
+ month: {
7921
+ type: 'string',
7922
+ description: 'Month key (YYYY-MM)',
7923
+ example: '2024-03'
7924
+ },
7925
+ income: {
7926
+ type: 'string',
7927
+ description: 'Income in base currency (absolute, converted)',
7928
+ example: '10000.00'
7929
+ },
7930
+ expense: {
7931
+ type: 'string',
7932
+ description: 'Expense in base currency (absolute, converted)',
7933
+ example: '5000.00'
7934
+ },
7935
+ netSavings: {
7936
+ type: 'string',
7937
+ description: 'netSavings = income − expense (savings positive)',
7938
+ example: '5000.00'
7939
+ }
7940
+ },
7941
+ required: ['month', 'income', 'expense', 'netSavings']
7942
+ } as const;
7943
+
7944
+ export const $CashFlowTrendSummaryDto = {
7945
+ type: 'object',
7946
+ properties: {
7947
+ totalIncome: {
7948
+ type: 'string',
7949
+ description: 'Total income across the period',
7950
+ example: '60000.00'
7951
+ },
7952
+ totalExpense: {
7953
+ type: 'string',
7954
+ description: 'Total expense across the period',
7955
+ example: '30000.00'
7956
+ },
7957
+ totalNetSavings: {
7958
+ type: 'string',
7959
+ description: 'income − expense across the period',
7960
+ example: '30000.00'
7961
+ },
7962
+ averageMonthlyNetSavings: {
7963
+ type: 'string',
7964
+ description:
7965
+ 'totalNetSavings divided by the window length (N months, incl. zero-filled)',
7966
+ example: '5000.00'
7967
+ }
7968
+ },
7969
+ required: [
7970
+ 'totalIncome',
7971
+ 'totalExpense',
7972
+ 'totalNetSavings',
7973
+ 'averageMonthlyNetSavings'
7974
+ ]
7975
+ } as const;
7976
+
7977
+ export const $CashFlowTrendsResponseDto = {
7978
+ type: 'object',
7979
+ properties: {
7980
+ series: {
7981
+ description:
7982
+ 'Monthly cash-flow series (fixed N-month window, zero-filled)',
7983
+ type: 'array',
7984
+ items: {
7985
+ $ref: '#/components/schemas/CashFlowPointDto'
7986
+ }
7987
+ },
7988
+ summary: {
7989
+ description: 'Period totals',
7990
+ allOf: [
7991
+ {
7992
+ $ref: '#/components/schemas/CashFlowTrendSummaryDto'
7993
+ }
7994
+ ]
7995
+ },
7996
+ period: {
7997
+ type: 'string',
7998
+ description: 'Period requested',
7999
+ example: '6m'
8000
+ },
8001
+ granularity: {
8002
+ type: 'string',
8003
+ description: 'Data granularity (v1 returns month buckets)',
8004
+ example: 'month'
8005
+ },
8006
+ currency: {
8007
+ type: 'string',
8008
+ description: 'Base currency for converted values',
8009
+ example: 'CNY'
8010
+ },
8011
+ warnings: {
8012
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
8013
+ type: 'array',
8014
+ items: {
8015
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
8016
+ }
8017
+ }
8018
+ },
8019
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
8020
+ } as const;
8021
+
7215
8022
  export const $GenerateSnapshotBody = {
7216
8023
  type: 'object',
7217
8024
  properties: {}
@@ -7242,3 +8049,15 @@ export const $AnonymousLoginDto = {
7242
8049
  },
7243
8050
  required: ['accessToken']
7244
8051
  } as const;
8052
+
8053
+ export const $AnonymousLoginResponseDto = {
8054
+ type: 'object',
8055
+ properties: {
8056
+ authToken: {
8057
+ type: 'string',
8058
+ description: 'JWT auth token',
8059
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
8060
+ }
8061
+ },
8062
+ required: ['authToken']
8063
+ } as const;