@firela/api-types 0.0.0-canary.a85ace93 → 0.0.0-canary.aba78d68

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.
@@ -316,6 +316,53 @@ export type RegionsMetadataResponseDto = {
316
316
  regions: Array<RegionInfoDto>;
317
317
  };
318
318
 
319
+ export type CostSpecDto = {
320
+ /**
321
+ * Cost specification mode (mirrors engine CostSpec)
322
+ */
323
+ mode: 'per-unit' | 'total' | 'date' | 'label' | 'auto';
324
+ /**
325
+ * Per-unit cost (required when mode is "per-unit")
326
+ */
327
+ numberPerUnit?: string;
328
+ /**
329
+ * Total cost for all units (required when mode is "total")
330
+ */
331
+ totalNumber?: string;
332
+ /**
333
+ * Cost currency (required in all modes)
334
+ */
335
+ currency: string;
336
+ /**
337
+ * Lot acquisition date, ISO 8601 (required when mode is "date")
338
+ */
339
+ date?: string;
340
+ /**
341
+ * Lot label (required when mode is "label"; optional tag in buy modes)
342
+ */
343
+ label?: string;
344
+ /**
345
+ * Merge lots for AVERAGE booking (mode: auto)
346
+ */
347
+ merge?: boolean;
348
+ };
349
+
350
+ /**
351
+ * Cost specification mode (mirrors engine CostSpec)
352
+ */
353
+ export type mode = 'per-unit' | 'total' | 'date' | 'label' | 'auto';
354
+
355
+ export type AmountDto = {
356
+ /**
357
+ * Amount as decimal string (max 15 integer + 15 decimal digits)
358
+ */
359
+ number: string;
360
+ /**
361
+ * Currency/commodity code
362
+ */
363
+ currency: string;
364
+ };
365
+
319
366
  export type CreatePostingDto = {
320
367
  /**
321
368
  * Account name in Beancount format (must start with uppercase, colon-separated)
@@ -335,6 +382,14 @@ export type CreatePostingDto = {
335
382
  meta?: {
336
383
  [key: string]: unknown;
337
384
  };
385
+ /**
386
+ * Cost basis (Beancount `{...}`). Maps to engine costSpec. Required for commodity holdings so they carry a monetary weight that can balance.
387
+ */
388
+ cost?: CostSpecDto;
389
+ /**
390
+ * Price annotation (Beancount `@...`). Maps to engine price. Used for valuation; cost takes priority for balance weight.
391
+ */
392
+ price?: AmountDto;
338
393
  };
339
394
 
