This commit is contained in:
Michael Zhang 2024-06-21 15:43:19 -05:00
parent 98e07b56b8
commit 81d28b6740
29 changed files with 477 additions and 464 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
export DATABASE_URL=sqlite://$(pwd)/test.db

538
Cargo.lock generated
View file

@ -129,6 +129,9 @@ name = "anyhow"
version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
dependencies = [
"backtrace",
]
[[package]]
name = "arbitrary"
@ -452,19 +455,10 @@ dependencies = [
"cfg-if",
"libc",
"miniz_oxide",
"object",
"object 0.32.2",
"rustc-demangle",
]
[[package]]
name = "backtrace-ext"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "537beee3be4a18fb023b570f80e3ae28003db9167a751266b259926e25539d50"
dependencies = [
"backtrace",
]
[[package]]
name = "base64"
version = "0.21.7"
@ -776,6 +770,12 @@ version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70"
[[package]]
name = "cobs"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15"
[[package]]
name = "cocoa"
version = "0.25.0"
@ -806,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"
@ -930,6 +920,16 @@ dependencies = [
"libc",
]
[[package]]
name = "cranelift-entity"
version = "0.109.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8cfdc315e5d18997093e040a8d234bea1ac1e118a716d3e30f40d449e78207b"
dependencies = [
"serde",
"serde_derive",
]
[[package]]
name = "crc"
version = "3.2.1"
@ -954,12 +954,6 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "critical-section"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216"
[[package]]
name = "crossbeam-channel"
version = "0.5.13"
@ -1354,6 +1348,12 @@ version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7"
[[package]]
name = "embedded-io"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced"
[[package]]
name = "encoding_rs"
version = "0.8.34"
@ -2025,6 +2025,7 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
dependencies = [
"ahash",
"allocator-api2",
"serde",
]
[[package]]
@ -2340,17 +2341,6 @@ dependencies = [
"once_cell",
]
[[package]]
name = "is-terminal"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b"
dependencies = [
"hermit-abi",
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "is-wsl"
version = "0.4.0"
@ -2361,12 +2351,6 @@ dependencies = [
"once_cell",
]
[[package]]
name = "is_ci"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45"
[[package]]
name = "is_terminal_polyfill"
version = "1.70.0"
@ -2671,6 +2655,15 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
[[package]]
name = "mach2"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709"
dependencies = [
"libc",
]
[[package]]
name = "malloc_buf"
version = "0.0.6"
@ -2741,6 +2734,15 @@ version = "2.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
[[package]]
name = "memfd"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64"
dependencies = [
"rustix",
]
[[package]]
name = "memmap2"
version = "0.9.4"
@ -2759,38 +2761,6 @@ dependencies = [
"autocfg",
]
[[package]]
name = "miette"
version = "5.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e"
dependencies = [
"backtrace",
"backtrace-ext",
"is-terminal",
"miette-derive",
"once_cell",
"owo-colors",
"supports-color",
"supports-hyperlinks",
"supports-unicode",
"terminal_size",
"textwrap",
"thiserror",
"unicode-width",
]
[[package]]
name = "miette-derive"
version = "5.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.66",
]
[[package]]
name = "mime"
version = "0.3.17"
@ -2859,45 +2829,6 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2195bf6aa996a481483b29d62a7663eed3fe39600c460e323f8ff41e90bdd89b"
[[package]]
name = "musli"
version = "0.0.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c21124dd24833900879114414b877f2136f4b7b7a3b49756ecc5c36eca332bb"
dependencies = [
"musli-macros",
]
[[package]]
name = "musli-common"
version = "0.0.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "178446623aa62978aa0f894b2081bc11ea77c2119ccfe35be428ab9ddb495dfc"
dependencies = [
"musli",
]
[[package]]
name = "musli-macros"
version = "0.0.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f1ab0e4ac2721bc4fa3528a6a2640c1c30c36c820f8c85159252fbf6c2fac24"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.66",
]
[[package]]
name = "musli-storage"
version = "0.0.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2fc1f80b166f611c462e1344220e9b3a9ad37c885e43039d5d2e6887445937c"
dependencies = [
"musli",
"musli-common",
]
[[package]]
name = "ndk"
version = "0.7.0"
@ -2971,30 +2902,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "num"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"
dependencies = [
"num-bigint",
"num-complex",
"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-bigint-dig"
version = "0.8.4"
@ -3012,15 +2919,6 @@ dependencies = [
"zeroize",
]
[[package]]
name = "num-complex"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
dependencies = [
"num-traits",
]
[[package]]
name = "num-conv"
version = "0.1.0"
@ -3047,17 +2945,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"
@ -3256,15 +3143,20 @@ dependencies = [
"memchr",
]
[[package]]
name = "object"
version = "0.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434"
dependencies = [
"memchr",
]
[[package]]
name = "once_cell"
version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
dependencies = [
"critical-section",
"portable-atomic",
]
[[package]]
name = "oneshot"
@ -3327,12 +3219,6 @@ dependencies = [
"stable_deref_trait",
]
[[package]]
name = "owo-colors"
version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
[[package]]
name = "pango"
version = "0.18.3"
@ -3380,22 +3266,23 @@ dependencies = [
name = "panorama-core"
version = "0.1.0"
dependencies = [
"anyhow",
"async-imap",
"backoff",
"bimap",
"chrono",
"futures",
"itertools 0.13.0",
"miette",
"rune",
"serde",
"serde_json",
"serde_yaml",
"sqlx",
"sugars",
"tantivy",
"tokio",
"uuid",
"walkdir",
"wasmtime",
]
[[package]]
@ -3410,7 +3297,6 @@ dependencies = [
"dirs",
"futures",
"itertools 0.13.0",
"miette",
"panorama-core",
"serde",
"serde_json",
@ -3733,10 +3619,15 @@ dependencies = [
]
[[package]]
name = "portable-atomic"
version = "1.6.0"
name = "postcard"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0"
checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8"
dependencies = [
"cobs",
"embedded-io",
"serde",
]
[[package]]
name = "powerfmt"
@ -3821,6 +3712,15 @@ version = "2.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33cb294fe86a74cbcf50d4445b37da762029549ebeea341421c7c70370f86cac"
[[package]]
name = "psm"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874"
dependencies = [
"cc",
]
[[package]]
name = "publicsuffix"
version = "2.2.3"
@ -4129,78 +4029,6 @@ dependencies = [
"zeroize",
]
[[package]]
name = "rune"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37f1ad3981e4bf4d336b913b33cab141192f7ce196b6faf3f489ce454e94c55f"
dependencies = [
"anyhow",
"codespan-reporting",
"futures-core",
"futures-util",
"itoa 1.0.11",
"musli",
"musli-storage",
"num",
"once_cell",
"pin-project",
"rune-alloc",
"rune-core",
"rune-macros",
"ryu",
"serde",
"tracing",
]
[[package]]
name = "rune-alloc"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd786d0d250e5768210ab54b57841e5fc48e2c96a2b7e43104dabe47348ee221"
dependencies = [
"ahash",
"pin-project",
"rune-alloc-macros",
"serde",
]
[[package]]
name = "rune-alloc-macros"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb6a9c787416444401172f875c1361c9b78d21fecf10206e9a996693ee2d1023"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.66",
]
[[package]]
name = "rune-core"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22249f328286279daf0f991dd04c09c30c8b7fda12fbb20391e3c041ba2dad22"
dependencies = [
"byteorder",
"musli",
"rune-alloc",
"serde",
"twox-hash",
]
[[package]]
name = "rune-macros"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32d7decd5a5f44e2e351f03f4d7dc6beab0c656baefd70528bfc375c1ab49b8d"
dependencies = [
"proc-macro2",
"quote",
"rune-core",
"syn 2.0.66",
]
[[package]]
name = "rust-embed"
version = "8.4.0"
@ -4708,12 +4536,9 @@ name = "smallvec"
version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "smawk"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c"
dependencies = [
"serde",
]
[[package]]
name = "socket2"
@ -4800,6 +4625,12 @@ dependencies = [
"der",
]
[[package]]
name = "sptr"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a"
[[package]]
name = "sqlformat"
version = "0.2.4"
@ -5104,34 +4935,6 @@ version = "3.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc0db74f9ee706e039d031a560bd7d110c7022f016051b3d33eeff9583e3e67a"
[[package]]
name = "supports-color"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89"
dependencies = [
"is-terminal",
"is_ci",
]
[[package]]
name = "supports-hyperlinks"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f84231692eb0d4d41e4cdd0cabfdd2e6cd9e255e65f80c9aa7c98dd502b4233d"
dependencies = [
"is-terminal",
]
[[package]]
name = "supports-unicode"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f850c19edd184a205e883199a261ed44471c81e39bd95b1357f5febbef00e77a"
dependencies = [
"is-terminal",
]
[[package]]
name = "swift-rs"
version = "1.0.6"
@ -5739,36 +5542,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"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "textwrap"
version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7b3e525a49ec206798b40326a44121291b530c963cfb01018f63e135bac543d"
dependencies = [
"smawk",
"unicode-linebreak",
"unicode-width",
]
[[package]]
name = "thin-slice"
version = "0.1.1"
@ -6108,16 +5881,6 @@ 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",
"static_assertions",
]
[[package]]
name = "typenum"
version = "1.17.0"
@ -6197,12 +5960,6 @@ version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-linebreak"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f"
[[package]]
name = "unicode-normalization"
version = "0.1.23"
@ -6224,12 +5981,6 @@ version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
[[package]]
name = "unicode-width"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6"
[[package]]
name = "unicode_categories"
version = "0.1.1"
@ -6520,6 +6271,129 @@ dependencies = [
"web-sys",
]
[[package]]
name = "wasmparser"
version = "0.209.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07035cc9a9b41e62d3bb3a3815a66ab87c993c06fe1cf6b2a3f2a18499d937db"
dependencies = [
"ahash",
"bitflags 2.5.0",
"hashbrown 0.14.5",
"indexmap 2.2.6",
"semver",
"serde",
]
[[package]]
name = "wasmtime"
version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "786d8b5e7a4d54917c5ebe555b9667337e5f93383f49bddaaeec2eba68093b45"
dependencies = [
"anyhow",
"bumpalo",
"cc",
"cfg-if",
"hashbrown 0.14.5",
"indexmap 2.2.6",
"libc",
"libm",
"log",
"mach2",
"memfd",
"memoffset",
"object 0.36.0",
"once_cell",
"paste",
"postcard",
"psm",
"rustix",
"serde",
"serde_derive",
"smallvec",
"sptr",
"target-lexicon",
"wasmparser",
"wasmtime-asm-macros",
"wasmtime-environ",
"wasmtime-jit-icache-coherence",
"wasmtime-slab",
"wasmtime-versioned-export-macros",
"windows-sys 0.52.0",
]
[[package]]
name = "wasmtime-asm-macros"
version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d697d99c341d4a9ffb72f3af7a02124d233eeb59aee010f36d88e97cca553d5e"
dependencies = [
"cfg-if",
]
[[package]]
name = "wasmtime-environ"
version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f444e900e848b884d8a8a2949b6f5b92af642a3e663ff8fbe78731143a55be61"
dependencies = [
"anyhow",
"cranelift-entity",
"gimli",
"indexmap 2.2.6",
"log",
"object 0.36.0",
"postcard",
"serde",
"serde_derive",
"target-lexicon",
"wasmparser",
"wasmtime-types",
]
[[package]]
name = "wasmtime-jit-icache-coherence"
version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5afe2f0499542f9a4bcfa1b55bfdda803b6ade4e7c93c6b99e0f39dba44b0a91"
dependencies = [
"anyhow",
"cfg-if",
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "wasmtime-slab"
version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a7de1f2bec5bbb35d532e61c85c049dc84ae671df60492f90b954ecf21169e7"
[[package]]
name = "wasmtime-types"
version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "412463e9000e14cf6856be48628d2213c20c153e29ffc22b036980c892ea6964"
dependencies = [
"cranelift-entity",
"serde",
"serde_derive",
"smallvec",
"wasmparser",
]
[[package]]
name = "wasmtime-versioned-export-macros"
version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de5a9bc4f44ceeb168e9e8e3be4e0b4beb9095b468479663a9e24c667e36826f"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.66",
]
[[package]]
name = "wayland-sys"
version = "0.31.2"

View file

@ -0,0 +1,22 @@
{
"targets": {
"debug": {
"outFile": "build/debug.wasm",
"textFile": "build/debug.wat",
"sourceMap": true,
"debug": true
},
"release": {
"outFile": "build/release.wasm",
"textFile": "build/release.wat",
"sourceMap": true,
"optimizeLevel": 3,
"shrinkLevel": 0,
"converge": false,
"noAssert": false
}
},
"options": {
"bindings": "esm"
}
}

View file

@ -0,0 +1,5 @@
// The entry file of your WebAssembly module.
export function add(a: i32, b: i32): i32 {
return a + b;
}

View file

@ -0,0 +1,6 @@
{
"extends": "../../../node_modules/.pnpm/assemblyscript@0.27.27/node_modules/assemblyscript/std/assembly.json",
"include": [
"./**/*.ts"
]
}

2
apps/journal/build/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

10
apps/journal/index.html Normal file
View file

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script type="module">
import { add } from "./build/release.js";
document.body.innerText = add(1, 2);
</script>
</head>
<body></body>
</html>

View file

@ -1,4 +1,6 @@
name: journal
version: 0.1.0
panorama_version: 0.1.0
description: Note taking app
description: Note taking app
installer_path: build/release.wasm

26
apps/journal/package.json Normal file
View file

@ -0,0 +1,26 @@
{
"name": "journal",
"version": "0.1.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "node tests",
"asbuild:debug": "asc assembly/index.ts --target debug",
"asbuild:release": "asc assembly/index.ts --target release",
"asbuild": "npm run asbuild:debug && npm run asbuild:release",
"start": "npx serve ."
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"assemblyscript": "^0.27.27"
},
"type": "module",
"exports": {
".": {
"import": "./build/release.js",
"types": "./build/release.d.ts"
}
}
}

