@@ -17,9 +17,10 @@ import {
1717} from "./default-data-provider" ;
1818import { getConfig } from "@/components/lib/config" ;
1919
20+ const mightRequireAuth = __APP_TYPE__ === "engine" ;
21+
2022export type CreateNamespace = {
2123 displayName : string ;
22- name ?: string ;
2324} ;
2425
2526export type Namespace = {
@@ -30,8 +31,8 @@ export type Namespace = {
3031} ;
3132
3233export function createClient (
33- baseUrl = getConfig ( ) . apiUrl ,
34- opts : { token : ( ( ) => string ) | string } ,
34+ baseUrl = engineEnv ( ) . VITE_APP_API_URL ,
35+ opts : { token : ( ( ) => string ) | string | ( ( ) => Promise < string > ) } ,
3536) {
3637 return new RivetClient ( {
3738 baseUrl : ( ) => baseUrl ,
@@ -88,7 +89,7 @@ export const createGlobalContext = (opts: {
8889 mutationFn : async ( data : CreateNamespace ) => {
8990 const response = await client . namespaces . create ( {
9091 displayName : data . displayName ,
91- name : data . name || convertStringToId ( data . displayName ) ,
92+ name : convertStringToId ( data . displayName ) ,
9293 } ) ;
9394
9495 return {
@@ -133,7 +134,7 @@ export const createNamespaceContext = ({
133134 retry : shouldRetryAllExpect403 ,
134135 throwOnError : noThrow ,
135136 meta : {
136- mightRequireAuth : true ,
137+ mightRequireAuth,
137138 } ,
138139 } ) ;
139140 } ,
@@ -158,7 +159,7 @@ export const createNamespaceContext = ({
158159 retry : shouldRetryAllExpect403 ,
159160 throwOnError : noThrow ,
160161 meta : {
161- mightRequireAuth : true ,
162+ mightRequireAuth,
162163 } ,
163164 } ) ;
164165 } ,
@@ -187,7 +188,7 @@ export const createNamespaceContext = ({
187188 retry : shouldRetryAllExpect403 ,
188189 throwOnError : noThrow ,
189190 meta : {
190- mightRequireAuth : true ,
191+ mightRequireAuth,
191192 } ,
192193 } ) ;
193194 } ,
@@ -214,7 +215,7 @@ export const createNamespaceContext = ({
214215 retry : shouldRetryAllExpect403 ,
215216 throwOnError : noThrow ,
216217 meta : {
217- mightRequireAuth : true ,
218+ mightRequireAuth,
218219 } ,
219220 } ) ;
220221 } ,
@@ -289,7 +290,7 @@ export const createNamespaceContext = ({
289290 retry : shouldRetryAllExpect403 ,
290291 throwOnError : noThrow ,
291292 meta : {
292- mightRequireAuth : true ,
293+ mightRequireAuth,
293294 } ,
294295 } ) ;
295296 } ,
@@ -330,7 +331,7 @@ export const createNamespaceContext = ({
330331 retry : shouldRetryAllExpect403 ,
331332 throwOnError : noThrow ,
332333 meta : {
333- mightRequireAuth : true ,
334+ mightRequireAuth,
334335 } ,
335336 } ) ;
336337 } ,
@@ -354,7 +355,7 @@ export const createNamespaceContext = ({
354355 throwOnError : noThrow ,
355356 retry : shouldRetryAllExpect403 ,
356357 meta : {
357- mightRequireAuth : true ,
358+ mightRequireAuth,
358359 } ,
359360 } ;
360361 } ,
@@ -364,7 +365,7 @@ export const createNamespaceContext = ({
364365 throwOnError : noThrow ,
365366 retry : shouldRetryAllExpect403 ,
366367 meta : {
367- mightRequireAuth : true ,
368+ mightRequireAuth,
368369 } ,
369370 mutationFn : async ( ) => {
370371 await client . actorsDelete ( actorId ) ;
@@ -375,14 +376,14 @@ export const createNamespaceContext = ({
375376
376377 return {
377378 ...dataProvider ,
378- runnersQueryOptions ( opts : { namespace : string } ) {
379+ runnersQueryOptions ( ) {
379380 return infiniteQueryOptions ( {
380- queryKey : [ opts . namespace , "runners" ] ,
381+ queryKey : [ { namespace } , "runners" ] ,
381382 initialPageParam : undefined as string | undefined ,
382383 queryFn : async ( { pageParam, signal : abortSignal } ) => {
383384 const data = await client . runners . list (
384385 {
385- namespace : opts . namespace ,
386+ namespace,
386387 cursor : pageParam ?? undefined ,
387388 limit : RECORDS_PER_PAGE ,
388389 } ,
@@ -399,7 +400,7 @@ export const createNamespaceContext = ({
399400 select : ( data ) => data . pages . flatMap ( ( page ) => page . runners ) ,
400401 retry : shouldRetryAllExpect403 ,
401402 meta : {
402- mightRequireAuth : true ,
403+ mightRequireAuth,
403404 } ,
404405 } ) ;
405406 } ,
@@ -430,7 +431,7 @@ export const createNamespaceContext = ({
430431 retry : shouldRetryAllExpect403 ,
431432 throwOnError : noThrow ,
432433 meta : {
433- mightRequireAuth : true ,
434+ mightRequireAuth,
434435 } ,
435436 } ) ;
436437 } ,
@@ -457,7 +458,7 @@ export const createNamespaceContext = ({
457458 throwOnError : noThrow ,
458459 retry : shouldRetryAllExpect403 ,
459460 meta : {
460- mightRequireAuth : true ,
461+ mightRequireAuth,
461462 } ,
462463 } ) ;
463464 } ,
@@ -482,7 +483,7 @@ export const createNamespaceContext = ({
482483 } ,
483484 retry : shouldRetryAllExpect403 ,
484485 meta : {
485- mightRequireAuth : true ,
486+ mightRequireAuth,
486487 } ,
487488 } ) ;
488489 } ,
@@ -507,6 +508,10 @@ export const createNamespaceContext = ({
507508 } ) ;
508509 return response ;
509510 } ,
511+ retry : shouldRetryAllExpect403 ,
512+ meta : {
513+ mightRequireAuth,
514+ } ,
510515 } ;
511516 } ,
512517 runnerConfigsQueryOptions ( ) {
@@ -539,6 +544,12 @@ export const createNamespaceContext = ({
539544 }
540545 return lastPage . pagination . cursor ;
541546 } ,
547+
548+ retryDelay : 50_000 ,
549+ retry : shouldRetryAllExpect403 ,
550+ meta : {
551+ mightRequireAuth,
552+ } ,
542553 } ) ;
543554 } ,
544555 } ;
0 commit comments