@zeniai/client-epic-state 4.19.37-betaVR8 → 4.19.37
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 -9
- package/lib/epic.js +1 -9
- package/lib/esm/entity/snackbar/snackbarTypes.js +0 -1
- package/lib/esm/epic.js +1 -9
- package/lib/esm/index.js +2 -4
- package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +1 -100
- package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +1 -264
- package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +1 -128
- package/lib/esm/zeniAPI.js +3 -41
- package/lib/index.d.ts +5 -7
- package/lib/index.js +30 -58
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +0 -108
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +0 -107
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +3 -51
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -265
- package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +1 -61
- package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.d.ts +1 -1
- package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +0 -127
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +0 -104
- package/lib/zeniAPI.d.ts +0 -9
- package/lib/zeniAPI.js +2 -40
- package/package.json +2 -2
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +0 -24
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +0 -49
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +0 -31
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +0 -41
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +0 -57
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +0 -35
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +0 -27
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +0 -41
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +0 -15
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +0 -28
- package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts +0 -7
- package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +0 -53
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +0 -35
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts +0 -7
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +0 -45
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +0 -61
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +0 -39
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +0 -6
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +0 -31
- package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +0 -15
- package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +0 -46
package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { EMPTY, from } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
|
|
4
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
5
|
-
import { extractTransactionPayloadsFromBatchFiles, toBatchDetails, } from '../../payload/missingReceiptsPayload';
|
|
6
|
-
import { fetchBulkUploadBatchesSuccess, storeBatchDetails, } from '../../reducers/missingReceiptsViewReducer';
|
|
7
|
-
export const fetchMultipleBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchBulkUploadBatchesSuccess.match), mergeMap((action) => {
|
|
8
|
-
const batchList = action.payload.batchList;
|
|
9
|
-
const { batchDetailsById } = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
|
|
10
|
-
const completedBatchIds = batchList
|
|
11
|
-
.filter((batch) => batch.status === 'completed' &&
|
|
12
|
-
batchDetailsById[batch.batchId] == null)
|
|
13
|
-
.map((batch) => batch.batchId);
|
|
14
|
-
if (completedBatchIds.length === 0) {
|
|
15
|
-
return EMPTY;
|
|
16
|
-
}
|
|
17
|
-
return from(completedBatchIds).pipe(mergeMap((batchId) => zeniAPI
|
|
18
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/receipts/batches/${batchId}`)
|
|
19
|
-
.pipe(mergeMap((response) => {
|
|
20
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
21
|
-
const actions = [];
|
|
22
|
-
const transactionPayloads = extractTransactionPayloadsFromBatchFiles(response.data.files);
|
|
23
|
-
if (transactionPayloads.length > 0) {
|
|
24
|
-
actions.push(updateTransactions(transactionPayloads, (value) => value.transaction_id));
|
|
25
|
-
}
|
|
26
|
-
actions.push(storeBatchDetails(toBatchDetails(response.data)));
|
|
27
|
-
return from(actions);
|
|
28
|
-
}
|
|
29
|
-
return EMPTY;
|
|
30
|
-
}), catchError((error) => {
|
|
31
|
-
console.error(`Failed to fetch batch details for ${batchId}:`, createZeniAPIStatus('Unexpected Error', 'Fetch batch details errored out: ' +
|
|
32
|
-
JSON.stringify(error)));
|
|
33
|
-
return EMPTY;
|
|
34
|
-
})), 5));
|
|
35
|
-
}));
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { of } from 'rxjs';
|
|
2
|
-
import { catchError, debounceTime, filter, switchMap } from 'rxjs/operators';
|
|
3
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
4
|
-
import { toManualSearchResult, } from '../../payload/missingReceiptsPayload';
|
|
5
|
-
import { searchTransactionsForManualMatch, searchTransactionsForManualMatchFailure, searchTransactionsForManualMatchSuccess, } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
-
export const searchTransactionsForManualMatchEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(searchTransactionsForManualMatch.match), debounceTime(300), switchMap((action) => {
|
|
7
|
-
const { query } = action.payload;
|
|
8
|
-
const searchQuery = JSON.stringify({
|
|
9
|
-
search_text: query,
|
|
10
|
-
search_fields: ['date', 'amount', 'vendor_name'],
|
|
11
|
-
});
|
|
12
|
-
const encodedQuery = encodeURIComponent(searchQuery);
|
|
13
|
-
return zeniAPI
|
|
14
|
-
.getJSON(`${zeniAPI.apiEndPoints.searchMicroServiceBaseUrl}/1.0/transaction-search?query=${encodedQuery}`)
|
|
15
|
-
.pipe(switchMap((response) => {
|
|
16
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
17
|
-
const results = response.data.transactions.map(toManualSearchResult);
|
|
18
|
-
return of(searchTransactionsForManualMatchSuccess(results));
|
|
19
|
-
}
|
|
20
|
-
return of(searchTransactionsForManualMatchFailure({
|
|
21
|
-
error: response.status,
|
|
22
|
-
}));
|
|
23
|
-
}), catchError((error) => of(searchTransactionsForManualMatchFailure({
|
|
24
|
-
error: createZeniAPIStatus('Unexpected Error', 'Search transactions for manual match errored: ' +
|
|
25
|
-
JSON.stringify(error)),
|
|
26
|
-
}))));
|
|
27
|
-
}));
|
package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { of, timer } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap, switchMap, takeUntil, takeWhile, } from 'rxjs/operators';
|
|
3
|
-
import { isSuccessResponse } from '../../../../responsePayload';
|
|
4
|
-
import { toBatchStatus, } from '../../payload/missingReceiptsPayload';
|
|
5
|
-
import { bulkUploadReceiptsSuccess, clearBulkUpload, fetchBulkUploadBatchDetails, pusherBatchStatusUpdate, updateBulkUploadBatchStatus, } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
-
/**
|
|
7
|
-
* Watches batch status using two strategies:
|
|
8
|
-
* 1. Pusher (primary): Reacts to `pusherBatchStatusUpdate` dispatched by the UI layer
|
|
9
|
-
* when a Pusher event arrives. Immediately fetches full details on completion.
|
|
10
|
-
* 2. Polling (fallback): Starts a relaxed 10s poll after upload success as a safety net
|
|
11
|
-
* in case the Pusher event is missed. Stops on completion or `clearBulkUpload`.
|
|
12
|
-
*/
|
|
13
|
-
// Pusher-driven: when Pusher delivers a completed status, fetch details
|
|
14
|
-
export const pusherBatchStatusCompletionEpic = (actions$) => actions$.pipe(filter(pusherBatchStatusUpdate.match), filter((action) => action.payload.status === 'completed'), mergeMap(() => of(fetchBulkUploadBatchDetails())));
|
|
15
|
-
// Polling fallback: relaxed interval as safety net
|
|
16
|
-
const FALLBACK_POLL_INTERVAL_MS = 10000;
|
|
17
|
-
export const pollBulkUploadBatchStatusEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(bulkUploadReceiptsSuccess.match), switchMap((action) => {
|
|
18
|
-
const { batchId } = action.payload;
|
|
19
|
-
return timer(0, FALLBACK_POLL_INTERVAL_MS).pipe(takeUntil(actions$.pipe(filter((a) => clearBulkUpload.match(a) ||
|
|
20
|
-
(pusherBatchStatusUpdate.match(a) &&
|
|
21
|
-
a.payload.status === 'completed')))), switchMap(() => zeniAPI
|
|
22
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/receipts/batches/${batchId}/status`)
|
|
23
|
-
.pipe(mergeMap((response) => {
|
|
24
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
25
|
-
const batchStatus = toBatchStatus(response.data);
|
|
26
|
-
const actions = [
|
|
27
|
-
updateBulkUploadBatchStatus(batchStatus),
|
|
28
|
-
];
|
|
29
|
-
if (batchStatus.status === 'completed') {
|
|
30
|
-
actions.push(fetchBulkUploadBatchDetails());
|
|
31
|
-
}
|
|
32
|
-
return actions;
|
|
33
|
-
}
|
|
34
|
-
return [];
|
|
35
|
-
}), catchError(() => of()))), takeWhile((action) => {
|
|
36
|
-
if (fetchBulkUploadBatchDetails.match(action)) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
return true;
|
|
40
|
-
}, true));
|
|
41
|
-
}));
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable } from 'redux-observable';
|
|
2
|
-
import { ZeniAPI } from '../../../../zeniAPI';
|
|
3
|
-
import { bulkUploadReceipts, bulkUploadReceiptsFailure, bulkUploadReceiptsSuccess } from '../../reducers/missingReceiptsViewReducer';
|
|
4
|
-
export type ActionType = ReturnType<typeof bulkUploadReceipts> | ReturnType<typeof bulkUploadReceiptsSuccess> | ReturnType<typeof bulkUploadReceiptsFailure>;
|
|
5
|
-
export declare const bulkUploadReceiptsEpic: (actions$: ActionsObservable<ActionType>, _state$: unknown, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
|
|
6
|
-
payload: {
|
|
7
|
-
batchId: import("../../../..").ID;
|
|
8
|
-
};
|
|
9
|
-
type: "expenseAutomationMissingReceiptsView/bulkUploadReceiptsSuccess";
|
|
10
|
-
} | {
|
|
11
|
-
payload: {
|
|
12
|
-
error: import("../../../../responsePayload").ZeniAPIStatus;
|
|
13
|
-
};
|
|
14
|
-
type: "expenseAutomationMissingReceiptsView/bulkUploadReceiptsFailure";
|
|
15
|
-
}>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bulkUploadReceiptsEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const responsePayload_1 = require("../../../../responsePayload");
|
|
7
|
-
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
8
|
-
const bulkUploadReceiptsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.bulkUploadReceipts.match), (0, operators_1.mergeMap)((action) => {
|
|
9
|
-
const { files } = action.payload;
|
|
10
|
-
const formData = new FormData();
|
|
11
|
-
for (const file of files) {
|
|
12
|
-
formData.append('files', file, file.name);
|
|
13
|
-
}
|
|
14
|
-
return zeniAPI
|
|
15
|
-
.postFormData(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`, formData)
|
|
16
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
17
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
18
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsSuccess)({
|
|
19
|
-
batchId: response.data.batch_id,
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
22
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsFailure)({ error: response.status }));
|
|
23
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsFailure)({
|
|
24
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Bulk upload receipts API call errored out: ' +
|
|
25
|
-
JSON.stringify(error)),
|
|
26
|
-
}))));
|
|
27
|
-
}));
|
|
28
|
-
exports.bulkUploadReceiptsEpic = bulkUploadReceiptsEpic;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
4
|
-
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
-
import { confirmBulkUploadMatch, confirmBulkUploadMatchFailure, confirmBulkUploadMatchSuccess } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
-
export type ActionType = ReturnType<typeof confirmBulkUploadMatch> | ReturnType<typeof confirmBulkUploadMatchSuccess> | ReturnType<typeof confirmBulkUploadMatchFailure> | ReturnType<typeof openSnackbar>;
|
|
7
|
-
export declare const confirmBulkUploadMatchEpic: (actions$: ActionsObservable<ActionType>, _state$: unknown, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.confirmBulkUploadMatchEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
|
|
7
|
-
const responsePayload_1 = require("../../../../responsePayload");
|
|
8
|
-
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
9
|
-
const confirmBulkUploadMatchEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.confirmBulkUploadMatch.match), (0, operators_1.mergeMap)((action) => {
|
|
10
|
-
const { batchId, attachmentId, transactionId, transactionType, fileName } = action.payload;
|
|
11
|
-
return zeniAPI
|
|
12
|
-
.postAndGetJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/manual-match`, {
|
|
13
|
-
attachment_id: attachmentId,
|
|
14
|
-
transaction_id: transactionId,
|
|
15
|
-
transaction_type: transactionType,
|
|
16
|
-
file_name: fileName,
|
|
17
|
-
})
|
|
18
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
19
|
-
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
20
|
-
return (0, rxjs_1.from)([
|
|
21
|
-
(0, missingReceiptsViewReducer_1.confirmBulkUploadMatchSuccess)({
|
|
22
|
-
batchId,
|
|
23
|
-
attachmentId,
|
|
24
|
-
transactionId,
|
|
25
|
-
}),
|
|
26
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
27
|
-
messageSection: 'receipt_match',
|
|
28
|
-
messageText: 'success',
|
|
29
|
-
type: 'success',
|
|
30
|
-
}),
|
|
31
|
-
]);
|
|
32
|
-
}
|
|
33
|
-
return (0, rxjs_1.from)([
|
|
34
|
-
(0, missingReceiptsViewReducer_1.confirmBulkUploadMatchFailure)({ error: response.status }),
|
|
35
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
36
|
-
messageSection: 'receipt_match',
|
|
37
|
-
messageText: 'failed',
|
|
38
|
-
type: 'error',
|
|
39
|
-
}),
|
|
40
|
-
]);
|
|
41
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
42
|
-
(0, missingReceiptsViewReducer_1.confirmBulkUploadMatchFailure)({
|
|
43
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Confirm bulk upload match errored out: ' +
|
|
44
|
-
JSON.stringify(error)),
|
|
45
|
-
}),
|
|
46
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
47
|
-
messageSection: 'receipt_match',
|
|
48
|
-
messageText: 'failed',
|
|
49
|
-
type: 'error',
|
|
50
|
-
}),
|
|
51
|
-
])));
|
|
52
|
-
}));
|
|
53
|
-
exports.confirmBulkUploadMatchEpic = confirmBulkUploadMatchEpic;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
|
|
4
|
-
import { RootState } from '../../../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../../../zeniAPI';
|
|
6
|
-
import { fetchBulkUploadBatchDetails, fetchBulkUploadBatchDetailsFailure, fetchBulkUploadBatchDetailsSuccess, fetchBulkUploadBatches } from '../../reducers/missingReceiptsViewReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof fetchBulkUploadBatchDetails> | ReturnType<typeof updateTransactions> | ReturnType<typeof fetchBulkUploadBatchDetailsSuccess> | ReturnType<typeof fetchBulkUploadBatchDetailsFailure> | ReturnType<typeof fetchBulkUploadBatches>;
|
|
8
|
-
export declare const fetchBulkUploadBatchDetailsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchBulkUploadBatchDetailsEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
|
|
7
|
-
const responsePayload_1 = require("../../../../responsePayload");
|
|
8
|
-
const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
|
|
9
|
-
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
10
|
-
const fetchBulkUploadBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatchDetails.match), (0, operators_1.mergeMap)(() => {
|
|
11
|
-
const { currentBatchId } = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
|
|
12
|
-
if (currentBatchId == null) {
|
|
13
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsFailure)({
|
|
14
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'No current batch ID available'),
|
|
15
|
-
}));
|
|
16
|
-
}
|
|
17
|
-
return zeniAPI
|
|
18
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/receipts/batches/${currentBatchId}`)
|
|
19
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
20
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
21
|
-
const actions = [];
|
|
22
|
-
const transactionPayloads = (0, missingReceiptsPayload_1.extractTransactionPayloadsFromBatchFiles)(response.data.files);
|
|
23
|
-
if (transactionPayloads.length > 0) {
|
|
24
|
-
actions.push((0, transactionReducer_1.updateTransactions)(transactionPayloads, (value) => value.transaction_id));
|
|
25
|
-
}
|
|
26
|
-
actions.push((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsSuccess)((0, missingReceiptsPayload_1.toBatchDetails)(response.data)));
|
|
27
|
-
actions.push((0, missingReceiptsViewReducer_1.fetchBulkUploadBatches)(true));
|
|
28
|
-
return (0, rxjs_1.from)(actions);
|
|
29
|
-
}
|
|
30
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsFailure)({ error: response.status }));
|
|
31
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsFailure)({
|
|
32
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch batch details errored out: ' + JSON.stringify(error)),
|
|
33
|
-
}))));
|
|
34
|
-
}));
|
|
35
|
-
exports.fetchBulkUploadBatchDetailsEpic = fetchBulkUploadBatchDetailsEpic;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts
DELETED
|
@@ -1,7 +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 { fetchBulkUploadBatches, fetchBulkUploadBatchesFailure, fetchBulkUploadBatchesSuccess } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
-
export type ActionType = ReturnType<typeof fetchBulkUploadBatches> | ReturnType<typeof fetchBulkUploadBatchesSuccess> | ReturnType<typeof fetchBulkUploadBatchesFailure>;
|
|
7
|
-
export declare const fetchBulkUploadBatchesEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchBulkUploadBatchesEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
|
|
7
|
-
const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
|
|
8
|
-
const responsePayload_1 = require("../../../../responsePayload");
|
|
9
|
-
const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
|
|
10
|
-
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
11
|
-
const fetchBulkUploadBatchesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatches.match), (0, operators_1.switchMap)((action) => {
|
|
12
|
-
const { cacheOverride } = action.payload;
|
|
13
|
-
const state = state$.value;
|
|
14
|
-
const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
|
|
15
|
-
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
16
|
-
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
17
|
-
const periodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
|
|
18
|
-
const existingBatches = bulkUpload.batchListByPeriod[periodId] ?? [];
|
|
19
|
-
if (cacheOverride !== true && existingBatches.length > 0) {
|
|
20
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesSuccess)({
|
|
21
|
-
batchList: existingBatches,
|
|
22
|
-
selectedPeriod,
|
|
23
|
-
}));
|
|
24
|
-
}
|
|
25
|
-
const period = (0, timePeriod_1.convertToPeriod)(selectedPeriod);
|
|
26
|
-
return zeniAPI
|
|
27
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/receipts/batches?start_date=${period.start}&end_date=${period.end}`)
|
|
28
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
29
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
30
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesSuccess)({
|
|
31
|
-
batchList: response.data.batches.map(missingReceiptsPayload_1.toBatchListItem),
|
|
32
|
-
selectedPeriod,
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesFailure)({
|
|
36
|
-
error: response.status,
|
|
37
|
-
selectedPeriod,
|
|
38
|
-
}));
|
|
39
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesFailure)({
|
|
40
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch bulk upload batches errored out: ' +
|
|
41
|
-
JSON.stringify(error)),
|
|
42
|
-
selectedPeriod,
|
|
43
|
-
}))));
|
|
44
|
-
}));
|
|
45
|
-
exports.fetchBulkUploadBatchesEpic = fetchBulkUploadBatchesEpic;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
|
|
4
|
-
import { RootState } from '../../../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../../../zeniAPI';
|
|
6
|
-
import { fetchCompletedTransactions, fetchCompletedTransactionsFailure, fetchCompletedTransactionsSuccess } from '../../reducers/missingReceiptsViewReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof fetchCompletedTransactions> | ReturnType<typeof updateTransactions> | ReturnType<typeof fetchCompletedTransactionsSuccess> | ReturnType<typeof fetchCompletedTransactionsFailure>;
|
|
8
|
-
export declare const fetchCompletedTransactionsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchCompletedTransactionsEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
|
|
7
|
-
const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
|
|
8
|
-
const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
|
|
9
|
-
const responsePayload_1 = require("../../../../responsePayload");
|
|
10
|
-
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
11
|
-
const fetchCompletedTransactionsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchCompletedTransactions.match), (0, operators_1.switchMap)((action) => {
|
|
12
|
-
const state = state$.value;
|
|
13
|
-
const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
|
|
14
|
-
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
15
|
-
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
16
|
-
const periodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
|
|
17
|
-
const isInitialLoad = action.payload.pageToken == null;
|
|
18
|
-
const existingData = bulkUpload.completedTransactionsByPeriod[periodId];
|
|
19
|
-
if (isInitialLoad && existingData != null && existingData.transactionIds.length > 0) {
|
|
20
|
-
return (0, rxjs_1.from)([]);
|
|
21
|
-
}
|
|
22
|
-
const period = (0, timePeriod_1.convertToPeriod)(selectedPeriod);
|
|
23
|
-
const queryPayload = {
|
|
24
|
-
start_date: period.start,
|
|
25
|
-
end_date: period.end,
|
|
26
|
-
sort_by: bulkUpload.sortKey,
|
|
27
|
-
sort_order: bulkUpload.sortOrder === 'ascending' ? 'asc' : 'desc',
|
|
28
|
-
page_token: action.payload.pageToken ?? null,
|
|
29
|
-
page_size: 25,
|
|
30
|
-
};
|
|
31
|
-
if (bulkUpload.completedSubTab !== 'all') {
|
|
32
|
-
queryPayload.match_type = bulkUpload.completedSubTab;
|
|
33
|
-
}
|
|
34
|
-
const encodedQuery = encodeURIComponent(JSON.stringify(queryPayload));
|
|
35
|
-
return zeniAPI
|
|
36
|
-
.getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipt-agent/transactions/completed?query=${encodedQuery}`)
|
|
37
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
38
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
39
|
-
const transactionIds = response.data.transactions.map((t) => t.transaction_id);
|
|
40
|
-
const updateActions = [];
|
|
41
|
-
updateActions.push((0, transactionReducer_1.updateTransactions)(response.data.transactions, (value) => value.transaction_id));
|
|
42
|
-
updateActions.push((0, missingReceiptsViewReducer_1.fetchCompletedTransactionsSuccess)({
|
|
43
|
-
isInitialLoad,
|
|
44
|
-
transactionIds,
|
|
45
|
-
nextPageToken: response.data.next_page_token,
|
|
46
|
-
totalCount: response.data.total_count,
|
|
47
|
-
selectedPeriod,
|
|
48
|
-
}));
|
|
49
|
-
return (0, rxjs_1.from)(updateActions);
|
|
50
|
-
}
|
|
51
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchCompletedTransactionsFailure)({
|
|
52
|
-
error: response.status,
|
|
53
|
-
selectedPeriod,
|
|
54
|
-
}));
|
|
55
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchCompletedTransactionsFailure)({
|
|
56
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch completed transactions errored: ' +
|
|
57
|
-
JSON.stringify(error)),
|
|
58
|
-
selectedPeriod,
|
|
59
|
-
}))));
|
|
60
|
-
}));
|
|
61
|
-
exports.fetchCompletedTransactionsEpic = fetchCompletedTransactionsEpic;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
|
|
4
|
-
import { RootState } from '../../../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../../../zeniAPI';
|
|
6
|
-
import { fetchBulkUploadBatchesSuccess, storeBatchDetails } from '../../reducers/missingReceiptsViewReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof fetchBulkUploadBatchesSuccess> | ReturnType<typeof updateTransactions> | ReturnType<typeof storeBatchDetails>;
|
|
8
|
-
export declare const fetchMultipleBatchDetailsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchMultipleBatchDetailsEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
|
|
7
|
-
const responsePayload_1 = require("../../../../responsePayload");
|
|
8
|
-
const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
|
|
9
|
-
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
10
|
-
const fetchMultipleBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatchesSuccess.match), (0, operators_1.mergeMap)((action) => {
|
|
11
|
-
const batchList = action.payload.batchList;
|
|
12
|
-
const { batchDetailsById } = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
|
|
13
|
-
const completedBatchIds = batchList
|
|
14
|
-
.filter((batch) => batch.status === 'completed' &&
|
|
15
|
-
batchDetailsById[batch.batchId] == null)
|
|
16
|
-
.map((batch) => batch.batchId);
|
|
17
|
-
if (completedBatchIds.length === 0) {
|
|
18
|
-
return rxjs_1.EMPTY;
|
|
19
|
-
}
|
|
20
|
-
return (0, rxjs_1.from)(completedBatchIds).pipe((0, operators_1.mergeMap)((batchId) => zeniAPI
|
|
21
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/receipts/batches/${batchId}`)
|
|
22
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
23
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
24
|
-
const actions = [];
|
|
25
|
-
const transactionPayloads = (0, missingReceiptsPayload_1.extractTransactionPayloadsFromBatchFiles)(response.data.files);
|
|
26
|
-
if (transactionPayloads.length > 0) {
|
|
27
|
-
actions.push((0, transactionReducer_1.updateTransactions)(transactionPayloads, (value) => value.transaction_id));
|
|
28
|
-
}
|
|
29
|
-
actions.push((0, missingReceiptsViewReducer_1.storeBatchDetails)((0, missingReceiptsPayload_1.toBatchDetails)(response.data)));
|
|
30
|
-
return (0, rxjs_1.from)(actions);
|
|
31
|
-
}
|
|
32
|
-
return rxjs_1.EMPTY;
|
|
33
|
-
}), (0, operators_1.catchError)((error) => {
|
|
34
|
-
console.error(`Failed to fetch batch details for ${batchId}:`, (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch batch details errored out: ' +
|
|
35
|
-
JSON.stringify(error)));
|
|
36
|
-
return rxjs_1.EMPTY;
|
|
37
|
-
})), 5));
|
|
38
|
-
}));
|
|
39
|
-
exports.fetchMultipleBatchDetailsEpic = fetchMultipleBatchDetailsEpic;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { ZeniAPI } from '../../../../zeniAPI';
|
|
4
|
-
import { searchTransactionsForManualMatch, searchTransactionsForManualMatchFailure, searchTransactionsForManualMatchSuccess } from '../../reducers/missingReceiptsViewReducer';
|
|
5
|
-
export type ActionType = ReturnType<typeof searchTransactionsForManualMatch> | ReturnType<typeof searchTransactionsForManualMatchSuccess> | ReturnType<typeof searchTransactionsForManualMatchFailure>;
|
|
6
|
-
export declare const searchTransactionsForManualMatchEpic: (actions$: ActionsObservable<ActionType>, _state$: unknown, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.searchTransactionsForManualMatchEpic = 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 searchTransactionsForManualMatchEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.searchTransactionsForManualMatch.match), (0, operators_1.debounceTime)(300), (0, operators_1.switchMap)((action) => {
|
|
10
|
-
const { query } = action.payload;
|
|
11
|
-
const searchQuery = JSON.stringify({
|
|
12
|
-
search_text: query,
|
|
13
|
-
search_fields: ['date', 'amount', 'vendor_name'],
|
|
14
|
-
});
|
|
15
|
-
const encodedQuery = encodeURIComponent(searchQuery);
|
|
16
|
-
return zeniAPI
|
|
17
|
-
.getJSON(`${zeniAPI.apiEndPoints.searchMicroServiceBaseUrl}/1.0/transaction-search?query=${encodedQuery}`)
|
|
18
|
-
.pipe((0, operators_1.switchMap)((response) => {
|
|
19
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
20
|
-
const results = response.data.transactions.map(missingReceiptsPayload_1.toManualSearchResult);
|
|
21
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.searchTransactionsForManualMatchSuccess)(results));
|
|
22
|
-
}
|
|
23
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.searchTransactionsForManualMatchFailure)({
|
|
24
|
-
error: response.status,
|
|
25
|
-
}));
|
|
26
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.searchTransactionsForManualMatchFailure)({
|
|
27
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Search transactions for manual match errored: ' +
|
|
28
|
-
JSON.stringify(error)),
|
|
29
|
-
}))));
|
|
30
|
-
}));
|
|
31
|
-
exports.searchTransactionsForManualMatchEpic = searchTransactionsForManualMatchEpic;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts
DELETED
|
@@ -1,15 +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 { bulkUploadReceiptsSuccess, clearBulkUpload, fetchBulkUploadBatchDetails, pusherBatchStatusUpdate, updateBulkUploadBatchStatus } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
-
export type ActionType = ReturnType<typeof bulkUploadReceiptsSuccess> | ReturnType<typeof updateBulkUploadBatchStatus> | ReturnType<typeof pusherBatchStatusUpdate> | ReturnType<typeof fetchBulkUploadBatchDetails> | ReturnType<typeof clearBulkUpload>;
|
|
7
|
-
/**
|
|
8
|
-
* Watches batch status using two strategies:
|
|
9
|
-
* 1. Pusher (primary): Reacts to `pusherBatchStatusUpdate` dispatched by the UI layer
|
|
10
|
-
* when a Pusher event arrives. Immediately fetches full details on completion.
|
|
11
|
-
* 2. Polling (fallback): Starts a relaxed 10s poll after upload success as a safety net
|
|
12
|
-
* in case the Pusher event is missed. Stops on completion or `clearBulkUpload`.
|
|
13
|
-
*/
|
|
14
|
-
export declare const pusherBatchStatusCompletionEpic: (actions$: ActionsObservable<ActionType>) => Observable<ActionType>;
|
|
15
|
-
export declare const pollBulkUploadBatchStatusEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pollBulkUploadBatchStatusEpic = exports.pusherBatchStatusCompletionEpic = 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
|
-
/**
|
|
10
|
-
* Watches batch status using two strategies:
|
|
11
|
-
* 1. Pusher (primary): Reacts to `pusherBatchStatusUpdate` dispatched by the UI layer
|
|
12
|
-
* when a Pusher event arrives. Immediately fetches full details on completion.
|
|
13
|
-
* 2. Polling (fallback): Starts a relaxed 10s poll after upload success as a safety net
|
|
14
|
-
* in case the Pusher event is missed. Stops on completion or `clearBulkUpload`.
|
|
15
|
-
*/
|
|
16
|
-
// Pusher-driven: when Pusher delivers a completed status, fetch details
|
|
17
|
-
const pusherBatchStatusCompletionEpic = (actions$) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.pusherBatchStatusUpdate.match), (0, operators_1.filter)((action) => action.payload.status === 'completed'), (0, operators_1.mergeMap)(() => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetails)())));
|
|
18
|
-
exports.pusherBatchStatusCompletionEpic = pusherBatchStatusCompletionEpic;
|
|
19
|
-
// Polling fallback: relaxed interval as safety net
|
|
20
|
-
const FALLBACK_POLL_INTERVAL_MS = 10000;
|
|
21
|
-
const pollBulkUploadBatchStatusEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.bulkUploadReceiptsSuccess.match), (0, operators_1.switchMap)((action) => {
|
|
22
|
-
const { batchId } = action.payload;
|
|
23
|
-
return (0, rxjs_1.timer)(0, FALLBACK_POLL_INTERVAL_MS).pipe((0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)((a) => missingReceiptsViewReducer_1.clearBulkUpload.match(a) ||
|
|
24
|
-
(missingReceiptsViewReducer_1.pusherBatchStatusUpdate.match(a) &&
|
|
25
|
-
a.payload.status === 'completed')))), (0, operators_1.switchMap)(() => zeniAPI
|
|
26
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/receipts/batches/${batchId}/status`)
|
|
27
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
28
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
29
|
-
const batchStatus = (0, missingReceiptsPayload_1.toBatchStatus)(response.data);
|
|
30
|
-
const actions = [
|
|
31
|
-
(0, missingReceiptsViewReducer_1.updateBulkUploadBatchStatus)(batchStatus),
|
|
32
|
-
];
|
|
33
|
-
if (batchStatus.status === 'completed') {
|
|
34
|
-
actions.push((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetails)());
|
|
35
|
-
}
|
|
36
|
-
return actions;
|
|
37
|
-
}
|
|
38
|
-
return [];
|
|
39
|
-
}), (0, operators_1.catchError)(() => (0, rxjs_1.of)()))), (0, operators_1.takeWhile)((action) => {
|
|
40
|
-
if (missingReceiptsViewReducer_1.fetchBulkUploadBatchDetails.match(action)) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
return true;
|
|
44
|
-
}, true));
|
|
45
|
-
}));
|
|
46
|
-
exports.pollBulkUploadBatchStatusEpic = pollBulkUploadBatchStatusEpic;
|