@zeniai/client-epic-state 5.0.77-betaAD01 → 5.0.77-betaAK1
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/commonStateTypes/amount.d.ts +1 -0
- package/lib/commonStateTypes/amount.js +3 -1
- package/lib/entity/aiCfo/aiCfoPayload.d.ts +0 -2
- package/lib/entity/aiCfo/aiCfoReducer.d.ts +1 -1
- package/lib/entity/aiCfo/aiCfoReducer.js +3 -33
- package/lib/entity/aiCfo/aiCfoSelector.js +1 -13
- package/lib/entity/aiCfo/aiCfoState.d.ts +0 -2
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventPayload.d.ts +11 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventPayload.js +23 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventReducer.d.ts +6 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventReducer.js +31 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventSelector.d.ts +4 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventSelector.js +16 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventState.d.ts +13 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventState.js +2 -0
- package/lib/epic.d.ts +4 -2
- package/lib/epic.js +4 -2
- package/lib/esm/commonStateTypes/amount.js +1 -0
- package/lib/esm/entity/aiCfo/aiCfoReducer.js +2 -32
- package/lib/esm/entity/aiCfo/aiCfoSelector.js +1 -13
- package/lib/esm/entity/upcomingPaymentEvent/upcomingPaymentEventPayload.js +19 -0
- package/lib/esm/entity/upcomingPaymentEvent/upcomingPaymentEventReducer.js +27 -0
- package/lib/esm/entity/upcomingPaymentEvent/upcomingPaymentEventSelector.js +11 -0
- package/lib/esm/entity/upcomingPaymentEvent/upcomingPaymentEventState.js +1 -0
- package/lib/esm/epic.js +4 -2
- package/lib/esm/index.js +4 -2
- package/lib/esm/reducer.js +6 -0
- package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +1 -11
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewPayload.js +1 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer.js +82 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.js +93 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewState.js +14 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementBannerEpic.js +6 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementOverviewPageEpic.js +42 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchUpcomingPaymentEventsEpic.js +22 -0
- package/lib/index.d.ts +5 -2
- package/lib/index.js +7 -4
- package/lib/reducer.d.ts +6 -0
- package/lib/reducer.js +6 -0
- package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +1 -4
- package/lib/view/aiCfoView/aiCfoViewReducer.js +2 -12
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewPayload.d.ts +10 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewPayload.js +2 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer.d.ts +20 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer.js +86 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.d.ts +20 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.js +98 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewState.d.ts +21 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewState.js +17 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementBannerEpic.d.ts +5 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementBannerEpic.js +10 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementOverviewPageEpic.d.ts +9 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementOverviewPageEpic.js +46 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchUpcomingPaymentEventsEpic.d.ts +8 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchUpcomingPaymentEventsEpic.js +26 -0
- package/package.json +1 -1
- package/lib/esm/view/aiCfoView/epics/updateChatSessionPinEpic.js +0 -46
- package/lib/view/aiCfoView/epics/updateChatSessionPinEpic.d.ts +0 -8
- package/lib/view/aiCfoView/epics/updateChatSessionPinEpic.js +0 -50
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchUpcomingPaymentEventsEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const responsePayload_1 = require("../../../../../responsePayload");
|
|
7
|
+
const upcomingPaymentEventReducer_1 = require("../../../../../entity/upcomingPaymentEvent/upcomingPaymentEventReducer");
|
|
8
|
+
const cashManagementOverviewReducer_1 = require("../cashManagementOverviewReducer");
|
|
9
|
+
const fetchUpcomingPaymentEventsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(cashManagementOverviewReducer_1.fetchUpcomingPaymentEvents.match), (0, operators_1.switchMap)(() => zeniAPI
|
|
10
|
+
.getJSON(
|
|
11
|
+
// TODO: drop /rajat/ once the prod endpoint lands. `${zeniAPI.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/upcoming-payment-events`
|
|
12
|
+
`https://dev.api.zeni.ai/version/spend-management/rajat/1.0/upcoming-payment-events`)
|
|
13
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
14
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
15
|
+
return (0, rxjs_1.of)((0, upcomingPaymentEventReducer_1.updateUpcomingPaymentEvents)(response.data.events), (0, cashManagementOverviewReducer_1.updateUpcomingPaymentEventsList)({ data: response.data }));
|
|
16
|
+
}
|
|
17
|
+
return (0, rxjs_1.of)((0, cashManagementOverviewReducer_1.updateUpcomingPaymentEventsListFetchStatus)({
|
|
18
|
+
fetchState: 'Error',
|
|
19
|
+
error: response.status,
|
|
20
|
+
}));
|
|
21
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, cashManagementOverviewReducer_1.updateUpcomingPaymentEventsListFetchStatus)({
|
|
22
|
+
fetchState: 'Error',
|
|
23
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch upcoming payment events REST API call errored out' +
|
|
24
|
+
JSON.stringify(error)),
|
|
25
|
+
}))))));
|
|
26
|
+
exports.fetchUpcomingPaymentEventsEpic = fetchUpcomingPaymentEventsEpic;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.0.77-
|
|
3
|
+
"version": "5.0.77-betaAK1",
|
|
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",
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { EMPTY, of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
|
-
import { mergeChatSessionFromPutResponse } from '../../../entity/aiCfo/aiCfoReducer';
|
|
4
|
-
import { isSuccessResponse } from '../../../responsePayload';
|
|
5
|
-
import { updateChatSessionPin } from '../aiCfoViewReducer';
|
|
6
|
-
/**
|
|
7
|
-
* TEMP (remove after chat platform pin API is deployed everywhere):
|
|
8
|
-
* When PUT pin/unpin fails, still merge requested pin state so the drawer/navbar UX works
|
|
9
|
-
* against older backends. Revert this file when the platform supports pin or when dropping
|
|
10
|
-
* compatibility — search for `TEMP_PIN_OPTIMISTIC`.
|
|
11
|
-
*/
|
|
12
|
-
function buildOptimisticPinPayload_TEMP_PIN_OPTIMISTIC(state, chatSessionId, isPinned) {
|
|
13
|
-
const session = state.aiCfoState.aiCfoByChatSessionId[chatSessionId]?.chatSession;
|
|
14
|
-
if (session == null) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
chat_session_id: chatSessionId,
|
|
19
|
-
user_id: session.userId,
|
|
20
|
-
created_at: session.createdAt.toISOString(),
|
|
21
|
-
chat_session_summary: session.chatSessionSummary ?? null,
|
|
22
|
-
is_pinned: isPinned,
|
|
23
|
-
pinned_at: isPinned ? new Date().toISOString() : null,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export const updateChatSessionPinEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(updateChatSessionPin.match), switchMap((action) => {
|
|
27
|
-
const { chatSessionId, isPinned } = action.payload;
|
|
28
|
-
return zeniAPI
|
|
29
|
-
.putAndGetJSON(`${zeniAPI.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/sessions/${chatSessionId}`, { is_pinned: isPinned })
|
|
30
|
-
.pipe(mergeMap((response) => {
|
|
31
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
32
|
-
return of(mergeChatSessionFromPutResponse(response.data));
|
|
33
|
-
}
|
|
34
|
-
// TEMP_PIN_OPTIMISTIC — see comment above
|
|
35
|
-
const synthetic = buildOptimisticPinPayload_TEMP_PIN_OPTIMISTIC(state$.value, chatSessionId, isPinned);
|
|
36
|
-
return synthetic != null
|
|
37
|
-
? of(mergeChatSessionFromPutResponse(synthetic))
|
|
38
|
-
: EMPTY;
|
|
39
|
-
}), catchError(() => {
|
|
40
|
-
// TEMP_PIN_OPTIMISTIC — see comment above
|
|
41
|
-
const synthetic = buildOptimisticPinPayload_TEMP_PIN_OPTIMISTIC(state$.value, chatSessionId, isPinned);
|
|
42
|
-
return synthetic != null
|
|
43
|
-
? of(mergeChatSessionFromPutResponse(synthetic))
|
|
44
|
-
: EMPTY;
|
|
45
|
-
}));
|
|
46
|
-
}));
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { mergeChatSessionFromPutResponse } from '../../../entity/aiCfo/aiCfoReducer';
|
|
4
|
-
import { RootState } from '../../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../../zeniAPI';
|
|
6
|
-
import { updateChatSessionPin } from '../aiCfoViewReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof updateChatSessionPin> | ReturnType<typeof mergeChatSessionFromPutResponse>;
|
|
8
|
-
export declare const updateChatSessionPinEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateChatSessionPinEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const aiCfoReducer_1 = require("../../../entity/aiCfo/aiCfoReducer");
|
|
7
|
-
const responsePayload_1 = require("../../../responsePayload");
|
|
8
|
-
const aiCfoViewReducer_1 = require("../aiCfoViewReducer");
|
|
9
|
-
/**
|
|
10
|
-
* TEMP (remove after chat platform pin API is deployed everywhere):
|
|
11
|
-
* When PUT pin/unpin fails, still merge requested pin state so the drawer/navbar UX works
|
|
12
|
-
* against older backends. Revert this file when the platform supports pin or when dropping
|
|
13
|
-
* compatibility — search for `TEMP_PIN_OPTIMISTIC`.
|
|
14
|
-
*/
|
|
15
|
-
function buildOptimisticPinPayload_TEMP_PIN_OPTIMISTIC(state, chatSessionId, isPinned) {
|
|
16
|
-
const session = state.aiCfoState.aiCfoByChatSessionId[chatSessionId]?.chatSession;
|
|
17
|
-
if (session == null) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
chat_session_id: chatSessionId,
|
|
22
|
-
user_id: session.userId,
|
|
23
|
-
created_at: session.createdAt.toISOString(),
|
|
24
|
-
chat_session_summary: session.chatSessionSummary ?? null,
|
|
25
|
-
is_pinned: isPinned,
|
|
26
|
-
pinned_at: isPinned ? new Date().toISOString() : null,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
const updateChatSessionPinEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(aiCfoViewReducer_1.updateChatSessionPin.match), (0, operators_1.switchMap)((action) => {
|
|
30
|
-
const { chatSessionId, isPinned } = action.payload;
|
|
31
|
-
return zeniAPI
|
|
32
|
-
.putAndGetJSON(`${zeniAPI.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/sessions/${chatSessionId}`, { is_pinned: isPinned })
|
|
33
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
34
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
35
|
-
return (0, rxjs_1.of)((0, aiCfoReducer_1.mergeChatSessionFromPutResponse)(response.data));
|
|
36
|
-
}
|
|
37
|
-
// TEMP_PIN_OPTIMISTIC — see comment above
|
|
38
|
-
const synthetic = buildOptimisticPinPayload_TEMP_PIN_OPTIMISTIC(state$.value, chatSessionId, isPinned);
|
|
39
|
-
return synthetic != null
|
|
40
|
-
? (0, rxjs_1.of)((0, aiCfoReducer_1.mergeChatSessionFromPutResponse)(synthetic))
|
|
41
|
-
: rxjs_1.EMPTY;
|
|
42
|
-
}), (0, operators_1.catchError)(() => {
|
|
43
|
-
// TEMP_PIN_OPTIMISTIC — see comment above
|
|
44
|
-
const synthetic = buildOptimisticPinPayload_TEMP_PIN_OPTIMISTIC(state$.value, chatSessionId, isPinned);
|
|
45
|
-
return synthetic != null
|
|
46
|
-
? (0, rxjs_1.of)((0, aiCfoReducer_1.mergeChatSessionFromPutResponse)(synthetic))
|
|
47
|
-
: rxjs_1.EMPTY;
|
|
48
|
-
}));
|
|
49
|
-
}));
|
|
50
|
-
exports.updateChatSessionPinEpic = updateChatSessionPinEpic;
|