Skip to main content

previa_engine/
lib.rs

1mod assertions;
2mod core;
3mod execution;
4mod extractions;
5mod template;
6
7use std::collections::HashMap;
8
9use serde_json::Value;
10
11pub use core::types::{
12    AssertionResult, Pipeline, PipelineStep, RuntimeEnvGroup, RuntimeSpec, StepAssertion,
13    StepExecutionResult, StepExtraction, StepRequest, StepResponse,
14};
15pub use execution::{
16    PreparedHttpStep, StartedHttpStep, complete_started_http_step_with_hook, execute_pipeline,
17    execute_pipeline_from_step_with_client_runtime_hooks, execute_pipeline_with_client,
18    execute_pipeline_with_client_hooks, execute_pipeline_with_client_runtime_request_gate,
19    execute_pipeline_with_hooks, execute_pipeline_with_runtime_hooks,
20    execute_pipeline_with_runtime_request_gate, execute_pipeline_with_specs_hooks,
21    prepare_http_step, send_prepared_http_step, send_prepared_http_step_with_hooks,
22    start_prepared_http_step_with_hooks,
23};
24pub use extractions::{evaluate_step_extractions, validate_step_extractions};
25
26pub fn render_template_value(
27    value: &Value,
28    context: &HashMap<String, StepExecutionResult>,
29    specs: Option<&[RuntimeSpec]>,
30) -> Value {
31    template::resolve::resolve_template_variables(value, context, specs, None, None)
32}
33
34pub fn render_template_value_with_runtime(
35    value: &Value,
36    context: &HashMap<String, StepExecutionResult>,
37    specs: Option<&[RuntimeSpec]>,
38    env_groups: Option<&[RuntimeEnvGroup]>,
39    selected_env_group_slug: Option<&str>,
40) -> Value {
41    template::resolve::resolve_template_variables(
42        value,
43        context,
44        specs,
45        env_groups,
46        selected_env_group_slug,
47    )
48}
49
50pub fn render_template_value_simple(value: &Value) -> Value {
51    let context = HashMap::<String, StepExecutionResult>::new();
52    render_template_value(value, &context, None)
53}