@zeniai/client-epic-state 4.19.96 → 4.19.97-betaRR0
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/epic.d.ts +6 -1
- package/lib/epic.js +6 -1
- package/lib/esm/epic.js +6 -1
- package/lib/esm/index.js +5 -2
- package/lib/esm/reducer.js +3 -0
- package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingDataRequests.js +58 -0
- package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingPayload.js +1 -0
- package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingReducer.js +103 -0
- package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingSelector.js +63 -0
- package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingState.js +5 -0
- package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/createAllAiRecommendedCardsEpic.js +62 -0
- package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/fetchAiCardRecommendationEpic.js +4 -0
- package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/fetchChainOfThoughtsForAiCardRecommendationEpic.js +4 -0
- package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/startAiCardAgentDrawerDataLoadEpic.js +10 -0
- package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +14 -1
- package/lib/esm/view/spendManagement/chargeCards/chargeCardList/fetchCardsOnboardingPageEpic.js +36 -0
- package/lib/index.d.ts +6 -2
- package/lib/index.js +22 -9
- package/lib/reducer.d.ts +3 -0
- package/lib/reducer.js +3 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingDataRequests.d.ts +7 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingDataRequests.js +62 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingPayload.d.ts +34 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingPayload.js +2 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingReducer.d.ts +7 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingReducer.js +107 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingSelector.d.ts +16 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingSelector.js +67 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingState.d.ts +63 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingState.js +8 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/createAllAiRecommendedCardsEpic.d.ts +20 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/createAllAiRecommendedCardsEpic.js +66 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/fetchAiCardRecommendationEpic.d.ts +8 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/fetchAiCardRecommendationEpic.js +8 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/fetchChainOfThoughtsForAiCardRecommendationEpic.d.ts +13 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/fetchChainOfThoughtsForAiCardRecommendationEpic.js +8 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/startAiCardAgentDrawerDataLoadEpic.d.ts +13 -0
- package/lib/view/spendManagement/chargeCards/cardsOnboarding/startAiCardAgentDrawerDataLoadEpic.js +14 -0
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +4 -1
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +15 -2
- package/lib/view/spendManagement/chargeCards/chargeCardList/fetchCardsOnboardingPageEpic.d.ts +12 -0
- package/lib/view/spendManagement/chargeCards/chargeCardList/fetchCardsOnboardingPageEpic.js +40 -0
- package/package.json +1 -1
- package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requestChainOfThoughtsForAiCardRecommendation$ = requestChainOfThoughtsForAiCardRecommendation$;
|
|
4
|
+
exports.requestAiCardRecommendation$ = requestAiCardRecommendation$;
|
|
5
|
+
const rxjs_1 = require("rxjs");
|
|
6
|
+
const operators_1 = require("rxjs/operators");
|
|
7
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
8
|
+
const cardsOnboardingReducer_1 = require("./cardsOnboardingReducer");
|
|
9
|
+
function isBareChainOfThoughtsPayload(value) {
|
|
10
|
+
if (value == null || typeof value !== 'object') {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const o = value;
|
|
14
|
+
return (typeof o.analyzing === 'string' &&
|
|
15
|
+
typeof o.thinking === 'string' &&
|
|
16
|
+
typeof o.thought_process === 'string');
|
|
17
|
+
}
|
|
18
|
+
function isBareAiCardRecommendationPayload(value) {
|
|
19
|
+
if (value == null || typeof value !== 'object') {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const o = value;
|
|
23
|
+
const pc = o.projected_coverage;
|
|
24
|
+
return (Array.isArray(o.vendor_cards) &&
|
|
25
|
+
Array.isArray(o.dept_cards) &&
|
|
26
|
+
typeof o.card_recommendation_pre_text === 'string' &&
|
|
27
|
+
(typeof pc === 'string' || typeof pc === 'number'));
|
|
28
|
+
}
|
|
29
|
+
function requestChainOfThoughtsForAiCardRecommendation$(zeniAPI) {
|
|
30
|
+
const url = `${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/chain-of-thoughts-for-ai-card-recommendation`;
|
|
31
|
+
return zeniAPI.getJSON(url).pipe((0, operators_1.mergeMap)((response) => {
|
|
32
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
33
|
+
return (0, rxjs_1.of)((0, cardsOnboardingReducer_1.updateChainOfThoughts)(response.data));
|
|
34
|
+
}
|
|
35
|
+
if (isBareChainOfThoughtsPayload(response)) {
|
|
36
|
+
return (0, rxjs_1.of)((0, cardsOnboardingReducer_1.updateChainOfThoughts)(response));
|
|
37
|
+
}
|
|
38
|
+
if ('status' in response && response.status != null) {
|
|
39
|
+
return (0, rxjs_1.of)((0, cardsOnboardingReducer_1.updateChainOfThoughtsFailure)(response.status));
|
|
40
|
+
}
|
|
41
|
+
return (0, rxjs_1.of)((0, cardsOnboardingReducer_1.updateChainOfThoughtsFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch chain of thoughts for AI card recommendation returned an invalid payload')));
|
|
42
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, cardsOnboardingReducer_1.updateChainOfThoughtsFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch chain of thoughts for AI card recommendation REST API call errored out' +
|
|
43
|
+
JSON.stringify(error))))));
|
|
44
|
+
}
|
|
45
|
+
function requestAiCardRecommendation$(zeniAPI) {
|
|
46
|
+
const url = `${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/ai-card-recommendation`;
|
|
47
|
+
return zeniAPI
|
|
48
|
+
.getJSON(url)
|
|
49
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
50
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
51
|
+
return (0, rxjs_1.of)((0, cardsOnboardingReducer_1.updateAiCardRecommendation)(response.data));
|
|
52
|
+
}
|
|
53
|
+
if (isBareAiCardRecommendationPayload(response)) {
|
|
54
|
+
return (0, rxjs_1.of)((0, cardsOnboardingReducer_1.updateAiCardRecommendation)(response));
|
|
55
|
+
}
|
|
56
|
+
if ('status' in response && response.status != null) {
|
|
57
|
+
return (0, rxjs_1.of)((0, cardsOnboardingReducer_1.updateAiCardRecommendationFailure)(response.status));
|
|
58
|
+
}
|
|
59
|
+
return (0, rxjs_1.of)((0, cardsOnboardingReducer_1.updateAiCardRecommendationFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch AI card recommendation returned an invalid payload')));
|
|
60
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, cardsOnboardingReducer_1.updateAiCardRecommendationFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch AI card recommendation REST API call errored out' +
|
|
61
|
+
JSON.stringify(error))))));
|
|
62
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ID } from '../../../../commonStateTypes/common';
|
|
2
|
+
import { ZeniAPIResponse } from '../../../../responsePayload';
|
|
3
|
+
export interface ChainOfThoughtsPayload {
|
|
4
|
+
analyzing: string;
|
|
5
|
+
thinking: string;
|
|
6
|
+
thought_process: string;
|
|
7
|
+
}
|
|
8
|
+
export type FetchChainOfThoughtsResponse = ZeniAPIResponse<ChainOfThoughtsPayload>;
|
|
9
|
+
export interface AiCardRecommendationCardItemPayload {
|
|
10
|
+
credit_limit: number;
|
|
11
|
+
name: string;
|
|
12
|
+
owner_id: string;
|
|
13
|
+
}
|
|
14
|
+
export interface AiCardRecommendationPayload {
|
|
15
|
+
card_recommendation_pre_text: string;
|
|
16
|
+
dept_cards: AiCardRecommendationCardItemPayload[];
|
|
17
|
+
projected_coverage: string | number;
|
|
18
|
+
vendor_cards: AiCardRecommendationCardItemPayload[];
|
|
19
|
+
}
|
|
20
|
+
export type FetchAiCardRecommendationResponse = ZeniAPIResponse<AiCardRecommendationPayload>;
|
|
21
|
+
/** Edited rows from the AI recommendation UI → POST `/1.0/cards` (see `createAllAiRecommendedCardsEpic`). */
|
|
22
|
+
export interface CreateAiRecommendedCardDraft {
|
|
23
|
+
/** Maps to API `card_name` (recommendation `name`). */
|
|
24
|
+
card_name: string;
|
|
25
|
+
/** Maps to `card_holder_user_ids: [owner_id]`. */
|
|
26
|
+
owner_id: ID;
|
|
27
|
+
/** Maps to API `purchase_limit` (recommendation `credit_limit`). */
|
|
28
|
+
purchase_limit: number;
|
|
29
|
+
card_type?: string;
|
|
30
|
+
currency_code?: string;
|
|
31
|
+
purchase_limit_frequency?: {
|
|
32
|
+
code: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ZeniAPIStatus } from '../../../../responsePayload';
|
|
2
|
+
import { AiCardRecommendationPayload, ChainOfThoughtsPayload, CreateAiRecommendedCardDraft } from './cardsOnboardingPayload';
|
|
3
|
+
import { CardsOnboardingState, ChainOfThoughtsRevealPhase } from './cardsOnboardingState';
|
|
4
|
+
export declare const initialState: CardsOnboardingState;
|
|
5
|
+
export declare const startAiCardAgentDrawerDataLoad: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cardsOnboarding/startAiCardAgentDrawerDataLoad">, fetchChainOfThoughtsForAiCardRecommendation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cardsOnboarding/fetchChainOfThoughtsForAiCardRecommendation">, updateChainOfThoughts: import("@reduxjs/toolkit").ActionCreatorWithPayload<ChainOfThoughtsPayload, "cardsOnboarding/updateChainOfThoughts">, updateChainOfThoughtsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "cardsOnboarding/updateChainOfThoughtsFailure">, setChainOfThoughtsRevealPhase: import("@reduxjs/toolkit").ActionCreatorWithPayload<ChainOfThoughtsRevealPhase, "cardsOnboarding/setChainOfThoughtsRevealPhase">, fetchAiCardRecommendation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cardsOnboarding/fetchAiCardRecommendation">, updateAiCardRecommendation: import("@reduxjs/toolkit").ActionCreatorWithPayload<AiCardRecommendationPayload, "cardsOnboarding/updateAiCardRecommendation">, updateAiCardRecommendationFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "cardsOnboarding/updateAiCardRecommendationFailure">, createAllAiRecommendedCards: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cards: CreateAiRecommendedCardDraft[]], CreateAiRecommendedCardDraft[], "cardsOnboarding/createAllAiRecommendedCards", never, never>, createAllAiRecommendedCardsSucceeded: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cardsOnboarding/createAllAiRecommendedCardsSucceeded">, createAllAiRecommendedCardsFailed: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "cardsOnboarding/createAllAiRecommendedCardsFailed">, clearCardsOnboarding: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cardsOnboarding/clearCardsOnboarding">;
|
|
6
|
+
declare const _default: import("redux").Reducer<CardsOnboardingState>;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.clearCardsOnboarding = exports.createAllAiRecommendedCardsFailed = exports.createAllAiRecommendedCardsSucceeded = exports.createAllAiRecommendedCards = exports.updateAiCardRecommendationFailure = exports.updateAiCardRecommendation = exports.fetchAiCardRecommendation = exports.setChainOfThoughtsRevealPhase = exports.updateChainOfThoughtsFailure = exports.updateChainOfThoughts = exports.fetchChainOfThoughtsForAiCardRecommendation = exports.startAiCardAgentDrawerDataLoad = exports.initialState = void 0;
|
|
5
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
+
const resetAiCardRecommendation = (draft) => {
|
|
7
|
+
draft.aiCardRecommendationFetchState = 'Not-Started';
|
|
8
|
+
draft.aiCardRecommendationResponse = undefined;
|
|
9
|
+
draft.aiCardRecommendationError = undefined;
|
|
10
|
+
};
|
|
11
|
+
const resetCreateAllAiRecommendedCards = (draft) => {
|
|
12
|
+
draft.createAllAiRecommendedCardsFetchState = 'Not-Started';
|
|
13
|
+
draft.createAllAiRecommendedCardsError = undefined;
|
|
14
|
+
};
|
|
15
|
+
exports.initialState = {
|
|
16
|
+
aiCardRecommendationFetchState: 'Not-Started',
|
|
17
|
+
chainOfThoughtsFetchState: 'Not-Started',
|
|
18
|
+
chainOfThoughtsRevealPhase: 'none',
|
|
19
|
+
createAllAiRecommendedCardsFetchState: 'Not-Started',
|
|
20
|
+
aiCardRecommendationError: undefined,
|
|
21
|
+
aiCardRecommendationResponse: undefined,
|
|
22
|
+
chainOfThoughtsError: undefined,
|
|
23
|
+
chainOfThoughtsResponse: undefined,
|
|
24
|
+
createAllAiRecommendedCardsError: undefined,
|
|
25
|
+
};
|
|
26
|
+
const cardsOnboarding = (0, toolkit_1.createSlice)({
|
|
27
|
+
name: 'cardsOnboarding',
|
|
28
|
+
initialState: exports.initialState,
|
|
29
|
+
reducers: {
|
|
30
|
+
startAiCardAgentDrawerDataLoad(draft) {
|
|
31
|
+
draft.chainOfThoughtsFetchState = 'In-Progress';
|
|
32
|
+
draft.chainOfThoughtsError = undefined;
|
|
33
|
+
draft.chainOfThoughtsRevealPhase = 'none';
|
|
34
|
+
draft.chainOfThoughtsResponse = undefined;
|
|
35
|
+
draft.aiCardRecommendationFetchState = 'In-Progress';
|
|
36
|
+
draft.aiCardRecommendationError = undefined;
|
|
37
|
+
draft.aiCardRecommendationResponse = undefined;
|
|
38
|
+
resetCreateAllAiRecommendedCards(draft);
|
|
39
|
+
},
|
|
40
|
+
fetchChainOfThoughtsForAiCardRecommendation(draft) {
|
|
41
|
+
draft.chainOfThoughtsFetchState = 'In-Progress';
|
|
42
|
+
draft.chainOfThoughtsError = undefined;
|
|
43
|
+
draft.chainOfThoughtsRevealPhase = 'none';
|
|
44
|
+
resetAiCardRecommendation(draft);
|
|
45
|
+
resetCreateAllAiRecommendedCards(draft);
|
|
46
|
+
},
|
|
47
|
+
updateChainOfThoughts(draft, action) {
|
|
48
|
+
draft.chainOfThoughtsResponse = toChainOfThoughtsResponse(action.payload);
|
|
49
|
+
draft.chainOfThoughtsFetchState = 'Completed';
|
|
50
|
+
draft.chainOfThoughtsRevealPhase = 'analyzing';
|
|
51
|
+
},
|
|
52
|
+
updateChainOfThoughtsFailure(draft, action) {
|
|
53
|
+
draft.chainOfThoughtsFetchState = 'Error';
|
|
54
|
+
draft.chainOfThoughtsError = action.payload;
|
|
55
|
+
draft.chainOfThoughtsRevealPhase = 'none';
|
|
56
|
+
},
|
|
57
|
+
setChainOfThoughtsRevealPhase(draft, action) {
|
|
58
|
+
draft.chainOfThoughtsRevealPhase = action.payload;
|
|
59
|
+
},
|
|
60
|
+
fetchAiCardRecommendation(draft) {
|
|
61
|
+
draft.aiCardRecommendationFetchState = 'In-Progress';
|
|
62
|
+
draft.aiCardRecommendationError = undefined;
|
|
63
|
+
},
|
|
64
|
+
updateAiCardRecommendation(draft, action) {
|
|
65
|
+
draft.aiCardRecommendationResponse = toAiCardRecommendationResponse(action.payload);
|
|
66
|
+
draft.aiCardRecommendationFetchState = 'Completed';
|
|
67
|
+
},
|
|
68
|
+
updateAiCardRecommendationFailure(draft, action) {
|
|
69
|
+
draft.aiCardRecommendationFetchState = 'Error';
|
|
70
|
+
draft.aiCardRecommendationError = action.payload;
|
|
71
|
+
},
|
|
72
|
+
createAllAiRecommendedCards: {
|
|
73
|
+
reducer(draft, action) {
|
|
74
|
+
void action;
|
|
75
|
+
draft.createAllAiRecommendedCardsFetchState = 'In-Progress';
|
|
76
|
+
draft.createAllAiRecommendedCardsError = undefined;
|
|
77
|
+
},
|
|
78
|
+
prepare(cards) {
|
|
79
|
+
return { payload: cards };
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
createAllAiRecommendedCardsSucceeded(draft) {
|
|
83
|
+
draft.createAllAiRecommendedCardsFetchState = 'Completed';
|
|
84
|
+
draft.createAllAiRecommendedCardsError = undefined;
|
|
85
|
+
},
|
|
86
|
+
createAllAiRecommendedCardsFailed(draft, action) {
|
|
87
|
+
draft.createAllAiRecommendedCardsFetchState = 'Error';
|
|
88
|
+
draft.createAllAiRecommendedCardsError = action.payload;
|
|
89
|
+
},
|
|
90
|
+
clearCardsOnboarding(draft) {
|
|
91
|
+
Object.assign(draft, exports.initialState);
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
_a = cardsOnboarding.actions, exports.startAiCardAgentDrawerDataLoad = _a.startAiCardAgentDrawerDataLoad, exports.fetchChainOfThoughtsForAiCardRecommendation = _a.fetchChainOfThoughtsForAiCardRecommendation, exports.updateChainOfThoughts = _a.updateChainOfThoughts, exports.updateChainOfThoughtsFailure = _a.updateChainOfThoughtsFailure, exports.setChainOfThoughtsRevealPhase = _a.setChainOfThoughtsRevealPhase, exports.fetchAiCardRecommendation = _a.fetchAiCardRecommendation, exports.updateAiCardRecommendation = _a.updateAiCardRecommendation, exports.updateAiCardRecommendationFailure = _a.updateAiCardRecommendationFailure, exports.createAllAiRecommendedCards = _a.createAllAiRecommendedCards, exports.createAllAiRecommendedCardsSucceeded = _a.createAllAiRecommendedCardsSucceeded, exports.createAllAiRecommendedCardsFailed = _a.createAllAiRecommendedCardsFailed, exports.clearCardsOnboarding = _a.clearCardsOnboarding;
|
|
96
|
+
exports.default = cardsOnboarding.reducer;
|
|
97
|
+
const toChainOfThoughtsResponse = (payload) => ({
|
|
98
|
+
analyzing: payload.analyzing,
|
|
99
|
+
thinking: payload.thinking,
|
|
100
|
+
thought_process: payload.thought_process,
|
|
101
|
+
});
|
|
102
|
+
const toAiCardRecommendationResponse = (payload) => ({
|
|
103
|
+
vendor_cards: payload.vendor_cards,
|
|
104
|
+
dept_cards: payload.dept_cards,
|
|
105
|
+
card_recommendation_pre_text: payload.card_recommendation_pre_text,
|
|
106
|
+
projected_coverage: String(payload.projected_coverage),
|
|
107
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RootState } from '../../../../reducer';
|
|
2
|
+
import { AiCardAgentDrawerDisplayState, AiCardRecommendationDisplayView } from './cardsOnboardingState';
|
|
3
|
+
/**
|
|
4
|
+
* Layout hints when using `startAiCardAgentDrawerDataLoad` (parallel CoT + recommendation GETs).
|
|
5
|
+
* - Run phased CoT after `hasChainOfThoughtContent`; end with `setChainOfThoughtsRevealPhase('complete')`.
|
|
6
|
+
* - Show sparkle when `showRecommendationSparkle` (AI still loading).
|
|
7
|
+
* - Render tables / pre text / coverage only when `showRecommendationSection`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getAiCardAgentDrawerDisplayState(state: RootState): AiCardAgentDrawerDisplayState;
|
|
10
|
+
/**
|
|
11
|
+
* Enriches `aiCardRecommendationResponse` with owner display name and photo from `userState`.
|
|
12
|
+
* `ownerIdsMissingFromStore` lists `owner_id`s not in `userState` after the **single** people load
|
|
13
|
+
* (e.g. `fetchCardsOnboardingPageEpic` → `fetchPeople()`). Do not refetch people from this package;
|
|
14
|
+
* show a fallback label or rely on the owner dropdown sourced from the same store.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getAiCardRecommendationDisplayView(state: RootState): AiCardRecommendationDisplayView | undefined;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAiCardAgentDrawerDisplayState = getAiCardAgentDrawerDisplayState;
|
|
4
|
+
exports.getAiCardRecommendationDisplayView = getAiCardRecommendationDisplayView;
|
|
5
|
+
const userSelector_1 = require("../../../../entity/user/userSelector");
|
|
6
|
+
function collectOwnerIds(rec) {
|
|
7
|
+
const ids = new Set();
|
|
8
|
+
for (const c of rec.vendor_cards) {
|
|
9
|
+
ids.add(c.owner_id);
|
|
10
|
+
}
|
|
11
|
+
for (const c of rec.dept_cards) {
|
|
12
|
+
ids.add(c.owner_id);
|
|
13
|
+
}
|
|
14
|
+
return [...ids];
|
|
15
|
+
}
|
|
16
|
+
function enrichCard(card, userState) {
|
|
17
|
+
const user = (0, userSelector_1.getUserByUserId)(userState, card.owner_id);
|
|
18
|
+
const hasOwnerDetails = user != null;
|
|
19
|
+
return {
|
|
20
|
+
...card,
|
|
21
|
+
hasOwnerDetails,
|
|
22
|
+
ownerDisplayName: hasOwnerDetails
|
|
23
|
+
? (0, userSelector_1.getUserName)(user) || card.owner_id
|
|
24
|
+
: card.owner_id,
|
|
25
|
+
ownerProfilePhoto: user?.photo,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Layout hints when using `startAiCardAgentDrawerDataLoad` (parallel CoT + recommendation GETs).
|
|
30
|
+
* - Run phased CoT after `hasChainOfThoughtContent`; end with `setChainOfThoughtsRevealPhase('complete')`.
|
|
31
|
+
* - Show sparkle when `showRecommendationSparkle` (AI still loading).
|
|
32
|
+
* - Render tables / pre text / coverage only when `showRecommendationSection`.
|
|
33
|
+
*/
|
|
34
|
+
function getAiCardAgentDrawerDisplayState(state) {
|
|
35
|
+
const c = state.cardsOnboardingState;
|
|
36
|
+
const cotDone = c.chainOfThoughtsRevealPhase === 'complete';
|
|
37
|
+
const aiDone = c.aiCardRecommendationFetchState === 'Completed' &&
|
|
38
|
+
c.aiCardRecommendationResponse != null;
|
|
39
|
+
return {
|
|
40
|
+
showChainOfThoughtShimmer: c.chainOfThoughtsFetchState === 'In-Progress',
|
|
41
|
+
hasChainOfThoughtContent: c.chainOfThoughtsFetchState === 'Completed' &&
|
|
42
|
+
c.chainOfThoughtsResponse != null,
|
|
43
|
+
showRecommendationSparkle: c.aiCardRecommendationFetchState === 'In-Progress',
|
|
44
|
+
showRecommendationSection: cotDone && aiDone,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Enriches `aiCardRecommendationResponse` with owner display name and photo from `userState`.
|
|
49
|
+
* `ownerIdsMissingFromStore` lists `owner_id`s not in `userState` after the **single** people load
|
|
50
|
+
* (e.g. `fetchCardsOnboardingPageEpic` → `fetchPeople()`). Do not refetch people from this package;
|
|
51
|
+
* show a fallback label or rely on the owner dropdown sourced from the same store.
|
|
52
|
+
*/
|
|
53
|
+
function getAiCardRecommendationDisplayView(state) {
|
|
54
|
+
const rec = state.cardsOnboardingState.aiCardRecommendationResponse;
|
|
55
|
+
if (rec == null) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const { userState } = state;
|
|
59
|
+
const ownerIdsMissingFromStore = collectOwnerIds(rec).filter((id) => userState.userByUserId[id] == null);
|
|
60
|
+
return {
|
|
61
|
+
card_recommendation_pre_text: rec.card_recommendation_pre_text,
|
|
62
|
+
projected_coverage: rec.projected_coverage,
|
|
63
|
+
vendor_cards: rec.vendor_cards.map((c) => enrichCard(c, userState)),
|
|
64
|
+
dept_cards: rec.dept_cards.map((c) => enrichCard(c, userState)),
|
|
65
|
+
ownerIdsMissingFromStore,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { FetchState, ID } from '../../../../commonStateTypes/common';
|
|
2
|
+
import { ZeniAPIStatus } from '../../../../responsePayload';
|
|
3
|
+
import ZeniUrl from '../../../../zeniUrl';
|
|
4
|
+
/**
|
|
5
|
+
* In-app path to open after a successful “Create All Cards” from AI recommendations
|
|
6
|
+
* (e.g. `https://qa.app.zeni.ai` + this path). Routing is handled by the host app.
|
|
7
|
+
*/
|
|
8
|
+
export declare const CREATE_ALL_AI_RECOMMENDED_CARDS_SUCCESS_APP_PATH = "/zeni.ai/cards";
|
|
9
|
+
export type ChainOfThoughtsRevealPhase = 'none' | 'analyzing' | 'thinking' | 'thought_process' | 'complete';
|
|
10
|
+
export interface ChainOfThoughtsResponse {
|
|
11
|
+
analyzing: string;
|
|
12
|
+
thinking: string;
|
|
13
|
+
thought_process: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AiCardRecommendationCardItem {
|
|
16
|
+
credit_limit: number;
|
|
17
|
+
name: string;
|
|
18
|
+
owner_id: string;
|
|
19
|
+
}
|
|
20
|
+
export interface AiCardRecommendationResponse {
|
|
21
|
+
card_recommendation_pre_text: string;
|
|
22
|
+
dept_cards: AiCardRecommendationCardItem[];
|
|
23
|
+
projected_coverage: string;
|
|
24
|
+
vendor_cards: AiCardRecommendationCardItem[];
|
|
25
|
+
}
|
|
26
|
+
/** Vendor / department row with owner resolved from `userState` when available (see `getAiCardRecommendationDisplayView`). */
|
|
27
|
+
export interface AiCardRecommendationCardRow extends AiCardRecommendationCardItem {
|
|
28
|
+
/** True when `userState.userByUserId[owner_id]` exists. */
|
|
29
|
+
hasOwnerDetails: boolean;
|
|
30
|
+
ownerDisplayName: string;
|
|
31
|
+
ownerProfilePhoto?: ZeniUrl;
|
|
32
|
+
}
|
|
33
|
+
/** UI-ready AI recommendation: enriched cards + which owner_ids still need a users fetch. */
|
|
34
|
+
export interface AiCardRecommendationDisplayView {
|
|
35
|
+
card_recommendation_pre_text: string;
|
|
36
|
+
dept_cards: AiCardRecommendationCardRow[];
|
|
37
|
+
ownerIdsMissingFromStore: ID[];
|
|
38
|
+
projected_coverage: string;
|
|
39
|
+
vendor_cards: AiCardRecommendationCardRow[];
|
|
40
|
+
}
|
|
41
|
+
/** Hints for AiCardAgentDrawer: phased CoT, sparkle while recommendations load, gated table. */
|
|
42
|
+
export interface AiCardAgentDrawerDisplayState {
|
|
43
|
+
/** CoT payload ready; run phased UI (`setChainOfThoughtsRevealPhase`) analyzing → thinking → thought_process → complete. */
|
|
44
|
+
hasChainOfThoughtContent: boolean;
|
|
45
|
+
/** Shimmer while chain-of-thoughts GET is in flight. */
|
|
46
|
+
showChainOfThoughtShimmer: boolean;
|
|
47
|
+
/** Show `card_recommendation_pre_text`, `projected_coverage`, vendor/dept tables only after CoT phases are `complete` and AI GET succeeded. */
|
|
48
|
+
showRecommendationSection: boolean;
|
|
49
|
+
/** Rotating sparkle in the recommendations block while AI recommendation GET is in flight. */
|
|
50
|
+
showRecommendationSparkle: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface CardsOnboardingState {
|
|
53
|
+
aiCardRecommendationFetchState: FetchState;
|
|
54
|
+
chainOfThoughtsFetchState: FetchState;
|
|
55
|
+
/** Phased CoT UI in the drawer; advance with `setChainOfThoughtsRevealPhase` to `complete` before showing recommendations (see `getAiCardAgentDrawerDisplayState`). */
|
|
56
|
+
chainOfThoughtsRevealPhase: ChainOfThoughtsRevealPhase;
|
|
57
|
+
createAllAiRecommendedCardsFetchState: FetchState;
|
|
58
|
+
aiCardRecommendationError?: ZeniAPIStatus;
|
|
59
|
+
aiCardRecommendationResponse?: AiCardRecommendationResponse;
|
|
60
|
+
chainOfThoughtsError?: ZeniAPIStatus;
|
|
61
|
+
chainOfThoughtsResponse?: ChainOfThoughtsResponse;
|
|
62
|
+
createAllAiRecommendedCardsError?: ZeniAPIStatus;
|
|
63
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CREATE_ALL_AI_RECOMMENDED_CARDS_SUCCESS_APP_PATH = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* In-app path to open after a successful “Create All Cards” from AI recommendations
|
|
6
|
+
* (e.g. `https://qa.app.zeni.ai` + this path). Routing is handled by the host app.
|
|
7
|
+
*/
|
|
8
|
+
exports.CREATE_ALL_AI_RECOMMENDED_CARDS_SUCCESS_APP_PATH = '/zeni.ai/cards';
|
package/lib/view/spendManagement/chargeCards/cardsOnboarding/createAllAiRecommendedCardsEpic.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { updateAddresses } from '../../../../entity/address/addressReducer';
|
|
4
|
+
import { updateChargeCards } from '../../../../entity/chargeCard/chargeCardReducer';
|
|
5
|
+
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
6
|
+
import { updateAllUsers } from '../../../../entity/user/userReducer';
|
|
7
|
+
import { updateUserRoles } from '../../../../entity/userRole/userRoleReducer';
|
|
8
|
+
import { RootState } from '../../../../reducer';
|
|
9
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
10
|
+
import { updateChargeCardList } from '../chargeCardList/chargeCardListReducer';
|
|
11
|
+
import { updateChargeCardCount, updateDebitCardCount } from '../issueChargeCard/issueChargeCardReducer';
|
|
12
|
+
import { createAllAiRecommendedCards, createAllAiRecommendedCardsFailed, createAllAiRecommendedCardsSucceeded } from './cardsOnboardingReducer';
|
|
13
|
+
export type ActionType = ReturnType<typeof createAllAiRecommendedCards> | ReturnType<typeof createAllAiRecommendedCardsSucceeded> | ReturnType<typeof createAllAiRecommendedCardsFailed> | ReturnType<typeof updateChargeCards> | ReturnType<typeof updateAllUsers> | ReturnType<typeof updateUserRoles> | ReturnType<typeof updateChargeCardList> | ReturnType<typeof updateAddresses> | ReturnType<typeof updateChargeCardCount> | ReturnType<typeof updateDebitCardCount> | ReturnType<typeof openSnackbar>;
|
|
14
|
+
/**
|
|
15
|
+
* POST `${cardMicroServiceBaseUrl}/1.0/cards` with edited AI recommendation rows.
|
|
16
|
+
* On success, merges issued cards into entity + list state (same pattern as issue charge card).
|
|
17
|
+
* Host app: when `createAllAiRecommendedCardsFetchState === 'Completed'`, navigate to
|
|
18
|
+
* `CREATE_ALL_AI_RECOMMENDED_CARDS_SUCCESS_APP_PATH`.
|
|
19
|
+
*/
|
|
20
|
+
export declare const createAllAiRecommendedCardsEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/spendManagement/chargeCards/cardsOnboarding/createAllAiRecommendedCardsEpic.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAllAiRecommendedCardsEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const addressReducer_1 = require("../../../../entity/address/addressReducer");
|
|
7
|
+
const chargeCardReducer_1 = require("../../../../entity/chargeCard/chargeCardReducer");
|
|
8
|
+
const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
|
|
9
|
+
const userReducer_1 = require("../../../../entity/user/userReducer");
|
|
10
|
+
const userRoleReducer_1 = require("../../../../entity/userRole/userRoleReducer");
|
|
11
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
12
|
+
const chargeCardListReducer_1 = require("../chargeCardList/chargeCardListReducer");
|
|
13
|
+
const issueChargeCardReducer_1 = require("../issueChargeCard/issueChargeCardReducer");
|
|
14
|
+
const cardsOnboardingReducer_1 = require("./cardsOnboardingReducer");
|
|
15
|
+
function draftsToApiCards(drafts) {
|
|
16
|
+
return drafts.map((d) => ({
|
|
17
|
+
card_holder_user_ids: [d.owner_id],
|
|
18
|
+
card_name: d.card_name,
|
|
19
|
+
card_type: d.card_type ?? 'business_virtual_credit_card',
|
|
20
|
+
currency_code: d.currency_code ?? 'USD',
|
|
21
|
+
purchase_limit: d.purchase_limit,
|
|
22
|
+
purchase_limit_frequency: d.purchase_limit_frequency ?? { code: 'monthly' },
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* POST `${cardMicroServiceBaseUrl}/1.0/cards` with edited AI recommendation rows.
|
|
27
|
+
* On success, merges issued cards into entity + list state (same pattern as issue charge card).
|
|
28
|
+
* Host app: when `createAllAiRecommendedCardsFetchState === 'Completed'`, navigate to
|
|
29
|
+
* `CREATE_ALL_AI_RECOMMENDED_CARDS_SUCCESS_APP_PATH`.
|
|
30
|
+
*/
|
|
31
|
+
const createAllAiRecommendedCardsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(cardsOnboardingReducer_1.createAllAiRecommendedCards.match), (0, operators_1.switchMap)((action) => {
|
|
32
|
+
if (action.payload.length === 0) {
|
|
33
|
+
return (0, rxjs_1.of)((0, cardsOnboardingReducer_1.createAllAiRecommendedCardsFailed)((0, responsePayload_1.createZeniAPIStatus)('Validation', 'No cards to create')));
|
|
34
|
+
}
|
|
35
|
+
const cards = draftsToApiCards(action.payload);
|
|
36
|
+
return zeniAPI
|
|
37
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards`, { cards })
|
|
38
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
39
|
+
if ((0, responsePayload_1.isSuccessStatus)(response) && response.data != null) {
|
|
40
|
+
const actions = [
|
|
41
|
+
(0, chargeCardReducer_1.updateChargeCards)(response.data.cards),
|
|
42
|
+
(0, userReducer_1.updateAllUsers)({ users: response.data.users }),
|
|
43
|
+
(0, userRoleReducer_1.updateUserRoles)(response.data.user_roles),
|
|
44
|
+
(0, chargeCardListReducer_1.updateChargeCardList)({
|
|
45
|
+
chargeCardListPayload: response.data,
|
|
46
|
+
keepExistingListItems: true,
|
|
47
|
+
}),
|
|
48
|
+
(0, addressReducer_1.updateAddresses)(response.data.addresses),
|
|
49
|
+
(0, issueChargeCardReducer_1.updateChargeCardCount)(response.data?.cards_count_by_user_id ?? []),
|
|
50
|
+
(0, issueChargeCardReducer_1.updateDebitCardCount)(response.data?.debit_cards_count_by_deposit_account_id ?? {}),
|
|
51
|
+
(0, cardsOnboardingReducer_1.createAllAiRecommendedCardsSucceeded)(),
|
|
52
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
53
|
+
messageSection: 'issue_charge_cards',
|
|
54
|
+
messageText: 'success',
|
|
55
|
+
type: 'success',
|
|
56
|
+
}),
|
|
57
|
+
];
|
|
58
|
+
return (0, rxjs_1.from)(actions);
|
|
59
|
+
}
|
|
60
|
+
return (0, rxjs_1.of)((0, cardsOnboardingReducer_1.createAllAiRecommendedCardsFailed)(response.status));
|
|
61
|
+
}), (0, operators_1.catchError)((error) => {
|
|
62
|
+
return (0, rxjs_1.of)((0, cardsOnboardingReducer_1.createAllAiRecommendedCardsFailed)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Create all AI recommended cards REST API call errored out' +
|
|
63
|
+
JSON.stringify(error))));
|
|
64
|
+
}));
|
|
65
|
+
}));
|
|
66
|
+
exports.createAllAiRecommendedCardsEpic = createAllAiRecommendedCardsEpic;
|
package/lib/view/spendManagement/chargeCards/cardsOnboarding/fetchAiCardRecommendationEpic.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../reducer';
|
|
4
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
+
import { AiCardRecommendationRequestAction } from './cardsOnboardingDataRequests';
|
|
6
|
+
import { fetchAiCardRecommendation } from './cardsOnboardingReducer';
|
|
7
|
+
export type ActionType = ReturnType<typeof fetchAiCardRecommendation> | AiCardRecommendationRequestAction;
|
|
8
|
+
export declare const fetchAiCardRecommendationEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchAiCardRecommendationEpic = void 0;
|
|
4
|
+
const operators_1 = require("rxjs/operators");
|
|
5
|
+
const cardsOnboardingDataRequests_1 = require("./cardsOnboardingDataRequests");
|
|
6
|
+
const cardsOnboardingReducer_1 = require("./cardsOnboardingReducer");
|
|
7
|
+
const fetchAiCardRecommendationEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(cardsOnboardingReducer_1.fetchAiCardRecommendation.match), (0, operators_1.switchMap)(() => (0, cardsOnboardingDataRequests_1.requestAiCardRecommendation$)(zeniAPI)));
|
|
8
|
+
exports.fetchAiCardRecommendationEpic = fetchAiCardRecommendationEpic;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chain-of-thoughts for the AI cards drawer — **GET only**:
|
|
3
|
+
* `GET …/1.0/chain-of-thoughts-for-ai-card-recommendation` (no body).
|
|
4
|
+
* Response feeds `chainOfThoughtsResponse` (analyzing, thinking, thought_process) for the drawer.
|
|
5
|
+
*/
|
|
6
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
7
|
+
import { Observable } from 'rxjs';
|
|
8
|
+
import { RootState } from '../../../../reducer';
|
|
9
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
10
|
+
import { ChainOfThoughtsRequestAction } from './cardsOnboardingDataRequests';
|
|
11
|
+
import { fetchChainOfThoughtsForAiCardRecommendation } from './cardsOnboardingReducer';
|
|
12
|
+
export type ActionType = ReturnType<typeof fetchChainOfThoughtsForAiCardRecommendation> | ChainOfThoughtsRequestAction;
|
|
13
|
+
export declare const fetchChainOfThoughtsForAiCardRecommendationEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchChainOfThoughtsForAiCardRecommendationEpic = void 0;
|
|
4
|
+
const operators_1 = require("rxjs/operators");
|
|
5
|
+
const cardsOnboardingDataRequests_1 = require("./cardsOnboardingDataRequests");
|
|
6
|
+
const cardsOnboardingReducer_1 = require("./cardsOnboardingReducer");
|
|
7
|
+
const fetchChainOfThoughtsForAiCardRecommendationEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(cardsOnboardingReducer_1.fetchChainOfThoughtsForAiCardRecommendation.match), (0, operators_1.switchMap)(() => (0, cardsOnboardingDataRequests_1.requestChainOfThoughtsForAiCardRecommendation$)(zeniAPI)));
|
|
8
|
+
exports.fetchChainOfThoughtsForAiCardRecommendationEpic = fetchChainOfThoughtsForAiCardRecommendationEpic;
|
package/lib/view/spendManagement/chargeCards/cardsOnboarding/startAiCardAgentDrawerDataLoadEpic.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../reducer';
|
|
4
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
+
import { AiCardRecommendationRequestAction, ChainOfThoughtsRequestAction } from './cardsOnboardingDataRequests';
|
|
6
|
+
import { startAiCardAgentDrawerDataLoad } from './cardsOnboardingReducer';
|
|
7
|
+
export type ActionType = ReturnType<typeof startAiCardAgentDrawerDataLoad> | ChainOfThoughtsRequestAction | AiCardRecommendationRequestAction;
|
|
8
|
+
/**
|
|
9
|
+
* On "Let's get started": runs chain-of-thoughts GET and AI card recommendation GET **in parallel**.
|
|
10
|
+
* Reducer (`startAiCardAgentDrawerDataLoad`) resets both slices; use `getAiCardAgentDrawerDisplayState`
|
|
11
|
+
* for phased CoT UI, sparkle while recommendations load, and gated recommendation content.
|
|
12
|
+
*/
|
|
13
|
+
export declare const startAiCardAgentDrawerDataLoadEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/spendManagement/chargeCards/cardsOnboarding/startAiCardAgentDrawerDataLoadEpic.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startAiCardAgentDrawerDataLoadEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const cardsOnboardingDataRequests_1 = require("./cardsOnboardingDataRequests");
|
|
7
|
+
const cardsOnboardingReducer_1 = require("./cardsOnboardingReducer");
|
|
8
|
+
/**
|
|
9
|
+
* On "Let's get started": runs chain-of-thoughts GET and AI card recommendation GET **in parallel**.
|
|
10
|
+
* Reducer (`startAiCardAgentDrawerDataLoad`) resets both slices; use `getAiCardAgentDrawerDisplayState`
|
|
11
|
+
* for phased CoT UI, sparkle while recommendations load, and gated recommendation content.
|
|
12
|
+
*/
|
|
13
|
+
const startAiCardAgentDrawerDataLoadEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(cardsOnboardingReducer_1.startAiCardAgentDrawerDataLoad.match), (0, operators_1.switchMap)(() => (0, rxjs_1.merge)((0, cardsOnboardingDataRequests_1.requestChainOfThoughtsForAiCardRecommendation$)(zeniAPI), (0, cardsOnboardingDataRequests_1.requestAiCardRecommendation$)(zeniAPI))));
|
|
14
|
+
exports.startAiCardAgentDrawerDataLoadEpic = startAiCardAgentDrawerDataLoadEpic;
|
|
@@ -10,7 +10,10 @@ export declare const fetchChargeCardListPage: import("@reduxjs/toolkit").ActionC
|
|
|
10
10
|
isDebitCardEnabled: boolean;
|
|
11
11
|
isCreditCardEnabled: boolean;
|
|
12
12
|
cacheOverride: any;
|
|
13
|
-
}, "chargeCardList/fetchChargeCardListPage", never, never>,
|
|
13
|
+
}, "chargeCardList/fetchChargeCardListPage", never, never>, fetchCardsOnboardingPage: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[isCreditCardEnabled: boolean, cacheOverride?: any], {
|
|
14
|
+
isCreditCardEnabled: boolean;
|
|
15
|
+
cacheOverride: any;
|
|
16
|
+
}, "chargeCardList/fetchCardsOnboardingPage", never, never>, fetchCreditAccountRepayment: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"chargeCardList/fetchCreditAccountRepayment">, updateCreditAccountRepayment: import("@reduxjs/toolkit").ActionCreatorWithPayload<CreditAccountRepaymentPayload, "chargeCardList/updateCreditAccountRepayment">, updateCreditAccountRepaymentFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "chargeCardList/updateCreditAccountRepaymentFailure">, updateCreditAccountRepaymentAmountAndDate: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
14
17
|
amount: Amount;
|
|
15
18
|
date: ZeniDate;
|
|
16
19
|
}, "chargeCardList/updateCreditAccountRepaymentAmountAndDate">, updateRowActionCardId: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, "chargeCardList/updateRowActionCardId">, fetchCreditAccount: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"chargeCardList/fetchCreditAccount">, updateCreditAccount: import("@reduxjs/toolkit").ActionCreatorWithPayload<CreditAccountPayload[], "chargeCardList/updateCreditAccount">, updateCreditAccountFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "chargeCardList/updateCreditAccountFailure">, fetchDebitCardSummary: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"chargeCardList/fetchDebitCardSummary">, updateDebitCardSummary: import("@reduxjs/toolkit").ActionCreatorWithPayload<DebitCardSummariesPayload, "chargeCardList/updateDebitCardSummary">, updateDebitCardSummaryFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "chargeCardList/updateDebitCardSummaryFailure">, fetchChargeCardList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"chargeCardList/fetchChargeCardList">, updateChargeCardList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.revokeChargeCardsInviteSuccessOrFailure = exports.revokeChargeCardsInvite = exports.closeChargeCardsSuccessOrFailure = exports.closeChargeCards = exports.unlockChargeCardsSuccessOrFailure = exports.unlockChargeCards = exports.lockChargeCardsSuccessOrFailure = exports.lockChargeCards = exports.updateChargeCardsSpendLimitSuccessOrFailure = exports.updateChargeCardsSpendLimit = exports.revokeCardInviteFailure = exports.revokeCardInviteSuccess = exports.revokeCardInvite = exports.resendCardInviteFailure = exports.resendCardInviteSuccess = exports.resendCardInvite = exports.clearChargeCardList = exports.updateChargeCardListUIState = exports.updateBulkActionCardIds = exports.updateSearchText = exports.updateChargeCardListFailure = exports.updateChargeCardList = exports.fetchChargeCardList = exports.updateDebitCardSummaryFailure = exports.updateDebitCardSummary = exports.fetchDebitCardSummary = exports.updateCreditAccountFailure = exports.updateCreditAccount = exports.fetchCreditAccount = exports.updateRowActionCardId = exports.updateCreditAccountRepaymentAmountAndDate = exports.updateCreditAccountRepaymentFailure = exports.updateCreditAccountRepayment = exports.fetchCreditAccountRepayment = exports.fetchChargeCardListPage = exports.initialState = void 0;
|
|
4
|
+
exports.revokeChargeCardsInviteSuccessOrFailure = exports.revokeChargeCardsInvite = exports.closeChargeCardsSuccessOrFailure = exports.closeChargeCards = exports.unlockChargeCardsSuccessOrFailure = exports.unlockChargeCards = exports.lockChargeCardsSuccessOrFailure = exports.lockChargeCards = exports.updateChargeCardsSpendLimitSuccessOrFailure = exports.updateChargeCardsSpendLimit = exports.revokeCardInviteFailure = exports.revokeCardInviteSuccess = exports.revokeCardInvite = exports.resendCardInviteFailure = exports.resendCardInviteSuccess = exports.resendCardInvite = exports.clearChargeCardList = exports.updateChargeCardListUIState = exports.updateBulkActionCardIds = exports.updateSearchText = exports.updateChargeCardListFailure = exports.updateChargeCardList = exports.fetchChargeCardList = exports.updateDebitCardSummaryFailure = exports.updateDebitCardSummary = exports.fetchDebitCardSummary = exports.updateCreditAccountFailure = exports.updateCreditAccount = exports.fetchCreditAccount = exports.updateRowActionCardId = exports.updateCreditAccountRepaymentAmountAndDate = exports.updateCreditAccountRepaymentFailure = exports.updateCreditAccountRepayment = exports.fetchCreditAccountRepayment = exports.fetchCardsOnboardingPage = exports.fetchChargeCardListPage = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
const amount_1 = require("../../../../commonStateTypes/amount");
|
|
7
7
|
const zeniDayJS_1 = require("../../../../zeniDayJS");
|
|
@@ -66,6 +66,19 @@ const chargeCardList = (0, toolkit_1.createSlice)({
|
|
|
66
66
|
};
|
|
67
67
|
},
|
|
68
68
|
},
|
|
69
|
+
fetchCardsOnboardingPage: {
|
|
70
|
+
reducer() {
|
|
71
|
+
//do nothing
|
|
72
|
+
},
|
|
73
|
+
prepare(isCreditCardEnabled, cacheOverride = false) {
|
|
74
|
+
return {
|
|
75
|
+
payload: {
|
|
76
|
+
isCreditCardEnabled,
|
|
77
|
+
cacheOverride,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
},
|
|
69
82
|
fetchCreditAccountRepayment(draft) {
|
|
70
83
|
draft.creditAccountRepayment.fetchState = 'In-Progress';
|
|
71
84
|
draft.creditAccountRepayment.error = undefined;
|
|
@@ -311,7 +324,7 @@ const chargeCardList = (0, toolkit_1.createSlice)({
|
|
|
311
324
|
},
|
|
312
325
|
},
|
|
313
326
|
});
|
|
314
|
-
_a = chargeCardList.actions, exports.fetchChargeCardListPage = _a.fetchChargeCardListPage, exports.fetchCreditAccountRepayment = _a.fetchCreditAccountRepayment, exports.updateCreditAccountRepayment = _a.updateCreditAccountRepayment, exports.updateCreditAccountRepaymentFailure = _a.updateCreditAccountRepaymentFailure, exports.updateCreditAccountRepaymentAmountAndDate = _a.updateCreditAccountRepaymentAmountAndDate, exports.updateRowActionCardId = _a.updateRowActionCardId, exports.fetchCreditAccount = _a.fetchCreditAccount, exports.updateCreditAccount = _a.updateCreditAccount, exports.updateCreditAccountFailure = _a.updateCreditAccountFailure, exports.fetchDebitCardSummary = _a.fetchDebitCardSummary, exports.updateDebitCardSummary = _a.updateDebitCardSummary, exports.updateDebitCardSummaryFailure = _a.updateDebitCardSummaryFailure, exports.fetchChargeCardList = _a.fetchChargeCardList, exports.updateChargeCardList = _a.updateChargeCardList, exports.updateChargeCardListFailure = _a.updateChargeCardListFailure, exports.updateSearchText = _a.updateSearchText, exports.updateBulkActionCardIds = _a.updateBulkActionCardIds, exports.updateChargeCardListUIState = _a.updateChargeCardListUIState, exports.clearChargeCardList = _a.clearChargeCardList, exports.resendCardInvite = _a.resendCardInvite, exports.resendCardInviteSuccess = _a.resendCardInviteSuccess, exports.resendCardInviteFailure = _a.resendCardInviteFailure, exports.revokeCardInvite = _a.revokeCardInvite, exports.revokeCardInviteSuccess = _a.revokeCardInviteSuccess, exports.revokeCardInviteFailure = _a.revokeCardInviteFailure, exports.updateChargeCardsSpendLimit = _a.updateChargeCardsSpendLimit, exports.updateChargeCardsSpendLimitSuccessOrFailure = _a.updateChargeCardsSpendLimitSuccessOrFailure, exports.lockChargeCards = _a.lockChargeCards, exports.lockChargeCardsSuccessOrFailure = _a.lockChargeCardsSuccessOrFailure, exports.unlockChargeCards = _a.unlockChargeCards, exports.unlockChargeCardsSuccessOrFailure = _a.unlockChargeCardsSuccessOrFailure, exports.closeChargeCards = _a.closeChargeCards, exports.closeChargeCardsSuccessOrFailure = _a.closeChargeCardsSuccessOrFailure, exports.revokeChargeCardsInvite = _a.revokeChargeCardsInvite, exports.revokeChargeCardsInviteSuccessOrFailure = _a.revokeChargeCardsInviteSuccessOrFailure;
|
|
327
|
+
_a = chargeCardList.actions, exports.fetchChargeCardListPage = _a.fetchChargeCardListPage, exports.fetchCardsOnboardingPage = _a.fetchCardsOnboardingPage, exports.fetchCreditAccountRepayment = _a.fetchCreditAccountRepayment, exports.updateCreditAccountRepayment = _a.updateCreditAccountRepayment, exports.updateCreditAccountRepaymentFailure = _a.updateCreditAccountRepaymentFailure, exports.updateCreditAccountRepaymentAmountAndDate = _a.updateCreditAccountRepaymentAmountAndDate, exports.updateRowActionCardId = _a.updateRowActionCardId, exports.fetchCreditAccount = _a.fetchCreditAccount, exports.updateCreditAccount = _a.updateCreditAccount, exports.updateCreditAccountFailure = _a.updateCreditAccountFailure, exports.fetchDebitCardSummary = _a.fetchDebitCardSummary, exports.updateDebitCardSummary = _a.updateDebitCardSummary, exports.updateDebitCardSummaryFailure = _a.updateDebitCardSummaryFailure, exports.fetchChargeCardList = _a.fetchChargeCardList, exports.updateChargeCardList = _a.updateChargeCardList, exports.updateChargeCardListFailure = _a.updateChargeCardListFailure, exports.updateSearchText = _a.updateSearchText, exports.updateBulkActionCardIds = _a.updateBulkActionCardIds, exports.updateChargeCardListUIState = _a.updateChargeCardListUIState, exports.clearChargeCardList = _a.clearChargeCardList, exports.resendCardInvite = _a.resendCardInvite, exports.resendCardInviteSuccess = _a.resendCardInviteSuccess, exports.resendCardInviteFailure = _a.resendCardInviteFailure, exports.revokeCardInvite = _a.revokeCardInvite, exports.revokeCardInviteSuccess = _a.revokeCardInviteSuccess, exports.revokeCardInviteFailure = _a.revokeCardInviteFailure, exports.updateChargeCardsSpendLimit = _a.updateChargeCardsSpendLimit, exports.updateChargeCardsSpendLimitSuccessOrFailure = _a.updateChargeCardsSpendLimitSuccessOrFailure, exports.lockChargeCards = _a.lockChargeCards, exports.lockChargeCardsSuccessOrFailure = _a.lockChargeCardsSuccessOrFailure, exports.unlockChargeCards = _a.unlockChargeCards, exports.unlockChargeCardsSuccessOrFailure = _a.unlockChargeCardsSuccessOrFailure, exports.closeChargeCards = _a.closeChargeCards, exports.closeChargeCardsSuccessOrFailure = _a.closeChargeCardsSuccessOrFailure, exports.revokeChargeCardsInvite = _a.revokeChargeCardsInvite, exports.revokeChargeCardsInviteSuccessOrFailure = _a.revokeChargeCardsInviteSuccessOrFailure;
|
|
315
328
|
exports.default = chargeCardList.reducer;
|
|
316
329
|
// helper
|
|
317
330
|
const toCreditAccount = (payload) => ({
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cards onboarding page: loads credit, cashback, and **full people directory** via `fetchPeople`
|
|
3
|
+
* (`GET …/user-roles` → `updateAllUsers`), not the card-holder-candidate subset.
|
|
4
|
+
*/
|
|
5
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
6
|
+
import { Observable } from 'rxjs';
|
|
7
|
+
import { RootState } from '../../../../reducer';
|
|
8
|
+
import { fetchPeople } from '../../../people/peopleReducer';
|
|
9
|
+
import { fetchCashbackDetail } from '../cashbackDetail/cashbackDetailReducer';
|
|
10
|
+
import { fetchCardsOnboardingPage, fetchCreditAccount } from './chargeCardListReducer';
|
|
11
|
+
export type ActionType = ReturnType<typeof fetchCardsOnboardingPage> | ReturnType<typeof fetchCreditAccount> | ReturnType<typeof fetchPeople> | ReturnType<typeof fetchCashbackDetail>;
|
|
12
|
+
export declare const fetchCardsOnboardingPageEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
|