@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.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _reduxjs_toolkit_query_react from '@reduxjs/toolkit/query/react';
|
|
2
2
|
import { BaseQueryFn } from '@reduxjs/toolkit/query/react';
|
|
3
3
|
import * as _iblai_iblai_api from '@iblai/iblai-api';
|
|
4
|
-
import { RbacGroup, RbacPolicy, RbacRole, RbacUser, PaginatedRbacRoleList, PatchedRbacRole, OAuthStartResponse, Issuer, Assertion, ReportList, ReportDetail, ReportRequest, ReportCreate, PathwayEnrollmentPlus, ProgramEnrollmentPlus, PaginatedProgramInvitation, Education, Experience, Institution, InstitutionTypeEnum, Company, Artifact, PatchedArtifact, Voice, TransportEnum, MentorSearchResponse, PaginatedPeriodicAgentList } from '@iblai/iblai-api';
|
|
4
|
+
import { PinnedMessageRequest, RbacGroup, RbacPolicy, RbacRole, RbacUser, PaginatedRbacRoleList, PatchedRbacRole, OAuthStartResponse, Issuer, Assertion, ReportList, ReportDetail, ReportRequest, ReportCreate, PathwayEnrollmentPlus, ProgramEnrollmentPlus, PaginatedProgramInvitation, Education, Experience, Institution, InstitutionTypeEnum, Company, Artifact, PatchedArtifact, Voice, TransportEnum, MentorSearchResponse, PaginatedPeriodicAgentList } from '@iblai/iblai-api';
|
|
5
5
|
export { LLMResponse, MentorSettings } from '@iblai/iblai-api';
|
|
6
6
|
import * as _reduxjs_toolkit_query from '@reduxjs/toolkit/query';
|
|
7
7
|
import { FetchArgs, FetchBaseQueryError } from '@reduxjs/toolkit/query';
|
|
@@ -2262,12 +2262,14 @@ declare const chatApiSlice: _reduxjs_toolkit_query.Api<_reduxjs_toolkit_query.Ba
|
|
|
2262
2262
|
} & _reduxjs_toolkit_query.RetryOptions, {}>, "pinnedMessages" | "recentMessages" | "messageFeedback", _iblai_iblai_api.PinnedMessageGet[], "chatApiSlice", any>;
|
|
2263
2263
|
unPinMessage: _reduxjs_toolkit_query.MutationDefinition<{
|
|
2264
2264
|
org: string;
|
|
2265
|
+
userId: string;
|
|
2266
|
+
requestBody: PinnedMessageRequest;
|
|
2265
2267
|
}, _reduxjs_toolkit_query.BaseQueryFn<void, unknown, unknown, {
|
|
2266
2268
|
attempt?: number;
|
|
2267
|
-
} & _reduxjs_toolkit_query.RetryOptions, {}>, "pinnedMessages" | "recentMessages" | "messageFeedback",
|
|
2269
|
+
} & _reduxjs_toolkit_query.RetryOptions, {}>, "pinnedMessages" | "recentMessages" | "messageFeedback", unknown, "chatApiSlice", any>;
|
|
2268
2270
|
addPinnedMessage: _reduxjs_toolkit_query.MutationDefinition<{
|
|
2269
2271
|
org: string;
|
|
2270
|
-
requestBody:
|
|
2272
|
+
requestBody: PinnedMessageRequest;
|
|
2271
2273
|
}, _reduxjs_toolkit_query.BaseQueryFn<void, unknown, unknown, {
|
|
2272
2274
|
attempt?: number;
|
|
2273
2275
|
} & _reduxjs_toolkit_query.RetryOptions, {}>, "pinnedMessages" | "recentMessages" | "messageFeedback", _iblai_iblai_api.PinnedMessageCreate, "chatApiSlice", any>;
|
|
@@ -2502,14 +2504,14 @@ declare const useUnPinMessageMutation: <R extends Record<string, any> = ({
|
|
|
2502
2504
|
status: _reduxjs_toolkit_query.QueryStatus.fulfilled;
|
|
2503
2505
|
} & Omit<{
|
|
2504
2506
|
requestId: string;
|
|
2505
|
-
data?:
|
|
2507
|
+
data?: unknown;
|
|
2506
2508
|
error?: unknown;
|
|
2507
2509
|
endpointName: string;
|
|
2508
2510
|
startedTimeStamp: number;
|
|
2509
2511
|
fulfilledTimeStamp?: number;
|
|
2510
2512
|
}, "data" | "fulfilledTimeStamp"> & Required<Pick<{
|
|
2511
2513
|
requestId: string;
|
|
2512
|
-
data?:
|
|
2514
|
+
data?: unknown;
|
|
2513
2515
|
error?: unknown;
|
|
2514
2516
|
endpointName: string;
|
|
2515
2517
|
startedTimeStamp: number;
|
|
@@ -2526,7 +2528,7 @@ declare const useUnPinMessageMutation: <R extends Record<string, any> = ({
|
|
|
2526
2528
|
status: _reduxjs_toolkit_query.QueryStatus.pending;
|
|
2527
2529
|
} & {
|
|
2528
2530
|
requestId: string;
|
|
2529
|
-
data?:
|
|
2531
|
+
data?: unknown;
|
|
2530
2532
|
error?: unknown;
|
|
2531
2533
|
endpointName: string;
|
|
2532
2534
|
startedTimeStamp: number;
|
|
@@ -2543,14 +2545,14 @@ declare const useUnPinMessageMutation: <R extends Record<string, any> = ({
|
|
|
2543
2545
|
status: _reduxjs_toolkit_query.QueryStatus.rejected;
|
|
2544
2546
|
} & Omit<{
|
|
2545
2547
|
requestId: string;
|
|
2546
|
-
data?:
|
|
2548
|
+
data?: unknown;
|
|
2547
2549
|
error?: unknown;
|
|
2548
2550
|
endpointName: string;
|
|
2549
2551
|
startedTimeStamp: number;
|
|
2550
2552
|
fulfilledTimeStamp?: number;
|
|
2551
2553
|
}, "error"> & Required<Pick<{
|
|
2552
2554
|
requestId: string;
|
|
2553
|
-
data?:
|
|
2555
|
+
data?: unknown;
|
|
2554
2556
|
error?: unknown;
|
|
2555
2557
|
endpointName: string;
|
|
2556
2558
|
startedTimeStamp: number;
|
|
@@ -2580,14 +2582,14 @@ declare const useUnPinMessageMutation: <R extends Record<string, any> = ({
|
|
|
2580
2582
|
status: _reduxjs_toolkit_query.QueryStatus.fulfilled;
|
|
2581
2583
|
} & Omit<{
|
|
2582
2584
|
requestId: string;
|
|
2583
|
-
data?:
|
|
2585
|
+
data?: unknown;
|
|
2584
2586
|
error?: unknown;
|
|
2585
2587
|
endpointName: string;
|
|
2586
2588
|
startedTimeStamp: number;
|
|
2587
2589
|
fulfilledTimeStamp?: number;
|
|
2588
2590
|
}, "data" | "fulfilledTimeStamp"> & Required<Pick<{
|
|
2589
2591
|
requestId: string;
|
|
2590
|
-
data?:
|
|
2592
|
+
data?: unknown;
|
|
2591
2593
|
error?: unknown;
|
|
2592
2594
|
endpointName: string;
|
|
2593
2595
|
startedTimeStamp: number;
|
|
@@ -2604,7 +2606,7 @@ declare const useUnPinMessageMutation: <R extends Record<string, any> = ({
|
|
|
2604
2606
|
status: _reduxjs_toolkit_query.QueryStatus.pending;
|
|
2605
2607
|
} & {
|
|
2606
2608
|
requestId: string;
|
|
2607
|
-
data?:
|
|
2609
|
+
data?: unknown;
|
|
2608
2610
|
error?: unknown;
|
|
2609
2611
|
endpointName: string;
|
|
2610
2612
|
startedTimeStamp: number;
|
|
@@ -2621,14 +2623,14 @@ declare const useUnPinMessageMutation: <R extends Record<string, any> = ({
|
|
|
2621
2623
|
status: _reduxjs_toolkit_query.QueryStatus.rejected;
|
|
2622
2624
|
} & Omit<{
|
|
2623
2625
|
requestId: string;
|
|
2624
|
-
data?:
|
|
2626
|
+
data?: unknown;
|
|
2625
2627
|
error?: unknown;
|
|
2626
2628
|
endpointName: string;
|
|
2627
2629
|
startedTimeStamp: number;
|
|
2628
2630
|
fulfilledTimeStamp?: number;
|
|
2629
2631
|
}, "error"> & Required<Pick<{
|
|
2630
2632
|
requestId: string;
|
|
2631
|
-
data?:
|
|
2633
|
+
data?: unknown;
|
|
2632
2634
|
error?: unknown;
|
|
2633
2635
|
endpointName: string;
|
|
2634
2636
|
startedTimeStamp: number;
|
|
@@ -2643,13 +2645,19 @@ declare const useUnPinMessageMutation: <R extends Record<string, any> = ({
|
|
|
2643
2645
|
fixedCacheKey?: string;
|
|
2644
2646
|
} | undefined) => readonly [(arg: {
|
|
2645
2647
|
org: string;
|
|
2648
|
+
userId: string;
|
|
2649
|
+
requestBody: PinnedMessageRequest;
|
|
2646
2650
|
}) => _reduxjs_toolkit_query.MutationActionCreatorResult<_reduxjs_toolkit_query.MutationDefinition<{
|
|
2647
2651
|
org: string;
|
|
2652
|
+
userId: string;
|
|
2653
|
+
requestBody: PinnedMessageRequest;
|
|
2648
2654
|
}, _reduxjs_toolkit_query.BaseQueryFn<void, unknown, unknown, {
|
|
2649
2655
|
attempt?: number;
|
|
2650
|
-
} & _reduxjs_toolkit_query.RetryOptions, {}>, "pinnedMessages" | "recentMessages" | "messageFeedback",
|
|
2656
|
+
} & _reduxjs_toolkit_query.RetryOptions, {}>, "pinnedMessages" | "recentMessages" | "messageFeedback", unknown, "chatApiSlice", any>>, _reduxjs_toolkit_query.TSHelpersNoInfer<R> & {
|
|
2651
2657
|
originalArgs?: {
|
|
2652
2658
|
org: string;
|
|
2659
|
+
userId: string;
|
|
2660
|
+
requestBody: PinnedMessageRequest;
|
|
2653
2661
|
} | undefined;
|
|
2654
2662
|
reset: () => void;
|
|
2655
2663
|
}];
|
|
@@ -3165,16 +3173,16 @@ declare const useAddPinnedMessageMutation: <R extends Record<string, any> = ({
|
|
|
3165
3173
|
fixedCacheKey?: string;
|
|
3166
3174
|
} | undefined) => readonly [(arg: {
|
|
3167
3175
|
org: string;
|
|
3168
|
-
requestBody:
|
|
3176
|
+
requestBody: PinnedMessageRequest;
|
|
3169
3177
|
}) => _reduxjs_toolkit_query.MutationActionCreatorResult<_reduxjs_toolkit_query.MutationDefinition<{
|
|
3170
3178
|
org: string;
|
|
3171
|
-
requestBody:
|
|
3179
|
+
requestBody: PinnedMessageRequest;
|
|
3172
3180
|
}, _reduxjs_toolkit_query.BaseQueryFn<void, unknown, unknown, {
|
|
3173
3181
|
attempt?: number;
|
|
3174
3182
|
} & _reduxjs_toolkit_query.RetryOptions, {}>, "pinnedMessages" | "recentMessages" | "messageFeedback", _iblai_iblai_api.PinnedMessageCreate, "chatApiSlice", any>>, _reduxjs_toolkit_query.TSHelpersNoInfer<R> & {
|
|
3175
3183
|
originalArgs?: {
|
|
3176
3184
|
org: string;
|
|
3177
|
-
requestBody:
|
|
3185
|
+
requestBody: PinnedMessageRequest;
|
|
3178
3186
|
} | undefined;
|
|
3179
3187
|
reset: () => void;
|
|
3180
3188
|
}];
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
@@ -39468,7 +39483,19 @@ const chatApiSlice = createApi({
|
|
|
39468
39483
|
providesTags: ['pinnedMessages'],
|
|
39469
39484
|
}),
|
|
39470
39485
|
unPinMessage: builder.mutation({
|
|
39471
|
-
|
|
39486
|
+
// The generated `aiMentorOrgsUsersPinMessageDestroy` only sends org/user
|
|
39487
|
+
// path params and omits the body, but the DELETE pin-message endpoint
|
|
39488
|
+
// needs `{ session_id }` to know which pinned message to remove.
|
|
39489
|
+
queryFn: async (args, api, extraOptions) => {
|
|
39490
|
+
const url = `/api/ai-mentor/orgs/${args.org}/users/${args.userId}/pin-message/`;
|
|
39491
|
+
return iblFetchBaseQuery({
|
|
39492
|
+
url,
|
|
39493
|
+
method: 'DELETE',
|
|
39494
|
+
body: args.requestBody,
|
|
39495
|
+
service: SERVICES.DM,
|
|
39496
|
+
}, api, extraOptions);
|
|
39497
|
+
},
|
|
39498
|
+
invalidatesTags: ['pinnedMessages'],
|
|
39472
39499
|
}),
|
|
39473
39500
|
addPinnedMessage: builder.mutation({
|
|
39474
39501
|
...buildEndpointFromDmService(AiMentorService.aiMentorOrgsUsersPinMessageCreate),
|
|
@@ -39778,7 +39805,13 @@ const mentorApiSlice = createApi({
|
|
|
39778
39805
|
],
|
|
39779
39806
|
}),
|
|
39780
39807
|
getShareableLink: builder.query({
|
|
39781
|
-
|
|
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
|
+
}),
|
|
39782
39815
|
providesTags: (_result, _error, arg) => [
|
|
39783
39816
|
{ type: 'shareableLinks', id: `${arg.mentor}-${arg.org}` },
|
|
39784
39817
|
],
|