* WIP * Add debug * Dedupe inserts * Add deterministic ordering * Fix whitespaces * Update insta * Add integration test script * Rename * Add test * Working for non-deletes * omg it mostly works for deletes * Isdeleted fix * remove created dates * update api * Take document id * No max attempt * works * Use string uuids * . * working!!!! (hopefully) * Improve bundling * Add module * lint * . * lint * Fix CI * use toolchain * clean up * Add useSlowFileEvents * Delete fuzz * Fix CI * use docker * fix script * clean up * Clean up * change node version * Build docker image on every commit * fix ci * 1 db per vault * Add scritps folder * Bump versions * Lint * . * Fix tests for real * Style * . * try * Consistent ordering * Fix tests * hmm * . * Clean up diff * Fixes * . * Fix version bump * . * . * .
68 lines
2 KiB
Rust
68 lines
2 KiB
Rust
use chrono::{DateTime, Utc};
|
|
use schemars::JsonSchema;
|
|
use serde::Serialize;
|
|
use sync_lib::bytes_to_base64;
|
|
|
|
pub type VaultId = String;
|
|
pub type VaultUpdateId = i64;
|
|
pub type DocumentId = uuid::Uuid;
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct StoredDocumentVersion {
|
|
pub vault_update_id: VaultUpdateId,
|
|
pub document_id: DocumentId,
|
|
pub relative_path: String,
|
|
pub updated_date: DateTime<Utc>,
|
|
pub content: Vec<u8>,
|
|
pub is_deleted: bool,
|
|
}
|
|
|
|
impl PartialEq<Self> for StoredDocumentVersion {
|
|
fn eq(&self, other: &Self) -> bool { self.vault_update_id == other.vault_update_id }
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, JsonSchema)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct DocumentVersionWithoutContent {
|
|
pub vault_update_id: VaultUpdateId,
|
|
pub document_id: DocumentId,
|
|
pub relative_path: String,
|
|
pub updated_date: DateTime<Utc>,
|
|
pub is_deleted: bool,
|
|
}
|
|
|
|
impl From<StoredDocumentVersion> for DocumentVersionWithoutContent {
|
|
fn from(value: StoredDocumentVersion) -> Self {
|
|
Self {
|
|
vault_update_id: value.vault_update_id,
|
|
document_id: value.document_id,
|
|
relative_path: value.relative_path,
|
|
updated_date: value.updated_date,
|
|
is_deleted: value.is_deleted,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, JsonSchema)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct DocumentVersion {
|
|
pub vault_update_id: VaultUpdateId,
|
|
pub document_id: DocumentId,
|
|
pub relative_path: String,
|
|
pub updated_date: DateTime<Utc>,
|
|
pub content_base64: String,
|
|
pub is_deleted: bool,
|
|
}
|
|
|
|
impl From<StoredDocumentVersion> for DocumentVersion {
|
|
fn from(value: StoredDocumentVersion) -> Self {
|
|
Self {
|
|
vault_update_id: value.vault_update_id,
|
|
document_id: value.document_id,
|
|
relative_path: value.relative_path,
|
|
updated_date: value.updated_date,
|
|
content_base64: bytes_to_base64(&value.content),
|
|
is_deleted: value.is_deleted,
|
|
}
|
|
}
|
|
}
|