@zeniai/client-epic-state 5.0.69-betaML31 → 5.0.69-betaML51

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 (35) hide show
  1. package/lib/epic.d.ts +1 -2
  2. package/lib/epic.js +1 -2
  3. package/lib/esm/epic.js +1 -2
  4. package/lib/esm/index.js +6 -6
  5. package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +1 -21
  6. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +14 -117
  7. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +0 -58
  8. package/lib/esm/view/recommendation/recommendationHelper.js +0 -29
  9. package/lib/esm/view/recommendation/recommendationReducer.js +1 -36
  10. package/lib/esm/view/transactionDetail/transactionDetailReducer.js +6 -121
  11. package/lib/esm/view/transactionDetail/transactionDetailSelector.js +0 -22
  12. package/lib/index.d.ts +6 -7
  13. package/lib/index.js +32 -35
  14. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +0 -1
  15. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -23
  16. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +1 -14
  17. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +14 -117
  18. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +0 -2
  19. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +0 -3
  20. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +0 -60
  21. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +0 -1
  22. package/lib/view/recommendation/recommendationHelper.d.ts +0 -9
  23. package/lib/view/recommendation/recommendationHelper.js +1 -31
  24. package/lib/view/recommendation/recommendationReducer.d.ts +1 -18
  25. package/lib/view/recommendation/recommendationReducer.js +2 -37
  26. package/lib/view/transactionDetail/transactionDetailReducer.d.ts +1 -11
  27. package/lib/view/transactionDetail/transactionDetailReducer.js +7 -122
  28. package/lib/view/transactionDetail/transactionDetailSelector.d.ts +0 -2
  29. package/lib/view/transactionDetail/transactionDetailSelector.js +1 -24
  30. package/lib/view/transactionDetail/transactionDetailTypes.d.ts +0 -1
  31. package/package.json +1 -1
  32. package/lib/esm/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -83
  33. package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
  34. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.d.ts +0 -9
  35. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -87
