11import  {  type  Rivet ,  RivetClient  }  from  "@rivetkit/engine-api-full" ; 
2- import  {  type   FetchFunction ,   fetcher  }  from  "@rivetkit/engine-api-full/core" ; 
2+ import  {  fetcher  }  from  "@rivetkit/engine-api-full/core" ; 
33import  { 
44	infiniteQueryOptions , 
55	mutationOptions , 
66	QueryKey , 
7- 	QueryOptions , 
87	queryOptions , 
98	UseQueryOptions , 
109}  from  "@tanstack/react-query" ; 
@@ -17,15 +16,14 @@ import {
1716}  from  "@/components/actors" ; 
1817import  {  engineEnv  }  from  "@/lib/env" ; 
1918import  {  convertStringToId  }  from  "@/lib/utils" ; 
20- import  {  queryClient  }  from  "@/queries/global" ; 
2119import  {  noThrow ,  shouldRetryAllExpect403  }  from  "@/queries/utils" ; 
2220import  { 
2321	ActorQueryOptions , 
2422	ActorQueryOptionsSchema , 
2523	createDefaultGlobalContext , 
26- 	type  DefaultDataProvider , 
2724	RECORDS_PER_PAGE , 
2825}  from  "./default-data-provider" ; 
26+ import  z  from  "zod" ; 
2927
3028const  mightRequireAuth  =  __APP_TYPE__  ===  "engine" ; 
3129
@@ -133,6 +131,7 @@ export const createGlobalContext = (opts: {
133131export  const  createNamespaceContext  =  ( { 
134132	namespace, 
135133	client, 
134+ 	...parent 
136135} : {  namespace : string ;  }  &  ReturnType < 
137136	typeof  createGlobalContext 
138137> )  =>  { 
@@ -407,7 +406,7 @@ export const createNamespaceContext = ({
407406				enabled : ! ! opts . runnerUrl , 
408407				queryFn : async  ( {  signal : abortSignal  } )  =>  { 
409408					const  res  = 
410- 						await  client . runnerConfigs . serverlessHealthCheck ( 
409+ 						await  client . runnerConfigsServerlessHealthCheck ( 
411410							{ 
412411								url : opts . runnerUrl , 
413412								headers : opts . headers , 
@@ -553,7 +552,7 @@ export const createNamespaceContext = ({
553552					name : string ; 
554553					config : Record < string ,  Rivet . RunnerConfig > ; 
555554				} )  =>  { 
556- 					const  response  =  await  client . runnerConfigs . upsert ( name ,  { 
555+ 					const  response  =  await  client . runnerConfigsUpsert ( name ,  { 
557556						namespace, 
558557						datacenters : config , 
559558					} ) ; 
@@ -572,7 +571,7 @@ export const createNamespaceContext = ({
572571				...opts , 
573572				mutationKey : [ "runner-config" ,  "delete" ]  as  QueryKey , 
574573				mutationFn : async  ( name : string )  =>  { 
575- 					await  client . runnerConfigs . delete ( name ,  {  namespace } ) ; 
574+ 					await  client . runnerConfigsDelete ( name ,  {  namespace } ) ; 
576575				} , 
577576				retry : shouldRetryAllExpect403 , 
578577				meta : { 
@@ -587,7 +586,7 @@ export const createNamespaceContext = ({
587586				queryKey : [ {  namespace } ,  "runners" ,  "configs" ,  opts ]  as  QueryKey , 
588587				initialPageParam : undefined  as  string  |  undefined , 
589588				queryFn : async  ( {  signal : abortSignal ,  pageParam } )  =>  { 
590- 					const  response  =  await  client . runnerConfigs . list ( 
589+ 					const  response  =  await  client . runnerConfigsList ( 
591590						{ 
592591							namespace, 
593592							cursor : pageParam  ??  undefined , 
@@ -630,7 +629,7 @@ export const createNamespaceContext = ({
630629				queryKey : [ {  namespace } ,  "runners" ,  "config" ,  opts ]  as  QueryKey , 
631630				enabled : ! ! opts . name , 
632631				queryFn : async  ( {  signal : abortSignal  } )  =>  { 
633- 					const  response  =  await  client . runnerConfigs . list ( 
632+ 					const  response  =  await  client . runnerConfigsList ( 
634633						{ 
635634							namespace, 
636635							runnerNames : opts . name , 
@@ -653,13 +652,13 @@ export const createNamespaceContext = ({
653652				} , 
654653			} ) ; 
655654		} , 
656- 		engineAdminTokenQueryOptions ( ) :  UseQueryOptions < string >  { 
655+ 		engineAdminTokenQueryOptions ( )  { 
657656			return  queryOptions ( { 
658657				staleTime : 1000 , 
659658				gcTime : 1000 , 
660659				queryKey : [ {  namespace } ,  "tokens" ,  "engine-admin" ]  as  QueryKey , 
661660				queryFn : async  ( )  =>  { 
662- 					return  ls . engineCredentials . get ( getConfig ( ) . apiUrl )  ||  "" ; 
661+ 					return  ( ls . engineCredentials . get ( getConfig ( ) . apiUrl )  ||  "" )   as   string ; 
663662				} , 
664663				meta : { 
665664					mightRequireAuth, 
@@ -699,3 +698,28 @@ function transformActor(a: Rivet.Actor): Actor {
699698		] , 
700699	} ; 
701700} 
701+ 
702+ type  RunnerConfig  =  [ 
703+ 	string , 
704+ 	{ 
705+ 		datacenters : Record < string ,  {  metadata ?: {  provider ?: string  }  } > ; 
706+ 	} , 
707+ ] ; 
708+ 
709+ export  function  hasMetadataProvider ( metadata : unknown ) : metadata  is {  provider ?: string  }  { 
710+ 	return  z . object ( {  provider : z . string ( ) . optional ( )  } ) . safeParse ( metadata ) . success ; 
711+ } 
712+ 
713+ export  function  hasProvider ( 
714+ 	configs : [ string ,  Rivet . RunnerConfigsListResponseRunnerConfigsValue ] [ ]  |  undefined , 
715+ 	providers : string [ ] , 
716+ ) : boolean  { 
717+ 	if  ( ! configs )  return  false ; 
718+ 	return  configs . some ( ( [ ,  config ] )  => 
719+ 		Object . values ( config . datacenters ) . some ( 
720+ 			( datacenter )  => 
721+ 				datacenter . metadata  &&  hasMetadataProvider ( datacenter . metadata )  &&  datacenter . metadata . provider  && 
722+ 				providers . includes ( datacenter . metadata . provider ) , 
723+ 		) , 
724+ 	) ; 
725+ } 
0 commit comments