@zeniai/client-epic-state 4.19.97-betaRR0 → 4.19.97

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 (156) hide show
  1. package/lib/entity/account/accountPayload.d.ts +0 -2
  2. package/lib/entity/account/accountPayload.js +0 -2
  3. package/lib/entity/account/accountState.d.ts +0 -2
  4. package/lib/entity/depositAccount/depositAccount.d.ts +1 -1
  5. package/lib/entity/depositAccount/depositAccount.js +1 -8
  6. package/lib/entity/reimbursement/reimbursementPayload.d.ts +0 -2
  7. package/lib/entity/reimbursement/reimbursementPayload.js +0 -7
  8. package/lib/entity/reimbursement/reimbursementState.d.ts +0 -2
  9. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  10. package/lib/entity/snackbar/snackbarTypes.js +0 -1
  11. package/lib/entity/task/taskPayload.d.ts +0 -1
  12. package/lib/entity/task/taskPayload.js +0 -1
  13. package/lib/entity/task/taskState.d.ts +0 -1
  14. package/lib/epic.d.ts +1 -17
  15. package/lib/epic.js +1 -17
  16. package/lib/esm/entity/account/accountPayload.js +0 -2
  17. package/lib/esm/entity/depositAccount/depositAccount.js +1 -8
  18. package/lib/esm/entity/reimbursement/reimbursementPayload.js +0 -7
  19. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -1
  20. package/lib/esm/entity/task/taskPayload.js +0 -1
  21. package/lib/esm/epic.js +1 -17
  22. package/lib/esm/index.js +5 -14
  23. package/lib/esm/reducer.js +0 -9
  24. package/lib/esm/view/expenseAutomationView/epics/accountRecon/saveReconciliationReviewEpic.js +3 -8
  25. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +5 -7
  26. package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +1 -189
  27. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -433
  28. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +1 -23
  29. package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +1 -244
  30. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +1 -2
  31. package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +0 -44
  32. package/lib/esm/view/expenseAutomationView/types/transactionsViewState.js +1 -2
  33. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +1 -14
  34. package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
  35. package/lib/esm/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +0 -1
  36. package/lib/esm/view/taskManager/taskListView/taskListSelector.js +1 -3
  37. package/lib/esm/view/userListView/fetchUserListByTypeEpic.js +0 -11
  38. package/lib/esm/zeniAPI.js +2 -0
  39. package/lib/index.d.ts +6 -14
  40. package/lib/index.js +32 -95
  41. package/lib/reducer.d.ts +0 -9
  42. package/lib/reducer.js +0 -9
  43. package/lib/view/expenseAutomationView/epics/accountRecon/saveReconciliationReviewEpic.js +3 -8
  44. package/lib/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +5 -7
  45. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  46. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +0 -118
  47. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +0 -201
  48. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +3 -76
  49. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -434
  50. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +3 -11
  51. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +2 -24
  52. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +1 -69
  53. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +0 -1
  54. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.d.ts +1 -1
  55. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +0 -243
  56. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +1 -2
  57. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +0 -142
  58. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +1 -54
  59. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -2
  60. package/lib/view/expenseAutomationView/types/transactionsViewState.js +1 -2
  61. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +1 -4
  62. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +2 -15
  63. package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
  64. package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.d.ts +0 -1
  65. package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +0 -1
  66. package/lib/view/taskManager/taskListView/taskListSelector.d.ts +0 -2
  67. package/lib/view/taskManager/taskListView/taskListSelector.js +1 -3
  68. package/lib/view/userListView/fetchUserListByTypeEpic.d.ts +1 -3
  69. package/lib/view/userListView/fetchUserListByTypeEpic.js +0 -11
  70. package/lib/view/userListView/userListViewPayload.d.ts +0 -2
  71. package/lib/zeniAPI.js +2 -0
  72. package/package.json +2 -2
  73. package/lib/entity/userGroups/userGroupsPayload.d.ts +0 -7
  74. package/lib/entity/userGroups/userGroupsPayload.js +0 -10
  75. package/lib/entity/userGroups/userGroupsReducer.d.ts +0 -8
  76. package/lib/entity/userGroups/userGroupsReducer.js +0 -29
  77. package/lib/entity/userGroups/userGroupsSelector.d.ts +0 -4
  78. package/lib/entity/userGroups/userGroupsSelector.js +0 -12
  79. package/lib/entity/userGroups/userGroupsState.d.ts +0 -9
  80. package/lib/entity/userGroups/userGroupsState.js +0 -2
  81. package/lib/esm/entity/userGroups/userGroupsPayload.js +0 -7
  82. package/lib/esm/entity/userGroups/userGroupsReducer.js +0 -25
  83. package/lib/esm/entity/userGroups/userGroupsSelector.js +0 -8
  84. package/lib/esm/entity/userGroups/userGroupsState.js +0 -1
  85. package/lib/esm/view/expenseAutomationView/bulkUploadTiming.js +0 -10
  86. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +0 -29
  87. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +0 -49
  88. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +0 -40
  89. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +0 -47
  90. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +0 -61
  91. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +0 -33
  92. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +0 -56
  93. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +0 -77
  94. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +0 -79
  95. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +0 -24
  96. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingDataRequests.js +0 -58
  97. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingPayload.js +0 -1
  98. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingReducer.js +0 -103
  99. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingSelector.js +0 -63
  100. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingState.js +0 -5
  101. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/createAllAiRecommendedCardsEpic.js +0 -62
  102. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/fetchAiCardRecommendationEpic.js +0 -4
  103. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/fetchChainOfThoughtsForAiCardRecommendationEpic.js +0 -4
  104. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/startAiCardAgentDrawerDataLoadEpic.js +0 -10
  105. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/fetchCardsOnboardingPageEpic.js +0 -36
  106. package/lib/esm/view/userGroupListView/userGroupListViewReducer.js +0 -65
  107. package/lib/esm/view/userGroupListView/userGroupListViewSelector.js +0 -16
  108. package/lib/esm/view/userGroupListView/userGroupListViewState.js +0 -1
  109. package/lib/view/expenseAutomationView/bulkUploadTiming.d.ts +0 -10
  110. package/lib/view/expenseAutomationView/bulkUploadTiming.js +0 -13
  111. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +0 -18
  112. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +0 -33
  113. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts +0 -7
  114. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +0 -53
  115. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts +0 -8
  116. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +0 -44
  117. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts +0 -7
  118. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +0 -51
  119. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts +0 -8
  120. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +0 -65
  121. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.d.ts +0 -8
  122. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +0 -37
  123. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +0 -9
  124. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +0 -61
  125. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +0 -14
  126. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +0 -81
  127. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +0 -25
  128. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +0 -85
  129. package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.d.ts +0 -7
  130. package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +0 -28
  131. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingDataRequests.d.ts +0 -7
  132. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingDataRequests.js +0 -62
  133. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingPayload.d.ts +0 -34
  134. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingPayload.js +0 -2
  135. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingReducer.d.ts +0 -7
  136. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingReducer.js +0 -107
  137. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingSelector.d.ts +0 -16
  138. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingSelector.js +0 -67
  139. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingState.d.ts +0 -63
  140. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingState.js +0 -8
  141. package/lib/view/spendManagement/chargeCards/cardsOnboarding/createAllAiRecommendedCardsEpic.d.ts +0 -20
  142. package/lib/view/spendManagement/chargeCards/cardsOnboarding/createAllAiRecommendedCardsEpic.js +0 -66
  143. package/lib/view/spendManagement/chargeCards/cardsOnboarding/fetchAiCardRecommendationEpic.d.ts +0 -8
  144. package/lib/view/spendManagement/chargeCards/cardsOnboarding/fetchAiCardRecommendationEpic.js +0 -8
  145. package/lib/view/spendManagement/chargeCards/cardsOnboarding/fetchChainOfThoughtsForAiCardRecommendationEpic.d.ts +0 -13
  146. package/lib/view/spendManagement/chargeCards/cardsOnboarding/fetchChainOfThoughtsForAiCardRecommendationEpic.js +0 -8
  147. package/lib/view/spendManagement/chargeCards/cardsOnboarding/startAiCardAgentDrawerDataLoadEpic.d.ts +0 -13
  148. package/lib/view/spendManagement/chargeCards/cardsOnboarding/startAiCardAgentDrawerDataLoadEpic.js +0 -14
  149. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchCardsOnboardingPageEpic.d.ts +0 -12
  150. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchCardsOnboardingPageEpic.js +0 -40
  151. package/lib/view/userGroupListView/userGroupListViewReducer.d.ts +0 -23
  152. package/lib/view/userGroupListView/userGroupListViewReducer.js +0 -69
  153. package/lib/view/userGroupListView/userGroupListViewSelector.d.ts +0 -7
  154. package/lib/view/userGroupListView/userGroupListViewSelector.js +0 -20
  155. package/lib/view/userGroupListView/userGroupListViewState.d.ts +0 -8
  156. package/lib/view/userGroupListView/userGroupListViewState.js +0 -2
