@zeniai/client-epic-state 5.1.53-betaRD1 → 5.1.53

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.
@@ -5,7 +5,7 @@ import { getTransactionWithCOT, getTransactionWithCOTFromRecommendations, } from
5
5
  import { createZeniAPIStatus, isSuccessResponse } from '../../responsePayload';
6
6
  import { getUncategorizedAccounts } from '../accountList/accountListSelector';
7
7
  import { markCategoryClassRecommendationsCompletedForCategorization, markCategoryClassRecommendationsFailureForCategorization, markCategoryClassRecommendationsInProgressForCategorization, setEntityRecommendationForLineIdsForCategorization, } from '../expenseAutomationView/reducers/transactionsViewReducer';
8
- import { markCategoryClassRecommendationsCompletedForTransactionDetail, markCategoryClassRecommendationsFailureForTransactionDetail, markCategoryClassRecommendationsInProgressForTransactionDetail, setEntityRecommendationForLineIdsForTransactionDetail, updateVendorBulkRecommendationsFetchStatus, } from '../transactionDetail/transactionDetailReducer';
8
+ import { markCategoryClassRecommendationsCompletedForTransactionDetail, markCategoryClassRecommendationsFailureForTransactionDetail, markCategoryClassRecommendationsInProgressForTransactionDetail, setEntityRecommendationForLineIdsForTransactionDetail, } from '../transactionDetail/transactionDetailReducer';
9
9
  import { buildRecommendationUrl, getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT, } from './recommendationHelper';
10
10
  import { fetchEntityRecommendationsForLineUpdate } from './recommendationReducer';
11
11
  // Close the per-target groupBy bucket after this much idle time so inactive
@@ -38,16 +38,6 @@ export const fetchEntityRecommendationsForLineUpdateEpic = (actions$, state$, ze
38
38
  const payload = action.payload;
39
39
  const { transactionId, transaction, lineIds } = payload.transactionDetails;
40
40
  const { entity, amount, isFetchCOT, isUncategorizedExpenseCategoryEnabled, } = payload;
41
- // The vendor "Update all lines" popup on the detail page watches
42
- // its own transaction-level fetch status, separate from the
43
- // per-line statuses below — surface completion/failure there too
44
- // when this fetch was triggered by that bulk action, or the popup
45
- // hangs until its own 60s timeout regardless of how this request
46
- // resolves.
47
- const isBulkDetailFetch = payload.flowType === 'detail' && payload.isBulkFetch === true;
48
- const emitWithBulkStatus = (primaryAction, bulkAction) => isBulkDetailFetch && bulkAction != null
49
- ? of(primaryAction, bulkAction)
50
- : of(primaryAction);
51
41
  // Synchronously emit the start arm so the per-line skeleton +
52
42
  // row uncheck happen before the HTTP request begins. The
53
43
  // discriminated-union payload narrows `payload.selectedTab` to
@@ -61,9 +51,9 @@ export const fetchEntityRecommendationsForLineUpdateEpic = (actions$, state$, ze
61
51
  .getJSON(url)
62
52
  .pipe(mergeMap((response) => {
63
53
  if (!isSuccessResponse(response) || response.data == null) {
64
- return emitWithBulkStatus(payload.flowType === 'categorization'
54
+ return of(payload.flowType === 'categorization'
65
55
  ? markCategoryClassRecommendationsFailureForCategorization(payload.selectedTab, transactionId, lineIds, response.status)
66
- : markCategoryClassRecommendationsFailureForTransactionDetail(transactionId, lineIds, response.status), updateVendorBulkRecommendationsFetchStatus(transactionId, 'Error', response.status));
56
+ : markCategoryClassRecommendationsFailureForTransactionDetail(transactionId, lineIds, response.status));
67
57
  }
68
58
  const recommendationWithCOTByLineId = getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT(response.data.recommendations, lineIds);
69
59
  // HTTP 200 with no per-line recommendations: NOT an error.
@@ -71,9 +61,9 @@ export const fetchEntityRecommendationsForLineUpdateEpic = (actions$, state$, ze
71
61
  // downstream UI can treat this as "we tried, nothing to
72
62
  // apply".
73
63
  if (recommendationWithCOTByLineId == null) {
74
- return emitWithBulkStatus(payload.flowType === 'categorization'
64
+ return of(payload.flowType === 'categorization'
75
65
  ? markCategoryClassRecommendationsCompletedForCategorization(payload.selectedTab, transactionId, lineIds)
76
- : markCategoryClassRecommendationsCompletedForTransactionDetail(transactionId, lineIds), updateVendorBulkRecommendationsFetchStatus(transactionId, 'Completed'));
66
+ : markCategoryClassRecommendationsCompletedForTransactionDetail(transactionId, lineIds));
77
67
  }
78
68
  const transactionWithCOT = isFetchCOT === true
79
69
  ? getTransactionWithCOTFromRecommendations(transaction, recommendationWithCOTByLineId)
@@ -82,16 +72,16 @@ export const fetchEntityRecommendationsForLineUpdateEpic = (actions$, state$, ze
82
72
  if (payload.flowType === 'categorization') {
83
73
  return of(setEntityRecommendationForLineIdsForCategorization(payload.selectedTab, transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense, isUncategorizedExpenseCategoryEnabled, getIsAccountingClassesEnabled(state$.value)));
84
74
  }
85
- return emitWithBulkStatus(setEntityRecommendationForLineIdsForTransactionDetail(transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense), updateVendorBulkRecommendationsFetchStatus(transactionId, 'Completed'));
75
+ return of(setEntityRecommendationForLineIdsForTransactionDetail(transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense));
86
76
  }), catchError((error) => {
87
77
  const errorMessage = 'fetchEntityRecommendationsForLineUpdate failed: ' +
88
78
  (error instanceof Error
89
79
  ? error.message
90
80
  : JSON.stringify(error));
91
81
  const status = createZeniAPIStatus('Unexpected Error', errorMessage);
92
- return emitWithBulkStatus(payload.flowType === 'categorization'
82
+ return of(payload.flowType === 'categorization'
93
83
  ? markCategoryClassRecommendationsFailureForCategorization(payload.selectedTab, transactionId, lineIds, status)
94
- : markCategoryClassRecommendationsFailureForTransactionDetail(transactionId, lineIds, status), updateVendorBulkRecommendationsFetchStatus(transactionId, 'Error', status));
84
+ : markCategoryClassRecommendationsFailureForTransactionDetail(transactionId, lineIds, status));
95
85
  }));
96
86
  return concat(of(startAction), httpStream$);
97
87
  }))));
@@ -3,7 +3,7 @@ import { Observable } from 'rxjs';
3
3
  import { RootState } from '../../reducer';
4
4
  import { ZeniAPI } from '../../zeniAPI';
5
5
  import { markCategoryClassRecommendationsCompletedForCategorization, markCategoryClassRecommendationsFailureForCategorization, markCategoryClassRecommendationsInProgressForCategorization, setEntityRecommendationForLineIdsForCategorization } from '../expenseAutomationView/reducers/transactionsViewReducer';
6
- import { markCategoryClassRecommendationsCompletedForTransactionDetail, markCategoryClassRecommendationsFailureForTransactionDetail, markCategoryClassRecommendationsInProgressForTransactionDetail, setEntityRecommendationForLineIdsForTransactionDetail, updateVendorBulkRecommendationsFetchStatus } from '../transactionDetail/transactionDetailReducer';
6
+ import { markCategoryClassRecommendationsCompletedForTransactionDetail, markCategoryClassRecommendationsFailureForTransactionDetail, markCategoryClassRecommendationsInProgressForTransactionDetail, setEntityRecommendationForLineIdsForTransactionDetail } from '../transactionDetail/transactionDetailReducer';
7
7
  import { fetchEntityRecommendationsForLineUpdate } from './recommendationReducer';
8
- export type ActionType = ReturnType<typeof fetchEntityRecommendationsForLineUpdate> | ReturnType<typeof markCategoryClassRecommendationsInProgressForCategorization> | ReturnType<typeof markCategoryClassRecommendationsCompletedForCategorization> | ReturnType<typeof markCategoryClassRecommendationsFailureForCategorization> | ReturnType<typeof markCategoryClassRecommendationsInProgressForTransactionDetail> | ReturnType<typeof markCategoryClassRecommendationsCompletedForTransactionDetail> | ReturnType<typeof markCategoryClassRecommendationsFailureForTransactionDetail> | ReturnType<typeof setEntityRecommendationForLineIdsForCategorization> | ReturnType<typeof setEntityRecommendationForLineIdsForTransactionDetail> | ReturnType<typeof updateVendorBulkRecommendationsFetchStatus>;
8
+ export type ActionType = ReturnType<typeof fetchEntityRecommendationsForLineUpdate> | ReturnType<typeof markCategoryClassRecommendationsInProgressForCategorization> | ReturnType<typeof markCategoryClassRecommendationsCompletedForCategorization> | ReturnType<typeof markCategoryClassRecommendationsFailureForCategorization> | ReturnType<typeof markCategoryClassRecommendationsInProgressForTransactionDetail> | ReturnType<typeof markCategoryClassRecommendationsCompletedForTransactionDetail> | ReturnType<typeof markCategoryClassRecommendationsFailureForTransactionDetail> | ReturnType<typeof setEntityRecommendationForLineIdsForCategorization> | ReturnType<typeof setEntityRecommendationForLineIdsForTransactionDetail>;
9
9
  export declare const fetchEntityRecommendationsForLineUpdateEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -41,16 +41,6 @@ const fetchEntityRecommendationsForLineUpdateEpic = (actions$, state$, zeniAPI)
41
41
  const payload = action.payload;
42
42
  const { transactionId, transaction, lineIds } = payload.transactionDetails;
43
43
  const { entity, amount, isFetchCOT, isUncategorizedExpenseCategoryEnabled, } = payload;
44
- // The vendor "Update all lines" popup on the detail page watches
45
- // its own transaction-level fetch status, separate from the
46
- // per-line statuses below — surface completion/failure there too
47
- // when this fetch was triggered by that bulk action, or the popup
48
- // hangs until its own 60s timeout regardless of how this request
49
- // resolves.
50
- const isBulkDetailFetch = payload.flowType === 'detail' && payload.isBulkFetch === true;
51
- const emitWithBulkStatus = (primaryAction, bulkAction) => isBulkDetailFetch && bulkAction != null
52
- ? (0, rxjs_1.of)(primaryAction, bulkAction)
53
- : (0, rxjs_1.of)(primaryAction);
54
44
  // Synchronously emit the start arm so the per-line skeleton +
55
45
  // row uncheck happen before the HTTP request begins. The
56
46
  // discriminated-union payload narrows `payload.selectedTab` to
@@ -64,9 +54,9 @@ const fetchEntityRecommendationsForLineUpdateEpic = (actions$, state$, zeniAPI)
64
54
  .getJSON(url)
