Skip to main content

mur_common/
sync_types.rs

1//! Typed DTOs for cloud sync API (Go server).
2//!
3//! These replace the previous stringly-typed /api/sync/pull, /api/sync/push
4//! endpoints with the current team-scoped, integer-versioned API.
5
6use serde::{Deserialize, Serialize};
7
8/// Response from GET /api/v1/core/teams/{id}/sync/pull?since={v}
9#[derive(Debug, Deserialize)]
10pub struct SyncPullResponse {
11    pub patterns: Vec<RemotePattern>,
12    pub version: i64,
13}
14
15/// A single remote pattern in a pull response.
16#[derive(Debug, Deserialize)]
17pub struct RemotePattern {
18    pub id: String,
19    pub name: String,
20    pub content: String,
21    pub version: i64,
22    #[serde(default)]
23    pub deleted: bool,
24}
25
26/// Request body for POST /api/v1/core/teams/{id}/sync/push
27#[derive(Debug, Serialize)]
28pub struct SyncPushRequest {
29    pub base_version: i64,
30    pub changes: Vec<PatternChange>,
31    #[serde(default)]
32    pub force_local: bool,
33}
34
35/// A single change in a push request.
36#[derive(Debug, Serialize)]
37pub struct PatternChange {
38    pub action: String,
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub id: Option<String>,
41    #[serde(skip_serializing_if = "Option::is_none")]
42    pub pattern: Option<PatternPayload>,
43}
44
45#[derive(Debug, Serialize)]
46pub struct PatternPayload {
47    pub name: String,
48    pub content: String,
49}
50
51/// Response from POST /api/v1/core/teams/{id}/sync/push
52#[derive(Debug, Deserialize)]
53pub struct SyncPushResponse {
54    pub ok: bool,
55    #[serde(default)]
56    pub version: Option<i64>,
57    #[serde(default)]
58    pub conflict: Option<bool>,
59}
60
61/// Response from GET /api/v1/workflows
62#[derive(Debug, Deserialize)]
63pub struct WorkflowListResponse {
64    pub data: Vec<serde_json::Value>,
65}