@@ -17,7 +17,6 @@ const taskGroupTemplateSelector_1 = require("../../../entity/taskGroupTemplate/t
17
17
  const userSelector_1 = require("../../../entity/user/userSelector");
18
18
  const userAndRole_1 = require("../../companyView/types/userAndRole");
19
19
  const spendManagementFilterHelpers_1 = require("../../spendManagement/spendManagementFilterHelpers");
20
- const userGroupListViewSelector_1 = require("../../userGroupListView/userGroupListViewSelector");
21
20
  const userListViewSelector_1 = require("../../userListView/userListViewSelector");
22
21
  const taskDetailSelector_1 = require("../taskDetailView/taskDetailSelector");
23
22
  const taskList_1 = require("./taskList");
@@ -317,7 +316,7 @@ const getTaskGroupsWithTaskList = ({ taskListState, taskState, userState, userRo
317
316
  tagState,
318
317
  });
319
318
  };
320
- exports.getAllTasks = (0, toolkit_1.createSelector)((state) => state.taskListState, (state) => state.taskState, (state) => state.userState, (state) => state.userRoleState, (state) => state.userListViewState, (state) => state.addressState, (state) => state.taskGroupState, (state) => state.taskGroupViewState, (state) => state.tagViewState, (state) => state.tagState, (state) => state.taskGroupTemplateState, (state) => state.taskGroupTemplateViewState, (state) => state.userGroupsState, (state) => state.userGroupListViewState, (_state, isTaskTemplatesEnabled) => isTaskTemplatesEnabled, (taskListState, taskState, userState, userRoleState, userListViewState, addressState, taskGroupState, taskGroupViewState, tagViewState, tagState, taskGroupTemplateState, taskGroupTemplateViewState, userGroupsState, userGroupListViewState, isTaskTemplatesEnabled) => {
319
+ exports.getAllTasks = (0, toolkit_1.createSelector)((state) => state.taskListState, (state) => state.taskState, (state) => state.userState, (state) => state.userRoleState, (state) => state.userListViewState, (state) => state.addressState, (state) => state.taskGroupState, (state) => state.taskGroupViewState, (state) => state.tagViewState, (state) => state.tagState, (state) => state.taskGroupTemplateState, (state) => state.taskGroupTemplateViewState, (_state, isTaskTemplatesEnabled) => isTaskTemplatesEnabled, (taskListState, taskState, userState, userRoleState, userListViewState, addressState, taskGroupState, taskGroupViewState, tagViewState, tagState, taskGroupTemplateState, taskGroupTemplateViewState, isTaskTemplatesEnabled) => {
321
320
  const { localData } = taskListState;
322
321
  const taskGroupsWithTasksList = getTaskGroupsWithTaskList({
323
322
  taskListState,
@@ -345,7 +344,6 @@ exports.getAllTasks = (0, toolkit_1.createSelector)((state) => state.taskListSta
345
344
  taskGroupTemplates,
346
345
  fetchState: fetchState,
347
346
  userList: (0, userListViewSelector_1.getUserList)(userState, userRoleState, userListViewState, 'taskManagerCandidate'),
348
- userGroupList: (0, userGroupListViewSelector_1.getUserGroupList)(userGroupsState, userGroupListViewState, 'taskManagerCandidate'),
349
347
  error: error,
350
348
  version: 0,
351
349
  taskGroupsWithTasksList,
@@ -1,12 +1,10 @@
1
1
  import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { updateAddresses } from '../../entity/address/addressReducer';
3
3
  import { updateAllUsers } from '../../entity/user/userReducer';
4
- import { updateAllUserGroups } from '../../entity/userGroups/userGroupsReducer';
5
4
  import { updateUserRoles } from '../../entity/userRole/userRoleReducer';
6
5
  import { RootState } from '../../reducer';
7
6
  import { ZeniAPI } from '../../zeniAPI';
8
7
  import { updateChargeCardCount, updateDebitCardCount } from '../spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer';
9
- import { updateUserGroupIds } from '../userGroupListView/userGroupListViewReducer';
10
8
  import { fetchUserListByType, updateUserIds, updateUserListFetchFailure } from './userListViewReducer';
11
- export type ActionType = ReturnType<typeof fetchUserListByType> | ReturnType<typeof updateAllUsers> | ReturnType<typeof updateUserRoles> | ReturnType<typeof updateUserIds> | ReturnType<typeof updateChargeCardCount> | ReturnType<typeof updateDebitCardCount> | ReturnType<typeof updateAddresses> | ReturnType<typeof updateUserListFetchFailure> | ReturnType<typeof updateAllUserGroups> | ReturnType<typeof updateUserGroupIds>;
9
+ export type ActionType = ReturnType<typeof fetchUserListByType> | ReturnType<typeof updateAllUsers> | ReturnType<typeof updateUserRoles> | ReturnType<typeof updateUserIds> | ReturnType<typeof updateChargeCardCount> | ReturnType<typeof updateDebitCardCount> | ReturnType<typeof updateAddresses> | ReturnType<typeof updateUserListFetchFailure>;
12
10
  export declare const fetchUserListByTypeEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
@@ -6,11 +6,9 @@ const operators_1 = require("rxjs/operators");
6
6
  const addressReducer_1 = require("../../entity/address/addressReducer");
7
7
  const tenantSelector_1 = require("../../entity/tenant/tenantSelector");
8
8
  const userReducer_1 = require("../../entity/user/userReducer");
9
- const userGroupsReducer_1 = require("../../entity/userGroups/userGroupsReducer");
10
9
  const userRoleReducer_1 = require("../../entity/userRole/userRoleReducer");
11
10
  const responsePayload_1 = require("../../responsePayload");
12
11
  const issueChargeCardReducer_1 = require("../spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer");
13
- const userGroupListViewReducer_1 = require("../userGroupListView/userGroupListViewReducer");
14
12
  const userListViewReducer_1 = require("./userListViewReducer");
15
13
  const fetchUserListByTypeEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(userListViewReducer_1.fetchUserListByType.match), (0, operators_1.mergeMap)((action) => {
16
14
  const { userType, cacheOverride } = action.payload;
@@ -34,15 +32,6 @@ const fetchUserListByTypeEpic = (actions$, state$, zeniAPI) => actions$.pipe((0,
34
32
  usersPayload: response.data?.users ?? [],
35
33
  }),
36
34
  ];
37
- if (response.data?.user_groups != null) {
38
- userListAction.push((0, userGroupsReducer_1.updateAllUserGroups)({ userGroups: response.data.user_groups }));
39
- if (userType === 'taskManagerCandidate') {
40
- userListAction.push((0, userGroupListViewReducer_1.updateUserGroupIds)({
41
- userGroupType: userType,
42
- userGroupsPayload: response.data.user_groups,
43
- }));
44
- }
45
- }
46
35
  if (userType === 'cardHolderCandidate') {
47
36
  userListAction.push((0, issueChargeCardReducer_1.updateChargeCardCount)(response.data?.cards_count_by_user_id ?? []));
48
37
  userListAction.push((0, issueChargeCardReducer_1.updateDebitCardCount)(response.data?.debit_cards_count_by_deposit_account_id ?? {}));
@@ -1,7 +1,6 @@
1
1
  import { ID } from '../../commonStateTypes/common';
2
2
  import { AddressPayload } from '../../entity/address/addressPayload';
3
3
  import { UserPayload } from '../../entity/user/userPayload';
4
- import { UserGroupPayload } from '../../entity/userGroups/userGroupsPayload';
5
4
  import { UserRolePayload } from '../../entity/userRole/userRolePayload';
6
5
  import { ZeniAPIResponse } from '../../responsePayload';
7
6
  interface UserListResponsePayload {
@@ -10,7 +9,6 @@ interface UserListResponsePayload {
10
9
  addresses?: AddressPayload[];
11
10
  cards_count_by_user_id?: ActiveChargeCardCountPayload[];
12
11
  debit_cards_count_by_deposit_account_id?: Record<ID, ActiveDebitCardCountByUserIdPayload>;
13
- user_groups?: UserGroupPayload[];
14
12
  }
15
13
  export interface ActiveChargeCardCountPayload {
16
14
  business_physical_credit_card_count: number;
package/lib/zeniAPI.js CHANGED
@@ -82,6 +82,8 @@ class ZeniAPIClient {
82
82
  return (0, rxjs_1.from)(promise);
83
83
  }
84
84
  postFormData(restEndPoint, formData, signal) {
85
+ // Use apiHeaders for auth headers, then remove Content-Type
86
+ // so the browser sets multipart/form-data with the correct boundary
85
87
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
86
88
  const { 'Content-Type': _contentType, ...headers } = this.apiHeaders();
87
89
  const promise = (0, cross_fetch_1.fetch)(restEndPoint, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.19.97-betaRR0",
3
+ "version": "4.19.97",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -105,7 +105,7 @@
105
105
  },
106
106
  "scripts": {
107
107
  "clean": "rimraf lib",
108
- "test:typecheck": "echo 'Typechecking test files...' && NODE_OPTIONS=--max-old-space-size=4096 time tsc -p tsconfig.typecheck.json",
108
+ "test:typecheck": "echo 'Typechecking test files...' && time tsc -p tsconfig.typecheck.json",
109
109
  "test": "pnpm test:typecheck && vitest run --typecheck",
110
110
  "lint": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
111
111
  "find-dead-code": "ts-prune | grep -v '(used in module)'",
@@ -1,7 +0,0 @@
1
- import { UserGroup } from './userGroupsState';
2
- export interface UserGroupPayload {
3
- id: string;
4
- name: string;
5
- user_ids?: string[] | null;
6
- }
7
- export declare function mapUserGroupPayloadToUserGroup(payload: UserGroupPayload): UserGroup;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapUserGroupPayloadToUserGroup = mapUserGroupPayloadToUserGroup;
4
- function mapUserGroupPayloadToUserGroup(payload) {
5
- return {
6
- userGroupId: payload.id,
7
- name: payload.name,
8
- userIds: payload.user_ids ?? [],
9
- };
10
- }
@@ -1,8 +0,0 @@
1
- import { UserGroupPayload } from './userGroupsPayload';
2
- import { UserGroupsState } from './userGroupsState';
3
- export declare const initialState: UserGroupsState;
4
- export declare const updateAllUserGroups: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
5
- userGroups: UserGroupPayload[];
6
- }, "userGroups/updateAllUserGroups">, removeUserGroup: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "userGroups/removeUserGroup">, clearAllUserGroups: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"userGroups/clearAllUserGroups">;
7
- declare const _default: import("redux").Reducer<UserGroupsState>;
8
- export default _default;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearAllUserGroups = exports.removeUserGroup = exports.updateAllUserGroups = exports.initialState = void 0;
5
- const toolkit_1 = require("@reduxjs/toolkit");
6
- const userGroupsPayload_1 = require("./userGroupsPayload");
7
- exports.initialState = {
8
- userGroupByUserGroupId: {},
9
- };
10
- const userGroups = (0, toolkit_1.createSlice)({
11
- name: 'userGroups',
12
- initialState: exports.initialState,
13
- reducers: {
14
- updateAllUserGroups(draft, action) {
15
- action.payload.userGroups.forEach((payload) => {
16
- const userGroup = (0, userGroupsPayload_1.mapUserGroupPayloadToUserGroup)(payload);
17
- draft.userGroupByUserGroupId[userGroup.userGroupId] = userGroup;
18
- });
19
- },
20
- removeUserGroup(draft, action) {
21
- delete draft.userGroupByUserGroupId[action.payload];
22
- },
23
- clearAllUserGroups(draft) {
24
- Object.assign(draft, exports.initialState);
25
- },
26
- },
27
- });
28
- _a = userGroups.actions, exports.updateAllUserGroups = _a.updateAllUserGroups, exports.removeUserGroup = _a.removeUserGroup, exports.clearAllUserGroups = _a.clearAllUserGroups;
29
- exports.default = userGroups.reducer;
@@ -1,4 +0,0 @@
1
- import { ID } from '../../commonStateTypes/common';
2
- import { UserGroup, UserGroupsState } from './userGroupsState';
3
- export declare function getUserGroupsByUserGroupIds(userGroupsState: UserGroupsState, userGroupIds: ID[]): UserGroup[];
4
- export declare function getUserGroupByUserGroupId(userGroupsState: UserGroupsState, userGroupId: ID): UserGroup | undefined;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUserGroupsByUserGroupIds = getUserGroupsByUserGroupIds;
4
- exports.getUserGroupByUserGroupId = getUserGroupByUserGroupId;
5
- function getUserGroupsByUserGroupIds(userGroupsState, userGroupIds) {
6
- return userGroupIds
7
- .map((id) => getUserGroupByUserGroupId(userGroupsState, id))
8
- .filter((value) => value != null);
9
- }
10
- function getUserGroupByUserGroupId(userGroupsState, userGroupId) {
11
- return userGroupsState.userGroupByUserGroupId[userGroupId] ?? undefined;
12
- }
@@ -1,9 +0,0 @@
1
- import { ID } from '../../commonStateTypes/common';
2
- export interface UserGroup {
3
- name: string;
4
- userGroupId: ID;
5
- userIds: ID[];
6
- }
7
- export interface UserGroupsState {
8
- userGroupByUserGroupId: Record<ID, UserGroup>;
9
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +0,0 @@
1
- export function mapUserGroupPayloadToUserGroup(payload) {
2
- return {
3
- userGroupId: payload.id,
4
- name: payload.name,
5
- userIds: payload.user_ids ?? [],
6
- };
7
- }
@@ -1,25 +0,0 @@
1
- import { createSlice } from '@reduxjs/toolkit';
2
- import { mapUserGroupPayloadToUserGroup, } from './userGroupsPayload';
3
- export const initialState = {
4
- userGroupByUserGroupId: {},
5
- };
6
- const userGroups = createSlice({
7
- name: 'userGroups',
8
- initialState,
9
- reducers: {
10
- updateAllUserGroups(draft, action) {
11
- action.payload.userGroups.forEach((payload) => {
12
- const userGroup = mapUserGroupPayloadToUserGroup(payload);
13
- draft.userGroupByUserGroupId[userGroup.userGroupId] = userGroup;
14
- });
15
- },
16
- removeUserGroup(draft, action) {
17
- delete draft.userGroupByUserGroupId[action.payload];
18
- },
19
- clearAllUserGroups(draft) {
20
- Object.assign(draft, initialState);
21
- },
22
- },
23
- });
24
- export const { updateAllUserGroups, removeUserGroup, clearAllUserGroups } = userGroups.actions;
25
- export default userGroups.reducer;
@@ -1,8 +0,0 @@
1
- export function getUserGroupsByUserGroupIds(userGroupsState, userGroupIds) {
2
- return userGroupIds
3
- .map((id) => getUserGroupByUserGroupId(userGroupsState, id))
4
- .filter((value) => value != null);
5
- }
6
- export function getUserGroupByUserGroupId(userGroupsState, userGroupId) {
7
- return userGroupsState.userGroupByUserGroupId[userGroupId] ?? undefined;
8
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- /**
2
- * After upload API success, hold the bar at 100% this long before transitioning to matching,
3
- * so the fill animation can complete without an abrupt swap to the auto-matching banner.
4
- */
5
- export const BULK_UPLOAD_BAR_COMPLETE_HOLD_MS = 400;
6
- /**
7
- * Max wall-clock wait for Pusher + batch-details resolution after upload. If exceeded, we stop
8
- * fallback polling, clear the automatching banner (`phase` → completed), and refresh batch list.
9
- */
10
- export const BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS = 300000;
@@ -1,29 +0,0 @@
1
- import { concat, of, timer } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
3
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
4
- import { BULK_UPLOAD_BAR_COMPLETE_HOLD_MS } from '../../bulkUploadTiming';
5
- import { bulkUploadReceipts, bulkUploadReceiptsFailure, bulkUploadReceiptsSuccess, updateBulkUploadProgress, } from '../../reducers/missingReceiptsViewReducer';
6
- export const bulkUploadReceiptsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(bulkUploadReceipts.match), mergeMap((action) => {
7
- const { files } = action.payload;
8
- const formData = new FormData();
9
- for (const file of files) {
10
- formData.append('files', file, file.name);
11
- }
12
- return zeniAPI
13
- .postFormData(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`, formData)
14
- .pipe(mergeMap((response) => {
15
- if (isSuccessResponse(response) && response.data != null) {
16
- const batchId = String(response.data.batch_id ?? '').trim();
17
- if (batchId === '') {
18
- return of(bulkUploadReceiptsFailure({
19
- error: createZeniAPIStatus('Unexpected Error', 'Bulk upload succeeded but batch_id was missing or empty.'),
20
- }));
21
- }
22
- return concat(of(updateBulkUploadProgress(100)), timer(BULK_UPLOAD_BAR_COMPLETE_HOLD_MS).pipe(mergeMap(() => of(bulkUploadReceiptsSuccess({ batchId })))));
23
- }
24
- return of(bulkUploadReceiptsFailure({ error: response.status }));
25
- }), catchError((error) => of(bulkUploadReceiptsFailure({
26
- error: createZeniAPIStatus('Unexpected Error', 'Bulk upload receipts API call errored out: ' +
27
- JSON.stringify(error)),
28
- }))));
29
- }));
@@ -1,49 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { catchError, exhaustMap, filter, mergeMap } from 'rxjs/operators';
3
- import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
4
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
5
- import { confirmBulkUploadMatch, confirmBulkUploadMatchFailure, confirmBulkUploadMatchSuccess, } from '../../reducers/missingReceiptsViewReducer';
6
- export const confirmBulkUploadMatchEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(confirmBulkUploadMatch.match), exhaustMap((action) => {
7
- const { batchId, attachmentId, transactionId, transactionType, fileName } = action.payload;
8
- return zeniAPI
9
- .postAndGetJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/manual-match`, {
10
- attachment_id: attachmentId,
11
- transaction_id: transactionId,
12
- transaction_type: transactionType,
13
- file_name: fileName,
14
- })
15
- .pipe(mergeMap((response) => {
16
- if (isSuccessResponse(response)) {
17
- return from([
18
- confirmBulkUploadMatchSuccess({
19
- batchId,
20
- attachmentId,
21
- transactionId,
22
- }),
23
- openSnackbar({
24
- messageSection: 'receipt_match',
25
- messageText: 'success',
26
- type: 'success',
27
- }),
28
- ]);
29
- }
30
- return from([
31
- confirmBulkUploadMatchFailure({ error: response.status }),
32
- openSnackbar({
33
- messageSection: 'receipt_match',
34
- messageText: 'failed',
35
- type: 'error',
36
- }),
37
- ]);
38
- }), catchError((error) => from([
39
- confirmBulkUploadMatchFailure({
40
- error: createZeniAPIStatus('Unexpected Error', 'Confirm bulk upload match errored out: ' +
41
- JSON.stringify(error)),
42
- }),
43
- openSnackbar({
44
- messageSection: 'receipt_match',
45
- messageText: 'failed',
46
- type: 'error',
47
- }),
48
- ])));
49
- }));
@@ -1,40 +0,0 @@
1
- import { EMPTY, from, of } 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, isBatchDetailsApiStatusCompleted, shouldFetchBatchDetailsForBatchId, toBatchDetails, } from '../../payload/missingReceiptsPayload';
6
- import { fetchBulkUploadBatchDetails, fetchBulkUploadBatchDetailsFailure, fetchBulkUploadBatchDetailsSuccess, fetchBulkUploadBatches, } from '../../reducers/missingReceiptsViewReducer';
7
- export const fetchBulkUploadBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchBulkUploadBatchDetails.match), mergeMap(() => {
8
- const bulkUpload = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
9
- const { currentBatchId } = bulkUpload;
10
- if (currentBatchId == null) {
11
- return of(fetchBulkUploadBatchDetailsFailure({
12
- error: createZeniAPIStatus('Unexpected Error', 'No current batch ID available'),
13
- }));
14
- }
15
- if (!shouldFetchBatchDetailsForBatchId(bulkUpload.batchStatusById, bulkUpload.batchListByPeriod, currentBatchId)) {
16
- return EMPTY;
17
- }
18
- return zeniAPI
19
- .getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${currentBatchId}`)
20
- .pipe(mergeMap((response) => {
21
- if (!isSuccessResponse(response) ||
22
- response.data == null ||
23
- !isBatchDetailsApiStatusCompleted(response.data.status)) {
24
- if (isSuccessResponse(response) && response.data != null) {
25
- return EMPTY;
26
- }
27
- return of(fetchBulkUploadBatchDetailsFailure({ error: response.status }));
28
- }
29
- const actions = [];
30
- const transactionPayloads = extractTransactionPayloadsFromBatchFiles(response.data.files);
31
- if (transactionPayloads.length > 0) {
32
- actions.push(updateTransactions(transactionPayloads, (value) => value.transaction_id));
33
- }
34
- actions.push(fetchBulkUploadBatchDetailsSuccess(toBatchDetails(response.data, zeniAPI.apiEndPoints.fileMicroServiceBaseUrl)));
35
- actions.push(fetchBulkUploadBatches({ cacheOverride: true }));
36
- return from(actions);
37
- }), catchError((error) => of(fetchBulkUploadBatchDetailsFailure({
38
- error: createZeniAPIStatus('Unexpected Error', 'Fetch batch details errored out: ' + JSON.stringify(error)),
39
- }))));
40
- }));
@@ -1,47 +0,0 @@
1
- import { of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { convertToPeriod, toMonthYearPeriodId, } from '../../../../commonStateTypes/timePeriod';
4
- import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
5
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
6
- import { toBatchListItem, } from '../../payload/missingReceiptsPayload';
7
- import { fetchBulkUploadBatches, fetchBulkUploadBatchesFailure, fetchBulkUploadBatchesSuccess, } from '../../reducers/missingReceiptsViewReducer';
8
- export const fetchBulkUploadBatchesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchBulkUploadBatches.match), switchMap((action) => {
9
- const { cacheOverride } = action.payload;
10
- const state = state$.value;
11
- const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
12
- const currentTenant = getCurrentTenant(state);
13
- const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
14
- const periodId = toMonthYearPeriodId(selectedPeriod);
15
- const existingBatches = bulkUpload.batchListByPeriod[periodId] ?? [];
16
- if (cacheOverride !== true && existingBatches.length > 0) {
17
- return of(fetchBulkUploadBatchesSuccess({
18
- batchList: existingBatches,
19
- selectedPeriod,
20
- }));
21
- }
22
- const period = convertToPeriod(selectedPeriod);
23
- const queryParam = {
24
- start_date: period.start,
25
- end_date: period.end,
26
- sort_order: 'desc',
27
- };
28
- return zeniAPI
29
- .getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
30
- .pipe(mergeMap((response) => {
31
- if (isSuccessResponse(response) && response.data != null) {
32
- /** Full list (all statuses) for UI; batch-details epics filter to `completed` only. */
33
- return of(fetchBulkUploadBatchesSuccess({
34
- batchList: response.data.batches.map(toBatchListItem),
35
- selectedPeriod,
36
- }));
37
- }
38
- return of(fetchBulkUploadBatchesFailure({
39
- error: response.status,
40
- selectedPeriod,
41
- }));
42
- }), catchError((error) => of(fetchBulkUploadBatchesFailure({
43
- error: createZeniAPIStatus('Unexpected Error', 'Fetch bulk upload batches errored out: ' +
44
- JSON.stringify(error)),
45
- selectedPeriod,
46
- }))));
47
- }));
@@ -1,61 +0,0 @@
1
- import { from, of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { convertToPeriod, toMonthYearPeriodId, } from '../../../../commonStateTypes/timePeriod';
4
- import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
5
- import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
6
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
7
- import { fetchCompletedTransactions, fetchCompletedTransactionsFailure, fetchCompletedTransactionsSuccess, getCompletedTransactionsCacheKey, } from '../../reducers/missingReceiptsViewReducer';
8
- export const fetchCompletedTransactionsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchCompletedTransactions.match), switchMap((action) => {
9
- const state = state$.value;
10
- const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
11
- const currentTenant = getCurrentTenant(state);
12
- const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
13
- const periodId = toMonthYearPeriodId(selectedPeriod);
14
- const isInitialLoad = action.payload.pageToken == null;
15
- const cacheKey = getCompletedTransactionsCacheKey(periodId, bulkUpload.sortKey, bulkUpload.sortOrder, bulkUpload.completedSubTab);
16
- const existingData = bulkUpload.completedTransactionsByPeriod[cacheKey];
17
- if (isInitialLoad &&
18
- action.payload.cacheOverride !== true &&
19
- existingData != null &&
20
- existingData.transactionIds.length > 0) {
21
- return from([]);
22
- }
23
- const period = convertToPeriod(selectedPeriod);
24
- const queryPayload = {
25
- start_date: period.start,
26
- end_date: period.end,
27
- sort_by: bulkUpload.sortKey,
28
- sort_order: bulkUpload.sortOrder === 'ascending' ? 'asc' : 'desc',
29
- page_token: action.payload.pageToken ?? null,
30
- page_size: 25,
31
- };
32
- if (bulkUpload.completedSubTab !== 'all') {
33
- queryPayload.match_type = bulkUpload.completedSubTab;
34
- }
35
- const encodedQuery = encodeURIComponent(JSON.stringify(queryPayload));
36
- return zeniAPI
37
- .getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipt-agent/transactions/completed?query=${encodedQuery}`)
38
- .pipe(mergeMap((response) => {
39
- if (isSuccessResponse(response) && response.data != null) {
40
- const transactionIds = response.data.transactions.map((t) => t.transaction_id);
41
- const updateActions = [];
42
- updateActions.push(updateTransactions(response.data.transactions, (value) => value.transaction_id));
43
- updateActions.push(fetchCompletedTransactionsSuccess({
44
- isInitialLoad,
45
- transactionIds,
46
- nextPageToken: response.data.next_page_token,
47
- totalCount: response.data.total_count,
48
- selectedPeriod,
49
- }));
50
- return from(updateActions);
51
- }
52
- return of(fetchCompletedTransactionsFailure({
53
- error: response.status,
54
- selectedPeriod,
55
- }));
56
- }), catchError((error) => of(fetchCompletedTransactionsFailure({
57
- error: createZeniAPIStatus('Unexpected Error', 'Fetch completed transactions errored: ' +
58
- JSON.stringify(error)),
59
- selectedPeriod,
60
- }))));
61
- }));
@@ -1,33 +0,0 @@
1
- import { concat, of } from 'rxjs';
2
- import { catchError, exhaustMap, filter } from 'rxjs/operators';
3
- import { toMonthYearPeriodId } from '../../../../commonStateTypes/timePeriod';
4
- import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
5
- import { createZeniAPIStatus } from '../../../../responsePayload';
6
- import { filterBatchListItemsForBatchDetailsFetch } from '../../payload/missingReceiptsPayload';
7
- import { fetchMoreBatchDetails, fetchMoreBatchDetailsComplete, fetchMoreBatchDetailsFailure, } from '../../reducers/missingReceiptsViewReducer';
8
- import { fetchBatchDetailsByIds } from './fetchMultipleBatchDetailsEpic';
9
- const MORE_BATCH_PAGE_SIZE = 5;
10
- export const fetchMoreBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchMoreBatchDetails.match),
11
- /** One page at a time — avoids duplicate loads if IO + scroll fallback both fire. */
12
- exhaustMap(() => {
13
- const state = state$.value;
14
- const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
15
- const currentTenant = getCurrentTenant(state);
16
- const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
17
- if (selectedPeriod == null) {
18
- return of(fetchMoreBatchDetailsComplete());
19
- }
20
- const periodId = toMonthYearPeriodId(selectedPeriod);
21
- const batchList = bulkUpload.batchListByPeriod[periodId] ?? [];
22
- const failedIds = new Set(bulkUpload.failedBatchDetailIds);
23
- const unfetchedBatches = filterBatchListItemsForBatchDetailsFetch(batchList).filter((batch) => bulkUpload.batchDetailsById[batch.batchId] == null &&
24
- !failedIds.has(batch.batchId));
25
- const unfetchedBatchIds = unfetchedBatches.map((batch) => batch.batchId);
26
- if (unfetchedBatchIds.length === 0) {
27
- return of(fetchMoreBatchDetailsComplete());
28
- }
29
- const nextPage = unfetchedBatchIds.slice(0, MORE_BATCH_PAGE_SIZE);
30
- return concat(fetchBatchDetailsByIds(nextPage, zeniAPI), of(fetchMoreBatchDetailsComplete())).pipe(catchError((error) => of(fetchMoreBatchDetailsFailure({
31
- error: createZeniAPIStatus('Unexpected Error', 'Fetch more batch details errored out: ' + JSON.stringify(error)),
32
- }))));
33
- }));
@@ -1,56 +0,0 @@
1
- import { EMPTY, concat, from, of } 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, filterBatchListItemsForBatchDetailsFetch, isBatchDetailsApiStatusCompleted, shouldFetchBatchDetailsForBatchId, toBatchDetails, } from '../../payload/missingReceiptsPayload';
6
- import { batchDetailFetchFailed, fetchBulkUploadBatchDetails, fetchBulkUploadBatchesSuccess, fetchMoreBatchDetailsComplete, setInitialBatchDetailsLoading, storeBatchDetails, } from '../../reducers/missingReceiptsViewReducer';
7
- const INITIAL_BATCH_PAGE_SIZE = 5;
8
- export function fetchBatchDetailsByIds(batchIds, zeniAPI) {
9
- if (batchIds.length === 0) {
10
- return EMPTY;
11
- }
12
- return from(batchIds).pipe(mergeMap((batchId) => zeniAPI
13
- .getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${batchId}`)
14
- .pipe(mergeMap((response) => {
15
- if (!isSuccessResponse(response) ||
16
- response.data == null ||
17
- !isBatchDetailsApiStatusCompleted(response.data.status)) {
18
- return EMPTY;
19
- }
20
- const actions = [];
21
- const transactionPayloads = extractTransactionPayloadsFromBatchFiles(response.data.files);
22
- if (transactionPayloads.length > 0) {
23
- actions.push(updateTransactions(transactionPayloads, (value) => value.transaction_id));
24
- }
25
- actions.push(storeBatchDetails(toBatchDetails(response.data, zeniAPI.apiEndPoints.fileMicroServiceBaseUrl)));
26
- return from(actions);
27
- }), catchError((error) => {
28
- console.error(`Failed to fetch batch details for ${batchId}:`, createZeniAPIStatus('Unexpected Error', 'Fetch batch details errored out: ' + JSON.stringify(error)));
29
- return of(batchDetailFetchFailed({ batchId }));
30
- })), 5));
31
- }
32
- export const fetchMultipleBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchBulkUploadBatchesSuccess.match), mergeMap((action) => {
33
- const batchList = action.payload.batchList;
34
- const { batchDetailsById } = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
35
- /** Only completed list rows may trigger batch-details API; preserve platform order. */
36
- const completedBatchesMissingDetails = filterBatchListItemsForBatchDetailsFetch(batchList).filter((batch) => batchDetailsById[batch.batchId] == null);
37
- const completedBatchIds = completedBatchesMissingDetails.map((batch) => batch.batchId);
38
- const batchIdsToFetch = completedBatchIds.slice(0, INITIAL_BATCH_PAGE_SIZE);
39
- if (batchIdsToFetch.length === 0) {
40
- /**
41
- * List refresh can complete while no row is `completed` yet (multi-fetch skips), or
42
- * `currentBatchId` may not appear in the filtered list but still needs `GET /batches/:id`.
43
- * Fall back to the single-batch-details epic so `phase` and details can resolve.
44
- */
45
- const bulkUpload = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
46
- const currentId = bulkUpload.currentBatchId;
47
- if (currentId != null &&
48
- bulkUpload.phase === 'matching' &&
49
- bulkUpload.batchDetailsById[currentId] == null &&
50
- shouldFetchBatchDetailsForBatchId(bulkUpload.batchStatusById, bulkUpload.batchListByPeriod, currentId)) {
51
- return of(fetchBulkUploadBatchDetails());
52
- }
53
- return EMPTY;
54
- }
55
- return concat(of(setInitialBatchDetailsLoading()), fetchBatchDetailsByIds(batchIdsToFetch, zeniAPI), of(fetchMoreBatchDetailsComplete()));
56
- }));