@zeniai/client-epic-state 4.19.87-beta2AD → 4.19.87-betaVR2

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 (88) hide show
  1. package/lib/entity/aiCfo/aiCfoSelector.d.ts +2 -1
  2. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  3. package/lib/entity/snackbar/snackbarTypes.js +1 -0
  4. package/lib/epic.d.ts +10 -2
  5. package/lib/epic.js +10 -2
  6. package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
  7. package/lib/esm/epic.js +10 -2
  8. package/lib/esm/index.js +10 -4
  9. package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +1 -83
  10. package/lib/esm/view/aiCfoView/aiCfoViewSelector.js +2 -8
  11. package/lib/esm/view/expenseAutomationView/bulkUploadTiming.js +10 -0
  12. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +29 -0
  13. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +49 -0
  14. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +40 -0
  15. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +47 -0
  16. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +61 -0
  17. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +34 -0
  18. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +57 -0
  19. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +78 -0
  20. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +82 -0
  21. package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +189 -1
  22. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +426 -2
  23. package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +246 -1
  24. package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +39 -0
  25. package/lib/esm/view/spendManagement/billPay/billList/billListSelector.js +0 -10
  26. package/lib/esm/view/spendManagement/billPay/billList/billListState.js +0 -1
  27. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardList.js +0 -1
  28. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +0 -2
  29. package/lib/esm/view/spendManagement/reimbursement/remiListView/remiListSelector.js +0 -12
  30. package/lib/esm/view/spendManagement/reimbursement/remiListView/remiListState.js +0 -1
  31. package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +2 -2
  32. package/lib/esm/zeniAPI.js +0 -2
  33. package/lib/index.d.ts +9 -8
  34. package/lib/index.js +80 -38
  35. package/lib/view/aiCfoView/aiCfoViewPayload.d.ts +0 -11
  36. package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +1 -15
  37. package/lib/view/aiCfoView/aiCfoViewReducer.js +2 -84
  38. package/lib/view/aiCfoView/aiCfoViewSelector.d.ts +1 -4
  39. package/lib/view/aiCfoView/aiCfoViewSelector.js +2 -9
  40. package/lib/view/aiCfoView/aiCfoViewState.d.ts +0 -22
  41. package/lib/view/auditReportView/auditReportViewState.d.ts +1 -1
  42. package/lib/view/expenseAutomationView/bulkUploadTiming.d.ts +10 -0
  43. package/lib/view/expenseAutomationView/bulkUploadTiming.js +13 -0
  44. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +18 -0
  45. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +33 -0
  46. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts +7 -0
  47. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +53 -0
  48. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts +8 -0
  49. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +44 -0
  50. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts +7 -0
  51. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +51 -0
  52. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts +8 -0
  53. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +65 -0
  54. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.d.ts +8 -0
  55. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +38 -0
  56. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +9 -0
  57. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +62 -0
  58. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +14 -0
  59. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +82 -0
  60. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +25 -0
  61. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +88 -0
  62. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  63. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +118 -0
  64. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +201 -0
  65. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +76 -3
  66. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +427 -2
  67. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +69 -1
  68. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.d.ts +1 -1
  69. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +245 -0
  70. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +142 -0
  71. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +49 -1
  72. package/lib/view/spendManagement/billPay/billList/billListSelector.js +0 -10
  73. package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
  74. package/lib/view/spendManagement/billPay/billList/billListState.js +0 -1
  75. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  76. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.js +0 -1
  77. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +0 -2
  78. package/lib/view/spendManagement/reimbursement/remiListView/remiListSelector.d.ts +0 -1
  79. package/lib/view/spendManagement/reimbursement/remiListView/remiListSelector.js +0 -12
  80. package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +1 -1
  81. package/lib/view/spendManagement/reimbursement/remiListView/remiListState.js +0 -1
  82. package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +2 -2
  83. package/lib/zeniAPI.js +0 -2
  84. package/package.json +2 -2
  85. package/lib/esm/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +0 -26
  86. package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
  87. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.d.ts +0 -8
  88. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +0 -30
