@zeniai/client-epic-state 4.16.82 → 4.16.83

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.
Files changed (64) hide show
  1. package/lib/entity/account/accountPayload.d.ts +0 -1
  2. package/lib/entity/account/accountPayload.js +0 -3
  3. package/lib/entity/account/accountSelector.js +0 -1
  4. package/lib/entity/account/accountState.d.ts +0 -4
  5. package/lib/entity/account/accountState.js +1 -6
  6. package/lib/entity/accountRecon/accountReconPayload.d.ts +0 -7
  7. package/lib/entity/accountRecon/accountReconPayload.js +0 -16
  8. package/lib/entity/accountRecon/accountReconReducer.d.ts +1 -8
  9. package/lib/entity/accountRecon/accountReconReducer.js +2 -57
  10. package/lib/entity/accountRecon/accountReconSelector.d.ts +2 -15
  11. package/lib/entity/accountRecon/accountReconSelector.js +1 -11
  12. package/lib/entity/accountRecon/accountReconState.d.ts +1 -17
  13. package/lib/entity/accountRecon/accountReconState.js +2 -21
  14. package/lib/entity/aiController/aiControllerPayload.d.ts +1 -1
  15. package/lib/entity/aiController/aiControllerReducer.d.ts +1 -4
  16. package/lib/entity/aiController/aiControllerReducer.js +90 -266
  17. package/lib/entity/aiController/aiControllerState.d.ts +1 -3
  18. package/lib/entity/file/filePayload.d.ts +9 -9
  19. package/lib/entity/file/fileState.d.ts +4 -4
  20. package/lib/entity/tenant/clearAllEpic.d.ts +2 -2
  21. package/lib/entity/tenant/clearAllEpic.js +1 -1
  22. package/lib/epic.d.ts +1 -3
  23. package/lib/epic.js +1 -3
  24. package/lib/index.d.ts +7 -9
  25. package/lib/index.js +28 -38
  26. package/lib/view/aiControllerView/aiControllerViewReducer.d.ts +1 -4
  27. package/lib/view/aiControllerView/aiControllerViewReducer.js +5 -27
  28. package/lib/view/aiControllerView/aiControllerViewSelector.d.ts +0 -1
  29. package/lib/view/aiControllerView/aiControllerViewSelector.js +2 -3
  30. package/lib/view/aiControllerView/aiControllerViewState.d.ts +2 -5
  31. package/lib/view/aiControllerView/epics/fetchChatHistoryEpic.d.ts +1 -1
  32. package/lib/view/aiControllerView/epics/fetchChatHistoryEpic.js +3 -15
  33. package/lib/view/aiControllerView/epics/fetchChatSessionsForUserEpic.d.ts +1 -1
  34. package/lib/view/aiControllerView/epics/fetchChatSessionsForUserEpic.js +3 -15
  35. package/lib/view/aiControllerView/epics/submitQuestionEpic.d.ts +2 -2
  36. package/lib/view/aiControllerView/epics/submitQuestionEpic.js +5 -6
  37. package/lib/view/autoComplete/entityAutoCompleteReducer.d.ts +2 -9
  38. package/lib/view/autoComplete/entityAutoCompleteReducer.js +11 -25
  39. package/lib/view/autoComplete/entityAutoCompleteSelector.d.ts +1 -3
  40. package/lib/view/autoComplete/entityAutoCompleteSelector.js +3 -3
  41. package/lib/view/autoComplete/entityAutoCompleteState.d.ts +2 -3
  42. package/lib/view/autoComplete/fetchEntityAutoCompleteEpic.js +6 -15
  43. package/lib/view/companyView/types/cockpitTypes.d.ts +2 -2
  44. package/lib/view/expenseAutomationView/epics/accountRecon/fetchReconciliationViewEpic.d.ts +1 -2
  45. package/lib/view/expenseAutomationView/epics/accountRecon/fetchReconciliationViewEpic.js +2 -4
  46. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +1 -27
  47. package/lib/view/expenseAutomationView/payload/reconciliationPayload.d.ts +1 -29
  48. package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.d.ts +4 -37
  49. package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.js +4 -80
  50. package/lib/view/expenseAutomationView/selectorTypes/reconciliationViewSelectorTypes.d.ts +4 -10
  51. package/lib/view/expenseAutomationView/selectors/reconciliationViewSelector.js +0 -12
  52. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +6 -16
  53. package/lib/view/spendManagement/billPay/billList/billListReducer.d.ts +1 -1
  54. package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
  55. package/lib/view/spendManagement/reimbursement/remiListView/remiListReducer.d.ts +1 -1
  56. package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +3 -3
  57. package/lib/view/vendorReviewView/vendorGlobalReviewView/vendorGlobalReviewViewState.d.ts +1 -1
  58. package/package.json +1 -1
  59. package/lib/view/expenseAutomationView/epics/accountRecon/deleteAccountStatementEpic.d.ts +0 -9
  60. package/lib/view/expenseAutomationView/epics/accountRecon/deleteAccountStatementEpic.js +0 -41
  61. package/lib/view/expenseAutomationView/epics/accountRecon/uploadAccountStatementDocumentAIHelper.d.ts +0 -12
  62. package/lib/view/expenseAutomationView/epics/accountRecon/uploadAccountStatementDocumentAIHelper.js +0 -54
  63. package/lib/view/expenseAutomationView/epics/accountRecon/uploadAccountStatementEpic.d.ts +0 -15
  64. package/lib/view/expenseAutomationView/epics/accountRecon/uploadAccountStatementEpic.js +0 -46
@@ -1,131 +1,105 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.updateNewSession = exports.deleteQuestion = exports.clearAIController = exports.addQuestionPayload = exports.upsertOrAddQuestionAnswerPayload = exports.upsertAnswerPayload = exports.setChatHistory = exports.setSessions = exports.clearSession = exports.setNewSession = exports.toAIControllerVisualization = exports.initialAIControllerState = void 0;
4
+ exports.deleteQuestion = exports.clearAIController = exports.addQuestionPayload = exports.upsertOrAddQuestionAnswerPayload = exports.upsertAnswerPayload = exports.setChatHistory = exports.setSessions = exports.clearSession = exports.setNewSession = exports.toAIControllerVisualization = exports.initialAIControllerState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const zeniDayJS_1 = require("../../zeniDayJS");
7
7
  const aiControllerState_1 = require("./aiControllerState");
8
8
  exports.initialAIControllerState = {
9
9
  aiControllerByChatSessionId: {},
10
- partialQuestionAnswers: {},
11
10
  };
12
- // Utility: Merge two arrays of Q&A pairs, combining responses for the same question
13
- function mergeQuestionAnswerPairs(existing, newQAs) {
14
- const merged = new Map();
15
- // Add existing Q&A pairs
16
- for (const qa of existing) {
17
- merged.set(qa.questionAnswerId, Object.assign({}, qa));
18
- }
19
- // Merge new Q&A pairs
20
- for (const newQA of newQAs) {
21
- const existingQA = merged.get(newQA.questionAnswerId);
22
- if (existingQA) {
23
- // Merge responses
24
- const mergedResponses = Object.assign(Object.assign({}, existingQA.responses), newQA.responses);
25
- merged.set(newQA.questionAnswerId, Object.assign(Object.assign({}, newQA), { responses: mergedResponses }));
26
- }
27
- else {
28
- // Add new Q&A pair
29
- merged.set(newQA.questionAnswerId, newQA);
30
- }
31
- }
32
- // Convert back to array and sort by question creation time
33
- return Array.from(merged.values()).sort((a, b) => a.question.createdAt.valueOf() - b.question.createdAt.valueOf());
34
- }
35
11
  // Utility: Convert chat history (array of MessagePayload) to AIControllerQuestionWithAnswer[]
36
12
  function chatHistoryToQA(history) {
37
- var _a, _b, _c;
38
- const questionGroups = new Map();
39
- // First pass: collect all messages and group by message_id
40
- for (const message of history) {
41
- const messageId = message.message_id;
42
- if (!questionGroups.has(messageId)) {
43
- questionGroups.set(messageId, {
44
- question: null,
45
- responses: [],
46
- });
47
- }
48
- const group = questionGroups.get(messageId);
49
- if (!group) {
50
- continue;
51
- }
52
- if (message.sender === 'user') {
53
- // User message is the question
54
- group.question = message;
55
- }
56
- else if (message.sender === 'agent') {
57
- // Agent message is a response block
58
- group.responses.push(message);
59
- }
60
- }
61
- // Convert groups to AIControllerQuestionWithAnswer
62
13
  const questionAnswerPairs = [];
63
- for (const [messageId, group] of questionGroups.entries()) {
64
- // Skip groups that don't have a question
65
- if (!group.question) {
66
- continue;
14
+ let userMessageIndex = 0;
15
+ while (userMessageIndex < history.length) {
16
+ // Skip all but the last consecutive user message
17
+ let lastUserMessageIndex = userMessageIndex;
18
+ while (lastUserMessageIndex + 1 < history.length &&
19
+ history[lastUserMessageIndex + 1].sender === 'user') {
20
+ lastUserMessageIndex++;
67
21
  }
68
- const question = {
69
- messageId: group.question.message_id,
70
- chatSessionId: group.question.chat_session_id,
71
- userId: group.question.user_id,
72
- sender: (0, aiControllerState_1.toMessageSender)(group.question.sender),
73
- state: 'complete',
74
- questionText: group.question.content,
75
- createdAt: (0, zeniDayJS_1.date)(group.question.created_at),
76
- };
77
- const responses = {};
78
- // Process each response for this question
79
- for (const agentMessage of group.responses) {
80
- try {
81
- const parsedAgentMessage = (0, aiControllerState_1.toMessageType)(agentMessage.message_type) === 'json'
82
- ? JSON.parse(agentMessage.content)
83
- : {
84
- text: agentMessage.content,
85
- state: 'complete',
86
- type: 'answer',
87
- visualization: null,
88
- follow_up_questions: [],
89
- };
90
- const responseType = (0, aiControllerState_1.toAIControllerAnswerResponseType)(parsedAgentMessage.type);
91
- const responseState = (0, aiControllerState_1.toAIControllerAnswerStateType)(parsedAgentMessage.state);
92
- if (typeof parsedAgentMessage.text === 'string' &&
93
- aiControllerState_1.ALL_AI_CONTROLLER_ANSWER_RESPONSE_TYPES.includes(responseType)) {
94
- responses[responseType] = {
95
- messageId: agentMessage.message_id,
96
- chatSessionId: agentMessage.chat_session_id,
97
- userId: agentMessage.user_id,
98
- sender: (0, aiControllerState_1.toMessageSender)(agentMessage.sender),
99
- type: responseType,
100
- state: responseState,
101
- content: {
102
- text: parsedAgentMessage.text,
103
- visualization: parsedAgentMessage.visualization
104
- ? (0, exports.toAIControllerVisualization)(parsedAgentMessage.visualization)
105
- : undefined,
106
- followUpQuestions: Array.isArray(parsedAgentMessage.follow_up_questions)
107
- ? parsedAgentMessage.follow_up_questions
108
- : [],
109
- assumptions: (_a = parsedAgentMessage.assumptions) !== null && _a !== void 0 ? _a : '',
110
- insights: (_b = parsedAgentMessage.insights) !== null && _b !== void 0 ? _b : '',
111
- summarizedTitle: (_c = parsedAgentMessage.summarized_title) !== null && _c !== void 0 ? _c : undefined,
112
- },
113
- createdAt: (0, zeniDayJS_1.date)(agentMessage.created_at),
114
- };
115
- }
22
+ const userMessage = history[lastUserMessageIndex];
23
+ if (userMessage.sender === 'user') {
24
+ // Find the next agent message
25
+ let agentMessageIndex = lastUserMessageIndex + 1;
26
+ while (agentMessageIndex < history.length &&
27
+ history[agentMessageIndex].sender !== 'agent') {
28
+ agentMessageIndex++;
116
29
  }
117
- catch (error) {
118
- console.error('Failed to parse agent message: ', error);
30
+ const agentMessage = agentMessageIndex < history.length &&
31
+ history[agentMessageIndex].sender === 'agent'
32
+ ? history[agentMessageIndex]
33
+ : null;
34
+ const questionAnswerId = `qa_${userMessage.message_id}`;
35
+ const sender = (0, aiControllerState_1.toMessageSender)(userMessage.sender);
36
+ const question = {
37
+ messageId: userMessage.message_id,
38
+ chatSessionId: userMessage.chat_session_id,
39
+ userId: userMessage.user_id,
40
+ sender,
41
+ state: 'complete',
42
+ questionText: userMessage.content,
43
+ createdAt: (0, zeniDayJS_1.date)(userMessage.created_at),
44
+ };
45
+ const responses = {};
46
+ if (agentMessage != null) {
47
+ try {
48
+ const parsedAgentMessage = (0, aiControllerState_1.toMessageType)(agentMessage.message_type) === 'json'
49
+ ? JSON.parse(agentMessage.content)
50
+ : {
51
+ text: agentMessage.content,
52
+ state: 'complete',
53
+ type: 'answer',
54
+ visualization: undefined,
55
+ follow_up_questions: [],
56
+ };
57
+ const responseType = (0, aiControllerState_1.toAIControllerAnswerResponseType)(parsedAgentMessage.type);
58
+ const responseState = (0, aiControllerState_1.toAIControllerAnswerStateType)(parsedAgentMessage.state);
59
+ if (typeof parsedAgentMessage.text === 'string' &&
60
+ aiControllerState_1.ALL_AI_CONTROLLER_ANSWER_RESPONSE_TYPES.includes(responseType)) {
61
+ responses[responseType] = {
62
+ messageId: agentMessage.message_id,
63
+ chatSessionId: agentMessage.chat_session_id,
64
+ userId: agentMessage.user_id,
65
+ sender: (0, aiControllerState_1.toMessageSender)(agentMessage.sender),
66
+ type: responseType,
67
+ state: responseState,
68
+ content: {
69
+ text: parsedAgentMessage.text,
70
+ visualization: parsedAgentMessage.visualization
71
+ ? (0, exports.toAIControllerVisualization)(parsedAgentMessage.visualization)
72
+ : undefined,
73
+ followUpQuestions: Array.isArray(parsedAgentMessage.follow_up_questions)
74
+ ? parsedAgentMessage.follow_up_questions
75
+ : [],
76
+ assumptions: '',
77
+ insights: '',
78
+ summarizedTitle: undefined,
79
+ },
80
+ createdAt: (0, zeniDayJS_1.date)(agentMessage.created_at),
81
+ };
82
+ }
83
+ }
84
+ catch (error) {
85
+ console.error('Failed to parse agent message: ', error);
86
+ }
119
87
  }
88
+ questionAnswerPairs.push({
89
+ questionAnswerId,
90
+ question,
91
+ responses,
92
+ });
93
+ userMessageIndex =
94
+ agentMessage !== null
95
+ ? agentMessageIndex + 1
96
+ : lastUserMessageIndex + 1;
97
+ }
98
+ else {
99
+ userMessageIndex++;
120
100
  }
121
- questionAnswerPairs.push({
122
- questionAnswerId: `qa_${messageId}`,
123
- question,
124
- responses,
125
- });
126
101
  }
127
- // Sort by question creation time (oldest first)
128
- return questionAnswerPairs.sort((a, b) => a.question.createdAt.valueOf() - b.question.createdAt.valueOf());
102
+ return questionAnswerPairs;
129
103
  }
130
104
  const toAIControllerVisualization = (visualization) => {
131
105
  var _a;
@@ -204,23 +178,10 @@ const aiController = (0, toolkit_1.createSlice)({
204
178
  chatSessionId,
205
179
  userId,
206
180
  chatSessionSummary: '',
207
- newSession: true,
208
181
  createdAt,
209
182
  },
210
183
  questionAnswers: [],
211
184
  };
212
- // Clear any existing partial Q&A when creating a new session
213
- draft.partialQuestionAnswers[chatSessionId] = undefined;
214
- },
215
- updateNewSession(draft, action) {
216
- const { chatSessionId } = action.payload;
217
- if (draft.aiControllerByChatSessionId[chatSessionId] == null) {
218
- console.warn(`session with id ${chatSessionId} not found`);
219
- return;
220
- }
221
- if (draft.aiControllerByChatSessionId[chatSessionId].chatSession.newSession) {
222
- draft.aiControllerByChatSessionId[chatSessionId].chatSession.newSession = false;
223
- }
224
185
  },
225
186
  setSessions(draft, action) {
226
187
  action.payload.forEach((chatSessionPayload) => {
@@ -229,145 +190,16 @@ const aiController = (0, toolkit_1.createSlice)({
229
190
  chatSession: toChatSession(chatSessionPayload),
230
191
  questionAnswers: [],
231
192
  };
232
- // Clear any existing partial Q&A for this session
233
- draft.partialQuestionAnswers[chatSessionPayload.chat_session_id] =
234
- undefined;
235
193
  });
236
194
  },
237
195
  setChatHistory(draft, action) {
238
- const { chatSessionId, history, isPaginationComplete = false, } = action.payload;
196
+ const { chatSessionId, history } = action.payload;
239
197
  if (draft.aiControllerByChatSessionId[chatSessionId] == null) {
240
198
  console.warn(`session with id ${chatSessionId} not found in setChatHistory`);
241
199
  return;
242
200
  }
243
- const session = draft.aiControllerByChatSessionId[chatSessionId];
244
- // Check if we have an existing partial Q&A pair for this session
245
- const existingPartialQA = draft.partialQuestionAnswers[chatSessionId];
246
- // Process new messages into Q&A pairs
247
- const newQAs = chatHistoryToQA(history);
248
- // If we have an existing partial Q&A pair, merge with new Q&A pairs
249
- let mergedQAs;
250
- if (existingPartialQA && newQAs.length > 0) {
251
- // Check if any new QAs have the same message_id as the existing partial QA
252
- const hasMatchingMessageId = newQAs.some((newQA) => newQA.question.messageId === existingPartialQA.question.messageId);
253
- if (hasMatchingMessageId) {
254
- // Merge the existing partial QA with new QAs that have matching message_id
255
- mergedQAs = mergeQuestionAnswerPairs([existingPartialQA], newQAs);
256
- }
257
- else {
258
- // No matching message_id - existing partial QA should be moved to complete
259
- // and new QAs should be processed separately
260
- mergedQAs = [existingPartialQA, ...newQAs];
261
- }
262
- }
263
- else if (existingPartialQA && newQAs.length === 0) {
264
- // Intermediate page scenario: existing partial QA but no new blocks to merge
265
- // This means the partial QA is complete (no more blocks coming to complete it)
266
- mergedQAs = [existingPartialQA];
267
- }
268
- else {
269
- mergedQAs = newQAs;
270
- }
271
- // Separate complete and incomplete pairs
272
- const completeQAs = [];
273
- let incompleteQA;
274
- for (const qa of mergedQAs) {
275
- const questionText = qa.question.questionText;
276
- const hasQuestion = questionText != null && questionText.trim().length > 0;
277
- if (!hasQuestion) {
278
- // Skip if no question text
279
- continue;
280
- }
281
- // Check if this Q&A pair is complete
282
- // A Q&A pair is considered complete if it has:
283
- // 1. A question (already checked above)
284
- // 2. At least one agent response (any type: thought, reasoning, analysis, answer, etc.)
285
- // 3. AND EITHER:
286
- // - At least one response with state: 'complete' (not 'partial')
287
- // - OR multiple response blocks (thought, reasoning, analysis) even if they're all partial
288
- const hasAnyResponse = Object.keys(qa.responses).length > 0;
289
- const hasCompleteResponse = Object.values(qa.responses).some((response) => response.state === 'complete');
290
- const hasMultipleResponseBlocks = Object.keys(qa.responses).length > 1;
291
- // Check if this is an existing partial QA that should be moved to complete
292
- // because no more blocks are coming to complete it
293
- const isExistingPartialQA = existingPartialQA &&
294
- qa.question.messageId === existingPartialQA.question.messageId &&
295
- !hasCompleteResponse;
296
- if (hasQuestion &&
297
- hasAnyResponse &&
298
- (hasCompleteResponse || hasMultipleResponseBlocks)) {
299
- // This Q&A pair is complete - has question and either:
300
- // - at least one complete response, OR
301
- // - multiple response blocks (thought, reasoning, analysis) even if all partial
302
- completeQAs.push(qa);
303
- }
304
- else if (hasQuestion &&
305
- hasAnyResponse &&
306
- isExistingPartialQA === true) {
307
- // This is an existing partial QA that should be moved to complete
308
- // because no more blocks are coming to complete it (intermediate page scenario)
309
- completeQAs.push(qa);
310
- }
311
- else if (hasQuestion && hasAnyResponse) {
312
- // This Q&A pair has a question and responses but they're all partial
313
- // Keep as incomplete for potential merging with future pages
314
- if (!incompleteQA) {
315
- incompleteQA = qa;
316
- }
317
- }
318
- else if (hasQuestion) {
319
- // This Q&A pair has only a question, no responses yet
320
- // Keep as incomplete for potential merging with future pages
321
- if (!incompleteQA) {
322
- incompleteQA = qa;
323
- }
324
- }
325
- }
326
- // Update partialQuestionAnswers based on completion status
327
- if (isPaginationComplete) {
328
- // If pagination is complete, we should have processed all messages
329
- // Any remaining incomplete Q&A pairs should be moved to complete
330
- if (incompleteQA) {
331
- // When pagination is complete, move all incomplete Q&A pairs to complete
332
- // This handles cases where:
333
- // 1. Question with no responses (error in generation)
334
- // 2. Question with only partial responses (error in generation)
335
- // 3. Question with only answer blocks (no thought/reasoning blocks)
336
- completeQAs.push(incompleteQA);
337
- draft.partialQuestionAnswers[chatSessionId] = undefined;
338
- }
339
- else {
340
- // No incomplete Q&A pairs, clear partialQuestionAnswers
341
- draft.partialQuestionAnswers[chatSessionId] = undefined;
342
- }
343
- }
344
- else if (incompleteQA) {
345
- // Check if this is an intermediate page scenario
346
- // If we had an existing partial QA but no new blocks were merged,
347
- // then the partial QA should be considered complete
348
- if (existingPartialQA && newQAs.length === 0) {
349
- // Intermediate page: existing partial QA but no new blocks to merge
350
- // Move the partial QA to complete since no more blocks are coming
351
- completeQAs.push(incompleteQA);
352
- draft.partialQuestionAnswers[chatSessionId] = undefined;
353
- }
354
- else {
355
- // Pagination is not complete, keep incomplete Q&A pairs for future merging
356
- draft.partialQuestionAnswers[chatSessionId] = incompleteQA;
357
- }
358
- }
359
- else if (existingPartialQA && newQAs.length === 0) {
360
- // Special case: existing partial QA but no new blocks and no incomplete QA in mergedQAs
361
- // This means the existing partial QA should be moved to complete
362
- completeQAs.push(existingPartialQA);
363
- draft.partialQuestionAnswers[chatSessionId] = undefined;
364
- }
365
- else {
366
- // No incomplete Q&A pairs, clear partialQuestionAnswers
367
- draft.partialQuestionAnswers[chatSessionId] = undefined;
368
- }
369
- // Update state - append new complete Q&As to existing ones
370
- session.questionAnswers = mergeQuestionAnswerPairs(session.questionAnswers, completeQAs);
201
+ draft.aiControllerByChatSessionId[chatSessionId].questionAnswers =
202
+ chatHistoryToQA(history);
371
203
  },
372
204
  /**
373
205
  * Upsert a Q/A pair: if the questionAnswerId exists, upsert the response block; if not, add a new Q/A entry.
@@ -449,17 +281,10 @@ const aiController = (0, toolkit_1.createSlice)({
449
281
  }
450
282
  },
451
283
  clearSession(draft, action) {
452
- var _a;
453
- const sessionId = action.payload;
454
- delete draft.aiControllerByChatSessionId[sessionId];
455
- // Clear partial Q&A if it belongs to the cleared session
456
- if (((_a = draft.partialQuestionAnswers) === null || _a === void 0 ? void 0 : _a[sessionId]) != null) {
457
- draft.partialQuestionAnswers[sessionId] = undefined;
458
- }
284
+ delete draft.aiControllerByChatSessionId[action.payload];
459
285
  },
460
286
  clearAIController(draft) {
461
287
  draft.aiControllerByChatSessionId = {};
462
- draft.partialQuestionAnswers = {};
463
288
  },
464
289
  deleteQuestion(draft, action) {
465
290
  const { chatSessionId, questionAnswerId } = action.payload;
@@ -480,10 +305,9 @@ const toChatSession = (chatSessionPayload) => {
480
305
  return {
481
306
  chatSessionId: chat_session_id,
482
307
  userId: user_id,
483
- newSession: false,
484
308
  chatSessionSummary: chat_session_summary !== null && chat_session_summary !== void 0 ? chat_session_summary : undefined,
485
309
  createdAt: (0, zeniDayJS_1.date)(created_at),
486
310
  };
487
311
  };
488
- _a = aiController.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.clearAIController = _a.clearAIController, exports.deleteQuestion = _a.deleteQuestion, exports.updateNewSession = _a.updateNewSession;
312
+ _a = aiController.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.clearAIController = _a.clearAIController, exports.deleteQuestion = _a.deleteQuestion;
489
313
  exports.default = aiController.reducer;
@@ -54,11 +54,11 @@ export interface ResponseBlockBase {
54
54
  }
55
55
  export interface AnswerContentBlockBase {
56
56
  text: string;
57
+ visualization?: AIControllerVisualization;
57
58
  followUpQuestions: string[];
58
59
  assumptions: string;
59
60
  insights: string;
60
61
  summarizedTitle?: string;
61
- visualization?: AIControllerVisualization;
62
62
  }
63
63
  export interface QuestionContentBlockBase extends ResponseBlockBase {
64
64
  questionText: string;
@@ -76,7 +76,6 @@ export interface ChatSession {
76
76
  chatSessionId: ID;
77
77
  userId: ID;
78
78
  createdAt: ZeniDate;
79
- newSession: boolean;
80
79
  chatSessionSummary?: string;
81
80
  }
82
81
  export interface ChatSessionWithMessages {
@@ -85,5 +84,4 @@ export interface ChatSessionWithMessages {
85
84
  }
86
85
  export interface AIControllerState {
87
86
  aiControllerByChatSessionId: Record<ID, ChatSessionWithMessages>;
88
- partialQuestionAnswers: Record<ID, AIControllerQuestionWithAnswer | undefined>;
89
87
  }
@@ -1,24 +1,24 @@
1
1
  import { ID } from '../../commonStateTypes/common';
2
2
  export interface FilePayload {
3
+ file_size_unit: string;
4
+ update_time?: string | null;
5
+ user_id?: string | null;
3
6
  image_file_ids: string[];
4
- document_type: string;
7
+ document_side: string;
5
8
  image_files: ImageFilePayload[];
6
9
  checksum: string;
7
- file_id: string;
8
10
  file_size: number;
9
- file_name: string;
10
- file_size_unit: string;
11
- file_location: string;
11
+ company_id?: string | null;
12
12
  signed_url: string;
13
13
  extension: string;
14
14
  create_time: string;
15
+ file_id: string;
15
16
  content_type: string;
17
+ file_name: string;
16
18
  purpose_id: string;
17
19
  create_userid: string;
18
- document_side: string | null;
19
- user_id?: string | null;
20
- company_id?: string | null;
21
- update_time?: string | null;
20
+ file_location: string;
21
+ document_type: string;
22
22
  update_userid?: string | null;
23
23
  }
24
24
  interface ImageFilePayload {
@@ -7,10 +7,14 @@ export interface FileState {
7
7
  }
8
8
  export interface File {
9
9
  fileSizeUnit: FileSizeUnit;
10
+ updateTime?: ZeniDate;
11
+ userId?: ID;
10
12
  imageFileIds: string[];
13
+ documentSide?: AllowedDocumentSideType;
11
14
  imageFiles: ImageFile[];
12
15
  checksum: string;
13
16
  fileSize: number;
17
+ companyId?: ID;
14
18
  signedUrl: ZeniUrl;
15
19
  extension: SupportedFileFormatType;
16
20
  createTime: ZeniDate;
@@ -21,10 +25,6 @@ export interface File {
21
25
  createUserid: ID;
22
26
  fileLocation: string;
23
27
  documentType: AllowedDocumentType;
24
- updateTime?: ZeniDate;
25
- userId?: ID;
26
- documentSide?: AllowedDocumentSideType;
27
- companyId?: ID;
28
28
  updateUserId?: ID;
29
29
  }
30
30
  interface ImageFile {
@@ -17,7 +17,7 @@ import { clearApAging } from '../../view/apAgingView/apAgingReport/apAgingReduce
17
17
  import { clearArAgingDetail } from '../../view/arAgingView/arAgingDetail/arAgingDetailReducer';
18
18
  import { clearArAging } from '../../view/arAgingView/arAgingReport/arAgingReducer';
19
19
  import { clearAuthenticationView } from '../../view/authenticationView/authenticationViewReducer';
20
- import { clearAllEntityAutoCompleteResults } from '../../view/autoComplete/entityAutoCompleteReducer';
20
+ import { clearEntityAutoCompleteResults } from '../../view/autoComplete/entityAutoCompleteReducer';
21
21
  import { clearBalanceSheet } from '../../view/balanceSheet/balanceSheetReducer';
22
22
  import { clearBankAccountView } from '../../view/bankAccountView/bankAccountViewReducer';
23
23
  import { clearBillPayCard } from '../../view/billPayCard/billPayCardReducer';
@@ -190,7 +190,7 @@ import { clearAllUserRoles } from '../userRole/userRoleReducer';
190
190
  import { clearAllVendors } from '../vendor/vendorReducer';
191
191
  import { clearAllVendorExpenseTrends } from '../vendorExpense/vendorExpenseReducer';
192
192
  import { clearAll } from './tenantReducer';
193
- type clearActionTypeForViews = ReturnType<typeof clearAccountList> | ReturnType<typeof clearAccountMappingView> | ReturnType<typeof clearActivityHistory> | ReturnType<typeof clearActivityRealTimeApproval> | ReturnType<typeof clearAddressView> | ReturnType<typeof clearAIControllerView> | ReturnType<typeof clearAllClasses> | ReturnType<typeof clearAllMonthEndCloseChecksView> | ReturnType<typeof clearApAging> | ReturnType<typeof clearApAgingDetail> | ReturnType<typeof clearArAging> | ReturnType<typeof clearArAgingDetail> | ReturnType<typeof clearAuthenticationView> | ReturnType<typeof clearBalanceSheet> | ReturnType<typeof clearBankAccountView> | ReturnType<typeof clearBillDetailView> | ReturnType<typeof clearBillList> | ReturnType<typeof clearBillPayBulkActionView> | ReturnType<typeof clearBillPayCard> | ReturnType<typeof clearBillPayConfig> | ReturnType<typeof clearBillPayReview> | ReturnType<typeof clearBillPaySetupApproverView> | ReturnType<typeof clearBillPaySetupView> | ReturnType<typeof clearCardBalance> | ReturnType<typeof clearCardPaymentView> | ReturnType<typeof clearCardUserOnboarding> | ReturnType<typeof clearCashbackDetail> | ReturnType<typeof clearCashBalance> | ReturnType<typeof clearCashFlow> | ReturnType<typeof clearCashInCashOut> | ReturnType<typeof clearCashPosition> | ReturnType<typeof clearChargeCardConfig> | ReturnType<typeof clearChargeCardDetail> | ReturnType<typeof clearChargeCardList> | ReturnType<typeof clearChargeCardSetupView> | ReturnType<typeof clearChargeCardStatementList> | ReturnType<typeof clearCheckDeposit> | ReturnType<typeof clearCompanyConfigView> | ReturnType<typeof clearCompanyHealthMetric> | ReturnType<typeof clearCompanyHealthMetricView> | ReturnType<typeof clearCompanyMonthEndReportView> | ReturnType<typeof clearCompanyTaskManagerView> | ReturnType<typeof clearCompanyView> | ReturnType<typeof clearDashboard> | ReturnType<typeof clearDashboardLayout> | ReturnType<typeof clearDepositAccountDetail> | ReturnType<typeof clearDepositAccountList> | ReturnType<typeof clearDepositAccountTransactionList> | ReturnType<typeof clearEditBillViewDetail> | ReturnType<typeof clearEditRemiViewDetail> | ReturnType<typeof clearAllEntityAutoCompleteResults> | ReturnType<typeof clearExpenseAutomationFluxAnalysisView> | ReturnType<typeof clearExpenseAutomationJESchedulesView> | ReturnType<typeof clearExpenseAutomationMissingReceiptsView> | ReturnType<typeof clearExpenseAutomationReconciliationView> | ReturnType<typeof clearExpenseAutomationTransactionsView> | ReturnType<typeof clearExpenseAutomationView> | ReturnType<typeof clearExpressPayView> | ReturnType<typeof clearFileViewList> | ReturnType<typeof clearFinanceStatement> | ReturnType<typeof clearForecastList> | ReturnType<typeof clearGlobalMerchantAutoCompleteResults> | ReturnType<typeof clearGlobalMerchantView> | ReturnType<typeof clearInsightsCard> | ReturnType<typeof clearInternationalWire> | ReturnType<typeof clearInternationalVerificationView> | ReturnType<typeof clearIssueChargeCard> | ReturnType<typeof clearMerchantList> | ReturnType<typeof clearNetBurnOrIncome> | ReturnType<typeof clearNetBurnOrIncomeClassesView> | ReturnType<typeof clearNetBurnOrIncomeStoryCard> | ReturnType<typeof clearNotificationView> | ReturnType<typeof clearOnboardingCockpitView> | ReturnType<typeof clearOnboardingCustomerView> | ReturnType<typeof clearOpEx> | ReturnType<typeof clearOpExByVendor> | ReturnType<typeof clearOpExClassesView> | ReturnType<typeof clearOwnerList> | ReturnType<typeof clearPaymentAccountList> | ReturnType<typeof clearPeople> | ReturnType<typeof clearPerformanceReportAndTimeSeries> | ReturnType<typeof clearPreviousBills> | ReturnType<typeof clearProfitAndLoss> | ReturnType<typeof clearProfitAndLossClassesView> | ReturnType<typeof clearRecommendation> | ReturnType<typeof clearReferrals> | ReturnType<typeof clearReimbursementCard> | ReturnType<typeof clearReimbursementConfig> | ReturnType<typeof clearRemiBulkActionView> | ReturnType<typeof clearRemiDetailView> | ReturnType<typeof clearRemiList> | ReturnType<typeof clearRemiSetupApproverView> | ReturnType<typeof clearRemiSetupView> | ReturnType<typeof clearReportUIOption> | ReturnType<typeof clearRevenue> | ReturnType<typeof clearRevenueClassesView> | ReturnType<typeof clearReviewCompany> | ReturnType<typeof clearScheduleDetailView> | ReturnType<typeof clearScheduleAccruedDetailView> | ReturnType<typeof clearScheduleList> | ReturnType<typeof clearSettingsView> | ReturnType<typeof clearSetupView> | ReturnType<typeof clearPlaidAccountView> | ReturnType<typeof clearSubscriptionView> | ReturnType<typeof clearTagView> | ReturnType<typeof clearTaskDetail> | ReturnType<typeof clearTaskGroupTemplatesView> | ReturnType<typeof clearTaskGroupView> | ReturnType<typeof clearTaskList> | ReturnType<typeof clearTasksCard> | ReturnType<typeof clearTopEx> | ReturnType<typeof clearTransactionDetail> | ReturnType<typeof clearTransactionList> | ReturnType<typeof clearTransferDetail> | ReturnType<typeof clearTrendData> | ReturnType<typeof clearTrendWithTransactions> | ReturnType<typeof clearTwoFactorAuthentication> | ReturnType<typeof clearUserFinancialAccount> | ReturnType<typeof clearUserListView> | ReturnType<typeof clearUserRoleConfigView> | ReturnType<typeof clearVendorGlobalReviewView> | ReturnType<typeof clearVendorReviewView> | ReturnType<typeof clearVendorTypeList> | ReturnType<typeof clearVendor1099TypeList> | ReturnType<typeof clearVendorView> | ReturnType<typeof clearVendorsFiling1099List> | ReturnType<typeof clearVendorsList> | ReturnType<typeof clearVendorsTabVendorView> | ReturnType<typeof clearWiseRedirectStatus> | ReturnType<typeof clearZeniAccStatementList> | ReturnType<typeof clearZeniAccountList> | ReturnType<typeof clearZeniAccountSetupView> | ReturnType<typeof clearZeniAccountsConfig> | ReturnType<typeof clearZeniAccountsPromoCard>;
193
+ type clearActionTypeForViews = ReturnType<typeof clearAccountList> | ReturnType<typeof clearAccountMappingView> | ReturnType<typeof clearActivityHistory> | ReturnType<typeof clearActivityRealTimeApproval> | ReturnType<typeof clearAddressView> | ReturnType<typeof clearAIControllerView> | ReturnType<typeof clearAllClasses> | ReturnType<typeof clearAllMonthEndCloseChecksView> | ReturnType<typeof clearApAging> | ReturnType<typeof clearApAgingDetail> | ReturnType<typeof clearArAging> | ReturnType<typeof clearArAgingDetail> | ReturnType<typeof clearAuthenticationView> | ReturnType<typeof clearBalanceSheet> | ReturnType<typeof clearBankAccountView> | ReturnType<typeof clearBillDetailView> | ReturnType<typeof clearBillList> | ReturnType<typeof clearBillPayBulkActionView> | ReturnType<typeof clearBillPayCard> | ReturnType<typeof clearBillPayConfig> | ReturnType<typeof clearBillPayReview> | ReturnType<typeof clearBillPaySetupApproverView> | ReturnType<typeof clearBillPaySetupView> | ReturnType<typeof clearCardBalance> | ReturnType<typeof clearCardPaymentView> | ReturnType<typeof clearCardUserOnboarding> | ReturnType<typeof clearCashbackDetail> | ReturnType<typeof clearCashBalance> | ReturnType<typeof clearCashFlow> | ReturnType<typeof clearCashInCashOut> | ReturnType<typeof clearCashPosition> | ReturnType<typeof clearChargeCardConfig> | ReturnType<typeof clearChargeCardDetail> | ReturnType<typeof clearChargeCardList> | ReturnType<typeof clearChargeCardSetupView> | ReturnType<typeof clearChargeCardStatementList> | ReturnType<typeof clearCheckDeposit> | ReturnType<typeof clearCompanyConfigView> | ReturnType<typeof clearCompanyHealthMetric> | ReturnType<typeof clearCompanyHealthMetricView> | ReturnType<typeof clearCompanyMonthEndReportView> | ReturnType<typeof clearCompanyTaskManagerView> | ReturnType<typeof clearCompanyView> | ReturnType<typeof clearDashboard> | ReturnType<typeof clearDashboardLayout> | ReturnType<typeof clearDepositAccountDetail> | ReturnType<typeof clearDepositAccountList> | ReturnType<typeof clearDepositAccountTransactionList> | ReturnType<typeof clearEditBillViewDetail> | ReturnType<typeof clearEditRemiViewDetail> | ReturnType<typeof clearEntityAutoCompleteResults> | ReturnType<typeof clearExpenseAutomationFluxAnalysisView> | ReturnType<typeof clearExpenseAutomationJESchedulesView> | ReturnType<typeof clearExpenseAutomationMissingReceiptsView> | ReturnType<typeof clearExpenseAutomationReconciliationView> | ReturnType<typeof clearExpenseAutomationTransactionsView> | ReturnType<typeof clearExpenseAutomationView> | ReturnType<typeof clearExpressPayView> | ReturnType<typeof clearFileViewList> | ReturnType<typeof clearFinanceStatement> | ReturnType<typeof clearForecastList> | ReturnType<typeof clearGlobalMerchantAutoCompleteResults> | ReturnType<typeof clearGlobalMerchantView> | ReturnType<typeof clearInsightsCard> | ReturnType<typeof clearInternationalWire> | ReturnType<typeof clearInternationalVerificationView> | ReturnType<typeof clearIssueChargeCard> | ReturnType<typeof clearMerchantList> | ReturnType<typeof clearNetBurnOrIncome> | ReturnType<typeof clearNetBurnOrIncomeClassesView> | ReturnType<typeof clearNetBurnOrIncomeStoryCard> | ReturnType<typeof clearNotificationView> | ReturnType<typeof clearOnboardingCockpitView> | ReturnType<typeof clearOnboardingCustomerView> | ReturnType<typeof clearOpEx> | ReturnType<typeof clearOpExByVendor> | ReturnType<typeof clearOpExClassesView> | ReturnType<typeof clearOwnerList> | ReturnType<typeof clearPaymentAccountList> | ReturnType<typeof clearPeople> | ReturnType<typeof clearPerformanceReportAndTimeSeries> | ReturnType<typeof clearPreviousBills> | ReturnType<typeof clearProfitAndLoss> | ReturnType<typeof clearProfitAndLossClassesView> | ReturnType<typeof clearRecommendation> | ReturnType<typeof clearReferrals> | ReturnType<typeof clearReimbursementCard> | ReturnType<typeof clearReimbursementConfig> | ReturnType<typeof clearRemiBulkActionView> | ReturnType<typeof clearRemiDetailView> | ReturnType<typeof clearRemiList> | ReturnType<typeof clearRemiSetupApproverView> | ReturnType<typeof clearRemiSetupView> | ReturnType<typeof clearReportUIOption> | ReturnType<typeof clearRevenue> | ReturnType<typeof clearRevenueClassesView> | ReturnType<typeof clearReviewCompany> | ReturnType<typeof clearScheduleDetailView> | ReturnType<typeof clearScheduleAccruedDetailView> | ReturnType<typeof clearScheduleList> | ReturnType<typeof clearSettingsView> | ReturnType<typeof clearSetupView> | ReturnType<typeof clearPlaidAccountView> | ReturnType<typeof clearSubscriptionView> | ReturnType<typeof clearTagView> | ReturnType<typeof clearTaskDetail> | ReturnType<typeof clearTaskGroupTemplatesView> | ReturnType<typeof clearTaskGroupView> | ReturnType<typeof clearTaskList> | ReturnType<typeof clearTasksCard> | ReturnType<typeof clearTopEx> | ReturnType<typeof clearTransactionDetail> | ReturnType<typeof clearTransactionList> | ReturnType<typeof clearTransferDetail> | ReturnType<typeof clearTrendData> | ReturnType<typeof clearTrendWithTransactions> | ReturnType<typeof clearTwoFactorAuthentication> | ReturnType<typeof clearUserFinancialAccount> | ReturnType<typeof clearUserListView> | ReturnType<typeof clearUserRoleConfigView> | ReturnType<typeof clearVendorGlobalReviewView> | ReturnType<typeof clearVendorReviewView> | ReturnType<typeof clearVendorTypeList> | ReturnType<typeof clearVendor1099TypeList> | ReturnType<typeof clearVendorView> | ReturnType<typeof clearVendorsFiling1099List> | ReturnType<typeof clearVendorsList> | ReturnType<typeof clearVendorsTabVendorView> | ReturnType<typeof clearWiseRedirectStatus> | ReturnType<typeof clearZeniAccStatementList> | ReturnType<typeof clearZeniAccountList> | ReturnType<typeof clearZeniAccountSetupView> | ReturnType<typeof clearZeniAccountsConfig> | ReturnType<typeof clearZeniAccountsPromoCard>;
194
194
  type clearActionTypeForEntities = ReturnType<typeof clearAllAccountGroups> | ReturnType<typeof clearAllAccountRecon> | ReturnType<typeof clearAllAccountingSummary> | ReturnType<typeof clearAllAccounts> | ReturnType<typeof clearAllAddresses> | ReturnType<typeof clearAllApprovalRules> | ReturnType<typeof clearAllBankAccounts> | ReturnType<typeof clearAllBillTransactions> | ReturnType<typeof clearAllCardPayments> | ReturnType<typeof clearAllChargeCardTransactions> | ReturnType<typeof clearAllChargeCards> | ReturnType<typeof clearAllCompanies> | ReturnType<typeof clearAllConnectedAccounts> | ReturnType<typeof clearAllCurrencies> | ReturnType<typeof clearAllCustomerIncomeTrend> | ReturnType<typeof clearAllCustomers> | ReturnType<typeof clearAllDepositAccounts> | ReturnType<typeof clearAllEntities> | ReturnType<typeof clearAllEntityApprovalStatus> | ReturnType<typeof clearAllFiles> | ReturnType<typeof clearAllForecasts> | ReturnType<typeof clearAllGlobalMerchants> | ReturnType<typeof clearAllInsights> | ReturnType<typeof clearAllAccruedJESchedules> | ReturnType<typeof clearAllJEScheduleTransactions> | ReturnType<typeof clearAllMerchants> | ReturnType<typeof clearAllMonthEndCloseChecks> | ReturnType<typeof clearAllNotifications> | ReturnType<typeof clearAllOnboardingCustomersInfo> | ReturnType<typeof clearAllPaymentAccounts> | ReturnType<typeof clearAllPaymentInstruments> | ReturnType<typeof clearAllRecurringBills> | ReturnType<typeof clearAllReimbursements> | ReturnType<typeof clearAllSectionsAccountsView> | ReturnType<typeof clearAllSectionsClassesViewV2> | ReturnType<typeof clearAllSubscriptionAddOns> | ReturnType<typeof clearAllSubscriptionCoupons> | ReturnType<typeof clearAllSubscriptionPlans> | ReturnType<typeof clearAllSubscriptionSummary> | ReturnType<typeof clearAllSubscriptions> | ReturnType<typeof clearAllTags> | ReturnType<typeof clearAllTaskGroups> | ReturnType<typeof clearAllTaskGroupTemplates> | ReturnType<typeof clearAllTaskSummary> | ReturnType<typeof clearAllTasks> | ReturnType<typeof clearAllToastNotifications> | ReturnType<typeof clearAllTransactions> | ReturnType<typeof clearAllUserRoles> | ReturnType<typeof clearAllUsers> | ReturnType<typeof clearAllVendorExpenseTrends> | ReturnType<typeof clearAllVendors> | ReturnType<typeof clearClassList> | ReturnType<typeof clearContacts> | ReturnType<typeof clearCountryList> | ReturnType<typeof clearDepositAccountTransaction> | ReturnType<typeof clearSnackbar> | ReturnType<typeof clearAIController>;
195
195
  export type ActionType = clearActionTypeForViews | clearActionTypeForEntities | ReturnType<typeof clearAll>;
196
196
  export declare const clearAllEpic: (actions$: ActionsObservable<ActionType>) => import("rxjs").Observable<ActionType>;
@@ -248,7 +248,7 @@ const clearAllEpic = (actions$) => actions$.pipe((0, operators_1.filter)(tenantR
248
248
  (0, depositAccountTransactionListReducer_1.clearDepositAccountTransactionList)(),
249
249
  (0, editBillViewReducer_1.clearEditBillViewDetail)(),
250
250
  (0, editRemiViewReducer_1.clearEditRemiViewDetail)(),
251
- (0, entityAutoCompleteReducer_1.clearAllEntityAutoCompleteResults)(),
251
+ (0, entityAutoCompleteReducer_1.clearEntityAutoCompleteResults)(),
252
252
  (0, fluxAnalysisViewReducer_1.clearExpenseAutomationFluxAnalysisView)(),
253
253
  (0, jeSchedulesViewReducer_1.clearExpenseAutomationJESchedulesView)(),
254
254
  (0, missingReceiptsViewReducer_1.clearExpenseAutomationMissingReceiptsView)(),