@zeniai/client-epic-state 5.0.81-betaML1 → 5.0.81-betaML3
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.
- package/lib/esm/view/createTransferEntry/createTransferEntryReducer.js +12 -2
- package/lib/esm/view/createTransferEntry/epics/createTransferEntryEpic.js +4 -4
- package/lib/esm/view/createTransferEntry/epics/fetchTransferAccountsEpic.js +1 -0
- package/lib/esm/view/transactionDetail/epics/transactionDetailEpic.js +1 -1
- package/lib/view/createTransferEntry/createTransferEntryReducer.js +12 -2
- package/lib/view/createTransferEntry/epics/createTransferEntryEpic.js +4 -4
- package/lib/view/createTransferEntry/epics/fetchTransferAccountsEpic.js +1 -0
- package/lib/view/transactionDetail/epics/transactionDetailEpic.js +1 -1
- package/package.json +1 -1
|
@@ -6,8 +6,18 @@ const createTransferEntrySlice = createSlice({
|
|
|
6
6
|
initialState,
|
|
7
7
|
reducers: {
|
|
8
8
|
fetchAccountsForTransferFlow(draft, action) {
|
|
9
|
-
draft.transferAccountsByType[action.payload.kind]
|
|
10
|
-
|
|
9
|
+
const slice = draft.transferAccountsByType[action.payload.kind];
|
|
10
|
+
// Idempotent: a duplicate dispatch must not briefly downgrade
|
|
11
|
+
// 'Completed' back to 'In-Progress' (would clear loaded data from a
|
|
12
|
+
// consumer's perspective) nor restart the in-flight epic stream.
|
|
13
|
+
// The hook (`useFetchTransferAccountsForFlow`) is the sole caller and
|
|
14
|
+
// already dedupes via `store.getState()`; this guard is defense in
|
|
15
|
+
// depth for any future caller.
|
|
16
|
+
if (slice.fetchState === 'In-Progress' ||
|
|
17
|
+
slice.fetchState === 'Completed') {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
slice.fetchState = 'In-Progress';
|
|
11
21
|
},
|
|
12
22
|
updateAccountsForTransferFlow(draft, action) {
|
|
13
23
|
const slice = draft.transferAccountsByType[action.payload.kind];
|
|
@@ -99,21 +99,21 @@ function handleSuccessWithTransactionBody(transactionPayload, vendorPayload, pre
|
|
|
99
99
|
return concat(from(immediate), delayedResetAndPreviousCleanup(replaced ? previousTransactionId : undefined));
|
|
100
100
|
}
|
|
101
101
|
// ─── Top-level epic ──────────────────────────────────────────────────────────
|
|
102
|
-
const CREATE_TRANSFER_ENTRY_URL = `https://dev.api.zeni.ai/version/accounting/komal/1.0/transactions/transaction-type-update`;
|
|
103
102
|
export const createTransferEntryEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(createTransferEntry.match), mergeMap((action) => {
|
|
104
103
|
const { transactionId, creditAccountIntegrationId, debitAccountIntegrationId, memo, transactionType, sourceTransactionType, } = action.payload;
|
|
105
104
|
const previousTransactionId = {
|
|
106
105
|
id: transactionId,
|
|
107
106
|
type: sourceTransactionType,
|
|
108
107
|
};
|
|
109
|
-
|
|
110
|
-
.postAndGetJSON(CREATE_TRANSFER_ENTRY_URL, {
|
|
108
|
+
const payload = {
|
|
111
109
|
transaction_type: transactionType,
|
|
112
110
|
transaction_id: transactionId,
|
|
113
111
|
to_account_integration_id: creditAccountIntegrationId,
|
|
114
112
|
from_account_integration_id: debitAccountIntegrationId,
|
|
115
113
|
memo,
|
|
116
|
-
}
|
|
114
|
+
};
|
|
115
|
+
return zeniAPI
|
|
116
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/transaction-type-update`, payload)
|
|
117
117
|
.pipe(mergeMap((response) => {
|
|
118
118
|
if (!isSuccessResponse(response)) {
|
|
119
119
|
return from(buildFailureActions());
|
|
@@ -22,6 +22,7 @@ export const fetchTransferAccountsEpic = (actions$, _state$, zeniAPI) => actions
|
|
|
22
22
|
const queryValue = QUERY_BY_TYPE[kind];
|
|
23
23
|
const reportId = REPORT_ID_BY_TYPE[kind];
|
|
24
24
|
const url = `https://dev.api.zeni.ai/version/accounting/komal/1.0/accounts?query=${encodeURIComponent(JSON.stringify(queryValue))}`;
|
|
25
|
+
// const url = `${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts?query=${encodeURIComponent(JSON.stringify(queryValue))}`;
|
|
25
26
|
return zeniAPI.getJSON(url).pipe(mergeMap((response) => {
|
|
26
27
|
if (isSuccessResponse(response) && response.data != null) {
|
|
27
28
|
const accountIds = response.data.accounts.map((account) => account.account_id);
|
|
@@ -48,7 +48,7 @@ export const fetchTransactionDetailEpic = (actions$, state$, zeniAPI) => actions
|
|
|
48
48
|
transactionActions.push(updateTransactionDetailFetchState(transactionId, 'In-Progress'));
|
|
49
49
|
const query = { transaction_type: transactionId.type };
|
|
50
50
|
const getTransactionDetail$ = zeniAPI
|
|
51
|
-
.getJSON(
|
|
51
|
+
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${transactionId.id}?query=${encodeURIComponent(JSON.stringify(query))}`)
|
|
52
52
|
.pipe(mergeMap((response) => {
|
|
53
53
|
if (isSuccessResponse(response) &&
|
|
54
54
|
response.data?.transaction?.transaction_id != null) {
|
|
@@ -10,8 +10,18 @@ const createTransferEntrySlice = (0, toolkit_1.createSlice)({
|
|
|
10
10
|
initialState: exports.initialState,
|
|
11
11
|
reducers: {
|
|
12
12
|
fetchAccountsForTransferFlow(draft, action) {
|
|
13
|
-
draft.transferAccountsByType[action.payload.kind]
|
|
14
|
-
|
|
13
|
+
const slice = draft.transferAccountsByType[action.payload.kind];
|
|
14
|
+
// Idempotent: a duplicate dispatch must not briefly downgrade
|
|
15
|
+
// 'Completed' back to 'In-Progress' (would clear loaded data from a
|
|
16
|
+
// consumer's perspective) nor restart the in-flight epic stream.
|
|
17
|
+
// The hook (`useFetchTransferAccountsForFlow`) is the sole caller and
|
|
18
|
+
// already dedupes via `store.getState()`; this guard is defense in
|
|
19
|
+
// depth for any future caller.
|
|
20
|
+
if (slice.fetchState === 'In-Progress' ||
|
|
21
|
+
slice.fetchState === 'Completed') {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
slice.fetchState = 'In-Progress';
|
|
15
25
|
},
|
|
16
26
|
updateAccountsForTransferFlow(draft, action) {
|
|
17
27
|
const slice = draft.transferAccountsByType[action.payload.kind];
|
|
@@ -102,21 +102,21 @@ function handleSuccessWithTransactionBody(transactionPayload, vendorPayload, pre
|
|
|
102
102
|
return (0, rxjs_1.concat)((0, rxjs_1.from)(immediate), delayedResetAndPreviousCleanup(replaced ? previousTransactionId : undefined));
|
|
103
103
|
}
|
|
104
104
|
// ─── Top-level epic ──────────────────────────────────────────────────────────
|
|
105
|
-
const CREATE_TRANSFER_ENTRY_URL = `https://dev.api.zeni.ai/version/accounting/komal/1.0/transactions/transaction-type-update`;
|
|
106
105
|
const createTransferEntryEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(createTransferEntryReducer_1.createTransferEntry.match), (0, operators_1.mergeMap)((action) => {
|
|
107
106
|
const { transactionId, creditAccountIntegrationId, debitAccountIntegrationId, memo, transactionType, sourceTransactionType, } = action.payload;
|
|
108
107
|
const previousTransactionId = {
|
|
109
108
|
id: transactionId,
|
|
110
109
|
type: sourceTransactionType,
|
|
111
110
|
};
|
|
112
|
-
|
|
113
|
-
.postAndGetJSON(CREATE_TRANSFER_ENTRY_URL, {
|
|
111
|
+
const payload = {
|
|
114
112
|
transaction_type: transactionType,
|
|
115
113
|
transaction_id: transactionId,
|
|
116
114
|
to_account_integration_id: creditAccountIntegrationId,
|
|
117
115
|
from_account_integration_id: debitAccountIntegrationId,
|
|
118
116
|
memo,
|
|
119
|
-
}
|
|
117
|
+
};
|
|
118
|
+
return zeniAPI
|
|
119
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/transaction-type-update`, payload)
|
|
120
120
|
.pipe((0, operators_1.mergeMap)((response) => {
|
|
121
121
|
if (!(0, responsePayload_1.isSuccessResponse)(response)) {
|
|
122
122
|
return (0, rxjs_1.from)(buildFailureActions());
|
|
@@ -25,6 +25,7 @@ const fetchTransferAccountsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(
|
|
|
25
25
|
const queryValue = QUERY_BY_TYPE[kind];
|
|
26
26
|
const reportId = REPORT_ID_BY_TYPE[kind];
|
|
27
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))}`;
|
|
28
29
|
return zeniAPI.getJSON(url).pipe((0, operators_1.mergeMap)((response) => {
|
|
29
30
|
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
30
31
|
const accountIds = response.data.accounts.map((account) => account.account_id);
|
|
@@ -54,7 +54,7 @@ const fetchTransactionDetailEpic = (actions$, state$, zeniAPI) => actions$.pipe(
|
|
|
54
54
|
transactionActions.push((0, transactionDetailReducer_1.updateTransactionDetailFetchState)(transactionId, 'In-Progress'));
|
|
55
55
|
const query = { transaction_type: transactionId.type };
|
|
56
56
|
const getTransactionDetail$ = zeniAPI
|
|
57
|
-
.getJSON(
|
|
57
|
+
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${transactionId.id}?query=${encodeURIComponent(JSON.stringify(query))}`)
|
|
58
58
|
.pipe((0, operators_1.mergeMap)((response) => {
|
|
59
59
|
if ((0, responsePayload_1.isSuccessResponse)(response) &&
|
|
60
60
|
response.data?.transaction?.transaction_id != null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.0.81-
|
|
3
|
+
"version": "5.0.81-betaML3",
|
|
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",
|