@firela/api-types 0.0.0-canary.3d558482 → 0.0.0-canary.3d7ae187

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:
@@ -88,6 +96,49 @@ export const $AccountResponseDto = {
88
96
  enum: ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity'],
89
97
  example: 'Assets'
90
98
  },
99
+ assetSubClass: {
100
+ type: 'string',
101
+ description:
102
+ 'Account-level asset sub-class (product type, e.g. STOCK/DEPOSIT/CREDIT_CARD/PERSONAL_LOAN). Computed from the account path via the asset-classifier (ADR-0077). Null for non-asset accounts (Income/Expenses/Equity) or unmatched paths.',
103
+ enum: [
104
+ 'DEPOSIT',
105
+ 'CASH',
106
+ 'MONEY_MARKET_FUND',
107
+ 'STOCK',
108
+ 'ETF',
109
+ 'MUTUAL_FUND',
110
+ 'EQUITY_COMPENSATION',
111
+ 'GOVERNMENT_BOND',
112
+ 'CORPORATE_BOND',
113
+ 'BOND_FUND',
114
+ 'PRIMARY_RESIDENCE',
115
+ 'INVESTMENT_PROPERTY',
116
+ 'REIT',
117
+ 'GOLD',
118
+ 'SILVER',
119
+ 'PRECIOUS_METAL',
120
+ 'PRECIOUS_METAL_FUND',
121
+ 'COMMODITY',
122
+ 'COMMODITY_FUND',
123
+ 'CRYPTOCURRENCY',
124
+ 'RETIREMENT_ACCOUNT',
125
+ 'HEALTH_ACCOUNT',
126
+ 'EDUCATION_ACCOUNT',
127
+ 'INSURANCE',
128
+ 'PRIVATE_EQUITY',
129
+ 'HEDGE_FUND',
130
+ 'COLLECTIBLES',
131
+ 'MORTGAGE',
132
+ 'STUDENT_LOAN',
133
+ 'CREDIT_CARD',
134
+ 'PERSONAL_LOAN',
135
+ 'ACCOUNTS_PAYABLE',
136
+ 'TAX_PAYABLE',
137
+ 'OTHER'
138
+ ],
139
+ nullable: true,
140
+ example: 'STOCK'
141
+ },
91
142
  status: {
92
143
  type: 'string',
93
144
  description: 'Account status',
@@ -138,7 +189,8 @@ export const $AccountResponseDto = {
138
189
  },
139
190
  displayName: {
140
191
  type: 'string',
141
- 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)',
142
194
  example: 'Checking'
143
195
  },
144
196
  icon: {
@@ -154,7 +206,7 @@ export const $AccountResponseDto = {
154
206
  }
155
207
  },
156
208
  platformId: {
157
- type: 'object',
209
+ type: 'string',
158
210
  description: 'Platform ID (null if unbound)',
159
211
  example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2'
160
212
  },
@@ -234,6 +286,14 @@ export const $UpdateAccountDto = {
234
286
  description: 'Icon identifier',
235
287
  example: 'bank-custom'
236
288
  },
289
+ displayName: {
290
+ type: 'string',
291
+ description:
292
+ 'User-set display name override (null = clear the override and fall back to the derived name, omit = unchanged)',
293
+ nullable: true,
294
+ maxLength: 50,
295
+ example: 'Salary card'
296
+ },
237
297
  openDirectiveMeta: {
238
298
  type: 'object',
239
299
  description:
@@ -334,16 +394,43 @@ export const $AccountStandardResponseDto = {
334
394
  },
335
395
  name: {
336
396
  type: 'string',
337
- description: 'Short localized display name',
397
+ description:
398
+ '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).',
338
399
  example: 'Housing Fund'
339
400
  },
401
+ aliases: {
402
+ description:
403
+ '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.',
404
+ example: ['Alipay', 'WeChat Pay'],
405
+ type: 'array',
406
+ items: {
407
+ type: 'string'
408
+ }
409
+ },
410
+ searchTerms: {
411
+ description:
412
+ '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).',
413
+ example: ['yinhangka', 'jiejika'],
414
+ type: 'array',
415
+ items: {
416
+ type: 'string'
417
+ }
418
+ },
419
+ currency: {
420
+ type: 'string',
421
+ description:
422
+ '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).',
423
+ example: 'HKD'
424
+ },
340
425
  description: {
341
426
  type: 'string',
342
- description: 'Account description (stable semantics only)',
427
+ description:
428
+ '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).',
343
429
  example: 'ICBC checking account for daily transactions'
344
430
  },
345
431
  tags: {
346
- description: 'Account tags for categorization',
432
+ description:
433
+ 'Account tags for categorization — structured metadata delivered verbatim (not localized, not xlf-managed). ADR-0131 class A.',
347
434
  example: ['bank', 'checking', 'primary'],
348
435
  type: 'array',
349
436
  items: {
@@ -354,9 +441,47 @@ export const $AccountStandardResponseDto = {
354
441
  type: 'string',
355
442
  description: 'Icon identifier for UI display',
356
443
  example: 'bank-icbc'
444
+ },
445
+ productCategory: {
446
+ type: 'string',
447
+ description:
448
+ 'Onboarding product category (coarse grouping derived from assetSubClass)',
449
+ enum: [
450
+ 'cash',
451
+ 'investment',
452
+ 'credit_card',
453
+ 'loan',
454
+ 'payable_tax',
455
+ 'other'
456
+ ],
457
+ example: 'investment'
458
+ },
459
+ assetClass: {
460
+ type: 'string',
461
+ description:
462
+ 'Asset class (LIQUIDITY/EQUITY/.../LIABILITY), derived at read time from classification rules',
463
+ enum: [
464
+ 'LIQUIDITY',
465
+ 'EQUITY',
466
+ 'FIXED_INCOME',
467
+ 'PRECIOUS_METALS',
468
+ 'COMMODITY',
469
+ 'INSURANCE',
470
+ 'ALTERNATIVE_INVESTMENT',
471
+ 'PERSONAL_ASSETS',
472
+ 'LIABILITY',
473
+ 'REAL_ESTATE',
474
+ 'INDEX'
475
+ ]
476
+ },
477
+ assetSubClass: {
478
+ type: 'string',
479
+ description:
480
+ 'Asset sub-class (product type, derived at read time from classification rules)',
481
+ example: 'STOCK'
357
482
  }
358
483
  },
359
- required: ['path', 'type', 'description', 'tags', 'icon']
484
+ required: ['path', 'type', 'description', 'tags', 'icon', 'productCategory']
360
485
  } as const;
361
486
 
362
487
  export const $AccountStandardListResponseDto = {
@@ -417,7 +542,10 @@ export const $RegionConfigDto = {
417
542
  },
418
543
  locale: {
419
544
  type: 'string',
420
- example: 'de-DE'
545
+ example: 'de-DE',
546
+ pattern: '^[a-z]{2,8}-[A-Z]{2}$',
547
+ description:
548
+ "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)"
421
549
  }
422
550
  },
423
551
  required: ['currency', 'dateFormat', 'locale']
@@ -430,6 +558,12 @@ export const $RegionInfoDto = {
430
558
  type: 'string',
431
559
  example: 'de'
432
560
  },
561
+ open: {
562
+ type: 'boolean',
563
+ example: true,
564
+ description:
565
+ '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.'
566
+ },
433
567
  displayName: {
434
568
  type: 'string',
435
569
  example: 'Germany'
@@ -448,7 +582,7 @@ export const $RegionInfoDto = {
448
582
  $ref: '#/components/schemas/RegionConfigDto'
449
583
  }
450
584
  },
451
- required: ['code', 'displayName', 'chain', 'config']
585
+ required: ['code', 'open', 'displayName', 'chain', 'config']
452
586
  } as const;
453
587
 
