@zeniai/client-epic-state 5.0.3-betaVR10 → 5.0.4-beta0ND

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 (31) hide show
  1. package/lib/coreEpics.js +2 -1
  2. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.d.ts +9 -1
  3. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +16 -1
  4. package/lib/entity/tenant/SessionManager.d.ts +38 -0
  5. package/lib/entity/tenant/SessionManager.js +171 -0
  6. package/lib/entity/tenant/epic/sessionHeartbeatEpic.d.ts +16 -0
  7. package/lib/entity/tenant/epic/sessionHeartbeatEpic.js +16 -0
  8. package/lib/entity/tenant/sessionTypes.d.ts +26 -0
  9. package/lib/entity/tenant/sessionTypes.js +12 -0
  10. package/lib/entity/tenant/tenantReducer.d.ts +5 -1
  11. package/lib/entity/tenant/tenantReducer.js +23 -2
  12. package/lib/entity/tenant/tenantState.d.ts +1 -0
  13. package/lib/esm/coreEpics.js +2 -1
  14. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +16 -1
  15. package/lib/esm/entity/tenant/SessionManager.js +167 -0
  16. package/lib/esm/entity/tenant/epic/sessionHeartbeatEpic.js +12 -0
  17. package/lib/esm/entity/tenant/sessionTypes.js +9 -0
  18. package/lib/esm/entity/tenant/tenantReducer.js +21 -1
  19. package/lib/esm/index.js +5 -2
  20. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +5 -22
  21. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +1 -9
  22. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +3 -3
  23. package/lib/index.d.ts +5 -2
  24. package/lib/index.js +36 -30
  25. package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
  26. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +5 -22
  27. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +2 -2
  28. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +0 -8
  29. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +0 -6
  30. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +3 -3
  31. package/package.json +1 -1
@@ -15,15 +15,7 @@ const fetchCompletedTransactionsEpic = (actions$, state$, zeniAPI) => actions$.p
15
15
  const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
16
16
  const periodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
17
17
  const isInitialLoad = action.payload.pageToken == null;
18
- /**
19
- * Snapshot sort config + subTab at request time so success/failure write
20
- * into the same cache key the request was made under, even if the user
21
- * toggles sort while the request is in flight.
22
- */
23
- const sortKey = bulkUpload.sortKey;
24
- const sortOrder = bulkUpload.sortOrder;
25
- const completedSubTab = bulkUpload.completedSubTab;
26
- const cacheKey = (0, missingReceiptsViewReducer_1.getCompletedTransactionsCacheKey)(periodId, sortKey, sortOrder, completedSubTab);
18
+ const cacheKey = (0, missingReceiptsViewReducer_1.getCompletedTransactionsCacheKey)(periodId, bulkUpload.sortKey, bulkUpload.sortOrder, bulkUpload.completedSubTab);
27
19
  const existingData = bulkUpload.completedTransactionsByPeriod[cacheKey];
28
20
  if (isInitialLoad &&
29
21
  action.payload.cacheOverride !== true &&
@@ -35,13 +27,13 @@ const fetchCompletedTransactionsEpic = (actions$, state$, zeniAPI) => actions$.p
35
27
  const queryPayload = {
36
28
  start_date: period.start,
37
29
  end_date: period.end,
38
- sort_by: sortKey,
39
- sort_order: sortOrder === 'ascending' ? 'asc' : 'desc',
30
+ sort_by: bulkUpload.sortKey,
31
+ sort_order: bulkUpload.sortOrder === 'ascending' ? 'asc' : 'desc',
40
32
  page_token: action.payload.pageToken ?? null,
41
33
  page_size: 25,
42
34
  };
43
- if (completedSubTab !== 'all') {
44
- queryPayload.match_type = completedSubTab;
35
+ if (bulkUpload.completedSubTab !== 'all') {
36
+ queryPayload.match_type = bulkUpload.completedSubTab;
45
37
  }
46
38
  const encodedQuery = encodeURIComponent(JSON.stringify(queryPayload));
47
39
  return zeniAPI
@@ -57,26 +49,17 @@ const fetchCompletedTransactionsEpic = (actions$, state$, zeniAPI) => actions$.p
57
49
  nextPageToken: response.data.next_page_token,
58
50
  totalCount: response.data.total_count,
59
51
  selectedPeriod,
60
- sortKey,
61
- sortOrder,
62
- completedSubTab,
63
52
  }));
