MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / generateWshClientApiMethod_ResponseStream

Function generateWshClientApiMethod_ResponseStream

pkg/tsgen/tsgen.go:463–481  ·  view source on GitHub ↗
(methodDecl *wshrpc.WshRpcMethodDecl, tsTypesMap map[reflect.Type]string)

Source from the content-addressed store, hash-verified

461}
462
463func generateWshClientApiMethod_ResponseStream(methodDecl *wshrpc.WshRpcMethodDecl, tsTypesMap map[reflect.Type]string) string {
464 var sb strings.Builder
465 sb.WriteString(fmt.Sprintf(" // command %q [%s]\n", methodDecl.Command, methodDecl.CommandType))
466 respType := "any"
467 if methodDecl.DefaultResponseDataType != nil {
468 respType, _ = TypeToTSType(methodDecl.DefaultResponseDataType, tsTypesMap)
469 }
470 methodSigDataParams, dataName := getTsWshMethodDataParamsAndExpr(methodDecl, tsTypesMap)
471 genRespType := fmt.Sprintf("AsyncGenerator<%s, void, boolean>", respType)
472 if methodSigDataParams == "" {
473 sb.WriteString(fmt.Sprintf(" %s(client: WshClient, opts?: RpcOpts): %s {\n", methodDecl.MethodName, genRespType))
474 } else {
475 sb.WriteString(fmt.Sprintf(" %s(client: WshClient, %s, opts?: RpcOpts): %s {\n", methodDecl.MethodName, methodSigDataParams, genRespType))
476 }
477 sb.WriteString(fmt.Sprintf(" if (this.mockClient) return this.mockClient.mockWshRpcStream(client, %q, %s, opts);\n", methodDecl.Command, dataName))
478 sb.WriteString(fmt.Sprintf(" return client.wshRpcStream(%q, %s, opts);\n", methodDecl.Command, dataName))
479 sb.WriteString(" }\n")
480 return sb.String()
481}
482
483func generateWshClientApiMethod_Call(methodDecl *wshrpc.WshRpcMethodDecl, tsTypesMap map[reflect.Type]string) string {
484 var sb strings.Builder

Callers 1

Calls 4

TypeToTSTypeFunction · 0.85
WriteStringMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected