Skip to main content

domain/
lead.rs

1//! Canonical domain contracts for cross-service lead conversion triage.
2//!
3//! These types describe resort sales/intake state independent of any one
4//! service line. They promote web/phone/SMS/source facts into validated sales
5//! workflow state so follow-up labor, booking readiness, and revenue opportunities
6//! are visible without letting an agent invent availability or bypass staff review.
7
8use nutype::nutype;
9#[allow(unused_imports)]
10use serde::{Deserialize, Serialize};
11
12use crate::entities::{CustomerId, ServiceKind};
13use crate::operations;
14
15#[nutype(
16    sanitize(trim),
17    validate(not_empty, len_char_max = 160),
18    derive(
19        Debug,
20        Clone,
21        PartialEq,
22        Eq,
23        PartialOrd,
24        Ord,
25        Hash,
26        Serialize,
27        Deserialize
28    )
29)]
30/// Validated local-referral/source name for lead provenance.
31pub struct SourceName(String);
32
33#[nutype(
34    sanitize(trim),
35    validate(not_empty, len_char_max = 160),
36    derive(
37        Debug,
38        Clone,
39        PartialEq,
40        Eq,
41        PartialOrd,
42        Ord,
43        Hash,
44        Serialize,
45        Deserialize
46    )
47)]
48/// Validated campaign name used to connect lead work to marketing sources.
49pub struct CampaignName(String);
50
51#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
52/// Source-derived lead triage record for sales follow-up and booking workflows.
53pub struct Triage {
54    /// Customer id fact promoted into this lead contract.
55    pub customer_id: Option<CustomerId>,
56    /// Source fact promoted into this lead contract.
57    pub source: Source,
58    /// Intent fact promoted into this lead contract.
59    pub intent: Intent,
60    /// Stage fact promoted into this lead contract.
61    pub stage: ConversionStage,
62    /// Requested service fact promoted into this lead contract.
63    pub requested_service: Option<ServiceKind>,
64    /// Next action fact promoted into this lead contract.
65    pub next_action: NextAction,
66}
67
68#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
69/// Domain vocabulary for source decisions in lead workflows.
70pub enum Source {
71    /// Website form sales lead state, source, or follow-up signal.
72    WebsiteForm,
73    /// Phone sales lead state, source, or follow-up signal.
74    Phone,
75    /// Sms sales lead state, source, or follow-up signal.
76    Sms,
77    /// Email sales lead state, source, or follow-up signal.
78    Email,
79    /// Social media sales lead state, source, or follow-up signal.
80    SocialMedia,
81    /// Source name fact promoted into this lead contract.
82    LocalReferral {
83        /// Source name carried by this variant.
84        source_name: SourceName,
85    },
86    /// Contact or display name used by staff.
87    Campaign {
88        /// Name carried by this variant.
89        name: CampaignName,
90    },
91}
92
93#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
94/// Domain vocabulary for intent decisions in lead workflows.
95pub enum Intent {
96    /// New customer intake sales lead state, source, or follow-up signal.
97    NewCustomerIntake,
98    /// Boarding quote sales lead state, source, or follow-up signal.
99    BoardingQuote,
100    /// Daycare trial sales lead state, source, or follow-up signal.
101    DaycareTrial,
102    /// Grooming appointment sales lead state, source, or follow-up signal.
103    GroomingAppointment,
104    /// Training consult sales lead state, source, or follow-up signal.
105    TrainingConsult,
106    /// Existing customer change sales lead state, source, or follow-up signal.
107    ExistingCustomerChange,
108    /// Provider role or status could not be mapped confidently.
109    Unknown,
110}
111
112#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
113/// Domain vocabulary for conversion stage decisions in lead workflows.
114pub enum ConversionStage {
115    /// New sales lead state, source, or follow-up signal.
116    New,
117    /// Contact attempted sales lead state, source, or follow-up signal.
118    ContactAttempted,
119    /// Waiting on customer sales lead state, source, or follow-up signal.
120    WaitingOnCustomer,
121    /// Missing requirements sales lead state, source, or follow-up signal.
122    MissingRequirements,
123    /// Ready to book sales lead state, source, or follow-up signal.
124    ReadyToBook,
125    /// Converted sales lead state, source, or follow-up signal.
126    Converted,
127    /// Lost sales lead state, source, or follow-up signal.
128    Lost,
129}
130
131#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
132/// Human-safe next step for converting a lead without overpromising capacity or policy.
133pub enum NextAction {
134    /// Draft reply sales lead state, source, or follow-up signal.
135    DraftReply,
136    /// Request missing pet profile sales lead state, source, or follow-up signal.
137    RequestMissingPetProfile,
138    /// Request vaccine proof sales lead state, source, or follow-up signal.
139    RequestVaccineProof,
140    /// Offer reservation times sales lead state, source, or follow-up signal.
141    OfferReservationTimes,
142    /// Route to human sales lead state, source, or follow-up signal.
143    RouteToHuman {
144        /// Business reason staff should review before proceeding.
145        reason: operations::operational::Observation,
146    },
147    /// No action sales lead state, source, or follow-up signal.
148    NoAction,
149}