@zeniai/client-epic-state 4.20.3-betaVR5 → 4.20.3
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/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +0 -1
- package/lib/epic.d.ts +1 -3
- package/lib/epic.js +1 -3
- package/lib/esm/entity/snackbar/snackbarTypes.js +0 -1
- package/lib/esm/epic.js +2 -4
- package/lib/esm/index.js +2 -2
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +4 -7
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +13 -7
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +5 -40
- package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +0 -9
- package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +3 -26
- package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +0 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +32 -35
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +3 -6
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +13 -7
- package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +2 -9
- package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +4 -40
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +0 -5
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +0 -10
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +2 -12
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +4 -27
- package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +0 -1
- package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +0 -1
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +0 -4
- package/package.json +2 -2
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/refetchCompletedTransactionsOnBulkUploadSortEpic.js +0 -12
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +0 -99
- package/lib/esm/view/expenseAutomationView/helpers/rollingCalendarDateRangeInclusive.js +0 -13
- package/lib/view/expenseAutomationView/epics/missingReceipts/refetchCompletedTransactionsOnBulkUploadSortEpic.d.ts +0 -10
- package/lib/view/expenseAutomationView/epics/missingReceipts/refetchCompletedTransactionsOnBulkUploadSortEpic.js +0 -16
- package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.d.ts +0 -18
- package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +0 -103
- package/lib/view/expenseAutomationView/helpers/rollingCalendarDateRangeInclusive.d.ts +0 -7
- package/lib/view/expenseAutomationView/helpers/rollingCalendarDateRangeInclusive.js +0 -16
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.refetchCompletedTransactionsOnBulkUploadSortEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
7
|
-
/**
|
|
8
|
-
* Completed transactions are cached per sort key/order/sub-tab. After a sort or sub-tab
|
|
9
|
-
* change, the fetch epic would otherwise skip the network when that cache entry already
|
|
10
|
-
* exists — dispatch a cache-bypassing initial fetch whenever either changes from the UI.
|
|
11
|
-
*/
|
|
12
|
-
const refetchCompletedTransactionsOnBulkUploadSortEpic = (actions$) => {
|
|
13
|
-
return actions$.pipe((0, operators_1.filter)((action) => missingReceiptsViewReducer_1.setBulkUploadSortConfig.match(action) ||
|
|
14
|
-
missingReceiptsViewReducer_1.setBulkUploadCompletedSubTab.match(action)), (0, operators_1.mergeMap)(() => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchCompletedTransactions)(undefined, true))));
|
|
15
|
-
};
|
|
16
|
-
exports.refetchCompletedTransactionsOnBulkUploadSortEpic = refetchCompletedTransactionsOnBulkUploadSortEpic;
|
|
@@ -1,18 +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 { fetchBulkUploadBatchesSuccess, restoreBulkUploadAutomatchingOnMount, restoreBulkUploadMatchingState } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
-
export type ActionType = ReturnType<typeof restoreBulkUploadAutomatchingOnMount> | ReturnType<typeof fetchBulkUploadBatchesSuccess> | ReturnType<typeof restoreBulkUploadMatchingState>;
|
|
7
|
-
/**
|
|
8
|
-
* On missing-receipts entry / period switch, hydrate the automatching banner for the logged-in
|
|
9
|
-
* user without relying on UI-driven list fetches (the Missing tab does not fetch the batch list
|
|
10
|
-
* while `phase === 'idle'`). Flow:
|
|
11
|
-
* 1. Call `GET /1.0/batches` (rolling 30-day window).
|
|
12
|
-
* 2. Emit `fetchBulkUploadBatchesSuccess` so `batchListByPeriod` is populated for the selected
|
|
13
|
-
* period (prevents a duplicate list fetch when the user switches to the Unmatched tab).
|
|
14
|
-
* 3. For each `processing|pending` row, call `GET /1.0/batches/:id` in order; for the first row
|
|
15
|
-
* whose details `user_id` matches the logged-in user and whose status is still
|
|
16
|
-
* pending/processing, dispatch `restoreBulkUploadMatchingState` and stop.
|
|
17
|
-
*/
|
|
18
|
-
export declare const restoreBulkUploadAutomatchingOnMountEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.restoreBulkUploadAutomatchingOnMountEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const responsePayload_1 = require("../../../../responsePayload");
|
|
7
|
-
const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
|
|
8
|
-
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
9
|
-
const rollingCalendarDateRangeInclusive_1 = require("../../helpers/rollingCalendarDateRangeInclusive");
|
|
10
|
-
const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
|
|
11
|
-
const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
|
|
12
|
-
/** Mirrors `BULK_UPLOAD_BATCH_LIST_DATE_RANGE_DAYS` in `fetchBulkUploadBatchesEpic` — rolling, period-agnostic. */
|
|
13
|
-
const BULK_UPLOAD_BATCH_LIST_DATE_RANGE_DAYS = 30;
|
|
14
|
-
/**
|
|
15
|
-
* On missing-receipts entry / period switch, hydrate the automatching banner for the logged-in
|
|
16
|
-
* user without relying on UI-driven list fetches (the Missing tab does not fetch the batch list
|
|
17
|
-
* while `phase === 'idle'`). Flow:
|
|
18
|
-
* 1. Call `GET /1.0/batches` (rolling 30-day window).
|
|
19
|
-
* 2. Emit `fetchBulkUploadBatchesSuccess` so `batchListByPeriod` is populated for the selected
|
|
20
|
-
* period (prevents a duplicate list fetch when the user switches to the Unmatched tab).
|
|
21
|
-
* 3. For each `processing|pending` row, call `GET /1.0/batches/:id` in order; for the first row
|
|
22
|
-
* whose details `user_id` matches the logged-in user and whose status is still
|
|
23
|
-
* pending/processing, dispatch `restoreBulkUploadMatchingState` and stop.
|
|
24
|
-
*/
|
|
25
|
-
const restoreBulkUploadAutomatchingOnMountEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.restoreBulkUploadAutomatchingOnMount.match), (0, operators_1.mergeMap)(() => {
|
|
26
|
-
const state = state$.value;
|
|
27
|
-
const { expenseAutomationMissingReceiptsViewState: { bulkUpload }, expenseAutomationViewState: { selectedPeriodByTenantId }, } = state;
|
|
28
|
-
if (bulkUpload.phase !== 'idle') {
|
|
29
|
-
return rxjs_1.EMPTY;
|
|
30
|
-
}
|
|
31
|
-
if (bulkUpload.batchListFetchState.fetchState === 'In-Progress') {
|
|
32
|
-
return rxjs_1.EMPTY;
|
|
33
|
-
}
|
|
34
|
-
const loggedInUserId = state.tenantState.loggedInUser?.userId;
|
|
35
|
-
if (loggedInUserId == null) {
|
|
36
|
-
return rxjs_1.EMPTY;
|
|
37
|
-
}
|
|
38
|
-
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
39
|
-
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
40
|
-
if (selectedPeriod == null) {
|
|
41
|
-
return rxjs_1.EMPTY;
|
|
42
|
-
}
|
|
43
|
-
const { end, start } = (0, rollingCalendarDateRangeInclusive_1.rollingCalendarDateRangeInclusive)(BULK_UPLOAD_BATCH_LIST_DATE_RANGE_DAYS);
|
|
44
|
-
const queryParam = {
|
|
45
|
-
start_date: start,
|
|
46
|
-
end_date: end,
|
|
47
|
-
sort_order: 'desc',
|
|
48
|
-
};
|
|
49
|
-
const listUrl = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches?query=${encodeURIComponent(JSON.stringify(queryParam))}`;
|
|
50
|
-
const detailsBaseUrl = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/`;
|
|
51
|
-
const periodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
|
|
52
|
-
const alreadyCached = (bulkUpload.batchListByPeriod[periodId] ?? []).length > 0 &&
|
|
53
|
-
bulkUpload.batchListFetchState.fetchState === 'Completed';
|
|
54
|
-
const listSource = alreadyCached
|
|
55
|
-
? (0, rxjs_1.of)(null)
|
|
56
|
-
: zeniAPI.getJSON(listUrl).pipe((0, operators_1.catchError)(() => (0, rxjs_1.of)(null)));
|
|
57
|
-
return listSource.pipe((0, operators_1.mergeMap)((listResponse) => {
|
|
58
|
-
const batchList = alreadyCached
|
|
59
|
-
? bulkUpload.batchListByPeriod[periodId] ?? []
|
|
60
|
-
: listResponse != null &&
|
|
61
|
-
(0, responsePayload_1.isSuccessResponse)(listResponse) &&
|
|
62
|
-
listResponse.data != null
|
|
63
|
-
? listResponse.data.batches.map(missingReceiptsPayload_1.toBatchListItem)
|
|
64
|
-
: null;
|
|
65
|
-
if (batchList == null) {
|
|
66
|
-
return rxjs_1.EMPTY;
|
|
67
|
-
}
|
|
68
|
-
const successAction = alreadyCached
|
|
69
|
-
? null
|
|
70
|
-
: (0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesSuccess)({
|
|
71
|
-
batchList,
|
|
72
|
-
selectedPeriod,
|
|
73
|
-
});
|
|
74
|
-
const processingBatches = batchList.filter((b) => {
|
|
75
|
-
const status = b.status.toLowerCase();
|
|
76
|
-
return status === 'processing' || status === 'pending';
|
|
77
|
-
});
|
|
78
|
-
const restoreStream = (0, rxjs_1.from)(processingBatches).pipe((0, operators_1.concatMap)((batch) => zeniAPI
|
|
79
|
-
.getJSON(`${detailsBaseUrl}${batch.batchId}`)
|
|
80
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
81
|
-
if (!(0, responsePayload_1.isSuccessResponse)(response) || response.data == null) {
|
|
82
|
-
return rxjs_1.EMPTY;
|
|
83
|
-
}
|
|
84
|
-
const data = response.data;
|
|
85
|
-
const detailsUserId = data.user_id;
|
|
86
|
-
if (detailsUserId == null ||
|
|
87
|
-
detailsUserId !== loggedInUserId) {
|
|
88
|
-
return rxjs_1.EMPTY;
|
|
89
|
-
}
|
|
90
|
-
if (!(0, missingReceiptsPayload_1.isBatchDetailsStatusPendingOrProcessing)(data.status)) {
|
|
91
|
-
return rxjs_1.EMPTY;
|
|
92
|
-
}
|
|
93
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.restoreBulkUploadMatchingState)({
|
|
94
|
-
batchId: batch.batchId,
|
|
95
|
-
totalFiles: batch.totalFiles,
|
|
96
|
-
}));
|
|
97
|
-
}), (0, operators_1.catchError)(() => rxjs_1.EMPTY))), (0, operators_1.take)(1));
|
|
98
|
-
return successAction != null
|
|
99
|
-
? (0, rxjs_1.concat)((0, rxjs_1.of)(successAction), restoreStream)
|
|
100
|
-
: restoreStream;
|
|
101
|
-
}));
|
|
102
|
-
}));
|
|
103
|
-
exports.restoreBulkUploadAutomatchingOnMountEpic = restoreBulkUploadAutomatchingOnMountEpic;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rollingCalendarDateRangeInclusive = rollingCalendarDateRangeInclusive;
|
|
4
|
-
const formatZeniDateFY_1 = require("../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
|
|
5
|
-
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
6
|
-
/**
|
|
7
|
-
* Local calendar dates from (end − (days − 1)) through end, inclusive.
|
|
8
|
-
*/
|
|
9
|
-
function rollingCalendarDateRangeInclusive(days) {
|
|
10
|
-
const end = (0, zeniDayJS_1.dateNow)().startOf('day');
|
|
11
|
-
const start = end.subtract(days - 1, 'day');
|
|
12
|
-
return {
|
|
13
|
-
end: end.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT),
|
|
14
|
-
start: start.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT),
|
|
15
|
-
};
|
|
16
|
-
}
|