@zeniai/client-epic-state 5.0.81-betaAD7 → 5.0.81-betaAD9

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.
@@ -498,18 +498,19 @@ const aiCfo = (0, toolkit_1.createSlice)({
498
498
  });
499
499
  const mergeChatSessionFromPayload = (prev, payload) => {
500
500
  const next = { ...prev };
501
- next.chatSessionSummary =
502
- payload.chat_session_summary !== undefined
503
- ? (payload.chat_session_summary ?? undefined)
504
- : prev.chatSessionSummary;
501
+ // Only apply a non-null summary string. `null` is omitted on pin-only PUT responses
502
+ // and must not clear an existing title in the drawer.
503
+ if (payload.chat_session_summary != null) {
504
+ next.chatSessionSummary = payload.chat_session_summary;
505
+ }
505
506
  if (payload.is_pinned !== undefined) {
506
507
  next.isPinned = payload.is_pinned;
507
- }
508
- if (payload.pinned_at != null) {
509
- next.pinnedAt = (0, zeniDayJS_1.date)(payload.pinned_at);
510
- }
511
- else if (payload.is_pinned === false) {
512
- next.pinnedAt = undefined;
508
+ if (payload.is_pinned === false) {
509
+ next.pinnedAt = undefined;
510
+ }
511
+ else if (payload.pinned_at != null) {
512
+ next.pinnedAt = (0, zeniDayJS_1.date)(payload.pinned_at);
513
+ }
513
514
  }
514
515
  return next;
515
516
  };
@@ -493,18 +493,19 @@ const aiCfo = createSlice({
493
493
  });
494
494
  const mergeChatSessionFromPayload = (prev, payload) => {
495
495
  const next = { ...prev };
496
- next.chatSessionSummary =
497
- payload.chat_session_summary !== undefined
498
- ? (payload.chat_session_summary ?? undefined)
499
- : prev.chatSessionSummary;
496
+ // Only apply a non-null summary string. `null` is omitted on pin-only PUT responses
497
+ // and must not clear an existing title in the drawer.
498
+ if (payload.chat_session_summary != null) {
499
+ next.chatSessionSummary = payload.chat_session_summary;
500
+ }
500
501
  if (payload.is_pinned !== undefined) {
501
502
  next.isPinned = payload.is_pinned;
502
- }
503
- if (payload.pinned_at != null) {
504
- next.pinnedAt = zeniDate(payload.pinned_at);
505
- }
506
- else if (payload.is_pinned === false) {
507
- next.pinnedAt = undefined;
503
+ if (payload.is_pinned === false) {
504
+ next.pinnedAt = undefined;
505
+ }
506
+ else if (payload.pinned_at != null) {
507
+ next.pinnedAt = zeniDate(payload.pinned_at);
508
+ }
508
509
  }
509
510
  return next;
510
511
  };
@@ -1,13 +1,18 @@
1
1
  import { from, of } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
2
+ import { catchError, exhaustMap, filter, groupBy, mergeMap, } from 'rxjs/operators';
3
3
  import { mergeChatSessionFromPutResponse } from '../../../entity/aiCfo/aiCfoReducer';
4
4
  import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
5
5
  import { createZeniAPIStatus, isSuccessResponse, } from '../../../responsePayload';
6
6
  import { updateChatSessionPin, updateChatSessionPinFailure, updateChatSessionPinSuccess, } from '../aiCfoViewReducer';
7
- export const updateChatSessionPinEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(updateChatSessionPin.match), mergeMap((action) => {
7
+ export const updateChatSessionPinEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(updateChatSessionPin.match), groupBy((action) => action.payload.chatSessionId), mergeMap((sessionActions$) => sessionActions$.pipe(
8
+ // `updateChatSessionPin` sets fetchState to In-Progress before epics run, so
9
+ // checking In-Progress here would block every legitimate request (see
10
+ // approveOAuthConsentEpic). exhaustMap drops duplicate pin/unpin for the
11
+ // same session while a PUT is already in flight.
12
+ exhaustMap((action) => {
8
13
  const { chatSessionId, isPinned } = action.payload;
9
14
  return zeniAPI
10
- .putAndGetJSON(`https://dev.api.zeni.ai/version/chat/05-20-d37fcc2/1.0/sessions/${chatSessionId}`, { is_pinned: isPinned })
15
+ .putAndGetJSON(`${zeniAPI.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/sessions/${chatSessionId}`, { is_pinned: isPinned })
11
16
  .pipe(mergeMap((response) => {
12
17
  if (isSuccessResponse(response) && response.data != null) {
13
18
  return from([
@@ -25,7 +30,7 @@ export const updateChatSessionPinEpic = (actions$, _state$, zeniAPI) => actions$
25
30
  variables: [
26
31
  {
27
32
  variableName: '_api-error_',
28
- variableValue: response.status?.message ?? String(response.status),
33
+ variableValue: response.status?.message ?? '',
29
34
  },
30
35
  ],
31
36
  }));
@@ -44,4 +49,4 @@ export const updateChatSessionPinEpic = (actions$, _state$, zeniAPI) => actions$
44
49
  },
45
50
  ],
46
51
  }))));
47
- }));
52
+ }))));
@@ -7,10 +7,15 @@ const aiCfoReducer_1 = require("../../../entity/aiCfo/aiCfoReducer");
7
7
  const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
8
8
  const responsePayload_1 = require("../../../responsePayload");
9
9
  const aiCfoViewReducer_1 = require("../aiCfoViewReducer");
10
- const updateChatSessionPinEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(aiCfoViewReducer_1.updateChatSessionPin.match), (0, operators_1.mergeMap)((action) => {
10
+ const updateChatSessionPinEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(aiCfoViewReducer_1.updateChatSessionPin.match), (0, operators_1.groupBy)((action) => action.payload.chatSessionId), (0, operators_1.mergeMap)((sessionActions$) => sessionActions$.pipe(
11
+ // `updateChatSessionPin` sets fetchState to In-Progress before epics run, so
12
+ // checking In-Progress here would block every legitimate request (see
13
+ // approveOAuthConsentEpic). exhaustMap drops duplicate pin/unpin for the
14
+ // same session while a PUT is already in flight.
15
+ (0, operators_1.exhaustMap)((action) => {
11
16
  const { chatSessionId, isPinned } = action.payload;
12
17
  return zeniAPI
13
- .putAndGetJSON(`https://dev.api.zeni.ai/version/chat/05-20-d37fcc2/1.0/sessions/${chatSessionId}`, { is_pinned: isPinned })
18
+ .putAndGetJSON(`${zeniAPI.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/sessions/${chatSessionId}`, { is_pinned: isPinned })
14
19
  .pipe((0, operators_1.mergeMap)((response) => {
15
20
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
16
21
  return (0, rxjs_1.from)([
@@ -28,7 +33,7 @@ const updateChatSessionPinEpic = (actions$, _state$, zeniAPI) => actions$.pipe((
28
33
  variables: [
29
34
  {
30
35
  variableName: '_api-error_',
31
- variableValue: response.status?.message ?? String(response.status),
36
+ variableValue: response.status?.message ?? '',
32
37
  },
33
38
  ],
34
39
  }));
@@ -47,5 +52,5 @@ const updateChatSessionPinEpic = (actions$, _state$, zeniAPI) => actions$.pipe((
47
52
  },
48
53
  ],
49
54
  }))));
50
- }));
55
+ }))));
51
56
  exports.updateChatSessionPinEpic = updateChatSessionPinEpic;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.81-betaAD7",
3
+ "version": "5.0.81-betaAD9",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",