@elevasis/ui 2.25.0 → 2.25.1
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/app/index.css +11 -0
- package/dist/app/index.d.ts +457 -357
- package/dist/app/index.js +8 -7
- package/dist/auth/index.js +4 -4
- package/dist/charts/index.js +7 -7
- package/dist/{chunk-DDZOHLHB.js → chunk-26HQMR7S.js} +1 -1
- package/dist/{chunk-ZMXZ476Y.js → chunk-3AHEHVJ6.js} +3 -3
- package/dist/{chunk-LJWV4TWV.js → chunk-4ZFBVND2.js} +2 -2
- package/dist/{chunk-7D2HSSIW.js → chunk-7LJUTTXU.js} +5 -5
- package/dist/{chunk-ABV5LDDC.js → chunk-AZQY7AJR.js} +13 -24
- package/dist/{chunk-BIWHHWCJ.js → chunk-DWK2QIAK.js} +2 -1
- package/dist/{chunk-ZDKQNQ4X.js → chunk-GESXCQWY.js} +1 -1
- package/dist/{chunk-Z6FAH4XV.js → chunk-HKBEURCV.js} +1 -1
- package/dist/{chunk-HC2KV6BU.js → chunk-HOIT677G.js} +1 -1
- package/dist/chunk-IS53MXE4.js +230 -0
- package/dist/{chunk-WSC5LU3U.js → chunk-IX7LWINC.js} +6 -5
- package/dist/{chunk-AXXTN44Z.js → chunk-IYIZYMIE.js} +2 -2
- package/dist/{chunk-WWVSPOJY.js → chunk-JDQSCEEF.js} +1237 -642
- package/dist/{chunk-AZXSFDG2.js → chunk-JMI7L7Y7.js} +113 -63
- package/dist/{chunk-TSSKOQBX.js → chunk-KMAXFJPH.js} +2 -2
- package/dist/{chunk-HQ7M6PBW.js → chunk-KU7ZDWQ7.js} +1 -1
- package/dist/{chunk-ZGZZIR6K.js → chunk-L4RT57WU.js} +7 -7
- package/dist/{chunk-LK4MPIMK.js → chunk-MU4VPAMR.js} +2 -2
- package/dist/{chunk-3JCMO7SD.js → chunk-N55DVMAG.js} +1 -1
- package/dist/{chunk-EIOJNUPL.js → chunk-PNLJIPV5.js} +1 -1
- package/dist/{chunk-6Z3G4U2R.js → chunk-Q5BEODAT.js} +3 -2
- package/dist/{chunk-HVC2BTFO.js → chunk-QB2CC4VH.js} +1979 -257
- package/dist/{chunk-QJLRDTYS.js → chunk-RSG2O3HF.js} +932 -707
- package/dist/{chunk-M25JL54Z.js → chunk-RYTEQBAO.js} +1 -1
- package/dist/{chunk-XUYBOO32.js → chunk-U36X6NZM.js} +15 -7
- package/dist/{chunk-QSTH6T77.js → chunk-VKMNWHTL.js} +1 -1
- package/dist/{chunk-V3UOW2HG.js → chunk-VOVZLL23.js} +4 -4
- package/dist/{chunk-SLH2QLKV.js → chunk-WFTNY755.js} +1 -1
- package/dist/{chunk-DK2HVHCY.js → chunk-WKJ47GIW.js} +1 -1
- package/dist/chunk-X4WBGKJQ.js +138 -0
- package/dist/{chunk-QHSW4WHM.js → chunk-XTVZFT7U.js} +1 -1
- package/dist/components/index.css +11 -0
- package/dist/components/index.d.ts +478 -386
- package/dist/components/index.js +138 -336
- package/dist/components/navigation/index.css +11 -0
- package/dist/components/navigation/index.js +8 -8
- package/dist/features/auth/index.css +11 -0
- package/dist/features/auth/index.d.ts +369 -363
- package/dist/features/auth/index.js +7 -7
- package/dist/features/crm/index.css +11 -0
- package/dist/features/crm/index.d.ts +551 -360
- package/dist/features/crm/index.js +19 -19
- package/dist/features/dashboard/index.css +11 -0
- package/dist/features/dashboard/index.js +20 -20
- package/dist/features/delivery/index.css +11 -0
- package/dist/features/delivery/index.d.ts +363 -357
- package/dist/features/delivery/index.js +19 -19
- package/dist/features/lead-gen/index.css +11 -0
- package/dist/features/lead-gen/index.d.ts +160 -2
- package/dist/features/lead-gen/index.js +20 -19
- package/dist/features/monitoring/index.css +11 -0
- package/dist/features/monitoring/index.js +21 -21
- package/dist/features/monitoring/requests/index.css +11 -0
- package/dist/features/monitoring/requests/index.js +17 -17
- package/dist/features/operations/index.css +11 -0
- package/dist/features/operations/index.js +24 -23
- package/dist/features/seo/index.js +2 -2
- package/dist/features/settings/index.css +11 -0
- package/dist/features/settings/index.d.ts +369 -363
- package/dist/features/settings/index.js +19 -19
- package/dist/hooks/delivery/index.css +11 -0
- package/dist/hooks/delivery/index.d.ts +363 -357
- package/dist/hooks/delivery/index.js +2 -2
- package/dist/hooks/index.css +11 -0
- package/dist/hooks/index.d.ts +746 -399
- package/dist/hooks/index.js +17 -17
- package/dist/hooks/published.css +11 -0
- package/dist/hooks/published.d.ts +746 -399
- package/dist/hooks/published.js +17 -17
- package/dist/index.css +11 -0
- package/dist/index.d.ts +862 -381
- package/dist/index.js +17 -17
- package/dist/initialization/index.d.ts +369 -363
- package/dist/initialization/index.js +4 -4
- package/dist/layout/index.d.ts +6 -0
- package/dist/layout/index.js +5 -5
- package/dist/organization/index.css +11 -0
- package/dist/organization/index.js +4 -4
- package/dist/profile/index.d.ts +369 -363
- package/dist/profile/index.js +2 -2
- package/dist/provider/ElevasisServiceContext.d.ts +1 -0
- package/dist/provider/ElevasisServiceContext.js +1 -1
- package/dist/provider/index.css +11 -0
- package/dist/provider/index.d.ts +503 -362
- package/dist/provider/index.js +14 -14
- package/dist/provider/published.css +11 -0
- package/dist/provider/published.d.ts +494 -359
- package/dist/provider/published.js +12 -12
- package/dist/supabase/index.d.ts +369 -357
- package/dist/test-utils/index.js +1 -1
- package/dist/typeform/index.js +49 -20
- package/dist/types/index.d.ts +382 -363
- package/package.json +4 -4
- package/dist/chunk-CEWTOKE7.js +0 -109
- /package/dist/{chunk-IRW7JMQ4.js → chunk-5WWZXCS5.js} +0 -0
- /package/dist/{chunk-QJ2KCHKX.js → chunk-E565XMTQ.js} +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { useSupabase } from './chunk-BRXELOHC.js';
|
|
2
|
-
import { observabilityKeys } from './chunk-
|
|
3
|
-
import { showApiErrorNotification, showSuccessNotification, projectKeys, noteKeys, taskKeys, milestoneKeys } from './chunk-
|
|
2
|
+
import { observabilityKeys } from './chunk-VKMNWHTL.js';
|
|
3
|
+
import { showApiErrorNotification, showSuccessNotification, projectKeys, noteKeys, taskKeys, milestoneKeys } from './chunk-HKBEURCV.js';
|
|
4
4
|
import { GRAPH_CONSTANTS } from './chunk-22UVE3RA.js';
|
|
5
|
-
import { useNotificationAdapter, deriveActions } from './chunk-
|
|
6
|
-
import { useOptionalElevasisFeatures } from './chunk-
|
|
5
|
+
import { useNotificationAdapter, deriveActions } from './chunk-JMI7L7Y7.js';
|
|
6
|
+
import { useOptionalElevasisFeatures } from './chunk-4ZFBVND2.js';
|
|
7
7
|
import { HTTP_HEADERS } from './chunk-T6INEVX6.js';
|
|
8
8
|
import { ResourceTypeSchema, NonEmptyStringSchema, OriginResourceTypeSchema, UuidSchema, CredentialNameSchema, STALE_TIME_DEFAULT, REFETCH_INTERVAL_DASHBOARD, STALE_TIME_MONITORING, STALE_TIME_ADMIN, getTimeRangeDates, REFETCH_INTERVAL_RUNNING, WS_MAX_RETRIES_BEFORE_ERROR, WS_RECONNECT_BASE_DELAY, WS_RECONNECT_MAX_DELAY, APIClientError, GC_TIME_MEDIUM, GC_TIME_SHORT } from './chunk-SGXXJE52.js';
|
|
9
|
-
import { useStableAccessToken } from './chunk-
|
|
10
|
-
import { useInitialization } from './chunk-
|
|
9
|
+
import { useStableAccessToken } from './chunk-WFTNY755.js';
|
|
10
|
+
import { useInitialization } from './chunk-WKJ47GIW.js';
|
|
11
11
|
import { useOrganization } from './chunk-DD3CCMCZ.js';
|
|
12
|
-
import { useElevasisServices } from './chunk-
|
|
12
|
+
import { useElevasisServices } from './chunk-5WWZXCS5.js';
|
|
13
13
|
import { useAuthContext } from './chunk-BRJ3QZ4E.js';
|
|
14
|
-
import { useMemo, useCallback, useState, useEffect,
|
|
14
|
+
import { useMemo, useCallback, useState, useEffect, useId, useRef } from 'react';
|
|
15
15
|
import { useQuery, useQueryClient, useMutation, useQueries } from '@tanstack/react-query';
|
|
16
16
|
import { z } from 'zod';
|
|
17
17
|
import { notifications } from '@mantine/notifications';
|
|
@@ -547,291 +547,6 @@ function useExecuteAsync() {
|
|
|
547
547
|
}
|
|
548
548
|
});
|
|
549
549
|
}
|
|
550
|
-
function useRetryExecution() {
|
|
551
|
-
const { apiRequest, organizationId } = useElevasisServices();
|
|
552
|
-
const queryClient = useQueryClient();
|
|
553
|
-
return useMutation({
|
|
554
|
-
mutationFn: async ({ resourceId, resourceType, input }) => {
|
|
555
|
-
const response = await apiRequest("/execution-engine/execute-async", {
|
|
556
|
-
method: "POST",
|
|
557
|
-
body: JSON.stringify({ resourceType, resourceId, input })
|
|
558
|
-
});
|
|
559
|
-
return { ...response, resourceId };
|
|
560
|
-
},
|
|
561
|
-
onSuccess: (data) => {
|
|
562
|
-
queryClient.invalidateQueries({
|
|
563
|
-
queryKey: executionsKeys.executionsListBase(organizationId, data.resourceId)
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
function useCancelExecution() {
|
|
569
|
-
const { apiRequest, organizationId } = useElevasisServices();
|
|
570
|
-
const queryClient = useQueryClient();
|
|
571
|
-
return useMutation({
|
|
572
|
-
mutationFn: async ({ resourceId, executionId }) => {
|
|
573
|
-
const response = await apiRequest(
|
|
574
|
-
`/execution-engine/executions/${resourceId}/${executionId}/cancel`,
|
|
575
|
-
{ method: "POST" }
|
|
576
|
-
);
|
|
577
|
-
return { ...response, resourceId, executionId };
|
|
578
|
-
},
|
|
579
|
-
onSuccess: (data) => {
|
|
580
|
-
queryClient.invalidateQueries({
|
|
581
|
-
queryKey: executionsKeys.execution(organizationId, data.resourceId, data.executionId)
|
|
582
|
-
});
|
|
583
|
-
queryClient.invalidateQueries({
|
|
584
|
-
queryKey: executionsKeys.executionsListBase(organizationId, data.resourceId)
|
|
585
|
-
});
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
function useDeleteExecution() {
|
|
590
|
-
const { apiRequest, organizationId } = useElevasisServices();
|
|
591
|
-
const queryClient = useQueryClient();
|
|
592
|
-
return useMutation({
|
|
593
|
-
mutationFn: async ({ resourceId, executionId }) => {
|
|
594
|
-
await apiRequest(`/execution-engine/executions/${resourceId}/${executionId}`, {
|
|
595
|
-
method: "DELETE"
|
|
596
|
-
});
|
|
597
|
-
return { resourceId, executionId };
|
|
598
|
-
},
|
|
599
|
-
onSuccess: (data) => {
|
|
600
|
-
queryClient.removeQueries({
|
|
601
|
-
queryKey: executionsKeys.execution(organizationId, data.resourceId, data.executionId)
|
|
602
|
-
});
|
|
603
|
-
queryClient.invalidateQueries({
|
|
604
|
-
queryKey: executionsKeys.executionsListBase(organizationId, data.resourceId)
|
|
605
|
-
});
|
|
606
|
-
}
|
|
607
|
-
});
|
|
608
|
-
}
|
|
609
|
-
function useBulkDeleteExecutions() {
|
|
610
|
-
const { apiRequest, organizationId } = useElevasisServices();
|
|
611
|
-
const queryClient = useQueryClient();
|
|
612
|
-
return useMutation({
|
|
613
|
-
mutationFn: async ({
|
|
614
|
-
resourceId,
|
|
615
|
-
resourceStatus
|
|
616
|
-
}) => {
|
|
617
|
-
const params = new URLSearchParams();
|
|
618
|
-
if (resourceStatus && resourceStatus !== "all") {
|
|
619
|
-
params.set("resourceStatus", resourceStatus);
|
|
620
|
-
}
|
|
621
|
-
const queryString = params.toString();
|
|
622
|
-
const endpoint = `/execution-engine/executions/${resourceId}${queryString ? `?${queryString}` : ""}`;
|
|
623
|
-
const response = await apiRequest(
|
|
624
|
-
endpoint,
|
|
625
|
-
{ method: "DELETE" }
|
|
626
|
-
);
|
|
627
|
-
return { resourceId, deletedCount: response.deletedCount, resourceStatus };
|
|
628
|
-
},
|
|
629
|
-
onSuccess: (data) => {
|
|
630
|
-
queryClient.invalidateQueries({
|
|
631
|
-
queryKey: executionsKeys.executionsListBase(organizationId, data.resourceId)
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
});
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
// src/hooks/services/OperationsService.ts
|
|
638
|
-
var OperationsService = class {
|
|
639
|
-
constructor(apiRequest) {
|
|
640
|
-
this.apiRequest = apiRequest;
|
|
641
|
-
}
|
|
642
|
-
/**
|
|
643
|
-
* Fetch all available Execution Engine resources
|
|
644
|
-
* Uses the unified /list-resources endpoint
|
|
645
|
-
*/
|
|
646
|
-
async getResources() {
|
|
647
|
-
return this.apiRequest("/execution-engine/resources");
|
|
648
|
-
}
|
|
649
|
-
/**
|
|
650
|
-
* Get detailed workflow information
|
|
651
|
-
* Optional: For future detailed views
|
|
652
|
-
*/
|
|
653
|
-
async getWorkflowDetails() {
|
|
654
|
-
return this.apiRequest("/execution-engine/workflows/details");
|
|
655
|
-
}
|
|
656
|
-
/**
|
|
657
|
-
* Get detailed agent information
|
|
658
|
-
* Optional: For future detailed views
|
|
659
|
-
*/
|
|
660
|
-
async getAgentDetails() {
|
|
661
|
-
return this.apiRequest("/execution-engine/agents/details");
|
|
662
|
-
}
|
|
663
|
-
/**
|
|
664
|
-
* Get detailed pipeline information
|
|
665
|
-
* Optional: For future detailed views
|
|
666
|
-
*/
|
|
667
|
-
async getPipelineDetails() {
|
|
668
|
-
return this.apiRequest("/execution-engine/pipelines/details");
|
|
669
|
-
}
|
|
670
|
-
/**
|
|
671
|
-
* Get resource definition (workflow steps, agent actions, pipeline stages, etc.)
|
|
672
|
-
*/
|
|
673
|
-
async getResourceDefinition(resourceId) {
|
|
674
|
-
return this.apiRequest(`/execution-engine/resources/${resourceId}/definition`);
|
|
675
|
-
}
|
|
676
|
-
/**
|
|
677
|
-
* List sessions with optional filtering
|
|
678
|
-
*/
|
|
679
|
-
async listSessions(params) {
|
|
680
|
-
const queryParams = new URLSearchParams();
|
|
681
|
-
if (params?.resourceId) queryParams.append("resourceId", params.resourceId);
|
|
682
|
-
const endpoint = queryParams.toString() ? `/sessions?${queryParams.toString()}` : "/sessions";
|
|
683
|
-
const response = await this.apiRequest(endpoint);
|
|
684
|
-
return response.sessions.map((session) => ({
|
|
685
|
-
sessionId: session.sessionId,
|
|
686
|
-
resourceId: session.resourceId,
|
|
687
|
-
turnCount: session.turnCount,
|
|
688
|
-
isEnded: session.isEnded,
|
|
689
|
-
createdAt: new Date(session.createdAt),
|
|
690
|
-
updatedAt: new Date(session.updatedAt)
|
|
691
|
-
}));
|
|
692
|
-
}
|
|
693
|
-
/**
|
|
694
|
-
* Get session details by ID
|
|
695
|
-
*/
|
|
696
|
-
async getSession(sessionId) {
|
|
697
|
-
SessionIdParamSchema.parse({ sessionId });
|
|
698
|
-
const response = await this.apiRequest(`/sessions/${sessionId}`);
|
|
699
|
-
return {
|
|
700
|
-
sessionId: response.sessionId,
|
|
701
|
-
resourceId: response.resourceId,
|
|
702
|
-
organizationId: response.organizationId,
|
|
703
|
-
userId: response.userId || void 0,
|
|
704
|
-
turnCount: response.turnCount,
|
|
705
|
-
isEnded: response.isEnded,
|
|
706
|
-
metadata: response.metadata || void 0,
|
|
707
|
-
memorySnapshot: response.memorySnapshot || void 0,
|
|
708
|
-
createdAt: new Date(response.createdAt),
|
|
709
|
-
updatedAt: new Date(response.updatedAt),
|
|
710
|
-
endedAt: response.endedAt ? new Date(response.endedAt) : void 0
|
|
711
|
-
};
|
|
712
|
-
}
|
|
713
|
-
/**
|
|
714
|
-
* Create a new session for an agent
|
|
715
|
-
*/
|
|
716
|
-
async createSession(resourceId) {
|
|
717
|
-
const validated = CreateSessionSchema.parse({
|
|
718
|
-
resourceId
|
|
719
|
-
});
|
|
720
|
-
const result = await this.apiRequest("/sessions", {
|
|
721
|
-
method: "POST",
|
|
722
|
-
body: JSON.stringify(validated)
|
|
723
|
-
});
|
|
724
|
-
return result;
|
|
725
|
-
}
|
|
726
|
-
/**
|
|
727
|
-
* Archive a session
|
|
728
|
-
*/
|
|
729
|
-
async archiveSession(sessionId) {
|
|
730
|
-
SessionIdParamSchema.parse({ sessionId });
|
|
731
|
-
return this.apiRequest(`/sessions/${sessionId}/archive`, {
|
|
732
|
-
method: "POST"
|
|
733
|
-
});
|
|
734
|
-
}
|
|
735
|
-
};
|
|
736
|
-
|
|
737
|
-
// src/hooks/executions/useResources.ts
|
|
738
|
-
function useResources() {
|
|
739
|
-
const { apiRequest, organizationId, isReady } = useElevasisServices();
|
|
740
|
-
return useQuery({
|
|
741
|
-
queryKey: executionsKeys.resources(organizationId),
|
|
742
|
-
queryFn: async () => {
|
|
743
|
-
const service = new OperationsService(apiRequest);
|
|
744
|
-
const result = await service.getResources();
|
|
745
|
-
return {
|
|
746
|
-
workflows: result.workflows ?? [],
|
|
747
|
-
agents: result.agents ?? [],
|
|
748
|
-
pipelines: result.pipelines ?? [],
|
|
749
|
-
total: (result.workflows?.length ?? 0) + (result.agents?.length ?? 0) + (result.pipelines?.length ?? 0)
|
|
750
|
-
};
|
|
751
|
-
},
|
|
752
|
-
enabled: isReady
|
|
753
|
-
});
|
|
754
|
-
}
|
|
755
|
-
function useResourceDefinition(resourceId, enabled = true) {
|
|
756
|
-
const { apiRequest, organizationId, isReady } = useElevasisServices();
|
|
757
|
-
return useQuery({
|
|
758
|
-
queryKey: executionsKeys.resourceDefinition(organizationId, resourceId),
|
|
759
|
-
queryFn: () => {
|
|
760
|
-
const service = new OperationsService(apiRequest);
|
|
761
|
-
return service.getResourceDefinition(resourceId);
|
|
762
|
-
},
|
|
763
|
-
enabled: enabled && isReady && !!resourceId,
|
|
764
|
-
retry: 2,
|
|
765
|
-
retryDelay: (attemptIndex) => Math.min(1e3 * 2 ** attemptIndex, 3e4)
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
function useArchivedLogs(executionId) {
|
|
769
|
-
const { apiRequest } = useElevasisServices();
|
|
770
|
-
const [logs, setLogs] = useState(null);
|
|
771
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
772
|
-
const [error, setError] = useState(null);
|
|
773
|
-
const fetch = useCallback(async () => {
|
|
774
|
-
if (!executionId || isLoading) return;
|
|
775
|
-
setIsLoading(true);
|
|
776
|
-
setError(null);
|
|
777
|
-
try {
|
|
778
|
-
const response = await apiRequest(
|
|
779
|
-
`/observability/executions/${executionId}/archived-logs`
|
|
780
|
-
);
|
|
781
|
-
setLogs(response.logs);
|
|
782
|
-
} catch (err) {
|
|
783
|
-
setError(err instanceof Error ? err.message : "Failed to load archived logs");
|
|
784
|
-
} finally {
|
|
785
|
-
setIsLoading(false);
|
|
786
|
-
}
|
|
787
|
-
}, [executionId, apiRequest, isLoading]);
|
|
788
|
-
return { logs, isLoading, error, fetch };
|
|
789
|
-
}
|
|
790
|
-
function useExecuteResource(options) {
|
|
791
|
-
const mutation = useExecuteAsync();
|
|
792
|
-
const execute = useCallback(
|
|
793
|
-
async (input) => {
|
|
794
|
-
let validatedInput = input;
|
|
795
|
-
if (options.schema) {
|
|
796
|
-
const parsed = options.schema.safeParse(input);
|
|
797
|
-
if (!parsed.success) {
|
|
798
|
-
throw new Error(`Invalid input for resource "${options.resourceId}": ${parsed.error.message}`);
|
|
799
|
-
}
|
|
800
|
-
validatedInput = parsed.data;
|
|
801
|
-
}
|
|
802
|
-
return mutation.mutateAsync({
|
|
803
|
-
resourceId: options.resourceId,
|
|
804
|
-
resourceType: options.resourceType,
|
|
805
|
-
input: validatedInput
|
|
806
|
-
});
|
|
807
|
-
},
|
|
808
|
-
[mutation, options.resourceId, options.resourceType, options.schema]
|
|
809
|
-
);
|
|
810
|
-
return {
|
|
811
|
-
execute,
|
|
812
|
-
mutation,
|
|
813
|
-
isPending: mutation.isPending,
|
|
814
|
-
isSuccess: mutation.isSuccess,
|
|
815
|
-
isError: mutation.isError,
|
|
816
|
-
error: mutation.error,
|
|
817
|
-
data: mutation.data,
|
|
818
|
-
reset: mutation.reset
|
|
819
|
-
};
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
// src/hooks/operations/shared/queryKeys.ts
|
|
823
|
-
var operationsKeys = {
|
|
824
|
-
all: ["operations"],
|
|
825
|
-
// Individual resource types (kept for CC-specific features)
|
|
826
|
-
workflows: (org) => [...operationsKeys.all, "workflows", org],
|
|
827
|
-
workflowDetails: (org) => [...operationsKeys.workflows(org), "details"],
|
|
828
|
-
workflow: (id, org) => [...operationsKeys.workflows(org), id],
|
|
829
|
-
agents: (org) => [...operationsKeys.all, "agents", org],
|
|
830
|
-
agentDetails: (org) => [...operationsKeys.agents(org), "details"],
|
|
831
|
-
agent: (id, org) => [...operationsKeys.agents(org), id],
|
|
832
|
-
sessions: (org, params) => [...operationsKeys.all, "sessions", org, params],
|
|
833
|
-
session: (org, sessionId) => [...operationsKeys.all, "session", org, sessionId]
|
|
834
|
-
};
|
|
835
550
|
function useCreateOrgRole() {
|
|
836
551
|
const { apiRequest, organizationId } = useElevasisServices();
|
|
837
552
|
const queryClient = useQueryClient();
|
|
@@ -990,6 +705,37 @@ function usePaginationState(pageSize, resetDeps, total) {
|
|
|
990
705
|
[page, pageSize]
|
|
991
706
|
);
|
|
992
707
|
}
|
|
708
|
+
function useExecuteResource(options) {
|
|
709
|
+
const mutation = useExecuteAsync();
|
|
710
|
+
const execute = useCallback(
|
|
711
|
+
async (input) => {
|
|
712
|
+
let validatedInput = input;
|
|
713
|
+
if (options.schema) {
|
|
714
|
+
const parsed = options.schema.safeParse(input);
|
|
715
|
+
if (!parsed.success) {
|
|
716
|
+
throw new Error(`Invalid input for resource "${options.resourceId}": ${parsed.error.message}`);
|
|
717
|
+
}
|
|
718
|
+
validatedInput = parsed.data;
|
|
719
|
+
}
|
|
720
|
+
return mutation.mutateAsync({
|
|
721
|
+
resourceId: options.resourceId,
|
|
722
|
+
resourceType: options.resourceType,
|
|
723
|
+
input: validatedInput
|
|
724
|
+
});
|
|
725
|
+
},
|
|
726
|
+
[mutation, options.resourceId, options.resourceType, options.schema]
|
|
727
|
+
);
|
|
728
|
+
return {
|
|
729
|
+
execute,
|
|
730
|
+
mutation,
|
|
731
|
+
isPending: mutation.isPending,
|
|
732
|
+
isSuccess: mutation.isSuccess,
|
|
733
|
+
isError: mutation.isError,
|
|
734
|
+
error: mutation.error,
|
|
735
|
+
data: mutation.data,
|
|
736
|
+
reset: mutation.reset
|
|
737
|
+
};
|
|
738
|
+
}
|
|
993
739
|
|
|
994
740
|
// src/hooks/settings/api-keys/apiKeyService.ts
|
|
995
741
|
var ApiKeyService = class {
|
|
@@ -1540,6 +1286,125 @@ function useDeleteSchedule() {
|
|
|
1540
1286
|
}
|
|
1541
1287
|
});
|
|
1542
1288
|
}
|
|
1289
|
+
|
|
1290
|
+
// src/hooks/services/OperationsService.ts
|
|
1291
|
+
var OperationsService = class {
|
|
1292
|
+
constructor(apiRequest) {
|
|
1293
|
+
this.apiRequest = apiRequest;
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Fetch all available Execution Engine resources
|
|
1297
|
+
* Uses the unified /list-resources endpoint
|
|
1298
|
+
*/
|
|
1299
|
+
async getResources() {
|
|
1300
|
+
return this.apiRequest("/execution-engine/resources");
|
|
1301
|
+
}
|
|
1302
|
+
/**
|
|
1303
|
+
* Get detailed workflow information
|
|
1304
|
+
* Optional: For future detailed views
|
|
1305
|
+
*/
|
|
1306
|
+
async getWorkflowDetails() {
|
|
1307
|
+
return this.apiRequest("/execution-engine/workflows/details");
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Get detailed agent information
|
|
1311
|
+
* Optional: For future detailed views
|
|
1312
|
+
*/
|
|
1313
|
+
async getAgentDetails() {
|
|
1314
|
+
return this.apiRequest("/execution-engine/agents/details");
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Get detailed pipeline information
|
|
1318
|
+
* Optional: For future detailed views
|
|
1319
|
+
*/
|
|
1320
|
+
async getPipelineDetails() {
|
|
1321
|
+
return this.apiRequest("/execution-engine/pipelines/details");
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Get resource definition (workflow steps, agent actions, pipeline stages, etc.)
|
|
1325
|
+
*/
|
|
1326
|
+
async getResourceDefinition(resourceId) {
|
|
1327
|
+
return this.apiRequest(`/execution-engine/resources/${resourceId}/definition`);
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* List sessions with optional filtering
|
|
1331
|
+
*/
|
|
1332
|
+
async listSessions(params) {
|
|
1333
|
+
const queryParams = new URLSearchParams();
|
|
1334
|
+
if (params?.resourceId) queryParams.append("resourceId", params.resourceId);
|
|
1335
|
+
const endpoint = queryParams.toString() ? `/sessions?${queryParams.toString()}` : "/sessions";
|
|
1336
|
+
const response = await this.apiRequest(endpoint);
|
|
1337
|
+
return response.sessions.map((session) => ({
|
|
1338
|
+
sessionId: session.sessionId,
|
|
1339
|
+
resourceId: session.resourceId,
|
|
1340
|
+
turnCount: session.turnCount,
|
|
1341
|
+
isEnded: session.isEnded,
|
|
1342
|
+
createdAt: new Date(session.createdAt),
|
|
1343
|
+
updatedAt: new Date(session.updatedAt)
|
|
1344
|
+
}));
|
|
1345
|
+
}
|
|
1346
|
+
/**
|
|
1347
|
+
* Get session details by ID
|
|
1348
|
+
*/
|
|
1349
|
+
async getSession(sessionId) {
|
|
1350
|
+
SessionIdParamSchema.parse({ sessionId });
|
|
1351
|
+
const response = await this.apiRequest(`/sessions/${sessionId}`);
|
|
1352
|
+
return {
|
|
1353
|
+
sessionId: response.sessionId,
|
|
1354
|
+
resourceId: response.resourceId,
|
|
1355
|
+
organizationId: response.organizationId,
|
|
1356
|
+
userId: response.userId || void 0,
|
|
1357
|
+
turnCount: response.turnCount,
|
|
1358
|
+
isEnded: response.isEnded,
|
|
1359
|
+
metadata: response.metadata || void 0,
|
|
1360
|
+
memorySnapshot: response.memorySnapshot || void 0,
|
|
1361
|
+
createdAt: new Date(response.createdAt),
|
|
1362
|
+
updatedAt: new Date(response.updatedAt),
|
|
1363
|
+
endedAt: response.endedAt ? new Date(response.endedAt) : void 0
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
/**
|
|
1367
|
+
* Create a new session for an agent
|
|
1368
|
+
*/
|
|
1369
|
+
async createSession(resourceId) {
|
|
1370
|
+
const validated = CreateSessionSchema.parse({
|
|
1371
|
+
resourceId
|
|
1372
|
+
});
|
|
1373
|
+
const result = await this.apiRequest("/sessions", {
|
|
1374
|
+
method: "POST",
|
|
1375
|
+
body: JSON.stringify(validated)
|
|
1376
|
+
});
|
|
1377
|
+
return result;
|
|
1378
|
+
}
|
|
1379
|
+
/**
|
|
1380
|
+
* Archive a session
|
|
1381
|
+
*/
|
|
1382
|
+
async archiveSession(sessionId) {
|
|
1383
|
+
SessionIdParamSchema.parse({ sessionId });
|
|
1384
|
+
return this.apiRequest(`/sessions/${sessionId}/archive`, {
|
|
1385
|
+
method: "POST"
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
};
|
|
1389
|
+
|
|
1390
|
+
// src/hooks/executions/useResources.ts
|
|
1391
|
+
function useResources() {
|
|
1392
|
+
const { apiRequest, organizationId, isReady } = useElevasisServices();
|
|
1393
|
+
return useQuery({
|
|
1394
|
+
queryKey: executionsKeys.resources(organizationId),
|
|
1395
|
+
queryFn: async () => {
|
|
1396
|
+
const service = new OperationsService(apiRequest);
|
|
1397
|
+
const result = await service.getResources();
|
|
1398
|
+
return {
|
|
1399
|
+
workflows: result.workflows ?? [],
|
|
1400
|
+
agents: result.agents ?? [],
|
|
1401
|
+
pipelines: result.pipelines ?? [],
|
|
1402
|
+
total: (result.workflows?.length ?? 0) + (result.agents?.length ?? 0) + (result.pipelines?.length ?? 0)
|
|
1403
|
+
};
|
|
1404
|
+
},
|
|
1405
|
+
enabled: isReady
|
|
1406
|
+
});
|
|
1407
|
+
}
|
|
1543
1408
|
function useCommandQueue({
|
|
1544
1409
|
status,
|
|
1545
1410
|
limit,
|
|
@@ -2355,106 +2220,46 @@ function useDealsLookup(filters = {}, options) {
|
|
|
2355
2220
|
const { apiRequest, isReady, organizationId } = useElevasisServices();
|
|
2356
2221
|
const normalizedFilters = normalizeLookupFilters(filters);
|
|
2357
2222
|
return useQuery({
|
|
2358
|
-
queryKey: dealKeys.lookup(organizationId, normalizedFilters),
|
|
2359
|
-
queryFn: async () => {
|
|
2360
|
-
const params = new URLSearchParams();
|
|
2361
|
-
if (normalizedFilters.search) params.set("search", normalizedFilters.search);
|
|
2362
|
-
params.set("limit", String(normalizedFilters.limit));
|
|
2363
|
-
return apiRequest(`/deals/lookup?${params.toString()}`);
|
|
2364
|
-
},
|
|
2365
|
-
enabled: isReady && (options?.enabled ?? true)
|
|
2366
|
-
});
|
|
2367
|
-
}
|
|
2368
|
-
function useDeleteDeal() {
|
|
2369
|
-
const { apiRequest, organizationId } = useElevasisServices();
|
|
2370
|
-
const queryClient = useQueryClient();
|
|
2371
|
-
return useMutation({
|
|
2372
|
-
mutationFn: async (dealId) => {
|
|
2373
|
-
await apiRequest(`/deals/${dealId}`, { method: "DELETE" });
|
|
2374
|
-
},
|
|
2375
|
-
onSuccess: (_, dealId) => {
|
|
2376
|
-
queryClient.removeQueries({ queryKey: ["deal-detail", organizationId, dealId], exact: true });
|
|
2377
|
-
queryClient.invalidateQueries({ queryKey: dealKeys.lists() });
|
|
2378
|
-
queryClient.invalidateQueries({ queryKey: dealKeys.summaries() });
|
|
2379
|
-
queryClient.invalidateQueries({ queryKey: dealKeys.lookups() });
|
|
2380
|
-
},
|
|
2381
|
-
onError: (error) => {
|
|
2382
|
-
showApiErrorNotification(error);
|
|
2383
|
-
}
|
|
2384
|
-
});
|
|
2385
|
-
}
|
|
2386
|
-
function useTransitionItem() {
|
|
2387
|
-
const { apiRequest, organizationId } = useElevasisServices();
|
|
2388
|
-
const queryClient = useQueryClient();
|
|
2389
|
-
return useMutation({
|
|
2390
|
-
mutationFn: async (input) => {
|
|
2391
|
-
const { dealId, pipelineKey, stageKey, stateKey, reason, expectedUpdatedAt } = input;
|
|
2392
|
-
await apiRequest(`/deals/${dealId}/transition`, {
|
|
2393
|
-
method: "PATCH",
|
|
2394
|
-
body: JSON.stringify({
|
|
2395
|
-
pipelineKey,
|
|
2396
|
-
stageKey,
|
|
2397
|
-
...stateKey !== void 0 ? { stateKey } : {},
|
|
2398
|
-
...reason !== void 0 ? { reason } : {},
|
|
2399
|
-
...expectedUpdatedAt !== void 0 ? { expectedUpdatedAt } : {}
|
|
2400
|
-
})
|
|
2401
|
-
});
|
|
2402
|
-
},
|
|
2403
|
-
onSuccess: (_, variables) => {
|
|
2404
|
-
queryClient.invalidateQueries({ queryKey: dealKeys.lists() });
|
|
2405
|
-
queryClient.invalidateQueries({ queryKey: dealKeys.summaries() });
|
|
2406
|
-
queryClient.invalidateQueries({ queryKey: ["deal-detail", organizationId, variables.dealId] });
|
|
2407
|
-
},
|
|
2408
|
-
onError: (error) => {
|
|
2409
|
-
queryClient.invalidateQueries({ queryKey: dealKeys.all });
|
|
2410
|
-
showApiErrorNotification(error);
|
|
2411
|
-
}
|
|
2412
|
-
});
|
|
2413
|
-
}
|
|
2414
|
-
var dealNoteKeys = {
|
|
2415
|
-
all: ["deal-notes"],
|
|
2416
|
-
list: (organizationId, dealId) => ["deal-notes", organizationId, dealId]
|
|
2417
|
-
};
|
|
2418
|
-
function useDealNotes(dealId) {
|
|
2419
|
-
const { apiRequest, isReady, organizationId } = useElevasisServices();
|
|
2420
|
-
return useQuery({
|
|
2421
|
-
queryKey: dealNoteKeys.list(organizationId, dealId),
|
|
2223
|
+
queryKey: dealKeys.lookup(organizationId, normalizedFilters),
|
|
2422
2224
|
queryFn: async () => {
|
|
2423
|
-
|
|
2225
|
+
const params = new URLSearchParams();
|
|
2226
|
+
if (normalizedFilters.search) params.set("search", normalizedFilters.search);
|
|
2227
|
+
params.set("limit", String(normalizedFilters.limit));
|
|
2228
|
+
return apiRequest(`/deals/lookup?${params.toString()}`);
|
|
2424
2229
|
},
|
|
2425
|
-
enabled: isReady &&
|
|
2230
|
+
enabled: isReady && (options?.enabled ?? true)
|
|
2426
2231
|
});
|
|
2427
2232
|
}
|
|
2428
|
-
function
|
|
2233
|
+
function useDeleteDeal() {
|
|
2429
2234
|
const { apiRequest, organizationId } = useElevasisServices();
|
|
2430
2235
|
const queryClient = useQueryClient();
|
|
2431
2236
|
return useMutation({
|
|
2432
|
-
mutationFn: async (
|
|
2433
|
-
|
|
2434
|
-
method: "POST",
|
|
2435
|
-
body: JSON.stringify({ body })
|
|
2436
|
-
});
|
|
2237
|
+
mutationFn: async (dealId) => {
|
|
2238
|
+
await apiRequest(`/deals/${dealId}`, { method: "DELETE" });
|
|
2437
2239
|
},
|
|
2438
|
-
onSuccess: (_,
|
|
2439
|
-
queryClient.
|
|
2440
|
-
queryClient.invalidateQueries({ queryKey:
|
|
2441
|
-
|
|
2240
|
+
onSuccess: (_, dealId) => {
|
|
2241
|
+
queryClient.removeQueries({ queryKey: ["deal-detail", organizationId, dealId], exact: true });
|
|
2242
|
+
queryClient.invalidateQueries({ queryKey: dealKeys.lists() });
|
|
2243
|
+
queryClient.invalidateQueries({ queryKey: dealKeys.summaries() });
|
|
2244
|
+
queryClient.invalidateQueries({ queryKey: dealKeys.lookups() });
|
|
2442
2245
|
},
|
|
2443
2246
|
onError: (error) => {
|
|
2444
2247
|
showApiErrorNotification(error);
|
|
2445
2248
|
}
|
|
2446
2249
|
});
|
|
2447
2250
|
}
|
|
2448
|
-
function
|
|
2251
|
+
function useTransitionItem() {
|
|
2449
2252
|
const { apiRequest, organizationId } = useElevasisServices();
|
|
2450
2253
|
const queryClient = useQueryClient();
|
|
2451
2254
|
return useMutation({
|
|
2452
2255
|
mutationFn: async (input) => {
|
|
2453
|
-
const { dealId, stateKey, reason, expectedUpdatedAt } = input;
|
|
2454
|
-
await apiRequest(`/deals/${dealId}/
|
|
2256
|
+
const { dealId, pipelineKey, stageKey, stateKey, reason, expectedUpdatedAt } = input;
|
|
2257
|
+
await apiRequest(`/deals/${dealId}/transition`, {
|
|
2455
2258
|
method: "PATCH",
|
|
2456
2259
|
body: JSON.stringify({
|
|
2457
|
-
|
|
2260
|
+
pipelineKey,
|
|
2261
|
+
stageKey,
|
|
2262
|
+
...stateKey !== void 0 ? { stateKey } : {},
|
|
2458
2263
|
...reason !== void 0 ? { reason } : {},
|
|
2459
2264
|
...expectedUpdatedAt !== void 0 ? { expectedUpdatedAt } : {}
|
|
2460
2265
|
})
|
|
@@ -2546,128 +2351,6 @@ function useCompleteDealTask() {
|
|
|
2546
2351
|
}
|
|
2547
2352
|
});
|
|
2548
2353
|
}
|
|
2549
|
-
var acquisitionListKeys = {
|
|
2550
|
-
all: ["acquisition-lists"],
|
|
2551
|
-
list: (organizationId) => [...acquisitionListKeys.all, organizationId],
|
|
2552
|
-
detail: (organizationId, listId) => [...acquisitionListKeys.all, organizationId, listId],
|
|
2553
|
-
telemetry: (organizationId) => [...acquisitionListKeys.all, "telemetry", organizationId],
|
|
2554
|
-
progress: (organizationId, listId) => [...acquisitionListKeys.all, "progress", organizationId, listId],
|
|
2555
|
-
executions: (organizationId, listId) => [...acquisitionListKeys.all, "executions", organizationId, listId]
|
|
2556
|
-
};
|
|
2557
|
-
function useLists() {
|
|
2558
|
-
const { apiRequest, isReady, organizationId } = useElevasisServices();
|
|
2559
|
-
return useQuery({
|
|
2560
|
-
queryKey: acquisitionListKeys.list(organizationId),
|
|
2561
|
-
queryFn: () => apiRequest("/acquisition/lists"),
|
|
2562
|
-
enabled: isReady
|
|
2563
|
-
});
|
|
2564
|
-
}
|
|
2565
|
-
function useList(listId) {
|
|
2566
|
-
const { apiRequest, isReady, organizationId } = useElevasisServices();
|
|
2567
|
-
return useQuery({
|
|
2568
|
-
queryKey: acquisitionListKeys.detail(organizationId, listId),
|
|
2569
|
-
queryFn: () => apiRequest(`/acquisition/lists/${listId}`),
|
|
2570
|
-
enabled: isReady && !!listId
|
|
2571
|
-
});
|
|
2572
|
-
}
|
|
2573
|
-
function useListsTelemetry() {
|
|
2574
|
-
const { apiRequest, isReady, organizationId } = useElevasisServices();
|
|
2575
|
-
return useQuery({
|
|
2576
|
-
queryKey: acquisitionListKeys.telemetry(organizationId),
|
|
2577
|
-
queryFn: () => apiRequest("/acquisition/lists/telemetry"),
|
|
2578
|
-
enabled: isReady
|
|
2579
|
-
});
|
|
2580
|
-
}
|
|
2581
|
-
function useListProgress(listId) {
|
|
2582
|
-
const { apiRequest, isReady, organizationId } = useElevasisServices();
|
|
2583
|
-
return useQuery({
|
|
2584
|
-
queryKey: acquisitionListKeys.progress(organizationId, listId),
|
|
2585
|
-
queryFn: () => apiRequest(`/acquisition/lists/${listId}/progress`),
|
|
2586
|
-
enabled: isReady && !!listId
|
|
2587
|
-
});
|
|
2588
|
-
}
|
|
2589
|
-
function useListExecutions(listId) {
|
|
2590
|
-
const { apiRequest, isReady, organizationId } = useElevasisServices();
|
|
2591
|
-
return useQuery({
|
|
2592
|
-
queryKey: acquisitionListKeys.executions(organizationId, listId),
|
|
2593
|
-
queryFn: () => apiRequest(`/acquisition/lists/${listId}/executions`),
|
|
2594
|
-
enabled: isReady && !!listId
|
|
2595
|
-
});
|
|
2596
|
-
}
|
|
2597
|
-
function useCreateList() {
|
|
2598
|
-
const { apiRequest, organizationId } = useElevasisServices();
|
|
2599
|
-
const queryClient = useQueryClient();
|
|
2600
|
-
return useMutation({
|
|
2601
|
-
mutationFn: (body) => apiRequest("/acquisition/lists", {
|
|
2602
|
-
method: "POST",
|
|
2603
|
-
body: JSON.stringify(body)
|
|
2604
|
-
}),
|
|
2605
|
-
onSuccess: () => {
|
|
2606
|
-
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.list(organizationId) });
|
|
2607
|
-
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.telemetry(organizationId) });
|
|
2608
|
-
showSuccessNotification("List created");
|
|
2609
|
-
},
|
|
2610
|
-
onError: (error) => {
|
|
2611
|
-
showApiErrorNotification(error);
|
|
2612
|
-
}
|
|
2613
|
-
});
|
|
2614
|
-
}
|
|
2615
|
-
function useUpdateList(listId) {
|
|
2616
|
-
const { apiRequest, organizationId } = useElevasisServices();
|
|
2617
|
-
const queryClient = useQueryClient();
|
|
2618
|
-
return useMutation({
|
|
2619
|
-
mutationFn: (body) => apiRequest(`/acquisition/lists/${listId}`, {
|
|
2620
|
-
method: "PATCH",
|
|
2621
|
-
body: JSON.stringify(body)
|
|
2622
|
-
}),
|
|
2623
|
-
onSuccess: () => {
|
|
2624
|
-
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.list(organizationId) });
|
|
2625
|
-
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.detail(organizationId, listId) });
|
|
2626
|
-
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.telemetry(organizationId) });
|
|
2627
|
-
showSuccessNotification("List updated");
|
|
2628
|
-
},
|
|
2629
|
-
onError: (error) => {
|
|
2630
|
-
showApiErrorNotification(error);
|
|
2631
|
-
}
|
|
2632
|
-
});
|
|
2633
|
-
}
|
|
2634
|
-
function useUpdateListConfig(listId) {
|
|
2635
|
-
const { apiRequest, organizationId } = useElevasisServices();
|
|
2636
|
-
const queryClient = useQueryClient();
|
|
2637
|
-
return useMutation({
|
|
2638
|
-
mutationFn: (body) => apiRequest(`/acquisition/lists/${listId}/config`, {
|
|
2639
|
-
method: "PATCH",
|
|
2640
|
-
body: JSON.stringify(body)
|
|
2641
|
-
}),
|
|
2642
|
-
onSuccess: () => {
|
|
2643
|
-
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.list(organizationId) });
|
|
2644
|
-
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.detail(organizationId, listId) });
|
|
2645
|
-
showSuccessNotification("List configuration saved");
|
|
2646
|
-
},
|
|
2647
|
-
onError: (error) => {
|
|
2648
|
-
showApiErrorNotification(error);
|
|
2649
|
-
}
|
|
2650
|
-
});
|
|
2651
|
-
}
|
|
2652
|
-
function useDeleteList() {
|
|
2653
|
-
const { apiRequest, organizationId } = useElevasisServices();
|
|
2654
|
-
const queryClient = useQueryClient();
|
|
2655
|
-
return useMutation({
|
|
2656
|
-
mutationFn: (listId) => apiRequest(`/acquisition/lists/${listId}`, {
|
|
2657
|
-
method: "DELETE"
|
|
2658
|
-
}),
|
|
2659
|
-
onSuccess: () => {
|
|
2660
|
-
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.list(organizationId) });
|
|
2661
|
-
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.telemetry(organizationId) });
|
|
2662
|
-
showSuccessNotification("List deleted");
|
|
2663
|
-
},
|
|
2664
|
-
onError: (error) => {
|
|
2665
|
-
showApiErrorNotification(error);
|
|
2666
|
-
}
|
|
2667
|
-
});
|
|
2668
|
-
}
|
|
2669
|
-
|
|
2670
|
-
// src/hooks/acquisition/useCompanies.ts
|
|
2671
2354
|
var companyKeys = {
|
|
2672
2355
|
all: ["acquisition-companies"],
|
|
2673
2356
|
list: (organizationId, filters) => [...companyKeys.all, "list", organizationId, filters],
|
|
@@ -3025,49 +2708,224 @@ function useDeriveActions(item) {
|
|
|
3025
2708
|
return [];
|
|
3026
2709
|
}, [item]);
|
|
3027
2710
|
}
|
|
3028
|
-
function useUpdateListStatus() {
|
|
3029
|
-
const { apiRequest, organizationId } = useElevasisServices();
|
|
2711
|
+
function useUpdateListStatus() {
|
|
2712
|
+
const { apiRequest, organizationId } = useElevasisServices();
|
|
2713
|
+
const queryClient = useQueryClient();
|
|
2714
|
+
return useMutation({
|
|
2715
|
+
mutationFn: async (input) => {
|
|
2716
|
+
await apiRequest(`/acquisition/lists/${input.listId}/status`, {
|
|
2717
|
+
method: "PATCH",
|
|
2718
|
+
body: JSON.stringify({ status: input.status })
|
|
2719
|
+
});
|
|
2720
|
+
},
|
|
2721
|
+
onSuccess: (_, variables) => {
|
|
2722
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.list(organizationId) });
|
|
2723
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.detail(organizationId, variables.listId) });
|
|
2724
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.telemetry(organizationId) });
|
|
2725
|
+
},
|
|
2726
|
+
onError: (error) => {
|
|
2727
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.all });
|
|
2728
|
+
showApiErrorNotification(error);
|
|
2729
|
+
}
|
|
2730
|
+
});
|
|
2731
|
+
}
|
|
2732
|
+
var projectActivityKeys = {
|
|
2733
|
+
all: ["project-activities"],
|
|
2734
|
+
list: (projectId) => [...projectActivityKeys.all, "list", projectId]
|
|
2735
|
+
};
|
|
2736
|
+
function useProjectActivities(projectId, enabled = true) {
|
|
2737
|
+
const { apiRequest, isReady, organizationId } = useElevasisServices();
|
|
2738
|
+
return useQuery({
|
|
2739
|
+
queryKey: [...projectActivityKeys.list(projectId), organizationId],
|
|
2740
|
+
queryFn: async () => {
|
|
2741
|
+
const params = new URLSearchParams();
|
|
2742
|
+
params.set("entityType", "project");
|
|
2743
|
+
params.set("entityId", projectId);
|
|
2744
|
+
params.set("limit", "50");
|
|
2745
|
+
const res = await apiRequest(`/activities?${params.toString()}`);
|
|
2746
|
+
return res.activities.map((activity) => ({
|
|
2747
|
+
...activity,
|
|
2748
|
+
occurredAt: new Date(activity.occurredAt),
|
|
2749
|
+
createdAt: new Date(activity.createdAt)
|
|
2750
|
+
}));
|
|
2751
|
+
},
|
|
2752
|
+
enabled: isReady && !!projectId && enabled
|
|
2753
|
+
});
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
// src/hooks/operations/shared/queryKeys.ts
|
|
2757
|
+
var operationsKeys = {
|
|
2758
|
+
all: ["operations"],
|
|
2759
|
+
// Individual resource types (kept for CC-specific features)
|
|
2760
|
+
workflows: (org) => [...operationsKeys.all, "workflows", org],
|
|
2761
|
+
workflowDetails: (org) => [...operationsKeys.workflows(org), "details"],
|
|
2762
|
+
workflow: (id, org) => [...operationsKeys.workflows(org), id],
|
|
2763
|
+
agents: (org) => [...operationsKeys.all, "agents", org],
|
|
2764
|
+
agentDetails: (org) => [...operationsKeys.agents(org), "details"],
|
|
2765
|
+
agent: (id, org) => [...operationsKeys.agents(org), id],
|
|
2766
|
+
sessions: (org, params) => [...operationsKeys.all, "sessions", org, params],
|
|
2767
|
+
session: (org, sessionId) => [...operationsKeys.all, "session", org, sessionId]
|
|
2768
|
+
};
|
|
2769
|
+
function useSSEConnection({
|
|
2770
|
+
manager,
|
|
2771
|
+
connectionKey,
|
|
2772
|
+
url,
|
|
2773
|
+
enabled = true,
|
|
2774
|
+
headers,
|
|
2775
|
+
onmessage,
|
|
2776
|
+
onopen,
|
|
2777
|
+
onerror,
|
|
2778
|
+
onclose
|
|
2779
|
+
}) {
|
|
2780
|
+
const [connected, setConnected] = useState(false);
|
|
2781
|
+
const [error, setError] = useState(null);
|
|
2782
|
+
const getAccessToken = useStableAccessToken();
|
|
2783
|
+
const subscriberId = useId();
|
|
2784
|
+
const onmessageRef = useRef(onmessage);
|
|
2785
|
+
const onopenRef = useRef(onopen);
|
|
2786
|
+
const onerrorRef = useRef(onerror);
|
|
2787
|
+
const oncloseRef = useRef(onclose);
|
|
2788
|
+
const headersRef = useRef(headers);
|
|
2789
|
+
onmessageRef.current = onmessage;
|
|
2790
|
+
onopenRef.current = onopen;
|
|
2791
|
+
onerrorRef.current = onerror;
|
|
2792
|
+
oncloseRef.current = onclose;
|
|
2793
|
+
headersRef.current = headers;
|
|
2794
|
+
useEffect(() => {
|
|
2795
|
+
if (!enabled) return;
|
|
2796
|
+
const unsubscribe = manager.subscribe(connectionKey, subscriberId, {
|
|
2797
|
+
url,
|
|
2798
|
+
getToken: getAccessToken,
|
|
2799
|
+
headers: headersRef.current ?? {},
|
|
2800
|
+
onopen(response) {
|
|
2801
|
+
if (response.ok) {
|
|
2802
|
+
setConnected(true);
|
|
2803
|
+
setError(null);
|
|
2804
|
+
}
|
|
2805
|
+
const customError = onopenRef.current?.(response);
|
|
2806
|
+
if (customError) setError(customError);
|
|
2807
|
+
},
|
|
2808
|
+
onmessage(event) {
|
|
2809
|
+
if (!event.data || event.data.trim() === "") return;
|
|
2810
|
+
onmessageRef.current(event.data);
|
|
2811
|
+
},
|
|
2812
|
+
onerror(err) {
|
|
2813
|
+
const msg = err instanceof Error ? err.message : "Unknown error";
|
|
2814
|
+
setConnected(false);
|
|
2815
|
+
setError(msg);
|
|
2816
|
+
onerrorRef.current?.(err instanceof Error ? err : new Error(msg));
|
|
2817
|
+
},
|
|
2818
|
+
onclose() {
|
|
2819
|
+
setConnected(false);
|
|
2820
|
+
oncloseRef.current?.();
|
|
2821
|
+
}
|
|
2822
|
+
});
|
|
2823
|
+
return () => {
|
|
2824
|
+
unsubscribe();
|
|
2825
|
+
setConnected(false);
|
|
2826
|
+
setError(null);
|
|
2827
|
+
};
|
|
2828
|
+
}, [enabled, connectionKey, url, subscriberId, getAccessToken, manager]);
|
|
2829
|
+
return { connected, error };
|
|
2830
|
+
}
|
|
2831
|
+
|
|
2832
|
+
// src/hooks/operations/shared/useExecutionLogSSE.ts
|
|
2833
|
+
function useExecutionLogSSE(resourceId, manager, apiUrl) {
|
|
3030
2834
|
const queryClient = useQueryClient();
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
2835
|
+
const [liveExecutions, setLiveExecutions] = useState(/* @__PURE__ */ new Set());
|
|
2836
|
+
const [streamingLogs, setStreamingLogs] = useState(/* @__PURE__ */ new Map());
|
|
2837
|
+
const { isReady: isOrganizationReady, organizationId } = useElevasisServices();
|
|
2838
|
+
const { currentMembership } = useOrganization();
|
|
2839
|
+
const currentWorkOSOrganizationId = currentMembership?.organization?.workos_org_id;
|
|
2840
|
+
const sseUrl = `${apiUrl}/api/execution-engine/sse/${resourceId}`;
|
|
2841
|
+
const headers = useMemo(() => {
|
|
2842
|
+
const h = {};
|
|
2843
|
+
if (currentWorkOSOrganizationId) h[HTTP_HEADERS.WORKOS_ORGANIZATION_ID] = currentWorkOSOrganizationId;
|
|
2844
|
+
return h;
|
|
2845
|
+
}, [currentWorkOSOrganizationId]);
|
|
2846
|
+
const handleMessage = useCallback(
|
|
2847
|
+
(data) => {
|
|
2848
|
+
try {
|
|
2849
|
+
const event = JSON.parse(data);
|
|
2850
|
+
switch (event.type) {
|
|
2851
|
+
case "connected":
|
|
2852
|
+
break;
|
|
2853
|
+
case "new-execution":
|
|
2854
|
+
if (event.executionId) {
|
|
2855
|
+
setLiveExecutions((prev) => {
|
|
2856
|
+
const updated = new Set(prev);
|
|
2857
|
+
updated.add(event.executionId);
|
|
2858
|
+
return updated;
|
|
2859
|
+
});
|
|
2860
|
+
queryClient.invalidateQueries({
|
|
2861
|
+
queryKey: executionsKeys.executionsListBase(organizationId, resourceId)
|
|
2862
|
+
});
|
|
2863
|
+
}
|
|
2864
|
+
break;
|
|
2865
|
+
case "execution-complete":
|
|
2866
|
+
if (event.executionId) {
|
|
2867
|
+
setLiveExecutions((prev) => {
|
|
2868
|
+
const updated = new Set(prev);
|
|
2869
|
+
updated.delete(event.executionId);
|
|
2870
|
+
return updated;
|
|
2871
|
+
});
|
|
2872
|
+
setStreamingLogs((prev) => {
|
|
2873
|
+
const updated = new Map(prev);
|
|
2874
|
+
updated.delete(event.executionId);
|
|
2875
|
+
return updated;
|
|
2876
|
+
});
|
|
2877
|
+
queryClient.invalidateQueries({
|
|
2878
|
+
queryKey: executionsKeys.executionsListBase(organizationId, resourceId)
|
|
2879
|
+
});
|
|
2880
|
+
queryClient.invalidateQueries({
|
|
2881
|
+
queryKey: executionsKeys.execution(organizationId, resourceId, event.executionId)
|
|
2882
|
+
});
|
|
2883
|
+
}
|
|
2884
|
+
break;
|
|
2885
|
+
case "log":
|
|
2886
|
+
if (event.executionId) {
|
|
2887
|
+
if (event.data?.log) {
|
|
2888
|
+
setStreamingLogs((prev) => {
|
|
2889
|
+
const updated = new Map(prev);
|
|
2890
|
+
const existing = updated.get(event.executionId) || [];
|
|
2891
|
+
updated.set(event.executionId, [...existing, event.data.log]);
|
|
2892
|
+
return updated;
|
|
2893
|
+
});
|
|
2894
|
+
}
|
|
2895
|
+
queryClient.invalidateQueries({
|
|
2896
|
+
queryKey: executionsKeys.execution(organizationId, resourceId, event.executionId)
|
|
2897
|
+
});
|
|
2898
|
+
}
|
|
2899
|
+
break;
|
|
2900
|
+
}
|
|
2901
|
+
} catch {
|
|
2902
|
+
}
|
|
3068
2903
|
},
|
|
3069
|
-
|
|
2904
|
+
[organizationId, resourceId, queryClient]
|
|
2905
|
+
);
|
|
2906
|
+
const { connected, error } = useSSEConnection({
|
|
2907
|
+
manager,
|
|
2908
|
+
connectionKey: `resource-${resourceId}`,
|
|
2909
|
+
url: sseUrl,
|
|
2910
|
+
enabled: !!resourceId && !!organizationId && isOrganizationReady,
|
|
2911
|
+
headers,
|
|
2912
|
+
onmessage: handleMessage,
|
|
2913
|
+
onopen: (response) => response.status === 403 ? "Organization access denied" : void 0
|
|
3070
2914
|
});
|
|
2915
|
+
useEffect(() => {
|
|
2916
|
+
return () => {
|
|
2917
|
+
setLiveExecutions(/* @__PURE__ */ new Set());
|
|
2918
|
+
setStreamingLogs(/* @__PURE__ */ new Map());
|
|
2919
|
+
};
|
|
2920
|
+
}, [resourceId, organizationId, isOrganizationReady]);
|
|
2921
|
+
return {
|
|
2922
|
+
liveExecutions,
|
|
2923
|
+
connected,
|
|
2924
|
+
error,
|
|
2925
|
+
runningCount: liveExecutions.size,
|
|
2926
|
+
isLive: (executionId) => liveExecutions.has(executionId),
|
|
2927
|
+
streamingLogs
|
|
2928
|
+
};
|
|
3071
2929
|
}
|
|
3072
2930
|
function useExecutionPanelState({
|
|
3073
2931
|
resourceId,
|
|
@@ -3601,252 +3459,499 @@ function useCreateWebhookEndpoint() {
|
|
|
3601
3459
|
}
|
|
3602
3460
|
});
|
|
3603
3461
|
}
|
|
3604
|
-
function useListWebhookEndpoints() {
|
|
3605
|
-
const { apiRequest, organizationId, isReady } = useElevasisServices();
|
|
3462
|
+
function useListWebhookEndpoints() {
|
|
3463
|
+
const { apiRequest, organizationId, isReady } = useElevasisServices();
|
|
3464
|
+
return useQuery({
|
|
3465
|
+
queryKey: ["webhook-endpoints", organizationId],
|
|
3466
|
+
queryFn: async () => {
|
|
3467
|
+
const service = new WebhookEndpointService(apiRequest);
|
|
3468
|
+
return await service.listEndpoints();
|
|
3469
|
+
},
|
|
3470
|
+
enabled: isReady
|
|
3471
|
+
});
|
|
3472
|
+
}
|
|
3473
|
+
function useOrgRoles(orgId) {
|
|
3474
|
+
const { apiRequest, organizationId, isReady } = useElevasisServices();
|
|
3475
|
+
const targetOrgId = orgId ?? organizationId;
|
|
3476
|
+
return useQuery({
|
|
3477
|
+
queryKey: ["org-roles", targetOrgId],
|
|
3478
|
+
queryFn: () => apiRequest(`/organizations/${targetOrgId}/roles`),
|
|
3479
|
+
enabled: isReady && !!targetOrgId,
|
|
3480
|
+
staleTime: STALE_TIME_DEFAULT
|
|
3481
|
+
});
|
|
3482
|
+
}
|
|
3483
|
+
function useUpdateOrgRole() {
|
|
3484
|
+
const { apiRequest, organizationId } = useElevasisServices();
|
|
3485
|
+
const queryClient = useQueryClient();
|
|
3486
|
+
return useMutation({
|
|
3487
|
+
mutationFn: ({ roleId, input }) => apiRequest(`/organizations/${organizationId}/roles/${roleId}`, {
|
|
3488
|
+
method: "PATCH",
|
|
3489
|
+
body: JSON.stringify(input)
|
|
3490
|
+
}),
|
|
3491
|
+
onSettled: (_data, _error, { roleId }) => {
|
|
3492
|
+
queryClient.invalidateQueries({ queryKey: ["org-roles", organizationId] });
|
|
3493
|
+
queryClient.invalidateQueries({ queryKey: ["org-role", organizationId, roleId] });
|
|
3494
|
+
}
|
|
3495
|
+
});
|
|
3496
|
+
}
|
|
3497
|
+
function useDeleteOrgRole() {
|
|
3498
|
+
const { apiRequest, organizationId } = useElevasisServices();
|
|
3499
|
+
const queryClient = useQueryClient();
|
|
3500
|
+
return useMutation({
|
|
3501
|
+
mutationFn: (roleId) => apiRequest(`/organizations/${organizationId}/roles/${roleId}`, {
|
|
3502
|
+
method: "DELETE"
|
|
3503
|
+
}),
|
|
3504
|
+
onSettled: () => {
|
|
3505
|
+
queryClient.invalidateQueries({ queryKey: ["org-roles", organizationId] });
|
|
3506
|
+
}
|
|
3507
|
+
});
|
|
3508
|
+
}
|
|
3509
|
+
function useAssignRole() {
|
|
3510
|
+
const { apiRequest, organizationId } = useElevasisServices();
|
|
3511
|
+
const queryClient = useQueryClient();
|
|
3512
|
+
return useMutation({
|
|
3513
|
+
mutationFn: ({ membershipId, roleId }) => apiRequest(`/memberships/${membershipId}/roles`, {
|
|
3514
|
+
method: "POST",
|
|
3515
|
+
body: JSON.stringify({ roleId })
|
|
3516
|
+
}),
|
|
3517
|
+
onSettled: (_data, _error, { membershipId }) => {
|
|
3518
|
+
queryClient.invalidateQueries({ queryKey: ["member-roles", organizationId, membershipId] });
|
|
3519
|
+
queryClient.invalidateQueries({ queryKey: ["organization-permissions", organizationId] });
|
|
3520
|
+
queryClient.invalidateQueries({ queryKey: ["org-roles", organizationId] });
|
|
3521
|
+
}
|
|
3522
|
+
});
|
|
3523
|
+
}
|
|
3524
|
+
function useRevokeRole() {
|
|
3525
|
+
const { apiRequest, organizationId } = useElevasisServices();
|
|
3526
|
+
const queryClient = useQueryClient();
|
|
3527
|
+
return useMutation({
|
|
3528
|
+
mutationFn: ({ membershipId, roleId }) => apiRequest(`/memberships/${membershipId}/roles/${roleId}`, {
|
|
3529
|
+
method: "DELETE"
|
|
3530
|
+
}),
|
|
3531
|
+
onSettled: (_data, _error, { membershipId }) => {
|
|
3532
|
+
queryClient.invalidateQueries({ queryKey: ["member-roles", organizationId, membershipId] });
|
|
3533
|
+
queryClient.invalidateQueries({ queryKey: ["organization-permissions", organizationId] });
|
|
3534
|
+
queryClient.invalidateQueries({ queryKey: ["org-roles", organizationId] });
|
|
3535
|
+
}
|
|
3536
|
+
});
|
|
3537
|
+
}
|
|
3538
|
+
function useEffectivePermissions(membershipId) {
|
|
3539
|
+
const { apiRequest, organizationId, isReady } = useElevasisServices();
|
|
3540
|
+
return useQuery({
|
|
3541
|
+
queryKey: ["member-roles", organizationId, membershipId],
|
|
3542
|
+
queryFn: () => apiRequest(`/memberships/${membershipId}/effective-permissions`),
|
|
3543
|
+
enabled: isReady && !!membershipId,
|
|
3544
|
+
staleTime: STALE_TIME_DEFAULT
|
|
3545
|
+
});
|
|
3546
|
+
}
|
|
3547
|
+
|
|
3548
|
+
// src/hooks/acquisition/useLists.ts
|
|
3549
|
+
var acquisitionListKeys = {
|
|
3550
|
+
all: ["acquisition-lists"],
|
|
3551
|
+
list: (organizationId) => [...acquisitionListKeys.all, organizationId],
|
|
3552
|
+
detail: (organizationId, listId) => [...acquisitionListKeys.all, organizationId, listId],
|
|
3553
|
+
telemetry: (organizationId) => [...acquisitionListKeys.all, "telemetry", organizationId],
|
|
3554
|
+
progress: (organizationId, listId) => [...acquisitionListKeys.all, "progress", organizationId, listId],
|
|
3555
|
+
executions: (organizationId, listId) => [...acquisitionListKeys.all, "executions", organizationId, listId]
|
|
3556
|
+
};
|
|
3557
|
+
function useLists() {
|
|
3558
|
+
const { apiRequest, isReady, organizationId } = useElevasisServices();
|
|
3559
|
+
return useQuery({
|
|
3560
|
+
queryKey: acquisitionListKeys.list(organizationId),
|
|
3561
|
+
queryFn: () => apiRequest("/acquisition/lists"),
|
|
3562
|
+
enabled: isReady
|
|
3563
|
+
});
|
|
3564
|
+
}
|
|
3565
|
+
function useList(listId) {
|
|
3566
|
+
const { apiRequest, isReady, organizationId } = useElevasisServices();
|
|
3606
3567
|
return useQuery({
|
|
3607
|
-
queryKey:
|
|
3608
|
-
queryFn:
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3568
|
+
queryKey: acquisitionListKeys.detail(organizationId, listId),
|
|
3569
|
+
queryFn: () => apiRequest(`/acquisition/lists/${listId}`),
|
|
3570
|
+
enabled: isReady && !!listId
|
|
3571
|
+
});
|
|
3572
|
+
}
|
|
3573
|
+
function useListsTelemetry() {
|
|
3574
|
+
const { apiRequest, isReady, organizationId } = useElevasisServices();
|
|
3575
|
+
return useQuery({
|
|
3576
|
+
queryKey: acquisitionListKeys.telemetry(organizationId),
|
|
3577
|
+
queryFn: () => apiRequest("/acquisition/lists/telemetry"),
|
|
3612
3578
|
enabled: isReady
|
|
3613
3579
|
});
|
|
3614
3580
|
}
|
|
3615
|
-
function
|
|
3616
|
-
const { apiRequest,
|
|
3617
|
-
const targetOrgId = orgId ?? organizationId;
|
|
3581
|
+
function useListProgress(listId) {
|
|
3582
|
+
const { apiRequest, isReady, organizationId } = useElevasisServices();
|
|
3618
3583
|
return useQuery({
|
|
3619
|
-
queryKey:
|
|
3620
|
-
queryFn: () => apiRequest(`/
|
|
3621
|
-
enabled: isReady && !!
|
|
3622
|
-
staleTime: STALE_TIME_DEFAULT
|
|
3584
|
+
queryKey: acquisitionListKeys.progress(organizationId, listId),
|
|
3585
|
+
queryFn: () => apiRequest(`/acquisition/lists/${listId}/progress`),
|
|
3586
|
+
enabled: isReady && !!listId
|
|
3623
3587
|
});
|
|
3624
3588
|
}
|
|
3625
|
-
function
|
|
3589
|
+
function useListExecutions(listId) {
|
|
3590
|
+
const { apiRequest, isReady, organizationId } = useElevasisServices();
|
|
3591
|
+
return useQuery({
|
|
3592
|
+
queryKey: acquisitionListKeys.executions(organizationId, listId),
|
|
3593
|
+
queryFn: () => apiRequest(`/acquisition/lists/${listId}/executions`),
|
|
3594
|
+
enabled: isReady && !!listId
|
|
3595
|
+
});
|
|
3596
|
+
}
|
|
3597
|
+
function useCreateList() {
|
|
3626
3598
|
const { apiRequest, organizationId } = useElevasisServices();
|
|
3627
3599
|
const queryClient = useQueryClient();
|
|
3628
3600
|
return useMutation({
|
|
3629
|
-
mutationFn: (
|
|
3630
|
-
method: "
|
|
3631
|
-
body: JSON.stringify(
|
|
3601
|
+
mutationFn: (body) => apiRequest("/acquisition/lists", {
|
|
3602
|
+
method: "POST",
|
|
3603
|
+
body: JSON.stringify(body)
|
|
3632
3604
|
}),
|
|
3633
|
-
|
|
3634
|
-
queryClient.invalidateQueries({ queryKey:
|
|
3635
|
-
queryClient.invalidateQueries({ queryKey:
|
|
3605
|
+
onSuccess: () => {
|
|
3606
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.list(organizationId) });
|
|
3607
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.telemetry(organizationId) });
|
|
3608
|
+
showSuccessNotification("List created");
|
|
3609
|
+
},
|
|
3610
|
+
onError: (error) => {
|
|
3611
|
+
showApiErrorNotification(error);
|
|
3636
3612
|
}
|
|
3637
3613
|
});
|
|
3638
3614
|
}
|
|
3639
|
-
function
|
|
3615
|
+
function useUpdateList(listId) {
|
|
3640
3616
|
const { apiRequest, organizationId } = useElevasisServices();
|
|
3641
3617
|
const queryClient = useQueryClient();
|
|
3642
3618
|
return useMutation({
|
|
3643
|
-
mutationFn: (
|
|
3644
|
-
method: "
|
|
3619
|
+
mutationFn: (body) => apiRequest(`/acquisition/lists/${listId}`, {
|
|
3620
|
+
method: "PATCH",
|
|
3621
|
+
body: JSON.stringify(body)
|
|
3645
3622
|
}),
|
|
3646
|
-
|
|
3647
|
-
queryClient.invalidateQueries({ queryKey:
|
|
3623
|
+
onSuccess: () => {
|
|
3624
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.list(organizationId) });
|
|
3625
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.detail(organizationId, listId) });
|
|
3626
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.telemetry(organizationId) });
|
|
3627
|
+
showSuccessNotification("List updated");
|
|
3628
|
+
},
|
|
3629
|
+
onError: (error) => {
|
|
3630
|
+
showApiErrorNotification(error);
|
|
3648
3631
|
}
|
|
3649
3632
|
});
|
|
3650
3633
|
}
|
|
3651
|
-
function
|
|
3634
|
+
function useUpdateListConfig(listId) {
|
|
3652
3635
|
const { apiRequest, organizationId } = useElevasisServices();
|
|
3653
3636
|
const queryClient = useQueryClient();
|
|
3654
3637
|
return useMutation({
|
|
3655
|
-
mutationFn: (
|
|
3656
|
-
method: "
|
|
3657
|
-
body: JSON.stringify(
|
|
3638
|
+
mutationFn: (body) => apiRequest(`/acquisition/lists/${listId}/config`, {
|
|
3639
|
+
method: "PATCH",
|
|
3640
|
+
body: JSON.stringify(body)
|
|
3658
3641
|
}),
|
|
3659
|
-
|
|
3660
|
-
queryClient.invalidateQueries({ queryKey:
|
|
3661
|
-
queryClient.invalidateQueries({ queryKey:
|
|
3662
|
-
|
|
3642
|
+
onSuccess: () => {
|
|
3643
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.list(organizationId) });
|
|
3644
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.detail(organizationId, listId) });
|
|
3645
|
+
showSuccessNotification("List configuration saved");
|
|
3646
|
+
},
|
|
3647
|
+
onError: (error) => {
|
|
3648
|
+
showApiErrorNotification(error);
|
|
3663
3649
|
}
|
|
3664
3650
|
});
|
|
3665
3651
|
}
|
|
3666
|
-
function
|
|
3652
|
+
function useDeleteList() {
|
|
3667
3653
|
const { apiRequest, organizationId } = useElevasisServices();
|
|
3668
3654
|
const queryClient = useQueryClient();
|
|
3669
3655
|
return useMutation({
|
|
3670
|
-
mutationFn: (
|
|
3656
|
+
mutationFn: (listId) => apiRequest(`/acquisition/lists/${listId}`, {
|
|
3671
3657
|
method: "DELETE"
|
|
3672
3658
|
}),
|
|
3673
|
-
|
|
3674
|
-
queryClient.invalidateQueries({ queryKey:
|
|
3675
|
-
queryClient.invalidateQueries({ queryKey:
|
|
3676
|
-
|
|
3659
|
+
onSuccess: () => {
|
|
3660
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.list(organizationId) });
|
|
3661
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.telemetry(organizationId) });
|
|
3662
|
+
showSuccessNotification("List deleted");
|
|
3663
|
+
},
|
|
3664
|
+
onError: (error) => {
|
|
3665
|
+
showApiErrorNotification(error);
|
|
3677
3666
|
}
|
|
3678
3667
|
});
|
|
3679
3668
|
}
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
enabled: isReady && !!membershipId,
|
|
3686
|
-
staleTime: STALE_TIME_DEFAULT
|
|
3687
|
-
});
|
|
3688
|
-
}
|
|
3689
|
-
function useSSEConnection({
|
|
3690
|
-
manager,
|
|
3691
|
-
connectionKey,
|
|
3692
|
-
url,
|
|
3693
|
-
enabled = true,
|
|
3694
|
-
headers,
|
|
3695
|
-
onmessage,
|
|
3696
|
-
onopen,
|
|
3697
|
-
onerror,
|
|
3698
|
-
onclose
|
|
3669
|
+
|
|
3670
|
+
// src/hooks/executions/useWorkflowExecution.ts
|
|
3671
|
+
function useWorkflowExecution({
|
|
3672
|
+
workflowId,
|
|
3673
|
+
listId
|
|
3699
3674
|
}) {
|
|
3700
|
-
const
|
|
3701
|
-
const
|
|
3702
|
-
const
|
|
3703
|
-
const
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
url,
|
|
3718
|
-
getToken: getAccessToken,
|
|
3719
|
-
headers: headersRef.current ?? {},
|
|
3720
|
-
onopen(response) {
|
|
3721
|
-
if (response.ok) {
|
|
3722
|
-
setConnected(true);
|
|
3723
|
-
setError(null);
|
|
3724
|
-
}
|
|
3725
|
-
const customError = onopenRef.current?.(response);
|
|
3726
|
-
if (customError) setError(customError);
|
|
3727
|
-
},
|
|
3728
|
-
onmessage(event) {
|
|
3729
|
-
if (!event.data || event.data.trim() === "") return;
|
|
3730
|
-
onmessageRef.current(event.data);
|
|
3731
|
-
},
|
|
3732
|
-
onerror(err) {
|
|
3733
|
-
const msg = err instanceof Error ? err.message : "Unknown error";
|
|
3734
|
-
setConnected(false);
|
|
3735
|
-
setError(msg);
|
|
3736
|
-
onerrorRef.current?.(err instanceof Error ? err : new Error(msg));
|
|
3737
|
-
},
|
|
3738
|
-
onclose() {
|
|
3739
|
-
setConnected(false);
|
|
3740
|
-
oncloseRef.current?.();
|
|
3675
|
+
const mutation = useExecuteAsync();
|
|
3676
|
+
const queryClient = useQueryClient();
|
|
3677
|
+
const { organizationId } = useElevasisServices();
|
|
3678
|
+
const execute = useCallback(
|
|
3679
|
+
async ({ input }) => {
|
|
3680
|
+
const result = await mutation.mutateAsync({
|
|
3681
|
+
resourceId: workflowId,
|
|
3682
|
+
resourceType: "workflow",
|
|
3683
|
+
input
|
|
3684
|
+
});
|
|
3685
|
+
queryClient.invalidateQueries({
|
|
3686
|
+
queryKey: executionsKeys.executionsListBase(organizationId, workflowId)
|
|
3687
|
+
});
|
|
3688
|
+
if (listId) {
|
|
3689
|
+
queryClient.invalidateQueries({
|
|
3690
|
+
queryKey: acquisitionListKeys.executions(organizationId, listId)
|
|
3691
|
+
});
|
|
3741
3692
|
}
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3693
|
+
return result;
|
|
3694
|
+
},
|
|
3695
|
+
[listId, mutation, organizationId, queryClient, workflowId]
|
|
3696
|
+
);
|
|
3697
|
+
return {
|
|
3698
|
+
execute,
|
|
3699
|
+
executionId: mutation.data?.executionId ?? null,
|
|
3700
|
+
status: mutation.data?.status ?? null,
|
|
3701
|
+
isIdle: mutation.isIdle,
|
|
3702
|
+
isPending: mutation.isPending,
|
|
3703
|
+
isSuccess: mutation.isSuccess,
|
|
3704
|
+
isError: mutation.isError,
|
|
3705
|
+
error: mutation.error,
|
|
3706
|
+
data: mutation.data,
|
|
3707
|
+
reset: mutation.reset
|
|
3708
|
+
};
|
|
3750
3709
|
}
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3710
|
+
function createDisabledManager() {
|
|
3711
|
+
return {
|
|
3712
|
+
subscribe: () => () => {
|
|
3713
|
+
},
|
|
3714
|
+
closeConnection: () => {
|
|
3715
|
+
},
|
|
3716
|
+
getConnectionInfo: () => /* @__PURE__ */ new Map()
|
|
3717
|
+
};
|
|
3718
|
+
}
|
|
3719
|
+
function useExecutionSSE(resourceId, options = {}) {
|
|
3754
3720
|
const queryClient = useQueryClient();
|
|
3721
|
+
const features = useOptionalElevasisFeatures();
|
|
3722
|
+
const { currentMembership } = useOrganization();
|
|
3723
|
+
const { isReady, organizationId } = useElevasisServices();
|
|
3724
|
+
const {
|
|
3725
|
+
enabled = true,
|
|
3726
|
+
apiUrl: apiUrlOverride,
|
|
3727
|
+
manager: managerOverride,
|
|
3728
|
+
listId,
|
|
3729
|
+
onEvent
|
|
3730
|
+
} = options;
|
|
3731
|
+
const [events, setEvents] = useState([]);
|
|
3755
3732
|
const [liveExecutions, setLiveExecutions] = useState(/* @__PURE__ */ new Set());
|
|
3756
3733
|
const [streamingLogs, setStreamingLogs] = useState(/* @__PURE__ */ new Map());
|
|
3757
|
-
const
|
|
3758
|
-
const
|
|
3759
|
-
const
|
|
3760
|
-
const
|
|
3734
|
+
const disabledManager = useMemo(() => createDisabledManager(), []);
|
|
3735
|
+
const apiUrl = apiUrlOverride ?? features?.operationsApiUrl;
|
|
3736
|
+
const manager = managerOverride ?? features?.operationsSSEManager ?? disabledManager;
|
|
3737
|
+
const workOSOrganizationId = currentMembership?.organization?.workos_org_id ?? organizationId;
|
|
3738
|
+
const connectionKey = `execution-sse-${workOSOrganizationId ?? "unknown"}-${resourceId}`;
|
|
3761
3739
|
const headers = useMemo(() => {
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3740
|
+
if (!workOSOrganizationId) return {};
|
|
3741
|
+
const nextHeaders = {};
|
|
3742
|
+
nextHeaders[HTTP_HEADERS.WORKOS_ORGANIZATION_ID] = workOSOrganizationId;
|
|
3743
|
+
return nextHeaders;
|
|
3744
|
+
}, [workOSOrganizationId]);
|
|
3745
|
+
const clear = useCallback(() => {
|
|
3746
|
+
setEvents([]);
|
|
3747
|
+
setLiveExecutions(/* @__PURE__ */ new Set());
|
|
3748
|
+
setStreamingLogs(/* @__PURE__ */ new Map());
|
|
3749
|
+
}, []);
|
|
3766
3750
|
const handleMessage = useCallback(
|
|
3767
|
-
(
|
|
3751
|
+
(rawData) => {
|
|
3768
3752
|
try {
|
|
3769
|
-
const event = JSON.parse(
|
|
3753
|
+
const event = JSON.parse(rawData);
|
|
3754
|
+
setEvents((current) => [...current, event]);
|
|
3755
|
+
onEvent?.(event);
|
|
3770
3756
|
switch (event.type) {
|
|
3771
|
-
case "connected":
|
|
3772
|
-
break;
|
|
3773
3757
|
case "new-execution":
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
});
|
|
3783
|
-
}
|
|
3758
|
+
setLiveExecutions((current) => {
|
|
3759
|
+
const next = new Set(current);
|
|
3760
|
+
next.add(event.executionId);
|
|
3761
|
+
return next;
|
|
3762
|
+
});
|
|
3763
|
+
queryClient.invalidateQueries({
|
|
3764
|
+
queryKey: executionsKeys.executionsListBase(organizationId, resourceId)
|
|
3765
|
+
});
|
|
3784
3766
|
break;
|
|
3785
3767
|
case "execution-complete":
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3768
|
+
setLiveExecutions((current) => {
|
|
3769
|
+
const next = new Set(current);
|
|
3770
|
+
next.delete(event.executionId);
|
|
3771
|
+
return next;
|
|
3772
|
+
});
|
|
3773
|
+
setStreamingLogs((current) => {
|
|
3774
|
+
const next = new Map(current);
|
|
3775
|
+
next.delete(event.executionId);
|
|
3776
|
+
return next;
|
|
3777
|
+
});
|
|
3778
|
+
queryClient.invalidateQueries({
|
|
3779
|
+
queryKey: executionsKeys.executionsListBase(organizationId, resourceId)
|
|
3780
|
+
});
|
|
3781
|
+
queryClient.invalidateQueries({
|
|
3782
|
+
queryKey: executionsKeys.execution(organizationId, resourceId, event.executionId)
|
|
3783
|
+
});
|
|
3784
|
+
if (listId) {
|
|
3797
3785
|
queryClient.invalidateQueries({
|
|
3798
|
-
queryKey:
|
|
3786
|
+
queryKey: acquisitionListKeys.executions(organizationId, listId)
|
|
3799
3787
|
});
|
|
3800
3788
|
queryClient.invalidateQueries({
|
|
3801
|
-
queryKey:
|
|
3789
|
+
queryKey: acquisitionListKeys.progress(organizationId, listId)
|
|
3802
3790
|
});
|
|
3803
3791
|
}
|
|
3804
3792
|
break;
|
|
3805
3793
|
case "log":
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
});
|
|
3818
|
-
}
|
|
3794
|
+
setStreamingLogs((current) => {
|
|
3795
|
+
const next = new Map(current);
|
|
3796
|
+
const existing = next.get(event.executionId) ?? [];
|
|
3797
|
+
next.set(event.executionId, [...existing, event.data.log]);
|
|
3798
|
+
return next;
|
|
3799
|
+
});
|
|
3800
|
+
queryClient.invalidateQueries({
|
|
3801
|
+
queryKey: executionsKeys.execution(organizationId, resourceId, event.executionId)
|
|
3802
|
+
});
|
|
3803
|
+
break;
|
|
3804
|
+
case "connected":
|
|
3819
3805
|
break;
|
|
3820
3806
|
}
|
|
3821
3807
|
} catch {
|
|
3822
3808
|
}
|
|
3823
3809
|
},
|
|
3824
|
-
[organizationId,
|
|
3810
|
+
[listId, onEvent, organizationId, queryClient, resourceId]
|
|
3825
3811
|
);
|
|
3826
3812
|
const { connected, error } = useSSEConnection({
|
|
3827
3813
|
manager,
|
|
3828
|
-
connectionKey
|
|
3829
|
-
url:
|
|
3830
|
-
enabled:
|
|
3814
|
+
connectionKey,
|
|
3815
|
+
url: apiUrl ? `${apiUrl}/api/execution-engine/sse/${resourceId}` : "",
|
|
3816
|
+
enabled: enabled && Boolean(apiUrl && resourceId && workOSOrganizationId && isReady),
|
|
3831
3817
|
headers,
|
|
3832
3818
|
onmessage: handleMessage,
|
|
3833
3819
|
onopen: (response) => response.status === 403 ? "Organization access denied" : void 0
|
|
3834
3820
|
});
|
|
3835
|
-
useEffect(() =>
|
|
3836
|
-
return () => {
|
|
3837
|
-
setLiveExecutions(/* @__PURE__ */ new Set());
|
|
3838
|
-
setStreamingLogs(/* @__PURE__ */ new Map());
|
|
3839
|
-
};
|
|
3840
|
-
}, [resourceId, organizationId, isOrganizationReady]);
|
|
3821
|
+
useEffect(() => () => clear(), [clear, connectionKey]);
|
|
3841
3822
|
return {
|
|
3842
|
-
liveExecutions,
|
|
3843
3823
|
connected,
|
|
3844
3824
|
error,
|
|
3825
|
+
events,
|
|
3826
|
+
latestEvent: events.length > 0 ? events[events.length - 1] : null,
|
|
3827
|
+
liveExecutions,
|
|
3828
|
+
streamingLogs,
|
|
3845
3829
|
runningCount: liveExecutions.size,
|
|
3846
3830
|
isLive: (executionId) => liveExecutions.has(executionId),
|
|
3847
|
-
|
|
3831
|
+
clear
|
|
3848
3832
|
};
|
|
3849
3833
|
}
|
|
3834
|
+
function useRetryExecution() {
|
|
3835
|
+
const { apiRequest, organizationId } = useElevasisServices();
|
|
3836
|
+
const queryClient = useQueryClient();
|
|
3837
|
+
return useMutation({
|
|
3838
|
+
mutationFn: async ({ resourceId, resourceType, input }) => {
|
|
3839
|
+
const response = await apiRequest("/execution-engine/execute-async", {
|
|
3840
|
+
method: "POST",
|
|
3841
|
+
body: JSON.stringify({ resourceType, resourceId, input })
|
|
3842
|
+
});
|
|
3843
|
+
return { ...response, resourceId };
|
|
3844
|
+
},
|
|
3845
|
+
onSuccess: (data) => {
|
|
3846
|
+
queryClient.invalidateQueries({
|
|
3847
|
+
queryKey: executionsKeys.executionsListBase(organizationId, data.resourceId)
|
|
3848
|
+
});
|
|
3849
|
+
}
|
|
3850
|
+
});
|
|
3851
|
+
}
|
|
3852
|
+
function useCancelExecution() {
|
|
3853
|
+
const { apiRequest, organizationId } = useElevasisServices();
|
|
3854
|
+
const queryClient = useQueryClient();
|
|
3855
|
+
return useMutation({
|
|
3856
|
+
mutationFn: async ({ resourceId, executionId }) => {
|
|
3857
|
+
const response = await apiRequest(
|
|
3858
|
+
`/execution-engine/executions/${resourceId}/${executionId}/cancel`,
|
|
3859
|
+
{ method: "POST" }
|
|
3860
|
+
);
|
|
3861
|
+
return { ...response, resourceId, executionId };
|
|
3862
|
+
},
|
|
3863
|
+
onSuccess: (data) => {
|
|
3864
|
+
queryClient.invalidateQueries({
|
|
3865
|
+
queryKey: executionsKeys.execution(organizationId, data.resourceId, data.executionId)
|
|
3866
|
+
});
|
|
3867
|
+
queryClient.invalidateQueries({
|
|
3868
|
+
queryKey: executionsKeys.executionsListBase(organizationId, data.resourceId)
|
|
3869
|
+
});
|
|
3870
|
+
}
|
|
3871
|
+
});
|
|
3872
|
+
}
|
|
3873
|
+
function useDeleteExecution() {
|
|
3874
|
+
const { apiRequest, organizationId } = useElevasisServices();
|
|
3875
|
+
const queryClient = useQueryClient();
|
|
3876
|
+
return useMutation({
|
|
3877
|
+
mutationFn: async ({ resourceId, executionId }) => {
|
|
3878
|
+
await apiRequest(`/execution-engine/executions/${resourceId}/${executionId}`, {
|
|
3879
|
+
method: "DELETE"
|
|
3880
|
+
});
|
|
3881
|
+
return { resourceId, executionId };
|
|
3882
|
+
},
|
|
3883
|
+
onSuccess: (data) => {
|
|
3884
|
+
queryClient.removeQueries({
|
|
3885
|
+
queryKey: executionsKeys.execution(organizationId, data.resourceId, data.executionId)
|
|
3886
|
+
});
|
|
3887
|
+
queryClient.invalidateQueries({
|
|
3888
|
+
queryKey: executionsKeys.executionsListBase(organizationId, data.resourceId)
|
|
3889
|
+
});
|
|
3890
|
+
}
|
|
3891
|
+
});
|
|
3892
|
+
}
|
|
3893
|
+
function useBulkDeleteExecutions() {
|
|
3894
|
+
const { apiRequest, organizationId } = useElevasisServices();
|
|
3895
|
+
const queryClient = useQueryClient();
|
|
3896
|
+
return useMutation({
|
|
3897
|
+
mutationFn: async ({
|
|
3898
|
+
resourceId,
|
|
3899
|
+
resourceStatus
|
|
3900
|
+
}) => {
|
|
3901
|
+
const params = new URLSearchParams();
|
|
3902
|
+
if (resourceStatus && resourceStatus !== "all") {
|
|
3903
|
+
params.set("resourceStatus", resourceStatus);
|
|
3904
|
+
}
|
|
3905
|
+
const queryString = params.toString();
|
|
3906
|
+
const endpoint = `/execution-engine/executions/${resourceId}${queryString ? `?${queryString}` : ""}`;
|
|
3907
|
+
const response = await apiRequest(
|
|
3908
|
+
endpoint,
|
|
3909
|
+
{ method: "DELETE" }
|
|
3910
|
+
);
|
|
3911
|
+
return { resourceId, deletedCount: response.deletedCount, resourceStatus };
|
|
3912
|
+
},
|
|
3913
|
+
onSuccess: (data) => {
|
|
3914
|
+
queryClient.invalidateQueries({
|
|
3915
|
+
queryKey: executionsKeys.executionsListBase(organizationId, data.resourceId)
|
|
3916
|
+
});
|
|
3917
|
+
}
|
|
3918
|
+
});
|
|
3919
|
+
}
|
|
3920
|
+
function useResourceDefinition(resourceId, enabled = true) {
|
|
3921
|
+
const { apiRequest, organizationId, isReady } = useElevasisServices();
|
|
3922
|
+
return useQuery({
|
|
3923
|
+
queryKey: executionsKeys.resourceDefinition(organizationId, resourceId),
|
|
3924
|
+
queryFn: () => {
|
|
3925
|
+
const service = new OperationsService(apiRequest);
|
|
3926
|
+
return service.getResourceDefinition(resourceId);
|
|
3927
|
+
},
|
|
3928
|
+
enabled: enabled && isReady && !!resourceId,
|
|
3929
|
+
retry: 2,
|
|
3930
|
+
retryDelay: (attemptIndex) => Math.min(1e3 * 2 ** attemptIndex, 3e4)
|
|
3931
|
+
});
|
|
3932
|
+
}
|
|
3933
|
+
function useArchivedLogs(executionId) {
|
|
3934
|
+
const { apiRequest } = useElevasisServices();
|
|
3935
|
+
const [logs, setLogs] = useState(null);
|
|
3936
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
3937
|
+
const [error, setError] = useState(null);
|
|
3938
|
+
const fetch = useCallback(async () => {
|
|
3939
|
+
if (!executionId || isLoading) return;
|
|
3940
|
+
setIsLoading(true);
|
|
3941
|
+
setError(null);
|
|
3942
|
+
try {
|
|
3943
|
+
const response = await apiRequest(
|
|
3944
|
+
`/observability/executions/${executionId}/archived-logs`
|
|
3945
|
+
);
|
|
3946
|
+
setLogs(response.logs);
|
|
3947
|
+
} catch (err) {
|
|
3948
|
+
setError(err instanceof Error ? err.message : "Failed to load archived logs");
|
|
3949
|
+
} finally {
|
|
3950
|
+
setIsLoading(false);
|
|
3951
|
+
}
|
|
3952
|
+
}, [executionId, apiRequest, isLoading]);
|
|
3953
|
+
return { logs, isLoading, error, fetch };
|
|
3954
|
+
}
|
|
3850
3955
|
function useActivitiesRealtime(organizationId, enabled) {
|
|
3851
3956
|
const queryClient = useQueryClient();
|
|
3852
3957
|
const supabase = useSupabase();
|
|
@@ -4503,6 +4608,32 @@ function useDealDetail(acqDealId) {
|
|
|
4503
4608
|
enabled: isReady && !!acqDealId
|
|
4504
4609
|
});
|
|
4505
4610
|
}
|
|
4611
|
+
function useTransitionState() {
|
|
4612
|
+
const { apiRequest, organizationId } = useElevasisServices();
|
|
4613
|
+
const queryClient = useQueryClient();
|
|
4614
|
+
return useMutation({
|
|
4615
|
+
mutationFn: async (input) => {
|
|
4616
|
+
const { dealId, stateKey, reason, expectedUpdatedAt } = input;
|
|
4617
|
+
await apiRequest(`/deals/${dealId}/state`, {
|
|
4618
|
+
method: "PATCH",
|
|
4619
|
+
body: JSON.stringify({
|
|
4620
|
+
stateKey,
|
|
4621
|
+
...reason !== void 0 ? { reason } : {},
|
|
4622
|
+
...expectedUpdatedAt !== void 0 ? { expectedUpdatedAt } : {}
|
|
4623
|
+
})
|
|
4624
|
+
});
|
|
4625
|
+
},
|
|
4626
|
+
onSuccess: (_, variables) => {
|
|
4627
|
+
queryClient.invalidateQueries({ queryKey: dealKeys.lists() });
|
|
4628
|
+
queryClient.invalidateQueries({ queryKey: dealKeys.summaries() });
|
|
4629
|
+
queryClient.invalidateQueries({ queryKey: ["deal-detail", organizationId, variables.dealId] });
|
|
4630
|
+
},
|
|
4631
|
+
onError: (error) => {
|
|
4632
|
+
queryClient.invalidateQueries({ queryKey: dealKeys.all });
|
|
4633
|
+
showApiErrorNotification(error);
|
|
4634
|
+
}
|
|
4635
|
+
});
|
|
4636
|
+
}
|
|
4506
4637
|
function useExecuteAction({ dealId }) {
|
|
4507
4638
|
const { apiRequest, organizationId } = useElevasisServices();
|
|
4508
4639
|
const queryClient = useQueryClient();
|
|
@@ -4524,6 +4655,100 @@ function useExecuteAction({ dealId }) {
|
|
|
4524
4655
|
}
|
|
4525
4656
|
});
|
|
4526
4657
|
}
|
|
4658
|
+
var dealNoteKeys = {
|
|
4659
|
+
all: ["deal-notes"],
|
|
4660
|
+
list: (organizationId, dealId) => ["deal-notes", organizationId, dealId]
|
|
4661
|
+
};
|
|
4662
|
+
function useDealNotes(dealId) {
|
|
4663
|
+
const { apiRequest, isReady, organizationId } = useElevasisServices();
|
|
4664
|
+
return useQuery({
|
|
4665
|
+
queryKey: dealNoteKeys.list(organizationId, dealId),
|
|
4666
|
+
queryFn: async () => {
|
|
4667
|
+
return apiRequest(`/deals/${dealId}/notes`);
|
|
4668
|
+
},
|
|
4669
|
+
enabled: isReady && !!dealId
|
|
4670
|
+
});
|
|
4671
|
+
}
|
|
4672
|
+
function useCreateDealNote() {
|
|
4673
|
+
const { apiRequest, organizationId } = useElevasisServices();
|
|
4674
|
+
const queryClient = useQueryClient();
|
|
4675
|
+
return useMutation({
|
|
4676
|
+
mutationFn: async ({ dealId, body }) => {
|
|
4677
|
+
return apiRequest(`/deals/${dealId}/notes`, {
|
|
4678
|
+
method: "POST",
|
|
4679
|
+
body: JSON.stringify({ body })
|
|
4680
|
+
});
|
|
4681
|
+
},
|
|
4682
|
+
onSuccess: (_, variables) => {
|
|
4683
|
+
queryClient.invalidateQueries({ queryKey: dealNoteKeys.list(organizationId, variables.dealId) });
|
|
4684
|
+
queryClient.invalidateQueries({ queryKey: ["recent-crm-activity", organizationId] });
|
|
4685
|
+
showSuccessNotification("Note added");
|
|
4686
|
+
},
|
|
4687
|
+
onError: (error) => {
|
|
4688
|
+
showApiErrorNotification(error);
|
|
4689
|
+
}
|
|
4690
|
+
});
|
|
4691
|
+
}
|
|
4692
|
+
function useAddCompaniesToList(listId) {
|
|
4693
|
+
const { apiRequest, organizationId } = useElevasisServices();
|
|
4694
|
+
const queryClient = useQueryClient();
|
|
4695
|
+
return useMutation({
|
|
4696
|
+
mutationFn: (body) => apiRequest(`/acquisition/lists/${listId}/companies`, {
|
|
4697
|
+
method: "POST",
|
|
4698
|
+
body: JSON.stringify(body)
|
|
4699
|
+
}),
|
|
4700
|
+
onSuccess: () => {
|
|
4701
|
+
queryClient.invalidateQueries({ queryKey: companyKeys.all });
|
|
4702
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.detail(organizationId, listId) });
|
|
4703
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.progress(organizationId, listId) });
|
|
4704
|
+
queryClient.invalidateQueries({ queryKey: leadGenListMemberKeys.list(organizationId, listId) });
|
|
4705
|
+
showSuccessNotification("Companies added to list");
|
|
4706
|
+
},
|
|
4707
|
+
onError: (error) => {
|
|
4708
|
+
showApiErrorNotification(error);
|
|
4709
|
+
}
|
|
4710
|
+
});
|
|
4711
|
+
}
|
|
4712
|
+
function useRemoveCompaniesFromList(listId) {
|
|
4713
|
+
const { apiRequest, organizationId } = useElevasisServices();
|
|
4714
|
+
const queryClient = useQueryClient();
|
|
4715
|
+
return useMutation({
|
|
4716
|
+
mutationFn: (body) => apiRequest(`/acquisition/lists/${listId}/companies`, {
|
|
4717
|
+
method: "DELETE",
|
|
4718
|
+
body: JSON.stringify(body)
|
|
4719
|
+
}),
|
|
4720
|
+
onSuccess: () => {
|
|
4721
|
+
queryClient.invalidateQueries({ queryKey: companyKeys.all });
|
|
4722
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.detail(organizationId, listId) });
|
|
4723
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.progress(organizationId, listId) });
|
|
4724
|
+
queryClient.invalidateQueries({ queryKey: leadGenListMemberKeys.list(organizationId, listId) });
|
|
4725
|
+
showSuccessNotification("Companies removed from list");
|
|
4726
|
+
},
|
|
4727
|
+
onError: (error) => {
|
|
4728
|
+
showApiErrorNotification(error);
|
|
4729
|
+
}
|
|
4730
|
+
});
|
|
4731
|
+
}
|
|
4732
|
+
function useAddContactsToList(listId) {
|
|
4733
|
+
const { apiRequest, organizationId } = useElevasisServices();
|
|
4734
|
+
const queryClient = useQueryClient();
|
|
4735
|
+
return useMutation({
|
|
4736
|
+
mutationFn: (body) => apiRequest(`/acquisition/lists/${listId}/contacts`, {
|
|
4737
|
+
method: "POST",
|
|
4738
|
+
body: JSON.stringify(body)
|
|
4739
|
+
}),
|
|
4740
|
+
onSuccess: () => {
|
|
4741
|
+
queryClient.invalidateQueries({ queryKey: contactKeys.all });
|
|
4742
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.detail(organizationId, listId) });
|
|
4743
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.progress(organizationId, listId) });
|
|
4744
|
+
queryClient.invalidateQueries({ queryKey: leadGenListMemberKeys.list(organizationId, listId) });
|
|
4745
|
+
showSuccessNotification("Contacts added to list");
|
|
4746
|
+
},
|
|
4747
|
+
onError: (error) => {
|
|
4748
|
+
showApiErrorNotification(error);
|
|
4749
|
+
}
|
|
4750
|
+
});
|
|
4751
|
+
}
|
|
4527
4752
|
|
|
4528
4753
|
// src/hooks/acquisition/useBatchTelemetry.ts
|
|
4529
4754
|
function useBatchTelemetry() {
|
|
@@ -5080,4 +5305,4 @@ function useProjectRealtime(projectId) {
|
|
|
5080
5305
|
});
|
|
5081
5306
|
}
|
|
5082
5307
|
|
|
5083
|
-
export { ApiKeyService, COMMAND_VIEW_VISUALIZATION_MODES, CredentialSchemas, CredentialService, DeploymentService, MEMBERSHIP_STATUS_COLORS, OperationsService, OrganizationMembershipService, WebhookEndpointService, acquisitionListKeys, collectResourceFilterFacets, companyKeys, contactKeys, dealKeys, dealNoteKeys, dealTaskKeys, executionsKeys, filterByDomainFilters, getCommandViewGraphPositions, getResourceFilterFacetIds, isSessionCapable, labelResourceFilterFacet, leadGenArtifactKeys, leadGenListCompanyKeys, leadGenListMemberKeys, operationsKeys, projectActivityKeys, requestsKeys, scheduleKeys, sessionsKeys, sortData, transformMembershipToTableRow, useActivateDeployment, useActivities, useActivitiesRealtime, useActivityFilters, useActivityTrend, useArchiveSession, useArchivedLogs, useArtifacts, useAssignRole, useBatchDelete, useBatchTelemetry, useBatchedResourcesHealth, useBulkDeleteExecutions, useBusinessImpact, useCancelExecution, useCancelSchedule, useCheckpointTasks, useCommandQueue, useCommandQueueTotals, useCommandViewData, useCommandViewDomainFilters, useCommandViewLayout, useCommandViewStats, useCommandViewStore, useCompanies, useCompany, useCompanyFacets, useCompleteDealTask, useContact, useContacts, useCostBreakdown, useCostByModel, useCostSummary, useCostTrends, useCreateApiKey, useCreateArtifact, useCreateCompany, useCreateContact, useCreateCredential, useCreateDealNote, useCreateDealTask, useCreateList, useCreateOrgRole, useCreateSchedule, useCreateSession, useCreateWebhookEndpoint, useCredentials, useDashboardMetrics, useDeactivateDeployment, useDeactivateMembership, useDealDetail, useDealNotes, useDealTasks, useDealTasksDue, useDeals, useDealsLookup, useDealsSummary, useDeleteApiKey, useDeleteCompanies, useDeleteContacts, useDeleteCredential, useDeleteDeal, useDeleteDeployment, useDeleteExecution, useDeleteList, useDeleteOrgRole, useDeleteRequest, useDeleteSchedule, useDeleteSession, useDeleteTask, useDeleteWebhookEndpoint, useDeriveActions, useEffectivePermissions, useErrorAnalysis, useErrorDetail, useErrorDetails, useErrorDistribution, useErrorNotification, useExecuteAction, useExecuteAsync, useExecuteResource, useExecution, useExecutionHealth, useExecutionLogSSE, useExecutionLogs, useExecutionLogsFilters, useExecutionPanelState, useExecutions, useGetExecutionHistory, useGetSchedule, useGraphStats, useHasPermission, useList, useListApiKeys, useListDeployments, useListExecutions, useListMember, useListMembers, useListProgress, useListSchedules, useListWebhookEndpoints, useLists, useListsTelemetry, useMarkAllAsRead, useMarkAsRead, useNotificationCount, useNotifications, useOrgRoles, useOrganizationMembers, useOrganizationPermissions, usePaginationState, usePatchTask, usePauseSchedule, usePermissionCatalog, useProjectActivities, useProjectRealtime, useReactivateMembership, useRecentExecutionsByResource, useRequest, useRequestsList, useResolveAllErrors, useResolveError, useResolveErrorsByExecution, useResourceDefinition, useResourceErrors, useResourceExecutions, useResourceSearch, useResources, useResourcesDomainFilters, useResourcesHealth, useResumeSchedule, useRetryExecution, useRevokeRole, useSSEConnection, useScheduledTasks, useSession, useSessionExecution, useSessionExecutions, useSessionMessages, useSessionWebSocket, useSessions, useSortedData, useStatusFilter, useSubmitAction, useSuccessNotification, useTableSelection, useTableSort, useTestNotification, useTimeRangeDates, useTopFailingResources, useTransitionItem, useTransitionListCompany, useTransitionListMember, useTransitionState, useUnresolveError, useUnresolvedErrors, useUpdateAnchor, useUpdateApiKey, useUpdateCompany, useUpdateContact, useUpdateCredential, useUpdateList, useUpdateListConfig, useUpdateListStatus, useUpdateMemberConfig, useUpdateOrgRole, useUpdateRequestStatus, useUpdateSchedule, useUpdateWebhookEndpoint, useUserMemberships, useVisibleResources, useWarningNotification };
|
|
5308
|
+
export { ApiKeyService, COMMAND_VIEW_VISUALIZATION_MODES, CredentialSchemas, CredentialService, DeploymentService, MEMBERSHIP_STATUS_COLORS, OperationsService, OrganizationMembershipService, WebhookEndpointService, acquisitionListKeys, collectResourceFilterFacets, companyKeys, contactKeys, dealKeys, dealNoteKeys, dealTaskKeys, executionsKeys, filterByDomainFilters, getCommandViewGraphPositions, getResourceFilterFacetIds, isSessionCapable, labelResourceFilterFacet, leadGenArtifactKeys, leadGenListCompanyKeys, leadGenListMemberKeys, operationsKeys, projectActivityKeys, requestsKeys, scheduleKeys, sessionsKeys, sortData, transformMembershipToTableRow, useActivateDeployment, useActivities, useActivitiesRealtime, useActivityFilters, useActivityTrend, useAddCompaniesToList, useAddContactsToList, useArchiveSession, useArchivedLogs, useArtifacts, useAssignRole, useBatchDelete, useBatchTelemetry, useBatchedResourcesHealth, useBulkDeleteExecutions, useBusinessImpact, useCancelExecution, useCancelSchedule, useCheckpointTasks, useCommandQueue, useCommandQueueTotals, useCommandViewData, useCommandViewDomainFilters, useCommandViewLayout, useCommandViewStats, useCommandViewStore, useCompanies, useCompany, useCompanyFacets, useCompleteDealTask, useContact, useContacts, useCostBreakdown, useCostByModel, useCostSummary, useCostTrends, useCreateApiKey, useCreateArtifact, useCreateCompany, useCreateContact, useCreateCredential, useCreateDealNote, useCreateDealTask, useCreateList, useCreateOrgRole, useCreateSchedule, useCreateSession, useCreateWebhookEndpoint, useCredentials, useDashboardMetrics, useDeactivateDeployment, useDeactivateMembership, useDealDetail, useDealNotes, useDealTasks, useDealTasksDue, useDeals, useDealsLookup, useDealsSummary, useDeleteApiKey, useDeleteCompanies, useDeleteContacts, useDeleteCredential, useDeleteDeal, useDeleteDeployment, useDeleteExecution, useDeleteList, useDeleteOrgRole, useDeleteRequest, useDeleteSchedule, useDeleteSession, useDeleteTask, useDeleteWebhookEndpoint, useDeriveActions, useEffectivePermissions, useErrorAnalysis, useErrorDetail, useErrorDetails, useErrorDistribution, useErrorNotification, useExecuteAction, useExecuteAsync, useExecuteResource, useExecution, useExecutionHealth, useExecutionLogSSE, useExecutionLogs, useExecutionLogsFilters, useExecutionPanelState, useExecutionSSE, useExecutions, useGetExecutionHistory, useGetSchedule, useGraphStats, useHasPermission, useList, useListApiKeys, useListDeployments, useListExecutions, useListMember, useListMembers, useListProgress, useListSchedules, useListWebhookEndpoints, useLists, useListsTelemetry, useMarkAllAsRead, useMarkAsRead, useNotificationCount, useNotifications, useOrgRoles, useOrganizationMembers, useOrganizationPermissions, usePaginationState, usePatchTask, usePauseSchedule, usePermissionCatalog, useProjectActivities, useProjectRealtime, useReactivateMembership, useRecentExecutionsByResource, useRemoveCompaniesFromList, useRequest, useRequestsList, useResolveAllErrors, useResolveError, useResolveErrorsByExecution, useResourceDefinition, useResourceErrors, useResourceExecutions, useResourceSearch, useResources, useResourcesDomainFilters, useResourcesHealth, useResumeSchedule, useRetryExecution, useRevokeRole, useSSEConnection, useScheduledTasks, useSession, useSessionExecution, useSessionExecutions, useSessionMessages, useSessionWebSocket, useSessions, useSortedData, useStatusFilter, useSubmitAction, useSuccessNotification, useTableSelection, useTableSort, useTestNotification, useTimeRangeDates, useTopFailingResources, useTransitionItem, useTransitionListCompany, useTransitionListMember, useTransitionState, useUnresolveError, useUnresolvedErrors, useUpdateAnchor, useUpdateApiKey, useUpdateCompany, useUpdateContact, useUpdateCredential, useUpdateList, useUpdateListConfig, useUpdateListStatus, useUpdateMemberConfig, useUpdateOrgRole, useUpdateRequestStatus, useUpdateSchedule, useUpdateWebhookEndpoint, useUserMemberships, useVisibleResources, useWarningNotification, useWorkflowExecution };
|