@@ -3,7 +3,7 @@ import { expectTypeOf, test } from "vitest";
33
44import { Leap0Client , Sandbox } from "@/client/index.js" ;
55import { SERVICES } from "@/client/sandbox.js" ;
6- import type { RequestOptions } from "@/models/index.js" ;
6+ import type { PresignedUrl , RequestOptions } from "@/models/index.js" ;
77
88test ( "Leap0Client wires services and supports direct access" , async ( ) => {
99 const originalApiKey = process . env . LEAP0_API_KEY ;
@@ -86,6 +86,16 @@ test("Sandbox binds service methods to itself", async () => {
8686 createdAt : "2026-01-01T00:00:00Z" ,
8787 } ) ,
8888 delete : async ( ) => undefined ,
89+ createPresignedUrl : async ( ) => ( {
90+ id : "psu-1" ,
91+ token : "tok_1" ,
92+ url : "https://tok_1.leap0.app" ,
93+ sandboxId : "sb-1" ,
94+ port : 8080 ,
95+ expiresAt : "2026-01-01T00:15:00Z" ,
96+ createdAt : "2026-01-01T00:00:00Z" ,
97+ } ) ,
98+ deletePresignedUrl : async ( ) => undefined ,
8999 getUserHomeDir : async ( id : string ) => `home:${ id } ` ,
90100 getWorkdir : async ( id : string ) => `workdir:${ id } ` ,
91101 invokeUrl : ( id : string , path : string , port ?: number ) => `invoke:${ id } :${ path } :${ port ?? "" } ` ,
@@ -124,6 +134,8 @@ test("Sandbox binds service methods to itself", async () => {
124134 assert . equal ( sandbox . invokeUrl ( "/healthz" , 3000 ) , "invoke:sb-1:/healthz:3000" ) ;
125135 assert . equal ( await sandbox . getUserHomeDir ( ) , "home:sb-1" ) ;
126136 assert . equal ( await sandbox . getWorkdir ( ) , "workdir:sb-1" ) ;
137+ assert . equal ( ( await sandbox . createPresignedUrl ( 8080 , 15 ) ) . url , "https://tok_1.leap0.app" ) ;
138+ await sandbox . deletePresignedUrl ( "psu-1" ) ;
127139} ) ;
128140
129141test ( "Sandbox refresh rejects invalid sandbox states" , async ( ) => {
@@ -180,10 +192,17 @@ test("client and sandbox helpers stay strongly typed", () => {
180192 [ params : { command : string ; cwd ?: string ; timeout ?: number ; env ?: Record < string , string > } , options ?: RequestOptions ]
181193 > ( ) ;
182194 expectTypeOf < Sandbox [ "ssh" ] [ "validateAccess" ] > ( ) . parameters . toEqualTypeOf <
183- [ accessId : string , password : string , options ?: RequestOptions ]
195+ [ id : string , password : string , options ?: RequestOptions ]
196+ > ( ) ;
197+ expectTypeOf < Sandbox [ "ssh" ] [ "deleteAccess" ] > ( ) . parameters . toEqualTypeOf <
198+ [ id : string , options ?: RequestOptions ]
199+ > ( ) ;
200+ expectTypeOf < Sandbox [ "ssh" ] [ "regenerateAccess" ] > ( ) . parameters . toEqualTypeOf <
201+ [ id : string , options ?: RequestOptions ]
184202 > ( ) ;
185203 expectTypeOf < ReturnType < Sandbox [ "getUserHomeDir" ] > > ( ) . toEqualTypeOf < Promise < string > > ( ) ;
186204 expectTypeOf < ReturnType < Sandbox [ "getWorkdir" ] > > ( ) . toEqualTypeOf < Promise < string > > ( ) ;
205+ expectTypeOf < ReturnType < Sandbox [ "createPresignedUrl" ] > > ( ) . toEqualTypeOf < Promise < PresignedUrl > > ( ) ;
187206 expectTypeOf < Sandbox [ "templateName" ] > ( ) . toEqualTypeOf < string | undefined > ( ) ;
188207 expectTypeOf < Sandbox [ "timeoutMin" ] > ( ) . toEqualTypeOf < number | undefined > ( ) ;
189208 expectTypeOf < Sandbox [ "envVars" ] > ( ) . toEqualTypeOf < Record < string , string > | undefined > ( ) ;
0 commit comments