@zeniai/client-epic-state 5.0.82-betaAK2 → 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.
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
- * Persists the form values into state and flips `saveStatus` to
36
- * `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`.
37
40
  */
38
- saveAutoSweepSettings(draft, action) {
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;
@@ -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,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 interface SaveAutoSweepSettingsBody {
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">, 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");
@@ -36,13 +36,25 @@ const autoSweepFlow = (0, toolkit_1.createSlice)({
36
36
  draft.error = action.payload.error;
37
37
  },
38
38
  /**
39
- * Persists the form values into state and flips `saveStatus` to
40
- * `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`.
41
44
  */
42
- saveAutoSweepSettings(draft, action) {
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;
@@ -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-betaAK2",
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",