@typespec/protobuf 0.82.0-dev.0 → 0.82.0-dev.2
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/dist/src/ast.d.ts +4 -0
- package/dist/src/ast.d.ts.map +1 -1
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/lib.d.ts +19 -1
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +12 -0
- package/dist/src/lib.js.map +1 -1
- package/dist/src/transform/index.js +33 -0
- package/dist/src/transform/index.js.map +1 -1
- package/dist/src/write.js +1 -1
- package/dist/src/write.js.map +1 -1
- package/package.json +10 -11
- package/src/ast.ts +4 -0
- package/src/lib.ts +14 -0
- package/src/transform/index.ts +37 -0
- package/src/write.ts +1 -1
- package/temp/tsconfig.tsbuildinfo +1 -1
- package/test/scenarios/optional/input/main.tsp +31 -0
- package/test/scenarios/optional/output/@typespec/protobuf/main.proto +27 -0
- package/test/scenarios/optional-lossy/diagnostics.txt +2 -0
- package/test/scenarios/optional-lossy/input/main.tsp +20 -0
- package/test/scenarios/optional-lossy/output/@typespec/protobuf/main.proto +16 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using Protobuf;
|
|
4
|
+
|
|
5
|
+
@package
|
|
6
|
+
namespace Test;
|
|
7
|
+
|
|
8
|
+
@Protobuf.service
|
|
9
|
+
interface Service {
|
|
10
|
+
foo(...Input): Output;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
enum Status {
|
|
14
|
+
Unknown: 0,
|
|
15
|
+
Ready: 1,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
model Input {
|
|
19
|
+
@field(1) id: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
model Details {
|
|
23
|
+
@field(1) note: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
model Output {
|
|
27
|
+
@field(1) count?: int32;
|
|
28
|
+
@field(2) name?: string;
|
|
29
|
+
@field(3) status?: Status;
|
|
30
|
+
@field(4) details?: Details;
|
|
31
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Generated by Microsoft TypeSpec
|
|
2
|
+
|
|
3
|
+
syntax = "proto3";
|
|
4
|
+
|
|
5
|
+
message Input {
|
|
6
|
+
string id = 1;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
enum Status {
|
|
10
|
+
Unknown = 0;
|
|
11
|
+
Ready = 1;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
message Details {
|
|
15
|
+
string note = 1;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
message Output {
|
|
19
|
+
optional int32 count = 1;
|
|
20
|
+
optional string name = 2;
|
|
21
|
+
optional Status status = 3;
|
|
22
|
+
Details details = 4;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
service Service {
|
|
26
|
+
rpc Foo(Input) returns (Output);
|
|
27
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/test/main.tsp:18:13 - warning @typespec/protobuf/optional-array-field: optional array fields cannot preserve unset versus empty in protobuf; emitting a repeated field without the 'optional' label
|
|
2
|
+
/test/main.tsp:19:13 - warning @typespec/protobuf/optional-map-field: optional map fields cannot preserve unset versus empty in protobuf; emitting a map field without the 'optional' label
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using Protobuf;
|
|
4
|
+
|
|
5
|
+
@package
|
|
6
|
+
namespace Test;
|
|
7
|
+
|
|
8
|
+
@Protobuf.service
|
|
9
|
+
interface Service {
|
|
10
|
+
foo(...Input): Output;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
model Input {
|
|
14
|
+
@field(1) id: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
model Output {
|
|
18
|
+
@field(1) tags?: string[];
|
|
19
|
+
@field(2) counters?: Map<sfixed32, string>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Generated by Microsoft TypeSpec
|
|
2
|
+
|
|
3
|
+
syntax = "proto3";
|
|
4
|
+
|
|
5
|
+
message Input {
|
|
6
|
+
string id = 1;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
message Output {
|
|
10
|
+
repeated string tags = 1;
|
|
11
|
+
map<sfixed32, string> counters = 2;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
service Service {
|
|
15
|
+
rpc Foo(Input) returns (Output);
|
|
16
|
+
}
|