Add API for propagating cursor locations #61
3 changed files with 16 additions and 1 deletions
Serialize Rust types to TS
commit
2cdf2ba74e
|
|
@ -30,13 +30,17 @@ impl PartialEq<Self> for StoredDocumentVersion {
|
||||||
#[derive(TS, Debug, Clone, Serialize, JsonSchema)]
|
#[derive(TS, Debug, Clone, Serialize, JsonSchema)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct DocumentVersionWithoutContent {
|
pub struct DocumentVersionWithoutContent {
|
||||||
|
#[ts(as = "i32")]
|
||||||
pub vault_update_id: VaultUpdateId,
|
pub vault_update_id: VaultUpdateId,
|
||||||
|
|
||||||
pub document_id: DocumentId,
|
pub document_id: DocumentId,
|
||||||
pub relative_path: String,
|
pub relative_path: String,
|
||||||
pub updated_date: DateTime<Utc>,
|
pub updated_date: DateTime<Utc>,
|
||||||
pub is_deleted: bool,
|
pub is_deleted: bool,
|
||||||
pub user_id: UserId,
|
pub user_id: UserId,
|
||||||
pub device_id: DeviceId,
|
pub device_id: DeviceId,
|
||||||
|
|
||||||
|
#[ts(as = "i32")]
|
||||||
pub content_size: u64,
|
pub content_size: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ use crate::app_state::database::models::{DeviceId, DocumentVersionWithoutContent
|
||||||
pub struct WebSocketHandshake {
|
pub struct WebSocketHandshake {
|
||||||
pub token: String,
|
pub token: String,
|
||||||
pub device_id: DeviceId,
|
pub device_id: DeviceId,
|
||||||
|
|
||||||
|
#[ts(as = "Option<i32>")]
|
||||||
pub last_seen_vault_update_id: Option<VaultUpdateId>,
|
pub last_seen_vault_update_id: Option<VaultUpdateId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -40,6 +42,7 @@ pub struct WebSocketVaultUpdate {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(TS, Deserialize, Clone, Debug)]
|
#[derive(TS, Deserialize, Clone, Debug)]
|
||||||
|
#[serde(rename_all = "camelCase", tag = "type")]
|
||||||
#[ts(export)]
|
#[ts(export)]
|
||||||
pub enum WebSocketClientMessage {
|
pub enum WebSocketClientMessage {
|
||||||
Handshake(WebSocketHandshake),
|
Handshake(WebSocketHandshake),
|
||||||
|
|
@ -47,6 +50,7 @@ pub enum WebSocketClientMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(TS, Serialize, Clone, Debug)]
|
#[derive(TS, Serialize, Clone, Debug)]
|
||||||
|
#[serde(rename_all = "camelCase", tag = "type")]
|
||||||
#[ts(export)]
|
#[ts(export)]
|
||||||
pub enum WebSocketServerMessage {
|
pub enum WebSocketServerMessage {
|
||||||
VaultUpdate(WebSocketVaultUpdate),
|
VaultUpdate(WebSocketVaultUpdate),
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,12 @@ set -e
|
||||||
|
|
||||||
./scripts/utils/wait-for-server.sh
|
./scripts/utils/wait-for-server.sh
|
||||||
|
|
||||||
|
rm -rf backend/sync_server/bindings
|
||||||
|
cd backend
|
||||||
|
cargo test export_bindings
|
||||||
|
cd -
|
||||||
|
|
||||||
|
cp -r backend/sync_server/bindings/* frontend/sync-client/src/services/types/
|
||||||
|
|
||||||
npm install -g openapi-typescript
|
npm install -g openapi-typescript
|
||||||
openapi-typescript http://localhost:3000/api.json --output frontend/sync-client/src/services/types.ts
|
openapi-typescript http://localhost:3000/api.json --output frontend/sync-client/src/services/types/http-api.ts
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue