presolve_compiler/
effect_projection.rs1use crate::RuntimeEffectRegistry;
3use serde::Serialize;
4pub const EFFECT_PROJECTION_SCHEMA_VERSION: u32 = 1;
5#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
6pub struct EffectProjectionRecordV1 {
7 pub effect: String,
8 pub execution_function: String,
9 pub browser_only: bool,
10 pub initial_trigger: bool,
11 pub action_trigger_count: usize,
12}
13#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
14pub struct EffectProjectionV1 {
15 pub schema_version: u32,
16 pub records: Vec<EffectProjectionRecordV1>,
17}
18#[must_use]
19pub fn build_effect_projection_v1(registry: &RuntimeEffectRegistry) -> EffectProjectionV1 {
20 let mut records = registry
21 .records
22 .values()
23 .map(|r| EffectProjectionRecordV1 {
24 effect: r.effect.to_string(),
25 execution_function: r.execution_function.to_string(),
26 browser_only: matches!(r.execution_boundary, crate::ExecutionBoundary::Client),
27 initial_trigger: r.initial_trigger.is_some(),
28 action_trigger_count: r.action_batch_triggers.len(),
29 })
30 .collect::<Vec<_>>();
31 records.sort_by(|a, b| a.effect.cmp(&b.effect));
32 EffectProjectionV1 {
33 schema_version: EFFECT_PROJECTION_SCHEMA_VERSION,
34 records,
35 }
36}