@zeniai/client-epic-state 4.20.9 → 4.20.11

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