Skip to content

Commit f4cfa42

Browse files
committed
Update dependencies in compiler-rs (#2878)
1 parent 3461525 commit f4cfa42

File tree

21 files changed

+94645
-93137
lines changed

21 files changed

+94645
-93137
lines changed

compiler-rs/Cargo.lock

Lines changed: 186 additions & 165 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler-rs/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,30 @@ members = [
77
"compiler-wasm-lib",
88
]
99

10+
[workspace.dependencies]
11+
anyhow = "1"
12+
arcstr = "1"
13+
clap = "4"
14+
console_error_panic_hook = "0.1"
15+
convert_case = "0.6"
16+
derive_more = "1.0.0-beta.6"
17+
either_n = "0.2"
18+
icu_segmenter = "1"
19+
indexmap = "2"
20+
maplit = "1"
21+
once_cell = "1.16"
22+
openapiv3 = "2"
23+
quantiles = "0.7"
24+
serde = "1"
25+
serde_ignored = "0.1"
26+
serde_json = "1"
27+
serde_path_to_error = "0.1"
28+
testresult = "0.4"
29+
tracing = "0.1"
30+
tracing-subscriber = "0.3"
31+
wasm-bindgen = "0.2"
32+
wasm-bindgen-test = "0.3"
33+
1034
[profile.release]
1135
lto = true
1236
# Tell `rustc` to optimize for small code size.

compiler-rs/clients_schema/Cargo.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ edition = "2021"
55
publish = false
66

77
[dependencies]
8-
derive_more = { version = "1.0.0-beta.6", features = ["from"] }
9-
serde = { version = "1.0", features=["derive", 'rc']}
10-
serde_json = "1.0"
11-
typed-builder = "0.11"
12-
once_cell = "1.16"
13-
anyhow = "1.0"
14-
indexmap = { version="1.9.3", features = ["serde"] }
8+
derive_more = { workspace = true, features = ["from"] }
9+
serde = { workspace = true, features = ["derive", "rc"] }
10+
serde_json = { workspace = true }
11+
once_cell = { workspace = true }
12+
anyhow = { workspace = true }
13+
indexmap = { workspace = true, features = ["serde"] }
1514

16-
arcstr = { version = "1.1.5", features = ["serde", "substr"] }
15+
arcstr = { workspace = true, features = ["serde", "substr"] }
16+
clap = { workspace = true, features = ["derive"] }
1717

1818
[dev-dependencies]
19-
serde_path_to_error = "0.1"
20-
serde_ignored = "0.1"
21-
testresult = "0.3.0"
19+
serde_path_to_error = { workspace = true }
20+
serde_ignored = { workspace = true }
21+
testresult = { workspace = true }
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// Licensed to Elasticsearch B.V. under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. Elasticsearch B.V. licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
use std::path::{Path, PathBuf};
19+
20+
use clap::Parser;
21+
22+
use clients_schema::{Availabilities, Flavor, Visibility};
23+
24+
fn main() -> anyhow::Result<()> {
25+
let cli = Cli::parse();
26+
27+
cli.run()?;
28+
29+
Ok(())
30+
}
31+
32+
impl Cli {
33+
fn run(self) -> anyhow::Result<()> {
34+
let json = if self.schema == Path::new("-") {
35+
std::io::read_to_string(std::io::stdin())?
36+
} else {
37+
std::fs::read_to_string(self.schema)?
38+
};
39+
40+
let mut schema = clients_schema::IndexedModel::from_reader(json.as_bytes())?;
41+
42+
let filter: fn(&Option<Availabilities>) -> bool = match self.flavor {
43+
Flavor::Stack => |a| {
44+
Flavor::Stack.available(a)
45+
},
46+
Flavor::Serverless => |a| {
47+
Flavor::Serverless.visibility(a) == Some(Visibility::Public)
48+
}
49+
};
50+
51+
schema = clients_schema::transform::filter_availability(schema, filter)?;
52+
53+
let output: Box<dyn std::io::Write> = {
54+
if let Some(output) = self.output {
55+
if output == Path::new("-") {
56+
Box::new(std::io::stdout())
57+
} else {
58+
Box::new(std::fs::File::create(output)?)
59+
}
60+
} else {
61+
Box::new(std::io::stdout())
62+
}
63+
};
64+
let output = std::io::BufWriter::new(output);
65+
serde_json::to_writer_pretty(output, &schema).expect("TODO: panic message");
66+
67+
Ok(())
68+
}
69+
}
70+
71+
72+
#[derive(Debug, Parser)]
73+
#[command(author, version, about, long_about)]
74+
pub struct Cli {
75+
/// input schema file, eg: ../output/schema/schema-no-generics.json
76+
schema: PathBuf,
77+
/// filter flavor, eg: stack
78+
flavor: Flavor,
79+
/// default is stdout
80+
#[arg(long)]
81+
output: Option<PathBuf>,
82+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Licensed to Elasticsearch B.V. under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. Elasticsearch B.V. licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
use std::path::{Path, PathBuf};
19+
20+
use clap::Parser;
21+
22+
use clients_schema::transform::ExpandConfig;
23+
24+
fn main() -> anyhow::Result<()> {
25+
let cli = Cli::parse();
26+
27+
cli.run()?;
28+
29+
Ok(())
30+
}
31+
32+
impl Cli {
33+
fn run(self) -> anyhow::Result<()> {
34+
let json = if self.schema == Path::new("-") {
35+
std::io::read_to_string(std::io::stdin())?
36+
} else {
37+
std::fs::read_to_string(self.schema)?
38+
};
39+
40+
let mut schema = clients_schema::IndexedModel::from_reader(json.as_bytes())?;
41+
schema = clients_schema::transform::expand_generics(schema, ExpandConfig::default())?;
42+
43+
let output: Box<dyn std::io::Write> = {
44+
if let Some(output) = self.output {
45+
if output == Path::new("-") {
46+
Box::new(std::io::stdout())
47+
} else {
48+
Box::new(std::fs::File::create(output)?)
49+
}
50+
} else {
51+
Box::new(std::io::stdout())
52+
}
53+
};
54+
let output = std::io::BufWriter::new(output);
55+
serde_json::to_writer_pretty(output, &schema).expect("TODO: panic message");
56+
57+
Ok(())
58+
}
59+
}
60+
61+
62+
#[derive(Debug, Parser)]
63+
#[command(author, version, about, long_about = None)]
64+
pub struct Cli {
65+
/// input schema file, eg: ../output/schema/schema-no-generics.json
66+
schema: PathBuf,
67+
/// default is stdout
68+
output: Option<PathBuf>,
69+
}

compiler-rs/clients_schema/src/lib.rs

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ use std::fmt::{Debug, Display, Formatter};
2020
use anyhow::anyhow;
2121
use derive_more::From;
2222
use indexmap::IndexMap;
23+
2324
// Re-export crates whose types we expose publicly
24-
pub use once_cell;
25+
pub use ::once_cell;
26+
pub use ::indexmap;
27+
pub use ::anyhow;
2528

2629
// Child modules
2730
pub mod builtins;
@@ -50,7 +53,6 @@ pub trait Documented {
5053
fn doc_url(&self) -> Option<&str>;
5154
fn doc_id(&self) -> Option<&str>;
5255
fn description(&self) -> Option<&str>;
53-
fn since(&self) -> Option<&str>;
5456
}
5557

5658
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -241,7 +243,7 @@ pub struct Deprecation {
241243
}
242244

243245
/// An API flavor
244-
#[derive(Debug, Clone, Serialize, Deserialize, Hash, PartialEq, Eq)]
246+
#[derive(Debug, Clone, Serialize, Deserialize, Hash, PartialEq, Eq, clap::ValueEnum)]
245247
#[serde(rename_all = "snake_case")]
246248
pub enum Flavor {
247249
Stack,
@@ -252,9 +254,9 @@ pub enum Flavor {
252254
#[derive(Debug, Clone, Serialize, Deserialize)]
253255
#[serde(rename_all = "camelCase")]
254256
pub struct Availability {
255-
since: Option<String>,
256-
stability: Option<Stability>,
257-
visibility: Option<Visibility>,
257+
pub since: Option<String>,
258+
pub stability: Option<Stability>,
259+
pub visibility: Option<Visibility>,
258260
}
259261

260262
/// The availability of an
@@ -312,9 +314,6 @@ pub struct Property {
312314
#[serde(skip_serializing_if = "Option::is_none")]
313315
pub doc_id: Option<String>,
314316

315-
#[serde(skip_serializing_if = "Option::is_none")]
316-
pub since: Option<String>,
317-
318317
#[serde(skip_serializing_if = "Option::is_none")]
319318
pub server_default: Option<ServerDefault>,
320319

@@ -324,9 +323,6 @@ pub struct Property {
324323
#[serde(skip_serializing_if = "Option::is_none")]
325324
pub availability: Option<Availabilities>,
326325

327-
#[serde(skip_serializing_if = "Option::is_none")]
328-
pub stability: Option<Stability>,
329-
330326
/// If specified takes precedence over `name` when generating code. `name` is always the value
331327
/// to be sent over the wire
332328
#[serde(skip_serializing_if = "Option::is_none")]
@@ -357,10 +353,6 @@ impl Documented for Property {
357353
fn description(&self) -> Option<&str> {
358354
self.description.as_deref()
359355
}
360-
361-
fn since(&self) -> Option<&str> {
362-
self.since.as_deref()
363-
}
364356
}
365357

366358
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -536,10 +528,6 @@ impl Documented for BaseType {
536528
fn description(&self) -> Option<&str> {
537529
self.description.as_deref()
538530
}
539-
540-
fn since(&self) -> Option<&str> {
541-
None
542-
}
543531
}
544532

545533
trait WithBaseType {
@@ -558,10 +546,6 @@ impl<T: WithBaseType> Documented for T {
558546
fn description(&self) -> Option<&str> {
559547
self.base().description()
560548
}
561-
562-
fn since(&self) -> Option<&str> {
563-
self.base().since()
564-
}
565549
}
566550

567551
/// An interface type
@@ -843,20 +827,6 @@ pub struct Endpoint {
843827

844828
pub urls: Vec<UrlTemplate>,
845829

846-
/// The version when this endpoint reached its current stability level.
847-
/// Missing data means "forever", i.e. before any of the target client versions produced from this spec.
848-
#[serde(skip_serializing_if = "Option::is_none")]
849-
pub since: Option<String>,
850-
851-
#[serde(skip_serializing_if = "Option::is_none")]
852-
pub stability: Option<Stability>,
853-
854-
#[serde(skip_serializing_if = "Option::is_none")]
855-
pub visibility: Option<Visibility>,
856-
857-
#[serde(skip_serializing_if = "Option::is_none")]
858-
pub feature_flag: Option<String>,
859-
860830
#[serde(default, skip_serializing_if = "Vec::is_empty")]
861831
pub request_media_type: Vec<String>,
862832

@@ -879,10 +849,6 @@ impl Documented for Endpoint {
879849
fn description(&self) -> Option<&str> {
880850
Some(self.description.as_str())
881851
}
882-
883-
fn since(&self) -> Option<&str> {
884-
self.since.as_deref()
885-
}
886852
}
887853

888854
#[derive(Debug, Clone, Serialize, Deserialize)]

compiler-rs/clients_schema_to_openapi/Cargo.toml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,14 @@ publish = false
77
[dependencies]
88
clients_schema = {path="../clients_schema"}
99

10-
serde = {version = "1.0", features=["derive"]}
11-
serde_json = "1.0"
12-
serde_path_to_error = "0.1"
13-
serde_ignored = "0.1"
14-
icu_segmenter = "1.5.0"
15-
openapiv3 = "1.0"
16-
anyhow = "1.0"
17-
indexmap = "1.9"
18-
convert_case = "0.6"
19-
either_n = "0.2.0"
20-
maplit = "1.0"
10+
serde_json = { workspace = true }
11+
serde_ignored = { workspace = true }
12+
icu_segmenter = { workspace = true }
13+
openapiv3 = { workspace = true }
14+
anyhow = { workspace = true }
15+
indexmap = { workspace = true }
2116

22-
tracing = "0.1.37"
23-
tracing-subscriber = "0.3.16"
24-
clap = { version = "4.4.2", features = ["derive"] }
17+
tracing = { workspace = true }
18+
tracing-subscriber = { workspace = true }
19+
clap = { workspace = true, features = ["derive"] }
2520

26-
27-
quantiles = "0.7.1"

0 commit comments

Comments
 (0)