lemma-sdk 0.2.5 → 0.2.6
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.
|
@@ -29,4 +29,4 @@ export interface UseFunctionSessionResult {
|
|
|
29
29
|
pageToken?: string;
|
|
30
30
|
}) => Promise<FunctionRun[]>;
|
|
31
31
|
}
|
|
32
|
-
export declare function useFunctionSession({ client, podId, functionName, runId:
|
|
32
|
+
export declare function useFunctionSession({ client, podId, functionName, runId: externalRunId, autoPoll, pollIntervalMs, onRun, onError, }: UseFunctionSessionOptions): UseFunctionSessionResult;
|
|
@@ -19,8 +19,8 @@ function normalizeError(error, fallback) {
|
|
|
19
19
|
return error;
|
|
20
20
|
return new Error(fallback);
|
|
21
21
|
}
|
|
22
|
-
export function useFunctionSession({ client, podId, functionName, runId:
|
|
23
|
-
const [runId, setRunIdState] = useState(
|
|
22
|
+
export function useFunctionSession({ client, podId, functionName, runId: externalRunId = null, autoPoll = true, pollIntervalMs = 2000, onRun, onError, }) {
|
|
23
|
+
const [runId, setRunIdState] = useState(externalRunId);
|
|
24
24
|
const [run, setRun] = useState(null);
|
|
25
25
|
const [status, setStatus] = useState(undefined);
|
|
26
26
|
const [isPolling, setIsPolling] = useState(false);
|
|
@@ -32,6 +32,13 @@ export function useFunctionSession({ client, podId, functionName, runId: initial
|
|
|
32
32
|
setStatus(undefined);
|
|
33
33
|
}
|
|
34
34
|
}, []);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
setRunIdState((current) => current === externalRunId ? current : externalRunId);
|
|
37
|
+
if (!externalRunId) {
|
|
38
|
+
setRun(null);
|
|
39
|
+
setStatus(undefined);
|
|
40
|
+
}
|
|
41
|
+
}, [externalRunId]);
|
|
35
42
|
const refresh = useCallback(async (explicitRunId) => {
|
|
36
43
|
const id = explicitRunId ?? runId;
|
|
37
44
|
if (!id)
|