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