@zeniai/client-epic-state 4.17.19 → 4.17.20
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/entity/accountRecon/accountReconPayload.d.ts +2 -0
- package/lib/entity/accountRecon/accountReconPayload.js +6 -1
- package/lib/entity/accountRecon/accountReconState.d.ts +2 -0
- package/lib/entity/{aiController/aiControllerPayload.d.ts → aiCfo/aiCfoPayload.d.ts} +10 -3
- package/lib/entity/aiCfo/aiCfoReducer.d.ts +45 -0
- package/lib/entity/{aiController/aiControllerReducer.js → aiCfo/aiCfoReducer.js} +53 -45
- package/lib/entity/aiCfo/aiCfoSelector.d.ts +14 -0
- package/lib/entity/{aiController/aiControllerSelector.js → aiCfo/aiCfoSelector.js} +6 -6
- package/lib/entity/aiCfo/aiCfoState.d.ts +107 -0
- package/lib/entity/aiCfo/aiCfoState.js +81 -0
- package/lib/entity/tenant/clearAllEpic.d.ts +4 -4
- package/lib/entity/tenant/clearAllEpic.js +4 -4
- package/lib/epic.d.ts +10 -8
- package/lib/epic.js +10 -8
- package/lib/index.d.ts +15 -13
- package/lib/index.js +83 -74
- package/lib/reducer.d.ts +6 -6
- package/lib/reducer.js +6 -6
- package/lib/view/{aiControllerView/aiControllerViewPayload.d.ts → aiCfoView/aiCfoViewPayload.d.ts} +2 -2
- package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +73 -0
- package/lib/view/{aiControllerView/aiControllerViewReducer.js → aiCfoView/aiCfoViewReducer.js} +10 -10
- package/lib/view/{aiControllerView/aiControllerViewSelector.d.ts → aiCfoView/aiCfoViewSelector.d.ts} +5 -5
- package/lib/view/{aiControllerView/aiControllerViewSelector.js → aiCfoView/aiCfoViewSelector.js} +6 -6
- package/lib/view/{aiControllerView/aiControllerViewState.d.ts → aiCfoView/aiCfoViewState.d.ts} +3 -3
- package/lib/view/{aiControllerView → aiCfoView}/epics/createSessionAndSubmitEpic.d.ts +2 -2
- package/lib/view/{aiControllerView → aiCfoView}/epics/createSessionAndSubmitEpic.js +9 -9
- package/lib/view/{aiControllerView → aiCfoView}/epics/createSessionEpic.d.ts +2 -2
- package/lib/view/{aiControllerView → aiCfoView}/epics/createSessionEpic.js +8 -8
- package/lib/view/{aiControllerView → aiCfoView}/epics/fetchChatHistoryEpic.d.ts +2 -2
- package/lib/view/{aiControllerView → aiCfoView}/epics/fetchChatHistoryEpic.js +9 -9
- package/lib/view/{aiControllerView → aiCfoView}/epics/fetchChatSessionsForUserEpic.d.ts +2 -2
- package/lib/view/{aiControllerView → aiCfoView}/epics/fetchChatSessionsForUserEpic.js +8 -9
- package/lib/view/{aiControllerView → aiCfoView}/epics/stopSubmitEpic.d.ts +2 -2
- package/lib/view/{aiControllerView → aiCfoView}/epics/stopSubmitEpic.js +11 -11
- package/lib/view/{aiControllerView → aiCfoView}/epics/stopSubmitQuestionEpic.d.ts +2 -2
- package/lib/view/{aiControllerView → aiCfoView}/epics/stopSubmitQuestionEpic.js +8 -8
- package/lib/view/{aiControllerView → aiCfoView}/epics/submitQuestionEpic.d.ts +2 -2
- package/lib/view/{aiControllerView → aiCfoView}/epics/submitQuestionEpic.js +10 -10
- package/lib/view/expenseAutomationView/epics/accountRecon/saveReconciliationReviewEpic.js +2 -0
- package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailPayload.d.ts +7 -0
- package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +11 -0
- package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailSelector.d.ts +2 -1
- package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailSelector.js +1 -0
- package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailState.d.ts +8 -0
- package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailState.js +7 -1
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetail.d.ts +19 -0
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetail.js +33 -1
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailPayload.d.ts +13 -0
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.d.ts +11 -2
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +18 -2
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailSelector.d.ts +2 -1
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailSelector.js +2 -1
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardTransactionStatisticsEpic.d.ts +7 -0
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardTransactionStatisticsEpic.js +39 -0
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +13 -0
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.js +14 -1
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListPayload.d.ts +14 -0
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +2 -2
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +26 -2
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.d.ts +17 -3
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +34 -4
- package/lib/view/spendManagement/chargeCards/chargeCardList/fetchCreditAccountRepaymentEpic.d.ts +7 -0
- package/lib/view/spendManagement/chargeCards/chargeCardList/fetchCreditAccountRepaymentEpic.js +23 -0
- package/lib/zeniAPI.d.ts +1 -1
- package/package.json +1 -1
- package/lib/entity/aiController/aiControllerReducer.d.ts +0 -46
- package/lib/entity/aiController/aiControllerSelector.d.ts +0 -14
- package/lib/entity/aiController/aiControllerState.d.ts +0 -88
- package/lib/entity/aiController/aiControllerState.js +0 -49
- package/lib/view/aiControllerView/aiControllerViewReducer.d.ts +0 -73
- /package/lib/entity/{aiController/aiControllerPayload.js → aiCfo/aiCfoPayload.js} +0 -0
- /package/lib/view/{aiControllerView/aiControllerViewPayload.js → aiCfoView/aiCfoViewPayload.js} +0 -0
- /package/lib/view/{aiControllerView/aiControllerViewState.js → aiCfoView/aiCfoViewState.js} +0 -0
|
@@ -56,6 +56,8 @@ interface RecommendedActionPayload {
|
|
|
56
56
|
recommended_actions: string;
|
|
57
57
|
recommended_action_description: string;
|
|
58
58
|
recommended_transactions: RecommendedReviewTransactionPayload[];
|
|
59
|
+
plaid_confidence_score?: string | null;
|
|
60
|
+
zeni_confidence_score?: number | null;
|
|
59
61
|
}
|
|
60
62
|
export interface TransactionsToReviewPayload {
|
|
61
63
|
amount: number;
|
|
@@ -7,7 +7,7 @@ const zeniDayJS_1 = require("../../zeniDayJS");
|
|
|
7
7
|
const reconciliationTransaction_1 = require("../transaction/stateTypes/reconciliationTransaction");
|
|
8
8
|
const accountReconState_1 = require("./accountReconState");
|
|
9
9
|
const toTransactionsToReview = (payload, currencyPayload) => {
|
|
10
|
-
var _a, _b;
|
|
10
|
+
var _a, _b, _c, _d;
|
|
11
11
|
return {
|
|
12
12
|
transactionId: payload.transaction_id,
|
|
13
13
|
transactionDirection: (0, reconciliationTransaction_1.toTransactionDirectionType)(payload.transaction_direction),
|
|
@@ -26,6 +26,8 @@ const toTransactionsToReview = (payload, currencyPayload) => {
|
|
|
26
26
|
: undefined,
|
|
27
27
|
recommendedAction: {
|
|
28
28
|
action: (0, accountReconState_1.toRecommendedActionCodeType)(payload.recommended_action.recommended_actions),
|
|
29
|
+
plaidConfidenceScore: (_c = payload.recommended_action.plaid_confidence_score) !== null && _c !== void 0 ? _c : null,
|
|
30
|
+
zeniConfidenceScore: (_d = payload.recommended_action.zeni_confidence_score) !== null && _d !== void 0 ? _d : null,
|
|
29
31
|
reason: payload.recommended_action.recommended_action_description,
|
|
30
32
|
recommendedTransactions: payload.recommended_action.recommended_transactions.map((transaction) => (0, exports.toRecommendedReviewTransaction)(transaction, currencyPayload)),
|
|
31
33
|
},
|
|
@@ -33,6 +35,7 @@ const toTransactionsToReview = (payload, currencyPayload) => {
|
|
|
33
35
|
};
|
|
34
36
|
exports.toTransactionsToReview = toTransactionsToReview;
|
|
35
37
|
const toTransactionsToReviewPayload = (payload) => {
|
|
38
|
+
var _a, _b;
|
|
36
39
|
return {
|
|
37
40
|
transaction_id: payload.transactionId,
|
|
38
41
|
transaction_direction: (0, reconciliationTransaction_1.toTransactionDirectionType)(payload.transactionDirection),
|
|
@@ -44,6 +47,8 @@ const toTransactionsToReviewPayload = (payload) => {
|
|
|
44
47
|
recommended_actions: (0, accountReconState_1.toRecommendedActionCodeType)(payload.recommendedAction.action),
|
|
45
48
|
recommended_action_description: payload.recommendedAction.reason,
|
|
46
49
|
recommended_transactions: payload.recommendedAction.recommendedTransactions.map((transaction) => (0, exports.toRecommendedReviewTransactionPayload)(transaction)),
|
|
50
|
+
plaid_confidence_score: (_a = payload.recommendedAction.plaidConfidenceScore) !== null && _a !== void 0 ? _a : null,
|
|
51
|
+
zeni_confidence_score: (_b = payload.recommendedAction.zeniConfidenceScore) !== null && _b !== void 0 ? _b : null,
|
|
47
52
|
},
|
|
48
53
|
};
|
|
49
54
|
};
|
|
@@ -78,6 +78,8 @@ export interface RecommendedAction {
|
|
|
78
78
|
action: RecommendedActionCodeType;
|
|
79
79
|
reason: string;
|
|
80
80
|
recommendedTransactions: RecommendedReviewTransaction[];
|
|
81
|
+
plaidConfidenceScore: string | null;
|
|
82
|
+
zeniConfidenceScore: number | null;
|
|
81
83
|
}
|
|
82
84
|
export interface RecommendedReviewTransaction {
|
|
83
85
|
confidenceScore: number;
|
|
@@ -3,6 +3,12 @@ export interface TableVisualizationPayload {
|
|
|
3
3
|
values: Array<Record<string, string>>;
|
|
4
4
|
columns: string[];
|
|
5
5
|
}
|
|
6
|
+
export interface YFormatPayload {
|
|
7
|
+
type: string;
|
|
8
|
+
unit: string;
|
|
9
|
+
scale: string;
|
|
10
|
+
symbol?: string;
|
|
11
|
+
}
|
|
6
12
|
export interface ChartVisualizationPayload {
|
|
7
13
|
values: Array<Record<string, string | number>>;
|
|
8
14
|
x: string;
|
|
@@ -11,17 +17,18 @@ export interface ChartVisualizationPayload {
|
|
|
11
17
|
* We will normalize it to string[] in state.
|
|
12
18
|
*/
|
|
13
19
|
y: string | string[];
|
|
20
|
+
y_format?: YFormatPayload;
|
|
14
21
|
lines?: string[] | null;
|
|
15
22
|
}
|
|
16
|
-
export interface
|
|
23
|
+
export interface AiCfoVisualizationPayload {
|
|
17
24
|
type: string | null;
|
|
18
25
|
data: TableVisualizationPayload | ChartVisualizationPayload | null;
|
|
19
26
|
}
|
|
20
|
-
export interface
|
|
27
|
+
export interface AiCfoAnswerPayload {
|
|
21
28
|
text: string;
|
|
22
29
|
state: string;
|
|
23
30
|
type: string;
|
|
24
|
-
visualization:
|
|
31
|
+
visualization: AiCfoVisualizationPayload | null;
|
|
25
32
|
metadata: Record<string, string>;
|
|
26
33
|
assumptions: string | null;
|
|
27
34
|
insights: string | null;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ID } from '../../commonStateTypes/common';
|
|
2
|
+
import { ZeniDate } from '../../zeniDayJS';
|
|
3
|
+
import { AiCfoAnswerPayload, AiCfoVisualizationPayload, ChatSessionPayload, MessagePayload } from './aiCfoPayload';
|
|
4
|
+
import { AiCfoState, AiCfoVisualization } from './aiCfoState';
|
|
5
|
+
export declare const initialAiCfoState: AiCfoState;
|
|
6
|
+
export declare const toAiCfoVisualization: (visualization: AiCfoVisualizationPayload) => AiCfoVisualization | undefined;
|
|
7
|
+
export declare const setNewSession: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
8
|
+
chatSessionId: ID;
|
|
9
|
+
userId: ID;
|
|
10
|
+
createdAt: ZeniDate;
|
|
11
|
+
}, "aiCfo/setNewSession">, clearSession: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "aiCfo/clearSession">, setSessions: import("@reduxjs/toolkit").ActionCreatorWithPayload<ChatSessionPayload[], "aiCfo/setSessions">, setChatHistory: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
12
|
+
chatSessionId: ID;
|
|
13
|
+
history: MessagePayload[];
|
|
14
|
+
isPaginationComplete?: boolean;
|
|
15
|
+
}, "aiCfo/setChatHistory">, upsertAnswerPayload: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
16
|
+
chatSessionId: ID;
|
|
17
|
+
answerPayload: AiCfoAnswerPayload;
|
|
18
|
+
userId: ID;
|
|
19
|
+
questionAnswerId?: ID;
|
|
20
|
+
}, "aiCfo/upsertAnswerPayload">, upsertOrAddQuestionAnswerPayload: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
21
|
+
chatSessionId: ID;
|
|
22
|
+
questionAnswerId: ID;
|
|
23
|
+
question: {
|
|
24
|
+
questionId: ID;
|
|
25
|
+
text: string;
|
|
26
|
+
createdAt: ZeniDate;
|
|
27
|
+
};
|
|
28
|
+
answerPayload: AiCfoAnswerPayload;
|
|
29
|
+
userId: ID;
|
|
30
|
+
insertQuestionAnswer?: boolean;
|
|
31
|
+
}, "aiCfo/upsertOrAddQuestionAnswerPayload">, addQuestionPayload: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
32
|
+
chatSessionId: ID;
|
|
33
|
+
questionAnswerId: ID;
|
|
34
|
+
question: {
|
|
35
|
+
questionId: ID;
|
|
36
|
+
text: string;
|
|
37
|
+
createdAt: ZeniDate;
|
|
38
|
+
};
|
|
39
|
+
userId: ID;
|
|
40
|
+
}, "aiCfo/addQuestionPayload">, clearAiCfo: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"aiCfo/clearAiCfo">, deleteQuestion: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
41
|
+
chatSessionId: ID;
|
|
42
|
+
questionAnswerId: ID;
|
|
43
|
+
}, "aiCfo/deleteQuestion">;
|
|
44
|
+
declare const _default: import("redux").Reducer<AiCfoState>;
|
|
45
|
+
export default _default;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.deleteQuestion = exports.
|
|
4
|
+
exports.deleteQuestion = exports.clearAiCfo = exports.addQuestionPayload = exports.upsertOrAddQuestionAnswerPayload = exports.upsertAnswerPayload = exports.setChatHistory = exports.setSessions = exports.clearSession = exports.setNewSession = exports.toAiCfoVisualization = exports.initialAiCfoState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
const zeniDayJS_1 = require("../../zeniDayJS");
|
|
7
|
-
const
|
|
8
|
-
exports.
|
|
9
|
-
|
|
7
|
+
const aiCfoState_1 = require("./aiCfoState");
|
|
8
|
+
exports.initialAiCfoState = {
|
|
9
|
+
aiCfoByChatSessionId: {},
|
|
10
10
|
partialQuestionAnswers: {},
|
|
11
11
|
};
|
|
12
12
|
// Utility: Merge two arrays of Q&A pairs, combining responses for the same question
|
|
@@ -32,7 +32,7 @@ function mergeQuestionAnswerPairs(existing, newQAs) {
|
|
|
32
32
|
// Convert back to array and sort by question creation time
|
|
33
33
|
return Array.from(merged.values()).sort((a, b) => a.question.createdAt.valueOf() - b.question.createdAt.valueOf());
|
|
34
34
|
}
|
|
35
|
-
// Utility: Convert chat history (array of MessagePayload) to
|
|
35
|
+
// Utility: Convert chat history (array of MessagePayload) to AiCfoQuestionWithAnswer[]
|
|
36
36
|
function chatHistoryToQA(history) {
|
|
37
37
|
var _a, _b, _c;
|
|
38
38
|
const questionGroups = new Map();
|
|
@@ -58,7 +58,7 @@ function chatHistoryToQA(history) {
|
|
|
58
58
|
group.responses.push(message);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
// Convert groups to
|
|
61
|
+
// Convert groups to AiCfoQuestionWithAnswer
|
|
62
62
|
const questionAnswerPairs = [];
|
|
63
63
|
for (const [messageId, group] of questionGroups.entries()) {
|
|
64
64
|
// Skip groups that don't have a question
|
|
@@ -69,7 +69,7 @@ function chatHistoryToQA(history) {
|
|
|
69
69
|
messageId: group.question.message_id,
|
|
70
70
|
chatSessionId: group.question.chat_session_id,
|
|
71
71
|
userId: group.question.user_id,
|
|
72
|
-
sender: (0,
|
|
72
|
+
sender: (0, aiCfoState_1.toMessageSender)(group.question.sender),
|
|
73
73
|
state: 'complete',
|
|
74
74
|
questionText: group.question.content,
|
|
75
75
|
createdAt: (0, zeniDayJS_1.date)(group.question.created_at),
|
|
@@ -78,7 +78,7 @@ function chatHistoryToQA(history) {
|
|
|
78
78
|
// Process each response for this question
|
|
79
79
|
for (const agentMessage of group.responses) {
|
|
80
80
|
try {
|
|
81
|
-
const parsedAgentMessage = (0,
|
|
81
|
+
const parsedAgentMessage = (0, aiCfoState_1.toMessageType)(agentMessage.message_type) === 'json'
|
|
82
82
|
? JSON.parse(agentMessage.content)
|
|
83
83
|
: {
|
|
84
84
|
text: agentMessage.content,
|
|
@@ -87,21 +87,21 @@ function chatHistoryToQA(history) {
|
|
|
87
87
|
visualization: null,
|
|
88
88
|
follow_up_questions: [],
|
|
89
89
|
};
|
|
90
|
-
const responseType = (0,
|
|
91
|
-
const responseState = (0,
|
|
90
|
+
const responseType = (0, aiCfoState_1.toAiCfoAnswerResponseType)(parsedAgentMessage.type);
|
|
91
|
+
const responseState = (0, aiCfoState_1.toAiCfoAnswerStateType)(parsedAgentMessage.state);
|
|
92
92
|
if (typeof parsedAgentMessage.text === 'string' &&
|
|
93
|
-
|
|
93
|
+
aiCfoState_1.ALL_AI_CFO_ANSWER_RESPONSE_TYPES.includes(responseType)) {
|
|
94
94
|
responses[responseType] = {
|
|
95
95
|
messageId: agentMessage.message_id,
|
|
96
96
|
chatSessionId: agentMessage.chat_session_id,
|
|
97
97
|
userId: agentMessage.user_id,
|
|
98
|
-
sender: (0,
|
|
98
|
+
sender: (0, aiCfoState_1.toMessageSender)(agentMessage.sender),
|
|
99
99
|
type: responseType,
|
|
100
100
|
state: responseState,
|
|
101
101
|
content: {
|
|
102
102
|
text: parsedAgentMessage.text,
|
|
103
103
|
visualization: parsedAgentMessage.visualization
|
|
104
|
-
? (0, exports.
|
|
104
|
+
? (0, exports.toAiCfoVisualization)(parsedAgentMessage.visualization)
|
|
105
105
|
: undefined,
|
|
106
106
|
followUpQuestions: Array.isArray(parsedAgentMessage.follow_up_questions)
|
|
107
107
|
? parsedAgentMessage.follow_up_questions
|
|
@@ -127,27 +127,37 @@ function chatHistoryToQA(history) {
|
|
|
127
127
|
// Sort by question creation time (oldest first)
|
|
128
128
|
return questionAnswerPairs.sort((a, b) => a.question.createdAt.valueOf() - b.question.createdAt.valueOf());
|
|
129
129
|
}
|
|
130
|
-
const
|
|
130
|
+
const toAiCfoVisualization = (visualization) => {
|
|
131
131
|
var _a;
|
|
132
132
|
if (visualization.type == null || visualization.data == null) {
|
|
133
133
|
return undefined;
|
|
134
134
|
}
|
|
135
135
|
return {
|
|
136
|
-
type: (_a = (0,
|
|
137
|
-
data:
|
|
136
|
+
type: (_a = (0, aiCfoState_1.toAiCfoVisualizationTypeStrict)(visualization.type)) !== null && _a !== void 0 ? _a : 'table',
|
|
137
|
+
data: toAiCfoVisualizationData(visualization.data),
|
|
138
138
|
};
|
|
139
139
|
};
|
|
140
|
-
exports.
|
|
141
|
-
const
|
|
142
|
-
var _a, _b;
|
|
140
|
+
exports.toAiCfoVisualization = toAiCfoVisualization;
|
|
141
|
+
const toAiCfoVisualizationData = (data) => {
|
|
142
|
+
var _a, _b, _c, _d, _e;
|
|
143
143
|
if ('x' in data && 'y' in data) {
|
|
144
144
|
// Normalize y to always be an array
|
|
145
145
|
const yArray = Array.isArray(data.y) ? data.y : [data.y];
|
|
146
|
+
// Handle y_format (now required)
|
|
147
|
+
const yFormat = data.y_format != null
|
|
148
|
+
? {
|
|
149
|
+
type: (_a = (0, aiCfoState_1.toYFormatTypeStrict)(data.y_format.type)) !== null && _a !== void 0 ? _a : 'number',
|
|
150
|
+
unit: (0, aiCfoState_1.toYFormatUnitStrict)(data.y_format.unit),
|
|
151
|
+
scale: (_b = (0, aiCfoState_1.toYFormatScaleStrict)(data.y_format.scale)) !== null && _b !== void 0 ? _b : 'raw',
|
|
152
|
+
symbol: (_c = data.y_format.symbol) !== null && _c !== void 0 ? _c : undefined,
|
|
153
|
+
}
|
|
154
|
+
: undefined;
|
|
146
155
|
return {
|
|
147
156
|
values: data.values,
|
|
148
157
|
x: data.x,
|
|
149
158
|
y: yArray,
|
|
150
|
-
lines: (
|
|
159
|
+
lines: (_d = data.lines) !== null && _d !== void 0 ? _d : [],
|
|
160
|
+
yFormat,
|
|
151
161
|
};
|
|
152
162
|
}
|
|
153
163
|
// Table cleaning logic: only strip quotes from column names and cell values
|
|
@@ -160,7 +170,7 @@ const toAIControllerVisualizationData = (data) => {
|
|
|
160
170
|
};
|
|
161
171
|
const columns = (Array.isArray(data.columns)
|
|
162
172
|
? data.columns
|
|
163
|
-
: Object.keys((
|
|
173
|
+
: Object.keys((_e = data.values[0]) !== null && _e !== void 0 ? _e : [])).map(stripQuotes);
|
|
164
174
|
const rows = data.values.map((row) => columns.map((col) => {
|
|
165
175
|
const value = row[col];
|
|
166
176
|
return value == null ? '' : stripQuotes(value);
|
|
@@ -178,13 +188,11 @@ const toResponseBlockType = (answer, userId) => {
|
|
|
178
188
|
chatSessionId: chat_session_id,
|
|
179
189
|
userId,
|
|
180
190
|
sender: 'agent',
|
|
181
|
-
state: (0,
|
|
182
|
-
type: (0,
|
|
191
|
+
state: (0, aiCfoState_1.toAiCfoAnswerStateType)(state),
|
|
192
|
+
type: (0, aiCfoState_1.toAiCfoAnswerResponseType)(type),
|
|
183
193
|
content: {
|
|
184
194
|
text: text,
|
|
185
|
-
visualization: visualization != null
|
|
186
|
-
? (0, exports.toAIControllerVisualization)(visualization)
|
|
187
|
-
: undefined,
|
|
195
|
+
visualization: visualization != null ? (0, exports.toAiCfoVisualization)(visualization) : undefined,
|
|
188
196
|
followUpQuestions: follow_up_questions !== null && follow_up_questions !== void 0 ? follow_up_questions : [],
|
|
189
197
|
assumptions: assumptions !== null && assumptions !== void 0 ? assumptions : '',
|
|
190
198
|
insights: insights !== null && insights !== void 0 ? insights : '',
|
|
@@ -193,13 +201,13 @@ const toResponseBlockType = (answer, userId) => {
|
|
|
193
201
|
createdAt: (0, zeniDayJS_1.date)(timestamp),
|
|
194
202
|
};
|
|
195
203
|
};
|
|
196
|
-
const
|
|
197
|
-
name: '
|
|
198
|
-
initialState: exports.
|
|
204
|
+
const aiCfo = (0, toolkit_1.createSlice)({
|
|
205
|
+
name: 'aiCfo',
|
|
206
|
+
initialState: exports.initialAiCfoState,
|
|
199
207
|
reducers: {
|
|
200
208
|
setNewSession(draft, action) {
|
|
201
209
|
const { chatSessionId, userId, createdAt } = action.payload;
|
|
202
|
-
draft.
|
|
210
|
+
draft.aiCfoByChatSessionId[chatSessionId] = {
|
|
203
211
|
chatSession: {
|
|
204
212
|
chatSessionId,
|
|
205
213
|
userId,
|
|
@@ -215,8 +223,8 @@ const aiController = (0, toolkit_1.createSlice)({
|
|
|
215
223
|
action.payload.forEach((chatSessionPayload) => {
|
|
216
224
|
const { chat_session_id } = chatSessionPayload;
|
|
217
225
|
// This is to prevent overwriting the session if it is already in state
|
|
218
|
-
if (draft.
|
|
219
|
-
draft.
|
|
226
|
+
if (draft.aiCfoByChatSessionId[chat_session_id] == null) {
|
|
227
|
+
draft.aiCfoByChatSessionId[chat_session_id] = {
|
|
220
228
|
chatSession: toChatSession(chatSessionPayload),
|
|
221
229
|
questionAnswers: [],
|
|
222
230
|
};
|
|
@@ -227,11 +235,11 @@ const aiController = (0, toolkit_1.createSlice)({
|
|
|
227
235
|
},
|
|
228
236
|
setChatHistory(draft, action) {
|
|
229
237
|
const { chatSessionId, history, isPaginationComplete = false, } = action.payload;
|
|
230
|
-
if (draft.
|
|
238
|
+
if (draft.aiCfoByChatSessionId[chatSessionId] == null) {
|
|
231
239
|
console.warn(`session with id ${chatSessionId} not found in setChatHistory`);
|
|
232
240
|
return;
|
|
233
241
|
}
|
|
234
|
-
const session = draft.
|
|
242
|
+
const session = draft.aiCfoByChatSessionId[chatSessionId];
|
|
235
243
|
// Check if we have an existing partial Q&A pair for this session
|
|
236
244
|
const existingPartialQA = draft.partialQuestionAnswers[chatSessionId];
|
|
237
245
|
// Process new messages into Q&A pairs
|
|
@@ -366,13 +374,13 @@ const aiController = (0, toolkit_1.createSlice)({
|
|
|
366
374
|
*/
|
|
367
375
|
upsertOrAddQuestionAnswerPayload(draft, action) {
|
|
368
376
|
const { chatSessionId, questionAnswerId, question: { questionId, createdAt, text }, answerPayload, userId, insertQuestionAnswer, } = action.payload;
|
|
369
|
-
const session = draft.
|
|
377
|
+
const session = draft.aiCfoByChatSessionId[chatSessionId];
|
|
370
378
|
if (session == null) {
|
|
371
379
|
console.warn(`session with id ${chatSessionId} not found `);
|
|
372
380
|
return;
|
|
373
381
|
}
|
|
374
382
|
let qa = session.questionAnswers.find((qa) => qa.questionAnswerId === questionAnswerId);
|
|
375
|
-
const responseType = (0,
|
|
383
|
+
const responseType = (0, aiCfoState_1.toAiCfoAnswerResponseTypeStrict)(answerPayload.type);
|
|
376
384
|
if (insertQuestionAnswer === true && qa == null) {
|
|
377
385
|
// Add new Q/A
|
|
378
386
|
qa = {
|
|
@@ -399,7 +407,7 @@ const aiController = (0, toolkit_1.createSlice)({
|
|
|
399
407
|
},
|
|
400
408
|
upsertAnswerPayload(draft, action) {
|
|
401
409
|
const { chatSessionId, answerPayload, questionAnswerId, userId } = action.payload;
|
|
402
|
-
const session = draft.
|
|
410
|
+
const session = draft.aiCfoByChatSessionId[chatSessionId];
|
|
403
411
|
if (session == null) {
|
|
404
412
|
console.warn(`session with id ${chatSessionId} not found in upsertAnswerPayload`);
|
|
405
413
|
return;
|
|
@@ -407,7 +415,7 @@ const aiController = (0, toolkit_1.createSlice)({
|
|
|
407
415
|
const latestQA = questionAnswerId != null
|
|
408
416
|
? session.questionAnswers.find((questionAnswer) => questionAnswer.questionAnswerId === questionAnswerId)
|
|
409
417
|
: session.questionAnswers.slice(-1)[0];
|
|
410
|
-
const responseType = (0,
|
|
418
|
+
const responseType = (0, aiCfoState_1.toAiCfoAnswerResponseTypeStrict)(answerPayload.type);
|
|
411
419
|
if (latestQA != null && responseType != null) {
|
|
412
420
|
// Directly mutate the responses property
|
|
413
421
|
latestQA.responses[responseType] = toResponseBlockType(answerPayload, userId);
|
|
@@ -415,7 +423,7 @@ const aiController = (0, toolkit_1.createSlice)({
|
|
|
415
423
|
},
|
|
416
424
|
addQuestionPayload(draft, action) {
|
|
417
425
|
const { chatSessionId, questionAnswerId, question: { questionId, createdAt, text }, userId, } = action.payload;
|
|
418
|
-
const session = draft.
|
|
426
|
+
const session = draft.aiCfoByChatSessionId[chatSessionId];
|
|
419
427
|
if (session == null) {
|
|
420
428
|
console.warn(`session with id ${chatSessionId} not found in addQuestionPayload`);
|
|
421
429
|
return;
|
|
@@ -442,19 +450,19 @@ const aiController = (0, toolkit_1.createSlice)({
|
|
|
442
450
|
clearSession(draft, action) {
|
|
443
451
|
var _a;
|
|
444
452
|
const sessionId = action.payload;
|
|
445
|
-
delete draft.
|
|
453
|
+
delete draft.aiCfoByChatSessionId[sessionId];
|
|
446
454
|
// Clear partial Q&A if it belongs to the cleared session
|
|
447
455
|
if (((_a = draft.partialQuestionAnswers) === null || _a === void 0 ? void 0 : _a[sessionId]) != null) {
|
|
448
456
|
draft.partialQuestionAnswers[sessionId] = undefined;
|
|
449
457
|
}
|
|
450
458
|
},
|
|
451
|
-
|
|
452
|
-
draft.
|
|
459
|
+
clearAiCfo(draft) {
|
|
460
|
+
draft.aiCfoByChatSessionId = {};
|
|
453
461
|
draft.partialQuestionAnswers = {};
|
|
454
462
|
},
|
|
455
463
|
deleteQuestion(draft, action) {
|
|
456
464
|
const { chatSessionId, questionAnswerId } = action.payload;
|
|
457
|
-
const session = draft.
|
|
465
|
+
const session = draft.aiCfoByChatSessionId[chatSessionId];
|
|
458
466
|
if (session == null) {
|
|
459
467
|
console.warn(`session with id ${chatSessionId} not found in deleteQuestion`);
|
|
460
468
|
return;
|
|
@@ -475,5 +483,5 @@ const toChatSession = (chatSessionPayload) => {
|
|
|
475
483
|
createdAt: (0, zeniDayJS_1.date)(created_at),
|
|
476
484
|
};
|
|
477
485
|
};
|
|
478
|
-
_a =
|
|
479
|
-
exports.default =
|
|
486
|
+
_a = aiCfo.actions, exports.setNewSession = _a.setNewSession, exports.clearSession = _a.clearSession, exports.setSessions = _a.setSessions, exports.setChatHistory = _a.setChatHistory, exports.upsertAnswerPayload = _a.upsertAnswerPayload, exports.upsertOrAddQuestionAnswerPayload = _a.upsertOrAddQuestionAnswerPayload, exports.addQuestionPayload = _a.addQuestionPayload, exports.clearAiCfo = _a.clearAiCfo, exports.deleteQuestion = _a.deleteQuestion;
|
|
487
|
+
exports.default = aiCfo.reducer;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ID } from '../../commonStateTypes/common';
|
|
2
|
+
import { AiCfoQuestionWithAnswer, AiCfoState } from './aiCfoState';
|
|
3
|
+
import { ChatSession } from './aiCfoState';
|
|
4
|
+
export declare function getAllQuestionAnswersForChatSession(state: AiCfoState, chatSessionId: ID): AiCfoQuestionWithAnswer[];
|
|
5
|
+
export declare function getQuestionAnswerByIdForChatSession(state: AiCfoState, chatSessionId: ID, questionAnswerId: ID): AiCfoQuestionWithAnswer | undefined;
|
|
6
|
+
export declare function getAllQuestionsForChatSession(state: AiCfoState, chatSessionId: ID): string[];
|
|
7
|
+
export interface AiCfoSelectorView {
|
|
8
|
+
allSessionsWithOrderedQuestionAnswers: ChatSessionWithOrderedQuestionAnswers[];
|
|
9
|
+
}
|
|
10
|
+
export interface ChatSessionWithOrderedQuestionAnswers {
|
|
11
|
+
chatSession: ChatSession;
|
|
12
|
+
questionAnswers: AiCfoQuestionWithAnswer[];
|
|
13
|
+
}
|
|
14
|
+
export declare function getAiCfoSelectorView(state: AiCfoState): AiCfoSelectorView;
|
|
@@ -3,17 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getAllQuestionAnswersForChatSession = getAllQuestionAnswersForChatSession;
|
|
4
4
|
exports.getQuestionAnswerByIdForChatSession = getQuestionAnswerByIdForChatSession;
|
|
5
5
|
exports.getAllQuestionsForChatSession = getAllQuestionsForChatSession;
|
|
6
|
-
exports.
|
|
6
|
+
exports.getAiCfoSelectorView = getAiCfoSelectorView;
|
|
7
7
|
function getAllQuestionAnswersForChatSession(state, chatSessionId) {
|
|
8
8
|
var _a, _b;
|
|
9
|
-
const arr = (_b = (_a = state.
|
|
9
|
+
const arr = (_b = (_a = state.aiCfoByChatSessionId[chatSessionId]) === null || _a === void 0 ? void 0 : _a.questionAnswers) !== null && _b !== void 0 ? _b : [];
|
|
10
10
|
return arr
|
|
11
11
|
.slice()
|
|
12
12
|
.sort((a, b) => a.question.createdAt.valueOf() - b.question.createdAt.valueOf());
|
|
13
13
|
}
|
|
14
14
|
function getQuestionAnswerByIdForChatSession(state, chatSessionId, questionAnswerId) {
|
|
15
15
|
var _a;
|
|
16
|
-
const arr = (_a = state.
|
|
16
|
+
const arr = (_a = state.aiCfoByChatSessionId[chatSessionId]) === null || _a === void 0 ? void 0 : _a.questionAnswers;
|
|
17
17
|
if (arr == null) {
|
|
18
18
|
return undefined;
|
|
19
19
|
}
|
|
@@ -21,7 +21,7 @@ function getQuestionAnswerByIdForChatSession(state, chatSessionId, questionAnswe
|
|
|
21
21
|
}
|
|
22
22
|
function getAllQuestionsForChatSession(state, chatSessionId) {
|
|
23
23
|
var _a;
|
|
24
|
-
const arr = (_a = state.
|
|
24
|
+
const arr = (_a = state.aiCfoByChatSessionId[chatSessionId]) === null || _a === void 0 ? void 0 : _a.questionAnswers;
|
|
25
25
|
if (arr == null) {
|
|
26
26
|
return [];
|
|
27
27
|
}
|
|
@@ -30,8 +30,8 @@ function getAllQuestionsForChatSession(state, chatSessionId) {
|
|
|
30
30
|
.sort((first, second) => first.question.createdAt.valueOf() - second.question.createdAt.valueOf())
|
|
31
31
|
.map((qa) => qa.question.questionText);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
const allSessionsWithOrderedQuestionAnswers = Object.values(state.
|
|
33
|
+
function getAiCfoSelectorView(state) {
|
|
34
|
+
const allSessionsWithOrderedQuestionAnswers = Object.values(state.aiCfoByChatSessionId)
|
|
35
35
|
.map((sessionWithQAs) => (Object.assign(Object.assign({}, sessionWithQAs), { questionAnswers: Array.isArray(sessionWithQAs.questionAnswers)
|
|
36
36
|
? sessionWithQAs.questionAnswers
|
|
37
37
|
.slice()
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ID } from '../../commonStateTypes/common';
|
|
2
|
+
import { ZeniDate } from '../../zeniDayJS';
|
|
3
|
+
export interface AiCfoAnswerParagraph {
|
|
4
|
+
text: string;
|
|
5
|
+
orderedList?: Array<{
|
|
6
|
+
text: string;
|
|
7
|
+
subText?: string;
|
|
8
|
+
unorderedList?: string[];
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
export declare const ALL_AI_CFO_CHARTS_TYPES: readonly ["bar_chart", "pie_chart", "line_chart"];
|
|
12
|
+
export declare const ALL_AI_CFO_VISUALIZATION_TYPES: readonly ["bar_chart", "pie_chart", "line_chart", "table"];
|
|
13
|
+
export declare const toAiCfoVisualizationType: (v: string) => "bar_chart" | "pie_chart" | "line_chart" | "table";
|
|
14
|
+
export declare const toAiCfoVisualizationTypeStrict: (v: string) => "bar_chart" | "pie_chart" | "line_chart" | "table" | undefined;
|
|
15
|
+
export type AiCfoVisualizationType = ReturnType<typeof toAiCfoVisualizationType>;
|
|
16
|
+
export declare const toAiCfoChartType: (v: string) => "bar_chart" | "pie_chart" | "line_chart";
|
|
17
|
+
export declare const toAiCfoChartTypeStrict: (v: string) => "bar_chart" | "pie_chart" | "line_chart" | undefined;
|
|
18
|
+
export type AiCfoChartType = ReturnType<typeof toAiCfoChartType>;
|
|
19
|
+
export declare const ALL_AI_CFO_ANSWER_STATE_TYPES: readonly ["complete", "partial"];
|
|
20
|
+
export declare const ALL_AI_CFO_ANSWER_RESPONSE_TYPES: readonly ["analysis", "answer", "reasoning", "thought"];
|
|
21
|
+
export declare const ALL_Y_FORMAT_TYPES: readonly ["currency", "number"];
|
|
22
|
+
export declare const ALL_Y_FORMAT_NON_CURRENCY_UNITS: readonly ["percentage", "unit", "ratio"];
|
|
23
|
+
export declare const ALL_Y_FORMAT_SCALES: readonly ["raw", "K", "M", "B", "T"];
|
|
24
|
+
export declare const toYFormatType: (v: string) => "number" | "currency";
|
|
25
|
+
export declare const toYFormatUnit: (v: string) => string;
|
|
26
|
+
export declare const toYFormatScale: (v: string) => "M" | "raw" | "K" | "B" | "T";
|
|
27
|
+
export declare const toYFormatTypeStrict: (v: string) => "number" | "currency" | undefined;
|
|
28
|
+
export declare const toYFormatUnitStrict: (v: string) => string;
|
|
29
|
+
export declare const toYFormatScaleStrict: (v: string) => "M" | "raw" | "K" | "B" | "T" | undefined;
|
|
30
|
+
export type YFormatType = ReturnType<typeof toYFormatType>;
|
|
31
|
+
export type YFormatUnit = ReturnType<typeof toYFormatUnit>;
|
|
32
|
+
export type YFormatScale = ReturnType<typeof toYFormatScale>;
|
|
33
|
+
export interface YFormat {
|
|
34
|
+
type: YFormatType;
|
|
35
|
+
unit: YFormatUnit;
|
|
36
|
+
scale: YFormatScale;
|
|
37
|
+
symbol?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare const toAiCfoAnswerStateType: (v: string) => "complete" | "partial";
|
|
40
|
+
export declare const toAiCfoAnswerResponseType: (v: string) => "analysis" | "answer" | "reasoning" | "thought";
|
|
41
|
+
export declare const toAiCfoAnswerStateTypeStrict: (v: string) => "complete" | "partial" | undefined;
|
|
42
|
+
export declare const toAiCfoAnswerResponseTypeStrict: (v: string) => "analysis" | "answer" | "reasoning" | "thought" | undefined;
|
|
43
|
+
export type AiCfoAnswerStateType = ReturnType<typeof toAiCfoAnswerStateType>;
|
|
44
|
+
export type AiCfoAnswerResponseType = ReturnType<typeof toAiCfoAnswerResponseType>;
|
|
45
|
+
export interface TableVisualization {
|
|
46
|
+
rows: string[][];
|
|
47
|
+
columns: string[];
|
|
48
|
+
}
|
|
49
|
+
export interface ChartVisualization {
|
|
50
|
+
values: Array<Record<string, string | number>>;
|
|
51
|
+
x: string;
|
|
52
|
+
y: string[];
|
|
53
|
+
yFormat?: YFormat;
|
|
54
|
+
lines?: string[];
|
|
55
|
+
}
|
|
56
|
+
export interface AiCfoVisualization {
|
|
57
|
+
type: AiCfoVisualizationType;
|
|
58
|
+
data: TableVisualization | ChartVisualization;
|
|
59
|
+
}
|
|
60
|
+
export declare const toMessageSender: (v: string) => "user" | "agent";
|
|
61
|
+
export declare const toMessageType: (v: string) => "plain_text" | "json";
|
|
62
|
+
export declare const toMessageSenderStrict: (v: string) => "user" | "agent" | undefined;
|
|
63
|
+
export declare const toMessageTypeStrict: (v: string) => "plain_text" | "json" | undefined;
|
|
64
|
+
export type MessageSender = ReturnType<typeof toMessageSender>;
|
|
65
|
+
export type MessageType = ReturnType<typeof toMessageType>;
|
|
66
|
+
export interface ResponseBlockBase {
|
|
67
|
+
messageId: ID;
|
|
68
|
+
state: AiCfoAnswerStateType;
|
|
69
|
+
createdAt: ZeniDate;
|
|
70
|
+
chatSessionId: ID;
|
|
71
|
+
userId: ID;
|
|
72
|
+
sender: MessageSender;
|
|
73
|
+
}
|
|
74
|
+
export interface AnswerContentBlockBase {
|
|
75
|
+
text: string;
|
|
76
|
+
followUpQuestions: string[];
|
|
77
|
+
assumptions: string;
|
|
78
|
+
insights: string;
|
|
79
|
+
summarizedTitle?: string;
|
|
80
|
+
visualization?: AiCfoVisualization;
|
|
81
|
+
}
|
|
82
|
+
export interface QuestionContentBlockBase extends ResponseBlockBase {
|
|
83
|
+
questionText: string;
|
|
84
|
+
}
|
|
85
|
+
export interface ResponseBlockType extends ResponseBlockBase {
|
|
86
|
+
content: AnswerContentBlockBase;
|
|
87
|
+
type: AiCfoAnswerResponseType;
|
|
88
|
+
}
|
|
89
|
+
export interface AiCfoQuestionWithAnswer {
|
|
90
|
+
questionAnswerId: ID;
|
|
91
|
+
question: QuestionContentBlockBase;
|
|
92
|
+
responses: Partial<Record<AiCfoAnswerResponseType, ResponseBlockType>>;
|
|
93
|
+
}
|
|
94
|
+
export interface ChatSession {
|
|
95
|
+
chatSessionId: ID;
|
|
96
|
+
userId: ID;
|
|
97
|
+
createdAt: ZeniDate;
|
|
98
|
+
chatSessionSummary?: string;
|
|
99
|
+
}
|
|
100
|
+
export interface ChatSessionWithMessages {
|
|
101
|
+
chatSession: ChatSession;
|
|
102
|
+
questionAnswers: AiCfoQuestionWithAnswer[];
|
|
103
|
+
}
|
|
104
|
+
export interface AiCfoState {
|
|
105
|
+
aiCfoByChatSessionId: Record<ID, ChatSessionWithMessages>;
|
|
106
|
+
partialQuestionAnswers: Record<ID, AiCfoQuestionWithAnswer | undefined>;
|
|
107
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toMessageTypeStrict = exports.toMessageSenderStrict = exports.toMessageType = exports.toMessageSender = exports.toAiCfoAnswerResponseTypeStrict = exports.toAiCfoAnswerStateTypeStrict = exports.toAiCfoAnswerResponseType = exports.toAiCfoAnswerStateType = exports.toYFormatScaleStrict = exports.toYFormatUnitStrict = exports.toYFormatTypeStrict = exports.toYFormatScale = exports.toYFormatUnit = exports.toYFormatType = exports.ALL_Y_FORMAT_SCALES = exports.ALL_Y_FORMAT_NON_CURRENCY_UNITS = exports.ALL_Y_FORMAT_TYPES = exports.ALL_AI_CFO_ANSWER_RESPONSE_TYPES = exports.ALL_AI_CFO_ANSWER_STATE_TYPES = exports.toAiCfoChartTypeStrict = exports.toAiCfoChartType = exports.toAiCfoVisualizationTypeStrict = exports.toAiCfoVisualizationType = exports.ALL_AI_CFO_VISUALIZATION_TYPES = exports.ALL_AI_CFO_CHARTS_TYPES = void 0;
|
|
4
|
+
const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
|
|
5
|
+
exports.ALL_AI_CFO_CHARTS_TYPES = [
|
|
6
|
+
'bar_chart',
|
|
7
|
+
'pie_chart',
|
|
8
|
+
'line_chart',
|
|
9
|
+
];
|
|
10
|
+
exports.ALL_AI_CFO_VISUALIZATION_TYPES = [
|
|
11
|
+
...exports.ALL_AI_CFO_CHARTS_TYPES,
|
|
12
|
+
'table',
|
|
13
|
+
];
|
|
14
|
+
const toAiCfoVisualizationType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_AI_CFO_VISUALIZATION_TYPES);
|
|
15
|
+
exports.toAiCfoVisualizationType = toAiCfoVisualizationType;
|
|
16
|
+
const toAiCfoVisualizationTypeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, exports.ALL_AI_CFO_VISUALIZATION_TYPES);
|
|
17
|
+
exports.toAiCfoVisualizationTypeStrict = toAiCfoVisualizationTypeStrict;
|
|
18
|
+
const toAiCfoChartType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_AI_CFO_CHARTS_TYPES);
|
|
19
|
+
exports.toAiCfoChartType = toAiCfoChartType;
|
|
20
|
+
const toAiCfoChartTypeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, exports.ALL_AI_CFO_CHARTS_TYPES);
|
|
21
|
+
exports.toAiCfoChartTypeStrict = toAiCfoChartTypeStrict;
|
|
22
|
+
exports.ALL_AI_CFO_ANSWER_STATE_TYPES = ['complete', 'partial'];
|
|
23
|
+
exports.ALL_AI_CFO_ANSWER_RESPONSE_TYPES = [
|
|
24
|
+
'analysis',
|
|
25
|
+
'answer',
|
|
26
|
+
'reasoning',
|
|
27
|
+
'thought',
|
|
28
|
+
];
|
|
29
|
+
exports.ALL_Y_FORMAT_TYPES = ['currency', 'number'];
|
|
30
|
+
exports.ALL_Y_FORMAT_NON_CURRENCY_UNITS = [
|
|
31
|
+
'percentage',
|
|
32
|
+
'unit',
|
|
33
|
+
'ratio',
|
|
34
|
+
];
|
|
35
|
+
exports.ALL_Y_FORMAT_SCALES = ['raw', 'K', 'M', 'B', 'T'];
|
|
36
|
+
const toYFormatType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_Y_FORMAT_TYPES);
|
|
37
|
+
exports.toYFormatType = toYFormatType;
|
|
38
|
+
const toYFormatUnit = (v) => {
|
|
39
|
+
// Check if it's one of the non-currency units
|
|
40
|
+
const nonCurrencyUnit = (0, stringToUnion_1.stringToUnion)(v, exports.ALL_Y_FORMAT_NON_CURRENCY_UNITS);
|
|
41
|
+
if (nonCurrencyUnit) {
|
|
42
|
+
return nonCurrencyUnit;
|
|
43
|
+
}
|
|
44
|
+
// If not a non-currency unit, assume it's a currency code and return it.
|
|
45
|
+
return v;
|
|
46
|
+
};
|
|
47
|
+
exports.toYFormatUnit = toYFormatUnit;
|
|
48
|
+
const toYFormatScale = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_Y_FORMAT_SCALES);
|
|
49
|
+
exports.toYFormatScale = toYFormatScale;
|
|
50
|
+
const toYFormatTypeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, exports.ALL_Y_FORMAT_TYPES);
|
|
51
|
+
exports.toYFormatTypeStrict = toYFormatTypeStrict;
|
|
52
|
+
const toYFormatUnitStrict = (v) => {
|
|
53
|
+
// Check if it's one of the non-currency units
|
|
54
|
+
const nonCurrencyUnit = (0, stringToUnion_1.stringToUnionStrict)(v, exports.ALL_Y_FORMAT_NON_CURRENCY_UNITS);
|
|
55
|
+
if (nonCurrencyUnit) {
|
|
56
|
+
return nonCurrencyUnit;
|
|
57
|
+
}
|
|
58
|
+
// If not a non-currency unit, assume it's a currency code and return it.
|
|
59
|
+
return v;
|
|
60
|
+
};
|
|
61
|
+
exports.toYFormatUnitStrict = toYFormatUnitStrict;
|
|
62
|
+
const toYFormatScaleStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, exports.ALL_Y_FORMAT_SCALES);
|
|
63
|
+
exports.toYFormatScaleStrict = toYFormatScaleStrict;
|
|
64
|
+
const toAiCfoAnswerStateType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_AI_CFO_ANSWER_STATE_TYPES);
|
|
65
|
+
exports.toAiCfoAnswerStateType = toAiCfoAnswerStateType;
|
|
66
|
+
const toAiCfoAnswerResponseType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_AI_CFO_ANSWER_RESPONSE_TYPES);
|
|
67
|
+
exports.toAiCfoAnswerResponseType = toAiCfoAnswerResponseType;
|
|
68
|
+
const toAiCfoAnswerStateTypeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, exports.ALL_AI_CFO_ANSWER_STATE_TYPES);
|
|
69
|
+
exports.toAiCfoAnswerStateTypeStrict = toAiCfoAnswerStateTypeStrict;
|
|
70
|
+
const toAiCfoAnswerResponseTypeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, exports.ALL_AI_CFO_ANSWER_RESPONSE_TYPES);
|
|
71
|
+
exports.toAiCfoAnswerResponseTypeStrict = toAiCfoAnswerResponseTypeStrict;
|
|
72
|
+
const ALL_MESSAGE_SENDERS = ['user', 'agent'];
|
|
73
|
+
const ALL_MESSAGE_TYPES = ['plain_text', 'json'];
|
|
74
|
+
const toMessageSender = (v) => (0, stringToUnion_1.stringToUnion)(v, ALL_MESSAGE_SENDERS);
|
|
75
|
+
exports.toMessageSender = toMessageSender;
|
|
76
|
+
const toMessageType = (v) => (0, stringToUnion_1.stringToUnion)(v, ALL_MESSAGE_TYPES);
|
|
77
|
+
exports.toMessageType = toMessageType;
|
|
78
|
+
const toMessageSenderStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, ALL_MESSAGE_SENDERS);
|
|
79
|
+
exports.toMessageSenderStrict = toMessageSenderStrict;
|
|
80
|
+
const toMessageTypeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, ALL_MESSAGE_TYPES);
|
|
81
|
+
exports.toMessageTypeStrict = toMessageTypeStrict;
|