64
53
  return (0, rxjs_1.from)(updateActions);
65
54
  }
66
55
  return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchCompletedTransactionsFailure)({
67
56
  error: response.status,
68
57
  selectedPeriod,
69
- sortKey,
70
- sortOrder,
71
- completedSubTab,
72
58
  }));
73
59
  }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchCompletedTransactionsFailure)({
74
60
  error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch completed transactions errored: ' +
75
61
  JSON.stringify(error)),
76
62
  selectedPeriod,
77
- sortKey,
78
- sortOrder,
79
- completedSubTab,
80
63
  }))));
81
64
  }));
82
65
  exports.fetchCompletedTransactionsEpic = fetchCompletedTransactionsEpic;
@@ -4,8 +4,8 @@ import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
4
4
  import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
5
5
  import { RootState } from '../../../../reducer';
6
6
  import { ZeniAPI } from '../../../../zeniAPI';
7
- import { bulkUploadAutomatchingTimedOut, bulkUploadReceiptsSuccess, clearBulkUpload, fetchBulkUploadBatchDetails, fetchBulkUploadBatchDetailsSuccess, fetchBulkUploadBatches, pusherBatchStatusUpdate, requestMissingReceiptsTabNavigation, restoreBulkUploadMatchingState } from '../../reducers/missingReceiptsViewReducer';
8
- export type ActionType = ReturnType<typeof bulkUploadReceiptsSuccess> | ReturnType<typeof restoreBulkUploadMatchingState> | ReturnType<typeof pusherBatchStatusUpdate> | ReturnType<typeof fetchBulkUploadBatchDetails> | ReturnType<typeof fetchBulkUploadBatchDetailsSuccess> | ReturnType<typeof fetchBulkUploadBatches> | ReturnType<typeof requestMissingReceiptsTabNavigation> | ReturnType<typeof updateTransactions> | ReturnType<typeof clearBulkUpload> | ReturnType<typeof openSnackbar> | ReturnType<typeof bulkUploadAutomatchingTimedOut>;
7
+ import { bulkUploadAutomatchingTimedOut, bulkUploadReceiptsSuccess, clearBulkUpload, fetchBulkUploadBatchDetailsSuccess, fetchBulkUploadBatches, pusherBatchStatusUpdate, requestMissingReceiptsTabNavigation, restoreBulkUploadMatchingState } from '../../reducers/missingReceiptsViewReducer';
8
+ export type ActionType = ReturnType<typeof bulkUploadReceiptsSuccess> | ReturnType<typeof restoreBulkUploadMatchingState> | ReturnType<typeof pusherBatchStatusUpdate> | ReturnType<typeof fetchBulkUploadBatchDetailsSuccess> | ReturnType<typeof fetchBulkUploadBatches> | ReturnType<typeof requestMissingReceiptsTabNavigation> | ReturnType<typeof updateTransactions> | ReturnType<typeof clearBulkUpload> | ReturnType<typeof openSnackbar> | ReturnType<typeof bulkUploadAutomatchingTimedOut>;
9
9
  /**
10
10
  * On Pusher batch completion: refresh batch list (then fetchMultipleBatchDetailsEpic runs),
11
11
  * and request switching to the Unmatched tab. Debounced to reduce duplicate refreshes.
@@ -39,17 +39,9 @@ const bulkUploadAutomatchingTimeoutEpic = (actions$, state$) => actions$.pipe((0
39
39
  if (bulk.phase !== 'matching' || bulk.currentBatchId !== batchId) {
40
40
  return rxjs_1.EMPTY;
41
41
  }
42
- /**
43
- * Also request the single-batch details directly so the "X out of Y Receipts Matched"
44
- * toast still fires when the backend actually completed between the last Pusher ping
45
- * and this timeout. If Pusher already tagged the batch as still `processing`,
46
- * `fetchBulkUploadBatchDetailsEpic`'s guard will skip the call and we simply rely on
47
- * the list refresh to eventually populate details via `fetchMultipleBatchDetailsEpic`.
48
- */
49
42
  return (0, rxjs_1.from)([
50
43
  (0, missingReceiptsViewReducer_1.bulkUploadAutomatchingTimedOut)(batchId),
51
44
  (0, missingReceiptsViewReducer_1.fetchBulkUploadBatches)({ cacheOverride: true }),
52
- (0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetails)(),
53
45
  ]);
