@firela/api-types 0.0.0-canary.2b8fcbd8 → 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',
@@ -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',
@@ -4312,40 +4547,429 @@ export const $UpdatePropertyDto = {
4312
4547
  required: ['value']
4313
4548
  } as const;
4314
4549
 
4315
- export const $FileImportDto = {
4550
+ export const $CreateBeanEventDto = {
4316
4551
  type: 'object',
4317
4552
  properties: {
4318
- file: {
4553
+ date: {
4319
4554
  type: 'string',
4320
- format: 'binary',
4321
- description: 'Bill file to import (CSV, PDF, OFX, etc.)',
4322
- example: 'alipay.csv'
4323
- }
4324
- },
4325
- required: ['file']
4326
- } as const;
4327
-
4328
- export const $ImportErrorDto = {
4329
- type: 'object',
4330
- properties: {
4331
- index: {
4332
- type: 'number',
4333
- description: 'Index of failed transaction in the file',
4334
- example: 5
4555
+ description: 'Life event date (ISO 8601)',
4556
+ example: '2024-03-15'
4335
4557
  },
4336
- error: {
4558
+ type: {
4337
4559
  type: 'string',
4338
- description: 'Error message',
4339
- 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
+ }
4340
4577
  }
4341
4578
  },
4342
- required: ['index', 'error']
4579
+ required: ['date', 'type', 'description']
4343
4580
  } as const;
4344
4581
 
4345
- export const $ReviewItemPreviewDto = {
4582
+ export const $EventResponseDto = {
4346
4583
  type: 'object',
4347
4584
  properties: {
4348
- index: {
4585
+ id: {
4586
+ type: 'string',
4587
+ description: 'Unique identifier',
4588
+ example: 'uuid-123-456'
4589
+ },
4590
+ userId: {
4591
+ type: 'string',
4592
+ description: 'User ID (owner of the life event)',
4593
+ example: 'user-123'
4594
+ },
4595
+ date: {
4596
+ type: 'string',
4597
+ description: 'Life event date (ISO 8601 format)',
4598
+ example: '2024-03-15',
4599
+ format: 'date'
4600
+ },
4601
+ type: {
4602
+ type: 'string',
4603
+ description:
4604
+ 'Life event type (user-defined, e.g., "employer", "location")',
4605
+ example: 'employer'
4606
+ },
4607
+ description: {
4608
+ type: 'string',
4609
+ description:
4610
+ 'Life event description. May be an empty string (a valid value distinct from absence).',
4611
+ example: 'Acme Corp'
4612
+ },
4613
+ meta: {
4614
+ type: 'object',
4615
+ description: 'Product-side metadata (free-form JSON)',
4616
+ example: {
4617
+ note: 'Promotion'
4618
+ }
4619
+ },
4620
+ createdAt: {
4621
+ format: 'date-time',
4622
+ type: 'string',
4623
+ description: 'Creation timestamp',
4624
+ example: '2024-03-15T10:00:00Z'
4625
+ },
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'
4632
+ }
4633
+ },
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: {
4349
4973
  type: 'number',
4350
4974
  description: 'Index in the import batch (for tracking)',
4351
4975
  example: 0
@@ -4478,7 +5102,7 @@ export const $IdentifyResultDto = {
4478
5102
  account: {
4479
5103
  type: 'string',
4480
5104
  description: 'Default account used by this importer',
4481
- example: 'Assets:Alipay:Balance'
5105
+ example: 'Assets:CN:Alipay:Balance'
4482
5106
  },
4483
5107
  message: {
4484
5108
  type: 'string',
@@ -4495,7 +5119,7 @@ export const $MapperDefaultsDto = {
4495
5119
  sourceAccount: {
4496
5120
  type: 'string',
4497
5121
  description: 'Source account for transactions (Beancount format)',
4498
- example: 'Assets:Alipay:Balance'
5122
+ example: 'Assets:CN:Alipay:Balance'
4499
5123
  },
4500
5124
  currency: {
4501
5125
  type: 'string',
@@ -4532,7 +5156,7 @@ export const $MapperDefaultsDto = {
4532
5156
  description:
4533
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).',
4534
5158
  example: {
4535
- HuaBei: 'Liabilities:Alipay:Huabei',
5159
+ HuaBei: 'Liabilities:CN:CreditLine',
4536
5160
  CreditCard: 'Liabilities:CreditCard'
4537
5161
  }
4538
5162
  }
@@ -4653,182 +5277,76 @@ export const $ImporterConfigDto = {
4653
5277
  'version',
4654
5278
  'schema',
4655
5279
  'config',
4656
- 'createdAt',
4657
- 'updatedAt'
4658
- ]
4659
- } as const;
4660
-
4661
- export const $UpdateMapperDefaultsDto = {
4662
- type: 'object',
4663
- properties: {
4664
- sourceAccount: {
4665
- type: 'string',
4666
- description: 'Source account for transactions (Beancount format)',
4667
- example: 'Assets:Alipay:Balance',
4668
- pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4669
- },
4670
- currency: {
4671
- type: 'string',
4672
- description: 'Default currency (ISO 4217 code)',
4673
- example: 'CNY',
4674
- minLength: 3,
4675
- maxLength: 3,
4676
- pattern: '^[A-Z]{3}$'
4677
- },
4678
- expenseAccount: {
4679
- type: 'string',
4680
- description: 'Default expense account (optional)',
4681
- example: 'Expenses:Unknown',
4682
- pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4683
- },
4684
- incomeAccount: {
4685
- type: 'string',
4686
- description: 'Default income account (optional)',
4687
- example: 'Income:Unknown',
4688
- pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
4689
- },
4690
- methodAccountMapping: {
4691
- type: 'object',
4692
- description:
4693
- '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).',
4694
- example: {
4695
- HuaBei: 'Liabilities:Alipay:Huabei',
4696
- CreditCard: 'Liabilities:CreditCard'
4697
- }
4698
- }
4699
- }
4700
- } as const;
4701
-
4702
- export const $UpdateConfigDataDto = {
4703
- type: 'object',
4704
- properties: {
4705
- defaults: {
4706
- description: 'Mapper defaults configuration',
4707
- allOf: [
4708
- {
4709
- $ref: '#/components/schemas/UpdateMapperDefaultsDto'
4710
- }
4711
- ]
4712
- }
4713
- }
4714
- } as const;
4715
-
4716
- export const $UpdateImporterConfigDto = {
4717
- type: 'object',
4718
- properties: {
4719
- data: {
4720
- description: 'Configuration data (v1 schema)',
4721
- allOf: [
4722
- {
4723
- $ref: '#/components/schemas/UpdateConfigDataDto'
4724
- }
4725
- ]
4726
- }
4727
- }
4728
- } as const;
4729
-
4730
- export const $CreatePlatformDto = {
4731
- type: 'object',
4732
- properties: {
4733
- name: {
4734
- type: 'string',
4735
- description: 'Platform name',
4736
- example: 'Binance'
4737
- },
4738
- canonical: {
4739
- type: 'string',
4740
- description: 'Platform canonical identifier (lowercase, kebab-case)',
4741
- example: 'binance'
4742
- },
4743
- aliases: {
4744
- description: 'Platform aliases (multi-language names for lookup)',
4745
- example: ['Binance', 'Binance Exchange', 'BNB'],
4746
- type: 'array',
4747
- items: {
4748
- type: 'string'
4749
- }
4750
- },
4751
- url: {
4752
- type: 'string',
4753
- description: 'Platform URL',
4754
- example: 'https://www.binance.com'
4755
- },
4756
- type: {
4757
- type: 'string',
4758
- description: 'Platform type',
4759
- enum: [
4760
- 'BANK',
4761
- 'BROKERAGE',
4762
- 'CRYPTO_EXCHANGE',
4763
- 'PAYMENT',
4764
- 'INVESTMENT',
4765
- 'INSURANCE',
4766
- 'OTHER'
4767
- ],
4768
- example: 'CRYPTO_EXCHANGE'
4769
- },
4770
- logoUrl: {
4771
- type: 'string',
4772
- description: 'Platform logo URL',
4773
- example: 'https://example.com/logos/binance.png'
4774
- },
4775
- isActive: {
4776
- type: 'boolean',
4777
- description: 'Whether the platform is active',
4778
- default: true
4779
- }
4780
- },
4781
- required: ['name', 'canonical', 'aliases', 'url', 'type']
5280
+ 'createdAt',
5281
+ 'updatedAt'
5282
+ ]
4782
5283
  } as const;
4783
5284
 
4784
- export const $UpdatePlatformDto = {
5285
+ export const $UpdateMapperDefaultsDto = {
4785
5286
  type: 'object',
4786
5287
  properties: {
4787
- name: {
4788
- type: 'string',
4789
- description: 'Platform name',
4790
- example: 'Binance'
4791
- },
4792
- canonical: {
5288
+ sourceAccount: {
4793
5289
  type: 'string',
4794
- description: 'Platform canonical identifier (lowercase, kebab-case)',
4795
- example: 'binance'
4796
- },
4797
- aliases: {
4798
- description: 'Platform aliases (multi-language names for lookup)',
4799
- example: ['Binance', 'Binance Exchange', 'BNB'],
4800
- type: 'array',
4801
- items: {
4802
- type: 'string'
4803
- }
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-:]+$'
4804
5293
  },
4805
- url: {
5294
+ currency: {
4806
5295
  type: 'string',
4807
- description: 'Platform URL',
4808
- 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}$'
4809
5301
  },
4810
- type: {
5302
+ expenseAccount: {
4811
5303
  type: 'string',
4812
- description: 'Platform type',
4813
- enum: [
4814
- 'BANK',
4815
- 'BROKERAGE',
4816
- 'CRYPTO_EXCHANGE',
4817
- 'PAYMENT',
4818
- 'INVESTMENT',
4819
- 'INSURANCE',
4820
- 'OTHER'
4821
- ],
4822
- 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-:]+$'
4823
5307
  },
4824
- logoUrl: {
5308
+ incomeAccount: {
4825
5309
  type: 'string',
4826
- description: 'Platform logo URL',
4827
- 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-:]+$'
4828
5313
  },
4829
- isActive: {
4830
- type: 'boolean',
4831
- 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
+ ]
4832
5350
  }
4833
5351
  }
4834
5352
  } as const;
@@ -4839,7 +5357,7 @@ export const $ProviderSyncConfigDto = {
4839
5357
  sourceAccount: {
4840
5358
  type: 'string',
4841
5359
  description: 'Source account for the first posting',
4842
- example: 'Assets:Bank:Chase'
5360
+ example: 'Assets:US:Chase:Checking'
4843
5361
  },
4844
5362
  defaultCurrency: {
4845
5363
  type: 'string',
@@ -4860,6 +5378,12 @@ export const $ProviderSyncConfigDto = {
4860
5378
  type: 'boolean',
4861
5379
  description: 'Filter pending transactions',
4862
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'
4863
5387
  }
4864
5388
  },
4865
5389
  required: [
@@ -4979,6 +5503,94 @@ export const $SupportedProvidersResponseDto = {
4979
5503
  required: ['providers']
4980
5504
  } as const;
4981
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
+
4982
5594
  export const $ParserTelemetryReportDto = {
4983
5595
  type: 'object',
4984
5596
  properties: {}
@@ -5528,7 +6140,7 @@ export const $NlpSuggestedAccountDto = {
5528
6140
  account: {
5529
6141
  type: 'string',
5530
6142
  description: 'Suggested account path',
5531
- example: 'Assets:Bank:Checking'
6143
+ example: 'Assets:Checking'
5532
6144
  },
5533
6145
  confidence: {
5534
6146
  type: 'number',
@@ -5569,7 +6181,7 @@ export const $NlpDefaultAccountsDto = {
5569
6181
  asset: {
5570
6182
  type: 'string',
5571
6183
  description: 'Default asset account',
5572
- example: 'Assets:Bank:Checking'
6184
+ example: 'Assets:Checking'
5573
6185
  },
5574
6186
  expense: {
5575
6187
  type: 'string',
@@ -5788,24 +6400,172 @@ export const $NlpResponseDto = {
5788
6400
  ]
5789
6401
  }
5790
6402
  },
5791
- 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']
5792
6517
  } as const;
5793
6518
 
5794
- export const $BalanceByCurrencyDto = {
6519
+ export const $UpdatePlatformDto = {
5795
6520
  type: 'object',
5796
6521
  properties: {
5797
- currency: {
6522
+ name: {
5798
6523
  type: 'string',
5799
- description: 'ISO 4217 currency code',
5800
- example: 'CNY'
6524
+ description: 'Platform name',
6525
+ example: 'Binance'
5801
6526
  },
5802
- balance: {
6527
+ canonical: {
5803
6528
  type: 'string',
5804
- description: 'Balance amount',
5805
- 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'
5806
6567
  }
5807
- },
5808
- required: ['currency', 'balance']
6568
+ }
5809
6569
  } as const;
5810
6570
 
5811
6571
  export const $NetWorthByCurrencyDto = {
@@ -5877,28 +6637,6 @@ export const $ConvertedNetWorthDto = {
5877
6637
  ]
5878
6638
  } as const;
5879
6639
 
5880
- export const $ExchangeRateWarningDto = {
5881
- type: 'object',
5882
- properties: {
5883
- type: {
5884
- type: 'string',
5885
- description: 'Warning type',
5886
- example: 'MISSING_EXCHANGE_RATE'
5887
- },
5888
- currency: {
5889
- type: 'string',
5890
- description: 'Currency without exchange rate',
5891
- example: 'EUR'
5892
- },
5893
- totalAmount: {
5894
- type: 'string',
5895
- description: 'Total amount affected',
5896
- example: '1000.00'
5897
- }
5898
- },
5899
- required: ['type', 'currency', 'totalAmount']
5900
- } as const;
5901
-
5902
6640
  export const $NetWorthResponseDto = {
5903
6641
  type: 'object',
5904
6642
  properties: {
@@ -5984,7 +6722,7 @@ export const $AccountItemDto = {
5984
6722
  name: {
5985
6723
  type: 'string',
5986
6724
  description: 'Full account name',
5987
- example: 'Assets:Bank:CMB:Savings'
6725
+ example: 'Assets:CN:CMB:Savings'
5988
6726
  },
5989
6727
  displayName: {
5990
6728
  type: 'string',
@@ -6000,6 +6738,12 @@ export const $AccountItemDto = {
6000
6738
  type: 'string',
6001
6739
  description: 'Currency code',
6002
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'
6003
6747
  }
6004
6748
  },
6005
6749
  required: ['id', 'name', 'displayName', 'balance', 'currency']
@@ -6026,11 +6770,66 @@ export const $PlatformGroupDto = {
6026
6770
  },
6027
6771
  totalBalance: {
6028
6772
  type: 'string',
6029
- 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)',
6030
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'
6031
6830
  }
6032
6831
  },
6033
- required: ['platformId', 'platformName', 'accounts', 'totalBalance']
6832
+ required: ['type', 'currency', 'accounts', 'totalAmount']
6034
6833
  } as const;
6035
6834
 
6036
6835
  export const $AccountsSummaryDto = {
@@ -6043,9 +6842,21 @@ export const $AccountsSummaryDto = {
6043
6842
  totalPlatforms: {
6044
6843
  type: 'number',
6045
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
+ }
6046
6857
  }
6047
6858
  },
6048
- required: ['totalAccounts', 'totalPlatforms']
6859
+ required: ['totalAccounts', 'totalPlatforms', 'baseCurrency']
6049
6860
  } as const;
6050
6861
 
6051
6862
  export const $AccountsResponseDto = {
@@ -6080,7 +6891,7 @@ export const $AccountItemWithAssetClassDto = {
6080
6891
  name: {
6081
6892
  type: 'string',
6082
6893
  description: 'Full account name',
6083
- example: 'Assets:Bank:CMB:Savings'
6894
+ example: 'Assets:CN:CMB:Savings'
6084
6895
  },
6085
6896
  displayName: {
6086
6897
  type: 'string',
@@ -6097,6 +6908,12 @@ export const $AccountItemWithAssetClassDto = {
6097
6908
  description: 'Currency code',
6098
6909
  example: 'CNY'
6099
6910
  },
6911
+ convertedBalance: {
6912
+ type: 'string',
6913
+ description:
6914
+ 'FX-converted balance in base currency; omitted when not convertible',
6915
+ example: '50000.00'
6916
+ },
6100
6917
  assetClass: {
6101
6918
  type: 'string',
6102
6919
  description: 'Asset class',
@@ -6176,35 +6993,6 @@ export const $AssetClassGroupDto = {
6176
6993
  required: ['assetClass', 'accounts', 'balanceByCurrency']
6177
6994
  } as const;
6178
6995
 
6179
- export const $AccountExchangeRateWarningDto = {
6180
- type: 'object',
6181
- properties: {
6182
- type: {
6183
- type: 'string',
6184
- description: 'Warning type',
6185
- example: 'MISSING_EXCHANGE_RATE'
6186
- },
6187
- currency: {
6188
- type: 'string',
6189
- description: 'Currency without exchange rate',
6190
- example: 'USD'
6191
- },
6192
- accounts: {
6193
- description: 'Affected account paths',
6194
- type: 'array',
6195
- items: {
6196
- type: 'string'
6197
- }
6198
- },
6199
- totalAmount: {
6200
- type: 'string',
6201
- description: 'Total amount in this currency',
6202
- example: '5000.00'
6203
- }
6204
- },
6205
- required: ['type', 'currency', 'accounts', 'totalAmount']
6206
- } as const;
6207
-
6208
6996
  export const $AssetClassSummaryDto = {
6209
6997
  type: 'object',
6210
6998
  properties: {
@@ -6278,7 +7066,7 @@ export const $HoldingAssetClassAccountSliceDto = {
6278
7066
  accountPath: {
6279
7067
  type: 'string',
6280
7068
  description: 'Full account path',
6281
- example: 'Assets:US:Investments:Brokerage'
7069
+ example: 'Assets:US:Fidelity:Brokerage'
6282
7070
  },
6283
7071
  accountCurrency: {
6284
7072
  type: 'string',
@@ -6458,30 +7246,125 @@ export const $CashFlowResponseDto = {
6458
7246
  }
6459
7247
  ]
6460
7248
  },
6461
- converted: {
6462
- 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',
6463
7353
  allOf: [
6464
7354
  {
6465
- $ref: '#/components/schemas/ConvertedCashFlowDto'
7355
+ $ref: '#/components/schemas/ExpensesByCategorySummaryDto'
6466
7356
  }
6467
7357
  ]
6468
7358
  },
6469
7359
  warnings: {
6470
- description: 'Exchange rate warnings',
7360
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
6471
7361
  type: 'array',
6472
7362
  items: {
6473
7363
  $ref: '#/components/schemas/ExchangeRateWarningDto'
6474
7364
  }
6475
7365
  }
6476
7366
  },
6477
- required: [
6478
- 'period',
6479
- 'income',
6480
- 'expense',
6481
- 'netSavings',
6482
- 'savingsRate',
6483
- 'currency'
6484
- ]
7367
+ required: ['period', 'baseCurrency', 'groups', 'summary']
6485
7368
  } as const;
6486
7369
 
6487
7370
  export const $MonetaryDto = {
@@ -6773,163 +7656,6 @@ export const $HoldingPnlResponseDto = {
6773
7656
  required: ['asOfDate', 'baseCurrency', 'method', 'rows', 'warnings']
6774
7657
  } as const;
6775
7658
 
6776
- export const $CreateBeanPriceDto = {
6777
- type: 'object',
6778
- properties: {
6779
- currency: {
6780
- type: 'string',
6781
- description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6782
- example: 'USD'
6783
- },
6784
- quoteCurrency: {
6785
- type: 'string',
6786
- description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
6787
- example: 'CNY'
6788
- },
6789
- amount: {
6790
- type: 'number',
6791
- description:
6792
- 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
6793
- example: 175.5,
6794
- minimum: 0
6795
- },
6796
- date: {
6797
- type: 'string',
6798
- description: 'Price date (ISO 8601 format)',
6799
- example: '2024-11-05'
6800
- },
6801
- metadata: {
6802
- type: 'object',
6803
- description:
6804
- 'Metadata (validated by Zod schema, max field lengths enforced)',
6805
- example: {
6806
- source: 'MANUAL',
6807
- note: 'Bank valuation report',
6808
- confidence: 0.95
6809
- }
6810
- }
6811
- },
6812
- required: ['currency', 'quoteCurrency', 'amount', 'date']
6813
- } as const;
6814
-
6815
- export const $PriceResponseDto = {
6816
- type: 'object',
6817
- properties: {
6818
- id: {
6819
- type: 'string',
6820
- description: 'Unique identifier',
6821
- example: 'uuid-123-456'
6822
- },
6823
- userId: {
6824
- type: 'string',
6825
- description: 'User ID (owner of the price)',
6826
- example: 'user-123'
6827
- },
6828
- currency: {
6829
- type: 'string',
6830
- description: 'Currency being priced (e.g., USD, AAPL, BTC)',
6831
- example: 'BTC'
6832
- },
6833
- quoteCurrency: {
6834
- type: 'string',
6835
- description: 'Quote currency (pricing currency, e.g., USD, CNY)',
6836
- example: 'USD'
6837
- },
6838
- amount: {
6839
- type: 'number',
6840
- description:
6841
- 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
6842
- example: 50000
6843
- },
6844
- date: {
6845
- type: 'string',
6846
- description:
6847
- 'Price date (ISO 8601 format). Represents the date this price was valid.',
6848
- example: '2024-01-01',
6849
- format: 'date'
6850
- },
6851
- meta: {
6852
- type: 'object',
6853
- description:
6854
- 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
6855
- example: {
6856
- source: 'MANUAL',
6857
- note: 'User-defined price',
6858
- confidence: 1
6859
- }
6860
- },
6861
- createdAt: {
6862
- format: 'date-time',
6863
- type: 'string',
6864
- description: 'Creation timestamp',
6865
- example: '2024-11-03T10:00:00Z'
6866
- },
6867
- updatedAt: {
6868
- format: 'date-time',
6869
- type: 'string',
6870
- description: 'Last update timestamp',
6871
- example: '2024-11-03T10:00:00Z'
6872
- }
6873
- },
6874
- required: [
6875
- 'id',
6876
- 'userId',
6877
- 'currency',
6878
- 'quoteCurrency',
6879
- 'amount',
6880
- 'date',
6881
- 'meta',
6882
- 'createdAt',
6883
- 'updatedAt'
6884
- ]
6885
- } as const;
6886
-
6887
- export const $PriceListResponseDto = {
6888
- type: 'object',
6889
- properties: {
6890
- items: {
6891
- description: 'List of prices',
6892
- type: 'array',
6893
- items: {
6894
- $ref: '#/components/schemas/PriceResponseDto'
6895
- }
6896
- },
6897
- total: {
6898
- type: 'number',
6899
- description: 'Total number of prices',
6900
- example: 42
6901
- }
6902
- },
6903
- required: ['items', 'total']
6904
- } as const;
6905
-
6906
- export const $UpdateBeanPriceDto = {
6907
- type: 'object',
6908
- properties: {
6909
- currency: {
6910
- type: 'string',
6911
- description: 'Currency being priced'
6912
- },
6913
- quoteCurrency: {
6914
- type: 'string',
6915
- description: 'Quote currency (pricing currency)'
6916
- },
6917
- amount: {
6918
- type: 'number',
6919
- description: 'Price amount (MUST be >= 0 per Beancount spec)',
6920
- minimum: 0
6921
- },
6922
- date: {
6923
- type: 'string',
6924
- description: 'Price date (ISO 8601 format)'
6925
- },
6926
- metadata: {
6927
- type: 'object',
6928
- description: 'Metadata'
6929
- }
6930
- }
6931
- } as const;
6932
-
6933
7659
  export const $CurrencyBalanceDto = {
6934
7660
  type: 'object',
6935
7661
  properties: {
@@ -6965,6 +7691,16 @@ export const $TimeSeriesPointDto = {
6965
7691
  description: 'Change from previous point',
6966
7692
  example: '5000.00'
6967
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
+ },
6968
7704
  byCurrency: {
6969
7705
  description: 'Multi-currency breakdown for this point',
6970
7706
  type: 'array',
@@ -7074,6 +7810,111 @@ export const $PortfolioTrendsResponseDto = {
7074
7810
  required: ['series', 'summary', 'period', 'granularity', 'currency']
7075
7811
  } as const;
7076
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
+
7077
7918
  export const $GenerateSnapshotBody = {
7078
7919
  type: 'object',
7079
7920
  properties: {}