@zeniai/client-epic-state 5.0.82-betaAK1 → 5.0.82-betaAK3

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 (22) hide show
  1. package/lib/esm/index.js +1 -1
  2. package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowPayload.js +4 -1
  3. package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowReducer.js +17 -4
  4. package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector.js +17 -5
  5. package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowState.js +1 -0
  6. package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/epics/fetchCashManagementSettingsEpic.js +7 -1
  7. package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/epics/saveAutoSweepSettingsEpic.js +22 -21
  8. package/lib/index.d.ts +2 -2
  9. package/lib/index.js +2 -1
  10. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowPayload.d.ts +12 -19
  11. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowPayload.js +4 -1
  12. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowReducer.d.ts +2 -2
  13. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowReducer.js +18 -5
  14. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector.d.ts +18 -1
  15. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector.js +17 -5
  16. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowState.d.ts +7 -0
  17. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowState.js +1 -0
  18. package/lib/view/spendManagement/cashManagement/autoSweepFlow/epics/fetchCashManagementSettingsEpic.d.ts +2 -1
  19. package/lib/view/spendManagement/cashManagement/autoSweepFlow/epics/fetchCashManagementSettingsEpic.js +7 -1
  20. package/lib/view/spendManagement/cashManagement/autoSweepFlow/epics/saveAutoSweepSettingsEpic.d.ts +1 -8
  21. package/lib/view/spendManagement/cashManagement/autoSweepFlow/epics/saveAutoSweepSettingsEpic.js +22 -21
  22. package/package.json +1 -1
package/lib/esm/index.js CHANGED
@@ -665,7 +665,7 @@ export { getTransactionActivityLogView, } from './view/transactionActivityLogVie
665
665
  export { SessionManager } from './entity/tenant/SessionManager';
666
666
  export { DEFAULT_SESSION_CONFIG } from './entity/tenant/sessionTypes';
667
667
  export { fetchCashManagementBanner, fetchCashManagementOverviewPage, } from './view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer';
668
- export { clearAutoSweepFlow, fetchCashManagementSettings, saveAutoSweepSettings, updateAutoSweepSettingsFetchStatus, updateCashManagementSettings, updateCashManagementSettingsFetchStatus, } from './view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowReducer';
668
+ export { clearAutoSweepFlow, fetchCashManagementSettings, saveAutoSweepSettings, updateAutoSweepDraft, updateAutoSweepSettingsFetchStatus, updateCashManagementSettings, updateCashManagementSettingsFetchStatus, } from './view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowReducer';
669
669
  export { getAutoSweepFlow } from './view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector';
670
670
  export { RISK_BUFFER_AMOUNT, bufferAmountToRisk, } from './view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowState';
671
671
  export { getCashManagementOverview, getCashManagementOverviewBanner, } from './view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector';
