@zeniai/client-epic-state 5.0.82-betaAK2 → 5.0.82-betaAK4
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/index.js +1 -1
- package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowReducer.js +16 -4
- package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector.js +2 -0
- package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/epics/saveAutoSweepSettingsEpic.js +22 -21
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -1
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowPayload.d.ts +2 -2
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowReducer.d.ts +2 -2
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowReducer.js +17 -5
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector.d.ts +7 -0
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector.js +2 -0
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowState.d.ts +0 -16
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/epics/saveAutoSweepSettingsEpic.d.ts +1 -8
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/epics/saveAutoSweepSettingsEpic.js +22 -21
- 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';
|
|
@@ -32,13 +32,25 @@ const autoSweepFlow = createSlice({
|
|
|
32
32
|
draft.error = action.payload.error;
|
|
33
33
|
},
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
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`.
|
|
37
40
|
*/
|
|
38
|
-
|
|
41
|
+
updateAutoSweepDraft(draft, action) {
|
|
39
42
|
draft.bufferAmount = action.payload.bufferAmount;
|
|
40
43
|
draft.frequency = action.payload.frequency;
|
|
41
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) {
|
|
42
54
|
draft.saveStatus = { fetchState: 'In-Progress', error: undefined };
|
|
43
55
|
},
|
|
44
56
|
updateAutoSweepSettingsFetchStatus(draft, action) {
|
|
@@ -52,5 +64,5 @@ const autoSweepFlow = createSlice({
|
|
|
52
64
|
},
|
|
53
65
|
},
|
|
54
66
|
});
|
|
55
|
-
export const { fetchCashManagementSettings, updateCashManagementSettings, updateCashManagementSettingsFetchStatus, saveAutoSweepSettings, updateAutoSweepSettingsFetchStatus, clearAutoSweepFlow, } = autoSweepFlow.actions;
|
|
67
|
+
export const { fetchCashManagementSettings, updateCashManagementSettings, updateCashManagementSettingsFetchStatus, updateAutoSweepDraft, saveAutoSweepSettings, updateAutoSweepSettingsFetchStatus, clearAutoSweepFlow, } = autoSweepFlow.actions;
|
|
56
68
|
export default autoSweepFlow.reducer;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getDepositAccountByDepositAccountId } from '../../../../entity/depositAccount/depositAccountSelector';
|
|
2
2
|
import { mapDepositAccToFundingAccount, } from '../../commonSetup/setupViewSelector';
|
|
3
3
|
import { getTreasuryDetail } from '../../treasury/treasuryList/treasuryDetailSelector';
|
|
4
|
+
import { getCashManagementOverviewBanner } from '../cashManagementOverview/cashManagementOverviewSelector';
|
|
4
5
|
import { bufferAmountToRisk, } from './autoSweepFlowState';
|
|
5
6
|
export const getAutoSweepFlow = (state) => {
|
|
6
7
|
const { bufferAmount, frequency, memo, saveStatus, settingsId, primaryFundingAccountId, fetchState, error, } = state.autoSweepFlowState;
|
|
@@ -21,6 +22,7 @@ export const getAutoSweepFlow = (state) => {
|
|
|
21
22
|
: undefined,
|
|
22
23
|
saveStatus,
|
|
23
24
|
settingsId,
|
|
25
|
+
sweepAmount: getCashManagementOverviewBanner(state).amount,
|
|
24
26
|
treasurySummary: getTreasuryDetail(state).accountSummary,
|
|
25
27
|
version: 0,
|
|
26
28
|
};
|
package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/epics/saveAutoSweepSettingsEpic.js
CHANGED
|
@@ -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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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:
|
|
22
|
-
|
|
23
|
-
})
|
|
24
|
-
|
|
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,7 +938,7 @@ 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
943
|
export type { AutoSweepFlowFormData, AutoSweepFlowSelectorView, } from './view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector';
|
|
944
944
|
export { RISK_BUFFER_AMOUNT, bufferAmountToRisk, } from './view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowState';
|
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; } });
|
|
@@ -8,12 +8,12 @@ import { AutoSweepFlowState, AutoSweepFrequency } from './autoSweepFlowState';
|
|
|
8
8
|
* cash-management-agent contract; `minimum_buffer_usd` is a plain number
|
|
9
9
|
* (the slice tracks the canonical `Amount` value).
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export type SaveAutoSweepSettingsBody = {
|
|
12
12
|
first_transfer_date: string;
|
|
13
13
|
frequency: string;
|
|
14
14
|
memo: string;
|
|
15
15
|
minimum_buffer_usd: number;
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
export type SaveAutoSweepSettingsResponse = ZeniAPIResponse<unknown>;
|
|
18
18
|
export declare const toSaveAutoSweepSettingsBody: (state: Pick<AutoSweepFlowState, "bufferAmount" | "frequency" | "memo">) => SaveAutoSweepSettingsBody;
|
|
19
19
|
/**
|
|
@@ -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">,
|
|
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");
|
|
@@ -36,13 +36,25 @@ const autoSweepFlow = (0, toolkit_1.createSlice)({
|
|
|
36
36
|
draft.error = action.payload.error;
|
|
37
37
|
},
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
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`.
|
|
41
44
|
*/
|
|
42
|
-
|
|
45
|
+
updateAutoSweepDraft(draft, action) {
|
|
43
46
|
draft.bufferAmount = action.payload.bufferAmount;
|
|
44
47
|
draft.frequency = action.payload.frequency;
|
|
45
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) {
|
|
46
58
|
draft.saveStatus = { fetchState: 'In-Progress', error: undefined };
|
|
47
59
|
},
|
|
48
60
|
updateAutoSweepSettingsFetchStatus(draft, action) {
|
|
@@ -56,5 +68,5 @@ const autoSweepFlow = (0, toolkit_1.createSlice)({
|
|
|
56
68
|
},
|
|
57
69
|
},
|
|
58
70
|
});
|
|
59
|
-
_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;
|
|
60
72
|
exports.default = autoSweepFlow.reducer;
|
|
@@ -22,6 +22,13 @@ export interface AutoSweepFlowFormData {
|
|
|
22
22
|
export interface AutoSweepFlowSelectorView extends SelectorView {
|
|
23
23
|
formData: AutoSweepFlowFormData;
|
|
24
24
|
saveStatus: FetchStateAndError;
|
|
25
|
+
/**
|
|
26
|
+
* Recommended sweep amount. Sourced from the cash management banner
|
|
27
|
+
* (the first money_movements[0].movements[0].amount returned by the
|
|
28
|
+
* agent's `/recommend` endpoint). Defaults to zero when the agent
|
|
29
|
+
* hasn't returned a movement yet.
|
|
30
|
+
*/
|
|
31
|
+
sweepAmount: Amount;
|
|
25
32
|
/** Resolved from `primaryFundingAccountId` against the deposit-account
|
|
26
33
|
* entity bucket. `undefined` until the GET fetch publishes the account. */
|
|
27
34
|
primaryFundingAccount?: FundingAccount;
|
|
@@ -4,6 +4,7 @@ exports.getAutoSweepFlow = void 0;
|
|
|
4
4
|
const depositAccountSelector_1 = require("../../../../entity/depositAccount/depositAccountSelector");
|
|
5
5
|
const setupViewSelector_1 = require("../../commonSetup/setupViewSelector");
|
|
6
6
|
const treasuryDetailSelector_1 = require("../../treasury/treasuryList/treasuryDetailSelector");
|
|
7
|
+
const cashManagementOverviewSelector_1 = require("../cashManagementOverview/cashManagementOverviewSelector");
|
|
7
8
|
const autoSweepFlowState_1 = require("./autoSweepFlowState");
|
|
8
9
|
const getAutoSweepFlow = (state) => {
|
|
9
10
|
const { bufferAmount, frequency, memo, saveStatus, settingsId, primaryFundingAccountId, fetchState, error, } = state.autoSweepFlowState;
|
|
@@ -24,6 +25,7 @@ const getAutoSweepFlow = (state) => {
|
|
|
24
25
|
: undefined,
|
|
25
26
|
saveStatus,
|
|
26
27
|
settingsId,
|
|
28
|
+
sweepAmount: (0, cashManagementOverviewSelector_1.getCashManagementOverviewBanner)(state).amount,
|
|
27
29
|
treasurySummary: (0, treasuryDetailSelector_1.getTreasuryDetail)(state).accountSummary,
|
|
28
30
|
version: 0,
|
|
29
31
|
};
|
|
@@ -24,27 +24,11 @@ export declare const RISK_BUFFER_AMOUNT: Record<RiskLevel, number>;
|
|
|
24
24
|
* uses this so it can pre-select the user's existing band on edit.
|
|
25
25
|
*/
|
|
26
26
|
export declare const bufferAmountToRisk: (amount: number) => RiskLevel;
|
|
27
|
-
/**
|
|
28
|
-
* Auto-sweep configuration state.
|
|
29
|
-
*
|
|
30
|
-
* `fetchState` / `error` (inherited from `FetchStateAndError`) track the
|
|
31
|
-
* GET `/cash-management/settings` fetch. `saveStatus` tracks the PUT save
|
|
32
|
-
* separately so the two flows don't stomp on each other's status.
|
|
33
|
-
*
|
|
34
|
-
* `settingsId` is the server-issued id (nullable on the wire — undefined
|
|
35
|
-
* here when the agent has no settings record yet).
|
|
36
|
-
*/
|
|
37
27
|
export interface AutoSweepFlowState extends FetchStateAndError {
|
|
38
28
|
bufferAmount: Amount;
|
|
39
29
|
frequency: AutoSweepFrequency;
|
|
40
30
|
memo: string;
|
|
41
31
|
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
32
|
primaryFundingAccountId?: ID;
|
|
49
33
|
settingsId?: ID;
|
|
50
34
|
}
|
package/lib/view/spendManagement/cashManagement/autoSweepFlow/epics/saveAutoSweepSettingsEpic.d.ts
CHANGED
|
@@ -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>;
|
package/lib/view/spendManagement/cashManagement/autoSweepFlow/epics/saveAutoSweepSettingsEpic.js
CHANGED
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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:
|
|
25
|
-
|
|
26
|
-
})
|
|
27
|
-
|
|
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-
|
|
3
|
+
"version": "5.0.82-betaAK4",
|
|
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",
|