65
55
  .pipe((0, operators_1.mergeMap)((response) => {
66
56
  if (!(0, responsePayload_1.isSuccessResponse)(response) || response.data == null) {
67
- return emitWithBulkStatus(payload.flowType === 'categorization'
57
+ return (0, rxjs_1.of)(payload.flowType === 'categorization'
68
58
  ? (0, transactionsViewReducer_1.markCategoryClassRecommendationsFailureForCategorization)(payload.selectedTab, transactionId, lineIds, response.status)
69
- : (0, transactionDetailReducer_1.markCategoryClassRecommendationsFailureForTransactionDetail)(transactionId, lineIds, response.status), (0, transactionDetailReducer_1.updateVendorBulkRecommendationsFetchStatus)(transactionId, 'Error', response.status));
59
+ : (0, transactionDetailReducer_1.markCategoryClassRecommendationsFailureForTransactionDetail)(transactionId, lineIds, response.status));
70
60
  }
71
61
  const recommendationWithCOTByLineId = (0, recommendationHelper_1.getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT)(response.data.recommendations, lineIds);
72
62
  // HTTP 200 with no per-line recommendations: NOT an error.
@@ -74,9 +64,9 @@ const fetchEntityRecommendationsForLineUpdateEpic = (actions$, state$, zeniAPI)
74
64
  // downstream UI can treat this as "we tried, nothing to
75
65
  // apply".
76
66
  if (recommendationWithCOTByLineId == null) {
77
- return emitWithBulkStatus(payload.flowType === 'categorization'
67
+ return (0, rxjs_1.of)(payload.flowType === 'categorization'
78
68
  ? (0, transactionsViewReducer_1.markCategoryClassRecommendationsCompletedForCategorization)(payload.selectedTab, transactionId, lineIds)
79
- : (0, transactionDetailReducer_1.markCategoryClassRecommendationsCompletedForTransactionDetail)(transactionId, lineIds), (0, transactionDetailReducer_1.updateVendorBulkRecommendationsFetchStatus)(transactionId, 'Completed'));
69
+ : (0, transactionDetailReducer_1.markCategoryClassRecommendationsCompletedForTransactionDetail)(transactionId, lineIds));
80
70
  }
81
71
  const transactionWithCOT = isFetchCOT === true
82
72
  ? (0, transactionHelper_1.getTransactionWithCOTFromRecommendations)(transaction, recommendationWithCOTByLineId)
@@ -85,16 +75,16 @@ const fetchEntityRecommendationsForLineUpdateEpic = (actions$, state$, zeniAPI)
85
75
  if (payload.flowType === 'categorization') {
86
76
  return (0, rxjs_1.of)((0, transactionsViewReducer_1.setEntityRecommendationForLineIdsForCategorization)(payload.selectedTab, transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense, isUncategorizedExpenseCategoryEnabled, (0, tenantSelector_1.getIsAccountingClassesEnabled)(state$.value)));
87
77
  }
88
- return emitWithBulkStatus((0, transactionDetailReducer_1.setEntityRecommendationForLineIdsForTransactionDetail)(transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense), (0, transactionDetailReducer_1.updateVendorBulkRecommendationsFetchStatus)(transactionId, 'Completed'));
78
+ return (0, rxjs_1.of)((0, transactionDetailReducer_1.setEntityRecommendationForLineIdsForTransactionDetail)(transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense));
89
79
  }), (0, operators_1.catchError)((error) => {
90
80
  const errorMessage = 'fetchEntityRecommendationsForLineUpdate failed: ' +
91
81
  (error instanceof Error
92
82
  ? error.message
93
83
  : JSON.stringify(error));
94
84
  const status = (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', errorMessage);
95
- return emitWithBulkStatus(payload.flowType === 'categorization'
85
+ return (0, rxjs_1.of)(payload.flowType === 'categorization'
96
86
  ? (0, transactionsViewReducer_1.markCategoryClassRecommendationsFailureForCategorization)(payload.selectedTab, transactionId, lineIds, status)
97
- : (0, transactionDetailReducer_1.markCategoryClassRecommendationsFailureForTransactionDetail)(transactionId, lineIds, status), (0, transactionDetailReducer_1.updateVendorBulkRecommendationsFetchStatus)(transactionId, 'Error', status));
87
+ : (0, transactionDetailReducer_1.markCategoryClassRecommendationsFailureForTransactionDetail)(transactionId, lineIds, status));
98
88
  }));
99
89
  return (0, rxjs_1.concat)((0, rxjs_1.of)(startAction), httpStream$);
100
90
  }))));
@@ -15,7 +15,6 @@ type FetchEntityRecommendationsForLineUpdateCommonPayload = {
15
15
  transaction: SupportedTransaction;
16
16
  transactionId: TransactionID;
17
17
  };
18
- isBulkFetch?: boolean;
19
18
  isFetchCOT?: boolean;
20
19
  isUncategorizedExpenseCategoryEnabled?: boolean;
21
20
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.1.53-betaRD1",
3
+ "version": "5.1.53",
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",