@iblai/data-layer 1.7.2 → 1.7.4

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
@@ -39178,8 +39178,9 @@ const QUERYFN_BASE_DELAY_MS = 1000;
39178
39178
  * skips baseQuery retry for queryFn endpoints).
39179
39179
  */
39180
39180
  const buildEndpointFromService = (service, serviceFn, options) => {
39181
- var _a;
39182
- const maxRetries = (_a = void 0 ) !== null && _a !== void 0 ? _a : QUERYFN_MAX_RETRIES;
39181
+ var _a, _b;
39182
+ const maxRetries = (_a = options === null || options === void 0 ? void 0 : options.maxRetries) !== null && _a !== void 0 ? _a : QUERYFN_MAX_RETRIES;
39183
+ const expectedErrorStatuses = (_b = options === null || options === void 0 ? void 0 : options.expectedErrorStatuses) !== null && _b !== void 0 ? _b : [];
39183
39184
  return {
39184
39185
  async queryFn(args) {
39185
39186
  let lastError;
@@ -39194,8 +39195,10 @@ const buildEndpointFromService = (service, serviceFn, options) => {
39194
39195
  catch (err) {
39195
39196
  lastError = err;
39196
39197
  const status = err === null || err === void 0 ? void 0 : err.status;
39197
- // Don't retry auth errors
39198
- if (QUERYFN_NON_RETRYABLE_STATUSES.includes(status)) {
39198
+ // Don't retry auth errors or statuses the endpoint expects as an
39199
+ // empty state (fail fast — no retry storm).
39200
+ if (QUERYFN_NON_RETRYABLE_STATUSES.includes(status) ||
39201
+ expectedErrorStatuses.includes(status)) {
39199
39202
  break;
39200
39203
  }
39201
39204
  // If we have retries left, wait with exponential backoff
@@ -39207,8 +39210,15 @@ const buildEndpointFromService = (service, serviceFn, options) => {
39207
39210
  }
39208
39211
  }
39209
39212
  }
39210
- // All retries exhausted or non-retryable error
39211
- console.error('[data-layer] API error:', `service=${service}, fn=${serviceFn.name || 'anonymous'}`, JSON.stringify(lastError, Object.getOwnPropertyNames(lastError)));
39213
+ // All retries exhausted or non-retryable error. Expected empty-state
39214
+ // statuses (e.g. a 404 before the resource is created) are logged at warn
39215
+ // level so Sentry's console integration doesn't escalate them to errors.
39216
+ if (expectedErrorStatuses.includes(lastError === null || lastError === void 0 ? void 0 : lastError.status)) {
39217
+ console.warn('[data-layer] expected empty result:', `service=${service}, fn=${serviceFn.name || 'anonymous'}, status=${lastError === null || lastError === void 0 ? void 0 : lastError.status}`);
39218
+ }
39219
+ else {
39220
+ console.error('[data-layer] API error:', `service=${service}, fn=${serviceFn.name || 'anonymous'}`, JSON.stringify(lastError, Object.getOwnPropertyNames(lastError)));
39221
+ }
39212
39222
  if (Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, lastError === null || lastError === void 0 ? void 0 : lastError.status)) {
39213
39223
  Config.httpErrorHandlers[lastError === null || lastError === void 0 ? void 0 : lastError.status]({
39214
39224
  ...((lastError === null || lastError === void 0 ? void 0 : lastError.data) || {}),
@@ -39226,11 +39236,11 @@ const buildEndpointFromService = (service, serviceFn, options) => {
39226
39236
  /**
39227
39237
  * Shortcut for building an endpoint using the DM service.
39228
39238
  */
39229
- const buildEndpointFromDmService = (serviceFn, options) => buildEndpointFromService(exports.SERVICES.DM, serviceFn);
39239
+ const buildEndpointFromDmService = (serviceFn, options) => buildEndpointFromService(exports.SERVICES.DM, serviceFn, options);
39230
39240
  /**
39231
39241
  * Shortcut for building an endpoint using the AXD service.
39232
39242
  */
39233
- const buildEndpointFromAxdService = (serviceFn, options) => buildEndpointFromService(exports.SERVICES.AXD, serviceFn);
39243
+ const buildEndpointFromAxdService = (serviceFn, options) => buildEndpointFromService(exports.SERVICES.AXD, serviceFn, options);
39234
39244
  const isErrorObject = (data) => {
39235
39245
  return (typeof data === 'object' &&
39236
39246
  data !== null &&
@@ -39366,8 +39376,9 @@ const iblFetchBaseQuery = async (args, api, extraOptions) => {
39366
39376
  * Includes built-in retry with exponential backoff.
39367
39377
  */
39368
39378
  const buildEndpointFromServiceLegacy = (service, serviceFn, options) => {
39369
- var _a;
39379
+ var _a, _b;
39370
39380
  const maxRetries = (_a = void 0 ) !== null && _a !== void 0 ? _a : QUERYFN_MAX_RETRIES;
39381
+ const expectedErrorStatuses = (_b = void 0 ) !== null && _b !== void 0 ? _b : [];
39371
39382
  return {
39372
39383
  async queryFn(args) {
39373
39384
  let lastError;
@@ -39382,7 +39393,8 @@ const buildEndpointFromServiceLegacy = (service, serviceFn, options) => {
39382
39393
  catch (err) {
39383
39394
  lastError = err;
39384
39395
  const status = err === null || err === void 0 ? void 0 : err.status;
39385
- if (QUERYFN_NON_RETRYABLE_STATUSES.includes(status)) {
39396
+ if (QUERYFN_NON_RETRYABLE_STATUSES.includes(status) ||
39397
+ expectedErrorStatuses.includes(status)) {
39386
39398
  break;
39387
39399
  }
39388
39400
  if (attempt < maxRetries) {
@@ -39393,6 +39405,9 @@ const buildEndpointFromServiceLegacy = (service, serviceFn, options) => {
39393
39405
  }
39394
39406
  }
39395
39407
  }
39408
+ if (expectedErrorStatuses.includes(lastError === null || lastError === void 0 ? void 0 : lastError.status)) {
39409
+ console.warn('[data-layer] expected empty result:', `service=${service}, fn=${serviceFn.name || 'anonymous'}, status=${lastError === null || lastError === void 0 ? void 0 : lastError.status}`);
39410
+ }
39396
39411
  if (Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, lastError === null || lastError === void 0 ? void 0 : lastError.status)) {
39397
39412
  Config.httpErrorHandlers[lastError === null || lastError === void 0 ? void 0 : lastError.status]({
39398
39413
  status: lastError === null || lastError === void 0 ? void 0 : lastError.status,
@@ -39792,7 +39807,13 @@ const mentorApiSlice = react.createApi({
39792
39807
  ],
39793
39808
  }),
39794
39809
  getShareableLink: builder.query({
39795
- ...buildEndpointFromDmService(AiMentorService.aiMentorOrgsUsersMentorsSharableLinkRetrieve),
39810
+ // A 404 here means "no ShareableMentorLink yet" — an expected empty state
39811
+ // (a token only exists after a Create/POST), not a real error. Mark 404 as
39812
+ // expected so the retry wrapper fails fast and logs via console.warn,
39813
+ // avoiding the ~34s retry storm + Sentry error escalation (issue #1844).
39814
+ ...buildEndpointFromDmService(AiMentorService.aiMentorOrgsUsersMentorsSharableLinkRetrieve, {
39815
+ expectedErrorStatuses: [404],
39816
+ }),
39796
39817
  providesTags: (_result, _error, arg) => [
39797
39818
  { type: 'shareableLinks', id: `${arg.mentor}-${arg.org}` },
39798
39819
  ],