@firela/api-types 0.0.0-canary.6feee68d → 0.0.0-canary.78c2840b

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.
@@ -393,7 +393,7 @@ export type PostingResponseDto = {
393
393
  */
394
394
  account: string;
395
395
  /**
396
- * Amount (may be null if interpolated)
396
+ * Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.
397
397
  */
398
398
  units?: string;
399
399
  /**
@@ -561,6 +561,55 @@ export type BatchTransactionResponseDto = {
561
561
  failed: Array<BatchTransactionErrorDto>;
562
562
  };
563
563
 
564
+ export type CorrectTransactionDto = {
565
+ /**
566
+ * Transaction date (ISO 8601 format)
567
+ */
568
+ date: string;
569
+ /**
570
+ * Transaction flag: * (cleared), ! (pending)
571
+ */
572
+ flag?: '*' | '!';
573
+ /**
574
+ * Payee name
575
+ */
576
+ payee?: string;
577
+ /**
578
+ * Transaction narration/description
579
+ */
580
+ narration: string;
581
+ /**
582
+ * Transaction tags (without # prefix)
583
+ */
584
+ tags?: Array<string>;
585
+ /**
586
+ * Transaction links (without ^ prefix)
587
+ */
588
+ links?: Array<string>;
589
+ /**
590
+ * Transaction postings (minimum 1, typically 2 for double-entry)
591
+ */
592
+ postings: Array<CreatePostingDto>;
593
+ /**
594
+ * Transaction-level metadata
595
+ */
596
+ meta?: {
597
+ [key: string]: unknown;
598
+ };
599
+ /**
600
+ * Unique key for idempotent transaction creation. If provided, duplicate requests with the same key will return the existing transaction.
601
+ */
602
+ idempotencyKey?: string;
603
+ /**
604
+ * Auto-create accounts if not found. When true, missing accounts will be automatically created. When false (default for API), missing accounts will cause a validation error. Set to true for quick entry scenarios where you want to create accounts on-the-fly.
605
+ */
606
+ autoCreateAccounts?: boolean;
607
+ /**
608
+ * Reason for correcting/superseding the original transaction
609
+ */
610
+ correctionReason?: string;
611
+ };
612
+
564
613
  export type PostingDetailDto = {
565
614
  /**
566
615
  * Posting ID
@@ -575,7 +624,7 @@ export type PostingDetailDto = {
575
624
  */
576
625
  accountName: string;
577
626
  /**
578
- * Amount (may be null if interpolated)
627
+ * Amount as decimal string. Typed optional but always present in responses: interpolation fills any MISSING posting before it is persisted or returned.
579
628
  */
580
629
  units?: string;
581
630
  /**
@@ -664,9 +713,9 @@ export type TransactionDetailDto = {
664
713
  */
665
714
  status: 'ACTIVE' | 'VOIDED' | 'SUPERSEDED';
666
715
  /**
667
- * Source type (how the transaction was created)
716
+ * Source type (free-form string from transaction metadata, e.g. import, api)
668
717
  */
669
- sourceType?: 'NLP' | 'CSV' | 'OCR' | 'API';
718
+ sourceType?: string;
670
719
  /**
671
720
  * Source platform (e.g., alipay, wechat)
672
721
  */
@@ -691,6 +740,14 @@ export type TransactionDetailDto = {
691
740
  * Correction reason (if voided or superseded)
692
741
  */
693
742
  correctionReason?: string;
743
+ /**
744
+ * ID of the transaction that supersedes this one (set when status=SUPERSEDED)
745
+ */
746
+ supersededBy?: string;
747
+ /**
748
+ * ID of the transaction this one corrected/replaced (back-link on the replacement)
749
+ */
750
+ originalTxn?: string;
694
751
  };
695
752
 
696
753
  /**
@@ -709,11 +766,6 @@ export type flag2 =
709
766
  */
710
767
  export type status2 = 'ACTIVE' | 'VOIDED' | 'SUPERSEDED';
711
768
 
712
- /**
713
- * Source type (how the transaction was created)
714
- */
715
- export type sourceType = 'NLP' | 'CSV' | 'OCR' | 'API';
716
-
717
769
  export type TransactionListResponseDto = {
718
770
  /**
719
771
  * List of transactions
@@ -733,6 +785,24 @@ export type TransactionListResponseDto = {
733
785
  offset: number;
734
786
  };
735
787
 
788
+ export type TagSuggestionDto = {
789
+ /**
790
+ * Tag name
791
+ */
792
+ tag: string;
793
+ /**
794
+ * Usage count across ACTIVE transactions
795
+ */
796
+ count: number;
797
+ };
798
+
799
+ export type TagSuggestionsResponseDto = {
800
+ /**
801
+ * Tag suggestions sorted as requested
802
+ */
803
+ data: Array<TagSuggestionDto>;
804
+ };
805
+
736
806
  export type UpdateTransactionDto = {
737
807
  /**
738
808
  * Transaction flag (CLEARED, PENDING, etc.)
@@ -834,9 +904,9 @@ export type TransactionSummaryDto = {
834
904
  */
835
905
  accountName?: string;
836
906
  /**
837
- * Source type (NLP, CSV, OCR, API)
907
+ * Source type (free-form string from transaction metadata, e.g. import, api)
838
908
  */
839
- sourceType?: 'NLP' | 'CSV' | 'OCR' | 'API';
909
+ sourceType?: string;
840
910
  /**
841
911
  * Source platform (e.g., alipay, wechat)
842
912
  */
@@ -866,9 +936,9 @@ export type ReviewSummaryDto = {
866
936
  */
867
937
  confidence: number;
868
938
  /**
869
- * Confidence level derived from score
939
+ * Confidence level derived from score. Null for error-type reviews (ACCOUNT_VALIDATION/PIPELINE_ERROR) which carry no confidence.
870
940
  */
871
- confidenceLevel: 'HIGH' | 'MEDIUM' | 'LOW';
941
+ confidenceLevel: 'HIGH' | 'MEDIUM' | 'LOW' | null;
872
942
  /**
873
943
  * i18n message key for summary (e.g., review.summary.duplicate). Translate on frontend with summaryParams.
874
944
  */
@@ -884,7 +954,7 @@ export type ReviewSummaryDto = {
884
954
  */
885
955
  matchReasons: Array<string>;
886
956
  /**
887
- * Source type (NLP, CSV, OCR, API)
957
+ * Source type (free-form string from transaction metadata, e.g. import, api)
888
958
  */
889
959
  sourceType: string;
890
960
  /**
@@ -937,7 +1007,7 @@ export type type2 =
937
1007
  export type status3 = 'PENDING' | 'RESOLVED' | 'EXPIRED' | 'CANCELLED';
938
1008
 
939
1009
  /**
940
- * Confidence level derived from score
1010
+ * Confidence level derived from score. Null for error-type reviews (ACCOUNT_VALIDATION/PIPELINE_ERROR) which carry no confidence.
941
1011
  */
942
1012
  export type confidenceLevel = 'HIGH' | 'MEDIUM' | 'LOW';
943
1013
 
@@ -982,7 +1052,18 @@ export type DecisionOptionDto = {
982
1052
  /**
983
1053
  * The action value to submit (e.g., UPGRADE_REPLACE, ACCEPT)
984
1054
  */
985
- value: string;
1055
+ value:
1056
+ | 'UPGRADE_REPLACE'
1057
+ | 'LINK_KEEP_BOTH'
1058
+ | 'IGNORE_NEW'
1059
+ | 'CONFIRM_DIFFERENT'
1060
+ | 'ACCEPT'
1061
+ | 'REJECT'
1062
+ | 'ACCEPT_AND_LEARN'
1063
+ | 'CHOOSE_OTHER'
1064
+ | 'CANCEL'
1065
+ | 'FIX'
1066
+ | 'IGNORE';
986
1067
  /**
987
1068
  * i18n message key for display label (e.g., review.payee.accept.label)
988
1069
  */
@@ -997,6 +1078,22 @@ export type DecisionOptionDto = {
997
1078
  recommended?: boolean;
998
1079
  };
999
1080
 
1081
+ /**
1082
+ * The action value to submit (e.g., UPGRADE_REPLACE, ACCEPT)
1083
+ */
1084
+ export type value =
1085
+ | 'UPGRADE_REPLACE'
1086
+ | 'LINK_KEEP_BOTH'
1087
+ | 'IGNORE_NEW'
1088
+ | 'CONFIRM_DIFFERENT'
1089
+ | 'ACCEPT'
1090
+ | 'REJECT'
1091
+ | 'ACCEPT_AND_LEARN'
1092
+ | 'CHOOSE_OTHER'
1093
+ | 'CANCEL'
1094
+ | 'FIX'
1095
+ | 'IGNORE';
1096
+
1000
1097
  export type ReviewDetailDto = {
1001
1098
  /**
1002
1099
  * Review item ID
@@ -1020,9 +1117,9 @@ export type ReviewDetailDto = {
1020
1117
  */
1021
1118
  confidence: number;
1022
1119
  /**
1023
- * Confidence level derived from score
1120
+ * Confidence level derived from score. Null for error-type reviews (ACCOUNT_VALIDATION/PIPELINE_ERROR) which carry no confidence.
1024
1121
  */
1025
- confidenceLevel: 'HIGH' | 'MEDIUM' | 'LOW';
1122
+ confidenceLevel: 'HIGH' | 'MEDIUM' | 'LOW' | null;
1026
1123
  /**
1027
1124
  * i18n message key for summary (e.g., review.summary.duplicate). Translate on frontend with summaryParams.
1028
1125
  */
@@ -1038,7 +1135,7 @@ export type ReviewDetailDto = {
1038
1135
  */
1039
1136
  matchReasons: Array<string>;
1040
1137
  /**
1041
- * Source type (NLP, CSV, OCR, API)
1138
+ * Source type (free-form string from transaction metadata, e.g. import, api)
1042
1139
  */
1043
1140
  sourceType: string;
1044
1141
  /**
@@ -1091,9 +1188,20 @@ export type ReviewDetailDto = {
1091
1188
 
1092
1189
  export type ResolveReviewDto = {
1093
1190
  /**
1094
- * Decision action. Available actions vary by review type: DUPLICATE: UPGRADE_REPLACE, KEEP_EXISTING, KEEP_BOTH | PAYEE_MATCH: ACCEPT, REJECT, ACCEPT_AND_LEARN | ACCOUNT_VALIDATION: FIX, REJECT | RULE_MATCH: ACCEPT, REJECT, ACCEPT_AND_LEARN
1191
+ * Decision action. Valid actions vary by review type — see DecisionOptionDto.value returned by the review detail endpoint.
1095
1192
  */
1096
- action: string;
1193
+ action:
1194
+ | 'UPGRADE_REPLACE'
1195
+ | 'LINK_KEEP_BOTH'
1196
+ | 'IGNORE_NEW'
1197
+ | 'CONFIRM_DIFFERENT'
1198
+ | 'ACCEPT'
1199
+ | 'REJECT'
1200
+ | 'ACCEPT_AND_LEARN'
1201
+ | 'CHOOSE_OTHER'
1202
+ | 'CANCEL'
1203
+ | 'FIX'
1204
+ | 'IGNORE';
1097
1205
  /**
1098
1206
  * Additional data for the decision (e.g., selected account ID)
1099
1207
  */
@@ -1102,6 +1210,22 @@ export type ResolveReviewDto = {
1102
1210
  };
1103
1211
  };
1104
1212
 
1213
+ /**
1214
+ * Decision action. Valid actions vary by review type — see DecisionOptionDto.value returned by the review detail endpoint.
1215
+ */
1216
+ export type action =
1217
+ | 'UPGRADE_REPLACE'
1218
+ | 'LINK_KEEP_BOTH'
1219
+ | 'IGNORE_NEW'
1220
+ | 'CONFIRM_DIFFERENT'
1221
+ | 'ACCEPT'
1222
+ | 'REJECT'
1223
+ | 'ACCEPT_AND_LEARN'
1224
+ | 'CHOOSE_OTHER'
1225
+ | 'CANCEL'
1226
+ | 'FIX'
1227
+ | 'IGNORE';
1228
+
1105
1229
  export type ResolveResultDto = {
1106
1230
  /**
1107
1231
  * Whether resolution was successful
@@ -1158,7 +1282,18 @@ export type BatchResolveDto = {
1158
1282
  /**
1159
1283
  * Decision action to apply to all items
1160
1284
  */
1161
- action: string;
1285
+ action:
1286
+ | 'UPGRADE_REPLACE'
1287
+ | 'LINK_KEEP_BOTH'
1288
+ | 'IGNORE_NEW'
1289
+ | 'CONFIRM_DIFFERENT'
1290
+ | 'ACCEPT'
1291
+ | 'REJECT'
1292
+ | 'ACCEPT_AND_LEARN'
1293
+ | 'CHOOSE_OTHER'
1294
+ | 'CANCEL'
1295
+ | 'FIX'
1296
+ | 'IGNORE';
1162
1297
  /**
1163
1298
  * Additional data for the decision
1164
1299
  */
@@ -3821,7 +3956,7 @@ export type status4 = 'success' | 'pending' | 'error';
3821
3956
  /**
3822
3957
  * Action taken or requested
3823
3958
  */
3824
- export type action =
3959
+ export type action2 =
3825
3960
  | 'created'
3826
3961
  | 'ask'
3827
3962
  | 'confirm'
@@ -4563,6 +4698,42 @@ export type TransactionControllerCreateBatchData = {
4563
4698
  export type TransactionControllerCreateBatchResponse =
4564
4699
  BatchTransactionResponseDto;
4565
4700
 
4701
+ export type TransactionControllerCorrectData = {
4702
+ /**
4703
+ * Original transaction ID to correct
4704
+ */
4705
+ id: string;
4706
+ /**
4707
+ * Region code for tenant context
4708
+ */
4709
+ region: 'cn' | 'us' | 'de' | 'gb';
4710
+ requestBody: CorrectTransactionDto;
4711
+ };
4712
+
4713
+ export type TransactionControllerCorrectResponse = TransactionDetailDto;
4714
+
4715
+ export type TransactionControllerSuggestTagsData = {
4716
+ /**
4717
+ * Max suggestions (1-100, default 10)
4718
+ */
4719
+ limit?: number;
4720
+ /**
4721
+ * Prefix match, case-insensitive (max 50 chars)
4722
+ */
4723
+ q?: string;
4724
+ /**
4725
+ * Region code for tenant context
4726
+ */
4727
+ region: 'cn' | 'us' | 'de' | 'gb';
4728
+ /**
4729
+ * usage (default) or name
4730
+ */
4731
+ sort?: 'usage' | 'name';
4732
+ };
4733
+
4734
+ export type TransactionControllerSuggestTagsResponse =
4735
+ TagSuggestionsResponseDto;
4736
+
4566
4737
  export type TransactionControllerGetDetailData = {
4567
4738
  /**
4568
4739
  * Transaction ID
@@ -6041,6 +6212,48 @@ export type $OpenApiTs = {
6041
6212
  };
6042
6213
  };
6043
6214
  };
6215
+ '/api/v1/{region}/bean/transactions/{id}/correct': {
6216
+ post: {
6217
+ req: TransactionControllerCorrectData;
6218
+ res: {
6219
+ /**
6220
+ * Corrected transaction created
6221
+ */
6222
+ 201: TransactionDetailDto;
6223
+ /**
6224
+ * Original transaction not found
6225
+ */
6226
+ 404: ApiProblemResponseDto;
6227
+ /**
6228
+ * Original no longer ACTIVE (concurrent modification)
6229
+ */
6230
+ 409: ApiProblemResponseDto;
6231
+ /**
6232
+ * Pipeline validation failed (does not balance, invalid accounts)
6233
+ */
6234
+ 422: ApiProblemResponseDto;
6235
+ };
6236
+ };
6237
+ };
6238
+ '/api/v1/{region}/bean/transactions/tags': {
6239
+ get: {
6240
+ req: TransactionControllerSuggestTagsData;
6241
+ res: {
6242
+ /**
6243
+ * Tag suggestions
6244
+ */
6245
+ 200: TagSuggestionsResponseDto;
6246
+ /**
6247
+ * Validation failed
6248
+ */
6249
+ 400: ApiProblemResponseDto;
6250
+ /**
6251
+ * Authentication required
6252
+ */
6253
+ 401: ApiProblemResponseDto;
6254
+ };
6255
+ };
6256
+ };
6044
6257
  '/api/v1/{region}/bean/transactions/{id}': {
6045
6258
  get: {
6046
6259
  req: TransactionControllerGetDetailData;