From 5c08c211ca4d9db5ecdfdeefcb0a38a4cc8c3144 Mon Sep 17 00:00:00 2001 From: Jamie Pine Date: Wed, 20 Apr 2022 02:25:50 -0700 Subject: [PATCH] upgrade to latest prisma-client-rust --- .cargo/config.toml | 2 + .vscode/settings.json | 5 +- Cargo.lock | 281 ++++++++++++++++++++++++++---- Cargo.toml | 1 + apps/desktop/src-tauri/Cargo.toml | 4 +- core/Cargo.toml | 4 +- core/prisma/Cargo.toml | 9 + core/prisma/schema.prisma | 2 +- core/prisma/src/main.rs | 3 + core/src/client/mod.rs | 15 +- core/src/db/migrate.rs | 12 +- core/src/encode/thumb.rs | 17 +- core/src/file/explorer/open.rs | 12 +- core/src/file/mod.rs | 6 +- core/src/job/jobs.rs | 34 ++-- core/src/library/loader.rs | 14 +- core/src/sys/locations.rs | 18 +- 17 files changed, 332 insertions(+), 107 deletions(-) create mode 100644 .cargo/config.toml create mode 100644 core/prisma/Cargo.toml create mode 100644 core/prisma/src/main.rs diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 000000000..ba19587f5 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[alias] +prisma = "run -p prisma-cli --" \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 67309fd05..e5cb9394b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,5 +15,8 @@ "tsparticles" ], "rust-analyzer.procMacro.enable": true, - "rust-analyzer.diagnostics.enableExperimental": false + "rust-analyzer.diagnostics.enableExperimental": false, + "rust-analyzer.inlayHints.parameterHints": false, + "rust-analyzer.inlayHints.enable": false, + "rust-analyzer.inlayHints.typeHints": false } diff --git a/Cargo.lock b/Cargo.lock index 2fef1c3a9..59f4b9178 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1124,6 +1124,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "convert_case" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb4a24b1aaf0fd0ce8b45161144d6f42cd91677fd5940fd431183eb023b3a2b8" + [[package]] name = "core-derive" version = "0.1.0" @@ -1524,7 +1530,7 @@ checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" [[package]] name = "datamodel" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "bigdecimal 0.2.2", "chrono", @@ -1547,7 +1553,7 @@ dependencies = [ [[package]] name = "datamodel-connector" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "diagnostics", "enumflags2", @@ -1611,7 +1617,7 @@ version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ - "convert_case", + "convert_case 0.4.0", "proc-macro2", "quote", "rustc_version 0.4.0", @@ -1621,7 +1627,7 @@ dependencies = [ [[package]] name = "diagnostics" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "colored", "pest", @@ -1657,6 +1663,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "directories" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210" +dependencies = [ + "dirs-sys", +] + [[package]] name = "dirs-next" version = "2.0.0" @@ -1667,6 +1682,17 @@ 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 0.3.9", +] + [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -1696,7 +1722,7 @@ dependencies = [ [[package]] name = "dml" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "chrono", "cuid", @@ -1712,7 +1738,7 @@ dependencies = [ [[package]] name = "dmmf" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "bigdecimal 0.2.2", "datamodel", @@ -1868,6 +1894,15 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" +[[package]] +name = "encoding_rs" +version = "0.8.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "enum-as-inner" version = "0.3.4" @@ -2056,15 +2091,15 @@ checksum = "279fb028e20b3c4c320317955b77c5e0c9701f05a1d309905d6fc702cdc5053e" [[package]] name = "flate2" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f" +checksum = "b39522e96686d38f4bc984b9198e3a0613264abaebaff2c5c918bfa6b6da09af" dependencies = [ "cfg-if 1.0.0", "crc32fast", "libc", "libz-sys", - "miniz_oxide 0.4.4", + "miniz_oxide 0.5.1", ] [[package]] @@ -2742,6 +2777,25 @@ dependencies = [ "syn", ] +[[package]] +name = "h2" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37a82c6d637fc9515a4694bbf1cb2457b79d81ce52b3108bdeea58b07dd34a57" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util 0.7.1", + "tracing", +] + [[package]] name = "half" version = "1.8.2" @@ -2919,6 +2973,17 @@ dependencies = [ "itoa 1.0.1", ] +[[package]] +name = "http-body" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" +dependencies = [ + "bytes", + "http", + "pin-project-lite 0.2.8", +] + [[package]] name = "http-range" version = "0.1.5" @@ -2931,12 +2996,55 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9100414882e15fb7feccb4897e5f0ff0ff1ca7d1a86a23208ada4d7a18e6c6c4" +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + [[package]] name = "humantime" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "hyper" +version = "0.14.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b26ae0a80afebe130861d90abf98e3814a4f28a4c6ffeb5ab8ebb2be311e0ef2" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa 1.0.1", + "pin-project-lite 0.2.8", + "socket2 0.4.4", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ico" version = "0.1.0" @@ -4468,7 +4576,7 @@ dependencies = [ [[package]] name = "mongodb-client" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "mongodb", "once_cell", @@ -4479,7 +4587,7 @@ dependencies = [ [[package]] name = "mongodb-datamodel-connector" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "datamodel-connector", "enumflags2", @@ -4491,7 +4599,7 @@ dependencies = [ [[package]] name = "mongodb-query-connector" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "anyhow", "async-trait", @@ -4616,7 +4724,7 @@ dependencies = [ "socket2 0.4.4", "thiserror", "tokio", - "tokio-native-tls", + "tokio-native-tls 0.3.0 (git+https://github.com/pimeys/tls?branch=vendored-openssl)", "tokio-util 0.6.9", "twox-hash", "url", @@ -4690,7 +4798,7 @@ dependencies = [ [[package]] name = "native-types" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "serde", "serde_json", @@ -5332,7 +5440,7 @@ dependencies = [ [[package]] name = "parser-database" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "diagnostics", "enumflags2", @@ -5711,7 +5819,7 @@ dependencies = [ "futures", "native-tls", "tokio", - "tokio-native-tls", + "tokio-native-tls 0.3.0 (git+https://github.com/pimeys/tls?branch=vendored-openssl)", "tokio-postgres", ] @@ -5765,10 +5873,17 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be91bcc43e73799dc46a6c194a55e7aae1d86cc867c860fd4a436019af21bd8c" +[[package]] +name = "prisma-cli" +version = "0.1.0" +dependencies = [ + "prisma-client-rust-cli", +] + [[package]] name = "prisma-client-rust" -version = "0.3.1" -source = "git+https://github.com/Brendonovich/prisma-client-rust.git?rev=3f742cc4fb4df9a77c6311d43183d5082cf32510#3f742cc4fb4df9a77c6311d43183d5082cf32510" +version = "0.4.0" +source = "git+https://github.com/Brendonovich/prisma-client-rust.git?tag=0.4.0#4c6c4bf93c8eb5f3a16efca161983a9537e5e53b" dependencies = [ "chrono", "datamodel", @@ -5782,10 +5897,28 @@ dependencies = [ "thiserror", ] +[[package]] +name = "prisma-client-rust-cli" +version = "0.4.0" +source = "git+https://github.com/Brendonovich/prisma-client-rust.git?tag=0.4.0#4c6c4bf93c8eb5f3a16efca161983a9537e5e53b" +dependencies = [ + "convert_case 0.5.0", + "directories", + "flate2", + "http", + "quote", + "regex", + "reqwest", + "serde", + "serde_json", + "serde_path_to_error", + "syn", +] + [[package]] name = "prisma-inflector" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "once_cell", "regex", @@ -5795,7 +5928,7 @@ dependencies = [ [[package]] name = "prisma-models" version = "0.0.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "bigdecimal 0.2.2", "chrono", @@ -5816,7 +5949,7 @@ dependencies = [ [[package]] name = "prisma-value" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "base64 0.12.3", "bigdecimal 0.2.2", @@ -5976,7 +6109,7 @@ dependencies = [ [[package]] name = "quaint" version = "0.2.0-alpha.13" -source = "git+https://github.com/prisma/quaint?rev=479e08a41b13902028906bc05f778688c06a3f18#479e08a41b13902028906bc05f778688c06a3f18" +source = "git+https://github.com/prisma/quaint?rev=a0722f26311669377ca9069843e8866a1706c42a#a0722f26311669377ca9069843e8866a1706c42a" dependencies = [ "async-trait", "base64 0.12.3", @@ -6015,7 +6148,7 @@ dependencies = [ [[package]] name = "query-connector" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "anyhow", "async-trait", @@ -6035,7 +6168,7 @@ dependencies = [ [[package]] name = "query-core" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "async-trait", "base64 0.12.3", @@ -6296,7 +6429,7 @@ dependencies = [ [[package]] name = "request-handlers" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "bigdecimal 0.2.2", "connection-string", @@ -6315,6 +6448,42 @@ dependencies = [ "user-facing-errors", ] +[[package]] +name = "reqwest" +version = "0.11.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46a1f7aa4f35e5e8b4160449f51afc758f0ce6454315a9fa7d0d113e958c41eb" +dependencies = [ + "base64 0.13.0", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "lazy_static", + "log", + "mime", + "native-tls", + "percent-encoding", + "pin-project-lite 0.2.8", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-native-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg 0.10.1", +] + [[package]] name = "resolv-conf" version = "0.7.0" @@ -6581,7 +6750,7 @@ dependencies = [ [[package]] name = "schema-ast" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "diagnostics", "pest", @@ -6798,6 +6967,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_path_to_error" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7868ad3b8196a8a0aea99a8220b124278ee5320a55e4fde97794b6f85b1a377" +dependencies = [ + "serde", +] + [[package]] name = "serde_repr" version = "0.1.7" @@ -7192,7 +7370,7 @@ dependencies = [ [[package]] name = "sql-datamodel-connector" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "datamodel-connector", "enumflags2", @@ -7205,7 +7383,7 @@ dependencies = [ [[package]] name = "sql-query-connector" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "anyhow", "async-trait", @@ -7967,6 +8145,16 @@ dependencies = [ "syn", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-native-tls" version = "0.3.0" @@ -8060,6 +8248,12 @@ dependencies = [ "vec1", ] +[[package]] +name = "tower-service" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" + [[package]] name = "tracing" version = "0.1.32" @@ -8243,6 +8437,12 @@ dependencies = [ "trust-dns-proto 0.21.2", ] +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + [[package]] name = "ts-rs" version = "6.1.2" @@ -8272,7 +8472,7 @@ version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ee73e6e4924fe940354b8d4d98cad5231175d615cd855b758adc658c0aac6a0" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 0.1.10", "rand 0.8.5", "static_assertions", ] @@ -8438,7 +8638,7 @@ dependencies = [ [[package]] name = "user-facing-error-macros" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "proc-macro2", "quote", @@ -8448,7 +8648,7 @@ dependencies = [ [[package]] name = "user-facing-errors" version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8c1da2fdc058b7af8905a61491856cade06f952f#8c1da2fdc058b7af8905a61491856cade06f952f" +source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" dependencies = [ "backtrace", "indoc", @@ -8550,6 +8750,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -9172,6 +9382,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "winres" version = "0.1.12" diff --git a/Cargo.toml b/Cargo.toml index 14553072c..abfdeec14 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,5 +3,6 @@ members = [ "apps/debug", "apps/desktop/src-tauri", "core", + "core/prisma", "core/derive" ] diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index 9a713509b..a0a583fde 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -2,11 +2,11 @@ name = "spacedrive" version = "0.1.0" description = "The next gen private virtual filesystem." -authors = ["NerdHouse, Inc.", "Jamie Pine"] +authors = ["Jamie Pine"] license = "" repository = "https://github.com/jamiepine/spacedrive" default-run = "spacedrive" -edition = "2018" +edition = "2021" build = "src/build.rs" [build-dependencies] diff --git a/core/Cargo.toml b/core/Cargo.toml index 4df640546..181d20ec6 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -5,7 +5,7 @@ description = "A virtual distributed filesystem." authors = ["Jamie Pine"] license = "GNU GENERAL PUBLIC LICENSE" repository = "https://github.com/jamiepine/spacedrive" -edition = "2018" +edition = "2021" [dependencies] swift-rs = "0.2.3" @@ -29,7 +29,7 @@ once_cell = "1.8.0" int-enum = "0.4.0" # Project dependencies ts-rs = "6.1" -prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust.git", rev = "3f742cc4fb4df9a77c6311d43183d5082cf32510" } +prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust.git", tag = "0.4.0" } walkdir = "^2.3.2" bytesize = "1.1.0" env_logger = "0.9.0" diff --git a/core/prisma/Cargo.toml b/core/prisma/Cargo.toml new file mode 100644 index 000000000..c8fd197f5 --- /dev/null +++ b/core/prisma/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "prisma-cli" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +prisma-client-rust-cli = { git = "https://github.com/Brendonovich/prisma-client-rust", tag = "0.4.0" } \ No newline at end of file diff --git a/core/prisma/schema.prisma b/core/prisma/schema.prisma index fc574fa90..7ca968982 100644 --- a/core/prisma/schema.prisma +++ b/core/prisma/schema.prisma @@ -4,7 +4,7 @@ datasource db { } generator client { - provider = "prisma-client-rust" + provider = "cargo prisma" output = "../src/prisma.rs" } diff --git a/core/prisma/src/main.rs b/core/prisma/src/main.rs new file mode 100644 index 000000000..b873b532b --- /dev/null +++ b/core/prisma/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + prisma_client_rust_cli::run(); +} diff --git a/core/src/client/mod.rs b/core/src/client/mod.rs index 501a04461..0d36f2bd6 100644 --- a/core/src/client/mod.rs +++ b/core/src/client/mod.rs @@ -1,4 +1,7 @@ -use crate::{prisma, state, Core}; +use crate::{ + prisma::{self, client}, + state, Core, +}; use chrono::{DateTime, Utc}; use int_enum::IntEnum; use serde::{Deserialize, Serialize}; @@ -51,7 +54,7 @@ pub async fn create(core: &Core) -> Result<(), ClientError> { let client = match db .client() - .find_unique(prisma::Client::pub_id().equals(config.client_uuid.clone())) + .find_unique(client::pub_id::equals(config.client_uuid.clone())) .exec() .await? { @@ -59,11 +62,11 @@ pub async fn create(core: &Core) -> Result<(), ClientError> { None => { db.client() .create( - prisma::Client::pub_id().set(config.client_uuid.clone()), - prisma::Client::name().set(hostname.clone()), + client::pub_id::set(config.client_uuid.clone()), + client::name::set(hostname.clone()), vec![ - prisma::Client::platform().set(platform as i32), - prisma::Client::online().set(Some(true)), + client::platform::set(platform as i32), + client::online::set(Some(true)), ], ) .exec() diff --git a/core/src/db/migrate.rs b/core/src/db/migrate.rs index 3afc1e0ac..bcfb524b1 100644 --- a/core/src/db/migrate.rs +++ b/core/src/db/migrate.rs @@ -1,4 +1,4 @@ -use crate::{prisma, prisma::Migration}; +use crate::prisma::{self, migration}; use anyhow::Result; use data_encoding::HEXLOWER; use include_dir::{include_dir, Dir}; @@ -88,7 +88,7 @@ pub async fn run_migrations(db_url: &str) -> Result<()> { // get existing migration by checksum, if it doesn't exist run the migration let existing_migration = client .migration() - .find_unique(Migration::checksum().equals(checksum.clone())) + .find_unique(migration::checksum::equals(checksum.clone())) .exec() .await?; @@ -101,8 +101,8 @@ pub async fn run_migrations(db_url: &str) -> Result<()> { client .migration() .create( - Migration::name().set(name.to_string()), - Migration::checksum().set(checksum.clone()), + migration::name::set(name.to_string()), + migration::checksum::set(checksum.clone()), vec![], ) .exec() @@ -114,8 +114,8 @@ pub async fn run_migrations(db_url: &str) -> Result<()> { println!("Step {} ran successfully", i); client .migration() - .find_unique(Migration::checksum().equals(checksum.clone())) - .update(vec![Migration::steps_applied().set(i as i32 + 1)]) + .find_unique(migration::checksum::equals(checksum.clone())) + .update(vec![migration::steps_applied::set(i as i32 + 1)]) .exec() .await?; } diff --git a/core/src/encode/thumb.rs b/core/src/encode/thumb.rs index ee8c4830e..6a586c75c 100644 --- a/core/src/encode/thumb.rs +++ b/core/src/encode/thumb.rs @@ -1,9 +1,8 @@ use crate::job::jobs::JobReportUpdate; -use crate::prisma::FilePathData; use crate::state::client; use crate::{ job::{jobs::Job, worker::WorkerContext}, - prisma::FilePath, + prisma::file_path, CoreContext, }; use crate::{sys, CoreEvent}; @@ -120,10 +119,10 @@ pub async fn get_images( ctx: &CoreContext, location_id: i32, path: &str, -) -> Result> { +) -> Result> { let mut params = vec![ - FilePath::location_id().equals(location_id), - FilePath::extension().in_vec(vec![ + file_path::location_id::equals(location_id), + file_path::extension::in_vec(vec![ "png".to_string(), "jpeg".to_string(), "jpg".to_string(), @@ -131,12 +130,12 @@ pub async fn get_images( "webp".to_string(), ]), ]; - + if !path.is_empty() { - params.push(FilePath::materialized_path().starts_with(path.to_string())) + params.push(file_path::materialized_path::starts_with(path.to_string())) } - + let image_files = ctx.database.file_path().find_many(params).exec().await?; - + Ok(image_files) } diff --git a/core/src/file/explorer/open.rs b/core/src/file/explorer/open.rs index d0ea68686..8b2ba0dac 100644 --- a/core/src/file/explorer/open.rs +++ b/core/src/file/explorer/open.rs @@ -3,7 +3,7 @@ use std::path::Path; use crate::{ encode::thumb::THUMBNAIL_CACHE_DIR_NAME, file::{DirectoryWithContents, FileError, FilePath}, - prisma, + prisma::file_path, state::client, sys::locations::get_location, CoreContext, @@ -23,9 +23,9 @@ pub async fn open_dir( let directory = db .file_path() .find_first(vec![ - prisma::FilePath::location_id().equals(location.id), - prisma::FilePath::materialized_path().equals(path.into()), - prisma::FilePath::is_dir().equals(true), + file_path::location_id::equals(location.id), + file_path::materialized_path::equals(path.into()), + file_path::is_dir::equals(true), ]) .exec() .await? @@ -33,9 +33,7 @@ pub async fn open_dir( let files = db .file_path() - .find_many(vec![ - prisma::FilePath::parent_id().equals(Some(directory.id)) - ]) + .find_many(vec![file_path::parent_id::equals(Some(directory.id))]) .exec() .await?; diff --git a/core/src/file/mod.rs b/core/src/file/mod.rs index f1a1acb2a..c7821b44f 100644 --- a/core/src/file/mod.rs +++ b/core/src/file/mod.rs @@ -5,7 +5,7 @@ use ts_rs::TS; use crate::{ crypto::encryption::EncryptionAlgorithm, - prisma::{self, FileData, FilePathData}, + prisma::{self, file, file_path}, sys::SysError, }; pub mod cas; @@ -84,7 +84,7 @@ pub enum FileKind { Alias = 8, } -impl Into for FileData { +impl Into for file::Data { fn into(self) -> File { File { id: self.id, @@ -109,7 +109,7 @@ impl Into for FileData { } } -impl Into for FilePathData { +impl Into for file_path::Data { fn into(self) -> FilePath { FilePath { id: self.id, diff --git a/core/src/job/jobs.rs b/core/src/job/jobs.rs index a1aa0c589..8e2657fa0 100644 --- a/core/src/job/jobs.rs +++ b/core/src/job/jobs.rs @@ -3,14 +3,13 @@ use super::{ JobError, }; use crate::{ - prisma::{self, JobData}, - state::client, + prisma::{client, job}, + state, sync::{crdt::Replicate, engine::SyncContext}, CoreContext, }; use anyhow::Result; use int_enum::IntEnum; -use prisma_client_rust::or; use serde::{Deserialize, Serialize}; use std::{collections::HashMap, fmt::Debug, sync::Arc}; use tokio::sync::Mutex; @@ -67,12 +66,7 @@ impl Jobs { let db = &ctx.database; let jobs = db .job() - .find_many(vec![or![ - prisma::Job::status().equals(JobStatus::Completed.int_value()), - prisma::Job::status().equals(JobStatus::Failed.int_value()), - prisma::Job::status().equals(JobStatus::Canceled.int_value()), - prisma::Job::status().equals(JobStatus::Queued.int_value()), - ]]) + .find_many(vec![job::status::not(JobStatus::Running.int_value())]) .exec() .await?; @@ -109,7 +103,7 @@ pub struct JobReport { } // convert database struct into a resource struct -impl Into for JobData { +impl Into for job::Data { fn into(self) -> JobReport { JobReport { id: self.id, @@ -140,14 +134,14 @@ impl JobReport { } } pub async fn create(&self, ctx: &CoreContext) -> Result<(), JobError> { - let config = client::get(); + let config = state::client::get(); ctx .database .job() .create( - prisma::Job::id().set(self.id.clone()), - prisma::Job::action().set(1), - prisma::Job::clients().link(prisma::Client::id().equals(config.client_id)), + job::id::set(self.id.clone()), + job::action::set(1), + job::clients::link(client::id::equals(config.client_id)), vec![], ) .exec() @@ -158,13 +152,13 @@ impl JobReport { ctx .database .job() - .find_unique(prisma::Job::id().equals(self.id.clone())) + .find_unique(job::id::equals(self.id.clone())) .update(vec![ - prisma::Job::status().set(self.status.int_value()), - prisma::Job::task_count().set(self.task_count), - prisma::Job::completed_task_count().set(self.completed_task_count), - prisma::Job::date_modified().set(chrono::Utc::now()), - prisma::Job::seconds_elapsed().set(self.seconds_elapsed), + job::status::set(self.status.int_value()), + job::task_count::set(self.task_count), + job::completed_task_count::set(self.completed_task_count), + job::date_modified::set(chrono::Utc::now()), + job::seconds_elapsed::set(self.seconds_elapsed), ]) .exec() .await?; diff --git a/core/src/library/loader.rs b/core/src/library/loader.rs index 4878ff0f1..1e3f57cd0 100644 --- a/core/src/library/loader.rs +++ b/core/src/library/loader.rs @@ -3,11 +3,7 @@ use thiserror::Error; use uuid::Uuid; use crate::state::client::LibraryState; -use crate::{ - db::migrate, - prisma::{Library, LibraryData}, - state, -}; +use crate::{db::migrate, prisma::library, state}; use crate::{prisma, Core}; pub static LIBRARY_DB_NAME: &str = "library.db"; @@ -19,7 +15,7 @@ pub enum LibraryError { DatabaseError(#[from] prisma::QueryError), } -pub async fn get(core: &Core) -> Result { +pub async fn get(core: &Core) -> Result { let config = state::client::get(); let db = &core.database; @@ -30,7 +26,7 @@ pub async fn get(core: &Core) -> Result { // get library from db let library = match db .library() - .find_unique(Library::pub_id().equals(library_state.library_uuid.clone())) + .find_unique(library::pub_id::equals(library_state.library_uuid.clone())) .exec() .await? { @@ -87,8 +83,8 @@ pub async fn create(core: &Core, name: Option) -> Result<()> { let _library = db .library() .create( - Library::pub_id().set(config.current_library_uuid), - Library::name().set(name.unwrap_or(DEFAULT_NAME.into())), + library::pub_id::set(config.current_library_uuid), + library::name::set(name.unwrap_or(DEFAULT_NAME.into())), vec![], ) .exec() diff --git a/core/src/sys/locations.rs b/core/src/sys/locations.rs index 9d57e575b..b617a8c38 100644 --- a/core/src/sys/locations.rs +++ b/core/src/sys/locations.rs @@ -1,6 +1,6 @@ use crate::{ file::indexer::IndexerJob, - prisma::{FilePath, Location}, + prisma::{file_path, location}, state::client, sys::{volumes, volumes::Volume}, ClientQuery, CoreContext, CoreEvent, @@ -12,8 +12,6 @@ use std::{fs, io, io::Write, path::Path}; use thiserror::Error; use ts_rs::TS; -pub use crate::prisma::LocationData; - use super::SysError; #[derive(Debug, Clone, Serialize, Deserialize, TS)] @@ -30,7 +28,7 @@ pub struct LocationResource { pub date_created: chrono::DateTime, } -impl Into for LocationData { +impl Into for location::Data { fn into(self) -> LocationResource { LocationResource { id: self.id, @@ -74,7 +72,7 @@ pub async fn get_location( // get location by location_id from db and include location_paths let location = match db .location() - .find_unique(Location::id().equals(location_id)) + .find_unique(location::id::equals(location_id)) .exec() .await? { @@ -127,7 +125,7 @@ pub async fn create_location(ctx: &CoreContext, path: &str) -> Result Result