starpc 0.31.6 → 0.31.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Makefile +4 -4
- package/cmd/protoc-gen-es-starpc/typescript.ts +17 -16
- package/dist/cmd/protoc-gen-es-starpc/typescript.js +15 -14
- package/dist/e2e/mock/mock_pb.d.ts +5 -12
- package/dist/e2e/mock/mock_pb.js +9 -33
- package/dist/e2e/mock/mock_srpc.pb.d.ts +8 -8
- package/dist/e2e/mock/mock_srpc.pb.js +7 -7
- package/dist/echo/echo_pb.d.ts +5 -12
- package/dist/echo/echo_pb.js +9 -33
- package/dist/echo/echo_srpc.pb.d.ts +21 -21
- package/dist/echo/echo_srpc.pb.js +15 -15
- package/dist/echo/server.d.ts +3 -3
- package/dist/rpcstream/rpcstream.d.ts +3 -3
- package/dist/rpcstream/rpcstream_pb.d.ts +36 -57
- package/dist/rpcstream/rpcstream_pb.js +28 -106
- package/dist/srpc/client-rpc.d.ts +1 -1
- package/dist/srpc/client-rpc.js +1 -1
- package/dist/srpc/common-rpc.d.ts +4 -5
- package/dist/srpc/definition.d.ts +2 -1
- package/dist/srpc/invoker.d.ts +3 -2
- package/dist/srpc/invoker.js +1 -1
- package/dist/srpc/message.d.ts +4 -4
- package/dist/srpc/message.js +3 -3
- package/dist/srpc/pushable.d.ts +2 -2
- package/dist/srpc/pushable.js +1 -1
- package/dist/srpc/rpcproto_pb.d.ts +55 -76
- package/dist/srpc/rpcproto_pb.js +30 -150
- package/e2e/mock/mock_pb.ts +18 -50
- package/e2e/mock/mock_srpc.pb.ts +7 -7
- package/echo/client-test.ts +2 -2
- package/echo/echo_pb.ts +18 -50
- package/echo/echo_srpc.pb.ts +13 -13
- package/echo/server.ts +3 -3
- package/go.mod +1 -1
- package/go.sum +2 -0
- package/package.json +22 -7
- package/srpc/client-rpc.ts +4 -4
- package/srpc/common-rpc.ts +9 -9
- package/srpc/definition.ts +2 -1
- package/srpc/invoker.ts +7 -12
- package/srpc/message.ts +9 -11
- package/srpc/pushable.ts +4 -6
- package/srpc/rpcproto_pb.ts +91 -188
package/Makefile
CHANGED
|
@@ -78,14 +78,14 @@ genproto: vendor node_modules $(GOIMPORTS) $(PROTOWRAP) $(PROTOC_GEN_GO) $(PROTO
|
|
|
78
78
|
PROTO_FILES=$$(git ls-files "$$1"); \
|
|
79
79
|
$(PROTOWRAP) \
|
|
80
80
|
-I $${OUT} \
|
|
81
|
-
--plugin=./node_modules/.bin/protoc-gen-es \
|
|
81
|
+
--plugin=./node_modules/.bin/protoc-gen-es-lite \
|
|
82
82
|
--plugin=./cmd/protoc-gen-es-starpc/dev/protoc-gen-es-starpc \
|
|
83
83
|
--go-lite_out=$${OUT} \
|
|
84
84
|
--go-lite_opt=features=marshal+unmarshal+size+equal+json+clone+text \
|
|
85
|
+
--es-lite_out=$${OUT} \
|
|
86
|
+
--es-lite_opt target=ts \
|
|
87
|
+
--es-lite_opt ts_nocheck=false \
|
|
85
88
|
--go-starpc_out=$${OUT} \
|
|
86
|
-
--es_out=$${OUT} \
|
|
87
|
-
--es_opt target=ts \
|
|
88
|
-
--es_opt ts_nocheck=false \
|
|
89
89
|
--es-starpc_out=$${OUT} \
|
|
90
90
|
--es-starpc_opt target=ts \
|
|
91
91
|
--es-starpc_opt ts_nocheck=false \
|
|
@@ -13,11 +13,13 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
|
|
16
|
-
import
|
|
17
|
-
import { MethodIdempotency, MethodKind } from '@bufbuild/protobuf'
|
|
16
|
+
import { DescService, MethodIdempotency, MethodKind } from '@bufbuild/protobuf'
|
|
18
17
|
import type { GeneratedFile, Schema } from '@bufbuild/protoplugin/ecmascript'
|
|
19
18
|
import { createImportSymbol, localName } from '@bufbuild/protoplugin/ecmascript'
|
|
20
19
|
|
|
20
|
+
const MessageStream = createImportSymbol('MessageStream', 'starpc')
|
|
21
|
+
const Message = createImportSymbol('Message', '@aptre/protobuf-es-lite')
|
|
22
|
+
|
|
21
23
|
export function generateTs(schema: Schema) {
|
|
22
24
|
for (const protoFile of schema.files) {
|
|
23
25
|
const file = schema.generateFile(protoFile.name + '_srpc.pb.ts')
|
|
@@ -34,9 +36,8 @@ function generateService(
|
|
|
34
36
|
f: GeneratedFile,
|
|
35
37
|
service: DescService
|
|
36
38
|
) {
|
|
37
|
-
const { MethodKind: rtMethodKind, MethodIdempotency: rtMethodIdempotency
|
|
39
|
+
const { MethodKind: rtMethodKind, MethodIdempotency: rtMethodIdempotency } =
|
|
38
40
|
schema.runtime;
|
|
39
|
-
const MessageStream = createImportSymbol("MessageStream", "starpc")
|
|
40
41
|
|
|
41
42
|
// NOTE: This matches generateService from @connectrpc/protoc-gen-connect-es.
|
|
42
43
|
f.print(f.jsDoc(service));
|
|
@@ -79,9 +80,9 @@ function generateService(
|
|
|
79
80
|
f.print(f.jsDoc(method, " "));
|
|
80
81
|
f.print(" ", method.name, "(");
|
|
81
82
|
if (method.methodKind === MethodKind.Unary) {
|
|
82
|
-
f.print("request: ",
|
|
83
|
+
f.print("request: ", Message, "<", method.input, ">, abortSignal?: AbortSignal");
|
|
83
84
|
} else if (method.methodKind === MethodKind.ServerStreaming) {
|
|
84
|
-
f.print("request: ",
|
|
85
|
+
f.print("request: ", Message, "<", method.input, ">, abortSignal?: AbortSignal");
|
|
85
86
|
} else if (method.methodKind === MethodKind.ClientStreaming) {
|
|
86
87
|
f.print("request: ", MessageStream, "<", method.input, ">, abortSignal?: AbortSignal");
|
|
87
88
|
} else if (method.methodKind === MethodKind.BiDiStreaming) {
|
|
@@ -89,11 +90,11 @@ function generateService(
|
|
|
89
90
|
}
|
|
90
91
|
f.print("): ");
|
|
91
92
|
if (method.methodKind === MethodKind.Unary) {
|
|
92
|
-
f.print("Promise<",
|
|
93
|
+
f.print("Promise<", Message, "<", method.output, ">>");
|
|
93
94
|
} else if (method.methodKind === MethodKind.ServerStreaming) {
|
|
94
95
|
f.print(MessageStream, "<", method.output, ">");
|
|
95
96
|
} else if (method.methodKind === MethodKind.ClientStreaming) {
|
|
96
|
-
f.print("Promise<",
|
|
97
|
+
f.print("Promise<", Message, "<", method.output, ">>");
|
|
97
98
|
} else if (method.methodKind === MethodKind.BiDiStreaming) {
|
|
98
99
|
f.print(MessageStream, "<", method.output, ">");
|
|
99
100
|
}
|
|
@@ -125,9 +126,9 @@ function generateService(
|
|
|
125
126
|
f.print(f.jsDoc(method, " "));
|
|
126
127
|
f.print(" ", method.methodKind === MethodKind.Unary || method.methodKind === MethodKind.ClientStreaming ? "async " : "", method.name, "(");
|
|
127
128
|
if (method.methodKind === MethodKind.Unary) {
|
|
128
|
-
f.print("request: ",
|
|
129
|
+
f.print("request: ", Message, "<", method.input, ">, abortSignal?: AbortSignal");
|
|
129
130
|
} else if (method.methodKind === MethodKind.ServerStreaming) {
|
|
130
|
-
f.print("request: ",
|
|
131
|
+
f.print("request: ", Message, "<", method.input, ">, abortSignal?: AbortSignal");
|
|
131
132
|
} else if (method.methodKind === MethodKind.ClientStreaming) {
|
|
132
133
|
f.print("request: ", MessageStream, "<", method.input, ">, abortSignal?: AbortSignal");
|
|
133
134
|
} else if (method.methodKind === MethodKind.BiDiStreaming) {
|
|
@@ -135,29 +136,29 @@ function generateService(
|
|
|
135
136
|
}
|
|
136
137
|
f.print("): ");
|
|
137
138
|
if (method.methodKind === MethodKind.Unary) {
|
|
138
|
-
f.print("Promise<",
|
|
139
|
-
f.print(" const requestMsg =
|
|
139
|
+
f.print("Promise<", Message, "<", method.output, ">> {");
|
|
140
|
+
f.print(" const requestMsg = ", method.input, ".create(request)");
|
|
140
141
|
f.print(" const result = await this.rpc.request(");
|
|
141
142
|
f.print(" this.service,");
|
|
142
143
|
f.print(" ", localName(service), "Definition.methods.", method.name, ".name,");
|
|
143
|
-
f.print("
|
|
144
|
+
f.print(" ", method.input, ".toBinary(requestMsg),");
|
|
144
145
|
f.print(" abortSignal || undefined,");
|
|
145
146
|
f.print(" )");
|
|
146
147
|
f.print(" return ", method.output, ".fromBinary(result)");
|
|
147
148
|
f.print(" }");
|
|
148
149
|
} else if (method.methodKind === MethodKind.ServerStreaming) {
|
|
149
150
|
f.print(MessageStream, "<", method.output, "> {");
|
|
150
|
-
f.print(" const requestMsg =
|
|
151
|
+
f.print(" const requestMsg = ", method.input, ".create(request)");
|
|
151
152
|
f.print(" const result = this.rpc.serverStreamingRequest(");
|
|
152
153
|
f.print(" this.service,");
|
|
153
154
|
f.print(" ", localName(service), "Definition.methods.", method.name, ".name,");
|
|
154
|
-
f.print("
|
|
155
|
+
f.print(" ", method.input, ".toBinary(requestMsg),");
|
|
155
156
|
f.print(" abortSignal || undefined,");
|
|
156
157
|
f.print(" )");
|
|
157
158
|
f.print(" return ", buildDecodeMessageTransformSymbol, "(", method.output, ")(result)");
|
|
158
159
|
f.print(" }");
|
|
159
160
|
} else if (method.methodKind === MethodKind.ClientStreaming) {
|
|
160
|
-
f.print("Promise<",
|
|
161
|
+
f.print("Promise<", Message, "<", method.output, ">> {");
|
|
161
162
|
f.print(" const result = await this.rpc.clientStreamingRequest(");
|
|
162
163
|
f.print(" this.service,");
|
|
163
164
|
f.print(" ", localName(service), "Definition.methods.", method.name, ".name,");
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
import { MethodIdempotency, MethodKind } from '@bufbuild/protobuf';
|
|
16
16
|
import { createImportSymbol, localName } from '@bufbuild/protoplugin/ecmascript';
|
|
17
|
+
const MessageStream = createImportSymbol('MessageStream', 'starpc');
|
|
18
|
+
const Message = createImportSymbol('Message', '@aptre/protobuf-es-lite');
|
|
17
19
|
export function generateTs(schema) {
|
|
18
20
|
for (const protoFile of schema.files) {
|
|
19
21
|
const file = schema.generateFile(protoFile.name + '_srpc.pb.ts');
|
|
@@ -25,8 +27,7 @@ export function generateTs(schema) {
|
|
|
25
27
|
}
|
|
26
28
|
// prettier-ignore
|
|
27
29
|
function generateService(schema, f, service) {
|
|
28
|
-
const { MethodKind: rtMethodKind, MethodIdempotency: rtMethodIdempotency
|
|
29
|
-
const MessageStream = createImportSymbol("MessageStream", "starpc");
|
|
30
|
+
const { MethodKind: rtMethodKind, MethodIdempotency: rtMethodIdempotency } = schema.runtime;
|
|
30
31
|
// NOTE: This matches generateService from @connectrpc/protoc-gen-connect-es.
|
|
31
32
|
f.print(f.jsDoc(service));
|
|
32
33
|
f.print(f.exportDecl("const", localName(service)), "Definition = {");
|
|
@@ -55,10 +56,10 @@ function generateService(schema, f, service) {
|
|
|
55
56
|
f.print(f.jsDoc(method, " "));
|
|
56
57
|
f.print(" ", method.name, "(");
|
|
57
58
|
if (method.methodKind === MethodKind.Unary) {
|
|
58
|
-
f.print("request: ",
|
|
59
|
+
f.print("request: ", Message, "<", method.input, ">, abortSignal?: AbortSignal");
|
|
59
60
|
}
|
|
60
61
|
else if (method.methodKind === MethodKind.ServerStreaming) {
|
|
61
|
-
f.print("request: ",
|
|
62
|
+
f.print("request: ", Message, "<", method.input, ">, abortSignal?: AbortSignal");
|
|
62
63
|
}
|
|
63
64
|
else if (method.methodKind === MethodKind.ClientStreaming) {
|
|
64
65
|
f.print("request: ", MessageStream, "<", method.input, ">, abortSignal?: AbortSignal");
|
|
@@ -68,13 +69,13 @@ function generateService(schema, f, service) {
|
|
|
68
69
|
}
|
|
69
70
|
f.print("): ");
|
|
70
71
|
if (method.methodKind === MethodKind.Unary) {
|
|
71
|
-
f.print("Promise<",
|
|
72
|
+
f.print("Promise<", Message, "<", method.output, ">>");
|
|
72
73
|
}
|
|
73
74
|
else if (method.methodKind === MethodKind.ServerStreaming) {
|
|
74
75
|
f.print(MessageStream, "<", method.output, ">");
|
|
75
76
|
}
|
|
76
77
|
else if (method.methodKind === MethodKind.ClientStreaming) {
|
|
77
|
-
f.print("Promise<",
|
|
78
|
+
f.print("Promise<", Message, "<", method.output, ">>");
|
|
78
79
|
}
|
|
79
80
|
else if (method.methodKind === MethodKind.BiDiStreaming) {
|
|
80
81
|
f.print(MessageStream, "<", method.output, ">");
|
|
@@ -103,10 +104,10 @@ function generateService(schema, f, service) {
|
|
|
103
104
|
f.print(f.jsDoc(method, " "));
|
|
104
105
|
f.print(" ", method.methodKind === MethodKind.Unary || method.methodKind === MethodKind.ClientStreaming ? "async " : "", method.name, "(");
|
|
105
106
|
if (method.methodKind === MethodKind.Unary) {
|
|
106
|
-
f.print("request: ",
|
|
107
|
+
f.print("request: ", Message, "<", method.input, ">, abortSignal?: AbortSignal");
|
|
107
108
|
}
|
|
108
109
|
else if (method.methodKind === MethodKind.ServerStreaming) {
|
|
109
|
-
f.print("request: ",
|
|
110
|
+
f.print("request: ", Message, "<", method.input, ">, abortSignal?: AbortSignal");
|
|
110
111
|
}
|
|
111
112
|
else if (method.methodKind === MethodKind.ClientStreaming) {
|
|
112
113
|
f.print("request: ", MessageStream, "<", method.input, ">, abortSignal?: AbortSignal");
|
|
@@ -116,12 +117,12 @@ function generateService(schema, f, service) {
|
|
|
116
117
|
}
|
|
117
118
|
f.print("): ");
|
|
118
119
|
if (method.methodKind === MethodKind.Unary) {
|
|
119
|
-
f.print("Promise<",
|
|
120
|
-
f.print(" const requestMsg =
|
|
120
|
+
f.print("Promise<", Message, "<", method.output, ">> {");
|
|
121
|
+
f.print(" const requestMsg = ", method.input, ".create(request)");
|
|
121
122
|
f.print(" const result = await this.rpc.request(");
|
|
122
123
|
f.print(" this.service,");
|
|
123
124
|
f.print(" ", localName(service), "Definition.methods.", method.name, ".name,");
|
|
124
|
-
f.print("
|
|
125
|
+
f.print(" ", method.input, ".toBinary(requestMsg),");
|
|
125
126
|
f.print(" abortSignal || undefined,");
|
|
126
127
|
f.print(" )");
|
|
127
128
|
f.print(" return ", method.output, ".fromBinary(result)");
|
|
@@ -129,18 +130,18 @@ function generateService(schema, f, service) {
|
|
|
129
130
|
}
|
|
130
131
|
else if (method.methodKind === MethodKind.ServerStreaming) {
|
|
131
132
|
f.print(MessageStream, "<", method.output, "> {");
|
|
132
|
-
f.print(" const requestMsg =
|
|
133
|
+
f.print(" const requestMsg = ", method.input, ".create(request)");
|
|
133
134
|
f.print(" const result = this.rpc.serverStreamingRequest(");
|
|
134
135
|
f.print(" this.service,");
|
|
135
136
|
f.print(" ", localName(service), "Definition.methods.", method.name, ".name,");
|
|
136
|
-
f.print("
|
|
137
|
+
f.print(" ", method.input, ".toBinary(requestMsg),");
|
|
137
138
|
f.print(" abortSignal || undefined,");
|
|
138
139
|
f.print(" )");
|
|
139
140
|
f.print(" return ", buildDecodeMessageTransformSymbol, "(", method.output, ")(result)");
|
|
140
141
|
f.print(" }");
|
|
141
142
|
}
|
|
142
143
|
else if (method.methodKind === MethodKind.ClientStreaming) {
|
|
143
|
-
f.print("Promise<",
|
|
144
|
+
f.print("Promise<", Message, "<", method.output, ">> {");
|
|
144
145
|
f.print(" const result = await this.rpc.clientStreamingRequest(");
|
|
145
146
|
f.print(" this.service,");
|
|
146
147
|
f.print(" ", localName(service), "Definition.methods.", method.name, ".name,");
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { Message, MessageType } from '@aptre/protobuf-es-lite';
|
|
2
|
+
export declare const protobufPackage = "e2e.mock";
|
|
3
3
|
/**
|
|
4
4
|
* MockMsg is the mock message body.
|
|
5
5
|
*
|
|
6
6
|
* @generated from message e2e.mock.MockMsg
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export interface MockMsg extends Message<MockMsg> {
|
|
9
9
|
/**
|
|
10
10
|
* @generated from field: string body = 1;
|
|
11
11
|
*/
|
|
12
|
-
body
|
|
13
|
-
constructor(data?: PartialMessage<MockMsg>);
|
|
14
|
-
static readonly runtime: typeof proto3;
|
|
15
|
-
static readonly typeName = "e2e.mock.MockMsg";
|
|
16
|
-
static readonly fields: FieldList;
|
|
17
|
-
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MockMsg;
|
|
18
|
-
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MockMsg;
|
|
19
|
-
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MockMsg;
|
|
20
|
-
static equals(a: MockMsg | PlainMessage<MockMsg> | undefined, b: MockMsg | PlainMessage<MockMsg> | undefined): boolean;
|
|
12
|
+
body?: string;
|
|
21
13
|
}
|
|
14
|
+
export declare const MockMsg: MessageType<MockMsg>;
|
package/dist/e2e/mock/mock_pb.js
CHANGED
|
@@ -1,36 +1,12 @@
|
|
|
1
|
-
// @generated by protoc-gen-es
|
|
1
|
+
// @generated by protoc-gen-es-lite unknown with parameter "target=ts,ts_nocheck=false"
|
|
2
2
|
// @generated from file github.com/aperturerobotics/starpc/e2e/mock/mock.proto (package e2e.mock, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
export class MockMsg extends Message {
|
|
11
|
-
/**
|
|
12
|
-
* @generated from field: string body = 1;
|
|
13
|
-
*/
|
|
14
|
-
body = '';
|
|
15
|
-
constructor(data) {
|
|
16
|
-
super();
|
|
17
|
-
proto3.util.initPartial(data, this);
|
|
18
|
-
}
|
|
19
|
-
static runtime = proto3;
|
|
20
|
-
static typeName = 'e2e.mock.MockMsg';
|
|
21
|
-
static fields = proto3.util.newFieldList(() => [
|
|
4
|
+
import { createMessageType, } from '@aptre/protobuf-es-lite';
|
|
5
|
+
export const protobufPackage = 'e2e.mock';
|
|
6
|
+
export const MockMsg = createMessageType({
|
|
7
|
+
typeName: 'e2e.mock.MockMsg',
|
|
8
|
+
fields: [
|
|
22
9
|
{ no: 1, name: 'body', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
|
|
23
|
-
]
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
static fromJson(jsonValue, options) {
|
|
28
|
-
return new MockMsg().fromJson(jsonValue, options);
|
|
29
|
-
}
|
|
30
|
-
static fromJsonString(jsonString, options) {
|
|
31
|
-
return new MockMsg().fromJsonString(jsonString, options);
|
|
32
|
-
}
|
|
33
|
-
static equals(a, b) {
|
|
34
|
-
return proto3.util.equals(MockMsg, a, b);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
10
|
+
],
|
|
11
|
+
packedByDefault: true,
|
|
12
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { MockMsg } from
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { ProtoRpc } from
|
|
1
|
+
import { MockMsg } from './mock_pb.js';
|
|
2
|
+
import { MethodKind } from '@bufbuild/protobuf';
|
|
3
|
+
import { Message } from '@aptre/protobuf-es-lite';
|
|
4
|
+
import { ProtoRpc } from 'starpc';
|
|
5
5
|
/**
|
|
6
6
|
* Mock service mocks some RPCs for the e2e tests.
|
|
7
7
|
*
|
|
@@ -17,8 +17,8 @@ export declare const MockDefinition: {
|
|
|
17
17
|
*/
|
|
18
18
|
readonly MockRequest: {
|
|
19
19
|
readonly name: "MockRequest";
|
|
20
|
-
readonly I:
|
|
21
|
-
readonly O:
|
|
20
|
+
readonly I: import("@aptre/protobuf-es-lite").MessageType<MockMsg>;
|
|
21
|
+
readonly O: import("@aptre/protobuf-es-lite").MessageType<MockMsg>;
|
|
22
22
|
readonly kind: MethodKind.Unary;
|
|
23
23
|
};
|
|
24
24
|
};
|
|
@@ -34,7 +34,7 @@ export interface Mock {
|
|
|
34
34
|
*
|
|
35
35
|
* @generated from rpc e2e.mock.Mock.MockRequest
|
|
36
36
|
*/
|
|
37
|
-
MockRequest(request:
|
|
37
|
+
MockRequest(request: Message<MockMsg>, abortSignal?: AbortSignal): Promise<Message<MockMsg>>;
|
|
38
38
|
}
|
|
39
39
|
export declare const MockServiceName: "e2e.mock.Mock";
|
|
40
40
|
export declare class MockClient implements Mock {
|
|
@@ -48,5 +48,5 @@ export declare class MockClient implements Mock {
|
|
|
48
48
|
*
|
|
49
49
|
* @generated from rpc e2e.mock.Mock.MockRequest
|
|
50
50
|
*/
|
|
51
|
-
MockRequest(request:
|
|
51
|
+
MockRequest(request: Message<MockMsg>, abortSignal?: AbortSignal): Promise<Message<MockMsg>>;
|
|
52
52
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// @generated by protoc-gen-es-starpc none with parameter "target=ts,ts_nocheck=false"
|
|
2
2
|
// @generated from file github.com/aperturerobotics/starpc/e2e/mock/mock.proto (package e2e.mock, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
|
-
import { MockMsg } from
|
|
5
|
-
import { MethodKind } from
|
|
4
|
+
import { MockMsg } from './mock_pb.js';
|
|
5
|
+
import { MethodKind } from '@bufbuild/protobuf';
|
|
6
6
|
/**
|
|
7
7
|
* Mock service mocks some RPCs for the e2e tests.
|
|
8
8
|
*
|
|
9
9
|
* @generated from service e2e.mock.Mock
|
|
10
10
|
*/
|
|
11
11
|
export const MockDefinition = {
|
|
12
|
-
typeName:
|
|
12
|
+
typeName: 'e2e.mock.Mock',
|
|
13
13
|
methods: {
|
|
14
14
|
/**
|
|
15
15
|
* MockRequest runs a mock unary request.
|
|
@@ -17,12 +17,12 @@ export const MockDefinition = {
|
|
|
17
17
|
* @generated from rpc e2e.mock.Mock.MockRequest
|
|
18
18
|
*/
|
|
19
19
|
MockRequest: {
|
|
20
|
-
name:
|
|
20
|
+
name: 'MockRequest',
|
|
21
21
|
I: MockMsg,
|
|
22
22
|
O: MockMsg,
|
|
23
23
|
kind: MethodKind.Unary,
|
|
24
24
|
},
|
|
25
|
-
}
|
|
25
|
+
},
|
|
26
26
|
};
|
|
27
27
|
export const MockServiceName = MockDefinition.typeName;
|
|
28
28
|
export class MockClient {
|
|
@@ -39,8 +39,8 @@ export class MockClient {
|
|
|
39
39
|
* @generated from rpc e2e.mock.Mock.MockRequest
|
|
40
40
|
*/
|
|
41
41
|
async MockRequest(request, abortSignal) {
|
|
42
|
-
const requestMsg =
|
|
43
|
-
const result = await this.rpc.request(this.service, MockDefinition.methods.MockRequest.name,
|
|
42
|
+
const requestMsg = MockMsg.create(request);
|
|
43
|
+
const result = await this.rpc.request(this.service, MockDefinition.methods.MockRequest.name, MockMsg.toBinary(requestMsg), abortSignal || undefined);
|
|
44
44
|
return MockMsg.fromBinary(result);
|
|
45
45
|
}
|
|
46
46
|
}
|
package/dist/echo/echo_pb.d.ts
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { Message, MessageType } from '@aptre/protobuf-es-lite';
|
|
2
|
+
export declare const protobufPackage = "echo";
|
|
3
3
|
/**
|
|
4
4
|
* EchoMsg is the message body for Echo.
|
|
5
5
|
*
|
|
6
6
|
* @generated from message echo.EchoMsg
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export interface EchoMsg extends Message<EchoMsg> {
|
|
9
9
|
/**
|
|
10
10
|
* @generated from field: string body = 1;
|
|
11
11
|
*/
|
|
12
|
-
body
|
|
13
|
-
constructor(data?: PartialMessage<EchoMsg>);
|
|
14
|
-
static readonly runtime: typeof proto3;
|
|
15
|
-
static readonly typeName = "echo.EchoMsg";
|
|
16
|
-
static readonly fields: FieldList;
|
|
17
|
-
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EchoMsg;
|
|
18
|
-
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EchoMsg;
|
|
19
|
-
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EchoMsg;
|
|
20
|
-
static equals(a: EchoMsg | PlainMessage<EchoMsg> | undefined, b: EchoMsg | PlainMessage<EchoMsg> | undefined): boolean;
|
|
12
|
+
body?: string;
|
|
21
13
|
}
|
|
14
|
+
export declare const EchoMsg: MessageType<EchoMsg>;
|
package/dist/echo/echo_pb.js
CHANGED
|
@@ -1,36 +1,12 @@
|
|
|
1
|
-
// @generated by protoc-gen-es
|
|
1
|
+
// @generated by protoc-gen-es-lite unknown with parameter "target=ts,ts_nocheck=false"
|
|
2
2
|
// @generated from file github.com/aperturerobotics/starpc/echo/echo.proto (package echo, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
export class EchoMsg extends Message {
|
|
11
|
-
/**
|
|
12
|
-
* @generated from field: string body = 1;
|
|
13
|
-
*/
|
|
14
|
-
body = '';
|
|
15
|
-
constructor(data) {
|
|
16
|
-
super();
|
|
17
|
-
proto3.util.initPartial(data, this);
|
|
18
|
-
}
|
|
19
|
-
static runtime = proto3;
|
|
20
|
-
static typeName = 'echo.EchoMsg';
|
|
21
|
-
static fields = proto3.util.newFieldList(() => [
|
|
4
|
+
import { createMessageType, } from '@aptre/protobuf-es-lite';
|
|
5
|
+
export const protobufPackage = 'echo';
|
|
6
|
+
export const EchoMsg = createMessageType({
|
|
7
|
+
typeName: 'echo.EchoMsg',
|
|
8
|
+
fields: [
|
|
22
9
|
{ no: 1, name: 'body', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
|
|
23
|
-
]
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
static fromJson(jsonValue, options) {
|
|
28
|
-
return new EchoMsg().fromJson(jsonValue, options);
|
|
29
|
-
}
|
|
30
|
-
static fromJsonString(jsonString, options) {
|
|
31
|
-
return new EchoMsg().fromJsonString(jsonString, options);
|
|
32
|
-
}
|
|
33
|
-
static equals(a, b) {
|
|
34
|
-
return proto3.util.equals(EchoMsg, a, b);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
10
|
+
],
|
|
11
|
+
packedByDefault: true,
|
|
12
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EchoMsg } from
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { MessageStream, ProtoRpc } from
|
|
1
|
+
import { EchoMsg } from './echo_pb.js';
|
|
2
|
+
import { MethodKind } from '@bufbuild/protobuf';
|
|
3
|
+
import { RpcStreamPacket } from '../rpcstream/rpcstream_pb.js';
|
|
4
|
+
import { Message } from '@aptre/protobuf-es-lite';
|
|
5
|
+
import { MessageStream, ProtoRpc } from 'starpc';
|
|
6
6
|
/**
|
|
7
7
|
* Echoer service returns the given message.
|
|
8
8
|
*
|
|
@@ -18,8 +18,8 @@ export declare const EchoerDefinition: {
|
|
|
18
18
|
*/
|
|
19
19
|
readonly Echo: {
|
|
20
20
|
readonly name: "Echo";
|
|
21
|
-
readonly I:
|
|
22
|
-
readonly O:
|
|
21
|
+
readonly I: import("@aptre/protobuf-es-lite").MessageType<EchoMsg>;
|
|
22
|
+
readonly O: import("@aptre/protobuf-es-lite").MessageType<EchoMsg>;
|
|
23
23
|
readonly kind: MethodKind.Unary;
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
@@ -29,8 +29,8 @@ export declare const EchoerDefinition: {
|
|
|
29
29
|
*/
|
|
30
30
|
readonly EchoServerStream: {
|
|
31
31
|
readonly name: "EchoServerStream";
|
|
32
|
-
readonly I:
|
|
33
|
-
readonly O:
|
|
32
|
+
readonly I: import("@aptre/protobuf-es-lite").MessageType<EchoMsg>;
|
|
33
|
+
readonly O: import("@aptre/protobuf-es-lite").MessageType<EchoMsg>;
|
|
34
34
|
readonly kind: MethodKind.ServerStreaming;
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
@@ -40,8 +40,8 @@ export declare const EchoerDefinition: {
|
|
|
40
40
|
*/
|
|
41
41
|
readonly EchoClientStream: {
|
|
42
42
|
readonly name: "EchoClientStream";
|
|
43
|
-
readonly I:
|
|
44
|
-
readonly O:
|
|
43
|
+
readonly I: import("@aptre/protobuf-es-lite").MessageType<EchoMsg>;
|
|
44
|
+
readonly O: import("@aptre/protobuf-es-lite").MessageType<EchoMsg>;
|
|
45
45
|
readonly kind: MethodKind.ClientStreaming;
|
|
46
46
|
};
|
|
47
47
|
/**
|
|
@@ -51,8 +51,8 @@ export declare const EchoerDefinition: {
|
|
|
51
51
|
*/
|
|
52
52
|
readonly EchoBidiStream: {
|
|
53
53
|
readonly name: "EchoBidiStream";
|
|
54
|
-
readonly I:
|
|
55
|
-
readonly O:
|
|
54
|
+
readonly I: import("@aptre/protobuf-es-lite").MessageType<EchoMsg>;
|
|
55
|
+
readonly O: import("@aptre/protobuf-es-lite").MessageType<EchoMsg>;
|
|
56
56
|
readonly kind: MethodKind.BiDiStreaming;
|
|
57
57
|
};
|
|
58
58
|
/**
|
|
@@ -62,8 +62,8 @@ export declare const EchoerDefinition: {
|
|
|
62
62
|
*/
|
|
63
63
|
readonly RpcStream: {
|
|
64
64
|
readonly name: "RpcStream";
|
|
65
|
-
readonly I:
|
|
66
|
-
readonly O:
|
|
65
|
+
readonly I: import("@aptre/protobuf-es-lite").MessageType<RpcStreamPacket>;
|
|
66
|
+
readonly O: import("@aptre/protobuf-es-lite").MessageType<RpcStreamPacket>;
|
|
67
67
|
readonly kind: MethodKind.BiDiStreaming;
|
|
68
68
|
};
|
|
69
69
|
};
|
|
@@ -79,19 +79,19 @@ export interface Echoer {
|
|
|
79
79
|
*
|
|
80
80
|
* @generated from rpc echo.Echoer.Echo
|
|
81
81
|
*/
|
|
82
|
-
Echo(request:
|
|
82
|
+
Echo(request: Message<EchoMsg>, abortSignal?: AbortSignal): Promise<Message<EchoMsg>>;
|
|
83
83
|
/**
|
|
84
84
|
* EchoServerStream is an example of a server -> client one-way stream.
|
|
85
85
|
*
|
|
86
86
|
* @generated from rpc echo.Echoer.EchoServerStream
|
|
87
87
|
*/
|
|
88
|
-
EchoServerStream(request:
|
|
88
|
+
EchoServerStream(request: Message<EchoMsg>, abortSignal?: AbortSignal): MessageStream<EchoMsg>;
|
|
89
89
|
/**
|
|
90
90
|
* EchoClientStream is an example of client->server one-way stream.
|
|
91
91
|
*
|
|
92
92
|
* @generated from rpc echo.Echoer.EchoClientStream
|
|
93
93
|
*/
|
|
94
|
-
EchoClientStream(request: MessageStream<EchoMsg>, abortSignal?: AbortSignal): Promise<
|
|
94
|
+
EchoClientStream(request: MessageStream<EchoMsg>, abortSignal?: AbortSignal): Promise<Message<EchoMsg>>;
|
|
95
95
|
/**
|
|
96
96
|
* EchoBidiStream is an example of a two-way stream.
|
|
97
97
|
*
|
|
@@ -117,19 +117,19 @@ export declare class EchoerClient implements Echoer {
|
|
|
117
117
|
*
|
|
118
118
|
* @generated from rpc echo.Echoer.Echo
|
|
119
119
|
*/
|
|
120
|
-
Echo(request:
|
|
120
|
+
Echo(request: Message<EchoMsg>, abortSignal?: AbortSignal): Promise<Message<EchoMsg>>;
|
|
121
121
|
/**
|
|
122
122
|
* EchoServerStream is an example of a server -> client one-way stream.
|
|
123
123
|
*
|
|
124
124
|
* @generated from rpc echo.Echoer.EchoServerStream
|
|
125
125
|
*/
|
|
126
|
-
EchoServerStream(request:
|
|
126
|
+
EchoServerStream(request: Message<EchoMsg>, abortSignal?: AbortSignal): MessageStream<EchoMsg>;
|
|
127
127
|
/**
|
|
128
128
|
* EchoClientStream is an example of client->server one-way stream.
|
|
129
129
|
*
|
|
130
130
|
* @generated from rpc echo.Echoer.EchoClientStream
|
|
131
131
|
*/
|
|
132
|
-
EchoClientStream(request: MessageStream<EchoMsg>, abortSignal?: AbortSignal): Promise<
|
|
132
|
+
EchoClientStream(request: MessageStream<EchoMsg>, abortSignal?: AbortSignal): Promise<Message<EchoMsg>>;
|
|
133
133
|
/**
|
|
134
134
|
* EchoBidiStream is an example of a two-way stream.
|
|
135
135
|
*
|