@zeniai/client-epic-state 5.0.65-betaML2 → 5.0.65-betaRR2

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 (121) hide show
  1. package/lib/common/aiCfo/aiCfoSuggestedQuestionsPageContext.d.ts +1 -1
  2. package/lib/entity/aiCfo/aiCfoPayload.d.ts +168 -1
  3. package/lib/entity/aiCfo/aiCfoReducer.js +186 -2
  4. package/lib/entity/aiCfo/aiCfoState.d.ts +164 -4
  5. package/lib/entity/aiCfo/aiCfoState.js +10 -1
  6. package/lib/entity/cardPolicy/cardPolicyPayload.d.ts +171 -0
  7. package/lib/entity/cardPolicy/cardPolicyPayload.js +112 -0
  8. package/lib/entity/cardPolicy/cardPolicyReducer.d.ts +13 -0
  9. package/lib/entity/cardPolicy/cardPolicyReducer.js +203 -0
  10. package/lib/entity/cardPolicy/cardPolicySelector.d.ts +28 -0
  11. package/lib/entity/cardPolicy/cardPolicySelector.js +86 -0
  12. package/lib/entity/cardPolicy/cardPolicyState.d.ts +162 -0
  13. package/lib/entity/cardPolicy/cardPolicyState.js +14 -0
  14. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.d.ts +18 -0
  15. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.js +54 -0
  16. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.d.ts +26 -0
  17. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +47 -0
  18. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -1
  19. package/lib/entity/monthEndCloseChecks/monthEndCloseChecksState.d.ts +1 -1
  20. package/lib/entity/tenant/clearAllEpic.d.ts +6 -2
  21. package/lib/entity/tenant/clearAllEpic.js +8 -0
  22. package/lib/epic.d.ts +9 -2
  23. package/lib/epic.js +9 -2
  24. package/lib/esm/entity/aiCfo/aiCfoReducer.js +187 -3
  25. package/lib/esm/entity/aiCfo/aiCfoState.js +7 -0
  26. package/lib/esm/entity/cardPolicy/cardPolicyPayload.js +101 -0
  27. package/lib/esm/entity/cardPolicy/cardPolicyReducer.js +199 -0
  28. package/lib/esm/entity/cardPolicy/cardPolicySelector.js +66 -0
  29. package/lib/esm/entity/cardPolicy/cardPolicyState.js +9 -0
  30. package/lib/esm/entity/cardPolicy/extractPolicyDocumentEpic.js +50 -0
  31. package/lib/esm/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +43 -0
  32. package/lib/esm/entity/tenant/clearAllEpic.js +8 -0
  33. package/lib/esm/epic.js +9 -2
  34. package/lib/esm/index.js +21 -7
  35. package/lib/esm/reducer.js +12 -0
  36. package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +1 -21
  37. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +14 -117
  38. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +0 -28
  39. package/lib/esm/view/recommendation/recommendationHelper.js +0 -29
  40. package/lib/esm/view/recommendation/recommendationReducer.js +1 -36
  41. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +70 -0
  42. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +22 -0
  43. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +1 -0
  44. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +44 -0
  45. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +49 -0
  46. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +42 -0
  47. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +72 -0
  48. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +21 -0
  49. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +1 -0
  50. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +46 -0
  51. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +50 -0
  52. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +6 -0
  53. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +1 -0
  54. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +34 -0
  55. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +17 -0
  56. package/lib/esm/view/transactionDetail/transactionDetailReducer.js +1 -110
  57. package/lib/esm/view/transactionDetail/transactionDetailSelector.js +0 -22
  58. package/lib/index.d.ts +20 -8
  59. package/lib/index.js +119 -35
  60. package/lib/reducer.d.ts +12 -0
  61. package/lib/reducer.js +12 -0
  62. package/lib/view/companyHealthMetricView/companyHealthMetricViewSelector.d.ts +1 -1
  63. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +0 -1
  64. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -23
  65. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +1 -14
  66. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +14 -117
  67. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +0 -2
  68. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +0 -3
  69. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +0 -29
  70. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +1 -1
  71. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +2 -2
  72. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -2
  73. package/lib/view/onboardingView/cockpitView/types/onboardingCockpitViewTypes.d.ts +1 -1
  74. package/lib/view/people/peopleTypes.d.ts +1 -1
  75. package/lib/view/recommendation/recommendationHelper.d.ts +0 -9
  76. package/lib/view/recommendation/recommendationHelper.js +1 -31
  77. package/lib/view/recommendation/recommendationReducer.d.ts +1 -18
  78. package/lib/view/recommendation/recommendationReducer.js +2 -37
  79. package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
  80. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.d.ts +14 -0
  81. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +74 -0
  82. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.d.ts +21 -0
  83. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +28 -0
  84. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.d.ts +25 -0
  85. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +2 -0
  86. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.d.ts +19 -0
  87. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +48 -0
  88. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.d.ts +18 -0
  89. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +53 -0
  90. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.d.ts +16 -0
  91. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +46 -0
  92. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.d.ts +15 -0
  93. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +76 -0
  94. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.d.ts +21 -0
  95. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +27 -0
  96. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.d.ts +19 -0
  97. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +2 -0
  98. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.d.ts +19 -0
  99. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +50 -0
  100. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.d.ts +12 -0
  101. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +54 -0
  102. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +4 -0
  103. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +10 -0
  104. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +15 -0
  105. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +2 -0
  106. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.d.ts +8 -0
  107. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +38 -0
  108. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.d.ts +15 -0
  109. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +21 -0
  110. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  111. package/lib/view/taskManager/taskListView/taskListReducer.d.ts +1 -1
  112. package/lib/view/transactionDetail/transactionDetailReducer.d.ts +1 -11
  113. package/lib/view/transactionDetail/transactionDetailReducer.js +2 -111
  114. package/lib/view/transactionDetail/transactionDetailSelector.d.ts +0 -2
  115. package/lib/view/transactionDetail/transactionDetailSelector.js +1 -24
  116. package/lib/view/transactionDetail/transactionDetailTypes.d.ts +0 -1
  117. package/package.json +1 -1
  118. package/lib/esm/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -88
  119. package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
  120. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.d.ts +0 -9
  121. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -92
