@zeniai/client-epic-state 5.0.69-betaML1 → 5.0.69-betaML11
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 -29
- 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 +3 -110
- 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 -30
- 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 +4 -111
- 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 -87
- package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.d.ts +0 -9
- package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -91
|
@@ -1,91 +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
|
-
// TEMP-LOG[JE-skeleton]: epic dispatch payload — confirms the
|
|
49
|
-
// targeted-fetch fired with the expected flowType / txnId / lineIds.
|
|
50
|
-
console.log('[JE-skeleton][epic] dispatch start arm', {
|
|
51
|
-
flowType,
|
|
52
|
-
selectedTab,
|
|
53
|
-
transactionId,
|
|
54
|
-
lineIds,
|
|
55
|
-
transactionType: transaction?.type,
|
|
56
|
-
});
|
|
57
|
-
const url = (0, recommendationHelper_1.buildRecommendationUrl)(zeniAPI.apiEndPoints.accountMicroServiceBaseUrl, entity, amount, transactionDetails, isFetchCOT === true);
|
|
58
|
-
const httpStream$ = zeniAPI
|
|
59
|
-
.getJSON(url)
|
|
60
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
61
|
-
if (!(0, responsePayload_1.isSuccessResponse)(response) || response.data == null) {
|
|
62
|
-
return (0, rxjs_1.of)(flowType === 'categorization' && selectedTab != null
|
|
63
|
-
? (0, transactionsViewReducer_1.markCategoryClassRecommendationsFailureForCategorization)(selectedTab, transactionId, lineIds, response.status)
|
|
64
|
-
: (0, transactionDetailReducer_1.markCategoryClassRecommendationsFailureForTransactionDetail)(transactionId, lineIds, response.status));
|
|
65
|
-
}
|
|
66
|
-
const recommendationWithCOTByLineId = (0, recommendationHelper_1.getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT)(response.data.recommendations, lineIds);
|
|
67
|
-
// HTTP 200 with no per-line recommendations: NOT an error.
|
|
68
|
-
// Flip lines to Completed so the skeleton resolves and
|
|
69
|
-
// downstream UI can treat this as "we tried, nothing to
|
|
70
|
-
// apply".
|
|
71
|
-
if (recommendationWithCOTByLineId == null) {
|
|
72
|
-
return (0, rxjs_1.of)(flowType === 'categorization' && selectedTab != null
|
|
73
|
-
? (0, transactionsViewReducer_1.markCategoryClassRecommendationsCompletedForCategorization)(selectedTab, transactionId, lineIds)
|
|
74
|
-
: (0, transactionDetailReducer_1.markCategoryClassRecommendationsCompletedForTransactionDetail)(transactionId, lineIds));
|
|
75
|
-
}
|
|
76
|
-
const transactionWithCOT = isFetchCOT === true
|
|
77
|
-
? (0, transactionHelper_1.getTransactionWithCOTFromRecommendations)(transaction, recommendationWithCOTByLineId)
|
|
78
|
-
: (0, transactionHelper_1.getTransactionWithCOT)(transaction);
|
|
79
|
-
const uncategorizedIncomeExpense = (0, accountListSelector_1.getUncategorizedAccounts)(state$.value.accountState, state$.value.accountListState, 'accountList');
|
|
80
|
-
if (flowType === 'categorization' && selectedTab != null) {
|
|
81
|
-
return (0, rxjs_1.of)((0, transactionsViewReducer_1.setEntityRecommendationForLineIdsForCategorization)(selectedTab, transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense, isUncategorizedExpenseCategoryEnabled, (0, tenantSelector_1.getIsAccountingClassesEnabled)(state$.value)));
|
|
82
|
-
}
|
|
83
|
-
return (0, rxjs_1.of)((0, transactionDetailReducer_1.setEntityRecommendationForLineIdsForTransactionDetail)(transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense));
|
|
84
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)(flowType === 'categorization' && selectedTab != null
|
|
85
|
-
? (0, transactionsViewReducer_1.markCategoryClassRecommendationsFailureForCategorization)(selectedTab, transactionId, lineIds, (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'fetchEntityRecommendationsForLineUpdate failed: ' +
|
|
86
|
-
JSON.stringify(error)))
|
|
87
|
-
: (0, transactionDetailReducer_1.markCategoryClassRecommendationsFailureForTransactionDetail)(transactionId, lineIds, (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'fetchEntityRecommendationsForLineUpdate failed: ' +
|
|
88
|
-
JSON.stringify(error))))));
|
|
89
|
-
return (0, rxjs_1.concat)((0, rxjs_1.of)(startAction), httpStream$);
|
|
90
|
-
}))));
|
|
91
|
-
exports.fetchEntityRecommendationsForLineUpdateEpic = fetchEntityRecommendationsForLineUpdateEpic;
|