54
46
  }), (0, operators_1.takeUntil)((0, rxjs_1.merge)(actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.clearBulkUpload.match)), actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.pusherBatchStatusUpdate.match), (0, operators_1.filter)((a) => a.payload.batchId === batchId &&
55
47
  a.payload.status === 'completed')), actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsSuccess.match), (0, operators_1.filter)((a) => a.payload.batchId === batchId)))));
@@ -101,20 +101,14 @@ export declare const fetchMissingReceipts: import("@reduxjs/toolkit").ActionCrea
101
101
  pageToken: string | undefined;
102
102
  cacheOverride: boolean | undefined;
103
103
  }, "expenseAutomationMissingReceiptsView/fetchCompletedTransactions", never, never>, fetchCompletedTransactionsSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
104
- completedSubTab: CompletedSubTab;
105
104
  isInitialLoad: boolean;
106
105
  nextPageToken: string | null;
107
106
  selectedPeriod: MonthYearPeriod;
108
- sortKey: BulkUploadSortKey;
109
- sortOrder: SortOrder;
110
107
  totalCount: number;
111
108
  transactionIds: ID[];
112
109
  }, "expenseAutomationMissingReceiptsView/fetchCompletedTransactionsSuccess">, fetchCompletedTransactionsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
113
- completedSubTab: CompletedSubTab;
114
110
  error: ZeniAPIStatus;
115
111
  selectedPeriod: MonthYearPeriod;
116
- sortKey: BulkUploadSortKey;
117
- sortOrder: SortOrder;
118
112
  }, "expenseAutomationMissingReceiptsView/fetchCompletedTransactionsFailure">;
119
113
  declare const _default: import("redux").Reducer<MissingReceiptsViewState>;
120
114
  export default _default;
@@ -527,9 +527,9 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
527
527
  },
528
528
  },
529
529
  fetchCompletedTransactionsSuccess(draft, action) {
530
- const { transactionIds, nextPageToken, totalCount, selectedPeriod, isInitialLoad, sortKey, sortOrder, completedSubTab, } = action.payload;
530
+ const { transactionIds, nextPageToken, totalCount, selectedPeriod, isInitialLoad, } = action.payload;
531
531
  const periodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
532
- const cacheKey = (0, exports.getCompletedTransactionsCacheKey)(periodId, sortKey, sortOrder, completedSubTab);
532
+ const cacheKey = (0, exports.getCompletedTransactionsCacheKey)(periodId, draft.bulkUpload.sortKey, draft.bulkUpload.sortOrder, draft.bulkUpload.completedSubTab);
533
533
  if (isInitialLoad) {
534
534
  draft.bulkUpload.completedTransactionsByPeriod[cacheKey] = {
535
535
  transactionIds,
@@ -558,7 +558,7 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
558
558
  },
559
559
  fetchCompletedTransactionsFailure(draft, action) {
560
560
  const periodId = (0, timePeriod_1.toMonthYearPeriodId)(action.payload.selectedPeriod);
561
- const cacheKey = (0, exports.getCompletedTransactionsCacheKey)(periodId, action.payload.sortKey, action.payload.sortOrder, action.payload.completedSubTab);
561
+ const cacheKey = (0, exports.getCompletedTransactionsCacheKey)(periodId, draft.bulkUpload.sortKey, draft.bulkUpload.sortOrder, draft.bulkUpload.completedSubTab);
562
562
  const existing = draft.bulkUpload.completedTransactionsByPeriod[cacheKey];
563
563
  if (existing != null) {
564
564
  existing.fetchState = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.3-betaVR10",
3
+ "version": "5.0.4-beta0ND",
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",