lemma-sdk 0.2.38 → 0.2.40
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/README.md +10 -3
- package/dist/browser/lemma-client.js +259 -92
- package/dist/client.d.ts +2 -0
- package/dist/client.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/namespaces/pod-members.d.ts +5 -3
- package/dist/namespaces/pod-members.js +12 -6
- package/dist/namespaces/schedules.d.ts +22 -0
- package/dist/namespaces/schedules.js +24 -0
- package/dist/namespaces/workflows.d.ts +4 -5
- package/dist/namespaces/workflows.js +1 -4
- package/dist/openapi_client/index.d.ts +12 -12
- package/dist/openapi_client/index.js +5 -3
- package/dist/openapi_client/models/CreateScheduleRequest.d.ts +14 -0
- package/dist/openapi_client/models/FlowResponse.d.ts +2 -2
- package/dist/openapi_client/models/FlowRunEntity.d.ts +5 -4
- package/dist/openapi_client/models/FormNodeConfig.d.ts +8 -0
- package/dist/openapi_client/models/PodConfigResponse.d.ts +0 -2
- package/dist/openapi_client/models/PodMemberDetailResponse.d.ts +2 -0
- package/dist/openapi_client/models/PodMemberResponse.d.ts +2 -0
- package/dist/openapi_client/models/ScheduleListResponse.d.ts +9 -0
- package/dist/openapi_client/models/{TriggerResponse.d.ts → ScheduleResponse.d.ts} +8 -4
- package/dist/openapi_client/models/{TriggerType.d.ts → ScheduleType.d.ts} +2 -2
- package/dist/openapi_client/models/ScheduleType.js +13 -0
- package/dist/openapi_client/models/ScheduledFlowStartInput.d.ts +1 -1
- package/dist/openapi_client/models/ScheduledFlowStartOutput.d.ts +1 -1
- package/dist/openapi_client/models/SendMessageRequest.d.ts +0 -2
- package/dist/openapi_client/models/{UpdateTriggerRequest.d.ts → UpdateScheduleRequest.d.ts} +4 -2
- package/dist/openapi_client/models/WorkflowCreateRequest.d.ts +3 -3
- package/dist/openapi_client/models/WorkflowMode.d.ts +7 -0
- package/dist/openapi_client/models/WorkflowMode.js +12 -0
- package/dist/openapi_client/models/WorkflowRunWaitAssignment.d.ts +6 -0
- package/dist/openapi_client/models/WorkflowRunWaitAssignmentListResponse.d.ts +6 -0
- package/dist/openapi_client/models/WorkflowRunWaitEntity.d.ts +20 -0
- package/dist/openapi_client/models/WorkflowRunWaitStatus.d.ts +6 -0
- package/dist/openapi_client/models/WorkflowRunWaitStatus.js +11 -0
- package/dist/openapi_client/models/WorkflowRunWaitType.d.ts +7 -0
- package/dist/openapi_client/models/WorkflowRunWaitType.js +12 -0
- package/dist/openapi_client/models/WorkflowUpdateRequest.d.ts +3 -3
- package/dist/openapi_client/services/PodMembersService.d.ts +25 -7
- package/dist/openapi_client/services/PodMembersService.js +57 -13
- package/dist/openapi_client/services/SchedulesService.d.ts +59 -0
- package/dist/openapi_client/services/SchedulesService.js +125 -0
- package/dist/openapi_client/services/WebhooksService.d.ts +4 -4
- package/dist/openapi_client/services/WebhooksService.js +6 -6
- package/dist/openapi_client/services/WorkflowsService.d.ts +12 -33
- package/dist/openapi_client/services/WorkflowsService.js +26 -69
- package/dist/react/AuthGuard.js +1 -1
- package/dist/react/index.d.ts +10 -0
- package/dist/react/index.js +5 -0
- package/dist/react/useCreateSchedule.d.ts +17 -0
- package/dist/react/useCreateSchedule.js +45 -0
- package/dist/react/useDeleteSchedule.d.ts +19 -0
- package/dist/react/useDeleteSchedule.js +49 -0
- package/dist/react/usePodAccess.js +1 -1
- package/dist/react/useSchedules.d.ts +30 -0
- package/dist/react/useSchedules.js +123 -0
- package/dist/react/useUpdateSchedule.d.ts +20 -0
- package/dist/react/useUpdateSchedule.js +49 -0
- package/dist/react/useWorkflowRun.js +1 -1
- package/dist/react/useWorkflowRunWaitAssignments.d.ts +26 -0
- package/dist/react/useWorkflowRunWaitAssignments.js +102 -0
- package/dist/react/useWorkflowStart.js +1 -1
- package/dist/types.d.ts +3 -1
- package/package.json +1 -1
- package/dist/openapi_client/models/CreateTriggerRequest.d.ts +0 -13
- package/dist/openapi_client/models/FlowInstallResponse.d.ts +0 -15
- package/dist/openapi_client/models/PodFlowConfigItem.d.ts +0 -7
- package/dist/openapi_client/models/TriggerListResponse.d.ts +0 -9
- package/dist/openapi_client/models/TriggerType.js +0 -13
- package/dist/openapi_client/models/WorkflowInstallListResponse.d.ts +0 -4
- package/dist/openapi_client/models/WorkflowInstallMode.d.ts +0 -7
- package/dist/openapi_client/models/WorkflowInstallMode.js +0 -12
- package/dist/openapi_client/models/WorkflowInstallRequest.d.ts +0 -11
- package/dist/openapi_client/models/WorkflowInstallRequest.js +0 -1
- package/dist/openapi_client/models/WorkflowTimeInstallConfig.d.ts +0 -19
- package/dist/openapi_client/models/WorkflowTimeInstallConfig.js +0 -1
- package/dist/openapi_client/services/TriggersService.d.ts +0 -53
- package/dist/openapi_client/services/TriggersService.js +0 -109
- /package/dist/openapi_client/models/{CreateTriggerRequest.js → CreateScheduleRequest.js} +0 -0
- /package/dist/openapi_client/models/{FlowInstallResponse.js → ScheduleListResponse.js} +0 -0
- /package/dist/openapi_client/models/{PodFlowConfigItem.js → ScheduleResponse.js} +0 -0
- /package/dist/openapi_client/models/{TriggerListResponse.js → UpdateScheduleRequest.js} +0 -0
- /package/dist/openapi_client/models/{TriggerResponse.js → WorkflowRunWaitAssignment.js} +0 -0
- /package/dist/openapi_client/models/{UpdateTriggerRequest.js → WorkflowRunWaitAssignmentListResponse.js} +0 -0
- /package/dist/openapi_client/models/{WorkflowInstallListResponse.js → WorkflowRunWaitEntity.js} +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { normalizeError, resolvePodClient } from "./utils.js";
|
|
3
|
+
export function useDeleteSchedule({ client, podId, scheduleId = null, enabled = true, onSuccess, onError, }) {
|
|
4
|
+
const [deletedScheduleId, setDeletedScheduleId] = useState(null);
|
|
5
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
6
|
+
const [error, setError] = useState(null);
|
|
7
|
+
const onSuccessRef = useRef(onSuccess);
|
|
8
|
+
const onErrorRef = useRef(onError);
|
|
9
|
+
useEffect(() => { onSuccessRef.current = onSuccess; }, [onSuccess]);
|
|
10
|
+
useEffect(() => { onErrorRef.current = onError; }, [onError]);
|
|
11
|
+
const trimmedScheduleId = typeof scheduleId === "string" ? scheduleId.trim() : "";
|
|
12
|
+
const remove = useCallback(async (overrides = {}) => {
|
|
13
|
+
const nextScheduleId = typeof overrides.scheduleId === "string"
|
|
14
|
+
? overrides.scheduleId.trim()
|
|
15
|
+
: trimmedScheduleId;
|
|
16
|
+
if (!enabled || nextScheduleId.length === 0)
|
|
17
|
+
return false;
|
|
18
|
+
setIsSubmitting(true);
|
|
19
|
+
setError(null);
|
|
20
|
+
try {
|
|
21
|
+
const scopedClient = resolvePodClient(client, podId);
|
|
22
|
+
await scopedClient.schedules.delete(nextScheduleId);
|
|
23
|
+
setDeletedScheduleId(nextScheduleId);
|
|
24
|
+
onSuccessRef.current?.(nextScheduleId);
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
catch (mutationError) {
|
|
28
|
+
const normalized = normalizeError(mutationError, "Failed to delete schedule.");
|
|
29
|
+
setError(normalized);
|
|
30
|
+
onErrorRef.current?.(mutationError);
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
setIsSubmitting(false);
|
|
35
|
+
}
|
|
36
|
+
}, [client, enabled, podId, trimmedScheduleId]);
|
|
37
|
+
const reset = useCallback(() => {
|
|
38
|
+
setDeletedScheduleId(null);
|
|
39
|
+
setError(null);
|
|
40
|
+
setIsSubmitting(false);
|
|
41
|
+
}, []);
|
|
42
|
+
return useMemo(() => ({
|
|
43
|
+
deletedScheduleId,
|
|
44
|
+
isSubmitting,
|
|
45
|
+
error,
|
|
46
|
+
remove,
|
|
47
|
+
reset,
|
|
48
|
+
}), [deletedScheduleId, error, isSubmitting, remove, reset]);
|
|
49
|
+
}
|
|
@@ -30,7 +30,7 @@ export function usePodAccess({ client, podId, enabled = true, autoLoad = true, }
|
|
|
30
30
|
const currentUser = await client.users.current();
|
|
31
31
|
setUser(currentUser);
|
|
32
32
|
try {
|
|
33
|
-
const nextMember = await client.podMembers.
|
|
33
|
+
const nextMember = await client.podMembers.lookupByUserId(resolvedPodId, currentUser.id);
|
|
34
34
|
setMember(nextMember);
|
|
35
35
|
setJoinRequest(null);
|
|
36
36
|
setStatus("member");
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { LemmaClient } from "../client.js";
|
|
2
|
+
import type { Schedule, ScheduleType } from "../types.js";
|
|
3
|
+
export interface UseSchedulesOptions {
|
|
4
|
+
client: LemmaClient;
|
|
5
|
+
podId?: string;
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
autoLoad?: boolean;
|
|
8
|
+
scheduleType?: ScheduleType | null;
|
|
9
|
+
isActive?: boolean | null;
|
|
10
|
+
agentName?: string | null;
|
|
11
|
+
workflowName?: string | null;
|
|
12
|
+
limit?: number;
|
|
13
|
+
pageToken?: string | null;
|
|
14
|
+
}
|
|
15
|
+
export interface UseSchedulesResult {
|
|
16
|
+
schedules: Schedule[];
|
|
17
|
+
total: number;
|
|
18
|
+
nextPageToken: string | null;
|
|
19
|
+
isLoading: boolean;
|
|
20
|
+
isLoadingMore: boolean;
|
|
21
|
+
error: Error | null;
|
|
22
|
+
refresh: (overrides?: {
|
|
23
|
+
limit?: number;
|
|
24
|
+
pageToken?: string | null;
|
|
25
|
+
}) => Promise<Schedule[]>;
|
|
26
|
+
loadMore: (overrides?: {
|
|
27
|
+
limit?: number;
|
|
28
|
+
}) => Promise<Schedule[]>;
|
|
29
|
+
}
|
|
30
|
+
export declare function useSchedules({ client, podId, enabled, autoLoad, scheduleType, isActive, agentName, workflowName, limit, pageToken, }: UseSchedulesOptions): UseSchedulesResult;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { normalizeError, resolvePodClient } from "./utils.js";
|
|
3
|
+
export function useSchedules({ client, podId, enabled = true, autoLoad = true, scheduleType = null, isActive = null, agentName = null, workflowName = null, limit = 100, pageToken = null, }) {
|
|
4
|
+
const [schedules, setSchedules] = useState([]);
|
|
5
|
+
const [total, setTotal] = useState(0);
|
|
6
|
+
const [nextPageToken, setNextPageToken] = useState(null);
|
|
7
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
8
|
+
const [isLoadingMore, setIsLoadingMore] = useState(false);
|
|
9
|
+
const [error, setError] = useState(null);
|
|
10
|
+
const refresh = useCallback(async (overrides = {}, signal) => {
|
|
11
|
+
if (!enabled) {
|
|
12
|
+
setSchedules([]);
|
|
13
|
+
setTotal(0);
|
|
14
|
+
setNextPageToken(null);
|
|
15
|
+
setError(null);
|
|
16
|
+
setIsLoading(false);
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
setIsLoading(true);
|
|
20
|
+
setError(null);
|
|
21
|
+
try {
|
|
22
|
+
const scopedClient = resolvePodClient(client, podId);
|
|
23
|
+
const response = await scopedClient.schedules.list({
|
|
24
|
+
scheduleType,
|
|
25
|
+
isActive,
|
|
26
|
+
agentName,
|
|
27
|
+
workflowName,
|
|
28
|
+
limit: overrides.limit ?? limit,
|
|
29
|
+
pageToken: overrides.pageToken ?? pageToken,
|
|
30
|
+
});
|
|
31
|
+
if (signal?.aborted)
|
|
32
|
+
return [];
|
|
33
|
+
const nextSchedules = response.items ?? [];
|
|
34
|
+
setSchedules(nextSchedules);
|
|
35
|
+
setTotal(response.total ?? nextSchedules.length);
|
|
36
|
+
setNextPageToken(response.next_page_token ?? null);
|
|
37
|
+
return nextSchedules;
|
|
38
|
+
}
|
|
39
|
+
catch (refreshError) {
|
|
40
|
+
if (signal?.aborted)
|
|
41
|
+
return [];
|
|
42
|
+
const normalized = normalizeError(refreshError, "Failed to load schedules.");
|
|
43
|
+
setError(normalized);
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
if (!signal?.aborted)
|
|
48
|
+
setIsLoading(false);
|
|
49
|
+
}
|
|
50
|
+
}, [agentName, client, enabled, isActive, limit, pageToken, podId, scheduleType, workflowName]);
|
|
51
|
+
const loadMore = useCallback(async (overrides = {}) => {
|
|
52
|
+
if (!enabled || !nextPageToken || isLoading || isLoadingMore) {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
setIsLoadingMore(true);
|
|
56
|
+
setError(null);
|
|
57
|
+
try {
|
|
58
|
+
const scopedClient = resolvePodClient(client, podId);
|
|
59
|
+
const response = await scopedClient.schedules.list({
|
|
60
|
+
scheduleType,
|
|
61
|
+
isActive,
|
|
62
|
+
agentName,
|
|
63
|
+
workflowName,
|
|
64
|
+
limit: overrides.limit ?? limit,
|
|
65
|
+
pageToken: nextPageToken,
|
|
66
|
+
});
|
|
67
|
+
const moreSchedules = response.items ?? [];
|
|
68
|
+
setSchedules((previous) => [...previous, ...moreSchedules]);
|
|
69
|
+
setTotal(response.total ?? schedules.length + moreSchedules.length);
|
|
70
|
+
setNextPageToken(response.next_page_token ?? null);
|
|
71
|
+
return moreSchedules;
|
|
72
|
+
}
|
|
73
|
+
catch (loadError) {
|
|
74
|
+
const normalized = normalizeError(loadError, "Failed to load more schedules.");
|
|
75
|
+
setError(normalized);
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
setIsLoadingMore(false);
|
|
80
|
+
}
|
|
81
|
+
}, [
|
|
82
|
+
agentName,
|
|
83
|
+
client,
|
|
84
|
+
enabled,
|
|
85
|
+
isActive,
|
|
86
|
+
isLoading,
|
|
87
|
+
isLoadingMore,
|
|
88
|
+
limit,
|
|
89
|
+
nextPageToken,
|
|
90
|
+
podId,
|
|
91
|
+
scheduleType,
|
|
92
|
+
schedules.length,
|
|
93
|
+
workflowName,
|
|
94
|
+
]);
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (!enabled) {
|
|
97
|
+
setSchedules([]);
|
|
98
|
+
setTotal(0);
|
|
99
|
+
setNextPageToken(null);
|
|
100
|
+
setError(null);
|
|
101
|
+
setIsLoading(false);
|
|
102
|
+
setIsLoadingMore(false);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (!autoLoad)
|
|
106
|
+
return;
|
|
107
|
+
const controller = new AbortController();
|
|
108
|
+
void refresh({}, controller.signal);
|
|
109
|
+
return () => {
|
|
110
|
+
controller.abort();
|
|
111
|
+
};
|
|
112
|
+
}, [autoLoad, enabled, refresh]);
|
|
113
|
+
return useMemo(() => ({
|
|
114
|
+
schedules,
|
|
115
|
+
total,
|
|
116
|
+
nextPageToken,
|
|
117
|
+
isLoading,
|
|
118
|
+
isLoadingMore,
|
|
119
|
+
error,
|
|
120
|
+
refresh,
|
|
121
|
+
loadMore,
|
|
122
|
+
}), [error, isLoading, isLoadingMore, loadMore, nextPageToken, refresh, schedules, total]);
|
|
123
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { LemmaClient } from "../client.js";
|
|
2
|
+
import type { Schedule, UpdateScheduleRequest } from "../types.js";
|
|
3
|
+
export interface UseUpdateScheduleOptions {
|
|
4
|
+
client: LemmaClient;
|
|
5
|
+
podId?: string;
|
|
6
|
+
scheduleId?: string | null;
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
onSuccess?: (schedule: Schedule) => void;
|
|
9
|
+
onError?: (error: unknown) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface UseUpdateScheduleResult {
|
|
12
|
+
schedule: Schedule | null;
|
|
13
|
+
isSubmitting: boolean;
|
|
14
|
+
error: Error | null;
|
|
15
|
+
update: (payload: UpdateScheduleRequest, overrides?: {
|
|
16
|
+
scheduleId?: string | null;
|
|
17
|
+
}) => Promise<Schedule | null>;
|
|
18
|
+
reset: () => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function useUpdateSchedule({ client, podId, scheduleId, enabled, onSuccess, onError, }: UseUpdateScheduleOptions): UseUpdateScheduleResult;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { normalizeError, resolvePodClient } from "./utils.js";
|
|
3
|
+
export function useUpdateSchedule({ client, podId, scheduleId = null, enabled = true, onSuccess, onError, }) {
|
|
4
|
+
const [schedule, setSchedule] = useState(null);
|
|
5
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
6
|
+
const [error, setError] = useState(null);
|
|
7
|
+
const onSuccessRef = useRef(onSuccess);
|
|
8
|
+
const onErrorRef = useRef(onError);
|
|
9
|
+
useEffect(() => { onSuccessRef.current = onSuccess; }, [onSuccess]);
|
|
10
|
+
useEffect(() => { onErrorRef.current = onError; }, [onError]);
|
|
11
|
+
const trimmedScheduleId = typeof scheduleId === "string" ? scheduleId.trim() : "";
|
|
12
|
+
const update = useCallback(async (payload, overrides = {}) => {
|
|
13
|
+
const nextScheduleId = typeof overrides.scheduleId === "string"
|
|
14
|
+
? overrides.scheduleId.trim()
|
|
15
|
+
: trimmedScheduleId;
|
|
16
|
+
if (!enabled || nextScheduleId.length === 0)
|
|
17
|
+
return null;
|
|
18
|
+
setIsSubmitting(true);
|
|
19
|
+
setError(null);
|
|
20
|
+
try {
|
|
21
|
+
const scopedClient = resolvePodClient(client, podId);
|
|
22
|
+
const nextSchedule = await scopedClient.schedules.update(nextScheduleId, payload);
|
|
23
|
+
setSchedule(nextSchedule);
|
|
24
|
+
onSuccessRef.current?.(nextSchedule);
|
|
25
|
+
return nextSchedule;
|
|
26
|
+
}
|
|
27
|
+
catch (mutationError) {
|
|
28
|
+
const normalized = normalizeError(mutationError, "Failed to update schedule.");
|
|
29
|
+
setError(normalized);
|
|
30
|
+
onErrorRef.current?.(mutationError);
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
setIsSubmitting(false);
|
|
35
|
+
}
|
|
36
|
+
}, [client, enabled, podId, trimmedScheduleId]);
|
|
37
|
+
const reset = useCallback(() => {
|
|
38
|
+
setSchedule(null);
|
|
39
|
+
setError(null);
|
|
40
|
+
setIsSubmitting(false);
|
|
41
|
+
}, []);
|
|
42
|
+
return useMemo(() => ({
|
|
43
|
+
schedule,
|
|
44
|
+
isSubmitting,
|
|
45
|
+
error,
|
|
46
|
+
update,
|
|
47
|
+
reset,
|
|
48
|
+
}), [error, isSubmitting, reset, schedule, update]);
|
|
49
|
+
}
|
|
@@ -33,7 +33,7 @@ export function useWorkflowRun({ workflowName, ...options }) {
|
|
|
33
33
|
const isWaitingForInput = normalizedStatus === "WAITING"
|
|
34
34
|
|| !!session.run?.waiting_agent_conversation_id
|
|
35
35
|
|| !!session.run?.waiting_function_run_id
|
|
36
|
-
|| !!session.run?.
|
|
36
|
+
|| !!session.run?.waiting_timer_id;
|
|
37
37
|
const output = session.run?.execution_context ?? null;
|
|
38
38
|
const finalOutput = isFinished ? output : null;
|
|
39
39
|
return {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { LemmaClient } from "../client.js";
|
|
2
|
+
import type { WorkflowRunWait } from "../types.js";
|
|
3
|
+
export interface UseWorkflowRunWaitAssignmentsOptions {
|
|
4
|
+
client: LemmaClient;
|
|
5
|
+
podId?: string;
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
autoLoad?: boolean;
|
|
8
|
+
limit?: number;
|
|
9
|
+
pageToken?: string | null;
|
|
10
|
+
}
|
|
11
|
+
export interface UseWorkflowRunWaitAssignmentsResult {
|
|
12
|
+
assignments: WorkflowRunWait[];
|
|
13
|
+
total: number;
|
|
14
|
+
nextPageToken: string | null;
|
|
15
|
+
isLoading: boolean;
|
|
16
|
+
isLoadingMore: boolean;
|
|
17
|
+
error: Error | null;
|
|
18
|
+
refresh: (overrides?: {
|
|
19
|
+
limit?: number;
|
|
20
|
+
pageToken?: string | null;
|
|
21
|
+
}) => Promise<WorkflowRunWait[]>;
|
|
22
|
+
loadMore: (overrides?: {
|
|
23
|
+
limit?: number;
|
|
24
|
+
}) => Promise<WorkflowRunWait[]>;
|
|
25
|
+
}
|
|
26
|
+
export declare function useWorkflowRunWaitAssignments({ client, podId, enabled, autoLoad, limit, pageToken, }: UseWorkflowRunWaitAssignmentsOptions): UseWorkflowRunWaitAssignmentsResult;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { normalizeError, resolvePodClient } from "./utils.js";
|
|
3
|
+
export function useWorkflowRunWaitAssignments({ client, podId, enabled = true, autoLoad = true, limit = 100, pageToken = null, }) {
|
|
4
|
+
const [assignments, setAssignments] = useState([]);
|
|
5
|
+
const [total, setTotal] = useState(0);
|
|
6
|
+
const [nextPageToken, setNextPageToken] = useState(null);
|
|
7
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
8
|
+
const [isLoadingMore, setIsLoadingMore] = useState(false);
|
|
9
|
+
const [error, setError] = useState(null);
|
|
10
|
+
const refresh = useCallback(async (overrides = {}, signal) => {
|
|
11
|
+
if (!enabled) {
|
|
12
|
+
setAssignments([]);
|
|
13
|
+
setTotal(0);
|
|
14
|
+
setNextPageToken(null);
|
|
15
|
+
setError(null);
|
|
16
|
+
setIsLoading(false);
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
setIsLoading(true);
|
|
20
|
+
setError(null);
|
|
21
|
+
try {
|
|
22
|
+
const scopedClient = resolvePodClient(client, podId);
|
|
23
|
+
const response = await scopedClient.workflows.runs.waitingAssignedToMe({
|
|
24
|
+
limit: overrides.limit ?? limit,
|
|
25
|
+
pageToken: overrides.pageToken ?? pageToken ?? undefined,
|
|
26
|
+
});
|
|
27
|
+
if (signal?.aborted)
|
|
28
|
+
return [];
|
|
29
|
+
const nextAssignments = response.items ?? [];
|
|
30
|
+
setAssignments(nextAssignments);
|
|
31
|
+
setTotal(response.total ?? nextAssignments.length);
|
|
32
|
+
setNextPageToken(response.next_page_token ?? null);
|
|
33
|
+
return nextAssignments;
|
|
34
|
+
}
|
|
35
|
+
catch (refreshError) {
|
|
36
|
+
if (signal?.aborted)
|
|
37
|
+
return [];
|
|
38
|
+
const normalized = normalizeError(refreshError, "Failed to load waiting workflow runs.");
|
|
39
|
+
setError(normalized);
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
if (!signal?.aborted)
|
|
44
|
+
setIsLoading(false);
|
|
45
|
+
}
|
|
46
|
+
}, [client, enabled, limit, pageToken, podId]);
|
|
47
|
+
const loadMore = useCallback(async (overrides = {}) => {
|
|
48
|
+
if (!enabled || !nextPageToken || isLoading || isLoadingMore) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
setIsLoadingMore(true);
|
|
52
|
+
setError(null);
|
|
53
|
+
try {
|
|
54
|
+
const scopedClient = resolvePodClient(client, podId);
|
|
55
|
+
const response = await scopedClient.workflows.runs.waitingAssignedToMe({
|
|
56
|
+
limit: overrides.limit ?? limit,
|
|
57
|
+
pageToken: nextPageToken,
|
|
58
|
+
});
|
|
59
|
+
const moreAssignments = response.items ?? [];
|
|
60
|
+
setAssignments((previous) => [...previous, ...moreAssignments]);
|
|
61
|
+
setTotal(response.total ?? assignments.length + moreAssignments.length);
|
|
62
|
+
setNextPageToken(response.next_page_token ?? null);
|
|
63
|
+
return moreAssignments;
|
|
64
|
+
}
|
|
65
|
+
catch (loadError) {
|
|
66
|
+
const normalized = normalizeError(loadError, "Failed to load more waiting workflow runs.");
|
|
67
|
+
setError(normalized);
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
setIsLoadingMore(false);
|
|
72
|
+
}
|
|
73
|
+
}, [assignments.length, client, enabled, isLoading, isLoadingMore, limit, nextPageToken, podId]);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (!enabled) {
|
|
76
|
+
setAssignments([]);
|
|
77
|
+
setTotal(0);
|
|
78
|
+
setNextPageToken(null);
|
|
79
|
+
setError(null);
|
|
80
|
+
setIsLoading(false);
|
|
81
|
+
setIsLoadingMore(false);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (!autoLoad)
|
|
85
|
+
return;
|
|
86
|
+
const controller = new AbortController();
|
|
87
|
+
void refresh({}, controller.signal);
|
|
88
|
+
return () => {
|
|
89
|
+
controller.abort();
|
|
90
|
+
};
|
|
91
|
+
}, [autoLoad, enabled, refresh]);
|
|
92
|
+
return useMemo(() => ({
|
|
93
|
+
assignments,
|
|
94
|
+
total,
|
|
95
|
+
nextPageToken,
|
|
96
|
+
isLoading,
|
|
97
|
+
isLoadingMore,
|
|
98
|
+
error,
|
|
99
|
+
refresh,
|
|
100
|
+
loadMore,
|
|
101
|
+
}), [assignments, error, isLoading, isLoadingMore, loadMore, nextPageToken, refresh, total]);
|
|
102
|
+
}
|
|
@@ -23,7 +23,7 @@ function isWaitingFlowRun(run) {
|
|
|
23
23
|
return normalizedStatus === "WAITING"
|
|
24
24
|
|| !!run.waiting_function_run_id
|
|
25
25
|
|| !!run.waiting_agent_conversation_id
|
|
26
|
-
|| !!run.
|
|
26
|
+
|| !!run.waiting_timer_id;
|
|
27
27
|
}
|
|
28
28
|
export function useWorkflowStart({ client, podId, workflowName, runId = null, enabled = true, autoLoad = true, autoPoll = true, pollIntervalMs = 2000, onRun, onError, }) {
|
|
29
29
|
const [workflow, setWorkflow] = useState(null);
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentModelName, AgentResponse, ColumnSchema, ConversationResponse as GeneratedConversationResponse, CreateAgentRequest, DatastoreQueryResponse, DirectoryTreeNode, DirectoryTreeResponse, FileResponse, FileNamespace, FileSearchResponse, FileSearchResultSchema, FlowRunEntity, FlowResponse, FunctionRunResponse, IconUploadResponse, OrganizationInvitationResponse, OrganizationMemberResponse, OrganizationResponse, PodConfigResponse, PodJoinRequestCreateResponse, PodMemberResponse, PodResponse, TableResponse, UpdateAgentRequest, UserResponse } from "./openapi_client/index.js";
|
|
1
|
+
import type { AgentModelName, AgentResponse, ColumnSchema, ConversationResponse as GeneratedConversationResponse, CreateAgentRequest, DatastoreQueryResponse, DirectoryTreeNode, DirectoryTreeResponse, FileResponse, FileNamespace, FileSearchResponse, FileSearchResultSchema, FlowRunEntity, FlowResponse, FunctionRunResponse, IconUploadResponse, OrganizationInvitationResponse, OrganizationMemberResponse, OrganizationResponse, PodConfigResponse, PodJoinRequestCreateResponse, PodMemberResponse, PodResponse, ScheduleResponse, TableResponse, UpdateAgentRequest, UserResponse, WorkflowRunWaitAssignment } from "./openapi_client/index.js";
|
|
2
2
|
/** Public ergonomic types. */
|
|
3
3
|
export interface AvailableModelInfo {
|
|
4
4
|
id: ConversationModel;
|
|
@@ -67,6 +67,8 @@ export type FlowRun = FlowRunEntity;
|
|
|
67
67
|
export type Workflow = FlowResponse;
|
|
68
68
|
export type WorkflowStart = Workflow["start"];
|
|
69
69
|
export type WorkflowStartType = NonNullable<WorkflowStart>["type"];
|
|
70
|
+
export type Schedule = ScheduleResponse;
|
|
71
|
+
export type WorkflowRunWait = WorkflowRunWaitAssignment;
|
|
70
72
|
export type Table = TableResponse;
|
|
71
73
|
export type TableColumn = ColumnSchema;
|
|
72
74
|
export type DatastoreQueryResult = DatastoreQueryResponse;
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { TriggerType } from './TriggerType.js';
|
|
2
|
-
/**
|
|
3
|
-
* Request to create a trigger.
|
|
4
|
-
*/
|
|
5
|
-
export type CreateTriggerRequest = {
|
|
6
|
-
account_id?: (string | null);
|
|
7
|
-
application_trigger_id?: (string | null);
|
|
8
|
-
config?: Record<string, any>;
|
|
9
|
-
filter_instruction?: (string | null);
|
|
10
|
-
filter_output_schema?: (Record<string, any> | null);
|
|
11
|
-
pod_id?: (string | null);
|
|
12
|
-
trigger_type: TriggerType;
|
|
13
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { DataStoreWorkflowStartOutput } from './DataStoreWorkflowStartOutput.js';
|
|
2
|
-
import type { EventWorkflowStartOutput } from './EventWorkflowStartOutput.js';
|
|
3
|
-
import type { ManualWorkflowStartOutput } from './ManualWorkflowStartOutput.js';
|
|
4
|
-
import type { ScheduledWorkflowStartOutput } from './ScheduledWorkflowStartOutput.js';
|
|
5
|
-
export type FlowInstallResponse = {
|
|
6
|
-
created_at: string;
|
|
7
|
-
flow_id: string;
|
|
8
|
-
flow_start: (ManualWorkflowStartOutput | ScheduledWorkflowStartOutput | EventWorkflowStartOutput | DataStoreWorkflowStartOutput);
|
|
9
|
-
id: string;
|
|
10
|
-
is_active?: boolean;
|
|
11
|
-
pod_id: string;
|
|
12
|
-
trigger_id?: (string | null);
|
|
13
|
-
updated_at: string;
|
|
14
|
-
user_id: string;
|
|
15
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
-
/* istanbul ignore file */
|
|
3
|
-
/* tslint:disable */
|
|
4
|
-
/* eslint-disable */
|
|
5
|
-
/**
|
|
6
|
-
* Type of trigger.
|
|
7
|
-
*/
|
|
8
|
-
export var TriggerType;
|
|
9
|
-
(function (TriggerType) {
|
|
10
|
-
TriggerType["TIME"] = "TIME";
|
|
11
|
-
TriggerType["WEBHOOK"] = "WEBHOOK";
|
|
12
|
-
TriggerType["DATASTORE"] = "DATASTORE";
|
|
13
|
-
})(TriggerType || (TriggerType = {}));
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
-
/* istanbul ignore file */
|
|
3
|
-
/* tslint:disable */
|
|
4
|
-
/* eslint-disable */
|
|
5
|
-
/**
|
|
6
|
-
* Workflow install scope for non-manual starts.
|
|
7
|
-
*/
|
|
8
|
-
export var WorkflowInstallMode;
|
|
9
|
-
(function (WorkflowInstallMode) {
|
|
10
|
-
WorkflowInstallMode["GLOBAL"] = "GLOBAL";
|
|
11
|
-
WorkflowInstallMode["USER"] = "USER";
|
|
12
|
-
})(WorkflowInstallMode || (WorkflowInstallMode = {}));
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { WorkflowTimeInstallConfig } from './WorkflowTimeInstallConfig.js';
|
|
2
|
-
export type WorkflowInstallRequest = {
|
|
3
|
-
/**
|
|
4
|
-
* Optional integration account to bind when installing an event-driven workflow. Scheduled and datastore-event workflows usually do not need this.
|
|
5
|
-
*/
|
|
6
|
-
account_id?: (string | null);
|
|
7
|
-
/**
|
|
8
|
-
* Concrete time trigger settings for scheduled workflows. Provide either a one-time `time` or a recurring `cron_expression`.
|
|
9
|
-
*/
|
|
10
|
-
schedule?: (WorkflowTimeInstallConfig | null);
|
|
11
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ScheduledFlowStartType } from './ScheduledFlowStartType.js';
|
|
2
|
-
export type WorkflowTimeInstallConfig = {
|
|
3
|
-
/**
|
|
4
|
-
* Cron expression for `CRON` schedules.
|
|
5
|
-
*/
|
|
6
|
-
cron_expression?: (string | null);
|
|
7
|
-
/**
|
|
8
|
-
* Concrete time trigger mode to install: `ONCE` or `CRON`.
|
|
9
|
-
*/
|
|
10
|
-
schedule_type: ScheduledFlowStartType;
|
|
11
|
-
/**
|
|
12
|
-
* One-time execution timestamp for `ONCE` schedules.
|
|
13
|
-
*/
|
|
14
|
-
time?: (string | null);
|
|
15
|
-
/**
|
|
16
|
-
* IANA timezone used for cron evaluation or naive one-time values.
|
|
17
|
-
*/
|
|
18
|
-
timezone?: (string | null);
|
|
19
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { CreateTriggerRequest } from '../models/CreateTriggerRequest.js';
|
|
2
|
-
import type { TriggerListResponse } from '../models/TriggerListResponse.js';
|
|
3
|
-
import type { TriggerResponse } from '../models/TriggerResponse.js';
|
|
4
|
-
import type { TriggerType } from '../models/TriggerType.js';
|
|
5
|
-
import type { UpdateTriggerRequest } from '../models/UpdateTriggerRequest.js';
|
|
6
|
-
import type { CancelablePromise } from '../core/CancelablePromise.js';
|
|
7
|
-
export declare class TriggersService {
|
|
8
|
-
/**
|
|
9
|
-
* List Triggers
|
|
10
|
-
* List triggers.
|
|
11
|
-
* @param triggerType
|
|
12
|
-
* @param isActive
|
|
13
|
-
* @param podId
|
|
14
|
-
* @param limit
|
|
15
|
-
* @param pageToken
|
|
16
|
-
* @returns TriggerListResponse Successful Response
|
|
17
|
-
* @throws ApiError
|
|
18
|
-
*/
|
|
19
|
-
static triggerList(triggerType?: (TriggerType | null), isActive?: (boolean | null), podId?: (string | null), limit?: number, pageToken?: (string | null)): CancelablePromise<TriggerListResponse>;
|
|
20
|
-
/**
|
|
21
|
-
* Create Trigger
|
|
22
|
-
* Create a new trigger.
|
|
23
|
-
* @param requestBody
|
|
24
|
-
* @returns TriggerResponse Successful Response
|
|
25
|
-
* @throws ApiError
|
|
26
|
-
*/
|
|
27
|
-
static triggerCreate(requestBody: CreateTriggerRequest): CancelablePromise<TriggerResponse>;
|
|
28
|
-
/**
|
|
29
|
-
* Delete Trigger
|
|
30
|
-
* Delete a trigger.
|
|
31
|
-
* @param triggerId
|
|
32
|
-
* @returns void
|
|
33
|
-
* @throws ApiError
|
|
34
|
-
*/
|
|
35
|
-
static triggerDelete(triggerId: string): CancelablePromise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* Get Trigger
|
|
38
|
-
* Get a trigger by ID.
|
|
39
|
-
* @param triggerId
|
|
40
|
-
* @returns TriggerResponse Successful Response
|
|
41
|
-
* @throws ApiError
|
|
42
|
-
*/
|
|
43
|
-
static triggerGet(triggerId: string): CancelablePromise<TriggerResponse>;
|
|
44
|
-
/**
|
|
45
|
-
* Update Trigger
|
|
46
|
-
* Update a trigger.
|
|
47
|
-
* @param triggerId
|
|
48
|
-
* @param requestBody
|
|
49
|
-
* @returns TriggerResponse Successful Response
|
|
50
|
-
* @throws ApiError
|
|
51
|
-
*/
|
|
52
|
-
static triggerUpdate(triggerId: string, requestBody: UpdateTriggerRequest): CancelablePromise<TriggerResponse>;
|
|
53
|
-
}
|