@iblai/data-layer 1.12.6 → 1.12.7

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
@@ -39055,6 +39055,86 @@ exports.SERVICES = void 0;
39055
39055
  SERVICES["STUDIO"] = "STUDIO";
39056
39056
  })(exports.SERVICES || (exports.SERVICES = {}));
39057
39057
 
39058
+ // Backend contract: ibl_ai_mentor/views/spend_cap_views.py.
39059
+ // Spend caps exist at three scopes, all under /api/ai-mentor/orgs/{org}/:
39060
+ // 1. Tenant singleton — spend-caps/tenant/
39061
+ // 2. Agent singleton — agents/{mentor_unique_id}/spend-cap/
39062
+ // 3. Per-user-per-agent — agents/{mentor_unique_id}/spend-caps/users/{username}/
39063
+ // A read-only learner-safe status summary lives at spend-caps/status/{user_id}/.
39064
+ // The `mentors/` spellings are deprecated aliases; only `agents/` is used here.
39065
+ const SPEND_CAPS_REDUCER_PATH = 'spendCapsApiSlice';
39066
+ /**
39067
+ * Error code returned (HTTP 429 body / WebSocket frame) when a hard-block
39068
+ * spend cap is exceeded. Distinguishes a spend-cap block from a genuine
39069
+ * provider rate limit, which also uses status 429.
39070
+ */
39071
+ const SPEND_CAP_EXCEEDED_ERROR_CODE = 'spend_cap_exceeded';
39072
+ const encodePathSegment$1 = (value) => encodeURIComponent(value);
39073
+ const tenantSpendCapPath = (org) => `/api/ai-mentor/orgs/${encodePathSegment$1(org)}/spend-caps/tenant/`;
39074
+ const agentSpendCapPath = (org, mentorId) => `/api/ai-mentor/orgs/${encodePathSegment$1(org)}/agents/${encodePathSegment$1(mentorId)}/spend-cap/`;
39075
+ const agentUserSpendCapsPath = (org, mentorId) => `/api/ai-mentor/orgs/${encodePathSegment$1(org)}/agents/${encodePathSegment$1(mentorId)}/spend-caps/users/`;
39076
+ const userSpendCapPath = (org, mentorId, username) => `${agentUserSpendCapsPath(org, mentorId)}${encodePathSegment$1(username)}/`;
39077
+ const spendCapStatusPath = (org, userId) => `/api/ai-mentor/orgs/${encodePathSegment$1(org)}/spend-caps/status/${encodePathSegment$1(userId)}/`;
39078
+ const agentSpendCapsListPath = (org) => `/api/ai-mentor/orgs/${encodePathSegment$1(org)}/spend-caps/agents/`;
39079
+ const SPEND_CAPS_ENDPOINTS = {
39080
+ GET_TENANT_SPEND_CAP: {
39081
+ service: exports.SERVICES.DM,
39082
+ path: tenantSpendCapPath,
39083
+ },
39084
+ UPSERT_TENANT_SPEND_CAP: {
39085
+ service: exports.SERVICES.DM,
39086
+ path: tenantSpendCapPath,
39087
+ },
39088
+ DELETE_TENANT_SPEND_CAP: {
39089
+ service: exports.SERVICES.DM,
39090
+ path: tenantSpendCapPath,
39091
+ },
39092
+ LIST_AGENT_SPEND_CAPS: {
39093
+ service: exports.SERVICES.DM,
39094
+ path: agentSpendCapsListPath,
39095
+ },
39096
+ GET_AGENT_SPEND_CAP: {
39097
+ service: exports.SERVICES.DM,
39098
+ path: agentSpendCapPath,
39099
+ },
39100
+ UPSERT_AGENT_SPEND_CAP: {
39101
+ service: exports.SERVICES.DM,
39102
+ path: agentSpendCapPath,
39103
+ },
39104
+ DELETE_AGENT_SPEND_CAP: {
39105
+ service: exports.SERVICES.DM,
39106
+ path: agentSpendCapPath,
39107
+ },
39108
+ LIST_AGENT_USER_SPEND_CAPS: {
39109
+ service: exports.SERVICES.DM,
39110
+ path: agentUserSpendCapsPath,
39111
+ },
39112
+ GET_USER_SPEND_CAP: {
39113
+ service: exports.SERVICES.DM,
39114
+ path: userSpendCapPath,
39115
+ },
39116
+ UPSERT_USER_SPEND_CAP: {
39117
+ service: exports.SERVICES.DM,
39118
+ path: userSpendCapPath,
39119
+ },
39120
+ DELETE_USER_SPEND_CAP: {
39121
+ service: exports.SERVICES.DM,
39122
+ path: userSpendCapPath,
39123
+ },
39124
+ GET_SPEND_CAP_STATUS: {
39125
+ service: exports.SERVICES.DM,
39126
+ path: spendCapStatusPath,
39127
+ },
39128
+ };
39129
+ const SPEND_CAPS_QUERY_KEYS = {
39130
+ TENANT_SPEND_CAP: 'TENANT_SPEND_CAP',
39131
+ AGENT_SPEND_CAP: 'AGENT_SPEND_CAP',
39132
+ AGENT_SPEND_CAPS_LIST: 'AGENT_SPEND_CAPS_LIST',
39133
+ AGENT_USER_SPEND_CAPS: 'AGENT_USER_SPEND_CAPS',
39134
+ USER_SPEND_CAP: 'USER_SPEND_CAP',
39135
+ SPEND_CAP_STATUS: 'SPEND_CAP_STATUS',
39136
+ };
39137
+
39058
39138
  class Config {
39059
39139
  }
39060
39140
  Config.legacyLmsUrl = 'https://learn.iblai.app';
@@ -39185,6 +39265,16 @@ const getHeaders = async (service) => {
39185
39265
  };
