File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,7 +46,12 @@ export class {{$service.Name}} implements {{$service.Name}}Client {
4646 {{- $methodRespName := "" -}}
4747 {{- if $method.Succinct -}}
4848 {{- $methodReqName = (index $method.Inputs 0).Type -}}
49- {{- $methodRespName = (index $method.Outputs 0).Type -}}
49+ {{- if gt (len $method.Outputs) 0 -}}
50+ {{- $methodRespName = (index $method.Outputs 0).Type -}}
51+ {{- if isCoreType (index $method.Outputs 0).Type -}}
52+ {{- $methodRespName = get $typeMap (index $method.Outputs 0).Type -}}
53+ {{- end -}}
54+ {{- end -}}
5055 {{- else -}}
5156 {{- if $opts.compat -}}
5257 {{- $methodReqName = printf "%sArgs" $method.Name -}}
@@ -56,7 +61,7 @@ export class {{$service.Name}} implements {{$service.Name}}Client {
5661 {{- $methodRespName = printf "%sResponse" $method.Name -}}
5762 {{- end -}}
5863 {{- end}}
59- {{firstLetterToLower .Name}} = ({{template "methodInputs" dict "Method" . "Opts" $opts "TypeMap" $typeMap}}): {{if $method.StreamOutput}}WebrpcStreamController{{else}}{{if $method.Succinct}}Promise<{{(index $method.Outputs 0).Type}} >{{else}}Promise<{{$method.Name}}{{if $opts.compat}}Return{{else}}Response{{end}}>{{end}}{{end}} => {
64+ {{firstLetterToLower .Name}} = ({{template "methodInputs" dict "Method" . "Opts" $opts "TypeMap" $typeMap}}): {{if $method.StreamOutput}}WebrpcStreamController{{else}}{{if and $method.Succinct (gt (len $method.Outputs) 0) }}Promise<{{template "type" dict "Type" (index $method.Outputs 0).Type "TypeMap" $typeMap}}>{{else if $method.Succinct}}Promise<void >{{else}}Promise<{{$method.Name}}{{if $opts.compat}}Return{{else}}Response{{end}}>{{end}}{{end}} => {
6065 {{- if $method.StreamOutput }}
6166 const abortController = new AbortController()
6267 const abortSignal = abortController.signal
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export interface {{$service.Name}}Client {
2828 * @deprecated {{ $deprecated.Value }}
2929 */
3030 {{- end }}
31- {{firstLetterToLower $method .Name }}({{template " methodInputs" dict " Method" $method " TypeMap" $typeMap " Opts" $opts }}): {{if $method .StreamOutput }}WebrpcStreamController{{else }}{{if $method .Succinct }}Promise<{{(index $method .Outputs 0).Type }} >{{else }}Promise<{{$method .Name }}{{if $opts .compat }}Return{{else }}Response{{end }}>{{end }}{{end }}
31+ {{firstLetterToLower $method .Name }}({{template " methodInputs" dict " Method" $method " TypeMap" $typeMap " Opts" $opts }}): {{if $method .StreamOutput }}WebrpcStreamController{{else }}{{if and $method .Succinct ( gt ( len $method .Outputs ) 0) }}Promise<{{template " type " dict " Type " (index $method .Outputs 0).Type " TypeMap " $typeMap }}>{{ else if $method .Succinct }}Promise<void >{{else }}Promise<{{$method .Name }}{{if $opts .compat }}Return{{else }}Response{{end }}>{{end }}{{end }}
3232 {{- if lt (add $i 1) (len $service .Methods )}}{{" \n " }}{{end }}
3333{{- end }}
3434}
Original file line number Diff line number Diff line change 1313export interface {{$service .Name }}Server<Context = unknown> {
1414 {{- range $_ , $method := $service .Methods }}
1515 {{- if $method .Succinct }}
16- {{firstLetterToLower $method .Name }}(ctx: Context, req: {{(index $method .Inputs 0).Type }}): Promise<{{( index $method .Outputs 0).Type }}>
16+ {{firstLetterToLower $method .Name }}(ctx: Context, req: {{(index $method .Inputs 0).Type }}): Promise<{{if gt ( len $method .Outputs ) 0}}{{ template " type " dict " Type " ( index $method .Outputs 0).Type " TypeMap " $typeMap }}{{ else }}void{{ end }}>
1717 {{- else }}
1818 {{- if $opts .compat }}
1919 {{firstLetterToLower $method .Name }}(ctx: Context, req: {{$method .Name }}Args): Promise<{{$method .Name }}Return>
You can’t perform that action at this time.
0 commit comments