@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.d.ts
CHANGED
|
@@ -5978,6 +5978,15 @@ interface CustomQueryArgs extends Omit<FetchArgs, 'url'> {
|
|
|
5978
5978
|
isJson?: boolean;
|
|
5979
5979
|
contentType?: string;
|
|
5980
5980
|
skipAuth?: boolean;
|
|
5981
|
+
/**
|
|
5982
|
+
* Statuses the caller needs to inspect (e.g. a 404 for a session the
|
|
5983
|
+
* caller no longer holds). Retries are unchanged; once they are exhausted
|
|
5984
|
+
* these are logged via `console.warn` and returned as `{ error }` instead
|
|
5985
|
+
* of thrown — RTK Query serializes a thrown error to `{}`, dropping
|
|
5986
|
+
* `status`. Defaults to `[]`, so existing endpoints behave exactly as
|
|
5987
|
+
* before.
|
|
5988
|
+
*/
|
|
5989
|
+
returnErrorStatuses?: number[];
|
|
5981
5990
|
}
|
|
5982
5991
|
type ExtendedFetchBaseQueryError = FetchBaseQueryError & {
|
|
5983
5992
|
data?: {
|
package/dist/index.esm.js
CHANGED
|
@@ -39516,8 +39516,12 @@ const buildEndpointFromAxdService = (serviceFn, options) => buildEndpointFromSer
|
|
|
39516
39516
|
* Build an endpoint from a hand-assembled URL (rather than a generated service
|
|
39517
39517
|
* method), routed through `iblFetchBaseQuery`. Defaults to the DM service.
|
|
39518
39518
|
*/
|
|
39519
|
-
const buildEndpointFromDmUrl = (buildUrl, service = SERVICES.DM) => ({
|
|
39520
|
-
queryFn: async (args, api, extraOptions) => iblFetchBaseQuery({
|
|
39519
|
+
const buildEndpointFromDmUrl = (buildUrl, service = SERVICES.DM, options) => ({
|
|
39520
|
+
queryFn: async (args, api, extraOptions) => iblFetchBaseQuery({
|
|
39521
|
+
url: buildUrl(args),
|
|
39522
|
+
service,
|
|
39523
|
+
returnErrorStatuses: options === null || options === void 0 ? void 0 : options.returnErrorStatuses,
|
|
39524
|
+
}, api, extraOptions),
|
|
39521
39525
|
});
|
|
39522
39526
|
/**
|
|
39523
39527
|
* Build an endpoint from a hand-assembled URL, taking its arguments in the
|
|
@@ -39581,7 +39585,6 @@ const baseQuery = (service, jsonContentType = true, contentType, skipAuth = fals
|
|
|
39581
39585
|
*/
|
|
39582
39586
|
const invokeHttpErrorHandler = (status, error) => {
|
|
39583
39587
|
const numericStatus = typeof status === 'number' ? status : parseInt(String(status), 10);
|
|
39584
|
-
console.log('[MONETIZATION error] ', { error });
|
|
39585
39588
|
if (!isNaN(numericStatus) &&
|
|
39586
39589
|
Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, numericStatus)) {
|
|
39587
39590
|
const err = error;
|
|
@@ -39629,7 +39632,7 @@ const withNonRetryableErrors = (query) => async (args, api, extraOptions) => {
|
|
|
39629
39632
|
return result;
|
|
39630
39633
|
};
|
|
39631
39634
|
const iblFetchBaseQuery = async (args, api, extraOptions) => {
|
|
39632
|
-
var _a, _b, _c;
|
|
39635
|
+
var _a, _b, _c, _d;
|
|
39633
39636
|
try {
|
|
39634
39637
|
const runQuery = () => {
|
|
39635
39638
|
var _a;
|
|
@@ -39650,9 +39653,21 @@ const iblFetchBaseQuery = async (args, api, extraOptions) => {
|
|
|
39650
39653
|
}
|
|
39651
39654
|
// Query completed
|
|
39652
39655
|
if (result.error) {
|
|
39653
|
-
|
|
39656
|
+
// A status the caller handles itself (e.g. a 404 for a session the
|
|
39657
|
+
// caller no longer holds): don't escalate to Sentry via console.error
|
|
39658
|
+
// and return `{ error }` instead of throwing, so the status reaches the
|
|
39659
|
+
// caller via RTK Query's normal `error` field.
|
|
39660
|
+
if ((_b = args.returnErrorStatuses) === null || _b === void 0 ? void 0 : _b.includes(result.error.status)) {
|
|
39661
|
+
console.warn('[data-layer] returning expected error:', `url=${args.url}, status=${result.error.status}`);
|
|
39662
|
+
return {
|
|
39663
|
+
error: {
|
|
39664
|
+
status: result.error.status,
|
|
39665
|
+
data: result.error.data,
|
|
39666
|
+
},
|
|
39667
|
+
};
|
|
39668
|
+
}
|
|
39654
39669
|
// Invoke registered HTTP error handlers (e.g., logout on 401)
|
|
39655
|
-
invokeHttpErrorHandler(result.error.status, (
|
|
39670
|
+
invokeHttpErrorHandler(result.error.status, (_c = result.error) === null || _c === void 0 ? void 0 : _c.data);
|
|
39656
39671
|
// For profile image upload errors, preserve the original error structure
|
|
39657
39672
|
if (args.url && args.url.includes('/profile_images/')) {
|
|
39658
39673
|
throw result.error;
|
|
@@ -39670,7 +39685,7 @@ const iblFetchBaseQuery = async (args, api, extraOptions) => {
|
|
|
39670
39685
|
// Ensure we throw a plain FetchBaseQueryError shape with enumerable fields
|
|
39671
39686
|
throw {
|
|
39672
39687
|
status: result.error.status,
|
|
39673
|
-
data: (
|
|
39688
|
+
data: (_d = result.error.data) !== null && _d !== void 0 ? _d : errorMessage,
|
|
39674
39689
|
};
|
|
39675
39690
|
}
|
|
39676
39691
|
return { data: result === null || result === void 0 ? void 0 : result.data };
|
|
@@ -42920,12 +42935,23 @@ const sessionApiSlice = createApi({
|
|
|
42920
42935
|
invalidatesTags: ['sessionId'],
|
|
42921
42936
|
}),
|
|
42922
42937
|
getSessionId: builder.query({
|
|
42923
|
-
|
|
42924
|
-
|
|
42938
|
+
// A 404 here means the caller holds a session id the backend no longer
|
|
42939
|
+
// recognizes (e.g. purged, or a stale localStorage cache). Return it as
|
|
42940
|
+
// `{ error }` so the chat can detect it and mint a fresh session.
|
|
42941
|
+
...buildEndpointFromDmUrl(buildSessionRetrieveUrl, SERVICES.DM, {
|
|
42942
|
+
returnErrorStatuses: [404],
|
|
42943
|
+
}),
|
|
42944
|
+
// A 404 is now returned as `{ error }` rather than thrown (see above),
|
|
42945
|
+
// so RTK Query would otherwise still tag the errored cache entry and
|
|
42946
|
+
// `createSessionId`'s invalidation would refetch the dead id right
|
|
42947
|
+
// after the heal mints a new session. Only provide the tag on success.
|
|
42948
|
+
providesTags: (_result, error) => (error ? [] : ['sessionId']),
|
|
42925
42949
|
}),
|
|
42926
42950
|
getSharedSessionId: builder.query({
|
|
42927
|
-
...buildEndpointFromDmUrl(buildSharedSessionRetrieveUrl
|
|
42928
|
-
|
|
42951
|
+
...buildEndpointFromDmUrl(buildSharedSessionRetrieveUrl, SERVICES.DM, {
|
|
42952
|
+
returnErrorStatuses: [404],
|
|
42953
|
+
}),
|
|
42954
|
+
providesTags: (_result, error) => (error ? [] : ['sessionId']),
|
|
42929
42955
|
}),
|
|
42930
42956
|
editSession: builder.mutation({
|
|
42931
42957
|
...buildEndpointFromDmService(AiMentorService.aiMentorOrgsUsersSessionsUpdate),
|