@zeniai/client-epic-state 5.1.92-beta0NB → 5.1.92-beta0ND

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.
Files changed (61) hide show
  1. package/lib/entity/accountRecon/accountReconReducer.js +0 -4
  2. package/lib/entity/accountRecon/accountReconState.d.ts +1 -4
  3. package/lib/entity/accountRecon/accountReconState.js +0 -1
  4. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  5. package/lib/entity/snackbar/snackbarTypes.js +0 -1
  6. package/lib/epic.d.ts +2 -4
  7. package/lib/epic.js +2 -4
  8. package/lib/esm/entity/accountRecon/accountReconReducer.js +0 -4
  9. package/lib/esm/entity/accountRecon/accountReconState.js +0 -1
  10. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -1
  11. package/lib/esm/epic.js +2 -4
  12. package/lib/esm/index.js +5 -5
  13. package/lib/esm/view/expenseAutomationView/epics/accountRecon/parseStatementEpic.js +18 -15
  14. package/lib/esm/view/expenseAutomationView/epics/accountRecon/updateStatementInfoEpic.js +10 -10
  15. package/lib/esm/view/expenseAutomationView/epics/accountRecon/uploadAccountStatementDocumentAIHelper.js +4 -12
  16. package/lib/esm/view/expenseAutomationView/epics/accountRecon/uploadAccountStatementEpic.js +2 -8
  17. package/lib/esm/view/expenseAutomationView/helpers/mapStatementUpdateLocalDataToRequestBody.js +5 -20
  18. package/lib/esm/view/expenseAutomationView/payload/reconciliationPayload.js +0 -135
  19. package/lib/esm/view/expenseAutomationView/reducers/reconciliationViewReducer.js +16 -119
  20. package/lib/esm/view/expenseAutomationView/selectors/reconciliationViewSelector.js +7 -28
  21. package/lib/esm/view/expenseAutomationView/selectors/statementParseViewSelector.js +10 -43
  22. package/lib/esm/view/expenseAutomationView/types/reconciliationViewState.js +1 -15
  23. package/lib/esm/view/recommendation/recommendationReducer.js +17 -1
  24. package/lib/esm/view/recommendation/submitRecommendationFeedbackEpic.js +52 -0
  25. package/lib/index.d.ts +6 -6
  26. package/lib/index.js +47 -50
  27. package/lib/view/expenseAutomationView/epics/accountRecon/parseStatementEpic.d.ts +1 -21
  28. package/lib/view/expenseAutomationView/epics/accountRecon/parseStatementEpic.js +18 -15
  29. package/lib/view/expenseAutomationView/epics/accountRecon/updateStatementInfoEpic.js +10 -10
  30. package/lib/view/expenseAutomationView/epics/accountRecon/uploadAccountStatementDocumentAIHelper.d.ts +1 -1
  31. package/lib/view/expenseAutomationView/epics/accountRecon/uploadAccountStatementDocumentAIHelper.js +4 -12
  32. package/lib/view/expenseAutomationView/epics/accountRecon/uploadAccountStatementEpic.js +1 -7
  33. package/lib/view/expenseAutomationView/helpers/mapStatementUpdateLocalDataToRequestBody.d.ts +0 -1
  34. package/lib/view/expenseAutomationView/helpers/mapStatementUpdateLocalDataToRequestBody.js +4 -20
  35. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  36. package/lib/view/expenseAutomationView/payload/reconciliationPayload.d.ts +4 -109
  37. package/lib/view/expenseAutomationView/payload/reconciliationPayload.js +0 -143
  38. package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.d.ts +4 -32
  39. package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.js +18 -121
  40. package/lib/view/expenseAutomationView/selectorTypes/reconciliationViewSelectorTypes.d.ts +1 -5
  41. package/lib/view/expenseAutomationView/selectors/reconciliationViewSelector.d.ts +1 -3
  42. package/lib/view/expenseAutomationView/selectors/reconciliationViewSelector.js +7 -29
  43. package/lib/view/expenseAutomationView/selectors/statementParseViewSelector.d.ts +2 -3
  44. package/lib/view/expenseAutomationView/selectors/statementParseViewSelector.js +10 -44
  45. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -74
  46. package/lib/view/expenseAutomationView/types/reconciliationViewState.js +1 -19
  47. package/lib/view/recommendation/recommendationPayload.d.ts +34 -0
  48. package/lib/view/recommendation/recommendationReducer.d.ts +2 -1
  49. package/lib/view/recommendation/recommendationReducer.js +18 -2
  50. package/lib/view/recommendation/submitRecommendationFeedbackEpic.d.ts +7 -0
  51. package/lib/view/recommendation/submitRecommendationFeedbackEpic.js +56 -0
  52. package/package.json +1 -1
  53. package/lib/esm/view/expenseAutomationView/epics/accountRecon/confirmStatementMappingEpic.js +0 -43
  54. package/lib/esm/view/expenseAutomationView/epics/accountRecon/parseCombinedStatementEpic.js +0 -31
  55. package/lib/esm/view/expenseAutomationView/epics/accountRecon/updateCombinedStatementInfoEpic.js +0 -68
  56. package/lib/view/expenseAutomationView/epics/accountRecon/confirmStatementMappingEpic.d.ts +0 -34
  57. package/lib/view/expenseAutomationView/epics/accountRecon/confirmStatementMappingEpic.js +0 -47
  58. package/lib/view/expenseAutomationView/epics/accountRecon/parseCombinedStatementEpic.d.ts +0 -26
  59. package/lib/view/expenseAutomationView/epics/accountRecon/parseCombinedStatementEpic.js +0 -35
  60. package/lib/view/expenseAutomationView/epics/accountRecon/updateCombinedStatementInfoEpic.d.ts +0 -27
  61. package/lib/view/expenseAutomationView/epics/accountRecon/updateCombinedStatementInfoEpic.js +0 -72
