@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.
- package/lib/commonStateTypes/viewAndReport/viewAndReport.d.ts +2 -2
- package/lib/commonStateTypes/viewAndReport/viewAndReport.js +2 -0
- package/lib/entity/account/accountSelector.d.ts +9 -0
- package/lib/entity/account/accountSelector.js +14 -1
- package/lib/entity/account/accountState.d.ts +1 -1
- package/lib/entity/accountGroup/accountGroupState.d.ts +1 -1
- package/lib/entity/class/classReducer.d.ts +4 -4
- package/lib/entity/class/classState.d.ts +1 -1
- package/lib/entity/forecast/forecastState.d.ts +1 -1
- package/lib/entity/sectionAccountsView/sectionAccountsView.d.ts +1 -1
- package/lib/entity/sectionClassesViewV2/sectionClassesView.d.ts +1 -1
- package/lib/entity/sectionClassesViewV2/sectionClassesViewReducer.d.ts +2 -2
- package/lib/entity/sectionProjectView/sectionProjectView.d.ts +1 -1
- package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +2 -2
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +1 -0
- package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +4 -0
- package/lib/entity/transaction/payloadTypes/transactionPayload.js +20 -58
- package/lib/entity/transaction/stateTypes/transaction.d.ts +3 -0
- package/lib/epic.d.ts +3 -2
- package/lib/epic.js +3 -2
- package/lib/esm/commonStateTypes/viewAndReport/viewAndReport.js +2 -0
- package/lib/esm/entity/account/accountSelector.js +11 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
- package/lib/esm/entity/transaction/payloadTypes/transactionPayload.js +20 -58
- package/lib/esm/epic.js +3 -2
- package/lib/esm/index.js +9 -8
- package/lib/esm/reducer.js +3 -0
- package/lib/esm/view/createTransferEntry/createTransferEntryReducer.js +56 -0
- package/lib/esm/view/createTransferEntry/createTransferEntrySelector.js +64 -0
- package/lib/esm/view/createTransferEntry/createTransferEntryState.js +17 -0
- package/lib/esm/view/createTransferEntry/epics/createTransferEntryEpic.js +112 -0
- package/lib/esm/view/createTransferEntry/epics/fetchTransferAccountsEpic.js +36 -0
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +8 -0
- package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +1 -21
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +26 -117
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +9 -59
- package/lib/esm/view/recommendation/recommendationHelper.js +0 -29
- package/lib/esm/view/recommendation/recommendationReducer.js +1 -36
- package/lib/esm/view/transactionDetail/epics/transactionDetailEpic.js +14 -2
- package/lib/esm/view/transactionDetail/transactionDetailReducer.js +8 -122
- package/lib/esm/view/transactionDetail/transactionDetailSelector.js +6 -23
- package/lib/index.d.ts +9 -9
- package/lib/index.js +43 -36
- package/lib/reducer.d.ts +3 -0
- package/lib/reducer.js +3 -0
- package/lib/view/auditReportView/auditReportViewState.d.ts +1 -1
- package/lib/view/billPayCard/billPayCardSelector.d.ts +1 -1
- package/lib/view/cardBalance/cardBalanceSelector.d.ts +1 -1
- package/lib/view/cashBalance/cashBalanceSelector.d.ts +1 -1
- package/lib/view/cashInCashOut/cashInCashOutSelector.d.ts +1 -1
- package/lib/view/cashPosition/cashPositionSelector.d.ts +1 -1
- package/lib/view/createTransferEntry/createTransferEntryReducer.d.ts +32 -0
- package/lib/view/createTransferEntry/createTransferEntryReducer.js +60 -0
- package/lib/view/createTransferEntry/createTransferEntrySelector.d.ts +39 -0
- package/lib/view/createTransferEntry/createTransferEntrySelector.js +69 -0
- package/lib/view/createTransferEntry/createTransferEntryState.d.ts +30 -0
- package/lib/view/createTransferEntry/createTransferEntryState.js +20 -0
- package/lib/view/createTransferEntry/epics/createTransferEntryEpic.d.ts +11 -0
- package/lib/view/createTransferEntry/epics/createTransferEntryEpic.js +116 -0
- package/lib/view/createTransferEntry/epics/fetchTransferAccountsEpic.d.ts +14 -0
- package/lib/view/createTransferEntry/epics/fetchTransferAccountsEpic.js +40 -0
- package/lib/view/dashboard/dashboardReducer.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.d.ts +2 -1
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +8 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -2
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -23
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +4 -15
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +26 -117
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +4 -3
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +1 -3
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +11 -61
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +0 -1
- package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
- package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
- package/lib/view/recommendation/recommendationHelper.d.ts +0 -9
- package/lib/view/recommendation/recommendationHelper.js +1 -31
- package/lib/view/recommendation/recommendationReducer.d.ts +1 -18
- package/lib/view/recommendation/recommendationReducer.js +2 -37
- package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
- package/lib/view/reportsResync/reportsResyncReducer.d.ts +2 -2
- package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
- package/lib/view/topEx/topExSelector.d.ts +1 -1
- package/lib/view/transactionDetail/epics/transactionDetailEpic.d.ts +2 -1
- package/lib/view/transactionDetail/epics/transactionDetailEpic.js +14 -2
- package/lib/view/transactionDetail/transactionDetailPayload.d.ts +1 -1
- package/lib/view/transactionDetail/transactionDetailReducer.d.ts +3 -12
- package/lib/view/transactionDetail/transactionDetailReducer.js +9 -123
- package/lib/view/transactionDetail/transactionDetailSelector.d.ts +6 -3
- package/lib/view/transactionDetail/transactionDetailSelector.js +7 -25
- package/lib/view/transactionDetail/transactionDetailTypes.d.ts +0 -1
- package/package.json +1 -1
- package/lib/esm/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -83
- package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
- package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.d.ts +0 -9
- 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
|
-
}))));
|