@zeniai/client-epic-state 5.0.81-betaML5 → 5.0.81-betaRR08

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 (76) hide show
  1. package/lib/commonStateTypes/viewAndReport/viewAndReport.d.ts +2 -2
  2. package/lib/commonStateTypes/viewAndReport/viewAndReport.js +0 -2
  3. package/lib/entity/account/accountSelector.d.ts +0 -9
  4. package/lib/entity/account/accountSelector.js +1 -14
  5. package/lib/entity/account/accountState.d.ts +1 -1
  6. package/lib/entity/accountGroup/accountGroupState.d.ts +1 -1
  7. package/lib/entity/class/classReducer.d.ts +4 -4
  8. package/lib/entity/class/classState.d.ts +1 -1
  9. package/lib/entity/forecast/forecastState.d.ts +1 -1
  10. package/lib/entity/sectionAccountsView/sectionAccountsView.d.ts +1 -1
  11. package/lib/entity/sectionClassesViewV2/sectionClassesView.d.ts +1 -1
  12. package/lib/entity/sectionClassesViewV2/sectionClassesViewReducer.d.ts +2 -2
  13. package/lib/entity/sectionProjectView/sectionProjectView.d.ts +1 -1
  14. package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +2 -2
  15. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  16. package/lib/entity/snackbar/snackbarTypes.js +0 -1
  17. package/lib/entity/tenant/clearAllEpic.d.ts +1 -2
  18. package/lib/entity/tenant/clearAllEpic.js +0 -2
  19. package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +0 -4
  20. package/lib/entity/transaction/payloadTypes/transactionPayload.js +10 -18
  21. package/lib/entity/transaction/stateTypes/transaction.d.ts +0 -3
  22. package/lib/epic.d.ts +1 -3
  23. package/lib/epic.js +1 -3
  24. package/lib/esm/commonStateTypes/viewAndReport/viewAndReport.js +0 -2
  25. package/lib/esm/entity/account/accountSelector.js +0 -11
  26. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -1
  27. package/lib/esm/entity/tenant/clearAllEpic.js +0 -2
  28. package/lib/esm/entity/transaction/payloadTypes/transactionPayload.js +10 -18
  29. package/lib/esm/epic.js +1 -3
  30. package/lib/esm/index.js +4 -5
  31. package/lib/esm/reducer.js +0 -3
  32. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +1 -13
  33. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +1 -9
  34. package/lib/esm/view/transactionDetail/transactionDetailSelector.js +1 -6
  35. package/lib/index.d.ts +4 -5
  36. package/lib/index.js +33 -43
  37. package/lib/reducer.d.ts +0 -3
  38. package/lib/reducer.js +0 -3
  39. package/lib/view/auditReportView/auditReportViewState.d.ts +1 -1
  40. package/lib/view/billPayCard/billPayCardSelector.d.ts +1 -1
  41. package/lib/view/cardBalance/cardBalanceSelector.d.ts +1 -1
  42. package/lib/view/cashBalance/cashBalanceSelector.d.ts +1 -1
  43. package/lib/view/cashInCashOut/cashInCashOutSelector.d.ts +1 -1
  44. package/lib/view/cashPosition/cashPositionSelector.d.ts +1 -1
  45. package/lib/view/dashboard/dashboardReducer.d.ts +2 -2
  46. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  47. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +1 -3
  48. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +2 -14
  49. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +1 -4
  50. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +0 -1
  51. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -11
  52. package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
  53. package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
  54. package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
  55. package/lib/view/reportsResync/reportsResyncReducer.d.ts +2 -2
  56. package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
  57. package/lib/view/topEx/topExSelector.d.ts +1 -1
  58. package/lib/view/transactionDetail/transactionDetailPayload.d.ts +1 -1
  59. package/lib/view/transactionDetail/transactionDetailSelector.d.ts +1 -6
  60. package/lib/view/transactionDetail/transactionDetailSelector.js +1 -6
  61. package/package.json +1 -1
  62. package/lib/esm/view/createTransferEntry/createTransferEntryReducer.js +0 -82
  63. package/lib/esm/view/createTransferEntry/createTransferEntrySelector.js +0 -64
  64. package/lib/esm/view/createTransferEntry/createTransferEntryState.js +0 -17
  65. package/lib/esm/view/createTransferEntry/epics/createTransferEntryEpic.js +0 -130
  66. package/lib/esm/view/createTransferEntry/epics/fetchTransferAccountsEpic.js +0 -37
  67. package/lib/view/createTransferEntry/createTransferEntryReducer.d.ts +0 -32
  68. package/lib/view/createTransferEntry/createTransferEntryReducer.js +0 -86
  69. package/lib/view/createTransferEntry/createTransferEntrySelector.d.ts +0 -39
  70. package/lib/view/createTransferEntry/createTransferEntrySelector.js +0 -69
  71. package/lib/view/createTransferEntry/createTransferEntryState.d.ts +0 -30
  72. package/lib/view/createTransferEntry/createTransferEntryState.js +0 -20
  73. package/lib/view/createTransferEntry/epics/createTransferEntryEpic.d.ts +0 -11
  74. package/lib/view/createTransferEntry/epics/createTransferEntryEpic.js +0 -134
  75. package/lib/view/createTransferEntry/epics/fetchTransferAccountsEpic.d.ts +0 -14
  76. package/lib/view/createTransferEntry/epics/fetchTransferAccountsEpic.js +0 -41
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initialCreateTransferEntryState = exports.TRANSFER_ACCOUNTS_FETCH_TYPE = void 0;
4
- /** Which pool `fetchAccountsForTransferFlow` / transfer-flow epic should load. */
5
- exports.TRANSFER_ACCOUNTS_FETCH_TYPE = [
6
- 'transferEntryEligible',
7
- 'creditCardOnlyEligible',
8
- ];
9
- const initialTransferAccountsState = {
10
- accountIds: [],
11
- fetchState: 'Not-Started',
12
- };
13
- exports.initialCreateTransferEntryState = {
14
- createTransferEntryStatus: 'Not-Started',
15
- lastTransferEntryReplacement: undefined,
16
- transferAccountsByType: {
17
- transferEntryEligible: initialTransferAccountsState,
18
- creditCardOnlyEligible: initialTransferAccountsState,
19
- },
20
- };
@@ -1,11 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
4
- import { removeTransaction, updateTransaction } from '../../../entity/transaction/transactionReducer';
5
- import { RootState } from '../../../reducer';
6
- import { ZeniAPI } from '../../../zeniAPI';
7
- import { removeTransactionFromAllTabs } from '../../expenseAutomationView/reducers/transactionsViewReducer';
8
- import { initializeTransactionDetailLocalData, removeTransactionDetail } from '../../transactionDetail/transactionDetailReducer';
9
- import { clearTransferEntryRouteReplacement, createTransferEntry, createTransferEntryFailure, createTransferEntryReplacedTransaction, createTransferEntrySuccess, resetCreateTransferEntryStatus } from '../createTransferEntryReducer';
10
- export type ActionType = ReturnType<typeof openSnackbar> | ReturnType<typeof createTransferEntry> | ReturnType<typeof createTransferEntrySuccess> | ReturnType<typeof createTransferEntryFailure> | ReturnType<typeof removeTransactionFromAllTabs> | ReturnType<typeof resetCreateTransferEntryStatus> | ReturnType<typeof createTransferEntryReplacedTransaction> | ReturnType<typeof clearTransferEntryRouteReplacement> | ReturnType<typeof updateTransaction> | ReturnType<typeof initializeTransactionDetailLocalData> | ReturnType<typeof removeTransaction> | ReturnType<typeof removeTransactionDetail>;
11
- export declare const createTransferEntryEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,134 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTransferEntryEpic = 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 transactionIDPayload_1 = require("../../../entity/transaction/payloadTypes/transactionIDPayload");
8
- const transactionReducer_1 = require("../../../entity/transaction/transactionReducer");
9
- const responsePayload_1 = require("../../../responsePayload");
10
- const transactionsViewReducer_1 = require("../../expenseAutomationView/reducers/transactionsViewReducer");
11
- const transactionDetailReducer_1 = require("../../transactionDetail/transactionDetailReducer");
12
- const transactionDetailState_1 = require("../../transactionDetail/transactionDetailState");
13
- const createTransferEntryReducer_1 = require("../createTransferEntryReducer");
14
- // ─── Pure helpers ────────────────────────────────────────────────────────────
15
- function transactionIdsAreEqual(a, b) {
16
- return a.id === b.id && a.type === b.type;
17
- }
18
- const successSnackbar = () => (0, snackbarReducer_1.openSnackbar)({
19
- messageSection: 'create_transfer_entry',
20
- messageText: 'success',
21
- type: 'success',
22
- });
23
- const failureSnackbar = () => (0, snackbarReducer_1.openSnackbar)({
24
- messageSection: 'create_transfer_entry',
25
- messageText: 'failed',
26
- type: 'error',
27
- });
28
- function buildFailureActions() {
29
- return [(0, createTransferEntryReducer_1.createTransferEntryFailure)(), failureSnackbar()];
30
- }
31
- /**
32
- * Defensive guard: a BE response that returns 200 with `transaction != null`
33
- * but where the body lacks a usable id/type is unsafe to seed into the store —
34
- * downstream code would store under a garbage key and the host hook would try
35
- * to navigate to a broken url. Treat that case as failure so the source row
36
- * stays visible and the user can retry.
37
- */
38
- function isWellFormedTransactionPayload(t) {
39
- return (t != null &&
40
- typeof t.transaction_id === 'string' &&
41
- t.transaction_id !== '' &&
42
- typeof t.transaction_type === 'string' &&
43
- t.transaction_type !== '');
44
- }
45
- function buildSuccessSideEffects(sourceTransactionId) {
46
- return [
47
- (0, createTransferEntryReducer_1.createTransferEntrySuccess)(),
48
- (0, transactionsViewReducer_1.removeTransactionFromAllTabs)(sourceTransactionId),
49
- successSnackbar(),
50
- ];
51
- }
52
- function buildPreviousTransactionCleanupActions(previousTransactionId) {
53
- return [
54
- (0, transactionReducer_1.removeTransaction)((0, transactionDetailState_1.getTransactionDetailKey)(previousTransactionId)),
55
- (0, transactionDetailReducer_1.removeTransactionDetail)(previousTransactionId),
56
- (0, createTransferEntryReducer_1.clearTransferEntryRouteReplacement)(),
57
- ];
58
- }
59
- /**
60
- * Emits `resetCreateTransferEntryStatus()` (and, on the replacement path, the
61
- * follow-up cleanup actions) one scheduler tick after the success actions.
62
- *
63
- * Why the `timer(0)` (and not synchronous emission):
64
- * On the replacement path the host (web-app-ui) watches
65
- * `lastTransferEntryReplacement`, navigates to the new transaction url, and
66
- * then sees `clearTransferEntryRouteReplacement` clear the signal. If we
67
- * dispatched the cleanup actions in the same tick as
68
- * `createTransferEntryReplacedTransaction`, redux subscribers would observe
69
- * `lastTransferEntryReplacement` flicker on then off in a single render, and
70
- * the old transaction's state (which the still-mounted detail view may be
71
- * reading) would be torn down before the host has had a chance to start
72
- * navigating. Deferring by one microtask gives the host exactly one render
73
- * pass to react before we tear down the previous transaction.
74
- */
75
- function delayedResetAndPreviousCleanup(previousTransactionId) {
76
- return (0, rxjs_1.timer)(0).pipe((0, operators_1.mergeMap)(() => {
77
- const actions = [(0, createTransferEntryReducer_1.resetCreateTransferEntryStatus)()];
78
- if (previousTransactionId != null) {
79
- actions.push(...buildPreviousTransactionCleanupActions(previousTransactionId));
80
- }
81
- return (0, rxjs_1.from)(actions);
82
- }));
83
- }
84
- // ─── Success-path branches ───────────────────────────────────────────────────
85
- function handleSuccessWithoutTransactionBody(transactionId) {
86
- return (0, rxjs_1.concat)((0, rxjs_1.from)(buildSuccessSideEffects(transactionId)), delayedResetAndPreviousCleanup(undefined));
87
- }
88
- function handleSuccessWithTransactionBody(transactionPayload, vendorPayload, previousTransactionId, sourceTransactionId) {
89
- const newTransactionId = (0, transactionIDPayload_1.toTransactionID)(transactionPayload);
90
- const replaced = !transactionIdsAreEqual(previousTransactionId, newTransactionId);
91
- const immediate = [
92
- (0, transactionReducer_1.updateTransaction)((0, transactionDetailState_1.getTransactionDetailKey)(newTransactionId), transactionPayload),
93
- (0, transactionDetailReducer_1.initializeTransactionDetailLocalData)({
94
- transactionId: newTransactionId,
95
- vendorId: vendorPayload?.[0]?.vendor_id,
96
- }),
97
- ...buildSuccessSideEffects(sourceTransactionId),
98
- ];
99
- if (replaced) {
100
- immediate.push((0, createTransferEntryReducer_1.createTransferEntryReplacedTransaction)(previousTransactionId, newTransactionId));
101
- }
102
- return (0, rxjs_1.concat)((0, rxjs_1.from)(immediate), delayedResetAndPreviousCleanup(replaced ? previousTransactionId : undefined));
103
- }
104
- // ─── Top-level epic ──────────────────────────────────────────────────────────
105
- const createTransferEntryEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(createTransferEntryReducer_1.createTransferEntry.match), (0, operators_1.mergeMap)((action) => {
106
- const { transactionId, creditAccountIntegrationId, debitAccountIntegrationId, memo, transactionType, sourceTransactionType, } = action.payload;
107
- const previousTransactionId = {
108
- id: transactionId,
109
- type: sourceTransactionType,
110
- };
111
- const payload = {
112
- transaction_type: transactionType,
113
- transaction_id: transactionId,
114
- to_account_integration_id: creditAccountIntegrationId,
115
- from_account_integration_id: debitAccountIntegrationId,
116
- memo,
117
- };
118
- return zeniAPI
119
- .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/transaction-type-update`, payload)
120
- .pipe((0, operators_1.mergeMap)((response) => {
121
- if (!(0, responsePayload_1.isSuccessResponse)(response)) {
122
- return (0, rxjs_1.from)(buildFailureActions());
123
- }
124
- const transaction = response.data?.transaction;
125
- if (transaction != null) {
126
- if (!isWellFormedTransactionPayload(transaction)) {
127
- return (0, rxjs_1.from)(buildFailureActions());
128
- }
129
- return handleSuccessWithTransactionBody(transaction, response.data?.vendors, previousTransactionId, transactionId);
130
- }
131
- return handleSuccessWithoutTransactionBody(transactionId);
132
- }), (0, operators_1.catchError)(() => (0, rxjs_1.from)(buildFailureActions())));
133
- }));
134
- exports.createTransferEntryEpic = createTransferEntryEpic;
@@ -1,14 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { updateAccounts } from '../../../entity/account/accountReducer';
4
- import { RootState } from '../../../reducer';
5
- import { ZeniAPI } from '../../../zeniAPI';
6
- import { fetchAccountsForTransferFlow, updateAccountsForTransferFlow, updateAccountsForTransferFlowFailure } from '../createTransferEntryReducer';
7
- export type ActionType = ReturnType<typeof fetchAccountsForTransferFlow> | ReturnType<typeof updateAccountsForTransferFlow> | ReturnType<typeof updateAccountsForTransferFlowFailure> | ReturnType<typeof updateAccounts>;
8
- /**
9
- * Pools fetched concurrently: `groupBy(kind)` keeps `transferEntryEligible`
10
- * and `creditCardOnlyEligible` in their own streams so a back-to-back dispatch
11
- * of both does not cancel the first. Within a single type, a fresh dispatch
12
- * supersedes any in-flight request (per-group `switchMap`).
13
- */
14
- export declare const fetchTransferAccountsEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchTransferAccountsEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const accountReducer_1 = require("../../../entity/account/accountReducer");
7
- const responsePayload_1 = require("../../../responsePayload");
8
- const createTransferEntryReducer_1 = require("../createTransferEntryReducer");
9
- const REPORT_ID_BY_TYPE = {
10
- transferEntryEligible: 'transfer_accounts',
11
- creditCardOnlyEligible: 'credit_card_transfer_accounts',
12
- };
13
- const QUERY_BY_TYPE = {
14
- transferEntryEligible: { is_only_include_transfer_accounts: true },
15
- creditCardOnlyEligible: { is_include_only_credit_card_accounts: true },
16
- };
17
- /**
18
- * Pools fetched concurrently: `groupBy(kind)` keeps `transferEntryEligible`
19
- * and `creditCardOnlyEligible` in their own streams so a back-to-back dispatch
20
- * of both does not cancel the first. Within a single type, a fresh dispatch
21
- * supersedes any in-flight request (per-group `switchMap`).
22
- */
23
- const fetchTransferAccountsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(createTransferEntryReducer_1.fetchAccountsForTransferFlow.match), (0, operators_1.groupBy)((action) => action.payload.kind), (0, operators_1.mergeMap)((group$) => group$.pipe((0, operators_1.switchMap)((action) => {
24
- const { kind } = action.payload;
25
- const queryValue = QUERY_BY_TYPE[kind];
26
- const reportId = REPORT_ID_BY_TYPE[kind];
27
- const url = `https://dev.api.zeni.ai/version/accounting/komal/1.0/accounts?query=${encodeURIComponent(JSON.stringify(queryValue))}`;
28
- // const url = `${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts?query=${encodeURIComponent(JSON.stringify(queryValue))}`;
29
- return zeniAPI.getJSON(url).pipe((0, operators_1.mergeMap)((response) => {
30
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
31
- const accountIds = response.data.accounts.map((account) => account.account_id);
32
- const actions = [
33
- (0, accountReducer_1.updateAccounts)(response.data.accounts, reportId),
34
- (0, createTransferEntryReducer_1.updateAccountsForTransferFlow)({ accountIds, kind }),
35
- ];
36
- return (0, rxjs_1.of)(...actions);
37
- }
38
- return (0, rxjs_1.of)((0, createTransferEntryReducer_1.updateAccountsForTransferFlowFailure)({ kind }));
39
- }), (0, operators_1.catchError)(() => (0, rxjs_1.of)((0, createTransferEntryReducer_1.updateAccountsForTransferFlowFailure)({ kind }))));
40
- }))));
41
- exports.fetchTransferAccountsEpic = fetchTransferAccountsEpic;