@iblai/data-layer 1.37.0 → 1.38.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
@@ -42129,6 +42129,44 @@ const skillsApiSlice = react.createApi({
42129
42129
  });
42130
42130
  const { useGetReportedSkillsQuery, useLazyGetReportedSkillsQuery, useGetSkillsPointsPercentileQuery, useLazyGetSkillsPointsPercentileQuery, useGetDesiredSkillsQuery, useLazyGetDesiredSkillsQuery, useGetUserEarnedSkillsQuery, useLazyGetUserEarnedSkillsQuery, } = skillsApiSlice;
42131
42131
 
42132
+ /**
42133
+ * Makes a base query that reports failures by THROWING report them by
42134
+ * RETURNING `{ error }` instead, which is the only form RTK Query keeps.
42135
+ *
42136
+ * `iblFetchBaseQuery` throws `{ status, data }` on any failed request. RTK
42137
+ * Query treats a thrown value as an unhandled exception: the thunk rejects
42138
+ * with `miniSerializeError(e)`, which copies only `name` / `message` /
42139
+ * `stack` / `code`. For a `{ status, data }` object that leaves `{}` — so
42140
+ * `.unwrap()` rejects with an empty object and a hook's `error` is empty too.
42141
+ * The HTTP status and the backend's body never reach the caller: a 403 cannot
42142
+ * be told from any other failure, and a 400's field messages or its
42143
+ * form-level `error` string cannot be shown.
42144
+ *
42145
+ * Wrap a slice's base query with this when its callers need the status or the
42146
+ * body, e.g. to place backend validation messages next to their fields.
42147
+ *
42148
+ * Only values that look like an RTK error (an object with a `status`) are
42149
+ * converted; anything else is rethrown untouched. Note that a returned error
42150
+ * also lets a mutation's static `invalidatesTags` run, as RTK does for any
42151
+ * handled error.
42152
+ */
42153
+ function withReturnedErrors(baseQuery) {
42154
+ // Returned as `Query` so a slice keeps the exact argument, error and meta
42155
+ // types of the base query it wraps.
42156
+ const wrapped = async (args, api, extraOptions) => {
42157
+ try {
42158
+ return await baseQuery(args, api, extraOptions);
42159
+ }
42160
+ catch (thrown) {
42161
+ if (typeof thrown === 'object' && thrown !== null && 'status' in thrown) {
42162
+ return { error: thrown };
42163
+ }
42164
+ throw thrown;
42165
+ }
42166
+ };
42167
+ return wrapped;
42168
+ }
42169
+
42132
42170
  const CREDENTIALS_CUSTOM_REDUCER_PATH = 'credentialsCustomApiSlice';
42133
42171
  const CREDENTIALS_CUSTOM_ENDPOINTS = {
42134
42172
  DELETE_INTEGRATION_CREDENTIAL: {
@@ -42391,7 +42429,9 @@ const credentialsApiSlice = react.createApi({
42391
42429
  // Build query string from params
42392
42430
  const queryString = new URLSearchParams(queryParams).toString();
42393
42431
  const url = `/api/ai-account/connected-services/callback/?${queryString}`;
42394
- return iblFetchBaseQuery({
42432
+ // The page that finishes a sign-in says why it failed, so the backend's
42433
+ // answer must reach it rather than RTK's empty `{}` for a thrown error.
42434
+ return withReturnedErrors(iblFetchBaseQuery)({
42395
42435
  url,
42396
42436
  service: exports.SERVICES.DM,
42397
42437
  }, api, extraOptions);
@@ -42486,44 +42526,6 @@ const credentialsApiSlice = react.createApi({
42486
42526
  });
42487
42527
  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;
42488
42528
 
42489
- /**
42490
- * Makes a base query that reports failures by THROWING report them by
42491
- * RETURNING `{ error }` instead, which is the only form RTK Query keeps.
42492
- *
42493
- * `iblFetchBaseQuery` throws `{ status, data }` on any failed request. RTK
42494
- * Query treats a thrown value as an unhandled exception: the thunk rejects
42495
- * with `miniSerializeError(e)`, which copies only `name` / `message` /
42496
- * `stack` / `code`. For a `{ status, data }` object that leaves `{}` — so
42497
- * `.unwrap()` rejects with an empty object and a hook's `error` is empty too.
42498
- * The HTTP status and the backend's body never reach the caller: a 403 cannot
42499
- * be told from any other failure, and a 400's field messages or its
42500
- * form-level `error` string cannot be shown.
42501
- *
42502
- * Wrap a slice's base query with this when its callers need the status or the
42503
- * body, e.g. to place backend validation messages next to their fields.
42504
- *
42505
- * Only values that look like an RTK error (an object with a `status`) are
42506
- * converted; anything else is rethrown untouched. Note that a returned error
42507
- * also lets a mutation's static `invalidatesTags` run, as RTK does for any
42508
- * handled error.
42509
- */
42510
- function withReturnedErrors(baseQuery) {
42511
- // Returned as `Query` so a slice keeps the exact argument, error and meta
42512
- // types of the base query it wraps.
42513
- const wrapped = async (args, api, extraOptions) => {
42514
- try {
42515
- return await baseQuery(args, api, extraOptions);
42516
- }
42517
- catch (thrown) {
42518
- if (typeof thrown === 'object' && thrown !== null && 'status' in thrown) {
42519
- return { error: thrown };
42520
- }
42521
- throw thrown;
42522
- }
42523
- };
42524
- return wrapped;
42525
- }
42526
-
42527
42529
  const chatPrivacyApiSlice = react.createApi({
42528
42530
  reducerPath: 'chatPrivacyApiSlice',
42529
42531
  // Callers read the failure itself: the 403 a locked mentor answers to a
@@ -46034,12 +46036,40 @@ const MCP_ENDPOINTS = {
46034
46036
  path: (org, userId) => `/api/ai-mentor/orgs/${org}/users/${userId}/mcp-servers/oauth-find/`,
46035
46037
  service: exports.SERVICES.DM,
46036
46038
  },
46039
+ // User preferences (permanent, and per conversation)
46040
+ MCP_SERVER_PREFERENCE: {
46041
+ path: (org, userId, id) => `/api/ai-mentor/orgs/${org}/users/${userId}/mcp-servers/${id}/preference/`,
46042
+ service: exports.SERVICES.DM,
46043
+ },
46044
+ MCP_SERVER_SESSION_PREFERENCE: {
46045
+ path: (org, userId, id) => `/api/ai-mentor/orgs/${org}/users/${userId}/mcp-servers/${id}/session-preference/`,
46046
+ service: exports.SERVICES.DM,
46047
+ },
46048
+ // How a server signs in for one agent (its override of auth_scope)
46049
+ MCP_SERVER_MENTOR_AUTH_SCOPE: {
46050
+ path: (org, userId, id) => `/api/ai-mentor/orgs/${org}/users/${userId}/mcp-servers/${id}/mentor-auth-scope/`,
46051
+ service: exports.SERVICES.DM,
46052
+ },
46053
+ // Organization credentials: the OAuth client or API key behind a server
46054
+ MCP_SERVER_CREDENTIALS: {
46055
+ path: (org, userId, id) => `/api/ai-mentor/orgs/${org}/users/${userId}/mcp-servers/${id}/credentials/`,
46056
+ service: exports.SERVICES.DM,
46057
+ },
46037
46058
  };
46038
- const MCP_TAG_TYPES = ['MCPServers', 'ConnectedServices', 'MCPServerConnections'];
46059
+ const MCP_TAG_TYPES = [
46060
+ 'MCPServers',
46061
+ 'ConnectedServices',
46062
+ 'MCPServerConnections',
46063
+ 'MCPServerPreferences',
46064
+ 'MCPServerCredentials',
46065
+ ];
46039
46066
 
46040
46067
  const mcpApiSlice = react.createApi({
46041
46068
  reducerPath: MCP_REDUCER_PATH,
46042
- baseQuery: iblFetchBaseQuery,
46069
+ // Returned, not thrown: `unwrap()` then rejects with `{ status, data }`, so the
46070
+ // backend's reason (a server required by the organization, a missing header)
46071
+ // reaches the toast instead of an empty object.
46072
+ baseQuery: withReturnedErrors(iblFetchBaseQuery),
46043
46073
  tagTypes: [...MCP_TAG_TYPES],
46044
46074
  endpoints: (builder) => ({
46045
46075
  // MCP Servers
@@ -46056,6 +46086,7 @@ const mcpApiSlice = react.createApi({
46056
46086
  page: args.page,
46057
46087
  page_size: args.pageSize,
46058
46088
  search: args.search,
46089
+ session_id: args.sessionId,
46059
46090
  transport: args.transport,
46060
46091
  url: args.url,
46061
46092
  },
@@ -46192,20 +46223,134 @@ const mcpApiSlice = react.createApi({
46192
46223
  }),
46193
46224
  // OAuth Find
46194
46225
  oauthFind: builder.mutation({
46226
+ query: (args) => {
46227
+ var _a;
46228
+ return ({
46229
+ url: MCP_ENDPOINTS.OAUTH_FIND.path(args.org, args.userId),
46230
+ service: MCP_ENDPOINTS.OAUTH_FIND.service,
46231
+ method: 'POST',
46232
+ body: {
46233
+ url: args.url,
46234
+ ...(args.name && { name: args.name }),
46235
+ ...(args.callback_url && { callback_url: args.callback_url }),
46236
+ ...(args.client_id !== undefined && {
46237
+ client_id: args.client_id,
46238
+ client_secret: (_a = args.client_secret) !== null && _a !== void 0 ? _a : '',
46239
+ ...(args.authorization_url !== undefined && {
46240
+ authorization_url: args.authorization_url,
46241
+ }),
46242
+ ...(args.token_url !== undefined && { token_url: args.token_url }),
46243
+ ...(args.token_endpoint_auth_method && {
46244
+ token_endpoint_auth_method: args.token_endpoint_auth_method,
46245
+ }),
46246
+ ...(args.scopes && { scopes: args.scopes }),
46247
+ }),
46248
+ },
46249
+ });
46250
+ },
46251
+ // The app it stores is the one every server of that provider signs in through.
46252
+ invalidatesTags: (_result, _error, args) => args.client_id !== undefined ? ['MCPServerCredentials'] : [],
46253
+ }),
46254
+ // User preferences: a server's on/off for the caller, permanently or in
46255
+ // one conversation. Saving either invalidates the server lists, whose
46256
+ // `user_enabled` reflects the choice.
46257
+ getMCPServerPreference: builder.query({
46195
46258
  query: (args) => ({
46196
- url: MCP_ENDPOINTS.OAUTH_FIND.path(args.org, args.userId),
46197
- service: MCP_ENDPOINTS.OAUTH_FIND.service,
46198
- method: 'POST',
46199
- body: {
46200
- url: args.url,
46201
- ...(args.name && { name: args.name }),
46202
- ...(args.callback_url && { callback_url: args.callback_url }),
46203
- },
46259
+ url: MCP_ENDPOINTS.MCP_SERVER_PREFERENCE.path(args.org, args.userId, args.id),
46260
+ service: MCP_ENDPOINTS.MCP_SERVER_PREFERENCE.service,
46261
+ }),
46262
+ providesTags: (_result, _error, args) => [{ type: 'MCPServerPreferences', id: args.id }],
46263
+ }),
46264
+ setMCPServerPreference: builder.mutation({
46265
+ query: (args) => ({
46266
+ url: MCP_ENDPOINTS.MCP_SERVER_PREFERENCE.path(args.org, args.userId, args.id),
46267
+ service: MCP_ENDPOINTS.MCP_SERVER_PREFERENCE.service,
46268
+ method: 'PUT',
46269
+ body: { is_enabled: args.isEnabled },
46270
+ }),
46271
+ invalidatesTags: (_result, _error, args) => [
46272
+ 'MCPServers',
46273
+ { type: 'MCPServerPreferences', id: args.id },
46274
+ ],
46275
+ }),
46276
+ getMCPServerSessionPreference: builder.query({
46277
+ query: (args) => ({
46278
+ url: MCP_ENDPOINTS.MCP_SERVER_SESSION_PREFERENCE.path(args.org, args.userId, args.id),
46279
+ service: MCP_ENDPOINTS.MCP_SERVER_SESSION_PREFERENCE.service,
46280
+ params: { session_id: args.sessionId },
46281
+ }),
46282
+ providesTags: (_result, _error, args) => [
46283
+ { type: 'MCPServerPreferences', id: `${args.id}:${args.sessionId}` },
46284
+ ],
46285
+ }),
46286
+ setMCPServerSessionPreference: builder.mutation({
46287
+ query: (args) => ({
46288
+ url: MCP_ENDPOINTS.MCP_SERVER_SESSION_PREFERENCE.path(args.org, args.userId, args.id),
46289
+ service: MCP_ENDPOINTS.MCP_SERVER_SESSION_PREFERENCE.service,
46290
+ method: 'PUT',
46291
+ body: { session_id: args.sessionId, is_enabled: args.isEnabled },
46292
+ }),
46293
+ invalidatesTags: (_result, _error, args) => [
46294
+ 'MCPServers',
46295
+ { type: 'MCPServerPreferences', id: `${args.id}:${args.sessionId}` },
46296
+ ],
46297
+ }),
46298
+ // How a server signs in for one agent (guide §5.9): the agent's override of
46299
+ // the server's auth_scope, for connectors the organization cannot edit.
46300
+ getMCPServerMentorAuthScope: builder.query({
46301
+ query: (args) => ({
46302
+ url: `${MCP_ENDPOINTS.MCP_SERVER_MENTOR_AUTH_SCOPE.path(args.org, args.userId, args.id)}?mentor=${encodeURIComponent(args.mentor)}`,
46303
+ service: MCP_ENDPOINTS.MCP_SERVER_MENTOR_AUTH_SCOPE.service,
46304
+ }),
46305
+ providesTags: (_result, _error, args) => [{ type: 'MCPServers', id: `scope:${args.id}` }],
46306
+ }),
46307
+ setMCPServerMentorAuthScope: builder.mutation({
46308
+ query: (args) => ({
46309
+ url: MCP_ENDPOINTS.MCP_SERVER_MENTOR_AUTH_SCOPE.path(args.org, args.userId, args.id),
46310
+ service: MCP_ENDPOINTS.MCP_SERVER_MENTOR_AUTH_SCOPE.service,
46311
+ method: 'PUT',
46312
+ body: { mentor: args.mentor, auth_scope: args.authScope },
46204
46313
  }),
46314
+ invalidatesTags: ['MCPServers'],
46315
+ }),
46316
+ // Organization credentials (administrators): the OAuth client users sign
46317
+ // in through, or the organization's API key. Secrets come back masked.
46318
+ getMCPServerCredentials: builder.query({
46319
+ query: (args) => ({
46320
+ url: MCP_ENDPOINTS.MCP_SERVER_CREDENTIALS.path(args.org, args.userId, args.id),
46321
+ service: MCP_ENDPOINTS.MCP_SERVER_CREDENTIALS.service,
46322
+ }),
46323
+ providesTags: (_result, _error, args) => [{ type: 'MCPServerCredentials', id: args.id }],
46324
+ }),
46325
+ setMCPServerCredentials: builder.mutation({
46326
+ query: (args) => ({
46327
+ url: MCP_ENDPOINTS.MCP_SERVER_CREDENTIALS.path(args.org, args.userId, args.id),
46328
+ service: MCP_ENDPOINTS.MCP_SERVER_CREDENTIALS.service,
46329
+ method: 'PUT',
46330
+ body: args.body,
46331
+ }),
46332
+ invalidatesTags: (_result, _error, args) => [
46333
+ { type: 'MCPServerCredentials', id: args.id },
46334
+ 'MCPServers',
46335
+ ],
46336
+ }),
46337
+ // Removing an OAuth client signs everyone out of that provider.
46338
+ deleteMCPServerCredentials: builder.mutation({
46339
+ query: (args) => ({
46340
+ url: MCP_ENDPOINTS.MCP_SERVER_CREDENTIALS.path(args.org, args.userId, args.id),
46341
+ service: MCP_ENDPOINTS.MCP_SERVER_CREDENTIALS.service,
46342
+ method: 'DELETE',
46343
+ }),
46344
+ invalidatesTags: (_result, _error, args) => [
46345
+ { type: 'MCPServerCredentials', id: args.id },
46346
+ 'MCPServers',
46347
+ 'ConnectedServices',
46348
+ 'MCPServerConnections',
46349
+ ],
46205
46350
  }),
46206
46351
  }),
46207
46352
  });
46208
- const { useGetMCPServersQuery, useLazyGetMCPServersQuery, useGetMCPServerQuery, useLazyGetMCPServerQuery, useCreateMCPServerMutation, useUpdateMCPServerMutation, usePartialUpdateMCPServerMutation, useDeleteMCPServerMutation, useGetOAuthServicesQuery, useLazyGetOAuthServicesQuery, useGetConnectedServicesQuery, useLazyGetConnectedServicesQuery, useLazyStartOAuthFlowQuery, useDisconnectServiceMutation, useGetMCPServerConnectionsQuery, useCreateMCPServerConnectionMutation, usePatchMCPServerConnectionMutation, useOauthFindMutation, } = mcpApiSlice;
46353
+ const { useGetMCPServersQuery, useLazyGetMCPServersQuery, useGetMCPServerQuery, useLazyGetMCPServerQuery, useCreateMCPServerMutation, useUpdateMCPServerMutation, usePartialUpdateMCPServerMutation, useDeleteMCPServerMutation, useGetOAuthServicesQuery, useLazyGetOAuthServicesQuery, useGetConnectedServicesQuery, useLazyGetConnectedServicesQuery, useLazyStartOAuthFlowQuery, useDisconnectServiceMutation, useGetMCPServerConnectionsQuery, useCreateMCPServerConnectionMutation, usePatchMCPServerConnectionMutation, useOauthFindMutation, useGetMCPServerPreferenceQuery, useLazyGetMCPServerPreferenceQuery, useSetMCPServerPreferenceMutation, useGetMCPServerSessionPreferenceQuery, useLazyGetMCPServerSessionPreferenceQuery, useSetMCPServerSessionPreferenceMutation, useGetMCPServerMentorAuthScopeQuery, useSetMCPServerMentorAuthScopeMutation, useGetMCPServerCredentialsQuery, useLazyGetMCPServerCredentialsQuery, useSetMCPServerCredentialsMutation, useDeleteMCPServerCredentialsMutation, } = mcpApiSlice;
46209
46354
 
46210
46355
  const CLAW_REDUCER_PATH = 'clawApiSlice';
46211
46356
  const CLAW_TAG_TYPES = ['ClawMentorConfig', 'ClawInstances', 'AgentConfig'];
@@ -50598,6 +50743,7 @@ exports.useDeleteIntegrationCredentialMutation = useDeleteIntegrationCredentialM
50598
50743
  exports.useDeleteLtiKeyMutation = useDeleteLtiKeyMutation;
50599
50744
  exports.useDeleteLtiMentorMutation = useDeleteLtiMentorMutation;
50600
50745
  exports.useDeleteLtiToolMutation = useDeleteLtiToolMutation;
50746
+ exports.useDeleteMCPServerCredentialsMutation = useDeleteMCPServerCredentialsMutation;
50601
50747
  exports.useDeleteMCPServerMutation = useDeleteMCPServerMutation;
50602
50748
  exports.useDeleteMemoryCategoryMutation = useDeleteMemoryCategoryMutation;
50603
50749
  exports.useDeleteMentorMemoryMutation = useDeleteMentorMemoryMutation;
@@ -50751,7 +50897,11 @@ exports.useGetLtiMentorsQuery = useGetLtiMentorsQuery;
50751
50897
  exports.useGetLtiToolDetailQuery = useGetLtiToolDetailQuery;
50752
50898
  exports.useGetLtiToolsQuery = useGetLtiToolsQuery;
50753
50899
  exports.useGetMCPServerConnectionsQuery = useGetMCPServerConnectionsQuery;
50900
+ exports.useGetMCPServerCredentialsQuery = useGetMCPServerCredentialsQuery;
50901
+ exports.useGetMCPServerMentorAuthScopeQuery = useGetMCPServerMentorAuthScopeQuery;
50902
+ exports.useGetMCPServerPreferenceQuery = useGetMCPServerPreferenceQuery;
50754
50903
  exports.useGetMCPServerQuery = useGetMCPServerQuery;
50904
+ exports.useGetMCPServerSessionPreferenceQuery = useGetMCPServerSessionPreferenceQuery;
50755
50905
  exports.useGetMCPServersQuery = useGetMCPServersQuery;
50756
50906
  exports.useGetMaskedIntegrationCredentialsQuery = useGetMaskedIntegrationCredentialsQuery;
50757
50907
  exports.useGetMaskedLLMCredentialsQuery = useGetMaskedLLMCredentialsQuery;
@@ -51008,7 +51158,10 @@ exports.useLazyGetLLMCredentialsQuery = useLazyGetLLMCredentialsQuery;
51008
51158
  exports.useLazyGetLearnerCourseOutlineQuery = useLazyGetLearnerCourseOutlineQuery;
51009
51159
  exports.useLazyGetLlmsQuery = useLazyGetLlmsQuery;
51010
51160
  exports.useLazyGetLtiKeyDetailQuery = useLazyGetLtiKeyDetailQuery;
51161
+ exports.useLazyGetMCPServerCredentialsQuery = useLazyGetMCPServerCredentialsQuery;
51162
+ exports.useLazyGetMCPServerPreferenceQuery = useLazyGetMCPServerPreferenceQuery;
51011
51163
  exports.useLazyGetMCPServerQuery = useLazyGetMCPServerQuery;
51164
+ exports.useLazyGetMCPServerSessionPreferenceQuery = useLazyGetMCPServerSessionPreferenceQuery;
51012
51165
  exports.useLazyGetMCPServersQuery = useLazyGetMCPServersQuery;
51013
51166
  exports.useLazyGetMemoryCategoriesAdminQuery = useLazyGetMemoryCategoriesAdminQuery;
51014
51167
  exports.useLazyGetMemsearchConfigQuery = useLazyGetMemsearchConfigQuery;
@@ -51216,6 +51369,10 @@ exports.useSendNotificationMutation = useSendNotificationMutation;
51216
51369
  exports.useSendTestTemplateEmailMutation = useSendTestTemplateEmailMutation;
51217
51370
  exports.useSetCurrentVersionMutation = useSetCurrentVersionMutation;
51218
51371
  exports.useSetLlmAccessMutation = useSetLlmAccessMutation;
51372
+ exports.useSetMCPServerCredentialsMutation = useSetMCPServerCredentialsMutation;
51373
+ exports.useSetMCPServerMentorAuthScopeMutation = useSetMCPServerMentorAuthScopeMutation;
51374
+ exports.useSetMCPServerPreferenceMutation = useSetMCPServerPreferenceMutation;
51375
+ exports.useSetMCPServerSessionPreferenceMutation = useSetMCPServerSessionPreferenceMutation;
51219
51376
  exports.useSetPlatformConfigurationsMutation = useSetPlatformConfigurationsMutation;
51220
51377
  exports.useSetStudentMentorCreationStatusMutation = useSetStudentMentorCreationStatusMutation;
51221
51378
  exports.useSetStudioAdvancedSettingsMutation = useSetStudioAdvancedSettingsMutation;