merge branches and cleanup db

This commit is contained in:
timurgordon
2025-06-27 12:11:04 +03:00
parent 5563d7e27e
commit 1f9ec01934
177 changed files with 1202 additions and 174 deletions

View File

@@ -0,0 +1,60 @@
# Flow Model
The `flow` model provides a framework for creating and managing multi-step workflows, particularly those requiring digital signatures. It is designed to orchestrate a sequence of actions that must be completed in a specific order.
## Core Components
### 1. `Flow`
The top-level container for a workflow.
- `flow_uuid`: A unique identifier for the entire flow, used for external references.
- `name`: A human-readable name for the flow (e.g., "Document Approval Process").
- `status`: The overall status of the flow (e.g., "Pending", "InProgress", "Completed").
- `steps`: A `Vec<FlowStep>` that defines the sequence of steps in the workflow.
### 2. `FlowStep`
Represents a single, distinct step within a `Flow`.
- `step_order`: A `u32` that determines the position of this step in the sequence.
- `description`: An optional text description of what this step entails.
- `status`: The status of this individual step.
### 3. `SignatureRequirement`
Defines a requirement for a digital signature within a `FlowStep`. A single step can have multiple signature requirements.
- `flow_step_id`: A foreign key linking the requirement to its parent `FlowStep`.
- `public_key`: The public key of the entity that is required to sign.
- `message`: The plaintext message that needs to be signed.
- `signature`: The resulting signature, once provided.
- `status`: The status of the signature requirement (e.g., "Pending", "Signed", "Failed").
## Usage
The models use a builder pattern to construct complex flows. You create a `Flow`, add `FlowStep`s to it, and associate `SignatureRequirement`s with each step.
```rust
use heromodels::models::flow::{Flow, FlowStep, SignatureRequirement};
use uuid::Uuid;
// 1. Define a signature requirement
let requirement = SignatureRequirement::new(
0, // ID is managed by the database
1, // Belongs to flow step 1
"0xPublicKey1...",
"I approve this document."
);
// 2. Create a flow step
// In a real application, you would add the signature requirement to the step.
let step1 = FlowStep::new(0, 1) // ID, step_order
.description("Initial review and approval");
// 3. Create the main flow and add the step
let flow = Flow::new(Uuid::new_v4().to_string())
.name("Contract Signing Flow")
.add_step(step1);
```

View File

@@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
#[model]
pub struct Flow {
/// Base model data (id, created_at, updated_at).
#[rhai_type(skip)]
#[rhai_type(skip)]
pub base_data: BaseModelData,
/// A unique UUID for the flow, for external reference.

View File

@@ -9,7 +9,7 @@ use std::default::Default;
#[model]
pub struct FlowStep {
/// Base model data.
#[rhai_type(skip)]
#[rhai_type(skip)]
pub base_data: BaseModelData,
/// Optional description for the step.

View File

@@ -6,4 +6,4 @@ pub mod signature_requirement;
// Re-export key types for convenience
pub use flow::Flow;
pub use flow_step::FlowStep;
pub use signature_requirement::SignatureRequirement;
pub use signature_requirement::SignatureRequirement;

View File

@@ -9,7 +9,7 @@ use std::default::Default;
#[model]
pub struct SignatureRequirement {
/// Base model data.
#[rhai_type(skip)]
#[rhai_type(skip)]
pub base_data: BaseModelData,
/// Foreign key to the FlowStep this requirement belongs to.