Skip to content

Commit 19cab48

Browse files
Update a way to generate *.ts files based on protobuf scheme
1 parent 1c7f47a commit 19cab48

File tree

131 files changed

+1935
-1237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+1935
-1237
lines changed

application/apps/protocol/binding/proto/Cargo.lock

+97-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

application/apps/protocol/binding/proto/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77
prost = "0.13"
88
prost-types = "0.13"
99
serde = { version = "1.0", features = ["derive"] }
10-
ts-rs = "9.0.1"
10+
tslink = "0.2"
1111

1212
[build-dependencies]
13-
prost-build = "0.13"
13+
prost-build = "0.13"

application/apps/protocol/binding/proto/build.rs

+17-6
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,22 @@ fn main() {
1818
}
1919
})
2020
.collect();
21-
prost_build::Config::new()
22-
.type_attribute(
23-
".",
24-
"#[derive(serde::Serialize, serde::Deserialize, ts_rs::TS)]#[ts(export)]",
25-
)
26-
.compile_protos(&protos, &[PROTO_SRC])
21+
let binding = prost_build::Config::new();
22+
let mut cfg = binding;
23+
cfg.type_attribute(".", r#"#[derive(serde::Serialize, serde::Deserialize)]"#);
24+
for proto in protos.iter() {
25+
let file_name = proto
26+
.file_stem()
27+
.expect("Proto file has filename")
28+
.to_str()
29+
.expect("File name is valid UTF8");
30+
cfg.type_attribute(
31+
format!(".{file_name}"),
32+
format!(
33+
"#[tslink::tslink(target = \"./output/{file_name}.ts\", module = \"{file_name}\")]"
34+
),
35+
);
36+
}
37+
cfg.compile_protos(&protos, &[PROTO_SRC])
2738
.expect("Fail to compile protos");
2839
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export interface AttachmentInfoList {
2+
elements: AttachmentInfo[];
3+
}
4+
export interface AttachmentInfo {
5+
uuid: string;
6+
filepath: string;
7+
name: string;
8+
ext: string;
9+
size: number;
10+
mime: string;
11+
messages: number[];
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
export interface StringVec {
2+
values: string[];
3+
}
4+
export interface CommandOutcome {
5+
outcome_oneof: OutcomeOneof | null;
6+
}
7+
export interface OutcomeOneof {
8+
Finished?: Finished;
9+
Cancelled?: Cancelled;
10+
}
11+
export interface OutputOneof {
12+
StringValue?: string;
13+
StringVecValue?: StringVec;
14+
OptionStringValue?: string;
15+
BoolValue?: boolean;
16+
Int64Value?: number;
17+
EmptyValue?: Empty;
18+
}
19+
export interface Output {
20+
output_oneof: OutputOneof | null;
21+
}
22+
export interface Cancelled {
23+
}
24+
export interface Finished {
25+
result: Output | null;
26+
}
27+
export interface Empty {
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export interface RangeInclusive {
2+
start: number;
3+
end: number;
4+
}
5+
export interface Range {
6+
start: number;
7+
end: number;
8+
}
9+
export interface RangeInclusiveList {
10+
elements: RangeInclusive[];
11+
}

0 commit comments

Comments
 (0)