@iblai/data-layer 1.29.2 → 1.30.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.d.ts +9 -0
- package/dist/index.esm.js +37 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +37 -11
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/features/utils.d.ts +12 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39518,8 +39518,12 @@ const buildEndpointFromAxdService = (serviceFn, options) => buildEndpointFromSer
|
|
|
39518
39518
|
* Build an endpoint from a hand-assembled URL (rather than a generated service
|
|
39519
39519
|
* method), routed through `iblFetchBaseQuery`. Defaults to the DM service.
|
|
39520
39520
|
*/
|
|
39521
|
-
const buildEndpointFromDmUrl = (buildUrl, service = exports.SERVICES.DM) => ({
|
|
39522
|
-
queryFn: async (args, api, extraOptions) => iblFetchBaseQuery({
|
|
39521
|
+
const buildEndpointFromDmUrl = (buildUrl, service = exports.SERVICES.DM, options) => ({
|
|
39522
|
+
queryFn: async (args, api, extraOptions) => iblFetchBaseQuery({
|
|
39523
|
+
url: buildUrl(args),
|
|
39524
|
+
service,
|
|
39525
|
+
returnErrorStatuses: options === null || options === void 0 ? void 0 : options.returnErrorStatuses,
|
|
39526
|
+
}, api, extraOptions),
|
|
39523
39527
|
});
|
|
39524
39528
|
/**
|
|
39525
39529
|
* Build an endpoint from a hand-assembled URL, taking its arguments in the
|
|
@@ -39583,7 +39587,6 @@ const baseQuery = (service, jsonContentType = true, contentType, skipAuth = fals
|
|
|
39583
39587
|
*/
|
|
39584
39588
|
const invokeHttpErrorHandler = (status, error) => {
|
|
39585
39589
|
const numericStatus = typeof status === 'number' ? status : parseInt(String(status), 10);
|
|
39586
|
-
console.log('[MONETIZATION error] ', { error });
|
|
39587
39590
|
if (!isNaN(numericStatus) &&
|
|
39588
39591
|
Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, numericStatus)) {
|
|
39589
39592
|
const err = error;
|
|
@@ -39631,7 +39634,7 @@ const withNonRetryableErrors = (query$1) => async (args, api, extraOptions) => {
|
|
|
39631
39634
|
return result;
|
|
39632
39635
|
};
|
|
39633
39636
|
const iblFetchBaseQuery = async (args, api, extraOptions) => {
|
|
39634
|
-
var _a, _b, _c;
|
|
39637
|
+
var _a, _b, _c, _d;
|
|
39635
39638
|
try {
|
|
39636
39639
|
const runQuery = () => {
|
|
39637
39640
|
var _a;
|
|
@@ -39652,9 +39655,21 @@ const iblFetchBaseQuery = async (args, api, extraOptions) => {
|
|
|
39652
39655
|
}
|
|
39653
39656
|
// Query completed
|
|
39654
39657
|
if (result.error) {
|
|
39655
|
-
|
|
39658
|
+
// A status the caller handles itself (e.g. a 404 for a session the
|
|
39659
|
+
// caller no longer holds): don't escalate to Sentry via console.error
|
|
39660
|
+
// and return `{ error }` instead of throwing, so the status reaches the
|
|
39661
|
+
// caller via RTK Query's normal `error` field.
|
|
39662
|
+
if ((_b = args.returnErrorStatuses) === null || _b === void 0 ? void 0 : _b.includes(result.error.status)) {
|
|
39663
|
+
console.warn('[data-layer] returning expected error:', `url=${args.url}, status=${result.error.status}`);
|
|
39664
|
+
return {
|
|
39665
|
+
error: {
|
|
39666
|
+
status: result.error.status,
|
|
39667
|
+
data: result.error.data,
|
|
39668
|
+
},
|
|
39669
|
+
};
|
|
39670
|
+
}
|
|
39656
39671
|
// Invoke registered HTTP error handlers (e.g., logout on 401)
|
|
39657
|
-
invokeHttpErrorHandler(result.error.status, (
|
|
39672
|
+
invokeHttpErrorHandler(result.error.status, (_c = result.error) === null || _c === void 0 ? void 0 : _c.data);
|
|
39658
39673
|
// For profile image upload errors, preserve the original error structure
|
|
39659
39674
|
if (args.url && args.url.includes('/profile_images/')) {
|
|
39660
39675
|
throw result.error;
|
|
@@ -39672,7 +39687,7 @@ const iblFetchBaseQuery = async (args, api, extraOptions) => {
|
|
|
39672
39687
|
// Ensure we throw a plain FetchBaseQueryError shape with enumerable fields
|
|
39673
39688
|
throw {
|
|
39674
39689
|
status: result.error.status,
|
|
39675
|
-
data: (
|
|
39690
|
+
data: (_d = result.error.data) !== null && _d !== void 0 ? _d : errorMessage,
|
|
39676
39691
|
};
|
|
39677
39692
|
}
|
|
39678
39693
|
return { data: result === null || result === void 0 ? void 0 : result.data };
|
|
@@ -42922,12 +42937,23 @@ const sessionApiSlice = react.createApi({
|
|
|
42922
42937
|
invalidatesTags: ['sessionId'],
|
|
42923
42938
|
}),
|
|
42924
42939
|
getSessionId: builder.query({
|
|
42925
|
-
|
|
42926
|
-
|
|
42940
|
+
// A 404 here means the caller holds a session id the backend no longer
|
|
42941
|
+
// recognizes (e.g. purged, or a stale localStorage cache). Return it as
|
|
42942
|
+
// `{ error }` so the chat can detect it and mint a fresh session.
|
|
42943
|
+
...buildEndpointFromDmUrl(buildSessionRetrieveUrl, exports.SERVICES.DM, {
|
|
42944
|
+
returnErrorStatuses: [404],
|
|
42945
|
+
}),
|
|
42946
|
+
// A 404 is now returned as `{ error }` rather than thrown (see above),
|
|
42947
|
+
// so RTK Query would otherwise still tag the errored cache entry and
|
|
42948
|
+
// `createSessionId`'s invalidation would refetch the dead id right
|
|
42949
|
+
// after the heal mints a new session. Only provide the tag on success.
|
|
42950
|
+
providesTags: (_result, error) => (error ? [] : ['sessionId']),
|
|
42927
42951
|
}),
|
|
42928
42952
|
getSharedSessionId: builder.query({
|
|
42929
|
-
...buildEndpointFromDmUrl(buildSharedSessionRetrieveUrl
|
|
42930
|
-
|
|
42953
|
+
...buildEndpointFromDmUrl(buildSharedSessionRetrieveUrl, exports.SERVICES.DM, {
|
|
42954
|
+
returnErrorStatuses: [404],
|
|
42955
|
+
}),
|
|
42956
|
+
providesTags: (_result, error) => (error ? [] : ['sessionId']),
|
|
42931
42957
|
}),
|
|
42932
42958
|
editSession: builder.mutation({
|
|
42933
42959
|
...buildEndpointFromDmService(AiMentorService.aiMentorOrgsUsersSessionsUpdate),
|