From 15e67fdd571c96a3d025d711d9bdf8a14236708f Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Wed, 19 Feb 2025 17:27:26 +0100 Subject: [PATCH] feat(sdk-js/react): make configurable typed --- libs/sdk-js/src/react/stream.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libs/sdk-js/src/react/stream.tsx b/libs/sdk-js/src/react/stream.tsx index 9919dfbc5..106cfea5e 100644 --- a/libs/sdk-js/src/react/stream.tsx +++ b/libs/sdk-js/src/react/stream.tsx @@ -401,6 +401,7 @@ interface UseStreamOptions< interface UseStream< StateType extends Record = Record, UpdateType extends Record = Partial, + ConfigurableType extends Record = Record, > { /** * The current values of the thread. @@ -425,7 +426,10 @@ interface UseStream< /** * Create and stream a run to the thread. */ - submit: (values: UpdateType, options?: SubmitOptions) => void; + submit: ( + values: UpdateType, + options?: SubmitOptions, + ) => void; /** * The current branch of the thread. @@ -468,10 +472,14 @@ interface UseStream< ) => MessageMetadata | undefined; } +type ConfigWithConfigurable> = + Config & { configurable?: ConfigurableType }; + interface SubmitOptions< StateType extends Record = Record, + ConfigurableType extends Record = Record, > { - config?: Config; + config?: ConfigWithConfigurable; checkpoint?: Omit | null; command?: Command; interruptBefore?: "*" | string[]; @@ -490,10 +498,11 @@ interface SubmitOptions< export function useStream< StateType extends Record = Record, UpdateType extends Record = Partial, + ConfigurableType extends Record = Record, CustomType = unknown, >( options: UseStreamOptions, -): UseStream { +): UseStream { type EventStreamEvent = | ValuesStreamEvent | UpdatesStreamEvent @@ -640,7 +649,7 @@ export function useStream< const submit = async ( values: UpdateType | undefined, - submitOptions?: SubmitOptions, + submitOptions?: SubmitOptions, ) => { try { setIsLoading(true);