View file

@ -0,0 +1,4 @@
import assert from "assert";
import { add } from "../build/debug.js";
assert.strictEqual(add(1, 2), 3);
console.log("ok");

View file

@ -4,21 +4,22 @@ version = "0.1.0"
edition = "2021"
[dependencies]
anyhow = { version = "1.0.86", features = ["backtrace"] }
backoff = { version = "0.4.0", features = ["tokio"] }
bimap = "0.6.3"
chrono = { version = "0.4.38", features = ["serde"] }
futures = "0.3.30"
itertools = "0.13.0"
miette = { version = "5.5.0", features = ["fancy", "backtrace"] }
rune = "0.13.2"
serde = { version = "1.0.203", features = ["derive"] }
serde_json = "1.0.117"
serde_yaml = "0.9.34"
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"] }
uuid = { version = "1.8.0", features = ["v7"] }
walkdir = "2.5.0"
wasmtime = { version = "22.0.0", default-features = false, features = ["runtime"] }
[dependencies.async-imap]
version = "0.9.7"

View file

@ -37,4 +37,4 @@ CREATE TABLE key_mapping (
app_table_name TEXT NOT NULL,
app_table_field TEXT NOT NULL,
is_fts_enabled BOOLEAN NOT NULL DEFAULT FALSE
);
);