@@ -1,9 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { RootState } from '../../reducer';
4
- import { ZeniAPI } from '../../zeniAPI';
5
- import { markCategoryClassRecommendationsCompletedForCategorization, markCategoryClassRecommendationsFailureForCategorization, markCategoryClassRecommendationsInProgressForCategorization, setEntityRecommendationForLineIdsForCategorization } from '../expenseAutomationView/reducers/transactionsViewReducer';
6
- import { markCategoryClassRecommendationsCompletedForTransactionDetail, markCategoryClassRecommendationsFailureForTransactionDetail, markCategoryClassRecommendationsInProgressForTransactionDetail, setEntityRecommendationForLineIdsForTransactionDetail } from '../transactionDetail/transactionDetailReducer';
7
- import { fetchEntityRecommendationsForLineUpdate } from './recommendationReducer';
8
- export type ActionType = ReturnType<typeof fetchEntityRecommendationsForLineUpdate> | ReturnType<typeof markCategoryClassRecommendationsInProgressForCategorization> | ReturnType<typeof markCategoryClassRecommendationsCompletedForCategorization> | ReturnType<typeof markCategoryClassRecommendationsFailureForCategorization> | ReturnType<typeof markCategoryClassRecommendationsInProgressForTransactionDetail> | ReturnType<typeof markCategoryClassRecommendationsCompletedForTransactionDetail> | ReturnType<typeof markCategoryClassRecommendationsFailureForTransactionDetail> | ReturnType<typeof setEntityRecommendationForLineIdsForCategorization> | ReturnType<typeof setEntityRecommendationForLineIdsForTransactionDetail>;
9
- export declare const fetchEntityRecommendationsForLineUpdateEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,87 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchEntityRecommendationsForLineUpdateEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const tenantSelector_1 = require("../../entity/tenant/tenantSelector");
7
- const transactionHelper_1 = require("../../entity/transaction/transactionHelper");
8
- const responsePayload_1 = require("../../responsePayload");
9
- const accountListSelector_1 = require("../accountList/accountListSelector");
10
- const transactionsViewReducer_1 = require("../expenseAutomationView/reducers/transactionsViewReducer");
11
- const transactionDetailReducer_1 = require("../transactionDetail/transactionDetailReducer");
12
- const recommendationHelper_1 = require("./recommendationHelper");
13
- const recommendationReducer_1 = require("./recommendationReducer");
14
- // Close the per-target groupBy bucket after this much idle time so inactive
15
- // groups don't accumulate forever (each group holds a Subject + a chain of
16
- // active subscribers; without a duration selector groupBy retains them for
17
- // the lifetime of the source observable, which is the lifetime of the app).
18
- // Picked at 60s to leave a generous window for re-fetches on the same
19
- // payee/transaction/line target while still bounding memory.
20
- const GROUP_INACTIVITY_TIMEOUT_MS = 60000;
21
- // Build the groupBy key. Same flow + same transaction + same line set
22
- // share a target so switchMap can cancel an in-flight prior fetch. Use
23
- // NUL (\u0000) as separator because it can never appear in transaction
24
- // or line ids (vs the `|` used in an earlier WIP which collides with
25
- // pipe-delimited synthetic ids).
26
- const SEPARATOR = '\u0000';
27
- const toGroupKey = (flowType, transactionId, lineIds) => `${flowType}${SEPARATOR}${transactionId}${SEPARATOR}${[...lineIds]
28
- .sort((a, b) => a.localeCompare(b))
29
- .join(SEPARATOR)}`;
30
- // Targeted recommendations fetch that drives the per-line skeleton, the
31
- // list-page row-checkbox uncheck/recheck, and the page-level Save
32
- // disable.
33
- //
34
- // Concurrency model:
35
- // - groupBy by (flowType, transactionId, sorted lineIds) so distinct
36
- // targets run in parallel.
37
- // - inside each group, switchMap so a re-fetch on the SAME target
38
- // cancels any prior in-flight request for that target.
39
- // - groupBy duration selector closes idle groups to bound memory.
40
- const fetchEntityRecommendationsForLineUpdateEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(recommendationReducer_1.fetchEntityRecommendationsForLineUpdate.match), (0, operators_1.groupBy)((action) => toGroupKey(action.payload.flowType, action.payload.transactionDetails.transactionId.id, action.payload.transactionDetails.lineIds), undefined, (group$) => group$.pipe((0, operators_1.debounce)(() => (0, rxjs_1.timer)(GROUP_INACTIVITY_TIMEOUT_MS)))), (0, operators_1.mergeMap)((group$) => group$.pipe((0, operators_1.switchMap)((action) => {
41
- const { entity, amount, transactionDetails, flowType, selectedTab, isFetchCOT, isUncategorizedExpenseCategoryEnabled, } = action.payload;
42
- const { transactionId, transaction, lineIds } = transactionDetails;
43
- // Synchronously emit the start arm so the per-line skeleton +
44
- // row uncheck happen before the HTTP request begins.
45
- const startAction = flowType === 'categorization' && selectedTab != null
46
- ? (0, transactionsViewReducer_1.markCategoryClassRecommendationsInProgressForCategorization)(selectedTab, transactionId, lineIds)
47
- : (0, transactionDetailReducer_1.markCategoryClassRecommendationsInProgressForTransactionDetail)(transactionId, lineIds);
48
- const url = (0, recommendationHelper_1.buildRecommendationUrl)(zeniAPI.apiEndPoints.accountMicroServiceBaseUrl, entity, amount, transactionDetails, isFetchCOT === true);
49
- const httpStream$ = zeniAPI
50
- .getJSON(url)
51
- .pipe((0, operators_1.mergeMap)((response) => {
52
- if (!(0, responsePayload_1.isSuccessResponse)(response) || response.data == null) {
53
- return (0, rxjs_1.of)(flowType === 'categorization' && selectedTab != null
54
- ? (0, transactionsViewReducer_1.markCategoryClassRecommendationsFailureForCategorization)(selectedTab, transactionId, lineIds, response.status)
55
- : (0, transactionDetailReducer_1.markCategoryClassRecommendationsFailureForTransactionDetail)(transactionId, lineIds, response.status));
56
- }
57
- const recommendationWithCOTByLineId = (0, recommendationHelper_1.getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT)(response.data.recommendations, lineIds);
58
- // HTTP 200 with no per-line recommendations: NOT an error.
59
- // Flip lines to Completed so the skeleton resolves and
60
- // downstream UI can treat this as "we tried, nothing to
61
- // apply".
62
- if (recommendationWithCOTByLineId == null) {
63
- return (0, rxjs_1.of)(flowType === 'categorization' && selectedTab != null
64
- ? (0, transactionsViewReducer_1.markCategoryClassRecommendationsCompletedForCategorization)(selectedTab, transactionId, lineIds)
65
- : (0, transactionDetailReducer_1.markCategoryClassRecommendationsCompletedForTransactionDetail)(transactionId, lineIds));
66
- }
67
- const transactionWithCOT = isFetchCOT === true
68
- ? (0, transactionHelper_1.getTransactionWithCOTFromRecommendations)(transaction, recommendationWithCOTByLineId)
69
- : (0, transactionHelper_1.getTransactionWithCOT)(transaction);
70
- const uncategorizedIncomeExpense = (0, accountListSelector_1.getUncategorizedAccounts)(state$.value.accountState, state$.value.accountListState, 'accountList');
71
- if (flowType === 'categorization' && selectedTab != null) {
72
- return (0, rxjs_1.of)((0, transactionsViewReducer_1.setEntityRecommendationForLineIdsForCategorization)(selectedTab, transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense, isUncategorizedExpenseCategoryEnabled, (0, tenantSelector_1.getIsAccountingClassesEnabled)(state$.value)));
73
- }
74
- return (0, rxjs_1.of)((0, transactionDetailReducer_1.setEntityRecommendationForLineIdsForTransactionDetail)(transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense));
75
- }), (0, operators_1.catchError)((error) => {
76
- const errorMessage = 'fetchEntityRecommendationsForLineUpdate failed: ' +
77
- (error instanceof Error
78
- ? error.message
79
- : JSON.stringify(error));
80
- const status = (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', errorMessage);
81
- return (0, rxjs_1.of)(flowType === 'categorization' && selectedTab != null
82
- ? (0, transactionsViewReducer_1.markCategoryClassRecommendationsFailureForCategorization)(selectedTab, transactionId, lineIds, status)
83
- : (0, transactionDetailReducer_1.markCategoryClassRecommendationsFailureForTransactionDetail)(transactionId, lineIds, status));
84
- }));
85
- return (0, rxjs_1.concat)((0, rxjs_1.of)(startAction), httpStream$);
86
- }))));
87
- exports.fetchEntityRecommendationsForLineUpdateEpic = fetchEntityRecommendationsForLineUpdateEpic;