1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-11-22 19:11:09 +00:00
This commit is contained in:
Felix Ableitner 2024-11-15 16:07:29 +01:00
parent 54951621e4
commit 4381159426
13 changed files with 638 additions and 284 deletions

443
Cargo.lock generated
View file

@ -36,7 +36,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"sha2", "sha2",
"thiserror 1.0.65", "thiserror 1.0.69",
"tokio", "tokio",
"tower 0.4.13", "tower 0.4.13",
"tracing", "tracing",
@ -91,9 +91,9 @@ dependencies = [
[[package]] [[package]]
name = "allocator-api2" name = "allocator-api2"
version = "0.2.18" version = "0.2.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9"
[[package]] [[package]]
name = "android-tzdata" name = "android-tzdata"
@ -117,16 +117,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9747eb01aed7603aba23f7c869d5d7e5d37aab9c3501aced42d8fdb786f1f6e3" checksum = "9747eb01aed7603aba23f7c869d5d7e5d37aab9c3501aced42d8fdb786f1f6e3"
dependencies = [ dependencies = [
"futures", "futures",
"thiserror 1.0.65", "thiserror 1.0.69",
"tokio", "tokio",
"wasm-bindgen-futures", "wasm-bindgen-futures",
] ]
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.91" version = "1.0.93"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775"
[[package]] [[package]]
name = "argparse" name = "argparse"
@ -424,9 +424,9 @@ checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.1.31" version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47"
dependencies = [ dependencies = [
"shlex", "shlex",
] ]
@ -482,7 +482,7 @@ checksum = "5d3ad3122b0001c7f140cf4d605ef9a9e2c24d96ab0b4fb4347b76de2425f445"
dependencies = [ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"thiserror 1.0.65", "thiserror 1.0.69",
] ]
[[package]] [[package]]
@ -619,12 +619,13 @@ dependencies = [
[[package]] [[package]]
name = "cookie_store" name = "cookie_store"
version = "0.21.0" version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4934e6b7e8419148b6ef56950d277af8561060b56afd59e2aadf98b59fce6baa" checksum = "2eac901828f88a5241ee0600950ab981148a18f2f756900ffba1b125ca6a3ef9"
dependencies = [ dependencies = [
"cookie", "cookie",
"idna 0.5.0", "document-features",
"idna 1.0.3",
"log", "log",
"publicsuffix", "publicsuffix",
"serde", "serde",
@ -652,9 +653,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
version = "0.2.14" version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -1062,6 +1063,15 @@ dependencies = [
"const-random", "const-random",
] ]
[[package]]
name = "document-features"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb6969eaabd2421f8a2775cfd2471a2b634372b4a25d41e3bd647b79912850a0"
dependencies = [
"litrs",
]
[[package]] [[package]]
name = "doku" name = "doku"
version = "0.21.1" version = "0.21.1"
@ -1258,15 +1268,15 @@ dependencies = [
[[package]] [[package]]
name = "fastrand" name = "fastrand"
version = "2.1.1" version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4"
[[package]] [[package]]
name = "flate2" name = "flate2"
version = "1.0.34" version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"miniz_oxide", "miniz_oxide",
@ -1445,7 +1455,7 @@ dependencies = [
"pin-project", "pin-project",
"serde", "serde",
"serde_json", "serde_json",
"thiserror 1.0.65", "thiserror 1.0.69",
"wasm-bindgen", "wasm-bindgen",
"wasm-bindgen-futures", "wasm-bindgen-futures",
"web-sys", "web-sys",
@ -1513,9 +1523,9 @@ dependencies = [
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.15.0" version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3"
[[package]] [[package]]
name = "hashlink" name = "hashlink"
@ -1615,7 +1625,7 @@ dependencies = [
"reqwest", "reqwest",
"reqwest-middleware", "reqwest-middleware",
"sha2", "sha2",
"thiserror 1.0.65", "thiserror 1.0.69",
"tokio", "tokio",
] ]
@ -1768,6 +1778,7 @@ dependencies = [
"enum_delegate", "enum_delegate",
"env_logger", "env_logger",
"futures", "futures",
"getrandom",
"hex", "hex",
"jsonwebtoken", "jsonwebtoken",
"katex", "katex",
@ -1788,6 +1799,7 @@ dependencies = [
"rand", "rand",
"reqwest", "reqwest",
"retry_future", "retry_future",
"send_wrapper",
"serde", "serde",
"serde_json", "serde_json",
"sha2", "sha2",
@ -1800,6 +1812,125 @@ dependencies = [
"tracing", "tracing",
"url", "url",
"uuid", "uuid",
"wasm-bindgen",
]
[[package]]
name = "icu_collections"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526"
dependencies = [
"displaydoc",
"yoke",
"zerofrom",
"zerovec",
]
[[package]]
name = "icu_locid"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637"
dependencies = [
"displaydoc",
"litemap",
"tinystr",
"writeable",
"zerovec",
]
[[package]]
name = "icu_locid_transform"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e"
dependencies = [
"displaydoc",
"icu_locid",
"icu_locid_transform_data",
"icu_provider",
"tinystr",
"zerovec",
]
[[package]]
name = "icu_locid_transform_data"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e"
[[package]]
name = "icu_normalizer"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f"
dependencies = [
"displaydoc",
"icu_collections",
"icu_normalizer_data",
"icu_properties",
"icu_provider",
"smallvec",
"utf16_iter",
"utf8_iter",
"write16",
"zerovec",
]
[[package]]
name = "icu_normalizer_data"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516"
[[package]]
name = "icu_properties"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5"
dependencies = [
"displaydoc",
"icu_collections",
"icu_locid_transform",
"icu_properties_data",
"icu_provider",
"tinystr",
"zerovec",
]
[[package]]
name = "icu_properties_data"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569"
[[package]]
name = "icu_provider"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9"
dependencies = [
"displaydoc",
"icu_locid",
"icu_provider_macros",
"stable_deref_trait",
"tinystr",
"writeable",
"yoke",
"zerofrom",
"zerovec",
]
[[package]]
name = "icu_provider_macros"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.87",
] ]
[[package]] [[package]]
@ -1820,12 +1951,23 @@ dependencies = [
[[package]] [[package]]
name = "idna" name = "idna"
version = "0.5.0" version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e"
dependencies = [ dependencies = [
"unicode-bidi", "idna_adapter",
"unicode-normalization", "smallvec",
"utf8_iter",
]
[[package]]
name = "idna_adapter"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71"
dependencies = [
"icu_normalizer",
"icu_properties",
] ]
[[package]] [[package]]
@ -1835,7 +1977,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da"
dependencies = [ dependencies = [
"equivalent", "equivalent",
"hashbrown 0.15.0", "hashbrown 0.15.1",
] ]
[[package]] [[package]]
@ -1935,7 +2077,7 @@ dependencies = [
"ducc", "ducc",
"itertools 0.10.5", "itertools 0.10.5",
"js-sys", "js-sys",
"thiserror 1.0.65", "thiserror 1.0.69",
"wasm-bindgen", "wasm-bindgen",
] ]
@ -1977,7 +2119,7 @@ dependencies = [
"server_fn", "server_fn",
"slotmap", "slotmap",
"tachys", "tachys",
"thiserror 1.0.65", "thiserror 1.0.69",
"throw_error", "throw_error",
"typed-builder", "typed-builder",
"typed-builder-macro", "typed-builder-macro",
@ -2044,7 +2186,7 @@ dependencies = [
"config", "config",
"regex", "regex",
"serde", "serde",
"thiserror 1.0.65", "thiserror 1.0.69",
"typed-builder", "typed-builder",
] ]
@ -2153,7 +2295,7 @@ dependencies = [
"reactive_graph", "reactive_graph",
"send_wrapper", "send_wrapper",
"tachys", "tachys",
"thiserror 1.0.65", "thiserror 1.0.69",
"url", "url",
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
@ -2192,9 +2334,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.161" version = "0.2.162"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398"
[[package]] [[package]]
name = "libm" name = "libm"
@ -2229,6 +2371,18 @@ version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
[[package]]
name = "litemap"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704"
[[package]]
name = "litrs"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5"
[[package]] [[package]]
name = "lock_api" name = "lock_api"
version = "0.4.12" version = "0.4.12"
@ -2444,7 +2598,7 @@ dependencies = [
"rustc_version", "rustc_version",
"smallvec", "smallvec",
"tagptr", "tagptr",
"thiserror 1.0.65", "thiserror 1.0.69",
"triomphe", "triomphe",
"uuid", "uuid",
] ]
@ -2587,7 +2741,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64b94982fe39a861561cf67ff17a7849f2cedadbbad960a797634032b7abb998" checksum = "64b94982fe39a861561cf67ff17a7849f2cedadbbad960a797634032b7abb998"
dependencies = [ dependencies = [
"serde", "serde",
"thiserror 1.0.65", "thiserror 1.0.69",
] ]
[[package]] [[package]]
@ -2729,7 +2883,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442"
dependencies = [ dependencies = [
"memchr", "memchr",
"thiserror 1.0.65", "thiserror 1.0.69",
"ucd-trie", "ucd-trie",
] ]
@ -2980,20 +3134,20 @@ checksum = "33cb294fe86a74cbcf50d4445b37da762029549ebeea341421c7c70370f86cac"
[[package]] [[package]]
name = "psm" name = "psm"
version = "0.1.23" version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa37f80ca58604976033fae9515a8a2989fc13797d953f7c04fb8fa36a11f205" checksum = "200b9ff220857e53e184257720a14553b2f4aa02577d2ed9842d45d4b9654810"
dependencies = [ dependencies = [
"cc", "cc",
] ]
[[package]] [[package]]
name = "publicsuffix" name = "publicsuffix"
version = "2.2.3" version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96a8c1bda5ae1af7f99a2962e49df150414a43d62404644d98dd5c3a93d07457" checksum = "6f42ea446cab60335f76979ec15e12619a2165b5ae2c12166bef27d283a9fadf"
dependencies = [ dependencies = [
"idna 0.3.0", "idna 1.0.3",
"psl-types", "psl-types",
] ]
@ -3023,9 +3177,9 @@ dependencies = [
[[package]] [[package]]
name = "quinn" name = "quinn"
version = "0.11.5" version = "0.11.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" checksum = "62e96808277ec6f97351a2380e6c25114bc9e67037775464979f3037c92d05ef"
dependencies = [ dependencies = [
"bytes", "bytes",
"pin-project-lite", "pin-project-lite",
@ -3034,33 +3188,36 @@ dependencies = [
"rustc-hash", "rustc-hash",
"rustls", "rustls",
"socket2", "socket2",
"thiserror 1.0.65", "thiserror 2.0.3",
"tokio", "tokio",
"tracing", "tracing",
] ]
[[package]] [[package]]
name = "quinn-proto" name = "quinn-proto"
version = "0.11.8" version = "0.11.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d"
dependencies = [ dependencies = [
"bytes", "bytes",
"getrandom",
"rand", "rand",
"ring", "ring",
"rustc-hash", "rustc-hash",
"rustls", "rustls",
"rustls-pki-types",
"slab", "slab",
"thiserror 1.0.65", "thiserror 2.0.3",
"tinyvec", "tinyvec",
"tracing", "tracing",
"web-time",
] ]
[[package]] [[package]]
name = "quinn-udp" name = "quinn-udp"
version = "0.5.6" version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e346e016eacfff12233c243718197ca12f148c84e1e84268a896699b41c71780" checksum = "7d5a626c6807713b15cac82a6acaccd6043c9a5408c24baae07611fec3f243da"
dependencies = [ dependencies = [
"cfg_aliases", "cfg_aliases",
"libc", "libc",
@ -3168,7 +3325,7 @@ dependencies = [
"send_wrapper", "send_wrapper",
"serde", "serde",
"slotmap", "slotmap",
"thiserror 1.0.65", "thiserror 1.0.69",
"web-sys", "web-sys",
] ]
@ -3234,9 +3391,9 @@ dependencies = [
[[package]] [[package]]
name = "regex-automata" name = "regex-automata"
version = "0.4.8" version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"memchr", "memchr",
@ -3312,7 +3469,7 @@ dependencies = [
"http", "http",
"reqwest", "reqwest",
"serde", "serde",
"thiserror 1.0.65", "thiserror 1.0.69",
"tower-service", "tower-service",
] ]
@ -3387,7 +3544,7 @@ dependencies = [
"quote", "quote",
"syn 2.0.87", "syn 2.0.87",
"syn_derive", "syn_derive",
"thiserror 1.0.65", "thiserror 1.0.69",
] ]
[[package]] [[package]]
@ -3423,9 +3580,9 @@ dependencies = [
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.38.38" version = "0.38.40"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"errno", "errno",
@ -3462,6 +3619,9 @@ name = "rustls-pki-types"
version = "1.10.0" version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b"
dependencies = [
"web-time",
]
[[package]] [[package]]
name = "rustls-webpki" name = "rustls-webpki"
@ -3534,9 +3694,9 @@ dependencies = [
[[package]] [[package]]
name = "security-framework-sys" name = "security-framework-sys"
version = "2.12.0" version = "2.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2"
dependencies = [ dependencies = [
"core-foundation-sys", "core-foundation-sys",
"libc", "libc",
@ -3559,18 +3719,18 @@ dependencies = [
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.214" version = "1.0.215"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.214" version = "1.0.215"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -3608,7 +3768,7 @@ checksum = "cd34f36fe4c5ba9654417139a9b3a20d2e1de6012ee678ad14d240c22c78d8d6"
dependencies = [ dependencies = [
"percent-encoding", "percent-encoding",
"serde", "serde",
"thiserror 1.0.65", "thiserror 1.0.69",
] ]
[[package]] [[package]]
@ -3656,7 +3816,7 @@ dependencies = [
"serde_json", "serde_json",
"serde_qs", "serde_qs",
"server_fn_macro_default", "server_fn_macro_default",
"thiserror 1.0.65", "thiserror 1.0.69",
"throw_error", "throw_error",
"tower 0.4.13", "tower 0.4.13",
"tower-layer", "tower-layer",
@ -3736,7 +3896,7 @@ checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085"
dependencies = [ dependencies = [
"num-bigint", "num-bigint",
"num-traits", "num-traits",
"thiserror 1.0.65", "thiserror 1.0.69",
"time", "time",
] ]
@ -3801,6 +3961,12 @@ dependencies = [
"der", "der",
] ]
[[package]]
name = "stable_deref_trait"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]] [[package]]
name = "stacker" name = "stacker"
version = "0.1.17" version = "0.1.17"
@ -3881,6 +4047,17 @@ dependencies = [
"futures-core", "futures-core",
] ]
[[package]]
name = "synstructure"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.87",
]
[[package]] [[package]]
name = "syntect" name = "syntect"
version = "5.2.0" version = "5.2.0"
@ -3898,7 +4075,7 @@ dependencies = [
"serde", "serde",
"serde_derive", "serde_derive",
"serde_json", "serde_json",
"thiserror 1.0.65", "thiserror 1.0.69",
"walkdir", "walkdir",
"yaml-rust", "yaml-rust",
] ]
@ -3964,9 +4141,9 @@ checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417"
[[package]] [[package]]
name = "tempfile" name = "tempfile"
version = "3.13.0" version = "3.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"fastrand", "fastrand",
@ -3977,11 +4154,11 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.65" version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
dependencies = [ dependencies = [
"thiserror-impl 1.0.65", "thiserror-impl 1.0.69",
] ]
[[package]] [[package]]
@ -3995,9 +4172,9 @@ dependencies = [
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.65" version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -4071,6 +4248,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f"
dependencies = [ dependencies = [
"displaydoc", "displaydoc",
"zerovec",
] ]
[[package]] [[package]]
@ -4090,9 +4268,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.41.0" version = "1.41.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"bytes", "bytes",
@ -4425,22 +4603,34 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]] [[package]]
name = "url" name = "url"
version = "2.5.2" version = "2.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada"
dependencies = [ dependencies = [
"form_urlencoded", "form_urlencoded",
"idna 0.5.0", "idna 1.0.3",
"percent-encoding", "percent-encoding",
"serde", "serde",
] ]
[[package]]
name = "utf16_iter"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246"
[[package]] [[package]]
name = "utf8-width" name = "utf8-width"
version = "0.1.7" version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3"
[[package]]
name = "utf8_iter"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
[[package]] [[package]]
name = "uuid" name = "uuid"
version = "1.11.0" version = "1.11.0"
@ -4516,9 +4706,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-futures" name = "wasm-bindgen-futures"
version = "0.4.43" version = "0.4.45"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"js-sys", "js-sys",
@ -4557,9 +4747,9 @@ checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d"
[[package]] [[package]]
name = "wasm-streams" name = "wasm-streams"
version = "0.4.1" version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e072d4e72f700fb3443d8fe94a39315df013eef1104903cdb0a2abd322bbecd" checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65"
dependencies = [ dependencies = [
"futures-util", "futures-util",
"js-sys", "js-sys",
@ -4578,6 +4768,16 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "web-time"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]] [[package]]
name = "webpki-roots" name = "webpki-roots"
version = "0.26.6" version = "0.26.6"
@ -4748,6 +4948,18 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "write16"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936"
[[package]]
name = "writeable"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
[[package]] [[package]]
name = "xxhash-rust" name = "xxhash-rust"
version = "0.8.12" version = "0.8.12"
@ -4780,6 +4992,30 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049"
[[package]]
name = "yoke"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5"
dependencies = [
"serde",
"stable_deref_trait",
"yoke-derive",
"zerofrom",
]
[[package]]
name = "yoke-derive"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.87",
"synstructure",
]
[[package]] [[package]]
name = "zerocopy" name = "zerocopy"
version = "0.7.35" version = "0.7.35"
@ -4801,8 +5037,51 @@ dependencies = [
"syn 2.0.87", "syn 2.0.87",
] ]
[[package]]
name = "zerofrom"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55"
dependencies = [
"zerofrom-derive",
]
[[package]]
name = "zerofrom-derive"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.87",
"synstructure",
]
[[package]] [[package]]
name = "zeroize" name = "zeroize"
version = "1.8.1" version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
[[package]]
name = "zerovec"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079"
dependencies = [
"yoke",
"zerofrom",
"zerovec-derive",
]
[[package]]
name = "zerovec-derive"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.87",
]

View file

@ -67,6 +67,7 @@ env_logger = { version = "0.11.5", default-features = false }
futures = "0.3.30" futures = "0.3.30"
hex = "0.4.3" hex = "0.4.3"
rand = "0.8.5" rand = "0.8.5"
getrandom = { version = "0.2", features = ["js"] }
serde_json = "1.0.128" serde_json = "1.0.128"
sha2 = "0.10.8" sha2 = "0.10.8"
uuid = { version = "1.10.0", features = ["serde"] } uuid = { version = "1.10.0", features = ["serde"] }
@ -88,6 +89,7 @@ markdown-it-sub = "1.0.0"
markdown-it-sup = "1.0.0" markdown-it-sup = "1.0.0"
leptos-use = "0.14.0-rc2" leptos-use = "0.14.0-rc2"
codee = "0.2.0" codee = "0.2.0"
wasm-bindgen = "0.2.95"
# backend-only features # backend-only features
axum = { version = "0.7.7", optional = true } axum = { version = "0.7.7", optional = true }
@ -118,6 +120,7 @@ config = { version = "0.14.0", features = ["toml"], optional = true }
tower = { version = "0.5.1", optional = true } tower = { version = "0.5.1", optional = true }
tower-layer = { version = "0.3.3", optional = true } tower-layer = { version = "0.3.3", optional = true }
console_log = "1.0.0" console_log = "1.0.0"
send_wrapper = "0.6.0"
[dev-dependencies] [dev-dependencies]
pretty_assertions = "1.4.1" pretty_assertions = "1.4.1"

View file

@ -131,7 +131,6 @@ async fn leptos_routes_handler(
req: Request<Body>, req: Request<Body>,
) -> Response { ) -> Response {
let handler = leptos_axum::render_app_async_with_context( let handler = leptos_axum::render_app_async_with_context(
option.clone(),
move || { move || {
let cookie = jar.get(AUTH_COOKIE).map(|c| c.value().to_string()); let cookie = jar.get(AUTH_COOKIE).map(|c| c.value().to_string());
provide_context(Auth(cookie)); provide_context(Auth(cookie));

View file

@ -3,7 +3,6 @@ pub mod utils;
pub mod validation; pub mod validation;
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use codee::{Decoder, Encoder};
use newtypes::{ArticleId, ConflictId, EditId, InstanceId, PersonId}; use newtypes::{ArticleId, ConflictId, EditId, InstanceId, PersonId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
@ -352,25 +351,6 @@ pub struct SiteView {
pub config: Options, pub config: Options,
} }
// TODO: using () doesnt make much sense
impl Encoder<()> for SiteView {
type Error = serde_json::Error;
type Encoded = String;
fn encode(val: &()) -> Result<Self::Encoded, Self::Error> {
serde_json::to_string(val)
}
}
impl Decoder<()> for SiteView {
type Error = serde_json::Error;
type Encoded = str;
fn decode(stored_value: &Self::Encoded) -> Result<(), Self::Error> {
serde_json::from_str(stored_value)
}
}
#[test] #[test]
fn test_edit_versions() { fn test_edit_versions() {
let default = EditVersion::default(); let default = EditVersion::default();

View file

@ -31,8 +31,12 @@ use crate::{
}; };
use anyhow::anyhow; use anyhow::anyhow;
use reqwest::{Client, RequestBuilder, StatusCode}; use reqwest::{Client, RequestBuilder, StatusCode};
use send_wrapper::SendWrapper;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::sync::LazyLock; use std::{
future::Future,
sync::{LazyLock},
};
use url::Url; use url::Url;
pub static CLIENT: LazyLock<ApiClient> = LazyLock::new(|| ApiClient::new(Client::new(), None)); pub static CLIENT: LazyLock<ApiClient> = LazyLock::new(|| ApiClient::new(Client::new(), None));
@ -84,189 +88,277 @@ impl ApiClient {
handle_json_res::<T>(req).await handle_json_res::<T>(req).await
} }
pub async fn get_article(&self, data: GetArticleForm) -> MyResult<ArticleView> { pub fn get_article(
self.get_query("/api/v1/article", Some(data)).await
}
pub async fn list_articles(&self, data: ListArticlesForm) -> MyResult<Vec<DbArticle>> {
self.get_query("/api/v1/article/list", Some(data)).await
}
pub async fn register(&self, register_form: RegisterUserForm) -> MyResult<LocalUserView> {
let req = self
.client
.post(self.request_endpoint("/api/v1/account/register"))
.form(&register_form);
handle_json_res::<LocalUserView>(req).await
}
pub async fn login(&self, login_form: LoginUserForm) -> MyResult<LocalUserView> {
let req = self
.client
.post(self.request_endpoint("/api/v1/account/login"))
.form(&login_form);
handle_json_res::<LocalUserView>(req).await
}
pub async fn create_article(&self, data: &CreateArticleForm) -> MyResult<ArticleView> {
let req = self
.client
.post(self.request_endpoint("/api/v1/article"))
.form(data);
handle_json_res(req).await
}
pub async fn edit_article_with_conflict(
&self, &self,
edit_form: &EditArticleForm, data: GetArticleForm,
) -> MyResult<Option<ApiConflict>> { ) -> impl Future<Output = MyResult<ArticleView>> + Send + '_ {
let req = self SendWrapper::new(async move { self.get_query("/api/v1/article", Some(data)).await })
.client
.patch(self.request_endpoint("/api/v1/article"))
.form(edit_form);
handle_json_res(req).await
} }
pub async fn edit_article(&self, edit_form: &EditArticleForm) -> MyResult<ArticleView> { pub fn list_articles(
let edit_res = self.edit_article_with_conflict(edit_form).await?; &self,
assert!(edit_res.is_none()); data: ListArticlesForm,
) -> impl Future<Output = MyResult<Vec<DbArticle>>> + Send + '_ {
SendWrapper::new(async move { self.get_query("/api/v1/article/list", Some(data)).await })
}
self.get_article(GetArticleForm { pub fn register(
title: None, &self,
domain: None, register_form: RegisterUserForm,
id: Some(edit_form.article_id), ) -> impl Future<Output = MyResult<LocalUserView>> + Send + '_ {
SendWrapper::new(async move {
let req = self
.client
.post(self.request_endpoint("/api/v1/account/register"))
.form(&register_form);
handle_json_res::<LocalUserView>(req).await
}) })
.await
} }
pub async fn notifications_list(&self) -> MyResult<Vec<Notification>> { pub fn login(
let req = self
.client
.get(self.request_endpoint("/api/v1/user/notifications/list"));
handle_json_res(req).await
}
pub async fn notifications_count(&self) -> MyResult<usize> {
let req = self
.client
.get(self.request_endpoint("/api/v1/user/notifications/count"));
handle_json_res(req).await
}
pub async fn approve_article(&self, article_id: ArticleId, approve: bool) -> MyResult<()> {
let form = ApproveArticleForm {
article_id,
approve,
};
let req = self
.client
.post(self.request_endpoint("/api/v1/article/approve"))
.form(&form);
handle_json_res(req).await
}
pub async fn delete_conflict(&self, conflict_id: ConflictId) -> MyResult<()> {
let form = DeleteConflictForm { conflict_id };
let req = self
.client
.delete(self.request_endpoint("/api/v1/conflict"))
.form(&form);
handle_json_res(req).await
}
pub async fn search(&self, search_form: &SearchArticleForm) -> MyResult<Vec<DbArticle>> {
self.get_query("/api/v1/search", Some(search_form)).await
}
pub async fn get_local_instance(&self) -> MyResult<InstanceView> {
self.get_query("/api/v1/instance", None::<i32>).await
}
pub async fn get_instance(&self, get_form: &GetInstance) -> MyResult<InstanceView> {
self.get_query("/api/v1/instance", Some(get_form)).await
}
pub async fn list_instances(&self) -> MyResult<Vec<DbInstance>> {
self.get_query("/api/v1/instance/list", None::<i32>).await
}
pub async fn follow_instance_with_resolve(
&self, &self,
follow_instance: &str, login_form: LoginUserForm,
) -> MyResult<DbInstance> { ) -> impl Future<Output = MyResult<LocalUserView>> + Send + '_ {
// fetch beta instance on alpha SendWrapper::new(async move {
let resolve_form = ResolveObject { let req = self
id: Url::parse(&format!("{}://{}", http_protocol_str(), follow_instance))?, .client
}; .post(self.request_endpoint("/api/v1/account/login"))
let instance_resolved: DbInstance = self .form(&login_form);
.get_query("/api/v1/instance/resolve", Some(resolve_form)) handle_json_res::<LocalUserView>(req).await
.await?; })
// send follow
let follow_form = FollowInstance {
id: instance_resolved.id,
};
self.follow_instance(follow_form).await?;
Ok(instance_resolved)
} }
pub async fn follow_instance(&self, follow_form: FollowInstance) -> MyResult<()> { pub fn create_article(
// cant use post helper because follow doesnt return json &self,
let res = self data: CreateArticleForm,
.client ) -> impl Future<Output = MyResult<ArticleView>> + Send + '_ {
.post(self.request_endpoint("/api/v1/instance/follow")) SendWrapper::new(async move {
.form(&follow_form) let req = self
.send() .client
.await?; .post(self.request_endpoint("/api/v1/article"))
if res.status() == StatusCode::OK { .form(&data);
handle_json_res(req).await
})
}
pub fn edit_article_with_conflict(
&self,
edit_form: EditArticleForm,
) -> impl Future<Output = MyResult<Option<ApiConflict>>> + Send + '_ {
SendWrapper::new(async move {
let req = self
.client
.patch(self.request_endpoint("/api/v1/article"))
.form(&edit_form);
handle_json_res(req).await
})
}
pub fn edit_article(
&self,
edit_form: EditArticleForm,
) -> impl Future<Output = MyResult<ArticleView>> + Send + '_ {
SendWrapper::new(async move {
let article_id = edit_form.article_id;
let edit_res = self.edit_article_with_conflict(edit_form).await?;
assert!(edit_res.is_none());
self.get_article(GetArticleForm {
title: None,
domain: None,
id: Some(article_id),
})
.await
})
}
pub fn notifications_list(
&self,
) -> impl Future<Output = MyResult<Vec<Notification>>> + Send + '_ {
SendWrapper::new(async move {
let req = self
.client
.get(self.request_endpoint("/api/v1/user/notifications/list"));
handle_json_res(req).await
})
}
pub fn notifications_count(&self) -> impl Future<Output = MyResult<usize>> + Send + '_ {
SendWrapper::new(async move {
let req = self
.client
.get(self.request_endpoint("/api/v1/user/notifications/count"));
handle_json_res(req).await
})
}
pub fn approve_article(
&self,
article_id: ArticleId,
approve: bool,
) -> impl Future<Output = MyResult<()>> + Send + '_ {
SendWrapper::new(async move {
let form = ApproveArticleForm {
article_id,
approve,
};
let req = self
.client
.post(self.request_endpoint("/api/v1/article/approve"))
.form(&form);
handle_json_res(req).await
})
}
pub fn delete_conflict(
&self,
conflict_id: ConflictId,
) -> impl Future<Output = MyResult<()>> + Send + '_ {
SendWrapper::new(async move {
let form = DeleteConflictForm { conflict_id };
let req = self
.client
.delete(self.request_endpoint("/api/v1/conflict"))
.form(&form);
handle_json_res(req).await
})
}
pub fn search(
&self,
search_form: SearchArticleForm,
) -> impl Future<Output = MyResult<Vec<DbArticle>>> + Send + '_ {
SendWrapper::new(async move { self.get_query("/api/v1/search", Some(search_form)).await })
}
pub fn get_local_instance(
&self,
) -> impl Future<Output = MyResult<Vec<InstanceView>>> + Send + '_ {
SendWrapper::new(async move { self.get_query("/api/v1/instance", None::<i32>).await })
}
pub fn get_instance(
&self,
get_form: GetInstance,
) -> impl Future<Output = MyResult<InstanceView>> + Send + '_ {
SendWrapper::new(async move { self.get_query("/api/v1/instance", Some(get_form)).await })
}
pub fn list_instances(&self) -> impl Future<Output = MyResult<Vec<DbInstance>>> + Send + '_ {
SendWrapper::new(async move { self.get_query("/api/v1/instance/list", None::<i32>).await })
}
pub fn follow_instance_with_resolve(
&self,
follow_instance: String,
) -> impl Future<Output = MyResult<DbInstance>> + Send + '_ {
SendWrapper::new(async move {
// fetch beta instance on alpha
let resolve_form = ResolveObject {
id: Url::parse(&format!("{}://{}", http_protocol_str(), follow_instance))?,
};
let instance_resolved: DbInstance = self
.get_query("/api/v1/instance/resolve", Some(resolve_form))
.await?;
// send follow
let follow_form = FollowInstance {
id: instance_resolved.id,
};
self.follow_instance(follow_form).await?;
Ok(instance_resolved)
})
}
pub fn follow_instance(
&self,
follow_form: FollowInstance,
) -> impl Future<Output = MyResult<()>> + Send + '_ {
SendWrapper::new(async move {
// cant use post helper because follow doesnt return json
let res = self
.client
.post(self.request_endpoint("/api/v1/instance/follow"))
.form(&follow_form)
.send()
.await?;
if res.status() == StatusCode::OK {
Ok(())
} else {
Err(anyhow!("API error: {}", res.text().await?).into())
}
})
}
pub fn site(&self) -> impl Future<Output = MyResult<SiteView>> + Send + '_ {
SendWrapper::new(async move {
let req = self.client.get(self.request_endpoint("/api/v1/site"));
handle_json_res(req).await
})
}
pub fn logout(&self) -> impl Future<Output = MyResult<()>> + Send + '_ {
SendWrapper::new(async move {
self.client
.get(self.request_endpoint("/api/v1/account/logout"))
.send()
.await?;
Ok(()) Ok(())
} else { })
Err(anyhow!("API error: {}", res.text().await?).into())
}
} }
pub async fn site(&self) -> MyResult<SiteView> { pub fn fork_article(
let req = self.client.get(self.request_endpoint("/api/v1/site")); &self,
handle_json_res(req).await form: ForkArticleForm,
) -> impl Future<Output = MyResult<ArticleView>> + Send + '_ {
SendWrapper::new(async move {
let req = self
.client
.post(self.request_endpoint("/api/v1/article/fork"))
.form(&form);
Ok(handle_json_res(req).await.unwrap())
})
} }
pub async fn logout(&self) -> MyResult<()> { pub fn protect_article(
self.client &self,
.get(self.request_endpoint("/api/v1/account/logout")) params: ProtectArticleForm,
.send() ) -> impl Future<Output = MyResult<DbArticle>> + Send + '_ {
.await?; SendWrapper::new(async move {
Ok(()) let req = self
.client
.post(self.request_endpoint("/api/v1/article/protect"))
.form(&params);
handle_json_res(req).await
})
} }
pub async fn fork_article(&self, form: &ForkArticleForm) -> MyResult<ArticleView> { pub fn resolve_article(
let req = self &self,
.client id: Url,
.post(self.request_endpoint("/api/v1/article/fork")) ) -> impl Future<Output = MyResult<ArticleView>> + Send + '_ {
.form(form); SendWrapper::new(async move {
Ok(handle_json_res(req).await.unwrap()) let resolve_object = ResolveObject { id };
self.get_query("/api/v1/article/resolve", Some(resolve_object))
.await
})
} }
pub async fn protect_article(&self, params: &ProtectArticleForm) -> MyResult<DbArticle> { pub fn resolve_instance(
let req = self &self,
.client id: Url,
.post(self.request_endpoint("/api/v1/article/protect")) ) -> impl Future<Output = MyResult<DbInstance>> + Send + '_ {
.form(params); SendWrapper::new(async move {
handle_json_res(req).await let resolve_object = ResolveObject { id };
self.get_query("/api/v1/instance/resolve", Some(resolve_object))
.await
})
} }
pub fn get_user(
pub async fn resolve_article(&self, id: Url) -> MyResult<ArticleView> { &self,
let resolve_object = ResolveObject { id }; data: GetUserForm,
self.get_query("/api/v1/article/resolve", Some(resolve_object)) ) -> impl Future<Output = MyResult<DbPerson>> + Send + '_ {
.await SendWrapper::new(async move { self.get_query("/api/v1/user", Some(data)).await })
}
pub async fn resolve_instance(&self, id: Url) -> MyResult<DbInstance> {
let resolve_object = ResolveObject { id };
self.get_query("/api/v1/instance/resolve", Some(resolve_object))
.await
}
pub async fn get_user(&self, data: GetUserForm) -> MyResult<DbPerson> {
self.get_query("/api/v1/user", Some(data)).await
} }
fn request_endpoint(&self, path: &str) -> String { fn request_endpoint(&self, path: &str) -> String {
@ -275,7 +367,7 @@ impl ApiClient {
} }
} }
async fn handle_json_res<T>(#[allow(unused_mut)] mut req: RequestBuilder) -> MyResult<T> async fn handle_json_res<T>(mut req: RequestBuilder) -> MyResult<T>
where where
T: for<'de> Deserialize<'de>, T: for<'de> Deserialize<'de>,
{ {

View file

@ -30,8 +30,8 @@ use leptos_router::{
path, path,
}; };
pub fn site() -> Resource<(), SiteView> { pub fn site() -> Resource<SiteView> {
use_context::<Resource<(), SiteView>>().unwrap() use_context::<Resource<SiteView>>().unwrap()
} }
pub fn is_logged_in() -> bool { pub fn is_logged_in() -> bool {
@ -51,7 +51,7 @@ pub trait DefaultResource<T> {
fn with_default<O>(&self, f: impl FnOnce(&T) -> O) -> O; fn with_default<O>(&self, f: impl FnOnce(&T) -> O) -> O;
} }
impl<T: Default> DefaultResource<T> for Resource<(), T> { impl<T: Default + Send + Sync> DefaultResource<T> for Resource<T> {
fn with_default<O>(&self, f: impl FnOnce(&T) -> O) -> O { fn with_default<O>(&self, f: impl FnOnce(&T) -> O) -> O {
self.with(|x| match x { self.with(|x| match x {
Some(x) => f(x), Some(x) => f(x),

View file

@ -35,7 +35,7 @@ pub fn ArticleNav(article: Resource<ArticleView>, active_tab: ActiveTab) -> impl
let form = GetInstance { let form = GetInstance {
id: Some(instance_id), id: Some(instance_id),
}; };
CLIENT.get_instance(&form).await.unwrap() CLIENT.get_instance(form).await.unwrap()
}, },
); );
let article_link = article_link(&article_.article); let article_link = article_link(&article_.article);

View file

@ -16,7 +16,7 @@ pub fn hydrate() {
use crate::frontend::app::App; use crate::frontend::app::App;
console_log::init_with_level(log::Level::Debug).expect("error initializing logger"); console_log::init_with_level(log::Level::Debug).expect("error initializing logger");
console_error_panic_hook::set_once(); console_error_panic_hook::set_once();
leptos::mount_to_body(App); mount_to_body(App);
} }
fn article_link(article: &DbArticle) -> String { fn article_link(article: &DbArticle) -> String {

View file

@ -25,7 +25,7 @@ pub fn ArticleActions() -> impl IntoView {
}; };
async move { async move {
set_error.update(|e| *e = None); set_error.update(|e| *e = None);
let result = CLIENT.fork_article(&params).await; let result = CLIENT.fork_article(params).await;
match result { match result {
Ok(res) => set_fork_response.set(Some(res.article)), Ok(res) => set_fork_response.set(Some(res.article)),
Err(err) => { Err(err) => {
@ -41,7 +41,7 @@ pub fn ArticleActions() -> impl IntoView {
}; };
async move { async move {
set_error.update(|e| *e = None); set_error.update(|e| *e = None);
let result = CLIENT.protect_article(&params).await; let result = CLIENT.protect_article(params).await;
match result { match result {
Ok(_res) => article.refetch(), Ok(_res) => article.refetch(),
Err(err) => { Err(err) => {

View file

@ -32,7 +32,7 @@ pub fn CreateArticle() -> impl IntoView {
summary, summary,
}; };
set_wait_for_response.update(|w| *w = true); set_wait_for_response.update(|w| *w = true);
let res = CLIENT.create_article(&form).await; let res = CLIENT.create_article(form).await;
set_wait_for_response.update(|w| *w = false); set_wait_for_response.update(|w| *w = false);
match res { match res {
Ok(_res) => { Ok(_res) => {

View file

@ -89,7 +89,7 @@ pub fn EditArticle() -> impl IntoView {
resolve_conflict_id, resolve_conflict_id,
}; };
set_wait_for_response.update(|w| *w = true); set_wait_for_response.update(|w| *w = true);
let res = CLIENT.edit_article_with_conflict(&form).await; let res = CLIENT.edit_article_with_conflict(form).await;
set_wait_for_response.update(|w| *w = false); set_wait_for_response.update(|w| *w = false);
match res { match res {
Ok(Some(conflict)) => { Ok(Some(conflict)) => {

View file

@ -7,8 +7,8 @@ use leptos::{html::Input, prelude::*};
#[component] #[component]
pub fn ListArticles() -> impl IntoView { pub fn ListArticles() -> impl IntoView {
let (only_local, set_only_local) = signal(false); let (only_local, set_only_local) = signal(false);
let button_only_local = create_node_ref::<Input>(); let button_only_local = NodeRef::<Input>::new();
let button_all = create_node_ref::<Input>(); let button_all = NodeRef::<Input>::new();
let articles = Resource::new( let articles = Resource::new(
move || only_local.get(), move || only_local.get(),
|only_local| async move { |only_local| async move {
@ -32,8 +32,9 @@ pub fn ListArticles() -> impl IntoView {
class="btn rounded-r-none" class="btn rounded-r-none"
node_ref=button_only_local node_ref=button_only_local
on:click=move |_| { on:click=move |_| {
button_all.get().map(|c| c.class("btn-primary", false)); // TODO
button_only_local.get().map(|c| c.class("btn-primary", true)); //button_all.get().map(|c| c.class("btn-primary", false));
//button_only_local.get().map(|c| c.class("btn-primary", true));
set_only_local.set(true); set_only_local.set(true);
} }
/> />
@ -43,8 +44,8 @@ pub fn ListArticles() -> impl IntoView {
class="btn btn-primary rounded-l-none" class="btn btn-primary rounded-l-none"
node_ref=button_all node_ref=button_all
on:click=move |_| { on:click=move |_| {
button_all.get().map(|c| c.class("btn-primary", true)); //button_all.get().map(|c| c.class("btn-primary", true));
button_only_local.get().map(|c| c.class("btn-primary", false)); //button_only_local.get().map(|c| c.class("btn-primary", false));
set_only_local.set(false); set_only_local.set(false);
} }
/> />

View file

@ -29,7 +29,7 @@ pub fn Search() -> impl IntoView {
let mut search_results = SearchResults::default(); let mut search_results = SearchResults::default();
let url = Url::parse(&query); let url = Url::parse(&query);
let search_data = SearchArticleForm { query }; let search_data = SearchArticleForm { query };
let search = CLIENT.search(&search_data); let search = CLIENT.search(search_data);
match search.await { match search.await {
Ok(mut a) => search_results.articles.append(&mut a), Ok(mut a) => search_results.articles.append(&mut a),