Skip to main content

previa_engine/
lib.rs

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