@iblai/data-layer 1.12.0 → 1.12.1

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
@@ -39486,17 +39486,84 @@ const buildEndpointFromServiceLegacy = (service, serviceFn, options) => {
39486
39486
  */
39487
39487
  const buildEndpointFromDmServiceLegacy = (serviceFn, options) => buildEndpointFromServiceLegacy(exports.SERVICES.DM, serviceFn);
39488
39488
 
39489
+ const API_TOKENS_PATH = '/api/core/platform/api-tokens/';
39490
+ /**
39491
+ * Normalizes a `getApiKeys` result: the endpoint returns a bare array unless
39492
+ * `pageSize` is sent, in which case it returns a DRF page envelope.
39493
+ */
39494
+ function unwrapApiTokenList(response) {
39495
+ var _a, _b;
39496
+ if (Array.isArray(response)) {
39497
+ return { tokens: response, count: response.length };
39498
+ }
39499
+ return { tokens: (_a = response === null || response === void 0 ? void 0 : response.results) !== null && _a !== void 0 ? _a : [], count: (_b = response === null || response === void 0 ? void 0 : response.count) !== null && _b !== void 0 ? _b : 0 };
39500
+ }
39501
+ /**
39502
+ * The detail/PATCH routes are registered without a trailing slash, matching the
39503
+ * `api-tokens/{name}` path in the OpenAPI schema.
39504
+ */
39505
+ const apiTokenDetailPath = (name, platformKey) => `${API_TOKENS_PATH}${encodeURIComponent(name)}?platform_key=${encodeURIComponent(platformKey)}`;
39506
+ async function requestApiToken(path, options, errorMessage) {
39507
+ const headers = { ...OpenAPI.HEADERS };
39508
+ if (options.body) {
39509
+ headers['Content-Type'] = 'application/json';
39510
+ }
39511
+ const response = await fetch(`${OpenAPI.BASE}${path}`, {
39512
+ method: options.method,
39513
+ headers,
39514
+ credentials: 'omit',
39515
+ body: options.body,
39516
+ });
39517
+ if (!response.ok) {
39518
+ throw Object.assign(new Error(errorMessage), {
39519
+ status: response.status,
39520
+ body: await response.text(),
39521
+ });
39522
+ }
39523
+ return response.status === 204 ? undefined : response.json();
39524
+ }
39489
39525
  const apiKeysApiSlice = react.createApi({
39490
39526
  reducerPath: 'apiKeysApiSlice',
39491
39527
  baseQuery: iblFakeBaseQuery,
39492
39528
  tagTypes: ['apiKeys'],
39493
39529
  endpoints: (builder) => ({
39530
+ /**
39531
+ * Paginates only when `pageSize` is supplied — without it the endpoint
39532
+ * returns a bare array, which is what existing callers rely on.
39533
+ */
39494
39534
  getApiKeys: builder.query({
39495
- ...buildEndpointFromDmService(CoreService.corePlatformApiTokensList),
39535
+ ...buildEndpointFromService(exports.SERVICES.DM, async (args) => {
39536
+ const queryParams = new URLSearchParams({ platform_key: args.platformKey });
39537
+ if (args.page !== undefined)
39538
+ queryParams.set('page', String(args.page));
39539
+ if (args.pageSize !== undefined)
39540
+ queryParams.set('page_size', String(args.pageSize));
39541
+ return requestApiToken(`${API_TOKENS_PATH}?${queryParams.toString()}`, { method: 'GET' }, 'Failed to fetch API keys');
39542
+ }),
39543
+ providesTags: ['apiKeys'],
39544
+ }),
39545
+ /** Detail read — the only GET that returns the token's policies and groups. */
39546
+ getApiKey: builder.query({
39547
+ ...buildEndpointFromService(exports.SERVICES.DM, async (args) => requestApiToken(apiTokenDetailPath(args.name, args.platformKey), { method: 'GET' }, 'Failed to fetch API key')),
39496
39548
  providesTags: ['apiKeys'],
39497
39549
  }),
39550
+ /**
39551
+ * Per-field write flags for the token-policy fields. Gated on create
39552
+ * access, so a 403 is an expected empty state for users who cannot create.
39553
+ */
39554
+ getApiKeyFieldPermissions: builder.query({
39555
+ ...buildEndpointFromService(exports.SERVICES.DM, async (args) => requestApiToken(`${API_TOKENS_PATH}field-permissions/?platform_key=${encodeURIComponent(args.platformKey)}`, { method: 'GET' }, 'Failed to fetch API key field permissions'), { expectedErrorStatuses: [403, 404] }),
39556
+ }),
39498
39557
  createApiKey: builder.mutation({
39499
- ...buildEndpointFromDmService(CoreService.corePlatformApiTokensCreate),
39558
+ ...buildEndpointFromService(exports.SERVICES.DM, async (args) => requestApiToken(API_TOKENS_PATH, { method: 'POST', body: JSON.stringify(args.requestBody) }, 'Failed to create API key')),
39559
+ invalidatesTags: ['apiKeys'],
39560
+ }),
39561
+ /**
39562
+ * `name` is the lookup key, so a rename PATCHes the old name and changes
39563
+ * the identifier the key is addressed by afterwards.
39564
+ */
39565
+ updateApiKey: builder.mutation({
39566
+ ...buildEndpointFromService(exports.SERVICES.DM, async (args) => requestApiToken(apiTokenDetailPath(args.name, args.platformKey), { method: 'PATCH', body: JSON.stringify(args.requestBody) }, 'Failed to update API key')),
39500
39567
  invalidatesTags: ['apiKeys'],
39501
39568
  }),
39502
39569
  deleteApiKey: builder.mutation({
@@ -39506,7 +39573,7 @@ const apiKeysApiSlice = react.createApi({
39506
39573
  }),
39507
39574
  });
39508
39575
  const apiKeysApiReducer = apiKeysApiSlice.reducer;
39509
- const { useGetApiKeysQuery, useLazyGetApiKeysQuery, useCreateApiKeyMutation, useDeleteApiKeyMutation, } = apiKeysApiSlice;
39576
+ const { useGetApiKeysQuery, useLazyGetApiKeysQuery, useGetApiKeyQuery, useLazyGetApiKeyQuery, useGetApiKeyFieldPermissionsQuery, useCreateApiKeyMutation, useUpdateApiKeyMutation, useDeleteApiKeyMutation, } = apiKeysApiSlice;
39510
39577
 
39511
39578
  const chatHistoryApiSlice = react.createApi({
39512
39579
  reducerPath: 'chatHistoryApiSlice',
@@ -40843,6 +40910,7 @@ const coreApiSlice = react.createApi({
40843
40910
  tagTypes: [
40844
40911
  'PlatformInfo',
40845
40912
  'PlatformUsers',
40913
+ 'AccessibleUsers',
40846
40914
  'RbacGroups',
40847
40915
  'RbacPolicies',
40848
40916
  'RbacRoles',
@@ -40866,6 +40934,43 @@ const coreApiSlice = react.createApi({
40866
40934
  updateUserStatus: builder.mutation({
40867
40935
  ...buildEndpointFromDmService(CoreService.coreUsersPlatformsCreate),
40868
40936
  }),
40937
+ /**
40938
+ * Users on the caller's platform that the caller holds `required_action`
40939
+ * on — the RBAC-scoped alternative to the admin-only
40940
+ * `GET /api/core/platform/users/`. A watcher, for instance, only gets back
40941
+ * the users in the groups they watch.
40942
+ *
40943
+ * Filters are per-field (`email`, `username`); there is no combined search
40944
+ * param. A 403 means the grant is collection-wide and the caller is missing
40945
+ * `Ibl.Core/AccessibleUsers/list`.
40946
+ */
40947
+ getAccessibleUsers: builder.query({
40948
+ ...buildEndpointFromService(exports.SERVICES.DM, async (args) => {
40949
+ const queryParams = new URLSearchParams();
40950
+ for (const [key, value] of Object.entries(args !== null && args !== void 0 ? args : {})) {
40951
+ // Empty strings are dropped: the backend treats `username=` as a
40952
+ // filter on the empty username rather than as "no filter".
40953
+ if (value !== undefined && value !== null && value !== '') {
40954
+ queryParams.set(key, String(value));
40955
+ }
40956
+ }
40957
+ const queryString = queryParams.toString();
40958
+ const url = `${OpenAPI.BASE}/api/core/users/accessible/${queryString ? `?${queryString}` : ''}`;
40959
+ const response = await fetch(url, {
40960
+ method: 'GET',
40961
+ headers: OpenAPI.HEADERS,
40962
+ credentials: 'omit',
40963
+ });
40964
+ if (!response.ok) {
40965
+ throw Object.assign(new Error('Failed to fetch accessible users'), {
40966
+ status: response.status,
40967
+ body: await response.text(),
40968
+ });
40969
+ }
40970
+ return response.json();
40971
+ }),
40972
+ providesTags: ['AccessibleUsers'],
40973
+ }),
40869
40974
  getRbacPermissions: builder.mutation({
40870
40975
  ...buildEndpointFromDmService(CoreService.coreRbacPermissionsCheckCreate),
40871
40976
  }),
@@ -41288,7 +41393,7 @@ const coreApiSlice = react.createApi({
41288
41393
  }),
41289
41394
  }),
41290
41395
  });
41291
- const { useCreateRedirectTokenMutation, useGetPlatformInfoQuery, useGetRbacPermissionsMutation, useLazyGetPlatformInfoQuery, useUpdatePlatformInfoMutation, useUpdateUserStatusMutation, useGetStudentMentorCreationStatusQuery, useSetStudentMentorCreationStatusMutation, useGetRbacGroupsQuery, useCreateRbacGroupMutation, useUpdateRbacGroupMutation, useDeleteRbacGroupMutation, useGetRbacGroupDetailsQuery, useGetRbacPoliciesQuery, useCreateRbacPolicyMutation, useUpdateRbacPolicyMutation, useDeleteRbacPolicyMutation, useGetRbacPolicyDetailsQuery, useGetRbacRolesQuery, useLazyGetRbacRolesQuery, useCreateRbacRoleMutation, useUpdateRbacRoleMutation, usePartialUpdateRbacRoleMutation, useDeleteRbacRoleMutation, useGetRbacRoleDetailsQuery, useGetDepartmentMemberCheckQuery, useLazyGetDepartmentMemberCheckQuery, useGetRbacMentorAccessListQuery, useUpdateRbacMentorAccessMutation, useGetRbacActionsDefinitionQuery, useLazyGetRbacActionsDefinitionQuery, useGetRbacResourceDiscoveryQuery, useLazyGetRbacResourceDiscoveryQuery, useGetRbacResourceListQuery, useLazyGetRbacResourceListQuery, useGetRbacTeamsAccessListQuery, useLazyGetRbacTeamsAccessListQuery, useCreateRbacTeamsAccessMutation,
41396
+ const { useCreateRedirectTokenMutation, useGetPlatformInfoQuery, useGetRbacPermissionsMutation, useLazyGetPlatformInfoQuery, useUpdatePlatformInfoMutation, useUpdateUserStatusMutation, useGetAccessibleUsersQuery, useLazyGetAccessibleUsersQuery, useGetStudentMentorCreationStatusQuery, useSetStudentMentorCreationStatusMutation, useGetRbacGroupsQuery, useCreateRbacGroupMutation, useUpdateRbacGroupMutation, useDeleteRbacGroupMutation, useGetRbacGroupDetailsQuery, useGetRbacPoliciesQuery, useCreateRbacPolicyMutation, useUpdateRbacPolicyMutation, useDeleteRbacPolicyMutation, useGetRbacPolicyDetailsQuery, useGetRbacRolesQuery, useLazyGetRbacRolesQuery, useCreateRbacRoleMutation, useUpdateRbacRoleMutation, usePartialUpdateRbacRoleMutation, useDeleteRbacRoleMutation, useGetRbacRoleDetailsQuery, useGetDepartmentMemberCheckQuery, useLazyGetDepartmentMemberCheckQuery, useGetRbacMentorAccessListQuery, useUpdateRbacMentorAccessMutation, useGetRbacActionsDefinitionQuery, useLazyGetRbacActionsDefinitionQuery, useGetRbacResourceDiscoveryQuery, useLazyGetRbacResourceDiscoveryQuery, useGetRbacResourceListQuery, useLazyGetRbacResourceListQuery, useGetRbacTeamsAccessListQuery, useLazyGetRbacTeamsAccessListQuery, useCreateRbacTeamsAccessMutation,
41292
41397
  // LTI Keys
41293
41398
  useGetLtiKeysQuery, useGetLtiKeyDetailQuery, useLazyGetLtiKeyDetailQuery, useCreateLtiKeyMutation, useUpdateLtiKeyMutation, useDeleteLtiKeyMutation,
41294
41399
  // LTI Agent (Mentor) Links
@@ -44299,6 +44404,11 @@ const MEMSEARCH_ENDPOINTS = {
44299
44404
  service: exports.SERVICES.AXD,
44300
44405
  path: (org, userId, mentorId) => `/api/ai-mentor/orgs/${org}/users/${userId}/mentors/${mentorId}/mentor-memories-list/`,
44301
44406
  },
44407
+ // Every mentor memory for a user, across all mentors (tenant admins only)
44408
+ GET_ALL_MENTOR_MEMORIES: {
44409
+ service: exports.SERVICES.AXD,
44410
+ path: (org, userId) => `/api/ai-mentor/orgs/${org}/users/${userId}/mentor-memories/`,
44411
+ },
44302
44412
  CREATE_MENTOR_MEMORY: {
44303
44413
  service: exports.SERVICES.AXD,
44304
44414
  path: (org, userId, mentorId) => `/api/ai-mentor/orgs/${org}/users/${userId}/mentors/${mentorId}/mentor-memories/`,
@@ -44416,6 +44526,14 @@ const memoryApiSlice = react.createApi({
44416
44526
  }),
44417
44527
  providesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MENTOR_MEMORIES(),
44418
44528
  }),
44529
+ getAllMentorMemories: builder.query({
44530
+ query: (args) => ({
44531
+ url: MEMSEARCH_ENDPOINTS.GET_ALL_MENTOR_MEMORIES.path(args.org, args.userId),
44532
+ service: MEMSEARCH_ENDPOINTS.GET_ALL_MENTOR_MEMORIES.service,
44533
+ params: args.params,
44534
+ }),
44535
+ providesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MENTOR_MEMORIES(),
44536
+ }),
44419
44537
  createMentorMemory: builder.mutation({
44420
44538
  query: (args) => ({
44421
44539
  url: MEMSEARCH_ENDPOINTS.CREATE_MENTOR_MEMORY.path(args.org, args.userId, args.mentorId),
@@ -44503,7 +44621,7 @@ const memoryApiSlice = react.createApi({
44503
44621
  }),
44504
44622
  }),
44505
44623
  });
44506
- const { useGetUserMemorySettingsQuery, useLazyGetUserMemorySettingsQuery, useUpdateUserMemorySettingsMutation, useGetGlobalMemoriesQuery, useLazyGetGlobalMemoriesQuery, useCreateGlobalMemoryMutation, useDeleteGlobalMemoryMutation, useGetMentorMemoriesQuery, useLazyGetMentorMemoriesQuery, useGetMentorMemoriesListQuery, useLazyGetMentorMemoriesListQuery, useCreateMentorMemoryMutation, useUpdateMentorMemoryMutation, useDeleteMentorMemoryMutation, useGetMemoryCategoriesAdminQuery, useLazyGetMemoryCategoriesAdminQuery, useCreateMemoryCategoryMutation, useUpdateMemoryCategoryMutation, useDeleteMemoryCategoryMutation, useGetMemsearchConfigQuery, useLazyGetMemsearchConfigQuery, useUpdateMemsearchConfigMutation, useGetMemsearchStatusQuery, useLazyGetMemsearchStatusQuery, } = memoryApiSlice;
44624
+ const { useGetUserMemorySettingsQuery, useLazyGetUserMemorySettingsQuery, useUpdateUserMemorySettingsMutation, useGetGlobalMemoriesQuery, useLazyGetGlobalMemoriesQuery, useCreateGlobalMemoryMutation, useDeleteGlobalMemoryMutation, useGetMentorMemoriesQuery, useLazyGetMentorMemoriesQuery, useGetMentorMemoriesListQuery, useLazyGetMentorMemoriesListQuery, useGetAllMentorMemoriesQuery, useLazyGetAllMentorMemoriesQuery, useCreateMentorMemoryMutation, useUpdateMentorMemoryMutation, useDeleteMentorMemoryMutation, useGetMemoryCategoriesAdminQuery, useLazyGetMemoryCategoriesAdminQuery, useCreateMemoryCategoryMutation, useUpdateMemoryCategoryMutation, useDeleteMemoryCategoryMutation, useGetMemsearchConfigQuery, useLazyGetMemsearchConfigQuery, useUpdateMemsearchConfigMutation, useGetMemsearchStatusQuery, useLazyGetMemsearchStatusQuery, } = memoryApiSlice;
44507
44625
 
44508
44626
  const MCP_REDUCER_PATH = 'mcpApiSlice';
44509
44627
  const MCP_ENDPOINTS = {
@@ -47544,6 +47662,7 @@ exports.tenantApiSlice = tenantApiSlice;
47544
47662
  exports.tenantLogoApiSlice = tenantLogoApiSlice;
47545
47663
  exports.toolsApiSlice = toolsApiSlice;
47546
47664
  exports.trainingDocumentsApiSlice = trainingDocumentsApiSlice;
47665
+ exports.unwrapApiTokenList = unwrapApiTokenList;
47547
47666
  exports.useActivateWorkflowMutation = useActivateWorkflowMutation;
47548
47667
  exports.useAddEvalDatasetItemsMutation = useAddEvalDatasetItemsMutation;
47549
47668
  exports.useAddPinnedMessageMutation = useAddPinnedMessageMutation;
@@ -47709,6 +47828,7 @@ exports.useExportChatHistoryMutation = useExportChatHistoryMutation;
47709
47828
  exports.useExportEvalRunMutation = useExportEvalRunMutation;
47710
47829
  exports.useForkMentorMutation = useForkMentorMutation;
47711
47830
  exports.useGetAccessTimeHeatmapQuery = useGetAccessTimeHeatmapQuery;
47831
+ exports.useGetAccessibleUsersQuery = useGetAccessibleUsersQuery;
47712
47832
  exports.useGetAccountBillingInfoQuery = useGetAccountBillingInfoQuery;
47713
47833
  exports.useGetAdminProjectDetailsQuery = useGetAdminProjectDetailsQuery;
47714
47834
  exports.useGetAdminProjectsQuery = useGetAdminProjectsQuery;
@@ -47718,6 +47838,9 @@ exports.useGetAgentSkillResourceQuery = useGetAgentSkillResourceQuery;
47718
47838
  exports.useGetAgentSkillResourcesQuery = useGetAgentSkillResourcesQuery;
47719
47839
  exports.useGetAgentSkillsQuery = useGetAgentSkillsQuery;
47720
47840
  exports.useGetAiSearchMentorsQuery = useGetAiSearchMentorsQuery;
47841
+ exports.useGetAllMentorMemoriesQuery = useGetAllMentorMemoriesQuery;
47842
+ exports.useGetApiKeyFieldPermissionsQuery = useGetApiKeyFieldPermissionsQuery;
47843
+ exports.useGetApiKeyQuery = useGetApiKeyQuery;
47721
47844
  exports.useGetApiKeysQuery = useGetApiKeysQuery;
47722
47845
  exports.useGetAppTokensMutation = useGetAppTokensMutation;
47723
47846
  exports.useGetApplicationAdminDetailQuery = useGetApplicationAdminDetailQuery;
@@ -47960,12 +48083,15 @@ exports.useJoinTenantMutation = useJoinTenantMutation;
47960
48083
  exports.useLazyCheckAccessQuery = useLazyCheckAccessQuery;
47961
48084
  exports.useLazyCheckAccessUnscopedQuery = useLazyCheckAccessUnscopedQuery;
47962
48085
  exports.useLazyConnectedServicesCallbackQuery = useLazyConnectedServicesCallbackQuery;
48086
+ exports.useLazyGetAccessibleUsersQuery = useLazyGetAccessibleUsersQuery;
47963
48087
  exports.useLazyGetAccountBillingInfoQuery = useLazyGetAccountBillingInfoQuery;
47964
48088
  exports.useLazyGetAdminProjectDetailsQuery = useLazyGetAdminProjectDetailsQuery;
47965
48089
  exports.useLazyGetAdminProjectsQuery = useLazyGetAdminProjectsQuery;
47966
48090
  exports.useLazyGetAgentConfigQuery = useLazyGetAgentConfigQuery;
47967
48091
  exports.useLazyGetAgentSkillResourcesQuery = useLazyGetAgentSkillResourcesQuery;
47968
48092
  exports.useLazyGetAgentSkillsQuery = useLazyGetAgentSkillsQuery;
48093
+ exports.useLazyGetAllMentorMemoriesQuery = useLazyGetAllMentorMemoriesQuery;
48094
+ exports.useLazyGetApiKeyQuery = useLazyGetApiKeyQuery;
47969
48095
  exports.useLazyGetApiKeysQuery = useLazyGetApiKeysQuery;
47970
48096
  exports.useLazyGetApplicationAdminDetailQuery = useLazyGetApplicationAdminDetailQuery;
47971
48097
  exports.useLazyGetApplicationAttachmentFileQuery = useLazyGetApplicationAttachmentFileQuery;
@@ -48228,6 +48354,7 @@ exports.useUpdateAdminProjectMutation = useUpdateAdminProjectMutation;
48228
48354
  exports.useUpdateAgentConfigMutation = useUpdateAgentConfigMutation;
48229
48355
  exports.useUpdateAgentSkillMutation = useUpdateAgentSkillMutation;
48230
48356
  exports.useUpdateAgentSkillResourceMutation = useUpdateAgentSkillResourceMutation;
48357
+ exports.useUpdateApiKeyMutation = useUpdateApiKeyMutation;
48231
48358
  exports.useUpdateApplicationFormMutation = useUpdateApplicationFormMutation;
48232
48359
  exports.useUpdateApplicationMutation = useUpdateApplicationMutation;
48233
48360
  exports.useUpdateApplicationNoteMutation = useUpdateApplicationNoteMutation;