@iblai/data-layer 1.26.0 → 1.28.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 +95 -129
- package/dist/index.esm.js +72 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +72 -6
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/features/chat/api-slice.d.ts +72 -127
- package/dist/src/features/chat-privacy/api-slice.d.ts +21 -0
- package/dist/src/features/return-base-query-errors.d.ts +25 -0
- package/dist/tests/features/chat-privacy/api-slice.test.d.ts +1 -0
- package/dist/tests/features/return-base-query-errors.test.d.ts +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39918,6 +39918,12 @@ const CHAT_CUSTOM_ENDPOINTS = {
|
|
|
39918
39918
|
const getNextRecentMessagesPageParam = (lastPage, lastPageParam) => lastPage && !Array.isArray(lastPage) && lastPage.next
|
|
39919
39919
|
? lastPageParam + RECENT_MESSAGES_PAGE_SIZE
|
|
39920
39920
|
: undefined;
|
|
39921
|
+
const appendChatFilterParams = (params, { mentor, search }) => {
|
|
39922
|
+
if (mentor)
|
|
39923
|
+
params.append('mentor', mentor);
|
|
39924
|
+
if (search && search.trim() !== '')
|
|
39925
|
+
params.append('search', search.trim());
|
|
39926
|
+
};
|
|
39921
39927
|
/**
|
|
39922
39928
|
* Build the recent-messages URL for a given row offset. The endpoint uses DRF
|
|
39923
39929
|
* LimitOffsetPagination (`limit`/`offset`), not page numbers.
|
|
@@ -39926,19 +39932,36 @@ const buildRecentMessagesUrl = (args, pageParam) => {
|
|
|
39926
39932
|
const params = new URLSearchParams();
|
|
39927
39933
|
params.append(RECENT_MESSAGES_LIMIT_PARAM, String(RECENT_MESSAGES_PAGE_SIZE));
|
|
39928
39934
|
params.append(RECENT_MESSAGES_OFFSET_PARAM, String(pageParam));
|
|
39929
|
-
|
|
39930
|
-
params.append('mentor', args.mentor);
|
|
39931
|
-
if (args.search && args.search.trim() !== '')
|
|
39932
|
-
params.append('search', args.search.trim());
|
|
39935
|
+
appendChatFilterParams(params, args);
|
|
39933
39936
|
return `/api/ai-mentor/orgs/${args.org}/users/${args.userId}/recent-messages/?${params.toString()}`;
|
|
39934
39937
|
};
|
|
39938
|
+
/**
|
|
39939
|
+
* Build the user-wide pin-message list URL. Never carries `session_id` (the
|
|
39940
|
+
* endpoint does not accept it); `mentor`/`search` are appended only when non-empty.
|
|
39941
|
+
*/
|
|
39942
|
+
const buildPinnedMessagesUrl = (args) => {
|
|
39943
|
+
const params = new URLSearchParams();
|
|
39944
|
+
appendChatFilterParams(params, args);
|
|
39945
|
+
const query = params.toString();
|
|
39946
|
+
return `/api/ai-mentor/orgs/${args.org}/users/${args.userId}/pin-message/${query ? `?${query}` : ''}`;
|
|
39947
|
+
};
|
|
39935
39948
|
const chatApiSlice = react.createApi({
|
|
39936
39949
|
reducerPath: 'chatApiSlice',
|
|
39937
39950
|
baseQuery: iblFakeBaseQuery,
|
|
39938
39951
|
tagTypes: ['pinnedMessages', 'recentMessages', 'messageFeedback'],
|
|
39939
39952
|
endpoints: (builder) => ({
|
|
39940
39953
|
getPinnedMessages: builder.query({
|
|
39941
|
-
|
|
39954
|
+
// The generated `aiMentorOrgsUsersPinMessageList` sends a `session_id`
|
|
39955
|
+
// query param the endpoint does not accept; the list is user-wide, so a
|
|
39956
|
+
// session in the cache key would refetch it on every chat switch.
|
|
39957
|
+
queryFn: async (args, api, extraOptions) => {
|
|
39958
|
+
const url = buildPinnedMessagesUrl(args);
|
|
39959
|
+
return iblFetchBaseQuery({
|
|
39960
|
+
url,
|
|
39961
|
+
method: 'GET',
|
|
39962
|
+
service: exports.SERVICES.DM,
|
|
39963
|
+
}, api, extraOptions);
|
|
39964
|
+
},
|
|
39942
39965
|
providesTags: ['pinnedMessages'],
|
|
39943
39966
|
}),
|
|
39944
39967
|
unPinMessage: builder.mutation({
|
|
@@ -42233,9 +42256,51 @@ const credentialsApiSlice = react.createApi({
|
|
|
42233
42256
|
});
|
|
42234
42257
|
const { useGetCredentialsQuery, useLazyGetCredentialsQuery, useGetUserCredentialsQuery, useLazyGetUserCredentialsQuery, useCreateCallCredentialsMutation, useGetIntegrationCredentialsQuery, useLazyGetIntegrationCredentialsQuery, useCreateIntegrationCredentialMutation, useUpdateIntegrationCredentialMutation, useGetLLMCredentialsQuery, useLazyGetLLMCredentialsQuery, useCreateLLMCredentialMutation, useGetConnectedServiceAuthUrlQuery, useLazyGetConnectedServiceAuthUrlQuery, useConnectedServicesCallbackQuery, useLazyConnectedServicesCallbackQuery, useGetUsersAsAssertionsQuery, useLazyGetUsersAsAssertionsQuery, useCreateCredentialAssertionMutation, useGetCredentialsListQuery, useLazyGetCredentialsListQuery, useCreateCredentialMutation, useUpdateCredentialMutation, useDeleteCourseCredentialMutation, useGetProviderConfigQuery, useLazyGetProviderConfigQuery, useCreateProviderConfigMutation, useDeleteProviderConfigMutation, useGetExternalMappingQuery, useLazyGetExternalMappingQuery, useCreateExternalMappingMutation, useDeleteExternalMappingMutation, } = credentialsApiSlice;
|
|
42235
42258
|
|
|
42259
|
+
/**
|
|
42260
|
+
* Makes a base query that reports failures by THROWING report them by
|
|
42261
|
+
* RETURNING `{ error }` instead, which is the only form RTK Query keeps.
|
|
42262
|
+
*
|
|
42263
|
+
* `iblFetchBaseQuery` throws `{ status, data }` on any failed request. RTK
|
|
42264
|
+
* Query treats a thrown value as an unhandled exception: the thunk rejects
|
|
42265
|
+
* with `miniSerializeError(e)`, which copies only `name` / `message` /
|
|
42266
|
+
* `stack` / `code`. For a `{ status, data }` object that leaves `{}` — so
|
|
42267
|
+
* `.unwrap()` rejects with an empty object and a hook's `error` is empty too.
|
|
42268
|
+
* The HTTP status and the backend's body never reach the caller: a 403 cannot
|
|
42269
|
+
* be told from any other failure, and a 400's field messages or its
|
|
42270
|
+
* form-level `error` string cannot be shown.
|
|
42271
|
+
*
|
|
42272
|
+
* Wrap a slice's base query with this when its callers need the status or the
|
|
42273
|
+
* body, e.g. to place backend validation messages next to their fields.
|
|
42274
|
+
*
|
|
42275
|
+
* Only values that look like an RTK error (an object with a `status`) are
|
|
42276
|
+
* converted; anything else is rethrown untouched. Note that a returned error
|
|
42277
|
+
* also lets a mutation's static `invalidatesTags` run, as RTK does for any
|
|
42278
|
+
* handled error.
|
|
42279
|
+
*/
|
|
42280
|
+
function withReturnedErrors(baseQuery) {
|
|
42281
|
+
// Returned as `Query` so a slice keeps the exact argument, error and meta
|
|
42282
|
+
// types of the base query it wraps.
|
|
42283
|
+
const wrapped = async (args, api, extraOptions) => {
|
|
42284
|
+
try {
|
|
42285
|
+
return await baseQuery(args, api, extraOptions);
|
|
42286
|
+
}
|
|
42287
|
+
catch (thrown) {
|
|
42288
|
+
if (typeof thrown === 'object' && thrown !== null && 'status' in thrown) {
|
|
42289
|
+
return { error: thrown };
|
|
42290
|
+
}
|
|
42291
|
+
throw thrown;
|
|
42292
|
+
}
|
|
42293
|
+
};
|
|
42294
|
+
return wrapped;
|
|
42295
|
+
}
|
|
42296
|
+
|
|
42236
42297
|
const chatPrivacyApiSlice = react.createApi({
|
|
42237
42298
|
reducerPath: 'chatPrivacyApiSlice',
|
|
42238
|
-
|
|
42299
|
+
// Callers read the failure itself: the 403 a locked mentor answers to a
|
|
42300
|
+
// `disable-chathistory` flip carries its reason in `data.detail`, and the
|
|
42301
|
+
// one-way 400 carries it under the field name. `iblFetchBaseQuery` throws
|
|
42302
|
+
// its errors, which reach `.unwrap()` and the hooks as `{}`.
|
|
42303
|
+
baseQuery: withReturnedErrors(iblFetchBaseQuery),
|
|
42239
42304
|
tagTypes: ['TenantChatPrivacyConfig', 'UserChatPrivacySettings', 'ChatPrivacyEffective'],
|
|
42240
42305
|
endpoints: (builder) => ({
|
|
42241
42306
|
getTenantChatPrivacyConfig: builder.query({
|
|
@@ -49861,6 +49926,7 @@ exports.billingApiSlice = billingApiSlice;
|
|
|
49861
49926
|
exports.billingCustomSlice = billingCustomSlice;
|
|
49862
49927
|
exports.buildGlobalSearchUrl = buildGlobalSearchUrl;
|
|
49863
49928
|
exports.buildLearnerCompletionUrl = buildLearnerCompletionUrl;
|
|
49929
|
+
exports.buildPinnedMessagesUrl = buildPinnedMessagesUrl;
|
|
49864
49930
|
exports.buildRecentMessagesUrl = buildRecentMessagesUrl;
|
|
49865
49931
|
exports.buildSessionRetrieveUrl = buildSessionRetrieveUrl;
|
|
49866
49932
|
exports.buildSharedSessionRetrieveUrl = buildSharedSessionRetrieveUrl;
|