View file

@ -17,7 +17,7 @@ use std::fmt;
pub use crate::state::AppState;
use miette::{bail, IntoDiagnostic, Result};
use anyhow::{bail, Result};
use serde_json::Value;
use uuid::Uuid;
@ -31,7 +31,7 @@ impl fmt::Display for NodeId {
}
pub fn ensure_ok(s: &str) -> Result<()> {
let status: Value = serde_json::from_str(&s).into_diagnostic()?;
let status: Value = serde_json::from_str(&s)?;
let status = status.as_object().unwrap();
let ok = status.get("ok").unwrap().as_bool().unwrap_or(false);
if !ok {

View file

@ -3,11 +3,11 @@ use std::{
time::Duration,
};
use anyhow::{Context as _, Result};
use async_imap::Session;
use backoff::{exponential::ExponentialBackoff, SystemClock};
use futures::TryStreamExt;
use itertools::Itertools;
use miette::{Context, IntoDiagnostic, Result};
use tokio::{net::TcpStream, time::sleep};
use uuid::Uuid;
@ -60,15 +60,13 @@ impl MailWorker {
let stream =
TcpStream::connect((config.imap_hostname.as_str(), config.imap_port))
.await
.into_diagnostic()?;
.await?;
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()?;
.map_err(|(err, _)| err)?;
let all_mailbox_ids = self
.fetch_and_store_all_mailboxes(config.node_id.to_string(), &mut session)
@ -98,11 +96,9 @@ impl MailWorker {
// println!("Session: {:?}", session);
let mailboxes = session
.list(None, Some("*"))
.await
.into_diagnostic()?
.await?
.try_collect::<Vec<_>>()
.await
.into_diagnostic()?;
.await?;
let mut all_mailboxes = HashMap::new();
@ -178,7 +174,6 @@ impl MailWorker {
let all_uids = session
.uid_search("ALL")
.await
.into_diagnostic()
.context("Could not fetch all UIDs")?;
println!("All UIDs ({}): {:?}", all_uids.len(), all_uids);

View file

@ -1,9 +1,6 @@
use miette::{IntoDiagnostic, Result};
use sqlx::migrate::Migrator;
use serde_json::Value;
use crate::ensure_ok;
pub static MIGRATOR: Migrator = sqlx::migrate!();

View file

@ -1,31 +1,38 @@
use std::{
collections::HashMap,
fs::{self, File},
io::Read,
path::{Path, PathBuf},
sync::Arc,
};
use miette::{IntoDiagnostic, Result};
use rune::{
prepare,
termcolor::{ColorChoice, StandardStream},
Context, Diagnostics, Hash, Module, Source, Sources, Vm,
};
use anyhow::{Context as _, Result};
use serde_yaml::Value;
use wasmtime::Module;
use crate::AppState;
pub type AllAppData = HashMap<String, AppData>;
impl AppState {
pub async fn install_apps_from_search_paths(&self) -> Result<()> {
let search_paths =
vec![PathBuf::from("/Users/michael/Projects/panorama/apps")];
pub async fn install_apps_from_search_paths(&self) -> Result<AllAppData> {
let search_paths = vec![
PathBuf::from("/Users/michael/Projects/panorama/apps"),
PathBuf::from("/home/michael/Projects/panorama/apps"),
];
let mut found = Vec::new();
for path in search_paths {
let read_dir = fs::read_dir(path).into_diagnostic()?;
if !path.exists() {
continue;
}
let read_dir = fs::read_dir(&path)
.with_context(|| format!("could not read {}", path.display()))?;
for dir_entry in read_dir {
let dir_entry = dir_entry.into_diagnostic()?;
let dir_entry = dir_entry?;
let path = dir_entry.path();
let manifest_path = path.join("manifest.yml");
@ -35,58 +42,88 @@ impl AppState {
}
}
let all_app_data = HashMap::new();
for path in found {
self.install_app_from_path(path).await;
let app_data = self.install_app_from_path(path).await;
}
Ok(())
Ok(all_app_data)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AppManifest {
name: String,
version: Option<String>,
panorama_version: Option<String>,
description: Option<String>,
installer_path: Option<String>,
}
#[derive(Debug)]
pub struct AppData {
name: String,
}
impl AppState {
async fn install_app_from_path(&self, path: impl AsRef<Path>) -> Result<()> {
let app_path = path.as_ref();
let manifest_path = app_path.join("manifest.yml");
let manifest: AppManifest = {
let file = File::open(manifest_path)?;
serde_yaml::from_reader(file)?
};
println!("manifest: {:?}", manifest);
let register_path = app_path.join("register.rn");
let register_script = {
let mut file = File::open(register_path).into_diagnostic()?;
let mut file = File::open(register_path)?;
let mut string = String::new();
file.read_to_string(&mut string).into_diagnostic()?;
file.read_to_string(&mut string)?;
string
};
let mut sources = Sources::new();
sources
.insert(Source::new("register.rn", register_script).into_diagnostic()?)
.into_diagnostic()?;
{
use wasmtime::{Config, Engine};
let mut diagnostics = Diagnostics::new();
let register_script_unit = prepare(&mut sources)
.with_diagnostics(&mut diagnostics)
.build();
if !diagnostics.is_empty() {
let mut writer = StandardStream::stderr(ColorChoice::Always);
diagnostics.emit(&mut writer, &sources).into_diagnostic()?;
let config = Config::new();
let engine = Engine::new(&config)?;
}
let register_script_unit =
Arc::new(register_script_unit.into_diagnostic()?);
let module = Module::new();
// let mut ctx = Context::new();
let mut ctx = Context::with_default_modules().into_diagnostic()?;
ctx.install(module).into_diagnostic()?;
// let mut sources = Sources::new();
// sources
// .insert(Source::new("register.rn", register_script).into_diagnostic()?)
// .into_diagnostic()?;
let rt_ctx = ctx.runtime().into_diagnostic()?;
let ctx_arc = Arc::new(rt_ctx);
let mut vm = Vm::new(ctx_arc, register_script_unit);
// let mut diagnostics = Diagnostics::new();
// let register_script_unit = prepare(&mut sources)
// .with_diagnostics(&mut diagnostics)
// .build();
// if !diagnostics.is_empty() {
// let mut writer = StandardStream::stderr(ColorChoice::Always);
// diagnostics.emit(&mut writer, &sources).into_diagnostic()?;
// }
// let register_script_unit =
// Arc::new(register_script_unit.into_diagnostic()?);
let main = Hash::type_hash(["main"]);
let result = vm
.execute(main, ())
.into_diagnostic()?
.complete()
.into_result()
.into_diagnostic()?;
println!("Executed. {result:?}");
// let module = Module::new();
// // let mut ctx = Context::new();
// let mut ctx = Context::with_default_modules().into_diagnostic()?;
// ctx.install(module).into_diagnostic()?;
// let rt_ctx = ctx.runtime().into_diagnostic()?;
// let ctx_arc = Arc::new(rt_ctx);
// let mut vm = Vm::new(ctx_arc, register_script_unit);
// let main = Hash::type_hash(["main"]);
// let result = vm
// .execute(main, ())
// .into_diagnostic()?
// .complete()
// .into_result()
// .into_diagnostic()?;
// println!("Executed. {result:?}");
Ok(())
}

View file

@ -1,7 +1,7 @@
use std::collections::HashMap;
use anyhow::Result;
use cozo::ScriptMutability;
use miette::Result;
use serde_json::Value;
use crate::AppState;

View file

@ -1,8 +1,7 @@
use std::str::FromStr;
use anyhow::Result;
use chrono::Local;
// use cozo::ScriptMutability;
use miette::{IntoDiagnostic, Result};
use uuid::Uuid;
use crate::{AppState, NodeId};

View file

@ -1,8 +1,8 @@
use std::{collections::HashMap, str::FromStr, time::Duration};
use anyhow::Result;
use cozo::{DataValue, JsonData, ScriptMutability};
use futures::TryStreamExt;
use miette::{IntoDiagnostic, Result};
use tokio::{net::TcpStream, time::sleep};
use uuid::Uuid;

View file

@ -7,14 +7,14 @@ pub mod node;
pub mod node_raw;
// pub mod utils;
use std::{collections::HashMap, fs, path::Path};
use std::{fs, path::Path};
use anyhow::{Context, Result};
use bimap::BiMap;
use miette::{Context, IntoDiagnostic, Result};
use sqlx::{
pool::PoolConnection,
sqlite::{SqliteConnectOptions, SqliteJournalMode, SqlitePoolOptions},
Sqlite, SqliteConnection, SqlitePool,
Sqlite, SqlitePool,
};
use tantivy::{
directory::MmapDirectory,
@ -24,7 +24,7 @@ use tantivy::{
use crate::{
// mail::MailWorker,
migrations::{self, MIGRATOR},
migrations::MIGRATOR,
};
pub fn tantivy_schema() -> (Schema, BiMap<String, Field>) {
@ -52,7 +52,6 @@ impl AppState {
pub async fn new(panorama_dir: impl AsRef<Path>) -> Result<Self> {
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());
@ -60,12 +59,9 @@ impl AppState {
let (tantivy_index, tantivy_field_map) = {
let (schema, field_map) = tantivy_schema();
let tantivy_path = panorama_dir.join("tantivy-index");
fs::create_dir_all(&tantivy_path).into_diagnostic()?;
let dir = MmapDirectory::open(&tantivy_path).into_diagnostic()?;
let index = Index::builder()
.schema(schema)
.open_or_create(dir)
.into_diagnostic()?;
fs::create_dir_all(&tantivy_path)?;
let dir = MmapDirectory::open(&tantivy_path)?;
let index = Index::builder().schema(schema).open_or_create(dir)?;
(index, field_map)
};
@ -77,7 +73,6 @@ impl AppState {
let db = SqlitePoolOptions::new()
.connect_with(sqlite_connect_options)
.await
.into_diagnostic()
.context("Could not connect to SQLite database")?;
let state = AppState {
@ -91,7 +86,7 @@ impl AppState {
}
pub async fn conn(&self) -> Result<PoolConnection<Sqlite>> {
self.db.acquire().await.into_diagnostic()
self.db.acquire().await.map_err(|err| err.into())
}
async fn init(&self) -> Result<()> {
@ -99,7 +94,6 @@ impl AppState {
MIGRATOR
.run(&self.db)
.await
.into_diagnostic()
.context("Could not migrate database")?;
// let state = self.clone();

View file

@ -1,21 +1,10 @@
use std::{
collections::{BTreeMap, HashMap},
str::FromStr,
};
use std::collections::{BTreeMap, HashMap};
use chrono::{DateTime, NaiveDateTime, TimeZone, Utc};
use anyhow::Result;
use chrono::{DateTime, Utc};
use itertools::Itertools;
use miette::{bail, Context, Error, IntoDiagnostic, Report, Result};
use serde_json::Value;
use sqlx::{
query::Query, sqlite::SqliteArguments, Acquire, Connection, Executor,
FromRow, QueryBuilder, Sqlite,
};
use tantivy::{
schema::{OwnedValue, Value as _},
time::Date,
Term,
};
use sqlx::{Connection, Executor, FromRow, QueryBuilder, Sqlite};
use uuid::Uuid;
use crate::{state::node_raw::FieldMappingRow, AppState, NodeId};
@ -99,8 +88,7 @@ impl AppState {
// })
})
})
.await
.into_diagnostic()?;
.await?;
todo!()
// Ok(())
@ -159,9 +147,13 @@ impl AppState {
// all_relation_constraints.push(format!("{table_gen_name}[{keys}],"))
}
query.push("SELECT");
if selected_fields.is_empty() {
return Ok(HashMap::new());
}
query.push("SELECT ");
query.push(selected_fields.join(", "));
query.push("FROM");
query.push(" FROM ");
println!("Query: {:?}", query.sql());
// let all_relation_constraints = all_relation_constraints.join("\n");
@ -181,7 +173,7 @@ impl AppState {
// "
// );
let rows = query.build().fetch_all(x).await.into_diagnostic();
let rows = query.build().fetch_all(x).await;
todo!()
}
@ -257,7 +249,7 @@ impl AppState {
})
})
.await
.into_diagnostic()
.map_err(|err| err.into())
}
async fn create_node_raw<'e, 'c: 'e, X>(
@ -327,6 +319,7 @@ impl AppState {
// Update database
let mut node_has_keys = Vec::new();
println!("Fields by table: {:?}", fields_by_table);
for ((app_id, app_table_name), fields) in fields_by_table.iter() {
for field_info in fields {
node_has_keys.push(&field_info.full_key);
@ -394,13 +387,15 @@ impl AppState {
// }
}
let mut query =
QueryBuilder::new("INSERT INTO node_has_key (node_id, full_key) VALUES ");
query.push_values(node_has_keys, |mut b, key| {
b.push_bind(node_id).push_bind(key);
});
println!("Query: {:?}", query.sql());
query.build().execute(x).await?;
if !node_has_keys.is_empty() {
let mut query =
QueryBuilder::new("INSERT INTO node_has_key (node_id, full_key) ");
query.push_values(node_has_keys, |mut b, key| {
b.push_bind(node_id).push_bind(key);
});
println!("Query: {:?}", query.sql());
query.build().execute(x).await?;
}
Ok(())
}

View file

@ -2,7 +2,7 @@ use sqlx::{Executor, FromRow, Sqlite};
use crate::AppState;
#[derive(FromRow)]
#[derive(Debug, FromRow)]
pub struct FieldMappingRow {
pub full_key: String,
pub app_id: i64,

View file

@ -1,21 +1,24 @@
use cozo::DbInstance;
use itertools::Itertools;
use miette::Result;
use anyhow::Result;
use sqlx::SqlitePool;
use tantivy::Index;
use crate::{migrations::run_migrations, state::tantivy_schema, AppState};
use crate::{
migrations::MIGRATOR,
state::{node::CreateOrUpdate, tantivy_schema},
AppState,
};
pub async fn test_state() -> Result<AppState> {
let db = DbInstance::new("mem", "", "")?;
let db = SqlitePool::connect(":memory:").await?;
let (schema, tantivy_field_map) = tantivy_schema();
let tantivy_index = Index::create_in_ram(schema);
MIGRATOR.run(&db).await?;
let state = AppState {
db,
tantivy_index,
tantivy_field_map,
};
run_migrations(&state.db).await?;
Ok(state)
}
@ -26,8 +29,9 @@ pub async fn test_create_node() -> Result<()> {
let node_info = state
.create_or_update_node(
None,
"panorama/journal/page",
CreateOrUpdate::Create {
r#type: "panorama/journal/page".to_string(),
},
Some(btmap! {
"panorama/journal/page/content".to_owned() => json!("helloge"),
}),
@ -49,19 +53,33 @@ pub async fn test_full_text_search() -> Result<()> {
let node_info = state
.create_or_update_node(
"panorama/journal/page",
CreateOrUpdate::Create {
r#type: "panorama/journal/page".to_string(),
},
Some(btmap! {
"panorama/journal/page/content".to_owned() => json!("Hello, world!"),
}),
)
.await?;
let results = state.search_nodes("world").await?;
todo!();
// let results = state.search_nodes("world").await?;
assert!(results
.into_iter()
.map(|entry| entry.0)
.contains(&node_info.node_id));
// assert!(results
// .into_iter()
// .map(|entry| entry.0)
// .contains(&node_info.node_id));
Ok(())
}
#[tokio::test]
pub async fn test_install_apps() -> Result<()> {
let state = test_state().await?;
state.install_apps_from_search_paths().await?;
panic!();
Ok(())
}

View file

@ -14,7 +14,6 @@ csv = "1.3.0"
dirs = "5.0.1"
futures = "0.3.30"
itertools = "0.13.0"
miette = { version = "5.5.0", features = ["fancy", "backtrace"] }
panorama-core = { path = "../panorama-core" }
serde = { version = "1.0.202", features = ["derive"] }
serde_json = "1.0.117"

View file

@ -7,7 +7,7 @@ pub type AppResult<T, E = AppError> = std::result::Result<T, E>;
// Make our own error that wraps `anyhow::Error`.
#[derive(Debug)]
pub struct AppError(miette::Report);
pub struct AppError(anyhow::Error);
// Tell axum how to convert `AppError` into a response.
impl IntoResponse for AppError {
@ -26,7 +26,7 @@ impl IntoResponse for AppError {
// `Result<_, AppError>`. That way you don't need to do that manually.
impl<E> From<E> for AppError
where
E: Into<miette::Report>,
E: Into<anyhow::Error>,
{
fn from(err: E) -> Self {
Self(err.into())

View file

@ -14,8 +14,8 @@ mod node;
use std::fs;
use anyhow::Result;
use axum::{http::Method, routing::get, Router};
use miette::{IntoDiagnostic, Result};
use panorama_core::AppState;
use tokio::net::TcpListener;
use tower::ServiceBuilder;
@ -39,7 +39,7 @@ pub async fn run() -> Result<()> {
let data_dir = dirs::data_dir().unwrap();
let panorama_dir = data_dir.join("panorama");
fs::create_dir_all(&panorama_dir).into_diagnostic()?;
fs::create_dir_all(&panorama_dir)?;
let state = AppState::new(&panorama_dir).await?;
@ -64,9 +64,9 @@ pub async fn run() -> Result<()> {
.layer(ServiceBuilder::new().layer(trace_layer))
.with_state(state.clone());
let listener = TcpListener::bind("0.0.0.0:5195").await.into_diagnostic()?;
let listener = TcpListener::bind("0.0.0.0:5195").await?;
println!("Listening... {:?}", listener);
axum::serve(listener, app).await.into_diagnostic()?;
axum::serve(listener, app).await?;
Ok(())
}

View file

@ -1,4 +1,4 @@
use miette::Result;
use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {

View file

@ -11,7 +11,6 @@ use axum::{
};
use chrono::{DateTime, Utc};
use itertools::Itertools;
use miette::IntoDiagnostic;
use panorama_core::{
// state::node::{CreateOrUpdate, ExtraData},
NodeId,

View file

@ -142,6 +142,12 @@ importers:
specifier: ^5.0.0
version: 5.2.11(sass@1.77.2)
apps/journal:
devDependencies:
assemblyscript:
specifier: ^0.27.27
version: 0.27.27
packages:
'@ampproject/remapping@2.3.0':
@ -893,6 +899,11 @@ packages:
resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==}
engines: {node: '>= 8'}
assemblyscript@0.27.27:
resolution: {integrity: sha512-z4ijXsjjk3uespEeCWpO1K2GQySc6bn+LL5dL0tsC2VXNYKFnKDmAh3wefcKazxXHFVhYlxqNfyv96ajaQyINQ==}
engines: {node: '>=16', npm: '>=7'}
hasBin: true
babel-plugin-macros@3.1.0:
resolution: {integrity: sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==}
engines: {node: '>=10', npm: '>=6'}
@ -907,6 +918,10 @@ packages:
resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==}
engines: {node: '>=8'}
binaryen@116.0.0-nightly.20240114:
resolution: {integrity: sha512-0GZrojJnuhoe+hiwji7QFaL3tBlJoA+KFUN7ouYSDGZLSo9CKM8swQX8n/UcbR0d1VuZKU+nhogNzv423JEu5A==}
hasBin: true
boolbase@1.0.0:
resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==}
@ -1303,6 +1318,9 @@ packages:
lodash@4.17.21:
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
long@5.2.3:
resolution: {integrity: sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==}
longest-streak@3.1.0:
resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==}
@ -2585,6 +2603,11 @@ snapshots:
normalize-path: 3.0.0
picomatch: 2.3.1
assemblyscript@0.27.27:
dependencies:
binaryen: 116.0.0-nightly.20240114
long: 5.2.3
babel-plugin-macros@3.1.0:
dependencies:
'@babel/runtime': 7.24.6
@ -2597,6 +2620,8 @@ snapshots:
binary-extensions@2.3.0: {}
binaryen@116.0.0-nightly.20240114: {}
boolbase@1.0.0: {}
braces@3.0.3:
@ -3081,6 +3106,8 @@ snapshots:
lodash@4.17.21: {}
long@5.2.3: {}
longest-streak@3.1.0: {}
loose-envify@1.4.0: