From fded21f2853fe4080a7228b7f04ed186df2e708b Mon Sep 17 00:00:00 2001 From: Natty Date: Fri, 4 Aug 2023 12:28:35 +0200 Subject: [PATCH] WASM SDK implementation --- Cargo.lock | 1058 +++++++++++++++++++--------- Cargo.toml | 14 + magnetar_sdk/Cargo.toml | 46 ++ magnetar_sdk/macros/Cargo.toml | 11 + magnetar_sdk/macros/src/lib.rs | 237 +++++++ magnetar_sdk/src/client/fetch.rs | 277 ++++++++ magnetar_sdk/src/client/mod.rs | 12 + magnetar_sdk/src/client/reqwest.rs | 112 +++ magnetar_sdk/src/endpoints/list.rs | 21 + magnetar_sdk/src/endpoints/mod.rs | 57 ++ magnetar_sdk/src/endpoints/user.rs | 24 + magnetar_sdk/src/lib.rs | 23 + magnetar_sdk/src/types/drive.rs | 89 +++ magnetar_sdk/src/types/emoji.rs | 22 + magnetar_sdk/src/types/mod.rs | 44 ++ magnetar_sdk/src/types/note.rs | 103 +++ magnetar_sdk/src/types/user.rs | 187 +++++ 17 files changed, 2015 insertions(+), 322 deletions(-) create mode 100644 magnetar_sdk/Cargo.toml create mode 100644 magnetar_sdk/macros/Cargo.toml create mode 100644 magnetar_sdk/macros/src/lib.rs create mode 100644 magnetar_sdk/src/client/fetch.rs create mode 100644 magnetar_sdk/src/client/mod.rs create mode 100644 magnetar_sdk/src/client/reqwest.rs create mode 100644 magnetar_sdk/src/endpoints/list.rs create mode 100644 magnetar_sdk/src/endpoints/mod.rs create mode 100644 magnetar_sdk/src/endpoints/user.rs create mode 100644 magnetar_sdk/src/lib.rs create mode 100644 magnetar_sdk/src/types/drive.rs create mode 100644 magnetar_sdk/src/types/emoji.rs create mode 100644 magnetar_sdk/src/types/mod.rs create mode 100644 magnetar_sdk/src/types/note.rs create mode 100644 magnetar_sdk/src/types/user.rs diff --git a/Cargo.lock b/Cargo.lock index 72ad8ca..d11132d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,6 +8,21 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +[[package]] +name = "addr2line" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "ahash" version = "0.7.6" @@ -30,15 +45,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - [[package]] name = "aho-corasick" version = "1.0.2" @@ -54,6 +60,18 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -65,9 +83,9 @@ dependencies = [ [[package]] name = "arrayvec" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "async-stream" @@ -88,18 +106,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.28", ] [[package]] name = "async-trait" -version = "0.1.68" +version = "0.1.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" +checksum = "cc6dde6e4ed435a4c1ee4e73592f5ba9da2151af10076cc04858746af9352d09" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.28", ] [[package]] @@ -119,14 +137,14 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8175979259124331c1d7bf6586ee7e0da434155e4b2d48ec2c8386281d8df39" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", "axum-core", "axum-macros", - "bitflags", + "bitflags 1.3.2", "bytes", "futures-util", "headers", @@ -177,7 +195,22 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.28", +] + +[[package]] +name = "backtrace" +version = "0.3.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", ] [[package]] @@ -201,9 +234,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" [[package]] name = "bigdecimal" @@ -222,6 +255,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" + [[package]] name = "bitvec" version = "1.0.1" @@ -300,9 +339,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.2" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c6ed94e98ecff0c12dd1b04c15ec0d7d9458ca8fe806cea6f12954efe74c63b" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" [[package]] name = "bytecheck" @@ -376,9 +415,12 @@ checksum = "3a4f925191b4367301851c6d99b09890311d74b0d43f274c0b34c86d308a3663" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "6c6b2562119bf28c3439f7f02db99faf0aa1a8cdfe5772a2ee155d32227239f0" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -388,13 +430,13 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.24" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" dependencies = [ + "android-tzdata", "iana-time-zone", "js-sys", - "num-integer", "num-traits", "serde", "time 0.1.45", @@ -438,10 +480,10 @@ version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ - "bitflags", + "bitflags 1.3.2", "clap_derive", "clap_lex", - "indexmap", + "indexmap 1.9.3", "once_cell", "textwrap", ] @@ -482,6 +524,16 @@ dependencies = [ "tokio-util", ] +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.4" @@ -490,9 +542,9 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpufeatures" -version = "0.2.7" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" dependencies = [ "libc", ] @@ -509,9 +561,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ "cfg-if", ] @@ -562,16 +614,25 @@ dependencies = [ ] [[package]] -name = "deunicode" -version = "0.4.3" +name = "deranged" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690" +checksum = "7684a49fb1af197853ef7b2ee694bc1f5b4179556f1e5710e1760c5db6f5e929" +dependencies = [ + "serde", +] + +[[package]] +name = "deunicode" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95203a6a50906215a502507c0f879a0ce7ff205a6111e2db2a5ef8e4bb92e43" [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", @@ -606,9 +667,45 @@ checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" [[package]] name = "either" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "encoding_rs" +version = "0.8.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] [[package]] name = "event-listener" @@ -624,6 +721,12 @@ dependencies = [ "tokio", ] +[[package]] +name = "fastrand" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" + [[package]] name = "fnv" version = "1.0.7" @@ -631,10 +734,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] -name = "form_urlencoded" -version = "1.1.0" +name = "foreign-types" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] @@ -700,7 +818,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.28", ] [[package]] @@ -745,9 +863,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", @@ -755,12 +873,18 @@ dependencies = [ ] [[package]] -name = "globset" -version = "0.4.10" +name = "gimli" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" + +[[package]] +name = "globset" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aca8bbd8e0707c1887a8bbb7e6b40e228f251ff5d62c8220a4a7a53c73aff006" dependencies = [ - "aho-corasick 0.7.20", + "aho-corasick", "bstr", "fnv", "log", @@ -773,7 +897,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc" dependencies = [ - "bitflags", + "bitflags 1.3.2", "ignore", "walkdir", ] @@ -790,7 +914,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.3", "slab", "tokio", "tokio-util", @@ -816,12 +940,22 @@ dependencies = [ ] [[package]] -name = "hashlink" -version = "0.8.2" +name = "hashbrown" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0761a1b9491c4f2e3d66aa0f62d0fba0af9a0e2852e4d48ea506632a4b56e6aa" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" dependencies = [ - "hashbrown 0.13.2", + "ahash 0.8.3", + "allocator-api2", +] + +[[package]] +name = "hashlink" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "312f66718a2d7789ffef4f4b7b213138ed9f1eb3aa1d0d82fc99f88fb3ffd26f" +dependencies = [ + "hashbrown 0.14.0", ] [[package]] @@ -831,7 +965,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" dependencies = [ "base64 0.13.1", - "bitflags", + "bitflags 1.3.2", "bytes", "headers-core", "http", @@ -869,12 +1003,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.2.6" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] name = "hex" @@ -924,9 +1055,9 @@ dependencies = [ [[package]] name = "http-range-header" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" +checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" [[package]] name = "httparse" @@ -948,9 +1079,9 @@ checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026" [[package]] name = "hyper" -version = "0.14.26" +version = "0.14.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" dependencies = [ "bytes", "futures-channel", @@ -971,10 +1102,23 @@ dependencies = [ ] [[package]] -name = "iana-time-zone" -version = "0.1.56" +name = "hyper-tls" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1001,9 +1145,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1036,6 +1180,16 @@ dependencies = [ "hashbrown 0.12.3", ] +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", +] + [[package]] name = "instant" version = "0.1.12" @@ -1045,6 +1199,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "ipnet" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" + [[package]] name = "itertools" version = "0.10.5" @@ -1056,15 +1216,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" -version = "0.3.63" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" dependencies = [ "wasm-bindgen", ] @@ -1077,15 +1237,21 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.144" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" + +[[package]] +name = "linux-raw-sys" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", @@ -1093,12 +1259,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "magnetar" @@ -1115,6 +1278,7 @@ dependencies = [ "magnetar_common", "magnetar_core", "magnetar_nodeinfo", + "magnetar_sdk", "magnetar_webfinger", "miette", "percent-encoding", @@ -1123,7 +1287,7 @@ dependencies = [ "strum", "thiserror", "tokio", - "toml 0.7.4", + "toml 0.7.6", "tower", "tower-http", "tracing", @@ -1146,7 +1310,7 @@ dependencies = [ "tera", "thiserror", "tokio", - "toml 0.7.4", + "toml 0.7.6", "tower", "tower-http", "tracing", @@ -1184,7 +1348,7 @@ dependencies = [ "percent-encoding", "serde", "thiserror", - "toml 0.7.4", + "toml 0.7.6", ] [[package]] @@ -1203,6 +1367,33 @@ dependencies = [ "serde_json", ] +[[package]] +name = "magnetar_sdk" +version = "0.2.0" +dependencies = [ + "async-trait", + "chrono", + "http", + "js-sys", + "magnetar_sdk_macros", + "reqwest", + "serde", + "serde-wasm-bindgen", + "serde_json", + "ts-rs", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "magnetar_sdk_macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn 2.0.28", +] + [[package]] name = "magnetar_webfinger" version = "0.2.0" @@ -1218,14 +1409,14 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] name = "matchit" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b87248edafb776e59e6ee64a79086f65890d3510f2c656c000bf2a7e8a0aea40" +checksum = "ed1202b2a6f884ae56f04cff409ab315c5ce26b5e58d7412e484f01fd52f52ef" [[package]] name = "md-5" @@ -1244,9 +1435,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "miette" -version = "5.9.0" +version = "5.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a236ff270093b0b67451bc50a509bd1bad302cb1d3c7d37d5efe931238581fa9" +checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e" dependencies = [ "miette-derive", "once_cell", @@ -1256,13 +1447,13 @@ dependencies = [ [[package]] name = "miette-derive" -version = "5.9.0" +version = "5.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4901771e1d44ddb37964565c654a3223ba41a594d02b8da471cc4464912b5cfa" +checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.28", ] [[package]] @@ -1288,15 +1479,41 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] -name = "mio" -version = "0.8.6" +name = "miniz_oxide" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", - "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.45.0", + "windows-sys", +] + +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", ] [[package]] @@ -1342,28 +1559,81 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] [[package]] name = "num_cpus" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ "hermit-abi", "libc", ] [[package]] -name = "once_cell" -version = "1.17.1" +name = "object" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "openssl" +version = "0.10.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "345df152bc43501c5eb9e4654ff05f794effb78d4efe3d53abc158baddc0703d" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "374533b0e45f3a7ced10fcaeccca020e66656bc03dac384f852e4e5a7a8104a6" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] [[package]] name = "os_str_bytes" @@ -1418,7 +1688,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.7", + "parking_lot_core 0.9.8", ] [[package]] @@ -1430,22 +1700,22 @@ dependencies = [ "cfg-if", "instant", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", "winapi", ] [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.3.5", "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] @@ -1459,21 +1729,21 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.7.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73935e4d55e2abf7f130186537b19e7a4abc886a0252380b59248af473a3fc9" +checksum = "1acb4a4365a13f749a93f1a094a7805e5cfa0955373a9de860d962eaa3a5fe5a" dependencies = [ "thiserror", "ucd-trie", @@ -1481,9 +1751,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aef623c9bbfa0eedf5a0efba11a5ee83209c326653ca31ff019bec3a95bfff2b" +checksum = "666d00490d4ac815001da55838c500eafb0320019bbaa44444137c48b443a853" dependencies = [ "pest", "pest_generator", @@ -1491,22 +1761,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e8cba4ec22bada7fc55ffe51e2deb6a0e0db2d0b7ab0b103acc80d2510c190" +checksum = "68ca01446f50dbda87c1786af8770d535423fa8a53aec03b8f4e3d7eb10e0929" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.28", ] [[package]] name = "pest_meta" -version = "2.7.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01f71cb40bd8bb94232df14b946909e14660e33fc05db3e50ae2a82d7ea0ca0" +checksum = "56af0a30af74d0445c0bf6d9d051c979b516a1a5af790d251daee76005420a48" dependencies = [ "once_cell", "pest", @@ -1554,29 +1824,29 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" +checksum = "030ad2bc4db10a8944cb0d837f158bdfec4d4a4873ab701a95046770d11f8842" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" +checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.28", ] [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" [[package]] name = "pin-utils" @@ -1584,6 +1854,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkg-config" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1625,9 +1901,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.58" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa1fb82fc0c281dd9671101b66b771ebbe1eaf967b96ac8740dcba4b70005ca8" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] @@ -1654,9 +1930,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.27" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" dependencies = [ "proc-macro2", ] @@ -1726,7 +2002,16 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags 1.3.2", ] [[package]] @@ -1736,19 +2021,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom", - "redox_syscall", + "redox_syscall 0.2.16", "thiserror", ] [[package]] name = "regex" -version = "1.8.1" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" +checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" dependencies = [ - "aho-corasick 1.0.2", + "aho-corasick", "memchr", - "regex-syntax 0.7.1", + "regex-automata 0.3.4", + "regex-syntax 0.7.4", ] [[package]] @@ -1760,6 +2046,17 @@ dependencies = [ "regex-syntax 0.6.29", ] +[[package]] +name = "regex-automata" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7b6d6190b7594385f61bd3911cd1be99dfddcfc365a4160cc2ab5bff4aed294" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.7.4", +] + [[package]] name = "regex-syntax" version = "0.6.29" @@ -1768,9 +2065,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.1" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" +checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" [[package]] name = "rend" @@ -1781,6 +2078,43 @@ dependencies = [ "bytecheck", ] +[[package]] +name = "reqwest" +version = "0.11.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +dependencies = [ + "base64 0.21.2", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + [[package]] name = "ring" version = "0.16.20" @@ -1826,13 +2160,12 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.29.1" +version = "1.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26bd36b60561ee1fb5ec2817f198b6fd09fa571c897a5e86d1487cfc2b096dfc" +checksum = "4a2ab0025103a60ecaaf3abf24db1db240a4e1c15837090d2c32f625ac98abea" dependencies = [ "arrayvec", "borsh", - "bytecheck", "byteorder", "bytes", "num-traits", @@ -1842,6 +2175,25 @@ dependencies = [ "serde_json", ] +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustix" +version = "0.38.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee020b1716f0a80e2ace9b03441a749e402e86712f15f16fe8a8f75afac732f" +dependencies = [ + "bitflags 2.3.3", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + [[package]] name = "rustls" version = "0.20.8" @@ -1856,24 +2208,24 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" +checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.0", + "base64 0.21.2", ] [[package]] name = "rustversion" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "same-file" @@ -1885,10 +2237,19 @@ dependencies = [ ] [[package]] -name = "scopeguard" -version = "1.1.0" +name = "schannel" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sct" @@ -1922,7 +2283,7 @@ dependencies = [ "serde_json", "sqlx", "thiserror", - "time 0.3.21", + "time 0.3.25", "tracing", "url", "uuid", @@ -1985,7 +2346,7 @@ dependencies = [ "rust_decimal", "sea-query-derive", "serde_json", - "time 0.3.21", + "time 0.3.25", "uuid", ] @@ -2001,7 +2362,7 @@ dependencies = [ "sea-query", "serde_json", "sqlx", - "time 0.3.21", + "time 0.3.25", "uuid", ] @@ -2070,30 +2431,64 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" [[package]] -name = "serde" -version = "1.0.163" +name = "security-framework" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.180" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea67f183f058fe88a4e3ec6e2788e003840893b91bac4559cabedd00863b3ed" dependencies = [ "serde_derive", ] [[package]] -name = "serde_derive" -version = "1.0.163" +name = "serde-wasm-bindgen" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + +[[package]] +name = "serde_derive" +version = "1.0.180" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24e744d7782b686ab3b73267ef05697159cc0e5abbed3f47f9933165e5219036" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.28", ] [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" dependencies = [ "itoa", "ryu", @@ -2102,18 +2497,19 @@ dependencies = [ [[package]] name = "serde_path_to_error" -version = "0.1.11" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7f05c1d5476066defcdfacce1f52fc3cae3af1d3089727100c02ae92e5abbe0" +checksum = "4beec8bce849d58d06238cb50db2e1c417cfeafa4c63f692b15c82b7c80f8335" dependencies = [ + "itoa", "serde", ] [[package]] name = "serde_spanned" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93107647184f6027e3b7dcb2e11034cf95ffa1e3a682c67951963ac69c1c007d" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" dependencies = [ "serde", ] @@ -2149,9 +2545,9 @@ checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" dependencies = [ "cfg-if", "cpufeatures", @@ -2208,9 +2604,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "socket2" @@ -2259,7 +2655,7 @@ dependencies = [ "atoi", "base64 0.13.1", "bigdecimal", - "bitflags", + "bitflags 1.3.2", "byteorder", "bytes", "chrono", @@ -2276,7 +2672,7 @@ dependencies = [ "hex", "hkdf", "hmac", - "indexmap", + "indexmap 1.9.3", "itoa", "libc", "log", @@ -2299,7 +2695,7 @@ dependencies = [ "sqlx-rt", "stringprep", "thiserror", - "time 0.3.21", + "time 0.3.25", "tokio-stream", "url", "uuid", @@ -2339,9 +2735,9 @@ dependencies = [ [[package]] name = "stringprep" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ee348cb74b87454fff4b551cbf727025810a004f88aeacae7f85b87f4e9a1c1" +checksum = "db3737bde7edce97102e0e2b15365bf7a20bfdb5f60f4f9e8d7004258a51a8da" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -2372,14 +2768,14 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.16", + "syn 2.0.28", ] [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" @@ -2394,9 +2790,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.16" +version = "2.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" +checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" dependencies = [ "proc-macro2", "quote", @@ -2415,6 +2811,19 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "tempfile" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5486094ee78b2e5038a6382ed7645bc084dc2ec433426ca4c3cb61e2007b8998" +dependencies = [ + "cfg-if", + "fastrand", + "redox_syscall 0.3.5", + "rustix", + "windows-sys", +] + [[package]] name = "tera" version = "1.17.1" @@ -2437,6 +2846,15 @@ dependencies = [ "unic-segment", ] +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + [[package]] name = "textwrap" version = "0.16.0" @@ -2445,22 +2863,22 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.28", ] [[package]] @@ -2486,10 +2904,11 @@ dependencies = [ [[package]] name = "time" -version = "0.3.21" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" +checksum = "b0fdd63d58b18d663fbdf70e049f00a22c8e42be082203be7f26589213cd75ea" dependencies = [ + "deranged", "itoa", "serde", "time-core", @@ -2504,9 +2923,9 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" +checksum = "eb71511c991639bb078fd5bf97757e03914361c48100d52878b8e52b46fb92cd" dependencies = [ "time-core", ] @@ -2528,11 +2947,12 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.28.1" +version = "1.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aa32867d44e6f2ce3385e89dceb990188b8bb0fb25b0cf576647a6f98ac5105" +checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" dependencies = [ "autocfg", + "backtrace", "bytes", "libc", "mio", @@ -2542,7 +2962,7 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -2553,7 +2973,17 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.28", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", ] [[package]] @@ -2603,9 +3033,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6135d499e69981f9ff0ef2167955a5333c35e36f6937d382974566b3d5b94ec" +checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" dependencies = [ "serde", "serde_spanned", @@ -2615,20 +3045,20 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.9" +version = "0.19.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d964908cec0d030b812013af25a0e57fddfadb1e066ecc6681d86253129d4f" +checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" dependencies = [ - "indexmap", + "indexmap 2.0.0", "serde", "serde_spanned", "toml_datetime", @@ -2653,11 +3083,11 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d1d42a9b3f3ec46ba828e8d376aec14592ea199f70a06a548587ecd1c4ab658" +checksum = "55ae70283aba8d2a8b411c695c437fe25b8b5e44e23e780662002fc72fb47a82" dependencies = [ - "bitflags", + "bitflags 2.3.3", "bytes", "futures-core", "futures-util", @@ -2703,13 +3133,13 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.28", ] [[package]] @@ -2757,6 +3187,30 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +[[package]] +name = "ts-rs" +version = "6.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4added4070a4fdf9df03457206cd2e4b12417c8560a2954d91ffcbe60177a56a" +dependencies = [ + "chrono", + "thiserror", + "ts-rs-macros", +] + +[[package]] +name = "ts-rs-macros" +version = "6.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f807fdb3151fee75df7485b901a89624358cd07a67a8fb1a5831bf5a07681ff" +dependencies = [ + "Inflector", + "proc-macro2", + "quote", + "syn 1.0.109", + "termcolor", +] + [[package]] name = "typenum" version = "1.16.0" @@ -2765,9 +3219,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "ucd-trie" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "uncased" @@ -2845,9 +3299,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unicode-normalization" @@ -2884,9 +3338,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" dependencies = [ "form_urlencoded", "idna", @@ -2895,9 +3349,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.3.3" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" +checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" dependencies = [ "serde", ] @@ -2908,6 +3362,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.4" @@ -2926,11 +3386,10 @@ dependencies = [ [[package]] name = "want" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" dependencies = [ - "log", "try-lock", ] @@ -2948,9 +3407,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2958,24 +3417,36 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.28", "wasm-bindgen-shared", ] [[package]] -name = "wasm-bindgen-macro" -version = "0.2.86" +name = "wasm-bindgen-futures" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" +checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2983,28 +3454,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.28", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "web-sys" -version = "0.3.63" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" dependencies = [ "js-sys", "wasm-bindgen", @@ -3031,9 +3502,9 @@ dependencies = [ [[package]] name = "whoami" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c70234412ca409cc04e864e89523cb0fc37f5e1344ebed5a3ebf4192b6b9f68" +checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" dependencies = [ "wasm-bindgen", "web-sys", @@ -3076,16 +3547,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.0", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", + "windows-targets", ] [[package]] @@ -3094,117 +3556,60 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", + "windows-targets", ] [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows-targets" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" -dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - [[package]] name = "windows_aarch64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - [[package]] name = "windows_x86_64_msvc" version = "0.48.0" @@ -3213,13 +3618,22 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.4.6" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" +checksum = "f46aab759304e4d7b2075a9aecba26228bb073ee8c50db796b2c72c676b5d807" dependencies = [ "memchr", ] +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + [[package]] name = "wyz" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 6b6540f..befdf89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ members = [ "ext_calckey_model", "fe_calckey", "magnetar_common", + "magnetar_sdk", "core" ] @@ -21,6 +22,7 @@ version = "0.2.0" edition = "2021" [workspace.dependencies] +async-trait = "0.1" axum = "0.6" cached = "0.44" cfg-if = "1" @@ -29,15 +31,19 @@ dotenvy = "0.15" futures-core = "0.3" futures-util = "0.3" headers = "0.3" +http = "0.2" hyper = "0.14" +js-sys = "0.3" log = "0.4" miette = "5.9" percent-encoding = "2.2" redis = "0.23" +reqwest = "0.11" sea-orm = "0.11" sea-orm-migration = "0.11" serde = "1" serde_json = "1" +serde-wasm-bindgen = "0.5" strum = "0.25" tera = { version = "1", default-features = false } thiserror = "1" @@ -48,8 +54,12 @@ tower = "0.4" tower-http = "0.4" tracing = "0.1" tracing-subscriber = "0.3" +ts-rs = "6" url = "2.3" walkdir = "2.3" +wasm-bindgen = "0.2" +wasm-bindgen-futures = "0.4" +web-sys = "0.3" [dependencies] magnetar_core = { path = "./core" } @@ -57,6 +67,7 @@ magnetar_common = { path = "./magnetar_common" } magnetar_webfinger = { path = "./ext_webfinger" } magnetar_nodeinfo = { path = "./ext_nodeinfo" } magnetar_calckey_model = { path = "./ext_calckey_model" } +magnetar_sdk = { path = "./magnetar_sdk" } cached = { workspace = true } chrono = { workspace = true } @@ -83,3 +94,6 @@ percent-encoding = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } toml = { workspace = true } + +[profile.release] +lto = true \ No newline at end of file diff --git a/magnetar_sdk/Cargo.toml b/magnetar_sdk/Cargo.toml new file mode 100644 index 0000000..73b4f32 --- /dev/null +++ b/magnetar_sdk/Cargo.toml @@ -0,0 +1,46 @@ +[package] +name = "magnetar_sdk" +version.workspace = true +edition.workspace = true + +[lib] +crate-type = ["rlib", "cdylib"] + +[features] +reqwest = ["dep:reqwest"] + +[target.'cfg(not(target_arch = "wasm32"))'.features] +default = ["reqwest"] + +[target.'cfg(target_arch = "wasm32")'.features] +default = [] + + +[dependencies] +magnetar_sdk_macros = { path = "./macros" } + +chrono = { workspace = true, features = ["serde"] } +reqwest = { workspace = true, features = ["json"], optional = true } + +http = { workspace = true } +async-trait = { workspace = true } +serde = { workspace = true, features = ["derive"] } +serde_json = { workspace = true } + +ts-rs = { workspace = true, features = ["chrono", "chrono-impl"] } + +[target.'cfg(target_arch = "wasm32")'.dependencies] +wasm-bindgen = { workspace = true } +wasm-bindgen-futures = { workspace = true } +serde-wasm-bindgen = { workspace = true } +chrono = { workspace = true, features = ["serde", "wasm-bindgen", "js-sys"] } +js-sys = { workspace = true } +web-sys = { workspace = true, features = [ + "Headers", + "Request", + "RequestInit", + "RequestMode", + "Response", + "Window", + "UrlSearchParams" +] } diff --git a/magnetar_sdk/macros/Cargo.toml b/magnetar_sdk/macros/Cargo.toml new file mode 100644 index 0000000..e116ad5 --- /dev/null +++ b/magnetar_sdk/macros/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "magnetar_sdk_macros" +version.workspace = true +edition.workspace = true + +[lib] +proc-macro = true + +[dependencies] +syn = { version = "2", features = ["full", "extra-traits"] } +quote = "1" \ No newline at end of file diff --git a/magnetar_sdk/macros/src/lib.rs b/magnetar_sdk/macros/src/lib.rs new file mode 100644 index 0000000..7339dc9 --- /dev/null +++ b/magnetar_sdk/macros/src/lib.rs @@ -0,0 +1,237 @@ +use proc_macro::TokenStream; +use std::collections::HashSet; +use syn::parse::Parse; +use syn::punctuated::Punctuated; +use syn::{Expr, ExprLit, ExprPath, Ident, Lit, Meta, MetaNameValue, Token}; + +struct Field { + name: Ident, + ty: Ident, +} + +struct PackInput { + struct_name: syn::Ident, + fields: Vec, +} + +impl Parse for PackInput { + fn parse(input: syn::parse::ParseStream) -> syn::Result { + let struct_name = input.parse()?; + let _ = input.parse::()?; + + let mut fields = Vec::new(); + + loop { + let ty = input.parse()?; + let _alias_keyword = input.parse::()?; + let name = input.parse()?; + + fields.push(Field { name, ty }); + + if input.is_empty() { + break; + } + + let _ = input.parse::()?; + } + + Ok(PackInput { + struct_name, + fields, + }) + } +} + +#[proc_macro] +pub fn pack(item: TokenStream) -> TokenStream { + let parsed = syn::parse_macro_input!(item as PackInput); + let struct_name = &parsed.struct_name; + let fields = &parsed.fields; + + let names = fields.iter().map(|f| &f.name); + let types = fields.iter().map(|f| &f.ty); + + let export_path = format!("bindings/packed/{}.ts", struct_name); + + let expanded = quote::quote! { + #[derive(Clone, Debug, Deserialize, Serialize, TS)] + #[ts(export, export_to = #export_path)] + pub struct #struct_name { + #( + #[serde(flatten)] + pub #names: #types + ),* + } + }; + + TokenStream::from(expanded) +} + +#[proc_macro_derive(Endpoint, attributes(name, endpoint, method, request, response))] +pub fn derive_endpoint(item: TokenStream) -> TokenStream { + let input = syn::parse_macro_input!(item as syn::DeriveInput); + + let struct_name = input.ident; + assert!(input.generics.params.is_empty(), "generics not supported"); + let where_clause = input.generics.where_clause; + assert!(where_clause.is_none(), "where clauses not supported"); + let data = match input.data { + syn::Data::Struct(data) => data, + _ => panic!("only unit structs are supported"), + }; + assert!( + matches!(data.fields, syn::Fields::Unit), + "only unit structs are supported" + ); + + let mut name = struct_name.to_string(); + let mut endpoint = None; + let mut method = None; + let mut request = None; + let mut response = None; + + let mut found = HashSet::new(); + + let struct_attrs = input.attrs; + + for struct_attr in struct_attrs { + if !struct_attr.meta.path().is_ident("endpoint") { + continue; + } + + if struct_attr.style != syn::AttrStyle::Outer { + panic!("expected outer attribute"); + } + + let Meta::List(list) = struct_attr.meta else { + panic!("expected a list of attributes"); + }; + + let nested = list + .parse_args_with(Punctuated::::parse_terminated) + .expect("expected a list of attributes"); + + for kvp in nested { + let key = kvp + .path + .get_ident() + .expect("expected a single identifier") + .to_owned(); + let value = kvp.value; + + if found.contains(&key) { + panic!("duplicate attribute: {}", key); + } + + match key.to_string().as_ref() { + "name" => { + let Expr::Lit(ExprLit { lit: Lit::Str(new_name), .. }) = value else { + panic!("expected a string literal"); + }; + + name = new_name.value(); + } + "endpoint" => { + let Expr::Lit(ExprLit { lit: Lit::Str(endpoint_val), .. }) = value else { + panic!("expected a string literal"); + }; + + endpoint = Some(endpoint_val.value()); + } + "method" => { + let Expr::Path(ExprPath { path, .. }) = value else { + panic!("expected a an identifier"); + }; + + method = Some(path); + } + "request" => { + let Expr::Path(ExprPath { path, .. }) = value else { + panic!("expected a an identifier"); + }; + + request = Some(path); + } + "response" => { + let Expr::Path(ExprPath { path, .. }) = value else { + panic!("expected an identifier") + }; + + response = Some(path); + } + _ => panic!("unknown attribute: {}", key), + } + + found.insert(key); + } + } + + let endpoint = endpoint.expect("missing endpoint attribute"); + let method = method.expect("missing method attribute"); + let request = request.expect("missing request attribute"); + let response = response.expect("missing response attribute"); + + let ts_path = format!("bindings/endpoints/{}.ts", name); + + let expanded = quote::quote! { + impl Default for #struct_name { + fn default() -> Self { + Self + } + } + + impl Endpoint for #struct_name { + const NAME: &'static str = #name; + const ENDPOINT: &'static str = #endpoint; + const METHOD: Method = #method; + + type Request = #request; + type Response = #response; + } + + #[cfg(test)] + #[test] + fn export_bindings_getuserbyid() { + #struct_name::export().expect("could not export type"); + } + + impl TS for #struct_name { + const EXPORT_TO: Option<&'static str> = Some(#ts_path); + + fn decl() -> String { + format!( + "interface {} {{\n \ + endpoint: \"{}\";\n \ + method: \"{}\";\n \ + request: {};\n \ + response: {};\n\ + }} + ", + Self::name(), + Self::ENDPOINT, + Self::METHOD, + <#struct_name as Endpoint>::Request::name(), + <#struct_name as Endpoint>::Response::name() + ) + } + + fn name() -> String { + #struct_name::NAME.to_string() + } + + fn dependencies() -> Vec { + vec![ + Dependency::from_ty::<<#struct_name as Endpoint>::Request>().unwrap(), + Dependency::from_ty::<<#struct_name as Endpoint>::Response>().unwrap(), + ] + } + + fn transparent() -> bool { + false + } + } + + }; + + TokenStream::from(expanded) +} diff --git a/magnetar_sdk/src/client/fetch.rs b/magnetar_sdk/src/client/fetch.rs new file mode 100644 index 0000000..a8cae60 --- /dev/null +++ b/magnetar_sdk/src/client/fetch.rs @@ -0,0 +1,277 @@ +use crate::client::ApiClientImpl; +use crate::endpoints::list::match_endpoint; +use crate::endpoints::{Endpoint, ErrorKind, ResponseError}; +use crate::Client; +use http::Method; +use serde::de::DeserializeOwned; +use serde::Serialize; +use std::collections::HashMap; +use wasm_bindgen::prelude::*; + +pub struct FetchClient { + base_url: String, + application: String, +} + +impl FetchClient { + pub fn new(base_url: &str, application: &str) -> Self { + FetchClient { + base_url: base_url.to_string(), + application: application.to_string(), + } + } +} + +#[async_trait::async_trait(?Send)] +impl Client for FetchClient { + fn base_url(&self) -> &str { + &self.base_url + } + + async fn call<'a, I, O, E>( + &self, + endpoint: &E, + data: &I, + path_params: &impl AsRef<[(&'a str, &'a str)]>, + ) -> Result + where + I: Serialize + DeserializeOwned + Send + 'static, + O: Serialize + DeserializeOwned + Send + 'static, + E: Endpoint + Send + 'static, + { + let url = endpoint.template_path(self.base_url(), path_params); + let url = if E::METHOD == Method::GET { + let search = web_sys::UrlSearchParams::new_with_str_sequence_sequence( + &serde_wasm_bindgen::to_value(data).unwrap(), + ) + .unwrap(); + + format!("{}?{}", url, search.to_string()) + } else { + url + }; + + let mut opts = web_sys::RequestInit::new(); + opts.method(E::METHOD.as_str()); + if E::METHOD != Method::GET { + opts.body(Some(&serde_wasm_bindgen::to_value(data).unwrap())); + } + let headers = web_sys::Headers::new().unwrap(); + headers.set("Content-Type", "application/json").unwrap(); + headers.set("User-Agent", &self.application).unwrap(); + opts.headers(&headers); + + let req = web_sys::Request::new_with_str_and_init(&url, &opts).unwrap(); + + let js_response = wasm_bindgen_futures::JsFuture::from( + web_sys::window() + .ok_or_else(|| ResponseError { + kind: ErrorKind::Other, + code: "FetchClient:NoWindow".to_string(), + message: "No window object".to_string(), + status: None, + })? + .fetch_with_request(&req), + ) + .await + .map_err(|e| ResponseError { + kind: ErrorKind::Other, + code: "FetchClient:FetchFail".to_string(), + message: format!("{:#?}", e), + status: None, + })?; + + let response = web_sys::Response::from(js_response); + let status = response.status(); + + if (400..=599).contains(&status) { + let body = wasm_bindgen_futures::JsFuture::from(response.json().map_err(|e| { + ResponseError { + kind: ErrorKind::Other, + code: "FetchClient:ResponseErrorPromiseFail".to_string(), + message: format!("{:#?}", e), + status: Some(status), + } + })?) + .await + .map_err(|e| ResponseError { + kind: ErrorKind::ApiError, + code: "FetchClient:ResponseErrorFail".to_string(), + message: format!("{:#?}", e), + status: Some(status), + })?; + + let data = serde_wasm_bindgen::from_value::(body).map_err(|e| { + ResponseError { + kind: ErrorKind::ApiError, + code: "FetchClient:ResponseErrorDeserializeFail".to_string(), + message: format!("{:#?}", e), + status: Some(status), + } + })?; + + return Err(data); + } else if (200..=299).contains(&status) { + if status == 204 { + return if let Some(val) = E::default_response() { + Ok(val) + } else { + Err(ResponseError { + kind: ErrorKind::ApiError, + code: "FetchClient:ResponseError204".to_string(), + message: "Response is empty".to_string(), + status: Some(status), + }) + }; + } + + let body = wasm_bindgen_futures::JsFuture::from(response.json().map_err(|e| { + ResponseError { + kind: ErrorKind::Other, + code: "FetchClient:ResponseJsonPromiseFail".to_string(), + message: format!("{:#?}", e), + status: None, + } + })?) + .await + .map_err(|e| ResponseError { + kind: ErrorKind::Other, + code: "FetchClient:ResponseJsonFail".to_string(), + message: format!("{:#?}", e), + status: None, + })?; + + let data = serde_wasm_bindgen::from_value::(body).map_err(|e| ResponseError { + kind: ErrorKind::Other, + code: "FetchClient:ResponseErrorDeserializeFail".to_string(), + message: e.to_string(), + status: None, + })?; + + return Ok(data); + } + + Err(ResponseError { + kind: ErrorKind::ApiError, + code: "FetchClient:ApiUnknownStatusError".to_string(), + message: response.status().to_string(), + status: Some(response.status()), + }) + } +} + +#[wasm_bindgen(getter_with_clone)] +pub struct ApiClientOptions { + base_url: String, + application: String, +} + +#[wasm_bindgen] +pub struct ApiClient { + client: ApiClientImpl, +} + +#[wasm_bindgen] +impl ApiClient { + #[wasm_bindgen(constructor)] + pub fn new(implementation: &str, options: ApiClientOptions) -> Option { + match implementation { + "fetch" => Some(Self { + client: ApiClientImpl::Fetch(FetchClient::new( + &options.base_url, + &options.application, + )), + }), + #[cfg(feature = "reqwest")] + "reqwest" => Some(Self { + client: ApiClientImpl::Reqwest(crate::client::reqwest::ReqwestClient::new( + &options.base_url, + &options.application, + )), + }), + _ => None, + } + } + + async fn call( + &self, + endpoint: &E, + data: &I, + path_params: &[(&str, &str)], + ) -> Result + where + I: Serialize + DeserializeOwned + Send + 'static, + O: Serialize + DeserializeOwned + Send + 'static, + E: Endpoint + Send + 'static, + { + match &self.client { + ApiClientImpl::Fetch(client) => { + client.call::(endpoint, data, &path_params).await + } + #[cfg(feature = "reqwest")] + ApiClientImpl::Reqwest(client) => { + client.call::(endpoint, data, &path_params).await + } + } + } +} + +#[wasm_bindgen(getter_with_clone)] +#[derive(Debug, Clone)] +pub struct EndpointLike { + pub path: String, + pub method: String, +} + +#[wasm_bindgen] +pub async fn api_call( + client: &ApiClient, + endpoint_like: &EndpointLike, + data: JsValue, + path_params: JsValue, +) -> Result { + let method = Method::try_from(endpoint_like.method.as_str()).map_err(|e| ResponseError { + kind: ErrorKind::Other, + code: "Bindgen::ParseMethod".to_string(), + message: e.to_string(), + status: None, + })?; + + let endpoint = match_endpoint(&endpoint_like.path, &method).ok_or_else(|| ResponseError { + kind: ErrorKind::Other, + code: "Bindgen::MatchEndpoint".to_string(), + message: format!( + "No endpoint `{}` with method `{}` found", + endpoint_like.path, method + ), + status: None, + })?; + + let input = serde_wasm_bindgen::from_value(data).map_err(|e| ResponseError { + kind: ErrorKind::Other, + code: "Bindgen::DeserializeInput".to_string(), + message: e.to_string(), + status: None, + })?; + + let path_params = serde_wasm_bindgen::from_value::>(path_params) + .map_err(|e| ResponseError { + kind: ErrorKind::Other, + code: "Bindgen::DeserializePathParams".to_string(), + message: e.to_string(), + status: None, + })?; + + let path_params_borrow = path_params + .iter() + .map(|(k, v)| (k.as_str(), v.as_str())) + .collect::>(); + + serde_wasm_bindgen::to_value(&client.call(&endpoint, &input, &path_params_borrow).await?) + .map_err(|e| ResponseError { + kind: ErrorKind::Other, + code: "Bindgen::SerializeOutput".to_string(), + message: e.to_string(), + status: None, + }) +} diff --git a/magnetar_sdk/src/client/mod.rs b/magnetar_sdk/src/client/mod.rs new file mode 100644 index 0000000..6cedeae --- /dev/null +++ b/magnetar_sdk/src/client/mod.rs @@ -0,0 +1,12 @@ +#[cfg(feature = "reqwest")] +pub mod reqwest; + +#[cfg(target_arch = "wasm32")] +pub mod fetch; + +pub enum ApiClientImpl { + #[cfg(feature = "reqwest")] + Reqwest(reqwest::ReqwestClient), + #[cfg(target_arch = "wasm32")] + Fetch(fetch::FetchClient), +} diff --git a/magnetar_sdk/src/client/reqwest.rs b/magnetar_sdk/src/client/reqwest.rs new file mode 100644 index 0000000..a8930dd --- /dev/null +++ b/magnetar_sdk/src/client/reqwest.rs @@ -0,0 +1,112 @@ +use crate::endpoints::{Endpoint, ErrorKind, ResponseError}; +use crate::Client; +use http::header::{CONTENT_TYPE, USER_AGENT}; +use http::{HeaderMap, HeaderValue, Method, StatusCode}; +use serde::de::DeserializeOwned; +use serde::Serialize; + +pub struct ReqwestClient { + client: reqwest::Client, + base_url: String, +} + +impl ReqwestClient { + pub fn new(base_url: &str, application: &str) -> Self { + let mut headers = HeaderMap::new(); + headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").unwrap(), + ); + headers.insert(USER_AGENT, HeaderValue::from_str(application).unwrap()); + + let client_builder = reqwest::ClientBuilder::new().default_headers(headers); + + #[cfg(not(target_arch = "wasm32"))] + let client_builder = { client_builder.https_only(true) }; + + let client = client_builder.build().unwrap(); + + ReqwestClient { + client, + base_url: base_url.to_string(), + } + } +} + +#[async_trait::async_trait(?Send)] +impl Client for ReqwestClient { + fn base_url(&self) -> &str { + &self.base_url + } + + async fn call<'a, I, O, E>( + &self, + endpoint: &E, + data: &I, + path_params: &impl AsRef<[(&'a str, &'a str)]>, + ) -> Result + where + I: Serialize + DeserializeOwned + Send + 'static, + O: Serialize + DeserializeOwned + Send + 'static, + E: Endpoint + Send + 'static, + { + let url = endpoint.template_path(self.base_url(), path_params); + + let req = self.client.request(E::METHOD, &url); + + let req = if E::METHOD == Method::GET { + req.query(&data) + } else { + req.json(&data) + }; + + let response = req.send().await.map_err(|e| ResponseError { + kind: ErrorKind::Other, + code: "ReqwestClient:Fail".to_string(), + message: e.to_string(), + status: None, + })?; + + let status = response.status(); + if status.is_client_error() || status.is_server_error() { + match response.json::().await { + Ok(res) => Err(res), + Err(e) => Err(ResponseError { + kind: ErrorKind::ApiError, + code: "ReqwestClient:ApiGenericError".to_string(), + message: e.to_string(), + status: Some(status.as_u16()), + }), + } + } else if status.is_success() { + if status == StatusCode::NO_CONTENT.as_u16() { + return if let Some(val) = E::default_response() { + Ok(val) + } else { + Err(ResponseError { + kind: ErrorKind::ApiError, + code: "ReqwestClient:ResponseError204".to_string(), + message: "Response is empty".to_string(), + status: Some(status.as_u16()), + }) + }; + } + + let data = response.json::().await.map_err(|e| ResponseError { + kind: ErrorKind::ApiError, + code: "ReqwestClient:JsonError".to_string(), + message: e.to_string(), + status: Some(status.as_u16()), + })?; + + Ok(data) + } else { + Err(ResponseError { + kind: ErrorKind::ApiError, + code: "ReqwestClient:ApiUnknownStatusError".to_string(), + message: status.to_string(), + status: Some(status.as_u16()), + }) + } + } +} diff --git a/magnetar_sdk/src/endpoints/list.rs b/magnetar_sdk/src/endpoints/list.rs new file mode 100644 index 0000000..572e446 --- /dev/null +++ b/magnetar_sdk/src/endpoints/list.rs @@ -0,0 +1,21 @@ +use crate::endpoints::Endpoint; + +macro_rules! match_from { + (($endpoint:expr, $method:expr) in [$($e:ty,)*]) => { + match ($endpoint, $method) { + $( + (<$e as Endpoint>::ENDPOINT, &<$e as Endpoint>::METHOD) => Some(<$e as Default>::default()), + )* + _ => None, + } + }; +} + +pub(crate) fn match_endpoint(endpoint: &str, method: &http::Method) -> Option { + match_from!( + (endpoint, method) + in [ + crate::endpoints::user::GetUserById, + ] + ) +} diff --git a/magnetar_sdk/src/endpoints/mod.rs b/magnetar_sdk/src/endpoints/mod.rs new file mode 100644 index 0000000..8d37ace --- /dev/null +++ b/magnetar_sdk/src/endpoints/mod.rs @@ -0,0 +1,57 @@ +pub(crate) mod list; +pub mod user; + +use http::Method; +use serde::de::DeserializeOwned; +use serde::{Deserialize, Serialize}; +use ts_rs::TS; + +#[cfg(target_arch = "wasm32")] +use wasm_bindgen::prelude::*; + +#[cfg_attr(target_arch = "wasm32", wasm_bindgen(getter_with_clone))] +#[derive(Clone, Debug, Serialize, Deserialize, TS)] +pub struct ResponseError { + pub kind: ErrorKind, + pub status: Option, + pub code: String, + pub message: String, +} + +#[cfg_attr(target_arch = "wasm32", wasm_bindgen)] +#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, TS)] +pub enum ErrorKind { + #[default] + ApiError, + Other, +} + +#[derive(Clone, Debug, Serialize, Deserialize, TS)] +pub struct Empty; + +impl From for () { + fn from(_: Empty) -> Self {} +} + +pub trait Endpoint { + const NAME: &'static str; + const ENDPOINT: &'static str; + const METHOD: Method; + + type Request: Serialize + DeserializeOwned + Send + Sync + 'static; + type Response: Serialize + DeserializeOwned + Send + Sync + 'static; + + fn default_response() -> Option { + None + } + + fn template_path<'a>(&self, base_path: &str, var: &impl AsRef<[(&'a str, &'a str)]>) -> String { + let mut path_suffix = Self::ENDPOINT.to_string(); + + for (key, value) in var.as_ref() { + path_suffix = path_suffix.replace(&format!(":{}", key), value); + } + + format!("{}{}", base_path, path_suffix) + } +} diff --git a/magnetar_sdk/src/endpoints/user.rs b/magnetar_sdk/src/endpoints/user.rs new file mode 100644 index 0000000..e3261e7 --- /dev/null +++ b/magnetar_sdk/src/endpoints/user.rs @@ -0,0 +1,24 @@ +use crate::endpoints::Endpoint; +use http::Method; +use magnetar_sdk_macros::Endpoint; +use serde::{Deserialize, Serialize}; +use ts_rs::{Dependency, TS}; + +use crate::types::user::PackUserProfileFull; + +#[derive(Serialize, Deserialize, TS)] +#[ts(export)] +pub struct UserByIdReq { + id: String, + #[serde(skip_serializing_if = "Option::is_none")] + detail: Option, +} + +#[derive(Endpoint, Deserialize)] +#[endpoint( + endpoint = "/users/:user_id", + method = Method::GET, + request = UserByIdReq, + response = PackUserProfileFull +)] +pub struct GetUserById; diff --git a/magnetar_sdk/src/lib.rs b/magnetar_sdk/src/lib.rs new file mode 100644 index 0000000..a772769 --- /dev/null +++ b/magnetar_sdk/src/lib.rs @@ -0,0 +1,23 @@ +pub mod client; +pub mod endpoints; +pub mod types; + +use crate::endpoints::Endpoint; +use endpoints::ResponseError; +use serde::{de::DeserializeOwned, Serialize}; + +#[async_trait::async_trait(?Send)] +pub trait Client { + fn base_url(&self) -> &str; + + async fn call<'a, I, O, E>( + &self, + endpoint: &E, + data: &I, + path_params: &impl AsRef<[(&'a str, &'a str)]>, + ) -> Result + where + I: Serialize + DeserializeOwned + Send + 'static, + O: Serialize + DeserializeOwned + Send + 'static, + E: Endpoint + Send + 'static; +} diff --git a/magnetar_sdk/src/types/drive.rs b/magnetar_sdk/src/types/drive.rs new file mode 100644 index 0000000..6d58394 --- /dev/null +++ b/magnetar_sdk/src/types/drive.rs @@ -0,0 +1,89 @@ +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use ts_rs::TS; + +use crate::types::user::PackUserBase; + +use magnetar_sdk_macros::pack; + +use crate::types::Id; + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct ImageMeta { + pub width: Option, + pub height: Option, + pub orientation: Option, + pub color: Option, +} + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct DriveFolderBase { + pub name: String, + pub created_at: DateTime, + pub comment: Option, + pub file_count: u64, + pub folder_count: u64, + pub parent_id: Option, + pub user_id: String, +} + +pack!(PackDriveFolderBase, Id as id & DriveFolderBase as folder); + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct DriveFolderParentExt { + pub folder: Box, +} + +pack!( + PackDriveFolderWithParent, + Id as id & DriveFolderBase as folder & DriveFolderParentExt as parent +); + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct DriveFileBase { + pub name: String, + pub created_at: DateTime, + pub size: u64, + pub sha256: String, + pub mime_type: String, + pub image_meta: ImageMeta, + pub url: Option, + pub thumbnail_url: Option, + pub sensitive: bool, + pub comment: Option, + pub folder_id: Option, + pub user_id: String, +} + +pack!(PackDriveFileBase, Id as id & DriveFileBase as file); + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct DriveFileFolderExt { + pub folder: Box, +} + +pack!( + PackDriveFileWithFolder, + Id as id & DriveFileBase as file & DriveFileFolderExt as folder +); + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct DriveFileUserExt { + pub user: Box, +} + +pack!( + PackDriveFileWithUser, + Id as id & DriveFileBase as file & DriveFileUserExt as user +); + +pack!( + PackDriveFileFull, + Id as id & DriveFileBase as file & DriveFileFolderExt as folder & DriveFileUserExt as user +); diff --git a/magnetar_sdk/src/types/emoji.rs b/magnetar_sdk/src/types/emoji.rs new file mode 100644 index 0000000..5bcb8a3 --- /dev/null +++ b/magnetar_sdk/src/types/emoji.rs @@ -0,0 +1,22 @@ +use serde::{Deserialize, Serialize}; +use ts_rs::TS; + +use crate::types::Id; +use magnetar_sdk_macros::pack; + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct EmojiBase { + pub shortcode: String, + pub url: String, + pub static_url: String, + pub visible_in_picker: bool, + pub category: Option, +} + +pack!(PackEmojiBase, Id as id & EmojiBase as emoji); + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +#[repr(transparent)] +pub struct EmojiContext(pub Vec); diff --git a/magnetar_sdk/src/types/mod.rs b/magnetar_sdk/src/types/mod.rs new file mode 100644 index 0000000..e52aeb0 --- /dev/null +++ b/magnetar_sdk/src/types/mod.rs @@ -0,0 +1,44 @@ +pub mod drive; +pub mod emoji; +pub mod note; +pub mod user; + +use serde::{Deserialize, Serialize}; +use ts_rs::TS; + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +#[repr(transparent)] +pub struct Id { + pub id: String, +} + +#[derive(Copy, Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub enum NotificationType { + Follow, + Mention, + Reply, + Renote, + Quote, + Reaction, + PollVote, + PollEnded, + FollowRequest, + FollowRequestAccepted, + App, +} + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct NotificationSettings { + pub enabled: Vec, +} + +#[derive(Copy, Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub enum FollowVisibility { + Public, + Followers, + Private, +} diff --git a/magnetar_sdk/src/types/note.rs b/magnetar_sdk/src/types/note.rs new file mode 100644 index 0000000..ad09fc1 --- /dev/null +++ b/magnetar_sdk/src/types/note.rs @@ -0,0 +1,103 @@ +use crate::types::emoji::EmojiContext; +use crate::types::user::{PackUserBase, UserBase}; +use crate::types::Id; +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use ts_rs::TS; + +use crate::types::drive::PackDriveFileBase; + +use magnetar_sdk_macros::pack; + +#[derive(Copy, Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub enum NoteVisibility { + Public, + Home, + Followers, + Specified, + Direct, +} + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct PollChoice { + pub title: String, + pub votes_count: u64, + pub voted: bool, +} + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct PollBase { + pub expires_at: DateTime, + pub expired: bool, + pub multiple_choice: bool, + pub options: Vec, +} + +pack!(PackPollBase, Id as id & PollBase as poll); + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct NoteBase { + pub created_at: DateTime, + pub cw: Option, + pub uri: Option, + pub url: Option, + pub text: String, + pub visibility: NoteVisibility, + pub user: Box, + pub parent_note_id: Option, + pub renoted_note_id: Option, + pub reply_count: u64, + pub renote_count: u64, + pub hashtags: Vec, + pub reactions: Vec, + pub emojis: EmojiContext, + pub local_only: bool, +} + +pack!(PackNoteBase, Id as id & NoteBase as note); + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct NoteAttachmentExt { + pub attachments: Vec, + pub poll: Option, +} + +pack!( + PackNoteWithAttachments, + Id as id & NoteBase as note & NoteAttachmentExt as attachment +); + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +pub struct NoteDetailExt { + pub poll: Option, + pub parent_note: Option>, + pub renoted_note: Option>, +} + +pack!( + PackNoteFull, + Id as id & NoteBase as note & NoteAttachmentExt as attachment & NoteDetailExt as detail +); + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +pub struct ReactionBase { + pub created_at: DateTime, + pub user_id: String, +} + +pack!(PackReactionBase, Id as id & ReactionBase as reaction); + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +pub struct ReactionUserExt { + pub user: Box, +} + +pack!( + PackReactionWithUser, + Id as id & ReactionBase as reaction & ReactionUserExt as user +); diff --git a/magnetar_sdk/src/types/user.rs b/magnetar_sdk/src/types/user.rs new file mode 100644 index 0000000..676a76f --- /dev/null +++ b/magnetar_sdk/src/types/user.rs @@ -0,0 +1,187 @@ +use crate::types::emoji::EmojiContext; +use crate::types::note::PackNoteBase; +use crate::types::{Id, NotificationSettings}; +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use ts_rs::TS; + +use magnetar_sdk_macros::pack; + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub enum AvatarDecoration { + None, + CatEars, +} + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub enum SpeechTransform { + None, + Cat, +} + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct ProfileField { + name: String, + value: String, + verified_at: Option>, +} + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct UserBase { + pub acct: String, + pub username: String, + pub display_name: String, + pub host: Option, + pub speech_transform: SpeechTransform, + pub created_at: DateTime, + pub avatar_url: Option, + pub avatar_blurhash: Option, + pub avatar_color: Option, + pub avatar_decoration: AvatarDecoration, + pub admin: bool, + pub moderator: bool, + pub bot: bool, + pub emojis: EmojiContext, +} + +pack!(PackUserBase, Id as id & UserBase as user); + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct UserProfileExt { + pub locked: bool, + pub silenced: bool, + pub suspended: bool, + + pub description: Option, + pub location: Option, + pub birthday: Option>, + pub fields: Vec, + + pub follower_count: u64, + pub following_count: u64, + pub note_count: u64, + + pub url: Option, + + pub moved_to_uri: Option, + pub also_known_as: Option, + + pub banner_url: Option, + pub banner_color: Option, + pub banner_blurhash: Option, + + pub public_reactions: bool, +} + +pack!( + PackUserProfile, + Id as id & UserBase as user & UserProfileExt as profile +); + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct UserProfilePinsEx { + pub pinned_notes: Vec, + // pub pinned_page: Option, +} + +pack!( + PackUserProfileFull, + Id as id + & UserBase as user + & UserProfileExt as profile + & UserProfilePinsEx as pins + & UserRelationExt as relation +); + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct UserRelationExt { + pub last_fetched_at: Option>, + pub follows_you: bool, + pub you_follow: bool, + pub blocks_you: bool, + pub you_block: bool, + pub mute: bool, + pub mute_renotes: bool, +} + +pack!( + PackUserRelation, + Id as id & UserBase as user & UserRelationExt as relation +); +pack!( + PackUserProfileRelation, + Id as id & UserBase as user & UserProfileExt as profile & UserRelationExt as relation +); + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct UserAuthOverviewExt { + pub two_factor_enabled: bool, + pub use_passwordless_login: bool, + pub security_keys: bool, +} + +pack!( + PackUserAuthOverview, + Id as id & UserBase as user & UserAuthOverviewExt as auth +); + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct UserSelfExt { + pub avatar_id: Option, + pub banner_id: Option, + pub email_announcements: bool, + pub always_mark_sensitive: bool, + pub reject_bot_follow_requests: bool, + pub reject_crawlers: bool, + pub reject_ai_training: bool, + pub has_unread_announcements: bool, + pub has_unread_antenna: bool, + pub has_unread_notifications: bool, + pub has_pending_follow_requests: bool, + pub word_mutes: Vec, + pub instance_mutes: Vec, + pub notification_settings: NotificationSettings, +} + +pack!( + PackUserSelf, + Id as id & UserBase as user & UserSelfExt as self_info +); + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct UserDetailExt { + pub uri: Option, + pub updated_at: Option>, +} + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct SecurityKeyBase { + pub name: String, + pub created_at: DateTime, + pub last_used_at: Option>, +} + +pack!(PackSecurityKeyBase, Id as id & SecurityKeyBase as key); + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct UserSecretsExt { + pub email: Option, + pub email_verified: bool, + pub security_keys: Vec, +} +pack!( + PackUserSelfAll, + Id as id & UserBase as user & UserSelfExt as self_info & UserSecretsExt as secrets +);