@iblai/data-layer 1.30.3 → 1.31.0
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.d.ts +24 -2
- package/dist/index.esm.js +25 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/features/chat/api-slice.d.ts +22 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39950,6 +39950,17 @@ const buildRecentMessagesUrl = (args, pageParam) => {
|
|
|
39950
39950
|
appendChatFilterParams(params, args);
|
|
39951
39951
|
return `/api/ai-mentor/orgs/${args.org}/users/${args.userId}/recent-messages/?${params.toString()}`;
|
|
39952
39952
|
};
|
|
39953
|
+
/**
|
|
39954
|
+
* The session id of the first recent-messages row, or `null` when there is
|
|
39955
|
+
* none. Assumes the endpoint lists newest first (not yet confirmed by the
|
|
39956
|
+
* backend) — this is the one place to change if that, or the source, changes.
|
|
39957
|
+
*/
|
|
39958
|
+
const latestSessionIdFrom = (body) => {
|
|
39959
|
+
var _a;
|
|
39960
|
+
const rows = Array.isArray(body) ? body : body === null || body === void 0 ? void 0 : body.results;
|
|
39961
|
+
const sessionId = (_a = rows === null || rows === void 0 ? void 0 : rows[0]) === null || _a === void 0 ? void 0 : _a.session_id;
|
|
39962
|
+
return typeof sessionId === 'string' && sessionId ? sessionId : null;
|
|
39963
|
+
};
|
|
39953
39964
|
/**
|
|
39954
39965
|
* Build the user-wide pin-message list URL. Never carries `session_id` (the
|
|
39955
39966
|
* endpoint does not accept it); `mentor`/`search` are appended only when non-empty.
|
|
@@ -40033,6 +40044,19 @@ const chatApiSlice = react.createApi({
|
|
|
40033
40044
|
}),
|
|
40034
40045
|
}),
|
|
40035
40046
|
});
|
|
40047
|
+
/**
|
|
40048
|
+
* The user's latest session with an agent, read from page 0 of the same
|
|
40049
|
+
* `getRecentMessages` entry the chat-history sidebar subscribes to (`search: ''`
|
|
40050
|
+
* is its idle search box), so an agent open costs one request, not two.
|
|
40051
|
+
* `forceRefetch` in seconds is the time since `openedAt`: an entry fulfilled
|
|
40052
|
+
* before this open is refetched (another device may have started a chat since),
|
|
40053
|
+
* one fulfilled after it is reused, and one in flight is joined — RTK never
|
|
40054
|
+
* starts a second request for a pending entry.
|
|
40055
|
+
*/
|
|
40056
|
+
const fetchLatestMentorSessionId = ({ org, userId, mentor }, openedAt) => async (dispatch) => {
|
|
40057
|
+
const data = await dispatch(chatApiSlice.endpoints.getRecentMessages.initiate({ org, userId, mentor, search: '' }, { forceRefetch: Math.max((Date.now() - openedAt) / 1000, 0.001), subscribe: false })).unwrap();
|
|
40058
|
+
return latestSessionIdFrom(data.pages[0]);
|
|
40059
|
+
};
|
|
40036
40060
|
const { useLazyGetPinnedMessagesQuery, useUnPinMessageMutation, useDeleteMessageMutation, useGetPinnedMessagesQuery, useAddPinnedMessageMutation, useGetVectorDocumentsQuery, useLazyGetVectorDocumentsQuery, useGetRecentMessageQuery, useLazyGetRecentMessageQuery, useGetRecentMessagesInfiniteQuery, useUpdateMessageFeedbackMutation, useAudioToTextMutation, } = chatApiSlice;
|
|
40037
40061
|
|
|
40038
40062
|
const chatCustomApiSlice = react.createApi({
|
|
@@ -50051,6 +50075,7 @@ exports.evaluationsApiSlice = evaluationsApiSlice;
|
|
|
50051
50075
|
exports.extractBoundMentorIds = extractBoundMentorIds;
|
|
50052
50076
|
exports.fakeBaseQueryWithLogging = fakeBaseQueryWithLogging;
|
|
50053
50077
|
exports.featureTags = featureTags;
|
|
50078
|
+
exports.fetchLatestMentorSessionId = fetchLatestMentorSessionId;
|
|
50054
50079
|
exports.fetchLearnerCompletion = fetchLearnerCompletion;
|
|
50055
50080
|
exports.fetchUserLlmUsage = fetchUserLlmUsage;
|
|
50056
50081
|
exports.filterCourseUserRoles = filterCourseUserRoles;
|
|
@@ -50080,6 +50105,7 @@ exports.isSpendCapExceededErrorBody = isSpendCapExceededErrorBody;
|
|
|
50080
50105
|
exports.isUserLlmUsageEmpty = isUserLlmUsageEmpty;
|
|
50081
50106
|
exports.isValidHostPort = isValidHostPort;
|
|
50082
50107
|
exports.isVirtualMachineEgressNetworked = isVirtualMachineEgressNetworked;
|
|
50108
|
+
exports.latestSessionIdFrom = latestSessionIdFrom;
|
|
50083
50109
|
exports.llmsApiSlice = llmsApiSlice;
|
|
50084
50110
|
exports.mcpApiSlice = mcpApiSlice;
|
|
50085
50111
|
exports.memoryApiSlice = memoryApiSlice;
|