39186
39266
  /** Status codes that should not be retried for queryFn endpoints. */
39187
39267
  const QUERYFN_NON_RETRYABLE_STATUSES = [401, 403, 500];
39268
+ /**
39269
+ * True when an error body carries the spend-cap `spend_cap_exceeded` code.
39270
+ * A spend-cap block returns HTTP 429, but unlike a genuine provider rate
39271
+ * limit (also 429) it will not clear on its own within a retry window, so
39272
+ * retrying only wastes ~30s of backoff. Keyed on the body's error_code —
39273
+ * NOT on status 429 alone — so real rate limits keep retrying.
39274
+ */
39275
+ const hasSpendCapExceededErrorCode = (body) => typeof body === 'object' &&
39276
+ body !== null &&
39277
+ body.error_code === SPEND_CAP_EXCEEDED_ERROR_CODE;
39188
39278
  /** Default max retries for queryFn endpoints. */
39189
39279
  const QUERYFN_MAX_RETRIES = 5;
39190
39280
  /** Base delay in ms for exponential backoff. */
@@ -39200,6 +39290,7 @@ const buildEndpointFromService = (service, serviceFn, options) => {
39200
39290
  const expectedErrorStatuses = (_b = options === null || options === void 0 ? void 0 : options.expectedErrorStatuses) !== null && _b !== void 0 ? _b : [];
39201
39291
  return {
39202
39292
  async queryFn(args) {
39293
+ var _a;
39203
39294
  let lastError;
39204
39295
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
39205
39296
  try {
@@ -39212,10 +39303,11 @@ const buildEndpointFromService = (service, serviceFn, options) => {
39212
39303
  catch (err) {
39213
39304
  lastError = err;
39214
39305
  const status = err === null || err === void 0 ? void 0 : err.status;
39215
- // Don't retry auth errors or statuses the endpoint expects as an
39216
- // empty state (fail fast — no retry storm).
39306
+ // Don't retry auth errors, statuses the endpoint expects as an
39307
+ // empty state, or a spend-cap block (fail fast — no retry storm).
39217
39308
  if (QUERYFN_NON_RETRYABLE_STATUSES.includes(status) ||
39218
- expectedErrorStatuses.includes(status)) {
39309
+ expectedErrorStatuses.includes(status) ||
39310
+ hasSpendCapExceededErrorCode((_a = err === null || err === void 0 ? void 0 : err.body) !== null && _a !== void 0 ? _a : err === null || err === void 0 ? void 0 : err.data)) {
39219
39311
  break;
39220
39312
  }
39221
39313
  // If we have retries left, wait with exponential backoff
@@ -39354,7 +39446,10 @@ const withNonRetryableErrors = (query$1) => async (args, api, extraOptions) => {
39354
39446
  },
39355
39447
  };
39356
39448
  }
39357
- if (result.error && NON_RETRYABLE_STATUS_CODES.includes(result.error.status)) {
39449
+ if (result.error &&
39450
+ (NON_RETRYABLE_STATUS_CODES.includes(result.error.status) ||
39451
+ // A 429 spend-cap block is a hard stop, not a transient rate limit.
39452
+ hasSpendCapExceededErrorCode(result.error.data))) {
39358
39453
  query.retry.fail(result.error);
39359
39454
  }
39360
39455
  return result;
@@ -41978,6 +42073,10 @@ const BILLING_CUSTOM_ENDPOINTS = {
41978
42073
  path: '/api/billing/account/',
41979
42074
  service: exports.SERVICES.DM,
41980
42075
  },
42076
+ GET_CREDIT_TRANSACTIONS: {
42077
+ path: '/api/billing/transactions/',
42078
+ service: exports.SERVICES.DM,
42079
+ },
41981
42080
  TRIGGER_AUTO_RECHARGE: {
41982
42081
  path: '/api/billing/auto-recharge/trigger/',
41983
42082
  service: exports.SERVICES.DM,
@@ -42018,9 +42117,26 @@ const billingCustomSlice = react.createApi({
42018
42117
  }),
42019
42118
  providesTags: ['accountBillingInfo', 'autoRecharge', 'triggerAutoRecharge'],
42020
42119
  }),
42120
+ getCreditTransactions: builder.query({
42121
+ query: ({ platform_key, transaction_type, from_date, to_date }) => ({
42122
+ url: BILLING_CUSTOM_ENDPOINTS.GET_CREDIT_TRANSACTIONS.path,
42123
+ service: BILLING_CUSTOM_ENDPOINTS.GET_CREDIT_TRANSACTIONS.service,
42124
+ method: 'GET',
42125
+ params: {
42126
+ platform_key,
42127
+ ...(transaction_type ? { transaction_type } : {}),
42128
+ ...(from_date ? { from_date } : {}),
42129
+ ...(to_date ? { to_date } : {}),
42130
+ },
42131
+ }),
42132
+ // The endpoint is paginated (DRF envelope) but may also return a bare
42133
+ // array — normalize both to the rows.
42134
+ transformResponse: (response) => { var _a; return Array.isArray(response) ? response : ((_a = response === null || response === void 0 ? void 0 : response.results) !== null && _a !== void 0 ? _a : []); },
42135
+ providesTags: ['accountBillingInfo', 'triggerAutoRecharge'],
42136
+ }),
42021
42137
  }),
42022
42138
  });
42023
- const { useUpdateAutoRechargeInfoMutation, useGetAccountBillingInfoQuery, useLazyGetAccountBillingInfoQuery, useTriggerAutoRechargeMutation, } = billingCustomSlice;
42139
+ const { useUpdateAutoRechargeInfoMutation, useGetAccountBillingInfoQuery, useLazyGetAccountBillingInfoQuery, useGetCreditTransactionsQuery, useTriggerAutoRechargeMutation, } = billingCustomSlice;
42024
42140
 
