@zeniai/client-epic-state 4.19.24-betaRR16 → 4.19.24-betaRR18

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.
@@ -6,20 +6,26 @@ const setupViewSelector_1 = require("../../commonSetup/setupViewSelector");
6
6
  const depositAccountListSelector_1 = require("../../zeniAccounts/depositAccountList/depositAccountListSelector");
7
7
  const paymentAccountListSelector_1 = require("../../zeniAccounts/paymentAccountList/paymentAccountListSelector");
8
8
  const getChargeCardRepaymentDetail = (state) => {
9
- var _a;
9
+ var _a, _b;
10
10
  const { chargeCardRepaymentDetailState, depositAccountState, paymentAccountState, depositAccountListState, paymentAccountListState, } = state;
11
11
  const { localData, fetchState, error } = chargeCardRepaymentDetailState;
12
12
  const depositAccountsView = (0, depositAccountListSelector_1.getAllDepositAccounts)(depositAccountState, depositAccountListState);
13
13
  const paymentAccountsView = (0, paymentAccountListSelector_1.getAllPaymentAccounts)(paymentAccountState, paymentAccountListState);
14
14
  let transferFromAccounts = [];
15
- if (depositAccountsView.fetchState === 'Completed' &&
16
- paymentAccountsView.fetchState === 'Completed') {
17
- transferFromAccounts = (0, setupViewSelector_1.getAllFundingAccounts)(depositAccountsView.depositAccounts, paymentAccountsView.paymentAccounts, paymentAccountListState.paymentAccountBalanceFetchStatus);
15
+ if (paymentAccountsView.fetchState === 'Completed') {
16
+ if (depositAccountsView.fetchState === 'Completed') {
17
+ transferFromAccounts = (0, setupViewSelector_1.getAllFundingAccounts)(depositAccountsView.depositAccounts, paymentAccountsView.paymentAccounts, paymentAccountListState.paymentAccountBalanceFetchStatus);
18
+ }
19
+ else {
20
+ const depositFundingFromLimit = Object.values((_a = depositAccountState.depositAccountLimitForChargeCardByID) !== null && _a !== void 0 ? _a : {}).map(setupViewSelector_1.mapDepositAccountWithLimitToFundingAccount);
21
+ const paymentFundingAccounts = (0, setupViewSelector_1.getAllFundingAccounts)([], paymentAccountsView.paymentAccounts, paymentAccountListState.paymentAccountBalanceFetchStatus);
22
+ transferFromAccounts = [...depositFundingFromLimit, ...paymentFundingAccounts];
23
+ }
18
24
  }
19
25
  // #region agent log
20
- fetch('http://127.0.0.1:7242/ingest/3d86d94d-63fc-405c-92bd-d68a0fc3a8c8', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '88d521' }, body: JSON.stringify({ sessionId: '88d521', location: 'chargeCardRepaymentDetailSelector.ts:selector', message: 'transferFromAccounts data flow', data: { depositFetchState: depositAccountsView.fetchState, paymentFetchState: paymentAccountsView.fetchState, depositAccountsCount: depositAccountsView.depositAccounts.length, paymentAccountsCount: paymentAccountsView.paymentAccounts.length, transferFromAccountsCount: transferFromAccounts.length, enteredIfBlock: depositAccountsView.fetchState === 'Completed' && paymentAccountsView.fetchState === 'Completed', accountIdsLength: (_a = depositAccountListState.accountIds) === null || _a === void 0 ? void 0 : _a.length, depositAccTypes: transferFromAccounts.map(a => a.accType) }, timestamp: Date.now(), hypothesisId: 'H1' }) }).catch(() => { });
26
+ fetch('http://127.0.0.1:7242/ingest/3d86d94d-63fc-405c-92bd-d68a0fc3a8c8', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '620b68' }, body: JSON.stringify({ sessionId: '620b68', location: 'chargeCardRepaymentDetailSelector.ts:selector', message: 'transferFromAccounts data flow', data: { depositFetchState: depositAccountsView.fetchState, paymentFetchState: paymentAccountsView.fetchState, depositAccountsCount: depositAccountsView.depositAccounts.length, paymentAccountsCount: paymentAccountsView.paymentAccounts.length, transferFromAccountsCount: transferFromAccounts.length, enteredIfBlock: paymentAccountsView.fetchState === 'Completed', accountIdsLength: (_b = depositAccountListState.accountIds) === null || _b === void 0 ? void 0 : _b.length, depositAccTypes: transferFromAccounts.map(a => a.accType) }, timestamp: Date.now(), hypothesisId: 'H1' }) }).catch(() => { });
21
27
  // #endregion