340
395
  export type CreateTransactionDto = {
@@ -387,6 +442,25 @@ export type CreateTransactionDto = {
387
442
  */
388
443
  export type flag = '*' | '!';
389
444
 
445
+ export type CostDetailDto = {
446
+ /**
447
+ * Per-unit cost basis (mirrors engine Cost.number)
448
+ */
449
+ number?: string;
450
+ /**
451
+ * Cost currency
452
+ */
453
+ currency?: string;
454
+ /**
455
+ * Lot acquisition date (ISO yyyy-mm-dd)
456
+ */
457
+ date?: string;
458
+ /**
459
+ * Lot label
460
+ */
461
+ label?: string;
462
+ };
463
+
390
464
  export type PostingResponseDto = {
391
465
  /**
392
466
  * Account name
@@ -400,6 +474,10 @@ export type PostingResponseDto = {
400
474
  * Currency
401
475
  */
402
476
  currency?: string;
477
+ /**
478
+ * Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.
479
+ */
480
+ cost?: CostDetailDto;
403
481
  };
404
482
 
405
483
  export type RecurringSuggestionDto = {
@@ -643,6 +721,10 @@ export type PostingDetailDto = {
643
721
  * Cost date
644
722
  */
645
723
  costDate?: string;
724
+ /**
725
+ * Booking-resolved cost (mirrors engine Cost). Undefined when the posting has no cost basis.
726
+ */
727
+ cost?: CostDetailDto;
646
728
  /**
647
729
  * Price amount
648
730
  */
@@ -1242,17 +1324,17 @@ export type ResolveResultDto = {
1242
1324
  [key: string]: string;
1243
1325
  };
1244
1326
  /**
1245
- * Resolution ID for undo
1327
+ * Resolution ID for undo. Absent when the resolver rejected the decision (review stayed PENDING).
1246
1328
  */
1247
- resolutionId: string;
1329
+ resolutionId?: string;
1248
1330
  /**
1249
1331
  * Whether this decision can be undone
1250
1332
  */
1251
- canUndo: boolean;
1333
+ canUndo?: boolean;
1252
1334
  /**
1253
1335
  * Deadline for undo (24h from resolution)
1254
1336
  */
1255
- undoDeadline: string;
1337
+ undoDeadline?: string;
1256
1338
  /**
1257
1339
  * Rule ID if learning was triggered (ACCEPT_AND_LEARN actions). Use this to deep-link to the rule management page.
1258
1340
  */
@@ -2947,6 +3029,96 @@ export type UpdatePropertyDto = {
2947
3029
  value: string;
2948
3030
  };
2949
3031
 
3032
+ export type CreateBeanEventDto = {
3033
+ /**
3034
+ * Life event date (ISO 8601)
3035
+ */
3036
+ date: string;
3037
+ /**
3038
+ * Life event type (e.g., "employer", "location", "marital-status") — user-defined, no enum constraint at engine layer
3039
+ */
3040
+ type: string;
3041
+ /**
3042
+ * Life event description. Empty string is a VALID value (distinct from absence).
3043
+ */
3044
+ description: string;
3045
+ /**
3046
+ * Product-side metadata (lives in BeanEvent.meta JSON, never in engine Event fields)
3047
+ */
3048
+ meta?: {
3049
+ [key: string]: unknown;
3050
+ };
3051
+ };
3052
+
3053
+ export type EventResponseDto = {
3054
+ /**
3055
+ * Unique identifier
3056
+ */
3057
+ id: string;
3058
+ /**
3059
+ * User ID (owner of the life event)
3060
+ */
3061
+ userId: string;
3062
+ /**
3063
+ * Life event date (ISO 8601 format)
3064
+ */
3065
+ date: string;
3066
+ /**
3067
+ * Life event type (user-defined, e.g., "employer", "location")
3068
+ */
3069
+ type: string;
3070
+ /**
3071
+ * Life event description. May be an empty string (a valid value distinct from absence).
3072
+ */
3073
+ description: string;
3074
+ /**
3075
+ * Product-side metadata (free-form JSON)
3076
+ */
3077
+ meta: {
3078
+ [key: string]: unknown;
3079
+ };
3080
+ /**
3081
+ * Creation timestamp
3082
+ */
3083
+ createdAt: string;
3084
+ /**
3085
+ * Last update timestamp. Also emitted as the ETag response header for If-Match optimistic concurrency.
3086
+ */
3087
+ updatedAt: string;
3088
+ };
3089
+
3090
+ export type EventListResponseDto = {
3091
+ /**
3092
+ * List of life events
3093
+ */
3094
+ items: Array<EventResponseDto>;
3095
+ /**
3096
+ * Total number of life events matching the query
3097
+ */
3098
+ total: number;
3099
+ };
3100
+
3101
+ export type UpdateBeanEventDto = {
3102
+ /**
3103
+ * Life event date (ISO 8601)
3104
+ */
3105
+ date?: string;
3106
+ /**
3107
+ * Life event type (user-defined)
3108
+ */
3109
+ type?: string;
3110
+ /**
3111
+ * Life event description. Empty string is a VALID value (distinct from absence).
3112
+ */
3113
+ description?: string;
3114
+ /**
3115
+ * Product-side metadata (free-form JSON)
3116
+ */
3117
+ meta?: {
3118
+ [key: string]: unknown;
3119
+ };
3120
+ };
3121
+
2950
3122
  export type FileImportDto = {
2951
3123
  /**
2952
3124
  * Bill file to import (CSV, PDF, OFX, etc.)
@@ -4837,6 +5009,71 @@ export type PortfolioTrendsResponseDto = {
4837
5009
  warnings?: Array<ExchangeRateWarningDto>;
4838
5010
  };
4839
5011
 
5012
+ export type CashFlowPointDto = {
5013
+ /**
5014
+ * Month key (YYYY-MM)
5015
+ */
5016
+ month: string;
5017
+ /**
5018
+ * Income in base currency (absolute, converted)
5019
+ */
5020
+ income: string;
5021
+ /**
5022
+ * Expense in base currency (absolute, converted)
5023
+ */
5024
+ expense: string;
5025
+ /**
5026
+ * netSavings = income − expense (savings positive)
5027
+ */
5028
+ netSavings: string;
5029
+ };
5030
+
5031
+ export type CashFlowTrendSummaryDto = {
5032
+ /**
5033
+ * Total income across the period
5034
+ */
5035
+ totalIncome: string;
5036
+ /**
5037
+ * Total expense across the period
5038
+ */
5039
+ totalExpense: string;
5040
+ /**
5041
+ * income − expense across the period
5042
+ */
5043
+ totalNetSavings: string;
5044
+ /**
5045
+ * totalNetSavings divided by the window length (N months, incl. zero-filled)
5046
+ */
5047
+ averageMonthlyNetSavings: string;
5048
+ };
5049
+
5050
+ export type CashFlowTrendsResponseDto = {
5051
+ /**
5052
+ * Monthly cash-flow series (fixed N-month window, zero-filled)
5053
+ */
5054
+ series: Array<CashFlowPointDto>;
5055
+ /**
5056
+ * Period totals
5057
+ */
5058
+ summary: CashFlowTrendSummaryDto;
5059
+ /**
5060
+ * Period requested
5061
+ */
5062
+ period: string;
5063
+ /**
5064
+ * Data granularity (v1 returns month buckets)
5065
+ */
5066
+ granularity: string;
5067
+ /**
5068
+ * Base currency for converted values
5069
+ */
5070
+ currency: string;
5071
+ /**
5072
+ * Exchange rate warnings (e.g. missing rate for a currency)
5073
+ */
5074
+ warnings?: Array<ExchangeRateWarningDto>;
5075
+ };
5076
+
4840
5077
  export type GenerateSnapshotBody = unknown;
4841
5078
 
4842
5079
  export type GenerateSnapshotResponse = unknown;
@@ -6014,6 +6251,104 @@ export type PropertyControllerDeleteData = {
6014
6251
 
6015
6252
  export type PropertyControllerDeleteResponse = void;
6016
6253
 
6254
+ export type EventControllerCreateData = {
6255
+ /**
6256
+ * Region code for tenant context (decorative for life events)
6257
+ */
6258
+ region: 'cn' | 'us' | 'de' | 'gb';
6259
+ requestBody: CreateBeanEventDto;
6260
+ };
6261
+
6262
+ export type EventControllerCreateResponse = EventResponseDto;
6263
+
6264
+ export type EventControllerFindAllData = {
6265
+ /**
6266
+ * Filter life events from this date (ISO 8601 format)
6267
+ */
6268
+ from?: string;
6269
+ /**
6270
+ * Number of items per page (default: 20, max: 100)
6271
+ */
6272
+ limit?: number;
6273
+ /**
6274
+ * Page number for pagination (default: 1)
6275
+ */
6276
+ page?: number;
6277
+ /**
6278
+ * Search term for description (case-insensitive partial match)
6279
+ */
6280
+ q?: string;
6281
+ /**
6282
+ * Region code for tenant context (decorative for life events)
6283
+ */
6284
+ region: 'cn' | 'us' | 'de' | 'gb';
6285
+ /**
6286
+ * Filter life events to this date (ISO 8601 format)
6287
+ */
6288
+ to?: string;
6289
+ /**
6290
+ * Filter by life event type (exact match)
6291
+ */
6292
+ type?: string;
6293
+ };
6294
+
6295
+ export type EventControllerFindAllResponse = EventListResponseDto;
6296
+
6297
+ export type EventControllerFindOneData = {
6298
+ /**
6299
+ * Life event ID
6300
+ */
6301
+ id: string;
6302
+ /**
6303
+ * Region code for tenant context (decorative for life events)
6304
+ */
6305
+ region: 'cn' | 'us' | 'de' | 'gb';
6306
+ };
6307
+
6308
+ export type EventControllerFindOneResponse = EventResponseDto;
6309
+
6310
+ export type EventControllerUpdateData = {
6311
+ /**
6312
+ * Life event ID
6313
+ */
6314
+ id: string;
6315
+ /**
6316
+ * Region code for tenant context (decorative for life events)
6317
+ */
6318
+ region: 'cn' | 'us' | 'de' | 'gb';
6319
+ requestBody: UpdateBeanEventDto;
6320
+ };
6321
+
6322
+ export type EventControllerUpdateResponse = EventResponseDto;
6323
+
6324
+ export type EventControllerDeleteData = {
6325
+ /**
6326
+ * Life event ID
6327
+ */
6328
+ id: string;
6329
+ /**
6330
+ * Region code for tenant context (decorative for life events)
6331
+ */
6332
+ region: 'cn' | 'us' | 'de' | 'gb';
6333
+ };
6334
+
6335
+ export type EventControllerDeleteResponse = void;
6336
+
6337
+ export type EventControllerGetSliceData = {
6338
+ accountPattern: string;
6339
+ granularity: string;
6340
+ /**
6341
+ * Life event ID
6342
+ */
6343
+ id: string;
6344
+ /**
6345
+ * Region code for tenant context (decorative for life events)
6346
+ */
6347
+ region: 'cn' | 'us' | 'de' | 'gb';
6348
+ };
6349
+
6350
+ export type EventControllerGetSliceResponse = unknown;
6351
+
6017
6352
  export type ExportControllerExportBeancountResponse = unknown;
6018
6353
 
6019
6354
  export type FileImportControllerImportFileData = {
@@ -6455,6 +6790,24 @@ export type ReportingControllerGetPortfolioTrendsData = {
6455
6790
  export type ReportingControllerGetPortfolioTrendsResponse =
6456
6791
  PortfolioTrendsResponseDto;
6457
6792
 
6793
+ export type ReportingControllerGetCashFlowTrendsData = {
6794
+ /**
6795
+ * Data granularity (accepted for API symmetry; v1 returns month buckets)
6796
+ */
6797
+ granularity?: 'day' | 'week' | 'month';
6798
+ /**
6799
+ * Time period
6800
+ */
6801
+ period?: '1m' | '3m' | '6m' | '1y';
6802
+ /**
6803
+ * Region code for tenant context
6804
+ */
6805
+ region: 'cn' | 'us' | 'de' | 'gb';
6806
+ };
6807
+
6808
+ export type ReportingControllerGetCashFlowTrendsResponse =
6809
+ CashFlowTrendsResponseDto;
6810
+
6458
6811
  export type ReportingControllerGenerateSnapshotData = {
6459
6812
  /**
6460
6813
  * Region code for tenant context
@@ -7886,6 +8239,102 @@ export type $OpenApiTs = {
7886
8239
  };
7887
8240
  };
7888
8241
  };
8242
+ '/api/v1/{region}/bean/events': {
8243
+ post: {
8244
+ req: EventControllerCreateData;
8245
+ res: {
8246
+ /**
8247
+ * Life event created successfully
8248
+ */
8249
+ 201: EventResponseDto;
8250
+ /**
8251
+ * Life event already exists for this (userId, type, date) combination
8252
+ */
8253
+ 409: unknown;
8254
+ };
8255
+ };
8256
+ get: {
8257
+ req: EventControllerFindAllData;
8258
+ res: {
8259
+ /**
8260
+ * Life events retrieved successfully
8261
+ */
8262
+ 200: EventListResponseDto;
8263
+ };
8264
+ };
8265
+ };
8266
+ '/api/v1/{region}/bean/events/{id}': {
8267
+ get: {
8268
+ req: EventControllerFindOneData;
8269
+ res: {
8270
+ /**
8271
+ * Life event retrieved successfully
8272
+ */
8273
+ 200: EventResponseDto;
8274
+ /**
8275
+ * Life event not found
8276
+ */
8277
+ 404: unknown;
8278
+ };
8279
+ };
8280
+ put: {
8281
+ req: EventControllerUpdateData;
8282
+ res: {
8283
+ /**
8284
+ * Life event updated successfully
8285
+ */
8286
+ 200: EventResponseDto;
8287
+ /**
8288
+ * If-Match header is not a valid ISO 8601 date
8289
+ */
8290
+ 400: unknown;
8291
+ /**
8292
+ * Life event not found
8293
+ */
8294
+ 404: unknown;
8295
+ /**
8296
+ * Updated event conflicts with an existing (userId, type, date) combination
8297
+ */
8298
+ 409: unknown;
8299
+ /**
8300
+ * If-Match precondition failed (updatedAt mismatch)
8301
+ */
8302
+ 412: unknown;
8303
+ };
8304
+ };
8305
+ delete: {
8306
+ req: EventControllerDeleteData;
8307
+ res: {
8308
+ /**
8309
+ * Life event deleted successfully
8310
+ */
8311
+ 204: void;
8312
+ /**
8313
+ * Life event not found
8314
+ */
8315
+ 404: unknown;
8316
+ };
8317
+ };
8318
+ };
8319
+ '/api/v1/{region}/bean/events/{id}/slice': {
8320
+ get: {
8321
+ req: EventControllerGetSliceData;
8322
+ res: {
8323
+ /**
8324
+ * Time-series sliced by the life event range
8325
+ */
8326
+ 200: unknown;
8327
+ /**
8328
+ * accountPattern query param is empty
8329
+ */
8330
+ 400: unknown;
8331
+ /**
8332
+ * Life event not found
8333
+ */
8334
+ 404: unknown;
8335
+ };
8336
+ };
8337
+ };
7889
8338
  '/api/v1/{region}/bean/export/beancount': {
7890
8339
  get: {
7891
8340
  res: {
@@ -8419,6 +8868,21 @@ export type $OpenApiTs = {
8419
8868
  };
8420
8869
  };
8421
8870
  };
8871
+ '/api/v1/{region}/reporting/cash-flow/trends': {
8872
+ get: {
8873
+ req: ReportingControllerGetCashFlowTrendsData;
8874
+ res: {
8875
+ /**
8876
+ * Cash-flow trends retrieved successfully
8877
+ */
8878
+ 200: CashFlowTrendsResponseDto;
8879
+ /**
8880
+ * User not authenticated
8881
+ */
8882
+ 401: unknown;
8883
+ };
8884
+ };
8885
+ };
8422
8886
  '/api/v1/{region}/reporting/snapshots/generate': {
8423
8887
  post: {
8424
8888
  req: ReportingControllerGenerateSnapshotData;