@zeniai/client-epic-state 4.20.3-betaSS13 → 4.20.3-betaSS14

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 (34) hide show
  1. package/lib/common/aiCfo/aiCfoSuggestedQuestionsPageContext.d.ts +1 -1
  2. package/lib/entity/tenant/clearAllEpic.d.ts +2 -1
  3. package/lib/entity/tenant/clearAllEpic.js +2 -0
  4. package/lib/esm/entity/tenant/clearAllEpic.js +2 -0
  5. package/lib/esm/index.js +1 -1
  6. package/lib/esm/view/creditAgentView/creditAgentViewReducer.js +73 -37
  7. package/lib/esm/view/creditAgentView/creditAgentViewState.js +1 -22
  8. package/lib/esm/view/creditAgentView/epics/downloadCreditReportEpic.js +20 -17
  9. package/lib/esm/view/creditAgentView/epics/fetchCardProfilesEpic.js +5 -5
  10. package/lib/esm/view/creditAgentView/epics/fetchCreditAgentAccessEpic.js +8 -8
  11. package/lib/esm/view/creditAgentView/epics/fetchCreditAgentMacroEpic.js +7 -7
  12. package/lib/esm/view/creditAgentView/epics/saveCreditAgentMacroEpic.js +8 -3
  13. package/lib/esm/view/creditAgentView/epics/updateCardProfileEpic.js +5 -11
  14. package/lib/esm/view/spendManagement/zeniAccounts/zeniAccountList/zeniAccountListSelector.js +10 -3
  15. package/lib/index.d.ts +3 -3
  16. package/lib/index.js +12 -12
  17. package/lib/view/creditAgentView/creditAgentViewReducer.d.ts +19 -8
  18. package/lib/view/creditAgentView/creditAgentViewReducer.js +76 -40
  19. package/lib/view/creditAgentView/creditAgentViewState.d.ts +5 -15
  20. package/lib/view/creditAgentView/creditAgentViewState.js +0 -23
  21. package/lib/view/creditAgentView/epics/downloadCreditReportEpic.d.ts +20 -5
  22. package/lib/view/creditAgentView/epics/downloadCreditReportEpic.js +21 -16
  23. package/lib/view/creditAgentView/epics/fetchCardProfilesEpic.d.ts +4 -4
  24. package/lib/view/creditAgentView/epics/fetchCardProfilesEpic.js +4 -4
  25. package/lib/view/creditAgentView/epics/fetchCreditAgentAccessEpic.d.ts +6 -6
  26. package/lib/view/creditAgentView/epics/fetchCreditAgentAccessEpic.js +5 -5
  27. package/lib/view/creditAgentView/epics/fetchCreditAgentMacroEpic.d.ts +5 -5
  28. package/lib/view/creditAgentView/epics/fetchCreditAgentMacroEpic.js +5 -5
  29. package/lib/view/creditAgentView/epics/saveCreditAgentMacroEpic.js +8 -3
  30. package/lib/view/creditAgentView/epics/updateCardProfileEpic.d.ts +5 -5
  31. package/lib/view/creditAgentView/epics/updateCardProfileEpic.js +4 -10
  32. package/lib/view/spendManagement/zeniAccounts/zeniAccountList/zeniAccountListSelector.d.ts +9 -1
  33. package/lib/view/spendManagement/zeniAccounts/zeniAccountList/zeniAccountListSelector.js +10 -3
  34. package/package.json +1 -1
