@firela/api-types 0.0.0-canary.d9762ea3 → 0.0.0-canary.da82874e

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.
@@ -51,6 +51,14 @@ export const $CreateAccountDto = {
51
51
  description: 'Icon identifier (overrides template)',
52
52
  example: 'bank-custom'
53
53
  },
54
+ displayName: {
55
+ type: 'string',
56
+ description:
57
+ 'User-set display name override (omit/null = keep the derived name)',
58
+ nullable: true,
59
+ maxLength: 50,
60
+ example: 'Salary card'
61
+ },
54
62
  openDirectiveMeta: {
55
63
  type: 'object',
56
64
  description:
@@ -181,7 +189,8 @@ export const $AccountResponseDto = {
181
189
  },
182
190
  displayName: {
183
191
  type: 'string',
184
- description: 'Localized display name (ADR-0114, read-time projection)',
192
+ description:
193
+ 'Display name with precedence: user-set name (#762) > ADR-0114 localized name > path leaf (read-time projection)',
185
194
  example: 'Checking'
186
195
  },
187
196
  icon: {
@@ -197,7 +206,7 @@ export const $AccountResponseDto = {
197
206
  }
198
207
  },
199
208
  platformId: {
200
- type: 'object',
209
+ type: 'string',
201
210
  description: 'Platform ID (null if unbound)',
202
211
  example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2'
203
212
  },
@@ -377,16 +386,43 @@ export const $AccountStandardResponseDto = {
377
386
  },
378
387
  name: {
379
388
  type: 'string',
380
- description: 'Short localized display name',
389
+ description:
390
+ 'Short display name. Universal rows project to the request locale (Accept-Language); regional rows keep the authored native name — mixed-language by design (ADR-0131 class P vs class A).',
381
391
  example: 'Housing Fund'
382
392
  },
393
+ aliases: {
394
+ description:
395
+ 'Authored market-language alternative names delivered verbatim (not localized copy, not xlf-managed, not locale-projected). Flat string[] per ADR-0129 D1; ADR-0131 class A.',
396
+ example: ['Alipay', 'WeChat Pay'],
397
+ type: 'array',
398
+ items: {
399
+ type: 'string'
400
+ }
401
+ },
402
+ searchTerms: {
403
+ description:
404
+ 'Locale-projected search synonyms (e.g. the zh bank-card / debit-card everyday terms for the checking account). Pure-locale projection — absent when the locale has no seeded synonyms; English fallback rides the authored aliases field. Search-only vocabulary, not the NLP routing corpus (#698, ADR-0131 fourth-class adjudication).',
405
+ example: ['yinhangka', 'jiejika'],
406
+ type: 'array',
407
+ items: {
408
+ type: 'string'
409
+ }
410
+ },
411
+ currency: {
412
+ type: 'string',
413
+ description:
414
+ 'Product denomination as a 3-letter ISO 4217 code, authored market data delivered verbatim (not localized, not xlf-managed). ADR-0131 class A. Absent = single-currency not asserted — consumers fall back to their own region currency (#714).',
415
+ example: 'HKD'
416
+ },
383
417
  description: {
384
418
  type: 'string',
385
- description: 'Account description (stable semantics only)',
419
+ description:
420
+ 'Account description (stable semantics only). Mixed-language contract: universal rows project to the request locale via the accountDesc xlf axis with an en fallback (ADR-0131 class P, ADR-0132; unseeded locales falling back to English are expected); regional rows deliver the authored market language (ADR-0131 class A, verbatim, never xlf-managed).',
386
421
  example: 'ICBC checking account for daily transactions'
387
422
  },
388
423
  tags: {
389
- description: 'Account tags for categorization',
424
+ description:
425
+ 'Account tags for categorization — structured metadata delivered verbatim (not localized, not xlf-managed). ADR-0131 class A.',
390
426
  example: ['bank', 'checking', 'primary'],
391
427
  type: 'array',
392
428
  items: {
@@ -498,7 +534,10 @@ export const $RegionConfigDto = {
498
534
  },
499
535
  locale: {
500
536
  type: 'string',
501
- example: 'de-DE'
537
+ example: 'de-DE',
538
+ pattern: '^[a-z]{2,8}-[A-Z]{2}$',
539
+ description:
540
+ "Region-qualified BCP-47 tag whose region subtag equals the region's own ISO 3166-1 code (e.g., ja-JP, zh-CN, zh-HK)"
502
541
  }
503
542
  },
504
543
  required: ['currency', 'dateFormat', 'locale']
@@ -511,6 +550,12 @@ export const $RegionInfoDto = {
511
550
  type: 'string',
512
551
  example: 'de'
513
552
  },
553
+ open: {
554
+ type: 'boolean',
555
+ example: true,
556
+ description:
557
+ 'Whether the region is open (has a ready regional account template). Not-yet-open regions still return identity metadata and degrade to the universal-only catalog.'
558
+ },
514
559
  displayName: {
515
560
  type: 'string',
516
561
  example: 'Germany'
@@ -529,7 +574,7 @@ export const $RegionInfoDto = {
529
574
  $ref: '#/components/schemas/RegionConfigDto'
530
575
  }
531
576
  },
532
- required: ['code', 'displayName', 'chain', 'config']
577
+ required: ['code', 'open', 'displayName', 'chain', 'config']
533
578
  } as const;
534
579
 
535
580
  export const $RegionsMetadataResponseDto = {
@@ -776,7 +821,7 @@ export const $PostingResponseDto = {
776
821
  units: {
777
822
  type: 'string',
778
823
  description:
779
- 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.',
824
+ 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned. Carries the raw Beancount sign (credit-normal accounts such as Income post negative — the accounting truth, ADR-0126); renderers must not infer economic semantics from this sign.',
780
825
  example: '100.50'
781
826
  },
782
827
  currency: {
@@ -1142,7 +1187,7 @@ export const $PostingDetailDto = {
1142
1187
  units: {
1143
1188
  type: 'string',
1144
1189
  description:
1145
- 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.',
1190
+ 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned. Carries the raw Beancount sign (credit-normal accounts such as Income post negative — the accounting truth, ADR-0126); renderers must not infer economic semantics from this sign.',
1146
1191
  example: '100.50'
1147
1192
  },
1148
1193
  currency: {
@@ -1326,6 +1371,147 @@ export const $TransactionDetailDto = {
1326
1371
  ]
1327
1372
  } as const;
1328
1373
 
1374
+ export const $TransactionListItemDto = {
1375
+ type: 'object',
1376
+ properties: {
1377
+ id: {
1378
+ type: 'string',
1379
+ description: 'Transaction ID',
1380
+ example: 'clh1234567890abcdef'
1381
+ },
1382
+ date: {
1383
+ type: 'string',
1384
+ description: 'Transaction date',
1385
+ example: '2024-11-28'
1386
+ },
1387
+ flag: {
1388
+ type: 'string',
1389
+ description: 'Transaction flag',
1390
+ enum: [
1391
+ 'CLEARED',
1392
+ 'PENDING',
1393
+ 'PADDING',
1394
+ 'SUMMARIZE',
1395
+ 'TRANSFER',
1396
+ 'CONVERSIONS'
1397
+ ],
1398
+ example: 'CLEARED'
1399
+ },
1400
+ customFlag: {
1401
+ type: 'string',
1402
+ description: 'Custom flag (if not using standard flags)',
1403
+ example: 'R'
1404
+ },
1405
+ payee: {
1406
+ type: 'string',
1407
+ description: 'Payee name',
1408
+ example: 'Whole Foods Market'
1409
+ },
1410
+ narration: {
1411
+ type: 'string',
1412
+ description: 'Transaction narration',
1413
+ example: 'Grocery shopping'
1414
+ },
1415
+ tags: {
1416
+ description: 'Transaction tags',
1417
+ example: ['groceries'],
1418
+ type: 'array',
1419
+ items: {
1420
+ type: 'string'
1421
+ }
1422
+ },
1423
+ links: {
1424
+ description: 'Transaction links',
1425
+ example: ['invoice-2024-001'],
1426
+ type: 'array',
1427
+ items: {
1428
+ type: 'string'
1429
+ }
1430
+ },
1431
+ meta: {
1432
+ type: 'object',
1433
+ description: 'Transaction metadata'
1434
+ },
1435
+ status: {
1436
+ type: 'string',
1437
+ description: 'Transaction status',
1438
+ enum: ['ACTIVE', 'VOIDED', 'SUPERSEDED'],
1439
+ example: 'ACTIVE'
1440
+ },
1441
+ sourceType: {
1442
+ type: 'string',
1443
+ description:
1444
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1445
+ },
1446
+ sourcePlatform: {
1447
+ type: 'string',
1448
+ description: 'Source platform (e.g., alipay, wechat)',
1449
+ example: 'alipay'
1450
+ },
1451
+ postings: {
1452
+ description: 'Transaction postings',
1453
+ type: 'array',
1454
+ items: {
1455
+ $ref: '#/components/schemas/PostingDetailDto'
1456
+ }
1457
+ },
1458
+ createdAt: {
1459
+ type: 'string',
1460
+ description: 'Created at timestamp',
1461
+ example: '2024-11-28T10:30:00.000Z'
1462
+ },
1463
+ voidedAt: {
1464
+ type: 'string',
1465
+ description: 'Voided at timestamp (if voided)',
1466
+ example: '2024-11-29T15:00:00.000Z'
1467
+ },
1468
+ voidedBy: {
1469
+ type: 'string',
1470
+ description: 'User ID who voided this transaction',
1471
+ example: 'clh1234567890abcdef'
1472
+ },
1473
+ correctionReason: {
1474
+ type: 'string',
1475
+ description: 'Correction reason (if voided or superseded)',
1476
+ example: 'Duplicate entry'
1477
+ },
1478
+ supersededBy: {
1479
+ type: 'string',
1480
+ description:
1481
+ 'ID of the transaction that supersedes this one (set when status=SUPERSEDED)',
1482
+ example: 'clh1234567890abcdef'
1483
+ },
1484
+ originalTxn: {
1485
+ type: 'string',
1486
+ description:
1487
+ 'ID of the transaction this one corrected/replaced (back-link on the replacement)',
1488
+ example: 'clh1234567890abcdef'
1489
+ },
1490
+ viewpointAmount: {
1491
+ type: 'string',
1492
+ description:
1493
+ 'Row amount under the request viewpoint (ADR-0126). Category viewpoint (category + flow): per-leg sign-normalized sum over the category account set (Income-root legs negated, Expenses-root identity) — positive under normal booking but NOT clamped (explicit negative expense legs and net-flip refund months stay negative). No viewpoint (plain list / search, no accountId): wallet money-flow net = raw-sign sum over cost-less Assets/Liabilities legs (income positive, expenses negative, transfers net ~0); color cue is the wallet sign (net < 0 = wealth-decreasing). Status-orthogonal: audit views match too (ADR-0128 amount-as-matching-key). Omitted under the account viewpoint (incl. dual) and for rows with no wallet leg.',
1494
+ example: '10000.00'
1495
+ },
1496
+ viewpointCurrency: {
1497
+ type: 'string',
1498
+ description:
1499
+ 'Currency of viewpointAmount. A row spanning multiple currencies takes the largest-magnitude currency group (known simplification, ADR-0126).',
1500
+ example: 'CNY'
1501
+ }
1502
+ },
1503
+ required: [
1504
+ 'id',
1505
+ 'date',
1506
+ 'narration',
1507
+ 'tags',
1508
+ 'links',
1509
+ 'status',
1510
+ 'postings',
1511
+ 'createdAt'
1512
+ ]
1513
+ } as const;
1514
+
1329
1515
  export const $BalanceByCurrencyDto = {
1330
1516
  type: 'object',
1331
1517
  properties: {
@@ -1371,7 +1557,7 @@ export const $TransactionListSummaryDto = {
1371
1557
  totalAmount: {
1372
1558
  type: 'string',
1373
1559
  description:
1374
- '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.',
1560
+ 'Partial converted total in base currency (rated currencies only). Sign by viewpoint (ADR-0126): account viewpoint keeps the raw Beancount sign (income negative); category viewpoint is per-leg sign-normalized (Income legs negated, Expenses legs identity — positive under normal booking, not clamped). 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.',
1375
1561
  example: '-6000.00'
1376
1562
  },
1377
1563
  currency: {
@@ -1397,6 +1583,26 @@ export const $TransactionListSummaryDto = {
1397
1583
  required: ['totalAmount', 'currency', 'balanceByCurrency']
1398
1584
  } as const;
1399
1585
 
1586
+ export const $TransactionListViewpointDto = {
1587
+ type: 'object',
1588
+ properties: {
1589
+ type: {
1590
+ type: 'string',
1591
+ description:
1592
+ 'Viewpoint type (only category drill-down carries a viewpoint today)',
1593
+ enum: ['category'],
1594
+ example: 'category'
1595
+ },
1596
+ flow: {
1597
+ type: 'string',
1598
+ description: 'Flow root the category account set is restricted to',
1599
+ enum: ['income', 'expense'],
1600
+ example: 'expense'
1601
+ }
1602
+ },
1603
+ required: ['type', 'flow']
1604
+ } as const;
1605
+
1400
1606
  export const $TransactionListResponseDto = {
1401
1607
  type: 'object',
1402
1608
  properties: {
@@ -1404,7 +1610,7 @@ export const $TransactionListResponseDto = {
1404
1610
  description: 'List of transactions',
1405
1611
  type: 'array',
1406
1612
  items: {
1407
- $ref: '#/components/schemas/TransactionDetailDto'
1613
+ $ref: '#/components/schemas/TransactionListItemDto'
1408
1614
  }
1409
1615
  },
1410
1616
  total: {
@@ -1430,6 +1636,15 @@ export const $TransactionListResponseDto = {
1430
1636
  $ref: '#/components/schemas/TransactionListSummaryDto'
1431
1637
  }
1432
1638
  ]
1639
+ },
1640
+ viewpoint: {
1641
+ description:
1642
+ 'Viewpoint metadata (ADR-0126). Present only for a single category filter (category + flow, no accountId); dual-perspective requests are viewpoint-less (raw signs, no viewpointAmount).',
1643
+ allOf: [
1644
+ {
1645
+ $ref: '#/components/schemas/TransactionListViewpointDto'
1646
+ }
1647
+ ]
1433
1648
  }
1434
1649
  },
1435
1650
  required: ['data', 'total', 'limit', 'offset']
@@ -2340,10 +2555,10 @@ export const $UpdatePayeeDto = {
2340
2555
  meta: {
2341
2556
  type: 'object',
2342
2557
  description:
2343
- 'Metadata for extended information (location, notes, contact info, etc.). Will merge with existing metadata.',
2558
+ 'Metadata for extended information (location, notes, contact info, etc.)',
2344
2559
  example: {
2345
2560
  location: 'Zhongguancun',
2346
- note: 'Updated note',
2561
+ note: 'Near subway station',
2347
2562
  favorite: true
2348
2563
  }
2349
2564
  },
@@ -2904,568 +3119,660 @@ export const $UpdateCommodityDto = {
2904
3119
  }
2905
3120
  } as const;
2906
3121
 
2907
- export const $CreateBeanPriceDto = {
3122
+ export const $CurrencyBalanceDto = {
2908
3123
  type: 'object',
2909
3124
  properties: {
2910
3125
  currency: {
2911
3126
  type: 'string',
2912
- description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2913
- example: 'USD'
2914
- },
2915
- quoteCurrency: {
2916
- type: 'string',
2917
- description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
3127
+ description: 'ISO 4217 currency code',
2918
3128
  example: 'CNY'
2919
3129
  },
2920
- amount: {
2921
- type: 'number',
2922
- description:
2923
- 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
2924
- example: 175.5,
2925
- minimum: 0
2926
- },
2927
- date: {
3130
+ balance: {
2928
3131
  type: 'string',
2929
- description: 'Price date (ISO 8601 format)',
2930
- example: '2024-11-05'
2931
- },
2932
- metadata: {
2933
- type: 'object',
2934
- description:
2935
- 'Metadata (validated by Zod schema, max field lengths enforced)',
2936
- example: {
2937
- source: 'MANUAL',
2938
- note: 'Bank valuation report',
2939
- confidence: 0.95
2940
- }
3132
+ description: 'Balance amount',
3133
+ example: '500000.00'
2941
3134
  }
2942
3135
  },
2943
- required: ['currency', 'quoteCurrency', 'amount', 'date']
3136
+ required: ['currency', 'balance']
2944
3137
  } as const;
2945
3138
 
2946
- export const $PriceResponseDto = {
3139
+ export const $TimeSeriesPointDto = {
2947
3140
  type: 'object',
2948
3141
  properties: {
2949
- id: {
3142
+ date: {
2950
3143
  type: 'string',
2951
- description: 'Unique identifier',
2952
- example: 'uuid-123-456'
3144
+ description: 'Date in YYYY-MM-DD format',
3145
+ example: '2024-06-15'
2953
3146
  },
2954
- userId: {
3147
+ value: {
2955
3148
  type: 'string',
2956
- description: 'User ID (owner of the price)',
2957
- example: 'user-123'
3149
+ description: 'Value at this date (in base currency)',
3150
+ example: '500000.00'
2958
3151
  },
2959
- currency: {
3152
+ change: {
2960
3153
  type: 'string',
2961
- description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2962
- example: 'BTC'
3154
+ description: 'Change from previous point',
3155
+ example: '5000.00'
2963
3156
  },
2964
- quoteCurrency: {
3157
+ assets: {
2965
3158
  type: 'string',
2966
- description: 'Quote currency (pricing currency, e.g., USD, CNY)',
2967
- example: 'USD'
2968
- },
2969
- amount: {
2970
- type: 'number',
2971
- description:
2972
- 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
2973
- example: 50000
3159
+ description: 'Total assets at this date (in base currency)',
3160
+ example: '494338.00'
2974
3161
  },
2975
- date: {
3162
+ liabilities: {
2976
3163
  type: 'string',
2977
- description:
2978
- 'Price date (ISO 8601 format). Represents the date this price was valid.',
2979
- example: '2024-01-01',
2980
- format: 'date'
3164
+ description: 'Total liabilities at this date (in base currency)',
3165
+ example: '310098.00'
2981
3166
  },
2982
- meta: {
2983
- type: 'object',
2984
- description:
2985
- 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
2986
- example: {
2987
- source: 'MANUAL',
2988
- note: 'User-defined price',
2989
- confidence: 1
3167
+ byCurrency: {
3168
+ description: 'Multi-currency breakdown for this point',
3169
+ type: 'array',
3170
+ items: {
3171
+ $ref: '#/components/schemas/CurrencyBalanceDto'
2990
3172
  }
3173
+ }
3174
+ },
3175
+ required: ['date', 'value']
3176
+ } as const;
3177
+
3178
+ export const $TrendSummaryDto = {
3179
+ type: 'object',
3180
+ properties: {
3181
+ startValue: {
3182
+ type: 'string',
3183
+ description: 'Value at start of period',
3184
+ example: '450000.00'
2991
3185
  },
2992
- createdAt: {
2993
- format: 'date-time',
3186
+ endValue: {
2994
3187
  type: 'string',
2995
- description: 'Creation timestamp',
2996
- example: '2024-11-03T10:00:00Z'
3188
+ description: 'Value at end of period',
3189
+ example: '500000.00'
2997
3190
  },
2998
- updatedAt: {
2999
- format: 'date-time',
3191
+ totalChange: {
3000
3192
  type: 'string',
3001
- description: 'Last update timestamp',
3002
- example: '2024-11-03T10:00:00Z'
3193
+ description: 'Total change over period',
3194
+ example: '50000.00'
3195
+ },
3196
+ totalChangePercentage: {
3197
+ type: 'string',
3198
+ description: 'Total change percentage',
3199
+ example: '+11.11%'
3003
3200
  }
3004
3201
  },
3005
- required: [
3006
- 'id',
3007
- 'userId',
3008
- 'currency',
3009
- 'quoteCurrency',
3010
- 'amount',
3011
- 'date',
3012
- 'meta',
3013
- 'createdAt',
3014
- 'updatedAt'
3015
- ]
3202
+ required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
3016
3203
  } as const;
3017
3204
 
3018
- export const $PriceListResponseDto = {
3205
+ export const $MultiCurrencyPointDto = {
3019
3206
  type: 'object',
3020
3207
  properties: {
3021
- items: {
3022
- description: 'List of prices',
3208
+ date: {
3209
+ type: 'string',
3210
+ description: 'Date in YYYY-MM-DD format',
3211
+ example: '2024-06-15'
3212
+ },
3213
+ byCurrency: {
3214
+ description: 'Balances by currency',
3023
3215
  type: 'array',
3024
3216
  items: {
3025
- $ref: '#/components/schemas/PriceResponseDto'
3217
+ $ref: '#/components/schemas/CurrencyBalanceDto'
3026
3218
  }
3027
- },
3028
- total: {
3029
- type: 'number',
3030
- description: 'Total number of prices',
3031
- example: 42
3032
3219
  }
3033
3220
  },
3034
- required: ['items', 'total']
3221
+ required: ['date', 'byCurrency']
3035
3222
  } as const;
3036
3223
 
3037
- export const $UpdateBeanPriceDto = {
3224
+ export const $PortfolioTrendsResponseDto = {
3038
3225
  type: 'object',
3039
3226
  properties: {
3040
- currency: {
3041
- type: 'string',
3042
- description: 'Currency being priced'
3227
+ series: {
3228
+ description: 'Time series data points',
3229
+ type: 'array',
3230
+ items: {
3231
+ $ref: '#/components/schemas/TimeSeriesPointDto'
3232
+ }
3043
3233
  },
3044
- quoteCurrency: {
3234
+ summary: {
3235
+ description: 'Period summary',
3236
+ allOf: [
3237
+ {
3238
+ $ref: '#/components/schemas/TrendSummaryDto'
3239
+ }
3240
+ ]
3241
+ },
3242
+ period: {
3045
3243
  type: 'string',
3046
- description: 'Quote currency (pricing currency)'
3244
+ description: 'Period requested',
3245
+ example: '6m'
3047
3246
  },
3048
- amount: {
3049
- type: 'number',
3050
- description: 'Price amount (MUST be >= 0 per Beancount spec)',
3051
- minimum: 0
3247
+ granularity: {
3248
+ type: 'string',
3249
+ description: 'Data granularity',
3250
+ example: 'month'
3052
3251
  },
3053
- date: {
3252
+ currency: {
3054
3253
  type: 'string',
3055
- description: 'Price date (ISO 8601 format)'
3254
+ description: 'Base currency for converted values',
3255
+ example: 'CNY'
3056
3256
  },
3057
- metadata: {
3058
- type: 'object',
3059
- description: 'Metadata'
3257
+ byCurrency: {
3258
+ description:
3259
+ 'Multi-currency time series (each point has currency breakdown)',
3260
+ type: 'array',
3261
+ items: {
3262
+ $ref: '#/components/schemas/MultiCurrencyPointDto'
3263
+ }
3264
+ },
3265
+ warnings: {
3266
+ description: 'Exchange rate warnings',
3267
+ type: 'array',
3268
+ items: {
3269
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
3270
+ }
3060
3271
  }
3061
- }
3272
+ },
3273
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
3062
3274
  } as const;
3063
3275
 
3064
- export const $CreateRecurringRuleDto = {
3276
+ export const $CashFlowPointDto = {
3065
3277
  type: 'object',
3066
3278
  properties: {
3067
- name: {
3068
- type: 'string',
3069
- description: 'Rule name (unique per user)',
3070
- maxLength: 100
3071
- },
3072
- icon: {
3073
- type: 'string',
3074
- description: 'Icon emoji',
3075
- maxLength: 10
3076
- },
3077
- frequency: {
3279
+ month: {
3078
3280
  type: 'string',
3079
- description: 'Recurring frequency',
3080
- enum: [
3081
- 'WEEKLY',
3082
- 'BIWEEKLY',
3083
- 'MONTHLY',
3084
- 'BIMONTHLY',
3085
- 'QUARTERLY',
3086
- 'YEARLY',
3087
- 'CUSTOM'
3088
- ]
3089
- },
3090
- expectedAmount: {
3091
- type: 'number',
3092
- description: 'Expected amount (positive number)',
3093
- minimum: 0
3094
- },
3095
- expectedDay: {
3096
- type: 'number',
3097
- description: 'Expected day of month (1-31)',
3098
- minimum: 1,
3099
- maximum: 31
3100
- },
3101
- customIntervalDays: {
3102
- type: 'number',
3103
- description: 'Custom interval in days (required for CUSTOM frequency)',
3104
- minimum: 1
3281
+ description: 'Month key (YYYY-MM)',
3282
+ example: '2024-03'
3105
3283
  },
3106
- currency: {
3284
+ income: {
3107
3285
  type: 'string',
3108
- description: 'Currency code',
3109
- default: 'CNY',
3110
- maxLength: 10
3286
+ description: 'Income in base currency (absolute, converted)',
3287
+ example: '10000.00'
3111
3288
  },
3112
- matchPayeePattern: {
3289
+ expense: {
3113
3290
  type: 'string',
3114
- description: 'Payee matching pattern (supports wildcards)',
3115
- maxLength: 200
3116
- },
3117
- matchAmountTolerance: {
3118
- type: 'number',
3119
- description: 'Amount tolerance percentage (0-1)',
3120
- default: 0.075,
3121
- minimum: 0,
3122
- maximum: 1
3291
+ description: 'Expense in base currency (absolute, converted)',
3292
+ example: '5000.00'
3123
3293
  },
3124
- defaultExpenseAccount: {
3294
+ netSavings: {
3125
3295
  type: 'string',
3126
- description: 'Default expense account for auto-create',
3127
- maxLength: 200
3128
- },
3129
- defaultPaymentAccount: {
3296
+ description: 'netSavings = income − expense (savings positive)',
3297
+ example: '5000.00'
3298
+ }
3299
+ },
3300
+ required: ['month', 'income', 'expense', 'netSavings']
3301
+ } as const;
3302
+
3303
+ export const $CashFlowTrendSummaryDto = {
3304
+ type: 'object',
3305
+ properties: {
3306
+ totalIncome: {
3130
3307
  type: 'string',
3131
- description: 'Default payment account for auto-create',
3132
- maxLength: 200
3308
+ description: 'Total income across the period',
3309
+ example: '60000.00'
3133
3310
  },
3134
- defaultPayee: {
3311
+ totalExpense: {
3135
3312
  type: 'string',
3136
- description: 'Default payee for auto-create',
3137
- maxLength: 200
3138
- },
3139
- autoCreate: {
3140
- type: 'boolean',
3141
- description: 'Auto-create transaction when expected date arrives',
3142
- default: false
3313
+ description: 'Total expense across the period',
3314
+ example: '30000.00'
3143
3315
  },
3144
- startDate: {
3316
+ totalNetSavings: {
3145
3317
  type: 'string',
3146
- description: 'Rule start date (ISO format)'
3318
+ description: 'income − expense across the period',
3319
+ example: '30000.00'
3147
3320
  },
3148
- endDate: {
3321
+ averageMonthlyNetSavings: {
3149
3322
  type: 'string',
3150
- description: 'Rule end date (ISO format)'
3323
+ description:
3324
+ 'totalNetSavings divided by the window length (N months, incl. zero-filled)',
3325
+ example: '5000.00'
3151
3326
  }
3152
3327
  },
3153
3328
  required: [
3154
- 'name',
3155
- 'frequency',
3156
- 'expectedAmount',
3157
- 'currency',
3158
- 'matchAmountTolerance',
3159
- 'autoCreate'
3329
+ 'totalIncome',
3330
+ 'totalExpense',
3331
+ 'totalNetSavings',
3332
+ 'averageMonthlyNetSavings'
3160
3333
  ]
3161
3334
  } as const;
3162
3335
 
3163
- export const $RecurringRuleResponseDto = {
3336
+ export const $CashFlowTrendsResponseDto = {
3164
3337
  type: 'object',
3165
3338
  properties: {
3166
- id: {
3167
- type: 'string',
3168
- description: 'Rule ID'
3339
+ series: {
3340
+ description:
3341
+ 'Monthly cash-flow series (fixed N-month window, zero-filled)',
3342
+ type: 'array',
3343
+ items: {
3344
+ $ref: '#/components/schemas/CashFlowPointDto'
3345
+ }
3169
3346
  },
3170
- userId: {
3171
- type: 'string',
3172
- description: 'User ID'
3347
+ summary: {
3348
+ description: 'Period totals',
3349
+ allOf: [
3350
+ {
3351
+ $ref: '#/components/schemas/CashFlowTrendSummaryDto'
3352
+ }
3353
+ ]
3173
3354
  },
3174
- name: {
3355
+ period: {
3175
3356
  type: 'string',
3176
- description: 'Rule name'
3177
- },
3178
- icon: {
3179
- type: 'object',
3180
- description: 'Icon emoji'
3357
+ description: 'Period requested',
3358
+ example: '6m'
3181
3359
  },
3182
- frequency: {
3360
+ granularity: {
3183
3361
  type: 'string',
3184
- description: 'Recurring frequency'
3185
- },
3186
- expectedAmount: {
3187
- type: 'number',
3188
- description: 'Expected amount'
3189
- },
3190
- expectedDay: {
3191
- type: 'object',
3192
- description: 'Expected day of month'
3362
+ description: 'Data granularity (v1 returns month buckets)',
3363
+ example: 'month'
3193
3364
  },
3194
- customIntervalDays: {
3195
- type: 'object',
3196
- description: 'Custom interval in days'
3365
+ currency: {
3366
+ type: 'string',
3367
+ description: 'Base currency for converted values',
3368
+ example: 'CNY'
3197
3369
  },
3370
+ warnings: {
3371
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
3372
+ type: 'array',
3373
+ items: {
3374
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
3375
+ }
3376
+ }
3377
+ },
3378
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
3379
+ } as const;
3380
+
3381
+ export const $GenerateSnapshotBody = {
3382
+ type: 'object',
3383
+ properties: {}
3384
+ } as const;
3385
+
3386
+ export const $GenerateSnapshotResponse = {
3387
+ type: 'object',
3388
+ properties: {}
3389
+ } as const;
3390
+
3391
+ export const $BackfillSnapshotsBody = {
3392
+ type: 'object',
3393
+ properties: {}
3394
+ } as const;
3395
+
3396
+ export const $BackfillSnapshotsResponse = {
3397
+ type: 'object',
3398
+ properties: {}
3399
+ } as const;
3400
+
3401
+ export const $CreateBeanPriceDto = {
3402
+ type: 'object',
3403
+ properties: {
3198
3404
  currency: {
3199
3405
  type: 'string',
3200
- description: 'Currency code'
3406
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
3407
+ example: 'USD'
3201
3408
  },
3202
- matchPayeePattern: {
3203
- type: 'object',
3204
- description: 'Payee matching pattern'
3409
+ quoteCurrency: {
3410
+ type: 'string',
3411
+ description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
3412
+ example: 'CNY'
3205
3413
  },
3206
- matchAmountTolerance: {
3414
+ amount: {
3207
3415
  type: 'number',
3208
- description: 'Amount tolerance percentage'
3416
+ description:
3417
+ 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
3418
+ example: 175.5,
3419
+ minimum: 0
3209
3420
  },
3210
- defaultExpenseAccount: {
3211
- type: 'object',
3212
- description: 'Default expense account'
3421
+ date: {
3422
+ type: 'string',
3423
+ description: 'Price date (ISO 8601 format)',
3424
+ example: '2024-11-05'
3213
3425
  },
3214
- defaultPaymentAccount: {
3426
+ metadata: {
3215
3427
  type: 'object',
3216
- description: 'Default payment account'
3428
+ description:
3429
+ 'Metadata (validated by Zod schema, max field lengths enforced)',
3430
+ example: {
3431
+ source: 'MANUAL',
3432
+ note: 'Bank valuation report',
3433
+ confidence: 0.95
3434
+ }
3435
+ }
3436
+ },
3437
+ required: ['currency', 'quoteCurrency', 'amount', 'date']
3438
+ } as const;
3439
+
3440
+ export const $PriceResponseDto = {
3441
+ type: 'object',
3442
+ properties: {
3443
+ id: {
3444
+ type: 'string',
3445
+ description: 'Unique identifier',
3446
+ example: 'uuid-123-456'
3217
3447
  },
3218
- defaultPayee: {
3219
- type: 'object',
3220
- description: 'Default payee'
3448
+ userId: {
3449
+ type: 'string',
3450
+ description: 'User ID (owner of the price)',
3451
+ example: 'user-123'
3221
3452
  },
3222
- isActive: {
3223
- type: 'boolean',
3224
- description: 'Whether rule is active'
3453
+ currency: {
3454
+ type: 'string',
3455
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
3456
+ example: 'BTC'
3225
3457
  },
3226
- startDate: {
3458
+ quoteCurrency: {
3227
3459
  type: 'string',
3228
- description: 'Rule start date (YYYY-MM-DD)'
3460
+ description: 'Quote currency (pricing currency, e.g., USD, CNY)',
3461
+ example: 'USD'
3229
3462
  },
3230
- endDate: {
3231
- type: 'object',
3232
- description: 'Rule end date (YYYY-MM-DD)'
3463
+ amount: {
3464
+ type: 'number',
3465
+ description:
3466
+ 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
3467
+ example: 50000
3233
3468
  },
3234
- autoCreate: {
3235
- type: 'boolean',
3236
- description: 'Auto-create transaction on expected date'
3469
+ date: {
3470
+ type: 'string',
3471
+ description:
3472
+ 'Price date (ISO 8601 format). Represents the date this price was valid.',
3473
+ example: '2024-01-01',
3474
+ format: 'date'
3237
3475
  },
3238
- lastOccurrence: {
3476
+ meta: {
3239
3477
  type: 'object',
3240
- description: 'Last matched occurrence date (YYYY-MM-DD)'
3241
- },
3242
- totalCount: {
3243
- type: 'number',
3244
- description: 'Total matched transactions count'
3478
+ description:
3479
+ 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
3480
+ example: {
3481
+ source: 'MANUAL',
3482
+ note: 'User-defined price',
3483
+ confidence: 1
3484
+ }
3245
3485
  },
3246
3486
  createdAt: {
3247
3487
  format: 'date-time',
3248
3488
  type: 'string',
3249
- description: 'Created at timestamp'
3489
+ description: 'Creation timestamp',
3490
+ example: '2024-11-03T10:00:00Z'
3250
3491
  },
3251
3492
  updatedAt: {
3252
3493
  format: 'date-time',
3253
3494
  type: 'string',
3254
- description: 'Updated at timestamp'
3495
+ description: 'Last update timestamp',
3496
+ example: '2024-11-03T10:00:00Z'
3255
3497
  }
3256
3498
  },
3257
3499
  required: [
3258
3500
  'id',
3259
3501
  'userId',
3260
- 'name',
3261
- 'frequency',
3262
- 'expectedAmount',
3263
3502
  'currency',
3264
- 'matchAmountTolerance',
3265
- 'isActive',
3266
- 'startDate',
3267
- 'autoCreate',
3268
- 'totalCount',
3503
+ 'quoteCurrency',
3504
+ 'amount',
3505
+ 'date',
3506
+ 'meta',
3269
3507
  'createdAt',
3270
3508
  'updatedAt'
3271
3509
  ]
3272
3510
  } as const;
3273
3511
 
3274
- export const $CreateRuleFromTransactionDto = {
3512
+ export const $PriceListResponseDto = {
3275
3513
  type: 'object',
3276
3514
  properties: {
3277
- frequency: {
3278
- type: 'string',
3279
- description: 'Recurring frequency',
3280
- enum: [
3281
- 'WEEKLY',
3282
- 'BIWEEKLY',
3283
- 'MONTHLY',
3284
- 'BIMONTHLY',
3285
- 'QUARTERLY',
3286
- 'YEARLY',
3287
- 'CUSTOM'
3288
- ],
3289
- example: 'MONTHLY'
3290
- },
3291
- name: {
3292
- type: 'string',
3293
- description: 'Optional name override (default: transaction payee)',
3294
- maxLength: 100
3515
+ items: {
3516
+ description: 'List of prices',
3517
+ type: 'array',
3518
+ items: {
3519
+ $ref: '#/components/schemas/PriceResponseDto'
3520
+ }
3295
3521
  },
3296
- icon: {
3297
- type: 'string',
3298
- description: 'Optional icon emoji',
3299
- maxLength: 10
3522
+ total: {
3523
+ type: 'number',
3524
+ description: 'Total number of prices',
3525
+ example: 42
3300
3526
  }
3301
3527
  },
3302
- required: ['frequency']
3528
+ required: ['items', 'total']
3303
3529
  } as const;
3304
3530
 
3305
- export const $RecurringRuleWithStatsResponseDto = {
3531
+ export const $UpdateBeanPriceDto = {
3306
3532
  type: 'object',
3307
3533
  properties: {
3308
- id: {
3534
+ currency: {
3309
3535
  type: 'string',
3310
- description: 'Rule ID'
3536
+ description: 'Currency being priced'
3311
3537
  },
3312
- userId: {
3538
+ quoteCurrency: {
3313
3539
  type: 'string',
3314
- description: 'User ID'
3540
+ description: 'Quote currency (pricing currency)'
3315
3541
  },
3316
- name: {
3542
+ amount: {
3543
+ type: 'number',
3544
+ description: 'Price amount (MUST be >= 0 per Beancount spec)',
3545
+ minimum: 0
3546
+ },
3547
+ date: {
3317
3548
  type: 'string',
3318
- description: 'Rule name'
3549
+ description: 'Price date (ISO 8601 format)'
3319
3550
  },
3320
- icon: {
3551
+ metadata: {
3321
3552
  type: 'object',
3322
- description: 'Icon emoji'
3323
- },
3324
- frequency: {
3553
+ description: 'Metadata'
3554
+ }
3555
+ }
3556
+ } as const;
3557
+
3558
+ export const $DeleteOwnUserDto = {
3559
+ type: 'object',
3560
+ properties: {
3561
+ accessToken: {
3325
3562
  type: 'string',
3326
- description: 'Recurring frequency'
3327
- },
3328
- expectedAmount: {
3329
- type: 'number',
3330
- description: 'Expected amount'
3563
+ description: 'Access token for user verification',
3564
+ example: 'abc123xyz'
3565
+ }
3566
+ },
3567
+ required: ['accessToken']
3568
+ } as const;
3569
+
3570
+ export const $UserSettingsResponseDto = {
3571
+ type: 'object',
3572
+ properties: {
3573
+ baseCurrency: {
3574
+ type: 'string',
3575
+ description:
3576
+ 'Stored base currency choice (ISO 4217) for net-worth/report aggregation. null = user never chose; aggregates fall back to the region default at display time (#713).',
3577
+ example: 'USD',
3578
+ nullable: true
3579
+ }
3580
+ },
3581
+ required: ['baseCurrency']
3582
+ } as const;
3583
+
3584
+ export const $UserResponseDto = {
3585
+ type: 'object',
3586
+ properties: {
3587
+ id: {
3588
+ type: 'string',
3589
+ description: 'User ID'
3331
3590
  },
3332
- expectedDay: {
3333
- type: 'object',
3334
- description: 'Expected day of month'
3591
+ role: {
3592
+ type: 'string',
3593
+ description: 'Assigned user role'
3335
3594
  },
3336
- customIntervalDays: {
3337
- type: 'object',
3338
- description: 'Custom interval in days'
3595
+ permissions: {
3596
+ description: 'Permission strings',
3597
+ type: 'array',
3598
+ items: {
3599
+ type: 'string'
3600
+ }
3339
3601
  },
3340
- currency: {
3602
+ settings: {
3603
+ description: 'User settings',
3604
+ allOf: [
3605
+ {
3606
+ $ref: '#/components/schemas/UserSettingsResponseDto'
3607
+ }
3608
+ ]
3609
+ }
3610
+ },
3611
+ required: ['id', 'role', 'permissions', 'settings']
3612
+ } as const;
3613
+
3614
+ export const $SignupDto = {
3615
+ type: 'object',
3616
+ properties: {
3617
+ turnstileToken: {
3341
3618
  type: 'string',
3342
- description: 'Currency code'
3619
+ description:
3620
+ 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
3621
+ example: '0.abc123def456...'
3622
+ }
3623
+ }
3624
+ } as const;
3625
+
3626
+ export const $SignupResponseDto = {
3627
+ type: 'object',
3628
+ properties: {
3629
+ authToken: {
3630
+ type: 'string',
3631
+ description: 'JWT auth token',
3632
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
3343
3633
  },
3344
- matchPayeePattern: {
3345
- type: 'object',
3346
- description: 'Payee matching pattern'
3634
+ accessToken: {
3635
+ type: 'string',
3636
+ description: 'Auto-generated access token'
3347
3637
  },
3348
- matchAmountTolerance: {
3638
+ role: {
3639
+ type: 'string',
3640
+ description: 'Assigned user role',
3641
+ enum: ['USER', 'ADMIN', 'DEMO', 'INACTIVE', 'PAID', 'OPS']
3642
+ }
3643
+ },
3644
+ required: ['authToken', 'accessToken', 'role']
3645
+ } as const;
3646
+
3647
+ export const $UpdateUserSettingDto = {
3648
+ type: 'object',
3649
+ properties: {
3650
+ secId: {
3349
3651
  type: 'number',
3350
- description: 'Amount tolerance percentage'
3652
+ description: 'Security ID'
3351
3653
  },
3352
- defaultExpenseAccount: {
3353
- type: 'object',
3354
- description: 'Default expense account'
3654
+ annualInterestRate: {
3655
+ type: 'number',
3656
+ description: 'Annual interest rate',
3657
+ example: 0.05
3355
3658
  },
3356
- defaultPaymentAccount: {
3357
- type: 'object',
3358
- description: 'Default payment account'
3659
+ currency: {
3660
+ type: 'string',
3661
+ description: 'Currency code',
3662
+ example: 'USD'
3359
3663
  },
3360
- defaultPayee: {
3361
- type: 'object',
3362
- description: 'Default payee'
3664
+ baseCurrency: {
3665
+ type: 'string',
3666
+ description: 'Base currency code',
3667
+ example: 'USD'
3363
3668
  },
3364
- isActive: {
3365
- type: 'boolean',
3366
- description: 'Whether rule is active'
3669
+ benchmark: {
3670
+ type: 'string',
3671
+ description: 'Benchmark symbol',
3672
+ example: 'SPY'
3367
3673
  },
3368
- startDate: {
3674
+ colorScheme: {
3369
3675
  type: 'string',
3370
- description: 'Rule start date (YYYY-MM-DD)'
3676
+ description: 'Color scheme',
3677
+ enum: ['DARK', 'LIGHT']
3371
3678
  },
3372
- endDate: {
3373
- type: 'object',
3374
- description: 'Rule end date (YYYY-MM-DD)'
3679
+ dateRange: {
3680
+ type: 'string',
3681
+ description: 'Date range filter',
3682
+ example: '1y'
3375
3683
  },
3376
- autoCreate: {
3377
- type: 'boolean',
3378
- description: 'Auto-create transaction on expected date'
3684
+ emergencyFund: {
3685
+ type: 'number',
3686
+ description: 'Emergency fund amount',
3687
+ example: 10000
3379
3688
  },
3380
- lastOccurrence: {
3381
- type: 'object',
3382
- description: 'Last matched occurrence date (YYYY-MM-DD)'
3689
+ 'filters.accounts': {
3690
+ description: 'Account filter IDs',
3691
+ type: 'array',
3692
+ items: {
3693
+ type: 'string'
3694
+ }
3383
3695
  },
3384
- totalCount: {
3385
- type: 'number',
3386
- description: 'Total matched transactions count'
3696
+ 'filters.assetClasses': {
3697
+ description: 'Asset class filters',
3698
+ type: 'array',
3699
+ items: {
3700
+ type: 'string'
3701
+ }
3387
3702
  },
3388
- createdAt: {
3389
- format: 'date-time',
3703
+ 'filters.dataSource': {
3390
3704
  type: 'string',
3391
- description: 'Created at timestamp'
3705
+ description: 'Data source filter'
3392
3706
  },
3393
- updatedAt: {
3394
- format: 'date-time',
3707
+ 'filters.symbol': {
3395
3708
  type: 'string',
3396
- description: 'Updated at timestamp'
3709
+ description: 'Symbol filter'
3397
3710
  },
3398
- pendingCount: {
3399
- type: 'number',
3400
- description: 'Number of pending expected transactions'
3711
+ 'filters.tags': {
3712
+ description: 'Tag filters',
3713
+ type: 'array',
3714
+ items: {
3715
+ type: 'string'
3716
+ }
3401
3717
  },
3402
- overdueCount: {
3403
- type: 'number',
3404
- description: 'Number of overdue expected transactions'
3718
+ isExperimentalFeatures: {
3719
+ type: 'boolean',
3720
+ description: 'Enable experimental features'
3405
3721
  },
3406
- nextExpectedDate: {
3407
- type: 'object',
3408
- description: 'Next expected date (YYYY-MM-DD)'
3722
+ isRestrictedView: {
3723
+ type: 'boolean',
3724
+ description: 'Enable restricted view mode'
3409
3725
  },
3410
- totalAmount: {
3411
- type: 'number',
3412
- description: 'Total amount of all matched transactions'
3726
+ language: {
3727
+ type: 'string',
3728
+ description: 'Language code',
3729
+ example: 'en'
3413
3730
  },
3414
- averageAmount: {
3415
- type: 'number',
3416
- description: 'Average amount per transaction'
3731
+ locale: {
3732
+ type: 'string',
3733
+ description: 'Locale code',
3734
+ example: 'en-US'
3417
3735
  },
3418
- transactionCount: {
3736
+ projectedTotalAmount: {
3419
3737
  type: 'number',
3420
- description: 'Number of matched transactions'
3421
- },
3422
- firstDate: {
3423
- type: 'object',
3424
- description: 'First matched transaction date (YYYY-MM-DD)'
3738
+ description: 'Projected total amount',
3739
+ example: 1000000
3425
3740
  },
3426
- lastDate: {
3427
- type: 'object',
3428
- description: 'Last matched transaction date (YYYY-MM-DD)'
3741
+ retirementDate: {
3742
+ type: 'string',
3743
+ description: 'Retirement date in ISO 8601 format',
3744
+ example: '2050-01-01'
3429
3745
  },
3430
- variance: {
3746
+ savingsRate: {
3431
3747
  type: 'number',
3432
- description: 'Amount variance (standard deviation squared)'
3748
+ description: 'Savings rate percentage',
3749
+ example: 0.2
3433
3750
  },
3434
- upcomingCount: {
3435
- type: 'number',
3436
- description: 'Number of upcoming expected transactions'
3751
+ viewMode: {
3752
+ type: 'string',
3753
+ description: 'View mode',
3754
+ enum: ['DEFAULT', 'ZEN']
3755
+ }
3756
+ }
3757
+ } as const;
3758
+
3759
+ export const $UpdatePropertyDto = {
3760
+ type: 'object',
3761
+ properties: {
3762
+ value: {
3763
+ type: 'string',
3764
+ description: 'Property value'
3437
3765
  }
3438
3766
  },
3439
- required: [
3440
- 'id',
3441
- 'userId',
3442
- 'name',
3443
- 'frequency',
3444
- 'expectedAmount',
3445
- 'currency',
3446
- 'matchAmountTolerance',
3447
- 'isActive',
3448
- 'startDate',
3449
- 'autoCreate',
3450
- 'totalCount',
3451
- 'createdAt',
3452
- 'updatedAt',
3453
- 'pendingCount',
3454
- 'overdueCount',
3455
- 'totalAmount',
3456
- 'averageAmount',
3457
- 'transactionCount',
3458
- 'variance',
3459
- 'upcomingCount'
3460
- ]
3767
+ required: ['value']
3461
3768
  } as const;
3462
3769
 
3463
- export const $UpdateRecurringRuleDto = {
3770
+ export const $CreateRecurringRuleDto = {
3464
3771
  type: 'object',
3465
3772
  properties: {
3466
3773
  name: {
3467
3774
  type: 'string',
3468
- description: 'Rule name',
3775
+ description: 'Rule name (unique per user)',
3469
3776
  maxLength: 100
3470
3777
  },
3471
3778
  icon: {
@@ -3488,7 +3795,7 @@ export const $UpdateRecurringRuleDto = {
3488
3795
  },
3489
3796
  expectedAmount: {
3490
3797
  type: 'number',
3491
- description: 'Expected amount',
3798
+ description: 'Expected amount (positive number)',
3492
3799
  minimum: 0
3493
3800
  },
3494
3801
  expectedDay: {
@@ -3499,7 +3806,7 @@ export const $UpdateRecurringRuleDto = {
3499
3806
  },
3500
3807
  customIntervalDays: {
3501
3808
  type: 'number',
3502
- description: 'Custom interval in days',
3809
+ description: 'Custom interval in days (required for CUSTOM frequency)',
3503
3810
  minimum: 1
3504
3811
  },
3505
3812
  currency: {
@@ -3509,818 +3816,726 @@ export const $UpdateRecurringRuleDto = {
3509
3816
  },
3510
3817
  matchPayeePattern: {
3511
3818
  type: 'string',
3512
- description: 'Payee matching pattern',
3819
+ description: 'Payee matching pattern (supports wildcards)',
3513
3820
  maxLength: 200
3514
3821
  },
3515
3822
  matchAmountTolerance: {
3516
3823
  type: 'number',
3517
3824
  description: 'Amount tolerance percentage (0-1)',
3825
+ default: 0.075,
3518
3826
  minimum: 0,
3519
3827
  maximum: 1
3520
3828
  },
3521
3829
  defaultExpenseAccount: {
3522
3830
  type: 'string',
3523
- description: 'Default expense account',
3831
+ description: 'Default expense account for auto-create',
3524
3832
  maxLength: 200
3525
3833
  },
3526
3834
  defaultPaymentAccount: {
3527
3835
  type: 'string',
3528
- description: 'Default payment account',
3836
+ description: 'Default payment account for auto-create',
3529
3837
  maxLength: 200
3530
3838
  },
3531
3839
  defaultPayee: {
3532
3840
  type: 'string',
3533
- description: 'Default payee',
3841
+ description: 'Default payee for auto-create',
3534
3842
  maxLength: 200
3535
3843
  },
3536
3844
  autoCreate: {
3537
3845
  type: 'boolean',
3538
- description: 'Auto-create transaction'
3846
+ description: 'Auto-create transaction when expected date arrives',
3847
+ default: false
3539
3848
  },
3540
- isActive: {
3541
- type: 'boolean',
3542
- description: 'Rule active status'
3849
+ startDate: {
3850
+ type: 'string',
3851
+ description: 'Rule start date (ISO format)'
3543
3852
  },
3544
3853
  endDate: {
3545
3854
  type: 'string',
3546
3855
  description: 'Rule end date (ISO format)'
3547
3856
  }
3548
- }
3549
- } as const;
3550
-
3551
- export const $ExpectedTransactionRuleDto = {
3552
- type: 'object',
3553
- properties: {
3554
- name: {
3555
- type: 'string',
3556
- description: 'Rule name'
3557
- },
3558
- icon: {
3559
- type: 'object',
3560
- description: 'Rule icon'
3561
- },
3562
- frequency: {
3563
- type: 'string',
3564
- description: 'Rule frequency'
3565
- },
3566
- currency: {
3567
- type: 'string',
3568
- description: 'Currency code'
3569
- }
3570
3857
  },
3571
- required: ['name', 'frequency', 'currency']
3858
+ required: [
3859
+ 'name',
3860
+ 'frequency',
3861
+ 'expectedAmount',
3862
+ 'matchAmountTolerance',
3863
+ 'autoCreate'
3864
+ ]
3572
3865
  } as const;
3573
3866
 
3574
- export const $ExpectedTransactionResponseDto = {
3867
+ export const $RecurringRuleResponseDto = {
3575
3868
  type: 'object',
3576
3869
  properties: {
3577
3870
  id: {
3578
3871
  type: 'string',
3579
- description: 'Expected transaction ID'
3872
+ description: 'Rule ID'
3580
3873
  },
3581
3874
  userId: {
3582
3875
  type: 'string',
3583
3876
  description: 'User ID'
3584
3877
  },
3585
- ruleId: {
3878
+ name: {
3586
3879
  type: 'string',
3587
- description: 'Associated rule ID'
3880
+ description: 'Rule name'
3588
3881
  },
3589
- expectedDate: {
3882
+ icon: {
3590
3883
  type: 'string',
3591
- description: 'Expected date (YYYY-MM-DD)'
3884
+ description: 'Icon emoji'
3885
+ },
3886
+ frequency: {
3887
+ type: 'string',
3888
+ description: 'Recurring frequency'
3592
3889
  },
3593
3890
  expectedAmount: {
3594
3891
  type: 'number',
3595
3892
  description: 'Expected amount'
3596
3893
  },
3597
- status: {
3598
- type: 'string',
3599
- description: 'Status (PENDING, COMPLETED, SKIPPED)'
3894
+ expectedDay: {
3895
+ type: 'number',
3896
+ description: 'Expected day of month'
3600
3897
  },
3601
- matchedTransactionId: {
3602
- type: 'object',
3603
- description: 'Matched transaction ID'
3898
+ customIntervalDays: {
3899
+ type: 'number',
3900
+ description: 'Custom interval in days'
3604
3901
  },
3605
- matchedAt: {
3606
- type: 'object',
3607
- description: 'Match timestamp (ISO 8601)'
3902
+ currency: {
3903
+ type: 'string',
3904
+ description: 'Currency code'
3608
3905
  },
3609
- matchConfidence: {
3610
- type: 'object',
3611
- description: 'Match confidence score (0-1)'
3906
+ matchPayeePattern: {
3907
+ type: 'string',
3908
+ description: 'Payee matching pattern'
3612
3909
  },
3613
- isOverdue: {
3614
- type: 'boolean',
3615
- description: 'Whether this expected transaction is overdue'
3910
+ matchAmountTolerance: {
3911
+ type: 'number',
3912
+ description: 'Amount tolerance percentage'
3616
3913
  },
3617
- rule: {
3618
- description: 'Rule information',
3619
- allOf: [
3620
- {
3621
- $ref: '#/components/schemas/ExpectedTransactionRuleDto'
3622
- }
3623
- ]
3914
+ defaultExpenseAccount: {
3915
+ type: 'string',
3916
+ description: 'Default expense account'
3624
3917
  },
3625
- createdAt: {
3626
- format: 'date-time',
3918
+ defaultPaymentAccount: {
3627
3919
  type: 'string',
3628
- description: 'Created at timestamp'
3920
+ description: 'Default payment account'
3629
3921
  },
3630
- updatedAt: {
3631
- format: 'date-time',
3922
+ defaultPayee: {
3632
3923
  type: 'string',
3633
- description: 'Updated at timestamp'
3634
- }
3635
- },
3636
- required: [
3637
- 'id',
3638
- 'userId',
3639
- 'ruleId',
3640
- 'expectedDate',
3641
- 'expectedAmount',
3642
- 'status',
3643
- 'isOverdue',
3644
- 'rule',
3645
- 'createdAt',
3646
- 'updatedAt'
3647
- ]
3648
- } as const;
3649
-
3650
- export const $ExpectedTransactionListResponseDto = {
3651
- type: 'object',
3652
- properties: {
3653
- items: {
3654
- type: 'array',
3655
- items: {
3656
- $ref: '#/components/schemas/ExpectedTransactionResponseDto'
3657
- }
3924
+ description: 'Default payee'
3658
3925
  },
3659
- total: {
3660
- type: 'number',
3661
- description: 'Total count'
3662
- }
3663
- },
3664
- required: ['items', 'total']
3665
- } as const;
3666
-
3667
- export const $ConfirmMatchDto = {
3668
- type: 'object',
3669
- properties: {
3670
- transactionId: {
3926
+ isActive: {
3927
+ type: 'boolean',
3928
+ description: 'Whether rule is active'
3929
+ },
3930
+ startDate: {
3671
3931
  type: 'string',
3672
- description: 'Transaction ID to match with'
3673
- }
3674
- },
3675
- required: ['transactionId']
3676
- } as const;
3677
-
3678
- export const $EnterNowDto = {
3679
- type: 'object',
3680
- properties: {
3681
- expenseAccount: {
3932
+ description: 'Rule start date (YYYY-MM-DD)'
3933
+ },
3934
+ endDate: {
3682
3935
  type: 'string',
3683
- description:
3684
- 'Override expense account (uses rule default if not provided)',
3685
- maxLength: 200
3936
+ description: 'Rule end date (YYYY-MM-DD)'
3686
3937
  },
3687
- paymentAccount: {
3938
+ autoCreate: {
3939
+ type: 'boolean',
3940
+ description: 'Auto-create transaction on expected date'
3941
+ },
3942
+ lastOccurrence: {
3688
3943
  type: 'string',
3689
- description:
3690
- 'Override payment account (uses rule default if not provided)',
3691
- maxLength: 200
3944
+ description: 'Last matched occurrence date (YYYY-MM-DD)'
3692
3945
  },
3693
- amount: {
3946
+ totalCount: {
3694
3947
  type: 'number',
3695
- description: 'Override amount (uses expected amount if not provided)',
3696
- minimum: 0
3948
+ description: 'Total matched transactions count'
3697
3949
  },
3698
- payee: {
3950
+ createdAt: {
3951
+ format: 'date-time',
3699
3952
  type: 'string',
3700
- description: 'Override payee (uses rule default if not provided)',
3701
- maxLength: 200
3953
+ description: 'Created at timestamp'
3702
3954
  },
3703
- narration: {
3955
+ updatedAt: {
3956
+ format: 'date-time',
3704
3957
  type: 'string',
3705
- description: 'Optional narration',
3706
- maxLength: 500
3958
+ description: 'Updated at timestamp'
3707
3959
  }
3708
- }
3960
+ },
3961
+ required: [
3962
+ 'id',
3963
+ 'userId',
3964
+ 'name',
3965
+ 'frequency',
3966
+ 'expectedAmount',
3967
+ 'currency',
3968
+ 'matchAmountTolerance',
3969
+ 'isActive',
3970
+ 'startDate',
3971
+ 'autoCreate',
3972
+ 'totalCount',
3973
+ 'createdAt',
3974
+ 'updatedAt'
3975
+ ]
3709
3976
  } as const;
3710
3977
 
3711
- export const $ForecastItemDto = {
3978
+ export const $CreateRuleFromTransactionDto = {
3712
3979
  type: 'object',
3713
3980
  properties: {
3714
- rule: {
3715
- type: 'string',
3716
- description: 'Rule name',
3717
- example: 'Rent'
3718
- },
3719
- ruleId: {
3981
+ frequency: {
3720
3982
  type: 'string',
3721
- description: 'Rule ID',
3722
- example: 'clx123...'
3723
- },
3724
- amount: {
3725
- type: 'number',
3726
- description: 'Expected amount',
3727
- example: 3000
3983
+ description: 'Recurring frequency',
3984
+ enum: [
3985
+ 'WEEKLY',
3986
+ 'BIWEEKLY',
3987
+ 'MONTHLY',
3988
+ 'BIMONTHLY',
3989
+ 'QUARTERLY',
3990
+ 'YEARLY',
3991
+ 'CUSTOM'
3992
+ ],
3993
+ example: 'MONTHLY'
3728
3994
  },
3729
- date: {
3995
+ name: {
3730
3996
  type: 'string',
3731
- description: 'Expected date (YYYY-MM-DD)',
3732
- example: '2024-04-01'
3997
+ description: 'Optional name override (default: transaction payee)',
3998
+ maxLength: 100
3733
3999
  },
3734
4000
  icon: {
3735
4001
  type: 'string',
3736
- description: 'Rule icon emoji',
3737
- example: '🏠',
3738
- nullable: true
3739
- },
3740
- currency: {
3741
- type: 'string',
3742
- description: 'Currency code',
3743
- example: 'CNY'
4002
+ description: 'Optional icon emoji',
4003
+ maxLength: 10
3744
4004
  }
3745
4005
  },
3746
- required: ['rule', 'ruleId', 'amount', 'date', 'icon', 'currency']
4006
+ required: ['frequency']
3747
4007
  } as const;
3748
4008
 
3749
- export const $MonthlyForecastDto = {
4009
+ export const $RecurringRuleWithStatsResponseDto = {
3750
4010
  type: 'object',
3751
4011
  properties: {
3752
- month: {
4012
+ id: {
3753
4013
  type: 'string',
3754
- description: 'Month (YYYY-MM)',
3755
- example: '2024-04'
4014
+ description: 'Rule ID'
3756
4015
  },
3757
- expectedOutflow: {
3758
- type: 'number',
3759
- description: 'Total expected outflow for the month',
3760
- example: 8500
4016
+ userId: {
4017
+ type: 'string',
4018
+ description: 'User ID'
3761
4019
  },
3762
- itemCount: {
3763
- type: 'number',
3764
- description: 'Number of expected transactions',
3765
- example: 3
4020
+ name: {
4021
+ type: 'string',
4022
+ description: 'Rule name'
3766
4023
  },
3767
- byCurrency: {
3768
- type: 'object',
3769
- description: 'Breakdown by currency',
3770
- example: {
3771
- CNY: 8500,
3772
- USD: 100
3773
- }
4024
+ icon: {
4025
+ type: 'string',
4026
+ description: 'Icon emoji'
3774
4027
  },
3775
- items: {
3776
- description: 'Individual forecast items',
3777
- type: 'array',
3778
- items: {
3779
- $ref: '#/components/schemas/ForecastItemDto'
3780
- }
3781
- }
3782
- },
3783
- required: ['month', 'expectedOutflow', 'itemCount', 'byCurrency', 'items']
3784
- } as const;
3785
-
3786
- export const $ForecastResponseDto = {
3787
- type: 'object',
3788
- properties: {
3789
- forecast: {
3790
- description: 'Monthly forecast data',
3791
- type: 'array',
3792
- items: {
3793
- $ref: '#/components/schemas/MonthlyForecastDto'
3794
- }
4028
+ frequency: {
4029
+ type: 'string',
4030
+ description: 'Recurring frequency'
3795
4031
  },
3796
- totalOutflow: {
4032
+ expectedAmount: {
3797
4033
  type: 'number',
3798
- description: 'Total expected outflow across all months',
3799
- example: 25500
4034
+ description: 'Expected amount'
3800
4035
  },
3801
- totalByCurrency: {
3802
- type: 'object',
3803
- description: 'Total by currency across all months',
3804
- example: {
3805
- CNY: 25500,
3806
- USD: 300
3807
- }
4036
+ expectedDay: {
4037
+ type: 'number',
4038
+ description: 'Expected day of month'
3808
4039
  },
3809
- rulesCount: {
4040
+ customIntervalDays: {
3810
4041
  type: 'number',
3811
- description: 'Number of active recurring rules included',
3812
- example: 5
4042
+ description: 'Custom interval in days'
3813
4043
  },
3814
- periodStart: {
4044
+ currency: {
3815
4045
  type: 'string',
3816
- description: 'Forecast period start date',
3817
- example: '2024-04-01'
4046
+ description: 'Currency code'
3818
4047
  },
3819
- periodEnd: {
3820
- type: 'string',
3821
- description: 'Forecast period end date',
3822
- example: '2024-06-30'
3823
- }
3824
- },
3825
- required: [
3826
- 'forecast',
3827
- 'totalOutflow',
3828
- 'totalByCurrency',
3829
- 'rulesCount',
3830
- 'periodStart',
3831
- 'periodEnd'
3832
- ]
3833
- } as const;
3834
-
3835
- export const $CurrencyBalanceDto = {
3836
- type: 'object',
3837
- properties: {
3838
- currency: {
4048
+ matchPayeePattern: {
3839
4049
  type: 'string',
3840
- description: 'ISO 4217 currency code',
3841
- example: 'CNY'
4050
+ description: 'Payee matching pattern'
3842
4051
  },
3843
- balance: {
4052
+ matchAmountTolerance: {
4053
+ type: 'number',
4054
+ description: 'Amount tolerance percentage'
4055
+ },
4056
+ defaultExpenseAccount: {
3844
4057
  type: 'string',
3845
- description: 'Balance amount',
3846
- example: '500000.00'
3847
- }
3848
- },
3849
- required: ['currency', 'balance']
3850
- } as const;
3851
-
3852
- export const $TimeSeriesPointDto = {
3853
- type: 'object',
3854
- properties: {
3855
- date: {
4058
+ description: 'Default expense account'
4059
+ },
4060
+ defaultPaymentAccount: {
3856
4061
  type: 'string',
3857
- description: 'Date in YYYY-MM-DD format',
3858
- example: '2024-06-15'
4062
+ description: 'Default payment account'
3859
4063
  },
3860
- value: {
4064
+ defaultPayee: {
3861
4065
  type: 'string',
3862
- description: 'Value at this date (in base currency)',
3863
- example: '500000.00'
4066
+ description: 'Default payee'
3864
4067
  },
3865
- change: {
3866
- type: 'object',
3867
- description: 'Change from previous point',
3868
- example: '5000.00'
4068
+ isActive: {
4069
+ type: 'boolean',
4070
+ description: 'Whether rule is active'
3869
4071
  },
3870
- assets: {
4072
+ startDate: {
3871
4073
  type: 'string',
3872
- description: 'Total assets at this date (in base currency)',
3873
- example: '494338.00'
4074
+ description: 'Rule start date (YYYY-MM-DD)'
3874
4075
  },
3875
- liabilities: {
4076
+ endDate: {
3876
4077
  type: 'string',
3877
- description: 'Total liabilities at this date (in base currency)',
3878
- example: '310098.00'
4078
+ description: 'Rule end date (YYYY-MM-DD)'
3879
4079
  },
3880
- byCurrency: {
3881
- description: 'Multi-currency breakdown for this point',
3882
- type: 'array',
3883
- items: {
3884
- $ref: '#/components/schemas/CurrencyBalanceDto'
3885
- }
3886
- }
3887
- },
3888
- required: ['date', 'value']
3889
- } as const;
3890
-
3891
- export const $TrendSummaryDto = {
3892
- type: 'object',
3893
- properties: {
3894
- startValue: {
3895
- type: 'string',
3896
- description: 'Value at start of period',
3897
- example: '450000.00'
4080
+ autoCreate: {
4081
+ type: 'boolean',
4082
+ description: 'Auto-create transaction on expected date'
3898
4083
  },
3899
- endValue: {
4084
+ lastOccurrence: {
3900
4085
  type: 'string',
3901
- description: 'Value at end of period',
3902
- example: '500000.00'
4086
+ description: 'Last matched occurrence date (YYYY-MM-DD)'
3903
4087
  },
3904
- totalChange: {
3905
- type: 'string',
3906
- description: 'Total change over period',
3907
- example: '50000.00'
4088
+ totalCount: {
4089
+ type: 'number',
4090
+ description: 'Total matched transactions count'
3908
4091
  },
3909
- totalChangePercentage: {
4092
+ createdAt: {
4093
+ format: 'date-time',
3910
4094
  type: 'string',
3911
- description: 'Total change percentage',
3912
- example: '+11.11%'
3913
- }
3914
- },
3915
- required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
3916
- } as const;
3917
-
3918
- export const $MultiCurrencyPointDto = {
3919
- type: 'object',
3920
- properties: {
3921
- date: {
4095
+ description: 'Created at timestamp'
4096
+ },
4097
+ updatedAt: {
4098
+ format: 'date-time',
3922
4099
  type: 'string',
3923
- description: 'Date in YYYY-MM-DD format',
3924
- example: '2024-06-15'
4100
+ description: 'Updated at timestamp'
3925
4101
  },
3926
- byCurrency: {
3927
- description: 'Balances by currency',
3928
- type: 'array',
3929
- items: {
3930
- $ref: '#/components/schemas/CurrencyBalanceDto'
3931
- }
3932
- }
3933
- },
3934
- required: ['date', 'byCurrency']
3935
- } as const;
3936
-
3937
- export const $PortfolioTrendsResponseDto = {
3938
- type: 'object',
3939
- properties: {
3940
- series: {
3941
- description: 'Time series data points',
3942
- type: 'array',
3943
- items: {
3944
- $ref: '#/components/schemas/TimeSeriesPointDto'
3945
- }
4102
+ pendingCount: {
4103
+ type: 'number',
4104
+ description: 'Number of pending expected transactions'
3946
4105
  },
3947
- summary: {
3948
- description: 'Period summary',
3949
- allOf: [
3950
- {
3951
- $ref: '#/components/schemas/TrendSummaryDto'
3952
- }
3953
- ]
4106
+ overdueCount: {
4107
+ type: 'number',
4108
+ description: 'Number of overdue expected transactions'
3954
4109
  },
3955
- period: {
4110
+ nextExpectedDate: {
3956
4111
  type: 'string',
3957
- description: 'Period requested',
3958
- example: '6m'
4112
+ description: 'Next expected date (YYYY-MM-DD)'
3959
4113
  },
3960
- granularity: {
4114
+ totalAmount: {
4115
+ type: 'number',
4116
+ description: 'Total amount of all matched transactions'
4117
+ },
4118
+ averageAmount: {
4119
+ type: 'number',
4120
+ description: 'Average amount per transaction'
4121
+ },
4122
+ transactionCount: {
4123
+ type: 'number',
4124
+ description: 'Number of matched transactions'
4125
+ },
4126
+ firstDate: {
3961
4127
  type: 'string',
3962
- description: 'Data granularity',
3963
- example: 'month'
4128
+ description: 'First matched transaction date (YYYY-MM-DD)'
3964
4129
  },
3965
- currency: {
4130
+ lastDate: {
3966
4131
  type: 'string',
3967
- description: 'Base currency for converted values',
3968
- example: 'CNY'
4132
+ description: 'Last matched transaction date (YYYY-MM-DD)'
3969
4133
  },
3970
- byCurrency: {
3971
- description:
3972
- 'Multi-currency time series (each point has currency breakdown)',
3973
- type: 'array',
3974
- items: {
3975
- $ref: '#/components/schemas/MultiCurrencyPointDto'
3976
- }
4134
+ variance: {
4135
+ type: 'number',
4136
+ description: 'Amount variance (standard deviation squared)'
3977
4137
  },
3978
- warnings: {
3979
- description: 'Exchange rate warnings',
3980
- type: 'array',
3981
- items: {
3982
- $ref: '#/components/schemas/ExchangeRateWarningDto'
3983
- }
4138
+ upcomingCount: {
4139
+ type: 'number',
4140
+ description: 'Number of upcoming expected transactions'
3984
4141
  }
3985
4142
  },
3986
- required: ['series', 'summary', 'period', 'granularity', 'currency']
4143
+ required: [
4144
+ 'id',
4145
+ 'userId',
4146
+ 'name',
4147
+ 'frequency',
4148
+ 'expectedAmount',
4149
+ 'currency',
4150
+ 'matchAmountTolerance',
4151
+ 'isActive',
4152
+ 'startDate',
4153
+ 'autoCreate',
4154
+ 'totalCount',
4155
+ 'createdAt',
4156
+ 'updatedAt',
4157
+ 'pendingCount',
4158
+ 'overdueCount',
4159
+ 'totalAmount',
4160
+ 'averageAmount',
4161
+ 'transactionCount',
4162
+ 'variance',
4163
+ 'upcomingCount'
4164
+ ]
3987
4165
  } as const;
3988
4166
 
3989
- export const $CashFlowPointDto = {
4167
+ export const $UpdateRecurringRuleDto = {
3990
4168
  type: 'object',
3991
4169
  properties: {
3992
- month: {
4170
+ name: {
3993
4171
  type: 'string',
3994
- description: 'Month key (YYYY-MM)',
3995
- example: '2024-03'
4172
+ description: 'Rule name (unique per user)',
4173
+ maxLength: 100
3996
4174
  },
3997
- income: {
4175
+ icon: {
3998
4176
  type: 'string',
3999
- description: 'Income in base currency (absolute, converted)',
4000
- example: '10000.00'
4177
+ description: 'Icon emoji',
4178
+ maxLength: 10
4001
4179
  },
4002
- expense: {
4180
+ frequency: {
4003
4181
  type: 'string',
4004
- description: 'Expense in base currency (absolute, converted)',
4005
- example: '5000.00'
4182
+ description: 'Recurring frequency',
4183
+ enum: [
4184
+ 'WEEKLY',
4185
+ 'BIWEEKLY',
4186
+ 'MONTHLY',
4187
+ 'BIMONTHLY',
4188
+ 'QUARTERLY',
4189
+ 'YEARLY',
4190
+ 'CUSTOM'
4191
+ ]
4006
4192
  },
4007
- netSavings: {
4008
- type: 'string',
4009
- description: 'netSavings = income − expense (savings positive)',
4010
- example: '5000.00'
4011
- }
4012
- },
4013
- required: ['month', 'income', 'expense', 'netSavings']
4014
- } as const;
4015
-
4016
- export const $CashFlowTrendSummaryDto = {
4017
- type: 'object',
4018
- properties: {
4019
- totalIncome: {
4020
- type: 'string',
4021
- description: 'Total income across the period',
4022
- example: '60000.00'
4193
+ expectedAmount: {
4194
+ type: 'number',
4195
+ description: 'Expected amount (positive number)',
4196
+ minimum: 0
4023
4197
  },
4024
- totalExpense: {
4198
+ expectedDay: {
4199
+ type: 'number',
4200
+ description: 'Expected day of month (1-31)',
4201
+ minimum: 1,
4202
+ maximum: 31
4203
+ },
4204
+ currency: {
4025
4205
  type: 'string',
4026
- description: 'Total expense across the period',
4027
- example: '30000.00'
4206
+ description: 'Currency code',
4207
+ maxLength: 10
4028
4208
  },
4029
- totalNetSavings: {
4209
+ matchPayeePattern: {
4030
4210
  type: 'string',
4031
- description: 'income − expense across the period',
4032
- example: '30000.00'
4211
+ description: 'Payee matching pattern (supports wildcards)',
4212
+ maxLength: 200
4033
4213
  },
4034
- averageMonthlyNetSavings: {
4214
+ matchAmountTolerance: {
4215
+ type: 'number',
4216
+ description: 'Amount tolerance percentage (0-1)',
4217
+ default: 0.075,
4218
+ minimum: 0,
4219
+ maximum: 1
4220
+ },
4221
+ defaultExpenseAccount: {
4035
4222
  type: 'string',
4036
- description:
4037
- 'totalNetSavings divided by the window length (N months, incl. zero-filled)',
4038
- example: '5000.00'
4039
- }
4040
- },
4041
- required: [
4042
- 'totalIncome',
4043
- 'totalExpense',
4044
- 'totalNetSavings',
4045
- 'averageMonthlyNetSavings'
4046
- ]
4047
- } as const;
4048
-
4049
- export const $CashFlowTrendsResponseDto = {
4050
- type: 'object',
4051
- properties: {
4052
- series: {
4053
- description:
4054
- 'Monthly cash-flow series (fixed N-month window, zero-filled)',
4055
- type: 'array',
4056
- items: {
4057
- $ref: '#/components/schemas/CashFlowPointDto'
4058
- }
4223
+ description: 'Default expense account for auto-create',
4224
+ maxLength: 200
4059
4225
  },
4060
- summary: {
4061
- description: 'Period totals',
4062
- allOf: [
4063
- {
4064
- $ref: '#/components/schemas/CashFlowTrendSummaryDto'
4065
- }
4066
- ]
4226
+ defaultPaymentAccount: {
4227
+ type: 'string',
4228
+ description: 'Default payment account for auto-create',
4229
+ maxLength: 200
4067
4230
  },
4068
- period: {
4231
+ defaultPayee: {
4069
4232
  type: 'string',
4070
- description: 'Period requested',
4071
- example: '6m'
4233
+ description: 'Default payee for auto-create',
4234
+ maxLength: 200
4235
+ },
4236
+ autoCreate: {
4237
+ type: 'boolean',
4238
+ description: 'Auto-create transaction when expected date arrives',
4239
+ default: false
4072
4240
  },
4073
- granularity: {
4241
+ endDate: {
4074
4242
  type: 'string',
4075
- description: 'Data granularity (v1 returns month buckets)',
4076
- example: 'month'
4243
+ description: 'Rule end date (ISO format)'
4077
4244
  },
4078
- currency: {
4079
- type: 'string',
4080
- description: 'Base currency for converted values',
4081
- example: 'CNY'
4245
+ customIntervalDays: {
4246
+ type: 'number',
4247
+ description: 'Custom interval in days',
4248
+ minimum: 1
4082
4249
  },
4083
- warnings: {
4084
- description: 'Exchange rate warnings (e.g. missing rate for a currency)',
4085
- type: 'array',
4086
- items: {
4087
- $ref: '#/components/schemas/ExchangeRateWarningDto'
4088
- }
4250
+ isActive: {
4251
+ type: 'boolean',
4252
+ description: 'Rule active status'
4089
4253
  }
4090
- },
4091
- required: ['series', 'summary', 'period', 'granularity', 'currency']
4092
- } as const;
4093
-
4094
- export const $GenerateSnapshotBody = {
4095
- type: 'object',
4096
- properties: {}
4097
- } as const;
4098
-
4099
- export const $GenerateSnapshotResponse = {
4100
- type: 'object',
4101
- properties: {}
4102
- } as const;
4103
-
4104
- export const $BackfillSnapshotsBody = {
4105
- type: 'object',
4106
- properties: {}
4107
- } as const;
4108
-
4109
- export const $BackfillSnapshotsResponse = {
4110
- type: 'object',
4111
- properties: {}
4254
+ }
4112
4255
  } as const;
4113
4256
 
4114
- export const $DeleteOwnUserDto = {
4257
+ export const $ExpectedTransactionRuleDto = {
4115
4258
  type: 'object',
4116
4259
  properties: {
4117
- accessToken: {
4260
+ name: {
4118
4261
  type: 'string',
4119
- description: 'Access token for user verification',
4120
- example: 'abc123xyz'
4121
- }
4122
- },
4123
- required: ['accessToken']
4124
- } as const;
4125
-
4126
- export const $UserSettingsResponseDto = {
4127
- type: 'object',
4128
- properties: {
4129
- baseCurrency: {
4262
+ description: 'Rule name'
4263
+ },
4264
+ icon: {
4130
4265
  type: 'string',
4131
- description:
4132
- 'Base currency (ISO 4217) for net-worth/report aggregation. Independent of region (ADR-0006).',
4133
- example: 'USD',
4134
- nullable: true
4266
+ description: 'Rule icon'
4267
+ },
4268
+ frequency: {
4269
+ type: 'string',
4270
+ description: 'Rule frequency'
4271
+ },
4272
+ currency: {
4273
+ type: 'string',
4274
+ description: 'Currency code'
4135
4275
  }
4136
4276
  },
4137
- required: ['baseCurrency']
4277
+ required: ['name', 'frequency', 'currency']
4138
4278
  } as const;
4139
4279
 
4140
- export const $UserResponseDto = {
4280
+ export const $ExpectedTransactionResponseDto = {
4141
4281
  type: 'object',
4142
4282
  properties: {
4143
4283
  id: {
4284
+ type: 'string',
4285
+ description: 'Expected transaction ID'
4286
+ },
4287
+ userId: {
4144
4288
  type: 'string',
4145
4289
  description: 'User ID'
4146
4290
  },
4147
- role: {
4291
+ ruleId: {
4148
4292
  type: 'string',
4149
- description: 'Assigned user role'
4293
+ description: 'Associated rule ID'
4150
4294
  },
4151
- permissions: {
4152
- description: 'Permission strings',
4153
- type: 'array',
4154
- items: {
4155
- type: 'string'
4156
- }
4295
+ expectedDate: {
4296
+ type: 'string',
4297
+ description: 'Expected date (YYYY-MM-DD)'
4157
4298
  },
4158
- settings: {
4159
- description: 'User settings',
4299
+ expectedAmount: {
4300
+ type: 'number',
4301
+ description: 'Expected amount'
4302
+ },
4303
+ status: {
4304
+ type: 'string',
4305
+ description: 'Status (PENDING, COMPLETED, SKIPPED)'
4306
+ },
4307
+ matchedTransactionId: {
4308
+ type: 'string',
4309
+ description: 'Matched transaction ID'
4310
+ },
4311
+ matchedAt: {
4312
+ type: 'string',
4313
+ description: 'Match timestamp (ISO 8601)'
4314
+ },
4315
+ matchConfidence: {
4316
+ type: 'number',
4317
+ description: 'Match confidence score (0-1)'
4318
+ },
4319
+ isOverdue: {
4320
+ type: 'boolean',
4321
+ description: 'Whether this expected transaction is overdue'
4322
+ },
4323
+ rule: {
4324
+ description: 'Rule information',
4160
4325
  allOf: [
4161
4326
  {
4162
- $ref: '#/components/schemas/UserSettingsResponseDto'
4327
+ $ref: '#/components/schemas/ExpectedTransactionRuleDto'
4163
4328
  }
4164
4329
  ]
4330
+ },
4331
+ createdAt: {
4332
+ format: 'date-time',
4333
+ type: 'string',
4334
+ description: 'Created at timestamp'
4335
+ },
4336
+ updatedAt: {
4337
+ format: 'date-time',
4338
+ type: 'string',
4339
+ description: 'Updated at timestamp'
4165
4340
  }
4166
4341
  },
4167
- required: ['id', 'role', 'permissions', 'settings']
4342
+ required: [
4343
+ 'id',
4344
+ 'userId',
4345
+ 'ruleId',
4346
+ 'expectedDate',
4347
+ 'expectedAmount',
4348
+ 'status',
4349
+ 'isOverdue',
4350
+ 'rule',
4351
+ 'createdAt',
4352
+ 'updatedAt'
4353
+ ]
4168
4354
  } as const;
4169
4355
 
4170
- export const $SignupDto = {
4356
+ export const $ExpectedTransactionListResponseDto = {
4171
4357
  type: 'object',
4172
4358
  properties: {
4173
- turnstileToken: {
4359
+ items: {
4360
+ type: 'array',
4361
+ items: {
4362
+ $ref: '#/components/schemas/ExpectedTransactionResponseDto'
4363
+ }
4364
+ },
4365
+ total: {
4366
+ type: 'number',
4367
+ description: 'Total count'
4368
+ }
4369
+ },
4370
+ required: ['items', 'total']
4371
+ } as const;
4372
+
4373
+ export const $ConfirmMatchDto = {
4374
+ type: 'object',
4375
+ properties: {
4376
+ transactionId: {
4174
4377
  type: 'string',
4175
- description:
4176
- 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
4177
- example: '0.abc123def456...'
4378
+ description: 'Transaction ID to match with'
4178
4379
  }
4179
- }
4380
+ },
4381
+ required: ['transactionId']
4180
4382
  } as const;
4181
4383
 
4182
- export const $SignupResponseDto = {
4384
+ export const $EnterNowDto = {
4183
4385
  type: 'object',
4184
4386
  properties: {
4185
- authToken: {
4387
+ expenseAccount: {
4186
4388
  type: 'string',
4187
- description: 'JWT auth token',
4188
- example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
4389
+ description:
4390
+ 'Override expense account (uses rule default if not provided)',
4391
+ maxLength: 200
4189
4392
  },
4190
- accessToken: {
4393
+ paymentAccount: {
4191
4394
  type: 'string',
4192
- description: 'Auto-generated access token'
4395
+ description:
4396
+ 'Override payment account (uses rule default if not provided)',
4397
+ maxLength: 200
4193
4398
  },
4194
- role: {
4399
+ amount: {
4400
+ type: 'number',
4401
+ description: 'Override amount (uses expected amount if not provided)',
4402
+ minimum: 0
4403
+ },
4404
+ payee: {
4195
4405
  type: 'string',
4196
- description: 'Assigned user role',
4197
- enum: ['USER', 'ADMIN', 'DEMO', 'INACTIVE', 'PAID', 'OPS']
4406
+ description: 'Override payee (uses rule default if not provided)',
4407
+ maxLength: 200
4408
+ },
4409
+ narration: {
4410
+ type: 'string',
4411
+ description: 'Optional narration',
4412
+ maxLength: 500
4198
4413
  }
4199
- },
4200
- required: ['authToken', 'accessToken', 'role']
4414
+ }
4201
4415
  } as const;
4202
4416
 
4203
- export const $UpdateUserSettingDto = {
4417
+ export const $ForecastItemDto = {
4204
4418
  type: 'object',
4205
4419
  properties: {
4206
- secId: {
4207
- type: 'number',
4208
- description: 'Security ID'
4420
+ rule: {
4421
+ type: 'string',
4422
+ description: 'Rule name',
4423
+ example: 'Rent'
4209
4424
  },
4210
- annualInterestRate: {
4425
+ ruleId: {
4426
+ type: 'string',
4427
+ description: 'Rule ID',
4428
+ example: 'clx123...'
4429
+ },
4430
+ amount: {
4211
4431
  type: 'number',
4212
- description: 'Annual interest rate',
4213
- example: 0.05
4432
+ description: 'Expected amount',
4433
+ example: 3000
4214
4434
  },
4215
- currency: {
4435
+ date: {
4216
4436
  type: 'string',
4217
- description: 'Currency code',
4218
- example: 'USD'
4437
+ description: 'Expected date (YYYY-MM-DD)',
4438
+ example: '2024-04-01'
4219
4439
  },
4220
- baseCurrency: {
4440
+ icon: {
4221
4441
  type: 'string',
4222
- description: 'Base currency code',
4223
- example: 'USD'
4442
+ description: 'Rule icon emoji',
4443
+ example: '🏠',
4444
+ nullable: true
4224
4445
  },
4225
- benchmark: {
4446
+ currency: {
4226
4447
  type: 'string',
4227
- description: 'Benchmark symbol',
4228
- example: 'SPY'
4229
- },
4230
- colorScheme: {
4448
+ description: 'Currency code',
4449
+ example: 'CNY'
4450
+ }
4451
+ },
4452
+ required: ['rule', 'ruleId', 'amount', 'date', 'icon', 'currency']
4453
+ } as const;
4454
+
4455
+ export const $MonthlyForecastDto = {
4456
+ type: 'object',
4457
+ properties: {
4458
+ month: {
4231
4459
  type: 'string',
4232
- description: 'Color scheme',
4233
- enum: ['DARK', 'LIGHT']
4460
+ description: 'Month (YYYY-MM)',
4461
+ example: '2024-04'
4234
4462
  },
4235
- dateRange: {
4236
- type: 'string',
4237
- description: 'Date range filter',
4238
- example: '1y'
4463
+ expectedOutflow: {
4464
+ type: 'number',
4465
+ description: 'Total expected outflow for the month',
4466
+ example: 8500
4239
4467
  },
4240
- emergencyFund: {
4468
+ itemCount: {
4241
4469
  type: 'number',
4242
- description: 'Emergency fund amount',
4243
- example: 10000
4470
+ description: 'Number of expected transactions',
4471
+ example: 3
4244
4472
  },
4245
- 'filters.accounts': {
4246
- description: 'Account filter IDs',
4247
- type: 'array',
4248
- items: {
4249
- type: 'string'
4473
+ byCurrency: {
4474
+ type: 'object',
4475
+ description: 'Breakdown by currency',
4476
+ example: {
4477
+ CNY: 8500,
4478
+ USD: 100
4250
4479
  }
4251
4480
  },
4252
- 'filters.assetClasses': {
4253
- description: 'Asset class filters',
4481
+ items: {
4482
+ description: 'Individual forecast items',
4254
4483
  type: 'array',
4255
4484
  items: {
4256
- type: 'string'
4485
+ $ref: '#/components/schemas/ForecastItemDto'
4257
4486
  }
4258
- },
4259
- 'filters.dataSource': {
4260
- type: 'string',
4261
- description: 'Data source filter'
4262
- },
4263
- 'filters.symbol': {
4264
- type: 'string',
4265
- description: 'Symbol filter'
4266
- },
4267
- 'filters.tags': {
4268
- description: 'Tag filters',
4487
+ }
4488
+ },
4489
+ required: ['month', 'expectedOutflow', 'itemCount', 'byCurrency', 'items']
4490
+ } as const;
4491
+
4492
+ export const $ForecastResponseDto = {
4493
+ type: 'object',
4494
+ properties: {
4495
+ forecast: {
4496
+ description: 'Monthly forecast data',
4269
4497
  type: 'array',
4270
4498
  items: {
4271
- type: 'string'
4499
+ $ref: '#/components/schemas/MonthlyForecastDto'
4272
4500
  }
4273
4501
  },
4274
- isExperimentalFeatures: {
4275
- type: 'boolean',
4276
- description: 'Enable experimental features'
4277
- },
4278
- isRestrictedView: {
4279
- type: 'boolean',
4280
- description: 'Enable restricted view mode'
4281
- },
4282
- language: {
4283
- type: 'string',
4284
- description: 'Language code',
4285
- example: 'en'
4286
- },
4287
- locale: {
4288
- type: 'string',
4289
- description: 'Locale code',
4290
- example: 'en-US'
4291
- },
4292
- projectedTotalAmount: {
4502
+ totalOutflow: {
4293
4503
  type: 'number',
4294
- description: 'Projected total amount',
4295
- example: 1000000
4504
+ description: 'Total expected outflow across all months',
4505
+ example: 25500
4296
4506
  },
4297
- retirementDate: {
4298
- type: 'string',
4299
- description: 'Retirement date in ISO 8601 format',
4300
- example: '2050-01-01'
4507
+ totalByCurrency: {
4508
+ type: 'object',
4509
+ description: 'Total by currency across all months',
4510
+ example: {
4511
+ CNY: 25500,
4512
+ USD: 300
4513
+ }
4301
4514
  },
4302
- savingsRate: {
4515
+ rulesCount: {
4303
4516
  type: 'number',
4304
- description: 'Savings rate percentage',
4305
- example: 0.2
4517
+ description: 'Number of active recurring rules included',
4518
+ example: 5
4306
4519
  },
4307
- viewMode: {
4520
+ periodStart: {
4308
4521
  type: 'string',
4309
- description: 'View mode',
4310
- enum: ['DEFAULT', 'ZEN']
4311
- }
4312
- }
4313
- } as const;
4314
-
4315
- export const $UpdatePropertyDto = {
4316
- type: 'object',
4317
- properties: {
4318
- value: {
4522
+ description: 'Forecast period start date',
4523
+ example: '2024-04-01'
4524
+ },
4525
+ periodEnd: {
4319
4526
  type: 'string',
4320
- description: 'Property value'
4527
+ description: 'Forecast period end date',
4528
+ example: '2024-06-30'
4321
4529
  }
4322
4530
  },
4323
- required: ['value']
4531
+ required: [
4532
+ 'forecast',
4533
+ 'totalOutflow',
4534
+ 'totalByCurrency',
4535
+ 'rulesCount',
4536
+ 'periodStart',
4537
+ 'periodEnd'
4538
+ ]
4324
4539
  } as const;
4325
4540
 
4326
4541
  export const $CreateTransactionRuleDto = {
@@ -4882,7 +5097,8 @@ export const $UpdateTransactionRuleDto = {
4882
5097
  },
4883
5098
  matchLogic: {
4884
5099
  type: 'string',
4885
- enum: ['OR', 'AND']
5100
+ enum: ['OR', 'AND'],
5101
+ default: 'OR'
4886
5102
  },
4887
5103
  amountMin: {
4888
5104
  type: 'number',
@@ -4896,13 +5112,10 @@ export const $UpdateTransactionRuleDto = {
4896
5112
  },
4897
5113
  priority: {
4898
5114
  type: 'number',
5115
+ default: 50,
4899
5116
  minimum: 0,
4900
5117
  maximum: 1000
4901
5118
  },
4902
- enabled: {
4903
- type: 'boolean',
4904
- description: 'Enable or disable the rule'
4905
- },
4906
5119
  additionalTags: {
4907
5120
  items: {
4908
5121
  type: 'array'
@@ -4912,6 +5125,10 @@ export const $UpdateTransactionRuleDto = {
4912
5125
  },
4913
5126
  additionalMetadata: {
4914
5127
  type: 'object'
5128
+ },
5129
+ enabled: {
5130
+ type: 'boolean',
5131
+ description: 'Enable or disable the rule'
4915
5132
  }
4916
5133
  }
4917
5134
  } as const;
@@ -5198,6 +5415,14 @@ export const $OnboardingAccountDto = {
5198
5415
  description:
5199
5416
  'Platform ID to bind the account to (references Platform.id); omit for unbound',
5200
5417
  example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2'
5418
+ },
5419
+ displayName: {
5420
+ type: 'string',
5421
+ description:
5422
+ 'User-set display name override (omit/null = keep the derived name)',
5423
+ nullable: true,
5424
+ maxLength: 50,
5425
+ example: 'Salary card'
5201
5426
  }
5202
5427
  },
5203
5428
  required: ['path', 'currency']
@@ -6217,8 +6442,27 @@ export const $ProcessNlpDto = {
6217
6442
  selectedAccount: {
6218
6443
  type: 'string',
6219
6444
  description:
6220
- 'confirm_account echo-back: account path selected from the prior confirm_account response (suggestedAccount, similarAccounts[i], or a typed path). Applied directly when the session is confirming_account — no NL re-parse.',
6445
+ 'confirm_account echo-back: account path selected from the prior confirm_account response (suggestedAccount, similarAccounts[i].path, or a typed path). Applied directly when the session is confirming_account — no NL re-parse.',
6221
6446
  example: 'Expenses:Food:Coffee'
6447
+ },
6448
+ viewpointAccount: {
6449
+ type: 'string',
6450
+ description:
6451
+ 'Viewpoint account hint: the beancount path the user drilled into (e.g. from an account drill-down). Tie-break only — never overrides accounts resolved from the text. Must be an owned, OPEN Assets:/Liabilities: account; unresolvable hints are silently ignored.',
6452
+ example: 'Assets:CN:Bank:ICBC'
6453
+ },
6454
+ viewpointCategory: {
6455
+ type: 'string',
6456
+ description:
6457
+ "Viewpoint category hint: the ADR-0075 Group segment the user drilled into (e.g. 'Food'). Resolved to a concrete OPEN account in that group; tie-break only — never overrides a category resolved from the text.",
6458
+ example: 'Food'
6459
+ },
6460
+ viewpointFlow: {
6461
+ type: 'string',
6462
+ description:
6463
+ "Companion flow root for viewpointCategory ('income' | 'expense'), mirroring the ADR-0126 list-endpoint invariant. Derived from the session's routed intent (multi-turn) when absent; a first-turn flow-less category hint is dropped — send the flow explicitly.",
6464
+ enum: ['income', 'expense'],
6465
+ example: 'expense'
6222
6466
  }
6223
6467
  }
6224
6468
  } as const;
@@ -6532,6 +6776,24 @@ export const $NlpRuleConfirmationDataDto = {
6532
6776
  ]
6533
6777
  } as const;
6534
6778
 
6779
+ export const $NlpAccountCandidateDto = {
6780
+ type: 'object',
6781
+ properties: {
6782
+ path: {
6783
+ type: 'string',
6784
+ description: 'Canonical beancount account path (echo back on selection)',
6785
+ example: 'Expenses:Food:Dining'
6786
+ },
6787
+ name: {
6788
+ type: 'string',
6789
+ description:
6790
+ 'Localized display name (ADR-0114 read-time projection, user locale)',
6791
+ example: '餐饮'
6792
+ }
6793
+ },
6794
+ required: ['path', 'name']
6795
+ } as const;
6796
+
6535
6797
  export const $NlpAccountConfirmationDataDto = {
6536
6798
  type: 'object',
6537
6799
  properties: {
@@ -6547,10 +6809,11 @@ export const $NlpAccountConfirmationDataDto = {
6547
6809
  example: 'Expenses:Food:Drinks'
6548
6810
  },
6549
6811
  similarAccounts: {
6550
- description: 'Similar accounts for user selection',
6812
+ description:
6813
+ 'Similar accounts for user selection (path + localized name, #680)',
6551
6814
  type: 'array',
6552
6815
  items: {
6553
- type: 'string'
6816
+ $ref: '#/components/schemas/NlpAccountCandidateDto'
6554
6817
  }
6555
6818
  },
6556
6819
  errorMessage: {
@@ -7127,55 +7390,128 @@ export const $PlatformMatchResultDto = {
7127
7390
  category: {
7128
7391
  type: 'string',
7129
7392
  description:
7130
- 'Region-aware category (institution vocab, e.g. DigitalWallet/Bank). null = no region-aware suggestion; fall back to type.',
7393
+ 'Region-aware category (institution vocab, e.g. DigitalWallet/Bank). null = no region-aware suggestion; fall back to type.',
7394
+ nullable: true,
7395
+ example: 'DigitalWallet'
7396
+ },
7397
+ matchType: {
7398
+ type: 'string',
7399
+ description: "How this row matched: 'exact' > 'prefix' > 'substring'",
7400
+ enum: ['exact', 'prefix', 'substring']
7401
+ }
7402
+ },
7403
+ required: [
7404
+ 'id',
7405
+ 'name',
7406
+ 'canonical',
7407
+ 'type',
7408
+ 'suggestedSegment',
7409
+ 'logoUrl',
7410
+ 'countryCode',
7411
+ 'category',
7412
+ 'matchType'
7413
+ ]
7414
+ } as const;
7415
+
7416
+ export const $PlatformMatchResponseDto = {
7417
+ type: 'object',
7418
+ properties: {
7419
+ platforms: {
7420
+ description: 'Ranked matches, best tier first (at most 10 rows)',
7421
+ type: 'array',
7422
+ items: {
7423
+ $ref: '#/components/schemas/PlatformMatchResultDto'
7424
+ }
7425
+ },
7426
+ matchType: {
7427
+ type: 'string',
7428
+ description:
7429
+ "Overall match quality — top row's tier, or 'none' when no hits",
7430
+ enum: ['none', 'exact', 'prefix', 'substring']
7431
+ },
7432
+ total: {
7433
+ type: 'number',
7434
+ description: 'Total matches before LIMIT (truncation transparency)'
7435
+ },
7436
+ hasMore: {
7437
+ type: 'boolean',
7438
+ description: 'true when total > platforms.length (more matches exist)'
7439
+ }
7440
+ },
7441
+ required: ['platforms', 'matchType', 'total', 'hasMore']
7442
+ } as const;
7443
+
7444
+ export const $PlatformStandardsPlatformDto = {
7445
+ type: 'object',
7446
+ properties: {
7447
+ id: {
7448
+ type: 'string',
7449
+ description: 'Global platform ID'
7450
+ },
7451
+ name: {
7452
+ type: 'string',
7453
+ description: 'Platform name (e.g., "ICBC")'
7454
+ },
7455
+ canonical: {
7456
+ type: 'string',
7457
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
7458
+ },
7459
+ suggestedSegment: {
7460
+ type: 'string',
7461
+ description:
7462
+ 'Suggested path segment — canonical PascalCased per hyphen-part, hyphens preserved (e.g. "Apple-Pay")'
7463
+ },
7464
+ type: {
7465
+ type: 'string',
7466
+ description: 'Platform type',
7467
+ enum: [
7468
+ 'BANK',
7469
+ 'BROKERAGE',
7470
+ 'CRYPTO_EXCHANGE',
7471
+ 'PAYMENT',
7472
+ 'INVESTMENT',
7473
+ 'INSURANCE',
7474
+ 'OTHER'
7475
+ ]
7476
+ },
7477
+ category: {
7478
+ type: 'string',
7479
+ description:
7480
+ 'Region-aware category (institution vocab, e.g. DigitalWallet/Bank) resolved against the final region. null = no region-aware suggestion; fall back to type.',
7131
7481
  nullable: true,
7132
- example: 'DigitalWallet'
7133
- },
7134
- matchType: {
7135
- type: 'string',
7136
- description: "How this row matched: 'exact' > 'prefix' > 'substring'",
7137
- enum: ['exact', 'prefix', 'substring']
7482
+ example: 'Bank'
7138
7483
  }
7139
7484
  },
7140
- required: [
7141
- 'id',
7142
- 'name',
7143
- 'canonical',
7144
- 'type',
7145
- 'suggestedSegment',
7146
- 'logoUrl',
7147
- 'countryCode',
7148
- 'category',
7149
- 'matchType'
7150
- ]
7485
+ required: ['id', 'name', 'canonical', 'suggestedSegment', 'type', 'category']
7151
7486
  } as const;
7152
7487
 
7153
- export const $PlatformMatchResponseDto = {
7488
+ export const $PlatformStandardsResponseDto = {
7154
7489
  type: 'object',
7155
7490
  properties: {
7156
- platforms: {
7157
- description: 'Ranked matches, best tier first (at most 10 rows)',
7158
- type: 'array',
7159
- items: {
7160
- $ref: '#/components/schemas/PlatformMatchResultDto'
7161
- }
7491
+ platform: {
7492
+ description: 'The selected platform (institution lock source)',
7493
+ allOf: [
7494
+ {
7495
+ $ref: '#/components/schemas/PlatformStandardsPlatformDto'
7496
+ }
7497
+ ]
7162
7498
  },
7163
- matchType: {
7499
+ region: {
7164
7500
  type: 'string',
7165
7501
  description:
7166
- "Overall match quality — top row's tier, or 'none' when no hits",
7167
- enum: ['none', 'exact', 'prefix', 'substring']
7168
- },
7169
- total: {
7170
- type: 'number',
7171
- description: 'Total matches before LIMIT (truncation transparency)'
7502
+ "Resolved template region (ISO 3166-1 alpha-2, UPPERCASE): the platform's own countryCode when set, else the region query param. For regions without a regional template file the template list falls back to the universal-only catalog while region still echoes the code.",
7503
+ example: 'CN'
7172
7504
  },
7173
- hasMore: {
7174
- type: 'boolean',
7175
- description: 'true when total > platforms.length (more matches exist)'
7505
+ templates: {
7506
+ description:
7507
+ 'Candidate account-standard templates of the resolved region (groupable by productCategory client-side)',
7508
+ type: 'array',
7509
+ items: {
7510
+ $ref: '#/components/schemas/AccountStandardResponseDto'
7511
+ }
7176
7512
  }
7177
7513
  },
7178
- required: ['platforms', 'matchType', 'total', 'hasMore']
7514
+ required: ['platform', 'region', 'templates']
7179
7515
  } as const;
7180
7516
 
7181
7517
  export const $CreatePlatformDto = {
@@ -7279,7 +7615,8 @@ export const $UpdatePlatformDto = {
7279
7615
  },
7280
7616
  isActive: {
7281
7617
  type: 'boolean',
7282
- description: 'Whether the platform is active'
7618
+ description: 'Whether the platform is active',
7619
+ default: true
7283
7620
  }
7284
7621
  }
7285
7622
  } as const;
@@ -7442,7 +7779,8 @@ export const $AccountItemDto = {
7442
7779
  },
7443
7780
  displayName: {
7444
7781
  type: 'string',
7445
- description: 'Display name (last part of account path)',
7782
+ description:
7783
+ 'Display name: user-set name if provided (#762), else last part of account path',
7446
7784
  example: 'Savings'
7447
7785
  },
7448
7786
  balance: {
@@ -7478,7 +7816,8 @@ export const $PlatformGroupDto = {
7478
7816
  example: 'CMB Bank'
7479
7817
  },
7480
7818
  accounts: {
7481
- description: 'Accounts within this platform',
7819
+ description:
7820
+ 'Accounts within this platform (Assets and Liabilities rows, #696)',
7482
7821
  type: 'array',
7483
7822
  items: {
7484
7823
  $ref: '#/components/schemas/AccountItemDto'
@@ -7486,7 +7825,8 @@ export const $PlatformGroupDto = {
7486
7825
  },
7487
7826
  totalBalance: {
7488
7827
  type: 'string',
7489
- description: 'FX-converted total balance in base currency',
7828
+ description:
7829
+ 'FX-converted total balance in base currency (nets Assets + Liabilities rows; can be negative)',
7490
7830
  example: '100000.00'
7491
7831
  },
7492
7832
  balanceByCurrency: {
@@ -7505,7 +7845,7 @@ export const $PlatformGroupDto = {
7505
7845
  sharePct: {
7506
7846
  type: 'number',
7507
7847
  description:
7508
- 'Share of the grand converted total (0-100); 0 when grand total is 0',
7848
+ 'Share of the converted asset-side grand total (0-100); liability balances are excluded from the basis; 0 when grand total is 0 (#696)',
7509
7849
  example: 42.5
7510
7850
  }
7511
7851
  },
@@ -7553,7 +7893,8 @@ export const $AccountsSummaryDto = {
7553
7893
  properties: {
7554
7894
  totalAccounts: {
7555
7895
  type: 'number',
7556
- description: 'Total number of accounts'
7896
+ description:
7897
+ 'Total number of accounts (balance sheet: Assets + Liabilities, #696)'
7557
7898
  },
7558
7899
  totalPlatforms: {
7559
7900
  type: 'number',
@@ -7611,7 +7952,8 @@ export const $AccountItemWithAssetClassDto = {
7611
7952
  },
7612
7953
  displayName: {
7613
7954
  type: 'string',
7614
- description: 'Display name (last part of account path)',
7955
+ description:
7956
+ 'Display name: user-set name if provided (#762), else last part of account path',
7615
7957
  example: 'Savings'
7616
7958
  },
7617
7959
  balance: {
@@ -8097,7 +8439,7 @@ export const $MonetaryDto = {
8097
8439
  example: 'USD'
8098
8440
  },
8099
8441
  baseCcyEquivalent: {
8100
- type: 'object',
8442
+ type: 'string',
8101
8443
  description: 'Converted to user base currency (Decimal string)',
8102
8444
  example: '21600',
8103
8445
  nullable: true
@@ -8173,13 +8515,13 @@ export const $HoldingPnlRowDto = {
8173
8515
  example: 'Assets:US:Broker:AAPL'
8174
8516
  },
8175
8517
  accountCcy: {
8176
- type: 'object',
8518
+ type: 'string',
8177
8519
  description: 'Account settlement currency (ISO 4217), from cost currency',
8178
8520
  nullable: true,
8179
8521
  example: 'USD'
8180
8522
  },
8181
8523
  brokerType: {
8182
- type: 'object',
8524
+ type: 'string',
8183
8525
  description: 'Broker type derived from Platform.type',
8184
8526
  nullable: true,
8185
8527
  example: 'broker'
@@ -8200,7 +8542,7 @@ export const $HoldingPnlRowDto = {
8200
8542
  example: 'EQUITY'
8201
8543
  },
8202
8544
  assetSubClass: {
8203
- type: 'object',
8545
+ type: 'string',
8204
8546
  nullable: true,
8205
8547
  example: 'STOCK'
8206
8548
  },
@@ -8247,14 +8589,14 @@ export const $HoldingPnlRowDto = {
8247
8589
  ]
8248
8590
  },
8249
8591
  unrealizedPnlBase: {
8250
- type: 'object',
8592
+ type: 'string',
8251
8593
  description:
8252
8594
  'Unrealized P&L in base currency (Decimal string); null when any FX/price missing',
8253
8595
  nullable: true,
8254
8596
  example: '6000'
8255
8597
  },
8256
8598
  unrealizedPnlPct: {
8257
- type: 'object',
8599
+ type: 'string',
8258
8600
  description: 'Unrealized P&L % (Decimal string)',
8259
8601
  nullable: true,
8260
8602
  example: '25'
@@ -8278,7 +8620,7 @@ export const $HoldingPnlRowDto = {
8278
8620
  ]
8279
8621
  },
8280
8622
  pctOfInvestedAssets: {
8281
- type: 'object',
8623
+ type: 'string',
8282
8624
  description:
8283
8625
  'Share of invested assets % (Decimal string); only for invested chartTokens',
8284
8626
  nullable: true,
@@ -8323,15 +8665,15 @@ export const $HoldingPnlWarningDto = {
8323
8665
  ]
8324
8666
  },
8325
8667
  symbol: {
8326
- type: 'object',
8668
+ type: 'string',
8327
8669
  nullable: true
8328
8670
  },
8329
8671
  accountId: {
8330
- type: 'object',
8672
+ type: 'string',
8331
8673
  nullable: true
8332
8674
  },
8333
8675
  currency: {
8334
- type: 'object',
8676
+ type: 'string',
8335
8677
  nullable: true
8336
8678
  }
8337
8679
  },
@@ -8395,6 +8737,216 @@ export const $AnonymousLoginResponseDto = {
8395
8737
  required: ['authToken']
8396
8738
  } as const;
8397
8739
 
8740
+ export const $ParserContributionMetaDto = {
8741
+ type: 'object',
8742
+ properties: {
8743
+ institution: {
8744
+ type: 'string',
8745
+ description: 'Institution slug (lowercase kebab-case)',
8746
+ pattern: '^[a-z0-9]+(-[a-z0-9]+)*$',
8747
+ example: 'icbc'
8748
+ },
8749
+ region: {
8750
+ type: 'string',
8751
+ enum: [
8752
+ 'cn',
8753
+ 'us',
8754
+ 'de',
8755
+ 'fr',
8756
+ 'gb',
8757
+ 'hk',
8758
+ 'jp',
8759
+ 'sg',
8760
+ 'au',
8761
+ 'ca',
8762
+ 'other'
8763
+ ]
8764
+ },
8765
+ accountType: {
8766
+ type: 'string',
8767
+ enum: ['checking', 'savings', 'credit', 'debit', 'investment']
8768
+ },
8769
+ format: {
8770
+ type: 'string',
8771
+ enum: ['csv', 'xlsx', 'pdf', 'ofx', 'qif']
8772
+ },
8773
+ institutionDisplayName: {
8774
+ type: 'string',
8775
+ example: '中国工商银行'
8776
+ },
8777
+ encoding: {
8778
+ type: 'string',
8779
+ example: 'utf-8'
8780
+ },
8781
+ delimiter: {
8782
+ type: 'string',
8783
+ description: 'CSV delimiter character: ",", ";", "\\t" or "|"'
8784
+ },
8785
+ headerRows: {
8786
+ type: 'number',
8787
+ default: 1,
8788
+ description: 'Header row count; the client omits the field when it is 1'
8789
+ },
8790
+ notes: {
8791
+ type: 'string',
8792
+ maxLength: 2000
8793
+ }
8794
+ },
8795
+ required: ['institution', 'region', 'accountType', 'format']
8796
+ } as const;
8797
+
8798
+ export const $ParserContributionSamplesDto = {
8799
+ type: 'object',
8800
+ properties: {
8801
+ rows: {
8802
+ description:
8803
+ 'Client-sanitized sample rows (key = column name, value = cell)',
8804
+ type: 'array',
8805
+ items: {
8806
+ type: 'object'
8807
+ }
8808
+ },
8809
+ rawHeaders: {
8810
+ type: 'array',
8811
+ items: {
8812
+ type: 'string'
8813
+ }
8814
+ }
8815
+ },
8816
+ required: ['rows']
8817
+ } as const;
8818
+
8819
+ export const $FieldHintDto = {
8820
+ type: 'object',
8821
+ properties: {
8822
+ columnName: {
8823
+ type: 'string',
8824
+ example: '交易日期'
8825
+ },
8826
+ format: {
8827
+ type: 'string',
8828
+ description: 'Date format, e.g. yyyy-MM-dd HH:mm',
8829
+ example: 'yyyy-MM-dd'
8830
+ },
8831
+ signConvention: {
8832
+ type: 'string',
8833
+ enum: ['negative-expense', 'positive-expense', 'separate-columns']
8834
+ },
8835
+ creditColumn: {
8836
+ type: 'string'
8837
+ },
8838
+ debitColumn: {
8839
+ type: 'string'
8840
+ }
8841
+ },
8842
+ required: ['columnName']
8843
+ } as const;
8844
+
8845
+ export const $ParserContributionFieldHintsDto = {
8846
+ type: 'object',
8847
+ properties: {
8848
+ date: {
8849
+ $ref: '#/components/schemas/FieldHintDto'
8850
+ },
8851
+ amount: {
8852
+ $ref: '#/components/schemas/FieldHintDto'
8853
+ },
8854
+ description: {
8855
+ $ref: '#/components/schemas/FieldHintDto'
8856
+ },
8857
+ balance: {
8858
+ $ref: '#/components/schemas/FieldHintDto'
8859
+ },
8860
+ payee: {
8861
+ $ref: '#/components/schemas/FieldHintDto'
8862
+ },
8863
+ reference: {
8864
+ $ref: '#/components/schemas/FieldHintDto'
8865
+ },
8866
+ category: {
8867
+ $ref: '#/components/schemas/FieldHintDto'
8868
+ }
8869
+ },
8870
+ required: ['date', 'amount']
8871
+ } as const;
8872
+
8873
+ export const $ExpectedTransactionDto = {
8874
+ type: 'object',
8875
+ properties: {
8876
+ date: {
8877
+ type: 'string',
8878
+ example: '2026-08-01'
8879
+ },
8880
+ amount: {
8881
+ type: 'number',
8882
+ example: -45.5
8883
+ },
8884
+ description: {
8885
+ type: 'string',
8886
+ example: '星巴克-***店'
8887
+ },
8888
+ payee: {
8889
+ type: 'string'
8890
+ },
8891
+ category: {
8892
+ type: 'string'
8893
+ }
8894
+ },
8895
+ required: ['date', 'amount', 'description']
8896
+ } as const;
8897
+
8898
+ export const $ParserContributionExamplesDto = {
8899
+ type: 'object',
8900
+ properties: {
8901
+ expectedTransactions: {
8902
+ type: 'array',
8903
+ items: {
8904
+ $ref: '#/components/schemas/ExpectedTransactionDto'
8905
+ }
8906
+ }
8907
+ },
8908
+ required: ['expectedTransactions']
8909
+ } as const;
8910
+
8911
+ export const $ParserContributionRequestDto = {
8912
+ type: 'object',
8913
+ properties: {
8914
+ meta: {
8915
+ $ref: '#/components/schemas/ParserContributionMetaDto'
8916
+ },
8917
+ samples: {
8918
+ $ref: '#/components/schemas/ParserContributionSamplesDto'
8919
+ },
8920
+ fieldHints: {
8921
+ $ref: '#/components/schemas/ParserContributionFieldHintsDto'
8922
+ },
8923
+ examples: {
8924
+ description: 'Omitted entirely by the client when empty',
8925
+ allOf: [
8926
+ {
8927
+ $ref: '#/components/schemas/ParserContributionExamplesDto'
8928
+ }
8929
+ ]
8930
+ }
8931
+ },
8932
+ required: ['meta', 'samples', 'fieldHints']
8933
+ } as const;
8934
+
8935
+ export const $ParserContributionRelayResponseDto = {
8936
+ type: 'object',
8937
+ properties: {
8938
+ issueUrl: {
8939
+ type: 'string',
8940
+ example: 'https://github.com/fire-zu/firela-vlt/issues/42'
8941
+ },
8942
+ issueNumber: {
8943
+ type: 'number',
8944
+ example: 42
8945
+ }
8946
+ },
8947
+ required: ['issueUrl', 'issueNumber']
8948
+ } as const;
8949
+
8398
8950
  export const $SymbolSearchResultDto = {
8399
8951
  type: 'object',
8400
8952
  properties: {
@@ -8403,35 +8955,35 @@ export const $SymbolSearchResultDto = {
8403
8955
  example: 'AAPL'
8404
8956
  },
8405
8957
  name: {
8406
- type: 'object',
8958
+ type: 'string',
8407
8959
  example: 'Apple Inc.',
8408
8960
  nullable: true
8409
8961
  },
8410
8962
  exchange: {
8411
- type: 'object',
8963
+ type: 'string',
8412
8964
  example: 'US',
8413
8965
  nullable: true
8414
8966
  },
8415
8967
  assetType: {
8416
- type: 'object',
8968
+ type: 'string',
8417
8969
  description: 'OpenBB asset_type (e.g. stock, etf)',
8418
8970
  example: 'stock',
8419
8971
  nullable: true
8420
8972
  },
8421
8973
  assetClass: {
8422
- type: 'object',
8974
+ type: 'string',
8423
8975
  description: 'IGN asset class (region.types.ts ASSET_CLASSES)',
8424
8976
  example: 'EQUITY',
8425
8977
  nullable: true
8426
8978
  },
8427
8979
  assetSubClass: {
8428
- type: 'object',
8980
+ type: 'string',
8429
8981
  description: 'IGN asset sub-class (region.types.ts ASSET_SUB_CLASSES)',
8430
8982
  example: 'STOCK',
8431
8983
  nullable: true
8432
8984
  },
8433
8985
  currency: {
8434
- type: 'object',
8986
+ type: 'string',
8435
8987
  description: 'Trading currency (extra_data or inferred from exchange)',
8436
8988
  example: 'USD',
8437
8989
  nullable: true
@@ -8448,90 +9000,90 @@ export const $SymbolQuoteDto = {
8448
9000
  example: 'AAPL'
8449
9001
  },
8450
9002
  name: {
8451
- type: 'object',
9003
+ type: 'string',
8452
9004
  example: 'Apple Inc.',
8453
9005
  nullable: true
8454
9006
  },
8455
9007
  exchange: {
8456
- type: 'object',
9008
+ type: 'string',
8457
9009
  example: 'US',
8458
9010
  nullable: true
8459
9011
  },
8460
9012
  assetType: {
8461
- type: 'object',
9013
+ type: 'string',
8462
9014
  description: 'OpenBB asset_type',
8463
9015
  example: 'stock',
8464
9016
  nullable: true
8465
9017
  },
8466
9018
  assetClass: {
8467
- type: 'object',
9019
+ type: 'string',
8468
9020
  description: 'IGN asset class',
8469
9021
  example: 'EQUITY',
8470
9022
  nullable: true
8471
9023
  },
8472
9024
  assetSubClass: {
8473
- type: 'object',
9025
+ type: 'string',
8474
9026
  description: 'IGN asset sub-class',
8475
9027
  example: 'STOCK',
8476
9028
  nullable: true
8477
9029
  },
8478
9030
  currency: {
8479
- type: 'object',
9031
+ type: 'string',
8480
9032
  description: 'Trading currency (extra_data or inferred from exchange)',
8481
9033
  example: 'USD',
8482
9034
  nullable: true
8483
9035
  },
8484
9036
  price: {
8485
- type: 'object',
9037
+ type: 'string',
8486
9038
  description: 'Latest price (Decimal string)',
8487
9039
  example: '189.84',
8488
9040
  nullable: true
8489
9041
  },
8490
9042
  priceDate: {
8491
- type: 'object',
9043
+ type: 'string',
8492
9044
  description: 'Date the price was observed (ISO yyyy-MM-dd)',
8493
9045
  example: '2026-08-05',
8494
9046
  nullable: true
8495
9047
  },
8496
9048
  changePercent: {
8497
- type: 'object',
9049
+ type: 'number',
8498
9050
  description:
8499
9051
  'Change vs previous close, in percentage points (1.7 == 1.7%). openbb stores change_percent as a normalized decimal; this exposes percentage points for frontend convenience.',
8500
9052
  example: 1.7,
8501
9053
  nullable: true
8502
9054
  },
8503
9055
  prevClose: {
8504
- type: 'object',
9056
+ type: 'string',
8505
9057
  description: 'Previous close (Decimal string)',
8506
9058
  nullable: true
8507
9059
  },
8508
9060
  open: {
8509
- type: 'object',
9061
+ type: 'string',
8510
9062
  description: 'Day open (Decimal string)',
8511
9063
  nullable: true
8512
9064
  },
8513
9065
  high: {
8514
- type: 'object',
9066
+ type: 'string',
8515
9067
  description: 'Day high (Decimal string)',
8516
9068
  nullable: true
8517
9069
  },
8518
9070
  low: {
8519
- type: 'object',
9071
+ type: 'string',
8520
9072
  description: 'Day low (Decimal string)',
8521
9073
  nullable: true
8522
9074
  },
8523
9075
  volume: {
8524
- type: 'object',
9076
+ type: 'string',
8525
9077
  description: 'Day volume (Decimal string)',
8526
9078
  nullable: true
8527
9079
  },
8528
9080
  yearHigh: {
8529
- type: 'object',
9081
+ type: 'string',
8530
9082
  description: '52-week high (Decimal string)',
8531
9083
  nullable: true
8532
9084
  },
8533
9085
  yearLow: {
8534
- type: 'object',
9086
+ type: 'string',
8535
9087
  description: '52-week low (Decimal string)',
8536
9088
  nullable: true
8537
9089
  }