@iblai/web-utils 1.1.14 → 1.1.16

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.js CHANGED
@@ -559,6 +559,13 @@ const MENTOR_AI_CONFIG = {
559
559
  description: "Allow users to access the mentors from the community.",
560
560
  type: "boolean",
561
561
  },
562
+ {
563
+ slug: "mentor_report_inappropriate_content",
564
+ label: "Report Inappropriate Content",
565
+ defaultValue: true,
566
+ description: "Allow users to report inappropriate content.",
567
+ type: "boolean",
568
+ },
562
569
  {
563
570
  slug: "help_center_url",
564
571
  label: "Help Center URL",
@@ -1278,6 +1285,10 @@ const useTenantMetadata = ({ org, spa, skip = false, }) => {
1278
1285
  var _a;
1279
1286
  return (_a = data === null || data === void 0 ? void 0 : data.metadata) === null || _a === void 0 ? void 0 : _a.support_email;
1280
1287
  };
1288
+ const isMentorInappropriateContentEnabled = () => {
1289
+ var _a;
1290
+ return ((_a = data === null || data === void 0 ? void 0 : data.metadata) === null || _a === void 0 ? void 0 : _a.mentor_report_inappropriate_content) !== false;
1291
+ };
1281
1292
  const getAllMetadatas = () => {
1282
1293
  const metadatas = loadMetadataConfig(spa);
1283
1294
  return metadatas.map((_metadata) => {
@@ -1298,6 +1309,7 @@ const useTenantMetadata = ({ org, spa, skip = false, }) => {
1298
1309
  isMentorAIEnabled,
1299
1310
  isSkillsLeaderBoardEnabled,
1300
1311
  getEmbeddedMentorToUse,
1312
+ isMentorInappropriateContentEnabled,
1301
1313
  metadataLoaded: !isLoading && (data === null || data === void 0 ? void 0 : data.metadata),
1302
1314
  getAllMetadatas,
1303
1315
  getSupportEmail,
@@ -3713,19 +3725,18 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
3713
3725
  userId: username,
3714
3726
  });
3715
3727
  console.log("[determineMentorToRedirectTo] recentlyAccessedResult ", recentlyAccessedResult);
3716
- // @ts-expect-error - API returns different shape than generated types
3717
3728
  const recentlyAccessedMentors = recentlyAccessedResult.data;
3718
3729
  const starredMentors = recentlyAccessedMentors === null || recentlyAccessedMentors === void 0 ? void 0 : recentlyAccessedMentors.starred_mentors;
3719
3730
  let recentMentors = recentlyAccessedMentors === null || recentlyAccessedMentors === void 0 ? void 0 : recentlyAccessedMentors.recent_mentors;
3720
3731
  console.log("[determineMentorToRedirectTo] starredMentors ", starredMentors);
3721
- if (starredMentors.length > 0) {
3732
+ if (starredMentors && starredMentors.length > 0) {
3722
3733
  const starredMentor = starredMentors[0];
3723
3734
  if (starredMentor === null || starredMentor === void 0 ? void 0 : starredMentor.unique_id) {
3724
3735
  return starredMentor;
3725
3736
  }
3726
3737
  }
3727
3738
  console.log("[determineMentorToRedirectTo] recentMentors ", recentMentors);
3728
- if (recentMentors.length > 0) {
3739
+ if (recentMentors && recentMentors.length > 0) {
3729
3740
  const recentMentor = recentMentors[0];
3730
3741
  if (recentMentor === null || recentMentor === void 0 ? void 0 : recentMentor.unique_id) {
3731
3742
  return recentMentor;
@@ -13370,11 +13381,12 @@ Hook ${hookName} was either not provided or not a function.`);
13370
13381
  var createApi = /* @__PURE__ */ buildCreateApi(coreModule(), reactHooksModule());
13371
13382
 
13372
13383
  const STORAGE_KEYS = {
13373
- EDX_TOKEN_KEY: "edx_jwt_token",
13374
- DM_TOKEN_KEY: "dm_token",
13375
- AXD_TOKEN_KEY: "axd_token"};
13384
+ EDX_TOKEN_KEY: 'edx_jwt_token',
13385
+ DM_TOKEN_KEY: 'dm_token',
13386
+ AXD_TOKEN_KEY: 'axd_token'};
13376
13387
  var SERVICES;
13377
13388
  (function (SERVICES) {
13389
+ SERVICES["LEGACY_LMS"] = "LEGACY_LMS";
13378
13390
  SERVICES["LMS"] = "LMS";
13379
13391
  SERVICES["DM"] = "DM";
13380
13392
  SERVICES["AXD"] = "AXD";
@@ -13382,10 +13394,11 @@ var SERVICES;
13382
13394
 
13383
13395
  class Config {
13384
13396
  }
13385
- Config.lmsUrl = "https://learn.iblai.app";
13386
- Config.dmUrl = "https://base.manager.iblai.app";
13387
- Config.axdUrl = "https://base.manager.iblai.app";
13388
- Config.mentorIframeUrl = "https://mentor.iblai.tech";
13397
+ Config.legacyLmsUrl = 'https://learn.iblai.app';
13398
+ Config.lmsUrl = 'https://learn.iblai.app';
13399
+ Config.dmUrl = 'https://base.manager.iblai.app';
13400
+ Config.axdUrl = 'https://base.manager.iblai.app';
13401
+ Config.mentorIframeUrl = 'https://mentor.iblai.tech';
13389
13402
  Config.httpErrorHandlers = {};
13390
13403
 
13391
13404
  class IblDataLayer {
@@ -13446,6 +13459,8 @@ const iblFakeBaseQuery = retry(fakeBaseQueryWithLogging, {
13446
13459
  */
13447
13460
  const getServiceUrl = (service) => {
13448
13461
  switch (service) {
13462
+ case SERVICES.LEGACY_LMS:
13463
+ return Config.legacyLmsUrl;
13449
13464
  case SERVICES.LMS:
13450
13465
  return Config.lmsUrl;
13451
13466
  case SERVICES.DM:
@@ -13499,6 +13514,7 @@ const buildEndpointFromService = (service, serviceFn) => {
13499
13514
  try {
13500
13515
  iblaiApi.OpenAPI.BASE = getServiceUrl(service);
13501
13516
  iblaiApi.OpenAPI.HEADERS = await getHeaders(service);
13517
+ iblaiApi.OpenAPI.CREDENTIALS = service === SERVICES.LEGACY_LMS ? 'include' : 'omit';
13502
13518
  // API request initiated
13503
13519
  const data = await serviceFn(args);
13504
13520
  // API response received
@@ -13534,6 +13550,7 @@ const isErrorObject = (data) => {
13534
13550
  const baseQuery = (service, jsonContentType = true, contentType, skipAuth = false) => fetchBaseQuery({
13535
13551
  baseUrl: getServiceUrl(service),
13536
13552
  timeout: 30000, // 30 second timeout
13553
+ credentials: service === SERVICES.LEGACY_LMS ? 'include' : 'omit',
13537
13554
  prepareHeaders: async (headers) => {
13538
13555
  // Only add auth headers if skipAuth is false
13539
13556
  if (!skipAuth) {
@@ -13647,6 +13664,7 @@ const buildEndpointFromServiceLegacy = (service, serviceFn) => {
13647
13664
  try {
13648
13665
  iblaiApi.OpenAPI.BASE = getServiceUrl(service);
13649
13666
  iblaiApi.OpenAPI.HEADERS = await getHeaders(service);
13667
+ iblaiApi.OpenAPI.CREDENTIALS = service === SERVICES.LEGACY_LMS ? 'include' : 'omit';
13650
13668
  const data = await serviceFn(...args);
13651
13669
  return { data };
13652
13670
  }
@@ -14153,7 +14171,7 @@ const AUTH_ENDPOINTS = {
14153
14171
  path: () => '/api/ibl/manager/consolidated-token/proxy/',
14154
14172
  },
14155
14173
  REFRESH_JWT_TOKEN: {
14156
- service: SERVICES.LMS,
14174
+ service: SERVICES.LEGACY_LMS,
14157
14175
  path: () => '/ibl-auth/request-jwt/',
14158
14176
  },
14159
14177
  };
@@ -14187,14 +14205,12 @@ createApi({
14187
14205
  isJson: false,
14188
14206
  method: 'POST',
14189
14207
  body: formData,
14190
- credentials: 'include',
14191
14208
  }),
14192
14209
  }),
14193
14210
  refreshJwtToken: builder.query({
14194
14211
  query: () => ({
14195
14212
  url: AUTH_ENDPOINTS.REFRESH_JWT_TOKEN.path(),
14196
14213
  service: AUTH_ENDPOINTS.REFRESH_JWT_TOKEN.service,
14197
- credentials: 'include',
14198
14214
  }),
14199
14215
  }),
14200
14216
  }),
@@ -14228,10 +14244,10 @@ createApi({
14228
14244
  try {
14229
14245
  const authHeaders = await getHeaders(SERVICES.LMS);
14230
14246
  const response = await fetch(`${Config.lmsUrl}${TENANTS_ENDPOINTS.GET_USER_TENANTS.path()}`, {
14231
- credentials: 'include',
14232
14247
  headers: {
14233
14248
  ...authHeaders,
14234
14249
  },
14250
+ credentials: 'omit',
14235
14251
  });
14236
14252
  if (!response.ok) {
14237
14253
  return {
@@ -14317,6 +14333,7 @@ createApi({
14317
14333
  const response = await fetch(url, {
14318
14334
  method: 'GET',
14319
14335
  headers: iblaiApi.OpenAPI.HEADERS,
14336
+ credentials: 'omit',
14320
14337
  });
14321
14338
  if (!response.ok) {
14322
14339
  const error = new Error('Failed to fetch platform users');
@@ -14351,6 +14368,7 @@ createApi({
14351
14368
  const response = await fetch(url, {
14352
14369
  method: 'GET',
14353
14370
  headers: iblaiApi.OpenAPI.HEADERS,
14371
+ credentials: 'omit',
14354
14372
  });
14355
14373
  if (!response.ok) {
14356
14374
  const error = new Error('Failed to fetch team details');
@@ -14372,6 +14390,7 @@ createApi({
14372
14390
  'Content-Type': 'application/json',
14373
14391
  },
14374
14392
  body: JSON.stringify(args.requestBody),
14393
+ credentials: 'omit',
14375
14394
  });
14376
14395
  if (!response.ok) {
14377
14396
  const error = new Error('Failed to update platform user role with policies');
@@ -14597,6 +14616,7 @@ createApi({
14597
14616
  const response = await fetch(url, {
14598
14617
  method: 'GET',
14599
14618
  headers: iblaiApi.OpenAPI.HEADERS,
14619
+ credentials: 'omit',
14600
14620
  });
14601
14621
  if (!response.ok) {
14602
14622
  const error = new Error('Failed to fetch RBAC group details');
@@ -14633,6 +14653,7 @@ createApi({
14633
14653
  const response = await fetch(url, {
14634
14654
  method: 'GET',
14635
14655
  headers: iblaiApi.OpenAPI.HEADERS,
14656
+ credentials: 'omit',
14636
14657
  });
14637
14658
  if (!response.ok) {
14638
14659
  const error = new Error('Failed to fetch RBAC policy details');
@@ -14673,6 +14694,7 @@ createApi({
14673
14694
  const response = await fetch(url, {
14674
14695
  method: 'GET',
14675
14696
  headers: iblaiApi.OpenAPI.HEADERS,
14697
+ credentials: 'omit',
14676
14698
  });
14677
14699
  if (!response.ok) {
14678
14700
  const error = new Error('Failed to fetch RBAC role details');
@@ -14783,6 +14805,7 @@ createApi({
14783
14805
  const response = await fetch(url, {
14784
14806
  method: 'GET',
14785
14807
  headers: iblaiApi.OpenAPI.HEADERS,
14808
+ credentials: 'omit',
14786
14809
  });
14787
14810
  if (!response.ok) {
14788
14811
  const error = new Error('Failed to fetch credentials');
@@ -15758,6 +15781,7 @@ createApi({
15758
15781
  const response = await fetch(url, {
15759
15782
  method: 'GET',
15760
15783
  headers: iblaiApi.OpenAPI.HEADERS,
15784
+ credentials: 'omit',
15761
15785
  });
15762
15786
  if (!response.ok) {
15763
15787
  const error = new Error('Failed to fetch program invitations');
@@ -15858,6 +15882,7 @@ const performCareerRequest = async (path, options = {}) => {
15858
15882
  method: (_b = options.method) !== null && _b !== void 0 ? _b : 'GET',
15859
15883
  body: (_c = options.body) !== null && _c !== void 0 ? _c : null,
15860
15884
  headers,
15885
+ credentials: 'omit',
15861
15886
  });
15862
15887
  if (!response.ok) {
15863
15888
  const errorData = await parseResponse(response);
@@ -17430,6 +17455,182 @@ createApi({
17430
17455
  }),
17431
17456
  });
17432
17457
 
17458
+ const WORKFLOWS_REDUCER_PATH = 'workflowsApiSlice';
17459
+ const WORKFLOWS_ENDPOINTS = {
17460
+ LIST: {
17461
+ service: SERVICES.AXD,
17462
+ path: (org) => `/api/ai-mentor/orgs/${org}/workflows/`,
17463
+ },
17464
+ CREATE: {
17465
+ service: SERVICES.AXD,
17466
+ path: (org) => `/api/ai-mentor/orgs/${org}/workflows/`,
17467
+ },
17468
+ RETRIEVE: {
17469
+ service: SERVICES.AXD,
17470
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/`,
17471
+ },
17472
+ UPDATE: {
17473
+ service: SERVICES.AXD,
17474
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/`,
17475
+ },
17476
+ DELETE: {
17477
+ service: SERVICES.AXD,
17478
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/`,
17479
+ },
17480
+ ACTIVATE: {
17481
+ service: SERVICES.AXD,
17482
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/activate/`,
17483
+ },
17484
+ DEACTIVATE: {
17485
+ service: SERVICES.AXD,
17486
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/deactivate/`,
17487
+ },
17488
+ PUBLISH: {
17489
+ service: SERVICES.AXD,
17490
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/publish/`,
17491
+ },
17492
+ UNPUBLISH: {
17493
+ service: SERVICES.AXD,
17494
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/unpublish/`,
17495
+ },
17496
+ VALIDATE: {
17497
+ service: SERVICES.AXD,
17498
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/validate/`,
17499
+ },
17500
+ CHAT: {
17501
+ service: SERVICES.AXD,
17502
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/chat/`,
17503
+ },
17504
+ NODE_TYPES: {
17505
+ service: SERVICES.AXD,
17506
+ path: (org) => `/api/ai-mentor/orgs/${org}/workflows/node-types/`,
17507
+ },
17508
+ };
17509
+ const WORKFLOWS_QUERY_KEYS = {
17510
+ LIST: () => ['WORKFLOWS'],
17511
+ DETAILS: () => ['WORKFLOW_DETAILS'],
17512
+ NODE_TYPES: () => ['WORKFLOW_NODE_TYPES'],
17513
+ };
17514
+
17515
+ createApi({
17516
+ reducerPath: WORKFLOWS_REDUCER_PATH,
17517
+ tagTypes: [
17518
+ ...WORKFLOWS_QUERY_KEYS.LIST(),
17519
+ ...WORKFLOWS_QUERY_KEYS.DETAILS(),
17520
+ ...WORKFLOWS_QUERY_KEYS.NODE_TYPES(),
17521
+ ],
17522
+ baseQuery: iblFetchBaseQuery,
17523
+ endpoints: (builder) => ({
17524
+ getWorkflows: builder.query({
17525
+ query: ({ org, params }) => ({
17526
+ url: WORKFLOWS_ENDPOINTS.LIST.path(org),
17527
+ params,
17528
+ service: WORKFLOWS_ENDPOINTS.LIST.service,
17529
+ }),
17530
+ providesTags: WORKFLOWS_QUERY_KEYS.LIST(),
17531
+ }),
17532
+ getWorkflow: builder.query({
17533
+ query: ({ org, uniqueId }) => ({
17534
+ url: WORKFLOWS_ENDPOINTS.RETRIEVE.path(org, uniqueId),
17535
+ service: WORKFLOWS_ENDPOINTS.RETRIEVE.service,
17536
+ }),
17537
+ providesTags: WORKFLOWS_QUERY_KEYS.DETAILS(),
17538
+ }),
17539
+ createWorkflow: builder.mutation({
17540
+ query: ({ org, data }) => ({
17541
+ url: WORKFLOWS_ENDPOINTS.CREATE.path(org),
17542
+ method: 'POST',
17543
+ body: data,
17544
+ service: WORKFLOWS_ENDPOINTS.CREATE.service,
17545
+ }),
17546
+ invalidatesTags: WORKFLOWS_QUERY_KEYS.LIST(),
17547
+ }),
17548
+ // Full update (PUT) - replaces entire workflow
17549
+ updateWorkflow: builder.mutation({
17550
+ query: ({ org, uniqueId, data }) => ({
17551
+ url: WORKFLOWS_ENDPOINTS.UPDATE.path(org, uniqueId),
17552
+ method: 'PUT',
17553
+ body: data,
17554
+ service: WORKFLOWS_ENDPOINTS.UPDATE.service,
17555
+ }),
17556
+ invalidatesTags: [...WORKFLOWS_QUERY_KEYS.LIST(), ...WORKFLOWS_QUERY_KEYS.DETAILS()],
17557
+ }),
17558
+ // Partial update (PATCH) - updates only provided fields
17559
+ patchWorkflow: builder.mutation({
17560
+ query: ({ org, uniqueId, data }) => ({
17561
+ url: WORKFLOWS_ENDPOINTS.UPDATE.path(org, uniqueId),
17562
+ method: 'PATCH',
17563
+ body: data,
17564
+ service: WORKFLOWS_ENDPOINTS.UPDATE.service,
17565
+ }),
17566
+ invalidatesTags: [...WORKFLOWS_QUERY_KEYS.LIST(), ...WORKFLOWS_QUERY_KEYS.DETAILS()],
17567
+ }),
17568
+ deleteWorkflow: builder.mutation({
17569
+ query: ({ org, uniqueId }) => ({
17570
+ url: WORKFLOWS_ENDPOINTS.DELETE.path(org, uniqueId),
17571
+ method: 'DELETE',
17572
+ service: WORKFLOWS_ENDPOINTS.DELETE.service,
17573
+ }),
17574
+ invalidatesTags: WORKFLOWS_QUERY_KEYS.LIST(),
17575
+ }),
17576
+ activateWorkflow: builder.mutation({
17577
+ query: ({ org, uniqueId }) => ({
17578
+ url: WORKFLOWS_ENDPOINTS.ACTIVATE.path(org, uniqueId),
17579
+ method: 'POST',
17580
+ service: WORKFLOWS_ENDPOINTS.ACTIVATE.service,
17581
+ }),
17582
+ invalidatesTags: [...WORKFLOWS_QUERY_KEYS.LIST(), ...WORKFLOWS_QUERY_KEYS.DETAILS()],
17583
+ }),
17584
+ deactivateWorkflow: builder.mutation({
17585
+ query: ({ org, uniqueId }) => ({
17586
+ url: WORKFLOWS_ENDPOINTS.DEACTIVATE.path(org, uniqueId),
17587
+ method: 'POST',
17588
+ service: WORKFLOWS_ENDPOINTS.DEACTIVATE.service,
17589
+ }),
17590
+ invalidatesTags: [...WORKFLOWS_QUERY_KEYS.LIST(), ...WORKFLOWS_QUERY_KEYS.DETAILS()],
17591
+ }),
17592
+ publishWorkflow: builder.mutation({
17593
+ query: ({ org, uniqueId, data }) => ({
17594
+ url: WORKFLOWS_ENDPOINTS.PUBLISH.path(org, uniqueId),
17595
+ method: 'POST',
17596
+ body: data,
17597
+ service: WORKFLOWS_ENDPOINTS.PUBLISH.service,
17598
+ }),
17599
+ invalidatesTags: [...WORKFLOWS_QUERY_KEYS.LIST(), ...WORKFLOWS_QUERY_KEYS.DETAILS()],
17600
+ }),
17601
+ unpublishWorkflow: builder.mutation({
17602
+ query: ({ org, uniqueId }) => ({
17603
+ url: WORKFLOWS_ENDPOINTS.UNPUBLISH.path(org, uniqueId),
17604
+ method: 'POST',
17605
+ service: WORKFLOWS_ENDPOINTS.UNPUBLISH.service,
17606
+ }),
17607
+ invalidatesTags: [...WORKFLOWS_QUERY_KEYS.LIST(), ...WORKFLOWS_QUERY_KEYS.DETAILS()],
17608
+ }),
17609
+ validateWorkflow: builder.mutation({
17610
+ query: ({ org, uniqueId }) => ({
17611
+ url: WORKFLOWS_ENDPOINTS.VALIDATE.path(org, uniqueId),
17612
+ method: 'POST',
17613
+ service: WORKFLOWS_ENDPOINTS.VALIDATE.service,
17614
+ }),
17615
+ }),
17616
+ chatWithWorkflow: builder.mutation({
17617
+ query: ({ org, uniqueId, message }) => ({
17618
+ url: WORKFLOWS_ENDPOINTS.CHAT.path(org, uniqueId),
17619
+ method: 'POST',
17620
+ body: { message },
17621
+ service: WORKFLOWS_ENDPOINTS.CHAT.service,
17622
+ }),
17623
+ }),
17624
+ getNodeTypes: builder.query({
17625
+ query: ({ org }) => ({
17626
+ url: WORKFLOWS_ENDPOINTS.NODE_TYPES.path(org),
17627
+ service: WORKFLOWS_ENDPOINTS.NODE_TYPES.service,
17628
+ }),
17629
+ providesTags: WORKFLOWS_QUERY_KEYS.NODE_TYPES(),
17630
+ }),
17631
+ }),
17632
+ });
17633
+
17433
17634
  function useMentorSettings({ mentorId, tenantKey, username, isPublicRoute, }) {
17434
17635
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
17435
17636
  const isLoggedIn = username !== ANONYMOUS_USERNAME;