@@ -8,14 +8,19 @@ const creditAgentViewReducer_1 = require("../creditAgentViewReducer");
8
8
  const saveCreditAgentMacroEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(creditAgentViewReducer_1.saveCreditAgentMacro.match), (0, operators_1.switchMap)((action) => {
9
9
  const { instructions } = action.payload;
10
10
  const existingMacro = state$.value.creditAgentViewState.macro.data;
11
+ // Fail fast if macro has not been loaded yet — avoids overwriting server-side
12
+ // name/description fields with empty defaults.
13
+ if (existingMacro == null) {
14
+ return (0, rxjs_1.of)((0, creditAgentViewReducer_1.saveCreditAgentMacroFailure)((0, responsePayload_1.createZeniAPIStatus)('Save failed', 'Cannot save macro: macro data has not been loaded yet.')));
15
+ }
11
16
  const url = `${zeniAPI.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/macros/credit-agent`;
12
17
  const body = {
13
18
  instructions,
14
- name: existingMacro?.name ?? 'credit-agent',
15
- description: existingMacro?.description ?? '',
19
+ name: existingMacro.name,
20
+ description: existingMacro.description,
16
21
  };
17
22
  return zeniAPI.putAndGetJSON(url, body).pipe((0, operators_1.mergeMap)((response) => {
18
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
23
+ if ((0, responsePayload_1.isSuccessResponse)(response)) {
19
24
  return (0, rxjs_1.of)((0, creditAgentViewReducer_1.saveCreditAgentMacroSuccess)(response.data));
20
25
  }
21
26
  else {
@@ -1,15 +1,15 @@
1
1
  import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { RootState } from '../../../reducer';
3
3
  import { ZeniAPI } from '../../../zeniAPI';
4
- import { updateCardProfile, updateCardProfileCompleted, updateCardProfileFailed } from '../creditAgentViewReducer';
5
- export type ActionType = ReturnType<typeof updateCardProfile> | ReturnType<typeof updateCardProfileCompleted> | ReturnType<typeof updateCardProfileFailed>;
4
+ import { updateCardProfile, updateCardProfileFailure, updateCardProfileSuccess } from '../creditAgentViewReducer';
5
+ export type ActionType = ReturnType<typeof updateCardProfile> | ReturnType<typeof updateCardProfileSuccess> | ReturnType<typeof updateCardProfileFailure>;
6
6
  export declare const updateCardProfileEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
7
7
  payload: {
8
- profile: Partial<import("../creditAgentViewState").CardTenantProfileRow>;
8
+ profile: import("../creditAgentViewState").CardTenantProfileRow;
9
9
  tenantNamespace: string;
10
10
  };
11
- type: "creditAgentView/updateCardProfileCompleted";
11
+ type: "creditAgentView/updateCardProfileSuccess";
12
12
  } | {
13
13
  payload: import("../../../responsePayload").ZeniAPIStatus<Record<string, unknown>>;
14
- type: "creditAgentView/updateCardProfileFailed";
14
+ type: "creditAgentView/updateCardProfileFailure";
15
15
  }>;
@@ -26,20 +26,14 @@ const updateCardProfileEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0,
26
26
  return zeniAPI.putAndGetJSON(url, body).pipe((0, operators_1.mergeMap)((response) => {
27
27
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data?.profile != null) {
28
28
  const mapped = (0, creditAgentViewReducer_1.mapCardTenantProfileRowPayload)(response.data.profile);
29
- return (0, rxjs_1.of)((0, creditAgentViewReducer_1.updateCardProfileCompleted)({
30
- profile: {
31
- cardStatus: mapped.cardStatus,
32
- creditLimit: mapped.creditLimit,
33
- updatedByName: mapped.updatedByName,
34
- updatedByUserId: mapped.updatedByUserId,
35
- updatedOn: mapped.updatedOn,
36
- },
29
+ return (0, rxjs_1.of)((0, creditAgentViewReducer_1.updateCardProfileSuccess)({
30
+ profile: mapped,
37
31
  tenantNamespace,
38
32
  }));
39
33
  }
40
34
  else {
41
- return (0, rxjs_1.of)((0, creditAgentViewReducer_1.updateCardProfileFailed)(response.status));
35
+ return (0, rxjs_1.of)((0, creditAgentViewReducer_1.updateCardProfileFailure)(response.status));
42
36
  }
43
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, creditAgentViewReducer_1.updateCardProfileFailed)((0, responsePayload_1.createZeniAPIStatus)('Unexpected error', 'REST API call errored out: ' + JSON.stringify(error))))));
37
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, creditAgentViewReducer_1.updateCardProfileFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected error', 'REST API call errored out: ' + JSON.stringify(error))))));
44
38
  }));
45
39
  exports.updateCardProfileEpic = updateCardProfileEpic;
@@ -1,13 +1,21 @@
1
1
  import { SelectorView } from '../../../../commonStateTypes/viewAndReport/viewAndReport';
2
+ import { DepositAccount } from '../../../../entity/depositAccount/depositAccount';
2
3
  import { PaymentAccount } from '../../../../entity/paymentAccount/paymentAccountState';
3
4
  import { RootState } from '../../../../reducer';
5
+ import { AutoTransferRule } from '../../autotransferRules/autoTransferRulesState';
4
6
  import { PlaidConnectionDetails } from '../../plaidAccount/plaidAccountViewState';
5
7
  import { DepositAccountListSelectorView } from '../depositAccountList/depositAccountListSelector';
6
8
  import { PaymentAccountListSelectorView } from '../paymentAccountList/paymentAccountListSelector';
7
9
  import { ZeniAccountsConfigSelectorView } from '../zeniAccountsConfig/zeniAccountsConfigSelector';
8
10
  import { NewCheckingAccount, ZeniAccountSummaryWithBalance } from './zeniAccountListState';
11
+ export interface DepositAccountWithAutoTransferRules extends DepositAccount {
12
+ autoTransferRules?: AutoTransferRule[];
13
+ }
14
+ export interface ZeniDepositAccountListSelectorView extends Omit<DepositAccountListSelectorView, 'depositAccounts'> {
15
+ depositAccounts: DepositAccountWithAutoTransferRules[];
16
+ }
9
17
  export interface ZeniAccountListSelectorView extends SelectorView {
10
- depositAccountsSelectorView: DepositAccountListSelectorView;
18
+ depositAccountsSelectorView: ZeniDepositAccountListSelectorView;
11
19
  externalAccountsSelectorView: PaymentAccountListSelectorView;
12
20
  newCheckingAccount: NewCheckingAccount;
13
21
  plaidConnectionDetails: PlaidConnectionDetails;
@@ -7,9 +7,16 @@ const depositAccountListSelector_1 = require("../depositAccountList/depositAccou
7
7
  const paymentAccountListSelector_1 = require("../paymentAccountList/paymentAccountListSelector");
8
8
  const zeniAccountsConfigSelector_1 = require("../zeniAccountsConfig/zeniAccountsConfigSelector");
9
9
  const getZeniAccountList = (state) => {
10
- const { zeniAccountListState, depositAccountState, paymentAccountState, plaidAccountViewState, depositAccountListState, paymentAccountListState, } = state;
10
+ const { zeniAccountListState, depositAccountState, paymentAccountState, plaidAccountViewState, depositAccountListState, paymentAccountListState, autotransferRulesState, } = state;
11
11
  const { plaidConnectionDetails } = plaidAccountViewState['external_account'];
12
- const depositAccountsSelectorView = (0, depositAccountListSelector_1.getAllDepositAccounts)(depositAccountState, depositAccountListState);
12
+ const baseDepositAccountsSelectorView = (0, depositAccountListSelector_1.getAllDepositAccounts)(depositAccountState, depositAccountListState);
13
+ const depositAccountsSelectorView = {
14
+ ...baseDepositAccountsSelectorView,
15
+ depositAccounts: baseDepositAccountsSelectorView.depositAccounts.map((depositAccount) => ({
16
+ ...depositAccount,
17
+ autoTransferRules: autotransferRulesState.rules.filter((rule) => !rule.isDeleted && rule.sourceBankAccountId === depositAccount.id),
18
+ })),
19
+ };
13
20
  const zeniAccountsConfig = (0, zeniAccountsConfigSelector_1.getZeniAccountsConfigDetail)(state);
14
21
  const { paymentAccountIds } = paymentAccountListState;
15
22
  const externalAccountsSelectorView = (0, paymentAccountListSelector_1.getAllPaymentAccounts)(paymentAccountState, paymentAccountListState);
@@ -45,7 +52,7 @@ const getZeniAccountList = (state) => {
45
52
  plaidConnectionDetails,
46
53
  externalAccountsSelectorView,
47
54
  newCheckingAccount: zeniAccountListState.newCheckingAccount,
48
- fetchState: depositAccountsSelectorView.fetchState,
55
+ fetchState: baseDepositAccountsSelectorView.fetchState,
49
56
  };
50
57
  };
51
58
  exports.getZeniAccountList = getZeniAccountList;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.20.3-betaSS13",
3
+ "version": "4.20.3-betaSS14",
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",