fix: update octobase and fix type mismatching

This commit is contained in:
linonetwo 2023-01-09 15:09:49 +08:00
parent 5513cbf724
commit 51a427496c
9 changed files with 31 additions and 20 deletions

@ -1 +1 @@
Subproject commit d682a717e37b1eb202224891340fb39d68d172db
Subproject commit f7f7eee8492a95509d237d64081e03669df2e31f

View File

@ -1746,9 +1746,11 @@ dependencies = [
"base64 0.20.0",
"bytes",
"chrono",
"dotenvy",
"futures",
"jwst",
"jwst-logger",
"path-ext",
"serde",
"serde_json",
"serde_repr",
@ -1756,6 +1758,7 @@ dependencies = [
"sqlx",
"tokio",
"tokio-util",
"uuid 1.2.2",
"yrs",
]
@ -2407,6 +2410,15 @@ version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1"
[[package]]
name = "path-ext"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8285c3c3c3085f8819bdcebc9c7e783851527f34974d7d283ced36c977ae812"
dependencies = [
"walkdir",
]
[[package]]
name = "pathdiff"
version = "0.2.1"
@ -4363,6 +4375,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c"
dependencies = [
"getrandom 0.2.8",
"rand 0.8.5",
"serde",
]

View File

@ -19,7 +19,7 @@ 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"] }
jwst-storage = { path = "../src-OctoBase/libs/jwst-storage", features = ["sqlite", "server"] }
lib0 = "0.12.0"
project-root = "0.2.2"
schemars = "0.8.3"

View File

@ -17,7 +17,7 @@ pub async fn get_doc<'s>(
.lock()
.await
.doc_storage
.get(parameters.id)
.get(parameters.id.clone())
.await
.ok()
{
@ -27,7 +27,7 @@ pub async fn get_doc<'s>(
} else {
Err(format!(
"Failed to get yDoc from {}",
parameters.id.to_string()
parameters.id
))
}
}
@ -42,7 +42,7 @@ pub async fn update_y_document<'s>(
.lock()
.await
.doc_storage
.write_update(parameters.id, &parameters.update)
.write_update(parameters.id.clone(), &parameters.update)
.await
.ok()
{
@ -50,7 +50,7 @@ pub async fn update_y_document<'s>(
} else {
Err(format!(
"Failed to update yDoc to {}",
parameters.id.to_string()
parameters.id
))
}
}

View File

@ -19,7 +19,7 @@ pub async fn create_workspace<'s>(
.await
{
Ok(new_workspace) => {
let workspace_doc = OctoBaseWorkspace::new(new_workspace.id.to_string());
let workspace_doc = OctoBaseWorkspace::new(new_workspace.id.clone());
workspace_doc.with_trx(|mut workspace_doc_transaction| {
workspace_doc_transaction.set_metadata(
@ -32,13 +32,13 @@ pub async fn create_workspace<'s>(
.lock()
.await
.doc_storage
.write_doc(new_workspace.id, workspace_doc.doc())
.write_doc(new_workspace.id.clone(), workspace_doc.doc())
.await
{
Err(error_message.to_string())
} else {
Ok(CreateWorkspaceResult {
id: new_workspace.id.to_string(),
id: new_workspace.id.clone(),
name: parameters.name,
})
}

View File

@ -1,4 +1,4 @@
use jwst_storage::{BlobFsStorage, DBContext, DocFsStorage};
use jwst_storage::{BlobFsStorage, SqliteDBContext, DocFsStorage};
use std::path::Path;
use tauri::api::path::document_dir;
use tokio::sync::Mutex;
@ -6,7 +6,7 @@ use tokio::sync::Mutex;
pub struct AppStateRaw {
pub blob_storage: BlobFsStorage,
pub doc_storage: DocFsStorage,
pub metadata_db: DBContext,
pub metadata_db: SqliteDBContext,
}
impl AppStateRaw {
@ -27,7 +27,7 @@ impl AppStateRaw {
Some(Self {
doc_storage: DocFsStorage::new(Some(16), 500, Path::new(&doc_env).into()).await,
blob_storage: BlobFsStorage::new(Some(16), Path::new(&blob_env).into()).await,
metadata_db: DBContext::new(db_env).await,
metadata_db: SqliteDBContext::new(db_env).await,
})
}
}

View File

@ -4,12 +4,12 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct YDocumentUpdate {
pub update: Vec<u8>,
pub id: i64,
pub id: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct GetDocumentParameter {
pub id: i64,
pub id: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct GetDocumentResponse {

View File

@ -39,8 +39,7 @@
"required": ["id"],
"properties": {
"id": {
"type": "integer",
"format": "int64"
"type": "string"
}
}
},
@ -63,8 +62,7 @@
"required": ["id", "update"],
"properties": {
"id": {
"type": "integer",
"format": "int64"
"type": "string"
},
"update": {
"type": "array",

View File

@ -17,12 +17,12 @@ export type IDocumentParameters =
};
export interface YDocumentUpdate {
id: number;
id: string;
update: number[];
[k: string]: unknown;
}
export interface GetDocumentParameter {
id: number;
id: string;
[k: string]: unknown;
}
export interface GetDocumentResponse {