42025
42141
  const MONETIZATION_REDUCER_PATH = 'monetizationApiSlice';
42026
42142
  const SERVICE_BASE = '/api/service/platforms';
@@ -44981,7 +45097,7 @@ const CLAW_ENDPOINTS = {
44981
45097
  * Normalize API responses that may return either a plain array or a
44982
45098
  * paginated envelope `{ results: T[] }`.
44983
45099
  */
44984
- function normalizeList$1(response) {
45100
+ function normalizeList(response) {
44985
45101
  return Array.isArray(response) ? response : response.results;
44986
45102
  }
44987
45103
  const clawApiSlice = react.createApi({
@@ -45079,7 +45195,7 @@ const clawApiSlice = react.createApi({
45079
45195
  url: CLAW_ENDPOINTS.GET_INSTANCES.path(args.org),
45080
45196
  service: CLAW_ENDPOINTS.GET_INSTANCES.service,
45081
45197
  }),
45082
- transformResponse: (response) => normalizeList$1(response),
45198
+ transformResponse: (response) => normalizeList(response),
45083
45199
  providesTags: ['ClawInstances'],
45084
45200
  }),
45085
45201
  getClawInstance: builder.query({
@@ -45304,13 +45420,6 @@ const AGENT_SKILLS_ENDPOINTS = {
45304
45420
  },
45305
45421
  };
45306
45422
 
45307
- /**
45308
- * Normalize API responses that may return either a plain array or a
45309
- * paginated envelope `{ results: T[] }`.
45310
- */
45311
- function normalizeList(response) {
45312
- return Array.isArray(response) ? response : response.results;
45313
- }
45314
45423
  const agentSkillsApiSlice = react.createApi({
45315
45424
  reducerPath: AGENT_SKILLS_REDUCER_PATH,
45316
45425
  baseQuery: iblFetchBaseQuery,
@@ -45482,6 +45591,8 @@ const agentSkillsApiSlice = react.createApi({
45482
45591
  invalidatesTags: ['AgentSkillResources'],
45483
45592
  }),
45484
45593
  // ── Mentor Skill Assignments (nested under mentor) ────────────────────
45594
+ // Returns the paginated envelope so list UIs can page on `count`;
45595
+ // bare-array responses are normalized into a single-page envelope.
45485
45596
  getMentorSkillAssignments: builder.query({
45486
45597
  query: (args) => ({
45487
45598
  url: AGENT_SKILLS_ENDPOINTS.GET_MENTOR_SKILL_ASSIGNMENTS.path(args.org, args.mentorUniqueId),
@@ -45492,7 +45603,9 @@ const agentSkillsApiSlice = react.createApi({
45492
45603
  ...(args.offset !== undefined && { offset: args.offset }),
45493
45604
  },
45494
45605
  }),
45495
- transformResponse: (response) => normalizeList(response),
45606
+ transformResponse: (response) => Array.isArray(response)
45607
+ ? { count: response.length, next: null, previous: null, results: response }
45608
+ : response,
45496
45609
  providesTags: (_result, _error, args) => [
45497
45610
  { type: 'MentorSkillAssignments', id: args.mentorUniqueId },
45498
45611
  ],
@@ -46311,6 +46424,175 @@ const gradingApiSlice = react.createApi({
46311
46424
  });
46312
46425
  const { useGetMentorGraderConfigurationQuery, useLazyGetMentorGraderConfigurationQuery, useCreateMentorGraderConfigurationMutation, useUpdateMentorGraderConfigurationMutation, useListGraderCriteriaQuery, useLazyListGraderCriteriaQuery, useGetGraderCriterionQuery, useLazyGetGraderCriterionQuery, useCreateGraderCriterionMutation, useUpdateGraderCriterionMutation, useDeleteGraderCriterionMutation, useListGradeResultsQuery, useLazyListGradeResultsQuery, useGetGradeResultQuery, useLazyGetGradeResultQuery, useOverrideGradeResultMutation, } = gradingApiSlice;
46313
46426
 
46427
+ const spendCapsApiSlice = react.createApi({
46428
+ reducerPath: SPEND_CAPS_REDUCER_PATH,
46429
+ tagTypes: [
46430
+ SPEND_CAPS_QUERY_KEYS.TENANT_SPEND_CAP,
46431
+ SPEND_CAPS_QUERY_KEYS.AGENT_SPEND_CAP,
46432
+ SPEND_CAPS_QUERY_KEYS.AGENT_SPEND_CAPS_LIST,
46433
+ SPEND_CAPS_QUERY_KEYS.AGENT_USER_SPEND_CAPS,
46434
+ SPEND_CAPS_QUERY_KEYS.USER_SPEND_CAP,
46435
+ SPEND_CAPS_QUERY_KEYS.SPEND_CAP_STATUS,
46436
+ ],
46437
+ baseQuery: iblFetchBaseQuery,
46438
+ endpoints: (builder) => ({
46439
+ getTenantSpendCap: builder.query({
46440
+ query: (args) => ({
46441
+ url: SPEND_CAPS_ENDPOINTS.GET_TENANT_SPEND_CAP.path(args.org),
46442
+ service: SPEND_CAPS_ENDPOINTS.GET_TENANT_SPEND_CAP.service,
46443
+ }),
46444
+ providesTags: [SPEND_CAPS_QUERY_KEYS.TENANT_SPEND_CAP],
46445
+ }),
46446
+ // The backend PUT is an upsert: 201 on first write, 200 on update.
46447
+ upsertTenantSpendCap: builder.mutation({
46448
+ query: (args) => ({
46449
+ url: SPEND_CAPS_ENDPOINTS.UPSERT_TENANT_SPEND_CAP.path(args.org),
46450
+ method: 'PUT',
46451
+ body: args.formData,
46452
+ service: SPEND_CAPS_ENDPOINTS.UPSERT_TENANT_SPEND_CAP.service,
46453
+ }),
46454
+ invalidatesTags: [
46455
+ SPEND_CAPS_QUERY_KEYS.TENANT_SPEND_CAP,
46456
+ SPEND_CAPS_QUERY_KEYS.SPEND_CAP_STATUS,
46457
+ ],
46458
+ }),
46459
+ deleteTenantSpendCap: builder.mutation({
46460
+ query: (args) => ({
46461
+ url: SPEND_CAPS_ENDPOINTS.DELETE_TENANT_SPEND_CAP.path(args.org),
46462
+ method: 'DELETE',
46463
+ service: SPEND_CAPS_ENDPOINTS.DELETE_TENANT_SPEND_CAP.service,
46464
+ }),
46465
+ invalidatesTags: [
46466
+ SPEND_CAPS_QUERY_KEYS.TENANT_SPEND_CAP,
46467
+ SPEND_CAPS_QUERY_KEYS.SPEND_CAP_STATUS,
46468
+ ],
46469
+ }),
46470
+ getAgentSpendCap: builder.query({
46471
+ query: (args) => ({
46472
+ url: SPEND_CAPS_ENDPOINTS.GET_AGENT_SPEND_CAP.path(args.org, args.mentorId),
46473
+ service: SPEND_CAPS_ENDPOINTS.GET_AGENT_SPEND_CAP.service,
46474
+ }),
46475
+ providesTags: (result, error, args) => [
46476
+ { type: SPEND_CAPS_QUERY_KEYS.AGENT_SPEND_CAP, id: args.mentorId },
46477
+ ],
46478
+ }),
46479
+ upsertAgentSpendCap: builder.mutation({
46480
+ query: (args) => ({
46481
+ url: SPEND_CAPS_ENDPOINTS.UPSERT_AGENT_SPEND_CAP.path(args.org, args.mentorId),
46482
+ method: 'PUT',
46483
+ body: args.formData,
46484
+ service: SPEND_CAPS_ENDPOINTS.UPSERT_AGENT_SPEND_CAP.service,
46485
+ }),
46486
+ invalidatesTags: (result, error, args) => [
46487
+ { type: SPEND_CAPS_QUERY_KEYS.AGENT_SPEND_CAP, id: args.mentorId },
46488
+ SPEND_CAPS_QUERY_KEYS.AGENT_SPEND_CAPS_LIST,
46489
+ SPEND_CAPS_QUERY_KEYS.SPEND_CAP_STATUS,
46490
+ ],
46491
+ }),
46492
+ deleteAgentSpendCap: builder.mutation({
46493
+ query: (args) => ({
46494
+ url: SPEND_CAPS_ENDPOINTS.DELETE_AGENT_SPEND_CAP.path(args.org, args.mentorId),
46495
+ method: 'DELETE',
46496
+ service: SPEND_CAPS_ENDPOINTS.DELETE_AGENT_SPEND_CAP.service,
46497
+ }),
46498
+ invalidatesTags: (result, error, args) => [
46499
+ { type: SPEND_CAPS_QUERY_KEYS.AGENT_SPEND_CAP, id: args.mentorId },
46500
+ SPEND_CAPS_QUERY_KEYS.AGENT_SPEND_CAPS_LIST,
46501
+ SPEND_CAPS_QUERY_KEYS.SPEND_CAP_STATUS,
46502
+ ],
46503
+ }),
46504
+ // Tenant-wide listing of every agent-scoped cap (no per-agent fan-out).
46505
+ // Items carry `mentor_name`/`mentor_unique_id` for display.
46506
+ listAgentSpendCaps: builder.query({
46507
+ query: (args) => ({
46508
+ url: SPEND_CAPS_ENDPOINTS.LIST_AGENT_SPEND_CAPS.path(args.org),
46509
+ params: args.mentor ? { mentor: args.mentor } : undefined,
46510
+ service: SPEND_CAPS_ENDPOINTS.LIST_AGENT_SPEND_CAPS.service,
46511
+ }),
46512
+ transformResponse: (response) => { var _a; return Array.isArray(response) ? response : ((_a = response === null || response === void 0 ? void 0 : response.results) !== null && _a !== void 0 ? _a : []); },
46513
+ providesTags: [SPEND_CAPS_QUERY_KEYS.AGENT_SPEND_CAPS_LIST],
46514
+ }),
46515
+ listAgentUserSpendCaps: builder.query({
46516
+ query: (args) => ({
46517
+ url: SPEND_CAPS_ENDPOINTS.LIST_AGENT_USER_SPEND_CAPS.path(args.org, args.mentorId),
46518
+ service: SPEND_CAPS_ENDPOINTS.LIST_AGENT_USER_SPEND_CAPS.service,
46519
+ }),
46520
+ transformResponse: (response) => { var _a; return Array.isArray(response) ? response : ((_a = response === null || response === void 0 ? void 0 : response.results) !== null && _a !== void 0 ? _a : []); },
46521
+ providesTags: (result, error, args) => [
46522
+ { type: SPEND_CAPS_QUERY_KEYS.AGENT_USER_SPEND_CAPS, id: args.mentorId },
46523
+ ],
46524
+ }),
46525
+ getUserSpendCap: builder.query({
46526
+ query: (args) => ({
46527
+ url: SPEND_CAPS_ENDPOINTS.GET_USER_SPEND_CAP.path(args.org, args.mentorId, args.username),
46528
+ service: SPEND_CAPS_ENDPOINTS.GET_USER_SPEND_CAP.service,
46529
+ }),
46530
+ providesTags: (result, error, args) => [
46531
+ { type: SPEND_CAPS_QUERY_KEYS.USER_SPEND_CAP, id: `${args.mentorId}-${args.username}` },
46532
+ ],
46533
+ }),
46534
+ upsertUserSpendCap: builder.mutation({
46535
+ query: (args) => ({
46536
+ url: SPEND_CAPS_ENDPOINTS.UPSERT_USER_SPEND_CAP.path(args.org, args.mentorId, args.username),
46537
+ method: 'PUT',
46538
+ body: args.formData,
46539
+ service: SPEND_CAPS_ENDPOINTS.UPSERT_USER_SPEND_CAP.service,
46540
+ }),
46541
+ invalidatesTags: (result, error, args) => [
46542
+ { type: SPEND_CAPS_QUERY_KEYS.USER_SPEND_CAP, id: `${args.mentorId}-${args.username}` },
46543
+ { type: SPEND_CAPS_QUERY_KEYS.AGENT_USER_SPEND_CAPS, id: args.mentorId },
46544
+ SPEND_CAPS_QUERY_KEYS.SPEND_CAP_STATUS,
46545
+ ],
46546
+ }),
46547
+ deleteUserSpendCap: builder.mutation({
46548
+ query: (args) => ({
46549
+ url: SPEND_CAPS_ENDPOINTS.DELETE_USER_SPEND_CAP.path(args.org, args.mentorId, args.username),
46550
+ method: 'DELETE',
46551
+ service: SPEND_CAPS_ENDPOINTS.DELETE_USER_SPEND_CAP.service,
46552
+ }),
46553
+ invalidatesTags: (result, error, args) => [
46554
+ { type: SPEND_CAPS_QUERY_KEYS.USER_SPEND_CAP, id: `${args.mentorId}-${args.username}` },
46555
+ { type: SPEND_CAPS_QUERY_KEYS.AGENT_USER_SPEND_CAPS, id: args.mentorId },
46556
+ SPEND_CAPS_QUERY_KEYS.SPEND_CAP_STATUS,
46557
+ ],
46558
+ }),
46559
+ getSpendCapStatus: builder.query({
46560
+ query: (args) => ({
46561
+ url: SPEND_CAPS_ENDPOINTS.GET_SPEND_CAP_STATUS.path(args.org, args.userId),
46562
+ params: args.mentor ? { mentor: args.mentor } : undefined,
46563
+ service: SPEND_CAPS_ENDPOINTS.GET_SPEND_CAP_STATUS.service,
46564
+ }),
46565
+ providesTags: [SPEND_CAPS_QUERY_KEYS.SPEND_CAP_STATUS],
46566
+ }),
46567
+ }),
46568
+ });
46569
+ const { useGetTenantSpendCapQuery, useLazyGetTenantSpendCapQuery, useUpsertTenantSpendCapMutation, useDeleteTenantSpendCapMutation, useGetAgentSpendCapQuery, useLazyGetAgentSpendCapQuery, useUpsertAgentSpendCapMutation, useDeleteAgentSpendCapMutation, useListAgentSpendCapsQuery, useLazyListAgentSpendCapsQuery, useListAgentUserSpendCapsQuery, useLazyListAgentUserSpendCapsQuery, useGetUserSpendCapQuery, useLazyGetUserSpendCapQuery, useUpsertUserSpendCapMutation, useDeleteUserSpendCapMutation, useGetSpendCapStatusQuery, useLazyGetSpendCapStatusQuery, } = spendCapsApiSlice;
46570
+
46571
+ /**
46572
+ * True when `body` is a spend-cap-exceeded error body — an object whose
46573
+ * `error_code` is `'spend_cap_exceeded'`. Works for HTTP 429 bodies and
46574
+ * WebSocket error frames alike.
46575
+ */
46576
+ const isSpendCapExceededErrorBody = (body) => typeof body === 'object' &&
46577
+ body !== null &&
46578
+ body.error_code === SPEND_CAP_EXCEEDED_ERROR_CODE;
46579
+ /**
46580
+ * Extract the spend-cap-exceeded body from either a raw error body or an RTK
46581
+ * Query error shape (`{ status, data }`). Returns null for anything else.
46582
+ */
46583
+ const getSpendCapExceededError = (error) => {
46584
+ if (isSpendCapExceededErrorBody(error)) {
46585
+ return error;
46586
+ }
46587
+ if (typeof error === 'object' && error !== null && 'data' in error) {
46588
+ const data = error.data;
46589
+ if (isSpendCapExceededErrorBody(data)) {
46590
+ return data;
46591
+ }
46592
+ }
46593
+ return null;
46594
+ };
46595
+
46314
46596
  exports.recommendationPromptTypeEnum = void 0;
46315
46597
  (function (recommendationPromptTypeEnum) {
46316
46598
  recommendationPromptTypeEnum["mentors"] = "mentors";
@@ -47557,6 +47839,7 @@ const mentorReducer = {
47557
47839
  [skillsApiSlice.reducerPath]: skillsApiSlice.reducer,
47558
47840
  [supportTicketsApiSlice.reducerPath]: supportTicketsApiSlice.reducer,
47559
47841
  [gradingApiSlice.reducerPath]: gradingApiSlice.reducer,
47842
+ [spendCapsApiSlice.reducerPath]: spendCapsApiSlice.reducer,
47560
47843
  };
47561
47844
  const mentorMiddleware = [
47562
47845
  mentorApiSlice.middleware,
@@ -47618,6 +47901,7 @@ const mentorMiddleware = [
47618
47901
  skillsApiSlice.middleware,
47619
47902
  supportTicketsApiSlice.middleware,
47620
47903
  gradingApiSlice.middleware,
47904
+ spendCapsApiSlice.middleware,
47621
47905
  ];
47622
47906
 
47623
47907
  const skillsReducer = {
@@ -47660,6 +47944,7 @@ const skillsReducer = {
47660
47944
  [edxSsoApiSlice.reducerPath]: edxSsoApiSlice.reducer,
47661
47945
  [studioAuthoringApiSlice.reducerPath]: studioAuthoringApiSlice.reducer,
47662
47946
  [watchedGroupsApiSlice.reducerPath]: watchedGroupsApiSlice.reducer,
47947
+ [spendCapsApiSlice.reducerPath]: spendCapsApiSlice.reducer,
47663
47948
  [chatPrivacyApiSlice.reducerPath]: chatPrivacyApiSlice.reducer,
47664
47949
  [agentSkillsApiSlice.reducerPath]: agentSkillsApiSlice.reducer,
47665
47950
  };
@@ -47703,6 +47988,7 @@ const skillsMiddleware = [
47703
47988
  edxSsoApiSlice.middleware,
47704
47989
  studioAuthoringApiSlice.middleware,
47705
47990
  watchedGroupsApiSlice.middleware,
47991
+ spendCapsApiSlice.middleware,
47706
47992
  chatPrivacyApiSlice.middleware,
47707
47993
  agentSkillsApiSlice.middleware,
47708
47994
  ];
@@ -47793,6 +48079,10 @@ exports.PROJECTS_CUSTOM_REDUCER_PATH = PROJECTS_CUSTOM_REDUCER_PATH;
47793
48079
  exports.PROJECTS_QUERY_KEYS = PROJECTS_QUERY_KEYS;
47794
48080
  exports.QUERY_PARAMS = QUERY_PARAMS;
47795
48081
  exports.RETIREMENT_ENDPOINTS = RETIREMENT_ENDPOINTS;
48082
+ exports.SPEND_CAPS_ENDPOINTS = SPEND_CAPS_ENDPOINTS;
48083
+ exports.SPEND_CAPS_QUERY_KEYS = SPEND_CAPS_QUERY_KEYS;
48084
+ exports.SPEND_CAPS_REDUCER_PATH = SPEND_CAPS_REDUCER_PATH;
48085
+ exports.SPEND_CAP_EXCEEDED_ERROR_CODE = SPEND_CAP_EXCEEDED_ERROR_CODE;
47796
48086
  exports.STORAGE_KEYS = STORAGE_KEYS;
47797
48087
  exports.STUDIO_AUTHORING_ENDPOINTS = STUDIO_AUTHORING_ENDPOINTS;
47798
48088
  exports.SUGGESTED_PRIVACY_ENTITIES = SUGGESTED_PRIVACY_ENTITIES;
@@ -47858,12 +48148,14 @@ exports.fakeBaseQueryWithLogging = fakeBaseQueryWithLogging;
47858
48148
  exports.featureTags = featureTags;
47859
48149
  exports.filterSlashSkills = filterSlashSkills;
47860
48150
  exports.getNextRecentMessagesPageParam = getNextRecentMessagesPageParam;
48151
+ exports.getSpendCapExceededError = getSpendCapExceededError;
47861
48152
  exports.gradingApiSlice = gradingApiSlice;
47862
48153
  exports.iblFakeBaseQuery = iblFakeBaseQuery;
47863
48154
  exports.initializeDataLayer = initializeDataLayer;
47864
48155
  exports.isBaseAgentMentor = isBaseAgentMentor;
47865
48156
  exports.isPoliciesResponse = isPoliciesResponse;
47866
48157
  exports.isPrivacyBlockedError = isPrivacyBlockedError;
48158
+ exports.isSpendCapExceededErrorBody = isSpendCapExceededErrorBody;
47867
48159
  exports.llmsApiSlice = llmsApiSlice;
47868
48160
  exports.mcpApiSlice = mcpApiSlice;
47869
48161
  exports.memoryApiSlice = memoryApiSlice;
@@ -47893,6 +48185,7 @@ exports.sessionApiSlice = sessionApiSlice;
47893
48185
  exports.skillsApiSlice = skillsApiSlice;
47894
48186
  exports.skillsMiddleware = skillsMiddleware;
47895
48187
  exports.skillsReducer = skillsReducer;
48188
+ exports.spendCapsApiSlice = spendCapsApiSlice;
47896
48189
  exports.stripeApiSlice = stripeApiSlice;
47897
48190
  exports.studioAuthoringApiSlice = studioAuthoringApiSlice;
47898
48191
  exports.supportTicketsApiSlice = supportTicketsApiSlice;
@@ -48003,6 +48296,7 @@ exports.useDeactivateWorkflowMutation = useDeactivateWorkflowMutation;
48003
48296
  exports.useDeleteAdminProjectMutation = useDeleteAdminProjectMutation;
48004
48297
  exports.useDeleteAgentSkillMutation = useDeleteAgentSkillMutation;
48005
48298
  exports.useDeleteAgentSkillResourceMutation = useDeleteAgentSkillResourceMutation;
48299
+ exports.useDeleteAgentSpendCapMutation = useDeleteAgentSpendCapMutation;
48006
48300
  exports.useDeleteApiKeyMutation = useDeleteApiKeyMutation;
48007
48301
  exports.useDeleteApplicationAttachmentMutation = useDeleteApplicationAttachmentMutation;
48008
48302
  exports.useDeleteApplicationBlockMutation = useDeleteApplicationBlockMutation;
@@ -48046,10 +48340,12 @@ exports.useDeleteRecommendedPromptMutation = useDeleteRecommendedPromptMutation;
48046
48340
  exports.useDeleteStudioCourseMutation = useDeleteStudioCourseMutation;
48047
48341
  exports.useDeleteSupportTicketMessageMutation = useDeleteSupportTicketMessageMutation;
48048
48342
  exports.useDeleteSupportTicketMutation = useDeleteSupportTicketMutation;
48343
+ exports.useDeleteTenantSpendCapMutation = useDeleteTenantSpendCapMutation;
48049
48344
  exports.useDeleteTrainingDocumentMutation = useDeleteTrainingDocumentMutation;
48050
48345
  exports.useDeleteUserEducationMutation = useDeleteUserEducationMutation;
48051
48346
  exports.useDeleteUserExperienceMutation = useDeleteUserExperienceMutation;
48052
48347
  exports.useDeleteUserProjectMutation = useDeleteUserProjectMutation;
48348
+ exports.useDeleteUserSpendCapMutation = useDeleteUserSpendCapMutation;
48053
48349
  exports.useDeleteWatchedGroupMutation = useDeleteWatchedGroupMutation;
48054
48350
  exports.useDeleteWatcherMutation = useDeleteWatcherMutation;
48055
48351
  exports.useDeleteWorkflowMutation = useDeleteWorkflowMutation;
@@ -48076,6 +48372,7 @@ exports.useGetAgentSkillQuery = useGetAgentSkillQuery;
48076
48372
  exports.useGetAgentSkillResourceQuery = useGetAgentSkillResourceQuery;
48077
48373
  exports.useGetAgentSkillResourcesQuery = useGetAgentSkillResourcesQuery;
48078
48374
  exports.useGetAgentSkillsQuery = useGetAgentSkillsQuery;
48375
+ exports.useGetAgentSpendCapQuery = useGetAgentSpendCapQuery;
48079
48376
  exports.useGetAiSearchMentorsQuery = useGetAiSearchMentorsQuery;
48080
48377
  exports.useGetAllMentorMemoriesQuery = useGetAllMentorMemoriesQuery;
48081
48378
  exports.useGetApiKeyFieldPermissionsQuery = useGetApiKeyFieldPermissionsQuery;
@@ -48127,6 +48424,7 @@ exports.useGetCourseProgressQuery = useGetCourseProgressQuery;
48127
48424
  exports.useGetCredentialsListQuery = useGetCredentialsListQuery;
48128
48425
  exports.useGetCredentialsQuery = useGetCredentialsQuery;
48129
48426
  exports.useGetCredentialsSchemaQuery = useGetCredentialsSchemaQuery;
48427
+ exports.useGetCreditTransactionsQuery = useGetCreditTransactionsQuery;
48130
48428
  exports.useGetCustomDomainsQuery = useGetCustomDomainsQuery;
48131
48429
  exports.useGetCustomMentorsQuery = useGetCustomMentorsQuery;
48132
48430
  exports.useGetDatasetsQuery = useGetDatasetsQuery;
@@ -48251,6 +48549,7 @@ exports.useGetShareableLinkPublicQuery = useGetShareableLinkPublicQuery;
48251
48549
  exports.useGetShareableLinkQuery = useGetShareableLinkQuery;
48252
48550
  exports.useGetSharedSessionIdQuery = useGetSharedSessionIdQuery;
48253
48551
  exports.useGetSkillsPointsPercentileQuery = useGetSkillsPointsPercentileQuery;
48552
+ exports.useGetSpendCapStatusQuery = useGetSpendCapStatusQuery;
48254
48553
  exports.useGetStripeConnectDashboardQuery = useGetStripeConnectDashboardQuery;
48255
48554
  exports.useGetStripeConnectStatusQuery = useGetStripeConnectStatusQuery;
48256
48555
  exports.useGetStripeContextQuery = useGetStripeContextQuery;
@@ -48264,6 +48563,7 @@ exports.useGetTemplateDetailsQuery = useGetTemplateDetailsQuery;
48264
48563
  exports.useGetTemplatesQuery = useGetTemplatesQuery;
48265
48564
  exports.useGetTenantChatPrivacyConfigQuery = useGetTenantChatPrivacyConfigQuery;
48266
48565
  exports.useGetTenantMetadataQuery = useGetTenantMetadataQuery;
48566
+ exports.useGetTenantSpendCapQuery = useGetTenantSpendCapQuery;
48267
48567
  exports.useGetToolsQuery = useGetToolsQuery;
48268
48568
  exports.useGetTopStudentsByChatMessagesQuery = useGetTopStudentsByChatMessagesQuery;
48269
48569
  exports.useGetTopicOverviewQuery = useGetTopicOverviewQuery;
@@ -48305,6 +48605,7 @@ exports.useGetUserProjectsQuery = useGetUserProjectsQuery;
48305
48605
  exports.useGetUserReportedSkillsQuery = useGetUserReportedSkillsQuery;
48306
48606
  exports.useGetUserResumeQuery = useGetUserResumeQuery;
48307
48607
  exports.useGetUserSkillsPointsQuery = useGetUserSkillsPointsQuery;
48608
+ exports.useGetUserSpendCapQuery = useGetUserSpendCapQuery;
48308
48609
  exports.useGetUserTenantsQuery = useGetUserTenantsQuery;
48309
48610
  exports.useGetUsersAsAssertionsQuery = useGetUsersAsAssertionsQuery;
48310
48611
  exports.useGetUsersStatsQuery = useGetUsersStatsQuery;
@@ -48332,6 +48633,7 @@ exports.useLazyGetAdminProjectsQuery = useLazyGetAdminProjectsQuery;
48332
48633
  exports.useLazyGetAgentConfigQuery = useLazyGetAgentConfigQuery;
48333
48634
  exports.useLazyGetAgentSkillResourcesQuery = useLazyGetAgentSkillResourcesQuery;
48334
48635
  exports.useLazyGetAgentSkillsQuery = useLazyGetAgentSkillsQuery;
48636
+ exports.useLazyGetAgentSpendCapQuery = useLazyGetAgentSpendCapQuery;
48335
48637
  exports.useLazyGetAllMentorMemoriesQuery = useLazyGetAllMentorMemoriesQuery;
48336
48638
  exports.useLazyGetApiKeyQuery = useLazyGetApiKeyQuery;
48337
48639
  exports.useLazyGetApiKeysQuery = useLazyGetApiKeysQuery;
@@ -48465,6 +48767,7 @@ exports.useLazyGetShareableLinkPublicQuery = useLazyGetShareableLinkPublicQuery;
48465
48767
  exports.useLazyGetShareableLinkQuery = useLazyGetShareableLinkQuery;
48466
48768
  exports.useLazyGetSharedSessionIdQuery = useLazyGetSharedSessionIdQuery;
48467
48769
  exports.useLazyGetSkillsPointsPercentileQuery = useLazyGetSkillsPointsPercentileQuery;
48770
+ exports.useLazyGetSpendCapStatusQuery = useLazyGetSpendCapStatusQuery;
48468
48771
  exports.useLazyGetStripeConnectDashboardQuery = useLazyGetStripeConnectDashboardQuery;
48469
48772
  exports.useLazyGetStripeConnectStatusQuery = useLazyGetStripeConnectStatusQuery;
48470
48773
  exports.useLazyGetStripeContextQuery = useLazyGetStripeContextQuery;
@@ -48477,6 +48780,7 @@ exports.useLazyGetTemplateDetailsQuery = useLazyGetTemplateDetailsQuery;
48477
48780
  exports.useLazyGetTemplatesQuery = useLazyGetTemplatesQuery;
48478
48781
  exports.useLazyGetTenantChatPrivacyConfigQuery = useLazyGetTenantChatPrivacyConfigQuery;
48479
48782
  exports.useLazyGetTenantMetadataQuery = useLazyGetTenantMetadataQuery;
48783
+ exports.useLazyGetTenantSpendCapQuery = useLazyGetTenantSpendCapQuery;
48480
48784
  exports.useLazyGetToolsQuery = useLazyGetToolsQuery;
48481
48785
  exports.useLazyGetTrainingDocumentRetrainScheduleQuery = useLazyGetTrainingDocumentRetrainScheduleQuery;
48482
48786
  exports.useLazyGetTrainingDocumentsQuery = useLazyGetTrainingDocumentsQuery;
@@ -48505,6 +48809,7 @@ exports.useLazyGetUserProjectsQuery = useLazyGetUserProjectsQuery;
48505
48809
  exports.useLazyGetUserReportedSkillsQuery = useLazyGetUserReportedSkillsQuery;
48506
48810
  exports.useLazyGetUserResumeQuery = useLazyGetUserResumeQuery;
48507
48811
  exports.useLazyGetUserSkillsPointsQuery = useLazyGetUserSkillsPointsQuery;
48812
+ exports.useLazyGetUserSpendCapQuery = useLazyGetUserSpendCapQuery;
48508
48813
  exports.useLazyGetUserTenantsQuery = useLazyGetUserTenantsQuery;
48509
48814
  exports.useLazyGetUsersAsAssertionsQuery = useLazyGetUsersAsAssertionsQuery;
48510
48815
  exports.useLazyGetVectorDocumentsQuery = useLazyGetVectorDocumentsQuery;
@@ -48516,6 +48821,8 @@ exports.useLazyGetWatchedUsersQuery = useLazyGetWatchedUsersQuery;
48516
48821
  exports.useLazyGetWatchersQuery = useLazyGetWatchersQuery;
48517
48822
  exports.useLazyGetWorkflowQuery = useLazyGetWorkflowQuery;
48518
48823
  exports.useLazyGetWorkflowsQuery = useLazyGetWorkflowsQuery;
48824
+ exports.useLazyListAgentSpendCapsQuery = useLazyListAgentSpendCapsQuery;
48825
+ exports.useLazyListAgentUserSpendCapsQuery = useLazyListAgentUserSpendCapsQuery;
48519
48826
  exports.useLazyListArtifactVersionsQuery = useLazyListArtifactVersionsQuery;
48520
48827
  exports.useLazyListArtifactsQuery = useLazyListArtifactsQuery;
48521
48828
  exports.useLazyListEvalDatasetItemsQuery = useLazyListEvalDatasetItemsQuery;
@@ -48538,6 +48845,8 @@ exports.useLazySeedMentorsQuery = useLazySeedMentorsQuery;
48538
48845
  exports.useLazyStarredMentorsQuery = useLazyStarredMentorsQuery;
48539
48846
  exports.useLazyStartOAuthFlowQuery = useLazyStartOAuthFlowQuery;
48540
48847
  exports.useLinkApplicationCandidateMutation = useLinkApplicationCandidateMutation;
48848
+ exports.useListAgentSpendCapsQuery = useListAgentSpendCapsQuery;
48849
+ exports.useListAgentUserSpendCapsQuery = useListAgentUserSpendCapsQuery;
48541
48850
  exports.useListArtifactVersionsQuery = useListArtifactVersionsQuery;
48542
48851
  exports.useListArtifactsQuery = useListArtifactsQuery;
48543
48852
  exports.useListEvalDatasetItemsQuery = useListEvalDatasetItemsQuery;
@@ -48681,6 +48990,9 @@ exports.useUploadProfileImageMutation = useUploadProfileImageMutation;
48681
48990
  exports.useUploadStudioCourseAssetMutation = useUploadStudioCourseAssetMutation;
48682
48991
  exports.useUploadStudioCourseVideoMutation = useUploadStudioCourseVideoMutation;
48683
48992
  exports.useUploadStudioScormPackageMutation = useUploadStudioScormPackageMutation;
48993
+ exports.useUpsertAgentSpendCapMutation = useUpsertAgentSpendCapMutation;
48994
+ exports.useUpsertTenantSpendCapMutation = useUpsertTenantSpendCapMutation;
48995
+ exports.useUpsertUserSpendCapMutation = useUpsertUserSpendCapMutation;
48684
48996
  exports.useUsersGradesPassedQuery = useUsersGradesPassedQuery;
48685
48997
  exports.useValidateWorkflowMutation = useValidateWorkflowMutation;
48686
48998
  exports.useWithdrawApplicationMutation = useWithdrawApplicationMutation;