From b7c48a40b218b5ddcbf7fe7d528c3a9673360ca4 Mon Sep 17 00:00:00 2001 From: Shashi Kant Date: Tue, 16 Apr 2024 05:17:24 +0000 Subject: [PATCH] fix(grpc): invalid type names for generated configurations from proto files (#1682) Co-authored-by: Tushar Mathur --- Cargo.lock | 488 +++++++++--------- src/config/config.rs | 41 +- src/generator/from_proto.rs | 366 ++++--------- src/generator/generator.rs | 2 +- src/generator/graphql_type.rs | 260 ++++++++++ src/generator/mod.rs | 3 +- src/generator/proto/greetings.proto | 7 + src/generator/proto/greetings_message.proto | 11 + ...nerator__from_proto__test__from_proto.snap | 69 +-- ...m_proto__test__from_proto_no_pkg_file.snap | 10 +- ...rom_proto__test__greetings_proto_file.snap | 19 + ...tor__from_proto__test__required_types.snap | 18 +- 12 files changed, 724 insertions(+), 570 deletions(-) create mode 100644 src/generator/graphql_type.rs create mode 100644 src/generator/proto/greetings.proto create mode 100644 src/generator/proto/greetings_message.proto create mode 100644 src/generator/snapshots/tailcall__generator__from_proto__test__greetings_proto_file.snap diff --git a/Cargo.lock b/Cargo.lock index 1b5d6e8a84..4e2db36004 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -58,18 +58,18 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "android-tzdata" @@ -200,28 +200,27 @@ dependencies = [ [[package]] name = "async-channel" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" +checksum = "136d4d23bcc79e27423727b36823d86233aad06dfea531837b038394d11e9928" dependencies = [ "concurrent-queue", "event-listener 5.3.0", - "event-listener-strategy 0.5.0", + "event-listener-strategy 0.5.1", "futures-core", "pin-project-lite", ] [[package]] name = "async-executor" -version = "1.8.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" +checksum = "b10202063978b3351199d68f8b22c4e47e4b1b822f8d43fd862d5ea8c006b29a" dependencies = [ - "async-lock 3.3.0", "async-task", "concurrent-queue", - "fastrand 2.0.1", - "futures-lite 2.2.0", + "fastrand 2.0.2", + "futures-lite 2.3.0", "slab", ] @@ -231,12 +230,12 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" dependencies = [ - "async-channel 2.2.0", + "async-channel 2.2.1", "async-executor", "async-io 2.3.2", "async-lock 3.3.0", "blocking", - "futures-lite 2.2.0", + "futures-lite 2.3.0", "once_cell", "tokio", ] @@ -262,7 +261,7 @@ dependencies = [ "futures-util", "handlebars", "http 1.1.0", - "indexmap 2.2.5", + "indexmap 2.2.6", "lru 0.7.8", "mime", "multer", @@ -292,7 +291,7 @@ dependencies = [ "proc-macro2", "quote", "strum 0.26.2", - "syn 2.0.52", + "syn 2.0.59", "thiserror", ] @@ -347,7 +346,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68e40849c29a39012d38bff87bfed431f1ed6c53fbec493294c1045d61a7ae75" dependencies = [ "bytes", - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", "serde_json", ] @@ -382,10 +381,10 @@ dependencies = [ "cfg-if", "concurrent-queue", "futures-io", - "futures-lite 2.2.0", + "futures-lite 2.3.0", "parking", - "polling 3.5.0", - "rustix 0.38.31", + "polling 3.6.0", + "rustix 0.38.32", "slab", "tracing", "windows-sys 0.52.0", @@ -433,7 +432,7 @@ dependencies = [ "cfg-if", "event-listener 3.1.0", "futures-lite 1.13.0", - "rustix 0.38.31", + "rustix 0.38.32", "windows-sys 0.48.0", ] @@ -445,7 +444,7 @@ checksum = "30c5ef0ede93efbf733c1a727f3b6b5a1060bbedd5600183e66f6e4be4af0ec5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -460,7 +459,7 @@ dependencies = [ "cfg-if", "futures-core", "futures-io", - "rustix 0.38.31", + "rustix 0.38.32", "signal-hook-registry", "slab", "windows-sys 0.48.0", @@ -513,7 +512,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -530,7 +529,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -541,9 +540,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "aws_lambda_events" @@ -555,7 +554,7 @@ dependencies = [ "bytes", "http 1.1.0", "http-body 1.0.0", - "http-serde 2.0.0", + "http-serde 2.1.0", "query_map", "serde", "serde_json", @@ -608,9 +607,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", "cc", @@ -704,9 +703,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "bitvec" @@ -744,12 +743,12 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ - "async-channel 2.2.0", + "async-channel 2.2.1", "async-lock 3.3.0", "async-task", - "fastrand 2.0.1", + "fastrand 2.0.2", "futures-io", - "futures-lite 2.2.0", + "futures-lite 2.3.0", "piper", "tracing", ] @@ -777,9 +776,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byteorder" @@ -789,9 +788,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" dependencies = [ "serde", ] @@ -810,9 +809,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.90" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" [[package]] name = "cesu8" @@ -828,16 +827,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -905,7 +904,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.0", + "strsim 0.11.1", ] [[package]] @@ -917,7 +916,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -944,9 +943,9 @@ dependencies = [ [[package]] name = "combine" -version = "4.6.6" +version = "4.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" dependencies = [ "bytes", "memchr", @@ -1207,7 +1206,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -1229,7 +1228,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core 0.20.8", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -1308,7 +1307,7 @@ dependencies = [ "quote", "strum 0.25.0", "strum_macros 0.25.3", - "syn 2.0.52", + "syn 2.0.59", "thiserror", ] @@ -1370,7 +1369,7 @@ dependencies = [ "darling 0.20.8", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -1454,9 +1453,9 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" [[package]] name = "either" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" [[package]] name = "ena" @@ -1475,9 +1474,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -1549,9 +1548,9 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feedafcaa9b749175d5ac357452a9d41ea2911da598fde46ce1fe02c37751291" +checksum = "332f51cb23d20b0de8458b86580878211da09bcd4503cb579c225b3d124cabb3" dependencies = [ "event-listener 5.3.0", "pin-project-lite", @@ -1593,9 +1592,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" [[package]] name = "fixedbitset" @@ -1699,11 +1698,11 @@ dependencies = [ [[package]] name = "futures-lite" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445ba825b27408685aaecefd65178908c36c6e96aaf6d8599419d46e624192ba" +checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ - "fastrand 2.0.1", + "fastrand 2.0.2", "futures-core", "futures-io", "parking", @@ -1729,7 +1728,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -2014,7 +2013,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.2.5", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", @@ -2023,9 +2022,9 @@ dependencies = [ [[package]] name = "half" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ "cfg-if", "crunchy", @@ -2260,9 +2259,9 @@ dependencies = [ [[package]] name = "http-serde" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fb7239a6d49eda628c2dfdd7e982c59b0c3f0fb99ce45c4237f02a520030688" +checksum = "1133cafcce27ea69d35e56b3a8772e265633e04de73c5f4e1afdffc1d19b5419" dependencies = [ "http 1.1.0", "serde", @@ -2375,7 +2374,7 @@ dependencies = [ "http 0.2.12", "hyper 0.14.28", "log", - "rustls 0.22.2", + "rustls 0.22.3", "rustls-native-certs", "rustls-pki-types", "tokio", @@ -2477,9 +2476,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -2501,7 +2500,7 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe95f33091b9b7b517a5849bce4dce1b550b430fc20d58059fcaa319ed895d8b" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "crossterm", "dyn-clone", "fuzzy-matcher", @@ -2580,11 +2579,20 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jni" @@ -2655,7 +2663,7 @@ dependencies = [ "petgraph", "pico-args", "regex", - "regex-syntax 0.8.2", + "regex-syntax 0.8.3", "string_cache", "term", "tiny-keccak", @@ -2712,7 +2720,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "http-body-util", - "http-serde 2.0.0", + "http-serde 2.1.0", "hyper 1.2.0", "hyper-util", "lambda_runtime_api_client", @@ -2812,13 +2820,12 @@ dependencies = [ [[package]] name = "libredox" -version = "0.0.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "libc", - "redox_syscall", ] [[package]] @@ -2887,7 +2894,7 @@ dependencies = [ "proc-macro2", "quote", "regex-syntax 0.6.29", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -2901,8 +2908,8 @@ dependencies = [ "lazy_static", "proc-macro2", "quote", - "regex-syntax 0.8.2", - "syn 2.0.52", + "regex-syntax 0.8.3", + "syn 2.0.59", ] [[package]] @@ -3012,15 +3019,15 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "memoffset" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] @@ -3045,7 +3052,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -3144,9 +3151,9 @@ dependencies = [ [[package]] name = "multimap" -version = "0.8.3" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" +checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" [[package]] name = "ndk-context" @@ -3156,9 +3163,9 @@ checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" [[package]] name = "new_debug_unreachable" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "newline-converter" @@ -3323,7 +3330,7 @@ checksum = "1e32339a5dc40459130b3bd269e9892439f55b33e772d2a9d402a789baaf4e8a" dependencies = [ "futures-core", "futures-sink", - "indexmap 2.2.5", + "indexmap 2.2.6", "js-sys", "once_cell", "pin-project-lite", @@ -3544,11 +3551,11 @@ dependencies = [ [[package]] name = "pem" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8fcc794035347fb64beda2d3b462595dd2753e3f268d89c5aae77e8cf2c310" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" dependencies = [ - "base64 0.21.7", + "base64 0.22.0", "serde", ] @@ -3560,9 +3567,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f8023d0fb78c8e03784ea1c7f3fa36e68a723138990b8d5a47d916b651e7a8" +checksum = "311fb059dee1a7b802f036316d790138c613a4e8b180c822e3925a662e9f0c95" dependencies = [ "memchr", "thiserror", @@ -3571,9 +3578,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0d24f72393fd16ab6ac5738bc33cdb6a9aa73f8b902e8fe29cf4e67d7dd1026" +checksum = "f73541b156d32197eecda1a4014d7f868fd2bcb3c550d5386087cfba442bf69c" dependencies = [ "pest", "pest_generator", @@ -3581,22 +3588,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc17e2a6c7d0a492f0158d7a4bd66cc17280308bbaff78d5bef566dca35ab80" +checksum = "c35eeed0a3fab112f75165fdc026b3913f4183133f19b49be773ac9ea966e8bd" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] name = "pest_meta" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "934cd7631c050f4674352a6e835d5f6711ffbfb9345c2fc0107155ac495ae293" +checksum = "2adbf29bb9776f28caece835398781ab24435585fe0d4dc1374a61db5accedca" dependencies = [ "once_cell", "pest", @@ -3610,7 +3617,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.2.5", + "indexmap 2.2.6", ] [[package]] @@ -3631,7 +3638,7 @@ dependencies = [ "bincode", "either", "fnv", - "itertools 0.11.0", + "itertools 0.12.1", "lazy_static", "nom", "quick-xml", @@ -3666,14 +3673,14 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -3688,7 +3695,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" dependencies = [ "atomic-waker", - "fastrand 2.0.1", + "fastrand 2.0.2", "futures-io", ] @@ -3738,14 +3745,15 @@ dependencies = [ [[package]] name = "polling" -version = "3.5.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24f040dee2588b4963afb4e420540439d126f73fdacf4a9c486a96d840bac3c9" +checksum = "e0c976a60b2d7e99d6f229e414670a9b85d13ac305cc6d1e9c134de58c5aaaf6" dependencies = [ "cfg-if", "concurrent-queue", + "hermit-abi", "pin-project-lite", - "rustix 0.38.31", + "rustix 0.38.32", "tracing", "windows-sys 0.52.0", ] @@ -3780,12 +3788,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.16" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" +checksum = "5ac2cf0f2e4f42b49f5ffd07dae8d746508ef7526c13940e5f524012ae6c6550" dependencies = [ "proc-macro2", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -3806,7 +3814,7 @@ checksum = "07c277e4e643ef00c1233393c673f655e3672cf7eb3ba08a00bdd0ea59139b5f" dependencies = [ "proc-macro-rules-macros", "proc-macro2", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -3818,14 +3826,14 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e" dependencies = [ "unicode-ident", ] @@ -3857,13 +3865,13 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55e02e35260070b6f716a2423c2ff1c3bb1642ddca6f99e1f26d06268a0e2d2" +checksum = "80b776a1b2dc779f5ee0641f8ade0125bc1298dd41a9a0c16d8bd57b42d222b1" dependencies = [ "bytes", - "heck 0.4.1", - "itertools 0.11.0", + "heck 0.5.0", + "itertools 0.12.1", "log", "multimap", "once_cell", @@ -3872,9 +3880,8 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.52", + "syn 2.0.59", "tempfile", - "which 4.4.2", ] [[package]] @@ -3884,10 +3891,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" dependencies = [ "anyhow", - "itertools 0.11.0", + "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -4016,9 +4023,9 @@ dependencies = [ [[package]] name = "quanta" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca0b7bac0b97248c40bb77288fc52029cf1459c0461ea1b05ee32ccf011de2c" +checksum = "8e5167a477619228a0b284fac2674e3c388cba90631d7b7de620e6f1fcd08da5" dependencies = [ "crossbeam-utils", "libc", @@ -4042,18 +4049,18 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.28.2" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce5e73202a820a31f8a0ee32ada5e21029c81fd9e3ebf668a40832e4219d9d1" +checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" dependencies = [ "memchr", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -4100,7 +4107,7 @@ version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d86a7c4638d42c44551f4791a20e687dbb4c3de1f33c43dd71e355cd429def1" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", ] [[package]] @@ -4111,9 +4118,9 @@ checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" [[package]] name = "rayon" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -4140,9 +4147,9 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", "libredox", @@ -4158,7 +4165,7 @@ dependencies = [ "aho-corasick", "memchr", "regex-automata 0.4.6", - "regex-syntax 0.8.2", + "regex-syntax 0.8.3", ] [[package]] @@ -4178,7 +4185,7 @@ checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.2", + "regex-syntax 0.8.3", ] [[package]] @@ -4201,15 +4208,15 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "reqwest" -version = "0.11.26" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78bf93c4af7a8bb7d879d51cebe797356ff10ae8516ace542b5182d9dcac10b2" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ "base64 0.21.7", "bytes", @@ -4335,11 +4342,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.31" +version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys 0.4.13", @@ -4360,9 +4367,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" dependencies = [ "log", "ring", @@ -4374,9 +4381,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.3" +version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b3818d6051afeb6f88412bc8693cf8219799b2f2c2365f15e7534f0e198a16c" +checksum = "8c4d6d8ad9f2492485e13453acbb291dd08f64441b6609c491f1c2cd2c6b4fe1" dependencies = [ "once_cell", "rustls-pki-types", @@ -4392,7 +4399,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" dependencies = [ "openssl-probe", - "rustls-pemfile 2.1.1", + "rustls-pemfile 2.1.2", "rustls-pki-types", "schannel", "security-framework", @@ -4409,11 +4416,11 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f48172685e6ff52a556baa527774f61fcaa884f59daf3375c62a3f1cd2549dab" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ - "base64 0.21.7", + "base64 0.22.0", "rustls-pki-types", ] @@ -4446,9 +4453,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" [[package]] name = "ryu" @@ -4516,9 +4523,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.2" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -4529,9 +4536,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" dependencies = [ "core-foundation-sys", "libc", @@ -4622,7 +4629,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -4642,7 +4649,7 @@ version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "itoa", "ryu", "serde", @@ -4707,11 +4714,11 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.9.32" +version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd075d994154d4a774f95b51fb96bdc2832b0ea48425c92546073816cda1f2f" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "itoa", "ryu", "serde", @@ -4816,9 +4823,9 @@ dependencies = [ [[package]] name = "similar" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21" +checksum = "fa42c91313f1d05da9b26f267f931cf178d4aba455b4c4622dd7355eb80c6640" [[package]] name = "simple_asn1" @@ -4849,9 +4856,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" @@ -4937,9 +4944,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strsim" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" @@ -4969,7 +4976,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -4982,7 +4989,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -5004,9 +5011,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" dependencies = [ "proc-macro2", "quote", @@ -5093,7 +5100,7 @@ dependencies = [ "httpmock", "hyper 0.14.28", "hyper-rustls 0.25.0", - "indexmap 2.2.5", + "indexmap 2.2.6", "inquire", "insta", "jsonwebtoken", @@ -5128,7 +5135,7 @@ dependencies = [ "reqwest", "reqwest-middleware", "resource", - "rustls 0.23.3", + "rustls 0.23.4", "rustls-pemfile 1.0.4", "rustls-pki-types", "schemars", @@ -5219,7 +5226,7 @@ dependencies = [ "dashmap", "futures-util", "indenter", - "indexmap 2.2.5", + "indexmap 2.2.6", "insta", "tailcall", "tokio", @@ -5256,8 +5263,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", - "fastrand 2.0.1", - "rustix 0.38.31", + "fastrand 2.0.2", + "rustix 0.38.32", "windows-sys 0.52.0", ] @@ -5289,7 +5296,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -5304,9 +5311,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -5325,9 +5332,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", @@ -5404,7 +5411,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -5423,16 +5430,16 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "rustls 0.22.2", + "rustls 0.22.3", "rustls-pki-types", "tokio", ] [[package]] name = "tokio-stream" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" dependencies = [ "futures-core", "pin-project-lite", @@ -5465,7 +5472,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "toml_datetime", "winnow", ] @@ -5490,7 +5497,7 @@ dependencies = [ "pin-project", "prost", "rustls-native-certs", - "rustls-pemfile 2.1.1", + "rustls-pemfile 2.1.2", "rustls-pki-types", "tokio", "tokio-rustls 0.25.0", @@ -5511,7 +5518,7 @@ dependencies = [ "proc-macro2", "prost-build", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -5577,7 +5584,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -5765,9 +5772,9 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "unsafe-libyaml" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" [[package]] name = "untrusted" @@ -5814,9 +5821,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" dependencies = [ "getrandom", "wasm-bindgen", @@ -5828,7 +5835,7 @@ version = "0.89.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe2197fbef82c98f7953d13568a961d4e1c663793b5caf3c74455a13918cdf33" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "fslock", "gzip-header", "home", @@ -5845,9 +5852,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "value-bag" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fec26a25bd6fca441cdd0f769fd7f891bae119f996de31f86a5eddccef54c1d" +checksum = "74797339c3b98616c009c7c3eb53a0ce41e85c8ec66bd3db96ed132d20cfdee8" [[package]] name = "version_check" @@ -5907,7 +5914,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", "wasm-bindgen-shared", ] @@ -5941,7 +5948,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6017,7 +6024,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.31", + "rustix 0.38.32", ] [[package]] @@ -6029,7 +6036,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.31", + "rustix 0.38.32", "windows-sys 0.48.0", ] @@ -6041,7 +6048,7 @@ checksum = "8211e4f58a2b2805adfbefbc07bab82958fc91e3836339b1ab7ae32465dce0d7" dependencies = [ "either", "home", - "rustix 0.38.31", + "rustix 0.38.32", "winsafe", ] @@ -6082,7 +6089,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -6109,7 +6116,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -6144,17 +6151,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] @@ -6171,9 +6179,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -6189,9 +6197,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -6207,9 +6215,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -6225,9 +6239,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -6243,9 +6257,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -6261,9 +6275,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -6279,9 +6293,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" @@ -6363,7 +6377,7 @@ dependencies = [ "async-trait", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-macro-support", @@ -6391,7 +6405,7 @@ dependencies = [ "darling 0.20.8", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] @@ -6426,7 +6440,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.59", ] [[package]] diff --git a/src/config/config.rs b/src/config/config.rs index 65d579f2a4..20af7f2887 100644 --- a/src/config/config.rs +++ b/src/config/config.rs @@ -1,4 +1,4 @@ -use std::collections::{BTreeMap, BTreeSet}; +use std::collections::{BTreeMap, BTreeSet, HashSet}; use std::fmt::{self, Display}; use std::num::NonZeroU64; @@ -113,6 +113,45 @@ impl Config { pub fn contains(&self, name: &str) -> bool { self.types.contains_key(name) || self.unions.contains_key(name) } + + /// Gets all the type names used in the schema. + pub fn get_all_used_type_names(&self) -> HashSet { + let mut set = HashSet::new(); + let mut stack = Vec::new(); + if let Some(query) = &self.schema.query { + stack.push(query.clone()); + } + if let Some(mutation) = &self.schema.mutation { + stack.push(mutation.clone()); + } + while let Some(type_name) = stack.pop() { + if let Some(typ) = self.types.get(&type_name) { + set.insert(type_name); + for field in typ.fields.values() { + stack.extend(field.args.values().map(|arg| arg.type_of.clone())); + stack.push(field.type_of.clone()); + } + } + } + + set + } + + pub fn get_all_unused_types(&self) -> HashSet { + let used_types = self.get_all_used_type_names(); + let all_types: HashSet = self.types.keys().cloned().collect(); + all_types.difference(&used_types).cloned().collect() + } + + /// Removes all types that are not used in the schema. + pub fn remove_unused_types(mut self) -> Self { + let unused_types = self.get_all_unused_types(); + for unused_type in unused_types { + self.types.remove(&unused_type); + } + + self + } } impl MergeRight for Config { diff --git a/src/generator/from_proto.rs b/src/generator/from_proto.rs index 8ac6d99dc9..75a4301c16 100644 --- a/src/generator/from_proto.rs +++ b/src/generator/from_proto.rs @@ -1,64 +1,18 @@ -use std::collections::{BTreeSet, HashMap}; +use std::collections::BTreeSet; -use convert_case::{Case, Casing}; use derive_setters::Setters; use prost_reflect::prost_types::{ DescriptorProto, EnumDescriptorProto, FileDescriptorSet, ServiceDescriptorProto, }; -use strum_macros::Display; use crate::blueprint::GrpcMethod; use crate::config::{Arg, Config, Field, Grpc, Tag, Type}; - -pub(super) static DEFAULT_SEPARATOR: &str = "__"; -pub(super) static DEFAULT_PACKAGE_SEPARATOR: &str = "_"; - -/// Enum to represent the type of the descriptor -#[derive(Display, Clone)] -enum DescriptorType { - Enum, - Message, - Operation, -} - -impl DescriptorType { - fn as_str_name(&self, package: &str, name: &str) -> String { - let package = package.replace('.', DEFAULT_PACKAGE_SEPARATOR); - if package.is_empty() { - return match self { - DescriptorType::Operation => name.to_case(Case::Camel).to_string(), - _ => name.to_string(), - }; - } - match self { - DescriptorType::Enum => { - format!( - "{}{}{}", - package.to_case(Case::UpperCamel), - DEFAULT_SEPARATOR, - name - ) - } - DescriptorType::Message => { - format!( - "{}{}{}", - package.to_case(Case::UpperCamel), - DEFAULT_SEPARATOR, - name - ) - } - DescriptorType::Operation => name.to_case(Case::Camel).to_string(), - } - } -} +use crate::generator::GraphQLType; /// Assists in the mapping and retrieval of proto type names to custom formatted /// strings based on the descriptor type. #[derive(Setters)] struct Context { - /// Maps proto type names to custom formatted names. - map: HashMap, - /// The current proto package name. package: String, @@ -73,83 +27,46 @@ impl Context { fn new(query: &str) -> Self { Self { query: query.to_string(), - map: Default::default(), package: Default::default(), config: Default::default(), } } - /// Formats a proto type name based on its `DescriptorType`. - fn get_name(&self, name: &str, ty: DescriptorType) -> String { - ty.as_str_name(&self.package, name) - } - - /// Inserts a formatted name into the map. - fn insert(mut self, name: &str, ty: DescriptorType) -> Self { - self.map.insert( - format!("{}.{}", self.package, name), - self.get_name(name, ty), - ); - self - } - /// Retrieves a formatted name from the map. - fn get(&self, name: &str) -> Option { - self.map.get(&format!("{}.{}", self.package, name)).cloned() - } - /// Resolves the actual name and inserts the type. - fn insert_type(mut self, name: &str, ty: Type) -> Self { - if let Some(name) = self.get(name) { - self.config.types.insert(name, ty); - } + fn insert_type(mut self, name: String, ty: Type) -> Self { + self.config.types.insert(name.to_string(), ty); self } - /// Retrieves or creates a Type configuration for a given proto type. - fn get_ty(&self, name: &str) -> Type { - let mut ty = self - .get(name) - .and_then(|name| self.config.types.get(&name)) - .cloned() - .unwrap_or_default(); - - let id = if self.package.is_empty() { - name.to_string() - } else { - format!("{}.{}", self.package, name) - }; - - ty.tag = Some(Tag { id }); - ty - } - /// Processes proto enum types. fn append_enums(mut self, enums: &Vec) -> Self { for enum_ in enums { - let enum_name = enum_.name(); + let mut ty = Type::default(); - self = self.insert(enum_name, DescriptorType::Enum); - let mut ty = self.get_ty(enum_name); + let enum_name = enum_.name(); + ty.tag = Some(Tag { id: enum_name.to_string() }); - let mut variants = enum_ + let variants = enum_ .value .iter() - .map(|v| v.name().to_string()) + .map(|v| { + GraphQLType::new(v.name()) + .as_enum_variant() + .unwrap() + .to_string() + }) .collect::>(); - if let Some(vars) = ty.variants { - variants.extend(vars); - } + ty.variants = Some(variants); - self = self.insert_type(enum_name, ty); + + let type_name = GraphQLType::new(enum_name).as_enum().unwrap().to_string(); + self = self.insert_type(type_name, ty); } self } /// Processes proto message types. fn append_msg_type(mut self, messages: &Vec) -> Self { - if messages.is_empty() { - return self; - } for message in messages { let msg_name = message.name().to_string(); if let Some(options) = message.options.as_ref() { @@ -158,14 +75,21 @@ impl Context { } } - self = self.insert(&msg_name, DescriptorType::Message); - let mut ty = self.get_ty(&msg_name); - self = self.append_enums(&message.enum_type); self = self.append_msg_type(&message.nested_type); + let msg_type = GraphQLType::new(&msg_name) + .package(&self.package) + .as_object_type() + .unwrap(); + + let mut ty = Type::default(); for field in message.field.iter() { - let field_name = field.name().to_string(); + let field_name = GraphQLType::new(field.name()) + .package(&self.package) + .as_field() + .unwrap(); + let mut cfg_field = Field::default(); let label = field.label().as_str_name().to_lowercase(); @@ -182,100 +106,28 @@ impl Context { } else { // for non-primitive types let type_of = convert_ty(field.type_name()); - cfg_field.type_of = self.get(&type_of).unwrap_or(type_of); + let type_of = GraphQLType::new(&type_of) + .package(self.package.as_str()) + .as_object_type() + .unwrap() + .to_string(); + + cfg_field.type_of = type_of; } - ty.fields.insert(field_name.to_case(Case::Camel), cfg_field); + ty.fields.insert(field_name.to_string(), cfg_field); } - self = self.insert_type(&msg_name, ty); - } - self - } - - /// Generates argument configurations for service methods. - fn get_arg(&self, input_ty: &str) -> Option<(String, Arg)> { - match input_ty { - "google.protobuf.Empty" | "" => None, - any => { - let key = convert_ty(any).to_case(Case::Camel); - let val = Arg { - type_of: self.get(any).unwrap_or(any.to_string()), - list: false, - required: true, - /* Setting it not null by default. There's no way to infer this - * from proto file */ - doc: None, - modify: None, - default_value: None, - }; - - Some((key, val)) - } - } - } + ty.tag = Some(Tag { id: msg_type.id() }); - fn append_nested_package(mut self, method_name: String, field: Field) -> Self { - let split = self - .package - .split('.') - .collect::>() - .iter() - .filter(|x| !x.is_empty()) - .map(|x| x.to_case(Case::UpperCamel)) - .collect::>(); - // let n = len(split) - // len(types) = n - // len(fields) = n-1 - let n = split.len(); - - for (i, type_name) in split.iter().enumerate() { - if i == 0 { - let mut ty = self - .config - .types - .get(&self.query) - .cloned() - .unwrap_or_default(); - let field = Field::default().type_of(type_name.clone()); - ty.fields.insert(type_name.to_case(Case::Camel), field); - self.config.schema.query = Some(self.query.to_owned()); - self.config.types.insert(self.query.to_owned(), ty); - } - if i + 1 < n { - let field_name = &split[i + 1]; - let field = Field::default().type_of(field_name.clone()); - let mut ty = Type::default(); - ty.fields.insert(field_name.to_case(Case::Camel), field); - self.config.types.insert(type_name.clone(), ty); - } else if let Some(ty) = self.config.types.get_mut(type_name) { - ty.fields.insert(method_name.clone(), field.clone()); - } else { - let mut ty = Type::default(); - ty.fields.insert(method_name.clone(), field.clone()); - self.config.types.insert(type_name.clone(), ty); - } + self = self.insert_type(msg_type.to_string(), ty); } - - if n == 0 { - let mut ty = self - .config - .types - .get(&self.query) - .cloned() - .unwrap_or_default(); - ty.fields.insert(method_name.to_case(Case::Camel), field); - self.config.schema.query = Some(self.query.to_owned()); - self.config.types.insert(self.query.to_owned(), ty); - } - self } /// Processes proto service definitions and their methods. fn append_query_service(mut self, services: &Vec) -> Self { if services.is_empty() { - self.config = Config::default(); return self; } @@ -285,45 +137,69 @@ impl Context { for service in services { let service_name = service.name().to_string(); for method in &service.method { - let method_name = method.name(); - - self = self.insert(method_name, DescriptorType::Operation); + let field_name = GraphQLType::new(method.name()) + .package(&self.package) + .as_method() + .unwrap(); let mut cfg_field = Field::default(); - let arg = self.get_arg(method.input_type()); - - if let Some((k, v)) = arg { - cfg_field.args.insert(k, v); + if let Some(arg_type) = get_input_ty(method.input_type()) { + let key = GraphQLType::new(&arg_type) + .package(&self.package) + .as_field() + .unwrap() + .to_string(); + let type_of = GraphQLType::new(&arg_type) + .package(&self.package) + .as_object_type() + .unwrap() + .to_string(); + let val = Arg { + type_of, + list: false, + required: true, + /* Setting it not null by default. There's no way to infer this + * from proto file */ + doc: None, + modify: None, + default_value: None, + }; + + cfg_field.args.insert(key, val); } let output_ty = get_output_ty(method.output_type()); - cfg_field.type_of = self.get(&output_ty).unwrap_or(output_ty.clone()); + let output_ty = GraphQLType::new(&output_ty) + .package(&self.package) + .as_object_type() + .unwrap() + .to_string(); + cfg_field.type_of = output_ty; cfg_field.required = true; grpc_method.service = service_name.clone(); - grpc_method.name = method_name.to_string(); - let grpc_method_string = grpc_method.to_string(); - - let method = if let Some(stripped) = grpc_method_string.strip_prefix('.') { - stripped.to_string() - } else { - grpc_method_string - }; + grpc_method.name = field_name.to_string(); cfg_field.grpc = Some(Grpc { base_url: None, body: None, group_by: vec![], headers: vec![], - method, + method: field_name.id(), }); - if let Some(method_name) = self.get(method_name) { - self = self.append_nested_package(method_name, cfg_field); - } + let ty = self + .config + .types + .entry(self.query.clone()) + .or_insert_with(|| { + self.config.schema.query = Some(self.query.clone()); + Type::default() + }); + + ty.fields.insert(field_name.to_string(), cfg_field); } } - self } } @@ -359,6 +235,13 @@ fn get_output_ty(output_ty: &str) -> String { } } +fn get_input_ty(input_ty: &str) -> Option { + match input_ty { + "google.protobuf.Empty" | "" => None, + any => Some(any.to_string()), + } +} + /// The main entry point that builds a Config object from proto descriptor sets. pub fn from_proto(descriptor_sets: &[FileDescriptorSet], query: &str) -> Config { let mut ctx = Context::new(query); @@ -373,6 +256,8 @@ pub fn from_proto(descriptor_sets: &[FileDescriptorSet], query: &str) -> Config } } + ctx.config = ctx.config.remove_unused_types(); + ctx.config } @@ -382,7 +267,7 @@ mod test { use prost_reflect::prost_types::{FileDescriptorProto, FileDescriptorSet}; - use crate::generator::from_proto::{from_proto, Context, DescriptorType}; + use crate::generator::from_proto::from_proto; fn get_proto_file_descriptor(name: &str) -> anyhow::Result { let path = @@ -437,6 +322,13 @@ mod test { Ok(()) } + #[test] + fn test_greetings_proto_file() { + let set = new_file_desc(&["greetings.proto", "greetings_message.proto"]).unwrap(); + let result = from_proto(&[set], "Query").to_sdl(); + insta::assert_snapshot!(result); + } + #[test] fn test_config_from_sdl() -> anyhow::Result<()> { let set = new_file_desc(&["news.proto", "greetings_a.proto", "greetings_b.proto"])?; @@ -465,60 +357,4 @@ mod test { insta::assert_snapshot!(config); Ok(()) } - - #[test] - fn test_get_value_enum() { - let ctx: Context = Context::new("Query").package("com.example".to_string()); - - let actual = ctx.get_name("TestEnum", DescriptorType::Enum); - let expected = "ComExample__TestEnum"; - assert_eq!(actual, expected); - } - - #[test] - fn test_get_value_message() { - let ctx: Context = Context::new("Query").package("com.example".to_string()); - - let actual = ctx.get_name("testMessage", DescriptorType::Message); - let expected = "ComExample__testMessage"; - assert_eq!(actual, expected); - } - - #[test] - fn test_get_value_query_name() { - let ctx: Context = Context::new("Query").package("com.example".to_string()); - - let actual = ctx.get_name("QueryName", DescriptorType::Operation); - let expected = "queryName"; - assert_eq!(actual, expected); - } - - #[test] - fn test_insert_and_get_enum() { - let ctx: Context = Context::new("Query") - .package("com.example".to_string()) - .insert("TestEnum", DescriptorType::Enum); - - let actual = ctx.get("TestEnum"); - let expected = Some("ComExample__TestEnum".to_string()); - assert_eq!(actual, expected); - } - - #[test] - fn test_insert_and_get_message() { - let ctx: Context = Context::new("Query") - .package("com.example".to_string()) - .insert("testMessage", DescriptorType::Message); - let actual = ctx.get("testMessage"); - let expected = Some("ComExample__testMessage".to_string()); - assert_eq!(actual, expected); - } - - #[test] - fn test_insert_and_get_non_existing() { - let ctx: Context = Context::new("Query").package("com.example".to_string()); - let actual = ctx.get("NonExisting"); - let expected = None; - assert_eq!(actual, expected); - } } diff --git a/src/generator/generator.rs b/src/generator/generator.rs index 8db1897784..343ac9a3f3 100644 --- a/src/generator/generator.rs +++ b/src/generator/generator.rs @@ -96,6 +96,6 @@ mod test { .unwrap(); assert_eq!(config.links.len(), 3); - assert_eq!(config.types.get("Query").unwrap().fields.len(), 3); + assert_eq!(config.types.get("Query").unwrap().fields.len(), 8); } } diff --git a/src/generator/graphql_type.rs b/src/generator/graphql_type.rs new file mode 100644 index 0000000000..67e305ce8a --- /dev/null +++ b/src/generator/graphql_type.rs @@ -0,0 +1,260 @@ +use std::fmt::Display; + +use convert_case::{Case, Casing}; +pub(super) static DEFAULT_SEPARATOR: &str = "_"; +static PACKAGE_SEPARATOR: &str = "."; + +/// A struct to represent the name of a GraphQL type. +#[derive(Debug, Clone)] +pub struct GraphQLType(A); + +#[derive(Debug, Clone)] +pub struct Parsed { + package: Option, + name: String, + entity: Entity, +} + +#[derive(Debug, Clone)] +pub struct Unparsed { + package: Option, + name: String, +} + +#[derive(Debug, Clone)] +struct Package { + path: Vec, + input: String, +} + +impl Package { + fn parse(input: &str) -> Option { + let separator = PACKAGE_SEPARATOR; + let path = input.split(separator).map(String::from).collect::>(); + if path.is_empty() | input.is_empty() { + None + } else { + Some(Self { path, input: input.to_string() }) + } + } + + fn source(&self) -> &str { + &self.input + } +} + +impl Display for Package { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str( + self.path + .iter() + .map(|a| a.to_case(Case::Snake)) + .collect::>() + .join(DEFAULT_SEPARATOR) + .as_str(), + ) + } +} + +impl GraphQLType { + pub fn new(input: &str) -> Self { + Self(Unparsed { package: None, name: input.to_string() }) + } + + fn parse(&self, entity: Entity) -> Option> { + let unparsed = &self.0; + let parsed_package = unparsed.package.as_deref().and_then(Package::parse); + + // Name contains package + if unparsed.name.contains(PACKAGE_SEPARATOR) { + if let Some((package, name)) = unparsed.name.rsplit_once(PACKAGE_SEPARATOR) { + Some(GraphQLType(Parsed { + name: name.to_string(), + package: parsed_package.or(Package::parse(package)), + entity, + })) + } else { + None + } + } + // Name doesn't contain package + else { + Some(GraphQLType(Parsed { + package: parsed_package, + name: unparsed.name.to_string(), + entity, + })) + } + } + + pub fn as_enum(&self) -> Option> { + self.parse(Entity::Enum) + } + + pub fn as_enum_variant(&self) -> Option> { + self.parse(Entity::EnumVariant) + } + + pub fn as_object_type(&self) -> Option> { + self.parse(Entity::ObjectType) + } + + pub fn as_method(&self) -> Option> { + self.parse(Entity::Method) + } + + pub fn as_field(&self) -> Option> { + self.parse(Entity::Field) + } + + pub fn package(mut self, package: &str) -> Self { + self.0.package = Some(package.to_string()); + self + } +} + +impl GraphQLType { + pub fn id(&self) -> String { + if let Some(ref package) = self.0.package { + format!("{}.{}", package.source(), self.0.name) + } else { + self.0.name.clone() + } + } +} + +// FIXME: make it private +/// Used to convert proto type names to GraphQL formatted names. +/// Enum to represent the type of the descriptor +#[derive(Clone, Debug)] +enum Entity { + Enum, + EnumVariant, + ObjectType, + Method, + Field, +} + +impl Display for GraphQLType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let parsed = &self.0; + match parsed.entity { + Entity::EnumVariant => { + f.write_str(parsed.name.to_case(Case::ScreamingSnake).as_str())? + } + Entity::Field => f.write_str(parsed.name.to_case(Case::Snake).as_str())?, + Entity::Method => { + if let Some(package) = &parsed.package { + f.write_str(package.to_string().to_case(Case::Snake).as_str())?; + f.write_str(DEFAULT_SEPARATOR)?; + }; + f.write_str(parsed.name.to_case(Case::Snake).as_str())? + } + Entity::Enum | Entity::ObjectType => { + if let Some(package) = &parsed.package { + f.write_str(package.to_string().to_case(Case::ScreamingSnake).as_str())?; + f.write_str(DEFAULT_SEPARATOR)?; + }; + f.write_str(parsed.name.to_case(Case::ScreamingSnake).as_str())? + } + }; + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use pretty_assertions::assert_eq; + + use super::*; + + type TestParams = ((Entity, Option<&'static str>, &'static str), &'static str); + + #[test] + fn test_from_enum() { + let input: Vec = vec![ + // Enums + ((Entity::Enum, None, "foo"), "FOO"), + ((Entity::Enum, None, "a.b.c.foo"), "A_B_C_FOO"), + ((Entity::Enum, Some("a.b.c"), "foo"), "A_B_C_FOO"), + ((Entity::Enum, Some("a.b.c"), "d.e.f.foo"), "A_B_C_FOO"), + ((Entity::Enum, Some(""), "a.b.c.foo"), "A_B_C_FOO"), + ((Entity::Enum, None, "a_b_c_foo"), "A_B_C_FOO"), + ]; + + assert_type_names(input); + } + + #[test] + fn test_from_enum_variant() { + let input: Vec = vec![ + // Enum variants + ((Entity::EnumVariant, None, "foo"), "FOO"), + ((Entity::EnumVariant, None, "a.b.c.foo"), "FOO"), + ((Entity::EnumVariant, Some("a.b.c"), "foo"), "FOO"), + ((Entity::EnumVariant, Some("a.b"), "d.e.foo"), "FOO"), + ((Entity::EnumVariant, Some(""), "a.b.c.foo"), "FOO"), + ((Entity::EnumVariant, None, "a_b_c_foo"), "A_B_C_FOO"), + ]; + + assert_type_names(input); + } + + #[test] + fn test_from_object_type() { + let input: Vec = vec![ + // Object types + ((Entity::ObjectType, None, "foo"), "FOO"), + ((Entity::ObjectType, None, "a.b.c.foo"), "A_B_C_FOO"), + ((Entity::ObjectType, Some("a.b.c"), "foo"), "A_B_C_FOO"), + ((Entity::ObjectType, Some("a.b"), "d.e.foo"), "A_B_FOO"), + ((Entity::ObjectType, Some(""), "a.b.c.foo"), "A_B_C_FOO"), + ((Entity::ObjectType, None, "a_b_c_foo"), "A_B_C_FOO"), + ((Entity::ObjectType, None, "foo.bar.Baz"), "FOO_BAR_BAZ"), + ]; + + assert_type_names(input); + } + + #[test] + fn test_from_method() { + let input: Vec = vec![ + // Methods + ((Entity::Method, None, "foo"), "foo"), + ((Entity::Method, None, "a.b.c.foo"), "a_b_c_foo"), + ((Entity::Method, Some("a.b.c"), "foo"), "a_b_c_foo"), + ((Entity::Method, Some("a.b"), "d.e.foo"), "a_b_foo"), + ((Entity::Method, Some(""), "a.b.c.foo"), "a_b_c_foo"), + ((Entity::Method, None, "a_bC_foo"), "a_b_c_foo"), + ]; + + assert_type_names(input); + } + + #[test] + fn test_from_field() { + let input: Vec = vec![ + // Fields + ((Entity::Field, None, "foo"), "foo"), + ((Entity::Field, None, "a.b.c.foo"), "foo"), + ((Entity::Field, Some("a.b.c"), "foo"), "foo"), + ((Entity::Field, Some("a.b"), "d.e.foo"), "foo"), + ((Entity::Field, Some(""), "a.b.c.foo"), "foo"), + ((Entity::Field, None, "a_bC_foo"), "a_b_c_foo"), + ]; + + assert_type_names(input); + } + + fn assert_type_names(input: Vec) { + for ((entity, package, name), expected) in input { + let mut g = GraphQLType::new(name); + if let Some(package) = package { + g = g.package(package); + } + + let actual = g.parse(entity).unwrap().to_string(); + assert_eq!(actual, expected, "Given: {:?}", g); + } + } +} diff --git a/src/generator/mod.rs b/src/generator/mod.rs index 885dbab4a9..cae58d4613 100644 --- a/src/generator/mod.rs +++ b/src/generator/mod.rs @@ -1,6 +1,7 @@ mod from_proto; mod generator; +mod graphql_type; mod source; - pub use generator::Generator; +pub use graphql_type::GraphQLType; pub use source::Source; diff --git a/src/generator/proto/greetings.proto b/src/generator/proto/greetings.proto new file mode 100644 index 0000000000..cb296d16ff --- /dev/null +++ b/src/generator/proto/greetings.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; + +package greetings; +import "src/generator/proto/greetings_message.proto"; +service Greeter { + rpc SayHello (greetings.HelloRequest) returns (greetings.HelloReply) {} +} \ No newline at end of file diff --git a/src/generator/proto/greetings_message.proto b/src/generator/proto/greetings_message.proto new file mode 100644 index 0000000000..44aba4072d --- /dev/null +++ b/src/generator/proto/greetings_message.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package greetings; + +message HelloRequest { + string name = 1; +} + +message HelloReply { + string message = 1; +} \ No newline at end of file diff --git a/src/generator/snapshots/tailcall__generator__from_proto__test__from_proto.snap b/src/generator/snapshots/tailcall__generator__from_proto__test__from_proto.snap index 633bebdef3..06dd410dba 100644 --- a/src/generator/snapshots/tailcall__generator__from_proto__test__from_proto.snap +++ b/src/generator/snapshots/tailcall__generator__from_proto__test__from_proto.snap @@ -6,80 +6,55 @@ schema @server @upstream { query: Query } -input GreetingsAB__HelloRequest @tag(id: "greetings_a.b.HelloRequest") { +input GREETINGS_A_B_HELLO_REQUEST @tag(id: "greetings_a.b.HelloRequest") { name: String } -input GreetingsBC__HelloRequest @tag(id: "greetings_b.c.HelloRequest") { +input GREETINGS_B_C_HELLO_REQUEST @tag(id: "greetings_b.c.HelloRequest") { name: String } -input News__Author @tag(id: "news.Author") { +input NEWS_AUTHOR @tag(id: "news.Author") { email: String name: String } -input News__MultipleNewsId @tag(id: "news.MultipleNewsId") { - ids: [News__NewsId]! +input NEWS_MULTIPLE_NEWS_ID @tag(id: "news.MultipleNewsId") { + ids: [NEWS_NEWS_ID]! } -input News__News @tag(id: "news.News") { - author: News__Author +input NEWS_NEWS @tag(id: "news.News") { + author: NEWS_AUTHOR body: String - foo: News__Status + foo: NEWS_STATUS id: Int - postImage: String + post_image: String title: String } -input News__NewsId @tag(id: "news.NewsId") { +input NEWS_NEWS_ID @tag(id: "news.NewsId") { id: Int } -enum News__Status @tag(id: "news.Status") { - DRAFT - PUBLISHED -} - -type B { - sayHello(helloRequest: GreetingsAB__HelloRequest!): GreetingsAB__HelloReply! @grpc(method: "greetings_a.b.Greeter.SayHello") -} - -type C { - sayHello(helloRequest: GreetingsBC__HelloRequest!): GreetingsBC__HelloReply! @grpc(method: "greetings_b.c.Greeter.SayHello") -} - -type GreetingsA { - b: B -} - -type GreetingsAB__HelloReply @tag(id: "greetings_a.b.HelloReply") { +type GREETINGS_A_B_HELLO_REPLY @tag(id: "greetings_a.b.HelloReply") { message: String } -type GreetingsB { - c: C -} - -type GreetingsBC__HelloReply @tag(id: "greetings_b.c.HelloReply") { +type GREETINGS_B_C_HELLO_REPLY @tag(id: "greetings_b.c.HelloReply") { message: String } -type News { - addNews(news: News__News!): News__News! @grpc(method: "news.NewsService.AddNews") - deleteNews(newsId: News__NewsId!): Empty! @grpc(method: "news.NewsService.DeleteNews") - editNews(news: News__News!): News__News! @grpc(method: "news.NewsService.EditNews") - getAllNews: News__NewsList! @grpc(method: "news.NewsService.GetAllNews") - getMultipleNews(multipleNewsId: News__MultipleNewsId!): News__NewsList! @grpc(method: "news.NewsService.GetMultipleNews") - getNews(newsId: News__NewsId!): News__News! @grpc(method: "news.NewsService.GetNews") -} - -type News__NewsList @tag(id: "news.NewsList") { - news: [News__News]! +type NEWS_NEWS_LIST @tag(id: "news.NewsList") { + news: [NEWS_NEWS]! } type Query { - greetingsA: GreetingsA - greetingsB: GreetingsB - news: News + greetings_a_b_say_hello(hello_request: GREETINGS_A_B_HELLO_REQUEST!): GREETINGS_A_B_HELLO_REPLY! @grpc(method: "greetings_a.b.SayHello") + greetings_b_c_say_hello(hello_request: GREETINGS_B_C_HELLO_REQUEST!): GREETINGS_B_C_HELLO_REPLY! @grpc(method: "greetings_b.c.SayHello") + news_add_news(news: NEWS_NEWS!): NEWS_NEWS! @grpc(method: "news.AddNews") + news_delete_news(news_id: NEWS_NEWS_ID!): NEWS_EMPTY! @grpc(method: "news.DeleteNews") + news_edit_news(news: NEWS_NEWS!): NEWS_NEWS! @grpc(method: "news.EditNews") + news_get_all_news: NEWS_NEWS_LIST! @grpc(method: "news.GetAllNews") + news_get_multiple_news(multiple_news_id: NEWS_MULTIPLE_NEWS_ID!): NEWS_NEWS_LIST! @grpc(method: "news.GetMultipleNews") + news_get_news(news_id: NEWS_NEWS_ID!): NEWS_NEWS! @grpc(method: "news.GetNews") } diff --git a/src/generator/snapshots/tailcall__generator__from_proto__test__from_proto_no_pkg_file.snap b/src/generator/snapshots/tailcall__generator__from_proto__test__from_proto_no_pkg_file.snap index fc706c3e52..2947033ec3 100644 --- a/src/generator/snapshots/tailcall__generator__from_proto__test__from_proto_no_pkg_file.snap +++ b/src/generator/snapshots/tailcall__generator__from_proto__test__from_proto_no_pkg_file.snap @@ -6,17 +6,17 @@ schema @server @upstream { query: Query } -type News @tag(id: "News") { +type NEWS @tag(id: "News") { body: String id: Int - postImage: String + post_image: String title: String } -type NewsList @tag(id: "NewsList") { - news: [News]! +type NEWS_LIST @tag(id: "NewsList") { + news: [NEWS]! } type Query { - getAllNews: NewsList! @grpc(method: "NewsService.GetAllNews") + get_all_news: NEWS_LIST! @grpc(method: "GetAllNews") } diff --git a/src/generator/snapshots/tailcall__generator__from_proto__test__greetings_proto_file.snap b/src/generator/snapshots/tailcall__generator__from_proto__test__greetings_proto_file.snap new file mode 100644 index 0000000000..65548ad9c4 --- /dev/null +++ b/src/generator/snapshots/tailcall__generator__from_proto__test__greetings_proto_file.snap @@ -0,0 +1,19 @@ +--- +source: src/generator/from_proto.rs +expression: result +--- +schema @server @upstream { + query: Query +} + +input GREETINGS_HELLO_REQUEST @tag(id: "greetings.HelloRequest") { + name: String +} + +type GREETINGS_HELLO_REPLY @tag(id: "greetings.HelloReply") { + message: String +} + +type Query { + greetings_say_hello(hello_request: GREETINGS_HELLO_REQUEST!): GREETINGS_HELLO_REPLY! @grpc(method: "greetings.SayHello") +} diff --git a/src/generator/snapshots/tailcall__generator__from_proto__test__required_types.snap b/src/generator/snapshots/tailcall__generator__from_proto__test__required_types.snap index 0a10d853aa..95ced99cc2 100644 --- a/src/generator/snapshots/tailcall__generator__from_proto__test__required_types.snap +++ b/src/generator/snapshots/tailcall__generator__from_proto__test__required_types.snap @@ -6,27 +6,19 @@ schema @server @upstream { query: Query } -type Person { - getPerson: Person__Person! @grpc(method: "person.PersonService.GetPerson") -} - -type Person__People @tag(id: "person.People") { - people: JSON -} - -type Person__Person @tag(id: "person.Person") { +type PERSON_PERSON @tag(id: "person.Person") { email: String id: Int! name: String! - phone: [Person__PhoneNumber]! - stringMap: JSON + phone: [PERSON_PHONE_NUMBER]! + string_map: JSON } -type Person__PhoneNumber @tag(id: "person.PhoneNumber") { +type PERSON_PHONE_NUMBER @tag(id: "person.PhoneNumber") { number: String! type: String } type Query { - person: Person + person_get_person: PERSON_PERSON! @grpc(method: "person.GetPerson") }