@zeniai/client-epic-state 4.19.37-betaAS2 → 4.19.37-betaVR1

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 (61) hide show
  1. package/lib/epic.d.ts +8 -1
  2. package/lib/epic.js +8 -1
  3. package/lib/esm/epic.js +8 -1
  4. package/lib/esm/index.js +8 -6
  5. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +28 -0
  6. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +25 -0
  7. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +31 -0
  8. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +16 -0
  9. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +48 -0
  10. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +27 -0
  11. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +41 -0
  12. package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +164 -1
  13. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +245 -1
  14. package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +114 -1
  15. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +1 -10
  16. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewSelector.js +2 -4
  17. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +2 -5
  18. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +1 -10
  19. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewSelector.js +2 -4
  20. package/lib/esm/zeniAPI.js +41 -3
  21. package/lib/index.d.ts +11 -9
  22. package/lib/index.js +57 -32
  23. package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
  24. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +18 -0
  25. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +32 -0
  26. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts +6 -0
  27. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +29 -0
  28. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts +8 -0
  29. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +35 -0
  30. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts +6 -0
  31. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +20 -0
  32. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts +8 -0
  33. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +52 -0
  34. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +6 -0
  35. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +31 -0
  36. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +15 -0
  37. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +46 -0
  38. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +168 -0
  39. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +172 -0
  40. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +43 -3
  41. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +246 -2
  42. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +60 -1
  43. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.d.ts +1 -1
  44. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +113 -0
  45. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +102 -0
  46. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.d.ts +1 -1
  47. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +2 -11
  48. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewSelector.js +2 -4
  49. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewSelectorTypes.d.ts +0 -2
  50. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewState.d.ts +0 -1
  51. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.d.ts +0 -1
  52. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +2 -5
  53. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonState.d.ts +0 -2
  54. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.d.ts +1 -1
  55. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +2 -11
  56. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewSelector.js +2 -4
  57. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewSelectorTypes.d.ts +0 -2
  58. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewState.d.ts +0 -1
  59. package/lib/zeniAPI.d.ts +9 -0
  60. package/lib/zeniAPI.js +40 -2
  61. package/package.json +1 -1
