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

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 (96) hide show
  1. package/lib/commonStateTypes/viewAndReport/viewAndReport.d.ts +2 -2
  2. package/lib/commonStateTypes/viewAndReport/viewAndReport.js +2 -0
  3. package/lib/entity/account/accountSelector.d.ts +9 -0
  4. package/lib/entity/account/accountSelector.js +14 -1
  5. package/lib/entity/account/accountState.d.ts +1 -1
  6. package/lib/entity/accountGroup/accountGroupState.d.ts +1 -1
  7. package/lib/entity/class/classReducer.d.ts +4 -4
  8. package/lib/entity/class/classState.d.ts +1 -1
  9. package/lib/entity/forecast/forecastState.d.ts +1 -1
  10. package/lib/entity/sectionAccountsView/sectionAccountsView.d.ts +1 -1
  11. package/lib/entity/sectionClassesViewV2/sectionClassesView.d.ts +1 -1
  12. package/lib/entity/sectionClassesViewV2/sectionClassesViewReducer.d.ts +2 -2
  13. package/lib/entity/sectionProjectView/sectionProjectView.d.ts +1 -1
  14. package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +2 -2
  15. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  16. package/lib/entity/snackbar/snackbarTypes.js +1 -0
  17. package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +4 -0
  18. package/lib/entity/transaction/payloadTypes/transactionPayload.js +20 -58
  19. package/lib/entity/transaction/stateTypes/transaction.d.ts +3 -0
  20. package/lib/epic.d.ts +3 -2
  21. package/lib/epic.js +3 -2
  22. package/lib/esm/commonStateTypes/viewAndReport/viewAndReport.js +2 -0
  23. package/lib/esm/entity/account/accountSelector.js +11 -0
  24. package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
  25. package/lib/esm/entity/transaction/payloadTypes/transactionPayload.js +20 -58
  26. package/lib/esm/epic.js +3 -2
  27. package/lib/esm/index.js +9 -8
  28. package/lib/esm/reducer.js +3 -0
  29. package/lib/esm/view/createTransferEntry/createTransferEntryReducer.js +56 -0
  30. package/lib/esm/view/createTransferEntry/createTransferEntrySelector.js +64 -0
  31. package/lib/esm/view/createTransferEntry/createTransferEntryState.js +17 -0
  32. package/lib/esm/view/createTransferEntry/epics/createTransferEntryEpic.js +112 -0
  33. package/lib/esm/view/createTransferEntry/epics/fetchTransferAccountsEpic.js +36 -0
  34. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +8 -0
  35. package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +1 -21
  36. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +26 -117
  37. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +9 -59
  38. package/lib/esm/view/recommendation/recommendationHelper.js +0 -29
  39. package/lib/esm/view/recommendation/recommendationReducer.js +1 -36
  40. package/lib/esm/view/transactionDetail/epics/transactionDetailEpic.js +14 -2
  41. package/lib/esm/view/transactionDetail/transactionDetailReducer.js +8 -122
  42. package/lib/esm/view/transactionDetail/transactionDetailSelector.js +6 -23
  43. package/lib/index.d.ts +9 -9
  44. package/lib/index.js +43 -36
  45. package/lib/reducer.d.ts +3 -0
  46. package/lib/reducer.js +3 -0
  47. package/lib/view/auditReportView/auditReportViewState.d.ts +1 -1
  48. package/lib/view/billPayCard/billPayCardSelector.d.ts +1 -1
  49. package/lib/view/cardBalance/cardBalanceSelector.d.ts +1 -1
  50. package/lib/view/cashBalance/cashBalanceSelector.d.ts +1 -1
  51. package/lib/view/cashInCashOut/cashInCashOutSelector.d.ts +1 -1
  52. package/lib/view/cashPosition/cashPositionSelector.d.ts +1 -1
  53. package/lib/view/createTransferEntry/createTransferEntryReducer.d.ts +32 -0
  54. package/lib/view/createTransferEntry/createTransferEntryReducer.js +60 -0
  55. package/lib/view/createTransferEntry/createTransferEntrySelector.d.ts +39 -0
  56. package/lib/view/createTransferEntry/createTransferEntrySelector.js +69 -0
  57. package/lib/view/createTransferEntry/createTransferEntryState.d.ts +30 -0
  58. package/lib/view/createTransferEntry/createTransferEntryState.js +20 -0
  59. package/lib/view/createTransferEntry/epics/createTransferEntryEpic.d.ts +11 -0
  60. package/lib/view/createTransferEntry/epics/createTransferEntryEpic.js +116 -0
  61. package/lib/view/createTransferEntry/epics/fetchTransferAccountsEpic.d.ts +14 -0
  62. package/lib/view/createTransferEntry/epics/fetchTransferAccountsEpic.js +40 -0
  63. package/lib/view/dashboard/dashboardReducer.d.ts +2 -2
  64. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.d.ts +2 -1
  65. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +8 -0
  66. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -2
  67. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -23
  68. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +4 -15
  69. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +26 -117
  70. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +4 -3
  71. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +1 -3
  72. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +11 -61
  73. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +0 -1
  74. package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
  75. package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
  76. package/lib/view/recommendation/recommendationHelper.d.ts +0 -9
  77. package/lib/view/recommendation/recommendationHelper.js +1 -31
  78. package/lib/view/recommendation/recommendationReducer.d.ts +1 -18
  79. package/lib/view/recommendation/recommendationReducer.js +2 -37
  80. package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
  81. package/lib/view/reportsResync/reportsResyncReducer.d.ts +2 -2
  82. package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
  83. package/lib/view/topEx/topExSelector.d.ts +1 -1
  84. package/lib/view/transactionDetail/epics/transactionDetailEpic.d.ts +2 -1
  85. package/lib/view/transactionDetail/epics/transactionDetailEpic.js +14 -2
  86. package/lib/view/transactionDetail/transactionDetailPayload.d.ts +1 -1
  87. package/lib/view/transactionDetail/transactionDetailReducer.d.ts +3 -12
  88. package/lib/view/transactionDetail/transactionDetailReducer.js +9 -123
  89. package/lib/view/transactionDetail/transactionDetailSelector.d.ts +6 -3
  90. package/lib/view/transactionDetail/transactionDetailSelector.js +7 -25
  91. package/lib/view/transactionDetail/transactionDetailTypes.d.ts +0 -1
  92. package/package.json +1 -1
  93. package/lib/esm/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -83
  94. package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
  95. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.d.ts +0 -9
  96. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -87
@@ -1,83 +0,0 @@
1
- import { concat, of, timer } from 'rxjs';
2
- import { catchError, debounce, filter, groupBy, mergeMap, switchMap, } from 'rxjs/operators';
3
- import { getIsAccountingClassesEnabled } from '../../entity/tenant/tenantSelector';
4
- import { getTransactionWithCOT, getTransactionWithCOTFromRecommendations, } from '../../entity/transaction/transactionHelper';
5
- import { createZeniAPIStatus, isSuccessResponse } from '../../responsePayload';
6
- import { getUncategorizedAccounts } from '../accountList/accountListSelector';
7
- import { markCategoryClassRecommendationsCompletedForCategorization, markCategoryClassRecommendationsFailureForCategorization, markCategoryClassRecommendationsInProgressForCategorization, setEntityRecommendationForLineIdsForCategorization, } from '../expenseAutomationView/reducers/transactionsViewReducer';
8
- import { markCategoryClassRecommendationsCompletedForTransactionDetail, markCategoryClassRecommendationsFailureForTransactionDetail, markCategoryClassRecommendationsInProgressForTransactionDetail, setEntityRecommendationForLineIdsForTransactionDetail, } from '../transactionDetail/transactionDetailReducer';
9
- import { buildRecommendationUrl, getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT, } from './recommendationHelper';
10
- import { fetchEntityRecommendationsForLineUpdate } from './recommendationReducer';
11
- // Close the per-target groupBy bucket after this much idle time so inactive
12
- // groups don't accumulate forever (each group holds a Subject + a chain of
13
- // active subscribers; without a duration selector groupBy retains them for
14
- // the lifetime of the source observable, which is the lifetime of the app).
15
- // Picked at 60s to leave a generous window for re-fetches on the same
16
- // payee/transaction/line target while still bounding memory.
17
- const GROUP_INACTIVITY_TIMEOUT_MS = 60000;
18
- // Build the groupBy key. Same flow + same transaction + same line set
19
- // share a target so switchMap can cancel an in-flight prior fetch. Use
20
- // NUL (\u0000) as separator because it can never appear in transaction
21
- // or line ids (vs the `|` used in an earlier WIP which collides with
22
- // pipe-delimited synthetic ids).
23
- const SEPARATOR = '\u0000';
24
- const toGroupKey = (flowType, transactionId, lineIds) => `${flowType}${SEPARATOR}${transactionId}${SEPARATOR}${[...lineIds]
25
- .sort((a, b) => a.localeCompare(b))
26
- .join(SEPARATOR)}`;
27
- // Targeted recommendations fetch that drives the per-line skeleton, the
28
- // list-page row-checkbox uncheck/recheck, and the page-level Save
29
- // disable.
30
- //
31
- // Concurrency model:
32
- // - groupBy by (flowType, transactionId, sorted lineIds) so distinct
33
- // targets run in parallel.
34
- // - inside each group, switchMap so a re-fetch on the SAME target
35
- // cancels any prior in-flight request for that target.
36
- // - groupBy duration selector closes idle groups to bound memory.
37
- export const fetchEntityRecommendationsForLineUpdateEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchEntityRecommendationsForLineUpdate.match), groupBy((action) => toGroupKey(action.payload.flowType, action.payload.transactionDetails.transactionId.id, action.payload.transactionDetails.lineIds), undefined, (group$) => group$.pipe(debounce(() => timer(GROUP_INACTIVITY_TIMEOUT_MS)))), mergeMap((group$) => group$.pipe(switchMap((action) => {
38
- const { entity, amount, transactionDetails, flowType, selectedTab, isFetchCOT, isUncategorizedExpenseCategoryEnabled, } = action.payload;
39
- const { transactionId, transaction, lineIds } = transactionDetails;
40
- // Synchronously emit the start arm so the per-line skeleton +
41
- // row uncheck happen before the HTTP request begins.
42
- const startAction = flowType === 'categorization' && selectedTab != null
43
- ? markCategoryClassRecommendationsInProgressForCategorization(selectedTab, transactionId, lineIds)
44
- : markCategoryClassRecommendationsInProgressForTransactionDetail(transactionId, lineIds);
45
- const url = buildRecommendationUrl(zeniAPI.apiEndPoints.accountMicroServiceBaseUrl, entity, amount, transactionDetails, isFetchCOT === true);
46
- const httpStream$ = zeniAPI
47
- .getJSON(url)
48
- .pipe(mergeMap((response) => {
49
- if (!isSuccessResponse(response) || response.data == null) {
50
- return of(flowType === 'categorization' && selectedTab != null
51
- ? markCategoryClassRecommendationsFailureForCategorization(selectedTab, transactionId, lineIds, response.status)
52
- : markCategoryClassRecommendationsFailureForTransactionDetail(transactionId, lineIds, response.status));
53
- }
54
- const recommendationWithCOTByLineId = getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT(response.data.recommendations, lineIds);
55
- // HTTP 200 with no per-line recommendations: NOT an error.
56
- // Flip lines to Completed so the skeleton resolves and
57
- // downstream UI can treat this as "we tried, nothing to
58
- // apply".
59
- if (recommendationWithCOTByLineId == null) {
60
- return of(flowType === 'categorization' && selectedTab != null
61
- ? markCategoryClassRecommendationsCompletedForCategorization(selectedTab, transactionId, lineIds)
62
- : markCategoryClassRecommendationsCompletedForTransactionDetail(transactionId, lineIds));
63
- }
64
- const transactionWithCOT = isFetchCOT === true
65
- ? getTransactionWithCOTFromRecommendations(transaction, recommendationWithCOTByLineId)
66
- : getTransactionWithCOT(transaction);
67
- const uncategorizedIncomeExpense = getUncategorizedAccounts(state$.value.accountState, state$.value.accountListState, 'accountList');
68
- if (flowType === 'categorization' && selectedTab != null) {
69
- return of(setEntityRecommendationForLineIdsForCategorization(selectedTab, transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense, isUncategorizedExpenseCategoryEnabled, getIsAccountingClassesEnabled(state$.value)));
70
- }
71
- return of(setEntityRecommendationForLineIdsForTransactionDetail(transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense));
72
- }), catchError((error) => {
73
- const errorMessage = 'fetchEntityRecommendationsForLineUpdate failed: ' +
74
- (error instanceof Error
75
- ? error.message
76
- : JSON.stringify(error));
77
- const status = createZeniAPIStatus('Unexpected Error', errorMessage);
78
- return of(flowType === 'categorization' && selectedTab != null
79
- ? markCategoryClassRecommendationsFailureForCategorization(selectedTab, transactionId, lineIds, status)
80
- : markCategoryClassRecommendationsFailureForTransactionDetail(transactionId, lineIds, status));
81
- }));
82
- return concat(of(startAction), httpStream$);
83
- }))));