@iblai/web-utils 1.1.15 → 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,
@@ -13369,11 +13381,12 @@ Hook ${hookName} was either not provided or not a function.`);
13369
13381
  var createApi = /* @__PURE__ */ buildCreateApi(coreModule(), reactHooksModule());
13370
13382
 
13371
13383
  const STORAGE_KEYS = {
13372
- EDX_TOKEN_KEY: "edx_jwt_token",
13373
- DM_TOKEN_KEY: "dm_token",
13374
- AXD_TOKEN_KEY: "axd_token"};
13384
+ EDX_TOKEN_KEY: 'edx_jwt_token',
13385
+ DM_TOKEN_KEY: 'dm_token',
13386
+ AXD_TOKEN_KEY: 'axd_token'};
13375
13387
  var SERVICES;
13376
13388
  (function (SERVICES) {
13389
+ SERVICES["LEGACY_LMS"] = "LEGACY_LMS";
13377
13390
  SERVICES["LMS"] = "LMS";
13378
13391
  SERVICES["DM"] = "DM";
13379
13392
  SERVICES["AXD"] = "AXD";
@@ -13381,10 +13394,11 @@ var SERVICES;
13381
13394
 
13382
13395
  class Config {
13383
13396
  }
13384
- Config.lmsUrl = "https://learn.iblai.app";
13385
- Config.dmUrl = "https://base.manager.iblai.app";
13386
- Config.axdUrl = "https://base.manager.iblai.app";
13387
- 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';
13388
13402
  Config.httpErrorHandlers = {};
13389
13403
 
13390
13404
  class IblDataLayer {
@@ -13445,6 +13459,8 @@ const iblFakeBaseQuery = retry(fakeBaseQueryWithLogging, {
13445
13459
  */
13446
13460
  const getServiceUrl = (service) => {
13447
13461
  switch (service) {
13462
+ case SERVICES.LEGACY_LMS:
13463
+ return Config.legacyLmsUrl;
13448
13464
  case SERVICES.LMS:
13449
13465
  return Config.lmsUrl;
13450
13466
  case SERVICES.DM:
@@ -13498,6 +13514,7 @@ const buildEndpointFromService = (service, serviceFn) => {
13498
13514
  try {
13499
13515
  iblaiApi.OpenAPI.BASE = getServiceUrl(service);
13500
13516
  iblaiApi.OpenAPI.HEADERS = await getHeaders(service);
13517
+ iblaiApi.OpenAPI.CREDENTIALS = service === SERVICES.LEGACY_LMS ? 'include' : 'omit';
13501
13518
  // API request initiated
13502
13519
  const data = await serviceFn(args);
13503
13520
  // API response received
@@ -13533,6 +13550,7 @@ const isErrorObject = (data) => {
13533
13550
  const baseQuery = (service, jsonContentType = true, contentType, skipAuth = false) => fetchBaseQuery({
13534
13551
  baseUrl: getServiceUrl(service),
13535
13552
  timeout: 30000, // 30 second timeout
13553
+ credentials: service === SERVICES.LEGACY_LMS ? 'include' : 'omit',
13536
13554
  prepareHeaders: async (headers) => {
13537
13555
  // Only add auth headers if skipAuth is false
13538
13556
  if (!skipAuth) {
@@ -13646,6 +13664,7 @@ const buildEndpointFromServiceLegacy = (service, serviceFn) => {
13646
13664
  try {
13647
13665
  iblaiApi.OpenAPI.BASE = getServiceUrl(service);
13648
13666
  iblaiApi.OpenAPI.HEADERS = await getHeaders(service);
13667
+ iblaiApi.OpenAPI.CREDENTIALS = service === SERVICES.LEGACY_LMS ? 'include' : 'omit';
13649
13668
  const data = await serviceFn(...args);
13650
13669
  return { data };
13651
13670
  }
@@ -14152,7 +14171,7 @@ const AUTH_ENDPOINTS = {
14152
14171
  path: () => '/api/ibl/manager/consolidated-token/proxy/',
14153
14172
  },
14154
14173
  REFRESH_JWT_TOKEN: {
14155
- service: SERVICES.LMS,
14174
+ service: SERVICES.LEGACY_LMS,
14156
14175
  path: () => '/ibl-auth/request-jwt/',
14157
14176
  },
14158
14177
  };
@@ -14186,14 +14205,12 @@ createApi({
14186
14205
  isJson: false,
14187
14206
  method: 'POST',
14188
14207
  body: formData,
14189
- credentials: 'include',
14190
14208
  }),
14191
14209
  }),
14192
14210
  refreshJwtToken: builder.query({
14193
14211
  query: () => ({
14194
14212
  url: AUTH_ENDPOINTS.REFRESH_JWT_TOKEN.path(),
14195
14213
  service: AUTH_ENDPOINTS.REFRESH_JWT_TOKEN.service,
14196
- credentials: 'include',
14197
14214
  }),
14198
14215
  }),
14199
14216
  }),
@@ -14227,10 +14244,10 @@ createApi({
14227
14244
  try {
14228
14245
  const authHeaders = await getHeaders(SERVICES.LMS);
14229
14246
  const response = await fetch(`${Config.lmsUrl}${TENANTS_ENDPOINTS.GET_USER_TENANTS.path()}`, {
14230
- credentials: 'include',
14231
14247
  headers: {
14232
14248
  ...authHeaders,
14233
14249
  },
14250
+ credentials: 'omit',
14234
14251
  });
14235
14252
  if (!response.ok) {
14236
14253
  return {
@@ -14316,6 +14333,7 @@ createApi({
14316
14333
  const response = await fetch(url, {
14317
14334
  method: 'GET',
14318
14335
  headers: iblaiApi.OpenAPI.HEADERS,
14336
+ credentials: 'omit',
14319
14337
  });
14320
14338
  if (!response.ok) {
14321
14339
  const error = new Error('Failed to fetch platform users');
@@ -14350,6 +14368,7 @@ createApi({
14350
14368
  const response = await fetch(url, {
14351
14369
  method: 'GET',
14352
14370
  headers: iblaiApi.OpenAPI.HEADERS,
14371
+ credentials: 'omit',
14353
14372
  });
14354
14373
  if (!response.ok) {
14355
14374
  const error = new Error('Failed to fetch team details');
@@ -14371,6 +14390,7 @@ createApi({
14371
14390
  'Content-Type': 'application/json',
14372
14391
  },
14373
14392
  body: JSON.stringify(args.requestBody),
14393
+ credentials: 'omit',
14374
14394
  });
14375
14395
  if (!response.ok) {
14376
14396
  const error = new Error('Failed to update platform user role with policies');
@@ -14596,6 +14616,7 @@ createApi({
14596
14616
  const response = await fetch(url, {
14597
14617
  method: 'GET',
14598
14618
  headers: iblaiApi.OpenAPI.HEADERS,
14619
+ credentials: 'omit',
14599
14620
  });
14600
14621
  if (!response.ok) {
14601
14622
  const error = new Error('Failed to fetch RBAC group details');
@@ -14632,6 +14653,7 @@ createApi({
14632
14653
  const response = await fetch(url, {
14633
14654
  method: 'GET',
14634
14655
  headers: iblaiApi.OpenAPI.HEADERS,
14656
+ credentials: 'omit',
14635
14657
  });
14636
14658
  if (!response.ok) {
14637
14659
  const error = new Error('Failed to fetch RBAC policy details');
@@ -14672,6 +14694,7 @@ createApi({
14672
14694
  const response = await fetch(url, {
14673
14695
  method: 'GET',
14674
14696
  headers: iblaiApi.OpenAPI.HEADERS,
14697
+ credentials: 'omit',
14675
14698
  });
14676
14699
  if (!response.ok) {
14677
14700
  const error = new Error('Failed to fetch RBAC role details');
@@ -14782,6 +14805,7 @@ createApi({
14782
14805
  const response = await fetch(url, {
14783
14806
  method: 'GET',
14784
14807
  headers: iblaiApi.OpenAPI.HEADERS,
14808
+ credentials: 'omit',
14785
14809
  });
14786
14810
  if (!response.ok) {
14787
14811
  const error = new Error('Failed to fetch credentials');
@@ -15757,6 +15781,7 @@ createApi({
15757
15781
  const response = await fetch(url, {
15758
15782
  method: 'GET',
15759
15783
  headers: iblaiApi.OpenAPI.HEADERS,
15784
+ credentials: 'omit',
15760
15785
  });
15761
15786
  if (!response.ok) {
15762
15787
  const error = new Error('Failed to fetch program invitations');
@@ -15857,6 +15882,7 @@ const performCareerRequest = async (path, options = {}) => {
15857
15882
  method: (_b = options.method) !== null && _b !== void 0 ? _b : 'GET',
15858
15883
  body: (_c = options.body) !== null && _c !== void 0 ? _c : null,
15859
15884
  headers,
15885
+ credentials: 'omit',
15860
15886
  });
15861
15887
  if (!response.ok) {
15862
15888
  const errorData = await parseResponse(response);
@@ -17429,6 +17455,182 @@ createApi({
17429
17455
  }),
17430
17456
  });
17431
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
+
17432
17634
  function useMentorSettings({ mentorId, tenantKey, username, isPublicRoute, }) {
17433
17635
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
17434
17636
  const isLoggedIn = username !== ANONYMOUS_USERNAME;