@iblai/data-layer 1.13.4 → 1.14.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
@@ -39054,6 +39054,19 @@ exports.SERVICES = void 0;
39054
39054
  SERVICES["AXD"] = "AXD";
39055
39055
  SERVICES["STUDIO"] = "STUDIO";
39056
39056
  })(exports.SERVICES || (exports.SERVICES = {}));
39057
+ /**
39058
+ * Client errors a retry cannot fix.
39059
+ *
39060
+ * These reject the request for what it IS — unauthenticated, forbidden,
39061
+ * malformed — not for anything transient. Sending it again unchanged produces
39062
+ * the same answer, just later, while multiplying load behind a failure the
39063
+ * user is already waiting on. A 401 in particular must surface promptly so the
39064
+ * token-refresh path can act on it rather than being buried under backoff.
39065
+ *
39066
+ * Shared so every retry policy agrees; individual call sites add their own
39067
+ * extras (a 402 payment block, a 500 an endpoint treats as terminal).
39068
+ */
39069
+ const NEVER_RETRY_STATUSES = [400, 401, 403];
39057
39070
 
39058
39071
  // Backend contract: ibl_ai_mentor/views/spend_cap_views.py.
39059
39072
  // Spend caps exist at three scopes, all under /api/ai-mentor/orgs/{org}/:
@@ -39193,11 +39206,11 @@ const iblFakeBaseQuery = react.retry(fakeBaseQueryWithLogging, {
39193
39206
  // Stop after 10 retries
39194
39207
  if (attempt >= 10)
39195
39208
  return false;
39196
- // Do NOT retry auth errors
39209
+ // Do NOT retry client errors a retry cannot fix
39197
39210
  // Check direct status (from rawFakeBaseQuery errors)
39198
39211
  const err = error;
39199
39212
  const status = typeof (err === null || err === void 0 ? void 0 : err.status) === 'number' ? err.status : (_a = err === null || err === void 0 ? void 0 : err.data) === null || _a === void 0 ? void 0 : _a.status;
39200
- if (status === 401 || status === 403) {
39213
+ if (typeof status === 'number' && NEVER_RETRY_STATUSES.includes(status)) {
39201
39214
  return false;
39202
39215
  }
39203
39216
  return true;
@@ -39396,8 +39409,14 @@ const getHeaders = async (service) => {
39396
39409
  }
39397
39410
  return token ? { Authorization: `${prefix} ${token}` } : undefined;
39398
39411
  };
39399
- /** Status codes that should not be retried for queryFn endpoints. */
39400
- const QUERYFN_NON_RETRYABLE_STATUSES = [401, 403, 500];
39412
+ /**
39413
+ * Status codes that should not be retried for queryFn endpoints.
39414
+ *
39415
+ * Only the shared client errors. A 5xx is the server failing, not the request
39416
+ * being wrong — it is transient by definition and exactly what the backoff
39417
+ * exists for, so it is retried like any other transient failure.
39418
+ */
39419
+ const QUERYFN_NON_RETRYABLE_STATUSES = [...NEVER_RETRY_STATUSES];
39401
39420
  /**
39402
39421
  * True when an error body carries the spend-cap `spend_cap_exceeded` code.
39403
39422
  * A spend-cap block returns HTTP 429, but unlike a genuine provider rate
@@ -39562,8 +39581,11 @@ const invokeHttpErrorHandler = (status, error) => {
39562
39581
  Config.httpErrorHandlers[numericStatus]({ ...(err || {}) });
39563
39582
  }
39564
39583
  };
39565
- /** HTTP status codes that should not be retried (e.g., 402 Payment Required). */
39566
- const NON_RETRYABLE_STATUS_CODES = [402, 401];
39584
+ /**
39585
+ * HTTP status codes that should not be retried: the shared client errors, plus
39586
+ * 402 Payment Required, which is a hard block rather than a transient failure.
39587
+ */
39588
+ const NON_RETRYABLE_STATUS_CODES = [...NEVER_RETRY_STATUSES, 402];
39567
39589
  /**
39568
39590
  * Wraps a base query to skip retries for non-retryable HTTP status codes.
39569
39591
  * Uses `retry.fail()` to immediately bail out of the retry loop.
@@ -40979,11 +41001,19 @@ const USERS_ENDPOINTS = {
40979
41001
  service: exports.SERVICES.DM,
40980
41002
  path: () => `/api/core/users/platform-metadata/`,
40981
41003
  },
41004
+ // Read-only profile-card allowlist served from DM-local data (no edX call).
41005
+ // Open to the user, DM admins, platform admins of the user and watchers of
41006
+ // the user, which the metadata endpoints above refuse.
41007
+ GET_USER_PROFILE_SUMMARY: {
41008
+ service: exports.SERVICES.DM,
41009
+ path: () => `/api/core/users/profile/summary/`,
41010
+ },
40982
41011
  };
40983
41012
  const USERS_QUERY_KEYS = {
40984
41013
  GET_USER_METADATA: () => ['USER_METADATA'],
40985
41014
  GET_USER_PLATFORM_METADATA: () => ['USER_PLATFORM_METADATA'],
40986
41015
  GET_USER_METADATA_EDX: () => ['USER_METADATA_EDX'],
41016
+ GET_USER_PROFILE_SUMMARY: () => ['USER_PROFILE_SUMMARY'],
40987
41017
  RESET_PASSWORD: () => ['RESET_PASSWORD'],
40988
41018
  UPDATE_USER_ROLES: () => ['UPDATE_USER_ROLES'],
40989
41019
  GET_USER_ROLES: () => ['USER_ROLES'],
@@ -41002,6 +41032,7 @@ const userApiSlice = react.createApi({
41002
41032
  ...USERS_QUERY_KEYS.GET_USER_METADATA_EDX(),
41003
41033
  ...USERS_QUERY_KEYS.GET_USER_PLATFORM_METADATA(),
41004
41034
  ...USERS_QUERY_KEYS.GET_USER_ROLES(),
41035
+ ...USERS_QUERY_KEYS.GET_USER_PROFILE_SUMMARY(),
41005
41036
  featureTags.PLATFORM_USERS,
41006
41037
  ],
41007
41038
  endpoints: (builder) => ({
@@ -41103,6 +41134,34 @@ const userApiSlice = react.createApi({
41103
41134
  }),
41104
41135
  providesTags: USERS_QUERY_KEYS.GET_USER_METADATA_EDX(),
41105
41136
  }),
41137
+ /**
41138
+ * A user's profile-card fields, read-only, from DM-local data. Unlike
41139
+ * `getUserMetadata` it is also served to watchers of the user, so use it
41140
+ * when previewing someone else's profile.
41141
+ */
41142
+ getUserProfileSummary: builder.query({
41143
+ query: ({ username, email, userId, platformKey }) => {
41144
+ const params = {};
41145
+ if (username) {
41146
+ params.username = username;
41147
+ }
41148
+ if (email) {
41149
+ params.email = email;
41150
+ }
41151
+ if (userId !== undefined) {
41152
+ params.user_id = userId;
41153
+ }
41154
+ if (platformKey) {
41155
+ params.platform_key = platformKey;
41156
+ }
41157
+ return {
41158
+ url: USERS_ENDPOINTS.GET_USER_PROFILE_SUMMARY.path(),
41159
+ service: USERS_ENDPOINTS.GET_USER_PROFILE_SUMMARY.service,
41160
+ params,
41161
+ };
41162
+ },
41163
+ providesTags: USERS_QUERY_KEYS.GET_USER_PROFILE_SUMMARY(),
41164
+ }),
41106
41165
  uploadProfileImage: builder.mutation({
41107
41166
  query: ({ file, filename, username }) => {
41108
41167
  const formData = new FormData();
@@ -41163,7 +41222,7 @@ const userApiSlice = react.createApi({
41163
41222
  }),
41164
41223
  }),
41165
41224
  });
41166
- const { useGetUserMetadataQuery, useLazyGetUserMetadataQuery, useUpdateUserMetadataMutation, useUpdateUserAccountMutation, useResetPasswordMutation, useUpdateUserRoleMutation, useGetUserRolesQuery, useLazyGetUserRolesQuery, useUploadProfileImageMutation, useRemoveProfileImageMutation, useGetUserMetadataEdxQuery, useLazyGetUserMetadataEdxQuery, useUpdateUserMetadataEdxMutation, useGetUserPlatformMetadataQuery, useLazyGetUserPlatformMetadataQuery, useUpdateUserPlatformMetadataMutation, } = userApiSlice;
41225
+ const { useGetUserMetadataQuery, useLazyGetUserMetadataQuery, useUpdateUserMetadataMutation, useUpdateUserAccountMutation, useResetPasswordMutation, useUpdateUserRoleMutation, useGetUserRolesQuery, useLazyGetUserRolesQuery, useUploadProfileImageMutation, useRemoveProfileImageMutation, useGetUserMetadataEdxQuery, useLazyGetUserMetadataEdxQuery, useGetUserProfileSummaryQuery, useLazyGetUserProfileSummaryQuery, useUpdateUserMetadataEdxMutation, useGetUserPlatformMetadataQuery, useLazyGetUserPlatformMetadataQuery, useUpdateUserPlatformMetadataMutation, } = userApiSlice;
41167
41226
 
41168
41227
  /**
41169
41228
  * Scope a role row applies to, read off its `org`/`course` fields:
@@ -48533,6 +48592,7 @@ exports.MENTOR_CUSTOM_ENDPOINTS = MENTOR_CUSTOM_ENDPOINTS;
48533
48592
  exports.MENTOR_CUSTOM_REDUCER_PATH = MENTOR_CUSTOM_REDUCER_PATH;
48534
48593
  exports.MENTOR_ENDPOINTS = MENTOR_ENDPOINTS;
48535
48594
  exports.MENTOR_SKILL_ASSIGNMENTS_PAGE_SIZE = MENTOR_SKILL_ASSIGNMENTS_PAGE_SIZE;
48595
+ exports.NEVER_RETRY_STATUSES = NEVER_RETRY_STATUSES;
48536
48596
  exports.NOTIFICATIONS_CUSTOM_ENDPOINTS = NOTIFICATIONS_CUSTOM_ENDPOINTS;
48537
48597
  exports.NOTIFICATIONS_CUSTOM_REDUCER_PATH = NOTIFICATIONS_CUSTOM_REDUCER_PATH;
48538
48598
  exports.NOTIFICATIONS_CUSTOM_TAGS = NOTIFICATIONS_CUSTOM_TAGS;
@@ -49092,6 +49152,7 @@ exports.useGetUserMetadataQuery = useGetUserMetadataQuery;
49092
49152
  exports.useGetUserMetricsPieChartQuery = useGetUserMetricsPieChartQuery;
49093
49153
  exports.useGetUserMetricsQuery = useGetUserMetricsQuery;
49094
49154
  exports.useGetUserPlatformMetadataQuery = useGetUserPlatformMetadataQuery;
49155
+ exports.useGetUserProfileSummaryQuery = useGetUserProfileSummaryQuery;
49095
49156
  exports.useGetUserProjectDetailsQuery = useGetUserProjectDetailsQuery;
49096
49157
  exports.useGetUserProjectsQuery = useGetUserProjectsQuery;
49097
49158
  exports.useGetUserReportedSkillsQuery = useGetUserReportedSkillsQuery;
@@ -49302,6 +49363,7 @@ exports.useLazyGetUserMemorySettingsQuery = useLazyGetUserMemorySettingsQuery;
49302
49363
  exports.useLazyGetUserMetadataEdxQuery = useLazyGetUserMetadataEdxQuery;
49303
49364
  exports.useLazyGetUserMetadataQuery = useLazyGetUserMetadataQuery;
49304
49365
  exports.useLazyGetUserPlatformMetadataQuery = useLazyGetUserPlatformMetadataQuery;
49366
+ exports.useLazyGetUserProfileSummaryQuery = useLazyGetUserProfileSummaryQuery;
49305
49367
  exports.useLazyGetUserProjectDetailsQuery = useLazyGetUserProjectDetailsQuery;
49306
49368
  exports.useLazyGetUserProjectsQuery = useLazyGetUserProjectsQuery;
49307
49369
  exports.useLazyGetUserReportedSkillsQuery = useLazyGetUserReportedSkillsQuery;