@iblai/web-utils 1.1.15 → 1.1.17

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.
@@ -0,0 +1,57 @@
1
+ import { SERVICES } from '@data-layer/constants';
2
+ export declare const WORKFLOWS_REDUCER_PATH = "workflowsApiSlice";
3
+ export declare const WORKFLOWS_ENDPOINTS: {
4
+ LIST: {
5
+ service: SERVICES;
6
+ path: (org: string) => string;
7
+ };
8
+ CREATE: {
9
+ service: SERVICES;
10
+ path: (org: string) => string;
11
+ };
12
+ RETRIEVE: {
13
+ service: SERVICES;
14
+ path: (org: string, uniqueId: string) => string;
15
+ };
16
+ UPDATE: {
17
+ service: SERVICES;
18
+ path: (org: string, uniqueId: string) => string;
19
+ };
20
+ DELETE: {
21
+ service: SERVICES;
22
+ path: (org: string, uniqueId: string) => string;
23
+ };
24
+ ACTIVATE: {
25
+ service: SERVICES;
26
+ path: (org: string, uniqueId: string) => string;
27
+ };
28
+ DEACTIVATE: {
29
+ service: SERVICES;
30
+ path: (org: string, uniqueId: string) => string;
31
+ };
32
+ PUBLISH: {
33
+ service: SERVICES;
34
+ path: (org: string, uniqueId: string) => string;
35
+ };
36
+ UNPUBLISH: {
37
+ service: SERVICES;
38
+ path: (org: string, uniqueId: string) => string;
39
+ };
40
+ VALIDATE: {
41
+ service: SERVICES;
42
+ path: (org: string, uniqueId: string) => string;
43
+ };
44
+ CHAT: {
45
+ service: SERVICES;
46
+ path: (org: string, uniqueId: string) => string;
47
+ };
48
+ NODE_TYPES: {
49
+ service: SERVICES;
50
+ path: (org: string) => string;
51
+ };
52
+ };
53
+ export declare const WORKFLOWS_QUERY_KEYS: {
54
+ LIST: () => readonly ["WORKFLOWS"];
55
+ DETAILS: () => readonly ["WORKFLOW_DETAILS"];
56
+ NODE_TYPES: () => readonly ["WORKFLOW_NODE_TYPES"];
57
+ };
@@ -0,0 +1,130 @@
1
+ export type WorkflowDefinition = {
2
+ nodes: unknown[];
3
+ edges: unknown[];
4
+ };
5
+ export type Workflow = {
6
+ readonly id: number;
7
+ readonly unique_id: string;
8
+ name: string;
9
+ description?: string;
10
+ definition: WorkflowDefinition;
11
+ is_active?: boolean;
12
+ is_template?: boolean;
13
+ parent_workflow?: number | null;
14
+ readonly platform: number;
15
+ readonly platform_key: string;
16
+ readonly platform_name: string;
17
+ readonly created_by: number;
18
+ readonly created_by_username: string;
19
+ readonly created_at: string;
20
+ readonly updated_at: string;
21
+ readonly node_count: number;
22
+ readonly edge_count: number;
23
+ readonly entry_mentor_id: string;
24
+ chat_name?: string;
25
+ chat_proactive_response?: string;
26
+ };
27
+ export type PaginatedWorkflowList = {
28
+ count: number;
29
+ next?: string | null;
30
+ previous?: string | null;
31
+ results: Workflow[];
32
+ };
33
+ export type GetWorkflowsParams = {
34
+ search?: string;
35
+ is_active?: boolean;
36
+ is_template?: boolean;
37
+ created_by?: string;
38
+ sort?: string;
39
+ limit?: number;
40
+ offset?: number;
41
+ };
42
+ export type GetWorkflowsArgs = {
43
+ org: string;
44
+ params?: GetWorkflowsParams;
45
+ };
46
+ export type GetWorkflowArgs = {
47
+ org: string;
48
+ uniqueId: string;
49
+ };
50
+ export type CreateWorkflowData = {
51
+ name: string;
52
+ description?: string;
53
+ definition?: WorkflowDefinition;
54
+ };
55
+ export type CreateWorkflowArgs = {
56
+ org: string;
57
+ data: CreateWorkflowData;
58
+ };
59
+ export type PatchWorkflowData = {
60
+ name?: string;
61
+ description?: string;
62
+ definition?: WorkflowDefinition;
63
+ chat_name?: string;
64
+ chat_proactive_response?: string;
65
+ };
66
+ export type PatchWorkflowArgs = {
67
+ org: string;
68
+ uniqueId: string;
69
+ data: PatchWorkflowData;
70
+ };
71
+ export type UpdateWorkflowData = {
72
+ name: string;
73
+ description?: string;
74
+ definition: WorkflowDefinition;
75
+ chat_name?: string;
76
+ chat_proactive_response?: string;
77
+ };
78
+ export type UpdateWorkflowArgs = {
79
+ org: string;
80
+ uniqueId: string;
81
+ data: UpdateWorkflowData;
82
+ };
83
+ export type DeleteWorkflowArgs = {
84
+ org: string;
85
+ uniqueId: string;
86
+ };
87
+ export type WorkflowActionArgs = {
88
+ org: string;
89
+ uniqueId: string;
90
+ };
91
+ export type PublishWorkflowArgs = {
92
+ org: string;
93
+ uniqueId: string;
94
+ data?: {
95
+ definition?: WorkflowDefinition;
96
+ };
97
+ };
98
+ export type WorkflowValidationResponse = {
99
+ is_valid: boolean;
100
+ errors: string[];
101
+ warnings: string[];
102
+ workflow?: Workflow;
103
+ };
104
+ export type WorkflowChatArgs = {
105
+ org: string;
106
+ uniqueId: string;
107
+ message: string;
108
+ };
109
+ export type WorkflowChatResponse = {
110
+ response: string;
111
+ workflow_id: string;
112
+ session_id: string;
113
+ };
114
+ export type GetNodeTypesArgs = {
115
+ org: string;
116
+ };
117
+ export type NodeTypeInfo = {
118
+ label: string;
119
+ category: string;
120
+ executable: boolean;
121
+ description: string;
122
+ required_fields: string[];
123
+ optional_fields: string[];
124
+ aliases?: string[];
125
+ status?: string;
126
+ };
127
+ export type NodeTypesResponse = {
128
+ node_types: Record<string, NodeTypeInfo>;
129
+ categories: string[];
130
+ };
@@ -87,6 +87,9 @@ export * from './features/search/constants';
87
87
  export * from './features/projects/api-slice';
