Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
pub mod domain;
mod pgsql;
mod storage;
use chrono::{DateTime, Utc};
use macro_uuid::generate_uuid_v7;
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
use uuid::Uuid;
pub use pgsql::PgViewStorage;
pub use storage::{ExcludedDefaultViewStorage, ViewPatch};
#[derive(Clone, Serialize, Deserialize, Debug, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct View {
pub id: Uuid,
pub user_id: String,
pub name: String,
/// It is an explicit choice that the structure of the view configuration
/// is up to the frontend. The structure and composition of view configuration
/// is still very much in flux.
pub config: serde_json::Value,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
/// Optimistic-write revision, omitted from legacy REST responses.
#[serde(skip)]
#[schema(ignore)]
pub revision: i64,
/// Requested share; effective visibility is determined by the service.
#[serde(skip)]
#[schema(ignore)]
pub shared_team_id: Option<Uuid>,
}
impl View {
pub fn new(user_id: String, name: String, config: serde_json::Value) -> Self {
let now = Utc::now();
Self {
id: generate_uuid_v7(),
user_id,
name,
config,
created_at: now,
updated_at: now,
revision: 1,
shared_team_id: None,
}
}
}
/// Frontend can define any set of its own default views for the user.
/// This is a list of views that are excluded from the default views list on the frontend.
///
/// It is important that the frontend can quickly iterate on default views, for that reason
/// we don't keep track of default views in the database, only those that are explicitly excluded.
#[derive(Clone, Serialize, Deserialize, Debug, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct ExcludedDefaultView {
id: Uuid,
pub user_id: String,
pub default_view_id: String,
}
impl ExcludedDefaultView {
pub fn new(user_id: String, default_view_id: String) -> Self {
Self {
id: generate_uuid_v7(),
user_id,
default_view_id,
}
}
}