@@ -1,23 +1,8 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearEmbeddingPageContext = exports.applyEmbeddingPageTransition = exports.fetchSuggestedQuestionsFailure = exports.fetchSuggestedQuestionsSuccess = exports.fetchSuggestedQuestions = exports.updateCotCollapsedState = exports.clearAiCfoView = exports.clearDeleteChatSessionStatus = exports.deleteChatSessionFailure = exports.deleteChatSessionSuccess = exports.deleteChatSession = exports.acceptMasterTOSFailure = exports.acceptMasterTOSSuccess = exports.acceptMasterTOS = exports.stopSubmitQuestionFailure = exports.stopSubmitQuestionSuccess = exports.stopSubmitQuestion = exports.stopSubmitFailure = exports.stopSubmitSuccess = exports.stopSubmit = exports.clearLastContextMessage = exports.clearCurrentSessionId = exports.fetchChatHistoryFailure = exports.fetchChatHistorySuccess = exports.fetchChatHistory = exports.fetchChatSessionsForUserFailure = exports.fetchChatSessionsForUserSuccess = exports.fetchChatSessionsForUser = exports.createSessionAndSubmitFailure = exports.createSessionAndSubmitSuccess = exports.initializeNewSessionState = exports.createSessionAndSubmit = exports.createSessionFailure = exports.createSessionSuccess = exports.createSession = exports.setSession = exports.clearInput = exports.updateCurrentInput = exports.updateAiCfoViewScrollPosition = exports.updateResponseState = exports.submitQuestionFailure = exports.submitQuestionSuccess = exports.submitQuestion = exports.initialAiCfoViewState = void 0;
4
+ exports.updateCotCollapsedState = exports.clearAiCfoView = exports.clearDeleteChatSessionStatus = exports.deleteChatSessionFailure = exports.deleteChatSessionSuccess = exports.deleteChatSession = exports.acceptMasterTOSFailure = exports.acceptMasterTOSSuccess = exports.acceptMasterTOS = exports.stopSubmitQuestionFailure = exports.stopSubmitQuestionSuccess = exports.stopSubmitQuestion = exports.stopSubmitFailure = exports.stopSubmitSuccess = exports.stopSubmit = exports.clearLastContextMessage = exports.clearCurrentSessionId = exports.fetchChatHistoryFailure = exports.fetchChatHistorySuccess = exports.fetchChatHistory = exports.fetchChatSessionsForUserFailure = exports.fetchChatSessionsForUserSuccess = exports.fetchChatSessionsForUser = exports.createSessionAndSubmitFailure = exports.createSessionAndSubmitSuccess = exports.initializeNewSessionState = exports.createSessionAndSubmit = exports.createSessionFailure = exports.createSessionSuccess = exports.createSession = exports.setSession = exports.clearInput = exports.updateCurrentInput = exports.updateAiCfoViewScrollPosition = exports.updateResponseState = exports.submitQuestionFailure = exports.submitQuestionSuccess = exports.submitQuestion = exports.initialAiCfoViewState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
- function removeSessionIdFromPageKeyMap(draft, sessionId) {
7
- const map = draft.uiState.chatSessionIdByPageKey;
8
- for (const key of Object.keys(map)) {
9
- if (map[key] === sessionId) {
10
- delete map[key];
11
- }
12
- }
13
- }
14
- function mirrorCurrentSessionToPageKeyMapIfActive(draft) {
15
- const key = draft.uiState.embeddingActivePageKey;
16
- const sessionId = draft.uiState.currentChatSessionId;
17
- if (key != null && sessionId != null) {
18
- draft.uiState.chatSessionIdByPageKey[key] = sessionId;
19
- }
20
- }
21
6
  exports.initialAiCfoViewState = {
22
7
  fetchState: 'Not-Started',
23
8
  error: undefined,
@@ -25,8 +10,6 @@ exports.initialAiCfoViewState = {
25
10
  currentInput: '',
26
11
  scrollPositionByChatSessionId: {},
27
12
  currentChatSessionId: undefined,
28
- embeddingActivePageKey: undefined,
29
- chatSessionIdByPageKey: {},
30
13
  agentId: undefined,
31
14
  chatHistoryNextPageToken: {},
32
15
  chatSessionsNextPageToken: { nextPageToken: null, hasMore: false },
@@ -50,7 +33,6 @@ exports.initialAiCfoViewState = {
50
33
  fetchChatSessionHistoryByChatSessionId: {},
51
34
  responseStateByChatSessionId: {},
52
35
  stopSubmitStateByChatSessionId: {},
53
- suggestedQuestionsByPageContext: {},
54
36
  };
55
37
  const aiCfoView = (0, toolkit_1.createSlice)({
56
38
  name: 'aiCfoView',
@@ -184,7 +166,6 @@ const aiCfoView = (0, toolkit_1.createSlice)({
184
166
  setSession(draft, action) {
185
167
  draft.uiState.currentChatSessionId = action.payload.sessionId;
186
168
  draft.uiState.agentId = action.payload.agentId;
187
- mirrorCurrentSessionToPageKeyMapIfActive(draft);
188
169
  },
189
170
  createSession: {
190
171
  reducer(draft, action) {
@@ -208,7 +189,6 @@ const aiCfoView = (0, toolkit_1.createSlice)({
208
189
  nextPageToken: null,
209
190
  hasMore: false,
210
191
  };
211
- mirrorCurrentSessionToPageKeyMapIfActive(draft);
212
192
  },
213
193
  createSessionFailure(draft, action) {
214
194
  draft.createSessionState.fetchState = 'Error';
@@ -246,7 +226,6 @@ const aiCfoView = (0, toolkit_1.createSlice)({
246
226
  nextPageToken: null,
247
227
  hasMore: false,
248
228
  };
249
- mirrorCurrentSessionToPageKeyMapIfActive(draft);
250
229
  },
251
230
  createSessionAndSubmitSuccess(draft) {
252
231
  // Note: currentChatSessionId, agentId, and chatHistoryNextPageToken are set by initializeNewSessionState
@@ -363,7 +342,6 @@ const aiCfoView = (0, toolkit_1.createSlice)({
363
342
  draft.uiState.currentChatSessionId = undefined;
364
343
  draft.uiState.agentId = undefined;
365
344
  }
366
- removeSessionIdFromPageKeyMap(draft, chatSessionId);
367
345
  delete draft.uiState.chatHistoryNextPageToken[chatSessionId];
368
346
  delete draft.uiState.scrollPositionByChatSessionId[chatSessionId];
369
347
  delete draft.fetchChatSessionHistoryByChatSessionId[chatSessionId];
@@ -386,66 +364,6 @@ const aiCfoView = (0, toolkit_1.createSlice)({
386
364
  },
387
365
  clearCurrentSessionId(draft) {
388
366
  draft.uiState.currentChatSessionId = undefined;
389
- const key = draft.uiState.embeddingActivePageKey;
390
- if (key != null) {
391
- delete draft.uiState.chatSessionIdByPageKey[key];
392
- }
393
- },
394
- applyEmbeddingPageTransition(draft, action) {
395
- const { newPageKey, nextCurrentChatSessionId } = action.payload;
396
- const prevKey = draft.uiState.embeddingActivePageKey;
397
- const curId = draft.uiState.currentChatSessionId;
398
- if (prevKey != null && prevKey !== newPageKey && curId != null) {
399
- draft.uiState.chatSessionIdByPageKey[prevKey] = curId;
400
- }
401
- draft.uiState.embeddingActivePageKey = newPageKey;
402
- if (nextCurrentChatSessionId == null) {
403
- draft.uiState.currentChatSessionId = undefined;
404
- }
405
- else {
406
- draft.uiState.currentChatSessionId = nextCurrentChatSessionId;
407
- }
408
- draft.uiState.currentInput = '';
409
- },
410
- clearEmbeddingPageContext(draft) {
411
- const key = draft.uiState.embeddingActivePageKey;
412
- const curId = draft.uiState.currentChatSessionId;
413
- if (key != null && curId != null) {
414
- draft.uiState.chatSessionIdByPageKey[key] = curId;
415
- }
416
- draft.uiState.embeddingActivePageKey = undefined;
417
- },
418
- fetchSuggestedQuestions(draft, action) {
419
- const { pageContext } = action.payload;
420
- const prev = draft.suggestedQuestionsByPageContext[pageContext];
421
- draft.suggestedQuestionsByPageContext[pageContext] = {
422
- fetchState: 'In-Progress',
423
- pageContext,
424
- suggestedQuestions: prev?.suggestedQuestions ?? [],
425
- generatedAt: prev?.generatedAt,
426
- error: undefined,
427
- };
428
- },
429
- fetchSuggestedQuestionsSuccess(draft, action) {
430
- const { pageContext, generatedAt, suggestedQuestions } = action.payload;
431
- draft.suggestedQuestionsByPageContext[pageContext] = {
432
- fetchState: 'Completed',
433
- pageContext,
434
- generatedAt,
435
- suggestedQuestions,
436
- error: undefined,
437
- };
438
- },
439
- fetchSuggestedQuestionsFailure(draft, action) {
440
- const { pageContext, error } = action.payload;
441
- const prev = draft.suggestedQuestionsByPageContext[pageContext];
442
- draft.suggestedQuestionsByPageContext[pageContext] = {
443
- fetchState: 'Error',
444
- pageContext,
445
- suggestedQuestions: prev?.suggestedQuestions ?? [],
446
- generatedAt: prev?.generatedAt,
447
- error,
448
- };
449
367
  },
450
368
  clearAiCfoView(draft) {
451
369
  Object.assign(draft, exports.initialAiCfoViewState);
@@ -457,5 +375,5 @@ const aiCfoView = (0, toolkit_1.createSlice)({
457
375
  },
458
376
  },
459
377
  });
460
- _a = aiCfoView.actions, exports.submitQuestion = _a.submitQuestion, exports.submitQuestionSuccess = _a.submitQuestionSuccess, exports.submitQuestionFailure = _a.submitQuestionFailure, exports.updateResponseState = _a.updateResponseState, exports.updateAiCfoViewScrollPosition = _a.updateAiCfoViewScrollPosition, exports.updateCurrentInput = _a.updateCurrentInput, exports.clearInput = _a.clearInput, exports.setSession = _a.setSession, exports.createSession = _a.createSession, exports.createSessionSuccess = _a.createSessionSuccess, exports.createSessionFailure = _a.createSessionFailure, exports.createSessionAndSubmit = _a.createSessionAndSubmit, exports.initializeNewSessionState = _a.initializeNewSessionState, exports.createSessionAndSubmitSuccess = _a.createSessionAndSubmitSuccess, exports.createSessionAndSubmitFailure = _a.createSessionAndSubmitFailure, exports.fetchChatSessionsForUser = _a.fetchChatSessionsForUser, exports.fetchChatSessionsForUserSuccess = _a.fetchChatSessionsForUserSuccess, exports.fetchChatSessionsForUserFailure = _a.fetchChatSessionsForUserFailure, exports.fetchChatHistory = _a.fetchChatHistory, exports.fetchChatHistorySuccess = _a.fetchChatHistorySuccess, exports.fetchChatHistoryFailure = _a.fetchChatHistoryFailure, exports.clearCurrentSessionId = _a.clearCurrentSessionId, exports.clearLastContextMessage = _a.clearLastContextMessage, exports.stopSubmit = _a.stopSubmit, exports.stopSubmitSuccess = _a.stopSubmitSuccess, exports.stopSubmitFailure = _a.stopSubmitFailure, exports.stopSubmitQuestion = _a.stopSubmitQuestion, exports.stopSubmitQuestionSuccess = _a.stopSubmitQuestionSuccess, exports.stopSubmitQuestionFailure = _a.stopSubmitQuestionFailure, exports.acceptMasterTOS = _a.acceptMasterTOS, exports.acceptMasterTOSSuccess = _a.acceptMasterTOSSuccess, exports.acceptMasterTOSFailure = _a.acceptMasterTOSFailure, exports.deleteChatSession = _a.deleteChatSession, exports.deleteChatSessionSuccess = _a.deleteChatSessionSuccess, exports.deleteChatSessionFailure = _a.deleteChatSessionFailure, exports.clearDeleteChatSessionStatus = _a.clearDeleteChatSessionStatus, exports.clearAiCfoView = _a.clearAiCfoView, exports.updateCotCollapsedState = _a.updateCotCollapsedState, exports.fetchSuggestedQuestions = _a.fetchSuggestedQuestions, exports.fetchSuggestedQuestionsSuccess = _a.fetchSuggestedQuestionsSuccess, exports.fetchSuggestedQuestionsFailure = _a.fetchSuggestedQuestionsFailure, exports.applyEmbeddingPageTransition = _a.applyEmbeddingPageTransition, exports.clearEmbeddingPageContext = _a.clearEmbeddingPageContext;
378
+ _a = aiCfoView.actions, exports.submitQuestion = _a.submitQuestion, exports.submitQuestionSuccess = _a.submitQuestionSuccess, exports.submitQuestionFailure = _a.submitQuestionFailure, exports.updateResponseState = _a.updateResponseState, exports.updateAiCfoViewScrollPosition = _a.updateAiCfoViewScrollPosition, exports.updateCurrentInput = _a.updateCurrentInput, exports.clearInput = _a.clearInput, exports.setSession = _a.setSession, exports.createSession = _a.createSession, exports.createSessionSuccess = _a.createSessionSuccess, exports.createSessionFailure = _a.createSessionFailure, exports.createSessionAndSubmit = _a.createSessionAndSubmit, exports.initializeNewSessionState = _a.initializeNewSessionState, exports.createSessionAndSubmitSuccess = _a.createSessionAndSubmitSuccess, exports.createSessionAndSubmitFailure = _a.createSessionAndSubmitFailure, exports.fetchChatSessionsForUser = _a.fetchChatSessionsForUser, exports.fetchChatSessionsForUserSuccess = _a.fetchChatSessionsForUserSuccess, exports.fetchChatSessionsForUserFailure = _a.fetchChatSessionsForUserFailure, exports.fetchChatHistory = _a.fetchChatHistory, exports.fetchChatHistorySuccess = _a.fetchChatHistorySuccess, exports.fetchChatHistoryFailure = _a.fetchChatHistoryFailure, exports.clearCurrentSessionId = _a.clearCurrentSessionId, exports.clearLastContextMessage = _a.clearLastContextMessage, exports.stopSubmit = _a.stopSubmit, exports.stopSubmitSuccess = _a.stopSubmitSuccess, exports.stopSubmitFailure = _a.stopSubmitFailure, exports.stopSubmitQuestion = _a.stopSubmitQuestion, exports.stopSubmitQuestionSuccess = _a.stopSubmitQuestionSuccess, exports.stopSubmitQuestionFailure = _a.stopSubmitQuestionFailure, exports.acceptMasterTOS = _a.acceptMasterTOS, exports.acceptMasterTOSSuccess = _a.acceptMasterTOSSuccess, exports.acceptMasterTOSFailure = _a.acceptMasterTOSFailure, exports.deleteChatSession = _a.deleteChatSession, exports.deleteChatSessionSuccess = _a.deleteChatSessionSuccess, exports.deleteChatSessionFailure = _a.deleteChatSessionFailure, exports.clearDeleteChatSessionStatus = _a.clearDeleteChatSessionStatus, exports.clearAiCfoView = _a.clearAiCfoView, exports.updateCotCollapsedState = _a.updateCotCollapsedState;
461
379
  exports.default = aiCfoView.reducer;
@@ -3,8 +3,7 @@ import { FetchStateAndError } from '../../commonStateTypes/common';
3
3
  import { SelectorView } from '../../commonStateTypes/viewAndReport/viewAndReport';
4
4
  import { AiCfoSelectorView } from '../../entity/aiCfo/aiCfoSelector';
5
5
  import { RootState } from '../../reducer';
6
- import { AiCfoSuggestedQuestionsPageContext } from './aiCfoViewState';
7
- import { AiCfoViewUIState, SuggestedQuestionsForPageContext } from './aiCfoViewState';
6
+ import { AiCfoViewUIState } from './aiCfoViewState';
8
7
  export interface AiCfoViewSelector extends SelectorView, AiCfoSelectorView {
9
8
  createSessionAndSubmitState: FetchStateAndError;
10
9
  createSessionState: FetchStateAndError;
@@ -18,8 +17,6 @@ export interface AiCfoViewSelector extends SelectorView, AiCfoSelectorView {
18
17
  thought: FetchStateAndError;
19
18
  }>;
20
19
  stopSubmitStateByChatSessionId: Record<ID, FetchStateAndError>;
21
- suggestedQuestionsByPageContext: Partial<Record<AiCfoSuggestedQuestionsPageContext, SuggestedQuestionsForPageContext>>;
22
20
  uiState: AiCfoViewUIState;
23
21
  }
24
22
  export declare const getAiCfoView: (state: RootState) => AiCfoViewSelector;
25
- export declare function getSuggestedQuestionsForPageContext(state: RootState, pageContext: AiCfoSuggestedQuestionsPageContext): SuggestedQuestionsForPageContext | undefined;
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAiCfoView = void 0;
4
- exports.getSuggestedQuestionsForPageContext = getSuggestedQuestionsForPageContext;
5
- const aiCfoReducer_1 = require("../../entity/aiCfo/aiCfoReducer");
6
4
  const aiCfoSelector_1 = require("../../entity/aiCfo/aiCfoSelector");
7
- const aiCfoViewReducer_1 = require("./aiCfoViewReducer");
8
5
  const getAiCfoView = (state) => {
9
- const { fetchState, error, uiState, createSessionState, createSessionAndSubmitState, deleteChatSessionStateByChatSessionId, stopSubmitStateByChatSessionId, responseStateByChatSessionId, fetchChatSessionHistoryByChatSessionId, masterTOSAcceptanceState, suggestedQuestionsByPageContext, } = state.aiCfoViewState ?? aiCfoViewReducer_1.initialAiCfoViewState;
6
+ const { fetchState, error, uiState, createSessionState, createSessionAndSubmitState, deleteChatSessionStateByChatSessionId, stopSubmitStateByChatSessionId, responseStateByChatSessionId, fetchChatSessionHistoryByChatSessionId, masterTOSAcceptanceState, } = state.aiCfoViewState;
10
7
  return {
11
8
  fetchState,
12
9
  error,
@@ -18,12 +15,8 @@ const getAiCfoView = (state) => {
18
15
  uiState,
19
16
  fetchChatSessionHistoryByChatSessionId,
20
17
  masterTOSAcceptanceState,
21
- suggestedQuestionsByPageContext,
22
- ...(0, aiCfoSelector_1.getAiCfoSelectorView)(state.aiCfoState ?? aiCfoReducer_1.initialAiCfoState),
18
+ ...(0, aiCfoSelector_1.getAiCfoSelectorView)(state.aiCfoState),
23
19
  version: 1,
24
20
  };
25
21
  };
26
22
  exports.getAiCfoView = getAiCfoView;
27
- function getSuggestedQuestionsForPageContext(state, pageContext) {
28
- return state.aiCfoViewState?.suggestedQuestionsByPageContext?.[pageContext];
29
- }
@@ -9,8 +9,6 @@ export interface AiCfoViewUIState {
9
9
  chatHistoryNextPageToken: {
10
10
  [chatSessionId: ID]: PageTokenState;
11
11
  };
12
- /** Last focused chat session id per embedded page key (e.g. `dashboard`, `reports:profit_loss`). */
13
- chatSessionIdByPageKey: Partial<Record<string, ID>>;
14
12
  chatSessionsFirstPageFetched: boolean;
15
13
  chatSessionsNextPageToken: PageTokenState;
16
14
  cotCollapsedByQuestionAnswerId: {
@@ -24,27 +22,9 @@ export interface AiCfoViewUIState {
24
22
  };
25
23
  agentId?: ID;
26
24
  currentChatSessionId?: ID;
27
- /**
28
- * When set, the embedded panel (e.g. dashboard/reports) is scoped to this **page key**;
29
- * session ids are mirrored into {@link chatSessionIdByPageKey}. Full `/ai-cfo/...` should clear this.
30
- */
31
- embeddingActivePageKey?: string;
32
25
  lastContextMessage?: string;
33
26
  lastContextStatus?: ContextStatus;
34
27
  }
35
- /**
36
- * Supported `page_context` values for GET .../suggested-questions and related UI state.
37
- */
38
- export type AiCfoSuggestedQuestionsPageContext = 'balance_sheet' | 'profit_loss' | 'vendors' | 'transactions' | 'cash_flow' | 'accounts_receivable' | 'accounts_payable' | 'transaction_details';
39
- /**
40
- * Suggested starter questions for AI CFO for a given page slug (e.g. balance_sheet).
41
- * Populated by {@link fetchSuggestedQuestionsEpic}; UI may fall back to Statsig defaults.
42
- */
43
- export interface SuggestedQuestionsForPageContext extends FetchStateAndError {
44
- pageContext: AiCfoSuggestedQuestionsPageContext;
45
- suggestedQuestions: string[];
46
- generatedAt?: string;
47
- }
48
28
  export interface AiCfoViewState extends FetchStateAndError {
49
29
  allChatSessionIds: ID[];
50
30
  createSessionAndSubmitState: FetchStateAndError;
@@ -59,7 +39,5 @@ export interface AiCfoViewState extends FetchStateAndError {
59
39
  thought: FetchStateAndError;
60
40
  }>;
61
41
  stopSubmitStateByChatSessionId: Record<ID, FetchStateAndError>;
62
- /** Keyed by `page_context` query value (e.g. balance_sheet). */
63
- suggestedQuestionsByPageContext: Partial<Record<AiCfoSuggestedQuestionsPageContext, SuggestedQuestionsForPageContext>>;
64
42
  uiState: AiCfoViewUIState;
65
43
  }
@@ -3,7 +3,7 @@ import { Status } from '../../commonStateTypes/status';
3
3
  import { View } from '../../commonStateTypes/viewAndReport/viewAndReport';
4
4
  import { ZeniDate } from '../../zeniDayJS';
5
5
  import { AuditSummary } from '../reviewCompanyView/reviewCompanyViewState';
6
- export declare const toAuditRuleEntityType: (v: string) => "dashboard" | "transactions" | "reports";
6
+ export declare const toAuditRuleEntityType: (v: string) => "dashboard" | "reports" | "transactions";
7
7
  export type AuditRuleEntityType = ReturnType<typeof toAuditRuleEntityType>;
8
8
  declare const toAuditRuleEntityIdType: (v: string) => "cash_balance" | "card_balance" | "expense_automation_card" | "operating_expenses" | "operating_expenses_by_classes" | "revenue" | "revenue_by_classes" | "net_burn_or_income" | "net_burn_or_income_story_card" | "net_burn_or_income_by_classes" | "cash_position" | "top_expenses" | "profit_and_loss" | "profit_and_loss_by_classes" | "balance_sheet" | "cash_flow" | "dashboard" | "finance_statement" | "transaction_list_of_account" | "transaction_list_missing_receipt" | "transaction_list_of_account_by_class" | "transaction_detail" | "cash_in_cash_out" | "insights_dashboard" | "company_details" | "class_list" | "account_list" | "account_list_by_type" | "vendor" | "task_card" | "bill_pay" | "reimbursement" | "bill_pay_card" | "reimbursement_card" | "bill_pay_promo_card" | "zeni_accounts" | "zeni_accounts_promo_card" | "zeni_treasury" | "charge_cards" | "other_connection" | "reimbursement_promo_card" | "onboarding" | "operating_expenses_by_vendor" | "operating_expenses_by_vendor_summary" | "vendors_tab" | "accounts_payable_aging" | "accounts_receivable_aging" | "vendor_global_review" | "prepaid_expenses" | "fixed_assets" | "notification" | "rewards_card" | "billing" | "flux_analysis_operating_expense" | "account_reconciliation" | "zeni_credit_promo_card" | "treasury_promo_card" | "uncategorized-expense" | "uncategorized-income";
9
9
  export type AuditRuleEntityIdType = ReturnType<typeof toAuditRuleEntityIdType>;
@@ -0,0 +1,10 @@
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 declare 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 declare const BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS = 300000;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS = exports.BULK_UPLOAD_BAR_COMPLETE_HOLD_MS = void 0;
4
+ /**
5
+ * After upload API success, hold the bar at 100% this long before transitioning to matching,
6
+ * so the fill animation can complete without an abrupt swap to the auto-matching banner.
7
+ */
8
+ exports.BULK_UPLOAD_BAR_COMPLETE_HOLD_MS = 400;
9
+ /**
10
+ * Max wall-clock wait for Pusher + batch-details resolution after upload. If exceeded, we stop
11
+ * fallback polling, clear the automatching banner (`phase` → completed), and refresh batch list.
12
+ */
13
+ exports.BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS = 300000;
@@ -0,0 +1,18 @@
1
+ import { ActionsObservable } from 'redux-observable';
2
+ import { ZeniAPI } from '../../../../zeniAPI';
3
+ import { bulkUploadReceipts, bulkUploadReceiptsFailure, bulkUploadReceiptsSuccess } from '../../reducers/missingReceiptsViewReducer';
4
+ export type ActionType = ReturnType<typeof bulkUploadReceipts> | ReturnType<typeof bulkUploadReceiptsSuccess> | ReturnType<typeof bulkUploadReceiptsFailure>;
5
+ export declare const bulkUploadReceiptsEpic: (actions$: ActionsObservable<ActionType>, _state$: unknown, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
6
+ payload: {
7
+ batchId: import("../../../..").ID;
8
+ };
9
+ type: "expenseAutomationMissingReceiptsView/bulkUploadReceiptsSuccess";
10
+ } | {
11
+ payload: {
12
+ error: import("../../../../responsePayload").ZeniAPIStatus;
13
+ };
14
+ type: "expenseAutomationMissingReceiptsView/bulkUploadReceiptsFailure";
15
+ } | {
16
+ payload: number;
17
+ type: "expenseAutomationMissingReceiptsView/updateBulkUploadProgress";
18
+ }>;
@@ -0,0 +1,33 @@
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 bulkUploadTiming_1 = require("../../bulkUploadTiming");
8
+ const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
9
+ const bulkUploadReceiptsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.bulkUploadReceipts.match), (0, operators_1.mergeMap)((action) => {
10
+ const { files } = action.payload;
11
+ const formData = new FormData();
12
+ for (const file of files) {
13
+ formData.append('files', file, file.name);
14
+ }
15
+ return zeniAPI
16
+ .postFormData(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`, formData)
17
+ .pipe((0, operators_1.mergeMap)((response) => {
18
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
19
+ const batchId = String(response.data.batch_id ?? '').trim();
20
+ if (batchId === '') {
21
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsFailure)({
22
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Bulk upload succeeded but batch_id was missing or empty.'),
23
+ }));
24
+ }
25
+ return (0, rxjs_1.concat)((0, rxjs_1.of)((0, missingReceiptsViewReducer_1.updateBulkUploadProgress)(100)), (0, rxjs_1.timer)(bulkUploadTiming_1.BULK_UPLOAD_BAR_COMPLETE_HOLD_MS).pipe((0, operators_1.mergeMap)(() => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsSuccess)({ batchId })))));
26
+ }
27
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsFailure)({ error: response.status }));
28
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsFailure)({
29
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Bulk upload receipts API call errored out: ' +
30
+ JSON.stringify(error)),
31
+ }))));
32
+ }));
33
+ exports.bulkUploadReceiptsEpic = bulkUploadReceiptsEpic;
@@ -0,0 +1,7 @@
1
+ import { ActionsObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
4
+ import { ZeniAPI } from '../../../../zeniAPI';
5
+ import { confirmBulkUploadMatch, confirmBulkUploadMatchFailure, confirmBulkUploadMatchSuccess } from '../../reducers/missingReceiptsViewReducer';
6
+ export type ActionType = ReturnType<typeof confirmBulkUploadMatch> | ReturnType<typeof confirmBulkUploadMatchSuccess> | ReturnType<typeof confirmBulkUploadMatchFailure> | ReturnType<typeof openSnackbar>;
7
+ export declare const confirmBulkUploadMatchEpic: (actions$: ActionsObservable<ActionType>, _state$: unknown, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.confirmBulkUploadMatchEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
7
+ const responsePayload_1 = require("../../../../responsePayload");
8
+ const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
9
+ const confirmBulkUploadMatchEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.confirmBulkUploadMatch.match), (0, operators_1.exhaustMap)((action) => {
10
+ const { batchId, attachmentId, transactionId, transactionType, fileName } = action.payload;
11
+ return zeniAPI
12
+ .postAndGetJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/manual-match`, {
13
+ attachment_id: attachmentId,
14
+ transaction_id: transactionId,
15
+ transaction_type: transactionType,
16
+ file_name: fileName,
17
+ })
18
+ .pipe((0, operators_1.mergeMap)((response) => {
19
+ if ((0, responsePayload_1.isSuccessResponse)(response)) {
20
+ return (0, rxjs_1.from)([
21
+ (0, missingReceiptsViewReducer_1.confirmBulkUploadMatchSuccess)({
22
+ batchId,
23
+ attachmentId,
24
+ transactionId,
25
+ }),
26
+ (0, snackbarReducer_1.openSnackbar)({
27
+ messageSection: 'receipt_match',
28
+ messageText: 'success',
29
+ type: 'success',
30
+ }),
31
+ ]);
32
+ }
33
+ return (0, rxjs_1.from)([
34
+ (0, missingReceiptsViewReducer_1.confirmBulkUploadMatchFailure)({ error: response.status }),
35
+ (0, snackbarReducer_1.openSnackbar)({
36
+ messageSection: 'receipt_match',
37
+ messageText: 'failed',
38
+ type: 'error',
39
+ }),
40
+ ]);
41
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
42
+ (0, missingReceiptsViewReducer_1.confirmBulkUploadMatchFailure)({
43
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Confirm bulk upload match errored out: ' +
44
+ JSON.stringify(error)),
45
+ }),
46
+ (0, snackbarReducer_1.openSnackbar)({
47
+ messageSection: 'receipt_match',
48
+ messageText: 'failed',
49
+ type: 'error',
50
+ }),
51
+ ])));
52
+ }));
53
+ exports.confirmBulkUploadMatchEpic = confirmBulkUploadMatchEpic;
@@ -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,44 @@
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 bulkUpload = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
12
+ const { currentBatchId } = bulkUpload;
13
+ if (currentBatchId == null) {
14
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsFailure)({
15
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'No current batch ID available'),
16
+ }));
17
+ }
18
+ if (!(0, missingReceiptsPayload_1.shouldFetchBatchDetailsForBatchId)(bulkUpload.batchStatusById, bulkUpload.batchListByPeriod, currentBatchId)) {
19
+ return rxjs_1.EMPTY;
20
+ }
21
+ return zeniAPI
22
+ .getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${currentBatchId}`)
23
+ .pipe((0, operators_1.mergeMap)((response) => {
24
+ if (!(0, responsePayload_1.isSuccessResponse)(response) ||
25
+ response.data == null ||
26
+ !(0, missingReceiptsPayload_1.isBatchDetailsApiStatusCompleted)(response.data.status)) {
27
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
28
+ return rxjs_1.EMPTY;
29
+ }
30
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsFailure)({ error: response.status }));
31
+ }
32
+ const actions = [];
33
+ const transactionPayloads = (0, missingReceiptsPayload_1.extractTransactionPayloadsFromBatchFiles)(response.data.files);
34
+ if (transactionPayloads.length > 0) {
35
+ actions.push((0, transactionReducer_1.updateTransactions)(transactionPayloads, (value) => value.transaction_id));
36
+ }
37
+ actions.push((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsSuccess)((0, missingReceiptsPayload_1.toBatchDetails)(response.data, zeniAPI.apiEndPoints.fileMicroServiceBaseUrl)));
38
+ actions.push((0, missingReceiptsViewReducer_1.fetchBulkUploadBatches)({ cacheOverride: true }));
39
+ return (0, rxjs_1.from)(actions);
40
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsFailure)({
41
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch batch details errored out: ' + JSON.stringify(error)),
42
+ }))));
43
+ }));
44
+ exports.fetchBulkUploadBatchDetailsEpic = fetchBulkUploadBatchDetailsEpic;
@@ -0,0 +1,7 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { RootState } from '../../../../reducer';
4
+ import { ZeniAPI } from '../../../../zeniAPI';
5
+ import { fetchBulkUploadBatches, fetchBulkUploadBatchesFailure, fetchBulkUploadBatchesSuccess } from '../../reducers/missingReceiptsViewReducer';
6
+ export type ActionType = ReturnType<typeof fetchBulkUploadBatches> | ReturnType<typeof fetchBulkUploadBatchesSuccess> | ReturnType<typeof fetchBulkUploadBatchesFailure>;
7
+ export declare const fetchBulkUploadBatchesEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchBulkUploadBatchesEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
7
+ const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
8
+ const responsePayload_1 = require("../../../../responsePayload");
9
+ const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
10
+ const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
11
+ const fetchBulkUploadBatchesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatches.match), (0, operators_1.switchMap)((action) => {
12
+ const { cacheOverride } = action.payload;
13
+ const state = state$.value;
14
+ const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
15
+ const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
16
+ const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
17
+ const periodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
18
+ const existingBatches = bulkUpload.batchListByPeriod[periodId] ?? [];
19
+ if (cacheOverride !== true && existingBatches.length > 0) {
20
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesSuccess)({
21
+ batchList: existingBatches,
22
+ selectedPeriod,
23
+ }));
24
+ }
25
+ const period = (0, timePeriod_1.convertToPeriod)(selectedPeriod);
26
+ const queryParam = {
27
+ start_date: period.start,
28
+ end_date: period.end,
29
+ sort_order: 'desc',
30
+ };
31
+ return zeniAPI
32
+ .getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
33
+ .pipe((0, operators_1.mergeMap)((response) => {
34
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
35
+ /** Full list (all statuses) for UI; batch-details epics filter to `completed` only. */
36
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesSuccess)({
37
+ batchList: response.data.batches.map(missingReceiptsPayload_1.toBatchListItem),
38
+ selectedPeriod,
39
+ }));
40
+ }
41
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesFailure)({
42
+ error: response.status,
43
+ selectedPeriod,
44
+ }));
45
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesFailure)({
46
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch bulk upload batches errored out: ' +
47
+ JSON.stringify(error)),
48
+ selectedPeriod,
49
+ }))));
50
+ }));
51
+ 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,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchCompletedTransactionsEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
7
+ const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
8
+ const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
9
+ const responsePayload_1 = require("../../../../responsePayload");
10
+ const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
11
+ const fetchCompletedTransactionsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchCompletedTransactions.match), (0, operators_1.switchMap)((action) => {
12
+ const state = state$.value;
13
+ const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
14
+ const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
15
+ const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
16
+ const periodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
17
+ const isInitialLoad = action.payload.pageToken == null;
18
+ const cacheKey = (0, missingReceiptsViewReducer_1.getCompletedTransactionsCacheKey)(periodId, bulkUpload.sortKey, bulkUpload.sortOrder, bulkUpload.completedSubTab);
19
+ const existingData = bulkUpload.completedTransactionsByPeriod[cacheKey];
20
+ if (isInitialLoad &&
21
+ action.payload.cacheOverride !== true &&
22
+ existingData != null &&
23
+ existingData.transactionIds.length > 0) {
24
+ return (0, rxjs_1.from)([]);
25
+ }
26
+ const period = (0, timePeriod_1.convertToPeriod)(selectedPeriod);
27
+ const queryPayload = {
28
+ start_date: period.start,
29
+ end_date: period.end,
30
+ sort_by: bulkUpload.sortKey,
31
+ sort_order: bulkUpload.sortOrder === 'ascending' ? 'asc' : 'desc',
32
+ page_token: action.payload.pageToken ?? null,
33
+ page_size: 25,
34
+ };
35
+ if (bulkUpload.completedSubTab !== 'all') {
36
+ queryPayload.match_type = bulkUpload.completedSubTab;
37
+ }
38
+ const encodedQuery = encodeURIComponent(JSON.stringify(queryPayload));
39
+ return zeniAPI
40
+ .getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipt-agent/transactions/completed?query=${encodedQuery}`)
41
+ .pipe((0, operators_1.mergeMap)((response) => {
42
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
43
+ const transactionIds = response.data.transactions.map((t) => t.transaction_id);
44
+ const updateActions = [];
45
+ updateActions.push((0, transactionReducer_1.updateTransactions)(response.data.transactions, (value) => value.transaction_id));
46
+ updateActions.push((0, missingReceiptsViewReducer_1.fetchCompletedTransactionsSuccess)({
47
+ isInitialLoad,
48
+ transactionIds,
49
+ nextPageToken: response.data.next_page_token,
50
+ totalCount: response.data.total_count,
51
+ selectedPeriod,
52
+ }));
53
+ return (0, rxjs_1.from)(updateActions);
54
+ }
55
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchCompletedTransactionsFailure)({
56
+ error: response.status,
57
+ selectedPeriod,
58
+ }));
59
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchCompletedTransactionsFailure)({
60
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch completed transactions errored: ' +
61
+ JSON.stringify(error)),
62
+ selectedPeriod,
63
+ }))));
64
+ }));
65
+ exports.fetchCompletedTransactionsEpic = fetchCompletedTransactionsEpic;
@@ -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 { batchDetailFetchFailed, fetchBulkUploadBatchDetails, fetchBulkUploadBatchesSuccess, fetchMoreBatchDetails, fetchMoreBatchDetailsComplete, fetchMoreBatchDetailsFailure, setInitialBatchDetailsLoading, storeBatchDetails } from '../../reducers/missingReceiptsViewReducer';
7
+ export type ActionType = ReturnType<typeof fetchBulkUploadBatchDetails> | ReturnType<typeof fetchBulkUploadBatchesSuccess> | ReturnType<typeof fetchMoreBatchDetails> | ReturnType<typeof fetchMoreBatchDetailsComplete> | ReturnType<typeof fetchMoreBatchDetailsFailure> | ReturnType<typeof batchDetailFetchFailed> | ReturnType<typeof setInitialBatchDetailsLoading> | ReturnType<typeof storeBatchDetails> | ReturnType<typeof updateTransactions>;
8
+ export declare const fetchMoreBatchDetailsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;