@@ -29,9 +29,6 @@ export interface StatementTransaction {
29
29
  transactionDirection: 'debit' | 'credit';
30
30
  transactionMemo: string;
31
31
  }
32
- export declare const toStatementBalanceSource: (v: string) => "ocr" | "prior_recon" | "default_zero";
33
- export type StatementBalanceSource = ReturnType<typeof toStatementBalanceSource>;
34
- export declare const toStatementBalanceSourceStrict: (v: string | null | undefined) => StatementBalanceSource | undefined;
35
32
  export interface StatementMeta {
36
33
  closingBalance: number;
37
34
  openingBalance: number;
@@ -48,10 +45,6 @@ export interface StatementMeta {
48
45
  statementUploadId: string;
49
46
  totalDeposits: number;
50
47
  totalPayments: number;
51
- balanceSource?: StatementBalanceSource;
52
- combinedStatementGroupId?: string;
53
- isCombinedStatement?: boolean;
54
- isCombinedStatementAnchor?: boolean;
55
48
  }
56
49
  export interface AccountInfo {
57
50
  accountId: string;
@@ -99,63 +92,15 @@ export interface AiSummary {
99
92
  fieldsCaptured: AiSummaryField[];
100
93
  transactionsExtracted: number;
101
94
  }
102
- export interface CombinedStatementAccountSuggestion {
103
- accountId: ID;
104
- accountName: string;
105
- matchConfidence: number;
106
- matchedBy: string;
107
- }
108
- export interface CombinedStatementAccount {
109
- accountName: string;
110
- accountType: string;
111
- closingBalance: number;
112
- isUploadContext: boolean;
113
- ledgerIdentifier: string;
114
- maskedAccountNumber: string;
115
- openingBalance: number;
116
- transactionCount: number;
117
- existingStatementStatus?: {
118
- code: string;
119
- label: string;
120
- } | null;
121
- suggestion?: CombinedStatementAccountSuggestion | null;
122
- }
123
- export interface CombinedStatementDetails {
124
- accounts: CombinedStatementAccount[];
125
- combinedStatementGroupId: string;
126
- isMappingConfirmed: boolean;
127
- statementUploads: ConfirmedCombinedStatementUpload[];
128
- }
129
- export interface ConfirmedCombinedStatementUpload {
130
- accountId: ID;
131
- isCombinedStatementAnchor: boolean;
132
- ledgerIdentifiers: string[];
133
- statementUploadId: ID;
134
- }
135
- export interface ConfirmStatementMappingConflict {
136
- collidingLedgerIdentifiers: string[];
137
- collidingAccountId?: ID;
138
- previousReconciliationInfo?: PreviousReconciliationInfo | null;
139
- }
140
95
  export interface StatementUpload {
141
96
  account: AccountInfo;
142
97
  file: FileInfo | null;
143
98
  statementMeta: StatementMeta;
144
99
  statementTransactions: StatementTransaction[];
145
100
  aiSummary?: AiSummary | null;
146
- combinedStatementDetails?: CombinedStatementDetails;
147
101
  }
148
102
  export interface ParsedStatementData {
149
- /**
150
- * Single-account parse: the only upload.
151
- * Combined-account parse: the anchor / PDF-owning upload (also in statementUploads).
152
- */
153
103
  statementUpload: StatementUpload;
154
- /**
155
- * Present only for combined multi-account parse responses after mapping.
156
- * When set, ParseInfo renders one section per upload.
157
- */
158
- statementUploads?: StatementUpload[];
159
104
  }
160
105
  export interface ReconciliationSummaryAccounts {
161
106
  done: number;
@@ -319,16 +264,9 @@ export interface StatementTransactionsUpdate {
319
264
  deletedIds: string[];
320
265
  updated: StatementTransactionForUpdate[];
321
266
  }
322
- /** Client-only totals derived from in-period transactions; not sent on PUT. */
323
- export interface StatementBalancesFromTransactions {
324
- closingBalance: number;
325
- totalDeposits: number;
326
- totalPayments: number;
327
- }
328
267
  export interface StatementUpdateLocalData {
329
268
  statementMeta: StatementMeta;
330
269
  statementTransactions: StatementTransactionsUpdate;
331
- balancesFromTransactions?: StatementBalancesFromTransactions;
332
270
  }
333
271
  export interface StatementUpdateLocalDataPayload {
334
272
  statement_meta: {
@@ -356,20 +294,12 @@ export interface StatementUpdateLocalDataPayload {
356
294
  }>;
357
295
  };
358
296
  }
359
- export declare const toStatementAccountScope: (v: string) => "single_account" | "multi_account";
360
- export type StatementAccountScope = ReturnType<typeof toStatementAccountScope>;
361
- export declare const toStatementAccountScopeStrict: (v: string | null | undefined) => StatementAccountScope | undefined;
362
- export declare const STATEMENT_ACCOUNT_SCOPES: readonly StatementAccountScope[];
363
297
  export interface AccountReconciliationLocalData {
364
298
  accountSource?: ReconciliationAccountSourceType;
365
- statementAccountScope?: StatementAccountScope;
366
- /** Confirm & Save drafts keyed by statementUploadId (single and combined). */
367
- statementUpdateLocalDataByUploadId?: Record<string, StatementUpdateLocalData>;
299
+ statementUpdateLocalData?: StatementUpdateLocalData;
368
300
  }
369
301
  export interface AccountReconciliationDataWithTransactionFetchState {
370
302
  accountId: ID;
371
- confirmStatementMappingConflict: ConfirmStatementMappingConflict | null;
372
- confirmStatementMappingStatus: FetchStateAndError;
373
303
  localData: AccountReconciliationLocalData;
374
304
  refreshStatus: FetchStateAndError;
375
305
  reparseStatementStatus: FetchStateAndError;
@@ -389,9 +319,6 @@ export interface AccountReconciliationDataWithTransactionFetchState {
389
319
  statementUploadStatus: FetchStateAndError;
390
320
  transactionFetchState: FetchStateAndError;
391
321
  accountDetectionReason?: string;
392
- /** Persisted after mapping confirm for batch GET / group pusher resolution. */
393
- combinedStatementGroupId?: string;
394
- confirmedCombinedStatementUploads?: ConfirmedCombinedStatementUpload[];
395
322
  parsedStatementData?: ParsedStatementData;
396
323
  reconciliationId?: ID;
397
324
  /** Wall-clock start used to recompute UI step progress after backgrounding. */
@@ -1,17 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STATEMENT_ACCOUNT_SCOPES = exports.toStatementAccountScopeStrict = exports.toStatementAccountScope = exports.toReconciliationTabsType = exports.toReconcileActions = exports.RECONCILE_ACTIONS = exports.toStatementBalanceSourceStrict = exports.toStatementBalanceSource = void 0;
3
+ exports.toReconciliationTabsType = exports.toReconcileActions = exports.RECONCILE_ACTIONS = void 0;
4
4
  exports.toReconciliationViewSummary = toReconciliationViewSummary;
5
5
  const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
6
- const ALL_STATEMENT_BALANCE_SOURCES = [
7
- 'ocr',
8
- 'prior_recon',
9
- 'default_zero',
10
- ];
11
- const toStatementBalanceSource = (v) => (0, stringToUnion_1.stringToUnion)(v, ALL_STATEMENT_BALANCE_SOURCES);
12
- exports.toStatementBalanceSource = toStatementBalanceSource;
13
- const toStatementBalanceSourceStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v ?? '', ALL_STATEMENT_BALANCE_SOURCES);
14
- exports.toStatementBalanceSourceStrict = toStatementBalanceSourceStrict;
15
6
  function toReconciliationViewSummary(payload) {
16
7
  return {
17
8
  accounts: {
@@ -74,12 +65,3 @@ const RECON_REVIEW_SORT_KEYS = [
74
65
  ];
75
66
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
76
67
  const toReconReviewSortKey = (v) => (0, stringToUnion_1.stringToUnion)(v, RECON_REVIEW_SORT_KEYS);
77
- const ALL_STATEMENT_ACCOUNT_SCOPES = [
78
- 'single_account',
79
- 'multi_account',
80
- ];
81
- const toStatementAccountScope = (v) => (0, stringToUnion_1.stringToUnion)(v, ALL_STATEMENT_ACCOUNT_SCOPES);
82
- exports.toStatementAccountScope = toStatementAccountScope;
83
- const toStatementAccountScopeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v ?? '', ALL_STATEMENT_ACCOUNT_SCOPES);
84
- exports.toStatementAccountScopeStrict = toStatementAccountScopeStrict;
85
- exports.STATEMENT_ACCOUNT_SCOPES = ALL_STATEMENT_ACCOUNT_SCOPES;
@@ -12,4 +12,38 @@ interface FetchRecommendationPayloadWithCOT {
12
12
  recommendations: RecommendationPayloadWithCOT[];
13
13
  }
14
14
  export type FetchRecommendationResponseWithCOT = ZeniAPIResponse<FetchRecommendationPayloadWithCOT>;
15
+ export type RecommendationFeedbackDimension = 'vendor' | 'category' | 'class';
16
+ export type RecommendationFeedbackSource = 'primary' | 'alternate' | 'shadow' | 'qbo';
17
+ export type RecommendationFeedbackOutcome = 'accepted' | 'override_ranked' | 'override_outside' | 'retracted';
18
+ export interface RecommendationFeedbackValue {
19
+ name: string;
20
+ id?: string | null;
21
+ integrationId?: string | null;
22
+ }
23
+ export interface ShownRecommendationForFeedback {
24
+ rank: number;
25
+ source: RecommendationFeedbackSource;
26
+ value: RecommendationFeedbackValue;
27
+ confidence?: number | null;
28
+ cot?: string[];
29
+ reasoning?: string | null;
30
+ }
31
+ export interface SubmitRecommendationFeedbackPayload {
32
+ dimension: RecommendationFeedbackDimension;
33
+ outcome: RecommendationFeedbackOutcome;
34
+ selected: RecommendationFeedbackValue & {
35
+ isNewEntity?: boolean;
36
+ };
37
+ transactionId: string;
38
+ features?: Record<string, unknown> | null;
39
+ lineId?: string | null;
40
+ matchedRank?: number | null;
41
+ matchedSource?: RecommendationFeedbackSource | null;
42
+ reasonText?: string | null;
43
+ recommendationSetId?: string | null;
44
+ retractsFeedbackId?: string | null;
45
+ shownRecommendations?: ShownRecommendationForFeedback[];
46
+ skipped?: boolean;
47
+ topPickSource?: RecommendationFeedbackSource | null;
48
+ }
15
49
  export {};
@@ -5,6 +5,7 @@ import { TransactionID } from '../../entity/transaction/stateTypes/transaction';
5
5
  import { SupportedTransaction } from '../../entity/transaction/transactionState';
6
6
  import { ZeniAPIStatus } from '../../responsePayload';
7
7
  import { TransactionsTab } from '../expenseAutomationView/types/transactionsViewState';
8
+ import { SubmitRecommendationFeedbackPayload } from './recommendationPayload';
8
9
  import { EntityRecommendationState } from './recommendationState';
9
10
  export type RecommendationLineUpdateFlowType = 'categorization' | 'detail';
10
11
  type FetchEntityRecommendationsForLineUpdateCommonPayload = {
@@ -57,6 +58,6 @@ export declare const fetchEntityRecommendationsByTransactionId: import("@reduxjs
57
58
  }, "recommendation/updateRecommendationForEntityFailure">, indicateReadyToInitializeRecommendation: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[entityIdOrName: string, entityType: EntityType], {
58
59
  entityIdOrName: string;
59
60
  entityType: EntityType;
60
- }, "recommendation/indicateReadyToInitializeRecommendation", never, never>, clearRecommendation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"recommendation/clearRecommendation">;
61
+ }, "recommendation/indicateReadyToInitializeRecommendation", never, never>, clearRecommendation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"recommendation/clearRecommendation">, submitRecommendationFeedback: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[args: SubmitRecommendationFeedbackPayload], SubmitRecommendationFeedbackPayload, "recommendation/submitRecommendationFeedback", never, never>;
61
62
  declare const _default: import("redux").Reducer<EntityRecommendationState>;
62
63
  export default _default;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearRecommendation = exports.indicateReadyToInitializeRecommendation = exports.updateRecommendationForEntityFailure = exports.updateRecommendationForEntity = exports.fetchRecommendationByEntityId = exports.fetchRecommendationByEntityName = exports.fetchEntityRecommendationsForLineUpdate = exports.fetchEntityRecommendationsByTransactionId = exports.initialState = void 0;
4
+ exports.submitRecommendationFeedback = exports.clearRecommendation = exports.indicateReadyToInitializeRecommendation = exports.updateRecommendationForEntityFailure = exports.updateRecommendationForEntity = exports.fetchRecommendationByEntityId = exports.fetchRecommendationByEntityName = exports.fetchEntityRecommendationsForLineUpdate = exports.fetchEntityRecommendationsByTransactionId = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const rootActions_1 = require("../../rootActions");
7
7
  const recommendationState_1 = require("./recommendationState");
@@ -138,6 +138,22 @@ const recommendation = (0, toolkit_1.createSlice)({
138
138
  clearRecommendation(draft) {
139
139
  Object.assign(draft, exports.initialState);
140
140
  },
141
+ // Fire-and-forget human feedback on a recommendation (accept, ranked
142
+ // override or outside override). Handled by submitRecommendationFeedbackEpic
143
+ // which POSTs to the accounting recommendation-feedback endpoint. No state
144
+ // mutation: the categorization UX must not depend on the feedback round-trip.
145
+ submitRecommendationFeedback: {
146
+ reducer(
147
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
148
+ _draft,
149
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
150
+ _action) {
151
+ // do nothing
152
+ },
153
+ prepare(args) {
154
+ return { payload: args };
155
+ },
156
+ },
141
157
  },
142
158
  extraReducers: (builder) => {
143
159
  builder.addCase(rootActions_1.clearAll, (draft) => {
@@ -145,7 +161,7 @@ const recommendation = (0, toolkit_1.createSlice)({
145
161
  });
146
162
  },
147
163
  });
148
- _a = recommendation.actions, exports.fetchEntityRecommendationsByTransactionId = _a.fetchEntityRecommendationsByTransactionId, exports.fetchEntityRecommendationsForLineUpdate = _a.fetchEntityRecommendationsForLineUpdate, exports.fetchRecommendationByEntityName = _a.fetchRecommendationByEntityName, exports.fetchRecommendationByEntityId = _a.fetchRecommendationByEntityId, exports.updateRecommendationForEntity = _a.updateRecommendationForEntity, exports.updateRecommendationForEntityFailure = _a.updateRecommendationForEntityFailure, exports.indicateReadyToInitializeRecommendation = _a.indicateReadyToInitializeRecommendation, exports.clearRecommendation = _a.clearRecommendation;
164
+ _a = recommendation.actions, exports.fetchEntityRecommendationsByTransactionId = _a.fetchEntityRecommendationsByTransactionId, exports.fetchEntityRecommendationsForLineUpdate = _a.fetchEntityRecommendationsForLineUpdate, exports.fetchRecommendationByEntityName = _a.fetchRecommendationByEntityName, exports.fetchRecommendationByEntityId = _a.fetchRecommendationByEntityId, exports.updateRecommendationForEntity = _a.updateRecommendationForEntity, exports.updateRecommendationForEntityFailure = _a.updateRecommendationForEntityFailure, exports.indicateReadyToInitializeRecommendation = _a.indicateReadyToInitializeRecommendation, exports.clearRecommendation = _a.clearRecommendation, exports.submitRecommendationFeedback = _a.submitRecommendationFeedback;
149
165
  exports.default = recommendation.reducer;
150
166
  const doUpdateRecommendationForEntity = (draft, entityId, entityType, payload) => {
151
167
  const key = (0, recommendationState_1.getEntityRecommendationKey)(entityType, entityId);
@@ -0,0 +1,7 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { RootState } from '../../reducer';
4
+ import { ZeniAPI } from '../../zeniAPI';
5
+ import { submitRecommendationFeedback } from './recommendationReducer';
6
+ export type ActionType = ReturnType<typeof submitRecommendationFeedback>;
7
+ export declare const submitRecommendationFeedbackEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.submitRecommendationFeedbackEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const responsePayload_1 = require("../../responsePayload");
7
+ const recommendationReducer_1 = require("./recommendationReducer");
8
+ const toRequestBody = (payload) => ({
9
+ line_id: payload.lineId ?? null,
10
+ dimension: payload.dimension,
11
+ recommendation_set_id: payload.recommendationSetId ?? null,
12
+ top_pick_source: payload.topPickSource ?? null,
13
+ shown_recommendations: (payload.shownRecommendations ?? []).map((recommendation) => ({
14
+ source: recommendation.source,
15
+ rank: recommendation.rank,
16
+ value: {
17
+ name: recommendation.value.name,
18
+ id: recommendation.value.id ?? null,
19
+ integration_id: recommendation.value.integrationId ?? null,
20
+ },
21
+ confidence: recommendation.confidence ?? null,
22
+ reasoning: recommendation.reasoning ?? null,
23
+ cot: recommendation.cot ?? [],
24
+ })),
25
+ selected: {
26
+ name: payload.selected.name,
27
+ id: payload.selected.id ?? null,
28
+ integration_id: payload.selected.integrationId ?? null,
29
+ is_new_entity: payload.selected.isNewEntity ?? false,
30
+ },
31
+ matched_source: payload.matchedSource ?? null,
32
+ matched_rank: payload.matchedRank ?? null,
33
+ outcome: payload.outcome,
34
+ reason_text: payload.reasonText ?? null,
35
+ skipped: payload.skipped ?? false,
36
+ retracts_feedback_id: payload.retractsFeedbackId ?? null,
37
+ features: payload.features ?? null,
38
+ });
39
+ // Fire-and-forget: the epic never re-emits an action. Feedback delivery is a
40
+ // side-effect that must not disrupt the categorization UX, so both the
41
+ // success and error paths complete silently (errors are logged for debugging).
42
+ const submitRecommendationFeedbackEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(recommendationReducer_1.submitRecommendationFeedback.match), (0, operators_1.mergeMap)((action) => {
43
+ const { transactionId } = action.payload;
44
+ return zeniAPI
45
+ .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${transactionId}/recommendation-feedback`, toRequestBody(action.payload))
46
+ .pipe((0, operators_1.mergeMap)((response) => {
47
+ if (!(0, responsePayload_1.isSuccessStatus)(response)) {
48
+ console.error('submitRecommendationFeedbackEpic: recommendation feedback was not recorded', response.status);
49
+ }
50
+ return rxjs_1.EMPTY;
51
+ }), (0, operators_1.catchError)((error) => {
52
+ console.error('submitRecommendationFeedbackEpic: failed to submit recommendation feedback', error);
53
+ return rxjs_1.EMPTY;
54
+ }));
55
+ }));
56
+ exports.submitRecommendationFeedbackEpic = submitRecommendationFeedbackEpic;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.1.92-beta0NB",
3
+ "version": "5.1.92-beta0ND",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -1,43 +0,0 @@
1
- import { of } from 'rxjs';
2
- import { catchError, exhaustMap, filter, mergeMap } from 'rxjs/operators';
3
- import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
4
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
5
- import { isConfirmStatementMappingConflictResponse, transformConfirmStatementMappingConflictToState, transformConfirmStatementMappingPayloadToState, } from '../../payload/reconciliationPayload';
6
- import { confirmStatementMapping, confirmStatementMappingFailure, confirmStatementMappingSuccess, } from '../../reducers/reconciliationViewReducer';
7
- const confirmStatementMappingErrorSnackbar = openSnackbar({
8
- messageSection: 'confirm_statement_mapping',
9
- messageText: 'failed',
10
- type: 'error',
11
- });
12
- export const confirmStatementMappingEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(confirmStatementMapping.match), exhaustMap((action) => {
13
- const { accountId, selectedPeriod, statementUploadId, accountMappings } = action.payload;
14
- const confirmMappingApi$ = zeniAPI.postAndGetJSON(`${zeniAPI.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/statements/${statementUploadId}/confirm-mapping`, {
15
- account_mappings: accountMappings.map((mapping) => ({
16
- ledger_identifier: mapping.ledgerIdentifier,
17
- account_id: mapping.accountId,
18
- })),
19
- });
20
- return confirmMappingApi$.pipe(mergeMap((response) => {
21
- if (isSuccessResponse(response) === true && response.data != null) {
22
- return of(confirmStatementMappingSuccess({
23
- accountId,
24
- selectedPeriod,
25
- statementUploads: transformConfirmStatementMappingPayloadToState(response.data),
26
- }));
27
- }
28
- const mappingConflict = isConfirmStatementMappingConflictResponse(response)
29
- ? transformConfirmStatementMappingConflictToState(response)
30
- : null;
31
- return of(confirmStatementMappingFailure({
32
- accountId,
33
- selectedPeriod,
34
- error: response.status,
35
- mappingConflict,
36
- }), confirmStatementMappingErrorSnackbar);
37
- }), catchError((error) => of(confirmStatementMappingFailure({
38
- accountId,
39
- selectedPeriod,
40
- error: createZeniAPIStatus('Unexpected Error', 'Confirm Statement Mapping REST API call errored out ' +
41
- (error instanceof Error ? error.message : String(error))),
42
- }), confirmStatementMappingErrorSnackbar)));
43
- }));
@@ -1,31 +0,0 @@
1
- import { from, of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
4
- import { transformCombinedStatementGroupPayloadToState, } from '../../payload/reconciliationPayload';
5
- import { parseCombinedStatement, parseStatementFailure, parseStatementSuccess, updateParsedStatementData, } from '../../reducers/reconciliationViewReducer';
6
- export const parseCombinedStatementEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(parseCombinedStatement.match), switchMap((action) => {
7
- const { accountId, selectedPeriod, combinedStatementGroupId } = action.payload;
8
- const parseUrl = `${zeniAPI.apiEndPoints.reconciliationMicroServiceBaseUrl}/2.0/statement-uploads/combined-statement-groups/${combinedStatementGroupId}`;
9
- return zeniAPI.getJSON(parseUrl).pipe(mergeMap((response) => {
10
- if (isSuccessResponse(response) === true && response.data != null) {
11
- return from([
12
- updateParsedStatementData({
13
- accountId,
14
- selectedPeriod,
15
- parsedStatementData: transformCombinedStatementGroupPayloadToState(response.data),
16
- }),
17
- parseStatementSuccess({ accountId, selectedPeriod }),
18
- ]);
19
- }
20
- return of(parseStatementFailure({
21
- accountId,
22
- selectedPeriod,
23
- error: response.status,
24
- }));
25
- }), catchError((error) => of(parseStatementFailure({
26
- accountId,
27
- selectedPeriod,
28
- error: createZeniAPIStatus('Unexpected Error', 'Parse Combined Statement REST API call errored out ' +
29
- (error instanceof Error ? error.message : String(error))),
30
- }))));
31
- }));
@@ -1,68 +0,0 @@
1
- import { of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { toMonthYearPeriodId } from '../../../../commonStateTypes/timePeriod';
4
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
5
- import { mapCombinedStatementUpdateLocalDataToRequestBody } from '../../helpers/mapStatementUpdateLocalDataToRequestBody';
6
- import { getStatementUploadsFromParsedData } from '../../selectors/statementParseViewSelector';
7
- import { isStatementDateConflictResponse, transformStatementDateConflictToState, transformUpdateStatementInfoPayloadToState, } from '../../payload/reconciliationPayload';
8
- import { submitCombinedStatementUpdate, submitStatementUpdateFailure, submitStatementUpdateSuccess, updateParsedStatementData, } from '../../reducers/reconciliationViewReducer';
9
- export const updateCombinedStatementInfoEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(submitCombinedStatementUpdate.match), switchMap((action) => {
10
- const { accountId, selectedPeriod } = action.payload;
11
- const accountRecon = state$.value.expenseAutomationReconciliationViewState
12
- .accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)]?.reconciliationByAccountID[accountId];
13
- const parsedStatementData = accountRecon?.parsedStatementData;
14
- const localDataByUploadId = accountRecon?.localData?.statementUpdateLocalDataByUploadId;
15
- const statementUploads = getStatementUploadsFromParsedData(parsedStatementData);
16
- if (parsedStatementData == null ||
17
- localDataByUploadId == null ||
18
- statementUploads.length === 0 ||
19
- statementUploads.some((statementUpload) => localDataByUploadId[statementUpload.statementMeta.statementUploadId] == null)) {
20
- return of(submitStatementUpdateFailure({
21
- accountId,
22
- selectedPeriod,
23
- error: createZeniAPIStatus('Missing Data', 'No statement update data found for combined accounts'),
24
- }));
25
- }
26
- const combinedStatementGroupId = accountRecon?.combinedStatementGroupId ??
27
- parsedStatementData.statementUpload.statementMeta
28
- .combinedStatementGroupId ??
29
- parsedStatementData.statementUpload.combinedStatementDetails
30
- ?.combinedStatementGroupId;
31
- if (combinedStatementGroupId == null || combinedStatementGroupId === '') {
32
- return of(submitStatementUpdateFailure({
33
- accountId,
34
- selectedPeriod,
35
- error: createZeniAPIStatus('Missing Data', 'No combined statement group id found for bulk update'),
36
- }));
37
- }
38
- const body = mapCombinedStatementUpdateLocalDataToRequestBody(localDataByUploadId, parsedStatementData);
39
- const updateUrl = `${zeniAPI.apiEndPoints.reconciliationMicroServiceBaseUrl}/2.0/statement-uploads/combined-statement-groups/${combinedStatementGroupId}`;
40
- return zeniAPI
41
- .putAndGetJSON(updateUrl, body)
42
- .pipe(mergeMap((response) => {
43
- if (isSuccessResponse(response) === true && response.data != null) {
44
- return of(updateParsedStatementData({
45
- accountId,
46
- selectedPeriod,
47
- parsedStatementData: transformUpdateStatementInfoPayloadToState(response.data),
48
- }), submitStatementUpdateSuccess({
49
- accountId,
50
- selectedPeriod,
51
- }));
52
- }
53
- const dateConflict = isStatementDateConflictResponse(response)
54
- ? transformStatementDateConflictToState(response)
55
- : null;
56
- return of(submitStatementUpdateFailure({
57
- accountId,
58
- selectedPeriod,
59
- error: response.status,
60
- dateConflict,
61
- }));
62
- }), catchError((error) => of(submitStatementUpdateFailure({
63
- accountId,
64
- selectedPeriod,
65
- error: createZeniAPIStatus('Unexpected Error', 'Update Statement REST API call errored out ' +
66
- (error instanceof Error ? error.message : String(error))),
67
- }))));
68
- }));
@@ -1,34 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
3
- import { RootState } from '../../../../reducer';
4
- import { ZeniAPI } from '../../../../zeniAPI';
5
- import { confirmStatementMapping, confirmStatementMappingFailure, confirmStatementMappingSuccess } from '../../reducers/reconciliationViewReducer';
6
- export type ActionType = ReturnType<typeof confirmStatementMapping> | ReturnType<typeof confirmStatementMappingSuccess> | ReturnType<typeof confirmStatementMappingFailure> | ReturnType<typeof openSnackbar>;
7
- export declare const confirmStatementMappingEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
8
- payload: {
9
- messageSection: import("../../../..").SnackbarMessageSections;
10
- messageText: import("../../../..").SnackbarMessageSectionTexts;
11
- type: import("../../../..").SnackbarMessageType;
12
- showStatusIcon?: boolean;
13
- variables?: {
14
- variableName: string;
15
- variableValue: string;
16
- }[];
17
- };
18
- type: "snackbar/openSnackbar";
19
- } | {
20
- payload: {
21
- accountId: import("../../../..").ID;
22
- selectedPeriod: import("../../../..").MonthYearPeriod;
23
- statementUploads: import("../../types/reconciliationViewState").ConfirmedCombinedStatementUpload[];
24
- };
25
- type: "expenseAutomationReconciliationView/confirmStatementMappingSuccess";
26
- } | {
27
- payload: {
28
- accountId: import("../../../..").ID;
29
- error: import("../../../../responsePayload").ZeniAPIStatus;
30
- selectedPeriod: import("../../../..").MonthYearPeriod;
31
- mappingConflict?: import("../../types/reconciliationViewState").ConfirmStatementMappingConflict | null;
32
- };
33
- type: "expenseAutomationReconciliationView/confirmStatementMappingFailure";
34
- }>;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.confirmStatementMappingEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
7
- const responsePayload_1 = require("../../../../responsePayload");
8
- const reconciliationPayload_1 = require("../../payload/reconciliationPayload");
9
- const reconciliationViewReducer_1 = require("../../reducers/reconciliationViewReducer");
10
- const confirmStatementMappingErrorSnackbar = (0, snackbarReducer_1.openSnackbar)({
11
- messageSection: 'confirm_statement_mapping',
12
- messageText: 'failed',
13
- type: 'error',
14
- });
15
- const confirmStatementMappingEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(reconciliationViewReducer_1.confirmStatementMapping.match), (0, operators_1.exhaustMap)((action) => {
16
- const { accountId, selectedPeriod, statementUploadId, accountMappings } = action.payload;
17
- const confirmMappingApi$ = zeniAPI.postAndGetJSON(`${zeniAPI.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/statements/${statementUploadId}/confirm-mapping`, {
18
- account_mappings: accountMappings.map((mapping) => ({
19
- ledger_identifier: mapping.ledgerIdentifier,
20
- account_id: mapping.accountId,
21
- })),
22
- });
23
- return confirmMappingApi$.pipe((0, operators_1.mergeMap)((response) => {
24
- if ((0, responsePayload_1.isSuccessResponse)(response) === true && response.data != null) {
25
- return (0, rxjs_1.of)((0, reconciliationViewReducer_1.confirmStatementMappingSuccess)({
26
- accountId,
27
- selectedPeriod,
28
- statementUploads: (0, reconciliationPayload_1.transformConfirmStatementMappingPayloadToState)(response.data),
29
- }));
30
- }
31
- const mappingConflict = (0, reconciliationPayload_1.isConfirmStatementMappingConflictResponse)(response)
32
- ? (0, reconciliationPayload_1.transformConfirmStatementMappingConflictToState)(response)
33
- : null;
34
- return (0, rxjs_1.of)((0, reconciliationViewReducer_1.confirmStatementMappingFailure)({
35
- accountId,
36
- selectedPeriod,
37
- error: response.status,
38
- mappingConflict,
39
- }), confirmStatementMappingErrorSnackbar);
40
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, reconciliationViewReducer_1.confirmStatementMappingFailure)({
41
- accountId,
42
- selectedPeriod,
43
- error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Confirm Statement Mapping REST API call errored out ' +
44
- (error instanceof Error ? error.message : String(error))),
45
- }), confirmStatementMappingErrorSnackbar)));
46
- }));
47
- exports.confirmStatementMappingEpic = confirmStatementMappingEpic;
@@ -1,26 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { RootState } from '../../../../reducer';
3
- import { ZeniAPI } from '../../../../zeniAPI';
4
- import { parseCombinedStatement, parseStatementFailure, parseStatementSuccess, updateParsedStatementData } from '../../reducers/reconciliationViewReducer';
5
- export type ActionType = ReturnType<typeof parseCombinedStatement> | ReturnType<typeof parseStatementSuccess> | ReturnType<typeof parseStatementFailure> | ReturnType<typeof updateParsedStatementData>;
6
- export declare const parseCombinedStatementEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
7
- payload: {
8
- accountId: import("../../../..").ID;
9
- selectedPeriod: import("../../../..").MonthYearPeriod;
10
- };
11
- type: "expenseAutomationReconciliationView/parseStatementSuccess";
12
- } | {
13
- payload: {
14
- accountId: import("../../../..").ID;
15
- error: import("../../../../responsePayload").ZeniAPIStatus;
16
- selectedPeriod: import("../../../..").MonthYearPeriod;
17
- };
18
- type: "expenseAutomationReconciliationView/parseStatementFailure";
19
- } | {
20
- payload: {
21
- accountId: import("../../../..").ID;
22
- parsedStatementData: import("../../types/reconciliationViewState").ParsedStatementData;
23
- selectedPeriod: import("../../../..").MonthYearPeriod;
24
- };
25
- type: "expenseAutomationReconciliationView/updateParsedStatementData";
26
- }>;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseCombinedStatementEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const responsePayload_1 = require("../../../../responsePayload");
7
- const reconciliationPayload_1 = require("../../payload/reconciliationPayload");
8
- const reconciliationViewReducer_1 = require("../../reducers/reconciliationViewReducer");
9
- const parseCombinedStatementEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(reconciliationViewReducer_1.parseCombinedStatement.match), (0, operators_1.switchMap)((action) => {
10
- const { accountId, selectedPeriod, combinedStatementGroupId } = action.payload;
11
- const parseUrl = `${zeniAPI.apiEndPoints.reconciliationMicroServiceBaseUrl}/2.0/statement-uploads/combined-statement-groups/${combinedStatementGroupId}`;
12
- return zeniAPI.getJSON(parseUrl).pipe((0, operators_1.mergeMap)((response) => {
13
- if ((0, responsePayload_1.isSuccessResponse)(response) === true && response.data != null) {
14
- return (0, rxjs_1.from)([
15
- (0, reconciliationViewReducer_1.updateParsedStatementData)({
16
- accountId,
17
- selectedPeriod,
18
- parsedStatementData: (0, reconciliationPayload_1.transformCombinedStatementGroupPayloadToState)(response.data),
19
- }),
20
- (0, reconciliationViewReducer_1.parseStatementSuccess)({ accountId, selectedPeriod }),
21
- ]);
22
- }
23
- return (0, rxjs_1.of)((0, reconciliationViewReducer_1.parseStatementFailure)({
24
- accountId,
25
- selectedPeriod,
26
- error: response.status,
27
- }));
28
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, reconciliationViewReducer_1.parseStatementFailure)({
29
- accountId,
30
- selectedPeriod,
31
- error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Parse Combined Statement REST API call errored out ' +
32
- (error instanceof Error ? error.message : String(error))),
33
- }))));
34
- }));
35
- exports.parseCombinedStatementEpic = parseCombinedStatementEpic;