@iblai/data-layer 1.27.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.js CHANGED
@@ -42256,9 +42256,51 @@ const credentialsApiSlice = react.createApi({
42256
42256
  });
42257
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;
42258
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
+
42259
42297
  const chatPrivacyApiSlice = react.createApi({
42260
42298
  reducerPath: 'chatPrivacyApiSlice',
42261
- baseQuery: iblFetchBaseQuery,
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),
42262
42304
  tagTypes: ['TenantChatPrivacyConfig', 'UserChatPrivacySettings', 'ChatPrivacyEffective'],
42263
42305
  endpoints: (builder) => ({
42264
42306
  getTenantChatPrivacyConfig: builder.query({