@iblai/data-layer 1.38.1 → 1.38.2

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
@@ -39085,10 +39085,13 @@ exports.SERVICES = void 0;
39085
39085
  const NEVER_RETRY_STATUSES = [400, 401, 403];
39086
39086
 
39087
39087
  // Backend contract: ibl_ai_mentor/views/spend_cap_views.py.
39088
- // Spend caps exist at three scopes, all under /api/ai-mentor/orgs/{org}/:
39088
+ // Spend caps exist at four scopes, all under /api/ai-mentor/orgs/{org}/:
39089
39089
  // 1. Tenant singleton — spend-caps/tenant/
39090
39090
  // 2. Agent singleton — agents/{mentor_unique_id}/spend-cap/
39091
39091
  // 3. Per-user-per-agent — agents/{mentor_unique_id}/spend-caps/users/{username}/
39092
+ // 4. Per-user (all agents) — spend-caps/users/{username}/ (iblai-platform#2513)
39093
+ // plus the tenant default for newly joined users at spend-caps/users/default/
39094
+ // (a config template, not a cap row — registered before the {username} route).
39092
39095
  // A read-only learner-safe status summary lives at spend-caps/status/{user_id}/.
39093
39096
  // The `mentors/` spellings are deprecated aliases; only `agents/` is used here.
39094
39097
  const SPEND_CAPS_REDUCER_PATH = 'spendCapsApiSlice';
@@ -39105,6 +39108,9 @@ const agentUserSpendCapsPath = (org, mentorId) => `/api/ai-mentor/orgs/${encodeP
39105
39108
  const userSpendCapPath = (org, mentorId, username) => `${agentUserSpendCapsPath(org, mentorId)}${encodePathSegment$3(username)}/`;
39106
39109
  const spendCapStatusPath = (org, userId) => `/api/ai-mentor/orgs/${encodePathSegment$3(org)}/spend-caps/status/${encodePathSegment$3(userId)}/`;
39107
39110
  const agentSpendCapsListPath = (org) => `/api/ai-mentor/orgs/${encodePathSegment$3(org)}/spend-caps/agents/`;
39111
+ const tenantUserSpendCapsPath = (org) => `/api/ai-mentor/orgs/${encodePathSegment$3(org)}/spend-caps/users/`;
39112
+ const tenantUserSpendCapPath = (org, username) => `${tenantUserSpendCapsPath(org)}${encodePathSegment$3(username)}/`;
39113
+ const newUserSpendCapDefaultPath = (org) => `${tenantUserSpendCapsPath(org)}default/`;
39108
39114
  const SPEND_CAPS_ENDPOINTS = {
39109
39115
  GET_TENANT_SPEND_CAP: {
39110
39116
  service: exports.SERVICES.DM,
@@ -39150,6 +39156,34 @@ const SPEND_CAPS_ENDPOINTS = {
39150
39156
  service: exports.SERVICES.DM,
39151
39157
  path: userSpendCapPath,
39152
39158
  },
39159
+ LIST_TENANT_USER_SPEND_CAPS: {
39160
+ service: exports.SERVICES.DM,
39161
+ path: tenantUserSpendCapsPath,
39162
+ },
39163
+ GET_TENANT_USER_SPEND_CAP: {
39164
+ service: exports.SERVICES.DM,
39165
+ path: tenantUserSpendCapPath,
39166
+ },
39167
+ UPSERT_TENANT_USER_SPEND_CAP: {
39168
+ service: exports.SERVICES.DM,
39169
+ path: tenantUserSpendCapPath,
39170
+ },
39171
+ DELETE_TENANT_USER_SPEND_CAP: {
39172
+ service: exports.SERVICES.DM,
39173
+ path: tenantUserSpendCapPath,
39174
+ },
39175
+ GET_NEW_USER_SPEND_CAP_DEFAULT: {
39176
+ service: exports.SERVICES.DM,
39177
+ path: newUserSpendCapDefaultPath,
39178
+ },
39179
+ UPSERT_NEW_USER_SPEND_CAP_DEFAULT: {
39180
+ service: exports.SERVICES.DM,
39181
+ path: newUserSpendCapDefaultPath,
39182
+ },
39183
+ DELETE_NEW_USER_SPEND_CAP_DEFAULT: {
39184
+ service: exports.SERVICES.DM,
39185
+ path: newUserSpendCapDefaultPath,
39186
+ },
39153
39187
  GET_SPEND_CAP_STATUS: {
39154
39188
  service: exports.SERVICES.DM,
39155
39189
  path: spendCapStatusPath,
@@ -39161,6 +39195,9 @@ const SPEND_CAPS_QUERY_KEYS = {
39161
39195
  AGENT_SPEND_CAPS_LIST: 'AGENT_SPEND_CAPS_LIST',
39162
39196
  AGENT_USER_SPEND_CAPS: 'AGENT_USER_SPEND_CAPS',
39163
39197
  USER_SPEND_CAP: 'USER_SPEND_CAP',
39198
+ TENANT_USER_SPEND_CAPS: 'TENANT_USER_SPEND_CAPS',
39199
+ TENANT_USER_SPEND_CAP: 'TENANT_USER_SPEND_CAP',
39200
+ NEW_USER_SPEND_CAP_DEFAULT: 'NEW_USER_SPEND_CAP_DEFAULT',
39164
39201
  SPEND_CAP_STATUS: 'SPEND_CAP_STATUS',
39165
39202
  };
39166
39203
 
@@ -47899,6 +47936,9 @@ const spendCapsApiSlice = react.createApi({
47899
47936
  SPEND_CAPS_QUERY_KEYS.AGENT_SPEND_CAPS_LIST,
47900
47937
  SPEND_CAPS_QUERY_KEYS.AGENT_USER_SPEND_CAPS,
47901
47938
  SPEND_CAPS_QUERY_KEYS.USER_SPEND_CAP,
47939
+ SPEND_CAPS_QUERY_KEYS.TENANT_USER_SPEND_CAPS,
47940
+ SPEND_CAPS_QUERY_KEYS.TENANT_USER_SPEND_CAP,
47941
+ SPEND_CAPS_QUERY_KEYS.NEW_USER_SPEND_CAP_DEFAULT,
47902
47942
  SPEND_CAPS_QUERY_KEYS.SPEND_CAP_STATUS,
47903
47943
  ],
47904
47944
  baseQuery: iblFetchBaseQuery,
@@ -48023,6 +48063,88 @@ const spendCapsApiSlice = react.createApi({
48023
48063
  SPEND_CAPS_QUERY_KEYS.SPEND_CAP_STATUS,
48024
48064
  ],
48025
48065
  }),
48066
+ // User scope: one user's spend across every agent (iblai-platform#2513).
48067
+ // A plain list ordered by username; `username`/`email` are exact-match
48068
+ // filters. Also where the rows the new-user default creates show up.
48069
+ listTenantUserSpendCaps: builder.query({
48070
+ query: (args) => {
48071
+ const params = {
48072
+ ...(args.username ? { username: args.username } : {}),
48073
+ ...(args.email ? { email: args.email } : {}),
48074
+ };
48075
+ return {
48076
+ url: SPEND_CAPS_ENDPOINTS.LIST_TENANT_USER_SPEND_CAPS.path(args.org),
48077
+ params: Object.keys(params).length > 0 ? params : undefined,
48078
+ service: SPEND_CAPS_ENDPOINTS.LIST_TENANT_USER_SPEND_CAPS.service,
48079
+ };
48080
+ },
48081
+ transformResponse: (response) => { var _a; return Array.isArray(response) ? response : ((_a = response === null || response === void 0 ? void 0 : response.results) !== null && _a !== void 0 ? _a : []); },
48082
+ providesTags: [SPEND_CAPS_QUERY_KEYS.TENANT_USER_SPEND_CAPS],
48083
+ }),
48084
+ getTenantUserSpendCap: builder.query({
48085
+ query: (args) => ({
48086
+ url: SPEND_CAPS_ENDPOINTS.GET_TENANT_USER_SPEND_CAP.path(args.org, args.username),
48087
+ service: SPEND_CAPS_ENDPOINTS.GET_TENANT_USER_SPEND_CAP.service,
48088
+ }),
48089
+ providesTags: (result, error, args) => [
48090
+ { type: SPEND_CAPS_QUERY_KEYS.TENANT_USER_SPEND_CAP, id: args.username },
48091
+ ],
48092
+ }),
48093
+ upsertTenantUserSpendCap: builder.mutation({
48094
+ query: (args) => ({
48095
+ url: SPEND_CAPS_ENDPOINTS.UPSERT_TENANT_USER_SPEND_CAP.path(args.org, args.username),
48096
+ method: 'PUT',
48097
+ body: args.formData,
48098
+ service: SPEND_CAPS_ENDPOINTS.UPSERT_TENANT_USER_SPEND_CAP.service,
48099
+ }),
48100
+ invalidatesTags: (result, error, args) => [
48101
+ { type: SPEND_CAPS_QUERY_KEYS.TENANT_USER_SPEND_CAP, id: args.username },
48102
+ SPEND_CAPS_QUERY_KEYS.TENANT_USER_SPEND_CAPS,
48103
+ SPEND_CAPS_QUERY_KEYS.SPEND_CAP_STATUS,
48104
+ ],
48105
+ }),
48106
+ deleteTenantUserSpendCap: builder.mutation({
48107
+ query: (args) => ({
48108
+ url: SPEND_CAPS_ENDPOINTS.DELETE_TENANT_USER_SPEND_CAP.path(args.org, args.username),
48109
+ method: 'DELETE',
48110
+ service: SPEND_CAPS_ENDPOINTS.DELETE_TENANT_USER_SPEND_CAP.service,
48111
+ }),
48112
+ invalidatesTags: (result, error, args) => [
48113
+ { type: SPEND_CAPS_QUERY_KEYS.TENANT_USER_SPEND_CAP, id: args.username },
48114
+ SPEND_CAPS_QUERY_KEYS.TENANT_USER_SPEND_CAPS,
48115
+ SPEND_CAPS_QUERY_KEYS.SPEND_CAP_STATUS,
48116
+ ],
48117
+ }),
48118
+ // Never 404s: with nothing configured it returns the registered default
48119
+ // (`enabled: false`). Only read at join time, so it does not touch the
48120
+ // status or the per-user rows.
48121
+ getNewUserSpendCapDefault: builder.query({
48122
+ query: (args) => ({
48123
+ url: SPEND_CAPS_ENDPOINTS.GET_NEW_USER_SPEND_CAP_DEFAULT.path(args.org),
48124
+ service: SPEND_CAPS_ENDPOINTS.GET_NEW_USER_SPEND_CAP_DEFAULT.service,
48125
+ }),
48126
+ providesTags: [SPEND_CAPS_QUERY_KEYS.NEW_USER_SPEND_CAP_DEFAULT],
48127
+ }),
48128
+ // Full replace (200, never 201): the body must carry every field.
48129
+ upsertNewUserSpendCapDefault: builder.mutation({
48130
+ query: (args) => ({
48131
+ url: SPEND_CAPS_ENDPOINTS.UPSERT_NEW_USER_SPEND_CAP_DEFAULT.path(args.org),
48132
+ method: 'PUT',
48133
+ body: args.formData,
48134
+ service: SPEND_CAPS_ENDPOINTS.UPSERT_NEW_USER_SPEND_CAP_DEFAULT.service,
48135
+ }),
48136
+ invalidatesTags: [SPEND_CAPS_QUERY_KEYS.NEW_USER_SPEND_CAP_DEFAULT],
48137
+ }),
48138
+ // Clears the platform override so the tenant falls back to the global
48139
+ // default (off). A PUT with `enabled: false` keeps the values instead.
48140
+ deleteNewUserSpendCapDefault: builder.mutation({
48141
+ query: (args) => ({
48142
+ url: SPEND_CAPS_ENDPOINTS.DELETE_NEW_USER_SPEND_CAP_DEFAULT.path(args.org),
48143
+ method: 'DELETE',
48144
+ service: SPEND_CAPS_ENDPOINTS.DELETE_NEW_USER_SPEND_CAP_DEFAULT.service,
48145
+ }),
48146
+ invalidatesTags: [SPEND_CAPS_QUERY_KEYS.NEW_USER_SPEND_CAP_DEFAULT],
48147
+ }),
48026
48148
  getSpendCapStatus: builder.query({
48027
48149
  query: (args) => ({
48028
48150
  url: SPEND_CAPS_ENDPOINTS.GET_SPEND_CAP_STATUS.path(args.org, args.userId),
@@ -48033,7 +48155,7 @@ const spendCapsApiSlice = react.createApi({
48033
48155
  }),
48034
48156
  }),
48035
48157
  });
48036
- const { useGetTenantSpendCapQuery, useLazyGetTenantSpendCapQuery, useUpsertTenantSpendCapMutation, useDeleteTenantSpendCapMutation, useGetAgentSpendCapQuery, useLazyGetAgentSpendCapQuery, useUpsertAgentSpendCapMutation, useDeleteAgentSpendCapMutation, useListAgentSpendCapsQuery, useLazyListAgentSpendCapsQuery, useListAgentUserSpendCapsQuery, useLazyListAgentUserSpendCapsQuery, useGetUserSpendCapQuery, useLazyGetUserSpendCapQuery, useUpsertUserSpendCapMutation, useDeleteUserSpendCapMutation, useGetSpendCapStatusQuery, useLazyGetSpendCapStatusQuery, } = spendCapsApiSlice;
48158
+ const { useGetTenantSpendCapQuery, useLazyGetTenantSpendCapQuery, useUpsertTenantSpendCapMutation, useDeleteTenantSpendCapMutation, useGetAgentSpendCapQuery, useLazyGetAgentSpendCapQuery, useUpsertAgentSpendCapMutation, useDeleteAgentSpendCapMutation, useListAgentSpendCapsQuery, useLazyListAgentSpendCapsQuery, useListAgentUserSpendCapsQuery, useLazyListAgentUserSpendCapsQuery, useGetUserSpendCapQuery, useLazyGetUserSpendCapQuery, useUpsertUserSpendCapMutation, useDeleteUserSpendCapMutation, useListTenantUserSpendCapsQuery, useLazyListTenantUserSpendCapsQuery, useGetTenantUserSpendCapQuery, useLazyGetTenantUserSpendCapQuery, useUpsertTenantUserSpendCapMutation, useDeleteTenantUserSpendCapMutation, useGetNewUserSpendCapDefaultQuery, useLazyGetNewUserSpendCapDefaultQuery, useUpsertNewUserSpendCapDefaultMutation, useDeleteNewUserSpendCapDefaultMutation, useGetSpendCapStatusQuery, useLazyGetSpendCapStatusQuery, } = spendCapsApiSlice;
48037
48159
 
48038
48160
  /**
48039
48161
  * True when `body` is a spend-cap-exceeded error body — an object whose
@@ -50751,6 +50873,7 @@ exports.useDeleteMentorMutation = useDeleteMentorMutation;
50751
50873
  exports.useDeleteMentorSkillAssignmentMutation = useDeleteMentorSkillAssignmentMutation;
50752
50874
  exports.useDeleteMessageMutation = useDeleteMessageMutation;
50753
50875
  exports.useDeleteModerationLogMutation = useDeleteModerationLogMutation;
50876
+ exports.useDeleteNewUserSpendCapDefaultMutation = useDeleteNewUserSpendCapDefaultMutation;
50754
50877
  exports.useDeletePeriodicAgentMutation = useDeletePeriodicAgentMutation;
50755
50878
  exports.useDeletePlatformConfigurationMutation = useDeletePlatformConfigurationMutation;
50756
50879
  exports.useDeletePlatformImageAssetMutation = useDeletePlatformImageAssetMutation;
@@ -50767,6 +50890,7 @@ exports.useDeleteStudioCourseMutation = useDeleteStudioCourseMutation;
50767
50890
  exports.useDeleteSupportTicketMessageMutation = useDeleteSupportTicketMessageMutation;
50768
50891
  exports.useDeleteSupportTicketMutation = useDeleteSupportTicketMutation;
50769
50892
  exports.useDeleteTenantSpendCapMutation = useDeleteTenantSpendCapMutation;
50893
+ exports.useDeleteTenantUserSpendCapMutation = useDeleteTenantUserSpendCapMutation;
50770
50894
  exports.useDeleteTrainingDocumentMutation = useDeleteTrainingDocumentMutation;
50771
50895
  exports.useDeleteUserEducationMutation = useDeleteUserEducationMutation;
50772
50896
  exports.useDeleteUserExperienceMutation = useDeleteUserExperienceMutation;
@@ -50926,6 +51050,7 @@ exports.useGetModelCostsQuery = useGetModelCostsQuery;
50926
51050
  exports.useGetModerationLogsQuery = useGetModerationLogsQuery;
50927
51051
  exports.useGetMostDiscussedTopicsQuery = useGetMostDiscussedTopicsQuery;
50928
51052
  exports.useGetMySubscriptionsQuery = useGetMySubscriptionsQuery;
51053
+ exports.useGetNewUserSpendCapDefaultQuery = useGetNewUserSpendCapDefaultQuery;
50929
51054
  exports.useGetNodeTypesQuery = useGetNodeTypesQuery;
50930
51055
  exports.useGetNotificationContextQuery = useGetNotificationContextQuery;
50931
51056
  exports.useGetNotificationsCountQuery = useGetNotificationsCountQuery;
@@ -51010,6 +51135,7 @@ exports.useGetTenantChatPrivacyConfigQuery = useGetTenantChatPrivacyConfigQuery;
51010
51135
  exports.useGetTenantCostQuery = useGetTenantCostQuery;
51011
51136
  exports.useGetTenantMetadataQuery = useGetTenantMetadataQuery;
51012
51137
  exports.useGetTenantSpendCapQuery = useGetTenantSpendCapQuery;
51138
+ exports.useGetTenantUserSpendCapQuery = useGetTenantUserSpendCapQuery;
51013
51139
  exports.useGetToolsQuery = useGetToolsQuery;
51014
51140
  exports.useGetTopStudentsByChatMessagesQuery = useGetTopStudentsByChatMessagesQuery;
51015
51141
  exports.useGetTopicOverviewQuery = useGetTopicOverviewQuery;
@@ -51180,6 +51306,7 @@ exports.useLazyGetMentorSummariesQuery = useLazyGetMentorSummariesQuery;
51180
51306
  exports.useLazyGetMentorsQuery = useLazyGetMentorsQuery;
51181
51307
  exports.useLazyGetModerationLogsQuery = useLazyGetModerationLogsQuery;
51182
51308
  exports.useLazyGetMySubscriptionsQuery = useLazyGetMySubscriptionsQuery;
51309
+ exports.useLazyGetNewUserSpendCapDefaultQuery = useLazyGetNewUserSpendCapDefaultQuery;
51183
51310
  exports.useLazyGetNodeTypesQuery = useLazyGetNodeTypesQuery;
51184
51311
  exports.useLazyGetNotificationContextQuery = useLazyGetNotificationContextQuery;
51185
51312
  exports.useLazyGetNotificationsCountQuery = useLazyGetNotificationsCountQuery;
@@ -51246,6 +51373,7 @@ exports.useLazyGetTemplatesQuery = useLazyGetTemplatesQuery;
51246
51373
  exports.useLazyGetTenantChatPrivacyConfigQuery = useLazyGetTenantChatPrivacyConfigQuery;
51247
51374
  exports.useLazyGetTenantMetadataQuery = useLazyGetTenantMetadataQuery;
51248
51375
  exports.useLazyGetTenantSpendCapQuery = useLazyGetTenantSpendCapQuery;
51376
+ exports.useLazyGetTenantUserSpendCapQuery = useLazyGetTenantUserSpendCapQuery;
51249
51377
  exports.useLazyGetToolsQuery = useLazyGetToolsQuery;
51250
51378
  exports.useLazyGetTrainingDocumentRetrainScheduleQuery = useLazyGetTrainingDocumentRetrainScheduleQuery;
51251
51379
  exports.useLazyGetTrainingDocumentsQuery = useLazyGetTrainingDocumentsQuery;
@@ -51310,6 +51438,7 @@ exports.useLazyListOwnApplicationsQuery = useLazyListOwnApplicationsQuery;
51310
51438
  exports.useLazyListPaywallsQuery = useLazyListPaywallsQuery;
51311
51439
  exports.useLazyListPricesQuery = useLazyListPricesQuery;
51312
51440
  exports.useLazyListSubscribersQuery = useLazyListSubscribersQuery;
51441
+ exports.useLazyListTenantUserSpendCapsQuery = useLazyListTenantUserSpendCapsQuery;
51313
51442
  exports.useLazyListVirtualMachineNetworkPoliciesQuery = useLazyListVirtualMachineNetworkPoliciesQuery;
51314
51443
  exports.useLazyListVirtualMachineSecretsQuery = useLazyListVirtualMachineSecretsQuery;
51315
51444
  exports.useLazyPlatformUserGroupsQuery = useLazyPlatformUserGroupsQuery;
@@ -51338,6 +51467,7 @@ exports.useListOwnApplicationsQuery = useListOwnApplicationsQuery;
51338
51467
  exports.useListPaywallsQuery = useListPaywallsQuery;
51339
51468
  exports.useListPricesQuery = useListPricesQuery;
51340
51469
  exports.useListSubscribersQuery = useListSubscribersQuery;
51470
+ exports.useListTenantUserSpendCapsQuery = useListTenantUserSpendCapsQuery;
51341
51471
  exports.useListVirtualMachineNetworkPoliciesQuery = useListVirtualMachineNetworkPoliciesQuery;
51342
51472
  exports.useListVirtualMachineSecretsQuery = useListVirtualMachineSecretsQuery;
51343
51473
  exports.useMarkAllAsReadMutation = useMarkAllAsReadMutation;
@@ -51478,7 +51608,9 @@ exports.useUploadStudioCourseAssetMutation = useUploadStudioCourseAssetMutation;
51478
51608
  exports.useUploadStudioCourseVideoMutation = useUploadStudioCourseVideoMutation;
51479
51609
  exports.useUploadStudioScormPackageMutation = useUploadStudioScormPackageMutation;
51480
51610
  exports.useUpsertAgentSpendCapMutation = useUpsertAgentSpendCapMutation;
51611
+ exports.useUpsertNewUserSpendCapDefaultMutation = useUpsertNewUserSpendCapDefaultMutation;
51481
51612
  exports.useUpsertTenantSpendCapMutation = useUpsertTenantSpendCapMutation;
51613
+ exports.useUpsertTenantUserSpendCapMutation = useUpsertTenantUserSpendCapMutation;
51482
51614
  exports.useUpsertUserSpendCapMutation = useUpsertUserSpendCapMutation;
51483
51615
  exports.useUserLlmCostByModel = useUserLlmCostByModel;
51484
51616
  exports.useUserLlmCostByService = useUserLlmCostByService;