22
- const reducedFetchState = (0, reduceFetchState_1.reduceAllFetchState)([
28
+ const reducedFetchState = (0, reduceFetchState_1.reduceAnyCompletedFetchState)([
23
29
  depositAccountsView,
24
30
  paymentAccountsView,
25
31
  ...Object.values(paymentAccountListState.paymentAccountBalanceFetchStatus),
@@ -16,7 +16,7 @@ const fetchChargeCardRepaymentDetailEpic = (actions$, state$) => actions$.pipe((
16
16
  fetchChargeCardRepaymentDetailActions.push((0, depositAccountListReducer_1.fetchDepositAccountList)());
17
17
  }
18
18
  // #region agent log
19
- fetch('http://127.0.0.1:7242/ingest/3d86d94d-63fc-405c-92bd-d68a0fc3a8c8', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '88d521' }, body: JSON.stringify({ sessionId: '88d521', location: 'fetchChargeCardRepaymentDetailEpic.ts:epic', message: 'fetchChargeCardRepaymentDetailEpic dispatch', data: { depositListFetchState: depositAccounts.fetchState, willFetchDeposit, accountIdsLength: (_a = depositAccounts.accountIds) === null || _a === void 0 ? void 0 : _a.length }, timestamp: Date.now(), hypothesisId: 'H3' }) }).catch(() => { });
19
+ fetch('http://127.0.0.1:7242/ingest/3d86d94d-63fc-405c-92bd-d68a0fc3a8c8', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '620b68' }, body: JSON.stringify({ sessionId: '620b68', location: 'fetchChargeCardRepaymentDetailEpic.ts:epic', message: 'fetchChargeCardRepaymentDetailEpic dispatch', data: { depositListFetchState: depositAccounts.fetchState, willFetchDeposit, accountIdsLength: (_a = depositAccounts.accountIds) === null || _a === void 0 ? void 0 : _a.length }, timestamp: Date.now(), hypothesisId: 'H1' }) }).catch(() => { });
20
20
  // #endregion
21
21
  const paymentAccounts = state.paymentAccountListState;
22
22
  if (paymentAccounts.fetchState !== 'In-Progress' &&
@@ -5,7 +5,7 @@ import { FetchStateAndError, ID } from '../../../commonStateTypes/common';
5
5
  import { AccountBase } from '../../../entity/account/accountState';
6
6
  import { CompanyBillPayInfo } from '../../../entity/company/companyStateTypes';
7
7
  import { Country } from '../../../entity/countryList/countryListState';
8
- import { DepositAccount } from '../../../entity/depositAccount/depositAccount';
8
+ import { DepositAccount, DepositAccountWithLimit } from '../../../entity/depositAccount/depositAccount';
9
9
  import { File } from '../../../entity/file/fileState';
10
10
  import { InstitutionDetails, Logo, PaymentAccount } from '../../../entity/paymentAccount/paymentAccountState';
11
11
  import { RootState } from '../../../reducer';
@@ -94,5 +94,6 @@ export declare function getBusinessVerificationDetails(state: RootState, company
94
94
  export declare const getCompanyAndIdentityDetails: (state: RootState, companyId: ID, companyAndIdentityDetails: CompanyAndIdentityDetails) => CompanyAndOfficerLocalData;
95
95
  export declare const getAllFundingAccounts: (depositAccounts: DepositAccount[], paymentAccounts: PaymentAccount[], paymentAccountBalanceFetchStatus: Record<ID, FetchStateAndError>, includeOnlyVerifiedAccounts?: boolean) => FundingAccount[];
96
96
  export declare const mapDepositAccToFundingAccount: (depositAcc: DepositAccount) => FundingAccount;
97
+ export declare const mapDepositAccountWithLimitToFundingAccount: (depositAcc: DepositAccountWithLimit) => FundingAccount;
97
98
  export declare const mapPaymentAccToFundingAccount: (paymentAcc: PaymentAccount, paymentAccountBalanceFetchStatus: Record<ID, FetchStateAndError>) => FundingAccount;
98
99
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapPaymentAccToFundingAccount = exports.mapDepositAccToFundingAccount = exports.getAllFundingAccounts = exports.getCompanyAndIdentityDetails = void 0;
3
+ exports.mapPaymentAccToFundingAccount = exports.mapDepositAccountWithLimitToFundingAccount = exports.mapDepositAccToFundingAccount = exports.getAllFundingAccounts = exports.getCompanyAndIdentityDetails = void 0;
4
4
  exports.getCommonSetupViewDetails = getCommonSetupViewDetails;
5
5
  exports.getBusinessVerificationDetails = getBusinessVerificationDetails;
6
6
  const accountSelector_1 = require("../../../entity/account/accountSelector");
@@ -224,6 +224,25 @@ const mapDepositAccToFundingAccount = (depositAcc) => ({
224
224
  accountLast4: depositAcc.accountLast4,
225
225
  });
226
226
  exports.mapDepositAccToFundingAccount = mapDepositAccToFundingAccount;
227
+ const mapDepositAccountWithLimitToFundingAccount = (depositAcc) => {
228
+ var _a, _b;
229
+ return ({
230
+ id: depositAcc.id,
231
+ accType: 'depositAccount',
232
+ label: depositAcc.accountName,
233
+ maskedAccountNumber: depositAcc.maskedAccountNumber,
234
+ accountBalance: depositAcc.accountBalance,
235
+ logo: undefined,
236
+ zeniAccountId: depositAcc.zeniAccountId,
237
+ balanceFetchStatus: {
238
+ fetchState: 'Completed',
239
+ error: undefined,
240
+ },
241
+ createTime: depositAcc.createTime,
242
+ accountLast4: (_b = (_a = depositAcc.maskedAccountNumber.match(/(\d{4})$/)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : undefined,
243
+ });
244
+ };
245
+ exports.mapDepositAccountWithLimitToFundingAccount = mapDepositAccountWithLimitToFundingAccount;
227
246
  const mapPaymentAccToFundingAccount = (paymentAcc, paymentAccountBalanceFetchStatus) => {
228
247
  var _a, _b;
229
248
  return ({
@@ -11,16 +11,22 @@ const fetchDepositAccountListEpic = (actions$, _state$, zeniAPI) => actions$.pip
11
11
  return zeniAPI
12
12
  .getJSON(`${zeniAPI.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts?query=${encodeURIComponent(`{"is_include_deposit_accounts_summary":true}`)}`)
13
13
  .pipe((0, operators_1.mergeMap)((response) => {
14
- var _a, _b, _c, _d, _e, _f, _g;
15
- if ((0, responsePayload_1.isSuccessResponse)(response)) {
16
- // #region agent log
17
- const depositAccounts = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.deposit_accounts) !== null && _b !== void 0 ? _b : [];
18
- fetch('http://127.0.0.1:7242/ingest/3d86d94d-63fc-405c-92bd-d68a0fc3a8c8', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '88d521' }, body: JSON.stringify({ sessionId: '88d521', location: 'fetchDepositAccountListEpic.ts:epic', message: 'deposit-accounts API response', data: { depositAccountsCount: depositAccounts.length, accountIds: depositAccounts.map((a) => a === null || a === void 0 ? void 0 : a.deposit_account_id) }, timestamp: Date.now(), hypothesisId: 'H5' }) }).catch(() => { });
19
- // #endregion
20
- return (0, rxjs_1.of)((0, depositAccountReducer_1.updateDepositAccounts)((_d = (_c = response.data) === null || _c === void 0 ? void 0 : _c.deposit_accounts) !== null && _d !== void 0 ? _d : []), (0, zeniAccountListReducer_1.updateZeniAccountsSummary)({
14
+ var _a, _b, _c, _d, _e;
15
+ const hasData = (response === null || response === void 0 ? void 0 : response.data) != null;
16
+ const statusCode = (_a = response === null || response === void 0 ? void 0 : response.status) === null || _a === void 0 ? void 0 : _a.code;
17
+ const isSuccess = (0, responsePayload_1.isSuccessResponse)(response);
18
+ // #region agent log
19
+ const respData = response === null || response === void 0 ? void 0 : response.data;
20
+ const dataKeys = respData != null ? Object.keys(respData) : [];
21
+ const topLevelKeys = response != null ? Object.keys(response) : [];
22
+ fetch('http://127.0.0.1:7242/ingest/3d86d94d-63fc-405c-92bd-d68a0fc3a8c8', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '620b68' }, body: JSON.stringify({ sessionId: '620b68', location: 'fetchDepositAccountListEpic.ts:mergeMap', message: 'deposit-accounts response inspection', data: { isSuccess, hasData, statusCode, topLevelKeys, dataKeys, depositAccountsCount: (_b = respData === null || respData === void 0 ? void 0 : respData.deposit_accounts) === null || _b === void 0 ? void 0 : _b.length }, timestamp: Date.now(), hypothesisId: 'H3' }) }).catch(() => { });
23
+ // #endregion
24
+ if (isSuccess) {
25
+ const depositAccounts = (_d = (_c = response.data) === null || _c === void 0 ? void 0 : _c.deposit_accounts) !== null && _d !== void 0 ? _d : [];
26
+ return (0, rxjs_1.of)((0, depositAccountReducer_1.updateDepositAccounts)(depositAccounts), (0, zeniAccountListReducer_1.updateZeniAccountsSummary)({
21
27
  summaryPayload: (_e = response.data) === null || _e === void 0 ? void 0 : _e.all_deposit_accounts_summary,
22
28
  }), (0, depositAccountListReducer_1.updateDepositAccountList)({
23
- data: (_g = (_f = response.data) === null || _f === void 0 ? void 0 : _f.deposit_accounts) !== null && _g !== void 0 ? _g : [],
29
+ data: depositAccounts,
24
30
  updateType: 'replace',
25
31
  }));
26
32
  }
@@ -31,6 +37,10 @@ const fetchDepositAccountListEpic = (actions$, _state$, zeniAPI) => actions$.pip
31
37
  }));
32
38
  }
33
39
  }), (0, operators_1.catchError)((error) => {
40
+ var _a;
41
+ // #region agent log
42
+ fetch('http://127.0.0.1:7242/ingest/3d86d94d-63fc-405c-92bd-d68a0fc3a8c8', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '620b68' }, body: JSON.stringify({ sessionId: '620b68', location: 'fetchDepositAccountListEpic.ts:catchError', message: 'deposit-accounts API catchError', data: { errorMsg: String(error === null || error === void 0 ? void 0 : error.message), errorName: error === null || error === void 0 ? void 0 : error.name, errorStack: (_a = error === null || error === void 0 ? void 0 : error.stack) === null || _a === void 0 ? void 0 : _a.slice(0, 200) }, timestamp: Date.now(), hypothesisId: 'H3' }) }).catch(() => { });
43
+ // #endregion
34
44
  return (0, rxjs_1.of)((0, depositAccountListReducer_1.updateDepositAccountListFetchStatus)({
35
45
  fetchState: 'Error',
36
46
  error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch deposit Accounts REST API call errored out' +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.19.24-betaRR16",
3
+ "version": "4.19.24-betaRR18",
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
  "types": "lib/index.d.ts",