@iblai/data-layer 1.7.0 → 1.7.3
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.d.ts +25 -17
- package/dist/index.esm.js +45 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +45 -12
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/features/__tests__/utils.test.d.ts +1 -0
- package/dist/src/features/chat/api-slice.d.ts +25 -16
- package/dist/src/features/utils.d.ts +21 -18
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
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,
|
|
@@ -39470,7 +39485,19 @@ const chatApiSlice = react.createApi({
|
|
|
39470
39485
|
providesTags: ['pinnedMessages'],
|
|
39471
39486
|
}),
|
|
39472
39487
|
unPinMessage: builder.mutation({
|
|
39473
|
-
|
|
39488
|
+
// The generated `aiMentorOrgsUsersPinMessageDestroy` only sends org/user
|
|
39489
|
+
// path params and omits the body, but the DELETE pin-message endpoint
|
|
39490
|
+
// needs `{ session_id }` to know which pinned message to remove.
|
|
39491
|
+
queryFn: async (args, api, extraOptions) => {
|
|
39492
|
+
const url = `/api/ai-mentor/orgs/${args.org}/users/${args.userId}/pin-message/`;
|
|
39493
|
+
return iblFetchBaseQuery({
|
|
39494
|
+
url,
|
|
39495
|
+
method: 'DELETE',
|
|
39496
|
+
body: args.requestBody,
|
|
39497
|
+
service: exports.SERVICES.DM,
|
|
39498
|
+
}, api, extraOptions);
|
|
39499
|
+
},
|
|
39500
|
+
invalidatesTags: ['pinnedMessages'],
|
|
39474
39501
|
}),
|
|
39475
39502
|
addPinnedMessage: builder.mutation({
|
|
39476
39503
|
...buildEndpointFromDmService(AiMentorService.aiMentorOrgsUsersPinMessageCreate),
|
|
@@ -39780,7 +39807,13 @@ const mentorApiSlice = react.createApi({
|
|
|
39780
39807
|
],
|
|
39781
39808
|
}),
|
|
39782
39809
|
getShareableLink: builder.query({
|
|
39783
|
-
|
|
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
|
+
}),
|
|
39784
39817
|
providesTags: (_result, _error, arg) => [
|
|
39785
39818
|
{ type: 'shareableLinks', id: `${arg.mentor}-${arg.org}` },
|
|
39786
39819
|
],
|