454
588
  export const $RegionsMetadataResponseDto = {
@@ -695,7 +829,7 @@ export const $PostingResponseDto = {
695
829
  units: {
696
830
  type: 'string',
697
831
  description:
698
- 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.',
832
+ '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.',
699
833
  example: '100.50'
700
834
  },
701
835
  currency: {
@@ -1061,7 +1195,7 @@ export const $PostingDetailDto = {
1061
1195
  units: {
1062
1196
  type: 'string',
1063
1197
  description:
1064
- 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.',
1198
+ '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.',
1065
1199
  example: '100.50'
1066
1200
  },
1067
1201
  currency: {
@@ -1245,6 +1379,147 @@ export const $TransactionDetailDto = {
1245
1379
  ]
1246
1380
  } as const;
1247
1381
 
1382
+ export const $TransactionListItemDto = {
1383
+ type: 'object',
1384
+ properties: {
1385
+ id: {
1386
+ type: 'string',
1387
+ description: 'Transaction ID',
1388
+ example: 'clh1234567890abcdef'
1389
+ },
1390
+ date: {
1391
+ type: 'string',
1392
+ description: 'Transaction date',
1393
+ example: '2024-11-28'
1394
+ },
1395
+ flag: {
1396
+ type: 'string',
1397
+ description: 'Transaction flag',
1398
+ enum: [
1399
+ 'CLEARED',
1400
+ 'PENDING',
1401
+ 'PADDING',
1402
+ 'SUMMARIZE',
1403
+ 'TRANSFER',
1404
+ 'CONVERSIONS'
1405
+ ],
1406
+ example: 'CLEARED'
1407
+ },
1408
+ customFlag: {
1409
+ type: 'string',
1410
+ description: 'Custom flag (if not using standard flags)',
1411
+ example: 'R'
1412
+ },
1413
+ payee: {
1414
+ type: 'string',
1415
+ description: 'Payee name',
1416
+ example: 'Whole Foods Market'
1417
+ },
1418
+ narration: {
1419
+ type: 'string',
1420
+ description: 'Transaction narration',
1421
+ example: 'Grocery shopping'
1422
+ },
1423
+ tags: {
1424
+ description: 'Transaction tags',
1425
+ example: ['groceries'],
1426
+ type: 'array',
1427
+ items: {
1428
+ type: 'string'
1429
+ }
1430
+ },
1431
+ links: {
1432
+ description: 'Transaction links',
1433
+ example: ['invoice-2024-001'],
1434
+ type: 'array',
1435
+ items: {
1436
+ type: 'string'
1437
+ }
1438
+ },
1439
+ meta: {
1440
+ type: 'object',
1441
+ description: 'Transaction metadata'
1442
+ },
1443
+ status: {
1444
+ type: 'string',
1445
+ description: 'Transaction status',
1446
+ enum: ['ACTIVE', 'VOIDED', 'SUPERSEDED'],
1447
+ example: 'ACTIVE'
1448
+ },
1449
+ sourceType: {
1450
+ type: 'string',
1451
+ description:
1452
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1453
+ },
1454
+ sourcePlatform: {
1455
+ type: 'string',
1456
+ description: 'Source platform (e.g., alipay, wechat)',
1457
+ example: 'alipay'
1458
+ },
1459
+ postings: {
1460
+ description: 'Transaction postings',
1461
+ type: 'array',
1462
+ items: {
1463
+ $ref: '#/components/schemas/PostingDetailDto'
1464
+ }
1465
+ },
1466
+ createdAt: {
1467
+ type: 'string',
1468
+ description: 'Created at timestamp',
1469
+ example: '2024-11-28T10:30:00.000Z'
1470
+ },
1471
+ voidedAt: {
1472
+ type: 'string',
1473
+ description: 'Voided at timestamp (if voided)',
1474
+ example: '2024-11-29T15:00:00.000Z'
1475
+ },
1476
+ voidedBy: {
1477
+ type: 'string',
1478
+ description: 'User ID who voided this transaction',
1479
+ example: 'clh1234567890abcdef'
1480
+ },
1481
+ correctionReason: {
1482
+ type: 'string',
1483
+ description: 'Correction reason (if voided or superseded)',
1484
+ example: 'Duplicate entry'
1485
+ },
1486
+ supersededBy: {
1487
+ type: 'string',
1488
+ description:
1489
+ 'ID of the transaction that supersedes this one (set when status=SUPERSEDED)',
1490
+ example: 'clh1234567890abcdef'
1491
+ },
1492
+ originalTxn: {
1493
+ type: 'string',
1494
+ description:
1495
+ 'ID of the transaction this one corrected/replaced (back-link on the replacement)',
1496
+ example: 'clh1234567890abcdef'
1497
+ },
1498
+ viewpointAmount: {
1499
+ type: 'string',
1500
+ description:
1501
+ '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.',
1502
+ example: '10000.00'
1503
+ },
1504
+ viewpointCurrency: {
1505
+ type: 'string',
1506
+ description:
1507
+ 'Currency of viewpointAmount. A row spanning multiple currencies takes the largest-magnitude currency group (known simplification, ADR-0126).',
1508
+ example: 'CNY'
1509
+ }
1510
+ },
1511
+ required: [
1512
+ 'id',
1513
+ 'date',
1514
+ 'narration',
1515
+ 'tags',
1516
+ 'links',
1517
+ 'status',
1518
+ 'postings',
1519
+ 'createdAt'
1520
+ ]
1521
+ } as const;
1522
+
1248
1523
  export const $BalanceByCurrencyDto = {
1249
1524
  type: 'object',
1250
1525
  properties: {
@@ -1290,7 +1565,7 @@ export const $TransactionListSummaryDto = {
1290
1565
  totalAmount: {
1291
1566
  type: 'string',
1292
1567
  description:
1293
- 'Partial converted total in base currency (rated currencies only, raw Beancount sign). When warnings is non-empty this excludes currencies missing an FX rate; may be "0.00" if ALL non-base currencies lack a rate. Converted at the dateTo (or current) available rate.',
1568
+ '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.',
1294
1569
  example: '-6000.00'
1295
1570
  },
1296
1571
  currency: {
@@ -1316,6 +1591,26 @@ export const $TransactionListSummaryDto = {
1316
1591
  required: ['totalAmount', 'currency', 'balanceByCurrency']
1317
1592
  } as const;
1318
1593
 
1594
+ export const $TransactionListViewpointDto = {
1595
+ type: 'object',
1596
+ properties: {
1597
+ type: {
1598
+ type: 'string',
1599
+ description:
1600
+ 'Viewpoint type (only category drill-down carries a viewpoint today)',
1601
+ enum: ['category'],
1602
+ example: 'category'
1603
+ },
1604
+ flow: {
1605
+ type: 'string',
1606
+ description: 'Flow root the category account set is restricted to',
1607
+ enum: ['income', 'expense'],
1608
+ example: 'expense'
1609
+ }
1610
+ },
1611
+ required: ['type', 'flow']
1612
+ } as const;
1613
+
1319
1614
  export const $TransactionListResponseDto = {
1320
1615
  type: 'object',
1321
1616
  properties: {
@@ -1323,7 +1618,7 @@ export const $TransactionListResponseDto = {
1323
1618
  description: 'List of transactions',
1324
1619
  type: 'array',
1325
1620
  items: {
1326
- $ref: '#/components/schemas/TransactionDetailDto'
1621
+ $ref: '#/components/schemas/TransactionListItemDto'
1327
1622
  }
1328
1623
  },
1329
1624
  total: {
@@ -1349,6 +1644,15 @@ export const $TransactionListResponseDto = {
1349
1644
  $ref: '#/components/schemas/TransactionListSummaryDto'
1350
1645
  }
1351
1646
  ]
1647
+ },
1648
+ viewpoint: {
1649
+ description:
1650
+ '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).',
1651
+ allOf: [
1652
+ {
1653
+ $ref: '#/components/schemas/TransactionListViewpointDto'
1654
+ }
1655
+ ]
1352
1656
  }
1353
1657
  },
1354
1658
  required: ['data', 'total', 'limit', 'offset']
@@ -2259,10 +2563,10 @@ export const $UpdatePayeeDto = {
2259
2563
  meta: {
2260
2564
  type: 'object',
2261
2565
  description:
2262
- 'Metadata for extended information (location, notes, contact info, etc.). Will merge with existing metadata.',
2566
+ 'Metadata for extended information (location, notes, contact info, etc.)',
2263
2567
  example: {
2264
2568
  location: 'Zhongguancun',
2265
- note: 'Updated note',
2569
+ note: 'Near subway station',
2266
2570
  favorite: true
2267
2571
  }
2268
2572
  },
@@ -2823,568 +3127,660 @@ export const $UpdateCommodityDto = {
2823
3127
  }
2824
3128
  } as const;
2825
3129
 
2826
- export const $CreateBeanPriceDto = {
3130
+ export const $CurrencyBalanceDto = {
2827
3131
  type: 'object',
2828
3132
  properties: {
2829
3133
  currency: {
2830
3134
  type: 'string',
2831
- description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2832
- example: 'USD'
2833
- },
2834
- quoteCurrency: {
2835
- type: 'string',
2836
- description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
3135
+ description: 'ISO 4217 currency code',
2837
3136
  example: 'CNY'
2838
3137
  },
2839
- amount: {
2840
- type: 'number',
2841
- description:
2842
- 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
2843
- example: 175.5,
2844
- minimum: 0
2845
- },
2846
- date: {
3138
+ balance: {
2847
3139
  type: 'string',
2848
- description: 'Price date (ISO 8601 format)',
2849
- example: '2024-11-05'
2850
- },
2851
- metadata: {
2852
- type: 'object',
2853
- description:
2854
- 'Metadata (validated by Zod schema, max field lengths enforced)',
2855
- example: {
2856
- source: 'MANUAL',
2857
- note: 'Bank valuation report',
2858
- confidence: 0.95
2859
- }
3140
+ description: 'Balance amount',
3141
+ example: '500000.00'
2860
3142
  }
2861
3143
  },
2862
- required: ['currency', 'quoteCurrency', 'amount', 'date']
3144
+ required: ['currency', 'balance']
2863
3145
  } as const;
2864
3146
 
2865
- export const $PriceResponseDto = {
3147
+ export const $TimeSeriesPointDto = {
2866
3148
  type: 'object',
2867
3149
  properties: {
2868
- id: {
3150
+ date: {
2869
3151
  type: 'string',
2870
- description: 'Unique identifier',
2871
- example: 'uuid-123-456'
3152
+ description: 'Date in YYYY-MM-DD format',
3153
+ example: '2024-06-15'
2872
3154
  },
2873
- userId: {
3155
+ value: {
2874
3156
  type: 'string',
2875
- description: 'User ID (owner of the price)',
2876
- example: 'user-123'
3157
+ description: 'Value at this date (in base currency)',
3158
+ example: '500000.00'
2877
3159
  },
2878
- currency: {
3160
+ change: {
2879
3161
  type: 'string',
2880
- description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2881
- example: 'BTC'
3162
+ description: 'Change from previous point',
3163
+ example: '5000.00'
2882
3164
  },
2883
- quoteCurrency: {
3165
+ assets: {
2884
3166
  type: 'string',
2885
- description: 'Quote currency (pricing currency, e.g., USD, CNY)',
2886
- example: 'USD'
2887
- },
2888
- amount: {
2889
- type: 'number',
2890
- description:
2891
- 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
2892
- example: 50000
3167
+ description: 'Total assets at this date (in base currency)',
3168
+ example: '494338.00'
2893
3169
  },
2894
- date: {
3170
+ liabilities: {
2895
3171
  type: 'string',
2896
- description:
2897
- 'Price date (ISO 8601 format). Represents the date this price was valid.',
2898
- example: '2024-01-01',
2899
- format: 'date'
3172
+ description: 'Total liabilities at this date (in base currency)',
3173
+ example: '310098.00'
2900
3174
  },
2901
- meta: {
2902
- type: 'object',
2903
- description:
2904
- 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
2905
- example: {
2906
- source: 'MANUAL',
2907
- note: 'User-defined price',
2908
- confidence: 1
3175
+ byCurrency: {
3176
+ description: 'Multi-currency breakdown for this point',
3177
+ type: 'array',
3178
+ items: {
3179
+ $ref: '#/components/schemas/CurrencyBalanceDto'
2909
3180
  }
3181
+ }
3182
+ },
3183
+ required: ['date', 'value']
3184
+ } as const;
3185
+
3186
+ export const $TrendSummaryDto = {
3187
+ type: 'object',
3188
+ properties: {
3189
+ startValue: {
3190
+ type: 'string',
3191
+ description: 'Value at start of period',
3192
+ example: '450000.00'
2910
3193
  },
2911
- createdAt: {
2912
- format: 'date-time',
3194
+ endValue: {
2913
3195
  type: 'string',
2914
- description: 'Creation timestamp',
2915
- example: '2024-11-03T10:00:00Z'
3196
+ description: 'Value at end of period',
3197
+ example: '500000.00'
2916
3198
  },
2917
- updatedAt: {
2918
- format: 'date-time',
3199
+ totalChange: {
2919
3200
  type: 'string',
2920
- description: 'Last update timestamp',
2921
- example: '2024-11-03T10:00:00Z'
3201
+ description: 'Total change over period',
3202
+ example: '50000.00'
3203
+ },
3204
+ totalChangePercentage: {
3205
+ type: 'string',
3206
+ description: 'Total change percentage',
3207
+ example: '+11.11%'
2922
3208
  }
2923
3209
  },
2924
- required: [
2925
- 'id',
2926
- 'userId',
2927
- 'currency',
2928
- 'quoteCurrency',
2929
- 'amount',
2930
- 'date',
2931
- 'meta',
2932
- 'createdAt',
2933
- 'updatedAt'
2934
- ]
3210
+ required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
2935
3211
  } as const;
2936
3212
 
2937
- export const $PriceListResponseDto = {
3213
+ export const $MultiCurrencyPointDto = {
2938
3214
  type: 'object',
2939
3215
  properties: {
2940
- items: {
2941
- description: 'List of prices',
3216
+ date: {
3217
+ type: 'string',
3218
+ description: 'Date in YYYY-MM-DD format',
3219
+ example: '2024-06-15'
3220
+ },
3221
+ byCurrency: {
3222
+ description: 'Balances by currency',
2942
3223
  type: 'array',
2943
3224
  items: {
2944
- $ref: '#/components/schemas/PriceResponseDto'
3225
+ $ref: '#/components/schemas/CurrencyBalanceDto'
2945
3226
  }
2946
- },
2947
- total: {
2948
- type: 'number',
2949
- description: 'Total number of prices',
2950
- example: 42
2951
3227
  }
2952
3228
  },
2953
- required: ['items', 'total']
3229
+ required: ['date', 'byCurrency']
2954
3230
  } as const;
2955
3231
 
2956
- export const $UpdateBeanPriceDto = {
3232
+ export const $PortfolioTrendsResponseDto = {
2957
3233
  type: 'object',
2958
3234
  properties: {
2959
- currency: {
2960
- type: 'string',
2961
- description: 'Currency being priced'
3235
+ series: {
3236
+ description: 'Time series data points',
3237
+ type: 'array',
3238
+ items: {
3239
+ $ref: '#/components/schemas/TimeSeriesPointDto'
3240
+ }
2962
3241
  },
2963
- quoteCurrency: {
3242
+ summary: {
3243
+ description: 'Period summary',
3244
+ allOf: [
3245
+ {
3246
+ $ref: '#/components/schemas/TrendSummaryDto'
3247
+ }
3248
+ ]
3249
+ },
3250
+ period: {
2964
3251
  type: 'string',
2965
- description: 'Quote currency (pricing currency)'
3252
+ description: 'Period requested',
3253
+ example: '6m'
2966
3254
  },
2967
- amount: {
2968
- type: 'number',
2969
- description: 'Price amount (MUST be >= 0 per Beancount spec)',
2970
- minimum: 0
3255
+ granularity: {
3256
+ type: 'string',
3257
+ description: 'Data granularity',
3258
+ example: 'month'
2971
3259
  },
2972
- date: {
3260
+ currency: {
2973
3261
  type: 'string',
2974
- description: 'Price date (ISO 8601 format)'
3262
+ description: 'Base currency for converted values',
3263
+ example: 'CNY'
2975
3264
  },
2976
- metadata: {
2977
- type: 'object',
2978
- description: 'Metadata'
3265
+ byCurrency: {
3266
+ description:
3267
+ 'Multi-currency time series (each point has currency breakdown)',
3268
+ type: 'array',
3269
+ items: {
3270
+ $ref: '#/components/schemas/MultiCurrencyPointDto'
3271
+ }
3272
+ },
3273
+ warnings: {
3274
+ description: 'Exchange rate warnings',
3275
+ type: 'array',
3276
+ items: {
3277
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
3278
+ }
2979
3279
  }
2980
- }
3280
+ },
3281
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
2981
3282
  } as const;
2982
3283
 
2983
- export const $CreateRecurringRuleDto = {
3284
+ export const $CashFlowPointDto = {
2984
3285
  type: 'object',
2985
3286
  properties: {
2986
- name: {
3287
+ month: {
2987
3288
  type: 'string',
2988
- description: 'Rule name (unique per user)',
2989
- maxLength: 100
3289
+ description: 'Month key (YYYY-MM)',
3290
+ example: '2024-03'
2990
3291
  },
2991
- icon: {
3292
+ income: {
2992
3293
  type: 'string',
2993
- description: 'Icon emoji',
2994
- maxLength: 10
3294
+ description: 'Income in base currency (absolute, converted)',
3295
+ example: '10000.00'
2995
3296
  },
2996
- frequency: {
3297
+ expense: {
2997
3298
  type: 'string',
2998
- description: 'Recurring frequency',
2999
- enum: [
3000
- 'WEEKLY',
3001
- 'BIWEEKLY',
3002
- 'MONTHLY',
3003
- 'BIMONTHLY',
3004
- 'QUARTERLY',
3005
- 'YEARLY',
3006
- 'CUSTOM'
3007
- ]
3008
- },
3009
- expectedAmount: {
3010
- type: 'number',
3011
- description: 'Expected amount (positive number)',
3012
- minimum: 0
3013
- },
3014
- expectedDay: {
3015
- type: 'number',
3016
- description: 'Expected day of month (1-31)',
3017
- minimum: 1,
3018
- maximum: 31
3299
+ description: 'Expense in base currency (absolute, converted)',
3300
+ example: '5000.00'
3019
3301
  },
3020
- customIntervalDays: {
3021
- type: 'number',
3022
- description: 'Custom interval in days (required for CUSTOM frequency)',
3023
- minimum: 1
3302
+ netSavings: {
3303
+ type: 'string',
3304
+ description: 'netSavings = income − expense (savings positive)',
3305
+ example: '5000.00'
3306
+ }
3307
+ },
3308
+ required: ['month', 'income', 'expense', 'netSavings']
3309
+ } as const;
3310
+
3311
+ export const $CashFlowTrendSummaryDto = {
3312
+ type: 'object',
3313
+ properties: {
3314
+ totalIncome: {
3315
+ type: 'string',
3316
+ description: 'Total income across the period',
3317
+ example: '60000.00'
3024
3318
  },
3025
- currency: {
3319
+ totalExpense: {
3026
3320
  type: 'string',
3027
- description: 'Currency code',
3028
- default: 'CNY',
3029
- maxLength: 10
3321
+ description: 'Total expense across the period',
3322
+ example: '30000.00'
3030
3323
  },
3031
- matchPayeePattern: {
3324
+ totalNetSavings: {
3032
3325
  type: 'string',
3033
- description: 'Payee matching pattern (supports wildcards)',
3034
- maxLength: 200
3326
+ description: 'income − expense across the period',
3327
+ example: '30000.00'
3035
3328
  },
3036
- matchAmountTolerance: {
3037
- type: 'number',
3038
- description: 'Amount tolerance percentage (0-1)',
3039
- default: 0.075,
3040
- minimum: 0,
3041
- maximum: 1
3042
- },
3043
- defaultExpenseAccount: {
3329
+ averageMonthlyNetSavings: {
3044
3330
  type: 'string',
3045
- description: 'Default expense account for auto-create',
3046
- maxLength: 200
3331
+ description:
3332
+ 'totalNetSavings divided by the window length (N months, incl. zero-filled)',
3333
+ example: '5000.00'
3334
+ }
3335
+ },
3336
+ required: [
3337
+ 'totalIncome',
3338
+ 'totalExpense',
3339
+ 'totalNetSavings',
3340
+ 'averageMonthlyNetSavings'
3341
+ ]
3342
+ } as const;
3343
+
3344
+ export const $CashFlowTrendsResponseDto = {
3345
+ type: 'object',
3346
+ properties: {
3347
+ series: {
3348
+ description:
3349
+ 'Monthly cash-flow series (fixed N-month window, zero-filled)',
3350
+ type: 'array',
3351
+ items: {
3352
+ $ref: '#/components/schemas/CashFlowPointDto'
3353
+ }
3047
3354
  },
3048
- defaultPaymentAccount: {
3049
- type: 'string',
3050
- description: 'Default payment account for auto-create',
3051
- maxLength: 200
3355
+ summary: {
3356
+ description: 'Period totals',
3357
+ allOf: [
3358
+ {
3359
+ $ref: '#/components/schemas/CashFlowTrendSummaryDto'
3360
+ }
3361
+ ]
3052
3362
  },
3053
- defaultPayee: {
3363
+ period: {
3054
3364
  type: 'string',
3055
- description: 'Default payee for auto-create',
3056
- maxLength: 200
3057
- },
3058
- autoCreate: {
3059
- type: 'boolean',
3060
- description: 'Auto-create transaction when expected date arrives',
3061
- default: false
3365
+ description: 'Period requested',
3366
+ example: '6m'
3062
3367
  },
3063
- startDate: {
3368
+ granularity: {
3064
3369
  type: 'string',
3065
- description: 'Rule start date (ISO format)'
3370
+ description: 'Data granularity (v1 returns month buckets)',
3371
+ example: 'month'
3066
3372
  },
3067
- endDate: {
3373
+ currency: {
3068
3374
  type: 'string',
3069
- description: 'Rule end date (ISO format)'
3375
+ description: 'Base currency for converted values',
3376
+ example: 'CNY'
3377
+ },
3378
+ warnings: {
3379
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
3380
+ type: 'array',
3381
+ items: {
3382
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
3383
+ }
3070
3384
  }
3071
3385
  },
3072
- required: [
3073
- 'name',
3074
- 'frequency',
3075
- 'expectedAmount',
3076
- 'currency',
3077
- 'matchAmountTolerance',
3078
- 'autoCreate'
3079
- ]
3386
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
3080
3387
  } as const;
3081
3388
 
3082
- export const $RecurringRuleResponseDto = {
3389
+ export const $GenerateSnapshotBody = {
3390
+ type: 'object',
3391
+ properties: {}
3392
+ } as const;
3393
+
3394
+ export const $GenerateSnapshotResponse = {
3395
+ type: 'object',
3396
+ properties: {}
3397
+ } as const;
3398
+
3399
+ export const $BackfillSnapshotsBody = {
3400
+ type: 'object',
3401
+ properties: {}
3402
+ } as const;
3403
+
3404
+ export const $BackfillSnapshotsResponse = {
3405
+ type: 'object',
3406
+ properties: {}
3407
+ } as const;
3408
+
3409
+ export const $CreateBeanPriceDto = {
3083
3410
  type: 'object',
3084
3411
  properties: {
3085
- id: {
3086
- type: 'string',
3087
- description: 'Rule ID'
3088
- },
3089
- userId: {
3412
+ currency: {
3090
3413
  type: 'string',
3091
- description: 'User ID'
3414
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
3415
+ example: 'USD'
3092
3416
  },
3093
- name: {
3417
+ quoteCurrency: {
3094
3418
  type: 'string',
3095
- description: 'Rule name'
3419
+ description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
3420
+ example: 'CNY'
3096
3421
  },
3097
- icon: {
3098
- type: 'object',
3099
- description: 'Icon emoji'
3422
+ amount: {
3423
+ type: 'number',
3424
+ description:
3425
+ 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
3426
+ example: 175.5,
3427
+ minimum: 0
3100
3428
  },
3101
- frequency: {
3429
+ date: {
3102
3430
  type: 'string',
3103
- description: 'Recurring frequency'
3104
- },
3105
- expectedAmount: {
3106
- type: 'number',
3107
- description: 'Expected amount'
3431
+ description: 'Price date (ISO 8601 format)',
3432
+ example: '2024-11-05'
3108
3433
  },
3109
- expectedDay: {
3434
+ metadata: {
3110
3435
  type: 'object',
3111
- description: 'Expected day of month'
3436
+ description:
3437
+ 'Metadata (validated by Zod schema, max field lengths enforced)',
3438
+ example: {
3439
+ source: 'MANUAL',
3440
+ note: 'Bank valuation report',
3441
+ confidence: 0.95
3442
+ }
3443
+ }
3444
+ },
3445
+ required: ['currency', 'quoteCurrency', 'amount', 'date']
3446
+ } as const;
3447
+
3448
+ export const $PriceResponseDto = {
3449
+ type: 'object',
3450
+ properties: {
3451
+ id: {
3452
+ type: 'string',
3453
+ description: 'Unique identifier',
3454
+ example: 'uuid-123-456'
3112
3455
  },
3113
- customIntervalDays: {
3114
- type: 'object',
3115
- description: 'Custom interval in days'
3456
+ userId: {
3457
+ type: 'string',
3458
+ description: 'User ID (owner of the price)',
3459
+ example: 'user-123'
3116
3460
  },
3117
3461
  currency: {
3118
3462
  type: 'string',
3119
- description: 'Currency code'
3463
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
3464
+ example: 'BTC'
3120
3465
  },
3121
- matchPayeePattern: {
3122
- type: 'object',
3123
- description: 'Payee matching pattern'
3466
+ quoteCurrency: {
3467
+ type: 'string',
3468
+ description: 'Quote currency (pricing currency, e.g., USD, CNY)',
3469
+ example: 'USD'
3124
3470
  },
3125
- matchAmountTolerance: {
3471
+ amount: {
3126
3472
  type: 'number',
3127
- description: 'Amount tolerance percentage'
3128
- },
3129
- defaultExpenseAccount: {
3130
- type: 'object',
3131
- description: 'Default expense account'
3132
- },
3133
- defaultPaymentAccount: {
3134
- type: 'object',
3135
- description: 'Default payment account'
3136
- },
3137
- defaultPayee: {
3138
- type: 'object',
3139
- description: 'Default payee'
3140
- },
3141
- isActive: {
3142
- type: 'boolean',
3143
- description: 'Whether rule is active'
3473
+ description:
3474
+ 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
3475
+ example: 50000
3144
3476
  },
3145
- startDate: {
3477
+ date: {
3146
3478
  type: 'string',
3147
- description: 'Rule start date (YYYY-MM-DD)'
3148
- },
3149
- endDate: {
3150
- type: 'object',
3151
- description: 'Rule end date (YYYY-MM-DD)'
3152
- },
3153
- autoCreate: {
3154
- type: 'boolean',
3155
- description: 'Auto-create transaction on expected date'
3479
+ description:
3480
+ 'Price date (ISO 8601 format). Represents the date this price was valid.',
3481
+ example: '2024-01-01',
3482
+ format: 'date'
3156
3483
  },
3157
- lastOccurrence: {
3484
+ meta: {
3158
3485
  type: 'object',
3159
- description: 'Last matched occurrence date (YYYY-MM-DD)'
3160
- },
3161
- totalCount: {
3162
- type: 'number',
3163
- description: 'Total matched transactions count'
3486
+ description:
3487
+ 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
3488
+ example: {
3489
+ source: 'MANUAL',
3490
+ note: 'User-defined price',
3491
+ confidence: 1
3492
+ }
3164
3493
  },
3165
3494
  createdAt: {
3166
3495
  format: 'date-time',
3167
3496
  type: 'string',
3168
- description: 'Created at timestamp'
3497
+ description: 'Creation timestamp',
3498
+ example: '2024-11-03T10:00:00Z'
3169
3499
  },
3170
3500
  updatedAt: {
3171
3501
  format: 'date-time',
3172
3502
  type: 'string',
3173
- description: 'Updated at timestamp'
3503
+ description: 'Last update timestamp',
3504
+ example: '2024-11-03T10:00:00Z'
3174
3505
  }
3175
3506
  },
3176
3507
  required: [
3177
3508
  'id',
3178
3509
  'userId',
3179
- 'name',
3180
- 'frequency',
3181
- 'expectedAmount',
3182
3510
  'currency',
3183
- 'matchAmountTolerance',
3184
- 'isActive',
3185
- 'startDate',
3186
- 'autoCreate',
3187
- 'totalCount',
3511
+ 'quoteCurrency',
3512
+ 'amount',
3513
+ 'date',
3514
+ 'meta',
3188
3515
  'createdAt',
3189
3516
  'updatedAt'
3190
3517
  ]
3191
3518
  } as const;
3192
3519
 
3193
- export const $CreateRuleFromTransactionDto = {
3520
+ export const $PriceListResponseDto = {
3194
3521
  type: 'object',
3195
3522
  properties: {
3196
- frequency: {
3197
- type: 'string',
3198
- description: 'Recurring frequency',
3199
- enum: [
3200
- 'WEEKLY',
3201
- 'BIWEEKLY',
3202
- 'MONTHLY',
3203
- 'BIMONTHLY',
3204
- 'QUARTERLY',
3205
- 'YEARLY',
3206
- 'CUSTOM'
3207
- ],
3208
- example: 'MONTHLY'
3523
+ items: {
3524
+ description: 'List of prices',
3525
+ type: 'array',
3526
+ items: {
3527
+ $ref: '#/components/schemas/PriceResponseDto'
3528
+ }
3209
3529
  },
3210
- name: {
3530
+ total: {
3531
+ type: 'number',
3532
+ description: 'Total number of prices',
3533
+ example: 42
3534
+ }
3535
+ },
3536
+ required: ['items', 'total']
3537
+ } as const;
3538
+
3539
+ export const $UpdateBeanPriceDto = {
3540
+ type: 'object',
3541
+ properties: {
3542
+ currency: {
3211
3543
  type: 'string',
3212
- description: 'Optional name override (default: transaction payee)',
3213
- maxLength: 100
3544
+ description: 'Currency being priced'
3214
3545
  },
3215
- icon: {
3546
+ quoteCurrency: {
3216
3547
  type: 'string',
3217
- description: 'Optional icon emoji',
3218
- maxLength: 10
3548
+ description: 'Quote currency (pricing currency)'
3549
+ },
3550
+ amount: {
3551
+ type: 'number',
3552
+ description: 'Price amount (MUST be >= 0 per Beancount spec)',
3553
+ minimum: 0
3554
+ },
3555
+ date: {
3556
+ type: 'string',
3557
+ description: 'Price date (ISO 8601 format)'
3558
+ },
3559
+ metadata: {
3560
+ type: 'object',
3561
+ description: 'Metadata'
3562
+ }
3563
+ }
3564
+ } as const;
3565
+
3566
+ export const $DeleteOwnUserDto = {
3567
+ type: 'object',
3568
+ properties: {
3569
+ accessToken: {
3570
+ type: 'string',
3571
+ description: 'Access token for user verification',
3572
+ example: 'abc123xyz'
3219
3573
  }
3220
3574
  },
3221
- required: ['frequency']
3575
+ required: ['accessToken']
3222
3576
  } as const;
3223
3577
 
3224
- export const $RecurringRuleWithStatsResponseDto = {
3578
+ export const $UserSettingsResponseDto = {
3579
+ type: 'object',
3580
+ properties: {
3581
+ baseCurrency: {
3582
+ type: 'string',
3583
+ description:
3584
+ '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).',
3585
+ example: 'USD',
3586
+ nullable: true
3587
+ }
3588
+ },
3589
+ required: ['baseCurrency']
3590
+ } as const;
3591
+
3592
+ export const $UserResponseDto = {
3225
3593
  type: 'object',
3226
3594
  properties: {
3227
3595
  id: {
3228
3596
  type: 'string',
3229
- description: 'Rule ID'
3597
+ description: 'User ID'
3230
3598
  },
3231
- userId: {
3599
+ role: {
3232
3600
  type: 'string',
3233
- description: 'User ID'
3601
+ description: 'Assigned user role'
3234
3602
  },
3235
- name: {
3603
+ permissions: {
3604
+ description: 'Permission strings',
3605
+ type: 'array',
3606
+ items: {
3607
+ type: 'string'
3608
+ }
3609
+ },
3610
+ settings: {
3611
+ description: 'User settings',
3612
+ allOf: [
3613
+ {
3614
+ $ref: '#/components/schemas/UserSettingsResponseDto'
3615
+ }
3616
+ ]
3617
+ }
3618
+ },
3619
+ required: ['id', 'role', 'permissions', 'settings']
3620
+ } as const;
3621
+
3622
+ export const $SignupDto = {
3623
+ type: 'object',
3624
+ properties: {
3625
+ turnstileToken: {
3236
3626
  type: 'string',
3237
- description: 'Rule name'
3627
+ description:
3628
+ 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
3629
+ example: '0.abc123def456...'
3630
+ }
3631
+ }
3632
+ } as const;
3633
+
3634
+ export const $SignupResponseDto = {
3635
+ type: 'object',
3636
+ properties: {
3637
+ authToken: {
3638
+ type: 'string',
3639
+ description: 'JWT auth token',
3640
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
3238
3641
  },
3239
- icon: {
3240
- type: 'object',
3241
- description: 'Icon emoji'
3642
+ accessToken: {
3643
+ type: 'string',
3644
+ description: 'Auto-generated access token'
3242
3645
  },
3243
- frequency: {
3646
+ role: {
3244
3647
  type: 'string',
3245
- description: 'Recurring frequency'
3648
+ description: 'Assigned user role',
3649
+ enum: ['USER', 'ADMIN', 'DEMO', 'INACTIVE', 'PAID', 'OPS']
3650
+ }
3651
+ },
3652
+ required: ['authToken', 'accessToken', 'role']
3653
+ } as const;
3654
+
3655
+ export const $UpdateUserSettingDto = {
3656
+ type: 'object',
3657
+ properties: {
3658
+ secId: {
3659
+ type: 'number',
3660
+ description: 'Security ID'
3246
3661
  },
3247
- expectedAmount: {
3662
+ annualInterestRate: {
3248
3663
  type: 'number',
3249
- description: 'Expected amount'
3664
+ description: 'Annual interest rate',
3665
+ example: 0.05
3250
3666
  },
3251
- expectedDay: {
3252
- type: 'object',
3253
- description: 'Expected day of month'
3667
+ currency: {
3668
+ type: 'string',
3669
+ description: 'Currency code',
3670
+ example: 'USD'
3254
3671
  },
3255
- customIntervalDays: {
3256
- type: 'object',
3257
- description: 'Custom interval in days'
3672
+ baseCurrency: {
3673
+ type: 'string',
3674
+ description: 'Base currency code',
3675
+ example: 'USD'
3258
3676
  },
3259
- currency: {
3677
+ benchmark: {
3260
3678
  type: 'string',
3261
- description: 'Currency code'
3679
+ description: 'Benchmark symbol',
3680
+ example: 'SPY'
3262
3681
  },
3263
- matchPayeePattern: {
3264
- type: 'object',
3265
- description: 'Payee matching pattern'
3682
+ colorScheme: {
3683
+ type: 'string',
3684
+ description: 'Color scheme',
3685
+ enum: ['DARK', 'LIGHT']
3266
3686
  },
3267
- matchAmountTolerance: {
3268
- type: 'number',
3269
- description: 'Amount tolerance percentage'
3687
+ dateRange: {
3688
+ type: 'string',
3689
+ description: 'Date range filter',
3690
+ example: '1y'
3270
3691
  },
3271
- defaultExpenseAccount: {
3272
- type: 'object',
3273
- description: 'Default expense account'
3692
+ emergencyFund: {
3693
+ type: 'number',
3694
+ description: 'Emergency fund amount',
3695
+ example: 10000
3274
3696
  },
3275
- defaultPaymentAccount: {
3276
- type: 'object',
3277
- description: 'Default payment account'
3697
+ 'filters.accounts': {
3698
+ description: 'Account filter IDs',
3699
+ type: 'array',
3700
+ items: {
3701
+ type: 'string'
3702
+ }
3278
3703
  },
3279
- defaultPayee: {
3280
- type: 'object',
3281
- description: 'Default payee'
3704
+ 'filters.assetClasses': {
3705
+ description: 'Asset class filters',
3706
+ type: 'array',
3707
+ items: {
3708
+ type: 'string'
3709
+ }
3282
3710
  },
3283
- isActive: {
3284
- type: 'boolean',
3285
- description: 'Whether rule is active'
3711
+ 'filters.dataSource': {
3712
+ type: 'string',
3713
+ description: 'Data source filter'
3286
3714
  },
3287
- startDate: {
3715
+ 'filters.symbol': {
3288
3716
  type: 'string',
3289
- description: 'Rule start date (YYYY-MM-DD)'
3717
+ description: 'Symbol filter'
3290
3718
  },
3291
- endDate: {
3292
- type: 'object',
3293
- description: 'Rule end date (YYYY-MM-DD)'
3719
+ 'filters.tags': {
3720
+ description: 'Tag filters',
3721
+ type: 'array',
3722
+ items: {
3723
+ type: 'string'
3724
+ }
3294
3725
  },
3295
- autoCreate: {
3726
+ isExperimentalFeatures: {
3296
3727
  type: 'boolean',
3297
- description: 'Auto-create transaction on expected date'
3298
- },
3299
- lastOccurrence: {
3300
- type: 'object',
3301
- description: 'Last matched occurrence date (YYYY-MM-DD)'
3728
+ description: 'Enable experimental features'
3302
3729
  },
3303
- totalCount: {
3304
- type: 'number',
3305
- description: 'Total matched transactions count'
3730
+ isRestrictedView: {
3731
+ type: 'boolean',
3732
+ description: 'Enable restricted view mode'
3306
3733
  },
3307
- createdAt: {
3308
- format: 'date-time',
3734
+ language: {
3309
3735
  type: 'string',
3310
- description: 'Created at timestamp'
3736
+ description: 'Language code',
3737
+ example: 'en'
3311
3738
  },
3312
- updatedAt: {
3313
- format: 'date-time',
3739
+ locale: {
3314
3740
  type: 'string',
3315
- description: 'Updated at timestamp'
3316
- },
3317
- pendingCount: {
3318
- type: 'number',
3319
- description: 'Number of pending expected transactions'
3741
+ description: 'Locale code',
3742
+ example: 'en-US'
3320
3743
  },
3321
- overdueCount: {
3744
+ projectedTotalAmount: {
3322
3745
  type: 'number',
3323
- description: 'Number of overdue expected transactions'
3746
+ description: 'Projected total amount',
3747
+ example: 1000000
3324
3748
  },
3325
- nextExpectedDate: {
3326
- type: 'object',
3327
- description: 'Next expected date (YYYY-MM-DD)'
3749
+ retirementDate: {
3750
+ type: 'string',
3751
+ description: 'Retirement date in ISO 8601 format',
3752
+ example: '2050-01-01'
3328
3753
  },
3329
- totalAmount: {
3754
+ savingsRate: {
3330
3755
  type: 'number',
3331
- description: 'Total amount of all matched transactions'
3756
+ description: 'Savings rate percentage',
3757
+ example: 0.2
3332
3758
  },
3333
- averageAmount: {
3334
- type: 'number',
3335
- description: 'Average amount per transaction'
3336
- },
3337
- transactionCount: {
3338
- type: 'number',
3339
- description: 'Number of matched transactions'
3340
- },
3341
- firstDate: {
3342
- type: 'object',
3343
- description: 'First matched transaction date (YYYY-MM-DD)'
3344
- },
3345
- lastDate: {
3346
- type: 'object',
3347
- description: 'Last matched transaction date (YYYY-MM-DD)'
3348
- },
3349
- variance: {
3350
- type: 'number',
3351
- description: 'Amount variance (standard deviation squared)'
3352
- },
3353
- upcomingCount: {
3354
- type: 'number',
3355
- description: 'Number of upcoming expected transactions'
3759
+ viewMode: {
3760
+ type: 'string',
3761
+ description: 'View mode',
3762
+ enum: ['DEFAULT', 'ZEN']
3763
+ }
3764
+ }
3765
+ } as const;
3766
+
3767
+ export const $UpdatePropertyDto = {
3768
+ type: 'object',
3769
+ properties: {
3770
+ value: {
3771
+ type: 'string',
3772
+ description: 'Property value'
3356
3773
  }
3357
3774
  },
3358
- required: [
3359
- 'id',
3360
- 'userId',
3361
- 'name',
3362
- 'frequency',
3363
- 'expectedAmount',
3364
- 'currency',
3365
- 'matchAmountTolerance',
3366
- 'isActive',
3367
- 'startDate',
3368
- 'autoCreate',
3369
- 'totalCount',
3370
- 'createdAt',
3371
- 'updatedAt',
3372
- 'pendingCount',
3373
- 'overdueCount',
3374
- 'totalAmount',
3375
- 'averageAmount',
3376
- 'transactionCount',
3377
- 'variance',
3378
- 'upcomingCount'
3379
- ]
3775
+ required: ['value']
3380
3776
  } as const;
3381
3777
 
3382
- export const $UpdateRecurringRuleDto = {
3778
+ export const $CreateRecurringRuleDto = {
3383
3779
  type: 'object',
3384
3780
  properties: {
3385
3781
  name: {
3386
3782
  type: 'string',
3387
- description: 'Rule name',
3783
+ description: 'Rule name (unique per user)',
3388
3784
  maxLength: 100
3389
3785
  },
3390
3786
  icon: {
@@ -3407,7 +3803,7 @@ export const $UpdateRecurringRuleDto = {
3407
3803
  },
3408
3804
  expectedAmount: {
3409
3805
  type: 'number',
3410
- description: 'Expected amount',
3806
+ description: 'Expected amount (positive number)',
3411
3807
  minimum: 0
3412
3808
  },
3413
3809
  expectedDay: {
@@ -3418,7 +3814,7 @@ export const $UpdateRecurringRuleDto = {
3418
3814
  },
3419
3815
  customIntervalDays: {
3420
3816
  type: 'number',
3421
- description: 'Custom interval in days',
3817
+ description: 'Custom interval in days (required for CUSTOM frequency)',
3422
3818
  minimum: 1
3423
3819
  },
3424
3820
  currency: {
@@ -3428,118 +3824,136 @@ export const $UpdateRecurringRuleDto = {
3428
3824
  },
3429
3825
  matchPayeePattern: {
3430
3826
  type: 'string',
3431
- description: 'Payee matching pattern',
3827
+ description: 'Payee matching pattern (supports wildcards)',
3432
3828
  maxLength: 200
3433
3829
  },
3434
3830
  matchAmountTolerance: {
3435
3831
  type: 'number',
3436
3832
  description: 'Amount tolerance percentage (0-1)',
3833
+ default: 0.075,
3437
3834
  minimum: 0,
3438
3835
  maximum: 1
3439
3836
  },
3440
3837
  defaultExpenseAccount: {
3441
3838
  type: 'string',
3442
- description: 'Default expense account',
3839
+ description: 'Default expense account for auto-create',
3443
3840
  maxLength: 200
3444
3841
  },
3445
3842
  defaultPaymentAccount: {
3446
3843
  type: 'string',
3447
- description: 'Default payment account',
3844
+ description: 'Default payment account for auto-create',
3448
3845
  maxLength: 200
3449
3846
  },
3450
3847
  defaultPayee: {
3451
3848
  type: 'string',
3452
- description: 'Default payee',
3849
+ description: 'Default payee for auto-create',
3453
3850
  maxLength: 200
3454
3851
  },
3455
3852
  autoCreate: {
3456
3853
  type: 'boolean',
3457
- description: 'Auto-create transaction'
3854
+ description: 'Auto-create transaction when expected date arrives',
3855
+ default: false
3458
3856
  },
3459
- isActive: {
3460
- type: 'boolean',
3461
- description: 'Rule active status'
3857
+ startDate: {
3858
+ type: 'string',
3859
+ description: 'Rule start date (ISO format)'
3462
3860
  },
3463
3861
  endDate: {
3464
3862
  type: 'string',
3465
3863
  description: 'Rule end date (ISO format)'
3466
3864
  }
3467
- }
3865
+ },
3866
+ required: [
3867
+ 'name',
3868
+ 'frequency',
3869
+ 'expectedAmount',
3870
+ 'matchAmountTolerance',
3871
+ 'autoCreate'
3872
+ ]
3468
3873
  } as const;
3469
3874
 
3470
- export const $ExpectedTransactionRuleDto = {
3875
+ export const $RecurringRuleResponseDto = {
3471
3876
  type: 'object',
3472
3877
  properties: {
3878
+ id: {
3879
+ type: 'string',
3880
+ description: 'Rule ID'
3881
+ },
3882
+ userId: {
3883
+ type: 'string',
3884
+ description: 'User ID'
3885
+ },
3473
3886
  name: {
3474
3887
  type: 'string',
3475
3888
  description: 'Rule name'
3476
3889
  },
3477
3890
  icon: {
3478
- type: 'object',
3479
- description: 'Rule icon'
3891
+ type: 'string',
3892
+ description: 'Icon emoji'
3480
3893
  },
3481
3894
  frequency: {
3482
3895
  type: 'string',
3483
- description: 'Rule frequency'
3896
+ description: 'Recurring frequency'
3897
+ },
3898
+ expectedAmount: {
3899
+ type: 'number',
3900
+ description: 'Expected amount'
3901
+ },
3902
+ expectedDay: {
3903
+ type: 'number',
3904
+ description: 'Expected day of month'
3905
+ },
3906
+ customIntervalDays: {
3907
+ type: 'number',
3908
+ description: 'Custom interval in days'
3484
3909
  },
3485
3910
  currency: {
3486
3911
  type: 'string',
3487
3912
  description: 'Currency code'
3488
- }
3489
- },
3490
- required: ['name', 'frequency', 'currency']
3491
- } as const;
3492
-
3493
- export const $ExpectedTransactionResponseDto = {
3494
- type: 'object',
3495
- properties: {
3496
- id: {
3497
- type: 'string',
3498
- description: 'Expected transaction ID'
3499
3913
  },
3500
- userId: {
3914
+ matchPayeePattern: {
3501
3915
  type: 'string',
3502
- description: 'User ID'
3916
+ description: 'Payee matching pattern'
3503
3917
  },
3504
- ruleId: {
3505
- type: 'string',
3506
- description: 'Associated rule ID'
3918
+ matchAmountTolerance: {
3919
+ type: 'number',
3920
+ description: 'Amount tolerance percentage'
3507
3921
  },
3508
- expectedDate: {
3922
+ defaultExpenseAccount: {
3509
3923
  type: 'string',
3510
- description: 'Expected date (YYYY-MM-DD)'
3924
+ description: 'Default expense account'
3511
3925
  },
3512
- expectedAmount: {
3513
- type: 'number',
3514
- description: 'Expected amount'
3926
+ defaultPaymentAccount: {
3927
+ type: 'string',
3928
+ description: 'Default payment account'
3515
3929
  },
3516
- status: {
3930
+ defaultPayee: {
3517
3931
  type: 'string',
3518
- description: 'Status (PENDING, COMPLETED, SKIPPED)'
3932
+ description: 'Default payee'
3519
3933
  },
3520
- matchedTransactionId: {
3521
- type: 'object',
3522
- description: 'Matched transaction ID'
3934
+ isActive: {
3935
+ type: 'boolean',
3936
+ description: 'Whether rule is active'
3523
3937
  },
3524
- matchedAt: {
3525
- type: 'object',
3526
- description: 'Match timestamp (ISO 8601)'
3938
+ startDate: {
3939
+ type: 'string',
3940
+ description: 'Rule start date (YYYY-MM-DD)'
3527
3941
  },
3528
- matchConfidence: {
3529
- type: 'object',
3530
- description: 'Match confidence score (0-1)'
3942
+ endDate: {
3943
+ type: 'string',
3944
+ description: 'Rule end date (YYYY-MM-DD)'
3531
3945
  },
3532
- isOverdue: {
3946
+ autoCreate: {
3533
3947
  type: 'boolean',
3534
- description: 'Whether this expected transaction is overdue'
3948
+ description: 'Auto-create transaction on expected date'
3535
3949
  },
3536
- rule: {
3537
- description: 'Rule information',
3538
- allOf: [
3539
- {
3540
- $ref: '#/components/schemas/ExpectedTransactionRuleDto'
3541
- }
3542
- ]
3950
+ lastOccurrence: {
3951
+ type: 'string',
3952
+ description: 'Last matched occurrence date (YYYY-MM-DD)'
3953
+ },
3954
+ totalCount: {
3955
+ type: 'number',
3956
+ description: 'Total matched transactions count'
3543
3957
  },
3544
3958
  createdAt: {
3545
3959
  format: 'date-time',
@@ -3555,713 +3969,584 @@ export const $ExpectedTransactionResponseDto = {
3555
3969
  required: [
3556
3970
  'id',
3557
3971
  'userId',
3558
- 'ruleId',
3559
- 'expectedDate',
3972
+ 'name',
3973
+ 'frequency',
3560
3974
  'expectedAmount',
3561
- 'status',
3562
- 'isOverdue',
3563
- 'rule',
3975
+ 'currency',
3976
+ 'matchAmountTolerance',
3977
+ 'isActive',
3978
+ 'startDate',
3979
+ 'autoCreate',
3980
+ 'totalCount',
3564
3981
  'createdAt',
3565
3982
  'updatedAt'
3566
3983
  ]
3567
3984
  } as const;
3568
3985
 
3569
- export const $ExpectedTransactionListResponseDto = {
3986
+ export const $CreateRuleFromTransactionDto = {
3570
3987
  type: 'object',
3571
3988
  properties: {
3572
- items: {
3573
- type: 'array',
3574
- items: {
3575
- $ref: '#/components/schemas/ExpectedTransactionResponseDto'
3576
- }
3989
+ frequency: {
3990
+ type: 'string',
3991
+ description: 'Recurring frequency',
3992
+ enum: [
3993
+ 'WEEKLY',
3994
+ 'BIWEEKLY',
3995
+ 'MONTHLY',
3996
+ 'BIMONTHLY',
3997
+ 'QUARTERLY',
3998
+ 'YEARLY',
3999
+ 'CUSTOM'
4000
+ ],
4001
+ example: 'MONTHLY'
3577
4002
  },
3578
- total: {
3579
- type: 'number',
3580
- description: 'Total count'
3581
- }
3582
- },
3583
- required: ['items', 'total']
3584
- } as const;
3585
-
3586
- export const $ConfirmMatchDto = {
3587
- type: 'object',
3588
- properties: {
3589
- transactionId: {
4003
+ name: {
3590
4004
  type: 'string',
3591
- description: 'Transaction ID to match with'
4005
+ description: 'Optional name override (default: transaction payee)',
4006
+ maxLength: 100
4007
+ },
4008
+ icon: {
4009
+ type: 'string',
4010
+ description: 'Optional icon emoji',
4011
+ maxLength: 10
3592
4012
  }
3593
4013
  },
3594
- required: ['transactionId']
4014
+ required: ['frequency']
3595
4015
  } as const;
3596
4016
 
3597
- export const $EnterNowDto = {
4017
+ export const $RecurringRuleWithStatsResponseDto = {
3598
4018
  type: 'object',
3599
4019
  properties: {
3600
- expenseAccount: {
4020
+ id: {
3601
4021
  type: 'string',
3602
- description:
3603
- 'Override expense account (uses rule default if not provided)',
3604
- maxLength: 200
4022
+ description: 'Rule ID'
3605
4023
  },
3606
- paymentAccount: {
4024
+ userId: {
3607
4025
  type: 'string',
3608
- description:
3609
- 'Override payment account (uses rule default if not provided)',
3610
- maxLength: 200
3611
- },
3612
- amount: {
3613
- type: 'number',
3614
- description: 'Override amount (uses expected amount if not provided)',
3615
- minimum: 0
4026
+ description: 'User ID'
3616
4027
  },
3617
- payee: {
4028
+ name: {
3618
4029
  type: 'string',
3619
- description: 'Override payee (uses rule default if not provided)',
3620
- maxLength: 200
4030
+ description: 'Rule name'
3621
4031
  },
3622
- narration: {
3623
- type: 'string',
3624
- description: 'Optional narration',
3625
- maxLength: 500
3626
- }
3627
- }
3628
- } as const;
3629
-
3630
- export const $ForecastItemDto = {
3631
- type: 'object',
3632
- properties: {
3633
- rule: {
4032
+ icon: {
3634
4033
  type: 'string',
3635
- description: 'Rule name',
3636
- example: 'Rent'
4034
+ description: 'Icon emoji'
3637
4035
  },
3638
- ruleId: {
4036
+ frequency: {
3639
4037
  type: 'string',
3640
- description: 'Rule ID',
3641
- example: 'clx123...'
4038
+ description: 'Recurring frequency'
3642
4039
  },
3643
- amount: {
4040
+ expectedAmount: {
3644
4041
  type: 'number',
3645
- description: 'Expected amount',
3646
- example: 3000
4042
+ description: 'Expected amount'
3647
4043
  },
3648
- date: {
3649
- type: 'string',
3650
- description: 'Expected date (YYYY-MM-DD)',
3651
- example: '2024-04-01'
4044
+ expectedDay: {
4045
+ type: 'number',
4046
+ description: 'Expected day of month'
3652
4047
  },
3653
- icon: {
3654
- type: 'string',
3655
- description: 'Rule icon emoji',
3656
- example: '🏠',
3657
- nullable: true
4048
+ customIntervalDays: {
4049
+ type: 'number',
4050
+ description: 'Custom interval in days'
3658
4051
  },
3659
4052
  currency: {
3660
4053
  type: 'string',
3661
- description: 'Currency code',
3662
- example: 'CNY'
3663
- }
3664
- },
3665
- required: ['rule', 'ruleId', 'amount', 'date', 'icon', 'currency']
3666
- } as const;
3667
-
3668
- export const $MonthlyForecastDto = {
3669
- type: 'object',
3670
- properties: {
3671
- month: {
3672
- type: 'string',
3673
- description: 'Month (YYYY-MM)',
3674
- example: '2024-04'
4054
+ description: 'Currency code'
3675
4055
  },
3676
- expectedOutflow: {
3677
- type: 'number',
3678
- description: 'Total expected outflow for the month',
3679
- example: 8500
4056
+ matchPayeePattern: {
4057
+ type: 'string',
4058
+ description: 'Payee matching pattern'
3680
4059
  },
3681
- itemCount: {
4060
+ matchAmountTolerance: {
3682
4061
  type: 'number',
3683
- description: 'Number of expected transactions',
3684
- example: 3
3685
- },
3686
- byCurrency: {
3687
- type: 'object',
3688
- description: 'Breakdown by currency',
3689
- example: {
3690
- CNY: 8500,
3691
- USD: 100
3692
- }
4062
+ description: 'Amount tolerance percentage'
3693
4063
  },
3694
- items: {
3695
- description: 'Individual forecast items',
3696
- type: 'array',
3697
- items: {
3698
- $ref: '#/components/schemas/ForecastItemDto'
3699
- }
3700
- }
3701
- },
3702
- required: ['month', 'expectedOutflow', 'itemCount', 'byCurrency', 'items']
3703
- } as const;
3704
-
3705
- export const $ForecastResponseDto = {
3706
- type: 'object',
3707
- properties: {
3708
- forecast: {
3709
- description: 'Monthly forecast data',
3710
- type: 'array',
3711
- items: {
3712
- $ref: '#/components/schemas/MonthlyForecastDto'
3713
- }
4064
+ defaultExpenseAccount: {
4065
+ type: 'string',
4066
+ description: 'Default expense account'
3714
4067
  },
3715
- totalOutflow: {
3716
- type: 'number',
3717
- description: 'Total expected outflow across all months',
3718
- example: 25500
4068
+ defaultPaymentAccount: {
4069
+ type: 'string',
4070
+ description: 'Default payment account'
3719
4071
  },
3720
- totalByCurrency: {
3721
- type: 'object',
3722
- description: 'Total by currency across all months',
3723
- example: {
3724
- CNY: 25500,
3725
- USD: 300
3726
- }
4072
+ defaultPayee: {
4073
+ type: 'string',
4074
+ description: 'Default payee'
3727
4075
  },
3728
- rulesCount: {
3729
- type: 'number',
3730
- description: 'Number of active recurring rules included',
3731
- example: 5
4076
+ isActive: {
4077
+ type: 'boolean',
4078
+ description: 'Whether rule is active'
3732
4079
  },
3733
- periodStart: {
4080
+ startDate: {
3734
4081
  type: 'string',
3735
- description: 'Forecast period start date',
3736
- example: '2024-04-01'
4082
+ description: 'Rule start date (YYYY-MM-DD)'
3737
4083
  },
3738
- periodEnd: {
3739
- type: 'string',
3740
- description: 'Forecast period end date',
3741
- example: '2024-06-30'
3742
- }
3743
- },
3744
- required: [
3745
- 'forecast',
3746
- 'totalOutflow',
3747
- 'totalByCurrency',
3748
- 'rulesCount',
3749
- 'periodStart',
3750
- 'periodEnd'
3751
- ]
3752
- } as const;
3753
-
3754
- export const $CreateTransactionRuleDto = {
3755
- type: 'object',
3756
- properties: {
3757
- name: {
4084
+ endDate: {
3758
4085
  type: 'string',
3759
- minLength: 1,
3760
- maxLength: 100
4086
+ description: 'Rule end date (YYYY-MM-DD)'
3761
4087
  },
3762
- description: {
4088
+ autoCreate: {
4089
+ type: 'boolean',
4090
+ description: 'Auto-create transaction on expected date'
4091
+ },
4092
+ lastOccurrence: {
3763
4093
  type: 'string',
3764
- maxLength: 500
4094
+ description: 'Last matched occurrence date (YYYY-MM-DD)'
3765
4095
  },
3766
- narrationKeywords: {
3767
- items: {
3768
- type: 'array'
3769
- },
3770
- maxItems: 50,
3771
- type: 'array'
4096
+ totalCount: {
4097
+ type: 'number',
4098
+ description: 'Total matched transactions count'
3772
4099
  },
3773
- payeeKeywords: {
3774
- items: {
3775
- type: 'array'
3776
- },
3777
- maxItems: 50,
3778
- type: 'array'
4100
+ createdAt: {
4101
+ format: 'date-time',
4102
+ type: 'string',
4103
+ description: 'Created at timestamp'
3779
4104
  },
3780
- categoryKeywords: {
3781
- items: {
3782
- type: 'array'
3783
- },
3784
- maxItems: 50,
3785
- type: 'array'
4105
+ updatedAt: {
4106
+ format: 'date-time',
4107
+ type: 'string',
4108
+ description: 'Updated at timestamp'
3786
4109
  },
3787
- methodKeywords: {
3788
- items: {
3789
- type: 'array'
3790
- },
3791
- maxItems: 50,
3792
- description: 'Payment method keywords (e.g., HuaBei, YuEBao)',
3793
- type: 'array'
4110
+ pendingCount: {
4111
+ type: 'number',
4112
+ description: 'Number of pending expected transactions'
3794
4113
  },
3795
- categoryAccount: {
3796
- type: 'string',
3797
- maxLength: 200,
3798
- description:
3799
- 'Destination account for expenses/income (e.g., Expenses:Food:Coffee)'
4114
+ overdueCount: {
4115
+ type: 'number',
4116
+ description: 'Number of overdue expected transactions'
3800
4117
  },
3801
- matchLogic: {
4118
+ nextExpectedDate: {
3802
4119
  type: 'string',
3803
- enum: ['OR', 'AND'],
3804
- default: 'OR'
4120
+ description: 'Next expected date (YYYY-MM-DD)'
3805
4121
  },
3806
- amountMin: {
4122
+ totalAmount: {
3807
4123
  type: 'number',
3808
- minimum: 0,
3809
- description: 'Minimum transaction amount (inclusive)'
4124
+ description: 'Total amount of all matched transactions'
3810
4125
  },
3811
- amountMax: {
4126
+ averageAmount: {
3812
4127
  type: 'number',
3813
- minimum: 0,
3814
- description: 'Maximum transaction amount (inclusive)'
4128
+ description: 'Average amount per transaction'
3815
4129
  },
3816
- priority: {
4130
+ transactionCount: {
3817
4131
  type: 'number',
3818
- default: 50,
3819
- minimum: 0,
3820
- maximum: 1000
4132
+ description: 'Number of matched transactions'
3821
4133
  },
3822
- additionalTags: {
3823
- items: {
3824
- type: 'array'
3825
- },
3826
- maxItems: 20,
3827
- type: 'array'
4134
+ firstDate: {
4135
+ type: 'string',
4136
+ description: 'First matched transaction date (YYYY-MM-DD)'
3828
4137
  },
3829
- additionalMetadata: {
3830
- type: 'object'
4138
+ lastDate: {
4139
+ type: 'string',
4140
+ description: 'Last matched transaction date (YYYY-MM-DD)'
3831
4141
  },
3832
- upsertByPayee: {
3833
- type: 'boolean',
3834
- description:
3835
- 'If true, update existing rule with matching payeeKeywords[0] instead of creating new rule'
3836
- }
3837
- },
3838
- required: ['name', 'matchLogic', 'priority']
3839
- } as const;
3840
-
3841
- export const $AmountRangeDto = {
3842
- type: 'object',
3843
- properties: {
3844
- min: {
4142
+ variance: {
3845
4143
  type: 'number',
3846
- description: 'Minimum amount'
4144
+ description: 'Amount variance (standard deviation squared)'
3847
4145
  },
3848
- max: {
4146
+ upcomingCount: {
3849
4147
  type: 'number',
3850
- description: 'Maximum amount'
4148
+ description: 'Number of upcoming expected transactions'
3851
4149
  }
3852
- }
4150
+ },
4151
+ required: [
4152
+ 'id',
4153
+ 'userId',
4154
+ 'name',
4155
+ 'frequency',
4156
+ 'expectedAmount',
4157
+ 'currency',
4158
+ 'matchAmountTolerance',
4159
+ 'isActive',
4160
+ 'startDate',
4161
+ 'autoCreate',
4162
+ 'totalCount',
4163
+ 'createdAt',
4164
+ 'updatedAt',
4165
+ 'pendingCount',
4166
+ 'overdueCount',
4167
+ 'totalAmount',
4168
+ 'averageAmount',
4169
+ 'transactionCount',
4170
+ 'variance',
4171
+ 'upcomingCount'
4172
+ ]
3853
4173
  } as const;
3854
4174
 
3855
- export const $TransactionRuleResponseDto = {
4175
+ export const $UpdateRecurringRuleDto = {
3856
4176
  type: 'object',
3857
4177
  properties: {
3858
- id: {
3859
- type: 'string',
3860
- description: 'Rule ID'
3861
- },
3862
4178
  name: {
3863
4179
  type: 'string',
3864
- description: 'Rule name'
3865
- },
3866
- description: {
3867
- type: 'string',
3868
- description: 'Rule description'
3869
- },
3870
- narrationKeywords: {
3871
- description: 'Keywords to match in transaction narration',
3872
- type: 'array',
3873
- items: {
3874
- type: 'string'
3875
- }
3876
- },
3877
- payeeKeywords: {
3878
- description: 'Keywords to match in payee name',
3879
- type: 'array',
3880
- items: {
3881
- type: 'string'
3882
- }
3883
- },
3884
- categoryKeywords: {
3885
- description: 'Keywords to match in category',
3886
- type: 'array',
3887
- items: {
3888
- type: 'string'
3889
- }
3890
- },
3891
- methodKeywords: {
3892
- description: 'Keywords to match in payment method',
3893
- type: 'array',
3894
- items: {
3895
- type: 'string'
3896
- }
4180
+ description: 'Rule name (unique per user)',
4181
+ maxLength: 100
3897
4182
  },
3898
- categoryAccount: {
4183
+ icon: {
3899
4184
  type: 'string',
3900
- description: 'Destination account for categorization'
4185
+ description: 'Icon emoji',
4186
+ maxLength: 10
3901
4187
  },
3902
- matchLogic: {
4188
+ frequency: {
3903
4189
  type: 'string',
3904
- description: 'Keyword matching logic',
3905
- enum: ['OR', 'AND'],
3906
- example: 'OR'
3907
- },
3908
- amountRange: {
3909
- description: 'Amount range for matching',
3910
- allOf: [
3911
- {
3912
- $ref: '#/components/schemas/AmountRangeDto'
3913
- }
4190
+ description: 'Recurring frequency',
4191
+ enum: [
4192
+ 'WEEKLY',
4193
+ 'BIWEEKLY',
4194
+ 'MONTHLY',
4195
+ 'BIMONTHLY',
4196
+ 'QUARTERLY',
4197
+ 'YEARLY',
4198
+ 'CUSTOM'
3914
4199
  ]
3915
4200
  },
3916
- priority: {
4201
+ expectedAmount: {
3917
4202
  type: 'number',
3918
- description: 'Rule priority (0-1000, higher = first match)',
3919
- example: 50
4203
+ description: 'Expected amount (positive number)',
4204
+ minimum: 0
3920
4205
  },
3921
- enabled: {
3922
- type: 'boolean',
3923
- description: 'Whether the rule is enabled'
4206
+ expectedDay: {
4207
+ type: 'number',
4208
+ description: 'Expected day of month (1-31)',
4209
+ minimum: 1,
4210
+ maximum: 31
3924
4211
  },
3925
- learningSource: {
4212
+ currency: {
3926
4213
  type: 'string',
3927
- description: 'Learning source: NLP, REVIEW_CENTER, or null for manual',
3928
- enum: ['NLP', 'REVIEW_CENTER'],
3929
- nullable: true,
3930
- example: 'REVIEW_CENTER'
4214
+ description: 'Currency code',
4215
+ maxLength: 10
3931
4216
  },
3932
- autoApplyEnabled: {
3933
- type: 'boolean',
3934
- description: 'Whether auto-apply is enabled for this rule'
4217
+ matchPayeePattern: {
4218
+ type: 'string',
4219
+ description: 'Payee matching pattern (supports wildcards)',
4220
+ maxLength: 200
3935
4221
  },
3936
- confirmationCount: {
4222
+ matchAmountTolerance: {
3937
4223
  type: 'number',
3938
- description: 'Number of confirmations for NLP-learned rules',
3939
- example: 3
4224
+ description: 'Amount tolerance percentage (0-1)',
4225
+ default: 0.075,
4226
+ minimum: 0,
4227
+ maximum: 1
3940
4228
  },
3941
- additionalTags: {
3942
- description: 'Additional tags',
3943
- type: 'array',
3944
- items: {
3945
- type: 'string'
3946
- }
4229
+ defaultExpenseAccount: {
4230
+ type: 'string',
4231
+ description: 'Default expense account for auto-create',
4232
+ maxLength: 200
3947
4233
  },
3948
- additionalMetadata: {
3949
- type: 'object',
3950
- description: 'Additional metadata',
3951
- additionalProperties: {
3952
- type: 'string'
3953
- }
4234
+ defaultPaymentAccount: {
4235
+ type: 'string',
4236
+ description: 'Default payment account for auto-create',
4237
+ maxLength: 200
3954
4238
  },
3955
- createdAt: {
3956
- format: 'date-time',
4239
+ defaultPayee: {
3957
4240
  type: 'string',
3958
- description: 'Created timestamp'
4241
+ description: 'Default payee for auto-create',
4242
+ maxLength: 200
3959
4243
  },
3960
- updatedAt: {
3961
- format: 'date-time',
4244
+ autoCreate: {
4245
+ type: 'boolean',
4246
+ description: 'Auto-create transaction when expected date arrives',
4247
+ default: false
4248
+ },
4249
+ endDate: {
3962
4250
  type: 'string',
3963
- description: 'Updated timestamp'
4251
+ description: 'Rule end date (ISO format)'
4252
+ },
4253
+ customIntervalDays: {
4254
+ type: 'number',
4255
+ description: 'Custom interval in days',
4256
+ minimum: 1
4257
+ },
4258
+ isActive: {
4259
+ type: 'boolean',
4260
+ description: 'Rule active status'
3964
4261
  }
3965
- },
3966
- required: [
3967
- 'id',
3968
- 'name',
3969
- 'narrationKeywords',
3970
- 'payeeKeywords',
3971
- 'categoryKeywords',
3972
- 'methodKeywords',
3973
- 'matchLogic',
3974
- 'priority',
3975
- 'enabled',
3976
- 'autoApplyEnabled',
3977
- 'confirmationCount',
3978
- 'additionalTags',
3979
- 'createdAt',
3980
- 'updatedAt'
3981
- ]
4262
+ }
3982
4263
  } as const;
3983
4264
 
3984
- export const $TransactionRuleListResponseDto = {
4265
+ export const $ExpectedTransactionRuleDto = {
3985
4266
  type: 'object',
3986
4267
  properties: {
3987
- data: {
3988
- type: 'array',
3989
- items: {
3990
- $ref: '#/components/schemas/TransactionRuleResponseDto'
3991
- }
4268
+ name: {
4269
+ type: 'string',
4270
+ description: 'Rule name'
3992
4271
  },
3993
- total: {
3994
- type: 'number',
3995
- description: 'Total count of rules'
4272
+ icon: {
4273
+ type: 'string',
4274
+ description: 'Rule icon'
3996
4275
  },
3997
- limit: {
3998
- type: 'number',
3999
- description: 'Results per page'
4276
+ frequency: {
4277
+ type: 'string',
4278
+ description: 'Rule frequency'
4000
4279
  },
4001
- offset: {
4002
- type: 'number',
4003
- description: 'Pagination offset'
4280
+ currency: {
4281
+ type: 'string',
4282
+ description: 'Currency code'
4004
4283
  }
4005
4284
  },
4006
- required: ['data', 'total', 'limit', 'offset']
4285
+ required: ['name', 'frequency', 'currency']
4007
4286
  } as const;
4008
4287
 
4009
- export const $ValidateRuleDto = {
4288
+ export const $ExpectedTransactionResponseDto = {
4010
4289
  type: 'object',
4011
4290
  properties: {
4012
- name: {
4291
+ id: {
4013
4292
  type: 'string',
4014
- minLength: 1,
4015
- maxLength: 100
4293
+ description: 'Expected transaction ID'
4016
4294
  },
4017
- description: {
4295
+ userId: {
4018
4296
  type: 'string',
4019
- maxLength: 500
4020
- },
4021
- narrationKeywords: {
4022
- items: {
4023
- type: 'array'
4024
- },
4025
- maxItems: 50,
4026
- type: 'array'
4297
+ description: 'User ID'
4027
4298
  },
4028
- payeeKeywords: {
4029
- items: {
4030
- type: 'array'
4031
- },
4032
- maxItems: 50,
4033
- type: 'array'
4299
+ ruleId: {
4300
+ type: 'string',
4301
+ description: 'Associated rule ID'
4034
4302
  },
4035
- categoryKeywords: {
4036
- items: {
4037
- type: 'array'
4038
- },
4039
- maxItems: 50,
4040
- type: 'array'
4303
+ expectedDate: {
4304
+ type: 'string',
4305
+ description: 'Expected date (YYYY-MM-DD)'
4041
4306
  },
4042
- methodKeywords: {
4043
- items: {
4044
- type: 'array'
4045
- },
4046
- maxItems: 50,
4047
- description: 'Payment method keywords (e.g., HuaBei, YuEBao)',
4048
- type: 'array'
4307
+ expectedAmount: {
4308
+ type: 'number',
4309
+ description: 'Expected amount'
4049
4310
  },
4050
- categoryAccount: {
4311
+ status: {
4051
4312
  type: 'string',
4052
- maxLength: 200,
4053
- description:
4054
- 'Destination account for expenses/income (e.g., Expenses:Food:Coffee)'
4313
+ description: 'Status (PENDING, COMPLETED, SKIPPED)'
4055
4314
  },
4056
- matchLogic: {
4315
+ matchedTransactionId: {
4057
4316
  type: 'string',
4058
- enum: ['OR', 'AND'],
4059
- default: 'OR'
4317
+ description: 'Matched transaction ID'
4060
4318
  },
4061
- amountMin: {
4062
- type: 'number',
4063
- minimum: 0,
4064
- description: 'Minimum transaction amount (inclusive)'
4319
+ matchedAt: {
4320
+ type: 'string',
4321
+ description: 'Match timestamp (ISO 8601)'
4065
4322
  },
4066
- amountMax: {
4323
+ matchConfidence: {
4067
4324
  type: 'number',
4068
- minimum: 0,
4069
- description: 'Maximum transaction amount (inclusive)'
4325
+ description: 'Match confidence score (0-1)'
4070
4326
  },
4071
- priority: {
4072
- type: 'number',
4073
- default: 50,
4074
- minimum: 0,
4075
- maximum: 1000
4327
+ isOverdue: {
4328
+ type: 'boolean',
4329
+ description: 'Whether this expected transaction is overdue'
4076
4330
  },
4077
- additionalTags: {
4078
- items: {
4079
- type: 'array'
4080
- },
4081
- maxItems: 20,
4082
- type: 'array'
4331
+ rule: {
4332
+ description: 'Rule information',
4333
+ allOf: [
4334
+ {
4335
+ $ref: '#/components/schemas/ExpectedTransactionRuleDto'
4336
+ }
4337
+ ]
4083
4338
  },
4084
- additionalMetadata: {
4085
- type: 'object'
4339
+ createdAt: {
4340
+ format: 'date-time',
4341
+ type: 'string',
4342
+ description: 'Created at timestamp'
4086
4343
  },
4087
- upsertByPayee: {
4088
- type: 'boolean',
4089
- description:
4090
- 'If true, update existing rule with matching payeeKeywords[0] instead of creating new rule'
4344
+ updatedAt: {
4345
+ format: 'date-time',
4346
+ type: 'string',
4347
+ description: 'Updated at timestamp'
4091
4348
  }
4092
4349
  },
4093
- required: ['name', 'matchLogic', 'priority']
4350
+ required: [
4351
+ 'id',
4352
+ 'userId',
4353
+ 'ruleId',
4354
+ 'expectedDate',
4355
+ 'expectedAmount',
4356
+ 'status',
4357
+ 'isOverdue',
4358
+ 'rule',
4359
+ 'createdAt',
4360
+ 'updatedAt'
4361
+ ]
4094
4362
  } as const;
4095
4363
 
4096
- export const $ValidateRuleResponseDto = {
4364
+ export const $ExpectedTransactionListResponseDto = {
4097
4365
  type: 'object',
4098
4366
  properties: {
4099
- valid: {
4100
- type: 'boolean',
4101
- description: 'Whether the rule configuration is valid',
4102
- example: true
4103
- },
4104
- errors: {
4105
- description: 'List of validation errors (empty if valid)',
4106
- example: [],
4367
+ items: {
4368
+ type: 'array',
4107
4369
  items: {
4108
- type: 'array'
4109
- },
4110
- type: 'array'
4370
+ $ref: '#/components/schemas/ExpectedTransactionResponseDto'
4371
+ }
4111
4372
  },
4112
- warnings: {
4113
- description: 'List of validation warnings (non-blocking issues)',
4114
- example: [
4115
- 'No account constraints specified - rule will match any account'
4116
- ],
4117
- items: {
4118
- type: 'array'
4119
- },
4120
- type: 'array'
4373
+ total: {
4374
+ type: 'number',
4375
+ description: 'Total count'
4121
4376
  }
4122
4377
  },
4123
- required: ['valid', 'errors', 'warnings']
4378
+ required: ['items', 'total']
4124
4379
  } as const;
4125
4380
 
4126
- export const $BulkCreateRulesDto = {
4381
+ export const $ConfirmMatchDto = {
4127
4382
  type: 'object',
4128
4383
  properties: {
4129
- rules: {
4130
- items: {
4131
- type: 'array'
4132
- },
4133
- description: 'Array of rules to import',
4134
- type: 'array'
4135
- },
4136
- conflictStrategy: {
4384
+ transactionId: {
4137
4385
  type: 'string',
4138
- enum: ['replace', 'skip'],
4139
- default: 'skip',
4140
- description:
4141
- 'Conflict handling strategy: skip (default) ignores duplicates, replace soft-deletes existing rule'
4386
+ description: 'Transaction ID to match with'
4142
4387
  }
4143
4388
  },
4144
- required: ['rules', 'conflictStrategy']
4389
+ required: ['transactionId']
4145
4390
  } as const;
4146
4391
 
4147
- export const $BulkCreateRulesResponseDto = {
4392
+ export const $EnterNowDto = {
4148
4393
  type: 'object',
4149
4394
  properties: {
4150
- successCount: {
4151
- type: 'number',
4152
- description: 'Number of successfully created rules'
4395
+ expenseAccount: {
4396
+ type: 'string',
4397
+ description:
4398
+ 'Override expense account (uses rule default if not provided)',
4399
+ maxLength: 200
4153
4400
  },
4154
- failureCount: {
4401
+ paymentAccount: {
4402
+ type: 'string',
4403
+ description:
4404
+ 'Override payment account (uses rule default if not provided)',
4405
+ maxLength: 200
4406
+ },
4407
+ amount: {
4155
4408
  type: 'number',
4156
- description: 'Number of failed rules'
4409
+ description: 'Override amount (uses expected amount if not provided)',
4410
+ minimum: 0
4157
4411
  },
4158
- errors: {
4159
- type: 'array',
4160
- description: 'Error details for failed rules',
4161
- items: {
4162
- type: 'object',
4163
- properties: {
4164
- index: {
4165
- type: 'number'
4166
- },
4167
- message: {
4168
- type: 'string'
4169
- }
4170
- }
4171
- }
4412
+ payee: {
4413
+ type: 'string',
4414
+ description: 'Override payee (uses rule default if not provided)',
4415
+ maxLength: 200
4172
4416
  },
4173
- createdRuleIds: {
4174
- description: 'IDs of successfully created rules',
4175
- type: 'array',
4176
- items: {
4177
- type: 'string'
4178
- }
4417
+ narration: {
4418
+ type: 'string',
4419
+ description: 'Optional narration',
4420
+ maxLength: 500
4179
4421
  }
4180
- },
4181
- required: ['successCount', 'failureCount', 'errors', 'createdRuleIds']
4422
+ }
4182
4423
  } as const;
4183
4424
 
4184
- export const $ExportRulesResponseDto = {
4425
+ export const $ForecastItemDto = {
4185
4426
  type: 'object',
4186
4427
  properties: {
4187
- exportedAt: {
4428
+ rule: {
4188
4429
  type: 'string',
4189
- description: 'Export timestamp'
4430
+ description: 'Rule name',
4431
+ example: 'Rent'
4190
4432
  },
4191
- userId: {
4433
+ ruleId: {
4192
4434
  type: 'string',
4193
- description: 'User ID'
4435
+ description: 'Rule ID',
4436
+ example: 'clx123...'
4194
4437
  },
4195
- ruleCount: {
4438
+ amount: {
4196
4439
  type: 'number',
4197
- description: 'Number of exported rules'
4440
+ description: 'Expected amount',
4441
+ example: 3000
4198
4442
  },
4199
- rules: {
4200
- type: 'array',
4201
- description: 'Exported rules'
4443
+ date: {
4444
+ type: 'string',
4445
+ description: 'Expected date (YYYY-MM-DD)',
4446
+ example: '2024-04-01'
4447
+ },
4448
+ icon: {
4449
+ type: 'string',
4450
+ description: 'Rule icon emoji',
4451
+ example: '🏠',
4452
+ nullable: true
4453
+ },
4454
+ currency: {
4455
+ type: 'string',
4456
+ description: 'Currency code',
4457
+ example: 'CNY'
4202
4458
  }
4203
4459
  },
4204
- required: ['exportedAt', 'userId', 'ruleCount', 'rules']
4460
+ required: ['rule', 'ruleId', 'amount', 'date', 'icon', 'currency']
4205
4461
  } as const;
4206
4462
 
4207
- export const $RuleStatisticsResponseDto = {
4463
+ export const $MonthlyForecastDto = {
4208
4464
  type: 'object',
4209
4465
  properties: {
4210
- period: {
4466
+ month: {
4211
4467
  type: 'string',
4212
- description: 'Statistics time period',
4213
- enum: ['7d', '30d', '90d']
4214
- },
4215
- totalRules: {
4216
- type: 'number',
4217
- description: 'Total number of rules'
4468
+ description: 'Month (YYYY-MM)',
4469
+ example: '2024-04'
4218
4470
  },
4219
- rulesWithMatches: {
4471
+ expectedOutflow: {
4220
4472
  type: 'number',
4221
- description: 'Number of rules with at least one match'
4473
+ description: 'Total expected outflow for the month',
4474
+ example: 8500
4222
4475
  },
4223
- totalMatches: {
4476
+ itemCount: {
4224
4477
  type: 'number',
4225
- description: 'Total number of matches across all rules'
4478
+ description: 'Number of expected transactions',
4479
+ example: 3
4226
4480
  },
4227
- averageConfidence: {
4228
- type: 'number',
4229
- description: 'Average confidence score across all matches',
4230
- example: 0.82
4481
+ byCurrency: {
4482
+ type: 'object',
4483
+ description: 'Breakdown by currency',
4484
+ example: {
4485
+ CNY: 8500,
4486
+ USD: 100
4487
+ }
4231
4488
  },
4232
- ruleStats: {
4489
+ items: {
4490
+ description: 'Individual forecast items',
4233
4491
  type: 'array',
4234
- description: 'Per-rule statistics',
4235
4492
  items: {
4236
- type: 'object',
4237
- properties: {
4238
- ruleId: {
4239
- type: 'string'
4240
- },
4241
- ruleName: {
4242
- type: 'string'
4243
- },
4244
- matchCount: {
4245
- type: 'number'
4246
- },
4247
- averageConfidence: {
4248
- type: 'number'
4249
- }
4250
- }
4493
+ $ref: '#/components/schemas/ForecastItemDto'
4494
+ }
4495
+ }
4496
+ },
4497
+ required: ['month', 'expectedOutflow', 'itemCount', 'byCurrency', 'items']
4498
+ } as const;
4499
+
4500
+ export const $ForecastResponseDto = {
4501
+ type: 'object',
4502
+ properties: {
4503
+ forecast: {
4504
+ description: 'Monthly forecast data',
4505
+ type: 'array',
4506
+ items: {
4507
+ $ref: '#/components/schemas/MonthlyForecastDto'
4508
+ }
4509
+ },
4510
+ totalOutflow: {
4511
+ type: 'number',
4512
+ description: 'Total expected outflow across all months',
4513
+ example: 25500
4514
+ },
4515
+ totalByCurrency: {
4516
+ type: 'object',
4517
+ description: 'Total by currency across all months',
4518
+ example: {
4519
+ CNY: 25500,
4520
+ USD: 300
4251
4521
  }
4522
+ },
4523
+ rulesCount: {
4524
+ type: 'number',
4525
+ description: 'Number of active recurring rules included',
4526
+ example: 5
4527
+ },
4528
+ periodStart: {
4529
+ type: 'string',
4530
+ description: 'Forecast period start date',
4531
+ example: '2024-04-01'
4532
+ },
4533
+ periodEnd: {
4534
+ type: 'string',
4535
+ description: 'Forecast period end date',
4536
+ example: '2024-06-30'
4252
4537
  }
4253
4538
  },
4254
4539
  required: [
4255
- 'period',
4256
- 'totalRules',
4257
- 'rulesWithMatches',
4258
- 'totalMatches',
4259
- 'averageConfidence',
4260
- 'ruleStats'
4540
+ 'forecast',
4541
+ 'totalOutflow',
4542
+ 'totalByCurrency',
4543
+ 'rulesCount',
4544
+ 'periodStart',
4545
+ 'periodEnd'
4261
4546
  ]
4262
4547
  } as const;
4263
4548
 
4264
- export const $UpdateTransactionRuleDto = {
4549
+ export const $CreateTransactionRuleDto = {
4265
4550
  type: 'object',
4266
4551
  properties: {
4267
4552
  name: {
@@ -4310,7 +4595,8 @@ export const $UpdateTransactionRuleDto = {
4310
4595
  },
4311
4596
  matchLogic: {
4312
4597
  type: 'string',
4313
- enum: ['OR', 'AND']
4598
+ enum: ['OR', 'AND'],
4599
+ default: 'OR'
4314
4600
  },
4315
4601
  amountMin: {
4316
4602
  type: 'number',
@@ -4324,12 +4610,9 @@ export const $UpdateTransactionRuleDto = {
4324
4610
  },
4325
4611
  priority: {
4326
4612
  type: 'number',
4327
- minimum: 0,
4328
- maximum: 1000
4329
- },
4330
- enabled: {
4331
- type: 'boolean',
4332
- description: 'Enable or disable the rule'
4613
+ default: 50,
4614
+ minimum: 0,
4615
+ maximum: 1000
4333
4616
  },
4334
4617
  additionalTags: {
4335
4618
  items: {
@@ -4340,511 +4623,655 @@ export const $UpdateTransactionRuleDto = {
4340
4623
  },
4341
4624
  additionalMetadata: {
4342
4625
  type: 'object'
4343
- }
4344
- }
4345
- } as const;
4346
-
4347
- export const $TestRuleDto = {
4348
- type: 'object',
4349
- properties: {
4350
- narration: {
4351
- type: 'string',
4352
- minLength: 1,
4353
- maxLength: 500
4354
- },
4355
- payee: {
4356
- type: 'string',
4357
- maxLength: 200
4358
- },
4359
- categoryAccount: {
4360
- type: 'string',
4361
- maxLength: 200
4362
- },
4363
- amount: {
4364
- type: 'number'
4365
4626
  },
4366
- currency: {
4367
- type: 'string',
4368
- maxLength: 10
4627
+ upsertByPayee: {
4628
+ type: 'boolean',
4629
+ description:
4630
+ 'If true, update existing rule with matching payeeKeywords[0] instead of creating new rule'
4369
4631
  }
4370
4632
  },
4371
- required: ['narration']
4633
+ required: ['name', 'matchLogic', 'priority']
4372
4634
  } as const;
4373
4635
 
4374
- export const $TestRuleResponseDto = {
4636
+ export const $AmountRangeDto = {
4375
4637
  type: 'object',
4376
4638
  properties: {
4377
- ruleId: {
4378
- type: 'string',
4379
- description: 'Rule ID that was tested'
4380
- },
4381
- matches: {
4382
- type: 'boolean',
4383
- description: 'Whether the rule matched the test data'
4384
- },
4385
- confidence: {
4639
+ min: {
4386
4640
  type: 'number',
4387
- description: 'Match confidence score (0-1)',
4388
- example: 0.85
4641
+ description: 'Minimum amount'
4389
4642
  },
4390
- matchDetails: {
4391
- type: 'object',
4392
- description: 'Details of which fields matched',
4393
- example: {
4394
- narration: true,
4395
- payee: false,
4396
- categoryAccount: false
4397
- }
4398
- }
4399
- },
4400
- required: ['ruleId', 'matches', 'confidence', 'matchDetails']
4401
- } as const;
4402
-
4403
- export const $DeleteOwnUserDto = {
4404
- type: 'object',
4405
- properties: {
4406
- accessToken: {
4407
- type: 'string',
4408
- description: 'Access token for user verification',
4409
- example: 'abc123xyz'
4410
- }
4411
- },
4412
- required: ['accessToken']
4413
- } as const;
4414
-
4415
- export const $SignupDto = {
4416
- type: 'object',
4417
- properties: {
4418
- turnstileToken: {
4419
- type: 'string',
4420
- description:
4421
- 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
4422
- example: '0.abc123def456...'
4643
+ max: {
4644
+ type: 'number',
4645
+ description: 'Maximum amount'
4423
4646
  }
4424
4647
  }
4425
4648
  } as const;
4426
4649
 
4427
- export const $SignupResponseDto = {
4650
+ export const $TransactionRuleResponseDto = {
4428
4651
  type: 'object',
4429
4652
  properties: {
4430
- authToken: {
4653
+ id: {
4431
4654
  type: 'string',
4432
- description: 'JWT auth token',
4433
- example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
4655
+ description: 'Rule ID'
4434
4656
  },
4435
- accessToken: {
4657
+ name: {
4436
4658
  type: 'string',
4437
- description: 'Auto-generated access token'
4659
+ description: 'Rule name'
4438
4660
  },
4439
- role: {
4661
+ description: {
4440
4662
  type: 'string',
4441
- description: 'Assigned user role',
4442
- enum: ['USER', 'ADMIN', 'DEMO', 'INACTIVE', 'PAID', 'OPS']
4443
- }
4444
- },
4445
- required: ['authToken', 'accessToken', 'role']
4446
- } as const;
4447
-
4448
- export const $UpdateUserSettingDto = {
4449
- type: 'object',
4450
- properties: {
4451
- secId: {
4452
- type: 'number',
4453
- description: 'Security ID'
4663
+ description: 'Rule description'
4454
4664
  },
4455
- annualInterestRate: {
4456
- type: 'number',
4457
- description: 'Annual interest rate',
4458
- example: 0.05
4665
+ narrationKeywords: {
4666
+ description: 'Keywords to match in transaction narration',
4667
+ type: 'array',
4668
+ items: {
4669
+ type: 'string'
4670
+ }
4459
4671
  },
4460
- currency: {
4461
- type: 'string',
4462
- description: 'Currency code',
4463
- example: 'USD'
4672
+ payeeKeywords: {
4673
+ description: 'Keywords to match in payee name',
4674
+ type: 'array',
4675
+ items: {
4676
+ type: 'string'
4677
+ }
4464
4678
  },
4465
- baseCurrency: {
4466
- type: 'string',
4467
- description: 'Base currency code',
4468
- example: 'USD'
4679
+ categoryKeywords: {
4680
+ description: 'Keywords to match in category',
4681
+ type: 'array',
4682
+ items: {
4683
+ type: 'string'
4684
+ }
4469
4685
  },
4470
- benchmark: {
4686
+ methodKeywords: {
4687
+ description: 'Keywords to match in payment method',
4688
+ type: 'array',
4689
+ items: {
4690
+ type: 'string'
4691
+ }
4692
+ },
4693
+ categoryAccount: {
4471
4694
  type: 'string',
4472
- description: 'Benchmark symbol',
4473
- example: 'SPY'
4695
+ description: 'Destination account for categorization'
4474
4696
  },
4475
- colorScheme: {
4697
+ matchLogic: {
4476
4698
  type: 'string',
4477
- description: 'Color scheme',
4478
- enum: ['DARK', 'LIGHT']
4699
+ description: 'Keyword matching logic',
4700
+ enum: ['OR', 'AND'],
4701
+ example: 'OR'
4479
4702
  },
4480
- dateRange: {
4703
+ amountRange: {
4704
+ description: 'Amount range for matching',
4705
+ allOf: [
4706
+ {
4707
+ $ref: '#/components/schemas/AmountRangeDto'
4708
+ }
4709
+ ]
4710
+ },
4711
+ priority: {
4712
+ type: 'number',
4713
+ description: 'Rule priority (0-1000, higher = first match)',
4714
+ example: 50
4715
+ },
4716
+ enabled: {
4717
+ type: 'boolean',
4718
+ description: 'Whether the rule is enabled'
4719
+ },
4720
+ learningSource: {
4481
4721
  type: 'string',
4482
- description: 'Date range filter',
4483
- example: '1y'
4722
+ description: 'Learning source: NLP, REVIEW_CENTER, or null for manual',
4723
+ enum: ['NLP', 'REVIEW_CENTER'],
4724
+ nullable: true,
4725
+ example: 'REVIEW_CENTER'
4484
4726
  },
4485
- emergencyFund: {
4727
+ autoApplyEnabled: {
4728
+ type: 'boolean',
4729
+ description: 'Whether auto-apply is enabled for this rule'
4730
+ },
4731
+ confirmationCount: {
4486
4732
  type: 'number',
4487
- description: 'Emergency fund amount',
4488
- example: 10000
4733
+ description: 'Number of confirmations for NLP-learned rules',
4734
+ example: 3
4489
4735
  },
4490
- 'filters.accounts': {
4491
- description: 'Account filter IDs',
4736
+ additionalTags: {
4737
+ description: 'Additional tags',
4492
4738
  type: 'array',
4493
4739
  items: {
4494
4740
  type: 'string'
4495
4741
  }
4496
4742
  },
4497
- 'filters.assetClasses': {
4498
- description: 'Asset class filters',
4743
+ additionalMetadata: {
4744
+ type: 'object',
4745
+ description: 'Additional metadata',
4746
+ additionalProperties: {
4747
+ type: 'string'
4748
+ }
4749
+ },
4750
+ createdAt: {
4751
+ format: 'date-time',
4752
+ type: 'string',
4753
+ description: 'Created timestamp'
4754
+ },
4755
+ updatedAt: {
4756
+ format: 'date-time',
4757
+ type: 'string',
4758
+ description: 'Updated timestamp'
4759
+ }
4760
+ },
4761
+ required: [
4762
+ 'id',
4763
+ 'name',
4764
+ 'narrationKeywords',
4765
+ 'payeeKeywords',
4766
+ 'categoryKeywords',
4767
+ 'methodKeywords',
4768
+ 'matchLogic',
4769
+ 'priority',
4770
+ 'enabled',
4771
+ 'autoApplyEnabled',
4772
+ 'confirmationCount',
4773
+ 'additionalTags',
4774
+ 'createdAt',
4775
+ 'updatedAt'
4776
+ ]
4777
+ } as const;
4778
+
4779
+ export const $TransactionRuleListResponseDto = {
4780
+ type: 'object',
4781
+ properties: {
4782
+ data: {
4499
4783
  type: 'array',
4500
4784
  items: {
4501
- type: 'string'
4785
+ $ref: '#/components/schemas/TransactionRuleResponseDto'
4502
4786
  }
4503
4787
  },
4504
- 'filters.dataSource': {
4788
+ total: {
4789
+ type: 'number',
4790
+ description: 'Total count of rules'
4791
+ },
4792
+ limit: {
4793
+ type: 'number',
4794
+ description: 'Results per page'
4795
+ },
4796
+ offset: {
4797
+ type: 'number',
4798
+ description: 'Pagination offset'
4799
+ }
4800
+ },
4801
+ required: ['data', 'total', 'limit', 'offset']
4802
+ } as const;
4803
+
4804
+ export const $ValidateRuleDto = {
4805
+ type: 'object',
4806
+ properties: {
4807
+ name: {
4505
4808
  type: 'string',
4506
- description: 'Data source filter'
4809
+ minLength: 1,
4810
+ maxLength: 100
4507
4811
  },
4508
- 'filters.symbol': {
4812
+ description: {
4509
4813
  type: 'string',
4510
- description: 'Symbol filter'
4814
+ maxLength: 500
4511
4815
  },
4512
- 'filters.tags': {
4513
- description: 'Tag filters',
4514
- type: 'array',
4816
+ narrationKeywords: {
4515
4817
  items: {
4516
- type: 'string'
4517
- }
4818
+ type: 'array'
4819
+ },
4820
+ maxItems: 50,
4821
+ type: 'array'
4518
4822
  },
4519
- isExperimentalFeatures: {
4520
- type: 'boolean',
4521
- description: 'Enable experimental features'
4823
+ payeeKeywords: {
4824
+ items: {
4825
+ type: 'array'
4826
+ },
4827
+ maxItems: 50,
4828
+ type: 'array'
4522
4829
  },
4523
- isRestrictedView: {
4524
- type: 'boolean',
4525
- description: 'Enable restricted view mode'
4830
+ categoryKeywords: {
4831
+ items: {
4832
+ type: 'array'
4833
+ },
4834
+ maxItems: 50,
4835
+ type: 'array'
4526
4836
  },
4527
- language: {
4837
+ methodKeywords: {
4838
+ items: {
4839
+ type: 'array'
4840
+ },
4841
+ maxItems: 50,
4842
+ description: 'Payment method keywords (e.g., HuaBei, YuEBao)',
4843
+ type: 'array'
4844
+ },
4845
+ categoryAccount: {
4528
4846
  type: 'string',
4529
- description: 'Language code',
4530
- example: 'en'
4847
+ maxLength: 200,
4848
+ description:
4849
+ 'Destination account for expenses/income (e.g., Expenses:Food:Coffee)'
4531
4850
  },
4532
- locale: {
4851
+ matchLogic: {
4533
4852
  type: 'string',
4534
- description: 'Locale code',
4535
- example: 'en-US'
4853
+ enum: ['OR', 'AND'],
4854
+ default: 'OR'
4536
4855
  },
4537
- projectedTotalAmount: {
4856
+ amountMin: {
4538
4857
  type: 'number',
4539
- description: 'Projected total amount',
4540
- example: 1000000
4858
+ minimum: 0,
4859
+ description: 'Minimum transaction amount (inclusive)'
4541
4860
  },
4542
- retirementDate: {
4543
- type: 'string',
4544
- description: 'Retirement date in ISO 8601 format',
4545
- example: '2050-01-01'
4861
+ amountMax: {
4862
+ type: 'number',
4863
+ minimum: 0,
4864
+ description: 'Maximum transaction amount (inclusive)'
4546
4865
  },
4547
- savingsRate: {
4866
+ priority: {
4548
4867
  type: 'number',
4549
- description: 'Savings rate percentage',
4550
- example: 0.2
4868
+ default: 50,
4869
+ minimum: 0,
4870
+ maximum: 1000
4551
4871
  },
4552
- viewMode: {
4553
- type: 'string',
4554
- description: 'View mode',
4555
- enum: ['DEFAULT', 'ZEN']
4872
+ additionalTags: {
4873
+ items: {
4874
+ type: 'array'
4875
+ },
4876
+ maxItems: 20,
4877
+ type: 'array'
4878
+ },
4879
+ additionalMetadata: {
4880
+ type: 'object'
4881
+ },
4882
+ upsertByPayee: {
4883
+ type: 'boolean',
4884
+ description:
4885
+ 'If true, update existing rule with matching payeeKeywords[0] instead of creating new rule'
4556
4886
  }
4557
- }
4887
+ },
4888
+ required: ['name', 'matchLogic', 'priority']
4558
4889
  } as const;
4559
4890
 
4560
- export const $UpdatePropertyDto = {
4891
+ export const $ValidateRuleResponseDto = {
4561
4892
  type: 'object',
4562
4893
  properties: {
4563
- value: {
4564
- type: 'string',
4565
- description: 'Property value'
4894
+ valid: {
4895
+ type: 'boolean',
4896
+ description: 'Whether the rule configuration is valid',
4897
+ example: true
4898
+ },
4899
+ errors: {
4900
+ description: 'List of validation errors (empty if valid)',
4901
+ example: [],
4902
+ items: {
4903
+ type: 'array'
4904
+ },
4905
+ type: 'array'
4906
+ },
4907
+ warnings: {
4908
+ description: 'List of validation warnings (non-blocking issues)',
4909
+ example: [
4910
+ 'No account constraints specified - rule will match any account'
4911
+ ],
4912
+ items: {
4913
+ type: 'array'
4914
+ },
4915
+ type: 'array'
4566
4916
  }
4567
4917
  },
4568
- required: ['value']
4918
+ required: ['valid', 'errors', 'warnings']
4569
4919
  } as const;
4570
4920
 
4571
- export const $CurrencyBalanceDto = {
4921
+ export const $BulkCreateRulesDto = {
4572
4922
  type: 'object',
4573
4923
  properties: {
4574
- currency: {
4575
- type: 'string',
4576
- description: 'ISO 4217 currency code',
4577
- example: 'CNY'
4924
+ rules: {
4925
+ items: {
4926
+ type: 'array'
4927
+ },
4928
+ description: 'Array of rules to import',
4929
+ type: 'array'
4578
4930
  },
4579
- balance: {
4931
+ conflictStrategy: {
4580
4932
  type: 'string',
4581
- description: 'Balance amount',
4582
- example: '500000.00'
4933
+ enum: ['replace', 'skip'],
4934
+ default: 'skip',
4935
+ description:
4936
+ 'Conflict handling strategy: skip (default) ignores duplicates, replace soft-deletes existing rule'
4583
4937
  }
4584
4938
  },
4585
- required: ['currency', 'balance']
4939
+ required: ['rules', 'conflictStrategy']
4586
4940
  } as const;
4587
4941
 
4588
- export const $TimeSeriesPointDto = {
4942
+ export const $BulkCreateRulesResponseDto = {
4589
4943
  type: 'object',
4590
4944
  properties: {
4591
- date: {
4592
- type: 'string',
4593
- description: 'Date in YYYY-MM-DD format',
4594
- example: '2024-06-15'
4595
- },
4596
- value: {
4597
- type: 'string',
4598
- description: 'Value at this date (in base currency)',
4599
- example: '500000.00'
4600
- },
4601
- change: {
4602
- type: 'object',
4603
- description: 'Change from previous point',
4604
- example: '5000.00'
4945
+ successCount: {
4946
+ type: 'number',
4947
+ description: 'Number of successfully created rules'
4605
4948
  },
4606
- assets: {
4607
- type: 'string',
4608
- description: 'Total assets at this date (in base currency)',
4609
- example: '494338.00'
4949
+ failureCount: {
4950
+ type: 'number',
4951
+ description: 'Number of failed rules'
4610
4952
  },
4611
- liabilities: {
4612
- type: 'string',
4613
- description: 'Total liabilities at this date (in base currency)',
4614
- example: '310098.00'
4953
+ errors: {
4954
+ type: 'array',
4955
+ description: 'Error details for failed rules',
4956
+ items: {
4957
+ type: 'object',
4958
+ properties: {
4959
+ index: {
4960
+ type: 'number'
4961
+ },
4962
+ message: {
4963
+ type: 'string'
4964
+ }
4965
+ }
4966
+ }
4615
4967
  },
4616
- byCurrency: {
4617
- description: 'Multi-currency breakdown for this point',
4968
+ createdRuleIds: {
4969
+ description: 'IDs of successfully created rules',
4618
4970
  type: 'array',
4619
4971
  items: {
4620
- $ref: '#/components/schemas/CurrencyBalanceDto'
4972
+ type: 'string'
4621
4973
  }
4622
4974
  }
4623
4975
  },
4624
- required: ['date', 'value']
4976
+ required: ['successCount', 'failureCount', 'errors', 'createdRuleIds']
4625
4977
  } as const;
4626
4978
 
4627
- export const $TrendSummaryDto = {
4979
+ export const $ExportRulesResponseDto = {
4628
4980
  type: 'object',
4629
4981
  properties: {
4630
- startValue: {
4982
+ exportedAt: {
4631
4983
  type: 'string',
4632
- description: 'Value at start of period',
4633
- example: '450000.00'
4984
+ description: 'Export timestamp'
4634
4985
  },
4635
- endValue: {
4986
+ userId: {
4636
4987
  type: 'string',
4637
- description: 'Value at end of period',
4638
- example: '500000.00'
4988
+ description: 'User ID'
4639
4989
  },
4640
- totalChange: {
4641
- type: 'string',
4642
- description: 'Total change over period',
4643
- example: '50000.00'
4990
+ ruleCount: {
4991
+ type: 'number',
4992
+ description: 'Number of exported rules'
4644
4993
  },
4645
- totalChangePercentage: {
4646
- type: 'string',
4647
- description: 'Total change percentage',
4648
- example: '+11.11%'
4994
+ rules: {
4995
+ type: 'array',
4996
+ description: 'Exported rules'
4649
4997
  }
4650
4998
  },
4651
- required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
4999
+ required: ['exportedAt', 'userId', 'ruleCount', 'rules']
4652
5000
  } as const;
4653
5001
 
4654
- export const $MultiCurrencyPointDto = {
5002
+ export const $RuleStatisticsResponseDto = {
4655
5003
  type: 'object',
4656
5004
  properties: {
4657
- date: {
5005
+ period: {
4658
5006
  type: 'string',
4659
- description: 'Date in YYYY-MM-DD format',
4660
- example: '2024-06-15'
5007
+ description: 'Statistics time period',
5008
+ enum: ['7d', '30d', '90d']
5009
+ },
5010
+ totalRules: {
5011
+ type: 'number',
5012
+ description: 'Total number of rules'
5013
+ },
5014
+ rulesWithMatches: {
5015
+ type: 'number',
5016
+ description: 'Number of rules with at least one match'
5017
+ },
5018
+ totalMatches: {
5019
+ type: 'number',
5020
+ description: 'Total number of matches across all rules'
4661
5021
  },
4662
- byCurrency: {
4663
- description: 'Balances by currency',
5022
+ averageConfidence: {
5023
+ type: 'number',
5024
+ description: 'Average confidence score across all matches',
5025
+ example: 0.82
5026
+ },
5027
+ ruleStats: {
4664
5028
  type: 'array',
5029
+ description: 'Per-rule statistics',
4665
5030
  items: {
4666
- $ref: '#/components/schemas/CurrencyBalanceDto'
5031
+ type: 'object',
5032
+ properties: {
5033
+ ruleId: {
5034
+ type: 'string'
5035
+ },
5036
+ ruleName: {
5037
+ type: 'string'
5038
+ },
5039
+ matchCount: {
5040
+ type: 'number'
5041
+ },
5042
+ averageConfidence: {
5043
+ type: 'number'
5044
+ }
5045
+ }
4667
5046
  }
4668
5047
  }
4669
5048
  },
4670
- required: ['date', 'byCurrency']
5049
+ required: [
5050
+ 'period',
5051
+ 'totalRules',
5052
+ 'rulesWithMatches',
5053
+ 'totalMatches',
5054
+ 'averageConfidence',
5055
+ 'ruleStats'
5056
+ ]
4671
5057
  } as const;
4672
5058
 
4673
- export const $PortfolioTrendsResponseDto = {
5059
+ export const $UpdateTransactionRuleDto = {
4674
5060
  type: 'object',
4675
5061
  properties: {
4676
- series: {
4677
- description: 'Time series data points',
4678
- type: 'array',
5062
+ name: {
5063
+ type: 'string',
5064
+ minLength: 1,
5065
+ maxLength: 100
5066
+ },
5067
+ description: {
5068
+ type: 'string',
5069
+ maxLength: 500
5070
+ },
5071
+ narrationKeywords: {
4679
5072
  items: {
4680
- $ref: '#/components/schemas/TimeSeriesPointDto'
4681
- }
5073
+ type: 'array'
5074
+ },
5075
+ maxItems: 50,
5076
+ type: 'array'
4682
5077
  },
4683
- summary: {
4684
- description: 'Period summary',
4685
- allOf: [
4686
- {
4687
- $ref: '#/components/schemas/TrendSummaryDto'
4688
- }
4689
- ]
5078
+ payeeKeywords: {
5079
+ items: {
5080
+ type: 'array'
5081
+ },
5082
+ maxItems: 50,
5083
+ type: 'array'
4690
5084
  },
4691
- period: {
4692
- type: 'string',
4693
- description: 'Period requested',
4694
- example: '6m'
5085
+ categoryKeywords: {
5086
+ items: {
5087
+ type: 'array'
5088
+ },
5089
+ maxItems: 50,
5090
+ type: 'array'
4695
5091
  },
4696
- granularity: {
5092
+ methodKeywords: {
5093
+ items: {
5094
+ type: 'array'
5095
+ },
5096
+ maxItems: 50,
5097
+ description: 'Payment method keywords (e.g., HuaBei, YuEBao)',
5098
+ type: 'array'
5099
+ },
5100
+ categoryAccount: {
4697
5101
  type: 'string',
4698
- description: 'Data granularity',
4699
- example: 'month'
5102
+ maxLength: 200,
5103
+ description:
5104
+ 'Destination account for expenses/income (e.g., Expenses:Food:Coffee)'
4700
5105
  },
4701
- currency: {
5106
+ matchLogic: {
4702
5107
  type: 'string',
4703
- description: 'Base currency for converted values',
4704
- example: 'CNY'
5108
+ enum: ['OR', 'AND'],
5109
+ default: 'OR'
4705
5110
  },
4706
- byCurrency: {
4707
- description:
4708
- 'Multi-currency time series (each point has currency breakdown)',
4709
- type: 'array',
4710
- items: {
4711
- $ref: '#/components/schemas/MultiCurrencyPointDto'
4712
- }
5111
+ amountMin: {
5112
+ type: 'number',
5113
+ minimum: 0,
5114
+ description: 'Minimum transaction amount (inclusive)'
4713
5115
  },
4714
- warnings: {
4715
- description: 'Exchange rate warnings',
4716
- type: 'array',
5116
+ amountMax: {
5117
+ type: 'number',
5118
+ minimum: 0,
5119
+ description: 'Maximum transaction amount (inclusive)'
5120
+ },
5121
+ priority: {
5122
+ type: 'number',
5123
+ default: 50,
5124
+ minimum: 0,
5125
+ maximum: 1000
5126
+ },
5127
+ additionalTags: {
4717
5128
  items: {
4718
- $ref: '#/components/schemas/ExchangeRateWarningDto'
4719
- }
5129
+ type: 'array'
5130
+ },
5131
+ maxItems: 20,
5132
+ type: 'array'
5133
+ },
5134
+ additionalMetadata: {
5135
+ type: 'object'
5136
+ },
5137
+ enabled: {
5138
+ type: 'boolean',
5139
+ description: 'Enable or disable the rule'
4720
5140
  }
4721
- },
4722
- required: ['series', 'summary', 'period', 'granularity', 'currency']
5141
+ }
4723
5142
  } as const;
4724
5143
 
4725
- export const $CashFlowPointDto = {
5144
+ export const $TestRuleDto = {
4726
5145
  type: 'object',
4727
5146
  properties: {
4728
- month: {
5147
+ narration: {
4729
5148
  type: 'string',
4730
- description: 'Month key (YYYY-MM)',
4731
- example: '2024-03'
5149
+ minLength: 1,
5150
+ maxLength: 500
4732
5151
  },
4733
- income: {
5152
+ payee: {
4734
5153
  type: 'string',
4735
- description: 'Income in base currency (absolute, converted)',
4736
- example: '10000.00'
5154
+ maxLength: 200
4737
5155
  },
4738
- expense: {
5156
+ categoryAccount: {
4739
5157
  type: 'string',
4740
- description: 'Expense in base currency (absolute, converted)',
4741
- example: '5000.00'
5158
+ maxLength: 200
4742
5159
  },
4743
- netSavings: {
5160
+ amount: {
5161
+ type: 'number'
5162
+ },
5163
+ currency: {
4744
5164
  type: 'string',
4745
- description: 'netSavings = income − expense (savings positive)',
4746
- example: '5000.00'
5165
+ maxLength: 10
4747
5166
  }
4748
5167
  },
4749
- required: ['month', 'income', 'expense', 'netSavings']
5168
+ required: ['narration']
4750
5169
  } as const;
4751
5170
 
4752
- export const $CashFlowTrendSummaryDto = {
5171
+ export const $TestRuleResponseDto = {
4753
5172
  type: 'object',
4754
5173
  properties: {
4755
- totalIncome: {
5174
+ ruleId: {
4756
5175
  type: 'string',
4757
- description: 'Total income across the period',
4758
- example: '60000.00'
5176
+ description: 'Rule ID that was tested'
4759
5177
  },
4760
- totalExpense: {
4761
- type: 'string',
4762
- description: 'Total expense across the period',
4763
- example: '30000.00'
5178
+ matches: {
5179
+ type: 'boolean',
5180
+ description: 'Whether the rule matched the test data'
4764
5181
  },
4765
- totalNetSavings: {
4766
- type: 'string',
4767
- description: 'income − expense across the period',
4768
- example: '30000.00'
5182
+ confidence: {
5183
+ type: 'number',
5184
+ description: 'Match confidence score (0-1)',
5185
+ example: 0.85
4769
5186
  },
4770
- averageMonthlyNetSavings: {
4771
- type: 'string',
4772
- description:
4773
- 'totalNetSavings divided by the window length (N months, incl. zero-filled)',
4774
- example: '5000.00'
5187
+ matchDetails: {
5188
+ type: 'object',
5189
+ description: 'Details of which fields matched',
5190
+ example: {
5191
+ narration: true,
5192
+ payee: false,
5193
+ categoryAccount: false
5194
+ }
4775
5195
  }
4776
5196
  },
4777
- required: [
4778
- 'totalIncome',
4779
- 'totalExpense',
4780
- 'totalNetSavings',
4781
- 'averageMonthlyNetSavings'
4782
- ]
5197
+ required: ['ruleId', 'matches', 'confidence', 'matchDetails']
4783
5198
  } as const;
4784
5199
 
4785
- export const $CashFlowTrendsResponseDto = {
5200
+ export const $CategoryCatalogEntryDto = {
4786
5201
  type: 'object',
4787
5202
  properties: {
4788
- series: {
4789
- description:
4790
- 'Monthly cash-flow series (fixed N-month window, zero-filled)',
4791
- type: 'array',
4792
- items: {
4793
- $ref: '#/components/schemas/CashFlowPointDto'
4794
- }
4795
- },
4796
- summary: {
4797
- description: 'Period totals',
4798
- allOf: [
4799
- {
4800
- $ref: '#/components/schemas/CashFlowTrendSummaryDto'
4801
- }
4802
- ]
4803
- },
4804
- period: {
5203
+ slug: {
4805
5204
  type: 'string',
4806
- description: 'Period requested',
4807
- example: '6m'
5205
+ description: 'Category slug (single source-of-truth)',
5206
+ example: 'food'
4808
5207
  },
4809
- granularity: {
5208
+ scenario: {
4810
5209
  type: 'string',
4811
- description: 'Data granularity (v1 returns month buckets)',
4812
- example: 'month'
5210
+ description: 'Display scenario group (maps to frontend picker _scenario)',
5211
+ enum: [
5212
+ 'expense',
5213
+ 'income',
5214
+ 'investment',
5215
+ 'banking',
5216
+ 'transfer',
5217
+ 'payment'
5218
+ ],
5219
+ example: 'expense'
4813
5220
  },
4814
- currency: {
5221
+ icon: {
4815
5222
  type: 'string',
4816
- description: 'Base currency for converted values',
4817
- example: 'CNY'
5223
+ description: 'Lucide icon name',
5224
+ example: 'utensils'
4818
5225
  },
4819
- warnings: {
4820
- description: 'Exchange rate warnings (e.g. missing rate for a currency)',
5226
+ regions: {
5227
+ description: "Applicable regions ('*' = all, 'cn' = CN-only)",
5228
+ example: ['*'],
4821
5229
  type: 'array',
4822
5230
  items: {
4823
- $ref: '#/components/schemas/ExchangeRateWarningDto'
5231
+ type: 'string'
5232
+ }
5233
+ },
5234
+ categoryAccounts: {
5235
+ description:
5236
+ "Beancount account paths (categoryAccount) of the region-enabled system rules whose categoryKeywords include this slug (#816). System rules only (public endpoint — user rules excluded); one-to-many by design (e.g. 'utilities' → Electricity/Water/Internet/Gas), sorted, [] when no rule maps the slug.",
5237
+ example: [
5238
+ 'Expenses:Utilities:Electricity',
5239
+ 'Expenses:Utilities:Gas',
5240
+ 'Expenses:Utilities:Internet',
5241
+ 'Expenses:Utilities:Water'
5242
+ ],
5243
+ type: 'array',
5244
+ items: {
5245
+ type: 'string'
4824
5246
  }
4825
5247
  }
4826
5248
  },
4827
- required: ['series', 'summary', 'period', 'granularity', 'currency']
4828
- } as const;
4829
-
4830
- export const $GenerateSnapshotBody = {
4831
- type: 'object',
4832
- properties: {}
4833
- } as const;
4834
-
4835
- export const $GenerateSnapshotResponse = {
4836
- type: 'object',
4837
- properties: {}
4838
- } as const;
4839
-
4840
- export const $BackfillSnapshotsBody = {
4841
- type: 'object',
4842
- properties: {}
5249
+ required: ['slug', 'scenario', 'icon', 'regions', 'categoryAccounts']
4843
5250
  } as const;
4844
5251
 
4845
- export const $BackfillSnapshotsResponse = {
5252
+ export const $CategoryCatalogListResponseDto = {
4846
5253
  type: 'object',
4847
- properties: {}
5254
+ properties: {
5255
+ items: {
5256
+ description: 'Category entries (region-scoped, query-filtered)',
5257
+ type: 'array',
5258
+ items: {
5259
+ $ref: '#/components/schemas/CategoryCatalogEntryDto'
5260
+ }
5261
+ },
5262
+ total: {
5263
+ type: 'number',
5264
+ description:
5265
+ 'Total category entries for the region (before query filtering)',
5266
+ example: 30
5267
+ },
5268
+ region: {
5269
+ type: 'string',
5270
+ description: 'Region code',
5271
+ example: 'cn'
5272
+ }
5273
+ },
5274
+ required: ['items', 'total', 'region']
4848
5275
  } as const;
4849
5276
 
4850
5277
  export const $CreateBeanEventDto = {
@@ -5010,6 +5437,14 @@ export const $OnboardingAccountDto = {
5010
5437
  description:
5011
5438
  'Platform ID to bind the account to (references Platform.id); omit for unbound',
5012
5439
  example: 'c98e5d4a-2f71-4a5a-bb3c-92c9f231d5e2'
5440
+ },
5441
+ displayName: {
5442
+ type: 'string',
5443
+ description:
5444
+ 'User-set display name override (omit/null = keep the derived name)',
5445
+ nullable: true,
5446
+ maxLength: 50,
5447
+ example: 'Salary card'
5013
5448
  }
5014
5449
  },
5015
5450
  required: ['path', 'currency']
@@ -5589,7 +6024,8 @@ export const $UpdateMapperDefaultsDto = {
5589
6024
  type: 'string',
5590
6025
  description: 'Source account for transactions (Beancount format)',
5591
6026
  example: 'Assets:CN:Alipay:Balance',
5592
- pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
6027
+ pattern:
6028
+ '^(Assets|Liabilities|Income|Expenses|Equity)(:[A-Za-z0-9][A-Za-z0-9-]*)+$'
5593
6029
  },
5594
6030
  currency: {
5595
6031
  type: 'string',
@@ -5603,13 +6039,15 @@ export const $UpdateMapperDefaultsDto = {
5603
6039
  type: 'string',
5604
6040
  description: 'Default expense account (optional)',
5605
6041
  example: 'Expenses:Unknown',
5606
- pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
6042
+ pattern:
6043
+ '^(Assets|Liabilities|Income|Expenses|Equity)(:[A-Za-z0-9][A-Za-z0-9-]*)+$'
5607
6044
  },
5608
6045
  incomeAccount: {
5609
6046
  type: 'string',
5610
6047
  description: 'Default income account (optional)',
5611
6048
  example: 'Income:Unknown',
5612
- pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
6049
+ pattern:
6050
+ '^(Assets|Liabilities|Income|Expenses|Equity)(:[A-Za-z0-9][A-Za-z0-9-]*)+$'
5613
6051
  },
5614
6052
  methodAccountMapping: {
5615
6053
  type: 'object',
@@ -5666,12 +6104,14 @@ export const $ProviderSyncConfigDto = {
5666
6104
  },
5667
6105
  defaultExpenseAccount: {
5668
6106
  type: 'string',
5669
- description: 'Default expense account for the second posting',
6107
+ description:
6108
+ 'Default expense account for the second posting. Omit when no real default exists; the pipeline routes to Review via the Uncategorized sentinel (#618).',
5670
6109
  example: 'Expenses:Unknown'
5671
6110
  },
5672
6111
  defaultIncomeAccount: {
5673
6112
  type: 'string',
5674
- description: 'Default income account for the second posting',
6113
+ description:
6114
+ 'Default income account for the second posting. Omit when no real default exists; the pipeline routes to Review via the Uncategorized sentinel (#618).',
5675
6115
  example: 'Income:Unknown'
5676
6116
  },
5677
6117
  filterPending: {
@@ -5686,12 +6126,7 @@ export const $ProviderSyncConfigDto = {
5686
6126
  example: 'acc_gocardless_001'
5687
6127
  }
5688
6128
  },
5689
- required: [
5690
- 'sourceAccount',
5691
- 'defaultCurrency',
5692
- 'defaultExpenseAccount',
5693
- 'defaultIncomeAccount'
5694
- ]
6129
+ required: ['sourceAccount', 'defaultCurrency']
5695
6130
  } as const;
5696
6131
 
5697
6132
  export const $ProviderSyncDto = {
@@ -5901,15 +6336,106 @@ export const $UncoveredFormatMissDto = {
5901
6336
  properties: {}
5902
6337
  } as const;
5903
6338
 
6339
+ export const $ClientParsedDataDto = {
6340
+ type: 'object',
6341
+ properties: {
6342
+ amount: {
6343
+ type: 'number',
6344
+ description: 'Transaction amount',
6345
+ example: 35
6346
+ },
6347
+ currency: {
6348
+ type: 'string',
6349
+ description: 'Currency code',
6350
+ example: 'CNY'
6351
+ },
6352
+ date: {
6353
+ type: 'string',
6354
+ description: 'Transaction date (ISO 8601)',
6355
+ example: '2026-08-15'
6356
+ },
6357
+ payee: {
6358
+ type: 'string',
6359
+ description: 'Payee/merchant name',
6360
+ example: 'Starbucks'
6361
+ },
6362
+ narration: {
6363
+ type: 'string',
6364
+ description: 'Transaction narration'
6365
+ },
6366
+ category: {
6367
+ type: 'string',
6368
+ description:
6369
+ 'Category in canonical form (catalog slug or Stage-2 rule keyword token, ADR-0116) — echo back verbatim from parsedData.category. Foreign forms (locale display names, account paths) are rejected with nlp.category.invalid.',
6370
+ example: 'food'
6371
+ },
6372
+ incomeType: {
6373
+ type: 'string',
6374
+ description: 'Income type',
6375
+ example: 'Salary'
6376
+ },
6377
+ incomeSource: {
6378
+ type: 'string',
6379
+ description: 'Income source',
6380
+ example: 'Anthropic Inc.'
6381
+ },
6382
+ symbol: {
6383
+ type: 'string',
6384
+ description: 'Security symbol code (e.g., 600519, AAPL)',
6385
+ example: 'AAPL'
6386
+ },
6387
+ quantity: {
6388
+ type: 'number',
6389
+ description: 'Quantity of shares/units',
6390
+ example: 100
6391
+ },
6392
+ price: {
6393
+ type: 'number',
6394
+ description: 'Unit price per share/unit',
6395
+ example: 1900
6396
+ },
6397
+ investmentAction: {
6398
+ type: 'string',
6399
+ description: 'Investment action',
6400
+ enum: ['buy', 'sell'],
6401
+ example: 'buy'
6402
+ },
6403
+ paymentSource: {
6404
+ type: 'string',
6405
+ description: 'Payment source: asset (default) or liability (credit card)',
6406
+ enum: ['asset', 'liability'],
6407
+ example: 'asset'
6408
+ },
6409
+ liabilityHint: {
6410
+ type: 'string',
6411
+ description: 'Liability account hint (CreditCard/Huabei/Baitiao)',
6412
+ example: 'CreditCard'
6413
+ },
6414
+ warning: {
6415
+ type: 'string',
6416
+ description:
6417
+ 'Display-only warning from the prior response; accepted but ignored.',
6418
+ example: 'Cross-currency settlement applies.'
6419
+ }
6420
+ }
6421
+ } as const;
6422
+
5904
6423
  export const $ProcessNlpDto = {
5905
6424
  type: 'object',
5906
6425
  properties: {
5907
6426
  message: {
5908
6427
  type: 'string',
5909
- description: 'Natural language text describing a transaction (Chinese)',
5910
- example: 'yesterday Starbucks spent 35 yuan',
6428
+ description:
6429
+ 'Natural language text describing a transaction. Optional when `confirm` is true (structured confirm); otherwise required.',
6430
+ example: 'Starbucks 35',
5911
6431
  maxLength: 500
5912
6432
  },
6433
+ confirm: {
6434
+ type: 'boolean',
6435
+ description:
6436
+ 'Structured confirm signal — bypasses NL confirm-word matching when true. Send parsedData field edits alongside. The NL word-list path is the fallback.',
6437
+ example: true
6438
+ },
5913
6439
  sessionId: {
5914
6440
  type: 'string',
5915
6441
  description:
@@ -5917,17 +6443,51 @@ export const $ProcessNlpDto = {
5917
6443
  example: 'session_abc123'
5918
6444
  },
5919
6445
  parsedData: {
5920
- type: 'object',
5921
6446
  description:
5922
6447
  'Parsed data from previous NLP response for session recovery. Send back the parsedData received in confirm_payee/confirm responses.',
5923
6448
  example: {
5924
6449
  amount: 35,
5925
6450
  currency: 'CNY',
5926
6451
  payee: 'Starbucks'
5927
- }
6452
+ },
6453
+ allOf: [
6454
+ {
6455
+ $ref: '#/components/schemas/ClientParsedDataDto'
6456
+ }
6457
+ ]
6458
+ },
6459
+ selectedRuleId: {
6460
+ type: 'string',
6461
+ description:
6462
+ 'confirm_rule echo-back: rule id selected from the prior confirm_rule response (matchedRule.id or alternatives[i].ruleId). Applied directly when the session is confirming_rule — no NL re-parse.',
6463
+ example: 'rule_abc123'
6464
+ },
6465
+ selectedAccount: {
6466
+ type: 'string',
6467
+ description:
6468
+ '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.',
6469
+ example: 'Expenses:Food:Coffee'
6470
+ },
6471
+ viewpointAccount: {
6472
+ type: 'string',
6473
+ description:
6474
+ '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.',
6475
+ example: 'Assets:CN:Bank:ICBC'
6476
+ },
6477
+ viewpointCategory: {
6478
+ type: 'string',
6479
+ description:
6480
+ "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.",
6481
+ example: 'Food'
6482
+ },
6483
+ viewpointFlow: {
6484
+ type: 'string',
6485
+ description:
6486
+ "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.",
6487
+ enum: ['income', 'expense'],
6488
+ example: 'expense'
5928
6489
  }
5929
- },
5930
- required: ['message']
6490
+ }
5931
6491
  } as const;
5932
6492
 
5933
6493
  export const $NlpTransactionInfoDto = {
@@ -5993,7 +6553,9 @@ export const $NlpParsedDataDto = {
5993
6553
  },
5994
6554
  category: {
5995
6555
  type: 'string',
5996
- description: 'Category'
6556
+ description:
6557
+ 'Category in canonical form: a CATEGORY_CATALOG slug (GET /{region}/bean/categories) or a Stage-2 rule categoryKeywords token (ADR-0116 D2). Never a locale display name or a beancount account path. Echo back verbatim on confirm.',
6558
+ example: 'food'
5997
6559
  },
5998
6560
  incomeType: {
5999
6561
  type: 'string',
@@ -6239,6 +6801,24 @@ export const $NlpRuleConfirmationDataDto = {
6239
6801
  ]
6240
6802
  } as const;
6241
6803
 
6804
+ export const $NlpAccountCandidateDto = {
6805
+ type: 'object',
6806
+ properties: {
6807
+ path: {
6808
+ type: 'string',
6809
+ description: 'Canonical beancount account path (echo back on selection)',
6810
+ example: 'Expenses:Food:Dining'
6811
+ },
6812
+ name: {
6813
+ type: 'string',
6814
+ description:
6815
+ 'Localized display name (ADR-0114 read-time projection, user locale)',
6816
+ example: '餐饮'
6817
+ }
6818
+ },
6819
+ required: ['path', 'name']
6820
+ } as const;
6821
+
6242
6822
  export const $NlpAccountConfirmationDataDto = {
6243
6823
  type: 'object',
6244
6824
  properties: {
@@ -6249,14 +6829,16 @@ export const $NlpAccountConfirmationDataDto = {
6249
6829
  },
6250
6830
  suggestedAccount: {
6251
6831
  type: 'string',
6252
- description: 'Suggested replacement account',
6832
+ description:
6833
+ 'Suggested replacement account (omitted when no clear candidate)',
6253
6834
  example: 'Expenses:Food:Drinks'
6254
6835
  },
6255
6836
  similarAccounts: {
6256
- description: 'Similar accounts for user selection',
6837
+ description:
6838
+ 'Similar accounts for user selection (path + localized name, #680)',
6257
6839
  type: 'array',
6258
6840
  items: {
6259
- type: 'string'
6841
+ $ref: '#/components/schemas/NlpAccountCandidateDto'
6260
6842
  }
6261
6843
  },
6262
6844
  errorMessage: {
@@ -6271,7 +6853,6 @@ export const $NlpAccountConfirmationDataDto = {
6271
6853
  },
6272
6854
  required: [
6273
6855
  'invalidAccount',
6274
- 'suggestedAccount',
6275
6856
  'similarAccounts',
6276
6857
  'errorMessage',
6277
6858
  'transactionContext'
@@ -6444,7 +7025,8 @@ export const $NlpSuggestedAccountDto = {
6444
7025
  },
6445
7026
  confidence: {
6446
7027
  type: 'number',
6447
- description: 'Confidence score for this suggestion (0-1)',
7028
+ description:
7029
+ 'Confidence score for this suggestion (0-1). Present = predicted (confirm/confirm_rule/confirm_account); omitted = actual persisted account (created). (#586)',
6448
7030
  example: 0.9
6449
7031
  }
6450
7032
  },
@@ -6480,23 +7062,31 @@ export const $NlpDefaultAccountsDto = {
6480
7062
  properties: {
6481
7063
  asset: {
6482
7064
  type: 'string',
6483
- description: 'Default asset account',
6484
- example: 'Assets:Checking'
7065
+ description:
7066
+ 'Default OPEN asset account (MRU when multiple), or null when none/ambiguous',
7067
+ example: 'Assets:Checking',
7068
+ nullable: true
6485
7069
  },
6486
7070
  expense: {
6487
7071
  type: 'string',
6488
- description: 'Default expense account',
6489
- example: 'Expenses:Uncategorized'
7072
+ description:
7073
+ 'Default OPEN expense account (MRU when multiple), or null when none/ambiguous',
7074
+ example: 'Expenses:Food:Coffee',
7075
+ nullable: true
6490
7076
  },
6491
7077
  income: {
6492
7078
  type: 'string',
6493
- description: 'Default income account',
6494
- example: 'Income:Uncategorized'
7079
+ description:
7080
+ 'Default OPEN income account (MRU when multiple), or null when none/ambiguous',
7081
+ example: 'Income:Salary',
7082
+ nullable: true
6495
7083
  },
6496
7084
  liability: {
6497
7085
  type: 'string',
6498
- description: 'Default liability account',
6499
- example: 'Liabilities:CreditCard'
7086
+ description:
7087
+ 'Default OPEN liability account (MRU when multiple), or null when none/ambiguous',
7088
+ example: 'Liabilities:CreditCard',
7089
+ nullable: true
6500
7090
  }
6501
7091
  },
6502
7092
  required: ['asset', 'expense', 'income', 'liability']
@@ -6521,7 +7111,8 @@ export const $NlpResponseDto = {
6521
7111
  'confirm_rule',
6522
7112
  'confirm_account',
6523
7113
  'confirm_payee',
6524
- 'cancel'
7114
+ 'cancel',
7115
+ 'aborted'
6525
7116
  ]
6526
7117
  },
6527
7118
  intent: {
@@ -6535,7 +7126,7 @@ export const $NlpResponseDto = {
6535
7126
  type: 'string',
6536
7127
  description:
6537
7128
  'Asset sub-type (only present when intent is "asset"). Determines which asset-related form to render.',
6538
- enum: ['transfer', 'banking', 'investment'],
7129
+ enum: ['transfer', 'banking', 'investment', 'lend', 'lend_collect'],
6539
7130
  example: 'investment'
6540
7131
  },
6541
7132
  liabilitySubType: {
@@ -6683,7 +7274,7 @@ export const $NlpResponseDto = {
6683
7274
  },
6684
7275
  suggestedAccounts: {
6685
7276
  description:
6686
- 'Suggested accounts for this transaction. Contains recommended source and destination accounts based on the detected intent and rules.',
7277
+ 'Suggested accounts for this transaction (#586). confirm/confirm_rule/confirm_account: predicted (source/destination carry confidence); created: actual persisted accounts (confidence omitted). confirm_account destination is the suggested replacement, never the invalid account.',
6687
7278
  allOf: [
6688
7279
  {
6689
7280
  $ref: '#/components/schemas/NlpSuggestedAccountsDto'
@@ -6692,7 +7283,7 @@ export const $NlpResponseDto = {
6692
7283
  },
6693
7284
  defaultAccounts: {
6694
7285
  description:
6695
- 'Default accounts for the user/region. These are fallback accounts used when no specific suggestion is available.',
7286
+ 'Default fallback accounts for the user/region (#586). v1 returns universal constants; per-user personalization is planned.',
6696
7287
  allOf: [
6697
7288
  {
6698
7289
  $ref: '#/components/schemas/NlpDefaultAccountsDto'
@@ -6738,13 +7329,26 @@ export const $PlatformListItemDto = {
6738
7329
  suggestedSegment: {
6739
7330
  type: 'string',
6740
7331
  description:
6741
- 'Suggested path segment — canonical with first char uppercased (ACC_COMP_NAME_RE)'
7332
+ 'Suggested path segment — canonical PascalCased per hyphen-part, hyphens preserved (e.g. "Apple-Pay")'
6742
7333
  },
6743
7334
  logoUrl: {
6744
7335
  type: 'string',
6745
7336
  description: 'Logo URL',
6746
7337
  nullable: true
6747
7338
  },
7339
+ countryCode: {
7340
+ type: 'string',
7341
+ description: 'ISO 3166-1 alpha-2 (UPPERCASE); null = global platform',
7342
+ example: 'CN',
7343
+ nullable: true
7344
+ },
7345
+ category: {
7346
+ type: 'string',
7347
+ description:
7348
+ 'Region-aware category (institution vocab, e.g. DigitalWallet/Bank). null = no region-aware suggestion; fall back to type.',
7349
+ nullable: true,
7350
+ example: 'DigitalWallet'
7351
+ },
6748
7352
  isBound: {
6749
7353
  type: 'boolean',
6750
7354
  description: 'Whether user has accounts using this platform'
@@ -6758,6 +7362,8 @@ export const $PlatformListItemDto = {
6758
7362
  'canonical',
6759
7363
  'suggestedSegment',
6760
7364
  'logoUrl',
7365
+ 'countryCode',
7366
+ 'category',
6761
7367
  'isBound'
6762
7368
  ]
6763
7369
  } as const;
@@ -6793,13 +7399,26 @@ export const $PlatformMatchResultDto = {
6793
7399
  suggestedSegment: {
6794
7400
  type: 'string',
6795
7401
  description:
6796
- 'Suggested path segment — canonical, already in ACCOUNT_RE format'
7402
+ 'Suggested path segment — canonical PascalCased per hyphen-part, hyphens preserved (e.g. "Apple-Pay")'
6797
7403
  },
6798
7404
  logoUrl: {
6799
7405
  type: 'string',
6800
7406
  description: 'Logo URL',
6801
7407
  nullable: true
6802
7408
  },
7409
+ countryCode: {
7410
+ type: 'string',
7411
+ description: 'ISO 3166-1 alpha-2 (UPPERCASE); null = global platform',
7412
+ example: 'CN',
7413
+ nullable: true
7414
+ },
7415
+ category: {
7416
+ type: 'string',
7417
+ description:
7418
+ 'Region-aware category (institution vocab, e.g. DigitalWallet/Bank). null = no region-aware suggestion; fall back to type.',
7419
+ nullable: true,
7420
+ example: 'DigitalWallet'
7421
+ },
6803
7422
  matchType: {
6804
7423
  type: 'string',
6805
7424
  description: "How this row matched: 'exact' > 'prefix' > 'substring'",
@@ -6813,6 +7432,8 @@ export const $PlatformMatchResultDto = {
6813
7432
  'type',
6814
7433
  'suggestedSegment',
6815
7434
  'logoUrl',
7435
+ 'countryCode',
7436
+ 'category',
6816
7437
  'matchType'
6817
7438
  ]
6818
7439
  } as const;
@@ -6842,7 +7463,80 @@ export const $PlatformMatchResponseDto = {
6842
7463
  description: 'true when total > platforms.length (more matches exist)'
6843
7464
  }
6844
7465
  },
6845
- required: ['platforms', 'matchType', 'total', 'hasMore']
7466
+ required: ['platforms', 'matchType', 'total', 'hasMore']
7467
+ } as const;
7468
+
7469
+ export const $PlatformStandardsPlatformDto = {
7470
+ type: 'object',
7471
+ properties: {
7472
+ id: {
7473
+ type: 'string',
7474
+ description: 'Global platform ID'
7475
+ },
7476
+ name: {
7477
+ type: 'string',
7478
+ description: 'Platform name (e.g., "ICBC")'
7479
+ },
7480
+ canonical: {
7481
+ type: 'string',
7482
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
7483
+ },
7484
+ suggestedSegment: {
7485
+ type: 'string',
7486
+ description:
7487
+ 'Suggested path segment — canonical PascalCased per hyphen-part, hyphens preserved (e.g. "Apple-Pay")'
7488
+ },
7489
+ type: {
7490
+ type: 'string',
7491
+ description: 'Platform type',
7492
+ enum: [
7493
+ 'BANK',
7494
+ 'BROKERAGE',
7495
+ 'CRYPTO_EXCHANGE',
7496
+ 'PAYMENT',
7497
+ 'INVESTMENT',
7498
+ 'INSURANCE',
7499
+ 'OTHER'
7500
+ ]
7501
+ },
7502
+ category: {
7503
+ type: 'string',
7504
+ description:
7505
+ 'Region-aware category (institution vocab, e.g. DigitalWallet/Bank) resolved against the final region. null = no region-aware suggestion; fall back to type.',
7506
+ nullable: true,
7507
+ example: 'Bank'
7508
+ }
7509
+ },
7510
+ required: ['id', 'name', 'canonical', 'suggestedSegment', 'type', 'category']
7511
+ } as const;
7512
+
7513
+ export const $PlatformStandardsResponseDto = {
7514
+ type: 'object',
7515
+ properties: {
7516
+ platform: {
7517
+ description: 'The selected platform (institution lock source)',
7518
+ allOf: [
7519
+ {
7520
+ $ref: '#/components/schemas/PlatformStandardsPlatformDto'
7521
+ }
7522
+ ]
7523
+ },
7524
+ region: {
7525
+ type: 'string',
7526
+ description:
7527
+ "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.",
7528
+ example: 'CN'
7529
+ },
7530
+ templates: {
7531
+ description:
7532
+ 'Candidate account-standard templates of the resolved region (groupable by productCategory client-side)',
7533
+ type: 'array',
7534
+ items: {
7535
+ $ref: '#/components/schemas/AccountStandardResponseDto'
7536
+ }
7537
+ }
7538
+ },
7539
+ required: ['platform', 'region', 'templates']
6846
7540
  } as const;
6847
7541
 
6848
7542
  export const $CreatePlatformDto = {
@@ -6946,7 +7640,8 @@ export const $UpdatePlatformDto = {
6946
7640
  },
6947
7641
  isActive: {
6948
7642
  type: 'boolean',
6949
- description: 'Whether the platform is active'
7643
+ description: 'Whether the platform is active',
7644
+ default: true
6950
7645
  }
6951
7646
  }
6952
7647
  } as const;
@@ -7109,7 +7804,8 @@ export const $AccountItemDto = {
7109
7804
  },
7110
7805
  displayName: {
7111
7806
  type: 'string',
7112
- description: 'Display name (last part of account path)',
7807
+ description:
7808
+ 'Display name: user-set name if provided (#762), else the ADR-0114 chain — request-locale catalog name, en pivot, then the last part of the account path (#771)',
7113
7809
  example: 'Savings'
7114
7810
  },
7115
7811
  balance: {
@@ -7145,7 +7841,8 @@ export const $PlatformGroupDto = {
7145
7841
  example: 'CMB Bank'
7146
7842
  },
7147
7843
  accounts: {
7148
- description: 'Accounts within this platform',
7844
+ description:
7845
+ 'Accounts within this platform (Assets and Liabilities rows, #696)',
7149
7846
  type: 'array',
7150
7847
  items: {
7151
7848
  $ref: '#/components/schemas/AccountItemDto'
@@ -7153,7 +7850,8 @@ export const $PlatformGroupDto = {
7153
7850
  },
7154
7851
  totalBalance: {
7155
7852
  type: 'string',
7156
- description: 'FX-converted total balance in base currency',
7853
+ description:
7854
+ 'FX-converted total balance in base currency (nets Assets + Liabilities rows; can be negative)',
7157
7855
  example: '100000.00'
7158
7856
  },
7159
7857
  balanceByCurrency: {
@@ -7172,7 +7870,7 @@ export const $PlatformGroupDto = {
7172
7870
  sharePct: {
7173
7871
  type: 'number',
7174
7872
  description:
7175
- 'Share of the grand converted total (0-100); 0 when grand total is 0',
7873
+ 'Share of the converted asset-side grand total (0-100); liability balances are excluded from the basis; 0 when grand total is 0 (#696)',
7176
7874
  example: 42.5
7177
7875
  }
7178
7876
  },
@@ -7220,7 +7918,8 @@ export const $AccountsSummaryDto = {
7220
7918
  properties: {
7221
7919
  totalAccounts: {
7222
7920
  type: 'number',
7223
- description: 'Total number of accounts'
7921
+ description:
7922
+ 'Total number of accounts (balance sheet: Assets + Liabilities, #696)'
7224
7923
  },
7225
7924
  totalPlatforms: {
7226
7925
  type: 'number',
@@ -7278,7 +7977,8 @@ export const $AccountItemWithAssetClassDto = {
7278
7977
  },
7279
7978
  displayName: {
7280
7979
  type: 'string',
7281
- description: 'Display name (last part of account path)',
7980
+ description:
7981
+ 'Display name: user-set name if provided (#762), else the ADR-0114 chain — request-locale catalog name, en pivot, then the last part of the account path (#771)',
7282
7982
  example: 'Savings'
7283
7983
  },
7284
7984
  balance: {
@@ -7764,7 +8464,7 @@ export const $MonetaryDto = {
7764
8464
  example: 'USD'
7765
8465
  },
7766
8466
  baseCcyEquivalent: {
7767
- type: 'object',
8467
+ type: 'string',
7768
8468
  description: 'Converted to user base currency (Decimal string)',
7769
8469
  example: '21600',
7770
8470
  nullable: true
@@ -7840,13 +8540,13 @@ export const $HoldingPnlRowDto = {
7840
8540
  example: 'Assets:US:Broker:AAPL'
7841
8541
  },
7842
8542
  accountCcy: {
7843
- type: 'object',
8543
+ type: 'string',
7844
8544
  description: 'Account settlement currency (ISO 4217), from cost currency',
7845
8545
  nullable: true,
7846
8546
  example: 'USD'
7847
8547
  },
7848
8548
  brokerType: {
7849
- type: 'object',
8549
+ type: 'string',
7850
8550
  description: 'Broker type derived from Platform.type',
7851
8551
  nullable: true,
7852
8552
  example: 'broker'
@@ -7867,7 +8567,7 @@ export const $HoldingPnlRowDto = {
7867
8567
  example: 'EQUITY'
7868
8568
  },
7869
8569
  assetSubClass: {
7870
- type: 'object',
8570
+ type: 'string',
7871
8571
  nullable: true,
7872
8572
  example: 'STOCK'
7873
8573
  },
@@ -7914,14 +8614,14 @@ export const $HoldingPnlRowDto = {
7914
8614
  ]
7915
8615
  },
7916
8616
  unrealizedPnlBase: {
7917
- type: 'object',
8617
+ type: 'string',
7918
8618
  description:
7919
8619
  'Unrealized P&L in base currency (Decimal string); null when any FX/price missing',
7920
8620
  nullable: true,
7921
8621
  example: '6000'
7922
8622
  },
7923
8623
  unrealizedPnlPct: {
7924
- type: 'object',
8624
+ type: 'string',
7925
8625
  description: 'Unrealized P&L % (Decimal string)',
7926
8626
  nullable: true,
7927
8627
  example: '25'
@@ -7945,7 +8645,7 @@ export const $HoldingPnlRowDto = {
7945
8645
  ]
7946
8646
  },
7947
8647
  pctOfInvestedAssets: {
7948
- type: 'object',
8648
+ type: 'string',
7949
8649
  description:
7950
8650
  'Share of invested assets % (Decimal string); only for invested chartTokens',
7951
8651
  nullable: true,
@@ -7990,15 +8690,15 @@ export const $HoldingPnlWarningDto = {
7990
8690
  ]
7991
8691
  },
7992
8692
  symbol: {
7993
- type: 'object',
8693
+ type: 'string',
7994
8694
  nullable: true
7995
8695
  },
7996
8696
  accountId: {
7997
- type: 'object',
8697
+ type: 'string',
7998
8698
  nullable: true
7999
8699
  },
8000
8700
  currency: {
8001
- type: 'object',
8701
+ type: 'string',
8002
8702
  nullable: true
8003
8703
  }
8004
8704
  },
@@ -8061,3 +8761,356 @@ export const $AnonymousLoginResponseDto = {
8061
8761
  },
8062
8762
  required: ['authToken']
8063
8763
  } as const;
8764
+
8765
+ export const $ParserContributionMetaDto = {
8766
+ type: 'object',
8767
+ properties: {
8768
+ institution: {
8769
+ type: 'string',
8770
+ description: 'Institution slug (lowercase kebab-case)',
8771
+ pattern: '^[a-z0-9]+(-[a-z0-9]+)*$',
8772
+ example: 'icbc'
8773
+ },
8774
+ region: {
8775
+ type: 'string',
8776
+ enum: [
8777
+ 'cn',
8778
+ 'us',
8779
+ 'de',
8780
+ 'fr',
8781
+ 'gb',
8782
+ 'hk',
8783
+ 'jp',
8784
+ 'sg',
8785
+ 'au',
8786
+ 'ca',
8787
+ 'other'
8788
+ ]
8789
+ },
8790
+ accountType: {
8791
+ type: 'string',
8792
+ enum: ['checking', 'savings', 'credit', 'debit', 'investment']
8793
+ },
8794
+ format: {
8795
+ type: 'string',
8796
+ enum: ['csv', 'xlsx', 'pdf', 'ofx', 'qif']
8797
+ },
8798
+ institutionDisplayName: {
8799
+ type: 'string',
8800
+ example: '中国工商银行'
8801
+ },
8802
+ encoding: {
8803
+ type: 'string',
8804
+ example: 'utf-8'
8805
+ },
8806
+ delimiter: {
8807
+ type: 'string',
8808
+ description: 'CSV delimiter character: ",", ";", "\\t" or "|"'
8809
+ },
8810
+ headerRows: {
8811
+ type: 'number',
8812
+ default: 1,
8813
+ description: 'Header row count; the client omits the field when it is 1'
8814
+ },
8815
+ notes: {
8816
+ type: 'string',
8817
+ maxLength: 2000
8818
+ }
8819
+ },
8820
+ required: ['institution', 'region', 'accountType', 'format']
8821
+ } as const;
8822
+
8823
+ export const $ParserContributionSamplesDto = {
8824
+ type: 'object',
8825
+ properties: {
8826
+ rows: {
8827
+ description:
8828
+ 'Client-sanitized sample rows (key = column name, value = cell)',
8829
+ type: 'array',
8830
+ items: {
8831
+ type: 'object'
8832
+ }
8833
+ },
8834
+ rawHeaders: {
8835
+ type: 'array',
8836
+ items: {
8837
+ type: 'string'
8838
+ }
8839
+ }
8840
+ },
8841
+ required: ['rows']
8842
+ } as const;
8843
+
8844
+ export const $FieldHintDto = {
8845
+ type: 'object',
8846
+ properties: {
8847
+ columnName: {
8848
+ type: 'string',
8849
+ example: '交易日期'
8850
+ },
8851
+ format: {
8852
+ type: 'string',
8853
+ description: 'Date format, e.g. yyyy-MM-dd HH:mm',
8854
+ example: 'yyyy-MM-dd'
8855
+ },
8856
+ signConvention: {
8857
+ type: 'string',
8858
+ enum: ['negative-expense', 'positive-expense', 'separate-columns']
8859
+ },
8860
+ creditColumn: {
8861
+ type: 'string'
8862
+ },
8863
+ debitColumn: {
8864
+ type: 'string'
8865
+ }
8866
+ },
8867
+ required: ['columnName']
8868
+ } as const;
8869
+
8870
+ export const $ParserContributionFieldHintsDto = {
8871
+ type: 'object',
8872
+ properties: {
8873
+ date: {
8874
+ $ref: '#/components/schemas/FieldHintDto'
8875
+ },
8876
+ amount: {
8877
+ $ref: '#/components/schemas/FieldHintDto'
8878
+ },
8879
+ description: {
8880
+ $ref: '#/components/schemas/FieldHintDto'
8881
+ },
8882
+ balance: {
8883
+ $ref: '#/components/schemas/FieldHintDto'
8884
+ },
8885
+ payee: {
8886
+ $ref: '#/components/schemas/FieldHintDto'
8887
+ },
8888
+ reference: {
8889
+ $ref: '#/components/schemas/FieldHintDto'
8890
+ },
8891
+ category: {
8892
+ $ref: '#/components/schemas/FieldHintDto'
8893
+ }
8894
+ },
8895
+ required: ['date', 'amount']
8896
+ } as const;
8897
+
8898
+ export const $ExpectedTransactionDto = {
8899
+ type: 'object',
8900
+ properties: {
8901
+ date: {
8902
+ type: 'string',
8903
+ example: '2026-08-01'
8904
+ },
8905
+ amount: {
8906
+ type: 'number',
8907
+ example: -45.5
8908
+ },
8909
+ description: {
8910
+ type: 'string',
8911
+ example: '星巴克-***店'
8912
+ },
8913
+ payee: {
8914
+ type: 'string'
8915
+ },
8916
+ category: {
8917
+ type: 'string'
8918
+ }
8919
+ },
8920
+ required: ['date', 'amount', 'description']
8921
+ } as const;
8922
+
8923
+ export const $ParserContributionExamplesDto = {
8924
+ type: 'object',
8925
+ properties: {
8926
+ expectedTransactions: {
8927
+ type: 'array',
8928
+ items: {
8929
+ $ref: '#/components/schemas/ExpectedTransactionDto'
8930
+ }
8931
+ }
8932
+ },
8933
+ required: ['expectedTransactions']
8934
+ } as const;
8935
+
8936
+ export const $ParserContributionRequestDto = {
8937
+ type: 'object',
8938
+ properties: {
8939
+ meta: {
8940
+ $ref: '#/components/schemas/ParserContributionMetaDto'
8941
+ },
8942
+ samples: {
8943
+ $ref: '#/components/schemas/ParserContributionSamplesDto'
8944
+ },
8945
+ fieldHints: {
8946
+ $ref: '#/components/schemas/ParserContributionFieldHintsDto'
8947
+ },
8948
+ examples: {
8949
+ description: 'Omitted entirely by the client when empty',
8950
+ allOf: [
8951
+ {
8952
+ $ref: '#/components/schemas/ParserContributionExamplesDto'
8953
+ }
8954
+ ]
8955
+ }
8956
+ },
8957
+ required: ['meta', 'samples', 'fieldHints']
8958
+ } as const;
8959
+
8960
+ export const $ParserContributionRelayResponseDto = {
8961
+ type: 'object',
8962
+ properties: {
8963
+ issueUrl: {
8964
+ type: 'string',
8965
+ example: 'https://github.com/fire-zu/firela-vlt/issues/42'
8966
+ },
8967
+ issueNumber: {
8968
+ type: 'number',
8969
+ example: 42
8970
+ }
8971
+ },
8972
+ required: ['issueUrl', 'issueNumber']
8973
+ } as const;
8974
+
8975
+ export const $SymbolSearchResultDto = {
8976
+ type: 'object',
8977
+ properties: {
8978
+ symbol: {
8979
+ type: 'string',
8980
+ example: 'AAPL'
8981
+ },
8982
+ name: {
8983
+ type: 'string',
8984
+ example: 'Apple Inc.',
8985
+ nullable: true
8986
+ },
8987
+ exchange: {
8988
+ type: 'string',
8989
+ example: 'US',
8990
+ nullable: true
8991
+ },
8992
+ assetType: {
8993
+ type: 'string',
8994
+ description: 'OpenBB asset_type (e.g. stock, etf)',
8995
+ example: 'stock',
8996
+ nullable: true
8997
+ },
8998
+ assetClass: {
8999
+ type: 'string',
9000
+ description: 'IGN asset class (region.types.ts ASSET_CLASSES)',
9001
+ example: 'EQUITY',
9002
+ nullable: true
9003
+ },
9004
+ assetSubClass: {
9005
+ type: 'string',
9006
+ description: 'IGN asset sub-class (region.types.ts ASSET_SUB_CLASSES)',
9007
+ example: 'STOCK',
9008
+ nullable: true
9009
+ },
9010
+ currency: {
9011
+ type: 'string',
9012
+ description: 'Trading currency (extra_data or inferred from exchange)',
9013
+ example: 'USD',
9014
+ nullable: true
9015
+ }
9016
+ },
9017
+ required: ['symbol']
9018
+ } as const;
9019
+
9020
+ export const $SymbolQuoteDto = {
9021
+ type: 'object',
9022
+ properties: {
9023
+ symbol: {
9024
+ type: 'string',
9025
+ example: 'AAPL'
9026
+ },
9027
+ name: {
9028
+ type: 'string',
9029
+ example: 'Apple Inc.',
9030
+ nullable: true
9031
+ },
9032
+ exchange: {
9033
+ type: 'string',
9034
+ example: 'US',
9035
+ nullable: true
9036
+ },
9037
+ assetType: {
9038
+ type: 'string',
9039
+ description: 'OpenBB asset_type',
9040
+ example: 'stock',
9041
+ nullable: true
9042
+ },
9043
+ assetClass: {
9044
+ type: 'string',
9045
+ description: 'IGN asset class',
9046
+ example: 'EQUITY',
9047
+ nullable: true
9048
+ },
9049
+ assetSubClass: {
9050
+ type: 'string',
9051
+ description: 'IGN asset sub-class',
9052
+ example: 'STOCK',
9053
+ nullable: true
9054
+ },
9055
+ currency: {
9056
+ type: 'string',
9057
+ description: 'Trading currency (extra_data or inferred from exchange)',
9058
+ example: 'USD',
9059
+ nullable: true
9060
+ },
9061
+ price: {
9062
+ type: 'string',
9063
+ description: 'Latest price (Decimal string)',
9064
+ example: '189.84',
9065
+ nullable: true
9066
+ },
9067
+ priceDate: {
9068
+ type: 'string',
9069
+ description: 'Date the price was observed (ISO yyyy-MM-dd)',
9070
+ example: '2026-08-05',
9071
+ nullable: true
9072
+ },
9073
+ changePercent: {
9074
+ type: 'number',
9075
+ description:
9076
+ '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.',
9077
+ example: 1.7,
9078
+ nullable: true
9079
+ },
9080
+ prevClose: {
9081
+ type: 'string',
9082
+ description: 'Previous close (Decimal string)',
9083
+ nullable: true
9084
+ },
9085
+ open: {
9086
+ type: 'string',
9087
+ description: 'Day open (Decimal string)',
9088
+ nullable: true
9089
+ },
9090
+ high: {
9091
+ type: 'string',
9092
+ description: 'Day high (Decimal string)',
9093
+ nullable: true
9094
+ },
9095
+ low: {
9096
+ type: 'string',
9097
+ description: 'Day low (Decimal string)',
9098
+ nullable: true
9099
+ },
9100
+ volume: {
9101
+ type: 'string',
9102
+ description: 'Day volume (Decimal string)',
9103
+ nullable: true
9104
+ },
9105
+ yearHigh: {
9106
+ type: 'string',
9107
+ description: '52-week high (Decimal string)',
9108
+ nullable: true
9109
+ },
9110
+ yearLow: {
9111
+ type: 'string',
9112
+ description: '52-week low (Decimal string)',
9113
+ nullable: true
9114
+ }
9115
+ }
9116
+ } as const;