Skip to content

Commit

Permalink
Update dependencies in compiler-rs (#2878)
Browse files Browse the repository at this point in the history
  • Loading branch information
swallez authored Sep 9, 2024
1 parent 7f78698 commit b2ad226
Show file tree
Hide file tree
Showing 16 changed files with 93,524 additions and 93,491 deletions.
342 changes: 181 additions & 161 deletions compiler-rs/Cargo.lock

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions compiler-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@ members = [
"compiler-wasm-lib",
]

[workspace.dependencies]
anyhow = "1"
arcstr = "1"
clap = "4"
console_error_panic_hook = "0.1"
convert_case = "0.6"
derive_more = "1.0.0-beta.6"
either_n = "0.2"
icu_segmenter = "1"
indexmap = "2"
maplit = "1"
once_cell = "1.16"
openapiv3 = "2"
quantiles = "0.7"
serde = "1"
serde_ignored = "0.1"
serde_json = "1"
serde_path_to_error = "0.1"
testresult = "0.4"
tracing = "0.1"
tracing-subscriber = "0.3"
wasm-bindgen = "0.2"
wasm-bindgen-test = "0.3"

[profile.release]
lto = true
# Tell `rustc` to optimize for small code size.
Expand Down
23 changes: 11 additions & 12 deletions compiler-rs/clients_schema/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ edition = "2021"
publish = false

[dependencies]
derive_more = { version = "1.0.0-beta.6", features = ["from"] }
serde = { version = "1.0", features=["derive", 'rc']}
serde_json = "1.0"
typed-builder = "0.11"
once_cell = "1.16"
anyhow = "1.0"
indexmap = { version="1.9.3", features = ["serde"] }
derive_more = { workspace = true, features = ["from"] }
serde = { workspace = true, features = ["derive", "rc"] }
serde_json = { workspace = true }
once_cell = { workspace = true }
anyhow = { workspace = true }
indexmap = { workspace = true, features = ["serde"] }

arcstr = { version = "1.1.5", features = ["serde", "substr"] }
clap = { version = "4.5.9", features = ["derive"] }
arcstr = { workspace = true, features = ["serde", "substr"] }
clap = { workspace = true, features = ["derive"] }

[dev-dependencies]
serde_path_to_error = "0.1"
serde_ignored = "0.1"
testresult = "0.3.0"
serde_path_to_error = { workspace = true }
serde_ignored = { workspace = true }
testresult = { workspace = true }
5 changes: 4 additions & 1 deletion compiler-rs/clients_schema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ use std::fmt::{Debug, Display, Formatter};
use anyhow::anyhow;
use derive_more::From;
use indexmap::IndexMap;

// Re-export crates whose types we expose publicly
pub use once_cell;
pub use ::once_cell;
pub use ::indexmap;
pub use ::anyhow;

// Child modules
pub mod builtins;
Expand Down
25 changes: 9 additions & 16 deletions compiler-rs/clients_schema_to_openapi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,14 @@ publish = false
[dependencies]
clients_schema = {path="../clients_schema"}

serde = {version = "1.0", features=["derive"]}
serde_json = "1.0"
serde_path_to_error = "0.1"
serde_ignored = "0.1"
icu_segmenter = "1.5.0"
openapiv3 = "1.0"
anyhow = "1.0"
indexmap = "1.9"
convert_case = "0.6"
either_n = "0.2.0"
maplit = "1.0"
serde_json = { workspace = true }
serde_ignored = { workspace = true }
icu_segmenter = { workspace = true }
openapiv3 = { workspace = true }
anyhow = { workspace = true }
indexmap = { workspace = true }

tracing = "0.1.37"
tracing-subscriber = "0.3.16"
clap = { version = "4.4.2", features = ["derive"] }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
clap = { workspace = true, features = ["derive"] }


quantiles = "0.7.1"
3 changes: 2 additions & 1 deletion compiler-rs/clients_schema_to_openapi/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ pub fn add_endpoint(
responses: responses.clone(),
extensions: Default::default(),
},
callbacks: Default::default(),
deprecated: endpoint.deprecation.is_some(),
security: None,
servers: vec![],
Expand Down Expand Up @@ -317,7 +318,7 @@ fn get_path_parameters(template: &str) -> Vec<&str> {

// Splits the original endpoint description into OpenAPI summary and description, where summary
// is the first sentence of the original description with no trailing `.`, and description contains
// the remaining sentences, if there are any left.
// the remaining sentences, if there are any left.
fn split_summary_desc(desc: &str) -> SplitDesc{
let segmenter = SentenceSegmenter::new();

Expand Down
2 changes: 1 addition & 1 deletion compiler-rs/clients_schema_to_openapi/src/schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl<'a> TypesAndComponents<'a> {
max_length: None,
})
.into_schema_ref()),
"boolean" => Ok(Type::Boolean {}.into_schema_ref()),
"boolean" => Ok(Type::Boolean(Default::default()).into_schema_ref()),
"number" => Ok(Type::Number(NumberType::default()).into_schema_ref()),
"void" => {
// Empty object
Expand Down
12 changes: 6 additions & 6 deletions compiler-rs/compiler-wasm-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "compiler-wasm-lib"
version = "0.1.0"
edition = "2021"
description = "WASM library to manipulate and convert schema.json files"
publish = false

[lib]
crate-type = ["cdylib", "rlib"]
Expand All @@ -11,17 +12,16 @@ crate-type = ["cdylib", "rlib"]
default = ["console_error_panic_hook"]

[dependencies]
wasm-bindgen = "0.2.87"
wasm-bindgen = { workspace = true }
clients_schema = {path="../clients_schema"}
clients_schema_to_openapi = {path="../clients_schema_to_openapi"}
serde_json = "1.0.107"
anyhow = "1.0.75"
serde_json = { workspace = true }
anyhow = { workspace = true }

console_error_panic_hook = { version = "0.1.7", optional = true }
web-sys = { version = "0.3.64", features = ["console"] }
console_error_panic_hook = { workspace = true, optional = true }

[dev-dependencies]
wasm-bindgen-test = "0.3.37"
wasm-bindgen-test = { workspace = true }

[package.metadata.wasm-pack.profile.release]
opt-level = 'z'
Expand Down
41 changes: 21 additions & 20 deletions compiler-rs/compiler-wasm-lib/pkg/compiler_wasm_lib.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

let imports = {};
imports['__wbindgen_placeholder__'] = module.exports;
let wasm;
Expand All @@ -7,18 +8,18 @@ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true

cachedTextDecoder.decode();

let cachedUint8Memory0 = null;
let cachedUint8ArrayMemory0 = null;

function getUint8Memory0() {
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8Memory0;
return cachedUint8ArrayMemory0;
}

function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}

const heap = new Array(128).fill(undefined);
Expand Down Expand Up @@ -72,15 +73,15 @@ function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}

