Skip to content

Commit

Permalink
feature(rust): initial work on rust (very broken)
Browse files Browse the repository at this point in the history
  • Loading branch information
pauliesnug committed Oct 25, 2023
1 parent a217c57 commit 13ccad3
Show file tree
Hide file tree
Showing 34 changed files with 770 additions and 37 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -729,3 +729,5 @@ apps/.deps
.cargo/config.toml
.cargo/config
.github/scripts/deps
dev.db
dev.db-journal
48 changes: 34 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ resolver = "2"
members = [
"core",
"crates/*",
"apps/cli",
"apps/desktop/src-tauri"
# "apps/cli",
# "apps/desktop/src-tauri"
]

[workspace.package]
Expand All @@ -13,39 +13,59 @@ edition = "2021"
repository = "https://github.com/Polyfrost/Nexus"
documentation = "https://docs.polyfrost.org/nexus"
readme = "README.md"
license-file = "LICENSE"
homepage = "https://polyfrost.org"
authors = ["Polyfrost"]

[workspace.dependencies]
prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust", features = [
"rspc",
# prisma client rust dependencies
prisma-client-rust = { git = "https://github.com/pauliesnug/prisma-client-rust", features = [
"sqlite-create-many",
"migrations",
"sqlite",
], default-features = false }
prisma-client-rust-cli = { git = "https://github.com/Brendonovich/prisma-client-rust", features = [
"rspc",
prisma-client-rust-cli = { git = "https://github.com/pauliesnug/prisma-client-rust", features = [
"sqlite-create-many",
"migrations",
"sqlite",
], default-features = false }
prisma-client-rust-sdk = { git = "https://github.com/Brendonovich/prisma-client-rust", features = [
prisma-client-rust-sdk = { git = "https://github.com/pauliesnug/prisma-client-rust", features = [
"sqlite",
], default-features = false }

rspc = { version = "1.0.0-rc.5" }
# rspc dependencies
rspc = { version = "1.0.0-rc.5", features = [
"uuid",
"chrono"
] }
specta = { version = "2.0.0-rc.6" }
tauri-specta = { version = "2.0.0-rc.3" }

# swift-rs for ios specific extensions
swift-rs = { version = "1.0.6" }
tokio = { version = "1.33.0" }

tracing = { git = "https://github.com/tokio-rs/tracing", rev = "f93cfa087e6ebdcbd8ecdcccca47d73c3a89ab94" }
tracing-subscriber = { git = "https://github.com/tokio-rs/tracing", rev = "f93cfa087e6ebdcbd8ecdcccca47d73c3a89ab94", features = ["env-filter"] }
tracing-appender = { git = "https://github.com/tokio-rs/tracing", rev = "f93cfa087e6ebdcbd8ecdcccca47d73c3a89ab94" }

# general use packages
tokio = { version = "1.33.0", features = ["full"] }
uuid = { version = "1.4.1", features = ["v4", "serde"] }
serde = { version = "1.0" }
serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.11", features = ["blocking", "json"] }
clap = { version = "4.4", features = ["derive"] }
chrono = { version = "0.4", features = ["serde"] }
thiserror = { version = "1.0" }
async-stream = { version = "0.3" }
itertools = { version = "0.11" }
dashmap = { version = "5.5", features = ["serde"] }
regex = { version = "1.10" }
bytes = { version = "1.5" }
anyhow = { version = "1.0" }
cargo_metadata = { version = "0.18" }
serde_json = { version = "1.0" }
lazy_static = { version = "1.4" }
futures = { version = "0.3" }

tracing = { git = "https://github.com/tokio-rs/tracing", rev = "29146260fb4615d271d2e899ad95a753bb42915e" }
tracing-subscriber = { git = "https://github.com/tokio-rs/tracing", rev = "29146260fb4615d271d2e899ad95a753bb42915e", features = ["env-filter"] }
tracing-appender = { git = "https://github.com/tokio-rs/tracing", rev = "29146260fb4615d271d2e899ad95a753bb42915e" }

[patch.crates-io]
specta = { git = "https://github.com/oscartbeaumont/specta", rev = "22d4392b9296e761d12aebf9b50001235f4b2be7" }
Expand Down
16 changes: 16 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "nexuscore"
version = "0.1.0"
license.workspace = true
edition.workspace = true
repository.workspace = true
documentation.workspace = true
readme.workspace = true
homepage.workspace = true
authors.workspace = true

[dependencies]
nexus-prisma = { path = "../crates/prisma" }
nexus-utils = { path = "../crates/utils"}

tauri-specta.workspace = true
11 changes: 11 additions & 0 deletions core/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use std::process::Command;

fn main() {
let output = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.expect("error getting git hash. Does `git rev-parse --short HEAD` work for you?");
let git_hash = String::from_utf8(output.stdout)
.expect("Error passing output of `git rev-parse --short HEAD`");
println!("cargo:rustc-env=GIT_HASH={git_hash}");
}
67 changes: 67 additions & 0 deletions core/prisma/migrations/20231024234944_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
-- CreateTable
CREATE TABLE "instance" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"pub_id" BLOB NOT NULL,
"node_id" BLOB NOT NULL,
"node_name" TEXT NOT NULL,
"node_platform" INTEGER NOT NULL,
"last_run" DATETIME NOT NULL,
"date_created" DATETIME NOT NULL,
"timestamp" BIGINT
);

-- CreateTable
CREATE TABLE "Statistics" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"date_captured" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"java_version" TEXT NOT NULL DEFAULT '0',
"operating_system" INTEGER NOT NULL DEFAULT 0
);

-- CreateTable
CREATE TABLE "object" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"pub_id" BLOB NOT NULL,
"kind" INTEGER,
"date_created" DATETIME,
"date_accessed" DATETIME
);

-- CreateTable
CREATE TABLE "job" (
"id" BLOB NOT NULL PRIMARY KEY,
"name" TEXT,
"action" TEXT,
"status" INTEGER,
"errors_text" TEXT,
"data" BLOB,
"metadata" BLOB,
"parent_id" BLOB,
"task_count" INTEGER,
"completed_task_count" INTEGER,
"estimated_completion" DATETIME,
"date_created" DATETIME,
"date_started" DATETIME,
"date_completed" DATETIME,
CONSTRAINT "job_parent_id_fkey" FOREIGN KEY ("parent_id") REFERENCES "job" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);

-- CreateTable
CREATE TABLE "preference" (
"key" TEXT NOT NULL PRIMARY KEY,
"value" BLOB
);

-- CreateTable
CREATE TABLE "notification" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"read" BOOLEAN NOT NULL DEFAULT false,
"data" BLOB NOT NULL,
"expires_at" DATETIME
);

-- CreateIndex
CREATE UNIQUE INDEX "instance_pub_id_key" ON "instance"("pub_id");

-- CreateIndex
CREATE UNIQUE INDEX "object_pub_id_key" ON "object"("pub_id");
3 changes: 3 additions & 0 deletions core/prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "sqlite"
94 changes: 94 additions & 0 deletions core/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
datasource db {
provider = "sqlite"
url = "file:dev.db"
}

generator client {
provider = "cargo prisma"
output = "../../crates/prisma/src/prisma"
module_path = "prisma"
client_format = "folder"
}

/// @local(id: pub_id)
model Instance {
id Int @id @default(autoincrement()) // This is NOT globally unique
pub_id Bytes @unique // This UUID exists solely for backwards compatibility.
node_id Bytes
node_name String
node_platform Int
last_run DateTime
date_created DateTime
timestamp BigInt?
@@map("instance")
}

model Statistics {
id Int @id @default(autoincrement())
date_captured DateTime @default(now())
java_version String @default("0")
operating_system Int @default(0)
}

/// @shared(id: pub_id)
model Object {
id Int @id @default(autoincrement())
pub_id Bytes @unique
kind Int?
date_created DateTime?
date_accessed DateTime?
@@map("object")
}

model Job {
id Bytes @id
name String?
action String?
status Int?
errors_text String?
data Bytes?
metadata Bytes?
parent_id Bytes?
task_count Int?
completed_task_count Int?
estimated_completion DateTime?
date_created DateTime?
date_started DateTime?
date_completed DateTime?
parent Job? @relation("jobs_dependency", fields: [parent_id], references: [id], onDelete: SetNull)
children Job[] @relation("jobs_dependency")
@@map("job")
}

/// @shared(id: key)
model Preference {
key String @id
value Bytes?
@@map("preference")
}

model Notification {
id Int @id @default(autoincrement())
read Boolean @default(false)
data Bytes
expires_at DateTime?
@@map("notification")
}
Empty file added core/src/lib.rs
Empty file.
18 changes: 18 additions & 0 deletions crates/generator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "generator"
version = "0.1.0"
license.workspace = true
edition.workspace = true
repository.workspace = true
documentation.workspace = true
readme.workspace = true
homepage.workspace = true
authors.workspace = true

[dependencies]
reqwest.workspace = true
clap.workspace = true
anyhow.workspace = true
serde.workspace = true
serde_json.workspace = true
cargo_metadata.workspace = true
Loading

0 comments on commit 13ccad3

Please sign in to comment.