dex_sdk/flow_info.rs
1// Copyright (c) 2026 Super Durable, Inc.
2//
3// Licensed under the Super Durable Source License 1.0.
4// You may not use this file except in compliance with the License.
5// See the LICENSE file in the repository root.
6//
7// SPDX-License-Identifier: LicenseRef-Super-Durable-1.0
8
9use std::collections::BTreeMap;
10use std::time::SystemTime;
11
12#[derive(Clone, Copy, Debug, Eq, PartialEq)]
13/// Describes the current or terminal state of a Flow run.
14pub enum FlowStatus {
15 /// The Flow can still execute Steps or receive RPCs and Channel messages.
16 Running,
17 /// The Flow completed successfully.
18 Completed,
19 /// The Flow ended because a Step, RPC, or user-code failure was not recovered.
20 Failed,
21 /// The Flow exceeded its configured timeout.
22 TimedOut,
23 /// An operator terminated the Flow immediately.
24 Terminated,
25 /// The Flow completed cooperative cancellation.
26 Canceled,
27 /// The run rolled its history into a successor run.
28 ContinuedAsNew,
29}
30
31#[derive(Clone, Copy, Debug, Eq, PartialEq)]
32/// Categorizes the failure recorded for an uncompleted Flow.
33pub enum FlowErrorType {
34 /// A Step returned an invalid or failing decision.
35 StepDecisionFailed,
36 /// A client API operation failed the Flow.
37 ClientApiFailed,
38 /// A Worker Step or RPC handler failed.
39 WorkerApiFailed,
40 /// The registered Flow or Step definition violated an SDK contract.
41 InvalidUserFlowCode,
42 /// Dex encountered an internal failure.
43 Internal,
44}
45
46#[derive(Clone, Debug, Eq, PartialEq)]
47/// Summarizes one Flow run returned by [`crate::Client::describe_flow`].
48pub struct FlowInfo {
49 /// Application-assigned Flow ID.
50 pub flow_id: String,
51 /// Server-assigned run ID for the described execution.
52 pub run_id: String,
53 /// Registered Flow type name.
54 pub flow_type: String,
55 /// Current or terminal status.
56 pub status: FlowStatus,
57 /// Server-recorded start time.
58 pub started_at: SystemTime,
59}
60
61#[derive(Clone, Debug, PartialEq)]
62/// Contains one Flow row returned by a search query.
63pub struct SearchFlowEntry {
64 /// Application-assigned Flow ID.
65 pub flow_id: String,
66 /// Server-assigned run ID.
67 pub run_id: String,
68 /// Registered Flow type name.
69 pub flow_type: String,
70 /// Status captured by the search index.
71 pub status: FlowStatus,
72 /// Indexed start time, or `None` when unavailable.
73 pub started_at: Option<SystemTime>,
74 /// Indexed close time, or `None` while open or unavailable.
75 pub closed_at: Option<SystemTime>,
76 /// Values keyed by their physical Indexed Attribute names.
77 pub indexed_attributes: BTreeMap<String, serde_json::Value>,
78}
79
80#[derive(Clone, Debug, PartialEq)]
81/// Contains one page of [`crate::Client::search_flows`] results.
82pub struct SearchFlowsPage {
83 /// Flow rows in server-defined query order.
84 pub flows: Vec<SearchFlowEntry>,
85 /// Opaque token for [`crate::Client::search_flows_page`], or empty on the last page.
86 pub next_page_token: String,
87}