@@ -0,0 +1,18 @@
1
+ import { ActionsObservable } from 'redux-observable';
2
+ import { ZeniAPI } from '../../../../zeniAPI';
3
+ import { bulkUploadReceipts, bulkUploadReceiptsFailure, bulkUploadReceiptsSuccess, updateBulkUploadProgress } from '../../reducers/missingReceiptsViewReducer';
4
+ export type ActionType = ReturnType<typeof bulkUploadReceipts> | ReturnType<typeof bulkUploadReceiptsSuccess> | ReturnType<typeof bulkUploadReceiptsFailure> | ReturnType<typeof updateBulkUploadProgress>;
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
+ } | {
16
+ payload: number;
17
+ type: "expenseAutomationMissingReceiptsView/updateBulkUploadProgress";
18
+ }>;
@@ -0,0 +1,32 @@
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
+ .postFormDataWithProgress(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/receipts/bulk-upload`, formData)
16
+ .pipe((0, operators_1.mergeMap)((event) => {
17
+ if (event.type === 'progress') {
18
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.updateBulkUploadProgress)(event.percentage));
19
+ }
20
+ const response = event.data;
21
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
22
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsSuccess)({
23
+ batchId: response.data.batch_id,
24
+ }));
25
+ }
26
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsFailure)({ error: response.status }));
27
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsFailure)({
28
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Bulk upload receipts API call errored out: ' +
29
+ JSON.stringify(error)),
30
+ }))));
31
+ }));
32
+ exports.bulkUploadReceiptsEpic = bulkUploadReceiptsEpic;
@@ -0,0 +1,6 @@
1
+ import { ActionsObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { ZeniAPI } from '../../../../zeniAPI';
4
+ import { confirmBulkUploadMatch, confirmBulkUploadMatchFailure, confirmBulkUploadMatchSuccess } from '../../reducers/missingReceiptsViewReducer';
5
+ export type ActionType = ReturnType<typeof confirmBulkUploadMatch> | ReturnType<typeof confirmBulkUploadMatchSuccess> | ReturnType<typeof confirmBulkUploadMatchFailure>;
6
+ export declare const confirmBulkUploadMatchEpic: (actions$: ActionsObservable<ActionType>, _state$: unknown, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,29 @@
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 responsePayload_1 = require("../../../../responsePayload");
7
+ const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
8
+ const confirmBulkUploadMatchEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.confirmBulkUploadMatch.match), (0, operators_1.mergeMap)((action) => {
9
+ const { batchId, attachmentId, transactionId } = action.payload;
10
+ return zeniAPI
11
+ .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/receipts/batches/${batchId}/match`, {
12
+ attachment_id: attachmentId,
13
+ transaction_id: transactionId,
14
+ })
15
+ .pipe((0, operators_1.mergeMap)((response) => {
16
+ if ((0, responsePayload_1.isSuccessResponse)(response)) {
17
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.confirmBulkUploadMatchSuccess)({
18
+ batchId,
19
+ attachmentId,
20
+ transactionId,
21
+ }));
22
+ }
23
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.confirmBulkUploadMatchFailure)({ error: response.status }));
24
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.confirmBulkUploadMatchFailure)({
25
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Confirm bulk upload match errored out: ' +
26
+ JSON.stringify(error)),
27
+ }))));
28
+ }));
29
+ exports.confirmBulkUploadMatchEpic = confirmBulkUploadMatchEpic;
@@ -0,0 +1,8 @@
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>;
@@ -0,0 +1,35 @@
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)());
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;
@@ -0,0 +1,6 @@
1
+ import { ActionsObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { ZeniAPI } from '../../../../zeniAPI';
4
+ import { fetchBulkUploadBatches, fetchBulkUploadBatchesFailure, fetchBulkUploadBatchesSuccess } from '../../reducers/missingReceiptsViewReducer';
5
+ export type ActionType = ReturnType<typeof fetchBulkUploadBatches> | ReturnType<typeof fetchBulkUploadBatchesSuccess> | ReturnType<typeof fetchBulkUploadBatchesFailure>;
6
+ export declare const fetchBulkUploadBatchesEpic: (actions$: ActionsObservable<ActionType>, _state$: unknown, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,20 @@
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 responsePayload_1 = require("../../../../responsePayload");
7
+ const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
8
+ const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
9
+ const fetchBulkUploadBatchesEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatches.match), (0, operators_1.mergeMap)(() => zeniAPI
10
+ .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/receipts/batches?days=30`)
11
+ .pipe((0, operators_1.mergeMap)((response) => {
12
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
13
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesSuccess)(response.data.batches.map(missingReceiptsPayload_1.toBatchListItem)));
14
+ }
15
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesFailure)({ error: response.status }));
16
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesFailure)({
17
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch bulk upload batches errored out: ' +
18
+ JSON.stringify(error)),
19
+ }))))));
20
+ exports.fetchBulkUploadBatchesEpic = fetchBulkUploadBatchesEpic;
@@ -0,0 +1,8 @@
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>;
@@ -0,0 +1,52 @@
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 transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
8
+ const responsePayload_1 = require("../../../../responsePayload");
9
+ const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
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 { expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
14
+ const { selectedPeriod } = action.payload;
15
+ const queryPayload = {};
16
+ if (bulkUpload.completedSubTab !== 'all') {
17
+ queryPayload.match_type = bulkUpload.completedSubTab;
18
+ }
19
+ const period = (0, timePeriod_1.convertToPeriod)(selectedPeriod);
20
+ queryPayload.start_date = period.start;
21
+ queryPayload.end_date = period.end;
22
+ if (action.payload.pageToken != null) {
23
+ queryPayload.page_token = action.payload.pageToken;
24
+ }
25
+ const encodedQuery = encodeURIComponent(JSON.stringify(queryPayload));
26
+ return zeniAPI
27
+ .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/receipt-agent/transactions/completed?query=${encodedQuery}`)
28
+ .pipe((0, operators_1.mergeMap)((response) => {
29
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
30
+ const transactionPayloads = response.data.transactions.map(missingReceiptsPayload_1.completedTransactionPayloadToSupportedTransactionPayload);
31
+ const transactionIds = response.data.transactions.map((t) => t.transaction_id);
32
+ const updateActions = [];
33
+ updateActions.push((0, transactionReducer_1.updateTransactions)(transactionPayloads, (value) => value.transaction_id));
34
+ updateActions.push((0, missingReceiptsViewReducer_1.fetchCompletedTransactionsSuccess)({
35
+ transactionIds,
36
+ nextPageToken: response.data.next_page_token,
37
+ totalCount: response.data.total_count,
38
+ selectedPeriod,
39
+ }));
40
+ return (0, rxjs_1.from)(updateActions);
41
+ }
42
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchCompletedTransactionsFailure)({
43
+ error: response.status,
44
+ selectedPeriod,
45
+ }));
46
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchCompletedTransactionsFailure)({
47
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch completed transactions errored: ' +
48
+ JSON.stringify(error)),
49
+ selectedPeriod,
50
+ }))));
51
+ }));
52
+ exports.fetchCompletedTransactionsEpic = fetchCompletedTransactionsEpic;
@@ -0,0 +1,6 @@
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>;
@@ -0,0 +1,31 @@
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;
@@ -0,0 +1,15 @@
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>;
@@ -0,0 +1,46 @@
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;
@@ -1,5 +1,7 @@
1
1
  import { TransactionPayload } from '../../../entity/transaction/payloadTypes/transactionPayload';