let len = arg.length;
let ptr = malloc(len, 1) >>> 0;

const mem = getUint8Memory0();
const mem = getUint8ArrayMemory0();

let offset = 0;

Expand All @@ -95,7 +96,7 @@ function passStringToWasm0(arg, malloc, realloc) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);

offset += ret.written;
Expand All @@ -106,13 +107,13 @@ function passStringToWasm0(arg, malloc, realloc) {
return ptr;
}

let cachedInt32Memory0 = null;
let cachedDataViewMemory0 = null;

function getInt32Memory0() {
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
function getDataViewMemory0() {
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
}
return cachedInt32Memory0;
return cachedDataViewMemory0;
}
/**
* @param {string} json
Expand All @@ -129,10 +130,10 @@ module.exports.convert_schema_to_openapi = function(json, flavor) {
const ptr1 = passStringToWasm0(flavor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len1 = WASM_VECTOR_LEN;
wasm.convert_schema_to_openapi(retptr, ptr0, len0, ptr1, len1);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var r2 = getInt32Memory0()[retptr / 4 + 2];
var r3 = getInt32Memory0()[retptr / 4 + 3];
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
var ptr3 = r0;
var len3 = r1;
if (r3) {
Expand Down Expand Up @@ -162,8 +163,8 @@ module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
const ret = getObject(arg1).stack;
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len1 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len1;
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
};

module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
Expand Down
Binary file modified compiler-rs/compiler-wasm-lib/pkg/compiler_wasm_lib_bg.wasm
Binary file not shown.
3 changes: 0 additions & 3 deletions compiler-rs/compiler-wasm-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ use clients_schema::{Availabilities, Visibility};
use wasm_bindgen::prelude::*;
use clients_schema::transform::ExpandConfig;

#[cfg(all(not(target_arch = "wasm32"), not(feature = "cargo-clippy")))]
compile_error!("To build this crate use `make compiler-wasm-lib`");

#[wasm_bindgen]
pub fn convert_schema_to_openapi(json: &str, flavor: &str) -> Result<String, String> {
set_panic_hook();
Expand Down
19 changes: 8 additions & 11 deletions compiler-rs/openapi_to_clients_schema/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@ publish = false
[dependencies]
clients_schema = {path="../clients_schema"}

serde = {version = "1.0", features=["derive"]}
serde_json = "1.0"
serde_path_to_error = "0.1"
serde_ignored = "0.1"
openapiv3 = "1.0"
anyhow = "1.0"
indexmap = "1.9"
convert_case = "0.6"
either_n = "0.2.0"
serde_json = { workspace = true }
serde_ignored = { workspace = true }
openapiv3 = { workspace = true }
anyhow = { workspace = true }
indexmap = { workspace = true }
convert_case = { workspace = true }

tracing = "0.1.37"
tracing-subscriber = "0.3.16"
tracing = { workspace = true }
tracing-subscriber = { workspace = true }

# Some json schema implementations
#boon = "0.3.1"
Expand Down
2 changes: 1 addition & 1 deletion compiler-rs/openapi_to_clients_schema/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ pub fn any_to_schema(any: AnySchema) -> anyhow::Result<SchemaKind> {
enumeration: vec![], // TODO: not supported in schema.json
}))),

"boolean" => Ok(SchemaKind::Type(Type::Boolean {})),
"boolean" => Ok(SchemaKind::Type(Type::Boolean(Default::default()))),

"array" => Ok(SchemaKind::Type(Type::Array(ArrayType {
items: any.items,
Expand Down
6 changes: 2 additions & 4 deletions compiler-rs/openapi_to_clients_schema/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ fn generate_schema_kind_type(
String(_) => types.add(id, alias(base, builtins::STRING.clone())),

//---------------------------------------------------------------------
Boolean {} => types.add(id, alias(base, builtins::BOOLEAN.clone())),
Boolean(_) => types.add(id, alias(base, builtins::BOOLEAN.clone())),

//---------------------------------------------------------------------
Integer(_) =>
Expand Down Expand Up @@ -323,7 +323,7 @@ fn generate_schema_kind_one_of(
let mut variants: Option<TypeAliasVariants> = None;

// TODO: do we want to allow untagged unions (those that are disambiguated by inspecting property names)?

if let Some(discriminator) = discriminator {
variants = Some(TypeAliasVariants::InternalTag(InternalTag {
default_tag: None,
Expand Down Expand Up @@ -406,8 +406,6 @@ fn generate_interface_def(
description: None,
aliases: Vec::default(),
deprecation: None,
stability: None,
since: None,
container_property: false,
es_quirk: None,
server_default: None,
Expand Down
Loading

0 comments on commit b2ad226

Please sign in to comment.