Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

refactor: adapt latest octobase

linonetwo44d9fbf264c1
diff --git a/client-app/src-tauri/Cargo.lock b/client-app/src-tauri/Cargo.lock
index 51ddc2a1d0..cc722cb571 100644
--- a/client-app/src-tauri/Cargo.lock
+++ b/client-app/src-tauri/Cargo.lock
@@ -7,6 +7,7 @@ name = "AFFiNE"
version = "0.0.0"
dependencies = [
"bytes",
+ "cloud-database",
"dotenvy",
"futures",
"ipc_types",
@@ -40,6 +41,14 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+[[package]]
+name = "affine-cloud-migration"
+version = "0.1.0"
+dependencies = [
+ "sea-orm-migration",
+ "tokio",
+]
+
[[package]]
name = "ahash"
version = "0.7.6"
@@ -60,6 +69,12 @@ dependencies = [
"memchr",
]
+[[package]]
+name = "aliasable"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd"
+
[[package]]
name = "alloc-no-stdlib"
version = "2.0.4"
@@ -96,6 +111,33 @@ version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "983cd8b9d4b02a6dc6ffa557262eb5858a27a0038ffffe21a0f133eaa819a164"
+[[package]]
+name = "arrayvec"
+version = "0.7.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
+
+[[package]]
+name = "async-stream"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dad5c83079eae9969be7fadefe640a1c566901f05ff91ab221de4b6f68d9507e"
+dependencies = [
+ "async-stream-impl",
+ "futures-core",
+]
+
+[[package]]
+name = "async-stream-impl"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
[[package]]
name = "async-trait"
version = "0.1.60"
@@ -156,12 +198,36 @@ dependencies = [
"url",
]
+[[package]]
+name = "atty"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
+dependencies = [
+ "hermit-abi",
+ "libc",
+ "winapi",
+]
+
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
+[[package]]
+name = "bae"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "33b8de67cc41132507eeece2584804efcb15f85ba516e34c944b7667f480397a"
+dependencies = [
+ "heck 0.3.3",
+ "proc-macro-error",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
[[package]]
name = "base64"
version = "0.13.1"
@@ -170,9 +236,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
[[package]]
name = "base64"
-version = "0.20.0"
+version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5"
+checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a"
[[package]]
name = "bitflags"
@@ -204,6 +270,51 @@ dependencies = [
"generic-array",
]
+[[package]]
+name = "borsh"
+version = "0.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa"
+dependencies = [
+ "borsh-derive",
+ "hashbrown 0.11.2",
+]
+
+[[package]]
+name = "borsh-derive"
+version = "0.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775"
+dependencies = [
+ "borsh-derive-internal",
+ "borsh-schema-derive-internal",
+ "proc-macro-crate 0.1.5",
+ "proc-macro2",
+ "syn",
+]
+
+[[package]]
+name = "borsh-derive-internal"
+version = "0.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "borsh-schema-derive-internal"
+version = "0.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
[[package]]
name = "brotli"
version = "3.3.4"
@@ -240,6 +351,27 @@ version = "3.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"
+[[package]]
+name = "bytecheck"
+version = "0.6.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d11cac2c12b5adc6570dad2ee1b87eff4955dac476fe12d81e5fdd352e52406f"
+dependencies = [
+ "bytecheck_derive",
+ "ptr_meta",
+]
+
+[[package]]
+name = "bytecheck_derive"
+version = "0.6.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "13e576ebe98e605500b3c8041bb888e966653577172df6dd97398714eb30b9bf"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
[[package]]
name = "bytemuck"
version = "1.12.3"
@@ -378,6 +510,73 @@ dependencies = [
"winapi",
]
+[[package]]
+name = "clap"
+version = "3.2.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5"
+dependencies = [
+ "atty",
+ "bitflags",
+ "clap_derive",
+ "clap_lex",
+ "indexmap",
+ "once_cell",
+ "strsim",
+ "termcolor",
+ "textwrap",
+]
+
+[[package]]
+name = "clap_derive"
+version = "3.2.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"
+dependencies = [
+ "heck 0.4.0",
+ "proc-macro-error",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "clap_lex"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
+dependencies = [
+ "os_str_bytes",
+]
+
+[[package]]
+name = "cloud-database"
+version = "0.1.0"
+dependencies = [
+ "affine-cloud-migration",
+ "anyhow",
+ "async-trait",
+ "base64 0.21.0",
+ "bytes",
+ "chrono",
+ "futures",
+ "jwst",
+ "jwst-logger",
+ "path-ext",
+ "schemars",
+ "sea-orm",
+ "sea-orm-migration",
+ "serde",
+ "serde_json",
+ "serde_repr",
+ "sha2",
+ "sqlx",
+ "tokio",
+ "tokio-util",
+ "uuid 1.2.2",
+ "yrs",
+]
+
[[package]]
name = "cocoa"
version = "0.24.1"
@@ -738,16 +937,6 @@ checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f"
dependencies = [
"block-buffer",
"crypto-common",
- "subtle",
-]
-
-[[package]]
-name = "dirs"
-version = "4.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
-dependencies = [
- "dirs-sys",
]
[[package]]
@@ -760,17 +949,6 @@ dependencies = [
"dirs-sys-next",
]
-[[package]]
-name = "dirs-sys"
-version = "0.3.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
-dependencies = [
- "libc",
- "redox_users",
- "winapi",
-]
-
[[package]]
name = "dirs-sys-next"
version = "0.1.2"
@@ -1274,7 +1452,7 @@ checksum = "25a68131a662b04931e71891fb14aaf65ee4b44d08e8abc10f49e77418c86c64"
dependencies = [
"anyhow",
"heck 0.4.0",
- "proc-macro-crate",
+ "proc-macro-crate 1.2.1",
"proc-macro-error",
"proc-macro2",
"quote",
@@ -1369,13 +1547,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24f518afe90c23fba585b2d7697856f9e6a7bbc62f65588035e66f6afb01a2e9"
dependencies = [
"anyhow",
- "proc-macro-crate",
+ "proc-macro-crate 1.2.1",
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
]
+[[package]]
+name = "hashbrown"
+version = "0.11.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
+dependencies = [
+ "ahash",
+]
+
[[package]]
name = "hashbrown"
version = "0.12.3"
@@ -1391,7 +1578,7 @@ version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa"
dependencies = [
- "hashbrown",
+ "hashbrown 0.12.3",
]
[[package]]
@@ -1427,24 +1614,6 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
-[[package]]
-name = "hkdf"
-version = "0.12.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437"
-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 = "html5ever"
version = "0.25.2"
@@ -1570,7 +1739,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399"
dependencies = [
"autocfg",
- "hashbrown",
+ "hashbrown 0.12.3",
"serde",
]
@@ -1599,6 +1768,7 @@ dependencies = [
name = "ipc_types"
version = "0.1.0"
dependencies = [
+ "cloud-database",
"jwst-storage",
"project-root",
"schemars",
@@ -1658,7 +1828,7 @@ checksum = "37228e06c75842d1097432d94d02f37fe3ebfca9791c2e8fef6e9db17ed128c1"
dependencies = [
"cedarwood",
"fxhash",
- "hashbrown",
+ "hashbrown 0.12.3",
"lazy_static",
"phf 0.11.1",
"phf_codegen 0.11.1",
@@ -1726,6 +1896,22 @@ dependencies = [
"yrs",
]
+[[package]]
+name = "jwst-blob-migration"
+version = "0.1.0"
+dependencies = [
+ "sea-orm-migration",
+ "tokio",
+]
+
+[[package]]
+name = "jwst-doc-migration"
+version = "0.1.0"
+dependencies = [
+ "sea-orm-migration",
+ "tokio",
+]
+
[[package]]
name = "jwst-logger"
version = "0.1.0"
@@ -1744,22 +1930,20 @@ version = "0.1.0"
dependencies = [
"anyhow",
"async-trait",
- "base64 0.20.0",
+ "base64 0.21.0",
"bytes",
"chrono",
"futures",
"jwst",
+ "jwst-blob-migration",
+ "jwst-doc-migration",
"jwst-logger",
"path-ext",
- "schemars",
- "serde",
- "serde_json",
- "serde_repr",
+ "sea-orm",
+ "sea-orm-migration",
"sha2",
- "sqlx",
"tokio",
"tokio-util",
- "uuid 1.2.2",
"yrs",
]
@@ -1883,7 +2067,7 @@ version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e999beba7b6e8345721bd280141ed958096a2e4abdf74f67ff4ce49b4b54e47a"
dependencies = [
- "hashbrown",
+ "hashbrown 0.12.3",
]
[[package]]
@@ -1949,15 +2133,6 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
-[[package]]
-name = "md-5"
-version = "0.10.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca"
-dependencies = [
- "digest",
-]
-
[[package]]
name = "measure_time"
version = "0.8.2"
@@ -2126,6 +2301,17 @@ dependencies = [
"winapi",
]
+[[package]]
+name = "num-bigint"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f"
+dependencies = [
+ "autocfg",
+ "num-integer",
+ "num-traits",
+]
+
[[package]]
name = "num-integer"
version = "0.1.45"
@@ -2181,7 +2367,7 @@ version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce"
dependencies = [
- "proc-macro-crate",
+ "proc-macro-crate 1.2.1",
"proc-macro2",
"quote",
"syn",
@@ -2317,6 +2503,35 @@ dependencies = [
"windows-sys 0.42.0",
]
+[[package]]
+name = "os_str_bytes"
+version = "6.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
+
+[[package]]
+name = "ouroboros"
+version = "0.15.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dfbb50b356159620db6ac971c6d5c9ab788c9cc38a6f49619fca2a27acb062ca"
+dependencies = [
+ "aliasable",
+ "ouroboros_macro",
+]
+
+[[package]]
+name = "ouroboros_macro"
+version = "0.15.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4a0d9d1a6191c4f391f87219d1ea42b23f09ee84d64763cd05ee6ea88d9f384d"
+dependencies = [
+ "Inflector",
+ "proc-macro-error",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
[[package]]
name = "overload"
version = "0.1.1"
@@ -2654,6 +2869,15 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
+[[package]]
+name = "proc-macro-crate"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785"
+dependencies = [
+ "toml",
+]
+
[[package]]
name = "proc-macro-crate"
version = "1.2.1"
@@ -2710,6 +2934,26 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bccbff07d5ed689c4087d20d7307a52ab6141edeedf487c3876a55b86cf63df"
+[[package]]
+name = "ptr_meta"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1"
+dependencies = [
+ "ptr_meta_derive",
+]
+
+[[package]]
+name = "ptr_meta_derive"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
[[package]]
name = "quick-xml"
version = "0.23.1"
@@ -2895,6 +3139,15 @@ dependencies = [
"winapi",
]
+[[package]]
+name = "rend"
+version = "0.3.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "79af64b4b6362ffba04eef3a4e10829718a4896dac19daa741851c86781edf95"
+dependencies = [
+ "bytecheck",
+]
+
[[package]]
name = "rfd"
version = "0.10.0"
@@ -2934,6 +3187,31 @@ dependencies = [
"winapi",
]
+[[package]]
+name = "rkyv"
+version = "0.7.39"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cec2b3485b07d96ddfd3134767b8a447b45ea4eb91448d0a35180ec0ffd5ed15"
+dependencies = [
+ "bytecheck",
+ "hashbrown 0.12.3",
+ "ptr_meta",
+ "rend",
+ "rkyv_derive",
+ "seahash",
+]
+
+[[package]]
+name = "rkyv_derive"
+version = "0.7.39"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6eaedadc88b53e36dd32d940ed21ae4d850d5916f2581526921f553a72ac34c4"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
[[package]]
name = "rust-stemmers"
version = "1.2.0"
@@ -2944,6 +3222,24 @@ dependencies = [
"serde_derive",
]
+[[package]]
+name = "rust_decimal"
+version = "1.28.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7fe32e8c89834541077a5c5bbe5691aa69324361e27e6aeb3552a737db4a70c8"
+dependencies = [
+ "arrayvec",
+ "borsh",
+ "bytecheck",
+ "byteorder",
+ "bytes",
+ "num-traits",
+ "rand 0.8.5",
+ "rkyv",
+ "serde",
+ "serde_json",
+]
+
[[package]]
name = "rustc-hash"
version = "1.1.0"
@@ -3078,6 +3374,172 @@ dependencies = [
"untrusted",
]
+[[package]]
+name = "sea-orm"
+version = "0.10.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "88694d01b528a94f90ad87f8d2f546d060d070eee180315c67d158cb69476034"
+dependencies = [
+ "async-stream",
+ "async-trait",
+ "chrono",
+ "futures",
+ "futures-util",
+ "log",
+ "ouroboros",
+ "rust_decimal",
+ "sea-orm-macros",
+ "sea-query",
+ "sea-query-binder",
+ "sea-strum",
+ "serde",
+ "serde_json",
+ "sqlx",
+ "thiserror",
+ "time 0.3.17",
+ "tracing",
+ "url",
+ "uuid 1.2.2",
+]
+
+[[package]]
+name = "sea-orm-cli"
+version = "0.10.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ebe1f820fe8949cf6a57272ba9ebd0be766e47c9b85c04b3cabea40ab9459b3"
+dependencies = [
+ "chrono",
+ "clap",
+ "dotenvy",
+ "regex",
+ "sea-schema",
+ "tracing",
+ "tracing-subscriber",
+ "url",
+]
+
+[[package]]
+name = "sea-orm-macros"
+version = "0.10.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7216195de9c6b2474fd0efab486173dccd0eff21f28cc54aa4c0205d52fb3af0"
+dependencies = [
+ "bae",
+ "heck 0.3.3",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "sea-orm-migration"
+version = "0.10.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ed3cdfa669e4c385922f902b9a58e0c2128782a4d0fe79c6c34f3b927565e5b"
+dependencies = [
+ "async-trait",
+ "clap",
+ "dotenvy",
+ "sea-orm",
+ "sea-orm-cli",
+ "sea-schema",
+ "tracing",
+ "tracing-subscriber",
+]
+
+[[package]]
+name = "sea-query"
+version = "0.27.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a4f0fc4d8e44e1d51c739a68d336252a18bc59553778075d5e32649be6ec92ed"
+dependencies = [
+ "chrono",
+ "rust_decimal",
+ "sea-query-derive",
+ "serde_json",
+ "time 0.3.17",
+ "uuid 1.2.2",
+]
+
+[[package]]
+name = "sea-query-binder"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9c2585b89c985cfacfe0ec9fc9e7bb055b776c1a2581c4e3c6185af2b8bf8865"
+dependencies = [
+ "chrono",
+ "rust_decimal",
+ "sea-query",
+ "serde_json",
+ "sqlx",
+ "time 0.3.17",
+ "uuid 1.2.2",
+]
+
+[[package]]
+name = "sea-query-derive"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "34cdc022b4f606353fe5dc85b09713a04e433323b70163e81513b141c6ae6eb5"
+dependencies = [
+ "heck 0.3.3",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "thiserror",
+]
+
+[[package]]
+name = "sea-schema"
+version = "0.10.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38d5fda574d980e9352b6c7abd6fc75697436fe0078cac2b548559b52643ad3b"
+dependencies = [
+ "futures",
+ "sea-query",
+ "sea-schema-derive",
+]
+
+[[package]]
+name = "sea-schema-derive"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "56821b7076f5096b8f726e2791ad255a99c82498e08ec477a65a96c461ff1927"
+dependencies = [
+ "heck 0.3.3",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "sea-strum"
+version = "0.23.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "391d06a6007842cfe79ac6f7f53911b76dfd69fc9a6769f1cf6569d12ce20e1b"
+dependencies = [
+ "sea-strum_macros",
+]
+
+[[package]]
+name = "sea-strum_macros"
+version = "0.23.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "69b4397b825df6ccf1e98bcdabef3bbcfc47ff5853983467850eeab878384f21"
+dependencies = [
+ "heck 0.3.3",
+ "proc-macro2",
+ "quote",
+ "rustversion",
+ "syn",
+]
+
+[[package]]
+name = "seahash"
+version = "4.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b"
+
[[package]]
name = "security-framework"
version = "2.7.0"
@@ -3267,17 +3729,6 @@ dependencies = [
"stable_deref_trait",
]
-[[package]]
-name = "sha1"
-version = "0.10.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3"
-dependencies = [
- "cfg-if",
- "cpufeatures",
- "digest",
-]
-
[[package]]
name = "sha2"
version = "0.10.6"
@@ -3420,14 +3871,12 @@ checksum = "dcbc16ddba161afc99e14d1713a453747a2b07fc097d2009f4c300ec99286105"
dependencies = [
"ahash",
"atoi",
- "base64 0.13.1",
"bitflags",
"byteorder",
"bytes",
"chrono",
"crc",
"crossbeam-queue",
- "dirs",
"dotenvy",
"either",
"event-listener",
@@ -3439,34 +3888,32 @@ dependencies = [
"futures-util",
"hashlink",
"hex",
- "hkdf",
- "hmac",
"indexmap",
"itoa 1.0.4",
"libc",
"libsqlite3-sys",
"log",
- "md-5",
"memchr",
+ "num-bigint",
"once_cell",
"paste",
"percent-encoding",
- "rand 0.8.5",
+ "rust_decimal",
"rustls",
"rustls-pemfile",
"serde",
"serde_json",
- "sha1",
"sha2",
"smallvec",
"sqlformat",
"sqlx-rt",
"stringprep",
"thiserror",
+ "time 0.3.17",
"tokio-stream",
"url",
+ "uuid 1.2.2",
"webpki-roots",
- "whoami",
]
[[package]]
@@ -3481,6 +3928,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
+ "serde_json",
"sha2",
"sqlx-core",
"sqlx-rt",
@@ -3577,12 +4025,6 @@ dependencies = [
"syn",
]
-[[package]]
-name = "subtle"
-version = "2.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
-
[[package]]
name = "syn"
version = "1.0.105"
@@ -3989,6 +4431,12 @@ dependencies = [
"winapi-util",
]
+[[package]]
+name = "textwrap"
+version = "0.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
+
[[package]]
name = "thin-slice"
version = "0.1.1"
@@ -4157,6 +4605,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
dependencies = [
"cfg-if",
+ "log",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
@@ -4619,16 +5068,6 @@ dependencies = [
"windows-metadata",
]
-[[package]]
-name = "whoami"
-version = "1.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "45dbc71f0cdca27dc261a9bd37ddec174e4a0af2b900b890f378460f745426e3"
-dependencies = [
- "wasm-bindgen",
- "web-sys",
-]
-
[[package]]
name = "winapi"
version = "0.3.9"
diff --git a/client-app/src-tauri/Cargo.toml b/client-app/src-tauri/Cargo.toml
index dd7e8352b9..bbd0f3d276 100644
--- a/client-app/src-tauri/Cargo.toml
+++ b/client-app/src-tauri/Cargo.toml
@@ -11,7 +11,7 @@ rust-version = "1.57"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
-tauri-build = {version = "1.2", features = [] }
+tauri-build = { version = "1.2", features = [] }
[dependencies]
bytes = "1.3.0"
@@ -19,24 +19,29 @@ ipc_types = { path = "./types" }
futures = "^0.3.25"
js-sys = "0.3.60"
jwst = { path = "../src-OctoBase/libs/jwst" }
-jwst-storage = { path = "../src-OctoBase/libs/jwst-storage", features = ["sqlite", "server"] }
-lib0 = "0.12.0"
+jwst-storage = { path = "../src-OctoBase/libs/jwst-storage", features = [
+ "sqlite",
+] }
+cloud-database = { path = "../src-OctoBase/libs/cloud-database", features = [
+ "sqlite",
+] }
project-root = "0.2.2"
schemars = "0.8.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
dotenvy = "0.15.6"
-tauri = {version = "1.2", features = ["api-all", "devtools"] }
+tauri = { version = "1.2", features = ["api-all", "devtools"] }
tokio = { version = "1.23.0", features = ["rt", "macros"] }
+lib0 = "0.12.0"
yrs = { path = "../src-OctoBase/libs/vendors/y-crdt/yrs" }
[features]
# by default Tauri runs in production mode
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
-default = [ "custom-protocol" ]
+default = ["custom-protocol"]
# this feature is used used for production builds where `devPath` points to the filesystem
# DO NOT remove this
-custom-protocol = [ "tauri/custom-protocol" ]
+custom-protocol = ["tauri/custom-protocol"]
[profile.release.package.wry]
debug = true
diff --git a/client-app/src-tauri/src/commands/document.rs b/client-app/src-tauri/src/commands/document.rs
index 7f78a1da0d..60caf07d06 100644
--- a/client-app/src-tauri/src/commands/document.rs
+++ b/client-app/src-tauri/src/commands/document.rs
@@ -51,33 +51,16 @@ pub async fn get_doc<'s>(
) -> Result<GetDocumentResponse, String> {
// TODO: check user permission
- let doc_file_path = &state
- .0
- .lock()
- .await
- .doc_storage
- .get_path(parameters.id.clone());
- let mut file = File::open(doc_file_path).await.unwrap();
- let mut updates_vector: Vec<Vec<u8>> = Vec::new();
- loop {
- let len = file.read_u64_le().await;
-
- let len = match len {
- Ok(len) => len,
- Err(e) if e.kind() == ErrorKind::UnexpectedEof => break,
- Err(e) => return Err(format!("Failed to get yDoc from {}", parameters.id)),
- };
-
- let mut update = vec![0; len as usize];
- file.read_exact(&mut update).await.unwrap();
-
- updates_vector.push(update);
-
- file.read_u64_le().await.unwrap();
+ if let Ok(all_updates_of_workspace) = &state.0.lock().await.doc_storage.all(&parameters.id).await {
+ Ok(GetDocumentResponse {
+ updates: all_updates_of_workspace.iter().map(|model| model.blob.clone()).collect::<Vec<Vec<u8>>>(),
+ })
+ } else {
+ Err(format!(
+ "Failed to get yDoc from workspace {}",
+ parameters.id
+ ))
}
- Ok(GetDocumentResponse {
- updates: updates_vector,
- })
}
#[tauri::command]
diff --git a/client-app/src-tauri/src/commands/user.rs b/client-app/src-tauri/src/commands/user.rs
index 0eb83f9ab0..c754e07aea 100644
--- a/client-app/src-tauri/src/commands/user.rs
+++ b/client-app/src-tauri/src/commands/user.rs
@@ -1,5 +1,5 @@
+use cloud_database::{CreateUser, User};
use ipc_types::document::CreateDocumentParameter;
-use jwst_storage::{CreateUser, User};
use crate::state::AppState;
diff --git a/client-app/src-tauri/src/state.rs b/client-app/src-tauri/src/state.rs
index e7abeeffe4..69876871f9 100644
--- a/client-app/src-tauri/src/state.rs
+++ b/client-app/src-tauri/src/state.rs
@@ -1,34 +1,45 @@
-use jwst_storage::{BlobFsStorage, DocFsStorage, SqliteDBContext};
+use cloud_database::SqliteDBContext;
+use jwst_storage::{BlobAutoStorage, DocAutoStorage};
use std::{fs, path::Path};
use tauri::api::path::document_dir;
use tokio::sync::Mutex;
pub struct AppStateRaw {
- pub blob_storage: BlobFsStorage,
- pub doc_storage: DocFsStorage,
+ pub doc_storage: DocAutoStorage,
+ pub blob_storage: BlobAutoStorage,
pub metadata_db: SqliteDBContext,
}
impl AppStateRaw {
pub async fn new() -> Option<AppStateRaw> {
let affine_document_path = Path::new(&document_dir()?.into_os_string()).join("affine");
- let doc_path = affine_document_path.join("doc");
- let blob_env = affine_document_path.join("blob");
- let db_env = format!(
+ let metadata_db_env = format!(
"sqlite://{}?mode=rwc",
affine_document_path
- .join("metadata.db")
- .into_os_string()
- .into_string()
- .unwrap()
+ .join("metadata")
+ .with_extension("db")
+ .display()
);
- fs::create_dir_all(doc_path.clone()).unwrap();
- fs::create_dir_all(blob_env.clone()).unwrap();
+ let blob_db_env = format!(
+ "sqlite://{}?mode=rwc",
+ affine_document_path
+ .join("blob")
+ .with_extension("db")
+ .display()
+ );
+ let doc_db_env = format!(
+ "sqlite://{}?mode=rwc",
+ affine_document_path
+ .join("doc")
+ .with_extension("db")
+ .display()
+ );
+ fs::create_dir_all(affine_document_path.clone()).unwrap();
Some(Self {
- doc_storage: DocFsStorage::new(Some(16), 500, Path::new(&doc_path).into()).await,
- blob_storage: BlobFsStorage::new(Some(16), Path::new(&blob_env).into()).await,
- metadata_db: SqliteDBContext::new(db_env).await,
+ doc_storage: DocAutoStorage::init_pool(&doc_db_env).await.unwrap(),
+ blob_storage: BlobAutoStorage::init_pool(&blob_db_env).await.unwrap(),
+ metadata_db: SqliteDBContext::new(metadata_db_env).await,
})
}
}
diff --git a/client-app/src-tauri/types/Cargo.toml b/client-app/src-tauri/types/Cargo.toml
index f738609be8..ae1a846988 100644
--- a/client-app/src-tauri/types/Cargo.toml
+++ b/client-app/src-tauri/types/Cargo.toml
@@ -3,7 +3,12 @@ name = "ipc_types"
version = "0.1.0"
[dependencies]
-jwst-storage = { path = "../../src-OctoBase/libs/jwst-storage", features = ["sqlite", "server"] }
+jwst-storage = { path = "../../src-OctoBase/libs/jwst-storage", features = [
+ "sqlite",
+] }
+cloud-database = { path = "../../src-OctoBase/libs/cloud-database", features = [
+ "sqlite",
+] }
project-root = "0.2.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
diff --git a/client-app/src-tauri/types/src/lib.rs b/client-app/src-tauri/types/src/lib.rs
index d6d8f19cc5..7760ade8fb 100644
--- a/client-app/src-tauri/types/src/lib.rs
+++ b/client-app/src-tauri/types/src/lib.rs
@@ -2,6 +2,7 @@
extern crate serde;
extern crate schemars;
extern crate jwst_storage;
+extern crate cloud_database;
pub mod blob;
pub mod document;
diff --git a/client-app/src-tauri/types/src/user.rs b/client-app/src-tauri/types/src/user.rs
index 9d3a1daf5a..40b90751aa 100644
--- a/client-app/src-tauri/types/src/user.rs
+++ b/client-app/src-tauri/types/src/user.rs
@@ -1,4 +1,4 @@
-use jwst_storage::{CreateUser, User};
+use cloud_database::{CreateUser, User};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
diff --git a/client-app/src-tauri/types/src/workspace.rs b/client-app/src-tauri/types/src/workspace.rs
index 1c68c2790a..2aca972bba 100644
--- a/client-app/src-tauri/types/src/workspace.rs
+++ b/client-app/src-tauri/types/src/workspace.rs
@@ -1,4 +1,4 @@
-use jwst_storage::{model::WorkspaceWithPermission, WorkspaceDetail};
+use cloud_database::{WorkspaceWithPermission, WorkspaceDetail};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};