@iblai/data-layer 1.9.1 → 1.9.3

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/dist/index.js CHANGED
@@ -39483,6 +39483,43 @@ const chatHistoryApiSlice = react.createApi({
39483
39483
  });
39484
39484
  const { useGetChatHistoryFilterQuery, useLazyGetChatHistoryFilterQuery, useGetChatHistoryQuery, useLazyGetChatHistoryQuery, useExportChatHistoryMutation, useGetChatHistoryExportStatusQuery, useLazyGetChatHistoryExportStatusQuery, } = chatHistoryApiSlice;
39485
39485
 
39486
+ const CHAT_CUSTOM_REDUCER_PATH = 'chatCustomApiSlice';
39487
+ /**
39488
+ * Recent-messages sidebar list pagination. The endpoint uses DRF
39489
+ * LimitOffsetPagination, so the page param is a row offset (not a page number).
39490
+ */
39491
+ const RECENT_MESSAGES_PAGE_SIZE = 10;
39492
+ const RECENT_MESSAGES_LIMIT_PARAM = 'limit';
39493
+ const RECENT_MESSAGES_OFFSET_PARAM = 'offset';
39494
+ const CHAT_CUSTOM_ENDPOINTS = {
39495
+ GET_CHAT_MESSAGE_TTS: {
39496
+ path: (org, user_id, chat_message_id) => `/api/ai-mentor/orgs/${org}/users/${user_id}/chat-messages/${chat_message_id}/tts`,
39497
+ service: exports.SERVICES.DM,
39498
+ },
39499
+ };
39500
+
39501
+ /**
39502
+ * Derive the next row offset from a DRF LimitOffset response. Returns `undefined`
39503
+ * when there is no further page (missing/null `next`, or a non-paginated shape
39504
+ * such as a bare array), so the query degrades to a single page.
39505
+ */
39506
+ const getNextRecentMessagesPageParam = (lastPage, lastPageParam) => lastPage && !Array.isArray(lastPage) && lastPage.next
39507
+ ? lastPageParam + RECENT_MESSAGES_PAGE_SIZE
39508
+ : undefined;
39509
+ /**
39510
+ * Build the recent-messages URL for a given row offset. The endpoint uses DRF
39511
+ * LimitOffsetPagination (`limit`/`offset`), not page numbers.
39512
+ */
39513
+ const buildRecentMessagesUrl = (args, pageParam) => {
39514
+ const params = new URLSearchParams();
39515
+ params.append(RECENT_MESSAGES_LIMIT_PARAM, String(RECENT_MESSAGES_PAGE_SIZE));
39516
+ params.append(RECENT_MESSAGES_OFFSET_PARAM, String(pageParam));
39517
+ if (args.mentor)
39518
+ params.append('mentor', args.mentor);
39519
+ if (args.search && args.search.trim() !== '')
39520
+ params.append('search', args.search.trim());
39521
+ return `/api/ai-mentor/orgs/${args.org}/users/${args.userId}/recent-messages/?${params.toString()}`;
39522
+ };
39486
39523
  const chatApiSlice = react.createApi({
39487
39524
  reducerPath: 'chatApiSlice',
39488
39525
  baseQuery: iblFakeBaseQuery,
@@ -39517,6 +39554,21 @@ const chatApiSlice = react.createApi({
39517
39554
  getRecentMessage: builder.query({
39518
39555
  ...buildEndpointFromDmService(AiMentorService.aiMentorOrgsUsersRecentMessagesRetrieve),
39519
39556
  }),
39557
+ getRecentMessages: builder.infiniteQuery({
39558
+ infiniteQueryOptions: {
39559
+ initialPageParam: 0,
39560
+ getNextPageParam: (lastPage, _allPages, lastPageParam) => getNextRecentMessagesPageParam(lastPage, lastPageParam),
39561
+ },
39562
+ queryFn: async ({ queryArg, pageParam }, api, extraOptions) => {
39563
+ const url = buildRecentMessagesUrl(queryArg, pageParam);
39564
+ return iblFetchBaseQuery({
39565
+ url,
39566
+ method: 'GET',
39567
+ service: exports.SERVICES.DM,
39568
+ }, api, extraOptions);
39569
+ },
39570
+ providesTags: ['recentMessages'],
39571
+ }),
39520
39572
  deleteMessage: builder.mutation({
39521
39573
  ...buildEndpointFromDmService(AiMentorService.aiMentorOrgsUsersSessionsDestroy),
39522
39574
  }),
@@ -39531,15 +39583,7 @@ const chatApiSlice = react.createApi({
39531
39583
  }),
39532
39584
  }),
39533
39585
  });
39534
- const { useLazyGetPinnedMessagesQuery, useUnPinMessageMutation, useDeleteMessageMutation, useGetPinnedMessagesQuery, useAddPinnedMessageMutation, useGetVectorDocumentsQuery, useLazyGetVectorDocumentsQuery, useGetRecentMessageQuery, useLazyGetRecentMessageQuery, useUpdateMessageFeedbackMutation, useAudioToTextMutation, } = chatApiSlice;
39535
-
39536
- const CHAT_CUSTOM_REDUCER_PATH = 'chatCustomApiSlice';
39537
- const CHAT_CUSTOM_ENDPOINTS = {
39538
- GET_CHAT_MESSAGE_TTS: {
39539
- path: (org, user_id, chat_message_id) => `/api/ai-mentor/orgs/${org}/users/${user_id}/chat-messages/${chat_message_id}/tts`,
39540
- service: exports.SERVICES.DM,
39541
- },
39542
- };
39586
+ const { useLazyGetPinnedMessagesQuery, useUnPinMessageMutation, useDeleteMessageMutation, useGetPinnedMessagesQuery, useAddPinnedMessageMutation, useGetVectorDocumentsQuery, useLazyGetVectorDocumentsQuery, useGetRecentMessageQuery, useLazyGetRecentMessageQuery, useGetRecentMessagesInfiniteQuery, useUpdateMessageFeedbackMutation, useAudioToTextMutation, } = chatApiSlice;
39543
39587
 
39544
39588
  const chatCustomApiSlice = react.createApi({
39545
39589
  reducerPath: CHAT_CUSTOM_REDUCER_PATH,
@@ -43440,7 +43484,7 @@ const { useGetModerationLogsQuery, useLazyGetModerationLogsQuery, useDeleteModer
43440
43484
  * `useGetMentorPublicSettingsQuery`) — this file just adds the typed
43441
43485
  * surface for the new fields.
43442
43486
  */
43443
- const PRIVACY_ACTIONS = ['redact', 'mask', 'block'];
43487
+ const PRIVACY_ACTIONS = ['allow', 'redact', 'mask', 'block'];
43444
43488
  const PRIVACY_ENTITY_TYPES = [
43445
43489
  'PERSON',
43446
43490
  'EMAIL_ADDRESS',
@@ -45981,6 +46025,7 @@ exports.auditLogsApiSlice = auditLogsApiSlice;
45981
46025
  exports.authApiSlice = authApiSlice;
45982
46026
  exports.billingApiSlice = billingApiSlice;
45983
46027
  exports.billingCustomSlice = billingCustomSlice;
46028
+ exports.buildRecentMessagesUrl = buildRecentMessagesUrl;
45984
46029
  exports.buildSessionRetrieveUrl = buildSessionRetrieveUrl;
45985
46030
  exports.buildSharedSessionRetrieveUrl = buildSharedSessionRetrieveUrl;
45986
46031
  exports.callConfigurationsApiReducer = callConfigurationsApiReducer;
@@ -46008,6 +46053,7 @@ exports.edxProctoringApiSlice = edxProctoringApiSlice;
46008
46053
  exports.edxSsoApiSlice = edxSsoApiSlice;
46009
46054
  exports.fakeBaseQueryWithLogging = fakeBaseQueryWithLogging;
46010
46055
  exports.featureTags = featureTags;
46056
+ exports.getNextRecentMessagesPageParam = getNextRecentMessagesPageParam;
46011
46057
  exports.iblFakeBaseQuery = iblFakeBaseQuery;
46012
46058
  exports.initializeDataLayer = initializeDataLayer;
46013
46059
  exports.isPoliciesResponse = isPoliciesResponse;
@@ -46324,6 +46370,7 @@ exports.useGetRbacRoleDetailsQuery = useGetRbacRoleDetailsQuery;
46324
46370
  exports.useGetRbacRolesQuery = useGetRbacRolesQuery;
46325
46371
  exports.useGetRbacTeamsAccessListQuery = useGetRbacTeamsAccessListQuery;
46326
46372
  exports.useGetRecentMessageQuery = useGetRecentMessageQuery;
46373
+ exports.useGetRecentMessagesInfiniteQuery = useGetRecentMessagesInfiniteQuery;
46327
46374
  exports.useGetRecentlyAccessedMentorsQuery = useGetRecentlyAccessedMentorsQuery;
46328
46375
  exports.useGetRecommendationsAiSearchQuery = useGetRecommendationsAiSearchQuery;
46329
46376
  exports.useGetRecommendedPromptsListQuery = useGetRecommendedPromptsListQuery;