88
88
  export * from './features/projects/constants';
89
89
  export type { Project, ProjectsFetchResponse, GetProjectsParams, GetProjectsArgs, GetProjectDetailsArgs, CreateProjectData, CreateProjectArgs, UpdateProjectData, UpdateProjectArgs, DeleteProjectArgs, } from './features/projects/types';
90
+ export * from './features/workflows/api-slice';
91
+ export * from './features/workflows/types';
92
+ export * from './features/workflows/constants';
90
93
  export * from './reducers';
91
94
  export * from './utils';
92
95
  export type { CustomQueryArgs } from './features/utils';
@@ -1,2 +1,2 @@
1
- import { StorageService } from "@data-layer/services/StorageService";
2
- export declare const initializeDataLayer: (dmUrl: string, lmsUrl: string, storageService: StorageService, httpErrorHandler?: Record<number, () => void>) => void;
1
+ import { StorageService } from '@data-layer/services/StorageService';
2
+ export declare const initializeDataLayer: (dmUrl: string, lmsUrl: string, legacyLmsUrl: string, storageService: StorageService, httpErrorHandler?: Record<number, () => void>) => void;
package/dist/index.d.ts CHANGED
@@ -1369,6 +1369,7 @@ declare const useTenantMetadata: ({ org, spa, skip, }: {
1369
1369
  isMentorAIEnabled: () => boolean;
1370
1370
  isSkillsLeaderBoardEnabled: () => boolean;
1371
1371
  getEmbeddedMentorToUse: () => any;
1372
+ isMentorInappropriateContentEnabled: () => boolean;
1372
1373
  metadataLoaded: any;
1373
1374
  getAllMetadatas: () => {
1374
1375
  value: any;
package/dist/index.esm.js CHANGED
@@ -539,6 +539,13 @@ const MENTOR_AI_CONFIG = {
539
539
  description: "Allow users to access the mentors from the community.",
540
540
  type: "boolean",
541
541
  },
542
+ {
543
+ slug: "mentor_report_inappropriate_content",
544
+ label: "Report Inappropriate Content",
545
+ defaultValue: true,
546
+ description: "Allow users to report inappropriate content.",
547
+ type: "boolean",
548
+ },
542
549
  {
543
550
  slug: "help_center_url",
544
551
  label: "Help Center URL",
@@ -1258,6 +1265,10 @@ const useTenantMetadata = ({ org, spa, skip = false, }) => {
1258
1265
  var _a;
1259
1266
  return (_a = data === null || data === void 0 ? void 0 : data.metadata) === null || _a === void 0 ? void 0 : _a.support_email;
1260
1267
  };
1268
+ const isMentorInappropriateContentEnabled = () => {
1269
+ var _a;
1270
+ return ((_a = data === null || data === void 0 ? void 0 : data.metadata) === null || _a === void 0 ? void 0 : _a.mentor_report_inappropriate_content) !== false;
1271
+ };
1261
1272
  const getAllMetadatas = () => {
1262
1273
  const metadatas = loadMetadataConfig(spa);
1263
1274
  return metadatas.map((_metadata) => {
@@ -1278,6 +1289,7 @@ const useTenantMetadata = ({ org, spa, skip = false, }) => {
1278
1289
  isMentorAIEnabled,
1279
1290
  isSkillsLeaderBoardEnabled,
1280
1291
  getEmbeddedMentorToUse,
1292
+ isMentorInappropriateContentEnabled,
1281
1293
  metadataLoaded: !isLoading && (data === null || data === void 0 ? void 0 : data.metadata),
1282
1294
  getAllMetadatas,
1283
1295
  getSupportEmail,
@@ -1299,7 +1311,7 @@ const useSubscriptionHandlerV2 = (subscriptionFlow) => {
1299
1311
  const [getUserApps] = useLazyGetUserAppsQuery();
1300
1312
  const CREDIT_INTERVAL_CHECK_COUNTER = 60 * 60 * 1000; // 1 hour
1301
1313
  const { getSupportEmail } = useTenantMetadata({
1302
- org: subscriptionFlow.getCurrentTenantOrg(),
1314
+ org: subscriptionFlow.getCurrentTenantKey(),
1303
1315
  });
1304
1316
  /**
1305
1317
  * Checks if user is currently on the main tenant
@@ -3419,13 +3431,6 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
3419
3431
  // user is not authenticated so we don't need to do anything that concerns an authenticated user
3420
3432
  return;
3421
3433
  }
3422
- // Logged-in user on a public route (e.g. shareable link) visiting another tenant
3423
- // — treat as visitor, skip tenant join/token/RBAC calls that will 403
3424
- if (userIsAccessingPublicRoute) {
3425
- saveVisitingTenant === null || saveVisitingTenant === void 0 ? void 0 : saveVisitingTenant(newCurrentTenant);
3426
- setIsLoading(false);
3427
- return;
3428
- }
3429
3434
  const { data: tenants } = await fetchUserTenants();
3430
3435
  const enhancedTenants = await enhanceTenants(tenants, data);
3431
3436
  saveUserTenants(enhancedTenants);
@@ -7068,7 +7073,6 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
7068
7073
  MAX_INITIAL_WEBSOCKET_CONNECTION_ATTEMPTS;
7069
7074
  if (shouldShowError) {
7070
7075
  console.error("[ws-error] WebSocket connection error exceeded max attempts", {
7071
- error,
7072
7076
  wsUrl,
7073
7077
  tenant: flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig.tenant,
7074
7078
  mentorId: flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig.name,
@@ -7771,7 +7775,6 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
7771
7775
  return;
7772
7776
  }
7773
7777
  console.error("[ws-error] WebSocket error on active connection", {
7774
- error,
7775
7778
  wsUrl,
7776
7779
  tenant: flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig.tenant,
7777
7780
  mentorId: flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig.name,
@@ -7786,7 +7789,7 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
7786
7789
  onStreamingChange === null || onStreamingChange === void 0 ? void 0 : onStreamingChange(false);
7787
7790
  onStatusChange("error");
7788
7791
  });
7789
- socket.addEventListener("close", () => {
7792
+ socket.addEventListener("close", (event) => {
7790
7793
  isConnected.current = false;
7791
7794
  onStreamingChange === null || onStreamingChange === void 0 ? void 0 : onStreamingChange(false);
7792
7795
  // Don't retry or show error if we're offline in Tauri - this is expected
@@ -7800,7 +7803,11 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
7800
7803
  // If this is an initial connection failure and we haven't exceeded max attempts
7801
7804
  if (isInitialConnection.current &&
7802
7805
  connectionAttempts.current < MAX_INITIAL_WEBSOCKET_CONNECTION_ATTEMPTS) {
7803
- console.log(`Initial connection closed, attempting retry ${connectionAttempts.current + 1}/${MAX_INITIAL_WEBSOCKET_CONNECTION_ATTEMPTS}`);
7806
+ console.log(`Initial connection closed, attempting retry ${connectionAttempts.current + 1}/${MAX_INITIAL_WEBSOCKET_CONNECTION_ATTEMPTS}`, {
7807
+ code: event === null || event === void 0 ? void 0 : event.code,
7808
+ reason: event === null || event === void 0 ? void 0 : event.reason,
7809
+ wasClean: event === null || event === void 0 ? void 0 : event.wasClean,
7810
+ });
7804
7811
  // Retry with exponential backoff
7805
7812
  const backoffDelay = Math.min(1000 * Math.pow(2, connectionAttempts.current), 5000);
7806
7813
  setTimeout(() => {
@@ -7816,6 +7823,9 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
7816
7823
  connectionAttempts.current >=
7817
7824
  MAX_INITIAL_WEBSOCKET_CONNECTION_ATTEMPTS) {
7818
7825
  console.error("[ws-close] Failed to connect to the mentor after multiple attempts", {
7826
+ code: event === null || event === void 0 ? void 0 : event.code,
7827
+ reason: event === null || event === void 0 ? void 0 : event.reason,
7828
+ wasClean: event === null || event === void 0 ? void 0 : event.wasClean,
7819
7829
  wsUrl,
7820
7830
  tenant: flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig.tenant,
7821
7831
  mentorId: flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig.name,
@@ -13349,11 +13359,12 @@ Hook ${hookName} was either not provided or not a function.`);
13349
13359
  var createApi = /* @__PURE__ */ buildCreateApi(coreModule(), reactHooksModule());
13350
13360
 
13351
13361
  const STORAGE_KEYS = {
13352
- EDX_TOKEN_KEY: "edx_jwt_token",
13353
- DM_TOKEN_KEY: "dm_token",
13354
- AXD_TOKEN_KEY: "axd_token"};
13362
+ EDX_TOKEN_KEY: 'edx_jwt_token',
13363
+ DM_TOKEN_KEY: 'dm_token',
13364
+ AXD_TOKEN_KEY: 'axd_token'};
13355
13365
  var SERVICES;
13356
13366
  (function (SERVICES) {
13367
+ SERVICES["LEGACY_LMS"] = "LEGACY_LMS";
13357
13368
  SERVICES["LMS"] = "LMS";
13358
13369
  SERVICES["DM"] = "DM";
13359
13370
  SERVICES["AXD"] = "AXD";
@@ -13361,10 +13372,11 @@ var SERVICES;
13361
13372
 
13362
13373
  class Config {
13363
13374
  }
13364
- Config.lmsUrl = "https://learn.iblai.app";
13365
- Config.dmUrl = "https://base.manager.iblai.app";
13366
- Config.axdUrl = "https://base.manager.iblai.app";
13367
- Config.mentorIframeUrl = "https://mentor.iblai.tech";
13375
+ Config.legacyLmsUrl = 'https://learn.iblai.app';
13376
+ Config.lmsUrl = 'https://learn.iblai.app';
13377
+ Config.dmUrl = 'https://base.manager.iblai.app';
13378
+ Config.axdUrl = 'https://base.manager.iblai.app';
13379
+ Config.mentorIframeUrl = 'https://mentor.iblai.tech';
13368
13380
  Config.httpErrorHandlers = {};
13369
13381
 
13370
13382
  class IblDataLayer {
@@ -13425,6 +13437,8 @@ const iblFakeBaseQuery = retry(fakeBaseQueryWithLogging, {
13425
13437
  */
13426
13438
  const getServiceUrl = (service) => {
13427
13439
  switch (service) {
13440
+ case SERVICES.LEGACY_LMS:
13441
+ return Config.legacyLmsUrl;
13428
13442
  case SERVICES.LMS:
13429
13443
  return Config.lmsUrl;
13430
13444
  case SERVICES.DM:
@@ -13478,6 +13492,7 @@ const buildEndpointFromService = (service, serviceFn) => {
13478
13492
  try {
13479
13493
  OpenAPI.BASE = getServiceUrl(service);
13480
13494
  OpenAPI.HEADERS = await getHeaders(service);
13495
+ OpenAPI.CREDENTIALS = service === SERVICES.LEGACY_LMS ? 'include' : 'omit';
13481
13496
  // API request initiated
13482
13497
  const data = await serviceFn(args);
13483
13498
  // API response received
@@ -13513,6 +13528,7 @@ const isErrorObject = (data) => {
13513
13528
  const baseQuery = (service, jsonContentType = true, contentType, skipAuth = false) => fetchBaseQuery({
13514
13529
  baseUrl: getServiceUrl(service),
13515
13530
  timeout: 30000, // 30 second timeout
13531
+ credentials: service === SERVICES.LEGACY_LMS ? 'include' : 'omit',
13516
13532
  prepareHeaders: async (headers) => {
13517
13533
  // Only add auth headers if skipAuth is false
13518
13534
  if (!skipAuth) {
@@ -13626,6 +13642,7 @@ const buildEndpointFromServiceLegacy = (service, serviceFn) => {
13626
13642
  try {
13627
13643
  OpenAPI.BASE = getServiceUrl(service);
13628
13644
  OpenAPI.HEADERS = await getHeaders(service);
13645
+ OpenAPI.CREDENTIALS = service === SERVICES.LEGACY_LMS ? 'include' : 'omit';
13629
13646
  const data = await serviceFn(...args);
13630
13647
  return { data };
13631
13648
  }
@@ -14132,7 +14149,7 @@ const AUTH_ENDPOINTS = {
14132
14149
  path: () => '/api/ibl/manager/consolidated-token/proxy/',
14133
14150
  },
14134
14151
  REFRESH_JWT_TOKEN: {
14135
- service: SERVICES.LMS,
14152
+ service: SERVICES.LEGACY_LMS,
14136
14153
  path: () => '/ibl-auth/request-jwt/',
14137
14154
  },
14138
14155
  };
@@ -14166,14 +14183,12 @@ createApi({
14166
14183
  isJson: false,
14167
14184
  method: 'POST',
14168
14185
  body: formData,
14169
- credentials: 'include',
14170
14186
  }),
14171
14187
  }),
14172
14188
  refreshJwtToken: builder.query({
14173
14189
  query: () => ({
14174
14190
  url: AUTH_ENDPOINTS.REFRESH_JWT_TOKEN.path(),
14175
14191
  service: AUTH_ENDPOINTS.REFRESH_JWT_TOKEN.service,
14176
- credentials: 'include',
14177
14192
  }),
14178
14193
  }),
14179
14194
  }),
@@ -14207,10 +14222,10 @@ createApi({
14207
14222
  try {
14208
14223
  const authHeaders = await getHeaders(SERVICES.LMS);
14209
14224
  const response = await fetch(`${Config.lmsUrl}${TENANTS_ENDPOINTS.GET_USER_TENANTS.path()}`, {
14210
- credentials: 'include',
14211
14225
  headers: {
14212
14226
  ...authHeaders,
14213
14227
  },
14228
+ credentials: 'omit',
14214
14229
  });
14215
14230
  if (!response.ok) {
14216
14231
  return {
@@ -14296,6 +14311,7 @@ createApi({
14296
14311
  const response = await fetch(url, {
14297
14312
  method: 'GET',
14298
14313
  headers: OpenAPI.HEADERS,
14314
+ credentials: 'omit',
14299
14315
  });
14300
14316
  if (!response.ok) {
14301
14317
  const error = new Error('Failed to fetch platform users');
@@ -14330,6 +14346,7 @@ createApi({
14330
14346
  const response = await fetch(url, {
14331
14347
  method: 'GET',
14332
14348
  headers: OpenAPI.HEADERS,
14349
+ credentials: 'omit',
14333
14350
  });
14334
14351
  if (!response.ok) {
14335
14352
  const error = new Error('Failed to fetch team details');
@@ -14351,6 +14368,7 @@ createApi({
14351
14368
  'Content-Type': 'application/json',
14352
14369
  },
14353
14370
  body: JSON.stringify(args.requestBody),
14371
+ credentials: 'omit',
14354
14372
  });
14355
14373
  if (!response.ok) {
14356
14374
  const error = new Error('Failed to update platform user role with policies');
@@ -14576,6 +14594,7 @@ createApi({
14576
14594
  const response = await fetch(url, {
14577
14595
  method: 'GET',
14578
14596
  headers: OpenAPI.HEADERS,
14597
+ credentials: 'omit',
14579
14598
  });
14580
14599
  if (!response.ok) {
14581
14600
  const error = new Error('Failed to fetch RBAC group details');
@@ -14612,6 +14631,7 @@ createApi({
14612
14631
  const response = await fetch(url, {
14613
14632
  method: 'GET',
14614
14633
  headers: OpenAPI.HEADERS,
14634
+ credentials: 'omit',
14615
14635
  });
14616
14636
  if (!response.ok) {
14617
14637
  const error = new Error('Failed to fetch RBAC policy details');
@@ -14652,6 +14672,7 @@ createApi({
14652
14672
  const response = await fetch(url, {
14653
14673
  method: 'GET',
14654
14674
  headers: OpenAPI.HEADERS,
14675
+ credentials: 'omit',
14655
14676
  });
14656
14677
  if (!response.ok) {
14657
14678
  const error = new Error('Failed to fetch RBAC role details');
@@ -14762,6 +14783,7 @@ createApi({
14762
14783
  const response = await fetch(url, {
14763
14784
  method: 'GET',
14764
14785
  headers: OpenAPI.HEADERS,
14786
+ credentials: 'omit',
14765
14787
  });
14766
14788
  if (!response.ok) {
14767
14789
  const error = new Error('Failed to fetch credentials');
@@ -15737,6 +15759,7 @@ createApi({
15737
15759
  const response = await fetch(url, {
15738
15760
  method: 'GET',
15739
15761
  headers: OpenAPI.HEADERS,
15762
+ credentials: 'omit',
15740
15763
  });
15741
15764
  if (!response.ok) {
15742
15765
  const error = new Error('Failed to fetch program invitations');
@@ -15837,6 +15860,7 @@ const performCareerRequest = async (path, options = {}) => {
15837
15860
  method: (_b = options.method) !== null && _b !== void 0 ? _b : 'GET',
15838
15861
  body: (_c = options.body) !== null && _c !== void 0 ? _c : null,
15839
15862
  headers,
15863
+ credentials: 'omit',
15840
15864
  });
15841
15865
  if (!response.ok) {
15842
15866
  const errorData = await parseResponse(response);
@@ -17409,6 +17433,182 @@ createApi({
17409
17433
  }),
17410
17434
  });
17411
17435
 
17436
+ const WORKFLOWS_REDUCER_PATH = 'workflowsApiSlice';
17437
+ const WORKFLOWS_ENDPOINTS = {
17438
+ LIST: {
17439
+ service: SERVICES.AXD,
17440
+ path: (org) => `/api/ai-mentor/orgs/${org}/workflows/`,
17441
+ },
17442
+ CREATE: {
17443
+ service: SERVICES.AXD,
17444
+ path: (org) => `/api/ai-mentor/orgs/${org}/workflows/`,
17445
+ },
17446
+ RETRIEVE: {
17447
+ service: SERVICES.AXD,
17448
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/`,
17449
+ },
17450
+ UPDATE: {
17451
+ service: SERVICES.AXD,
17452
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/`,
17453
+ },
17454
+ DELETE: {
17455
+ service: SERVICES.AXD,
17456
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/`,
17457
+ },
17458
+ ACTIVATE: {
17459
+ service: SERVICES.AXD,
17460
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/activate/`,
17461
+ },
17462
+ DEACTIVATE: {
17463
+ service: SERVICES.AXD,
17464
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/deactivate/`,
17465
+ },
17466
+ PUBLISH: {
17467
+ service: SERVICES.AXD,
17468
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/publish/`,
17469
+ },
17470
+ UNPUBLISH: {
17471
+ service: SERVICES.AXD,
17472
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/unpublish/`,
17473
+ },
17474
+ VALIDATE: {
17475
+ service: SERVICES.AXD,
17476
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/validate/`,
17477
+ },
17478
+ CHAT: {
17479
+ service: SERVICES.AXD,
17480
+ path: (org, uniqueId) => `/api/ai-mentor/orgs/${org}/workflows/${uniqueId}/chat/`,
17481
+ },
17482
+ NODE_TYPES: {
17483
+ service: SERVICES.AXD,
17484
+ path: (org) => `/api/ai-mentor/orgs/${org}/workflows/node-types/`,
17485
+ },
17486
+ };
17487
+ const WORKFLOWS_QUERY_KEYS = {
17488
+ LIST: () => ['WORKFLOWS'],
17489
+ DETAILS: () => ['WORKFLOW_DETAILS'],
17490
+ NODE_TYPES: () => ['WORKFLOW_NODE_TYPES'],
17491
+ };
17492
+
17493
+ createApi({
17494
+ reducerPath: WORKFLOWS_REDUCER_PATH,
17495
+ tagTypes: [
17496
+ ...WORKFLOWS_QUERY_KEYS.LIST(),
17497
+ ...WORKFLOWS_QUERY_KEYS.DETAILS(),
17498
+ ...WORKFLOWS_QUERY_KEYS.NODE_TYPES(),
17499
+ ],
17500
+ baseQuery: iblFetchBaseQuery,
17501
+ endpoints: (builder) => ({
17502
+ getWorkflows: builder.query({
17503
+ query: ({ org, params }) => ({
17504
+ url: WORKFLOWS_ENDPOINTS.LIST.path(org),
17505
+ params,
17506
+ service: WORKFLOWS_ENDPOINTS.LIST.service,
17507
+ }),
17508
+ providesTags: WORKFLOWS_QUERY_KEYS.LIST(),
17509
+ }),
17510
+ getWorkflow: builder.query({
17511
+ query: ({ org, uniqueId }) => ({
17512
+ url: WORKFLOWS_ENDPOINTS.RETRIEVE.path(org, uniqueId),
17513
+ service: WORKFLOWS_ENDPOINTS.RETRIEVE.service,
17514
+ }),
17515
+ providesTags: WORKFLOWS_QUERY_KEYS.DETAILS(),
17516
+ }),
17517
+ createWorkflow: builder.mutation({
17518
+ query: ({ org, data }) => ({
17519
+ url: WORKFLOWS_ENDPOINTS.CREATE.path(org),
17520
+ method: 'POST',
17521
+ body: data,
17522
+ service: WORKFLOWS_ENDPOINTS.CREATE.service,
17523
+ }),
17524
+ invalidatesTags: WORKFLOWS_QUERY_KEYS.LIST(),
17525
+ }),
17526
+ // Full update (PUT) - replaces entire workflow
17527
+ updateWorkflow: builder.mutation({
17528
+ query: ({ org, uniqueId, data }) => ({
17529
+ url: WORKFLOWS_ENDPOINTS.UPDATE.path(org, uniqueId),
17530
+ method: 'PUT',
17531
+ body: data,
17532
+ service: WORKFLOWS_ENDPOINTS.UPDATE.service,
17533
+ }),
17534
+ invalidatesTags: [...WORKFLOWS_QUERY_KEYS.LIST(), ...WORKFLOWS_QUERY_KEYS.DETAILS()],
17535
+ }),
17536
+ // Partial update (PATCH) - updates only provided fields
17537
+ patchWorkflow: builder.mutation({
17538
+ query: ({ org, uniqueId, data }) => ({
17539
+ url: WORKFLOWS_ENDPOINTS.UPDATE.path(org, uniqueId),
17540
+ method: 'PATCH',
17541
+ body: data,
17542
+ service: WORKFLOWS_ENDPOINTS.UPDATE.service,
17543
+ }),
17544
+ invalidatesTags: [...WORKFLOWS_QUERY_KEYS.LIST(), ...WORKFLOWS_QUERY_KEYS.DETAILS()],
17545
+ }),
17546
+ deleteWorkflow: builder.mutation({
17547
+ query: ({ org, uniqueId }) => ({
17548
+ url: WORKFLOWS_ENDPOINTS.DELETE.path(org, uniqueId),
17549
+ method: 'DELETE',
17550
+ service: WORKFLOWS_ENDPOINTS.DELETE.service,
17551
+ }),
17552
+ invalidatesTags: WORKFLOWS_QUERY_KEYS.LIST(),
17553
+ }),
17554
+ activateWorkflow: builder.mutation({
17555
+ query: ({ org, uniqueId }) => ({
17556
+ url: WORKFLOWS_ENDPOINTS.ACTIVATE.path(org, uniqueId),
17557
+ method: 'POST',
17558
+ service: WORKFLOWS_ENDPOINTS.ACTIVATE.service,
17559
+ }),
17560
+ invalidatesTags: [...WORKFLOWS_QUERY_KEYS.LIST(), ...WORKFLOWS_QUERY_KEYS.DETAILS()],
17561
+ }),
17562
+ deactivateWorkflow: builder.mutation({
17563
+ query: ({ org, uniqueId }) => ({
17564
+ url: WORKFLOWS_ENDPOINTS.DEACTIVATE.path(org, uniqueId),
17565
+ method: 'POST',
17566
+ service: WORKFLOWS_ENDPOINTS.DEACTIVATE.service,
17567
+ }),
17568
+ invalidatesTags: [...WORKFLOWS_QUERY_KEYS.LIST(), ...WORKFLOWS_QUERY_KEYS.DETAILS()],
17569
+ }),
17570
+ publishWorkflow: builder.mutation({
17571
+ query: ({ org, uniqueId, data }) => ({
17572
+ url: WORKFLOWS_ENDPOINTS.PUBLISH.path(org, uniqueId),
17573
+ method: 'POST',
17574
+ body: data,
17575
+ service: WORKFLOWS_ENDPOINTS.PUBLISH.service,
17576
+ }),
17577
+ invalidatesTags: [...WORKFLOWS_QUERY_KEYS.LIST(), ...WORKFLOWS_QUERY_KEYS.DETAILS()],
17578
+ }),
17579
+ unpublishWorkflow: builder.mutation({
17580
+ query: ({ org, uniqueId }) => ({
17581
+ url: WORKFLOWS_ENDPOINTS.UNPUBLISH.path(org, uniqueId),
17582
+ method: 'POST',
17583
+ service: WORKFLOWS_ENDPOINTS.UNPUBLISH.service,
17584
+ }),
17585
+ invalidatesTags: [...WORKFLOWS_QUERY_KEYS.LIST(), ...WORKFLOWS_QUERY_KEYS.DETAILS()],
17586
+ }),
17587
+ validateWorkflow: builder.mutation({
17588
+ query: ({ org, uniqueId }) => ({
17589
+ url: WORKFLOWS_ENDPOINTS.VALIDATE.path(org, uniqueId),
17590
+ method: 'POST',
17591
+ service: WORKFLOWS_ENDPOINTS.VALIDATE.service,
17592
+ }),
17593
+ }),
17594
+ chatWithWorkflow: builder.mutation({
17595
+ query: ({ org, uniqueId, message }) => ({
17596
+ url: WORKFLOWS_ENDPOINTS.CHAT.path(org, uniqueId),
17597
+ method: 'POST',
17598
+ body: { message },
17599
+ service: WORKFLOWS_ENDPOINTS.CHAT.service,
17600
+ }),
17601
+ }),
17602
+ getNodeTypes: builder.query({
17603
+ query: ({ org }) => ({
17604
+ url: WORKFLOWS_ENDPOINTS.NODE_TYPES.path(org),
17605
+ service: WORKFLOWS_ENDPOINTS.NODE_TYPES.service,
17606
+ }),
17607
+ providesTags: WORKFLOWS_QUERY_KEYS.NODE_TYPES(),
17608
+ }),
17609
+ }),
17610
+ });
17611
+
17412
17612
  function useMentorSettings({ mentorId, tenantKey, username, isPublicRoute, }) {
17413
17613
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
17414
17614
  const isLoggedIn = username !== ANONYMOUS_USERNAME;