11import { type Rivet , RivetClient } from "@rivetkit/engine-api-full" ;
22import { type FetchFunction , fetcher } from "@rivetkit/engine-api-full/core" ;
3- import { infiniteQueryOptions , queryOptions } from "@tanstack/react-query" ;
3+ import {
4+ infiniteQueryOptions ,
5+ mutationOptions ,
6+ queryOptions ,
7+ } from "@tanstack/react-query" ;
48import { getConfig , ls } from "@/components" ;
59import {
610 type Actor ,
@@ -10,6 +14,7 @@ import {
1014} from "@/components/actors" ;
1115import { engineEnv } from "@/lib/env" ;
1216import { convertStringToId } from "@/lib/utils" ;
17+ import { queryClient } from "@/queries/global" ;
1318import { noThrow , shouldRetryAllExpect403 } from "@/queries/utils" ;
1419import {
1520 ActorQueryOptionsSchema ,
@@ -505,7 +510,7 @@ export const createNamespaceContext = ({
505510 } ,
506511 } ) ;
507512 } ,
508- runnerByNameQueryOptions ( opts : { runnerName : string } ) {
513+ runnerByNameQueryOptions ( opts : { runnerName : string | undefined } ) {
509514 return queryOptions ( {
510515 queryKey : [ { namespace } , "runner" , opts . runnerName ] ,
511516 enabled : ! ! opts . runnerName ,
@@ -532,7 +537,7 @@ export const createNamespaceContext = ({
532537 onSuccess ?: ( data : Rivet . RunnerConfigsUpsertResponse ) => void ;
533538 } = { } ,
534539 ) {
535- return {
540+ return mutationOptions ( {
536541 ...opts ,
537542 mutationKey : [ "runner-config" ] ,
538543 mutationFn : async ( {
@@ -552,7 +557,7 @@ export const createNamespaceContext = ({
552557 meta : {
553558 mightRequireAuth,
554559 } ,
555- } ;
560+ } ) ;
556561 } ,
557562 deleteRunnerConfigMutationOptions (
558563 opts : { onSuccess ?: ( data : void ) => void } = { } ,
@@ -569,16 +574,19 @@ export const createNamespaceContext = ({
569574 } ,
570575 } ;
571576 } ,
572- runnerConfigsQueryOptions ( ) {
577+ runnerConfigsQueryOptions ( opts ?: {
578+ variant ?: Rivet . RunnerConfigVariant ;
579+ } ) {
573580 return infiniteQueryOptions ( {
574- queryKey : [ { namespace } , "runners" , "configs" ] ,
581+ queryKey : [ { namespace } , "runners" , "configs" , opts ] ,
575582 initialPageParam : undefined as string | undefined ,
576583 queryFn : async ( { signal : abortSignal , pageParam } ) => {
577584 const response = await client . runnerConfigs . list (
578585 {
579586 namespace,
580587 cursor : pageParam ?? undefined ,
581588 limit : RECORDS_PER_PAGE ,
589+ variant : opts ?. variant ,
582590 } ,
583591 { abortSignal } ,
584592 ) ;
@@ -608,20 +616,24 @@ export const createNamespaceContext = ({
608616 } ) ;
609617 } ,
610618
611- runnerConfigQueryOptions ( runnerName : string ) {
619+ runnerConfigQueryOptions ( opts : {
620+ name : string | undefined ;
621+ variant ?: Rivet . RunnerConfigVariant ;
622+ } ) {
612623 return queryOptions ( {
613- queryKey : [ { namespace } , "runners" , "config" , runnerName ] ,
614- enabled : ! ! runnerName ,
624+ queryKey : [ { namespace } , "runners" , "config" , opts ] ,
625+ enabled : ! ! opts . name ,
615626 queryFn : async ( { signal : abortSignal } ) => {
616627 const response = await client . runnerConfigs . list (
617628 {
618629 namespace,
619- runnerNames : runnerName ,
630+ runnerNames : opts . name ,
631+ variant : opts . variant ,
620632 } ,
621633 { abortSignal } ,
622634 ) ;
623635
624- const config = response . runnerConfigs [ runnerName ] ;
636+ const config = response . runnerConfigs [ opts . name ! ] ;
625637
626638 if ( ! config ) {
627639 throw new Error ( "Runner config not found" ) ;
0 commit comments