@firela/api-types 0.0.0-canary.97006feb → 0.0.0-canary.9b21c9cd

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.
@@ -88,6 +88,49 @@ export const $AccountResponseDto = {
88
88
  enum: ['Assets', 'Liabilities', 'Income', 'Expenses', 'Equity'],
89
89
  example: 'Assets'
90
90
  },
91
+ assetSubClass: {
92
+ type: 'string',
93
+ description:
94
+ '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.',
95
+ enum: [
96
+ 'DEPOSIT',
97
+ 'CASH',
98
+ 'MONEY_MARKET_FUND',
99
+ 'STOCK',
100
+ 'ETF',
101
+ 'MUTUAL_FUND',
102
+ 'EQUITY_COMPENSATION',
103
+ 'GOVERNMENT_BOND',
104
+ 'CORPORATE_BOND',
105
+ 'BOND_FUND',
106
+ 'PRIMARY_RESIDENCE',
107
+ 'INVESTMENT_PROPERTY',
108
+ 'REIT',
109
+ 'GOLD',
110
+ 'SILVER',
111
+ 'PRECIOUS_METAL',
112
+ 'PRECIOUS_METAL_FUND',
113
+ 'COMMODITY',
114
+ 'COMMODITY_FUND',
115
+ 'CRYPTOCURRENCY',
116
+ 'RETIREMENT_ACCOUNT',
117
+ 'HEALTH_ACCOUNT',
118
+ 'EDUCATION_ACCOUNT',
119
+ 'INSURANCE',
120
+ 'PRIVATE_EQUITY',
121
+ 'HEDGE_FUND',
122
+ 'COLLECTIBLES',
123
+ 'MORTGAGE',
124
+ 'STUDENT_LOAN',
125
+ 'CREDIT_CARD',
126
+ 'PERSONAL_LOAN',
127
+ 'ACCOUNTS_PAYABLE',
128
+ 'TAX_PAYABLE',
129
+ 'OTHER'
130
+ ],
131
+ nullable: true,
132
+ example: 'STOCK'
133
+ },
91
134
  status: {
92
135
  type: 'string',
93
136
  description: 'Account status',
@@ -334,16 +377,43 @@ export const $AccountStandardResponseDto = {
334
377
  },
335
378
  name: {
336
379
  type: 'string',
337
- description: 'Short localized display name',
380
+ description:
381
+ '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
382
  example: 'Housing Fund'
339
383
  },
384
+ aliases: {
385
+ description:
386
+ '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.',
387
+ example: ['Alipay', 'WeChat Pay'],
388
+ type: 'array',
389
+ items: {
390
+ type: 'string'
391
+ }
392
+ },
393
+ searchTerms: {
394
+ description:
395
+ '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).',
396
+ example: ['yinhangka', 'jiejika'],
397
+ type: 'array',
398
+ items: {
399
+ type: 'string'
400
+ }
401
+ },
402
+ currency: {
403
+ type: 'string',
404
+ description:
405
+ '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).',
406
+ example: 'HKD'
407
+ },
340
408
  description: {
341
409
  type: 'string',
342
- description: 'Account description (stable semantics only)',
410
+ description:
411
+ '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
412
  example: 'ICBC checking account for daily transactions'
344
413
  },
345
414
  tags: {
346
- description: 'Account tags for categorization',
415
+ description:
416
+ 'Account tags for categorization — structured metadata delivered verbatim (not localized, not xlf-managed). ADR-0131 class A.',
347
417
  example: ['bank', 'checking', 'primary'],
348
418
  type: 'array',
349
419
  items: {
@@ -354,9 +424,47 @@ export const $AccountStandardResponseDto = {
354
424
  type: 'string',
355
425
  description: 'Icon identifier for UI display',
356
426
  example: 'bank-icbc'
427
+ },
428
+ productCategory: {
429
+ type: 'string',
430
+ description:
431
+ 'Onboarding product category (coarse grouping derived from assetSubClass)',
432
+ enum: [
433
+ 'cash',
434
+ 'investment',
435
+ 'credit_card',
436
+ 'loan',
437
+ 'payable_tax',
438
+ 'other'
439
+ ],
440
+ example: 'investment'
441
+ },
442
+ assetClass: {
443
+ type: 'string',
444
+ description:
445
+ 'Asset class (LIQUIDITY/EQUITY/.../LIABILITY), derived at read time from classification rules',
446
+ enum: [
447
+ 'LIQUIDITY',
448
+ 'EQUITY',
449
+ 'FIXED_INCOME',
450
+ 'PRECIOUS_METALS',
451
+ 'COMMODITY',
452
+ 'INSURANCE',
453
+ 'ALTERNATIVE_INVESTMENT',
454
+ 'PERSONAL_ASSETS',
455
+ 'LIABILITY',
456
+ 'REAL_ESTATE',
457
+ 'INDEX'
458
+ ]
459
+ },
460
+ assetSubClass: {
461
+ type: 'string',
462
+ description:
463
+ 'Asset sub-class (product type, derived at read time from classification rules)',
464
+ example: 'STOCK'
357
465
  }
358
466
  },
359
- required: ['path', 'type', 'description', 'tags', 'icon']
467
+ required: ['path', 'type', 'description', 'tags', 'icon', 'productCategory']
360
468
  } as const;
361
469
 
362
470
  export const $AccountStandardListResponseDto = {
@@ -695,7 +803,7 @@ export const $PostingResponseDto = {
695
803
  units: {
696
804
  type: 'string',
697
805
  description:
698
- 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.',
806
+ '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
807
  example: '100.50'
700
808
  },
701
809
  currency: {
@@ -1061,7 +1169,7 @@ export const $PostingDetailDto = {
1061
1169
  units: {
1062
1170
  type: 'string',
1063
1171
  description:
1064
- 'Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.',
1172
+ '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
1173
  example: '100.50'
1066
1174
  },
1067
1175
  currency: {
@@ -1245,6 +1353,147 @@ export const $TransactionDetailDto = {
1245
1353
  ]
1246
1354
  } as const;
1247
1355
 
1356
+ export const $TransactionListItemDto = {
1357
+ type: 'object',
1358
+ properties: {
1359
+ id: {
1360
+ type: 'string',
1361
+ description: 'Transaction ID',
1362
+ example: 'clh1234567890abcdef'
1363
+ },
1364
+ date: {
1365
+ type: 'string',
1366
+ description: 'Transaction date',
1367
+ example: '2024-11-28'
1368
+ },
1369
+ flag: {
1370
+ type: 'string',
1371
+ description: 'Transaction flag',
1372
+ enum: [
1373
+ 'CLEARED',
1374
+ 'PENDING',
1375
+ 'PADDING',
1376
+ 'SUMMARIZE',
1377
+ 'TRANSFER',
1378
+ 'CONVERSIONS'
1379
+ ],
1380
+ example: 'CLEARED'
1381
+ },
1382
+ customFlag: {
1383
+ type: 'string',
1384
+ description: 'Custom flag (if not using standard flags)',
1385
+ example: 'R'
1386
+ },
1387
+ payee: {
1388
+ type: 'string',
1389
+ description: 'Payee name',
1390
+ example: 'Whole Foods Market'
1391
+ },
1392
+ narration: {
1393
+ type: 'string',
1394
+ description: 'Transaction narration',
1395
+ example: 'Grocery shopping'
1396
+ },
1397
+ tags: {
1398
+ description: 'Transaction tags',
1399
+ example: ['groceries'],
1400
+ type: 'array',
1401
+ items: {
1402
+ type: 'string'
1403
+ }
1404
+ },
1405
+ links: {
1406
+ description: 'Transaction links',
1407
+ example: ['invoice-2024-001'],
1408
+ type: 'array',
1409
+ items: {
1410
+ type: 'string'
1411
+ }
1412
+ },
1413
+ meta: {
1414
+ type: 'object',
1415
+ description: 'Transaction metadata'
1416
+ },
1417
+ status: {
1418
+ type: 'string',
1419
+ description: 'Transaction status',
1420
+ enum: ['ACTIVE', 'VOIDED', 'SUPERSEDED'],
1421
+ example: 'ACTIVE'
1422
+ },
1423
+ sourceType: {
1424
+ type: 'string',
1425
+ description:
1426
+ 'Source type (free-form string from transaction metadata, e.g. import, api)'
1427
+ },
1428
+ sourcePlatform: {
1429
+ type: 'string',
1430
+ description: 'Source platform (e.g., alipay, wechat)',
1431
+ example: 'alipay'
1432
+ },
1433
+ postings: {
1434
+ description: 'Transaction postings',
1435
+ type: 'array',
1436
+ items: {
1437
+ $ref: '#/components/schemas/PostingDetailDto'
1438
+ }
1439
+ },
1440
+ createdAt: {
1441
+ type: 'string',
1442
+ description: 'Created at timestamp',
1443
+ example: '2024-11-28T10:30:00.000Z'
1444
+ },
1445
+ voidedAt: {
1446
+ type: 'string',
1447
+ description: 'Voided at timestamp (if voided)',
1448
+ example: '2024-11-29T15:00:00.000Z'
1449
+ },
1450
+ voidedBy: {
1451
+ type: 'string',
1452
+ description: 'User ID who voided this transaction',
1453
+ example: 'clh1234567890abcdef'
1454
+ },
1455
+ correctionReason: {
1456
+ type: 'string',
1457
+ description: 'Correction reason (if voided or superseded)',
1458
+ example: 'Duplicate entry'
1459
+ },
1460
+ supersededBy: {
1461
+ type: 'string',
1462
+ description:
1463
+ 'ID of the transaction that supersedes this one (set when status=SUPERSEDED)',
1464
+ example: 'clh1234567890abcdef'
1465
+ },
1466
+ originalTxn: {
1467
+ type: 'string',
1468
+ description:
1469
+ 'ID of the transaction this one corrected/replaced (back-link on the replacement)',
1470
+ example: 'clh1234567890abcdef'
1471
+ },
1472
+ viewpointAmount: {
1473
+ type: 'string',
1474
+ description:
1475
+ '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.',
1476
+ example: '10000.00'
1477
+ },
1478
+ viewpointCurrency: {
1479
+ type: 'string',
1480
+ description:
1481
+ 'Currency of viewpointAmount. A row spanning multiple currencies takes the largest-magnitude currency group (known simplification, ADR-0126).',
1482
+ example: 'CNY'
1483
+ }
1484
+ },
1485
+ required: [
1486
+ 'id',
1487
+ 'date',
1488
+ 'narration',
1489
+ 'tags',
1490
+ 'links',
1491
+ 'status',
1492
+ 'postings',
1493
+ 'createdAt'
1494
+ ]
1495
+ } as const;
1496
+
1248
1497
  export const $BalanceByCurrencyDto = {
1249
1498
  type: 'object',
1250
1499
  properties: {
@@ -1290,7 +1539,7 @@ export const $TransactionListSummaryDto = {
1290
1539
  totalAmount: {
1291
1540
  type: 'string',
1292
1541
  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.',
1542
+ '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
1543
  example: '-6000.00'
1295
1544
  },
1296
1545
  currency: {
@@ -1316,6 +1565,26 @@ export const $TransactionListSummaryDto = {
1316
1565
  required: ['totalAmount', 'currency', 'balanceByCurrency']
1317
1566
  } as const;
1318
1567
 
1568
+ export const $TransactionListViewpointDto = {
1569
+ type: 'object',
1570
+ properties: {
1571
+ type: {
1572
+ type: 'string',
1573
+ description:
1574
+ 'Viewpoint type (only category drill-down carries a viewpoint today)',
1575
+ enum: ['category'],
1576
+ example: 'category'
1577
+ },
1578
+ flow: {
1579
+ type: 'string',
1580
+ description: 'Flow root the category account set is restricted to',
1581
+ enum: ['income', 'expense'],
1582
+ example: 'expense'
1583
+ }
1584
+ },
1585
+ required: ['type', 'flow']
1586
+ } as const;
1587
+
1319
1588
  export const $TransactionListResponseDto = {
1320
1589
  type: 'object',
1321
1590
  properties: {
@@ -1323,7 +1592,7 @@ export const $TransactionListResponseDto = {
1323
1592
  description: 'List of transactions',
1324
1593
  type: 'array',
1325
1594
  items: {
1326
- $ref: '#/components/schemas/TransactionDetailDto'
1595
+ $ref: '#/components/schemas/TransactionListItemDto'
1327
1596
  }
1328
1597
  },
1329
1598
  total: {
@@ -1349,6 +1618,15 @@ export const $TransactionListResponseDto = {
1349
1618
  $ref: '#/components/schemas/TransactionListSummaryDto'
1350
1619
  }
1351
1620
  ]
1621
+ },
1622
+ viewpoint: {
1623
+ description:
1624
+ '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).',
1625
+ allOf: [
1626
+ {
1627
+ $ref: '#/components/schemas/TransactionListViewpointDto'
1628
+ }
1629
+ ]
1352
1630
  }
1353
1631
  },
1354
1632
  required: ['data', 'total', 'limit', 'offset']
@@ -2259,10 +2537,10 @@ export const $UpdatePayeeDto = {
2259
2537
  meta: {
2260
2538
  type: 'object',
2261
2539
  description:
2262
- 'Metadata for extended information (location, notes, contact info, etc.). Will merge with existing metadata.',
2540
+ 'Metadata for extended information (location, notes, contact info, etc.)',
2263
2541
  example: {
2264
2542
  location: 'Zhongguancun',
2265
- note: 'Updated note',
2543
+ note: 'Near subway station',
2266
2544
  favorite: true
2267
2545
  }
2268
2546
  },
@@ -2823,568 +3101,660 @@ export const $UpdateCommodityDto = {
2823
3101
  }
2824
3102
  } as const;
2825
3103
 
2826
- export const $CreateBeanPriceDto = {
3104
+ export const $CurrencyBalanceDto = {
2827
3105
  type: 'object',
2828
3106
  properties: {
2829
3107
  currency: {
2830
3108
  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)',
3109
+ description: 'ISO 4217 currency code',
2837
3110
  example: 'CNY'
2838
3111
  },
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: {
3112
+ balance: {
2847
3113
  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
- }
3114
+ description: 'Balance amount',
3115
+ example: '500000.00'
2860
3116
  }
2861
3117
  },
2862
- required: ['currency', 'quoteCurrency', 'amount', 'date']
3118
+ required: ['currency', 'balance']
2863
3119
  } as const;
2864
3120
 
2865
- export const $PriceResponseDto = {
3121
+ export const $TimeSeriesPointDto = {
2866
3122
  type: 'object',
2867
3123
  properties: {
2868
- id: {
3124
+ date: {
2869
3125
  type: 'string',
2870
- description: 'Unique identifier',
2871
- example: 'uuid-123-456'
2872
- },
2873
- userId: {
2874
- type: 'string',
2875
- description: 'User ID (owner of the price)',
2876
- example: 'user-123'
3126
+ description: 'Date in YYYY-MM-DD format',
3127
+ example: '2024-06-15'
2877
3128
  },
2878
- currency: {
3129
+ value: {
2879
3130
  type: 'string',
2880
- description: 'Currency being priced (e.g., USD, AAPL, BTC)',
2881
- example: 'BTC'
3131
+ description: 'Value at this date (in base currency)',
3132
+ example: '500000.00'
2882
3133
  },
2883
- quoteCurrency: {
2884
- type: 'string',
2885
- description: 'Quote currency (pricing currency, e.g., USD, CNY)',
2886
- example: 'USD'
3134
+ change: {
3135
+ type: 'object',
3136
+ description: 'Change from previous point',
3137
+ example: '5000.00'
2887
3138
  },
2888
- amount: {
2889
- type: 'number',
2890
- description:
2891
- 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
2892
- example: 50000
3139
+ assets: {
3140
+ type: 'string',
3141
+ description: 'Total assets at this date (in base currency)',
3142
+ example: '494338.00'
2893
3143
  },
2894
- date: {
3144
+ liabilities: {
2895
3145
  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'
3146
+ description: 'Total liabilities at this date (in base currency)',
3147
+ example: '310098.00'
2900
3148
  },
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
3149
+ byCurrency: {
3150
+ description: 'Multi-currency breakdown for this point',
3151
+ type: 'array',
3152
+ items: {
3153
+ $ref: '#/components/schemas/CurrencyBalanceDto'
2909
3154
  }
3155
+ }
3156
+ },
3157
+ required: ['date', 'value']
3158
+ } as const;
3159
+
3160
+ export const $TrendSummaryDto = {
3161
+ type: 'object',
3162
+ properties: {
3163
+ startValue: {
3164
+ type: 'string',
3165
+ description: 'Value at start of period',
3166
+ example: '450000.00'
2910
3167
  },
2911
- createdAt: {
2912
- format: 'date-time',
3168
+ endValue: {
2913
3169
  type: 'string',
2914
- description: 'Creation timestamp',
2915
- example: '2024-11-03T10:00:00Z'
3170
+ description: 'Value at end of period',
3171
+ example: '500000.00'
2916
3172
  },
2917
- updatedAt: {
2918
- format: 'date-time',
3173
+ totalChange: {
2919
3174
  type: 'string',
2920
- description: 'Last update timestamp',
2921
- example: '2024-11-03T10:00:00Z'
3175
+ description: 'Total change over period',
3176
+ example: '50000.00'
3177
+ },
3178
+ totalChangePercentage: {
3179
+ type: 'string',
3180
+ description: 'Total change percentage',
3181
+ example: '+11.11%'
2922
3182
  }
2923
3183
  },
2924
- required: [
2925
- 'id',
2926
- 'userId',
2927
- 'currency',
2928
- 'quoteCurrency',
2929
- 'amount',
2930
- 'date',
2931
- 'meta',
2932
- 'createdAt',
2933
- 'updatedAt'
2934
- ]
3184
+ required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
2935
3185
  } as const;
2936
3186
 
2937
- export const $PriceListResponseDto = {
3187
+ export const $MultiCurrencyPointDto = {
2938
3188
  type: 'object',
2939
3189
  properties: {
2940
- items: {
2941
- description: 'List of prices',
3190
+ date: {
3191
+ type: 'string',
3192
+ description: 'Date in YYYY-MM-DD format',
3193
+ example: '2024-06-15'
3194
+ },
3195
+ byCurrency: {
3196
+ description: 'Balances by currency',
2942
3197
  type: 'array',
2943
3198
  items: {
2944
- $ref: '#/components/schemas/PriceResponseDto'
3199
+ $ref: '#/components/schemas/CurrencyBalanceDto'
2945
3200
  }
2946
- },
2947
- total: {
2948
- type: 'number',
2949
- description: 'Total number of prices',
2950
- example: 42
2951
3201
  }
2952
3202
  },
2953
- required: ['items', 'total']
3203
+ required: ['date', 'byCurrency']
2954
3204
  } as const;
2955
3205
 
2956
- export const $UpdateBeanPriceDto = {
3206
+ export const $PortfolioTrendsResponseDto = {
2957
3207
  type: 'object',
2958
3208
  properties: {
2959
- currency: {
2960
- type: 'string',
2961
- description: 'Currency being priced'
3209
+ series: {
3210
+ description: 'Time series data points',
3211
+ type: 'array',
3212
+ items: {
3213
+ $ref: '#/components/schemas/TimeSeriesPointDto'
3214
+ }
2962
3215
  },
2963
- quoteCurrency: {
3216
+ summary: {
3217
+ description: 'Period summary',
3218
+ allOf: [
3219
+ {
3220
+ $ref: '#/components/schemas/TrendSummaryDto'
3221
+ }
3222
+ ]
3223
+ },
3224
+ period: {
2964
3225
  type: 'string',
2965
- description: 'Quote currency (pricing currency)'
3226
+ description: 'Period requested',
3227
+ example: '6m'
2966
3228
  },
2967
- amount: {
2968
- type: 'number',
2969
- description: 'Price amount (MUST be >= 0 per Beancount spec)',
2970
- minimum: 0
3229
+ granularity: {
3230
+ type: 'string',
3231
+ description: 'Data granularity',
3232
+ example: 'month'
2971
3233
  },
2972
- date: {
3234
+ currency: {
2973
3235
  type: 'string',
2974
- description: 'Price date (ISO 8601 format)'
3236
+ description: 'Base currency for converted values',
3237
+ example: 'CNY'
2975
3238
  },
2976
- metadata: {
2977
- type: 'object',
2978
- description: 'Metadata'
3239
+ byCurrency: {
3240
+ description:
3241
+ 'Multi-currency time series (each point has currency breakdown)',
3242
+ type: 'array',
3243
+ items: {
3244
+ $ref: '#/components/schemas/MultiCurrencyPointDto'
3245
+ }
3246
+ },
3247
+ warnings: {
3248
+ description: 'Exchange rate warnings',
3249
+ type: 'array',
3250
+ items: {
3251
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
3252
+ }
2979
3253
  }
2980
- }
3254
+ },
3255
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
2981
3256
  } as const;
2982
3257
 
2983
- export const $CreateRecurringRuleDto = {
3258
+ export const $CashFlowPointDto = {
2984
3259
  type: 'object',
2985
3260
  properties: {
2986
- name: {
3261
+ month: {
2987
3262
  type: 'string',
2988
- description: 'Rule name (unique per user)',
2989
- maxLength: 100
3263
+ description: 'Month key (YYYY-MM)',
3264
+ example: '2024-03'
2990
3265
  },
2991
- icon: {
3266
+ income: {
2992
3267
  type: 'string',
2993
- description: 'Icon emoji',
2994
- maxLength: 10
3268
+ description: 'Income in base currency (absolute, converted)',
3269
+ example: '10000.00'
2995
3270
  },
2996
- frequency: {
3271
+ expense: {
2997
3272
  type: 'string',
2998
- description: 'Recurring frequency',
2999
- enum: [
3000
- 'WEEKLY',
3001
- 'BIWEEKLY',
3002
- 'MONTHLY',
3003
- 'BIMONTHLY',
3004
- 'QUARTERLY',
3005
- 'YEARLY',
3006
- 'CUSTOM'
3007
- ]
3008
- },
3009
- expectedAmount: {
3010
- type: 'number',
3011
- description: 'Expected amount (positive number)',
3012
- minimum: 0
3013
- },
3014
- expectedDay: {
3015
- type: 'number',
3016
- description: 'Expected day of month (1-31)',
3017
- minimum: 1,
3018
- maximum: 31
3019
- },
3020
- customIntervalDays: {
3021
- type: 'number',
3022
- description: 'Custom interval in days (required for CUSTOM frequency)',
3023
- minimum: 1
3273
+ description: 'Expense in base currency (absolute, converted)',
3274
+ example: '5000.00'
3024
3275
  },
3025
- currency: {
3276
+ netSavings: {
3026
3277
  type: 'string',
3027
- description: 'Currency code',
3028
- default: 'CNY',
3029
- maxLength: 10
3030
- },
3031
- matchPayeePattern: {
3278
+ description: 'netSavings = income − expense (savings positive)',
3279
+ example: '5000.00'
3280
+ }
3281
+ },
3282
+ required: ['month', 'income', 'expense', 'netSavings']
3283
+ } as const;
3284
+
3285
+ export const $CashFlowTrendSummaryDto = {
3286
+ type: 'object',
3287
+ properties: {
3288
+ totalIncome: {
3032
3289
  type: 'string',
3033
- description: 'Payee matching pattern (supports wildcards)',
3034
- maxLength: 200
3035
- },
3036
- matchAmountTolerance: {
3037
- type: 'number',
3038
- description: 'Amount tolerance percentage (0-1)',
3039
- default: 0.075,
3040
- minimum: 0,
3041
- maximum: 1
3290
+ description: 'Total income across the period',
3291
+ example: '60000.00'
3042
3292
  },
3043
- defaultExpenseAccount: {
3293
+ totalExpense: {
3044
3294
  type: 'string',
3045
- description: 'Default expense account for auto-create',
3046
- maxLength: 200
3295
+ description: 'Total expense across the period',
3296
+ example: '30000.00'
3047
3297
  },
3048
- defaultPaymentAccount: {
3298
+ totalNetSavings: {
3049
3299
  type: 'string',
3050
- description: 'Default payment account for auto-create',
3051
- maxLength: 200
3300
+ description: 'income − expense across the period',
3301
+ example: '30000.00'
3052
3302
  },
3053
- defaultPayee: {
3303
+ averageMonthlyNetSavings: {
3054
3304
  type: 'string',
3055
- description: 'Default payee for auto-create',
3056
- maxLength: 200
3057
- },
3058
- autoCreate: {
3059
- type: 'boolean',
3060
- description: 'Auto-create transaction when expected date arrives',
3061
- default: false
3062
- },
3063
- startDate: {
3064
- type: 'string',
3065
- description: 'Rule start date (ISO format)'
3066
- },
3067
- endDate: {
3068
- type: 'string',
3069
- description: 'Rule end date (ISO format)'
3305
+ description:
3306
+ 'totalNetSavings divided by the window length (N months, incl. zero-filled)',
3307
+ example: '5000.00'
3070
3308
  }
3071
3309
  },
3072
3310
  required: [
3073
- 'name',
3074
- 'frequency',
3075
- 'expectedAmount',
3076
- 'currency',
3077
- 'matchAmountTolerance',
3078
- 'autoCreate'
3311
+ 'totalIncome',
3312
+ 'totalExpense',
3313
+ 'totalNetSavings',
3314
+ 'averageMonthlyNetSavings'
3079
3315
  ]
3080
3316
  } as const;
3081
3317
 
3082
- export const $RecurringRuleResponseDto = {
3318
+ export const $CashFlowTrendsResponseDto = {
3083
3319
  type: 'object',
3084
3320
  properties: {
3085
- id: {
3086
- type: 'string',
3087
- description: 'Rule ID'
3321
+ series: {
3322
+ description:
3323
+ 'Monthly cash-flow series (fixed N-month window, zero-filled)',
3324
+ type: 'array',
3325
+ items: {
3326
+ $ref: '#/components/schemas/CashFlowPointDto'
3327
+ }
3088
3328
  },
3089
- userId: {
3090
- type: 'string',
3091
- description: 'User ID'
3329
+ summary: {
3330
+ description: 'Period totals',
3331
+ allOf: [
3332
+ {
3333
+ $ref: '#/components/schemas/CashFlowTrendSummaryDto'
3334
+ }
3335
+ ]
3092
3336
  },
3093
- name: {
3337
+ period: {
3094
3338
  type: 'string',
3095
- description: 'Rule name'
3096
- },
3097
- icon: {
3098
- type: 'object',
3099
- description: 'Icon emoji'
3339
+ description: 'Period requested',
3340
+ example: '6m'
3100
3341
  },
3101
- frequency: {
3342
+ granularity: {
3102
3343
  type: 'string',
3103
- description: 'Recurring frequency'
3104
- },
3105
- expectedAmount: {
3106
- type: 'number',
3107
- description: 'Expected amount'
3108
- },
3109
- expectedDay: {
3110
- type: 'object',
3111
- description: 'Expected day of month'
3344
+ description: 'Data granularity (v1 returns month buckets)',
3345
+ example: 'month'
3112
3346
  },
3113
- customIntervalDays: {
3114
- type: 'object',
3115
- description: 'Custom interval in days'
3347
+ currency: {
3348
+ type: 'string',
3349
+ description: 'Base currency for converted values',
3350
+ example: 'CNY'
3116
3351
  },
3352
+ warnings: {
3353
+ description: 'Exchange rate warnings (e.g. missing rate for a currency)',
3354
+ type: 'array',
3355
+ items: {
3356
+ $ref: '#/components/schemas/ExchangeRateWarningDto'
3357
+ }
3358
+ }
3359
+ },
3360
+ required: ['series', 'summary', 'period', 'granularity', 'currency']
3361
+ } as const;
3362
+
3363
+ export const $GenerateSnapshotBody = {
3364
+ type: 'object',
3365
+ properties: {}
3366
+ } as const;
3367
+
3368
+ export const $GenerateSnapshotResponse = {
3369
+ type: 'object',
3370
+ properties: {}
3371
+ } as const;
3372
+
3373
+ export const $BackfillSnapshotsBody = {
3374
+ type: 'object',
3375
+ properties: {}
3376
+ } as const;
3377
+
3378
+ export const $BackfillSnapshotsResponse = {
3379
+ type: 'object',
3380
+ properties: {}
3381
+ } as const;
3382
+
3383
+ export const $CreateBeanPriceDto = {
3384
+ type: 'object',
3385
+ properties: {
3117
3386
  currency: {
3118
3387
  type: 'string',
3119
- description: 'Currency code'
3388
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
3389
+ example: 'USD'
3120
3390
  },
3121
- matchPayeePattern: {
3122
- type: 'object',
3123
- description: 'Payee matching pattern'
3391
+ quoteCurrency: {
3392
+ type: 'string',
3393
+ description: 'Quote currency (pricing currency, e.g., CNY, EUR)',
3394
+ example: 'CNY'
3124
3395
  },
3125
- matchAmountTolerance: {
3396
+ amount: {
3126
3397
  type: 'number',
3127
- description: 'Amount tolerance percentage'
3398
+ description:
3399
+ 'Price amount (MUST be >= 0 per Beancount spec, supports up to 15 decimal places). Zero allowed for conversion entries, negative strictly prohibited.',
3400
+ example: 175.5,
3401
+ minimum: 0
3128
3402
  },
3129
- defaultExpenseAccount: {
3130
- type: 'object',
3131
- description: 'Default expense account'
3403
+ date: {
3404
+ type: 'string',
3405
+ description: 'Price date (ISO 8601 format)',
3406
+ example: '2024-11-05'
3132
3407
  },
3133
- defaultPaymentAccount: {
3408
+ metadata: {
3134
3409
  type: 'object',
3135
- description: 'Default payment account'
3410
+ description:
3411
+ 'Metadata (validated by Zod schema, max field lengths enforced)',
3412
+ example: {
3413
+ source: 'MANUAL',
3414
+ note: 'Bank valuation report',
3415
+ confidence: 0.95
3416
+ }
3417
+ }
3418
+ },
3419
+ required: ['currency', 'quoteCurrency', 'amount', 'date']
3420
+ } as const;
3421
+
3422
+ export const $PriceResponseDto = {
3423
+ type: 'object',
3424
+ properties: {
3425
+ id: {
3426
+ type: 'string',
3427
+ description: 'Unique identifier',
3428
+ example: 'uuid-123-456'
3136
3429
  },
3137
- defaultPayee: {
3138
- type: 'object',
3139
- description: 'Default payee'
3430
+ userId: {
3431
+ type: 'string',
3432
+ description: 'User ID (owner of the price)',
3433
+ example: 'user-123'
3140
3434
  },
3141
- isActive: {
3142
- type: 'boolean',
3143
- description: 'Whether rule is active'
3435
+ currency: {
3436
+ type: 'string',
3437
+ description: 'Currency being priced (e.g., USD, AAPL, BTC)',
3438
+ example: 'BTC'
3144
3439
  },
3145
- startDate: {
3440
+ quoteCurrency: {
3146
3441
  type: 'string',
3147
- description: 'Rule start date (YYYY-MM-DD)'
3442
+ description: 'Quote currency (pricing currency, e.g., USD, CNY)',
3443
+ example: 'USD'
3148
3444
  },
3149
- endDate: {
3150
- type: 'object',
3151
- description: 'Rule end date (YYYY-MM-DD)'
3445
+ amount: {
3446
+ type: 'number',
3447
+ description:
3448
+ 'Price amount (corresponds to Beancount Amount.number). Supports up to 15 decimal places.',
3449
+ example: 50000
3152
3450
  },
3153
- autoCreate: {
3154
- type: 'boolean',
3155
- description: 'Auto-create transaction on expected date'
3451
+ date: {
3452
+ type: 'string',
3453
+ description:
3454
+ 'Price date (ISO 8601 format). Represents the date this price was valid.',
3455
+ example: '2024-01-01',
3456
+ format: 'date'
3156
3457
  },
3157
- lastOccurrence: {
3458
+ meta: {
3158
3459
  type: 'object',
3159
- description: 'Last matched occurrence date (YYYY-MM-DD)'
3160
- },
3161
- totalCount: {
3162
- type: 'number',
3163
- description: 'Total matched transactions count'
3460
+ description:
3461
+ 'Metadata (corresponds to Beancount meta field). Contains source, confidence, note, etc.',
3462
+ example: {
3463
+ source: 'MANUAL',
3464
+ note: 'User-defined price',
3465
+ confidence: 1
3466
+ }
3164
3467
  },
3165
3468
  createdAt: {
3166
3469
  format: 'date-time',
3167
3470
  type: 'string',
3168
- description: 'Created at timestamp'
3471
+ description: 'Creation timestamp',
3472
+ example: '2024-11-03T10:00:00Z'
3169
3473
  },
3170
3474
  updatedAt: {
3171
3475
  format: 'date-time',
3172
3476
  type: 'string',
3173
- description: 'Updated at timestamp'
3477
+ description: 'Last update timestamp',
3478
+ example: '2024-11-03T10:00:00Z'
3174
3479
  }
3175
3480
  },
3176
3481
  required: [
3177
3482
  'id',
3178
3483
  'userId',
3179
- 'name',
3180
- 'frequency',
3181
- 'expectedAmount',
3182
3484
  'currency',
3183
- 'matchAmountTolerance',
3184
- 'isActive',
3185
- 'startDate',
3186
- 'autoCreate',
3187
- 'totalCount',
3485
+ 'quoteCurrency',
3486
+ 'amount',
3487
+ 'date',
3488
+ 'meta',
3188
3489
  'createdAt',
3189
3490
  'updatedAt'
3190
3491
  ]
3191
3492
  } as const;
3192
3493
 
3193
- export const $CreateRuleFromTransactionDto = {
3494
+ export const $PriceListResponseDto = {
3194
3495
  type: 'object',
3195
3496
  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'
3209
- },
3210
- name: {
3211
- type: 'string',
3212
- description: 'Optional name override (default: transaction payee)',
3213
- maxLength: 100
3497
+ items: {
3498
+ description: 'List of prices',
3499
+ type: 'array',
3500
+ items: {
3501
+ $ref: '#/components/schemas/PriceResponseDto'
3502
+ }
3214
3503
  },
3215
- icon: {
3216
- type: 'string',
3217
- description: 'Optional icon emoji',
3218
- maxLength: 10
3504
+ total: {
3505
+ type: 'number',
3506
+ description: 'Total number of prices',
3507
+ example: 42
3219
3508
  }
3220
3509
  },
3221
- required: ['frequency']
3510
+ required: ['items', 'total']
3222
3511
  } as const;
3223
3512
 
3224
- export const $RecurringRuleWithStatsResponseDto = {
3513
+ export const $UpdateBeanPriceDto = {
3225
3514
  type: 'object',
3226
3515
  properties: {
3227
- id: {
3516
+ currency: {
3228
3517
  type: 'string',
3229
- description: 'Rule ID'
3518
+ description: 'Currency being priced'
3230
3519
  },
3231
- userId: {
3520
+ quoteCurrency: {
3232
3521
  type: 'string',
3233
- description: 'User ID'
3522
+ description: 'Quote currency (pricing currency)'
3234
3523
  },
3235
- name: {
3524
+ amount: {
3525
+ type: 'number',
3526
+ description: 'Price amount (MUST be >= 0 per Beancount spec)',
3527
+ minimum: 0
3528
+ },
3529
+ date: {
3236
3530
  type: 'string',
3237
- description: 'Rule name'
3531
+ description: 'Price date (ISO 8601 format)'
3238
3532
  },
3239
- icon: {
3533
+ metadata: {
3240
3534
  type: 'object',
3241
- description: 'Icon emoji'
3242
- },
3243
- frequency: {
3535
+ description: 'Metadata'
3536
+ }
3537
+ }
3538
+ } as const;
3539
+
3540
+ export const $DeleteOwnUserDto = {
3541
+ type: 'object',
3542
+ properties: {
3543
+ accessToken: {
3244
3544
  type: 'string',
3245
- description: 'Recurring frequency'
3246
- },
3247
- expectedAmount: {
3248
- type: 'number',
3249
- description: 'Expected amount'
3545
+ description: 'Access token for user verification',
3546
+ example: 'abc123xyz'
3547
+ }
3548
+ },
3549
+ required: ['accessToken']
3550
+ } as const;
3551
+
3552
+ export const $UserSettingsResponseDto = {
3553
+ type: 'object',
3554
+ properties: {
3555
+ baseCurrency: {
3556
+ type: 'string',
3557
+ description:
3558
+ '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).',
3559
+ example: 'USD',
3560
+ nullable: true
3561
+ }
3562
+ },
3563
+ required: ['baseCurrency']
3564
+ } as const;
3565
+
3566
+ export const $UserResponseDto = {
3567
+ type: 'object',
3568
+ properties: {
3569
+ id: {
3570
+ type: 'string',
3571
+ description: 'User ID'
3250
3572
  },
3251
- expectedDay: {
3252
- type: 'object',
3253
- description: 'Expected day of month'
3573
+ role: {
3574
+ type: 'string',
3575
+ description: 'Assigned user role'
3254
3576
  },
3255
- customIntervalDays: {
3256
- type: 'object',
3257
- description: 'Custom interval in days'
3577
+ permissions: {
3578
+ description: 'Permission strings',
3579
+ type: 'array',
3580
+ items: {
3581
+ type: 'string'
3582
+ }
3258
3583
  },
3259
- currency: {
3584
+ settings: {
3585
+ description: 'User settings',
3586
+ allOf: [
3587
+ {
3588
+ $ref: '#/components/schemas/UserSettingsResponseDto'
3589
+ }
3590
+ ]
3591
+ }
3592
+ },
3593
+ required: ['id', 'role', 'permissions', 'settings']
3594
+ } as const;
3595
+
3596
+ export const $SignupDto = {
3597
+ type: 'object',
3598
+ properties: {
3599
+ turnstileToken: {
3260
3600
  type: 'string',
3261
- description: 'Currency code'
3601
+ description:
3602
+ 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
3603
+ example: '0.abc123def456...'
3604
+ }
3605
+ }
3606
+ } as const;
3607
+
3608
+ export const $SignupResponseDto = {
3609
+ type: 'object',
3610
+ properties: {
3611
+ authToken: {
3612
+ type: 'string',
3613
+ description: 'JWT auth token',
3614
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
3262
3615
  },
3263
- matchPayeePattern: {
3264
- type: 'object',
3265
- description: 'Payee matching pattern'
3616
+ accessToken: {
3617
+ type: 'string',
3618
+ description: 'Auto-generated access token'
3266
3619
  },
3267
- matchAmountTolerance: {
3620
+ role: {
3621
+ type: 'string',
3622
+ description: 'Assigned user role',
3623
+ enum: ['USER', 'ADMIN', 'DEMO', 'INACTIVE', 'PAID', 'OPS']
3624
+ }
3625
+ },
3626
+ required: ['authToken', 'accessToken', 'role']
3627
+ } as const;
3628
+
3629
+ export const $UpdateUserSettingDto = {
3630
+ type: 'object',
3631
+ properties: {
3632
+ secId: {
3268
3633
  type: 'number',
3269
- description: 'Amount tolerance percentage'
3634
+ description: 'Security ID'
3270
3635
  },
3271
- defaultExpenseAccount: {
3272
- type: 'object',
3273
- description: 'Default expense account'
3636
+ annualInterestRate: {
3637
+ type: 'number',
3638
+ description: 'Annual interest rate',
3639
+ example: 0.05
3274
3640
  },
3275
- defaultPaymentAccount: {
3276
- type: 'object',
3277
- description: 'Default payment account'
3641
+ currency: {
3642
+ type: 'string',
3643
+ description: 'Currency code',
3644
+ example: 'USD'
3278
3645
  },
3279
- defaultPayee: {
3280
- type: 'object',
3281
- description: 'Default payee'
3646
+ baseCurrency: {
3647
+ type: 'string',
3648
+ description: 'Base currency code',
3649
+ example: 'USD'
3282
3650
  },
3283
- isActive: {
3284
- type: 'boolean',
3285
- description: 'Whether rule is active'
3651
+ benchmark: {
3652
+ type: 'string',
3653
+ description: 'Benchmark symbol',
3654
+ example: 'SPY'
3286
3655
  },
3287
- startDate: {
3656
+ colorScheme: {
3288
3657
  type: 'string',
3289
- description: 'Rule start date (YYYY-MM-DD)'
3658
+ description: 'Color scheme',
3659
+ enum: ['DARK', 'LIGHT']
3290
3660
  },
3291
- endDate: {
3292
- type: 'object',
3293
- description: 'Rule end date (YYYY-MM-DD)'
3661
+ dateRange: {
3662
+ type: 'string',
3663
+ description: 'Date range filter',
3664
+ example: '1y'
3294
3665
  },
3295
- autoCreate: {
3296
- type: 'boolean',
3297
- description: 'Auto-create transaction on expected date'
3666
+ emergencyFund: {
3667
+ type: 'number',
3668
+ description: 'Emergency fund amount',
3669
+ example: 10000
3298
3670
  },
3299
- lastOccurrence: {
3300
- type: 'object',
3301
- description: 'Last matched occurrence date (YYYY-MM-DD)'
3671
+ 'filters.accounts': {
3672
+ description: 'Account filter IDs',
3673
+ type: 'array',
3674
+ items: {
3675
+ type: 'string'
3676
+ }
3302
3677
  },
3303
- totalCount: {
3304
- type: 'number',
3305
- description: 'Total matched transactions count'
3678
+ 'filters.assetClasses': {
3679
+ description: 'Asset class filters',
3680
+ type: 'array',
3681
+ items: {
3682
+ type: 'string'
3683
+ }
3306
3684
  },
3307
- createdAt: {
3308
- format: 'date-time',
3685
+ 'filters.dataSource': {
3309
3686
  type: 'string',
3310
- description: 'Created at timestamp'
3687
+ description: 'Data source filter'
3311
3688
  },
3312
- updatedAt: {
3313
- format: 'date-time',
3689
+ 'filters.symbol': {
3314
3690
  type: 'string',
3315
- description: 'Updated at timestamp'
3691
+ description: 'Symbol filter'
3316
3692
  },
3317
- pendingCount: {
3318
- type: 'number',
3319
- description: 'Number of pending expected transactions'
3693
+ 'filters.tags': {
3694
+ description: 'Tag filters',
3695
+ type: 'array',
3696
+ items: {
3697
+ type: 'string'
3698
+ }
3320
3699
  },
3321
- overdueCount: {
3322
- type: 'number',
3323
- description: 'Number of overdue expected transactions'
3700
+ isExperimentalFeatures: {
3701
+ type: 'boolean',
3702
+ description: 'Enable experimental features'
3324
3703
  },
3325
- nextExpectedDate: {
3326
- type: 'object',
3327
- description: 'Next expected date (YYYY-MM-DD)'
3704
+ isRestrictedView: {
3705
+ type: 'boolean',
3706
+ description: 'Enable restricted view mode'
3328
3707
  },
3329
- totalAmount: {
3330
- type: 'number',
3331
- description: 'Total amount of all matched transactions'
3708
+ language: {
3709
+ type: 'string',
3710
+ description: 'Language code',
3711
+ example: 'en'
3332
3712
  },
3333
- averageAmount: {
3334
- type: 'number',
3335
- description: 'Average amount per transaction'
3713
+ locale: {
3714
+ type: 'string',
3715
+ description: 'Locale code',
3716
+ example: 'en-US'
3336
3717
  },
3337
- transactionCount: {
3718
+ projectedTotalAmount: {
3338
3719
  type: 'number',
3339
- description: 'Number of matched transactions'
3340
- },
3341
- firstDate: {
3342
- type: 'object',
3343
- description: 'First matched transaction date (YYYY-MM-DD)'
3720
+ description: 'Projected total amount',
3721
+ example: 1000000
3344
3722
  },
3345
- lastDate: {
3346
- type: 'object',
3347
- description: 'Last matched transaction date (YYYY-MM-DD)'
3723
+ retirementDate: {
3724
+ type: 'string',
3725
+ description: 'Retirement date in ISO 8601 format',
3726
+ example: '2050-01-01'
3348
3727
  },
3349
- variance: {
3728
+ savingsRate: {
3350
3729
  type: 'number',
3351
- description: 'Amount variance (standard deviation squared)'
3730
+ description: 'Savings rate percentage',
3731
+ example: 0.2
3352
3732
  },
3353
- upcomingCount: {
3354
- type: 'number',
3355
- description: 'Number of upcoming expected transactions'
3733
+ viewMode: {
3734
+ type: 'string',
3735
+ description: 'View mode',
3736
+ enum: ['DEFAULT', 'ZEN']
3737
+ }
3738
+ }
3739
+ } as const;
3740
+
3741
+ export const $UpdatePropertyDto = {
3742
+ type: 'object',
3743
+ properties: {
3744
+ value: {
3745
+ type: 'string',
3746
+ description: 'Property value'
3356
3747
  }
3357
3748
  },
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
- ]
3749
+ required: ['value']
3380
3750
  } as const;
3381
3751
 
3382
- export const $UpdateRecurringRuleDto = {
3752
+ export const $CreateRecurringRuleDto = {
3383
3753
  type: 'object',
3384
3754
  properties: {
3385
3755
  name: {
3386
3756
  type: 'string',
3387
- description: 'Rule name',
3757
+ description: 'Rule name (unique per user)',
3388
3758
  maxLength: 100
3389
3759
  },
3390
3760
  icon: {
@@ -3407,7 +3777,7 @@ export const $UpdateRecurringRuleDto = {
3407
3777
  },
3408
3778
  expectedAmount: {
3409
3779
  type: 'number',
3410
- description: 'Expected amount',
3780
+ description: 'Expected amount (positive number)',
3411
3781
  minimum: 0
3412
3782
  },
3413
3783
  expectedDay: {
@@ -3418,7 +3788,7 @@ export const $UpdateRecurringRuleDto = {
3418
3788
  },
3419
3789
  customIntervalDays: {
3420
3790
  type: 'number',
3421
- description: 'Custom interval in days',
3791
+ description: 'Custom interval in days (required for CUSTOM frequency)',
3422
3792
  minimum: 1
3423
3793
  },
3424
3794
  currency: {
@@ -3428,118 +3798,136 @@ export const $UpdateRecurringRuleDto = {
3428
3798
  },
3429
3799
  matchPayeePattern: {
3430
3800
  type: 'string',
3431
- description: 'Payee matching pattern',
3801
+ description: 'Payee matching pattern (supports wildcards)',
3432
3802
  maxLength: 200
3433
3803
  },
3434
3804
  matchAmountTolerance: {
3435
3805
  type: 'number',
3436
3806
  description: 'Amount tolerance percentage (0-1)',
3807
+ default: 0.075,
3437
3808
  minimum: 0,
3438
3809
  maximum: 1
3439
3810
  },
3440
3811
  defaultExpenseAccount: {
3441
3812
  type: 'string',
3442
- description: 'Default expense account',
3813
+ description: 'Default expense account for auto-create',
3443
3814
  maxLength: 200
3444
3815
  },
3445
3816
  defaultPaymentAccount: {
3446
3817
  type: 'string',
3447
- description: 'Default payment account',
3818
+ description: 'Default payment account for auto-create',
3448
3819
  maxLength: 200
3449
3820
  },
3450
3821
  defaultPayee: {
3451
3822
  type: 'string',
3452
- description: 'Default payee',
3823
+ description: 'Default payee for auto-create',
3453
3824
  maxLength: 200
3454
3825
  },
3455
3826
  autoCreate: {
3456
3827
  type: 'boolean',
3457
- description: 'Auto-create transaction'
3828
+ description: 'Auto-create transaction when expected date arrives',
3829
+ default: false
3458
3830
  },
3459
- isActive: {
3460
- type: 'boolean',
3461
- description: 'Rule active status'
3831
+ startDate: {
3832
+ type: 'string',
3833
+ description: 'Rule start date (ISO format)'
3462
3834
  },
3463
3835
  endDate: {
3464
3836
  type: 'string',
3465
3837
  description: 'Rule end date (ISO format)'
3466
3838
  }
3467
- }
3468
- } as const;
3469
-
3470
- export const $ExpectedTransactionRuleDto = {
3471
- type: 'object',
3472
- properties: {
3473
- name: {
3474
- type: 'string',
3475
- description: 'Rule name'
3476
- },
3477
- icon: {
3478
- type: 'object',
3479
- description: 'Rule icon'
3480
- },
3481
- frequency: {
3482
- type: 'string',
3483
- description: 'Rule frequency'
3484
- },
3485
- currency: {
3486
- type: 'string',
3487
- description: 'Currency code'
3488
- }
3489
3839
  },
3490
- required: ['name', 'frequency', 'currency']
3840
+ required: [
3841
+ 'name',
3842
+ 'frequency',
3843
+ 'expectedAmount',
3844
+ 'matchAmountTolerance',
3845
+ 'autoCreate'
3846
+ ]
3491
3847
  } as const;
3492
3848
 
3493
- export const $ExpectedTransactionResponseDto = {
3849
+ export const $RecurringRuleResponseDto = {
3494
3850
  type: 'object',
3495
3851
  properties: {
3496
3852
  id: {
3497
3853
  type: 'string',
3498
- description: 'Expected transaction ID'
3854
+ description: 'Rule ID'
3499
3855
  },
3500
3856
  userId: {
3501
3857
  type: 'string',
3502
3858
  description: 'User ID'
3503
3859
  },
3504
- ruleId: {
3860
+ name: {
3505
3861
  type: 'string',
3506
- description: 'Associated rule ID'
3862
+ description: 'Rule name'
3507
3863
  },
3508
- expectedDate: {
3864
+ icon: {
3865
+ type: 'object',
3866
+ description: 'Icon emoji'
3867
+ },
3868
+ frequency: {
3509
3869
  type: 'string',
3510
- description: 'Expected date (YYYY-MM-DD)'
3870
+ description: 'Recurring frequency'
3511
3871
  },
3512
3872
  expectedAmount: {
3513
3873
  type: 'number',
3514
3874
  description: 'Expected amount'
3515
3875
  },
3516
- status: {
3876
+ expectedDay: {
3877
+ type: 'object',
3878
+ description: 'Expected day of month'
3879
+ },
3880
+ customIntervalDays: {
3881
+ type: 'object',
3882
+ description: 'Custom interval in days'
3883
+ },
3884
+ currency: {
3517
3885
  type: 'string',
3518
- description: 'Status (PENDING, COMPLETED, SKIPPED)'
3886
+ description: 'Currency code'
3519
3887
  },
3520
- matchedTransactionId: {
3888
+ matchPayeePattern: {
3521
3889
  type: 'object',
3522
- description: 'Matched transaction ID'
3890
+ description: 'Payee matching pattern'
3523
3891
  },
3524
- matchedAt: {
3892
+ matchAmountTolerance: {
3893
+ type: 'number',
3894
+ description: 'Amount tolerance percentage'
3895
+ },
3896
+ defaultExpenseAccount: {
3525
3897
  type: 'object',
3526
- description: 'Match timestamp (ISO 8601)'
3898
+ description: 'Default expense account'
3527
3899
  },
3528
- matchConfidence: {
3900
+ defaultPaymentAccount: {
3529
3901
  type: 'object',
3530
- description: 'Match confidence score (0-1)'
3902
+ description: 'Default payment account'
3531
3903
  },
3532
- isOverdue: {
3904
+ defaultPayee: {
3905
+ type: 'object',
3906
+ description: 'Default payee'
3907
+ },
3908
+ isActive: {
3533
3909
  type: 'boolean',
3534
- description: 'Whether this expected transaction is overdue'
3910
+ description: 'Whether rule is active'
3535
3911
  },
3536
- rule: {
3537
- description: 'Rule information',
3538
- allOf: [
3539
- {
3540
- $ref: '#/components/schemas/ExpectedTransactionRuleDto'
3541
- }
3542
- ]
3912
+ startDate: {
3913
+ type: 'string',
3914
+ description: 'Rule start date (YYYY-MM-DD)'
3915
+ },
3916
+ endDate: {
3917
+ type: 'object',
3918
+ description: 'Rule end date (YYYY-MM-DD)'
3919
+ },
3920
+ autoCreate: {
3921
+ type: 'boolean',
3922
+ description: 'Auto-create transaction on expected date'
3923
+ },
3924
+ lastOccurrence: {
3925
+ type: 'object',
3926
+ description: 'Last matched occurrence date (YYYY-MM-DD)'
3927
+ },
3928
+ totalCount: {
3929
+ type: 'number',
3930
+ description: 'Total matched transactions count'
3543
3931
  },
3544
3932
  createdAt: {
3545
3933
  format: 'date-time',
@@ -3555,647 +3943,581 @@ export const $ExpectedTransactionResponseDto = {
3555
3943
  required: [
3556
3944
  'id',
3557
3945
  'userId',
3558
- 'ruleId',
3559
- 'expectedDate',
3946
+ 'name',
3947
+ 'frequency',
3560
3948
  'expectedAmount',
3561
- 'status',
3562
- 'isOverdue',
3563
- 'rule',
3949
+ 'currency',
3950
+ 'matchAmountTolerance',
3951
+ 'isActive',
3952
+ 'startDate',
3953
+ 'autoCreate',
3954
+ 'totalCount',
3564
3955
  'createdAt',
3565
3956
  'updatedAt'
3566
3957
  ]
3567
3958
  } as const;
3568
3959
 
3569
- export const $ExpectedTransactionListResponseDto = {
3960
+ export const $CreateRuleFromTransactionDto = {
3570
3961
  type: 'object',
3571
3962
  properties: {
3572
- items: {
3573
- type: 'array',
3574
- items: {
3575
- $ref: '#/components/schemas/ExpectedTransactionResponseDto'
3576
- }
3963
+ frequency: {
3964
+ type: 'string',
3965
+ description: 'Recurring frequency',
3966
+ enum: [
3967
+ 'WEEKLY',
3968
+ 'BIWEEKLY',
3969
+ 'MONTHLY',
3970
+ 'BIMONTHLY',
3971
+ 'QUARTERLY',
3972
+ 'YEARLY',
3973
+ 'CUSTOM'
3974
+ ],
3975
+ example: 'MONTHLY'
3577
3976
  },
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: {
3977
+ name: {
3590
3978
  type: 'string',
3591
- description: 'Transaction ID to match with'
3979
+ description: 'Optional name override (default: transaction payee)',
3980
+ maxLength: 100
3981
+ },
3982
+ icon: {
3983
+ type: 'string',
3984
+ description: 'Optional icon emoji',
3985
+ maxLength: 10
3592
3986
  }
3593
3987
  },
3594
- required: ['transactionId']
3988
+ required: ['frequency']
3595
3989
  } as const;
3596
3990
 
3597
- export const $EnterNowDto = {
3991
+ export const $RecurringRuleWithStatsResponseDto = {
3598
3992
  type: 'object',
3599
3993
  properties: {
3600
- expenseAccount: {
3994
+ id: {
3601
3995
  type: 'string',
3602
- description:
3603
- 'Override expense account (uses rule default if not provided)',
3604
- maxLength: 200
3996
+ description: 'Rule ID'
3605
3997
  },
3606
- paymentAccount: {
3998
+ userId: {
3607
3999
  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
4000
+ description: 'User ID'
3616
4001
  },
3617
- payee: {
4002
+ name: {
3618
4003
  type: 'string',
3619
- description: 'Override payee (uses rule default if not provided)',
3620
- maxLength: 200
4004
+ description: 'Rule name'
3621
4005
  },
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: {
3634
- type: 'string',
3635
- description: 'Rule name',
3636
- example: 'Rent'
4006
+ icon: {
4007
+ type: 'object',
4008
+ description: 'Icon emoji'
3637
4009
  },
3638
- ruleId: {
4010
+ frequency: {
3639
4011
  type: 'string',
3640
- description: 'Rule ID',
3641
- example: 'clx123...'
4012
+ description: 'Recurring frequency'
3642
4013
  },
3643
- amount: {
4014
+ expectedAmount: {
3644
4015
  type: 'number',
3645
- description: 'Expected amount',
3646
- example: 3000
4016
+ description: 'Expected amount'
3647
4017
  },
3648
- date: {
3649
- type: 'string',
3650
- description: 'Expected date (YYYY-MM-DD)',
3651
- example: '2024-04-01'
4018
+ expectedDay: {
4019
+ type: 'object',
4020
+ description: 'Expected day of month'
3652
4021
  },
3653
- icon: {
3654
- type: 'string',
3655
- description: 'Rule icon emoji',
3656
- example: '🏠',
3657
- nullable: true
4022
+ customIntervalDays: {
4023
+ type: 'object',
4024
+ description: 'Custom interval in days'
3658
4025
  },
3659
4026
  currency: {
3660
4027
  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'
4028
+ description: 'Currency code'
3675
4029
  },
3676
- expectedOutflow: {
3677
- type: 'number',
3678
- description: 'Total expected outflow for the month',
3679
- example: 8500
4030
+ matchPayeePattern: {
4031
+ type: 'object',
4032
+ description: 'Payee matching pattern'
3680
4033
  },
3681
- itemCount: {
4034
+ matchAmountTolerance: {
3682
4035
  type: 'number',
3683
- description: 'Number of expected transactions',
3684
- example: 3
4036
+ description: 'Amount tolerance percentage'
3685
4037
  },
3686
- byCurrency: {
4038
+ defaultExpenseAccount: {
3687
4039
  type: 'object',
3688
- description: 'Breakdown by currency',
3689
- example: {
3690
- CNY: 8500,
3691
- USD: 100
3692
- }
4040
+ description: 'Default expense account'
3693
4041
  },
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
- }
4042
+ defaultPaymentAccount: {
4043
+ type: 'object',
4044
+ description: 'Default payment account'
3714
4045
  },
3715
- totalOutflow: {
3716
- type: 'number',
3717
- description: 'Total expected outflow across all months',
3718
- example: 25500
4046
+ defaultPayee: {
4047
+ type: 'object',
4048
+ description: 'Default payee'
3719
4049
  },
3720
- totalByCurrency: {
4050
+ isActive: {
4051
+ type: 'boolean',
4052
+ description: 'Whether rule is active'
4053
+ },
4054
+ startDate: {
4055
+ type: 'string',
4056
+ description: 'Rule start date (YYYY-MM-DD)'
4057
+ },
4058
+ endDate: {
3721
4059
  type: 'object',
3722
- description: 'Total by currency across all months',
3723
- example: {
3724
- CNY: 25500,
3725
- USD: 300
3726
- }
4060
+ description: 'Rule end date (YYYY-MM-DD)'
3727
4061
  },
3728
- rulesCount: {
4062
+ autoCreate: {
4063
+ type: 'boolean',
4064
+ description: 'Auto-create transaction on expected date'
4065
+ },
4066
+ lastOccurrence: {
4067
+ type: 'object',
4068
+ description: 'Last matched occurrence date (YYYY-MM-DD)'
4069
+ },
4070
+ totalCount: {
3729
4071
  type: 'number',
3730
- description: 'Number of active recurring rules included',
3731
- example: 5
4072
+ description: 'Total matched transactions count'
3732
4073
  },
3733
- periodStart: {
4074
+ createdAt: {
4075
+ format: 'date-time',
3734
4076
  type: 'string',
3735
- description: 'Forecast period start date',
3736
- example: '2024-04-01'
4077
+ description: 'Created at timestamp'
3737
4078
  },
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 $CurrencyBalanceDto = {
3755
- type: 'object',
3756
- properties: {
3757
- currency: {
4079
+ updatedAt: {
4080
+ format: 'date-time',
3758
4081
  type: 'string',
3759
- description: 'ISO 4217 currency code',
3760
- example: 'CNY'
4082
+ description: 'Updated at timestamp'
3761
4083
  },
3762
- balance: {
3763
- type: 'string',
3764
- description: 'Balance amount',
3765
- example: '500000.00'
3766
- }
3767
- },
3768
- required: ['currency', 'balance']
3769
- } as const;
3770
-
3771
- export const $TimeSeriesPointDto = {
3772
- type: 'object',
3773
- properties: {
3774
- date: {
3775
- type: 'string',
3776
- description: 'Date in YYYY-MM-DD format',
3777
- example: '2024-06-15'
4084
+ pendingCount: {
4085
+ type: 'number',
4086
+ description: 'Number of pending expected transactions'
3778
4087
  },
3779
- value: {
3780
- type: 'string',
3781
- description: 'Value at this date (in base currency)',
3782
- example: '500000.00'
4088
+ overdueCount: {
4089
+ type: 'number',
4090
+ description: 'Number of overdue expected transactions'
3783
4091
  },
3784
- change: {
4092
+ nextExpectedDate: {
3785
4093
  type: 'object',
3786
- description: 'Change from previous point',
3787
- example: '5000.00'
4094
+ description: 'Next expected date (YYYY-MM-DD)'
3788
4095
  },
3789
- assets: {
3790
- type: 'string',
3791
- description: 'Total assets at this date (in base currency)',
3792
- example: '494338.00'
4096
+ totalAmount: {
4097
+ type: 'number',
4098
+ description: 'Total amount of all matched transactions'
3793
4099
  },
3794
- liabilities: {
3795
- type: 'string',
3796
- description: 'Total liabilities at this date (in base currency)',
3797
- example: '310098.00'
4100
+ averageAmount: {
4101
+ type: 'number',
4102
+ description: 'Average amount per transaction'
3798
4103
  },
3799
- byCurrency: {
3800
- description: 'Multi-currency breakdown for this point',
3801
- type: 'array',
3802
- items: {
3803
- $ref: '#/components/schemas/CurrencyBalanceDto'
3804
- }
4104
+ transactionCount: {
4105
+ type: 'number',
4106
+ description: 'Number of matched transactions'
4107
+ },
4108
+ firstDate: {
4109
+ type: 'object',
4110
+ description: 'First matched transaction date (YYYY-MM-DD)'
4111
+ },
4112
+ lastDate: {
4113
+ type: 'object',
4114
+ description: 'Last matched transaction date (YYYY-MM-DD)'
4115
+ },
4116
+ variance: {
4117
+ type: 'number',
4118
+ description: 'Amount variance (standard deviation squared)'
4119
+ },
4120
+ upcomingCount: {
4121
+ type: 'number',
4122
+ description: 'Number of upcoming expected transactions'
3805
4123
  }
3806
4124
  },
3807
- required: ['date', 'value']
4125
+ required: [
4126
+ 'id',
4127
+ 'userId',
4128
+ 'name',
4129
+ 'frequency',
4130
+ 'expectedAmount',
4131
+ 'currency',
4132
+ 'matchAmountTolerance',
4133
+ 'isActive',
4134
+ 'startDate',
4135
+ 'autoCreate',
4136
+ 'totalCount',
4137
+ 'createdAt',
4138
+ 'updatedAt',
4139
+ 'pendingCount',
4140
+ 'overdueCount',
4141
+ 'totalAmount',
4142
+ 'averageAmount',
4143
+ 'transactionCount',
4144
+ 'variance',
4145
+ 'upcomingCount'
4146
+ ]
3808
4147
  } as const;
3809
4148
 
3810
- export const $TrendSummaryDto = {
4149
+ export const $UpdateRecurringRuleDto = {
3811
4150
  type: 'object',
3812
4151
  properties: {
3813
- startValue: {
4152
+ name: {
3814
4153
  type: 'string',
3815
- description: 'Value at start of period',
3816
- example: '450000.00'
4154
+ description: 'Rule name (unique per user)',
4155
+ maxLength: 100
3817
4156
  },
3818
- endValue: {
4157
+ icon: {
3819
4158
  type: 'string',
3820
- description: 'Value at end of period',
3821
- example: '500000.00'
4159
+ description: 'Icon emoji',
4160
+ maxLength: 10
4161
+ },
4162
+ frequency: {
4163
+ type: 'string',
4164
+ description: 'Recurring frequency',
4165
+ enum: [
4166
+ 'WEEKLY',
4167
+ 'BIWEEKLY',
4168
+ 'MONTHLY',
4169
+ 'BIMONTHLY',
4170
+ 'QUARTERLY',
4171
+ 'YEARLY',
4172
+ 'CUSTOM'
4173
+ ]
4174
+ },
4175
+ expectedAmount: {
4176
+ type: 'number',
4177
+ description: 'Expected amount (positive number)',
4178
+ minimum: 0
4179
+ },
4180
+ expectedDay: {
4181
+ type: 'number',
4182
+ description: 'Expected day of month (1-31)',
4183
+ minimum: 1,
4184
+ maximum: 31
3822
4185
  },
3823
- totalChange: {
4186
+ currency: {
3824
4187
  type: 'string',
3825
- description: 'Total change over period',
3826
- example: '50000.00'
4188
+ description: 'Currency code',
4189
+ maxLength: 10
3827
4190
  },
3828
- totalChangePercentage: {
3829
- type: 'string',
3830
- description: 'Total change percentage',
3831
- example: '+11.11%'
3832
- }
3833
- },
3834
- required: ['startValue', 'endValue', 'totalChange', 'totalChangePercentage']
3835
- } as const;
3836
-
3837
- export const $MultiCurrencyPointDto = {
3838
- type: 'object',
3839
- properties: {
3840
- date: {
4191
+ matchPayeePattern: {
3841
4192
  type: 'string',
3842
- description: 'Date in YYYY-MM-DD format',
3843
- example: '2024-06-15'
4193
+ description: 'Payee matching pattern (supports wildcards)',
4194
+ maxLength: 200
3844
4195
  },
3845
- byCurrency: {
3846
- description: 'Balances by currency',
3847
- type: 'array',
3848
- items: {
3849
- $ref: '#/components/schemas/CurrencyBalanceDto'
3850
- }
3851
- }
3852
- },
3853
- required: ['date', 'byCurrency']
3854
- } as const;
3855
-
3856
- export const $PortfolioTrendsResponseDto = {
3857
- type: 'object',
3858
- properties: {
3859
- series: {
3860
- description: 'Time series data points',
3861
- type: 'array',
3862
- items: {
3863
- $ref: '#/components/schemas/TimeSeriesPointDto'
3864
- }
4196
+ matchAmountTolerance: {
4197
+ type: 'number',
4198
+ description: 'Amount tolerance percentage (0-1)',
4199
+ default: 0.075,
4200
+ minimum: 0,
4201
+ maximum: 1
3865
4202
  },
3866
- summary: {
3867
- description: 'Period summary',
3868
- allOf: [
3869
- {
3870
- $ref: '#/components/schemas/TrendSummaryDto'
3871
- }
3872
- ]
4203
+ defaultExpenseAccount: {
4204
+ type: 'string',
4205
+ description: 'Default expense account for auto-create',
4206
+ maxLength: 200
3873
4207
  },
3874
- period: {
4208
+ defaultPaymentAccount: {
3875
4209
  type: 'string',
3876
- description: 'Period requested',
3877
- example: '6m'
4210
+ description: 'Default payment account for auto-create',
4211
+ maxLength: 200
3878
4212
  },
3879
- granularity: {
4213
+ defaultPayee: {
3880
4214
  type: 'string',
3881
- description: 'Data granularity',
3882
- example: 'month'
4215
+ description: 'Default payee for auto-create',
4216
+ maxLength: 200
3883
4217
  },
3884
- currency: {
4218
+ autoCreate: {
4219
+ type: 'boolean',
4220
+ description: 'Auto-create transaction when expected date arrives',
4221
+ default: false
4222
+ },
4223
+ endDate: {
3885
4224
  type: 'string',
3886
- description: 'Base currency for converted values',
3887
- example: 'CNY'
4225
+ description: 'Rule end date (ISO format)'
3888
4226
  },
3889
- byCurrency: {
3890
- description:
3891
- 'Multi-currency time series (each point has currency breakdown)',
3892
- type: 'array',
3893
- items: {
3894
- $ref: '#/components/schemas/MultiCurrencyPointDto'
3895
- }
4227
+ customIntervalDays: {
4228
+ type: 'number',
4229
+ description: 'Custom interval in days',
4230
+ minimum: 1
3896
4231
  },
3897
- warnings: {
3898
- description: 'Exchange rate warnings',
3899
- type: 'array',
3900
- items: {
3901
- $ref: '#/components/schemas/ExchangeRateWarningDto'
3902
- }
4232
+ isActive: {
4233
+ type: 'boolean',
4234
+ description: 'Rule active status'
3903
4235
  }
3904
- },
3905
- required: ['series', 'summary', 'period', 'granularity', 'currency']
4236
+ }
3906
4237
  } as const;
3907
4238
 
3908
- export const $CashFlowPointDto = {
4239
+ export const $ExpectedTransactionRuleDto = {
3909
4240
  type: 'object',
3910
4241
  properties: {
3911
- month: {
4242
+ name: {
3912
4243
  type: 'string',
3913
- description: 'Month key (YYYY-MM)',
3914
- example: '2024-03'
4244
+ description: 'Rule name'
3915
4245
  },
3916
- income: {
3917
- type: 'string',
3918
- description: 'Income in base currency (absolute, converted)',
3919
- example: '10000.00'
4246
+ icon: {
4247
+ type: 'object',
4248
+ description: 'Rule icon'
3920
4249
  },
3921
- expense: {
4250
+ frequency: {
3922
4251
  type: 'string',
3923
- description: 'Expense in base currency (absolute, converted)',
3924
- example: '5000.00'
4252
+ description: 'Rule frequency'
3925
4253
  },
3926
- netSavings: {
4254
+ currency: {
3927
4255
  type: 'string',
3928
- description: 'netSavings = income − expense (savings positive)',
3929
- example: '5000.00'
4256
+ description: 'Currency code'
3930
4257
  }
3931
4258
  },
3932
- required: ['month', 'income', 'expense', 'netSavings']
4259
+ required: ['name', 'frequency', 'currency']
3933
4260
  } as const;
3934
4261
 
3935
- export const $CashFlowTrendSummaryDto = {
4262
+ export const $ExpectedTransactionResponseDto = {
3936
4263
  type: 'object',
3937
4264
  properties: {
3938
- totalIncome: {
4265
+ id: {
3939
4266
  type: 'string',
3940
- description: 'Total income across the period',
3941
- example: '60000.00'
4267
+ description: 'Expected transaction ID'
3942
4268
  },
3943
- totalExpense: {
4269
+ userId: {
3944
4270
  type: 'string',
3945
- description: 'Total expense across the period',
3946
- example: '30000.00'
4271
+ description: 'User ID'
3947
4272
  },
3948
- totalNetSavings: {
4273
+ ruleId: {
3949
4274
  type: 'string',
3950
- description: 'income − expense across the period',
3951
- example: '30000.00'
4275
+ description: 'Associated rule ID'
3952
4276
  },
3953
- averageMonthlyNetSavings: {
4277
+ expectedDate: {
3954
4278
  type: 'string',
3955
- description:
3956
- 'totalNetSavings divided by the window length (N months, incl. zero-filled)',
3957
- example: '5000.00'
3958
- }
3959
- },
3960
- required: [
3961
- 'totalIncome',
3962
- 'totalExpense',
3963
- 'totalNetSavings',
3964
- 'averageMonthlyNetSavings'
3965
- ]
3966
- } as const;
3967
-
3968
- export const $CashFlowTrendsResponseDto = {
3969
- type: 'object',
3970
- properties: {
3971
- series: {
3972
- description:
3973
- 'Monthly cash-flow series (fixed N-month window, zero-filled)',
3974
- type: 'array',
3975
- items: {
3976
- $ref: '#/components/schemas/CashFlowPointDto'
3977
- }
4279
+ description: 'Expected date (YYYY-MM-DD)'
3978
4280
  },
3979
- summary: {
3980
- description: 'Period totals',
4281
+ expectedAmount: {
4282
+ type: 'number',
4283
+ description: 'Expected amount'
4284
+ },
4285
+ status: {
4286
+ type: 'string',
4287
+ description: 'Status (PENDING, COMPLETED, SKIPPED)'
4288
+ },
4289
+ matchedTransactionId: {
4290
+ type: 'object',
4291
+ description: 'Matched transaction ID'
4292
+ },
4293
+ matchedAt: {
4294
+ type: 'object',
4295
+ description: 'Match timestamp (ISO 8601)'
4296
+ },
4297
+ matchConfidence: {
4298
+ type: 'object',
4299
+ description: 'Match confidence score (0-1)'
4300
+ },
4301
+ isOverdue: {
4302
+ type: 'boolean',
4303
+ description: 'Whether this expected transaction is overdue'
4304
+ },
4305
+ rule: {
4306
+ description: 'Rule information',
3981
4307
  allOf: [
3982
4308
  {
3983
- $ref: '#/components/schemas/CashFlowTrendSummaryDto'
4309
+ $ref: '#/components/schemas/ExpectedTransactionRuleDto'
3984
4310
  }
3985
4311
  ]
3986
4312
  },
3987
- period: {
3988
- type: 'string',
3989
- description: 'Period requested',
3990
- example: '6m'
3991
- },
3992
- granularity: {
4313
+ createdAt: {
4314
+ format: 'date-time',
3993
4315
  type: 'string',
3994
- description: 'Data granularity (v1 returns month buckets)',
3995
- example: 'month'
4316
+ description: 'Created at timestamp'
3996
4317
  },
3997
- currency: {
4318
+ updatedAt: {
4319
+ format: 'date-time',
3998
4320
  type: 'string',
3999
- description: 'Base currency for converted values',
4000
- example: 'CNY'
4001
- },
4002
- warnings: {
4003
- description: 'Exchange rate warnings (e.g. missing rate for a currency)',
4004
- type: 'array',
4005
- items: {
4006
- $ref: '#/components/schemas/ExchangeRateWarningDto'
4007
- }
4321
+ description: 'Updated at timestamp'
4008
4322
  }
4009
4323
  },
4010
- required: ['series', 'summary', 'period', 'granularity', 'currency']
4011
- } as const;
4012
-
4013
- export const $GenerateSnapshotBody = {
4014
- type: 'object',
4015
- properties: {}
4016
- } as const;
4017
-
4018
- export const $GenerateSnapshotResponse = {
4019
- type: 'object',
4020
- properties: {}
4021
- } as const;
4022
-
4023
- export const $BackfillSnapshotsBody = {
4024
- type: 'object',
4025
- properties: {}
4026
- } as const;
4027
-
4028
- export const $BackfillSnapshotsResponse = {
4029
- type: 'object',
4030
- properties: {}
4324
+ required: [
4325
+ 'id',
4326
+ 'userId',
4327
+ 'ruleId',
4328
+ 'expectedDate',
4329
+ 'expectedAmount',
4330
+ 'status',
4331
+ 'isOverdue',
4332
+ 'rule',
4333
+ 'createdAt',
4334
+ 'updatedAt'
4335
+ ]
4031
4336
  } as const;
4032
4337
 
4033
- export const $DeleteOwnUserDto = {
4338
+ export const $ExpectedTransactionListResponseDto = {
4034
4339
  type: 'object',
4035
4340
  properties: {
4036
- accessToken: {
4037
- type: 'string',
4038
- description: 'Access token for user verification',
4039
- example: 'abc123xyz'
4341
+ items: {
4342
+ type: 'array',
4343
+ items: {
4344
+ $ref: '#/components/schemas/ExpectedTransactionResponseDto'
4345
+ }
4346
+ },
4347
+ total: {
4348
+ type: 'number',
4349
+ description: 'Total count'
4040
4350
  }
4041
4351
  },
4042
- required: ['accessToken']
4352
+ required: ['items', 'total']
4043
4353
  } as const;
4044
4354
 
4045
- export const $SignupDto = {
4355
+ export const $ConfirmMatchDto = {
4046
4356
  type: 'object',
4047
4357
  properties: {
4048
- turnstileToken: {
4358
+ transactionId: {
4049
4359
  type: 'string',
4050
- description:
4051
- 'Cloudflare Turnstile verification token (optional when Turnstile disabled)',
4052
- example: '0.abc123def456...'
4360
+ description: 'Transaction ID to match with'
4053
4361
  }
4054
- }
4362
+ },
4363
+ required: ['transactionId']
4055
4364
  } as const;
4056
4365
 
4057
- export const $SignupResponseDto = {
4366
+ export const $EnterNowDto = {
4058
4367
  type: 'object',
4059
4368
  properties: {
4060
- authToken: {
4369
+ expenseAccount: {
4061
4370
  type: 'string',
4062
- description: 'JWT auth token',
4063
- example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
4371
+ description:
4372
+ 'Override expense account (uses rule default if not provided)',
4373
+ maxLength: 200
4064
4374
  },
4065
- accessToken: {
4375
+ paymentAccount: {
4066
4376
  type: 'string',
4067
- description: 'Auto-generated access token'
4377
+ description:
4378
+ 'Override payment account (uses rule default if not provided)',
4379
+ maxLength: 200
4068
4380
  },
4069
- role: {
4381
+ amount: {
4382
+ type: 'number',
4383
+ description: 'Override amount (uses expected amount if not provided)',
4384
+ minimum: 0
4385
+ },
4386
+ payee: {
4070
4387
  type: 'string',
4071
- description: 'Assigned user role',
4072
- enum: ['USER', 'ADMIN', 'DEMO', 'INACTIVE', 'PAID', 'OPS']
4388
+ description: 'Override payee (uses rule default if not provided)',
4389
+ maxLength: 200
4390
+ },
4391
+ narration: {
4392
+ type: 'string',
4393
+ description: 'Optional narration',
4394
+ maxLength: 500
4073
4395
  }
4074
- },
4075
- required: ['authToken', 'accessToken', 'role']
4396
+ }
4076
4397
  } as const;
4077
4398
 
4078
- export const $UpdateUserSettingDto = {
4399
+ export const $ForecastItemDto = {
4079
4400
  type: 'object',
4080
4401
  properties: {
4081
- secId: {
4082
- type: 'number',
4083
- description: 'Security ID'
4402
+ rule: {
4403
+ type: 'string',
4404
+ description: 'Rule name',
4405
+ example: 'Rent'
4084
4406
  },
4085
- annualInterestRate: {
4407
+ ruleId: {
4408
+ type: 'string',
4409
+ description: 'Rule ID',
4410
+ example: 'clx123...'
4411
+ },
4412
+ amount: {
4086
4413
  type: 'number',
4087
- description: 'Annual interest rate',
4088
- example: 0.05
4414
+ description: 'Expected amount',
4415
+ example: 3000
4089
4416
  },
4090
- currency: {
4417
+ date: {
4091
4418
  type: 'string',
4092
- description: 'Currency code',
4093
- example: 'USD'
4419
+ description: 'Expected date (YYYY-MM-DD)',
4420
+ example: '2024-04-01'
4094
4421
  },
4095
- baseCurrency: {
4422
+ icon: {
4096
4423
  type: 'string',
4097
- description: 'Base currency code',
4098
- example: 'USD'
4424
+ description: 'Rule icon emoji',
4425
+ example: '🏠',
4426
+ nullable: true
4099
4427
  },
4100
- benchmark: {
4428
+ currency: {
4101
4429
  type: 'string',
4102
- description: 'Benchmark symbol',
4103
- example: 'SPY'
4104
- },
4105
- colorScheme: {
4430
+ description: 'Currency code',
4431
+ example: 'CNY'
4432
+ }
4433
+ },
4434
+ required: ['rule', 'ruleId', 'amount', 'date', 'icon', 'currency']
4435
+ } as const;
4436
+
4437
+ export const $MonthlyForecastDto = {
4438
+ type: 'object',
4439
+ properties: {
4440
+ month: {
4106
4441
  type: 'string',
4107
- description: 'Color scheme',
4108
- enum: ['DARK', 'LIGHT']
4442
+ description: 'Month (YYYY-MM)',
4443
+ example: '2024-04'
4109
4444
  },
4110
- dateRange: {
4111
- type: 'string',
4112
- description: 'Date range filter',
4113
- example: '1y'
4445
+ expectedOutflow: {
4446
+ type: 'number',
4447
+ description: 'Total expected outflow for the month',
4448
+ example: 8500
4114
4449
  },
4115
- emergencyFund: {
4450
+ itemCount: {
4116
4451
  type: 'number',
4117
- description: 'Emergency fund amount',
4118
- example: 10000
4452
+ description: 'Number of expected transactions',
4453
+ example: 3
4119
4454
  },
4120
- 'filters.accounts': {
4121
- description: 'Account filter IDs',
4122
- type: 'array',
4123
- items: {
4124
- type: 'string'
4455
+ byCurrency: {
4456
+ type: 'object',
4457
+ description: 'Breakdown by currency',
4458
+ example: {
4459
+ CNY: 8500,
4460
+ USD: 100
4125
4461
  }
4126
4462
  },
4127
- 'filters.assetClasses': {
4128
- description: 'Asset class filters',
4463
+ items: {
4464
+ description: 'Individual forecast items',
4129
4465
  type: 'array',
4130
4466
  items: {
4131
- type: 'string'
4467
+ $ref: '#/components/schemas/ForecastItemDto'
4132
4468
  }
4133
- },
4134
- 'filters.dataSource': {
4135
- type: 'string',
4136
- description: 'Data source filter'
4137
- },
4138
- 'filters.symbol': {
4139
- type: 'string',
4140
- description: 'Symbol filter'
4141
- },
4142
- 'filters.tags': {
4143
- description: 'Tag filters',
4469
+ }
4470
+ },
4471
+ required: ['month', 'expectedOutflow', 'itemCount', 'byCurrency', 'items']
4472
+ } as const;
4473
+
4474
+ export const $ForecastResponseDto = {
4475
+ type: 'object',
4476
+ properties: {
4477
+ forecast: {
4478
+ description: 'Monthly forecast data',
4144
4479
  type: 'array',
4145
4480
  items: {
4146
- type: 'string'
4481
+ $ref: '#/components/schemas/MonthlyForecastDto'
4147
4482
  }
4148
4483
  },
4149
- isExperimentalFeatures: {
4150
- type: 'boolean',
4151
- description: 'Enable experimental features'
4152
- },
4153
- isRestrictedView: {
4154
- type: 'boolean',
4155
- description: 'Enable restricted view mode'
4156
- },
4157
- language: {
4158
- type: 'string',
4159
- description: 'Language code',
4160
- example: 'en'
4161
- },
4162
- locale: {
4163
- type: 'string',
4164
- description: 'Locale code',
4165
- example: 'en-US'
4166
- },
4167
- projectedTotalAmount: {
4484
+ totalOutflow: {
4168
4485
  type: 'number',
4169
- description: 'Projected total amount',
4170
- example: 1000000
4486
+ description: 'Total expected outflow across all months',
4487
+ example: 25500
4171
4488
  },
4172
- retirementDate: {
4173
- type: 'string',
4174
- description: 'Retirement date in ISO 8601 format',
4175
- example: '2050-01-01'
4489
+ totalByCurrency: {
4490
+ type: 'object',
4491
+ description: 'Total by currency across all months',
4492
+ example: {
4493
+ CNY: 25500,
4494
+ USD: 300
4495
+ }
4176
4496
  },
4177
- savingsRate: {
4497
+ rulesCount: {
4178
4498
  type: 'number',
4179
- description: 'Savings rate percentage',
4180
- example: 0.2
4499
+ description: 'Number of active recurring rules included',
4500
+ example: 5
4181
4501
  },
4182
- viewMode: {
4502
+ periodStart: {
4183
4503
  type: 'string',
4184
- description: 'View mode',
4185
- enum: ['DEFAULT', 'ZEN']
4186
- }
4187
- }
4188
- } as const;
4189
-
4190
- export const $UpdatePropertyDto = {
4191
- type: 'object',
4192
- properties: {
4193
- value: {
4504
+ description: 'Forecast period start date',
4505
+ example: '2024-04-01'
4506
+ },
4507
+ periodEnd: {
4194
4508
  type: 'string',
4195
- description: 'Property value'
4509
+ description: 'Forecast period end date',
4510
+ example: '2024-06-30'
4196
4511
  }
4197
4512
  },
4198
- required: ['value']
4513
+ required: [
4514
+ 'forecast',
4515
+ 'totalOutflow',
4516
+ 'totalByCurrency',
4517
+ 'rulesCount',
4518
+ 'periodStart',
4519
+ 'periodEnd'
4520
+ ]
4199
4521
  } as const;
4200
4522
 
4201
4523
  export const $CreateTransactionRuleDto = {
@@ -4757,7 +5079,8 @@ export const $UpdateTransactionRuleDto = {
4757
5079
  },
4758
5080
  matchLogic: {
4759
5081
  type: 'string',
4760
- enum: ['OR', 'AND']
5082
+ enum: ['OR', 'AND'],
5083
+ default: 'OR'
4761
5084
  },
4762
5085
  amountMin: {
4763
5086
  type: 'number',
@@ -4771,13 +5094,10 @@ export const $UpdateTransactionRuleDto = {
4771
5094
  },
4772
5095
  priority: {
4773
5096
  type: 'number',
5097
+ default: 50,
4774
5098
  minimum: 0,
4775
5099
  maximum: 1000
4776
5100
  },
4777
- enabled: {
4778
- type: 'boolean',
4779
- description: 'Enable or disable the rule'
4780
- },
4781
5101
  additionalTags: {
4782
5102
  items: {
4783
5103
  type: 'array'
@@ -4787,6 +5107,10 @@ export const $UpdateTransactionRuleDto = {
4787
5107
  },
4788
5108
  additionalMetadata: {
4789
5109
  type: 'object'
5110
+ },
5111
+ enabled: {
5112
+ type: 'boolean',
5113
+ description: 'Enable or disable the rule'
4790
5114
  }
4791
5115
  }
4792
5116
  } as const;
@@ -4847,6 +5171,69 @@ export const $TestRuleResponseDto = {
4847
5171
  required: ['ruleId', 'matches', 'confidence', 'matchDetails']
4848
5172
  } as const;
4849
5173
 
5174
+ export const $CategoryCatalogEntryDto = {
5175
+ type: 'object',
5176
+ properties: {
5177
+ slug: {
5178
+ type: 'string',
5179
+ description: 'Category slug (single source-of-truth)',
5180
+ example: 'food'
5181
+ },
5182
+ scenario: {
5183
+ type: 'string',
5184
+ description: 'Display scenario group (maps to frontend picker _scenario)',
5185
+ enum: [
5186
+ 'expense',
5187
+ 'income',
5188
+ 'investment',
5189
+ 'banking',
5190
+ 'transfer',
5191
+ 'payment'
5192
+ ],
5193
+ example: 'expense'
5194
+ },
5195
+ icon: {
5196
+ type: 'string',
5197
+ description: 'Lucide icon name',
5198
+ example: 'utensils'
5199
+ },
5200
+ regions: {
5201
+ description: "Applicable regions ('*' = all, 'cn' = CN-only)",
5202
+ example: ['*'],
5203
+ type: 'array',
5204
+ items: {
5205
+ type: 'string'
5206
+ }
5207
+ }
5208
+ },
5209
+ required: ['slug', 'scenario', 'icon', 'regions']
5210
+ } as const;
5211
+
5212
+ export const $CategoryCatalogListResponseDto = {
5213
+ type: 'object',
5214
+ properties: {
5215
+ items: {
5216
+ description: 'Category entries (region-scoped, query-filtered)',
5217
+ type: 'array',
5218
+ items: {
5219
+ $ref: '#/components/schemas/CategoryCatalogEntryDto'
5220
+ }
5221
+ },
5222
+ total: {
5223
+ type: 'number',
5224
+ description:
5225
+ 'Total category entries for the region (before query filtering)',
5226
+ example: 30
5227
+ },
5228
+ region: {
5229
+ type: 'string',
5230
+ description: 'Region code',
5231
+ example: 'cn'
5232
+ }
5233
+ },
5234
+ required: ['items', 'total', 'region']
5235
+ } as const;
5236
+
4850
5237
  export const $CreateBeanEventDto = {
4851
5238
  type: 'object',
4852
5239
  properties: {
@@ -5589,7 +5976,8 @@ export const $UpdateMapperDefaultsDto = {
5589
5976
  type: 'string',
5590
5977
  description: 'Source account for transactions (Beancount format)',
5591
5978
  example: 'Assets:CN:Alipay:Balance',
5592
- pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
5979
+ pattern:
5980
+ '^(Assets|Liabilities|Income|Expenses|Equity)(:[A-Za-z0-9][A-Za-z0-9-]*)+$'
5593
5981
  },
5594
5982
  currency: {
5595
5983
  type: 'string',
@@ -5603,13 +5991,15 @@ export const $UpdateMapperDefaultsDto = {
5603
5991
  type: 'string',
5604
5992
  description: 'Default expense account (optional)',
5605
5993
  example: 'Expenses:Unknown',
5606
- pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
5994
+ pattern:
5995
+ '^(Assets|Liabilities|Income|Expenses|Equity)(:[A-Za-z0-9][A-Za-z0-9-]*)+$'
5607
5996
  },
5608
5997
  incomeAccount: {
5609
5998
  type: 'string',
5610
5999
  description: 'Default income account (optional)',
5611
6000
  example: 'Income:Unknown',
5612
- pattern: '^[A-Z][a-zA-Z0-9-]*:[a-zA-Z0-9-:]+$'
6001
+ pattern:
6002
+ '^(Assets|Liabilities|Income|Expenses|Equity)(:[A-Za-z0-9][A-Za-z0-9-]*)+$'
5613
6003
  },
5614
6004
  methodAccountMapping: {
5615
6005
  type: 'object',
@@ -5666,12 +6056,14 @@ export const $ProviderSyncConfigDto = {
5666
6056
  },
5667
6057
  defaultExpenseAccount: {
5668
6058
  type: 'string',
5669
- description: 'Default expense account for the second posting',
6059
+ description:
6060
+ 'Default expense account for the second posting. Omit when no real default exists; the pipeline routes to Review via the Uncategorized sentinel (#618).',
5670
6061
  example: 'Expenses:Unknown'
5671
6062
  },
5672
6063
  defaultIncomeAccount: {
5673
6064
  type: 'string',
5674
- description: 'Default income account for the second posting',
6065
+ description:
6066
+ 'Default income account for the second posting. Omit when no real default exists; the pipeline routes to Review via the Uncategorized sentinel (#618).',
5675
6067
  example: 'Income:Unknown'
5676
6068
  },
5677
6069
  filterPending: {
@@ -5686,12 +6078,7 @@ export const $ProviderSyncConfigDto = {
5686
6078
  example: 'acc_gocardless_001'
5687
6079
  }
5688
6080
  },
5689
- required: [
5690
- 'sourceAccount',
5691
- 'defaultCurrency',
5692
- 'defaultExpenseAccount',
5693
- 'defaultIncomeAccount'
5694
- ]
6081
+ required: ['sourceAccount', 'defaultCurrency']
5695
6082
  } as const;
5696
6083
 
5697
6084
  export const $ProviderSyncDto = {
@@ -5901,15 +6288,105 @@ export const $UncoveredFormatMissDto = {
5901
6288
  properties: {}
5902
6289
  } as const;
5903
6290
 
6291
+ export const $ClientParsedDataDto = {
6292
+ type: 'object',
6293
+ properties: {
6294
+ amount: {
6295
+ type: 'number',
6296
+ description: 'Transaction amount',
6297
+ example: 35
6298
+ },
6299
+ currency: {
6300
+ type: 'string',
6301
+ description: 'Currency code',
6302
+ example: 'CNY'
6303
+ },
6304
+ date: {
6305
+ type: 'string',
6306
+ description: 'Transaction date (ISO 8601)',
6307
+ example: '2026-08-15'
6308
+ },
6309
+ payee: {
6310
+ type: 'string',
6311
+ description: 'Payee/merchant name',
6312
+ example: 'Starbucks'
6313
+ },
6314
+ narration: {
6315
+ type: 'string',
6316
+ description: 'Transaction narration'
6317
+ },
6318
+ category: {
6319
+ type: 'string',
6320
+ description: 'Category slug',
6321
+ example: 'food_restaurant'
6322
+ },
6323
+ incomeType: {
6324
+ type: 'string',
6325
+ description: 'Income type',
6326
+ example: 'Salary'
6327
+ },
6328
+ incomeSource: {
6329
+ type: 'string',
6330
+ description: 'Income source',
6331
+ example: 'Anthropic Inc.'
6332
+ },
6333
+ symbol: {
6334
+ type: 'string',
6335
+ description: 'Security symbol code (e.g., 600519, AAPL)',
6336
+ example: 'AAPL'
6337
+ },
6338
+ quantity: {
6339
+ type: 'number',
6340
+ description: 'Quantity of shares/units',
6341
+ example: 100
6342
+ },
6343
+ price: {
6344
+ type: 'number',
6345
+ description: 'Unit price per share/unit',
6346
+ example: 1900
6347
+ },
6348
+ investmentAction: {
6349
+ type: 'string',
6350
+ description: 'Investment action',
6351
+ enum: ['buy', 'sell'],
6352
+ example: 'buy'
6353
+ },
6354
+ paymentSource: {
6355
+ type: 'string',
6356
+ description: 'Payment source: asset (default) or liability (credit card)',
6357
+ enum: ['asset', 'liability'],
6358
+ example: 'asset'
6359
+ },
6360
+ liabilityHint: {
6361
+ type: 'string',
6362
+ description: 'Liability account hint (CreditCard/Huabei/Baitiao)',
6363
+ example: 'CreditCard'
6364
+ },
6365
+ warning: {
6366
+ type: 'string',
6367
+ description:
6368
+ 'Display-only warning from the prior response; accepted but ignored.',
6369
+ example: 'Cross-currency settlement applies.'
6370
+ }
6371
+ }
6372
+ } as const;
6373
+
5904
6374
  export const $ProcessNlpDto = {
5905
6375
  type: 'object',
5906
6376
  properties: {
5907
6377
  message: {
5908
6378
  type: 'string',
5909
- description: 'Natural language text describing a transaction (Chinese)',
5910
- example: 'yesterday Starbucks spent 35 yuan',
6379
+ description:
6380
+ 'Natural language text describing a transaction. Optional when `confirm` is true (structured confirm); otherwise required.',
6381
+ example: 'Starbucks 35',
5911
6382
  maxLength: 500
5912
6383
  },
6384
+ confirm: {
6385
+ type: 'boolean',
6386
+ description:
6387
+ 'Structured confirm signal — bypasses NL confirm-word matching when true. Send parsedData field edits alongside. The NL word-list path is the fallback.',
6388
+ example: true
6389
+ },
5913
6390
  sessionId: {
5914
6391
  type: 'string',
5915
6392
  description:
@@ -5917,17 +6394,51 @@ export const $ProcessNlpDto = {
5917
6394
  example: 'session_abc123'
5918
6395
  },
5919
6396
  parsedData: {
5920
- type: 'object',
5921
6397
  description:
5922
6398
  'Parsed data from previous NLP response for session recovery. Send back the parsedData received in confirm_payee/confirm responses.',
5923
6399
  example: {
5924
6400
  amount: 35,
5925
6401
  currency: 'CNY',
5926
6402
  payee: 'Starbucks'
5927
- }
6403
+ },
6404
+ allOf: [
6405
+ {
6406
+ $ref: '#/components/schemas/ClientParsedDataDto'
6407
+ }
6408
+ ]
6409
+ },
6410
+ selectedRuleId: {
6411
+ type: 'string',
6412
+ description:
6413
+ '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.',
6414
+ example: 'rule_abc123'
6415
+ },
6416
+ selectedAccount: {
6417
+ type: 'string',
6418
+ description:
6419
+ '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.',
6420
+ example: 'Expenses:Food:Coffee'
6421
+ },
6422
+ viewpointAccount: {
6423
+ type: 'string',
6424
+ description:
6425
+ '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.',
6426
+ example: 'Assets:CN:Bank:ICBC'
6427
+ },
6428
+ viewpointCategory: {
6429
+ type: 'string',
6430
+ description:
6431
+ "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.",
6432
+ example: 'Food'
6433
+ },
6434
+ viewpointFlow: {
6435
+ type: 'string',
6436
+ description:
6437
+ "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.",
6438
+ enum: ['income', 'expense'],
6439
+ example: 'expense'
5928
6440
  }
5929
- },
5930
- required: ['message']
6441
+ }
5931
6442
  } as const;
5932
6443
 
5933
6444
  export const $NlpTransactionInfoDto = {
@@ -6239,6 +6750,24 @@ export const $NlpRuleConfirmationDataDto = {
6239
6750
  ]
6240
6751
  } as const;
6241
6752
 
6753
+ export const $NlpAccountCandidateDto = {
6754
+ type: 'object',
6755
+ properties: {
6756
+ path: {
6757
+ type: 'string',
6758
+ description: 'Canonical beancount account path (echo back on selection)',
6759
+ example: 'Expenses:Food:Dining'
6760
+ },
6761
+ name: {
6762
+ type: 'string',
6763
+ description:
6764
+ 'Localized display name (ADR-0114 read-time projection, user locale)',
6765
+ example: '餐饮'
6766
+ }
6767
+ },
6768
+ required: ['path', 'name']
6769
+ } as const;
6770
+
6242
6771
  export const $NlpAccountConfirmationDataDto = {
6243
6772
  type: 'object',
6244
6773
  properties: {
@@ -6249,14 +6778,16 @@ export const $NlpAccountConfirmationDataDto = {
6249
6778
  },
6250
6779
  suggestedAccount: {
6251
6780
  type: 'string',
6252
- description: 'Suggested replacement account',
6781
+ description:
6782
+ 'Suggested replacement account (omitted when no clear candidate)',
6253
6783
  example: 'Expenses:Food:Drinks'
6254
6784
  },
6255
6785
  similarAccounts: {
6256
- description: 'Similar accounts for user selection',
6786
+ description:
6787
+ 'Similar accounts for user selection (path + localized name, #680)',
6257
6788
  type: 'array',
6258
6789
  items: {
6259
- type: 'string'
6790
+ $ref: '#/components/schemas/NlpAccountCandidateDto'
6260
6791
  }
6261
6792
  },
6262
6793
  errorMessage: {
@@ -6271,7 +6802,6 @@ export const $NlpAccountConfirmationDataDto = {
6271
6802
  },
6272
6803
  required: [
6273
6804
  'invalidAccount',
6274
- 'suggestedAccount',
6275
6805
  'similarAccounts',
6276
6806
  'errorMessage',
6277
6807
  'transactionContext'
@@ -6444,7 +6974,8 @@ export const $NlpSuggestedAccountDto = {
6444
6974
  },
6445
6975
  confidence: {
6446
6976
  type: 'number',
6447
- description: 'Confidence score for this suggestion (0-1)',
6977
+ description:
6978
+ 'Confidence score for this suggestion (0-1). Present = predicted (confirm/confirm_rule/confirm_account); omitted = actual persisted account (created). (#586)',
6448
6979
  example: 0.9
6449
6980
  }
6450
6981
  },
@@ -6480,23 +7011,31 @@ export const $NlpDefaultAccountsDto = {
6480
7011
  properties: {
6481
7012
  asset: {
6482
7013
  type: 'string',
6483
- description: 'Default asset account',
6484
- example: 'Assets:Checking'
7014
+ description:
7015
+ 'Default OPEN asset account (MRU when multiple), or null when none/ambiguous',
7016
+ example: 'Assets:Checking',
7017
+ nullable: true
6485
7018
  },
6486
7019
  expense: {
6487
7020
  type: 'string',
6488
- description: 'Default expense account',
6489
- example: 'Expenses:Uncategorized'
7021
+ description:
7022
+ 'Default OPEN expense account (MRU when multiple), or null when none/ambiguous',
7023
+ example: 'Expenses:Food:Coffee',
7024
+ nullable: true
6490
7025
  },
6491
7026
  income: {
6492
7027
  type: 'string',
6493
- description: 'Default income account',
6494
- example: 'Income:Uncategorized'
7028
+ description:
7029
+ 'Default OPEN income account (MRU when multiple), or null when none/ambiguous',
7030
+ example: 'Income:Salary',
7031
+ nullable: true
6495
7032
  },
6496
7033
  liability: {
6497
7034
  type: 'string',
6498
- description: 'Default liability account',
6499
- example: 'Liabilities:CreditCard'
7035
+ description:
7036
+ 'Default OPEN liability account (MRU when multiple), or null when none/ambiguous',
7037
+ example: 'Liabilities:CreditCard',
7038
+ nullable: true
6500
7039
  }
6501
7040
  },
6502
7041
  required: ['asset', 'expense', 'income', 'liability']
@@ -6536,7 +7075,7 @@ export const $NlpResponseDto = {
6536
7075
  type: 'string',
6537
7076
  description:
6538
7077
  'Asset sub-type (only present when intent is "asset"). Determines which asset-related form to render.',
6539
- enum: ['transfer', 'banking', 'investment'],
7078
+ enum: ['transfer', 'banking', 'investment', 'lend', 'lend_collect'],
6540
7079
  example: 'investment'
6541
7080
  },
6542
7081
  liabilitySubType: {
@@ -6684,7 +7223,7 @@ export const $NlpResponseDto = {
6684
7223
  },
6685
7224
  suggestedAccounts: {
6686
7225
  description:
6687
- 'Suggested accounts for this transaction. Contains recommended source and destination accounts based on the detected intent and rules.',
7226
+ '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.',
6688
7227
  allOf: [
6689
7228
  {
6690
7229
  $ref: '#/components/schemas/NlpSuggestedAccountsDto'
@@ -6693,7 +7232,7 @@ export const $NlpResponseDto = {
6693
7232
  },
6694
7233
  defaultAccounts: {
6695
7234
  description:
6696
- 'Default accounts for the user/region. These are fallback accounts used when no specific suggestion is available.',
7235
+ 'Default fallback accounts for the user/region (#586). v1 returns universal constants; per-user personalization is planned.',
6697
7236
  allOf: [
6698
7237
  {
6699
7238
  $ref: '#/components/schemas/NlpDefaultAccountsDto'
@@ -6739,13 +7278,26 @@ export const $PlatformListItemDto = {
6739
7278
  suggestedSegment: {
6740
7279
  type: 'string',
6741
7280
  description:
6742
- 'Suggested path segment — canonical with first char uppercased (ACC_COMP_NAME_RE)'
7281
+ 'Suggested path segment — canonical PascalCased per hyphen-part, hyphens preserved (e.g. "Apple-Pay")'
6743
7282
  },
6744
7283
  logoUrl: {
6745
7284
  type: 'string',
6746
7285
  description: 'Logo URL',
6747
7286
  nullable: true
6748
7287
  },
7288
+ countryCode: {
7289
+ type: 'string',
7290
+ description: 'ISO 3166-1 alpha-2 (UPPERCASE); null = global platform',
7291
+ example: 'CN',
7292
+ nullable: true
7293
+ },
7294
+ category: {
7295
+ type: 'string',
7296
+ description:
7297
+ 'Region-aware category (institution vocab, e.g. DigitalWallet/Bank). null = no region-aware suggestion; fall back to type.',
7298
+ nullable: true,
7299
+ example: 'DigitalWallet'
7300
+ },
6749
7301
  isBound: {
6750
7302
  type: 'boolean',
6751
7303
  description: 'Whether user has accounts using this platform'
@@ -6759,6 +7311,8 @@ export const $PlatformListItemDto = {
6759
7311
  'canonical',
6760
7312
  'suggestedSegment',
6761
7313
  'logoUrl',
7314
+ 'countryCode',
7315
+ 'category',
6762
7316
  'isBound'
6763
7317
  ]
6764
7318
  } as const;
@@ -6794,13 +7348,26 @@ export const $PlatformMatchResultDto = {
6794
7348
  suggestedSegment: {
6795
7349
  type: 'string',
6796
7350
  description:
6797
- 'Suggested path segment — canonical, already in ACCOUNT_RE format'
7351
+ 'Suggested path segment — canonical PascalCased per hyphen-part, hyphens preserved (e.g. "Apple-Pay")'
6798
7352
  },
6799
7353
  logoUrl: {
6800
7354
  type: 'string',
6801
7355
  description: 'Logo URL',
6802
7356
  nullable: true
6803
7357
  },
7358
+ countryCode: {
7359
+ type: 'string',
7360
+ description: 'ISO 3166-1 alpha-2 (UPPERCASE); null = global platform',
7361
+ example: 'CN',
7362
+ nullable: true
7363
+ },
7364
+ category: {
7365
+ type: 'string',
7366
+ description:
7367
+ 'Region-aware category (institution vocab, e.g. DigitalWallet/Bank). null = no region-aware suggestion; fall back to type.',
7368
+ nullable: true,
7369
+ example: 'DigitalWallet'
7370
+ },
6804
7371
  matchType: {
6805
7372
  type: 'string',
6806
7373
  description: "How this row matched: 'exact' > 'prefix' > 'substring'",
@@ -6814,6 +7381,8 @@ export const $PlatformMatchResultDto = {
6814
7381
  'type',
6815
7382
  'suggestedSegment',
6816
7383
  'logoUrl',
7384
+ 'countryCode',
7385
+ 'category',
6817
7386
  'matchType'
6818
7387
  ]
6819
7388
  } as const;
@@ -6828,22 +7397,95 @@ export const $PlatformMatchResponseDto = {
6828
7397
  $ref: '#/components/schemas/PlatformMatchResultDto'
6829
7398
  }
6830
7399
  },
6831
- matchType: {
7400
+ matchType: {
7401
+ type: 'string',
7402
+ description:
7403
+ "Overall match quality — top row's tier, or 'none' when no hits",
7404
+ enum: ['none', 'exact', 'prefix', 'substring']
7405
+ },
7406
+ total: {
7407
+ type: 'number',
7408
+ description: 'Total matches before LIMIT (truncation transparency)'
7409
+ },
7410
+ hasMore: {
7411
+ type: 'boolean',
7412
+ description: 'true when total > platforms.length (more matches exist)'
7413
+ }
7414
+ },
7415
+ required: ['platforms', 'matchType', 'total', 'hasMore']
7416
+ } as const;
7417
+
7418
+ export const $PlatformStandardsPlatformDto = {
7419
+ type: 'object',
7420
+ properties: {
7421
+ id: {
7422
+ type: 'string',
7423
+ description: 'Global platform ID'
7424
+ },
7425
+ name: {
7426
+ type: 'string',
7427
+ description: 'Platform name (e.g., "ICBC")'
7428
+ },
7429
+ canonical: {
7430
+ type: 'string',
7431
+ description: 'Canonical identifier in ACCOUNT_RE format (e.g., "icbc")'
7432
+ },
7433
+ suggestedSegment: {
7434
+ type: 'string',
7435
+ description:
7436
+ 'Suggested path segment — canonical PascalCased per hyphen-part, hyphens preserved (e.g. "Apple-Pay")'
7437
+ },
7438
+ type: {
7439
+ type: 'string',
7440
+ description: 'Platform type',
7441
+ enum: [
7442
+ 'BANK',
7443
+ 'BROKERAGE',
7444
+ 'CRYPTO_EXCHANGE',
7445
+ 'PAYMENT',
7446
+ 'INVESTMENT',
7447
+ 'INSURANCE',
7448
+ 'OTHER'
7449
+ ]
7450
+ },
7451
+ category: {
7452
+ type: 'string',
7453
+ description:
7454
+ 'Region-aware category (institution vocab, e.g. DigitalWallet/Bank) resolved against the final region. null = no region-aware suggestion; fall back to type.',
7455
+ nullable: true,
7456
+ example: 'Bank'
7457
+ }
7458
+ },
7459
+ required: ['id', 'name', 'canonical', 'suggestedSegment', 'type', 'category']
7460
+ } as const;
7461
+
7462
+ export const $PlatformStandardsResponseDto = {
7463
+ type: 'object',
7464
+ properties: {
7465
+ platform: {
7466
+ description: 'The selected platform (institution lock source)',
7467
+ allOf: [
7468
+ {
7469
+ $ref: '#/components/schemas/PlatformStandardsPlatformDto'
7470
+ }
7471
+ ]
7472
+ },
7473
+ region: {
6832
7474
  type: 'string',
6833
7475
  description:
6834
- "Overall match quality — top row's tier, or 'none' when no hits",
6835
- enum: ['none', 'exact', 'prefix', 'substring']
6836
- },
6837
- total: {
6838
- type: 'number',
6839
- description: 'Total matches before LIMIT (truncation transparency)'
7476
+ "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.",
7477
+ example: 'CN'
6840
7478
  },
6841
- hasMore: {
6842
- type: 'boolean',
6843
- description: 'true when total > platforms.length (more matches exist)'
7479
+ templates: {
7480
+ description:
7481
+ 'Candidate account-standard templates of the resolved region (groupable by productCategory client-side)',
7482
+ type: 'array',
7483
+ items: {
7484
+ $ref: '#/components/schemas/AccountStandardResponseDto'
7485
+ }
6844
7486
  }
6845
7487
  },
6846
- required: ['platforms', 'matchType', 'total', 'hasMore']
7488
+ required: ['platform', 'region', 'templates']
6847
7489
  } as const;
6848
7490
 
6849
7491
  export const $CreatePlatformDto = {
@@ -6947,7 +7589,8 @@ export const $UpdatePlatformDto = {
6947
7589
  },
6948
7590
  isActive: {
6949
7591
  type: 'boolean',
6950
- description: 'Whether the platform is active'
7592
+ description: 'Whether the platform is active',
7593
+ default: true
6951
7594
  }
6952
7595
  }
6953
7596
  } as const;
@@ -7146,7 +7789,8 @@ export const $PlatformGroupDto = {
7146
7789
  example: 'CMB Bank'
7147
7790
  },
7148
7791
  accounts: {
7149
- description: 'Accounts within this platform',
7792
+ description:
7793
+ 'Accounts within this platform (Assets and Liabilities rows, #696)',
7150
7794
  type: 'array',
7151
7795
  items: {
7152
7796
  $ref: '#/components/schemas/AccountItemDto'
@@ -7154,7 +7798,8 @@ export const $PlatformGroupDto = {
7154
7798
  },
7155
7799
  totalBalance: {
7156
7800
  type: 'string',
7157
- description: 'FX-converted total balance in base currency',
7801
+ description:
7802
+ 'FX-converted total balance in base currency (nets Assets + Liabilities rows; can be negative)',
7158
7803
  example: '100000.00'
7159
7804
  },
7160
7805
  balanceByCurrency: {
@@ -7173,7 +7818,7 @@ export const $PlatformGroupDto = {
7173
7818
  sharePct: {
7174
7819
  type: 'number',
7175
7820
  description:
7176
- 'Share of the grand converted total (0-100); 0 when grand total is 0',
7821
+ 'Share of the converted asset-side grand total (0-100); liability balances are excluded from the basis; 0 when grand total is 0 (#696)',
7177
7822
  example: 42.5
7178
7823
  }
7179
7824
  },
@@ -7221,7 +7866,8 @@ export const $AccountsSummaryDto = {
7221
7866
  properties: {
7222
7867
  totalAccounts: {
7223
7868
  type: 'number',
7224
- description: 'Total number of accounts'
7869
+ description:
7870
+ 'Total number of accounts (balance sheet: Assets + Liabilities, #696)'
7225
7871
  },
7226
7872
  totalPlatforms: {
7227
7873
  type: 'number',
@@ -8062,3 +8708,356 @@ export const $AnonymousLoginResponseDto = {
8062
8708
  },
8063
8709
  required: ['authToken']
8064
8710
  } as const;
8711
+
8712
+ export const $ParserContributionMetaDto = {
8713
+ type: 'object',
8714
+ properties: {
8715
+ institution: {
8716
+ type: 'string',
8717
+ description: 'Institution slug (lowercase kebab-case)',
8718
+ pattern: '^[a-z0-9]+(-[a-z0-9]+)*$',
8719
+ example: 'icbc'
8720
+ },
8721
+ region: {
8722
+ type: 'string',
8723
+ enum: [
8724
+ 'cn',
8725
+ 'us',
8726
+ 'de',
8727
+ 'fr',
8728
+ 'gb',
8729
+ 'hk',
8730
+ 'jp',
8731
+ 'sg',
8732
+ 'au',
8733
+ 'ca',
8734
+ 'other'
8735
+ ]
8736
+ },
8737
+ accountType: {
8738
+ type: 'string',
8739
+ enum: ['checking', 'savings', 'credit', 'debit', 'investment']
8740
+ },
8741
+ format: {
8742
+ type: 'string',
8743
+ enum: ['csv', 'xlsx', 'pdf', 'ofx', 'qif']
8744
+ },
8745
+ institutionDisplayName: {
8746
+ type: 'string',
8747
+ example: '中国工商银行'
8748
+ },
8749
+ encoding: {
8750
+ type: 'string',
8751
+ example: 'utf-8'
8752
+ },
8753
+ delimiter: {
8754
+ type: 'string',
8755
+ description: 'CSV delimiter character: ",", ";", "\\t" or "|"'
8756
+ },
8757
+ headerRows: {
8758
+ type: 'number',
8759
+ default: 1,
8760
+ description: 'Header row count; the client omits the field when it is 1'
8761
+ },
8762
+ notes: {
8763
+ type: 'string',
8764
+ maxLength: 2000
8765
+ }
8766
+ },
8767
+ required: ['institution', 'region', 'accountType', 'format']
8768
+ } as const;
8769
+
8770
+ export const $ParserContributionSamplesDto = {
8771
+ type: 'object',
8772
+ properties: {
8773
+ rows: {
8774
+ description:
8775
+ 'Client-sanitized sample rows (key = column name, value = cell)',
8776
+ type: 'array',
8777
+ items: {
8778
+ type: 'object'
8779
+ }
8780
+ },
8781
+ rawHeaders: {
8782
+ type: 'array',
8783
+ items: {
8784
+ type: 'string'
8785
+ }
8786
+ }
8787
+ },
8788
+ required: ['rows']
8789
+ } as const;
8790
+
8791
+ export const $FieldHintDto = {
8792
+ type: 'object',
8793
+ properties: {
8794
+ columnName: {
8795
+ type: 'string',
8796
+ example: '交易日期'
8797
+ },
8798
+ format: {
8799
+ type: 'string',
8800
+ description: 'Date format, e.g. yyyy-MM-dd HH:mm',
8801
+ example: 'yyyy-MM-dd'
8802
+ },
8803
+ signConvention: {
8804
+ type: 'string',
8805
+ enum: ['negative-expense', 'positive-expense', 'separate-columns']
8806
+ },
8807
+ creditColumn: {
8808
+ type: 'string'
8809
+ },
8810
+ debitColumn: {
8811
+ type: 'string'
8812
+ }
8813
+ },
8814
+ required: ['columnName']
8815
+ } as const;
8816
+
8817
+ export const $ParserContributionFieldHintsDto = {
8818
+ type: 'object',
8819
+ properties: {
8820
+ date: {
8821
+ $ref: '#/components/schemas/FieldHintDto'
8822
+ },
8823
+ amount: {
8824
+ $ref: '#/components/schemas/FieldHintDto'
8825
+ },
8826
+ description: {
8827
+ $ref: '#/components/schemas/FieldHintDto'
8828
+ },
8829
+ balance: {
8830
+ $ref: '#/components/schemas/FieldHintDto'
8831
+ },
8832
+ payee: {
8833
+ $ref: '#/components/schemas/FieldHintDto'
8834
+ },
8835
+ reference: {
8836
+ $ref: '#/components/schemas/FieldHintDto'
8837
+ },
8838
+ category: {
8839
+ $ref: '#/components/schemas/FieldHintDto'
8840
+ }
8841
+ },
8842
+ required: ['date', 'amount']
8843
+ } as const;
8844
+
8845
+ export const $ExpectedTransactionDto = {
8846
+ type: 'object',
8847
+ properties: {
8848
+ date: {
8849
+ type: 'string',
8850
+ example: '2026-08-01'
8851
+ },
8852
+ amount: {
8853
+ type: 'number',
8854
+ example: -45.5
8855
+ },
8856
+ description: {
8857
+ type: 'string',
8858
+ example: '星巴克-***店'
8859
+ },
8860
+ payee: {
8861
+ type: 'string'
8862
+ },
8863
+ category: {
8864
+ type: 'string'
8865
+ }
8866
+ },
8867
+ required: ['date', 'amount', 'description']
8868
+ } as const;
8869
+
8870
+ export const $ParserContributionExamplesDto = {
8871
+ type: 'object',
8872
+ properties: {
8873
+ expectedTransactions: {
8874
+ type: 'array',
8875
+ items: {
8876
+ $ref: '#/components/schemas/ExpectedTransactionDto'
8877
+ }
8878
+ }
8879
+ },
8880
+ required: ['expectedTransactions']
8881
+ } as const;
8882
+
8883
+ export const $ParserContributionRequestDto = {
8884
+ type: 'object',
8885
+ properties: {
8886
+ meta: {
8887
+ $ref: '#/components/schemas/ParserContributionMetaDto'
8888
+ },
8889
+ samples: {
8890
+ $ref: '#/components/schemas/ParserContributionSamplesDto'
8891
+ },
8892
+ fieldHints: {
8893
+ $ref: '#/components/schemas/ParserContributionFieldHintsDto'
8894
+ },
8895
+ examples: {
8896
+ description: 'Omitted entirely by the client when empty',
8897
+ allOf: [
8898
+ {
8899
+ $ref: '#/components/schemas/ParserContributionExamplesDto'
8900
+ }
8901
+ ]
8902
+ }
8903
+ },
8904
+ required: ['meta', 'samples', 'fieldHints']
8905
+ } as const;
8906
+
8907
+ export const $ParserContributionRelayResponseDto = {
8908
+ type: 'object',
8909
+ properties: {
8910
+ issueUrl: {
8911
+ type: 'string',
8912
+ example: 'https://github.com/fire-zu/firela-vlt/issues/42'
8913
+ },
8914
+ issueNumber: {
8915
+ type: 'number',
8916
+ example: 42
8917
+ }
8918
+ },
8919
+ required: ['issueUrl', 'issueNumber']
8920
+ } as const;
8921
+
8922
+ export const $SymbolSearchResultDto = {
8923
+ type: 'object',
8924
+ properties: {
8925
+ symbol: {
8926
+ type: 'string',
8927
+ example: 'AAPL'
8928
+ },
8929
+ name: {
8930
+ type: 'object',
8931
+ example: 'Apple Inc.',
8932
+ nullable: true
8933
+ },
8934
+ exchange: {
8935
+ type: 'object',
8936
+ example: 'US',
8937
+ nullable: true
8938
+ },
8939
+ assetType: {
8940
+ type: 'object',
8941
+ description: 'OpenBB asset_type (e.g. stock, etf)',
8942
+ example: 'stock',
8943
+ nullable: true
8944
+ },
8945
+ assetClass: {
8946
+ type: 'object',
8947
+ description: 'IGN asset class (region.types.ts ASSET_CLASSES)',
8948
+ example: 'EQUITY',
8949
+ nullable: true
8950
+ },
8951
+ assetSubClass: {
8952
+ type: 'object',
8953
+ description: 'IGN asset sub-class (region.types.ts ASSET_SUB_CLASSES)',
8954
+ example: 'STOCK',
8955
+ nullable: true
8956
+ },
8957
+ currency: {
8958
+ type: 'object',
8959
+ description: 'Trading currency (extra_data or inferred from exchange)',
8960
+ example: 'USD',
8961
+ nullable: true
8962
+ }
8963
+ },
8964
+ required: ['symbol']
8965
+ } as const;
8966
+
8967
+ export const $SymbolQuoteDto = {
8968
+ type: 'object',
8969
+ properties: {
8970
+ symbol: {
8971
+ type: 'string',
8972
+ example: 'AAPL'
8973
+ },
8974
+ name: {
8975
+ type: 'object',
8976
+ example: 'Apple Inc.',
8977
+ nullable: true
8978
+ },
8979
+ exchange: {
8980
+ type: 'object',
8981
+ example: 'US',
8982
+ nullable: true
8983
+ },
8984
+ assetType: {
8985
+ type: 'object',
8986
+ description: 'OpenBB asset_type',
8987
+ example: 'stock',
8988
+ nullable: true
8989
+ },
8990
+ assetClass: {
8991
+ type: 'object',
8992
+ description: 'IGN asset class',
8993
+ example: 'EQUITY',
8994
+ nullable: true
8995
+ },
8996
+ assetSubClass: {
8997
+ type: 'object',
8998
+ description: 'IGN asset sub-class',
8999
+ example: 'STOCK',
9000
+ nullable: true
9001
+ },
9002
+ currency: {
9003
+ type: 'object',
9004
+ description: 'Trading currency (extra_data or inferred from exchange)',
9005
+ example: 'USD',
9006
+ nullable: true
9007
+ },
9008
+ price: {
9009
+ type: 'object',
9010
+ description: 'Latest price (Decimal string)',
9011
+ example: '189.84',
9012
+ nullable: true
9013
+ },
9014
+ priceDate: {
9015
+ type: 'object',
9016
+ description: 'Date the price was observed (ISO yyyy-MM-dd)',
9017
+ example: '2026-08-05',
9018
+ nullable: true
9019
+ },
9020
+ changePercent: {
9021
+ type: 'object',
9022
+ description:
9023
+ '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.',
9024
+ example: 1.7,
9025
+ nullable: true
9026
+ },
9027
+ prevClose: {
9028
+ type: 'object',
9029
+ description: 'Previous close (Decimal string)',
9030
+ nullable: true
9031
+ },
9032
+ open: {
9033
+ type: 'object',
9034
+ description: 'Day open (Decimal string)',
9035
+ nullable: true
9036
+ },
9037
+ high: {
9038
+ type: 'object',
9039
+ description: 'Day high (Decimal string)',
9040
+ nullable: true
9041
+ },
9042
+ low: {
9043
+ type: 'object',
9044
+ description: 'Day low (Decimal string)',
9045
+ nullable: true
9046
+ },
9047
+ volume: {
9048
+ type: 'object',
9049
+ description: 'Day volume (Decimal string)',
9050
+ nullable: true
9051
+ },
9052
+ yearHigh: {
9053
+ type: 'object',
9054
+ description: '52-week high (Decimal string)',
9055
+ nullable: true
9056
+ },
9057
+ yearLow: {
9058
+ type: 'object',
9059
+ description: '52-week low (Decimal string)',
9060
+ nullable: true
9061
+ }
9062
+ }
9063
+ } as const;