@@ -1,88 +0,0 @@
1
- import { concat, of, timer } from 'rxjs';
2
- import { catchError, debounce, filter, groupBy, mergeMap, switchMap, } from 'rxjs/operators';
3
- import { getIsAccountingClassesEnabled } from '../../entity/tenant/tenantSelector';
4
- import { getTransactionWithCOT, getTransactionWithCOTFromRecommendations, } from '../../entity/transaction/transactionHelper';
5
- import { createZeniAPIStatus, isSuccessResponse } from '../../responsePayload';
6
- import { getUncategorizedAccounts } from '../accountList/accountListSelector';
7
- import { markCategoryClassRecommendationsCompletedForCategorization, markCategoryClassRecommendationsFailureForCategorization, markCategoryClassRecommendationsInProgressForCategorization, setEntityRecommendationForLineIdsForCategorization, } from '../expenseAutomationView/reducers/transactionsViewReducer';
8
- import { markCategoryClassRecommendationsCompletedForTransactionDetail, markCategoryClassRecommendationsFailureForTransactionDetail, markCategoryClassRecommendationsInProgressForTransactionDetail, setEntityRecommendationForLineIdsForTransactionDetail, } from '../transactionDetail/transactionDetailReducer';
9
- import { buildRecommendationUrl, getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT, } from './recommendationHelper';
10
- import { fetchEntityRecommendationsForLineUpdate } from './recommendationReducer';
11
- // Close the per-target groupBy bucket after this much idle time so inactive
12
- // groups don't accumulate forever (each group holds a Subject + a chain of
13
- // active subscribers; without a duration selector groupBy retains them for
14
- // the lifetime of the source observable, which is the lifetime of the app).
15
- // Picked at 60s to leave a generous window for re-fetches on the same
16
- // payee/transaction/line target while still bounding memory.
17
- const GROUP_INACTIVITY_TIMEOUT_MS = 60000;
18
- // Build the groupBy key. Same flow + same transaction + same line set
19
- // share a target so switchMap can cancel an in-flight prior fetch. Use
20
- // NUL (\u0000) as separator because it can never appear in transaction
21
- // or line ids (vs the `|` used in an earlier WIP which collides with
22
- // pipe-delimited synthetic ids).
23
- const SEPARATOR = '\u0000';
24
- const toGroupKey = (flowType, transactionId, lineIds) => `${flowType}${SEPARATOR}${transactionId}${SEPARATOR}${[...lineIds]
25
- .sort((a, b) => a.localeCompare(b))
26
- .join(SEPARATOR)}`;
27
- // Targeted recommendations fetch that drives the per-line skeleton, the
28
- // list-page row-checkbox uncheck/recheck, and the page-level Save
29
- // disable.
30
- //
31
- // Concurrency model:
32
- // - groupBy by (flowType, transactionId, sorted lineIds) so distinct
33
- // targets run in parallel.
34
- // - inside each group, switchMap so a re-fetch on the SAME target
35
- // cancels any prior in-flight request for that target.
36
- // - groupBy duration selector closes idle groups to bound memory.
37
- export const fetchEntityRecommendationsForLineUpdateEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchEntityRecommendationsForLineUpdate.match), groupBy((action) => toGroupKey(action.payload.flowType, action.payload.transactionDetails.transactionId.id, action.payload.transactionDetails.lineIds), undefined, (group$) => group$.pipe(debounce(() => timer(GROUP_INACTIVITY_TIMEOUT_MS)))), mergeMap((group$) => group$.pipe(switchMap((action) => {
38
- const { entity, amount, transactionDetails, flowType, selectedTab, isFetchCOT, isUncategorizedExpenseCategoryEnabled, } = action.payload;
39
- const { transactionId, transaction, lineIds } = transactionDetails;
40
- // Synchronously emit the start arm so the per-line skeleton +
41
- // row uncheck happen before the HTTP request begins.
42
- const startAction = flowType === 'categorization' && selectedTab != null
43
- ? markCategoryClassRecommendationsInProgressForCategorization(selectedTab, transactionId, lineIds)
44
- : markCategoryClassRecommendationsInProgressForTransactionDetail(transactionId, lineIds);
45
- // TEMP-LOG[JE-skeleton]: epic dispatch payload — confirms the
46
- // targeted-fetch fired with the expected flowType / txnId / lineIds.
47
- // eslint-disable-next-line no-console
48
- console.log('[JE-skeleton][epic] dispatch start arm', {
49
- flowType,
50
- selectedTab,
51
- transactionId,
52
- lineIds,
53
- transactionType: transaction?.type,
54
- });
55
- const url = buildRecommendationUrl(zeniAPI.apiEndPoints.accountMicroServiceBaseUrl, entity, amount, transactionDetails, isFetchCOT === true);
56
- const httpStream$ = zeniAPI
57
- .getJSON(url)
58
- .pipe(mergeMap((response) => {
59
- if (!isSuccessResponse(response) || response.data == null) {
60
- return of(flowType === 'categorization' && selectedTab != null
61
- ? markCategoryClassRecommendationsFailureForCategorization(selectedTab, transactionId, lineIds, response.status)
62
- : markCategoryClassRecommendationsFailureForTransactionDetail(transactionId, lineIds, response.status));
63
- }
64
- const recommendationWithCOTByLineId = getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT(response.data.recommendations, lineIds);
65
- // HTTP 200 with no per-line recommendations: NOT an error.
66
- // Flip lines to Completed so the skeleton resolves and
67
- // downstream UI can treat this as "we tried, nothing to
68
- // apply".
69
- if (recommendationWithCOTByLineId == null) {
70
- return of(flowType === 'categorization' && selectedTab != null
71
- ? markCategoryClassRecommendationsCompletedForCategorization(selectedTab, transactionId, lineIds)
72
- : markCategoryClassRecommendationsCompletedForTransactionDetail(transactionId, lineIds));
73
- }
74
- const transactionWithCOT = isFetchCOT === true
75
- ? getTransactionWithCOTFromRecommendations(transaction, recommendationWithCOTByLineId)
76
- : getTransactionWithCOT(transaction);
77
- const uncategorizedIncomeExpense = getUncategorizedAccounts(state$.value.accountState, state$.value.accountListState, 'accountList');
78
- if (flowType === 'categorization' && selectedTab != null) {
79
- return of(setEntityRecommendationForLineIdsForCategorization(selectedTab, transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense, isUncategorizedExpenseCategoryEnabled, getIsAccountingClassesEnabled(state$.value)));
80
- }
81
- return of(setEntityRecommendationForLineIdsForTransactionDetail(transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense));
82
- }), catchError((error) => of(flowType === 'categorization' && selectedTab != null
83
- ? markCategoryClassRecommendationsFailureForCategorization(selectedTab, transactionId, lineIds, createZeniAPIStatus('Unexpected Error', 'fetchEntityRecommendationsForLineUpdate failed: ' +
84
- JSON.stringify(error)))
85
- : markCategoryClassRecommendationsFailureForTransactionDetail(transactionId, lineIds, createZeniAPIStatus('Unexpected Error', 'fetchEntityRecommendationsForLineUpdate failed: ' +
86
- JSON.stringify(error))))));
87
- return concat(of(startAction), httpStream$);
88
- }))));