@@ -489,12 +489,12 @@ pub async fn get_func_view(ctx: &DalContext, func: &Func) -> FuncResult<GetFuncR
489489 } ;
490490 //
491491 // let is_revertible = is_func_revertible(ctx, func).await?;
492- // let types = [
493- // compile_return_types(* func.backend_response_type(), * func.backend_kind() ),
494- // &input_type,
495- // langjs_types(),
496- // ]
497- // .join("\n");
492+ let types = [
493+ compile_return_types ( func. backend_response_type , func. backend_kind ) ,
494+ & input_type,
495+ langjs_types ( ) ,
496+ ]
497+ . join ( "\n " ) ;
498498
499499 Ok ( GetFuncResponse {
500500 id : func. id . to_owned ( ) ,
@@ -506,7 +506,7 @@ pub async fn get_func_view(ctx: &DalContext, func: &Func) -> FuncResult<GetFuncR
506506 is_builtin : func. builtin ,
507507 is_revertible : false ,
508508 associations,
509- types : input_type ,
509+ types,
510510 } )
511511}
512512
@@ -574,6 +574,48 @@ pub fn compile_return_types(ty: FuncBackendResponseType, kind: FuncBackendKind)
574574 }
575575}
576576
577+ // TODO: stop duplicating definition
578+ // TODO: use execa types instead of any
579+ // TODO: add os, fs and path types (possibly fetch but I think it comes with DOM)
580+ fn langjs_types ( ) -> & ' static str {
581+ "declare namespace YAML {
582+ function stringify(obj: unknown): string;
583+ }
584+
585+ declare namespace zlib {
586+ function gzip(inputstr: string, callback: any);
587+ }
588+
589+ declare namespace requestStorage {
590+ function getEnv(key: string): string;
591+ function getItem(key: string): any;
592+ function getEnvKeys(): string[];
593+ function getKeys(): string[];
594+ }
595+
596+ declare namespace siExec {
597+
598+ interface WatchArgs {
599+ cmd: string,
600+ args?: readonly string[],
601+ execaOptions?: Options<string>,
602+ retryMs?: number,
603+ maxRetryCount?: number,
604+ callback: (child: execa.ExecaReturnValue<string>) => Promise<boolean>,
605+ }
606+
607+ interface WatchResult {
608+ result: SiExecResult,
609+ failed?: 'deadlineExceeded' | 'commandFailed',
610+ }
611+
612+ type SiExecResult = ExecaReturnValue<string>;
613+
614+ async function waitUntilEnd(execaFile: string, execaArgs?: string[], execaOptions?: any): Promise<any>;
615+ async function watch(options: WatchArgs, deadlineCount?: number): Promise<WatchResult>;
616+ }"
617+ }
618+
577619pub fn routes ( ) -> Router < AppState > {
578620 Router :: new ( )
579621 . route ( "/list_funcs" , get ( list_funcs:: list_funcs) )
0 commit comments