@@ -11,7 +11,9 @@ export const toSaveAutoSweepSettingsBody = (state) => ({
11
11
  * Map a `GET /cash-management/settings` payload into the slice's writable
12
12
  * fields. Defensive on the frequency (string-from-the-wire → union via
13
13
  * `toAutoSweepFrequency`, falling back to `'weekly'` if the server returns
14
- * something we don't model yet).
14
+ * something we don't model yet). Only the source account *id* is stored
15
+ * here — the full deposit-account payload is published to the entity bucket
16
+ * by the fetch epic.
15
17
  */
16
18
  export const toAutoSweepFlowStatePatch = (payload) => {
17
19
  const currencyCode = payload.source_bank_account.balances?.currency_code;
@@ -19,6 +21,7 @@ export const toAutoSweepFlowStatePatch = (payload) => {
19
21
  return {
20
22
  bufferAmount: toAmount(payload.minimum_buffer_usd, currencyCode ?? 'USD', currencySymbol ?? '$'),
21
23
  frequency: toAutoSweepFrequency(payload.frequency) ?? 'weekly',
24
+ primaryFundingAccountId: payload.source_bank_account.deposit_account_id ?? undefined,
22
25
  settingsId: payload.cash_management_settings_id ?? undefined,
23
26
  };
24
27
  };
@@ -22,6 +22,7 @@ const autoSweepFlow = createSlice({
22
22
  const patch = toAutoSweepFlowStatePatch(action.payload.data);
23
23
  draft.bufferAmount = patch.bufferAmount;
24
24
  draft.frequency = patch.frequency;
25
+ draft.primaryFundingAccountId = patch.primaryFundingAccountId;
25
26
  draft.settingsId = patch.settingsId;
26
27
  draft.fetchState = 'Completed';
27
28
  draft.error = undefined;
@@ -31,13 +32,25 @@ const autoSweepFlow = createSlice({
31
32
  draft.error = action.payload.error;
32
33
  },
33
34
  /**
34
- * Persists the form values into state and flips `saveStatus` to
35
- * `In-Progress`; the save epic picks this up and PUTs the settings.
35
+ * Stage the in-flight form values without submitting them fired from
36
+ * the setup→review transition so other selectors (and devtools) can see
37
+ * what the user is about to confirm. Leaves `saveStatus` untouched; the
38
+ * actual PUT only kicks off when the user clicks "Confirm Sweep" via
39
+ * `saveAutoSweepSettings`.
36
40
  */
37
- saveAutoSweepSettings(draft, action) {
41
+ updateAutoSweepDraft(draft, action) {
38
42
  draft.bufferAmount = action.payload.bufferAmount;
39
43
  draft.frequency = action.payload.frequency;
40
44
  draft.memo = action.payload.memo;
45
+ },
46
+ /**
47
+ * Trigger the PUT for the auto-sweep settings already staged via
48
+ * `updateAutoSweepDraft`. Carries no payload — flips `saveStatus` to
49
+ * `In-Progress` and the save epic reads `bufferAmount` / `frequency` /
50
+ * `memo` straight from the slice. Callers must ensure those fields
51
+ * reflect the user's latest input before dispatching.
52
+ */
53
+ saveAutoSweepSettings(draft) {
41
54
  draft.saveStatus = { fetchState: 'In-Progress', error: undefined };
42
55
  },
43
56
  updateAutoSweepSettingsFetchStatus(draft, action) {
@@ -51,5 +64,5 @@ const autoSweepFlow = createSlice({
51
64
  },
52
65
  },
53
66
  });
54
- export const { fetchCashManagementSettings, updateCashManagementSettings, updateCashManagementSettingsFetchStatus, saveAutoSweepSettings, updateAutoSweepSettingsFetchStatus, clearAutoSweepFlow, } = autoSweepFlow.actions;
67
+ export const { fetchCashManagementSettings, updateCashManagementSettings, updateCashManagementSettingsFetchStatus, updateAutoSweepDraft, saveAutoSweepSettings, updateAutoSweepSettingsFetchStatus, clearAutoSweepFlow, } = autoSweepFlow.actions;
55
68
  export default autoSweepFlow.reducer;
@@ -1,15 +1,27 @@
1
+ import { getDepositAccountByDepositAccountId } from '../../../../entity/depositAccount/depositAccountSelector';
2
+ import { mapDepositAccToFundingAccount, } from '../../commonSetup/setupViewSelector';
3
+ import { getTreasuryDetail } from '../../treasury/treasuryList/treasuryDetailSelector';
1
4
  import { bufferAmountToRisk, } from './autoSweepFlowState';
2
5
  export const getAutoSweepFlow = (state) => {
3
- const { bufferAmount, frequency, memo, saveStatus, settingsId, fetchState, error, } = state.autoSweepFlowState;
6
+ const { bufferAmount, frequency, memo, saveStatus, settingsId, primaryFundingAccountId, fetchState, error, } = state.autoSweepFlowState;
7
+ const depositAccount = primaryFundingAccountId != null
8
+ ? getDepositAccountByDepositAccountId(state.depositAccountState, primaryFundingAccountId)
9
+ : undefined;
4
10
  return {
5
11
  fetchState,
6
12
  error,
7
- bufferAmount,
8
- frequency,
9
- memo,
10
- risk: bufferAmountToRisk(bufferAmount.amount),
13
+ formData: {
14
+ bufferAmount,
15
+ frequency,
16
+ memo,
17
+ risk: bufferAmountToRisk(bufferAmount.amount),
18
+ },
19
+ primaryFundingAccount: depositAccount != null
20
+ ? mapDepositAccToFundingAccount(depositAccount)
21
+ : undefined,
11
22
  saveStatus,
12
23
  settingsId,
24
+ treasurySummary: getTreasuryDetail(state).accountSummary,
13
25
  version: 0,
14
26
  };
15
27
  };
@@ -39,6 +39,7 @@ export const initialAutoSweepFlowState = {
39
39
  frequency: 'weekly',
40
40
  memo: '',
41
41
  saveStatus: { fetchState: 'Not-Started', error: undefined },
42
+ primaryFundingAccountId: undefined,
42
43
  settingsId: undefined,
43
44
  fetchState: 'Not-Started',
44
45
  error: undefined,
@@ -1,5 +1,6 @@
1
1
  import { of } from 'rxjs';
2
2
  import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
+ import { updateDepositAccounts } from '../../../../../entity/depositAccount/depositAccountReducer';
3
4
  import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
4
5
  import { fetchCashManagementSettings, updateCashManagementSettings, updateCashManagementSettingsFetchStatus, } from '../autoSweepFlowReducer';
5
6
  /**
@@ -15,7 +16,12 @@ export const fetchCashManagementSettingsEpic = (actions$, _state$, zeniAPI) => a
15
16
  .getJSON(`https://dev.api.zeni.ai/cash-management-agent/1.0/cash-management/settings`)
16
17
  .pipe(mergeMap((response) => {
17
18
  if (isSuccessResponse(response) && response.data != null) {
18
- return of(updateCashManagementSettings({ data: response.data }));
19
+ return of(
20
+ // Publish the source deposit account into the shared entity
21
+ // bucket so the selector can hydrate the full `FundingAccount`
22
+ // from `getDepositAccountByDepositAccountId` rather than the
23
+ // auto-sweep slice holding a duplicate copy.
24
+ updateDepositAccounts([response.data.source_bank_account]), updateCashManagementSettings({ data: response.data }));
19
25
  }
20
26
  return of(updateCashManagementSettingsFetchStatus({
21
27
  fetchState: 'Error',
@@ -3,25 +3,26 @@ import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
3
  import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
4
4
  import { toSaveAutoSweepSettingsBody, } from '../autoSweepFlowPayload';
5
5
  import { saveAutoSweepSettings, updateAutoSweepSettingsFetchStatus, } from '../autoSweepFlowReducer';
6
- /**
7
- * Hits `PUT /cash-management/settings` with the values the user just
8
- * confirmed in the auto-sweep flow.
9
- *
10
- * TODO: switch the endpoint to a base URL constant once the prod endpoint
11
- * lands; right now this hits the dev environment directly.
12
- */
13
- export const saveAutoSweepSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(saveAutoSweepSettings.match), switchMap((action) => zeniAPI
14
- .putAndGetJSON(`https://dev.api.zeni.ai/cash-management-agent/1.0/cash-management/settings`, toSaveAutoSweepSettingsBody(action.payload))
15
- .pipe(mergeMap((response) => {
16
- if (isSuccessResponse(response)) {
17
- return of(updateAutoSweepSettingsFetchStatus({ fetchState: 'Completed' }));
18
- }
19
- return of(updateAutoSweepSettingsFetchStatus({
6
+ export const saveAutoSweepSettingsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(saveAutoSweepSettings.match), switchMap(() => {
7
+ const { bufferAmount, frequency, memo } = state$.value.autoSweepFlowState;
8
+ const payload = toSaveAutoSweepSettingsBody({
9
+ bufferAmount,
10
+ frequency,
11
+ memo,
12
+ });
13
+ return zeniAPI
14
+ .putAndGetJSON(`https://dev.api.zeni.ai/cash-management-agent/1.0/cash-management/settings`, payload)
15
+ .pipe(mergeMap((response) => {
16
+ if (isSuccessResponse(response)) {
17
+ return of(updateAutoSweepSettingsFetchStatus({ fetchState: 'Completed' }));
18
+ }
19
+ return of(updateAutoSweepSettingsFetchStatus({
20
+ fetchState: 'Error',
21
+ error: response.status,
22
+ }));
23
+ }), catchError((error) => of(updateAutoSweepSettingsFetchStatus({
20
24
  fetchState: 'Error',
21
- error: response.status,
22
- }));
23
- }), catchError((error) => of(updateAutoSweepSettingsFetchStatus({
24
- fetchState: 'Error',
25
- error: createZeniAPIStatus('Unexpected Error', 'Save auto-sweep settings REST API call errored out' +
26
- JSON.stringify(error)),
27
- }))))));
25
+ error: createZeniAPIStatus('Unexpected Error', 'Save auto-sweep settings REST API call errored out' +
26
+ JSON.stringify(error)),
27
+ }))));
28
+ }));
package/lib/index.d.ts CHANGED
@@ -938,9 +938,9 @@ export { SessionManager } from './entity/tenant/SessionManager';
938
938
  export type { SessionCallbacks, SessionConfig, } from './entity/tenant/sessionTypes';
939
939
  export { DEFAULT_SESSION_CONFIG } from './entity/tenant/sessionTypes';
940
940
  export { fetchCashManagementBanner, fetchCashManagementOverviewPage, } from './view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer';
941
- export { clearAutoSweepFlow, fetchCashManagementSettings, saveAutoSweepSettings, updateAutoSweepSettingsFetchStatus, updateCashManagementSettings, updateCashManagementSettingsFetchStatus, } from './view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowReducer';
941
+ export { clearAutoSweepFlow, fetchCashManagementSettings, saveAutoSweepSettings, updateAutoSweepDraft, updateAutoSweepSettingsFetchStatus, updateCashManagementSettings, updateCashManagementSettingsFetchStatus, } from './view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowReducer';
942
942
  export { getAutoSweepFlow } from './view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector';
943
- export type { AutoSweepFlowSelectorView } from './view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector';
943
+ export type { AutoSweepFlowFormData, AutoSweepFlowSelectorView, } from './view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector';
944
944
  export { RISK_BUFFER_AMOUNT, bufferAmountToRisk, } from './view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowState';
945
945
  export type { AutoSweepFlowState, AutoSweepFrequency, RiskLevel, } from './view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowState';
946
946
  export { CashManagementOverviewBannerSelectorView, CashManagementOverviewSelectorView, CashProjectionPoint, getCashManagementOverview, getCashManagementOverviewBanner, } from './view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector';
package/lib/index.js CHANGED
@@ -71,7 +71,7 @@ exports.saveReasonForAuditRule = exports.fetchAuditReportGroupView = exports.fet
71
71
  exports.updateReferralListSortUiState = exports.saveReferralFormDataInLocalStore = exports.clearReferrals = exports.sendReferralInvite = exports.fetchReferrals = exports.AmountStatusTypes = exports.StatusTypes = exports.toReferralListViewSortKeyType = exports.getInviteFormView = exports.getReferralListView = exports.getNotifications = exports.getLastNotificationTime = exports.pushToastNotification = exports.isFeatureInterestRegistered = exports.getRegisteredInterestsByFeature = exports.getRegisteredInterests = exports.getFeatureNotificationView = exports.notifyMeForFeature = exports.fetchRegisteredInterests = exports.clearFeatureNotificationView = exports.getNotificationsForSelectedSubTab = exports.getExternalNotificationsForSelectedSubTab = exports.getNotificationView = exports.updateNotificationViewUIState = exports.updateNotificationViewSubTab = exports.updateNotificationViewCurrentTabAndSubTab = exports.updateNotificationViewTabState = exports.updateNotificationViewNotificationStatus = exports.updateNotificationViewAllNotificationsStatus = exports.fetchNotificationUnreadCountSuccess = exports.fetchNotificationUnreadCount = exports.fetchNotificationView = exports.toNotificationTabTypeStrict = exports.toNotificationSubTabTypeStrict = exports.updateCommentsNotificationsStatuses = exports.updateCommentsNotifications = exports.toNotificationModeStrict = exports.parseOAuthParams = exports.getZeniOAuthApproveRedirectUrl = exports.getZeniOAuthApproveFetchState = exports.getZeniOAuthApproveError = exports.clearZeniOAuthView = exports.approveOAuthConsentSuccess = exports.approveOAuthConsentFailure = exports.approveOAuthConsent = exports.fetchZeniAccountsPromoCard = exports.getZeniAccountsPromoCard = exports.getAuthenticationView = exports.fetchCollaborationAuthToken = exports.clearAuditReportGroupViewByCompanyId = void 0;
72
72
  exports.fetchAiAccountantJobs = exports.fetchAiAccountantCustomers = exports.clearAiAccountantView = exports.cancelAiAccountantOnboarding = exports.getAiAccountantJobsByTenantId = exports.getAiAccountantCustomers = exports.updateAiAccountantJobs = exports.updateAiAccountantCustomer = exports.updateAiAccountantCustomers = exports.clearAllAiAccountantCustomers = exports.toAiAccountantJob = exports.toAiAccountantEnrollment = exports.toAiAccountantCustomer = exports.toAiAccountantOperationType = exports.toAiAccountantJobStatus = exports.toAiAccountantEnrollmentStatus = exports.getAllowedOperationsForStatus = exports.getTreasuryFundsMaximumYield = exports.getTreasurySetupViewDetails = exports.updateTreasuryVideoViewed = exports.updateFundAllocationLocalData = exports.fetchPortfolioAllocation = exports.updatePortfolioAllocation = exports.fetchTreasuryFunds = exports.clearTreasurySetupView = exports.fetchTreasurySetupView = exports.acceptTreasuryTerms = exports.getExpressPayView = exports.resetExpressPayLocalData = exports.submitExpressPay = exports.updateExpressPayFormLocalData = exports.fetchExpressPayInitialDetails = exports.getIntlWireVerificationView = exports.updateVerificationFormLocalData = exports.submitInternationalVerificationForm = exports.fetchInternationalVerificationForm = exports.createTaskFromTaskGroupTemplate = exports.getCompanyTaskManagerView = exports.fetchTaskManagerMetrics = exports.fetchCompanyTaskManagerView = exports.toRecurringFrequency = exports.toDayOfWeek = exports.getRecurringEndDateFromCount = exports.getMinAllowedEndDate = exports.SEMI_WEEKLY_REQUIRED_DAYS_COUNT = exports.ALL_WEEK_DAYS = exports.updateReferViewed = exports.getRewardsPlanCard = exports.fetchRewardsPlan = exports.resendReferralInvite = void 0;
73
73
  exports.toAiCfoChartTypeStrict = exports.toAiCfoChartType = exports.toAiCfoVisualizationTypeStrict = exports.toAiCfoVisualizationType = exports.ALL_AI_CFO_ANSWER_RESPONSE_TYPES = exports.ALL_AI_CFO_ANSWER_STATE_TYPES = exports.ALL_AI_CFO_VISUALIZATION_TYPES = exports.ALL_AI_CFO_CHARTS_TYPES = exports.getAiCfoSelectorView = exports.getAllQuestionsForChatSession = exports.getQuestionAnswerByIdForChatSession = exports.getAllQuestionAnswersForChatSession = exports.toAiCfoVisualization = exports.clearAiCfo = exports.clearSession = exports.addQuestionPayload = exports.upsertOrAddQuestionAnswerPayload = exports.upsertAnswerPayload = exports.setSessions = exports.setNewSession = exports.getSuggestedQuestionsForPageContext = exports.getAiCfoView = exports.clearAiCfoSidePanelHostPageContext = exports.applyAiCfoSidePanelHostPageTransition = exports.fetchSuggestedQuestionsFailure = exports.fetchSuggestedQuestionsSuccess = exports.fetchSuggestedQuestions = exports.updateResponseState = exports.deleteChatSession = exports.acceptMasterTOS = exports.fetchChatHistory = exports.stopSubmitQuestion = exports.stopSubmit = exports.createSessionAndSubmit = exports.clearLastContextMessage = exports.clearDeleteChatSessionStatus = exports.clearCurrentSessionId = exports.clearAiCfoView = exports.setSession = exports.clearInput = exports.updateCotCollapsedState = exports.updateCurrentInput = exports.updateAiCfoViewScrollPosition = exports.submitQuestion = exports.createSession = exports.fetchChatSessionsForUser = exports.getAiAccountantCockpitView = exports.updateAiAccountantUIState = exports.triggerAiAccountantJob = exports.setSelectedTenantIdsForJobTrigger = void 0;
74
- exports.getCashManagementOverviewBanner = exports.getCashManagementOverview = exports.bufferAmountToRisk = exports.RISK_BUFFER_AMOUNT = exports.getAutoSweepFlow = exports.updateCashManagementSettingsFetchStatus = exports.updateCashManagementSettings = exports.updateAutoSweepSettingsFetchStatus = exports.saveAutoSweepSettings = exports.fetchCashManagementSettings = exports.clearAutoSweepFlow = exports.fetchCashManagementOverviewPage = exports.fetchCashManagementBanner = exports.DEFAULT_SESSION_CONFIG = exports.SessionManager = exports.getTransactionActivityLogView = exports.fetchTransactionActivityLog = exports.BULK_UPLOAD_BAR_COMPLETE_HOLD_MS = exports.BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS = exports.getAutoTransferRuleHistory = exports.getAutoTransferRuleById = exports.getAutoTransferRules = exports.clearRuleUpdateLocalData = exports.updateRuleLocalData = exports.fetchAutoTransferReviewDetail = exports.fetchAutoTransferRuleHistory = exports.deleteAutoTransferRule = exports.updateAutoTransferRule = exports.createAutoTransferRule = exports.fetchAutoTransferRules = exports.getTreasuryTaxLetters = exports.fetchTreasuryTaxLetterList = exports.getTreasuryStatements = exports.fetchTreasuryStatementList = exports.getTreasuryTransferMoney = exports.clearTreasuryTransferMoney = exports.updateTreasuryTransferMoneyLocalData = exports.executeTreasuryTransferMoney = exports.getTreasuryDetail = exports.updateTreasuryTransactionListUIState = exports.fetchTreasuryTransactionList = exports.fetchTreasuryOverviewDetail = exports.toMessageType = exports.toMessageSender = exports.toAiCfoAnswerResponseTypeStrict = exports.toAiCfoAnswerResponseType = exports.toAiCfoAnswerStateTypeStrict = exports.toAiCfoAnswerStateType = void 0;
74
+ exports.getCashManagementOverviewBanner = exports.getCashManagementOverview = exports.bufferAmountToRisk = exports.RISK_BUFFER_AMOUNT = exports.getAutoSweepFlow = exports.updateCashManagementSettingsFetchStatus = exports.updateCashManagementSettings = exports.updateAutoSweepSettingsFetchStatus = exports.updateAutoSweepDraft = exports.saveAutoSweepSettings = exports.fetchCashManagementSettings = exports.clearAutoSweepFlow = exports.fetchCashManagementOverviewPage = exports.fetchCashManagementBanner = exports.DEFAULT_SESSION_CONFIG = exports.SessionManager = exports.getTransactionActivityLogView = exports.fetchTransactionActivityLog = exports.BULK_UPLOAD_BAR_COMPLETE_HOLD_MS = exports.BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS = exports.getAutoTransferRuleHistory = exports.getAutoTransferRuleById = exports.getAutoTransferRules = exports.clearRuleUpdateLocalData = exports.updateRuleLocalData = exports.fetchAutoTransferReviewDetail = exports.fetchAutoTransferRuleHistory = exports.deleteAutoTransferRule = exports.updateAutoTransferRule = exports.createAutoTransferRule = exports.fetchAutoTransferRules = exports.getTreasuryTaxLetters = exports.fetchTreasuryTaxLetterList = exports.getTreasuryStatements = exports.fetchTreasuryStatementList = exports.getTreasuryTransferMoney = exports.clearTreasuryTransferMoney = exports.updateTreasuryTransferMoneyLocalData = exports.executeTreasuryTransferMoney = exports.getTreasuryDetail = exports.updateTreasuryTransactionListUIState = exports.fetchTreasuryTransactionList = exports.fetchTreasuryOverviewDetail = exports.toMessageType = exports.toMessageSender = exports.toAiCfoAnswerResponseTypeStrict = exports.toAiCfoAnswerResponseType = exports.toAiCfoAnswerStateTypeStrict = exports.toAiCfoAnswerStateType = void 0;
75
75
  const allowedValue_1 = require("./commonStateTypes/allowedValue");
76
76
  Object.defineProperty(exports, "isAllowedValueWithCode", { enumerable: true, get: function () { return allowedValue_1.isAllowedValueWithCode; } });
77
77
  Object.defineProperty(exports, "isAllowedValueWithID", { enumerable: true, get: function () { return allowedValue_1.isAllowedValueWithID; } });
@@ -2339,6 +2339,7 @@ var autoSweepFlowReducer_1 = require("./view/spendManagement/cashManagement/auto
2339
2339
  Object.defineProperty(exports, "clearAutoSweepFlow", { enumerable: true, get: function () { return autoSweepFlowReducer_1.clearAutoSweepFlow; } });
2340
2340
  Object.defineProperty(exports, "fetchCashManagementSettings", { enumerable: true, get: function () { return autoSweepFlowReducer_1.fetchCashManagementSettings; } });
2341
2341
  Object.defineProperty(exports, "saveAutoSweepSettings", { enumerable: true, get: function () { return autoSweepFlowReducer_1.saveAutoSweepSettings; } });
2342
+ Object.defineProperty(exports, "updateAutoSweepDraft", { enumerable: true, get: function () { return autoSweepFlowReducer_1.updateAutoSweepDraft; } });
2342
2343
  Object.defineProperty(exports, "updateAutoSweepSettingsFetchStatus", { enumerable: true, get: function () { return autoSweepFlowReducer_1.updateAutoSweepSettingsFetchStatus; } });
2343
2344
  Object.defineProperty(exports, "updateCashManagementSettings", { enumerable: true, get: function () { return autoSweepFlowReducer_1.updateCashManagementSettings; } });
2344
2345
  Object.defineProperty(exports, "updateCashManagementSettingsFetchStatus", { enumerable: true, get: function () { return autoSweepFlowReducer_1.updateCashManagementSettingsFetchStatus; } });
@@ -1,5 +1,6 @@
1
1
  import { Amount } from '../../../../commonStateTypes/amount';
2
2
  import { ID } from '../../../../commonStateTypes/common';
3
+ import { DepositAccountPayload } from '../../../../entity/depositAccount/depositAccountPayload';
3
4
  import { ZeniAPIResponse } from '../../../../responsePayload';
4
5
  import { AutoSweepFlowState, AutoSweepFrequency } from './autoSweepFlowState';
5
6
  /**
@@ -7,46 +8,38 @@ import { AutoSweepFlowState, AutoSweepFrequency } from './autoSweepFlowState';
7
8
  * cash-management-agent contract; `minimum_buffer_usd` is a plain number
8
9
  * (the slice tracks the canonical `Amount` value).
9
10
  */
10
- export interface SaveAutoSweepSettingsBody {
11
+ export type SaveAutoSweepSettingsBody = {
11
12
  first_transfer_date: string;
12
13
  frequency: string;
13
14
  memo: string;
14
15
  minimum_buffer_usd: number;
15
- }
16
+ };
16
17
  export type SaveAutoSweepSettingsResponse = ZeniAPIResponse<unknown>;
17
18
  export declare const toSaveAutoSweepSettingsBody: (state: Pick<AutoSweepFlowState, "bufferAmount" | "frequency" | "memo">) => SaveAutoSweepSettingsBody;
18
19
  /**
19
- * Subset of the source bank account payload the cash-management settings
20
- * endpoint embeds. Kept narrow on purpose we only consume the fields the
21
- * banner / setup flow needs today (account id + balances + currency). The
22
- * rest of the deposit-account shape is available via the deposit-account
23
- * entity bucket if a caller needs more.
20
+ * `source_bank_account` on the cash-management settings response matches the
21
+ * shared `DepositAccountPayload` shape, so the fetch epic dispatches it into
22
+ * the deposit-account entity bucket and the auto-sweep slice only keeps the
23
+ * id. The selector hydrates the full `FundingAccount` on read.
24
24
  */
25
- export interface CashManagementSettingsSourceBankAccountPayload {
26
- balances?: {
27
- available?: number;
28
- currency_code?: string;
29
- currency_symbol?: string;
30
- current?: number;
31
- hold?: number;
32
- };
33
- deposit_account_id?: string;
34
- }
35
25
  export interface CashManagementSettingsPayload {
36
26
  cash_management_settings_id: string | null;
37
27
  frequency: string;
38
28
  minimum_buffer_usd: number;
39
- source_bank_account: CashManagementSettingsSourceBankAccountPayload;
29
+ source_bank_account: DepositAccountPayload;
40
30
  }
41
31
  export type CashManagementSettingsResponse = ZeniAPIResponse<CashManagementSettingsPayload>;
42
32
  /**
43
33
  * Map a `GET /cash-management/settings` payload into the slice's writable
44
34
  * fields. Defensive on the frequency (string-from-the-wire → union via
45
35
  * `toAutoSweepFrequency`, falling back to `'weekly'` if the server returns
46
- * something we don't model yet).
36
+ * something we don't model yet). Only the source account *id* is stored
37
+ * here — the full deposit-account payload is published to the entity bucket
38
+ * by the fetch epic.
47
39
  */
48
40
  export declare const toAutoSweepFlowStatePatch: (payload: CashManagementSettingsPayload) => {
49
41
  bufferAmount: Amount;
50
42
  frequency: AutoSweepFrequency;
43
+ primaryFundingAccountId?: ID;
51
44
  settingsId?: ID;
52
45
  };
@@ -15,7 +15,9 @@ exports.toSaveAutoSweepSettingsBody = toSaveAutoSweepSettingsBody;
15
15
  * Map a `GET /cash-management/settings` payload into the slice's writable
16
16
  * fields. Defensive on the frequency (string-from-the-wire → union via
17
17
  * `toAutoSweepFrequency`, falling back to `'weekly'` if the server returns
18
- * something we don't model yet).
18
+ * something we don't model yet). Only the source account *id* is stored
19
+ * here — the full deposit-account payload is published to the entity bucket
20
+ * by the fetch epic.
19
21
  */
20
22
  const toAutoSweepFlowStatePatch = (payload) => {
21
23
  const currencyCode = payload.source_bank_account.balances?.currency_code;
@@ -23,6 +25,7 @@ const toAutoSweepFlowStatePatch = (payload) => {
23
25
  return {
24
26
  bufferAmount: (0, amount_1.toAmount)(payload.minimum_buffer_usd, currencyCode ?? 'USD', currencySymbol ?? '$'),
25
27
  frequency: (0, autoSweepFlowState_1.toAutoSweepFrequency)(payload.frequency) ?? 'weekly',
28
+ primaryFundingAccountId: payload.source_bank_account.deposit_account_id ?? undefined,
26
29
  settingsId: payload.cash_management_settings_id ?? undefined,
27
30
  };
28
31
  };
@@ -9,11 +9,11 @@ export declare const fetchCashManagementSettings: import("@reduxjs/toolkit").Act
9
9
  }, "autoSweepFlow/updateCashManagementSettings">, updateCashManagementSettingsFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
10
10
  fetchState: FetchState;
11
11
  error?: ZeniAPIStatus;
12
- }, "autoSweepFlow/updateCashManagementSettingsFetchStatus">, saveAutoSweepSettings: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
12
+ }, "autoSweepFlow/updateCashManagementSettingsFetchStatus">, updateAutoSweepDraft: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
13
13
  bufferAmount: Amount;
14
14
  frequency: AutoSweepFrequency;
15
15
  memo: string;
16
- }, "autoSweepFlow/saveAutoSweepSettings">, updateAutoSweepSettingsFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
16
+ }, "autoSweepFlow/updateAutoSweepDraft">, saveAutoSweepSettings: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"autoSweepFlow/saveAutoSweepSettings">, updateAutoSweepSettingsFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
17
17
  fetchState: FetchState;
18
18
  error?: ZeniAPIStatus;
19
19
  }, "autoSweepFlow/updateAutoSweepSettingsFetchStatus">, clearAutoSweepFlow: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"autoSweepFlow/clearAutoSweepFlow">;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearAutoSweepFlow = exports.updateAutoSweepSettingsFetchStatus = exports.saveAutoSweepSettings = exports.updateCashManagementSettingsFetchStatus = exports.updateCashManagementSettings = exports.fetchCashManagementSettings = exports.initialState = void 0;
4
+ exports.clearAutoSweepFlow = exports.updateAutoSweepSettingsFetchStatus = exports.saveAutoSweepSettings = exports.updateAutoSweepDraft = exports.updateCashManagementSettingsFetchStatus = exports.updateCashManagementSettings = exports.fetchCashManagementSettings = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const autoSweepFlowPayload_1 = require("./autoSweepFlowPayload");
7
7
  const autoSweepFlowState_1 = require("./autoSweepFlowState");
@@ -26,6 +26,7 @@ const autoSweepFlow = (0, toolkit_1.createSlice)({
26
26
  const patch = (0, autoSweepFlowPayload_1.toAutoSweepFlowStatePatch)(action.payload.data);
27
27
  draft.bufferAmount = patch.bufferAmount;
28
28
  draft.frequency = patch.frequency;
29
+ draft.primaryFundingAccountId = patch.primaryFundingAccountId;
29
30
  draft.settingsId = patch.settingsId;
30
31
  draft.fetchState = 'Completed';
31
32
  draft.error = undefined;
@@ -35,13 +36,25 @@ const autoSweepFlow = (0, toolkit_1.createSlice)({
35
36
  draft.error = action.payload.error;
36
37
  },
37
38
  /**
38
- * Persists the form values into state and flips `saveStatus` to
39
- * `In-Progress`; the save epic picks this up and PUTs the settings.
39
+ * Stage the in-flight form values without submitting them fired from
40
+ * the setup→review transition so other selectors (and devtools) can see
41
+ * what the user is about to confirm. Leaves `saveStatus` untouched; the
42
+ * actual PUT only kicks off when the user clicks "Confirm Sweep" via
43
+ * `saveAutoSweepSettings`.
40
44
  */
41
- saveAutoSweepSettings(draft, action) {
45
+ updateAutoSweepDraft(draft, action) {
42
46
  draft.bufferAmount = action.payload.bufferAmount;
43
47
  draft.frequency = action.payload.frequency;
44
48
  draft.memo = action.payload.memo;
49
+ },
50
+ /**
51
+ * Trigger the PUT for the auto-sweep settings already staged via
52
+ * `updateAutoSweepDraft`. Carries no payload — flips `saveStatus` to
53
+ * `In-Progress` and the save epic reads `bufferAmount` / `frequency` /
54
+ * `memo` straight from the slice. Callers must ensure those fields
55
+ * reflect the user's latest input before dispatching.
56
+ */
57
+ saveAutoSweepSettings(draft) {
45
58
  draft.saveStatus = { fetchState: 'In-Progress', error: undefined };
46
59
  },
47
60
  updateAutoSweepSettingsFetchStatus(draft, action) {
@@ -55,5 +68,5 @@ const autoSweepFlow = (0, toolkit_1.createSlice)({
55
68
  },
56
69
  },
57
70
  });
58
- _a = autoSweepFlow.actions, exports.fetchCashManagementSettings = _a.fetchCashManagementSettings, exports.updateCashManagementSettings = _a.updateCashManagementSettings, exports.updateCashManagementSettingsFetchStatus = _a.updateCashManagementSettingsFetchStatus, exports.saveAutoSweepSettings = _a.saveAutoSweepSettings, exports.updateAutoSweepSettingsFetchStatus = _a.updateAutoSweepSettingsFetchStatus, exports.clearAutoSweepFlow = _a.clearAutoSweepFlow;
71
+ _a = autoSweepFlow.actions, exports.fetchCashManagementSettings = _a.fetchCashManagementSettings, exports.updateCashManagementSettings = _a.updateCashManagementSettings, exports.updateCashManagementSettingsFetchStatus = _a.updateCashManagementSettingsFetchStatus, exports.updateAutoSweepDraft = _a.updateAutoSweepDraft, exports.saveAutoSweepSettings = _a.saveAutoSweepSettings, exports.updateAutoSweepSettingsFetchStatus = _a.updateAutoSweepSettingsFetchStatus, exports.clearAutoSweepFlow = _a.clearAutoSweepFlow;
59
72
  exports.default = autoSweepFlow.reducer;
@@ -2,15 +2,32 @@ import { Amount } from '../../../../commonStateTypes/amount';
2
2
  import { FetchStateAndError, ID } from '../../../../commonStateTypes/common';
3
3
  import { SelectorView } from '../../../../commonStateTypes/viewAndReport/viewAndReport';
4
4
  import { RootState } from '../../../../reducer';
5
+ import { FundingAccount } from '../../commonSetup/setupViewSelector';
6
+ import { TreasurySummaryWithBalance } from '../../treasury/treasuryList/treasuryDetailState';
5
7
  import { AutoSweepFrequency, RiskLevel } from './autoSweepFlowState';
6
- export interface AutoSweepFlowSelectorView extends SelectorView {
8
+ /**
9
+ * The editable form state behind `<AutoSweepSetupPage>`. Kept as a nested
10
+ * object on the selector view so the screen can pass it through as a single
11
+ * unit and the rest of the view (server-derived data + statuses) stays
12
+ * separate from "what the user is currently editing".
13
+ */
14
+ export interface AutoSweepFlowFormData {
7
15
  bufferAmount: Amount;
8
16
  frequency: AutoSweepFrequency;
9
17
  memo: string;
10
18
  /** Derived from `bufferAmount` — the matching preset risk level, falling
11
19
  * back to `'moderate'` for custom server-side values. */
12
20
  risk: RiskLevel;
21
+ }
22
+ export interface AutoSweepFlowSelectorView extends SelectorView {
23
+ formData: AutoSweepFlowFormData;
13
24
  saveStatus: FetchStateAndError;
25
+ /** Resolved from `primaryFundingAccountId` against the deposit-account
26
+ * entity bucket. `undefined` until the GET fetch publishes the account. */
27
+ primaryFundingAccount?: FundingAccount;
14
28
  settingsId?: ID;
29
+ /** Treasury account summary used by the setup / review flow to render the
30
+ * destination column. Mirrors `getTreasuryDetail().accountSummary`. */
31
+ treasurySummary?: TreasurySummaryWithBalance;
15
32
  }
16
33
  export declare const getAutoSweepFlow: (state: RootState) => AutoSweepFlowSelectorView;
@@ -1,18 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAutoSweepFlow = void 0;
4
+ const depositAccountSelector_1 = require("../../../../entity/depositAccount/depositAccountSelector");
5
+ const setupViewSelector_1 = require("../../commonSetup/setupViewSelector");
6
+ const treasuryDetailSelector_1 = require("../../treasury/treasuryList/treasuryDetailSelector");
4
7
  const autoSweepFlowState_1 = require("./autoSweepFlowState");
5
8
  const getAutoSweepFlow = (state) => {
6
- const { bufferAmount, frequency, memo, saveStatus, settingsId, fetchState, error, } = state.autoSweepFlowState;
9
+ const { bufferAmount, frequency, memo, saveStatus, settingsId, primaryFundingAccountId, fetchState, error, } = state.autoSweepFlowState;
10
+ const depositAccount = primaryFundingAccountId != null
11
+ ? (0, depositAccountSelector_1.getDepositAccountByDepositAccountId)(state.depositAccountState, primaryFundingAccountId)
12
+ : undefined;
7
13
  return {
8
14
  fetchState,
9
15
  error,
10
- bufferAmount,
11
- frequency,
12
- memo,
13
- risk: (0, autoSweepFlowState_1.bufferAmountToRisk)(bufferAmount.amount),
16
+ formData: {
17
+ bufferAmount,
18
+ frequency,
19
+ memo,
20
+ risk: (0, autoSweepFlowState_1.bufferAmountToRisk)(bufferAmount.amount),
21
+ },
22
+ primaryFundingAccount: depositAccount != null
23
+ ? (0, setupViewSelector_1.mapDepositAccToFundingAccount)(depositAccount)
24
+ : undefined,
14
25
  saveStatus,
15
26
  settingsId,
27
+ treasurySummary: (0, treasuryDetailSelector_1.getTreasuryDetail)(state).accountSummary,
16
28
  version: 0,
17
29
  };
18
30
  };
@@ -39,6 +39,13 @@ export interface AutoSweepFlowState extends FetchStateAndError {
39
39
  frequency: AutoSweepFrequency;
40
40
  memo: string;
41
41
  saveStatus: FetchStateAndError;
42
+ /**
43
+ * Deposit-account id of the primary funding account returned by GET
44
+ * `/cash-management/settings`. The selector resolves it against the
45
+ * deposit-account entity bucket via `getDepositAccountByDepositAccountId`
46
+ * and exposes a hydrated `FundingAccount`.
47
+ */
48
+ primaryFundingAccountId?: ID;
42
49
  settingsId?: ID;
43
50
  }
44
51
  export declare const initialAutoSweepFlowState: AutoSweepFlowState;
@@ -45,6 +45,7 @@ exports.initialAutoSweepFlowState = {
45
45
  frequency: 'weekly',
46
46
  memo: '',
47
47
  saveStatus: { fetchState: 'Not-Started', error: undefined },
48
+ primaryFundingAccountId: undefined,
48
49
  settingsId: undefined,
49
50
  fetchState: 'Not-Started',
50
51
  error: undefined,
@@ -1,9 +1,10 @@
1
1
  import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { Observable } from 'rxjs';
3
+ import { updateDepositAccounts } from '../../../../../entity/depositAccount/depositAccountReducer';
3
4
  import { RootState } from '../../../../../reducer';
4
5
  import { ZeniAPI } from '../../../../../zeniAPI';
5
6
  import { fetchCashManagementSettings, updateCashManagementSettings, updateCashManagementSettingsFetchStatus } from '../autoSweepFlowReducer';
6
- export type ActionType = ReturnType<typeof fetchCashManagementSettings> | ReturnType<typeof updateCashManagementSettings> | ReturnType<typeof updateCashManagementSettingsFetchStatus>;
7
+ export type ActionType = ReturnType<typeof fetchCashManagementSettings> | ReturnType<typeof updateCashManagementSettings> | ReturnType<typeof updateCashManagementSettingsFetchStatus> | ReturnType<typeof updateDepositAccounts>;
7
8
  /**
8
9
  * Hits `GET /cash-management/settings` and hydrates the auto-sweep slice
9
10
  * with the server's existing settings (frequency, minimum buffer, settings
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fetchCashManagementSettingsEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
+ const depositAccountReducer_1 = require("../../../../../entity/depositAccount/depositAccountReducer");
6
7
  const responsePayload_1 = require("../../../../../responsePayload");
7
8
  const autoSweepFlowReducer_1 = require("../autoSweepFlowReducer");
8
9
  /**
@@ -18,7 +19,12 @@ const fetchCashManagementSettingsEpic = (actions$, _state$, zeniAPI) => actions$
18
19
  .getJSON(`https://dev.api.zeni.ai/cash-management-agent/1.0/cash-management/settings`)
19
20
  .pipe((0, operators_1.mergeMap)((response) => {
20
21
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
21
- return (0, rxjs_1.of)((0, autoSweepFlowReducer_1.updateCashManagementSettings)({ data: response.data }));
22
+ return (0, rxjs_1.of)(
23
+ // Publish the source deposit account into the shared entity
24
+ // bucket so the selector can hydrate the full `FundingAccount`
25
+ // from `getDepositAccountByDepositAccountId` rather than the
26
+ // auto-sweep slice holding a duplicate copy.
27
+ (0, depositAccountReducer_1.updateDepositAccounts)([response.data.source_bank_account]), (0, autoSweepFlowReducer_1.updateCashManagementSettings)({ data: response.data }));
22
28
  }
23
29
  return (0, rxjs_1.of)((0, autoSweepFlowReducer_1.updateCashManagementSettingsFetchStatus)({
24
30
  fetchState: 'Error',
@@ -4,11 +4,4 @@ import { RootState } from '../../../../../reducer';
4
4
  import { ZeniAPI } from '../../../../../zeniAPI';
5
5
  import { saveAutoSweepSettings, updateAutoSweepSettingsFetchStatus } from '../autoSweepFlowReducer';
6
6
  export type ActionType = ReturnType<typeof saveAutoSweepSettings> | ReturnType<typeof updateAutoSweepSettingsFetchStatus>;
7
- /**
8
- * Hits `PUT /cash-management/settings` with the values the user just
9
- * confirmed in the auto-sweep flow.
10
- *
11
- * TODO: switch the endpoint to a base URL constant once the prod endpoint
12
- * lands; right now this hits the dev environment directly.
13
- */
14
- export declare const saveAutoSweepSettingsEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
7
+ export declare const saveAutoSweepSettingsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -6,26 +6,27 @@ const operators_1 = require("rxjs/operators");
6
6
  const responsePayload_1 = require("../../../../../responsePayload");
7
7
  const autoSweepFlowPayload_1 = require("../autoSweepFlowPayload");
8
8
  const autoSweepFlowReducer_1 = require("../autoSweepFlowReducer");
9
- /**
10
- * Hits `PUT /cash-management/settings` with the values the user just
11
- * confirmed in the auto-sweep flow.
12
- *
13
- * TODO: switch the endpoint to a base URL constant once the prod endpoint
14
- * lands; right now this hits the dev environment directly.
15
- */
16
- const saveAutoSweepSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(autoSweepFlowReducer_1.saveAutoSweepSettings.match), (0, operators_1.switchMap)((action) => zeniAPI
17
- .putAndGetJSON(`https://dev.api.zeni.ai/cash-management-agent/1.0/cash-management/settings`, (0, autoSweepFlowPayload_1.toSaveAutoSweepSettingsBody)(action.payload))
18
- .pipe((0, operators_1.mergeMap)((response) => {
19
- if ((0, responsePayload_1.isSuccessResponse)(response)) {
20
- return (0, rxjs_1.of)((0, autoSweepFlowReducer_1.updateAutoSweepSettingsFetchStatus)({ fetchState: 'Completed' }));
21
- }
22
- return (0, rxjs_1.of)((0, autoSweepFlowReducer_1.updateAutoSweepSettingsFetchStatus)({
9
+ const saveAutoSweepSettingsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(autoSweepFlowReducer_1.saveAutoSweepSettings.match), (0, operators_1.switchMap)(() => {
10
+ const { bufferAmount, frequency, memo } = state$.value.autoSweepFlowState;
11
+ const payload = (0, autoSweepFlowPayload_1.toSaveAutoSweepSettingsBody)({
12
+ bufferAmount,
13
+ frequency,
14
+ memo,
15
+ });
16
+ return zeniAPI
17
+ .putAndGetJSON(`https://dev.api.zeni.ai/cash-management-agent/1.0/cash-management/settings`, payload)
18
+ .pipe((0, operators_1.mergeMap)((response) => {
19
+ if ((0, responsePayload_1.isSuccessResponse)(response)) {
20
+ return (0, rxjs_1.of)((0, autoSweepFlowReducer_1.updateAutoSweepSettingsFetchStatus)({ fetchState: 'Completed' }));
21
+ }
22
+ return (0, rxjs_1.of)((0, autoSweepFlowReducer_1.updateAutoSweepSettingsFetchStatus)({
23
+ fetchState: 'Error',
24
+ error: response.status,
25
+ }));
26
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, autoSweepFlowReducer_1.updateAutoSweepSettingsFetchStatus)({
23
27
  fetchState: 'Error',
24
- error: response.status,
25
- }));
26
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, autoSweepFlowReducer_1.updateAutoSweepSettingsFetchStatus)({
27
- fetchState: 'Error',
28
- error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Save auto-sweep settings REST API call errored out' +
29
- JSON.stringify(error)),
30
- }))))));
28
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Save auto-sweep settings REST API call errored out' +
29
+ JSON.stringify(error)),
30
+ }))));
31
+ }));
31
32
  exports.saveAutoSweepSettingsEpic = saveAutoSweepSettingsEpic;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.82-betaAK1",
3
+ "version": "5.0.82-betaAK3",
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",