2
+ import { SupportedTransactionPayload } from '../../../entity/transaction/transactionState';
2
3
  import { ZeniAPIResponse } from '../../../responsePayload';
4
+ import type { BatchDetails, BatchFile, BatchListItem, BatchStatus, BatchSummary, ManualSearchResult } from '../types/missingReceiptsViewState';
3
5
  export interface MissingReceiptsQueryPayload {
4
6
  end_date: string;
5
7
  is_attachment_missing_only: boolean;
@@ -13,4 +15,170 @@ interface MissingReceiptsPayload {
13
15
  transactions: TransactionPayload[];
14
16
  }
15
17
  export type MissingReceiptsResponse = ZeniAPIResponse<MissingReceiptsPayload>;
18
+ export interface BulkUploadResponsePayload {
19
+ batch_id: string;
20
+ status: string;
21
+ total_files: number;
22
+ }
23
+ export type BulkUploadResponse = ZeniAPIResponse<BulkUploadResponsePayload>;
24
+ export interface BatchStatusResponsePayload {
25
+ batch_id: string;
26
+ progress: {
27
+ processed: number;
28
+ total: number;
29
+ };
30
+ status: string;
31
+ }
32
+ export type BatchStatusResponse = ZeniAPIResponse<BatchStatusResponsePayload>;
33
+ export interface BatchListResponsePayload {
34
+ batches: BatchListItemPayload[];
35
+ }
36
+ export interface BatchListItemPayload {
37
+ batch_id: string;
38
+ created_at: string;
39
+ failed_count: number;
40
+ matched_count: number;
41
+ no_match_count: number;
42
+ possible_matches_count: number;
43
+ status: string;
44
+ total_files: number;
45
+ }
46
+ export type BatchListResponse = ZeniAPIResponse<BatchListResponsePayload>;
47
+ export interface MatchedTransactionPayload {
48
+ amount: number;
49
+ currency_code: string;
50
+ transaction_date: string;
51
+ transaction_id: string;
52
+ vendor_name: string;
53
+ vendor_logo?: string;
54
+ }
55
+ export interface MatchCandidatePayload extends MatchedTransactionPayload {
56
+ match_score: number;
57
+ }
58
+ export interface BatchFilePayload {
59
+ attachment_id: string;
60
+ file_id: string;
61
+ file_preview_url: string;
62
+ filename: string;
63
+ status: string;
64
+ candidates?: MatchCandidatePayload[];
65
+ matched_transaction?: MatchedTransactionPayload;
66
+ }
67
+ export interface BatchDetailsResponsePayload {
68
+ batch_id: string;
69
+ created_at: string;
70
+ files: BatchFilePayload[];
71
+ status: string;
72
+ summary: {
73
+ failed: number;
74
+ matched: number;
75
+ no_match: number;
76
+ possible_matches: number;
77
+ total: number;
78
+ };
79
+ }
80
+ export type BatchDetailsResponse = ZeniAPIResponse<BatchDetailsResponsePayload>;
81
+ export declare function toBatchFile(payload: BatchFilePayload): BatchFile;
82
+ export declare function extractTransactionPayloadsFromBatchFiles(files: BatchFilePayload[]): SupportedTransactionPayload[];
83
+ export declare function toBatchSummary(payload: BatchDetailsResponsePayload['summary']): BatchSummary;
84
+ export declare function toBatchStatus(payload: BatchStatusResponsePayload): BatchStatus;
85
+ export declare function toBatchDetails(payload: BatchDetailsResponsePayload): BatchDetails;
86
+ export declare function toBatchListItem(payload: BatchListItemPayload): BatchListItem;
87
+ export interface TransactionSearchQueryPayload {
88
+ search_text: string;
89
+ search_fields?: string[];
90
+ }
91
+ export interface TransactionSearchItemPayload {
92
+ amount: number;
93
+ currency: string;
94
+ entity_id: string;
95
+ memo: string;
96
+ transaction_date: string;
97
+ transaction_id: string;
98
+ transaction_type: string;
99
+ vendor_name: string;
100
+ }
101
+ export interface TransactionSearchResponsePayload {
102
+ transactions: TransactionSearchItemPayload[];
103
+ }
104
+ export type TransactionSearchResponse = ZeniAPIResponse<TransactionSearchResponsePayload>;
105
+ export declare function toManualSearchResult(payload: TransactionSearchItemPayload): ManualSearchResult;
106
+ export interface CompletedTransactionsQueryPayload {
107
+ end_date?: string;
108
+ match_type?: string;
109
+ page_token?: string;
110
+ start_date?: string;
111
+ }
112
+ export interface CompletedTransactionAttachmentPayload {
113
+ attachment_id: string;
114
+ content_type: string;
115
+ file_download_url: string;
116
+ file_name: string;
117
+ file_size: number;
118
+ attachment_create_time?: string;
119
+ attachment_update_time?: string;
120
+ }
121
+ export interface CompletedTransactionLineDetailPayload {
122
+ account?: {
123
+ account_id: string;
124
+ account_name: string;
125
+ coa_id?: string;
126
+ qbo_id?: string;
127
+ };
128
+ class?: {
129
+ accounting_class_id: string;
130
+ accounting_class_name: string;
131
+ accounting_class_number?: string;
132
+ fully_qualified_accounting_class_name?: string;
133
+ qbo_id?: string;
134
+ };
135
+ customer?: {
136
+ customer_id: string;
137
+ customer_name: string;
138
+ logo?: Record<string, unknown>;
139
+ qbo_id?: string;
140
+ };
141
+ posting_type?: string;
142
+ posting_type_name?: string;
143
+ vendor?: {
144
+ vendor_id: string;
145
+ vendor_name: string;
146
+ logo?: Record<string, unknown>;
147
+ qbo_id?: string;
148
+ };
149
+ }
150
+ export interface CompletedTransactionLinePayload {
151
+ amount: number;
152
+ categorization_status: string;
153
+ line_description: string;
154
+ line_detail: CompletedTransactionLineDetailPayload;
155
+ line_detail_type: string;
156
+ line_id: string;
157
+ line_type: string;
158
+ receipt_matched_source?: string;
159
+ }
160
+ export interface CompletedTransactionPayload {
161
+ attachments: CompletedTransactionAttachmentPayload[];
162
+ currency_code: string;
163
+ is_deleted: boolean;
164
+ lines: CompletedTransactionLinePayload[];
165
+ total_amount: number;
166
+ transaction_date: string;
167
+ transaction_id: string;
168
+ account_id?: string;
169
+ account_name?: string;
170
+ currency_symbol?: string;
171
+ logo?: Record<string, unknown>;
172
+ transaction_type?: string;
173
+ transaction_type_name?: string;
174
+ vendor_id?: string;
175
+ vendor_name?: string;
176
+ }
177
+ export interface CompletedTransactionsResponsePayload {
178
+ next_page_token: string | null;
179
+ total_count: number;
180
+ transactions: CompletedTransactionPayload[];
181
+ }
182
+ export type CompletedTransactionsResponse = ZeniAPIResponse<CompletedTransactionsResponsePayload>;
183
+ export declare function completedTransactionPayloadToSupportedTransactionPayload(payload: CompletedTransactionPayload): SupportedTransactionPayload;
16
184
  export {};