From b08f584ab011efc6b6eeb78c419b7c4b0908556d Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Mon, 17 Jun 2024 15:08:03 -0400 Subject: [PATCH] rip out cozo --- Cargo.lock | 1216 +++++++---------- app/src/components/SearchBar.tsx | 15 +- app/src/components/nodes/JournalPage.tsx | 15 +- app/src/lib/data.ts | 11 + crates/panorama-core/Cargo.toml | 2 +- crates/panorama-core/build.rs | 3 + .../migrations/00001_initial.sql | 6 + crates/panorama-core/src/lib.rs | 3 +- crates/panorama-core/src/mail.rs | 343 +++-- crates/panorama-core/src/messaging/mod.rs | 4 + crates/panorama-core/src/migrations.rs | 342 ++--- crates/panorama-core/src/state/codetrack.rs | 3 + crates/panorama-core/src/state/export.rs | 4 + crates/panorama-core/src/state/journal.rs | 2 +- crates/panorama-core/src/state/mod.rs | 55 +- crates/panorama-core/src/state/node.rs | 6 +- crates/panorama-core/src/state/utils.rs | 54 +- crates/panorama-daemon/Cargo.toml | 2 +- crates/panorama-daemon/src/codetrack.rs | 0 crates/panorama-daemon/src/export.rs | 25 - crates/panorama-daemon/src/journal.rs | 36 +- crates/panorama-daemon/src/lib.rs | 12 +- crates/panorama-daemon/src/mail.rs | 85 +- crates/panorama-daemon/src/node.rs | 298 ++-- 24 files changed, 1243 insertions(+), 1299 deletions(-) create mode 100644 app/src/lib/data.ts create mode 100644 crates/panorama-core/build.rs create mode 100644 crates/panorama-core/migrations/00001_initial.sql create mode 100644 crates/panorama-core/src/messaging/mod.rs create mode 100644 crates/panorama-core/src/state/codetrack.rs create mode 100644 crates/panorama-daemon/src/codetrack.rs delete mode 100644 crates/panorama-daemon/src/export.rs diff --git a/Cargo.lock b/Cargo.lock index 6c5a134..d54acdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,17 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" -dependencies = [ - "getrandom 0.2.15", - "once_cell", - "version_check", -] - [[package]] name = "ahash" version = "0.8.11" @@ -141,15 +130,6 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "approx" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" -dependencies = [ - "num-traits", -] - [[package]] name = "arbitrary" version = "1.3.2" @@ -165,12 +145,6 @@ version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "async-broadcast" version = "0.7.1" @@ -392,12 +366,6 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" -[[package]] -name = "atomic_float" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62af46d040ba9df09edc6528dae9d8e49f5f3e82f55b7d2ec31a733c38dbc49d" - [[package]] name = "autocfg" version = "1.3.0" @@ -509,21 +477,18 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + [[package]] name = "bimap" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "230c5f1ca6a325a32553f8640d31ac9b49f2411e901e427570154868b46da4f7" -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - [[package]] name = "bitflags" version = "1.3.2" @@ -612,12 +577,6 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "bytemuck" version = "1.16.0" @@ -706,15 +665,6 @@ dependencies = [ "toml 0.8.2", ] -[[package]] -name = "casey" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614586263949597dcc18675da12ef9b429135e13628d92eb8b8c6fa50ca5656b" -dependencies = [ - "syn 1.0.109", -] - [[package]] name = "cc" version = "1.0.98" @@ -726,15 +676,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "cedarwood" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d910bedd62c24733263d0bed247460853c9d22e8956bd4cd964302095e04e90" -dependencies = [ - "smallvec", -] - [[package]] name = "census" version = "0.4.2" @@ -795,28 +736,6 @@ dependencies = [ "windows-targets 0.52.5", ] -[[package]] -name = "chrono-tz" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59ae0466b83e838b81a54256c39d5d7c20b9d7daa10510a242d9b75abd5936e" -dependencies = [ - "chrono", - "chrono-tz-build", - "phf 0.11.2", -] - -[[package]] -name = "chrono-tz-build" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433e39f13c9a060046954e0592a8d0a4bcb1040125cbf91cb8ee58964cfb350f" -dependencies = [ - "parse-zoneinfo", - "phf 0.11.2", - "phf_codegen 0.11.2", -] - [[package]] name = "clap" version = "4.5.7" @@ -887,16 +806,6 @@ dependencies = [ "objc", ] -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - [[package]] name = "colorchoice" version = "1.0.1" @@ -922,6 +831,12 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "convert_case" version = "0.4.0" @@ -996,79 +911,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cozo" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a0e07500b27e8f77ebcb6eac4c9a76a173f960da42e843fd13cd8f74178e3f8" -dependencies = [ - "aho-corasick", - "approx", - "base64 0.21.7", - "byteorder", - "casey", - "chrono", - "chrono-tz", - "cozorocks", - "crossbeam", - "csv", - "document-features", - "either", - "env_logger", - "fast2s", - "graph", - "itertools 0.12.1", - "jieba-rs", - "lazy_static", - "log", - "miette", - "minreq", - "ndarray", - "num-traits", - "ordered-float", - "pest", - "pest_derive", - "priority-queue", - "quadrature", - "rand 0.8.5", - "rayon", - "regex", - "rmp", - "rmp-serde", - "rmpv", - "rust-stemmers", - "rustc-hash", - "serde", - "serde_bytes", - "serde_derive", - "serde_json", - "sha2", - "smallvec", - "smartstring", - "sqlite", - "sqlite3-src", - "swapvec", - "thiserror", - "twox-hash", - "unicode-normalization", - "uuid", -] - -[[package]] -name = "cozorocks" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c948d757956819219eb6ddab355a2dcc96b1f3896b38d6dbb202f79d2405a8d" -dependencies = [ - "cc", - "cxx", - "cxx-build", - "libc", - "lz4-sys", - "miette", - "zstd-sys", -] - [[package]] name = "cpufeatures" version = "0.2.12" @@ -1078,6 +920,21 @@ dependencies = [ "libc", ] +[[package]] +name = "crc" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + [[package]] name = "crc32fast" version = "1.4.2" @@ -1087,19 +944,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-epoch", - "crossbeam-queue", - "crossbeam-utils", -] - [[package]] name = "crossbeam-channel" version = "0.5.13" @@ -1217,50 +1061,6 @@ dependencies = [ "syn 2.0.66", ] -[[package]] -name = "cxx" -version = "1.0.121" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21db378d04296a84d8b7d047c36bb3954f0b46529db725d7e62fb02f9ba53ccc" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.121" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5262a7fa3f0bae2a55b767c223ba98032d7c328f5c13fa5cdc980b77fc0658" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn 2.0.66", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.121" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be8dcadd2e2fb4a501e1d9e93d6e88e6ea494306d8272069c92d5a9edf8855c0" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.121" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad08a837629ad949b73d032c637653d069e909cffe4ee7870b02301939ce39cc" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "darling" version = "0.20.9" @@ -1296,19 +1096,6 @@ dependencies = [ "syn 2.0.66", ] -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown 0.14.5", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "data-url" version = "0.3.1" @@ -1316,14 +1103,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a" [[package]] -name = "delegate" -version = "0.8.0" +name = "der" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "082a24a9967533dc5d743c602157637116fc1b52806d694a5a45e6f32567fcdd" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "const-oid", + "pem-rfc7468", + "zeroize", ] [[package]] @@ -1378,7 +1165,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", + "subtle", ] [[package]] @@ -1473,13 +1262,10 @@ dependencies = [ ] [[package]] -name = "document-features" -version = "0.2.8" +name = "dotenvy" +version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef5282ad69563b5fc40319526ba27e0e7363d552a896f0297d54f767717f9b95" -dependencies = [ - "litrs", -] +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" [[package]] name = "downcast-rs" @@ -1528,6 +1314,9 @@ name = "either" version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +dependencies = [ + "serde", +] [[package]] name = "embed-resource" @@ -1585,19 +1374,6 @@ dependencies = [ "syn 2.0.66", ] -[[package]] -name = "env_logger" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -1614,6 +1390,17 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys 0.48.0", +] + [[package]] name = "event-listener" version = "2.5.3" @@ -1641,23 +1428,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "fast-float" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95765f67b4b18863968b4a1bd5bb576f732b29a4a28c7cd84c09fa3e2875f33c" - -[[package]] -name = "fast2s" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1316063b5422f1f7bf4cc784c959eaf04b843de7c9ecbd4190c60614aa23b27e" -dependencies = [ - "bincode", - "hashbrown 0.12.3", - "lazy_static", -] - [[package]] name = "fastdivide" version = "0.4.1" @@ -1699,6 +1469,17 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "flume" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +dependencies = [ + "futures-core", + "futures-sink", + "spin 0.9.8", +] + [[package]] name = "fnv" version = "1.0.7" @@ -1803,6 +1584,17 @@ dependencies = [ "futures-util", ] +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot", +] + [[package]] name = "futures-io" version = "0.3.30" @@ -2132,46 +1924,6 @@ dependencies = [ "system-deps", ] -[[package]] -name = "graph" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e5a6f21cf3fabb758f26cea0f3b5854189d435d4337d85226020e3869fcc8b3" -dependencies = [ - "ahash 0.8.11", - "atomic_float", - "graph_builder", - "log", - "nanorand", - "num-format", - "rayon", -] - -[[package]] -name = "graph_builder" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e1cfa7a71e06cdd160ce79175bdffd0477bbc97ec943491dd882ba3bd0a2e63" -dependencies = [ - "atoi", - "atomic", - "byte-slice-cast", - "dashmap", - "delegate", - "fast-float", - "fxhash", - "linereader", - "log", - "memmap2 0.5.10", - "num", - "num-format", - "num_cpus", - "page_size", - "parking_lot", - "rayon", - "thiserror", -] - [[package]] name = "gtk" version = "0.18.1" @@ -2248,9 +2000,6 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.8", -] [[package]] name = "hashbrown" @@ -2258,15 +2007,27 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ - "ahash 0.8.11", + "ahash", "allocator-api2", ] +[[package]] +name = "hashlink" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" +dependencies = [ + "hashbrown 0.14.5", +] + [[package]] name = "heck" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +dependencies = [ + "unicode-segmentation", +] [[package]] name = "heck" @@ -2286,6 +2047,33 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "html5ever" version = "0.26.0" @@ -2352,12 +2140,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hyper" version = "1.3.1" @@ -2628,21 +2410,6 @@ dependencies = [ "system-deps", ] -[[package]] -name = "jieba-rs" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f0c1347cd3ac8d7c6e3a2dc33ac496d365cf09fc0831aa61111e1a6738983e" -dependencies = [ - "cedarwood", - "fxhash", - "hashbrown 0.14.5", - "lazy_static", - "phf 0.11.2", - "phf_codegen 0.11.2", - "regex", -] - [[package]] name = "jni" version = "0.21.1" @@ -2723,6 +2490,9 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin 0.5.2", +] [[package]] name = "levenshtein_automata" @@ -2796,42 +2566,29 @@ dependencies = [ "libc", ] +[[package]] +name = "libsqlite3-sys" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4e226dcd58b4be396f7bd3c20da8fdee2911400705297ba7d2d7cc2c30f716" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + [[package]] name = "line-wrap" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd1bc4d24ad230d21fb898d1116b1801d7adfc449d42026475862ab48b11e70e" -[[package]] -name = "linereader" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d921fea6860357575519aca014c6e22470585accdd543b370c404a8a72d0dd1d" -dependencies = [ - "memchr", -] - -[[package]] -name = "link-cplusplus" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9" -dependencies = [ - "cc", -] - [[package]] name = "linux-raw-sys" version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" -[[package]] -name = "litrs" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" - [[package]] name = "lock_api" version = "0.4.12" @@ -2886,25 +2643,6 @@ dependencies = [ "hashbrown 0.14.5", ] -[[package]] -name = "lz4-sys" -version = "1.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d27b317e207b10f69f5e75494119e391a96f48861ae870d1da6edac98ca900" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "lz4_flex" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b8c72594ac26bfd34f2d99dfced2edfaddfe8a476e3ff2ca0eb293d925c4f83" -dependencies = [ - "twox-hash", -] - [[package]] name = "lz4_flex" version = "0.11.3" @@ -2962,13 +2700,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] -name = "matrixmultiply" -version = "0.3.8" +name = "md-5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7574c1cf36da4798ab73da5b215bbf444f50718207754cb522201d78d1cd0ff2" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" dependencies = [ - "autocfg", - "rawpointer", + "cfg-if", + "digest", ] [[package]] @@ -2987,15 +2725,6 @@ version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" -[[package]] -name = "memmap2" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" -dependencies = [ - "libc", -] - [[package]] name = "memmap2" version = "0.9.4" @@ -3078,19 +2807,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "minreq" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fdef521c74c2884a4f3570bcdb6d2a77b3c533feb6b27ac2ae72673cc221c64" -dependencies = [ - "log", - "once_cell", - "rustls 0.21.12", - "rustls-webpki 0.101.7", - "webpki-roots 0.25.4", -] - [[package]] name = "mio" version = "0.8.11" @@ -3127,26 +2843,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2195bf6aa996a481483b29d62a7663eed3fe39600c460e323f8ff41e90bdd89b" -[[package]] -name = "nanorand" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" - -[[package]] -name = "ndarray" -version = "0.15.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb12d4e967ec485a5f71c6311fe28158e9d6f4bc4a447b474184d0f91a8fa32" -dependencies = [ - "matrixmultiply", - "num-complex", - "num-integer", - "num-traits", - "rawpointer", - "serde", -] - [[package]] name = "ndk" version = "0.7.0" @@ -3221,36 +2917,20 @@ dependencies = [ ] [[package]] -name = "num" -version = "0.4.3" +name = "num-bigint-dig" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" dependencies = [ - "num-bigint", - "num-complex", + "byteorder", + "lazy_static", + "libm", "num-integer", "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ "num-traits", + "rand 0.8.5", + "smallvec", + "zeroize", ] [[package]] @@ -3259,16 +2939,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" -[[package]] -name = "num-format" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" -dependencies = [ - "arrayvec", - "itoa 1.0.11", -] - [[package]] name = "num-integer" version = "0.1.46" @@ -3289,17 +2959,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -3530,15 +3189,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" -[[package]] -name = "ordered-float" -version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76df7075c7d4d01fdcb46c912dd17fba5b60c78ea480b475f2b6ab6f666584e" -dependencies = [ - "num-traits", -] - [[package]] name = "ordered-stream" version = "0.2.0" @@ -3580,16 +3230,6 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" -[[package]] -name = "page_size" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebde548fbbf1ea81a99b128872779c437752fb99f217c45245e1a61dcd9edcd" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "pango" version = "0.18.3" @@ -3641,12 +3281,12 @@ dependencies = [ "backoff", "bimap", "chrono", - "cozo", "futures", "itertools 0.13.0", "miette", "serde", "serde_json", + "sqlx", "sugars", "tantivy", "tokio", @@ -3661,7 +3301,6 @@ dependencies = [ "async-imap", "axum", "chrono", - "cozo", "csv", "dirs", "futures", @@ -3710,20 +3349,11 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.5.1", "smallvec", "windows-targets 0.52.5", ] -[[package]] -name = "parse-zoneinfo" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f2a05b18d44e2957b88f96ba460715e295bc1d7510468a2f3d3b44535d26c24" -dependencies = [ - "regex", -] - [[package]] name = "paste" version = "1.0.15" @@ -3736,57 +3366,21 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" -[[package]] -name = "pest" -version = "2.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" -dependencies = [ - "memchr", - "thiserror", - "ucd-trie", -] - -[[package]] -name = "pest_derive" -version = "2.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459" -dependencies = [ - "pest", - "pest_generator", -] - -[[package]] -name = "pest_generator" -version = "2.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687" -dependencies = [ - "pest", - "pest_meta", - "proc-macro2", - "quote", - "syn 2.0.66", -] - -[[package]] -name = "pest_meta" -version = "2.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd" -dependencies = [ - "once_cell", - "pest", - "sha2", -] - [[package]] name = "phf" version = "0.8.0" @@ -3837,16 +3431,6 @@ dependencies = [ "phf_shared 0.10.0", ] -[[package]] -name = "phf_codegen" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a" -dependencies = [ - "phf_generator 0.11.2", - "phf_shared 0.11.2", -] - [[package]] name = "phf_generator" version = "0.8.0" @@ -3974,6 +3558,27 @@ dependencies = [ "futures-io", ] +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.30" @@ -4040,16 +3645,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" -[[package]] -name = "priority-queue" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0bda9164fe05bc9225752d54aae413343c36f684380005398a6a8fde95fe785" -dependencies = [ - "autocfg", - "indexmap 1.9.3", -] - [[package]] name = "proc-macro-crate" version = "1.3.1" @@ -4125,12 +3720,6 @@ dependencies = [ "psl-types", ] -[[package]] -name = "quadrature" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2054ccb02f454fcb2bc81e343aa0a171636a6331003fd5ec24c47a10966634b7" - [[package]] name = "quick-xml" version = "0.31.0" @@ -4252,12 +3841,6 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" -[[package]] -name = "rawpointer" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" - [[package]] name = "rayon" version = "1.10.0" @@ -4278,6 +3861,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_syscall" version = "0.5.1" @@ -4371,7 +3963,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustls 0.22.4", - "rustls-pemfile", + "rustls-pemfile 2.1.2", "rustls-pki-types", "serde", "serde_json", @@ -4401,41 +3993,29 @@ dependencies = [ "cfg-if", "getrandom 0.2.15", "libc", - "spin", + "spin 0.9.8", "untrusted", "windows-sys 0.52.0", ] [[package]] -name = "rmp" -version = "0.8.14" +name = "rsa" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "228ed7c16fa39782c3b3468e974aec2795e9089153cd08ee2e9aefb3613334c4" +checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" dependencies = [ - "byteorder", + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", "num-traits", - "paste", -] - -[[package]] -name = "rmp-serde" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e599a477cf9840e92f2cde9a7189e67b42c57532749bf90aea6ec10facd4db" -dependencies = [ - "byteorder", - "rmp", - "serde", -] - -[[package]] -name = "rmpv" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58450723cd9ee93273ce44a20b6ec4efe17f8ed2e3631474387bfdecf18bb2a9" -dependencies = [ - "num-traits", - "rmp", + "pkcs1", + "pkcs8", + "rand_core 0.6.4", + "signature", + "spki", + "subtle", + "zeroize", ] [[package]] @@ -4522,7 +4102,6 @@ version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ - "log", "ring", "rustls-webpki 0.101.7", "sct", @@ -4542,6 +4121,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.7", +] + [[package]] name = "rustls-pemfile" version = "2.1.2" @@ -4638,12 +4226,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "scratch" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" - [[package]] name = "sct" version = "0.7.1" @@ -4698,15 +4280,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde_bytes" -version = "0.11.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" -dependencies = [ - "serde", -] - [[package]] name = "serde_derive" version = "1.0.203" @@ -4907,6 +4480,16 @@ dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core 0.6.4", +] + [[package]] name = "simd-adler32" version = "0.3.7" @@ -4942,21 +4525,6 @@ name = "smallvec" version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -dependencies = [ - "serde", -] - -[[package]] -name = "smartstring" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" -dependencies = [ - "autocfg", - "serde", - "static_assertions", - "version_check", -] [[package]] name = "smawk" @@ -4991,7 +4559,7 @@ dependencies = [ "objc2-foundation", "objc2-quartz-core", "raw-window-handle 0.6.2", - "redox_syscall", + "redox_syscall 0.5.1", "wasm-bindgen", "wayland-sys", "web-sys", @@ -5024,40 +4592,245 @@ dependencies = [ "system-deps", ] +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + [[package]] name = "spin" version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - -[[package]] -name = "sqlite" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03801c10193857d6a4a71ec46cee198a15cbc659622aabe1db0d0bdbefbcf8e6" dependencies = [ - "libc", - "sqlite3-sys", + "lock_api", ] [[package]] -name = "sqlite3-src" -version = "0.5.1" +name = "spki" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfc95a51a1ee38839599371685b9d4a926abb51791f0bc3bf8c3bb7867e6e454" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ - "cc", - "pkg-config", + "base64ct", + "der", ] [[package]] -name = "sqlite3-sys" -version = "0.15.2" +name = "sqlformat" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2752c669433e40ebb08fde824146f50d9628aa0b66a3b7fc6be34db82a8063b" +checksum = "f895e3734318cc55f1fe66258926c9b910c124d47520339efecbb6c59cec7c1f" dependencies = [ - "libc", - "sqlite3-src", + "nom", + "unicode_categories", +] + +[[package]] +name = "sqlx" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9a2ccff1a000a5a59cd33da541d9f2fdcd9e6e8229cc200565942bff36d0aaa" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24ba59a9342a3d9bab6c56c118be528b27c9b60e490080e9711a04dccac83ef6" +dependencies = [ + "ahash", + "atoi", + "byteorder", + "bytes", + "chrono", + "crc", + "crossbeam-queue", + "either", + "event-listener 2.5.3", + "futures-channel", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashlink", + "hex", + "indexmap 2.2.6", + "log", + "memchr", + "once_cell", + "paste", + "percent-encoding", + "rustls 0.21.12", + "rustls-pemfile 1.0.4", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlformat", + "thiserror", + "tokio", + "tokio-stream", + "tracing", + "url", + "uuid", + "webpki-roots 0.25.4", +] + +[[package]] +name = "sqlx-macros" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea40e2345eb2faa9e1e5e326db8c34711317d2b5e08d0d5741619048a803127" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 1.0.109", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5833ef53aaa16d860e92123292f1f6a3d53c34ba8b1969f152ef1a7bb803f3c8" +dependencies = [ + "dotenvy", + "either", + "heck 0.4.1", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", + "sqlx-core", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", + "syn 1.0.109", + "tempfile", + "tokio", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ed31390216d20e538e447a7a9b959e06ed9fc51c37b514b46eb758016ecd418" +dependencies = [ + "atoi", + "base64 0.21.7", + "bitflags 2.5.0", + "byteorder", + "bytes", + "chrono", + "crc", + "digest", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array", + "hex", + "hkdf", + "hmac", + "itoa 1.0.11", + "log", + "md-5", + "memchr", + "once_cell", + "percent-encoding", + "rand 0.8.5", + "rsa", + "serde", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "uuid", + "whoami", +] + +[[package]] +name = "sqlx-postgres" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c824eb80b894f926f89a0b9da0c7f435d27cdd35b8c655b114e58223918577e" +dependencies = [ + "atoi", + "base64 0.21.7", + "bitflags 2.5.0", + "byteorder", + "chrono", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa 1.0.11", + "log", + "md-5", + "memchr", + "once_cell", + "rand 0.8.5", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "uuid", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b244ef0a8414da0bed4bb1910426e890b19e5e9bccc27ada6b797d05c55ae0aa" +dependencies = [ + "atoi", + "chrono", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "regex", + "serde", + "sqlx-core", + "tracing", + "url", + "urlencoding", + "uuid", ] [[package]] @@ -5119,6 +4892,17 @@ dependencies = [ "quote", ] +[[package]] +name = "stringprep" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" +dependencies = [ + "unicode-bidi", + "unicode-normalization", + "unicode-properties", +] + [[package]] name = "strsim" version = "0.11.1" @@ -5165,19 +4949,6 @@ dependencies = [ "is-terminal", ] -[[package]] -name = "swapvec" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec5f895272298fe2ed7c8f15dcee10b00ce396c8caebd602275fd10f49797d02" -dependencies = [ - "bincode", - "lz4_flex 0.10.0", - "miniz_oxide", - "serde", - "tempfile", -] - [[package]] name = "swift-rs" version = "1.0.6" @@ -5280,9 +5051,9 @@ dependencies = [ "levenshtein_automata", "log", "lru", - "lz4_flex 0.11.3", + "lz4_flex", "measure_time", - "memmap2 0.9.4", + "memmap2", "num_cpus", "once_cell", "oneshot", @@ -5785,15 +5556,6 @@ dependencies = [ "utf-8", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "terminal_size" version = "0.1.17" @@ -5938,6 +5700,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-stream" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.11" @@ -6143,29 +5916,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" -[[package]] -name = "twox-hash" -version = "1.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" -dependencies = [ - "cfg-if", - "rand 0.8.5", - "static_assertions", -] - [[package]] name = "typenum" version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" -[[package]] -name = "ucd-trie" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" - [[package]] name = "uds_windows" version = "1.1.0" @@ -6254,6 +6010,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-properties" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4259d9d4425d9f0661581b804cb85fe66a4c631cadd8f490d1c13a35d5d9291" + [[package]] name = "unicode-segmentation" version = "1.11.0" @@ -6266,6 +6028,12 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + [[package]] name = "unsafe-libyaml" version = "0.2.11" @@ -6290,6 +6058,12 @@ dependencies = [ "serde", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + [[package]] name = "urlpattern" version = "0.2.0" @@ -6390,6 +6164,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-compare" version = "0.2.0" @@ -6453,6 +6233,12 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" + [[package]] name = "wasm-bindgen" version = "0.2.92" @@ -6648,6 +6434,16 @@ dependencies = [ "windows-core 0.56.0", ] +[[package]] +name = "whoami" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" +dependencies = [ + "redox_syscall 0.4.1", + "wasite", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/app/src/components/SearchBar.tsx b/app/src/components/SearchBar.tsx index 2f5f22a..57fbde7 100644 --- a/app/src/components/SearchBar.tsx +++ b/app/src/components/SearchBar.tsx @@ -1,20 +1,18 @@ import styles from "./SearchBar.module.scss"; import { - FloatingFocusManager, FloatingOverlay, FloatingPortal, autoUpdate, offset, - useClick, useDismiss, useFloating, useFocus, useInteractions, } from "@floating-ui/react"; -import { useDebounce } from "use-debounce"; -import { useEffect, useState } from "react"; +import { useCallback, useEffect, useState } from "react"; import { atom, useAtom, useSetAtom } from "jotai"; import { useNodeControls } from "../App"; +import { useDebounce, useDebouncedCallback } from "use-debounce"; const searchQueryAtom = atom(""); const showMenuAtom = atom(false); @@ -37,8 +35,7 @@ export default function SearchBar() { useDismiss(context), ]); - useEffect(() => { - setSearchResults([]); + const performSearch = useCallback(() => { const trimmed = searchQuery.trim(); if (trimmed === "") return; @@ -63,7 +60,11 @@ export default function SearchBar() { onFocus={() => setShowMenu(true)} ref={refs.setReference} value={searchQuery} - onChange={(evt) => setSearchQuery(evt.target.value)} + onChange={(evt) => { + setSearchQuery(evt.target.value); + if (evt.target.value) performSearch(); + else setSearchResults([]); + }} {...getReferenceProps()} /> diff --git a/app/src/components/nodes/JournalPage.tsx b/app/src/components/nodes/JournalPage.tsx index 20ae931..e4c7665 100644 --- a/app/src/components/nodes/JournalPage.tsx +++ b/app/src/components/nodes/JournalPage.tsx @@ -7,18 +7,15 @@ import remarkMath from "remark-math"; import rehypeKatex from "rehype-katex"; import { parse as parseDate, format as formatDate } from "date-fns"; import { useDebounce } from "use-debounce"; - -const JOURNAL_PAGE_CONTENT_FIELD_NAME = "panorama/journal/page/content"; -const JOURNAL_PAGE_TITLE_FIELD_NAME = "panorama/journal/page/title"; +import { + JOURNAL_PAGE_CONTENT_FIELD_NAME, + JOURNAL_PAGE_TITLE_FIELD_NAME, + NodeInfo, +} from "../../lib/data"; export interface JournalPageProps { id: string; - data: { - day?: string; - title?: string; - content: string; - fields: object; - }; + data: NodeInfo; } export default function JournalPage({ id, data }: JournalPageProps) { diff --git a/app/src/lib/data.ts b/app/src/lib/data.ts new file mode 100644 index 0000000..b94cef8 --- /dev/null +++ b/app/src/lib/data.ts @@ -0,0 +1,11 @@ +export interface NodeInfo { + fields: Partial; +} + +export const JOURNAL_PAGE_CONTENT_FIELD_NAME = "panorama/journal/page/content"; +export const JOURNAL_PAGE_TITLE_FIELD_NAME = "panorama/journal/page/title"; + +export interface NodeFields { + [JOURNAL_PAGE_CONTENT_FIELD_NAME]: string; + [JOURNAL_PAGE_TITLE_FIELD_NAME]: string; +} diff --git a/crates/panorama-core/Cargo.toml b/crates/panorama-core/Cargo.toml index 7ea96f1..02d3444 100644 --- a/crates/panorama-core/Cargo.toml +++ b/crates/panorama-core/Cargo.toml @@ -7,12 +7,12 @@ edition = "2021" backoff = { version = "0.4.0", features = ["tokio"] } bimap = "0.6.3" chrono = { version = "0.4.38", features = ["serde"] } -cozo = { version = "0.7.6", features = ["storage-rocksdb"] } futures = "0.3.30" itertools = "0.13.0" miette = { version = "5.5.0", features = ["fancy", "backtrace"] } serde = { version = "1.0.203", features = ["derive"] } serde_json = "1.0.117" +sqlx = { version = "0.7.4", features = ["runtime-tokio", "tls-rustls", "macros", "sqlite", "uuid", "chrono", "regexp"] } sugars = "3.0.1" tantivy = { version = "0.22.0", features = ["zstd"] } tokio = { version = "1.38.0", features = ["full"] } diff --git a/crates/panorama-core/build.rs b/crates/panorama-core/build.rs new file mode 100644 index 0000000..48ee2e3 --- /dev/null +++ b/crates/panorama-core/build.rs @@ -0,0 +1,3 @@ +fn main() { + println!("cargo:rerun-if-changed=migrations"); +} diff --git a/crates/panorama-core/migrations/00001_initial.sql b/crates/panorama-core/migrations/00001_initial.sql new file mode 100644 index 0000000..750590b --- /dev/null +++ b/crates/panorama-core/migrations/00001_initial.sql @@ -0,0 +1,6 @@ +CREATE TABLE "node" ( + id TEXT PRIMARY KEY, + type TEXT, + updated_at DATETIME DEFAULT NOW(), + extra_data JSON +); \ No newline at end of file diff --git a/crates/panorama-core/src/lib.rs b/crates/panorama-core/src/lib.rs index 810f458..bffa430 100644 --- a/crates/panorama-core/src/lib.rs +++ b/crates/panorama-core/src/lib.rs @@ -8,7 +8,8 @@ extern crate sugars; pub mod migrations; pub mod state; -pub mod mail; +// pub mod mail; +pub mod messaging; #[cfg(test)] mod tests; diff --git a/crates/panorama-core/src/mail.rs b/crates/panorama-core/src/mail.rs index 8af9702..b98207a 100644 --- a/crates/panorama-core/src/mail.rs +++ b/crates/panorama-core/src/mail.rs @@ -1,160 +1,291 @@ -use std::{collections::HashMap, time::Duration}; +use std::{ + collections::{HashMap, HashSet}, + time::Duration, +}; +use async_imap::Session; use backoff::{exponential::ExponentialBackoff, SystemClock}; -use cozo::{DataValue, JsonData, ScriptMutability}; use futures::TryStreamExt; -use miette::{IntoDiagnostic, Result}; +use itertools::Itertools; +use miette::{Context, IntoDiagnostic, Result}; use tokio::{net::TcpStream, time::sleep}; use uuid::Uuid; -use crate::AppState; +use crate::{mail, AppState}; -pub async fn mail_loop(state: AppState) -> Result<()> { - backoff::future::retry( - ExponentialBackoff::::default(), - || async { - mail_loop_inner(&state).await?; - // For now, just sleep 30 seconds and then fetch again - // TODO: Run a bunch of connections at once and do IDLE over them (if possible) - sleep(Duration::from_secs(30)).await; - - Ok(()) - }, - ) - .await?; - - Ok(()) +pub struct MailWorker { + state: AppState, } -async fn mail_loop_inner(state: &AppState) -> Result<()> { - // Fetch the mail configs - let configs = state.fetch_mail_configs()?; - if configs.len() == 0 { - return Ok(()); +impl MailWorker { + pub fn new(state: AppState) -> MailWorker { + MailWorker { state } } - // TODO: Do all configs instead of just the first - let config = &configs[0]; + pub async fn mail_loop(self) -> Result<()> { + loop { + let mut policy = ExponentialBackoff::::default(); + policy.current_interval = Duration::from_secs(5); + policy.initial_interval = Duration::from_secs(5); - let stream = - TcpStream::connect((config.imap_hostname.as_str(), config.imap_port)) + backoff::future::retry(policy, || async { + match self.mail_loop_inner().await { + Ok(_) => {} + Err(err) => { + eprintln!("Mail error: {:?}", err); + Err(err)?; + } + } + // For now, just sleep 30 seconds and then fetch again + // TODO: Run a bunch of connections at once and do IDLE over them (if possible) + sleep(Duration::from_secs(30)).await; + + Ok(()) + }) + .await?; + } + + Ok(()) + } + + async fn mail_loop_inner(&self) -> Result<()> { + // Fetch the mail configs + let configs = self.state.fetch_mail_configs()?; + if configs.is_empty() { + return Ok(()); + } + + // TODO: Do all configs instead of just the first + let config = &configs[0]; + + let stream = + TcpStream::connect((config.imap_hostname.as_str(), config.imap_port)) + .await + .into_diagnostic()?; + + let client = async_imap::Client::new(stream); + let mut session = client + .login(&config.imap_username, &config.imap_password) + .await + .map_err(|(err, _)| err) + .into_diagnostic()?; + + let all_mailbox_ids = self + .fetch_and_store_all_mailboxes(config.node_id.to_string(), &mut session) + .await + .context("Could not fetch mailboxes")?; + + self + .fetch_all_mail_from_single_mailbox( + &mut session, + &all_mailbox_ids, + config.node_id.to_string(), + "INBOX", + ) + .await + .context("Could not fetch mail from INBOX")?; + + session.logout().await.into_diagnostic()?; + + Ok(()) + } + + async fn fetch_and_store_all_mailboxes( + &self, + config_node_id: String, + session: &mut Session, + ) -> Result> { + // println!("Session: {:?}", session); + let mailboxes = session + .list(None, Some("*")) + .await + .into_diagnostic()? + .try_collect::>() .await .into_diagnostic()?; - let client = async_imap::Client::new(stream); - let mut session = client - .login(&config.imap_username, &config.imap_password) - .await - .map_err(|(err, _)| err) - .into_diagnostic()?; + let mut all_mailboxes = HashMap::new(); - // println!("Session: {:?}", session); - let mailboxes = session - .list(None, Some("*")) - .await - .into_diagnostic()? - .try_collect::>() - .await - .into_diagnostic()?; - let mailbox_names = - mailboxes.iter().map(|name| name.name()).collect::>(); - println!("mailboxes: {mailbox_names:?}"); + // TODO: Make this more efficient by using bulk in query - // Get the mailbox with INBOX - let inbox_node_id = { - let result = state.db.run_script(" - ?[node_id] := - *mailbox{node_id, account_node_id, mailbox_name}, - account_node_id = $account_node_id, - mailbox_name = 'INBOX' - ", btmap! {"account_node_id".to_owned()=>DataValue::from(config.node_id.to_string())}, ScriptMutability::Immutable)?; + for mailbox in mailboxes { + let tx = self.state.db.multi_transaction(true); - if result.rows.len() == 0 { - let new_node_id = Uuid::now_v7(); - let new_node_id = new_node_id.to_string(); - state.db.run_script(" - ?[node_id, account_node_id, mailbox_name] <- - [[$new_node_id, $account_node_id, 'INBOX']] - :put mailbox { node_id, account_node_id, mailbox_name } - ", - btmap! { - "new_node_id".to_owned() => DataValue::from(new_node_id.clone()), - "account_node_id".to_owned() => DataValue::from(config.node_id.to_string()), - }, - ScriptMutability::Mutable)?; - new_node_id - } else { - result.rows[0][0].get_str().unwrap().to_owned() + let result = tx.run_script( + " + ?[node_id] := + *mailbox{node_id, account_node_id, mailbox_name}, + account_node_id = $account_node_id, + mailbox_name = $mailbox_name, + ", + btmap! { + "account_node_id".to_owned()=>DataValue::from(config_node_id.clone()), + "mailbox_name".to_owned()=>DataValue::from(mailbox.name().to_string()), + }, + )?; + + let node_id = if result.rows.len() == 0 { + let new_node_id = Uuid::now_v7(); + let new_node_id = new_node_id.to_string(); + let extra_data = json!({ + "name": mailbox.name(), + }); + tx.run_script(" + ?[node_id, account_node_id, mailbox_name, extra_data] <- + [[$new_node_id, $account_node_id, $mailbox_name, $extra_data]] + :put mailbox { node_id, account_node_id, mailbox_name, extra_data } + ", + btmap! { + "new_node_id".to_owned() => DataValue::from(new_node_id.clone()), + "account_node_id".to_owned() => DataValue::from(config_node_id.clone()), + "mailbox_name".to_owned()=>DataValue::from(mailbox.name().to_string()), + "extra_data".to_owned()=>DataValue::Json(JsonData(extra_data)), + }, + )?; + new_node_id + } else { + result.rows[0][0].get_str().unwrap().to_owned() + }; + + tx.commit()?; + + all_mailboxes.insert(mailbox.name().to_owned(), node_id); } - }; - println!("INBOX: {:?}", inbox_node_id); - let inbox = session.select("INBOX").await.into_diagnostic()?; - println!("last unseen: {:?}", inbox.unseen); + // println!("All mailboxes: {:?}", all_mailboxes); - let messages = session - .fetch( - "1:4", - "(FLAGS ENVELOPE BODY[HEADER] BODY[TEXT] INTERNALDATE)", - ) - .await - .into_diagnostic()? - .try_collect::>() - .await - .into_diagnostic()?; - println!( - "messages {:?}", - messages.iter().map(|f| f.body()).collect::>() - ); + Ok(all_mailboxes) + } - let input_data = DataValue::List( - messages + async fn fetch_all_mail_from_single_mailbox( + &self, + session: &mut Session, + all_mailbox_ids: &HashMap, + config_node_id: String, + mailbox_name: impl AsRef, + ) -> Result<()> { + let mailbox_name = mailbox_name.as_ref(); + let mailbox = session.select(mailbox_name).await.into_diagnostic()?; + let mailbox_node_id = all_mailbox_ids.get(mailbox_name).unwrap(); + + let extra_data = json!({ + "uid_validity": mailbox.uid_validity, + "last_seen": mailbox.unseen, + }); + + // TODO: Validate uid validity here + + let all_uids = session + .uid_search("ALL") + .await + .into_diagnostic() + .context("Could not fetch all UIDs")?; + + println!("All UIDs ({}): {:?}", all_uids.len(), all_uids); + + let messages = session + .uid_fetch( + all_uids.iter().join(","), + "(FLAGS ENVELOPE BODY[HEADER] BODY[TEXT] INTERNALDATE)", + ) + .await + .into_diagnostic()? + .try_collect::>() + .await + .into_diagnostic() + .context("Could not fetch messages")?; + println!( + "messages {:?}", + messages.iter().map(|f| f.body()).collect::>() + ); + + let mut unique_message_ids = HashSet::new(); + let data: Vec<_> = messages .iter() .map(|msg| { - let message_id = Uuid::now_v7(); + let message_node_id = Uuid::now_v7(); let headers = String::from_utf8(msg.header().unwrap().to_vec()).unwrap(); let headers = headers .split("\r\n") .filter_map(|s| { + // This is really bad lmao let p = s.split(": ").collect::>(); if p.len() < 2 { None } else { - Some((p[0], p[1])) + Some((p[0], p[1..].join(": "))) } }) .collect::>(); + + let message_id = headers + .get("Message-ID") + .map(|s| (*s).to_owned()) + .unwrap_or(message_node_id.to_string()); + unique_message_ids.insert(message_id.clone()); + DataValue::List(vec![ - DataValue::from(message_id.to_string()), - DataValue::from(config.node_id.to_string()), - DataValue::from(inbox_node_id.clone()), + DataValue::from(message_node_id.to_string()), + DataValue::from(config_node_id.to_string()), + DataValue::from(mailbox_node_id.clone()), DataValue::from( headers .get("Subject") .map(|s| (*s).to_owned()) .unwrap_or("Subject".to_owned()), ), - DataValue::Json(JsonData(serde_json::to_value(headers).unwrap())), + DataValue::Json(JsonData(serde_json::to_value(&headers).unwrap())), DataValue::Bytes(msg.text().unwrap().to_vec()), DataValue::from(msg.internal_date().unwrap().to_rfc3339()), + DataValue::from(message_id), ]) }) - .collect(), - ); + .collect(); - state.db.run_script( + println!("Adding {} messages to database...", data.len()); + let input_data = DataValue::List(data); + + // TODO: Can this be one query? + let tx = self.state.db.multi_transaction(true); + + let unique_message_ids_data_value = DataValue::List( + unique_message_ids + .into_iter() + .map(|s| DataValue::from(s)) + .collect_vec(), + ); + + let existing_ids = tx.run_script( " - ?[node_id, account_node_id, mailbox_node_id, subject, headers, body, internal_date] <- $input_data - :put message { node_id, account_node_id, mailbox_node_id, subject, headers, body, internal_date } + ?[node_id] := *message { node_id, message_id }, + is_in(message_id, $message_ids) ", - btmap! { - "input_data".to_owned() => input_data, - }, - ScriptMutability::Mutable, + btmap! { "message_ids".to_owned() => unique_message_ids_data_value }, )?; + println!("Existing ids: {:?}", existing_ids); - session.logout().await.into_diagnostic()?; + self + .state + .db + .run_script( + " + ?[ + node_id, account_node_id, mailbox_node_id, subject, headers, body, + internal_date, message_id + ] <- $input_data + :put message { + node_id, account_node_id, mailbox_node_id, subject, headers, body, + internal_date, message_id + } + ", + btmap! { + "input_data".to_owned() => input_data, + }, + ScriptMutability::Mutable, + ) + .context("Could not add message to database")?; - Ok(()) + Ok(()) + } } diff --git a/crates/panorama-core/src/messaging/mod.rs b/crates/panorama-core/src/messaging/mod.rs new file mode 100644 index 0000000..9a3ba71 --- /dev/null +++ b/crates/panorama-core/src/messaging/mod.rs @@ -0,0 +1,4 @@ +//! Panorama uses an internal messaging system to pass content around +//! +//! This implementation is dead simple, just passes all messages and filters on the other end +pub struct Messaging {} diff --git a/crates/panorama-core/src/migrations.rs b/crates/panorama-core/src/migrations.rs index 0ddf4a4..bad97a2 100644 --- a/crates/panorama-core/src/migrations.rs +++ b/crates/panorama-core/src/migrations.rs @@ -1,196 +1,200 @@ -use cozo::DbInstance; use miette::{IntoDiagnostic, Result}; +use sqlx::migrate::Migrator; use serde_json::Value; use crate::ensure_ok; -pub async fn run_migrations(db: &DbInstance) -> Result<()> { - let migration_status = check_migration_status(db).await?; - println!("migration status: {:?}", migration_status); +pub static MIGRATOR: Migrator = sqlx::migrate!(); - let migrations: Vec Fn(&'a DbInstance) -> Result<()>>> = - vec![Box::new(no_op), Box::new(migration_01)]; +// pub async fn run_migrations(db: &DbInstance) -> Result<()> { +// let migration_status = check_migration_status(db).await?; +// println!("migration status: {:?}", migration_status); - if let MigrationStatus::NoMigrations = migration_status { - let result = db.run_script_str( - " - { :create migrations { yeah: Int default 0 => version: Int default 0 } } - { - ?[yeah, version] <- [[0, 0]] - :put migrations { yeah, version } - } - ", - "", - false, - ); - ensure_ok(&result)?; - } +// let migrations: Vec Fn(&'a DbInstance) -> Result<()>>> = +// vec![Box::new(no_op), Box::new(migration_01)]; - let start_at_migration = match migration_status { - MigrationStatus::NoMigrations => 0, - MigrationStatus::HasVersion(n) => n, - }; - let migrations_to_run = migrations - .iter() - .enumerate() - .skip(start_at_migration as usize + 1); - // println!("running {} migrations...", migrations_to_run.len()); +// if let MigrationStatus::NoMigrations = migration_status { +// let result = db.run_script_str( +// " +// { :create migrations { yeah: Int default 0 => version: Int default 0 } } +// { +// ?[yeah, version] <- [[0, 0]] +// :put migrations { yeah, version } +// } +// ", +// "", +// false, +// ); +// ensure_ok(&result)?; +// } - //TODO: This should all be done in a transaction - for (idx, migration) in migrations_to_run { - println!("running migration {idx}..."); +// let start_at_migration = match migration_status { +// MigrationStatus::NoMigrations => 0, +// MigrationStatus::HasVersion(n) => n, +// }; +// let migrations_to_run = migrations +// .iter() +// .enumerate() +// .skip(start_at_migration as usize + 1); +// // println!("running {} migrations...", migrations_to_run.len()); - migration(db)?; +// //TODO: This should all be done in a transaction +// for (idx, migration) in migrations_to_run { +// println!("running migration {idx}..."); - let result = db.run_script_str( - " - ?[yeah, version] <- [[0, $version]] - :put migrations { yeah => version } - ", - &format!("{{\"version\":{}}}", idx), - false, - ); +// migration(db)?; - ensure_ok(&result)?; +// let result = db.run_script_str( +// " +// ?[yeah, version] <- [[0, $version]] +// :put migrations { yeah => version } +// ", +// &format!("{{\"version\":{}}}", idx), +// false, +// ); - println!("succeeded migration {idx}!"); - } +// ensure_ok(&result)?; - Ok(()) -} +// println!("succeeded migration {idx}!"); +// } -#[derive(Debug)] -enum MigrationStatus { - NoMigrations, - HasVersion(u64), -} +// Ok(()) +// } -async fn check_migration_status(db: &DbInstance) -> Result { - let status = db.run_script_str( - " - ?[yeah, version] := *migrations[yeah, version] - ", - "", - true, - ); - println!("Status: {}", status); +// #[derive(Debug)] +// enum MigrationStatus { +// NoMigrations, +// HasVersion(u64), +// } - let status: Value = serde_json::from_str(&status).into_diagnostic()?; - let status = status.as_object().unwrap(); - let ok = status.get("ok").unwrap().as_bool().unwrap_or(false); - if !ok { - let status_code = status.get("code").unwrap().as_str().unwrap(); - if status_code == "query::relation_not_found" { - return Ok(MigrationStatus::NoMigrations); - } - } +// async fn check_migration_status(db: &DbInstance) -> Result { +// let status = db.run_script_str( +// " +// ?[yeah, version] := *migrations[yeah, version] +// ", +// "", +// true, +// ); +// println!("Status: {}", status); - let rows = status.get("rows").unwrap().as_array().unwrap(); - let row = rows[0].as_array().unwrap(); - let version = row[1].as_number().unwrap().as_u64().unwrap(); - println!("row: {row:?}"); +// let status: Value = serde_json::from_str(&status).into_diagnostic()?; +// let status = status.as_object().unwrap(); +// let ok = status.get("ok").unwrap().as_bool().unwrap_or(false); +// if !ok { +// let status_code = status.get("code").unwrap().as_str().unwrap(); +// if status_code == "query::relation_not_found" { +// return Ok(MigrationStatus::NoMigrations); +// } +// } - Ok(MigrationStatus::HasVersion(version)) -} +// let rows = status.get("rows").unwrap().as_array().unwrap(); +// let row = rows[0].as_array().unwrap(); +// let version = row[1].as_number().unwrap().as_u64().unwrap(); +// println!("row: {row:?}"); -fn no_op(_: &DbInstance) -> Result<()> { - Ok(()) -} +// Ok(MigrationStatus::HasVersion(version)) +// } -fn migration_01(db: &DbInstance) -> Result<()> { - let result = db.run_script_str( - " - # Primary node type - { - :create node { - id: String - => - type: String, - created_at: Float default now(), - updated_at: Float default now(), - extra_data: Json default {}, - } - } +// fn no_op(_: &DbInstance) -> Result<()> { +// Ok(()) +// } - # Inverse mappings for easy querying - { :create node_has_key { key: String => id: String } } - { ::index create node_has_key:inverse { id } } - { :create node_managed_by_app { node_id: String => app: String } } - { :create node_refers_to { node_id: String => other_node_id: String } } - { - :create fqkey_to_dbkey { - key: String - => - relation: String, - field_name: String, - type: String, - is_fts_enabled: Bool, - } - } - { - ?[key, relation, field_name, type, is_fts_enabled] <- [ - ['panorama/journal/page/day', 'journal_day', 'day', 'string', false], - ['panorama/journal/page/title', 'journal', 'title', 'string', true], - ['panorama/journal/page/content', 'journal', 'content', 'string', true], - ['panorama/mail/config/imap_hostname', 'mail_config', 'imap_hostname', 'string', false], - ['panorama/mail/config/imap_port', 'mail_config', 'imap_port', 'int', false], - ['panorama/mail/config/imap_username', 'mail_config', 'imap_username', 'string', false], - ['panorama/mail/config/imap_password', 'mail_config', 'imap_password', 'string', false], - ['panorama/mail/message/body', 'message', 'body', 'string', true], - ['panorama/mail/message/subject', 'message', 'subject', 'string', true], - ['panorama/mail/message/message_id', 'message', 'message_id', 'string', false], - ] - :put fqkey_to_dbkey { key, relation, field_name, type, is_fts_enabled } - } +// fn migration_01(db: &DbInstance) -> Result<()> { +// let result = db.run_script_str( +// " +// # Primary node type +// { +// :create node { +// id: String +// => +// type: String, +// created_at: Float default now(), +// updated_at: Float default now(), +// extra_data: Json default {}, +// } +// } - # Create journal type - { :create journal { node_id: String => title: String default '', content: String } } - { :create journal_day { day: String => node_id: String } } +// # Inverse mappings for easy querying +// { :create node_has_key { key: String => id: String } } +// { ::index create node_has_key:inverse { id } } +// { :create node_managed_by_app { node_id: String => app: String } } +// { :create node_refers_to { node_id: String => other_node_id: String } } +// { +// :create fqkey_to_dbkey { +// key: String +// => +// relation: String, +// field_name: String, +// type: String, +// is_fts_enabled: Bool, +// } +// } +// { +// ?[key, relation, field_name, type, is_fts_enabled] <- [ +// ['panorama/journal/page/day', 'journal_day', 'day', 'string', false], +// ['panorama/journal/page/title', 'journal', 'title', 'string', true], +// ['panorama/journal/page/content', 'journal', 'content', 'string', true], +// ['panorama/mail/config/imap_hostname', 'mail_config', 'imap_hostname', 'string', false], +// ['panorama/mail/config/imap_port', 'mail_config', 'imap_port', 'int', false], +// ['panorama/mail/config/imap_username', 'mail_config', 'imap_username', 'string', false], +// ['panorama/mail/config/imap_password', 'mail_config', 'imap_password', 'string', false], +// ['panorama/mail/message/body', 'message', 'body', 'string', true], +// ['panorama/mail/message/subject', 'message', 'subject', 'string', true], +// ['panorama/mail/message/message_id', 'message', 'message_id', 'string', false], +// ] +// :put fqkey_to_dbkey { key, relation, field_name, type, is_fts_enabled } +// } - # Mail - { - :create mail_config { - node_id: String - => - imap_hostname: String, - imap_port: Int, - imap_username: String, - imap_password: String, - } - } - { - :create mailbox { - node_id: String - => - account_node_id: String, - mailbox_name: String, - } - } - { ::index create mailbox:by_account_id_and_name { account_node_id, mailbox_name } } - { - :create message { - node_id: String - => - message_id: String, - account_node_id: String, - mailbox_node_id: String, - subject: String, - headers: Json?, - body: Bytes, - internal_date: String, - } - } - { ::index create message:message_id { message_id } } - { ::index create message:date { internal_date } } - { ::index create message:by_mailbox_id { mailbox_node_id } } +// # Create journal type +// { :create journal { node_id: String => title: String default '', content: String } } +// { :create journal_day { day: String => node_id: String } } - # Calendar - ", - "", - false, - ); - ensure_ok(&result)?; +// # Mail +// { +// :create mail_config { +// node_id: String +// => +// imap_hostname: String, +// imap_port: Int, +// imap_username: String, +// imap_password: String, +// } +// } +// { +// :create mailbox { +// node_id: String +// => +// account_node_id: String, +// mailbox_name: String, +// uid_validity: Int? default null, +// extra_data: Json default {}, +// } +// } +// { ::index create mailbox:by_account_id_and_name { account_node_id, mailbox_name } } +// { +// :create message { +// node_id: String +// => +// message_id: String, +// account_node_id: String, +// mailbox_node_id: String, +// subject: String, +// headers: Json?, +// body: Bytes, +// internal_date: String, +// } +// } +// { ::index create message:message_id { message_id } } +// { ::index create message:date { internal_date } } +// { ::index create message:by_mailbox_id { mailbox_node_id } } - Ok(()) -} +// # Calendar +// ", +// "", +// false, +// ); +// ensure_ok(&result)?; + +// Ok(()) +// } diff --git a/crates/panorama-core/src/state/codetrack.rs b/crates/panorama-core/src/state/codetrack.rs new file mode 100644 index 0000000..9710d2b --- /dev/null +++ b/crates/panorama-core/src/state/codetrack.rs @@ -0,0 +1,3 @@ +use crate::AppState; + +impl AppState {} diff --git a/crates/panorama-core/src/state/export.rs b/crates/panorama-core/src/state/export.rs index fdd5607..a169af9 100644 --- a/crates/panorama-core/src/state/export.rs +++ b/crates/panorama-core/src/state/export.rs @@ -47,6 +47,10 @@ impl AppState { let mut all_relations = hmap! {}; for relation_name in relation_names.iter() { + if relation_name.contains(":") { + continue; + } + let mut relation_info = vec![]; let columns = relation_columns.get(relation_name.as_str()).unwrap(); diff --git a/crates/panorama-core/src/state/journal.rs b/crates/panorama-core/src/state/journal.rs index 4bc4660..eed3447 100644 --- a/crates/panorama-core/src/state/journal.rs +++ b/crates/panorama-core/src/state/journal.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use chrono::Local; -use cozo::ScriptMutability; +// use cozo::ScriptMutability; use miette::{IntoDiagnostic, Result}; use uuid::Uuid; diff --git a/crates/panorama-core/src/state/mod.rs b/crates/panorama-core/src/state/mod.rs index a117b4c..3ff2532 100644 --- a/crates/panorama-core/src/state/mod.rs +++ b/crates/panorama-core/src/state/mod.rs @@ -1,21 +1,28 @@ -pub mod export; -pub mod journal; -pub mod mail; -pub mod node; -pub mod utils; +// pub mod codetrack; +// pub mod export; +// pub mod journal; +// pub mod mail; +// pub mod node; +// pub mod utils; use std::{collections::HashMap, fs, path::Path}; use bimap::BiMap; -use cozo::DbInstance; -use miette::{IntoDiagnostic, Result}; +use miette::{Context, IntoDiagnostic, Result}; +use sqlx::{ + sqlite::{SqliteConnectOptions, SqliteJournalMode, SqlitePoolOptions}, + SqlitePool, +}; use tantivy::{ directory::MmapDirectory, schema::{Field, Schema, STORED, STRING, TEXT}, Index, }; -use crate::{mail::mail_loop, migrations::run_migrations}; +use crate::{ + // mail::MailWorker, + migrations::{self, MIGRATOR}, +}; pub fn tantivy_schema() -> (Schema, BiMap) { let mut schema_builder = Schema::builder(); @@ -33,7 +40,7 @@ pub fn tantivy_schema() -> (Schema, BiMap) { #[derive(Clone)] pub struct AppState { - pub db: DbInstance, + pub db: SqlitePool, pub tantivy_index: Index, pub tantivy_field_map: BiMap, } @@ -41,6 +48,10 @@ pub struct AppState { impl AppState { pub async fn new(panorama_dir: impl AsRef) -> Result { let panorama_dir = panorama_dir.as_ref().to_path_buf(); + fs::create_dir_all(&panorama_dir) + .into_diagnostic() + .context("Could not create panorama directory")?; + println!("Panorama dir: {}", panorama_dir.display()); let (tantivy_index, tantivy_field_map) = { @@ -56,12 +67,14 @@ impl AppState { }; let db_path = panorama_dir.join("db.sqlite"); - let db = DbInstance::new( - "sqlite", - db_path.display().to_string(), - Default::default(), - ) - .unwrap(); + let sqlite_connect_options = SqliteConnectOptions::new() + .filename(db_path) + .journal_mode(SqliteJournalMode::Wal); + let db = SqlitePoolOptions::new() + .connect_with(sqlite_connect_options) + .await + .into_diagnostic() + .context("Could not connect to SQLite database")?; let state = AppState { db, @@ -74,10 +87,16 @@ impl AppState { } async fn init(&self) -> Result<()> { - run_migrations(&self.db).await?; + // run_migrations(&self.db).await?; + MIGRATOR + .run(&self.db) + .await + .into_diagnostic() + .context("Could not migrate database")?; - let state = self.clone(); - tokio::spawn(async move { mail_loop(state).await }); + // let state = self.clone(); + // let mail_worker = MailWorker::new(state); + // tokio::spawn(mail_worker.mail_loop()); Ok(()) } diff --git a/crates/panorama-core/src/state/node.rs b/crates/panorama-core/src/state/node.rs index 230a130..6286249 100644 --- a/crates/panorama-core/src/state/node.rs +++ b/crates/panorama-core/src/state/node.rs @@ -4,7 +4,6 @@ use std::{ }; use chrono::{DateTime, Utc}; -use cozo::{DataValue, MultiTransaction, NamedRows}; use itertools::Itertools; use miette::{bail, IntoDiagnostic, Result}; use serde_json::Value; @@ -18,7 +17,7 @@ use uuid::Uuid; use crate::{AppState, NodeId}; -use super::utils::{data_value_to_json_value, owned_value_to_json_value}; +use super::utils::owned_value_to_json_value; pub type ExtraData = BTreeMap; @@ -377,8 +376,9 @@ impl AppState { .get_by_left("panorama/journal/page/content") .unwrap() .clone(); - let query_parser = + let mut query_parser = QueryParser::for_index(&self.tantivy_index, vec![journal_page_field]); + query_parser.set_field_fuzzy(journal_page_field, true, 2, true); let query = query_parser.parse_query(query).into_diagnostic()?; let top_docs = searcher diff --git a/crates/panorama-core/src/state/utils.rs b/crates/panorama-core/src/state/utils.rs index 959249a..ef2d54a 100644 --- a/crates/panorama-core/src/state/utils.rs +++ b/crates/panorama-core/src/state/utils.rs @@ -1,4 +1,3 @@ -use cozo::{DataValue, Num}; use itertools::Itertools; use serde_json::{Number, Value}; use tantivy::schema::OwnedValue; @@ -30,28 +29,31 @@ pub fn owned_value_to_json_value(data_value: &OwnedValue) -> Value { } } -pub fn data_value_to_json_value(data_value: &DataValue) -> Value { - match data_value { - DataValue::Null => Value::Null, - DataValue::Bool(b) => Value::Bool(*b), - DataValue::Num(n) => Value::Number(match n { - Num::Int(i) => Number::from(*i), - Num::Float(f) => Number::from_f64(*f).unwrap(), - }), - DataValue::Str(s) => Value::String(s.to_string()), - DataValue::List(v) => { - Value::Array(v.into_iter().map(data_value_to_json_value).collect_vec()) - } - DataValue::Json(v) => v.0.clone(), - _ => { - println!("Converting unknown {:?}", data_value); - serde_json::to_value(data_value).unwrap() - } // DataValue::Bytes(s) => todo!(), - // DataValue::Uuid(_) => todo!(), - // DataValue::Regex(_) => todo!(), - // DataValue::Set(_) => todo!(), - // DataValue::Vec(_) => todo!(), - // DataValue::Validity(_) => todo!(), - // DataValue::Bot => todo!(), - } -} +// pub fn data_value_to_json_value(data_value: &DataValue) -> Value { +// match data_value { +// DataValue::Null => Value::Null, +// DataValue::Bool(b) => Value::Bool(*b), +// DataValue::Num(n) => Value::Number(match n { +// Num::Int(i) => Number::from(*i), +// Num::Float(f) => Number::from_f64(*f).unwrap(), +// }), +// DataValue::Str(s) => Value::String(s.to_string()), +// DataValue::List(v) => { +// Value::Array(v.into_iter().map(data_value_to_json_value).collect_vec()) +// } +// DataValue::Json(v) => v.0.clone(), +// DataValue::Bytes(s) => { +// Value::String(String::from_utf8_lossy(s).to_string()) +// } +// _ => { +// println!("Converting unknown {:?}", data_value); +// serde_json::to_value(data_value).unwrap() +// } // DataValue::Bytes(s) => todo!(), +// // DataValue::Uuid(_) => todo!(), +// // DataValue::Regex(_) => todo!(), +// // DataValue::Set(_) => todo!(), +// // DataValue::Vec(_) => todo!(), +// // DataValue::Validity(_) => todo!(), +// // DataValue::Bot => todo!(), +// } +// } diff --git a/crates/panorama-daemon/Cargo.toml b/crates/panorama-daemon/Cargo.toml index 50f8390..6c4ead6 100644 --- a/crates/panorama-daemon/Cargo.toml +++ b/crates/panorama-daemon/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" anyhow = "1.0.86" axum = "0.7.5" chrono = { version = "0.4.38", features = ["serde"] } -cozo = { version = "0.7.6", features = ["storage-rocksdb"] } +# cozo = { version = "0.7.6", features = ["storage-rocksdb"] } csv = "1.3.0" dirs = "5.0.1" futures = "0.3.30" diff --git a/crates/panorama-daemon/src/codetrack.rs b/crates/panorama-daemon/src/codetrack.rs new file mode 100644 index 0000000..e69de29 diff --git a/crates/panorama-daemon/src/export.rs b/crates/panorama-daemon/src/export.rs deleted file mode 100644 index 3b6b667..0000000 --- a/crates/panorama-daemon/src/export.rs +++ /dev/null @@ -1,25 +0,0 @@ -use std::{ - fs::{self, File}, - path::PathBuf, -}; - -use axum::{extract::State, Json}; -use miette::IntoDiagnostic; -use serde_json::Value; - -use crate::{error::AppResult, AppState}; - -// This code is really bad but gives me a quick way to look at all of the data -// in the data at once. Rip this out once there's any Real Security Mechanism. -pub async fn export(State(state): State) -> AppResult> { - let export = state.export().await?; - - let base_dir = PathBuf::from("export"); - fs::create_dir_all(&base_dir).into_diagnostic()?; - - let file = File::create(base_dir.join("export.json")).into_diagnostic()?; - - serde_json::to_writer_pretty(file, &export).into_diagnostic()?; - - Ok(Json(export)) -} diff --git a/crates/panorama-daemon/src/journal.rs b/crates/panorama-daemon/src/journal.rs index 668adfc..18f7371 100644 --- a/crates/panorama-daemon/src/journal.rs +++ b/crates/panorama-daemon/src/journal.rs @@ -1,6 +1,5 @@ use axum::{extract::State, routing::get, Json, Router}; use chrono::Local; -use cozo::ScriptMutability; use serde_json::Value; use utoipa::OpenApi; use uuid::Uuid; @@ -9,26 +8,27 @@ use crate::{error::AppResult, AppState}; /// Node API #[derive(OpenApi)] -#[openapi(paths(get_todays_journal_id), components(schemas()))] +#[openapi(paths(), components(schemas()))] pub(super) struct JournalApi; pub(super) fn router() -> Router { - Router::new().route("/get_todays_journal_id", get(get_todays_journal_id)) + Router::new() + // .route("/get_todays_journal_id", get(get_todays_journal_id)) } -#[utoipa::path( - get, - path = "/get_todays_journal_id", - responses( - (status = 200), - ), -)] -pub async fn get_todays_journal_id( - State(state): State, -) -> AppResult> { - let node_id = state.get_todays_journal_id().await?; +// #[utoipa::path( +// get, +// path = "/get_todays_journal_id", +// responses( +// (status = 200), +// ), +// )] +// pub async fn get_todays_journal_id( +// State(state): State, +// ) -> AppResult> { +// let node_id = state.get_todays_journal_id().await?; - Ok(Json(json!({ - "node_id": node_id.to_string(), - }))) -} +// Ok(Json(json!({ +// "node_id": node_id.to_string(), +// }))) +// } diff --git a/crates/panorama-daemon/src/lib.rs b/crates/panorama-daemon/src/lib.rs index 3ceaa86..4df6f09 100644 --- a/crates/panorama-daemon/src/lib.rs +++ b/crates/panorama-daemon/src/lib.rs @@ -8,7 +8,6 @@ extern crate serde_json; extern crate sugars; mod error; -mod export; mod journal; pub mod mail; mod node; @@ -27,12 +26,6 @@ use tower_http::{ use utoipa::OpenApi; use utoipa_scalar::{Scalar, Servable}; -use crate::{ - export::export, - mail::{get_mail, get_mail_config}, - node::search_nodes, -}; - pub async fn run() -> Result<()> { #[derive(OpenApi)] #[openapi( @@ -61,11 +54,10 @@ pub async fn run() -> Result<()> { let app = Router::new() .merge(Scalar::with_url("/api/docs", ApiDoc::openapi())) .route("/", get(|| async { "Hello, World!" })) - .route("/export", get(export)) .nest("/node", node::router().with_state(state.clone())) .nest("/journal", journal::router().with_state(state.clone())) - .route("/mail/config", get(get_mail_config)) - .route("/mail", get(get_mail)) + // .route("/mail/config", get(get_mail_config)) + // .route("/mail", get(get_mail)) .layer(ServiceBuilder::new().layer(cors_layer)) .layer(ServiceBuilder::new().layer(trace_layer)) .with_state(state.clone()); diff --git a/crates/panorama-daemon/src/mail.rs b/crates/panorama-daemon/src/mail.rs index 61c0d04..664d9c0 100644 --- a/crates/panorama-daemon/src/mail.rs +++ b/crates/panorama-daemon/src/mail.rs @@ -1,54 +1,53 @@ use axum::{extract::State, Json}; -use cozo::ScriptMutability; use panorama_core::AppState; use serde_json::Value; use crate::error::AppResult; -pub async fn get_mail_config( - State(state): State, -) -> AppResult> { - let configs = state.fetch_mail_configs()?; - Ok(Json(json!({ "configs": configs }))) -} +// pub async fn get_mail_config( +// State(state): State, +// ) -> AppResult> { +// let configs = state.fetch_mail_configs()?; +// Ok(Json(json!({ "configs": configs }))) +// } -pub async fn get_mail(State(state): State) -> AppResult> { - let mailboxes = state.db.run_script(" - ?[node_id, account_node_id, mailbox_name] := *mailbox {node_id, account_node_id, mailbox_name} - ", Default::default(), ScriptMutability::Immutable)?; +// pub async fn get_mail(State(state): State) -> AppResult> { +// let mailboxes = state.db.run_script(" +// ?[node_id, account_node_id, mailbox_name] := *mailbox {node_id, account_node_id, mailbox_name} +// ", Default::default(), ScriptMutability::Immutable)?; - let mailboxes = mailboxes - .rows - .iter() - .map(|mb| { - json!({ - "node_id": mb[0].get_str().unwrap(), - "account_node_id": mb[1].get_str().unwrap(), - "mailbox_name": mb[2].get_str().unwrap(), - }) - }) - .collect::>(); +// let mailboxes = mailboxes +// .rows +// .iter() +// .map(|mb| { +// json!({ +// "node_id": mb[0].get_str().unwrap(), +// "account_node_id": mb[1].get_str().unwrap(), +// "mailbox_name": mb[2].get_str().unwrap(), +// }) +// }) +// .collect::>(); - let messages = state.db.run_script(" - ?[node_id, subject, body, internal_date] := *message {node_id, subject, body, internal_date} - :limit 10 - ", Default::default(), ScriptMutability::Immutable)?; +// let messages = state.db.run_script(" +// ?[node_id, subject, body, internal_date] := *message {node_id, subject, body, internal_date} +// :limit 10 +// ", Default::default(), ScriptMutability::Immutable)?; - let messages = messages - .rows - .iter() - .map(|m| { - json!({ - "node_id": m[0].get_str().unwrap(), - "subject": m[1].get_str().unwrap(), - "body": m[2].get_str(), - "internal_date": m[3].get_str().unwrap(), - }) - }) - .collect::>(); +// let messages = messages +// .rows +// .iter() +// .map(|m| { +// json!({ +// "node_id": m[0].get_str().unwrap(), +// "subject": m[1].get_str().unwrap(), +// "body": m[2].get_str(), +// "internal_date": m[3].get_str().unwrap(), +// }) +// }) +// .collect::>(); - Ok(Json(json!({ - "mailboxes": mailboxes, - "messages": messages, - }))) -} +// Ok(Json(json!({ +// "mailboxes": mailboxes, +// "messages": messages, +// }))) +// } diff --git a/crates/panorama-daemon/src/node.rs b/crates/panorama-daemon/src/node.rs index c688033..3a40f91 100644 --- a/crates/panorama-daemon/src/node.rs +++ b/crates/panorama-daemon/src/node.rs @@ -10,11 +10,10 @@ use axum::{ Json, Router, }; use chrono::{DateTime, Utc}; -use cozo::{DataValue, MultiTransaction}; use itertools::Itertools; use miette::IntoDiagnostic; use panorama_core::{ - state::node::{CreateOrUpdate, ExtraData}, + // state::node::{CreateOrUpdate, ExtraData}, NodeId, }; use serde_json::Value; @@ -25,172 +24,169 @@ use crate::{error::AppResult, AppState}; /// Node API #[derive(OpenApi)] -#[openapi( - paths(get_node, update_node, create_node), - components(schemas(GetNodeResult)) -)] +#[openapi(paths(), components(schemas()))] pub(super) struct NodeApi; pub(super) fn router() -> Router { Router::new() - .route("/", put(create_node)) - .route("/:id", get(get_node)) - .route("/:id", post(update_node)) - .route("/search", get(search_nodes)) + // .route("/", put(create_node)) + // .route("/:id", get(get_node)) + // .route("/:id", post(update_node)) + // .route("/search", get(search_nodes)) } -#[derive(Serialize, Deserialize, ToSchema, Clone)] -struct GetNodeResult { - node_id: String, - fields: HashMap, - created_at: DateTime, - updated_at: DateTime, -} +// #[derive(Serialize, Deserialize, ToSchema, Clone)] +// struct GetNodeResult { +// node_id: String, +// fields: HashMap, +// created_at: DateTime, +// updated_at: DateTime, +// } -/// Get node info -/// -/// This endpoint retrieves all the fields for a particular node -#[utoipa::path( - get, - path = "/{id}", - responses( - (status = 200, body = [GetNodeResult]), - (status = 404, description = "the node ID provided was not found") - ), - params( - ("id" = String, Path, description = "Node ID"), - ), -)] -pub async fn get_node( - State(state): State, - Path(node_id): Path, -) -> AppResult<(StatusCode, Json)> { - let node_info = state.get_node(&node_id).await?; +// /// Get node info +// /// +// /// This endpoint retrieves all the fields for a particular node +// #[utoipa::path( +// get, +// path = "/{id}", +// responses( +// (status = 200, body = [GetNodeResult]), +// (status = 404, description = "the node ID provided was not found") +// ), +// params( +// ("id" = String, Path, description = "Node ID"), +// ), +// )] +// pub async fn get_node( +// State(state): State, +// Path(node_id): Path, +// ) -> AppResult<(StatusCode, Json)> { +// let node_info = state.get_node(&node_id).await?; - Ok(( - StatusCode::OK, - Json(json!({ - "node_id": node_id, - "fields": node_info.fields, - "created_at": node_info.created_at, - "updated_at": node_info.updated_at, - })), - )) -} +// Ok(( +// StatusCode::OK, +// Json(json!({ +// "node_id": node_id, +// "fields": node_info.fields, +// "created_at": node_info.created_at, +// "updated_at": node_info.updated_at, +// })), +// )) +// } -#[derive(Deserialize, Debug)] -pub struct UpdateData { - extra_data: Option, -} +// #[derive(Deserialize, Debug)] +// pub struct UpdateData { +// extra_data: Option, +// } -/// Update node info -#[utoipa::path( - post, - path = "/{id}", - responses( - (status = 200) - ), - params( - ("id" = String, Path, description = "Node ID"), - ) -)] -pub async fn update_node( - State(state): State, - Path(node_id): Path, - Json(opts): Json, -) -> AppResult> { - let node_id = NodeId(Uuid::from_str(&node_id).into_diagnostic()?); - let node_info = state - .create_or_update_node(CreateOrUpdate::Update { node_id }, opts.extra_data) - .await?; +// /// Update node info +// #[utoipa::path( +// post, +// path = "/{id}", +// responses( +// (status = 200) +// ), +// params( +// ("id" = String, Path, description = "Node ID"), +// ) +// )] +// pub async fn update_node( +// State(state): State, +// Path(node_id): Path, +// Json(opts): Json, +// ) -> AppResult> { +// let node_id = NodeId(Uuid::from_str(&node_id).into_diagnostic()?); +// let node_info = state +// .create_or_update_node(CreateOrUpdate::Update { node_id }, opts.extra_data) +// .await?; - Ok(Json(json!({ - "node_id": node_info.node_id.to_string(), - }))) -} +// Ok(Json(json!({ +// "node_id": node_info.node_id.to_string(), +// }))) +// } -#[derive(Debug, Deserialize)] -pub struct CreateNodeOpts { - // TODO: Allow submitting a string - // id: Option, - #[serde(rename = "type")] - ty: String, - extra_data: Option, -} +// #[derive(Debug, Deserialize)] +// pub struct CreateNodeOpts { +// // TODO: Allow submitting a string +// // id: Option, +// #[serde(rename = "type")] +// ty: String, +// extra_data: Option, +// } -#[utoipa::path( - put, - path = "/", - responses((status = 200)), -)] -pub async fn create_node( - State(state): State, - Json(opts): Json, -) -> AppResult> { - let node_info = state - .create_or_update_node( - CreateOrUpdate::Create { r#type: opts.ty }, - opts.extra_data, - ) - .await?; +// #[utoipa::path( +// put, +// path = "/", +// responses((status = 200)), +// )] +// pub async fn create_node( +// State(state): State, +// Json(opts): Json, +// ) -> AppResult> { +// let node_info = state +// .create_or_update_node( +// CreateOrUpdate::Create { r#type: opts.ty }, +// opts.extra_data, +// ) +// .await?; - Ok(Json(json!({ - "node_id": node_info.node_id.to_string(), - }))) -} +// Ok(Json(json!({ +// "node_id": node_info.node_id.to_string(), +// }))) +// } -#[derive(Deserialize)] -pub struct SearchQuery { - query: String, -} +// #[derive(Deserialize)] +// pub struct SearchQuery { +// query: String, +// } -#[utoipa::path( - get, - path = "/search", - responses((status = 200)), -)] -pub async fn search_nodes( - State(state): State, - Query(query): Query, -) -> AppResult> { - let search_result = state.search_nodes(query.query).await?; - let search_result = search_result - .into_iter() - .map(|(id, value)| value["fields"].clone()) - .collect_vec(); +// #[utoipa::path( +// get, +// path = "/search", +// responses((status = 200)), +// )] +// pub async fn search_nodes( +// State(state): State, +// Query(query): Query, +// ) -> AppResult> { +// let search_result = state.search_nodes(query.query).await?; +// let search_result = search_result +// .into_iter() +// .map(|(id, value)| value["fields"].clone()) +// .collect_vec(); - Ok(Json(json!({ - "results": search_result, - }))) -} +// Ok(Json(json!({ +// "results": search_result, +// }))) +// } -fn get_rows_for_extra_keys( - tx: &MultiTransaction, - extra_data: &ExtraData, -) -> AppResult> { - let result = tx.run_script( - " - ?[key, relation, field_name, type] := - *fqkey_to_dbkey{key, relation, field_name, type}, - is_in(key, $keys) - ", - btmap! { - "keys".to_owned() => DataValue::List( - extra_data - .keys() - .map(|s| DataValue::from(s.as_str())) - .collect::>() - ), - }, - )?; +// fn get_rows_for_extra_keys( +// tx: &MultiTransaction, +// extra_data: &ExtraData, +// ) -> AppResult> { +// let result = tx.run_script( +// " +// ?[key, relation, field_name, type] := +// *fqkey_to_dbkey{key, relation, field_name, type}, +// is_in(key, $keys) +// ", +// btmap! { +// "keys".to_owned() => DataValue::List( +// extra_data +// .keys() +// .map(|s| DataValue::from(s.as_str())) +// .collect::>() +// ), +// }, +// )?; - let s = |s: &DataValue| s.get_str().unwrap().to_owned(); +// let s = |s: &DataValue| s.get_str().unwrap().to_owned(); - Ok( - result - .rows - .into_iter() - .map(|row| (s(&row[0]), (s(&row[1]), s(&row[2]), s(&row[3])))) - .collect::>(), - ) -} +// Ok( +// result +// .rows +// .into_iter() +// .map(|row| (s(&row[0]), (s(&row[1]), s(&row[2]), s(&row[3])))) +// .collect::>(), +// ) +// }