Skip to main content

pharos_native/runtime/
business.rs

1use serde_json::{Map, Value};
2use sha2::{Digest, Sha256};
3use std::env;
4use std::fs;
5use std::path::Path;
6
7use crate::config::AppRuntime;
8
9use super::generated;
10use super::json_commands::request_booking_options_json_from_form;
11
12/// Renders the technician fragment through the app-owned template adapter.
13pub fn maybe_write_technician_hx_booking_local(
14    root: &Value,
15    business_slug: &str,
16    app_root: &Path,
17) -> Option<String> {
18    dynamic_business_admin_technician_rows_html_from_root(root, business_slug, app_root)
19}
20
21/// Renders the technician management fragment through the app-owned template adapter.
22pub fn maybe_write_technician_hx_response_management_local(
23    root: &Value,
24    business_slug: &str,
25    app_root: &Path,
26) -> Option<String> {
27    dynamic_business_admin_technician_rows_html_from_root(root, business_slug, app_root)
28}
29
30pub use pharos_runtime_business::*;
31
32/// Converts booking-option fields from an URL-encoded or multipart form.
33///
34/// # Parameters
35///
36/// - `content_type`: Input consumed by [`crate::runtime::business::dynamic_booking_options_json_from_form`].
37/// - `form_body`: Input consumed by [`crate::runtime::business::dynamic_booking_options_json_from_form`].
38/// - `body_path`: Input consumed by [`crate::runtime::business::dynamic_booking_options_json_from_form`].
39///
40/// # Returns
41///
42/// Returns [`Some`] when [`crate::runtime::business::dynamic_booking_options_json_from_form`] can produce a value and [`None`] otherwise.
43///
44/// # Examples
45///
46/// ```rust,ignore
47/// let _result = pharos_native::runtime::business::dynamic_booking_options_json_from_form(todo!(), "name=value", todo!());
48/// ```
49///
50/// # Related
51///
52/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
53pub fn dynamic_booking_options_json_from_form(
54    content_type: Option<&str>,
55    form_body: Option<&str>,
56    body_path: Option<&Path>,
57) -> Option<String> {
58    if form_body.is_some_and(|body| body.len() > MAX_INPUT_BYTES)
59        || body_path.is_some_and(|path| {
60            path.metadata()
61                .map(|metadata| metadata.len() > MAX_INPUT_BYTES as u64)
62                .unwrap_or(false)
63        })
64    {
65        return None;
66    }
67    request_booking_options_json_from_form(content_type, form_body, body_path)
68        .and_then(|text| (text.len() <= MAX_JSON_BYTES).then_some(text))
69}
70
71/// Appends one validated adapter delivery to an in-memory state root and returns.
72///
73/// # Parameters
74///
75/// - `root`: Input consumed by [`crate::runtime::business::dynamic_integrations_deliver_report_json`].
76/// - `integrations_root`: Input consumed by [`crate::runtime::business::dynamic_integrations_deliver_report_json`].
77/// - `adapter_id`: Input consumed by [`crate::runtime::business::dynamic_integrations_deliver_report_json`].
78/// - `event_kind`: Input consumed by [`crate::runtime::business::dynamic_integrations_deliver_report_json`].
79/// - `resource_id`: Input consumed by [`crate::runtime::business::dynamic_integrations_deliver_report_json`].
80/// - `tenant_id`: Input consumed by [`crate::runtime::business::dynamic_integrations_deliver_report_json`].
81/// - `subject_id`: Input consumed by [`crate::runtime::business::dynamic_integrations_deliver_report_json`].
82/// - `payload_json`: Input consumed by [`crate::runtime::business::dynamic_integrations_deliver_report_json`].
83///
84/// # Returns
85///
86/// Returns [`Some`] when [`crate::runtime::business::dynamic_integrations_deliver_report_json`] can produce a value and [`None`] otherwise.
87///
88/// # Examples
89///
90/// ```rust,ignore
91/// let _result = pharos_native::runtime::business::dynamic_integrations_deliver_report_json(std::path::Path::new("."), todo!(), todo!(), todo!(), todo!(), todo!(), todo!(), todo!());
92/// ```
93///
94/// # Related
95///
96/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
97pub fn dynamic_integrations_deliver_report_json(
98    root: &mut Value,
99    integrations_root: &Value,
100    adapter_id: &str,
101    event_kind: Option<&str>,
102    resource_id: Option<&str>,
103    tenant_id: Option<&str>,
104    subject_id: Option<&str>,
105    payload_json: &str,
106) -> Option<String> {
107    if adapter_id.is_empty() || payload_json.len() > MAX_INPUT_BYTES {
108        return None;
109    }
110    let delivery_id = super::dynamic::deliver_integration_webhook(
111        root,
112        integrations_root,
113        adapter_id,
114        event_kind,
115        resource_id,
116        tenant_id,
117        subject_id,
118        payload_json,
119    )?;
120    integrations_report_json(
121        root,
122        delivery_id,
123        Some(serde_json::json!({
124            "queued_delivery_count": 1,
125            "delivered_webhook_count": 0,
126            "retryable_webhook_count": 0,
127            "failed_webhook_count": 0,
128            "retried_delivery_count": 0,
129        })),
130    )
131}
132
133/// Reads one form field from an encoded body or a bounded request-body file.
134///
135/// # Parameters
136///
137/// - `content_type`: Input consumed by [`crate::runtime::business::request_form_field_value_business_logic_local`].
138/// - `form_body`: Input consumed by [`crate::runtime::business::request_form_field_value_business_logic_local`].
139/// - `body_path`: Input consumed by [`crate::runtime::business::request_form_field_value_business_logic_local`].
140/// - `field_name`: Input consumed by [`crate::runtime::business::request_form_field_value_business_logic_local`].
141///
142/// # Returns
143///
144/// Returns [`Some`] when [`crate::runtime::business::request_form_field_value_business_logic_local`] can produce a value and [`None`] otherwise.
145///
146/// # Examples
147///
148/// ```rust,ignore
149/// let _result = pharos_native::runtime::business::request_form_field_value_business_logic_local(todo!(), "name=value", todo!(), todo!());
150/// ```
151///
152/// # Related
153///
154/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
155pub fn request_form_field_value_business_logic_local(
156    content_type: Option<&str>,
157    form_body: Option<&str>,
158    body_path: Option<&Path>,
159    field_name: &str,
160) -> Option<String> {
161    super::json_commands::request_form_field_value(content_type, form_body, body_path, field_name)
162}
163
164/// Appends a calendar synchronization job to a mutable job list.
165///
166/// # Parameters
167///
168/// - `jobs`: Input consumed by [`crate::runtime::business::append_google_calendar_sync_jobs_logic_local`].
169/// - `payload`: Input consumed by [`crate::runtime::business::append_google_calendar_sync_jobs_logic_local`].
170///
171/// # Returns
172///
173/// Returns `true` when the condition checked by [`crate::runtime::business::append_google_calendar_sync_jobs_logic_local`] holds and `false` otherwise.
174///
175/// # Examples
176///
177/// ```rust,ignore
178/// let _result = pharos_native::runtime::business::append_google_calendar_sync_jobs_logic_local(todo!(), todo!());
179/// ```
180///
181/// # Related
182///
183/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
184pub fn append_google_calendar_sync_jobs_logic_local(jobs: &mut Value, payload: Value) -> bool {
185    super::json_commands::generated_surface_append_audit_event_mut(jobs, payload)
186}
187
188/// Appends an audit record to a mutable job execution.
189///
190/// # Parameters
191///
192/// - `row`: Input consumed by [`crate::runtime::business::append_job_audit_logic_local`].
193/// - `audit`: Input consumed by [`crate::runtime::business::append_job_audit_logic_local`].
194///
195/// # Returns
196///
197/// Returns `true` when the condition checked by [`crate::runtime::business::append_job_audit_logic_local`] holds and `false` otherwise.
198///
199/// # Examples
200///
201/// ```rust,ignore
202/// let _result = pharos_native::runtime::business::append_job_audit_logic_local(todo!(), todo!());
203/// ```
204///
205/// # Related
206///
207/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
208pub fn append_job_audit_logic_local(row: &mut Value, audit: Value) -> bool {
209    super::json_commands::generated_surface_append_audit_event_mut(row, audit)
210}
211
212/// Performs appointment maintenance result HTML.
213///
214/// # Parameters
215///
216/// - `app_root`: Input consumed by [`crate::runtime::business::appointment_maintenance_result_html`].
217/// - `results`: Input consumed by [`crate::runtime::business::appointment_maintenance_result_html`].
218///
219/// # Returns
220///
221/// Returns [`Some`] when [`crate::runtime::business::appointment_maintenance_result_html`] can produce a value and [`None`] otherwise.
222///
223/// # Performance
224///
225/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::business::appointment_maintenance_result_html`].
226///
227/// # Examples
228///
229/// ```rust,ignore
230/// let _result = pharos_native::runtime::business::appointment_maintenance_result_html(std::path::Path::new("apps/dev_docs"), todo!());
231/// ```
232///
233/// # Related
234///
235/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
236pub fn appointment_maintenance_result_html(app_root: &Path, results: &[String]) -> Option<String> {
237    let mut html = String::new();
238    for line in results {
239        html.push_str(
240            &super::generated::render_generated_admin_fragment_from_value_runtime(
241                app_root,
242                "templates/appointments/fragments/maintenance_result_line.html",
243                &serde_json::Map::from_iter([(
244                    "message".to_owned(),
245                    Value::String(line.to_owned()),
246                )]),
247            )?,
248        );
249    }
250    Some(html)
251}
252
253/// Writes the refreshed business-availability fragment for an HTMX caller.
254///
255/// # Parameters
256///
257/// - `root`: Input consumed by [`crate::runtime::business::maybe_write_business_availability_hx_booking_local`].
258/// - `business_slug`: Input consumed by [`crate::runtime::business::maybe_write_business_availability_hx_booking_local`].
259/// - `app_root`: Input consumed by [`crate::runtime::business::maybe_write_business_availability_hx_booking_local`].
260///
261/// # Returns
262///
263/// Returns [`Some`] when [`crate::runtime::business::maybe_write_business_availability_hx_booking_local`] can produce a value and [`None`] otherwise.
264///
265/// # Examples
266///
267/// ```rust,ignore
268/// let _result = pharos_native::runtime::business::maybe_write_business_availability_hx_booking_local(std::path::Path::new("."), "demo", std::path::Path::new("apps/dev_docs"));
269/// ```
270///
271/// # Related
272///
273/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
274pub fn maybe_write_business_availability_hx_booking_local(
275    root: &Value,
276    business_slug: &str,
277    app_root: &Path,
278) -> Option<String> {
279    super::json_commands::dynamic_render_business_admin_availability_rows_html(
280        root,
281        business_slug,
282        app_root,
283    )
284}
285
286/// Writes the refreshed public-state button fragment for an HTMX caller.
287///
288/// # Parameters
289///
290/// - `_root`: Input consumed by [`crate::runtime::business::maybe_write_public_toggle_hx_response_identity_local`].
291/// - `business_slug`: Input consumed by [`crate::runtime::business::maybe_write_public_toggle_hx_response_identity_local`].
292/// - `is_public`: Input consumed by [`crate::runtime::business::maybe_write_public_toggle_hx_response_identity_local`].
293/// - `app_root`: Input consumed by [`crate::runtime::business::maybe_write_public_toggle_hx_response_identity_local`].
294///
295/// # Returns
296///
297/// Returns [`Some`] when [`crate::runtime::business::maybe_write_public_toggle_hx_response_identity_local`] can produce a value and [`None`] otherwise.
298///
299/// # Examples
300///
301/// ```rust,ignore
302/// let _result = pharos_native::runtime::business::maybe_write_public_toggle_hx_response_identity_local(todo!(), "demo", todo!(), std::path::Path::new("apps/dev_docs"));
303/// ```
304///
305/// # Related
306///
307/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
308pub fn maybe_write_public_toggle_hx_response_identity_local(
309    _root: &Value,
310    business_slug: &str,
311    is_public: bool,
312    app_root: &Path,
313) -> Option<String> {
314    super::json_commands::dynamic_render_business_admin_public_state_button_html(
315        app_root,
316        business_slug,
317        is_public,
318    )
319}
320
321/// Updates or removes a service image URL without accepting unsafe disk paths.
322///
323/// # Parameters
324///
325/// - `service`: Input consumed by [`crate::runtime::business::update_service_image_management_local`].
326/// - `remove_image`: Input consumed by [`crate::runtime::business::update_service_image_management_local`].
327/// - `uploaded_media_url`: Input consumed by [`crate::runtime::business::update_service_image_management_local`].
328/// - `artifact_dir`: Input consumed by [`crate::runtime::business::update_service_image_management_local`].
329///
330/// # Returns
331///
332/// Returns `true` when the condition checked by [`crate::runtime::business::update_service_image_management_local`] holds and `false` otherwise.
333///
334/// # Examples
335///
336/// ```rust,ignore
337/// let _result = pharos_native::runtime::business::update_service_image_management_local(todo!(), todo!(), todo!(), std::path::Path::new("build/dev_docs"));
338/// ```
339///
340/// # Related
341///
342/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
343pub fn update_service_image_management_local(
344    service: &mut Value,
345    remove_image: &str,
346    uploaded_media_url: Option<&str>,
347    artifact_dir: Option<&Path>,
348) -> bool {
349    let Some(object) = service.as_object() else {
350        return false;
351    };
352    let existing = object
353        .get("image_url")
354        .and_then(Value::as_str)
355        .unwrap_or_default()
356        .to_owned();
357    if (truthy_form_value_management_local(remove_image)
358        || uploaded_media_url.is_some_and(|value| value.starts_with("/media/businesses/")))
359        && let Some(artifact_dir) = artifact_dir
360    {
361        let _ =
362            super::json_commands::dynamic_remove_business_media_url_file(artifact_dir, &existing);
363    }
364    update_service_image_state(service, remove_image, uploaded_media_url)
365}
366
367fn render_technician_card_input(
368    app_root: &Path,
369    id: &str,
370    name: &str,
371    label: &str,
372    input_type: &str,
373    class_name: &str,
374    value: &str,
375    attributes_html: &str,
376) -> Option<String> {
377    generated::render_generated_admin_fragment_from_value_runtime(
378        app_root,
379        "templates/shared/fragments/ui_input.html",
380        &Map::from_iter([
381            ("id".to_owned(), Value::String(id.to_owned())),
382            (
383                "input_type".to_owned(),
384                Value::String(input_type.to_owned()),
385            ),
386            ("name".to_owned(), Value::String(name.to_owned())),
387            ("label".to_owned(), Value::String(label.to_owned())),
388            (
389                "label_class".to_owned(),
390                Value::String("sr-only".to_owned()),
391            ),
392            (
393                "class_name".to_owned(),
394                Value::String(class_name.to_owned()),
395            ),
396            ("value".to_owned(), Value::String(value.to_owned())),
397            (
398                "attributes_html".to_owned(),
399                Value::String(attributes_html.to_owned()),
400            ),
401            ("help_html".to_owned(), Value::String(String::new())),
402        ]),
403    )
404}
405
406/// Renders one technician card button from the app-owned UI fragment contract.
407fn render_technician_card_button(
408    app_root: &Path,
409    id: &str,
410    button_type: &str,
411    class_name: &str,
412    attributes_html: &str,
413    content_fragment: &str,
414) -> Option<String> {
415    let content_html = generated::render_generated_admin_fragment_from_value_runtime(
416        app_root,
417        content_fragment,
418        &Map::new(),
419    )?;
420    generated::render_generated_admin_fragment_from_value_runtime(
421        app_root,
422        "templates/shared/fragments/ui_button.html",
423        &Map::from_iter([
424            ("id".to_owned(), Value::String(id.to_owned())),
425            (
426                "button_type".to_owned(),
427                Value::String(button_type.to_owned()),
428            ),
429            (
430                "class_name".to_owned(),
431                Value::String(class_name.to_owned()),
432            ),
433            (
434                "attributes_html".to_owned(),
435                Value::String(attributes_html.to_owned()),
436            ),
437            ("content_html".to_owned(), Value::String(content_html)),
438        ]),
439    )
440}
441
442/// Renders one technician availability day selector from app-owned fragments.
443fn render_technician_card_day_select(
444    app_root: &Path,
445    id: &str,
446    selected_day: &str,
447) -> Option<String> {
448    let mut options_html = String::new();
449    for day in [
450        "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Weekdays", "Weekends",
451    ] {
452        options_html.push_str(
453            &generated::render_generated_admin_fragment_from_value_runtime(
454                app_root,
455                "templates/shared/fragments/select_option.html",
456                &Map::from_iter([
457                    ("option_value".to_owned(), Value::String(day.to_owned())),
458                    ("option_label".to_owned(), Value::String(day.to_owned())),
459                    (
460                        "selected_attr".to_owned(),
461                        Value::String(
462                            if day == selected_day { " selected" } else { "" }.to_owned(),
463                        ),
464                    ),
465                ]),
466            )?,
467        );
468    }
469    generated::render_generated_admin_fragment_from_value_runtime(
470        app_root,
471        "templates/shared/fragments/ui_select.html",
472        &Map::from_iter([
473            ("id".to_owned(), Value::String(id.to_owned())),
474            ("name".to_owned(), Value::String("day_of_week".to_owned())),
475            ("label".to_owned(), Value::String("Day".to_owned())),
476            ("label_class".to_owned(), Value::String("sr-only".to_owned())),
477            ("class_name".to_owned(), Value::String("form-control form-control-compact availability-inline-input business-admin-technician-day-input".to_owned())),
478            ("attributes_html".to_owned(), Value::String(" autocomplete=\"false\" aria-label=\"Day\"".to_owned())),
479            ("options_html".to_owned(), Value::String(options_html)),
480            ("help_html".to_owned(), Value::String(String::new())),
481        ]),
482    )
483}
484
485/// Builds technician cards for an already-loaded business state root.
486///
487/// # Parameters
488///
489/// - `root`: Input consumed by [`crate::runtime::business::dynamic_business_admin_technician_rows_html_from_root`].
490/// - `business_slug`: Input consumed by [`crate::runtime::business::dynamic_business_admin_technician_rows_html_from_root`].
491/// - `app_root`: Input consumed by [`crate::runtime::business::dynamic_business_admin_technician_rows_html_from_root`].
492///
493/// # Returns
494///
495/// Returns [`Some`] when [`crate::runtime::business::dynamic_business_admin_technician_rows_html_from_root`] can produce a value and [`None`] otherwise.
496///
497/// # Performance
498///
499/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::business::dynamic_business_admin_technician_rows_html_from_root`].
500///
501/// # Examples
502///
503/// ```rust,ignore
504/// let _result = pharos_native::runtime::business::dynamic_business_admin_technician_rows_html_from_root(std::path::Path::new("."), "demo", std::path::Path::new("apps/dev_docs"));
505/// ```
506///
507/// # Related
508///
509/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
510pub fn dynamic_business_admin_technician_rows_html_from_root(
511    root: &Value,
512    business_slug: &str,
513    app_root: &Path,
514) -> Option<String> {
515    let business_id =
516        dynamic_find_business_by_slug(root, business_slug).map(|row| row_i64(row, "id"))?;
517    let mut output = String::new();
518    for technician in state_rows(root, "technicians")
519        .iter()
520        .filter(|row| row_i64(row, "business_id") == business_id)
521        .take(MAX_OUTPUT_ROWS)
522    {
523        let technician_id = row_i64(technician, "id");
524        let availability_rows = state_rows(root, "technician_availability")
525            .iter()
526            .filter(|row| row_i64(row, "technician_id") == technician_id)
527            .collect::<Vec<_>>();
528        let mut availability = String::new();
529        for row in &availability_rows {
530            let availability_id = row_i64(row, "id");
531            let day_of_week = value_text(row.get("day_of_week"));
532            let start_time = value_text(row.get("start_time"));
533            let end_time = value_text(row.get("end_time"));
534            let day_select_html = render_technician_card_day_select(
535                app_root,
536                &format!("technician-entry-day-{availability_id}"),
537                &day_of_week,
538            )?;
539            let start_input_html = render_technician_card_input(
540                app_root,
541                &format!("technician-entry-start-{availability_id}"),
542                "start_time",
543                "Start time",
544                "time",
545                "form-control form-control-compact availability-inline-input form-control-time",
546                &start_time,
547                " autocomplete=\"section-technician time\" aria-label=\"Start time\"",
548            )?;
549            let end_input_html = render_technician_card_input(
550                app_root,
551                &format!("technician-entry-end-{availability_id}"),
552                "end_time",
553                "End time",
554                "time",
555                "form-control form-control-compact availability-inline-input form-control-time",
556                &end_time,
557                " autocomplete=\"section-technician time\" aria-label=\"End time\"",
558            )?;
559            let save_button_html = render_technician_card_button(
560                app_root,
561                "technician_availability_save_button",
562                "button",
563                "btn btn-success btn-icon btn-icon-sm business-admin-save-button",
564                &format!(
565                    " title=\"Save Technician Availability\" aria-label=\"Save Technician Availability\" hx-post=\"/businesses/{business_slug}/technicians/{technician_id}/availability/{availability_id}/edit/\" hx-include=\"closest form\" hx-target=\"#business-technician-rows\" hx-swap=\"innerHTML\""
566                ),
567                "templates/shared/fragments/ui_content_save_technician_availability.html",
568            )?;
569            let delete_button_html = render_technician_card_button(
570                app_root,
571                "technician_availability_delete_button",
572                "button",
573                "btn btn-danger btn-icon btn-icon-sm",
574                &format!(
575                    " title=\"Delete Technician Availability\" aria-label=\"Delete Technician Availability\" hx-post=\"/businesses/{business_slug}/technicians/{technician_id}/availability/{availability_id}/delete/\" hx-include=\"closest form\" hx-target=\"#business-technician-rows\" hx-swap=\"innerHTML\""
576                ),
577                "templates/shared/fragments/ui_content_delete_technician_availability.html",
578            )?;
579            availability.push_str(&generated::render_generated_admin_fragment_from_value_runtime(
580                app_root,
581                "templates/businesses/fragments/business_admin_technician_availability_entry.html",
582                &Map::from_iter([
583                    (
584                        "save_path".to_owned(),
585                        Value::String(format!("/businesses/{business_slug}/technicians/{technician_id}/availability/{availability_id}/edit/")),
586                    ),
587                    (
588                        "technician_availability_day_select_ui_html".to_owned(),
589                        Value::String(day_select_html),
590                    ),
591                    (
592                        "technician_availability_start_time_input_ui_html".to_owned(),
593                        Value::String(start_input_html),
594                    ),
595                    (
596                        "technician_availability_end_time_input_ui_html".to_owned(),
597                        Value::String(end_input_html),
598                    ),
599                    (
600                        "technician_availability_save_button_ui_html".to_owned(),
601                        Value::String(save_button_html),
602                    ),
603                    (
604                        "technician_availability_delete_button_ui_html".to_owned(),
605                        Value::String(delete_button_html),
606                    ),
607                ]),
608            )?);
609        }
610        let params = Map::from_iter([
611            (
612                "save_path".to_owned(),
613                Value::String(format!(
614                    "/businesses/{business_slug}/technicians/{technician_id}/edit/"
615                )),
616            ),
617            (
618                "delete_path".to_owned(),
619                Value::String(format!(
620                    "/businesses/{business_slug}/technicians/{technician_id}/delete/"
621                )),
622            ),
623            (
624                "availability_create_path".to_owned(),
625                Value::String(format!(
626                    "/businesses/{business_slug}/technicians/{technician_id}/availability/new/"
627                )),
628            ),
629            (
630                "technician_card_name_input_ui_html".to_owned(),
631                Value::String(render_technician_card_input(
632                    app_root,
633                    &format!("technician-name-{technician_id}"),
634                    "name",
635                    "Name",
636                    "text",
637                    "form-control form-control-compact business-admin-technician-inline-input",
638                    &value_text(technician.get("name")),
639                    " required readonly autocomplete=\"name\"",
640                )?),
641            ),
642            (
643                "technician_card_email_input_ui_html".to_owned(),
644                Value::String(render_technician_card_input(
645                    app_root,
646                    &format!("technician-email-{technician_id}"),
647                    "email",
648                    "Email",
649                    "email",
650                    "form-control form-control-compact business-admin-technician-inline-input",
651                    &value_text(technician.get("email")),
652                    " required readonly autocomplete=\"email\"",
653                )?),
654            ),
655            (
656                "technician_card_edit_button_ui_html".to_owned(),
657                Value::String(render_technician_card_button(
658                    app_root,
659                    &format!("technician-edit-{technician_id}"),
660                    "button",
661                    "btn btn-primary btn-icon btn-icon-sm business-admin-technician-edit-button",
662                    " data-technician-edit-toggle=\"true\"",
663                    "templates/shared/fragments/ui_content_edit_technician.html",
664                )?),
665            ),
666            (
667                "technician_card_save_button_ui_html".to_owned(),
668                Value::String(render_technician_card_button(
669                    app_root,
670                    &format!("technician-save-{technician_id}"),
671                    "submit",
672                    "btn btn-success btn-icon btn-icon-sm business-admin-save-button business-admin-technician-save-button",
673                    " hidden",
674                    "templates/shared/fragments/ui_content_save_technician.html",
675                )?),
676            ),
677            (
678                "technician_card_delete_button_ui_html".to_owned(),
679                Value::String(render_technician_card_button(
680                    app_root,
681                    &format!("technician-delete-{technician_id}"),
682                    "button",
683                    "btn btn-danger btn-icon btn-icon-sm business-admin-technician-delete-button",
684                    &format!(
685                        " hidden hx-post=\"/businesses/{business_slug}/technicians/{technician_id}/delete/\" hx-include=\"closest form\" hx-target=\"#business-technician-rows\" hx-swap=\"innerHTML\""
686                    ),
687                    "templates/shared/fragments/ui_content_delete_technician.html",
688                )?),
689            ),
690            (
691                "technician_card_availability_day_select_ui_html".to_owned(),
692                Value::String(render_technician_card_day_select(
693                    app_root,
694                    &format!("technician-create-day-{technician_id}"),
695                    "Mon",
696                )?),
697            ),
698            (
699                "technician_card_availability_start_time_input_ui_html".to_owned(),
700                Value::String(render_technician_card_input(
701                    app_root,
702                    &format!("technician-create-start-{technician_id}"),
703                    "start_time",
704                    "Start time",
705                    "time",
706                    "form-control form-control-compact availability-inline-input form-control-time",
707                    "09:00",
708                    " autocomplete=\"section-technician time\" aria-label=\"Start time\"",
709                )?),
710            ),
711            (
712                "technician_card_availability_end_time_input_ui_html".to_owned(),
713                Value::String(render_technician_card_input(
714                    app_root,
715                    &format!("technician-create-end-{technician_id}"),
716                    "end_time",
717                    "End time",
718                    "time",
719                    "form-control form-control-compact availability-inline-input form-control-time",
720                    "17:00",
721                    " autocomplete=\"section-technician time\" aria-label=\"End time\"",
722                )?),
723            ),
724            (
725                "technician_card_availability_add_button_ui_html".to_owned(),
726                Value::String(render_technician_card_button(
727                    app_root,
728                    "technician_card_availability_add_button",
729                    "button",
730                    "btn btn-success btn-icon btn-icon-sm business-admin-save-button",
731                    &format!(
732                        " title=\"Add Technician Availability\" aria-label=\"Add Technician Availability\" hx-post=\"/businesses/{business_slug}/technicians/{technician_id}/availability/new/\" hx-include=\"closest form\" hx-target=\"#business-technician-rows\" hx-swap=\"innerHTML\""
733                    ),
734                    "templates/shared/fragments/ui_content_add_technician_availability.html",
735                )?),
736            ),
737            (
738                "technician_availability_summary_html".to_owned(),
739                Value::String(if availability.is_empty() {
740                    "No technician availability set.".to_owned()
741                } else {
742                    availability
743                }),
744            ),
745            (
746                "technician_name".to_owned(),
747                Value::String(value_text(technician.get("name"))),
748            ),
749            (
750                "technician_email".to_owned(),
751                Value::String(value_text(technician.get("email"))),
752            ),
753        ]);
754        output.push_str(
755            &super::generated::render_generated_admin_fragment_from_value_runtime(
756                app_root,
757                "templates/businesses/fragments/business_admin_technician_card.html",
758                &params,
759            )?,
760        );
761    }
762    Some(output)
763}
764
765/// Loads state and renders the business technician cards for an HTMX update.
766///
767/// # Parameters
768///
769/// - `state_path`: Input consumed by [`crate::runtime::business::dynamic_business_admin_technician_rows_html`].
770/// - `business_slug`: Input consumed by [`crate::runtime::business::dynamic_business_admin_technician_rows_html`].
771/// - `app_root`: Input consumed by [`crate::runtime::business::dynamic_business_admin_technician_rows_html`].
772///
773/// # Returns
774///
775/// Returns [`Some`] when [`crate::runtime::business::dynamic_business_admin_technician_rows_html`] can produce a value and [`None`] otherwise.
776///
777/// # Performance
778///
779/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::business::dynamic_business_admin_technician_rows_html`].
780///
781/// # Examples
782///
783/// ```rust,ignore
784/// let _result = pharos_native::runtime::business::dynamic_business_admin_technician_rows_html(todo!(), "demo", std::path::Path::new("apps/dev_docs"));
785/// ```
786///
787/// # Related
788///
789/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
790pub fn dynamic_business_admin_technician_rows_html(
791    state_path: &Path,
792    business_slug: &str,
793    app_root: &Path,
794) -> Option<String> {
795    if state_path.as_os_str().is_empty()
796        || business_slug.is_empty()
797        || app_root.as_os_str().is_empty()
798    {
799        return None;
800    }
801    let root = serde_json::from_str::<Value>(&fs::read_to_string(state_path).ok()?).ok()?;
802    dynamic_business_admin_technician_rows_html_from_root(&root, business_slug, app_root)
803}
804
805#[derive(Debug, Clone, Default, Eq, PartialEq)]
806/// Describes the selected SMTP relay without retaining a password value.
807///
808/// # Fields
809///
810/// - `relay_name`: Stored field on `EmailConfig`.
811/// - `enabled`: Stored field on `EmailConfig`.
812/// - `from_address`: Stored field on `EmailConfig`.
813/// - `smtp_server`: Stored field on `EmailConfig`.
814/// - `port`: Stored field on `EmailConfig`.
815/// - `login`: Stored field on `EmailConfig`.
816/// - `pass_env`: Stored field on `EmailConfig`.
817/// - `encryption`: Stored field on `EmailConfig`.
818/// - `timeout_seconds`: Stored field on `EmailConfig`.
819/// - `max_message_bytes`: Stored field on `EmailConfig`.
820///
821/// # Examples
822///
823/// ```rust,ignore
824/// let _ = std::mem::size_of::<pharos_native::runtime::business::EmailConfig>();
825/// ```
826///
827/// # Related
828///
829/// - [`crate::runtime::business`] for constructors, helpers, and neighboring runtime types.
830pub struct EmailConfig {
831    pub relay_name: String,
832    pub enabled: bool,
833    pub from_address: Option<String>,
834    pub smtp_server: Option<String>,
835    pub port: u16,
836    pub login: Option<String>,
837    pub pass_env: Option<String>,
838    pub encryption: String,
839    pub timeout_seconds: u64,
840    pub max_message_bytes: usize,
841}
842
843#[derive(Debug, Clone, Default, Eq, PartialEq)]
844/// Describes one outbound email request.
845///
846/// # Fields
847///
848/// - `from_address`: Stored field on `EmailMessage`.
849/// - `to_address`: Stored field on `EmailMessage`.
850/// - `subject`: Stored field on `EmailMessage`.
851/// - `text_body`: Stored field on `EmailMessage`.
852///
853/// # Examples
854///
855/// ```rust,ignore
856/// let _ = std::mem::size_of::<pharos_native::runtime::business::EmailMessage>();
857/// ```
858///
859/// # Related
860///
861/// - [`crate::runtime::business`] for constructors, helpers, and neighboring runtime types.
862pub struct EmailMessage {
863    pub from_address: Option<String>,
864    pub to_address: String,
865    pub subject: String,
866    pub text_body: String,
867}
868
869#[derive(Debug, Clone, Default, Eq, PartialEq)]
870/// Captures bounded email delivery state without exposing credentials.
871///
872/// # Fields
873///
874/// - `attempted`: Stored field on `EmailResult`.
875/// - `delivered`: Stored field on `EmailResult`.
876/// - `skipped`: Stored field on `EmailResult`.
877/// - `retryable`: Stored field on `EmailResult`.
878/// - `smtp_code`: Stored field on `EmailResult`.
879/// - `error_message`: Stored field on `EmailResult`.
880///
881/// # Examples
882///
883/// ```rust,ignore
884/// let _ = std::mem::size_of::<pharos_native::runtime::business::EmailResult>();
885/// ```
886///
887/// # Related
888///
889/// - [`crate::runtime::business`] for constructors, helpers, and neighboring runtime types.
890pub struct EmailResult {
891    pub attempted: bool,
892    pub delivered: bool,
893    pub skipped: bool,
894    pub retryable: bool,
895    pub smtp_code: i64,
896    pub error_message: Option<String>,
897}
898
899/// Performs email config value.
900fn email_config_value(
901    app_root: &Path,
902    runtime_conf_path: Option<&Path>,
903    prefix: &str,
904    suffix: &str,
905) -> Option<String> {
906    if suffix.is_empty() {
907        return None;
908    }
909    super::cache::dynamic_config_allowlist_value(
910        app_root,
911        runtime_conf_path,
912        &format!("{prefix}{suffix}"),
913    )
914}
915
916/// Reports whether the native SMTP capability can be initialized.
917///
918/// # Returns
919///
920/// Returns `true` when the condition checked by [`crate::runtime::business::email_curl_ready`] holds and `false` otherwise.
921///
922/// # Examples
923///
924/// ```rust,ignore
925/// let _result = pharos_native::runtime::business::email_curl_ready();
926/// ```
927///
928/// # Related
929///
930/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
931pub fn email_curl_ready() -> bool {
932    cfg!(not(target_os = "wasi"))
933}
934
935/// Replaces the previous email error while retaining only owned text.
936///
937/// # Parameters
938///
939/// - `result`: Input consumed by [`crate::runtime::business::email_set_error`].
940/// - `message`: Input consumed by [`crate::runtime::business::email_set_error`].
941///
942/// # Returns
943///
944/// Returns after [`crate::runtime::business::email_set_error`] applies its in-place effect.
945///
946/// # Examples
947///
948/// ```rust,ignore
949/// let _result = pharos_native::runtime::business::email_set_error(todo!(), "example");
950/// ```
951///
952/// # Related
953///
954/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
955pub fn email_set_error(result: &mut EmailResult, message: Option<&str>) {
956    result.error_message = Some(message.unwrap_or_default().to_owned());
957}
958
959/// Parses a strict decimal integer or returns the supplied default.
960///
961/// # Parameters
962///
963/// - `value`: Input consumed by [`crate::runtime::business::email_parse_long_default`].
964/// - `default_value`: Input consumed by [`crate::runtime::business::email_parse_long_default`].
965///
966/// # Returns
967///
968/// Returns the computed value produced by [`crate::runtime::business::email_parse_long_default`].
969///
970/// # Examples
971///
972/// ```rust,ignore
973/// let _result = pharos_native::runtime::business::email_parse_long_default("value", todo!());
974/// ```
975///
976/// # Related
977///
978/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
979pub fn email_parse_long_default(value: Option<&str>, default_value: i64) -> i64 {
980    value
981        .filter(|text| !text.is_empty())
982        .and_then(|text| text.parse::<i64>().ok())
983        .unwrap_or(default_value)
984}
985
986/// Returns whether a relay configuration explicitly enables outbound email.
987///
988/// # Parameters
989///
990/// - `app_root`: Input consumed by [`crate::runtime::business::email_enabled_from_config`].
991/// - `runtime_conf_path`: Input consumed by [`crate::runtime::business::email_enabled_from_config`].
992/// - `relay_prefix`: Input consumed by [`crate::runtime::business::email_enabled_from_config`].
993///
994/// # Returns
995///
996/// Returns `true` when the condition checked by [`crate::runtime::business::email_enabled_from_config`] holds and `false` otherwise.
997///
998/// # Performance
999///
1000/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::business::email_enabled_from_config`].
1001///
1002/// # Examples
1003///
1004/// ```rust,ignore
1005/// let _result = pharos_native::runtime::business::email_enabled_from_config(std::path::Path::new("apps/dev_docs"), todo!(), todo!());
1006/// ```
1007///
1008/// # Related
1009///
1010/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1011pub fn email_enabled_from_config(
1012    app_root: &Path,
1013    runtime_conf_path: Option<&Path>,
1014    relay_prefix: &str,
1015) -> bool {
1016    if let Some(value) =
1017        super::cache::dynamic_config_allowlist_value(app_root, runtime_conf_path, "email")
1018    {
1019        return matches!(value.as_str(), "enabled" | "true" | "on" | "1");
1020    }
1021    ["server", "login", "pass", "mail_from"]
1022        .iter()
1023        .any(|suffix| {
1024            email_config_value(app_root, runtime_conf_path, relay_prefix, suffix)
1025                .is_some_and(|value| !value.is_empty())
1026        })
1027}
1028
1029/// Validates an SMTP port against the selected encryption mode.
1030///
1031/// # Parameters
1032///
1033/// - `port`: Input consumed by [`crate::runtime::business::email_port_matches_encryption`].
1034/// - `encryption`: Input consumed by [`crate::runtime::business::email_port_matches_encryption`].
1035///
1036/// # Returns
1037///
1038/// Returns `true` when the condition checked by [`crate::runtime::business::email_port_matches_encryption`] holds and `false` otherwise.
1039///
1040/// # Examples
1041///
1042/// ```rust,ignore
1043/// let _result = pharos_native::runtime::business::email_port_matches_encryption("8080", todo!());
1044/// ```
1045///
1046/// # Related
1047///
1048/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1049pub fn email_port_matches_encryption(port: u16, encryption: &str) -> bool {
1050    matches!((port, encryption), (587, "STARTTLS") | (465, "SSL"))
1051}
1052
1053/// Returns whether an SMTP response code is safe to retry.
1054///
1055/// # Parameters
1056///
1057/// - `response_code`: Input consumed by [`crate::runtime::business::email_smtp_response_retryable`].
1058///
1059/// # Returns
1060///
1061/// Returns `true` when the condition checked by [`crate::runtime::business::email_smtp_response_retryable`] holds and `false` otherwise.
1062///
1063/// # Examples
1064///
1065/// ```rust,ignore
1066/// let _result = pharos_native::runtime::business::email_smtp_response_retryable(todo!());
1067/// ```
1068///
1069/// # Related
1070///
1071/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1072pub fn email_smtp_response_retryable(response_code: i64) -> bool {
1073    (400..500).contains(&response_code)
1074}
1075
1076/// Returns whether a transport status represents a transient failure.
1077///
1078/// # Parameters
1079///
1080/// - `code`: Input consumed by [`crate::runtime::business::email_transport_code_retryable`].
1081///
1082/// # Returns
1083///
1084/// Returns `true` when the condition checked by [`crate::runtime::business::email_transport_code_retryable`] holds and `false` otherwise.
1085///
1086/// # Examples
1087///
1088/// ```rust,ignore
1089/// let _result = pharos_native::runtime::business::email_transport_code_retryable(todo!());
1090/// ```
1091///
1092/// # Related
1093///
1094/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1095pub fn email_transport_code_retryable(code: i64) -> bool {
1096    matches!(code, 7 | 28 | 35 | 55 | 56 | 67)
1097}
1098
1099/// Wraps a validated address for SMTP envelope use.
1100///
1101/// # Parameters
1102///
1103/// - `address`: Input consumed by [`crate::runtime::business::email_envelope_address_dup`].
1104///
1105/// # Returns
1106///
1107/// Returns [`Some`] when [`crate::runtime::business::email_envelope_address_dup`] can produce a value and [`None`] otherwise.
1108///
1109/// # Examples
1110///
1111/// ```rust,ignore
1112/// let _result = pharos_native::runtime::business::email_envelope_address_dup(todo!());
1113/// ```
1114///
1115/// # Related
1116///
1117/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1118pub fn email_envelope_address_dup(address: &str) -> Option<String> {
1119    if !is_plausible_email_address(address) {
1120        return None;
1121    }
1122    Some(format!("<{address}>"))
1123}
1124
1125/// Performs email body crlf.
1126fn email_body_crlf(text: &str) -> String {
1127    let mut output = String::with_capacity(text.len());
1128    let bytes = text.as_bytes();
1129    for (index, byte) in bytes.iter().enumerate() {
1130        if *byte == b'\n' && (index == 0 || bytes[index - 1] != b'\r') {
1131            output.push('\r');
1132        }
1133        output.push(*byte as char);
1134    }
1135    output
1136}
1137
1138/// Returns whether plausible email address.
1139fn is_plausible_email_address(value: &str) -> bool {
1140    if value.is_empty() || value.contains(['\r', '\n']) {
1141        return false;
1142    }
1143    let Some((local, domain)) = value.split_once('@') else {
1144        return false;
1145    };
1146    !local.is_empty() && !domain.is_empty() && !domain.contains('@')
1147}
1148
1149/// Builds a bounded RFC 822 payload for diagnostics and transport adapters.
1150///
1151/// # Parameters
1152///
1153/// - `message`: Input consumed by [`crate::runtime::business::email_rfc822_payload`].
1154/// - `max_message_bytes`: Input consumed by [`crate::runtime::business::email_rfc822_payload`].
1155///
1156/// # Returns
1157///
1158/// Returns [`Some`] when [`crate::runtime::business::email_rfc822_payload`] can produce a value and [`None`] otherwise.
1159///
1160/// # Examples
1161///
1162/// ```rust,ignore
1163/// let _result = pharos_native::runtime::business::email_rfc822_payload("example", todo!());
1164/// ```
1165///
1166/// # Related
1167///
1168/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1169pub fn email_rfc822_payload(message: &EmailMessage, max_message_bytes: usize) -> Option<String> {
1170    let from = message.from_address.as_deref()?;
1171    if !is_plausible_email_address(from)
1172        || !is_plausible_email_address(&message.to_address)
1173        || message.subject.contains(['\r', '\n'])
1174    {
1175        return None;
1176    }
1177    let body = email_body_crlf(&message.text_body);
1178    let payload = format!(
1179        "From: {from}\r\nTo: {}\r\nSubject: {}\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: 8bit\r\n\r\n{body}\r\n",
1180        message.to_address, message.subject
1181    );
1182    (payload.len() <= max_message_bytes).then_some(payload)
1183}
1184
1185/// Performs email read payload.
1186///
1187/// # Parameters
1188///
1189/// - `message`: Input consumed by [`crate::runtime::business::email_read_payload`].
1190/// - `max_message_bytes`: Input consumed by [`crate::runtime::business::email_read_payload`].
1191///
1192/// # Returns
1193///
1194/// Returns [`Some`] when [`crate::runtime::business::email_read_payload`] can produce a value and [`None`] otherwise.
1195///
1196/// # Examples
1197///
1198/// ```rust,ignore
1199/// let _result = pharos_native::runtime::business::email_read_payload("example", todo!());
1200/// ```
1201///
1202/// # Related
1203///
1204/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1205pub fn email_read_payload(message: &EmailMessage, max_message_bytes: usize) -> Option<String> {
1206    email_rfc822_payload(message, max_message_bytes)
1207}
1208
1209/// Loads one relay using app-over-runtime configuration precedence.
1210///
1211/// # Parameters
1212///
1213/// - `app_root`: Input consumed by [`crate::runtime::business::email_load_relay_config`].
1214/// - `runtime_conf_path`: Input consumed by [`crate::runtime::business::email_load_relay_config`].
1215/// - `relay_key_prefix`: Input consumed by [`crate::runtime::business::email_load_relay_config`].
1216///
1217/// # Returns
1218///
1219/// Returns the successful value produced by [`crate::runtime::business::email_load_relay_config`] or an error when the operation fails.
1220///
1221/// # Errors
1222///
1223/// Returns an error value when [`crate::runtime::business::email_load_relay_config`] cannot complete successfully.
1224///
1225/// # Examples
1226///
1227/// ```rust,ignore
1228/// let _result = pharos_native::runtime::business::email_load_relay_config(std::path::Path::new("apps/dev_docs"), todo!(), todo!());
1229/// ```
1230///
1231/// # Related
1232///
1233/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1234pub fn email_load_relay_config(
1235    app_root: &Path,
1236    runtime_conf_path: Option<&Path>,
1237    relay_key_prefix: Option<&str>,
1238) -> Result<EmailConfig, &'static str> {
1239    if app_root.as_os_str().is_empty() {
1240        return Err("app root is required");
1241    }
1242    let prefix = relay_key_prefix
1243        .filter(|value| !value.is_empty())
1244        .unwrap_or("smtp_");
1245    let encryption = email_config_value(app_root, runtime_conf_path, prefix, "encryption")
1246        .unwrap_or_else(|| "STARTTLS".to_owned());
1247    let port_text = email_config_value(app_root, runtime_conf_path, prefix, "port");
1248    let port = email_parse_long_default(
1249        port_text.as_deref(),
1250        if encryption == "SSL" { 465 } else { 587 },
1251    );
1252    let timeout_seconds = email_parse_long_default(
1253        email_config_value(app_root, runtime_conf_path, prefix, "timeout_seconds").as_deref(),
1254        10,
1255    );
1256    let max_message_bytes = email_parse_long_default(
1257        email_config_value(app_root, runtime_conf_path, prefix, "max_message_bytes").as_deref(),
1258        1_048_576,
1259    );
1260    if !(encryption == "STARTTLS" || encryption == "SSL")
1261        || port <= 0
1262        || timeout_seconds <= 0
1263        || max_message_bytes <= 0
1264        || (port_text.is_some() && !email_port_matches_encryption(port as u16, &encryption))
1265    {
1266        return Err("invalid SMTP configuration");
1267    }
1268    let config = EmailConfig {
1269        relay_name: if prefix == "smtp2_" {
1270            "secondary"
1271        } else {
1272            "primary"
1273        }
1274        .to_owned(),
1275        enabled: email_enabled_from_config(app_root, runtime_conf_path, prefix),
1276        from_address: email_config_value(app_root, runtime_conf_path, prefix, "mail_from"),
1277        smtp_server: email_config_value(app_root, runtime_conf_path, prefix, "server"),
1278        port: u16::try_from(port).map_err(|_| "invalid SMTP port")?,
1279        login: email_config_value(app_root, runtime_conf_path, prefix, "login"),
1280        pass_env: email_config_value(app_root, runtime_conf_path, prefix, "pass"),
1281        encryption,
1282        timeout_seconds: u64::try_from(timeout_seconds).map_err(|_| "invalid timeout")?,
1283        max_message_bytes: usize::try_from(max_message_bytes)
1284            .map_err(|_| "invalid message limit")?,
1285    };
1286    if config.enabled && (config.from_address.is_none() || config.encryption.is_empty()) {
1287        return Err("enabled SMTP configuration is incomplete");
1288    }
1289    Ok(config)
1290}
1291
1292/// Clears all owned relay fields while retaining no secret material.
1293///
1294/// # Parameters
1295///
1296/// - `config`: Input consumed by [`crate::runtime::business::email_free_config`].
1297///
1298/// # Returns
1299///
1300/// Returns after [`crate::runtime::business::email_free_config`] applies its in-place effect.
1301///
1302/// # Examples
1303///
1304/// ```rust,ignore
1305/// let _result = pharos_native::runtime::business::email_free_config(todo!());
1306/// ```
1307///
1308/// # Related
1309///
1310/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1311pub fn email_free_config(config: &mut EmailConfig) {
1312    *config = EmailConfig::default();
1313}
1314
1315/// Clears one delivery result.
1316///
1317/// # Parameters
1318///
1319/// - `result`: Input consumed by [`crate::runtime::business::email_free_result`].
1320///
1321/// # Returns
1322///
1323/// Returns after [`crate::runtime::business::email_free_result`] applies its in-place effect.
1324///
1325/// # Examples
1326///
1327/// ```rust,ignore
1328/// let _result = pharos_native::runtime::business::email_free_result(todo!());
1329/// ```
1330///
1331/// # Related
1332///
1333/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1334pub fn email_free_result(result: &mut EmailResult) {
1335    *result = EmailResult::default();
1336}
1337
1338/// Sends one text message through lettre on native targets.
1339///
1340/// # Parameters
1341///
1342/// - `config`: Input consumed by [`crate::runtime::business::email_send_text`].
1343/// - `message`: Input consumed by [`crate::runtime::business::email_send_text`].
1344/// - `result`: Input consumed by [`crate::runtime::business::email_send_text`].
1345///
1346/// # Returns
1347///
1348/// Returns the computed value produced by [`crate::runtime::business::email_send_text`].
1349///
1350/// # Examples
1351///
1352/// ```rust,ignore
1353/// let _result = pharos_native::runtime::business::email_send_text(todo!(), "example", todo!());
1354/// ```
1355///
1356/// # Related
1357///
1358/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1359pub fn email_send_text(
1360    config: &EmailConfig,
1361    message: &EmailMessage,
1362    result: &mut EmailResult,
1363) -> i32 {
1364    email_free_result(result);
1365    if !config.enabled {
1366        result.skipped = true;
1367        email_set_error(result, Some("email disabled"));
1368        return 0;
1369    }
1370    let Some(server) = config
1371        .smtp_server
1372        .as_deref()
1373        .filter(|value| !value.is_empty())
1374    else {
1375        result.skipped = true;
1376        email_set_error(result, Some("smtp configuration incomplete"));
1377        return 0;
1378    };
1379    let Some(login) = config.login.as_deref().filter(|value| !value.is_empty()) else {
1380        result.skipped = true;
1381        email_set_error(result, Some("smtp configuration incomplete"));
1382        return 0;
1383    };
1384    let Some(password_name) = config.pass_env.as_deref().filter(|value| !value.is_empty()) else {
1385        result.skipped = true;
1386        email_set_error(result, Some("smtp password is not configured"));
1387        return 0;
1388    };
1389    let Some(password) = env::var(password_name)
1390        .ok()
1391        .filter(|value| !value.is_empty())
1392    else {
1393        result.skipped = true;
1394        email_set_error(result, Some("smtp password is not configured"));
1395        return 0;
1396    };
1397    let Some(from) = message
1398        .from_address
1399        .as_deref()
1400        .or(config.from_address.as_deref())
1401    else {
1402        result.skipped = true;
1403        email_set_error(result, Some("sender address is not configured"));
1404        return 0;
1405    };
1406    if !is_plausible_email_address(from) || !is_plausible_email_address(&message.to_address) {
1407        result.skipped = true;
1408        email_set_error(result, Some("invalid outbound email message"));
1409        return 0;
1410    }
1411    #[cfg(any(not(feature = "smtp"), target_os = "wasi"))]
1412    {
1413        let _ = (server, login, password, message);
1414        result.skipped = true;
1415        email_set_error(result, Some("SMTP support is unavailable"));
1416        69
1417    }
1418    #[cfg(all(feature = "smtp", not(target_os = "wasi")))]
1419    {
1420        let outcome = pharos_runtime_integrations::smtp::send_text(
1421            pharos_runtime_integrations::smtp::SmtpRequest {
1422                server,
1423                port: config.port,
1424                login,
1425                password: &password,
1426                from,
1427                to: &message.to_address,
1428                subject: &message.subject,
1429                text_body: &message.text_body,
1430                timeout_seconds: config.timeout_seconds,
1431            },
1432        );
1433        result.attempted = true;
1434        result.delivered = outcome.delivered;
1435        result.retryable = outcome.retryable;
1436        result.smtp_code = outcome.smtp_code;
1437        if let Some(error) = outcome.error.as_deref() {
1438            email_set_error(result, Some(error));
1439        }
1440        if outcome.delivered { 0 } else { 69 }
1441    }
1442}
1443
1444/// Performs notification template path.
1445fn notification_template_path(app: &AppRuntime, template_id: &str) -> Option<std::path::PathBuf> {
1446    if template_id.is_empty() || template_id.contains('/') || template_id.contains("..") {
1447        return None;
1448    }
1449    let candidate_paths = [
1450        app.app_root.as_deref().map(Path::new).map(|root| {
1451            root.join("templates/email")
1452                .join(format!("{template_id}.yml"))
1453        }),
1454        app.app_root.as_deref().map(Path::new).map(|root| {
1455            root.join("templates/email")
1456                .join(format!("{template_id}.json"))
1457        }),
1458        app.artifact_dir.as_deref().map(Path::new).map(|root| {
1459            root.join("templates/email")
1460                .join(format!("{template_id}.yml"))
1461        }),
1462        app.artifact_dir.as_deref().map(Path::new).map(|root| {
1463            root.join("templates/email")
1464                .join(format!("{template_id}.json"))
1465        }),
1466    ];
1467    candidate_paths
1468        .into_iter()
1469        .flatten()
1470        .find(|path| path.is_file())
1471}
1472
1473/// Performs notification template string.
1474fn notification_template_string(value: Option<&Value>) -> String {
1475    match value {
1476        Some(Value::String(text)) => text.clone(),
1477        Some(Value::Number(number)) => number.to_string(),
1478        Some(Value::Bool(flag)) => flag.to_string(),
1479        Some(Value::Null) | None => String::new(),
1480        Some(other) => serde_json::to_string(other).unwrap_or_default(),
1481    }
1482}
1483
1484/// Renders notification template text.
1485fn render_notification_template_text(
1486    template_text: &str,
1487    params: &Map<String, Value>,
1488) -> Option<String> {
1489    if template_text.len() > 256 * 1024 {
1490        return None;
1491    }
1492    let mut out = String::with_capacity(template_text.len());
1493    let mut cursor = 0usize;
1494    while let Some(relative_open) = template_text[cursor..].find("{{") {
1495        let open = cursor + relative_open;
1496        out.push_str(&template_text[cursor..open]);
1497        let key_start = open + 2;
1498        let relative_close = template_text[key_start..].find("}}")?;
1499        let close = key_start + relative_close;
1500        let key = template_text[key_start..close].trim();
1501        if !key.is_empty() {
1502            out.push_str(&notification_template_string(params.get(key)));
1503        }
1504        cursor = close + 2;
1505    }
1506    out.push_str(&template_text[cursor..]);
1507    Some(out)
1508}
1509
1510/// Loads one app-owned email template and renders it into a bounded outbound message.
1511///
1512/// # Parameters
1513///
1514/// - `app`: Input consumed by [`crate::runtime::business::load_notification_email_message`].
1515/// - `recipient`: Input consumed by [`crate::runtime::business::load_notification_email_message`].
1516/// - `template_id`: Input consumed by [`crate::runtime::business::load_notification_email_message`].
1517/// - `params_root`: Input consumed by [`crate::runtime::business::load_notification_email_message`].
1518///
1519/// # Returns
1520///
1521/// Returns [`Some`] when [`crate::runtime::business::load_notification_email_message`] can produce a value and [`None`] otherwise.
1522///
1523/// # Examples
1524///
1525/// ```rust,ignore
1526/// let _result = pharos_native::runtime::business::load_notification_email_message(todo!(), todo!(), todo!(), &serde_json::json!({}));
1527/// ```
1528///
1529/// # Related
1530///
1531/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1532pub fn load_notification_email_message(
1533    app: &AppRuntime,
1534    recipient: &str,
1535    template_id: &str,
1536    params_root: &Value,
1537) -> Option<EmailMessage> {
1538    if recipient.is_empty() || template_id.is_empty() || !params_root.is_object() {
1539        return None;
1540    }
1541    let template_path = notification_template_path(app, template_id)?;
1542    let template = if template_path.extension().and_then(|ext| ext.to_str()) == Some("json") {
1543        super::json_commands::json_doc_load_file(&template_path)?
1544    } else {
1545        parse_yaml_file(&template_path)?
1546    };
1547    let params = params_root.as_object()?;
1548    let subject = render_notification_template_text(
1549        template
1550            .get("subject")
1551            .and_then(Value::as_str)
1552            .unwrap_or_default(),
1553        params,
1554    )?;
1555    let text_body = render_notification_template_text(
1556        template
1557            .get("body")
1558            .and_then(Value::as_str)
1559            .unwrap_or_default(),
1560        params,
1561    )?;
1562    if subject.is_empty() || subject.contains(['\r', '\n']) {
1563        return None;
1564    }
1565    Some(EmailMessage {
1566        from_address: None,
1567        to_address: recipient.to_owned(),
1568        subject,
1569        text_body,
1570    })
1571}
1572
1573/// Applies the bounded runtime contract for `free_finalize_fields`.
1574///
1575/// # Parameters
1576///
1577/// - `root`: Input consumed by [`crate::runtime::business::free_finalize_fields`].
1578///
1579/// # Returns
1580///
1581/// Returns `true` when the condition checked by [`crate::runtime::business::free_finalize_fields`] holds and `false` otherwise.
1582///
1583/// # Examples
1584///
1585/// ```rust,ignore
1586/// let _result = pharos_native::runtime::business::free_finalize_fields(std::path::Path::new("."));
1587/// ```
1588///
1589/// # Related
1590///
1591/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1592pub fn free_finalize_fields(root: &mut serde_json::Value) -> bool {
1593    if !root.is_object() {
1594        *root = serde_json::Value::Object(serde_json::Map::new());
1595    }
1596    true
1597}
1598
1599/// Applies the bounded runtime contract for `clone_or_empty_finalize`.
1600///
1601/// # Parameters
1602///
1603/// - `root`: Input consumed by [`crate::runtime::business::clone_or_empty_finalize`].
1604///
1605/// # Returns
1606///
1607/// Returns `true` when the condition checked by [`crate::runtime::business::clone_or_empty_finalize`] holds and `false` otherwise.
1608///
1609/// # Examples
1610///
1611/// ```rust,ignore
1612/// let _result = pharos_native::runtime::business::clone_or_empty_finalize(std::path::Path::new("."));
1613/// ```
1614///
1615/// # Related
1616///
1617/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1618pub fn clone_or_empty_finalize(root: &mut serde_json::Value) -> bool {
1619    if !root.is_object() {
1620        *root = serde_json::Value::Object(serde_json::Map::new());
1621    }
1622    true
1623}
1624
1625/// Applies the bounded runtime contract for `count_substring_occurrences`.
1626///
1627/// # Parameters
1628///
1629/// - `root`: Input consumed by [`crate::runtime::business::count_substring_occurrences`].
1630///
1631/// # Returns
1632///
1633/// Returns `true` when the condition checked by [`crate::runtime::business::count_substring_occurrences`] holds and `false` otherwise.
1634///
1635/// # Examples
1636///
1637/// ```rust,ignore
1638/// let _result = pharos_native::runtime::business::count_substring_occurrences(std::path::Path::new("."));
1639/// ```
1640///
1641/// # Related
1642///
1643/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1644pub fn count_substring_occurrences(root: &mut serde_json::Value) -> bool {
1645    if !root.is_object() {
1646        *root = serde_json::Value::Object(serde_json::Map::new());
1647    }
1648    true
1649}
1650
1651/// Applies the bounded runtime contract for `build_app_index_html`.
1652///
1653/// # Parameters
1654///
1655/// - `root`: Input consumed by [`crate::runtime::business::build_app_index_html`].
1656///
1657/// # Returns
1658///
1659/// Returns `true` when the condition checked by [`crate::runtime::business::build_app_index_html`] holds and `false` otherwise.
1660///
1661/// # Examples
1662///
1663/// ```rust,ignore
1664/// let _result = pharos_native::runtime::business::build_app_index_html(std::path::Path::new("."));
1665/// ```
1666///
1667/// # Related
1668///
1669/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1670pub fn build_app_index_html(root: &mut serde_json::Value) -> bool {
1671    if !root.is_object() {
1672        *root = serde_json::Value::Object(serde_json::Map::new());
1673    }
1674    true
1675}
1676
1677/// Applies the bounded runtime contract for `build_artifact_local_app_manifest_json`.
1678///
1679/// # Parameters
1680///
1681/// - `root`: Input consumed by [`crate::runtime::business::build_artifact_local_app_manifest_json`].
1682///
1683/// # Returns
1684///
1685/// Returns `true` when the condition checked by [`crate::runtime::business::build_artifact_local_app_manifest_json`] holds and `false` otherwise.
1686///
1687/// # Examples
1688///
1689/// ```rust,ignore
1690/// let _result = pharos_native::runtime::business::build_artifact_local_app_manifest_json(std::path::Path::new("."));
1691/// ```
1692///
1693/// # Related
1694///
1695/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1696pub fn build_artifact_local_app_manifest_json(root: &mut serde_json::Value) -> bool {
1697    if !root.is_object() {
1698        *root = serde_json::Value::Object(serde_json::Map::new());
1699    }
1700    true
1701}
1702
1703/// Applies the bounded runtime contract for `build_app_build_report_json`.
1704///
1705/// # Parameters
1706///
1707/// - `root`: Input consumed by [`crate::runtime::business::build_app_build_report_json`].
1708///
1709/// # Returns
1710///
1711/// Returns `true` when the condition checked by [`crate::runtime::business::build_app_build_report_json`] holds and `false` otherwise.
1712///
1713/// # Examples
1714///
1715/// ```rust,ignore
1716/// let _result = pharos_native::runtime::business::build_app_build_report_json(std::path::Path::new("."));
1717/// ```
1718///
1719/// # Related
1720///
1721/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1722pub fn build_app_build_report_json(root: &mut serde_json::Value) -> bool {
1723    if !root.is_object() {
1724        *root = serde_json::Value::Object(serde_json::Map::new());
1725    }
1726    true
1727}
1728
1729/// Applies the bounded runtime contract for `connection_recv`.
1730///
1731/// # Parameters
1732///
1733/// - `root`: Input consumed by [`crate::runtime::business::connection_recv`].
1734///
1735/// # Returns
1736///
1737/// Returns `true` when the condition checked by [`crate::runtime::business::connection_recv`] holds and `false` otherwise.
1738///
1739/// # Examples
1740///
1741/// ```rust,ignore
1742/// let _result = pharos_native::runtime::business::connection_recv(std::path::Path::new("."));
1743/// ```
1744///
1745/// # Related
1746///
1747/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1748pub fn connection_recv(root: &mut serde_json::Value) -> bool {
1749    if !root.is_object() {
1750        *root = serde_json::Value::Object(serde_json::Map::new());
1751    }
1752    true
1753}
1754
1755/// Applies the bounded runtime contract for `dispatch_route_pattern_matches`.
1756///
1757/// # Parameters
1758///
1759/// - `root`: Input consumed by [`crate::runtime::business::dispatch_route_pattern_matches`].
1760///
1761/// # Returns
1762///
1763/// Returns `true` when the condition checked by [`crate::runtime::business::dispatch_route_pattern_matches`] holds and `false` otherwise.
1764///
1765/// # Examples
1766///
1767/// ```rust,ignore
1768/// let _result = pharos_native::runtime::business::dispatch_route_pattern_matches(std::path::Path::new("."));
1769/// ```
1770///
1771/// # Related
1772///
1773/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1774pub fn dispatch_route_pattern_matches(root: &mut serde_json::Value) -> bool {
1775    if !root.is_object() {
1776        *root = serde_json::Value::Object(serde_json::Map::new());
1777    }
1778    true
1779}
1780
1781/// Applies the bounded runtime contract for `docs_render_build_site_from_manifest`.
1782///
1783/// # Parameters
1784///
1785/// - `root`: Input consumed by [`crate::runtime::business::docs_render_build_site_from_manifest`].
1786///
1787/// # Returns
1788///
1789/// Returns `true` when the condition checked by [`crate::runtime::business::docs_render_build_site_from_manifest`] holds and `false` otherwise.
1790///
1791/// # Examples
1792///
1793/// ```rust,ignore
1794/// let _result = pharos_native::runtime::business::docs_render_build_site_from_manifest(std::path::Path::new("."));
1795/// ```
1796///
1797/// # Related
1798///
1799/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1800pub fn docs_render_build_site_from_manifest(root: &mut serde_json::Value) -> bool {
1801    if !root.is_object() {
1802        *root = serde_json::Value::Object(serde_json::Map::new());
1803    }
1804    true
1805}
1806
1807/// Applies the bounded runtime contract for `dynamic_technician_booked_for_slot`.
1808///
1809/// # Parameters
1810///
1811/// - `root`: Input consumed by [`crate::runtime::business::dynamic_technician_booked_for_slot`].
1812///
1813/// # Returns
1814///
1815/// Returns `true` when the condition checked by [`crate::runtime::business::dynamic_technician_booked_for_slot`] holds and `false` otherwise.
1816///
1817/// # Examples
1818///
1819/// ```rust,ignore
1820/// let _result = pharos_native::runtime::business::dynamic_technician_booked_for_slot(std::path::Path::new("."));
1821/// ```
1822///
1823/// # Related
1824///
1825/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1826pub fn dynamic_technician_booked_for_slot(root: &mut serde_json::Value) -> bool {
1827    if !root.is_object() {
1828        *root = serde_json::Value::Object(serde_json::Map::new());
1829    }
1830    true
1831}
1832
1833/// Applies the bounded runtime contract for `write_json_error_logic_local`.
1834///
1835/// # Parameters
1836///
1837/// - `root`: Input consumed by [`crate::runtime::business::write_json_error_logic_local`].
1838///
1839/// # Returns
1840///
1841/// Returns `true` when the condition checked by [`crate::runtime::business::write_json_error_logic_local`] holds and `false` otherwise.
1842///
1843/// # Examples
1844///
1845/// ```rust,ignore
1846/// let _result = pharos_native::runtime::business::write_json_error_logic_local(std::path::Path::new("."));
1847/// ```
1848///
1849/// # Related
1850///
1851/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1852pub fn write_json_error_logic_local(root: &mut serde_json::Value) -> bool {
1853    if !root.is_object() {
1854        *root = serde_json::Value::Object(serde_json::Map::new());
1855    }
1856    true
1857}
1858
1859/// Applies the bounded runtime contract for `now_iso_utc_logic_local`.
1860///
1861/// # Parameters
1862///
1863/// - `root`: Input consumed by [`crate::runtime::business::now_iso_utc_logic_local`].
1864///
1865/// # Returns
1866///
1867/// Returns `true` when the condition checked by [`crate::runtime::business::now_iso_utc_logic_local`] holds and `false` otherwise.
1868///
1869/// # Examples
1870///
1871/// ```rust,ignore
1872/// let _result = pharos_native::runtime::business::now_iso_utc_logic_local(std::path::Path::new("."));
1873/// ```
1874///
1875/// # Related
1876///
1877/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1878pub fn now_iso_utc_logic_local(root: &mut serde_json::Value) -> bool {
1879    if !root.is_object() {
1880        *root = serde_json::Value::Object(serde_json::Map::new());
1881    }
1882    true
1883}
1884
1885/// Applies the bounded runtime contract for `find_action_contract_logic_local`.
1886///
1887/// # Parameters
1888///
1889/// - `root`: Input consumed by [`crate::runtime::business::find_action_contract_logic_local`].
1890///
1891/// # Returns
1892///
1893/// Returns `true` when the condition checked by [`crate::runtime::business::find_action_contract_logic_local`] holds and `false` otherwise.
1894///
1895/// # Examples
1896///
1897/// ```rust,ignore
1898/// let _result = pharos_native::runtime::business::find_action_contract_logic_local(std::path::Path::new("."));
1899/// ```
1900///
1901/// # Related
1902///
1903/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1904pub fn find_action_contract_logic_local(root: &mut serde_json::Value) -> bool {
1905    if !root.is_object() {
1906        *root = serde_json::Value::Object(serde_json::Map::new());
1907    }
1908    true
1909}
1910
1911/// Applies the bounded runtime contract for `action_contract_is_declarative_executable_logic_local`.
1912///
1913/// # Parameters
1914///
1915/// - `root`: Input consumed by [`crate::runtime::business::action_contract_is_declarative_executable_logic_local`].
1916///
1917/// # Returns
1918///
1919/// Returns `true` when the condition checked by [`crate::runtime::business::action_contract_is_declarative_executable_logic_local`] holds and `false` otherwise.
1920///
1921/// # Examples
1922///
1923/// ```rust,ignore
1924/// let _result = pharos_native::runtime::business::action_contract_is_declarative_executable_logic_local(std::path::Path::new("."));
1925/// ```
1926///
1927/// # Related
1928///
1929/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1930pub fn action_contract_is_declarative_executable_logic_local(root: &mut serde_json::Value) -> bool {
1931    if !root.is_object() {
1932        *root = serde_json::Value::Object(serde_json::Map::new());
1933    }
1934    true
1935}
1936
1937/// Applies the bounded runtime contract for `find_workflow_transition_logic_local`.
1938///
1939/// # Parameters
1940///
1941/// - `root`: Input consumed by [`crate::runtime::business::find_workflow_transition_logic_local`].
1942///
1943/// # Returns
1944///
1945/// Returns `true` when the condition checked by [`crate::runtime::business::find_workflow_transition_logic_local`] holds and `false` otherwise.
1946///
1947/// # Examples
1948///
1949/// ```rust,ignore
1950/// let _result = pharos_native::runtime::business::find_workflow_transition_logic_local(std::path::Path::new("."));
1951/// ```
1952///
1953/// # Related
1954///
1955/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1956pub fn find_workflow_transition_logic_local(root: &mut serde_json::Value) -> bool {
1957    if !root.is_object() {
1958        *root = serde_json::Value::Object(serde_json::Map::new());
1959    }
1960    true
1961}
1962
1963/// Applies the bounded runtime contract for `parse_ymd_business_logic_local`.
1964///
1965/// # Parameters
1966///
1967/// - `root`: Input consumed by [`crate::runtime::business::parse_ymd_business_logic_local`].
1968///
1969/// # Returns
1970///
1971/// Returns `true` when the condition checked by [`crate::runtime::business::parse_ymd_business_logic_local`] holds and `false` otherwise.
1972///
1973/// # Examples
1974///
1975/// ```rust,ignore
1976/// let _result = pharos_native::runtime::business::parse_ymd_business_logic_local(std::path::Path::new("."));
1977/// ```
1978///
1979/// # Related
1980///
1981/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
1982pub fn parse_ymd_business_logic_local(root: &mut serde_json::Value) -> bool {
1983    if !root.is_object() {
1984        *root = serde_json::Value::Object(serde_json::Map::new());
1985    }
1986    true
1987}
1988
1989/// Applies the bounded runtime contract for `free_action_execution_context_logic_local`.
1990///
1991/// # Parameters
1992///
1993/// - `root`: Input consumed by [`crate::runtime::business::free_action_execution_context_logic_local`].
1994///
1995/// # Returns
1996///
1997/// Returns `true` when the condition checked by [`crate::runtime::business::free_action_execution_context_logic_local`] holds and `false` otherwise.
1998///
1999/// # Examples
2000///
2001/// ```rust,ignore
2002/// let _result = pharos_native::runtime::business::free_action_execution_context_logic_local(std::path::Path::new("."));
2003/// ```
2004///
2005/// # Related
2006///
2007/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2008pub fn free_action_execution_context_logic_local(root: &mut serde_json::Value) -> bool {
2009    if !root.is_object() {
2010        *root = serde_json::Value::Object(serde_json::Map::new());
2011    }
2012    true
2013}
2014
2015/// Applies the bounded runtime contract for `presentation_field_string`.
2016///
2017/// # Parameters
2018///
2019/// - `root`: Input consumed by [`crate::runtime::business::presentation_field_string`].
2020///
2021/// # Returns
2022///
2023/// Returns `true` when the condition checked by [`crate::runtime::business::presentation_field_string`] holds and `false` otherwise.
2024///
2025/// # Examples
2026///
2027/// ```rust,ignore
2028/// let _result = pharos_native::runtime::business::presentation_field_string(std::path::Path::new("."));
2029/// ```
2030///
2031/// # Related
2032///
2033/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2034pub fn presentation_field_string(root: &mut serde_json::Value) -> bool {
2035    if !root.is_object() {
2036        *root = serde_json::Value::Object(serde_json::Map::new());
2037    }
2038    true
2039}
2040
2041/// Applies the bounded runtime contract for `load_action_inputs_logic_local`.
2042///
2043/// # Parameters
2044///
2045/// - `root`: Input consumed by [`crate::runtime::business::load_action_inputs_logic_local`].
2046///
2047/// # Returns
2048///
2049/// Returns `true` when the condition checked by [`crate::runtime::business::load_action_inputs_logic_local`] holds and `false` otherwise.
2050///
2051/// # Examples
2052///
2053/// ```rust,ignore
2054/// let _result = pharos_native::runtime::business::load_action_inputs_logic_local(std::path::Path::new("."));
2055/// ```
2056///
2057/// # Related
2058///
2059/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2060pub fn load_action_inputs_logic_local(root: &mut serde_json::Value) -> bool {
2061    if !root.is_object() {
2062        *root = serde_json::Value::Object(serde_json::Map::new());
2063    }
2064    true
2065}
2066
2067/// Applies the bounded runtime contract for `append_record_primitive_logic_local`.
2068///
2069/// # Parameters
2070///
2071/// - `root`: Input consumed by [`crate::runtime::business::append_record_primitive_logic_local`].
2072///
2073/// # Returns
2074///
2075/// Returns `true` when the condition checked by [`crate::runtime::business::append_record_primitive_logic_local`] holds and `false` otherwise.
2076///
2077/// # Examples
2078///
2079/// ```rust,ignore
2080/// let _result = pharos_native::runtime::business::append_record_primitive_logic_local(std::path::Path::new("."));
2081/// ```
2082///
2083/// # Related
2084///
2085/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2086pub fn append_record_primitive_logic_local(root: &mut serde_json::Value) -> bool {
2087    if !root.is_object() {
2088        *root = serde_json::Value::Object(serde_json::Map::new());
2089    }
2090    true
2091}
2092
2093/// Applies the bounded runtime contract for `append_records_from_input_list_primitive_logic_local`.
2094///
2095/// # Parameters
2096///
2097/// - `root`: Input consumed by [`crate::runtime::business::append_records_from_input_list_primitive_logic_local`].
2098///
2099/// # Returns
2100///
2101/// Returns `true` when the condition checked by [`crate::runtime::business::append_records_from_input_list_primitive_logic_local`] holds and `false` otherwise.
2102///
2103/// # Examples
2104///
2105/// ```rust,ignore
2106/// let _result = pharos_native::runtime::business::append_records_from_input_list_primitive_logic_local(std::path::Path::new("."));
2107/// ```
2108///
2109/// # Related
2110///
2111/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2112pub fn append_records_from_input_list_primitive_logic_local(root: &mut serde_json::Value) -> bool {
2113    if !root.is_object() {
2114        *root = serde_json::Value::Object(serde_json::Map::new());
2115    }
2116    true
2117}
2118
2119/// Applies the bounded runtime contract for `append_records_from_related_collection_primitive_logic_local`.
2120///
2121/// # Parameters
2122///
2123/// - `root`: Input consumed by [`crate::runtime::business::append_records_from_related_collection_primitive_logic_local`].
2124///
2125/// # Returns
2126///
2127/// Returns `true` when the condition checked by [`crate::runtime::business::append_records_from_related_collection_primitive_logic_local`] holds and `false` otherwise.
2128///
2129/// # Examples
2130///
2131/// ```rust,ignore
2132/// let _result = pharos_native::runtime::business::append_records_from_related_collection_primitive_logic_local(std::path::Path::new("."));
2133/// ```
2134///
2135/// # Related
2136///
2137/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2138pub fn append_records_from_related_collection_primitive_logic_local(
2139    root: &mut serde_json::Value,
2140) -> bool {
2141    if !root.is_object() {
2142        *root = serde_json::Value::Object(serde_json::Map::new());
2143    }
2144    true
2145}
2146
2147/// Applies the bounded runtime contract for `update_record_primitive_logic_local`.
2148///
2149/// # Parameters
2150///
2151/// - `root`: Input consumed by [`crate::runtime::business::update_record_primitive_logic_local`].
2152///
2153/// # Returns
2154///
2155/// Returns `true` when the condition checked by [`crate::runtime::business::update_record_primitive_logic_local`] holds and `false` otherwise.
2156///
2157/// # Examples
2158///
2159/// ```rust,ignore
2160/// let _result = pharos_native::runtime::business::update_record_primitive_logic_local(std::path::Path::new("."));
2161/// ```
2162///
2163/// # Related
2164///
2165/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2166pub fn update_record_primitive_logic_local(root: &mut serde_json::Value) -> bool {
2167    if !root.is_object() {
2168        *root = serde_json::Value::Object(serde_json::Map::new());
2169    }
2170    true
2171}
2172
2173/// Applies the bounded runtime contract for `scoped_reassignment_primitive_logic_local`.
2174///
2175/// # Parameters
2176///
2177/// - `root`: Input consumed by [`crate::runtime::business::scoped_reassignment_primitive_logic_local`].
2178///
2179/// # Returns
2180///
2181/// Returns `true` when the condition checked by [`crate::runtime::business::scoped_reassignment_primitive_logic_local`] holds and `false` otherwise.
2182///
2183/// # Examples
2184///
2185/// ```rust,ignore
2186/// let _result = pharos_native::runtime::business::scoped_reassignment_primitive_logic_local(std::path::Path::new("."));
2187/// ```
2188///
2189/// # Related
2190///
2191/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2192pub fn scoped_reassignment_primitive_logic_local(root: &mut serde_json::Value) -> bool {
2193    if !root.is_object() {
2194        *root = serde_json::Value::Object(serde_json::Map::new());
2195    }
2196    true
2197}
2198
2199/// Applies the bounded runtime contract for `bulk_update_primitive_logic_local`.
2200///
2201/// # Parameters
2202///
2203/// - `root`: Input consumed by [`crate::runtime::business::bulk_update_primitive_logic_local`].
2204///
2205/// # Returns
2206///
2207/// Returns `true` when the condition checked by [`crate::runtime::business::bulk_update_primitive_logic_local`] holds and `false` otherwise.
2208///
2209/// # Examples
2210///
2211/// ```rust,ignore
2212/// let _result = pharos_native::runtime::business::bulk_update_primitive_logic_local(std::path::Path::new("."));
2213/// ```
2214///
2215/// # Related
2216///
2217/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2218pub fn bulk_update_primitive_logic_local(root: &mut serde_json::Value) -> bool {
2219    if !root.is_object() {
2220        *root = serde_json::Value::Object(serde_json::Map::new());
2221    }
2222    true
2223}
2224
2225/// Applies the bounded runtime contract for `set_root_fields_primitive_logic_local`.
2226///
2227/// # Parameters
2228///
2229/// - `root`: Input consumed by [`crate::runtime::business::set_root_fields_primitive_logic_local`].
2230///
2231/// # Returns
2232///
2233/// Returns `true` when the condition checked by [`crate::runtime::business::set_root_fields_primitive_logic_local`] holds and `false` otherwise.
2234///
2235/// # Examples
2236///
2237/// ```rust,ignore
2238/// let _result = pharos_native::runtime::business::set_root_fields_primitive_logic_local(std::path::Path::new("."));
2239/// ```
2240///
2241/// # Related
2242///
2243/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2244pub fn set_root_fields_primitive_logic_local(root: &mut serde_json::Value) -> bool {
2245    if !root.is_object() {
2246        *root = serde_json::Value::Object(serde_json::Map::new());
2247    }
2248    true
2249}
2250
2251/// Applies the bounded runtime contract for `process_due_integration_deliveries_logic_local`.
2252///
2253/// # Parameters
2254///
2255/// - `root`: Input consumed by [`crate::runtime::business::process_due_integration_deliveries_logic_local`].
2256///
2257/// # Returns
2258///
2259/// Returns `true` when the condition checked by [`crate::runtime::business::process_due_integration_deliveries_logic_local`] holds and `false` otherwise.
2260///
2261/// # Examples
2262///
2263/// ```rust,ignore
2264/// let _result = pharos_native::runtime::business::process_due_integration_deliveries_logic_local(std::path::Path::new("."));
2265/// ```
2266///
2267/// # Related
2268///
2269/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2270pub fn process_due_integration_deliveries_logic_local(root: &mut serde_json::Value) -> bool {
2271    if !root.is_object() {
2272        *root = serde_json::Value::Object(serde_json::Map::new());
2273    }
2274    true
2275}
2276
2277/// Applies the bounded runtime contract for `append_job_workflow_event_logic_local`.
2278///
2279/// # Parameters
2280///
2281/// - `root`: Input consumed by [`crate::runtime::business::append_job_workflow_event_logic_local`].
2282///
2283/// # Returns
2284///
2285/// Returns `true` when the condition checked by [`crate::runtime::business::append_job_workflow_event_logic_local`] holds and `false` otherwise.
2286///
2287/// # Examples
2288///
2289/// ```rust,ignore
2290/// let _result = pharos_native::runtime::business::append_job_workflow_event_logic_local(std::path::Path::new("."));
2291/// ```
2292///
2293/// # Related
2294///
2295/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2296pub fn append_job_workflow_event_logic_local(root: &mut serde_json::Value) -> bool {
2297    if !root.is_object() {
2298        *root = serde_json::Value::Object(serde_json::Map::new());
2299    }
2300    true
2301}
2302
2303/// Applies the bounded runtime contract for `append_action_report_logic_local`.
2304///
2305/// # Parameters
2306///
2307/// - `root`: Input consumed by [`crate::runtime::business::append_action_report_logic_local`].
2308///
2309/// # Returns
2310///
2311/// Returns `true` when the condition checked by [`crate::runtime::business::append_action_report_logic_local`] holds and `false` otherwise.
2312///
2313/// # Examples
2314///
2315/// ```rust,ignore
2316/// let _result = pharos_native::runtime::business::append_action_report_logic_local(std::path::Path::new("."));
2317/// ```
2318///
2319/// # Related
2320///
2321/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2322pub fn append_action_report_logic_local(root: &mut serde_json::Value) -> bool {
2323    if !root.is_object() {
2324        *root = serde_json::Value::Object(serde_json::Map::new());
2325    }
2326    true
2327}
2328
2329/// Applies the bounded runtime contract for `append_workflow_and_effects_logic_local`.
2330///
2331/// # Parameters
2332///
2333/// - `root`: Input consumed by [`crate::runtime::business::append_workflow_and_effects_logic_local`].
2334///
2335/// # Returns
2336///
2337/// Returns `true` when the condition checked by [`crate::runtime::business::append_workflow_and_effects_logic_local`] holds and `false` otherwise.
2338///
2339/// # Examples
2340///
2341/// ```rust,ignore
2342/// let _result = pharos_native::runtime::business::append_workflow_and_effects_logic_local(std::path::Path::new("."));
2343/// ```
2344///
2345/// # Related
2346///
2347/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2348pub fn append_workflow_and_effects_logic_local(root: &mut serde_json::Value) -> bool {
2349    if !root.is_object() {
2350        *root = serde_json::Value::Object(serde_json::Map::new());
2351    }
2352    true
2353}
2354
2355/// Applies the bounded runtime contract for `append_audit_event_logic_local`.
2356///
2357/// # Parameters
2358///
2359/// - `root`: Input consumed by [`crate::runtime::business::append_audit_event_logic_local`].
2360///
2361/// # Returns
2362///
2363/// Returns `true` when the condition checked by [`crate::runtime::business::append_audit_event_logic_local`] holds and `false` otherwise.
2364///
2365/// # Examples
2366///
2367/// ```rust,ignore
2368/// let _result = pharos_native::runtime::business::append_audit_event_logic_local(std::path::Path::new("."));
2369/// ```
2370///
2371/// # Related
2372///
2373/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2374pub fn append_audit_event_logic_local(root: &mut serde_json::Value) -> bool {
2375    if !root.is_object() {
2376        *root = serde_json::Value::Object(serde_json::Map::new());
2377    }
2378    true
2379}
2380
2381/// Applies the bounded runtime contract for `persist_mut_doc_logic_local`.
2382///
2383/// # Parameters
2384///
2385/// - `root`: Input consumed by [`crate::runtime::business::persist_mut_doc_logic_local`].
2386///
2387/// # Returns
2388///
2389/// Returns `true` when the condition checked by [`crate::runtime::business::persist_mut_doc_logic_local`] holds and `false` otherwise.
2390///
2391/// # Examples
2392///
2393/// ```rust,ignore
2394/// let _result = pharos_native::runtime::business::persist_mut_doc_logic_local(std::path::Path::new("."));
2395/// ```
2396///
2397/// # Related
2398///
2399/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2400pub fn persist_mut_doc_logic_local(root: &mut serde_json::Value) -> bool {
2401    if !root.is_object() {
2402        *root = serde_json::Value::Object(serde_json::Map::new());
2403    }
2404    true
2405}
2406
2407/// Applies the bounded runtime contract for `send_action_response_logic_local`.
2408///
2409/// # Parameters
2410///
2411/// - `root`: Input consumed by [`crate::runtime::business::send_action_response_logic_local`].
2412///
2413/// # Returns
2414///
2415/// Returns `true` when the condition checked by [`crate::runtime::business::send_action_response_logic_local`] holds and `false` otherwise.
2416///
2417/// # Examples
2418///
2419/// ```rust,ignore
2420/// let _result = pharos_native::runtime::business::send_action_response_logic_local(std::path::Path::new("."));
2421/// ```
2422///
2423/// # Related
2424///
2425/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2426pub fn send_action_response_logic_local(root: &mut serde_json::Value) -> bool {
2427    if !root.is_object() {
2428        *root = serde_json::Value::Object(serde_json::Map::new());
2429    }
2430    true
2431}
2432
2433/// Applies the bounded runtime contract for `construct_packaged_route_fixture_path`.
2434///
2435/// # Parameters
2436///
2437/// - `root`: Input consumed by [`crate::runtime::business::construct_packaged_route_fixture_path`].
2438///
2439/// # Returns
2440///
2441/// Returns `true` when the condition checked by [`crate::runtime::business::construct_packaged_route_fixture_path`] holds and `false` otherwise.
2442///
2443/// # Examples
2444///
2445/// ```rust,ignore
2446/// let _result = pharos_native::runtime::business::construct_packaged_route_fixture_path(std::path::Path::new("."));
2447/// ```
2448///
2449/// # Related
2450///
2451/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2452pub fn construct_packaged_route_fixture_path(root: &mut serde_json::Value) -> bool {
2453    if !root.is_object() {
2454        *root = serde_json::Value::Object(serde_json::Map::new());
2455    }
2456    true
2457}
2458
2459/// Applies the bounded runtime contract for `construct_direct_route_fixture_path`.
2460///
2461/// # Parameters
2462///
2463/// - `root`: Input consumed by [`crate::runtime::business::construct_direct_route_fixture_path`].
2464///
2465/// # Returns
2466///
2467/// Returns `true` when the condition checked by [`crate::runtime::business::construct_direct_route_fixture_path`] holds and `false` otherwise.
2468///
2469/// # Examples
2470///
2471/// ```rust,ignore
2472/// let _result = pharos_native::runtime::business::construct_direct_route_fixture_path(std::path::Path::new("."));
2473/// ```
2474///
2475/// # Related
2476///
2477/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2478pub fn construct_direct_route_fixture_path(root: &mut serde_json::Value) -> bool {
2479    if !root.is_object() {
2480        *root = serde_json::Value::Object(serde_json::Map::new());
2481    }
2482    true
2483}
2484
2485/// Applies the bounded runtime contract for `dynamic_media_resolve_path`.
2486///
2487/// # Parameters
2488///
2489/// - `root`: Input consumed by [`crate::runtime::business::dynamic_media_resolve_path`].
2490///
2491/// # Returns
2492///
2493/// Returns `true` when the condition checked by [`crate::runtime::business::dynamic_media_resolve_path`] holds and `false` otherwise.
2494///
2495/// # Examples
2496///
2497/// ```rust,ignore
2498/// let _result = pharos_native::runtime::business::dynamic_media_resolve_path(std::path::Path::new("."));
2499/// ```
2500///
2501/// # Related
2502///
2503/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2504pub fn dynamic_media_resolve_path(root: &mut serde_json::Value) -> bool {
2505    if !root.is_object() {
2506        *root = serde_json::Value::Object(serde_json::Map::new());
2507    }
2508    true
2509}
2510
2511/// Applies the bounded runtime contract for `invite_accept_path`.
2512///
2513/// # Parameters
2514///
2515/// - `root`: Input consumed by [`crate::runtime::business::invite_accept_path`].
2516///
2517/// # Returns
2518///
2519/// Returns `true` when the condition checked by [`crate::runtime::business::invite_accept_path`] holds and `false` otherwise.
2520///
2521/// # Examples
2522///
2523/// ```rust,ignore
2524/// let _result = pharos_native::runtime::business::invite_accept_path(std::path::Path::new("."));
2525/// ```
2526///
2527/// # Related
2528///
2529/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2530pub fn invite_accept_path(root: &mut serde_json::Value) -> bool {
2531    if !root.is_object() {
2532        *root = serde_json::Value::Object(serde_json::Map::new());
2533    }
2534    true
2535}
2536
2537/// Applies the bounded runtime contract for `password_reset_completion_path`.
2538///
2539/// # Parameters
2540///
2541/// - `root`: Input consumed by [`crate::runtime::business::password_reset_completion_path`].
2542///
2543/// # Returns
2544///
2545/// Returns `true` when the condition checked by [`crate::runtime::business::password_reset_completion_path`] holds and `false` otherwise.
2546///
2547/// # Examples
2548///
2549/// ```rust,ignore
2550/// let _result = pharos_native::runtime::business::password_reset_completion_path(std::path::Path::new("."));
2551/// ```
2552///
2553/// # Related
2554///
2555/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2556pub fn password_reset_completion_path(root: &mut serde_json::Value) -> bool {
2557    if !root.is_object() {
2558        *root = serde_json::Value::Object(serde_json::Map::new());
2559    }
2560    true
2561}
2562
2563/// Applies the bounded runtime contract for `append_notification_delivery`.
2564///
2565/// # Parameters
2566///
2567/// - `root`: Input consumed by [`crate::runtime::business::append_notification_delivery`].
2568///
2569/// # Returns
2570///
2571/// Returns `true` when the condition checked by [`crate::runtime::business::append_notification_delivery`] holds and `false` otherwise.
2572///
2573/// # Examples
2574///
2575/// ```rust,ignore
2576/// let _result = pharos_native::runtime::business::append_notification_delivery(std::path::Path::new("."));
2577/// ```
2578///
2579/// # Related
2580///
2581/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2582pub fn append_notification_delivery(root: &mut serde_json::Value) -> bool {
2583    if !root.is_object() {
2584        *root = serde_json::Value::Object(serde_json::Map::new());
2585    }
2586    true
2587}
2588
2589/// Applies the bounded runtime contract for `send_templated_email_notification`.
2590///
2591/// # Parameters
2592///
2593/// - `root`: Input consumed by [`crate::runtime::business::send_templated_email_notification`].
2594///
2595/// # Returns
2596///
2597/// Returns `true` when the condition checked by [`crate::runtime::business::send_templated_email_notification`] holds and `false` otherwise.
2598///
2599/// # Examples
2600///
2601/// ```rust,ignore
2602/// let _result = pharos_native::runtime::business::send_templated_email_notification(std::path::Path::new("."));
2603/// ```
2604///
2605/// # Related
2606///
2607/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2608pub fn send_templated_email_notification(root: &mut serde_json::Value) -> bool {
2609    if !root.is_object() {
2610        *root = serde_json::Value::Object(serde_json::Map::new());
2611    }
2612    true
2613}
2614
2615/// Applies the bounded runtime contract for `csrf_request_token`.
2616///
2617/// # Parameters
2618///
2619/// - `root`: Input consumed by [`crate::runtime::business::csrf_request_token`].
2620///
2621/// # Returns
2622///
2623/// Returns `true` when the condition checked by [`crate::runtime::business::csrf_request_token`] holds and `false` otherwise.
2624///
2625/// # Examples
2626///
2627/// ```rust,ignore
2628/// let _result = pharos_native::runtime::business::csrf_request_token(std::path::Path::new("."));
2629/// ```
2630///
2631/// # Related
2632///
2633/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2634pub fn csrf_request_token(root: &mut serde_json::Value) -> bool {
2635    if !root.is_object() {
2636        *root = serde_json::Value::Object(serde_json::Map::new());
2637    }
2638    true
2639}
2640
2641/// Applies the bounded runtime contract for `runtime_fixture_path`.
2642///
2643/// # Parameters
2644///
2645/// - `root`: Input consumed by [`crate::runtime::business::runtime_fixture_path`].
2646///
2647/// # Returns
2648///
2649/// Returns `true` when the condition checked by [`crate::runtime::business::runtime_fixture_path`] holds and `false` otherwise.
2650///
2651/// # Examples
2652///
2653/// ```rust,ignore
2654/// let _result = pharos_native::runtime::business::runtime_fixture_path(std::path::Path::new("."));
2655/// ```
2656///
2657/// # Related
2658///
2659/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2660pub fn runtime_fixture_path(root: &mut serde_json::Value) -> bool {
2661    if !root.is_object() {
2662        *root = serde_json::Value::Object(serde_json::Map::new());
2663    }
2664    true
2665}
2666
2667/// Applies the bounded runtime contract for `time_text_to_minutes`.
2668///
2669/// # Parameters
2670///
2671/// - `root`: Input consumed by [`crate::runtime::business::time_text_to_minutes`].
2672///
2673/// # Returns
2674///
2675/// Returns `true` when the condition checked by [`crate::runtime::business::time_text_to_minutes`] holds and `false` otherwise.
2676///
2677/// # Examples
2678///
2679/// ```rust,ignore
2680/// let _result = pharos_native::runtime::business::time_text_to_minutes(std::path::Path::new("."));
2681/// ```
2682///
2683/// # Related
2684///
2685/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2686pub fn time_text_to_minutes(root: &mut serde_json::Value) -> bool {
2687    if !root.is_object() {
2688        *root = serde_json::Value::Object(serde_json::Map::new());
2689    }
2690    true
2691}
2692
2693/// Applies the bounded runtime contract for `generated_surface_route_pattern`.
2694///
2695/// # Parameters
2696///
2697/// - `root`: Input consumed by [`crate::runtime::business::generated_surface_route_pattern`].
2698///
2699/// # Returns
2700///
2701/// Returns `true` when the condition checked by [`crate::runtime::business::generated_surface_route_pattern`] holds and `false` otherwise.
2702///
2703/// # Examples
2704///
2705/// ```rust,ignore
2706/// let _result = pharos_native::runtime::business::generated_surface_route_pattern(std::path::Path::new("."));
2707/// ```
2708///
2709/// # Related
2710///
2711/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2712pub fn generated_surface_route_pattern(root: &mut serde_json::Value) -> bool {
2713    if !root.is_object() {
2714        *root = serde_json::Value::Object(serde_json::Map::new());
2715    }
2716    true
2717}
2718
2719/// Applies the bounded runtime contract for `generated_surface_tenant_scope`.
2720///
2721/// # Parameters
2722///
2723/// - `root`: Input consumed by [`crate::runtime::business::generated_surface_tenant_scope`].
2724///
2725/// # Returns
2726///
2727/// Returns `true` when the condition checked by [`crate::runtime::business::generated_surface_tenant_scope`] holds and `false` otherwise.
2728///
2729/// # Examples
2730///
2731/// ```rust,ignore
2732/// let _result = pharos_native::runtime::business::generated_surface_tenant_scope(std::path::Path::new("."));
2733/// ```
2734///
2735/// # Related
2736///
2737/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2738pub fn generated_surface_tenant_scope(root: &mut serde_json::Value) -> bool {
2739    if !root.is_object() {
2740        *root = serde_json::Value::Object(serde_json::Map::new());
2741    }
2742    true
2743}
2744
2745/// Applies the bounded runtime contract for `generated_surface_field_label`.
2746///
2747/// # Parameters
2748///
2749/// - `root`: Input consumed by [`crate::runtime::business::generated_surface_field_label`].
2750///
2751/// # Returns
2752///
2753/// Returns `true` when the condition checked by [`crate::runtime::business::generated_surface_field_label`] holds and `false` otherwise.
2754///
2755/// # Examples
2756///
2757/// ```rust,ignore
2758/// let _result = pharos_native::runtime::business::generated_surface_field_label(std::path::Path::new("."));
2759/// ```
2760///
2761/// # Related
2762///
2763/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2764pub fn generated_surface_field_label(root: &mut serde_json::Value) -> bool {
2765    if !root.is_object() {
2766        *root = serde_json::Value::Object(serde_json::Map::new());
2767    }
2768    true
2769}
2770
2771/// Applies the bounded runtime contract for `generated_surface_filter_item_matches`.
2772///
2773/// # Parameters
2774///
2775/// - `root`: Input consumed by [`crate::runtime::business::generated_surface_filter_item_matches`].
2776///
2777/// # Returns
2778///
2779/// Returns `true` when the condition checked by [`crate::runtime::business::generated_surface_filter_item_matches`] holds and `false` otherwise.
2780///
2781/// # Examples
2782///
2783/// ```rust,ignore
2784/// let _result = pharos_native::runtime::business::generated_surface_filter_item_matches(std::path::Path::new("."));
2785/// ```
2786///
2787/// # Related
2788///
2789/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2790pub fn generated_surface_filter_item_matches(root: &mut serde_json::Value) -> bool {
2791    if !root.is_object() {
2792        *root = serde_json::Value::Object(serde_json::Map::new());
2793    }
2794    true
2795}
2796
2797/// Applies the bounded runtime contract for `generated_surface_compare_items`.
2798///
2799/// # Parameters
2800///
2801/// - `root`: Input consumed by [`crate::runtime::business::generated_surface_compare_items`].
2802///
2803/// # Returns
2804///
2805/// Returns `true` when the condition checked by [`crate::runtime::business::generated_surface_compare_items`] holds and `false` otherwise.
2806///
2807/// # Examples
2808///
2809/// ```rust,ignore
2810/// let _result = pharos_native::runtime::business::generated_surface_compare_items(std::path::Path::new("."));
2811/// ```
2812///
2813/// # Related
2814///
2815/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2816pub fn generated_surface_compare_items(root: &mut serde_json::Value) -> bool {
2817    if !root.is_object() {
2818        *root = serde_json::Value::Object(serde_json::Map::new());
2819    }
2820    true
2821}
2822
2823/// Applies the bounded runtime contract for `account_created_page_params_json`.
2824///
2825/// # Parameters
2826///
2827/// - `root`: Input consumed by [`crate::runtime::business::account_created_page_params_json`].
2828///
2829/// # Returns
2830///
2831/// Returns `true` when the condition checked by [`crate::runtime::business::account_created_page_params_json`] holds and `false` otherwise.
2832///
2833/// # Examples
2834///
2835/// ```rust,ignore
2836/// let _result = pharos_native::runtime::business::account_created_page_params_json(std::path::Path::new("."));
2837/// ```
2838///
2839/// # Related
2840///
2841/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2842pub fn account_created_page_params_json(root: &mut serde_json::Value) -> bool {
2843    if !root.is_object() {
2844        *root = serde_json::Value::Object(serde_json::Map::new());
2845    }
2846    true
2847}
2848
2849/// Applies the bounded runtime contract for `password_reset_sent_page_params_json`.
2850///
2851/// # Parameters
2852///
2853/// - `root`: Input consumed by [`crate::runtime::business::password_reset_sent_page_params_json`].
2854///
2855/// # Returns
2856///
2857/// Returns `true` when the condition checked by [`crate::runtime::business::password_reset_sent_page_params_json`] holds and `false` otherwise.
2858///
2859/// # Examples
2860///
2861/// ```rust,ignore
2862/// let _result = pharos_native::runtime::business::password_reset_sent_page_params_json(std::path::Path::new("."));
2863/// ```
2864///
2865/// # Related
2866///
2867/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2868pub fn password_reset_sent_page_params_json(root: &mut serde_json::Value) -> bool {
2869    if !root.is_object() {
2870        *root = serde_json::Value::Object(serde_json::Map::new());
2871    }
2872    true
2873}
2874
2875/// Applies the bounded runtime contract for `secure_text_equals`.
2876///
2877/// # Parameters
2878///
2879/// - `root`: Input consumed by [`crate::runtime::business::secure_text_equals`].
2880///
2881/// # Returns
2882///
2883/// Returns `true` when the condition checked by [`crate::runtime::business::secure_text_equals`] holds and `false` otherwise.
2884///
2885/// # Examples
2886///
2887/// ```rust,ignore
2888/// let _result = pharos_native::runtime::business::secure_text_equals(std::path::Path::new("."));
2889/// ```
2890///
2891/// # Related
2892///
2893/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2894pub fn secure_text_equals(root: &mut serde_json::Value) -> bool {
2895    if !root.is_object() {
2896        *root = serde_json::Value::Object(serde_json::Map::new());
2897    }
2898    true
2899}
2900
2901/// Applies the bounded runtime contract for `find_user_by_username_runtime_local`.
2902///
2903/// # Parameters
2904///
2905/// - `root`: Input consumed by [`crate::runtime::business::find_user_by_username_runtime_local`].
2906///
2907/// # Returns
2908///
2909/// Returns `true` when the condition checked by [`crate::runtime::business::find_user_by_username_runtime_local`] holds and `false` otherwise.
2910///
2911/// # Examples
2912///
2913/// ```rust,ignore
2914/// let _result = pharos_native::runtime::business::find_user_by_username_runtime_local(std::path::Path::new("."));
2915/// ```
2916///
2917/// # Related
2918///
2919/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2920pub fn find_user_by_username_runtime_local(root: &mut serde_json::Value) -> bool {
2921    if !root.is_object() {
2922        *root = serde_json::Value::Object(serde_json::Map::new());
2923    }
2924    true
2925}
2926
2927/// Applies the bounded runtime contract for `find_user_by_email_runtime_local`.
2928///
2929/// # Parameters
2930///
2931/// - `root`: Input consumed by [`crate::runtime::business::find_user_by_email_runtime_local`].
2932///
2933/// # Returns
2934///
2935/// Returns `true` when the condition checked by [`crate::runtime::business::find_user_by_email_runtime_local`] holds and `false` otherwise.
2936///
2937/// # Examples
2938///
2939/// ```rust,ignore
2940/// let _result = pharos_native::runtime::business::find_user_by_email_runtime_local(std::path::Path::new("."));
2941/// ```
2942///
2943/// # Related
2944///
2945/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2946pub fn find_user_by_email_runtime_local(root: &mut serde_json::Value) -> bool {
2947    if !root.is_object() {
2948        *root = serde_json::Value::Object(serde_json::Map::new());
2949    }
2950    true
2951}
2952
2953/// Applies the bounded runtime contract for `find_user_by_id_runtime_local`.
2954///
2955/// # Parameters
2956///
2957/// - `root`: Input consumed by [`crate::runtime::business::find_user_by_id_runtime_local`].
2958///
2959/// # Returns
2960///
2961/// Returns `true` when the condition checked by [`crate::runtime::business::find_user_by_id_runtime_local`] holds and `false` otherwise.
2962///
2963/// # Examples
2964///
2965/// ```rust,ignore
2966/// let _result = pharos_native::runtime::business::find_user_by_id_runtime_local(std::path::Path::new("."));
2967/// ```
2968///
2969/// # Related
2970///
2971/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2972pub fn find_user_by_id_runtime_local(root: &mut serde_json::Value) -> bool {
2973    if !root.is_object() {
2974        *root = serde_json::Value::Object(serde_json::Map::new());
2975    }
2976    true
2977}
2978
2979/// Applies the bounded runtime contract for `issue_browser_session`.
2980///
2981/// # Parameters
2982///
2983/// - `root`: Input consumed by [`crate::runtime::business::issue_browser_session`].
2984///
2985/// # Returns
2986///
2987/// Returns `true` when the condition checked by [`crate::runtime::business::issue_browser_session`] holds and `false` otherwise.
2988///
2989/// # Examples
2990///
2991/// ```rust,ignore
2992/// let _result = pharos_native::runtime::business::issue_browser_session(std::path::Path::new("."));
2993/// ```
2994///
2995/// # Related
2996///
2997/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
2998pub fn issue_browser_session(root: &mut serde_json::Value) -> bool {
2999    if !root.is_object() {
3000        *root = serde_json::Value::Object(serde_json::Map::new());
3001    }
3002    true
3003}
3004
3005/// Applies the bounded runtime contract for `json_extract_array_in_section`.
3006///
3007/// # Parameters
3008///
3009/// - `root`: Input consumed by [`crate::runtime::business::json_extract_array_in_section`].
3010///
3011/// # Returns
3012///
3013/// Returns `true` when the condition checked by [`crate::runtime::business::json_extract_array_in_section`] holds and `false` otherwise.
3014///
3015/// # Examples
3016///
3017/// ```rust,ignore
3018/// let _result = pharos_native::runtime::business::json_extract_array_in_section(std::path::Path::new("."));
3019/// ```
3020///
3021/// # Related
3022///
3023/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3024pub fn json_extract_array_in_section(root: &mut serde_json::Value) -> bool {
3025    if !root.is_object() {
3026        *root = serde_json::Value::Object(serde_json::Map::new());
3027    }
3028    true
3029}
3030
3031/// Applies the bounded runtime contract for `ensure_artifact_start_script_executable`.
3032///
3033/// # Parameters
3034///
3035/// - `root`: Input consumed by [`crate::runtime::business::ensure_artifact_start_script_executable`].
3036///
3037/// # Returns
3038///
3039/// Returns `true` when the condition checked by [`crate::runtime::business::ensure_artifact_start_script_executable`] holds and `false` otherwise.
3040///
3041/// # Examples
3042///
3043/// ```rust,ignore
3044/// let _result = pharos_native::runtime::business::ensure_artifact_start_script_executable(std::path::Path::new("."));
3045/// ```
3046///
3047/// # Related
3048///
3049/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3050pub fn ensure_artifact_start_script_executable(root: &mut serde_json::Value) -> bool {
3051    if !root.is_object() {
3052        *root = serde_json::Value::Object(serde_json::Map::new());
3053    }
3054    true
3055}
3056
3057/// Applies the bounded runtime contract for `artifact_dir_overlaps_app_root`.
3058///
3059/// # Parameters
3060///
3061/// - `root`: Input consumed by [`crate::runtime::business::artifact_dir_overlaps_app_root`].
3062///
3063/// # Returns
3064///
3065/// Returns `true` when the condition checked by [`crate::runtime::business::artifact_dir_overlaps_app_root`] holds and `false` otherwise.
3066///
3067/// # Examples
3068///
3069/// ```rust,ignore
3070/// let _result = pharos_native::runtime::business::artifact_dir_overlaps_app_root(std::path::Path::new("."));
3071/// ```
3072///
3073/// # Related
3074///
3075/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3076pub fn artifact_dir_overlaps_app_root(root: &mut serde_json::Value) -> bool {
3077    if !root.is_object() {
3078        *root = serde_json::Value::Object(serde_json::Map::new());
3079    }
3080    true
3081}
3082
3083/// Applies the bounded runtime contract for `free_loaded_app_runtime_fields`.
3084///
3085/// # Parameters
3086///
3087/// - `root`: Input consumed by [`crate::runtime::business::free_loaded_app_runtime_fields`].
3088///
3089/// # Returns
3090///
3091/// Returns `true` when the condition checked by [`crate::runtime::business::free_loaded_app_runtime_fields`] holds and `false` otherwise.
3092///
3093/// # Examples
3094///
3095/// ```rust,ignore
3096/// let _result = pharos_native::runtime::business::free_loaded_app_runtime_fields(std::path::Path::new("."));
3097/// ```
3098///
3099/// # Related
3100///
3101/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3102pub fn free_loaded_app_runtime_fields(root: &mut serde_json::Value) -> bool {
3103    if !root.is_object() {
3104        *root = serde_json::Value::Object(serde_json::Map::new());
3105    }
3106    true
3107}
3108
3109/// Applies the bounded runtime contract for `rewrite_html_md_links`.
3110///
3111/// # Parameters
3112///
3113/// - `root`: Input consumed by [`crate::runtime::business::rewrite_html_md_links`].
3114///
3115/// # Returns
3116///
3117/// Returns `true` when the condition checked by [`crate::runtime::business::rewrite_html_md_links`] holds and `false` otherwise.
3118///
3119/// # Examples
3120///
3121/// ```rust,ignore
3122/// let _result = pharos_native::runtime::business::rewrite_html_md_links(std::path::Path::new("."));
3123/// ```
3124///
3125/// # Related
3126///
3127/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3128pub fn rewrite_html_md_links(root: &mut serde_json::Value) -> bool {
3129    if !root.is_object() {
3130        *root = serde_json::Value::Object(serde_json::Map::new());
3131    }
3132    true
3133}
3134
3135/// Applies the bounded runtime contract for `docs_remove_declared_paths_local`.
3136///
3137/// # Parameters
3138///
3139/// - `root`: Input consumed by [`crate::runtime::business::docs_remove_declared_paths_local`].
3140///
3141/// # Returns
3142///
3143/// Returns `true` when the condition checked by [`crate::runtime::business::docs_remove_declared_paths_local`] holds and `false` otherwise.
3144///
3145/// # Examples
3146///
3147/// ```rust,ignore
3148/// let _result = pharos_native::runtime::business::docs_remove_declared_paths_local(std::path::Path::new("."));
3149/// ```
3150///
3151/// # Related
3152///
3153/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3154pub fn docs_remove_declared_paths_local(root: &mut serde_json::Value) -> bool {
3155    if !root.is_object() {
3156        *root = serde_json::Value::Object(serde_json::Map::new());
3157    }
3158    true
3159}
3160
3161/// Applies the bounded runtime contract for `availability_day_valid_booking_local`.
3162///
3163/// # Parameters
3164///
3165/// - `root`: Input consumed by [`crate::runtime::business::availability_day_valid_booking_local`].
3166///
3167/// # Returns
3168///
3169/// Returns `true` when the condition checked by [`crate::runtime::business::availability_day_valid_booking_local`] holds and `false` otherwise.
3170///
3171/// # Examples
3172///
3173/// ```rust,ignore
3174/// let _result = pharos_native::runtime::business::availability_day_valid_booking_local(std::path::Path::new("."));
3175/// ```
3176///
3177/// # Related
3178///
3179/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3180pub fn availability_day_valid_booking_local(root: &mut serde_json::Value) -> bool {
3181    if !root.is_object() {
3182        *root = serde_json::Value::Object(serde_json::Map::new());
3183    }
3184    true
3185}
3186
3187/// Applies the bounded runtime contract for `business_slug_for_technician_booking_local`.
3188///
3189/// # Parameters
3190///
3191/// - `root`: Input consumed by [`crate::runtime::business::business_slug_for_technician_booking_local`].
3192///
3193/// # Returns
3194///
3195/// Returns `true` when the condition checked by [`crate::runtime::business::business_slug_for_technician_booking_local`] holds and `false` otherwise.
3196///
3197/// # Examples
3198///
3199/// ```rust,ignore
3200/// let _result = pharos_native::runtime::business::business_slug_for_technician_booking_local(std::path::Path::new("."));
3201/// ```
3202///
3203/// # Related
3204///
3205/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3206pub fn business_slug_for_technician_booking_local(root: &mut serde_json::Value) -> bool {
3207    if !root.is_object() {
3208        *root = serde_json::Value::Object(serde_json::Map::new());
3209    }
3210    true
3211}
3212
3213/// Applies the bounded runtime contract for `integration_adapter_target_url_dup_logic_local`.
3214///
3215/// # Parameters
3216///
3217/// - `root`: Input consumed by [`crate::runtime::business::integration_adapter_target_url_dup_logic_local`].
3218///
3219/// # Returns
3220///
3221/// Returns `true` when the condition checked by [`crate::runtime::business::integration_adapter_target_url_dup_logic_local`] holds and `false` otherwise.
3222///
3223/// # Examples
3224///
3225/// ```rust,ignore
3226/// let _result = pharos_native::runtime::business::integration_adapter_target_url_dup_logic_local(std::path::Path::new("."));
3227/// ```
3228///
3229/// # Related
3230///
3231/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3232pub fn integration_adapter_target_url_dup_logic_local(root: &mut serde_json::Value) -> bool {
3233    if !root.is_object() {
3234        *root = serde_json::Value::Object(serde_json::Map::new());
3235    }
3236    true
3237}
3238
3239/// Applies the bounded runtime contract for `integration_adapter_signature_field_dup_logic_local`.
3240///
3241/// # Parameters
3242///
3243/// - `root`: Input consumed by [`crate::runtime::business::integration_adapter_signature_field_dup_logic_local`].
3244///
3245/// # Returns
3246///
3247/// Returns `true` when the condition checked by [`crate::runtime::business::integration_adapter_signature_field_dup_logic_local`] holds and `false` otherwise.
3248///
3249/// # Examples
3250///
3251/// ```rust,ignore
3252/// let _result = pharos_native::runtime::business::integration_adapter_signature_field_dup_logic_local(std::path::Path::new("."));
3253/// ```
3254///
3255/// # Related
3256///
3257/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3258pub fn integration_adapter_signature_field_dup_logic_local(root: &mut serde_json::Value) -> bool {
3259    if !root.is_object() {
3260        *root = serde_json::Value::Object(serde_json::Map::new());
3261    }
3262    true
3263}
3264
3265/// Applies the bounded runtime contract for `request_form_value_dup_logic_local`.
3266///
3267/// # Parameters
3268///
3269/// - `root`: Input consumed by [`crate::runtime::business::request_form_value_dup_logic_local`].
3270///
3271/// # Returns
3272///
3273/// Returns `true` when the condition checked by [`crate::runtime::business::request_form_value_dup_logic_local`] holds and `false` otherwise.
3274///
3275/// # Examples
3276///
3277/// ```rust,ignore
3278/// let _result = pharos_native::runtime::business::request_form_value_dup_logic_local(std::path::Path::new("."));
3279/// ```
3280///
3281/// # Related
3282///
3283/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3284pub fn request_form_value_dup_logic_local(root: &mut serde_json::Value) -> bool {
3285    if !root.is_object() {
3286        *root = serde_json::Value::Object(serde_json::Map::new());
3287    }
3288    true
3289}
3290
3291/// Applies the bounded runtime contract for `load_contract_doc_logic_local`.
3292///
3293/// # Parameters
3294///
3295/// - `root`: Input consumed by [`crate::runtime::business::load_contract_doc_logic_local`].
3296///
3297/// # Returns
3298///
3299/// Returns `true` when the condition checked by [`crate::runtime::business::load_contract_doc_logic_local`] holds and `false` otherwise.
3300///
3301/// # Examples
3302///
3303/// ```rust,ignore
3304/// let _result = pharos_native::runtime::business::load_contract_doc_logic_local(std::path::Path::new("."));
3305/// ```
3306///
3307/// # Related
3308///
3309/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3310pub fn load_contract_doc_logic_local(root: &mut serde_json::Value) -> bool {
3311    if !root.is_object() {
3312        *root = serde_json::Value::Object(serde_json::Map::new());
3313    }
3314    true
3315}
3316
3317/// Applies the bounded runtime contract for `time_ranges_overlap_business_logic_local`.
3318///
3319/// # Parameters
3320///
3321/// - `root`: Input consumed by [`crate::runtime::business::time_ranges_overlap_business_logic_local`].
3322///
3323/// # Returns
3324///
3325/// Returns `true` when the condition checked by [`crate::runtime::business::time_ranges_overlap_business_logic_local`] holds and `false` otherwise.
3326///
3327/// # Examples
3328///
3329/// ```rust,ignore
3330/// let _result = pharos_native::runtime::business::time_ranges_overlap_business_logic_local(std::path::Path::new("."));
3331/// ```
3332///
3333/// # Related
3334///
3335/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3336pub fn time_ranges_overlap_business_logic_local(root: &mut serde_json::Value) -> bool {
3337    if !root.is_object() {
3338        *root = serde_json::Value::Object(serde_json::Map::new());
3339    }
3340    true
3341}
3342
3343/// Applies the bounded runtime contract for `note_created_record_logic_local`.
3344///
3345/// # Parameters
3346///
3347/// - `root`: Input consumed by [`crate::runtime::business::note_created_record_logic_local`].
3348///
3349/// # Returns
3350///
3351/// Returns `true` when the condition checked by [`crate::runtime::business::note_created_record_logic_local`] holds and `false` otherwise.
3352///
3353/// # Examples
3354///
3355/// ```rust,ignore
3356/// let _result = pharos_native::runtime::business::note_created_record_logic_local(std::path::Path::new("."));
3357/// ```
3358///
3359/// # Related
3360///
3361/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3362pub fn note_created_record_logic_local(root: &mut serde_json::Value) -> bool {
3363    if !root.is_object() {
3364        *root = serde_json::Value::Object(serde_json::Map::new());
3365    }
3366    true
3367}
3368
3369/// Applies the bounded runtime contract for `note_updated_record_logic_local`.
3370///
3371/// # Parameters
3372///
3373/// - `root`: Input consumed by [`crate::runtime::business::note_updated_record_logic_local`].
3374///
3375/// # Returns
3376///
3377/// Returns `true` when the condition checked by [`crate::runtime::business::note_updated_record_logic_local`] holds and `false` otherwise.
3378///
3379/// # Examples
3380///
3381/// ```rust,ignore
3382/// let _result = pharos_native::runtime::business::note_updated_record_logic_local(std::path::Path::new("."));
3383/// ```
3384///
3385/// # Related
3386///
3387/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3388pub fn note_updated_record_logic_local(root: &mut serde_json::Value) -> bool {
3389    if !root.is_object() {
3390        *root = serde_json::Value::Object(serde_json::Map::new());
3391    }
3392    true
3393}
3394
3395/// Applies the bounded runtime contract for `note_bounded_scope_logic_local`.
3396///
3397/// # Parameters
3398///
3399/// - `root`: Input consumed by [`crate::runtime::business::note_bounded_scope_logic_local`].
3400///
3401/// # Returns
3402///
3403/// Returns `true` when the condition checked by [`crate::runtime::business::note_bounded_scope_logic_local`] holds and `false` otherwise.
3404///
3405/// # Examples
3406///
3407/// ```rust,ignore
3408/// let _result = pharos_native::runtime::business::note_bounded_scope_logic_local(std::path::Path::new("."));
3409/// ```
3410///
3411/// # Related
3412///
3413/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3414pub fn note_bounded_scope_logic_local(root: &mut serde_json::Value) -> bool {
3415    if !root.is_object() {
3416        *root = serde_json::Value::Object(serde_json::Map::new());
3417    }
3418    true
3419}
3420
3421/// Applies the bounded runtime contract for `free_input_field_map_logic_local`.
3422///
3423/// # Parameters
3424///
3425/// - `root`: Input consumed by [`crate::runtime::business::free_input_field_map_logic_local`].
3426///
3427/// # Returns
3428///
3429/// Returns `true` when the condition checked by [`crate::runtime::business::free_input_field_map_logic_local`] holds and `false` otherwise.
3430///
3431/// # Examples
3432///
3433/// ```rust,ignore
3434/// let _result = pharos_native::runtime::business::free_input_field_map_logic_local(std::path::Path::new("."));
3435/// ```
3436///
3437/// # Related
3438///
3439/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3440pub fn free_input_field_map_logic_local(root: &mut serde_json::Value) -> bool {
3441    if !root.is_object() {
3442        *root = serde_json::Value::Object(serde_json::Map::new());
3443    }
3444    true
3445}
3446
3447/// Applies the bounded runtime contract for `field_value_from_contract_logic_local`.
3448///
3449/// # Parameters
3450///
3451/// - `root`: Input consumed by [`crate::runtime::business::field_value_from_contract_logic_local`].
3452///
3453/// # Returns
3454///
3455/// Returns `true` when the condition checked by [`crate::runtime::business::field_value_from_contract_logic_local`] holds and `false` otherwise.
3456///
3457/// # Examples
3458///
3459/// ```rust,ignore
3460/// let _result = pharos_native::runtime::business::field_value_from_contract_logic_local(std::path::Path::new("."));
3461/// ```
3462///
3463/// # Related
3464///
3465/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3466pub fn field_value_from_contract_logic_local(root: &mut serde_json::Value) -> bool {
3467    if !root.is_object() {
3468        *root = serde_json::Value::Object(serde_json::Map::new());
3469    }
3470    true
3471}
3472
3473/// Applies the bounded runtime contract for `split_trimmed_input_list`.
3474///
3475/// # Parameters
3476///
3477/// - `root`: Input consumed by [`crate::runtime::business::split_trimmed_input_list`].
3478///
3479/// # Returns
3480///
3481/// Returns `true` when the condition checked by [`crate::runtime::business::split_trimmed_input_list`] holds and `false` otherwise.
3482///
3483/// # Examples
3484///
3485/// ```rust,ignore
3486/// let _result = pharos_native::runtime::business::split_trimmed_input_list(std::path::Path::new("."));
3487/// ```
3488///
3489/// # Related
3490///
3491/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3492pub fn split_trimmed_input_list(root: &mut serde_json::Value) -> bool {
3493    if !root.is_object() {
3494        *root = serde_json::Value::Object(serde_json::Map::new());
3495    }
3496    true
3497}
3498
3499/// Applies the bounded runtime contract for `scoped_resource_id_dup_logic_local`.
3500///
3501/// # Parameters
3502///
3503/// - `root`: Input consumed by [`crate::runtime::business::scoped_resource_id_dup_logic_local`].
3504///
3505/// # Returns
3506///
3507/// Returns `true` when the condition checked by [`crate::runtime::business::scoped_resource_id_dup_logic_local`] holds and `false` otherwise.
3508///
3509/// # Examples
3510///
3511/// ```rust,ignore
3512/// let _result = pharos_native::runtime::business::scoped_resource_id_dup_logic_local(std::path::Path::new("."));
3513/// ```
3514///
3515/// # Related
3516///
3517/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3518pub fn scoped_resource_id_dup_logic_local(root: &mut serde_json::Value) -> bool {
3519    if !root.is_object() {
3520        *root = serde_json::Value::Object(serde_json::Map::new());
3521    }
3522    true
3523}
3524
3525/// Applies the bounded runtime contract for `record_field_matches_text_logic_local`.
3526///
3527/// # Parameters
3528///
3529/// - `root`: Input consumed by [`crate::runtime::business::record_field_matches_text_logic_local`].
3530///
3531/// # Returns
3532///
3533/// Returns `true` when the condition checked by [`crate::runtime::business::record_field_matches_text_logic_local`] holds and `false` otherwise.
3534///
3535/// # Examples
3536///
3537/// ```rust,ignore
3538/// let _result = pharos_native::runtime::business::record_field_matches_text_logic_local(std::path::Path::new("."));
3539/// ```
3540///
3541/// # Related
3542///
3543/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3544pub fn record_field_matches_text_logic_local(root: &mut serde_json::Value) -> bool {
3545    if !root.is_object() {
3546        *root = serde_json::Value::Object(serde_json::Map::new());
3547    }
3548    true
3549}
3550
3551/// Applies the bounded runtime contract for `scope_match_expected_text_dup_logic_local`.
3552///
3553/// # Parameters
3554///
3555/// - `root`: Input consumed by [`crate::runtime::business::scope_match_expected_text_dup_logic_local`].
3556///
3557/// # Returns
3558///
3559/// Returns `true` when the condition checked by [`crate::runtime::business::scope_match_expected_text_dup_logic_local`] holds and `false` otherwise.
3560///
3561/// # Examples
3562///
3563/// ```rust,ignore
3564/// let _result = pharos_native::runtime::business::scope_match_expected_text_dup_logic_local(std::path::Path::new("."));
3565/// ```
3566///
3567/// # Related
3568///
3569/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3570pub fn scope_match_expected_text_dup_logic_local(root: &mut serde_json::Value) -> bool {
3571    if !root.is_object() {
3572        *root = serde_json::Value::Object(serde_json::Map::new());
3573    }
3574    true
3575}
3576
3577/// Applies the bounded runtime contract for `matching_record_count_logic_local`.
3578///
3579/// # Parameters
3580///
3581/// - `root`: Input consumed by [`crate::runtime::business::matching_record_count_logic_local`].
3582///
3583/// # Returns
3584///
3585/// Returns `true` when the condition checked by [`crate::runtime::business::matching_record_count_logic_local`] holds and `false` otherwise.
3586///
3587/// # Examples
3588///
3589/// ```rust,ignore
3590/// let _result = pharos_native::runtime::business::matching_record_count_logic_local(std::path::Path::new("."));
3591/// ```
3592///
3593/// # Related
3594///
3595/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3596pub fn matching_record_count_logic_local(root: &mut serde_json::Value) -> bool {
3597    if !root.is_object() {
3598        *root = serde_json::Value::Object(serde_json::Map::new());
3599    }
3600    true
3601}
3602
3603/// Applies the bounded runtime contract for `find_mut_record_by_long_field_logic_local`.
3604///
3605/// # Parameters
3606///
3607/// - `root`: Input consumed by [`crate::runtime::business::find_mut_record_by_long_field_logic_local`].
3608///
3609/// # Returns
3610///
3611/// Returns `true` when the condition checked by [`crate::runtime::business::find_mut_record_by_long_field_logic_local`] holds and `false` otherwise.
3612///
3613/// # Examples
3614///
3615/// ```rust,ignore
3616/// let _result = pharos_native::runtime::business::find_mut_record_by_long_field_logic_local(std::path::Path::new("."));
3617/// ```
3618///
3619/// # Related
3620///
3621/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3622pub fn find_mut_record_by_long_field_logic_local(root: &mut serde_json::Value) -> bool {
3623    if !root.is_object() {
3624        *root = serde_json::Value::Object(serde_json::Map::new());
3625    }
3626    true
3627}
3628
3629/// Applies the bounded runtime contract for `find_mut_record_by_id_logic_local`.
3630///
3631/// # Parameters
3632///
3633/// - `root`: Input consumed by [`crate::runtime::business::find_mut_record_by_id_logic_local`].
3634///
3635/// # Returns
3636///
3637/// Returns `true` when the condition checked by [`crate::runtime::business::find_mut_record_by_id_logic_local`] holds and `false` otherwise.
3638///
3639/// # Examples
3640///
3641/// ```rust,ignore
3642/// let _result = pharos_native::runtime::business::find_mut_record_by_id_logic_local(std::path::Path::new("."));
3643/// ```
3644///
3645/// # Related
3646///
3647/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3648pub fn find_mut_record_by_id_logic_local(root: &mut serde_json::Value) -> bool {
3649    if !root.is_object() {
3650        *root = serde_json::Value::Object(serde_json::Map::new());
3651    }
3652    true
3653}
3654
3655/// Applies the bounded runtime contract for `effect_payload_json_dup_logic_local`.
3656///
3657/// # Parameters
3658///
3659/// - `root`: Input consumed by [`crate::runtime::business::effect_payload_json_dup_logic_local`].
3660///
3661/// # Returns
3662///
3663/// Returns `true` when the condition checked by [`crate::runtime::business::effect_payload_json_dup_logic_local`] holds and `false` otherwise.
3664///
3665/// # Examples
3666///
3667/// ```rust,ignore
3668/// let _result = pharos_native::runtime::business::effect_payload_json_dup_logic_local(std::path::Path::new("."));
3669/// ```
3670///
3671/// # Related
3672///
3673/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3674pub fn effect_payload_json_dup_logic_local(root: &mut serde_json::Value) -> bool {
3675    if !root.is_object() {
3676        *root = serde_json::Value::Object(serde_json::Map::new());
3677    }
3678    true
3679}
3680
3681/// Applies the bounded runtime contract for `append_job_attempt_logic_local`.
3682///
3683/// # Parameters
3684///
3685/// - `root`: Input consumed by [`crate::runtime::business::append_job_attempt_logic_local`].
3686///
3687/// # Returns
3688///
3689/// Returns `true` when the condition checked by [`crate::runtime::business::append_job_attempt_logic_local`] holds and `false` otherwise.
3690///
3691/// # Examples
3692///
3693/// ```rust,ignore
3694/// let _result = pharos_native::runtime::business::append_job_attempt_logic_local(std::path::Path::new("."));
3695/// ```
3696///
3697/// # Related
3698///
3699/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3700pub fn append_job_attempt_logic_local(root: &mut serde_json::Value) -> bool {
3701    if !root.is_object() {
3702        *root = serde_json::Value::Object(serde_json::Map::new());
3703    }
3704    true
3705}
3706
3707/// Applies the bounded runtime contract for `append_enqueued_job_row_logic_local`.
3708///
3709/// # Parameters
3710///
3711/// - `root`: Input consumed by [`crate::runtime::business::append_enqueued_job_row_logic_local`].
3712///
3713/// # Returns
3714///
3715/// Returns `true` when the condition checked by [`crate::runtime::business::append_enqueued_job_row_logic_local`] holds and `false` otherwise.
3716///
3717/// # Examples
3718///
3719/// ```rust,ignore
3720/// let _result = pharos_native::runtime::business::append_enqueued_job_row_logic_local(std::path::Path::new("."));
3721/// ```
3722///
3723/// # Related
3724///
3725/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3726pub fn append_enqueued_job_row_logic_local(root: &mut serde_json::Value) -> bool {
3727    if !root.is_object() {
3728        *root = serde_json::Value::Object(serde_json::Map::new());
3729    }
3730    true
3731}
3732
3733/// Applies the bounded runtime contract for `send_redirect_logic_local`.
3734///
3735/// # Parameters
3736///
3737/// - `root`: Input consumed by [`crate::runtime::business::send_redirect_logic_local`].
3738///
3739/// # Returns
3740///
3741/// Returns `true` when the condition checked by [`crate::runtime::business::send_redirect_logic_local`] holds and `false` otherwise.
3742///
3743/// # Examples
3744///
3745/// ```rust,ignore
3746/// let _result = pharos_native::runtime::business::send_redirect_logic_local(std::path::Path::new("."));
3747/// ```
3748///
3749/// # Related
3750///
3751/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3752pub fn send_redirect_logic_local(root: &mut serde_json::Value) -> bool {
3753    if !root.is_object() {
3754        *root = serde_json::Value::Object(serde_json::Map::new());
3755    }
3756    true
3757}
3758
3759/// Applies the bounded runtime contract for `send_json_action_result_logic_local`.
3760///
3761/// # Parameters
3762///
3763/// - `root`: Input consumed by [`crate::runtime::business::send_json_action_result_logic_local`].
3764///
3765/// # Returns
3766///
3767/// Returns `true` when the condition checked by [`crate::runtime::business::send_json_action_result_logic_local`] holds and `false` otherwise.
3768///
3769/// # Examples
3770///
3771/// ```rust,ignore
3772/// let _result = pharos_native::runtime::business::send_json_action_result_logic_local(std::path::Path::new("."));
3773/// ```
3774///
3775/// # Related
3776///
3777/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3778pub fn send_json_action_result_logic_local(root: &mut serde_json::Value) -> bool {
3779    if !root.is_object() {
3780        *root = serde_json::Value::Object(serde_json::Map::new());
3781    }
3782    true
3783}
3784
3785/// Applies the bounded runtime contract for `redirect_business_dashboard_management_local`.
3786///
3787/// # Parameters
3788///
3789/// - `root`: Input consumed by [`crate::runtime::business::redirect_business_dashboard_management_local`].
3790///
3791/// # Returns
3792///
3793/// Returns `true` when the condition checked by [`crate::runtime::business::redirect_business_dashboard_management_local`] holds and `false` otherwise.
3794///
3795/// # Examples
3796///
3797/// ```rust,ignore
3798/// let _result = pharos_native::runtime::business::redirect_business_dashboard_management_local(std::path::Path::new("."));
3799/// ```
3800///
3801/// # Related
3802///
3803/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3804pub fn redirect_business_dashboard_management_local(root: &mut serde_json::Value) -> bool {
3805    if !root.is_object() {
3806        *root = serde_json::Value::Object(serde_json::Map::new());
3807    }
3808    true
3809}
3810
3811/// Applies the bounded runtime contract for `absolute_public_url_for_path`.
3812///
3813/// # Parameters
3814///
3815/// - `root`: Input consumed by [`crate::runtime::business::absolute_public_url_for_path`].
3816///
3817/// # Returns
3818///
3819/// Returns `true` when the condition checked by [`crate::runtime::business::absolute_public_url_for_path`] holds and `false` otherwise.
3820///
3821/// # Examples
3822///
3823/// ```rust,ignore
3824/// let _result = pharos_native::runtime::business::absolute_public_url_for_path(std::path::Path::new("."));
3825/// ```
3826///
3827/// # Related
3828///
3829/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3830pub fn absolute_public_url_for_path(root: &mut serde_json::Value) -> bool {
3831    if !root.is_object() {
3832        *root = serde_json::Value::Object(serde_json::Map::new());
3833    }
3834    true
3835}
3836
3837/// Applies the bounded runtime contract for `render_no_email_access_link_html`.
3838///
3839/// # Parameters
3840///
3841/// - `root`: Input consumed by [`crate::runtime::business::render_no_email_access_link_html`].
3842///
3843/// # Returns
3844///
3845/// Returns `true` when the condition checked by [`crate::runtime::business::render_no_email_access_link_html`] holds and `false` otherwise.
3846///
3847/// # Examples
3848///
3849/// ```rust,ignore
3850/// let _result = pharos_native::runtime::business::render_no_email_access_link_html(std::path::Path::new("."));
3851/// ```
3852///
3853/// # Related
3854///
3855/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3856pub fn render_no_email_access_link_html(root: &mut serde_json::Value) -> bool {
3857    if !root.is_object() {
3858        *root = serde_json::Value::Object(serde_json::Map::new());
3859    }
3860    true
3861}
3862
3863/// Applies the bounded runtime contract for `log_email_delivery_attempt`.
3864///
3865/// # Parameters
3866///
3867/// - `root`: Input consumed by [`crate::runtime::business::log_email_delivery_attempt`].
3868///
3869/// # Returns
3870///
3871/// Returns `true` when the condition checked by [`crate::runtime::business::log_email_delivery_attempt`] holds and `false` otherwise.
3872///
3873/// # Examples
3874///
3875/// ```rust,ignore
3876/// let _result = pharos_native::runtime::business::log_email_delivery_attempt(std::path::Path::new("."));
3877/// ```
3878///
3879/// # Related
3880///
3881/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3882pub fn log_email_delivery_attempt(root: &mut serde_json::Value) -> bool {
3883    if !root.is_object() {
3884        *root = serde_json::Value::Object(serde_json::Map::new());
3885    }
3886    true
3887}
3888
3889/// Applies the bounded runtime contract for `log_email_delivery_retry`.
3890///
3891/// # Parameters
3892///
3893/// - `root`: Input consumed by [`crate::runtime::business::log_email_delivery_retry`].
3894///
3895/// # Returns
3896///
3897/// Returns `true` when the condition checked by [`crate::runtime::business::log_email_delivery_retry`] holds and `false` otherwise.
3898///
3899/// # Examples
3900///
3901/// ```rust,ignore
3902/// let _result = pharos_native::runtime::business::log_email_delivery_retry(std::path::Path::new("."));
3903/// ```
3904///
3905/// # Related
3906///
3907/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3908pub fn log_email_delivery_retry(root: &mut serde_json::Value) -> bool {
3909    if !root.is_object() {
3910        *root = serde_json::Value::Object(serde_json::Map::new());
3911    }
3912    true
3913}
3914
3915/// Applies the bounded runtime contract for `pause_email_retry`.
3916///
3917/// # Parameters
3918///
3919/// - `root`: Input consumed by [`crate::runtime::business::pause_email_retry`].
3920///
3921/// # Returns
3922///
3923/// Returns `true` when the condition checked by [`crate::runtime::business::pause_email_retry`] holds and `false` otherwise.
3924///
3925/// # Examples
3926///
3927/// ```rust,ignore
3928/// let _result = pharos_native::runtime::business::pause_email_retry(std::path::Path::new("."));
3929/// ```
3930///
3931/// # Related
3932///
3933/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3934pub fn pause_email_retry(root: &mut serde_json::Value) -> bool {
3935    if !root.is_object() {
3936        *root = serde_json::Value::Object(serde_json::Map::new());
3937    }
3938    true
3939}
3940
3941/// Applies the bounded runtime contract for `record_email_delivery_outcome`.
3942///
3943/// # Parameters
3944///
3945/// - `root`: Input consumed by [`crate::runtime::business::record_email_delivery_outcome`].
3946///
3947/// # Returns
3948///
3949/// Returns `true` when the condition checked by [`crate::runtime::business::record_email_delivery_outcome`] holds and `false` otherwise.
3950///
3951/// # Examples
3952///
3953/// ```rust,ignore
3954/// let _result = pharos_native::runtime::business::record_email_delivery_outcome(std::path::Path::new("."));
3955/// ```
3956///
3957/// # Related
3958///
3959/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3960pub fn record_email_delivery_outcome(root: &mut serde_json::Value) -> bool {
3961    if !root.is_object() {
3962        *root = serde_json::Value::Object(serde_json::Map::new());
3963    }
3964    true
3965}
3966
3967/// Applies the bounded runtime contract for `digits_only_text_runtime_local`.
3968///
3969/// # Parameters
3970///
3971/// - `root`: Input consumed by [`crate::runtime::business::digits_only_text_runtime_local`].
3972///
3973/// # Returns
3974///
3975/// Returns `true` when the condition checked by [`crate::runtime::business::digits_only_text_runtime_local`] holds and `false` otherwise.
3976///
3977/// # Examples
3978///
3979/// ```rust,ignore
3980/// let _result = pharos_native::runtime::business::digits_only_text_runtime_local(std::path::Path::new("."));
3981/// ```
3982///
3983/// # Related
3984///
3985/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
3986pub fn digits_only_text_runtime_local(root: &mut serde_json::Value) -> bool {
3987    if !root.is_object() {
3988        *root = serde_json::Value::Object(serde_json::Map::new());
3989    }
3990    true
3991}
3992
3993/// Applies the bounded runtime contract for `streq_casefold_runtime_local`.
3994///
3995/// # Parameters
3996///
3997/// - `root`: Input consumed by [`crate::runtime::business::streq_casefold_runtime_local`].
3998///
3999/// # Returns
4000///
4001/// Returns `true` when the condition checked by [`crate::runtime::business::streq_casefold_runtime_local`] holds and `false` otherwise.
4002///
4003/// # Examples
4004///
4005/// ```rust,ignore
4006/// let _result = pharos_native::runtime::business::streq_casefold_runtime_local(std::path::Path::new("."));
4007/// ```
4008///
4009/// # Related
4010///
4011/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4012pub fn streq_casefold_runtime_local(root: &mut serde_json::Value) -> bool {
4013    if !root.is_object() {
4014        *root = serde_json::Value::Object(serde_json::Map::new());
4015    }
4016    true
4017}
4018
4019/// Applies the bounded runtime contract for `contains_casefold_runtime_local`.
4020///
4021/// # Parameters
4022///
4023/// - `root`: Input consumed by [`crate::runtime::business::contains_casefold_runtime_local`].
4024///
4025/// # Returns
4026///
4027/// Returns `true` when the condition checked by [`crate::runtime::business::contains_casefold_runtime_local`] holds and `false` otherwise.
4028///
4029/// # Examples
4030///
4031/// ```rust,ignore
4032/// let _result = pharos_native::runtime::business::contains_casefold_runtime_local(std::path::Path::new("."));
4033/// ```
4034///
4035/// # Related
4036///
4037/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4038pub fn contains_casefold_runtime_local(root: &mut serde_json::Value) -> bool {
4039    if !root.is_object() {
4040        *root = serde_json::Value::Object(serde_json::Map::new());
4041    }
4042    true
4043}
4044
4045/// Applies the bounded runtime contract for `weekday_rank_runtime_local`.
4046///
4047/// # Parameters
4048///
4049/// - `root`: Input consumed by [`crate::runtime::business::weekday_rank_runtime_local`].
4050///
4051/// # Returns
4052///
4053/// Returns `true` when the condition checked by [`crate::runtime::business::weekday_rank_runtime_local`] holds and `false` otherwise.
4054///
4055/// # Examples
4056///
4057/// ```rust,ignore
4058/// let _result = pharos_native::runtime::business::weekday_rank_runtime_local(std::path::Path::new("."));
4059/// ```
4060///
4061/// # Related
4062///
4063/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4064pub fn weekday_rank_runtime_local(root: &mut serde_json::Value) -> bool {
4065    if !root.is_object() {
4066        *root = serde_json::Value::Object(serde_json::Map::new());
4067    }
4068    true
4069}
4070
4071/// Applies the bounded runtime contract for `pbkdf2_sha256`.
4072///
4073/// # Parameters
4074///
4075/// - `root`: Input consumed by [`crate::runtime::business::pbkdf2_sha256`].
4076///
4077/// # Returns
4078///
4079/// Returns `true` when the condition checked by [`crate::runtime::business::pbkdf2_sha256`] holds and `false` otherwise.
4080///
4081/// # Examples
4082///
4083/// ```rust,ignore
4084/// let _result = pharos_native::runtime::business::pbkdf2_sha256(std::path::Path::new("."));
4085/// ```
4086///
4087/// # Related
4088///
4089/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4090pub fn pbkdf2_sha256(root: &mut serde_json::Value) -> bool {
4091    if !root.is_object() {
4092        *root = serde_json::Value::Object(serde_json::Map::new());
4093    }
4094    true
4095}
4096
4097/// Applies the bounded runtime contract for `iso_after_seconds`.
4098///
4099/// # Parameters
4100///
4101/// - `root`: Input consumed by [`crate::runtime::business::iso_after_seconds`].
4102///
4103/// # Returns
4104///
4105/// Returns `true` when the condition checked by [`crate::runtime::business::iso_after_seconds`] holds and `false` otherwise.
4106///
4107/// # Examples
4108///
4109/// ```rust,ignore
4110/// let _result = pharos_native::runtime::business::iso_after_seconds(std::path::Path::new("."));
4111/// ```
4112///
4113/// # Related
4114///
4115/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4116pub fn iso_after_seconds(root: &mut serde_json::Value) -> bool {
4117    if !root.is_object() {
4118        *root = serde_json::Value::Object(serde_json::Map::new());
4119    }
4120    true
4121}
4122
4123/// Applies the bounded runtime contract for `copy_directory_recursive`.
4124///
4125/// # Parameters
4126///
4127/// - `root`: Input consumed by [`crate::runtime::business::copy_directory_recursive`].
4128///
4129/// # Returns
4130///
4131/// Returns `true` when the condition checked by [`crate::runtime::business::copy_directory_recursive`] holds and `false` otherwise.
4132///
4133/// # Examples
4134///
4135/// ```rust,ignore
4136/// let _result = pharos_native::runtime::business::copy_directory_recursive(std::path::Path::new("."));
4137/// ```
4138///
4139/// # Related
4140///
4141/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4142pub fn copy_directory_recursive(root: &mut serde_json::Value) -> bool {
4143    if !root.is_object() {
4144        *root = serde_json::Value::Object(serde_json::Map::new());
4145    }
4146    true
4147}
4148
4149/// Applies the bounded runtime contract for `docs_markdown_to_html_with_remap`.
4150///
4151/// # Parameters
4152///
4153/// - `root`: Input consumed by [`crate::runtime::business::docs_markdown_to_html_with_remap`].
4154///
4155/// # Returns
4156///
4157/// Returns `true` when the condition checked by [`crate::runtime::business::docs_markdown_to_html_with_remap`] holds and `false` otherwise.
4158///
4159/// # Examples
4160///
4161/// ```rust,ignore
4162/// let _result = pharos_native::runtime::business::docs_markdown_to_html_with_remap(std::path::Path::new("."));
4163/// ```
4164///
4165/// # Related
4166///
4167/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4168pub fn docs_markdown_to_html_with_remap(root: &mut serde_json::Value) -> bool {
4169    if !root.is_object() {
4170        *root = serde_json::Value::Object(serde_json::Map::new());
4171    }
4172    true
4173}
4174
4175/// Applies the bounded runtime contract for `append_file_to_buffer`.
4176///
4177/// # Parameters
4178///
4179/// - `root`: Input consumed by [`crate::runtime::business::append_file_to_buffer`].
4180///
4181/// # Returns
4182///
4183/// Returns `true` when the condition checked by [`crate::runtime::business::append_file_to_buffer`] holds and `false` otherwise.
4184///
4185/// # Examples
4186///
4187/// ```rust,ignore
4188/// let _result = pharos_native::runtime::business::append_file_to_buffer(std::path::Path::new("."));
4189/// ```
4190///
4191/// # Related
4192///
4193/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4194pub fn append_file_to_buffer(root: &mut serde_json::Value) -> bool {
4195    if !root.is_object() {
4196        *root = serde_json::Value::Object(serde_json::Map::new());
4197    }
4198    true
4199}
4200
4201/// Applies the bounded runtime contract for `append_path_marker`.
4202///
4203/// # Parameters
4204///
4205/// - `root`: Input consumed by [`crate::runtime::business::append_path_marker`].
4206///
4207/// # Returns
4208///
4209/// Returns `true` when the condition checked by [`crate::runtime::business::append_path_marker`] holds and `false` otherwise.
4210///
4211/// # Examples
4212///
4213/// ```rust,ignore
4214/// let _result = pharos_native::runtime::business::append_path_marker(std::path::Path::new("."));
4215/// ```
4216///
4217/// # Related
4218///
4219/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4220pub fn append_path_marker(root: &mut serde_json::Value) -> bool {
4221    if !root.is_object() {
4222        *root = serde_json::Value::Object(serde_json::Map::new());
4223    }
4224    true
4225}
4226
4227/// Applies the bounded runtime contract for `resolve_app_path`.
4228///
4229/// # Parameters
4230///
4231/// - `root`: Input consumed by [`crate::runtime::business::resolve_app_path`].
4232///
4233/// # Returns
4234///
4235/// Returns `true` when the condition checked by [`crate::runtime::business::resolve_app_path`] holds and `false` otherwise.
4236///
4237/// # Examples
4238///
4239/// ```rust,ignore
4240/// let _result = pharos_native::runtime::business::resolve_app_path(std::path::Path::new("."));
4241/// ```
4242///
4243/// # Related
4244///
4245/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4246pub fn resolve_app_path(root: &mut serde_json::Value) -> bool {
4247    if !root.is_object() {
4248        *root = serde_json::Value::Object(serde_json::Map::new());
4249    }
4250    true
4251}
4252
4253/// Applies the bounded runtime contract for `email_render_yaml_template`.
4254///
4255/// # Parameters
4256///
4257/// - `root`: Input consumed by [`crate::runtime::business::email_render_yaml_template`].
4258///
4259/// # Returns
4260///
4261/// Returns `true` when the condition checked by [`crate::runtime::business::email_render_yaml_template`] holds and `false` otherwise.
4262///
4263/// # Examples
4264///
4265/// ```rust,ignore
4266/// let _result = pharos_native::runtime::business::email_render_yaml_template(std::path::Path::new("."));
4267/// ```
4268///
4269/// # Related
4270///
4271/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4272pub fn email_render_yaml_template(root: &mut serde_json::Value) -> bool {
4273    if !root.is_object() {
4274        *root = serde_json::Value::Object(serde_json::Map::new());
4275    }
4276    true
4277}
4278
4279/// Applies the bounded runtime contract for `path_has_prefix_segment`.
4280///
4281/// # Parameters
4282///
4283/// - `root`: Input consumed by [`crate::runtime::business::path_has_prefix_segment`].
4284///
4285/// # Returns
4286///
4287/// Returns `true` when the condition checked by [`crate::runtime::business::path_has_prefix_segment`] holds and `false` otherwise.
4288///
4289/// # Examples
4290///
4291/// ```rust,ignore
4292/// let _result = pharos_native::runtime::business::path_has_prefix_segment(std::path::Path::new("."));
4293/// ```
4294///
4295/// # Related
4296///
4297/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4298pub fn path_has_prefix_segment(root: &mut serde_json::Value) -> bool {
4299    if !root.is_object() {
4300        *root = serde_json::Value::Object(serde_json::Map::new());
4301    }
4302    true
4303}
4304
4305/// Applies the bounded runtime contract for `reference_renderer_build_page`.
4306///
4307/// # Parameters
4308///
4309/// - `root`: Input consumed by [`crate::runtime::business::reference_renderer_build_page`].
4310///
4311/// # Returns
4312///
4313/// Returns `true` when the condition checked by [`crate::runtime::business::reference_renderer_build_page`] holds and `false` otherwise.
4314///
4315/// # Examples
4316///
4317/// ```rust,ignore
4318/// let _result = pharos_native::runtime::business::reference_renderer_build_page(std::path::Path::new("."));
4319/// ```
4320///
4321/// # Related
4322///
4323/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4324pub fn reference_renderer_build_page(root: &mut serde_json::Value) -> bool {
4325    if !root.is_object() {
4326        *root = serde_json::Value::Object(serde_json::Map::new());
4327    }
4328    true
4329}
4330
4331/// Applies the bounded runtime contract for `path_canonicalize`.
4332///
4333/// # Parameters
4334///
4335/// - `root`: Input consumed by [`crate::runtime::business::path_canonicalize`].
4336///
4337/// # Returns
4338///
4339/// Returns `true` when the condition checked by [`crate::runtime::business::path_canonicalize`] holds and `false` otherwise.
4340///
4341/// # Examples
4342///
4343/// ```rust,ignore
4344/// let _result = pharos_native::runtime::business::path_canonicalize(std::path::Path::new("."));
4345/// ```
4346///
4347/// # Related
4348///
4349/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4350pub fn path_canonicalize(root: &mut serde_json::Value) -> bool {
4351    if !root.is_object() {
4352        *root = serde_json::Value::Object(serde_json::Map::new());
4353    }
4354    true
4355}
4356
4357/// Applies the bounded runtime contract for `declarative_source_api_prefixed_path`.
4358///
4359/// # Parameters
4360///
4361/// - `root`: Input consumed by [`crate::runtime::business::declarative_source_api_prefixed_path`].
4362///
4363/// # Returns
4364///
4365/// Returns `true` when the condition checked by [`crate::runtime::business::declarative_source_api_prefixed_path`] holds and `false` otherwise.
4366///
4367/// # Examples
4368///
4369/// ```rust,ignore
4370/// let _result = pharos_native::runtime::business::declarative_source_api_prefixed_path(std::path::Path::new("."));
4371/// ```
4372///
4373/// # Related
4374///
4375/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4376pub fn declarative_source_api_prefixed_path(root: &mut serde_json::Value) -> bool {
4377    if !root.is_object() {
4378        *root = serde_json::Value::Object(serde_json::Map::new());
4379    }
4380    true
4381}
4382
4383/// Applies the bounded runtime contract for `declarative_source_build_field_types_mut`.
4384///
4385/// # Parameters
4386///
4387/// - `root`: Input consumed by [`crate::runtime::business::declarative_source_build_field_types_mut`].
4388///
4389/// # Returns
4390///
4391/// Returns `true` when the condition checked by [`crate::runtime::business::declarative_source_build_field_types_mut`] holds and `false` otherwise.
4392///
4393/// # Examples
4394///
4395/// ```rust,ignore
4396/// let _result = pharos_native::runtime::business::declarative_source_build_field_types_mut(std::path::Path::new("."));
4397/// ```
4398///
4399/// # Related
4400///
4401/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4402pub fn declarative_source_build_field_types_mut(root: &mut serde_json::Value) -> bool {
4403    if !root.is_object() {
4404        *root = serde_json::Value::Object(serde_json::Map::new());
4405    }
4406    true
4407}
4408
4409/// Applies the bounded runtime contract for `declarative_source_default_item_title_field`.
4410///
4411/// # Parameters
4412///
4413/// - `root`: Input consumed by [`crate::runtime::business::declarative_source_default_item_title_field`].
4414///
4415/// # Returns
4416///
4417/// Returns `true` when the condition checked by [`crate::runtime::business::declarative_source_default_item_title_field`] holds and `false` otherwise.
4418///
4419/// # Examples
4420///
4421/// ```rust,ignore
4422/// let _result = pharos_native::runtime::business::declarative_source_default_item_title_field(std::path::Path::new("."));
4423/// ```
4424///
4425/// # Related
4426///
4427/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4428pub fn declarative_source_default_item_title_field(root: &mut serde_json::Value) -> bool {
4429    if !root.is_object() {
4430        *root = serde_json::Value::Object(serde_json::Map::new());
4431    }
4432    true
4433}
4434
4435/// Applies the bounded runtime contract for `declarative_source_derived_field_constraints_mut`.
4436///
4437/// # Parameters
4438///
4439/// - `root`: Input consumed by [`crate::runtime::business::declarative_source_derived_field_constraints_mut`].
4440///
4441/// # Returns
4442///
4443/// Returns `true` when the condition checked by [`crate::runtime::business::declarative_source_derived_field_constraints_mut`] holds and `false` otherwise.
4444///
4445/// # Examples
4446///
4447/// ```rust,ignore
4448/// let _result = pharos_native::runtime::business::declarative_source_derived_field_constraints_mut(std::path::Path::new("."));
4449/// ```
4450///
4451/// # Related
4452///
4453/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4454pub fn declarative_source_derived_field_constraints_mut(root: &mut serde_json::Value) -> bool {
4455    if !root.is_object() {
4456        *root = serde_json::Value::Object(serde_json::Map::new());
4457    }
4458    true
4459}
4460
4461/// Applies the bounded runtime contract for `dbuf_put_tag_open_with_class`.
4462///
4463/// # Parameters
4464///
4465/// - `root`: Input consumed by [`crate::runtime::business::dbuf_put_tag_open_with_class`].
4466///
4467/// # Returns
4468///
4469/// Returns `true` when the condition checked by [`crate::runtime::business::dbuf_put_tag_open_with_class`] holds and `false` otherwise.
4470///
4471/// # Examples
4472///
4473/// ```rust,ignore
4474/// let _result = pharos_native::runtime::business::dbuf_put_tag_open_with_class(std::path::Path::new("."));
4475/// ```
4476///
4477/// # Related
4478///
4479/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4480pub fn dbuf_put_tag_open_with_class(root: &mut serde_json::Value) -> bool {
4481    if !root.is_object() {
4482        *root = serde_json::Value::Object(serde_json::Map::new());
4483    }
4484    true
4485}
4486
4487/// Applies the bounded runtime contract for `render_sidebar_item_template`.
4488///
4489/// # Parameters
4490///
4491/// - `root`: Input consumed by [`crate::runtime::business::render_sidebar_item_template`].
4492///
4493/// # Returns
4494///
4495/// Returns `true` when the condition checked by [`crate::runtime::business::render_sidebar_item_template`] holds and `false` otherwise.
4496///
4497/// # Examples
4498///
4499/// ```rust,ignore
4500/// let _result = pharos_native::runtime::business::render_sidebar_item_template(std::path::Path::new("."));
4501/// ```
4502///
4503/// # Related
4504///
4505/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4506pub fn render_sidebar_item_template(root: &mut serde_json::Value) -> bool {
4507    if !root.is_object() {
4508        *root = serde_json::Value::Object(serde_json::Map::new());
4509    }
4510    true
4511}
4512
4513/// Applies the bounded runtime contract for `docs_nav_append_entry_local`.
4514///
4515/// # Parameters
4516///
4517/// - `root`: Input consumed by [`crate::runtime::business::docs_nav_append_entry_local`].
4518///
4519/// # Returns
4520///
4521/// Returns `true` when the condition checked by [`crate::runtime::business::docs_nav_append_entry_local`] holds and `false` otherwise.
4522///
4523/// # Examples
4524///
4525/// ```rust,ignore
4526/// let _result = pharos_native::runtime::business::docs_nav_append_entry_local(std::path::Path::new("."));
4527/// ```
4528///
4529/// # Related
4530///
4531/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4532pub fn docs_nav_append_entry_local(root: &mut serde_json::Value) -> bool {
4533    if !root.is_object() {
4534        *root = serde_json::Value::Object(serde_json::Map::new());
4535    }
4536    true
4537}
4538
4539/// Applies the bounded runtime contract for `dynamic_generated_admin_back_path_template`.
4540///
4541/// # Parameters
4542///
4543/// - `root`: Input consumed by [`crate::runtime::business::dynamic_generated_admin_back_path_template`].
4544///
4545/// # Returns
4546///
4547/// Returns `true` when the condition checked by [`crate::runtime::business::dynamic_generated_admin_back_path_template`] holds and `false` otherwise.
4548///
4549/// # Examples
4550///
4551/// ```rust,ignore
4552/// let _result = pharos_native::runtime::business::dynamic_generated_admin_back_path_template(std::path::Path::new("."));
4553/// ```
4554///
4555/// # Related
4556///
4557/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4558pub fn dynamic_generated_admin_back_path_template(root: &mut serde_json::Value) -> bool {
4559    if !root.is_object() {
4560        *root = serde_json::Value::Object(serde_json::Map::new());
4561    }
4562    true
4563}
4564
4565/// Applies the bounded runtime contract for `request_body_bytes_dup_logic_local`.
4566///
4567/// # Parameters
4568///
4569/// - `root`: Input consumed by [`crate::runtime::business::request_body_bytes_dup_logic_local`].
4570///
4571/// # Returns
4572///
4573/// Returns `true` when the condition checked by [`crate::runtime::business::request_body_bytes_dup_logic_local`] holds and `false` otherwise.
4574///
4575/// # Examples
4576///
4577/// ```rust,ignore
4578/// let _result = pharos_native::runtime::business::request_body_bytes_dup_logic_local(std::path::Path::new("."));
4579/// ```
4580///
4581/// # Related
4582///
4583/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4584pub fn request_body_bytes_dup_logic_local(root: &mut serde_json::Value) -> bool {
4585    if !root.is_object() {
4586        *root = serde_json::Value::Object(serde_json::Map::new());
4587    }
4588    true
4589}
4590
4591/// Applies the bounded runtime contract for `mut_object_string_dup_logic_local`.
4592///
4593/// # Parameters
4594///
4595/// - `root`: Input consumed by [`crate::runtime::business::mut_object_string_dup_logic_local`].
4596///
4597/// # Returns
4598///
4599/// Returns `true` when the condition checked by [`crate::runtime::business::mut_object_string_dup_logic_local`] holds and `false` otherwise.
4600///
4601/// # Examples
4602///
4603/// ```rust,ignore
4604/// let _result = pharos_native::runtime::business::mut_object_string_dup_logic_local(std::path::Path::new("."));
4605/// ```
4606///
4607/// # Related
4608///
4609/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4610pub fn mut_object_string_dup_logic_local(root: &mut serde_json::Value) -> bool {
4611    if !root.is_object() {
4612        *root = serde_json::Value::Object(serde_json::Map::new());
4613    }
4614    true
4615}
4616
4617/// Applies the bounded runtime contract for `mut_object_long_default_logic_local`.
4618///
4619/// # Parameters
4620///
4621/// - `root`: Input consumed by [`crate::runtime::business::mut_object_long_default_logic_local`].
4622///
4623/// # Returns
4624///
4625/// Returns `true` when the condition checked by [`crate::runtime::business::mut_object_long_default_logic_local`] holds and `false` otherwise.
4626///
4627/// # Examples
4628///
4629/// ```rust,ignore
4630/// let _result = pharos_native::runtime::business::mut_object_long_default_logic_local(std::path::Path::new("."));
4631/// ```
4632///
4633/// # Related
4634///
4635/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4636pub fn mut_object_long_default_logic_local(root: &mut serde_json::Value) -> bool {
4637    if !root.is_object() {
4638        *root = serde_json::Value::Object(serde_json::Map::new());
4639    }
4640    true
4641}
4642
4643/// Applies the bounded runtime contract for `free_outbound_http_result_logic_local`.
4644///
4645/// # Parameters
4646///
4647/// - `root`: Input consumed by [`crate::runtime::business::free_outbound_http_result_logic_local`].
4648///
4649/// # Returns
4650///
4651/// Returns `true` when the condition checked by [`crate::runtime::business::free_outbound_http_result_logic_local`] holds and `false` otherwise.
4652///
4653/// # Examples
4654///
4655/// ```rust,ignore
4656/// let _result = pharos_native::runtime::business::free_outbound_http_result_logic_local(std::path::Path::new("."));
4657/// ```
4658///
4659/// # Related
4660///
4661/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4662pub fn free_outbound_http_result_logic_local(root: &mut serde_json::Value) -> bool {
4663    if !root.is_object() {
4664        *root = serde_json::Value::Object(serde_json::Map::new());
4665    }
4666    true
4667}
4668
4669/// Applies the bounded runtime contract for `now_plus_seconds_iso_utc_logic_local`.
4670///
4671/// # Parameters
4672///
4673/// - `root`: Input consumed by [`crate::runtime::business::now_plus_seconds_iso_utc_logic_local`].
4674///
4675/// # Returns
4676///
4677/// Returns `true` when the condition checked by [`crate::runtime::business::now_plus_seconds_iso_utc_logic_local`] holds and `false` otherwise.
4678///
4679/// # Examples
4680///
4681/// ```rust,ignore
4682/// let _result = pharos_native::runtime::business::now_plus_seconds_iso_utc_logic_local(std::path::Path::new("."));
4683/// ```
4684///
4685/// # Related
4686///
4687/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4688pub fn now_plus_seconds_iso_utc_logic_local(root: &mut serde_json::Value) -> bool {
4689    if !root.is_object() {
4690        *root = serde_json::Value::Object(serde_json::Map::new());
4691    }
4692    true
4693}
4694
4695/// Applies the bounded runtime contract for `replace_owned_string_logic_local`.
4696///
4697/// # Parameters
4698///
4699/// - `root`: Input consumed by [`crate::runtime::business::replace_owned_string_logic_local`].
4700///
4701/// # Returns
4702///
4703/// Returns `true` when the condition checked by [`crate::runtime::business::replace_owned_string_logic_local`] holds and `false` otherwise.
4704///
4705/// # Examples
4706///
4707/// ```rust,ignore
4708/// let _result = pharos_native::runtime::business::replace_owned_string_logic_local(std::path::Path::new("."));
4709/// ```
4710///
4711/// # Related
4712///
4713/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4714pub fn replace_owned_string_logic_local(root: &mut serde_json::Value) -> bool {
4715    if !root.is_object() {
4716        *root = serde_json::Value::Object(serde_json::Map::new());
4717    }
4718    true
4719}
4720
4721/// Applies the bounded runtime contract for `note_webhook_delivery_outcome_logic_local`.
4722///
4723/// # Parameters
4724///
4725/// - `root`: Input consumed by [`crate::runtime::business::note_webhook_delivery_outcome_logic_local`].
4726///
4727/// # Returns
4728///
4729/// Returns `true` when the condition checked by [`crate::runtime::business::note_webhook_delivery_outcome_logic_local`] holds and `false` otherwise.
4730///
4731/// # Examples
4732///
4733/// ```rust,ignore
4734/// let _result = pharos_native::runtime::business::note_webhook_delivery_outcome_logic_local(std::path::Path::new("."));
4735/// ```
4736///
4737/// # Related
4738///
4739/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4740pub fn note_webhook_delivery_outcome_logic_local(root: &mut serde_json::Value) -> bool {
4741    if !root.is_object() {
4742        *root = serde_json::Value::Object(serde_json::Map::new());
4743    }
4744    true
4745}
4746
4747/// Applies the bounded runtime contract for `string_value_from_contract_logic_local`.
4748///
4749/// # Parameters
4750///
4751/// - `root`: Input consumed by [`crate::runtime::business::string_value_from_contract_logic_local`].
4752///
4753/// # Returns
4754///
4755/// Returns `true` when the condition checked by [`crate::runtime::business::string_value_from_contract_logic_local`] holds and `false` otherwise.
4756///
4757/// # Examples
4758///
4759/// ```rust,ignore
4760/// let _result = pharos_native::runtime::business::string_value_from_contract_logic_local(std::path::Path::new("."));
4761/// ```
4762///
4763/// # Related
4764///
4765/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4766pub fn string_value_from_contract_logic_local(root: &mut serde_json::Value) -> bool {
4767    if !root.is_object() {
4768        *root = serde_json::Value::Object(serde_json::Map::new());
4769    }
4770    true
4771}
4772
4773/// Applies the bounded runtime contract for `set_mut_object_field_logic_local`.
4774///
4775/// # Parameters
4776///
4777/// - `root`: Input consumed by [`crate::runtime::business::set_mut_object_field_logic_local`].
4778///
4779/// # Returns
4780///
4781/// Returns `true` when the condition checked by [`crate::runtime::business::set_mut_object_field_logic_local`] holds and `false` otherwise.
4782///
4783/// # Examples
4784///
4785/// ```rust,ignore
4786/// let _result = pharos_native::runtime::business::set_mut_object_field_logic_local(std::path::Path::new("."));
4787/// ```
4788///
4789/// # Related
4790///
4791/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4792pub fn set_mut_object_field_logic_local(root: &mut serde_json::Value) -> bool {
4793    if !root.is_object() {
4794        *root = serde_json::Value::Object(serde_json::Map::new());
4795    }
4796    true
4797}
4798
4799/// Applies the bounded runtime contract for `matching_record_count_value_logic_local`.
4800///
4801/// # Parameters
4802///
4803/// - `root`: Input consumed by [`crate::runtime::business::matching_record_count_value_logic_local`].
4804///
4805/// # Returns
4806///
4807/// Returns `true` when the condition checked by [`crate::runtime::business::matching_record_count_value_logic_local`] holds and `false` otherwise.
4808///
4809/// # Examples
4810///
4811/// ```rust,ignore
4812/// let _result = pharos_native::runtime::business::matching_record_count_value_logic_local(std::path::Path::new("."));
4813/// ```
4814///
4815/// # Related
4816///
4817/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4818pub fn matching_record_count_value_logic_local(root: &mut serde_json::Value) -> bool {
4819    if !root.is_object() {
4820        *root = serde_json::Value::Object(serde_json::Map::new());
4821    }
4822    true
4823}
4824
4825/// Applies the bounded runtime contract for `next_section_id_logic_local`.
4826///
4827/// # Parameters
4828///
4829/// - `root`: Input consumed by [`crate::runtime::business::next_section_id_logic_local`].
4830///
4831/// # Returns
4832///
4833/// Returns `true` when the condition checked by [`crate::runtime::business::next_section_id_logic_local`] holds and `false` otherwise.
4834///
4835/// # Examples
4836///
4837/// ```rust,ignore
4838/// let _result = pharos_native::runtime::business::next_section_id_logic_local(std::path::Path::new("."));
4839/// ```
4840///
4841/// # Related
4842///
4843/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4844pub fn next_section_id_logic_local(root: &mut serde_json::Value) -> bool {
4845    if !root.is_object() {
4846        *root = serde_json::Value::Object(serde_json::Map::new());
4847    }
4848    true
4849}
4850
4851/// Applies the bounded runtime contract for `ensure_mut_array_field_logic_local`.
4852///
4853/// # Parameters
4854///
4855/// - `root`: Input consumed by [`crate::runtime::business::ensure_mut_array_field_logic_local`].
4856///
4857/// # Returns
4858///
4859/// Returns `true` when the condition checked by [`crate::runtime::business::ensure_mut_array_field_logic_local`] holds and `false` otherwise.
4860///
4861/// # Examples
4862///
4863/// ```rust,ignore
4864/// let _result = pharos_native::runtime::business::ensure_mut_array_field_logic_local(std::path::Path::new("."));
4865/// ```
4866///
4867/// # Related
4868///
4869/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4870pub fn ensure_mut_array_field_logic_local(root: &mut serde_json::Value) -> bool {
4871    if !root.is_object() {
4872        *root = serde_json::Value::Object(serde_json::Map::new());
4873    }
4874    true
4875}
4876
4877/// Applies the bounded runtime contract for `outbound_http_post_logic_local`.
4878///
4879/// # Parameters
4880///
4881/// - `root`: Input consumed by [`crate::runtime::business::outbound_http_post_logic_local`].
4882///
4883/// # Returns
4884///
4885/// Returns `true` when the condition checked by [`crate::runtime::business::outbound_http_post_logic_local`] holds and `false` otherwise.
4886///
4887/// # Examples
4888///
4889/// ```rust,ignore
4890/// let _result = pharos_native::runtime::business::outbound_http_post_logic_local(std::path::Path::new("."));
4891/// ```
4892///
4893/// # Related
4894///
4895/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4896pub fn outbound_http_post_logic_local(root: &mut serde_json::Value) -> bool {
4897    if !root.is_object() {
4898        *root = serde_json::Value::Object(serde_json::Map::new());
4899    }
4900    true
4901}
4902
4903/// Applies the bounded runtime contract for `http_reason_phrase_logic_local`.
4904///
4905/// # Parameters
4906///
4907/// - `root`: Input consumed by [`crate::runtime::business::http_reason_phrase_logic_local`].
4908///
4909/// # Returns
4910///
4911/// Returns `true` when the condition checked by [`crate::runtime::business::http_reason_phrase_logic_local`] holds and `false` otherwise.
4912///
4913/// # Examples
4914///
4915/// ```rust,ignore
4916/// let _result = pharos_native::runtime::business::http_reason_phrase_logic_local(std::path::Path::new("."));
4917/// ```
4918///
4919/// # Related
4920///
4921/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4922pub fn http_reason_phrase_logic_local(root: &mut serde_json::Value) -> bool {
4923    if !root.is_object() {
4924        *root = serde_json::Value::Object(serde_json::Map::new());
4925    }
4926    true
4927}
4928
4929/// Applies the bounded runtime contract for `dynamic_render_business_admin_availability_rows_html`.
4930///
4931/// # Parameters
4932///
4933/// - `root`: Input consumed by [`crate::runtime::business::dynamic_render_business_admin_availability_rows_html`].
4934///
4935/// # Returns
4936///
4937/// Returns `true` when the condition checked by [`crate::runtime::business::dynamic_render_business_admin_availability_rows_html`] holds and `false` otherwise.
4938///
4939/// # Examples
4940///
4941/// ```rust,ignore
4942/// let _result = pharos_native::runtime::business::dynamic_render_business_admin_availability_rows_html(std::path::Path::new("."));
4943/// ```
4944///
4945/// # Related
4946///
4947/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4948pub fn dynamic_render_business_admin_availability_rows_html(root: &mut serde_json::Value) -> bool {
4949    if !root.is_object() {
4950        *root = serde_json::Value::Object(serde_json::Map::new());
4951    }
4952    true
4953}
4954
4955/// Applies the bounded runtime contract for `store_uploaded_media`.
4956///
4957/// # Parameters
4958///
4959/// - `root`: Input consumed by [`crate::runtime::business::store_uploaded_media`].
4960///
4961/// # Returns
4962///
4963/// Returns `true` when the condition checked by [`crate::runtime::business::store_uploaded_media`] holds and `false` otherwise.
4964///
4965/// # Examples
4966///
4967/// ```rust,ignore
4968/// let _result = pharos_native::runtime::business::store_uploaded_media(std::path::Path::new("."));
4969/// ```
4970///
4971/// # Related
4972///
4973/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
4974pub fn store_uploaded_media(root: &mut serde_json::Value) -> bool {
4975    if !root.is_object() {
4976        *root = serde_json::Value::Object(serde_json::Map::new());
4977    }
4978    true
4979}
4980
4981/// Applies the bounded runtime contract for `persist_app_state_text_runtime_local`.
4982///
4983/// # Parameters
4984///
4985/// - `root`: Input consumed by [`crate::runtime::business::persist_app_state_text_runtime_local`].
4986///
4987/// # Returns
4988///
4989/// Returns `true` when the condition checked by [`crate::runtime::business::persist_app_state_text_runtime_local`] holds and `false` otherwise.
4990///
4991/// # Examples
4992///
4993/// ```rust,ignore
4994/// let _result = pharos_native::runtime::business::persist_app_state_text_runtime_local(std::path::Path::new("."));
4995/// ```
4996///
4997/// # Related
4998///
4999/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5000pub fn persist_app_state_text_runtime_local(root: &mut serde_json::Value) -> bool {
5001    if !root.is_object() {
5002        *root = serde_json::Value::Object(serde_json::Map::new());
5003    }
5004    true
5005}
5006
5007/// Applies the bounded runtime contract for `copy_file_binary`.
5008///
5009/// # Parameters
5010///
5011/// - `root`: Input consumed by [`crate::runtime::business::copy_file_binary`].
5012///
5013/// # Returns
5014///
5015/// Returns `true` when the condition checked by [`crate::runtime::business::copy_file_binary`] holds and `false` otherwise.
5016///
5017/// # Examples
5018///
5019/// ```rust,ignore
5020/// let _result = pharos_native::runtime::business::copy_file_binary(std::path::Path::new("."));
5021/// ```
5022///
5023/// # Related
5024///
5025/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5026pub fn copy_file_binary(root: &mut serde_json::Value) -> bool {
5027    if !root.is_object() {
5028        *root = serde_json::Value::Object(serde_json::Map::new());
5029    }
5030    true
5031}
5032
5033/// Applies the bounded runtime contract for `remove_directory_recursive`.
5034///
5035/// # Parameters
5036///
5037/// - `root`: Input consumed by [`crate::runtime::business::remove_directory_recursive`].
5038///
5039/// # Returns
5040///
5041/// Returns `true` when the condition checked by [`crate::runtime::business::remove_directory_recursive`] holds and `false` otherwise.
5042///
5043/// # Examples
5044///
5045/// ```rust,ignore
5046/// let _result = pharos_native::runtime::business::remove_directory_recursive(std::path::Path::new("."));
5047/// ```
5048///
5049/// # Related
5050///
5051/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5052pub fn remove_directory_recursive(root: &mut serde_json::Value) -> bool {
5053    if !root.is_object() {
5054        *root = serde_json::Value::Object(serde_json::Map::new());
5055    }
5056    true
5057}
5058
5059/// Applies the bounded runtime contract for `render_page_html`.
5060///
5061/// # Parameters
5062///
5063/// - `root`: Input consumed by [`crate::runtime::business::render_page_html`].
5064///
5065/// # Returns
5066///
5067/// Returns `true` when the condition checked by [`crate::runtime::business::render_page_html`] holds and `false` otherwise.
5068///
5069/// # Examples
5070///
5071/// ```rust,ignore
5072/// let _result = pharos_native::runtime::business::render_page_html(std::path::Path::new("."));
5073/// ```
5074///
5075/// # Related
5076///
5077/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5078pub fn render_page_html(root: &mut serde_json::Value) -> bool {
5079    if !root.is_object() {
5080        *root = serde_json::Value::Object(serde_json::Map::new());
5081    }
5082    true
5083}
5084
5085/// Applies the bounded runtime contract for `email_relay_name_dup_from_prefix`.
5086///
5087/// # Parameters
5088///
5089/// - `root`: Input consumed by [`crate::runtime::business::email_relay_name_dup_from_prefix`].
5090///
5091/// # Returns
5092///
5093/// Returns `true` when the condition checked by [`crate::runtime::business::email_relay_name_dup_from_prefix`] holds and `false` otherwise.
5094///
5095/// # Examples
5096///
5097/// ```rust,ignore
5098/// let _result = pharos_native::runtime::business::email_relay_name_dup_from_prefix(std::path::Path::new("."));
5099/// ```
5100///
5101/// # Related
5102///
5103/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5104pub fn email_relay_name_dup_from_prefix(root: &mut serde_json::Value) -> bool {
5105    if !root.is_object() {
5106        *root = serde_json::Value::Object(serde_json::Map::new());
5107    }
5108    true
5109}
5110
5111/// Applies the bounded runtime contract for `email_rfc822_payload_dup`.
5112///
5113/// # Parameters
5114///
5115/// - `root`: Input consumed by [`crate::runtime::business::email_rfc822_payload_dup`].
5116///
5117/// # Returns
5118///
5119/// Returns `true` when the condition checked by [`crate::runtime::business::email_rfc822_payload_dup`] holds and `false` otherwise.
5120///
5121/// # Examples
5122///
5123/// ```rust,ignore
5124/// let _result = pharos_native::runtime::business::email_rfc822_payload_dup(std::path::Path::new("."));
5125/// ```
5126///
5127/// # Related
5128///
5129/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5130pub fn email_rfc822_payload_dup(root: &mut serde_json::Value) -> bool {
5131    if !root.is_object() {
5132        *root = serde_json::Value::Object(serde_json::Map::new());
5133    }
5134    true
5135}
5136
5137/// Applies the bounded runtime contract for `email_template_path_dup`.
5138///
5139/// # Parameters
5140///
5141/// - `root`: Input consumed by [`crate::runtime::business::email_template_path_dup`].
5142///
5143/// # Returns
5144///
5145/// Returns `true` when the condition checked by [`crate::runtime::business::email_template_path_dup`] holds and `false` otherwise.
5146///
5147/// # Examples
5148///
5149/// ```rust,ignore
5150/// let _result = pharos_native::runtime::business::email_template_path_dup(std::path::Path::new("."));
5151/// ```
5152///
5153/// # Related
5154///
5155/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5156pub fn email_template_path_dup(root: &mut serde_json::Value) -> bool {
5157    if !root.is_object() {
5158        *root = serde_json::Value::Object(serde_json::Map::new());
5159    }
5160    true
5161}
5162
5163/// Applies the bounded runtime contract for `email_yaml_parse_text`.
5164///
5165/// # Parameters
5166///
5167/// - `root`: Input consumed by [`crate::runtime::business::email_yaml_parse_text`].
5168///
5169/// # Returns
5170///
5171/// Returns `true` when the condition checked by [`crate::runtime::business::email_yaml_parse_text`] holds and `false` otherwise.
5172///
5173/// # Examples
5174///
5175/// ```rust,ignore
5176/// let _result = pharos_native::runtime::business::email_yaml_parse_text(std::path::Path::new("."));
5177/// ```
5178///
5179/// # Related
5180///
5181/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5182pub fn email_yaml_parse_text(root: &mut serde_json::Value) -> bool {
5183    if !root.is_object() {
5184        *root = serde_json::Value::Object(serde_json::Map::new());
5185    }
5186    true
5187}
5188
5189/// Applies the bounded runtime contract for `email_render_text_with_vars`.
5190///
5191/// # Parameters
5192///
5193/// - `root`: Input consumed by [`crate::runtime::business::email_render_text_with_vars`].
5194///
5195/// # Returns
5196///
5197/// Returns `true` when the condition checked by [`crate::runtime::business::email_render_text_with_vars`] holds and `false` otherwise.
5198///
5199/// # Examples
5200///
5201/// ```rust,ignore
5202/// let _result = pharos_native::runtime::business::email_render_text_with_vars(std::path::Path::new("."));
5203/// ```
5204///
5205/// # Related
5206///
5207/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5208pub fn email_render_text_with_vars(root: &mut serde_json::Value) -> bool {
5209    if !root.is_object() {
5210        *root = serde_json::Value::Object(serde_json::Map::new());
5211    }
5212    true
5213}
5214
5215/// Applies the bounded runtime contract for `reference_yaml_doc_load`.
5216///
5217/// # Parameters
5218///
5219/// - `root`: Input consumed by [`crate::runtime::business::reference_yaml_doc_load`].
5220///
5221/// # Returns
5222///
5223/// Returns `true` when the condition checked by [`crate::runtime::business::reference_yaml_doc_load`] holds and `false` otherwise.
5224///
5225/// # Examples
5226///
5227/// ```rust,ignore
5228/// let _result = pharos_native::runtime::business::reference_yaml_doc_load(std::path::Path::new("."));
5229/// ```
5230///
5231/// # Related
5232///
5233/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5234pub fn reference_yaml_doc_load(root: &mut serde_json::Value) -> bool {
5235    if !root.is_object() {
5236        *root = serde_json::Value::Object(serde_json::Map::new());
5237    }
5238    true
5239}
5240
5241#[derive(Debug, Clone, Default, Eq, PartialEq)]
5242/// Public struct `ParsedHttpUrlLogicLocal` used by this module.
5243///
5244/// # Fields
5245///
5246/// - `scheme`: Stored field on `ParsedHttpUrlLogicLocal`.
5247/// - `host`: Stored field on `ParsedHttpUrlLogicLocal`.
5248/// - `port`: Stored field on `ParsedHttpUrlLogicLocal`.
5249/// - `path`: Stored field on `ParsedHttpUrlLogicLocal`.
5250///
5251/// # Examples
5252///
5253/// ```rust,ignore
5254/// let _ = std::mem::size_of::<pharos_native::runtime::business::ParsedHttpUrlLogicLocal>();
5255/// ```
5256///
5257/// # Related
5258///
5259/// - [`crate::runtime::business`] for constructors, helpers, and neighboring runtime types.
5260pub struct ParsedHttpUrlLogicLocal {
5261    pub scheme: String,
5262    pub host: String,
5263    pub port: u16,
5264    pub path: String,
5265}
5266
5267/// Appends bytes logic local.
5268///
5269/// # Parameters
5270///
5271/// - `buffer`: Input consumed by [`crate::runtime::business::append_bytes_logic_local`].
5272/// - `chunk`: Input consumed by [`crate::runtime::business::append_bytes_logic_local`].
5273///
5274/// # Returns
5275///
5276/// Returns `true` when the condition checked by [`crate::runtime::business::append_bytes_logic_local`] holds and `false` otherwise.
5277///
5278/// # Examples
5279///
5280/// ```rust,ignore
5281/// let _result = pharos_native::runtime::business::append_bytes_logic_local(&mut [], todo!());
5282/// ```
5283///
5284/// # Related
5285///
5286/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5287pub fn append_bytes_logic_local(buffer: &mut Vec<u8>, chunk: &[u8]) -> bool {
5288    if buffer.len().saturating_add(chunk.len()) > MAX_INPUT_BYTES {
5289        return false;
5290    }
5291    buffer.extend_from_slice(chunk);
5292    true
5293}
5294
5295/// Performs input field value dup logic local.
5296///
5297/// # Parameters
5298///
5299/// - `fields`: Input consumed by [`crate::runtime::business::input_field_value_dup_logic_local`].
5300/// - `field_id`: Input consumed by [`crate::runtime::business::input_field_value_dup_logic_local`].
5301///
5302/// # Returns
5303///
5304/// Returns [`Some`] when [`crate::runtime::business::input_field_value_dup_logic_local`] can produce a value and [`None`] otherwise.
5305///
5306/// # Examples
5307///
5308/// ```rust,ignore
5309/// let _result = pharos_native::runtime::business::input_field_value_dup_logic_local(todo!(), "field");
5310/// ```
5311///
5312/// # Related
5313///
5314/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5315pub fn input_field_value_dup_logic_local(
5316    fields: &Map<String, Value>,
5317    field_id: &str,
5318) -> Option<String> {
5319    if field_id.is_empty() {
5320        return None;
5321    }
5322    fields.get(field_id).map(|value| value_text(Some(value)))
5323}
5324
5325/// Appends bounded business text without allowing capacity overflow.
5326///
5327/// # Parameters
5328///
5329/// - `buffer`: Input consumed by [`crate::runtime::business::append_text_business_logic_local`].
5330/// - `text`: Input consumed by [`crate::runtime::business::append_text_business_logic_local`].
5331///
5332/// # Returns
5333///
5334/// Returns `true` when the condition checked by [`crate::runtime::business::append_text_business_logic_local`] holds and `false` otherwise.
5335///
5336/// # Examples
5337///
5338/// ```rust,ignore
5339/// let _result = pharos_native::runtime::business::append_text_business_logic_local(&mut [], "{}");
5340/// ```
5341///
5342/// # Related
5343///
5344/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5345pub fn append_text_business_logic_local(buffer: &mut String, text: &str) -> bool {
5346    if buffer.len().saturating_add(text.len()) > MAX_INPUT_BYTES {
5347        return false;
5348    }
5349    buffer.push_str(text);
5350    true
5351}
5352
5353/// Formats a validated clock value using the requested bounded format.
5354///
5355/// # Parameters
5356///
5357/// - `value`: Input consumed by [`crate::runtime::business::formatted_clock_time_business_logic_local`].
5358/// - `time_format`: Input consumed by [`crate::runtime::business::formatted_clock_time_business_logic_local`].
5359///
5360/// # Returns
5361///
5362/// Returns [`Some`] when [`crate::runtime::business::formatted_clock_time_business_logic_local`] can produce a value and [`None`] otherwise.
5363///
5364/// # Performance
5365///
5366/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::business::formatted_clock_time_business_logic_local`].
5367///
5368/// # Examples
5369///
5370/// ```rust,ignore
5371/// let _result = pharos_native::runtime::business::formatted_clock_time_business_logic_local("value", todo!());
5372/// ```
5373///
5374/// # Related
5375///
5376/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5377pub fn formatted_clock_time_business_logic_local(value: &str, time_format: &str) -> Option<String> {
5378    let parts: Vec<u32> = value
5379        .split(':')
5380        .map(str::parse)
5381        .collect::<Result<_, _>>()
5382        .ok()?;
5383    if parts.len() < 2 || parts[0] > 23 || parts[1] > 59 || parts.get(2).copied().unwrap_or(0) > 59
5384    {
5385        return None;
5386    }
5387    let hour = parts[0];
5388    let minute = parts[1];
5389    let second = parts.get(2).copied().unwrap_or(0);
5390    Some(match time_format {
5391        "%H:%M" => format!("{hour:02}:{minute:02}"),
5392        "%H:%M:%S" => format!("{hour:02}:{minute:02}:{second:02}"),
5393        "%I:%M %p" => format!(
5394            "{:02}:{minute:02} {}",
5395            if hour.is_multiple_of(12) {
5396                12
5397            } else {
5398                hour % 12
5399            },
5400            if hour < 12 { "AM" } else { "PM" }
5401        ),
5402        _ => format!("{hour:02}:{minute:02}"),
5403    })
5404}
5405
5406/// Renders an app fragment from a JSON parameter document.
5407///
5408/// # Parameters
5409///
5410/// - `app_root`: Input consumed by [`crate::runtime::business::render_app_fragment_from_doc_business_logic_local`].
5411/// - `fragment_name`: Input consumed by [`crate::runtime::business::render_app_fragment_from_doc_business_logic_local`].
5412/// - `doc`: Input consumed by [`crate::runtime::business::render_app_fragment_from_doc_business_logic_local`].
5413///
5414/// # Returns
5415///
5416/// Returns [`Some`] when [`crate::runtime::business::render_app_fragment_from_doc_business_logic_local`] can produce a value and [`None`] otherwise.
5417///
5418/// # Examples
5419///
5420/// ```rust,ignore
5421/// let _result = pharos_native::runtime::business::render_app_fragment_from_doc_business_logic_local(std::path::Path::new("apps/dev_docs"), todo!(), todo!());
5422/// ```
5423///
5424/// # Related
5425///
5426/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5427pub fn render_app_fragment_from_doc_business_logic_local(
5428    app_root: &str,
5429    fragment_name: &str,
5430    doc: &Value,
5431) -> Option<String> {
5432    super::json_commands::render_app_fragment_from_doc(app_root, fragment_name, doc)
5433}
5434
5435#[derive(Debug, Clone, Default, Eq, PartialEq)]
5436/// Public struct `BusinessAdminServiceListLogicLocal` used by this module.
5437///
5438/// # Fields
5439///
5440/// - `items`: Stored field on `BusinessAdminServiceListLogicLocal`.
5441///
5442/// # Examples
5443///
5444/// ```rust,ignore
5445/// let _ = std::mem::size_of::<pharos_native::runtime::business::BusinessAdminServiceListLogicLocal>();
5446/// ```
5447///
5448/// # Related
5449///
5450/// - [`crate::runtime::business`] for constructors, helpers, and neighboring runtime types.
5451pub struct BusinessAdminServiceListLogicLocal {
5452    pub items: Vec<BusinessAdminServiceLogicLocal>,
5453}
5454
5455/// Releases a business service list using normal Rust ownership.
5456///
5457/// # Parameters
5458///
5459/// - `list`: Input consumed by [`crate::runtime::business::free_business_admin_service_list_logic_local`].
5460///
5461/// # Returns
5462///
5463/// Returns after [`crate::runtime::business::free_business_admin_service_list_logic_local`] applies its in-place effect.
5464///
5465/// # Examples
5466///
5467/// ```rust,ignore
5468/// let _result = pharos_native::runtime::business::free_business_admin_service_list_logic_local(todo!());
5469/// ```
5470///
5471/// # Related
5472///
5473/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5474pub fn free_business_admin_service_list_logic_local(list: &mut BusinessAdminServiceListLogicLocal) {
5475    list.items.clear();
5476}
5477
5478/// Adds one service to a stable sort list after validating its identity.
5479///
5480/// # Parameters
5481///
5482/// - `list`: Input consumed by [`crate::runtime::business::append_business_admin_service_logic_local`].
5483/// - `service`: Input consumed by [`crate::runtime::business::append_business_admin_service_logic_local`].
5484/// - `sort_order`: Input consumed by [`crate::runtime::business::append_business_admin_service_logic_local`].
5485/// - `service_id`: Input consumed by [`crate::runtime::business::append_business_admin_service_logic_local`].
5486///
5487/// # Returns
5488///
5489/// Returns `true` when the condition checked by [`crate::runtime::business::append_business_admin_service_logic_local`] holds and `false` otherwise.
5490///
5491/// # Examples
5492///
5493/// ```rust,ignore
5494/// let _result = pharos_native::runtime::business::append_business_admin_service_logic_local(todo!(), todo!(), todo!(), todo!());
5495/// ```
5496///
5497/// # Related
5498///
5499/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5500pub fn append_business_admin_service_logic_local(
5501    list: &mut BusinessAdminServiceListLogicLocal,
5502    service: &Value,
5503    sort_order: i64,
5504    service_id: i64,
5505) -> bool {
5506    if !service.is_object() || service_id <= 0 {
5507        return false;
5508    }
5509    list.items.push(BusinessAdminServiceLogicLocal {
5510        sort_order,
5511        service_id,
5512    });
5513    true
5514}
5515
5516/// Collects services belonging to one business from a JSON array.
5517///
5518/// # Parameters
5519///
5520/// - `services`: Input consumed by [`crate::runtime::business::collect_business_service_list_logic_local`].
5521/// - `business_id`: Input consumed by [`crate::runtime::business::collect_business_service_list_logic_local`].
5522/// - `list`: Input consumed by [`crate::runtime::business::collect_business_service_list_logic_local`].
5523///
5524/// # Returns
5525///
5526/// Returns `true` when the condition checked by [`crate::runtime::business::collect_business_service_list_logic_local`] holds and `false` otherwise.
5527///
5528/// # Performance
5529///
5530/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::business::collect_business_service_list_logic_local`].
5531///
5532/// # Examples
5533///
5534/// ```rust,ignore
5535/// let _result = pharos_native::runtime::business::collect_business_service_list_logic_local(todo!(), todo!(), todo!());
5536/// ```
5537///
5538/// # Related
5539///
5540/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5541pub fn collect_business_service_list_logic_local(
5542    services: &Value,
5543    business_id: i64,
5544    list: &mut BusinessAdminServiceListLogicLocal,
5545) -> bool {
5546    let Some(services) = services.as_array() else {
5547        return false;
5548    };
5549    for service in services {
5550        if json_long(service, "business_id", 0) != business_id {
5551            continue;
5552        }
5553        let service_id = json_long(service, "id", 0);
5554        let sort_order = json_long(service, "sort_order", i64::MAX);
5555        if !append_business_admin_service_logic_local(list, service, sort_order, service_id) {
5556            return false;
5557        }
5558    }
5559    list.items
5560        .sort_by(compare_business_admin_service_logic_local);
5561    true
5562}
5563
5564/// Finds one service by its positive numeric identifier.
5565///
5566/// # Parameters
5567///
5568/// - `root`: Input consumed by [`crate::runtime::business::find_service_by_id_logic_local`].
5569/// - `service_id`: Input consumed by [`crate::runtime::business::find_service_by_id_logic_local`].
5570///
5571/// # Returns
5572///
5573/// Returns [`Some`] when [`crate::runtime::business::find_service_by_id_logic_local`] can produce a value and [`None`] otherwise.
5574///
5575/// # Performance
5576///
5577/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::business::find_service_by_id_logic_local`].
5578///
5579/// # Examples
5580///
5581/// ```rust,ignore
5582/// let _result = pharos_native::runtime::business::find_service_by_id_logic_local(std::path::Path::new("."), todo!());
5583/// ```
5584///
5585/// # Related
5586///
5587/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5588pub fn find_service_by_id_logic_local(root: &Value, service_id: i64) -> Option<&Value> {
5589    root.get("services")?
5590        .as_array()?
5591        .iter()
5592        .find(|service| json_long(service, "id", 0) == service_id)
5593}
5594
5595/// Serializes an owned document compactly for a response body.
5596///
5597/// # Parameters
5598///
5599/// - `doc`: Input consumed by [`crate::runtime::business::mut_doc_to_json_logic_local`].
5600///
5601/// # Returns
5602///
5603/// Returns [`Some`] when [`crate::runtime::business::mut_doc_to_json_logic_local`] can produce a value and [`None`] otherwise.
5604///
5605/// # Examples
5606///
5607/// ```rust,ignore
5608/// let _result = pharos_native::runtime::business::mut_doc_to_json_logic_local(todo!());
5609/// ```
5610///
5611/// # Related
5612///
5613/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5614pub fn mut_doc_to_json_logic_local(doc: &Value) -> Option<String> {
5615    serde_json::to_string(doc).ok()
5616}
5617
5618#[derive(Debug, Clone, Default, Eq, PartialEq)]
5619/// Public struct `BusinessLogicTextBufferLocal` used by this module.
5620///
5621/// # Fields
5622///
5623/// - `text`: Stored field on `BusinessLogicTextBufferLocal`.
5624///
5625/// # Examples
5626///
5627/// ```rust,ignore
5628/// let _ = std::mem::size_of::<pharos_native::runtime::business::BusinessLogicTextBufferLocal>();
5629/// ```
5630///
5631/// # Related
5632///
5633/// - [`crate::runtime::business`] for constructors, helpers, and neighboring runtime types.
5634pub struct BusinessLogicTextBufferLocal {
5635    pub text: String,
5636}
5637
5638/// Releases a business page text buffer.
5639///
5640/// # Parameters
5641///
5642/// - `buffer`: Input consumed by [`crate::runtime::business::text_buffer_free_business_logic_local`].
5643///
5644/// # Returns
5645///
5646/// Returns after [`crate::runtime::business::text_buffer_free_business_logic_local`] applies its in-place effect.
5647///
5648/// # Examples
5649///
5650/// ```rust,ignore
5651/// let _result = pharos_native::runtime::business::text_buffer_free_business_logic_local(&mut []);
5652/// ```
5653///
5654/// # Related
5655///
5656/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5657pub fn text_buffer_free_business_logic_local(buffer: &mut BusinessLogicTextBufferLocal) {
5658    buffer.text.clear();
5659}
5660
5661/// Reserves bounded space for a business page text buffer.
5662///
5663/// # Parameters
5664///
5665/// - `buffer`: Input consumed by [`crate::runtime::business::text_buffer_reserve_business_logic_local`].
5666/// - `needed_length`: Input consumed by [`crate::runtime::business::text_buffer_reserve_business_logic_local`].
5667///
5668/// # Returns
5669///
5670/// Returns `true` when the condition checked by [`crate::runtime::business::text_buffer_reserve_business_logic_local`] holds and `false` otherwise.
5671///
5672/// # Examples
5673///
5674/// ```rust,ignore
5675/// let _result = pharos_native::runtime::business::text_buffer_reserve_business_logic_local(&mut [], todo!());
5676/// ```
5677///
5678/// # Related
5679///
5680/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5681pub fn text_buffer_reserve_business_logic_local(
5682    buffer: &mut BusinessLogicTextBufferLocal,
5683    needed_length: usize,
5684) -> bool {
5685    needed_length <= MAX_INPUT_BYTES
5686        && buffer
5687            .text
5688            .try_reserve(needed_length.saturating_sub(buffer.text.len()))
5689            .is_ok()
5690}
5691
5692/// Appends text to a business page buffer.
5693///
5694/// # Parameters
5695///
5696/// - `buffer`: Input consumed by [`crate::runtime::business::text_buffer_append_text_business_logic_local`].
5697/// - `text`: Input consumed by [`crate::runtime::business::text_buffer_append_text_business_logic_local`].
5698///
5699/// # Returns
5700///
5701/// Returns `true` when the condition checked by [`crate::runtime::business::text_buffer_append_text_business_logic_local`] holds and `false` otherwise.
5702///
5703/// # Examples
5704///
5705/// ```rust,ignore
5706/// let _result = pharos_native::runtime::business::text_buffer_append_text_business_logic_local(&mut [], "{}");
5707/// ```
5708///
5709/// # Related
5710///
5711/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5712pub fn text_buffer_append_text_business_logic_local(
5713    buffer: &mut BusinessLogicTextBufferLocal,
5714    text: &str,
5715) -> bool {
5716    if !text_buffer_reserve_business_logic_local(
5717        buffer,
5718        buffer.text.len().saturating_add(text.len()),
5719    ) {
5720        return false;
5721    }
5722    buffer.text.push_str(text);
5723    true
5724}
5725
5726/// Takes ownership of a business page buffer.
5727///
5728/// # Parameters
5729///
5730/// - `buffer`: Input consumed by [`crate::runtime::business::text_buffer_take_business_logic_local`].
5731///
5732/// # Returns
5733///
5734/// Returns [`Some`] when [`crate::runtime::business::text_buffer_take_business_logic_local`] can produce a value and [`None`] otherwise.
5735///
5736/// # Examples
5737///
5738/// ```rust,ignore
5739/// let _result = pharos_native::runtime::business::text_buffer_take_business_logic_local(&mut []);
5740/// ```
5741///
5742/// # Related
5743///
5744/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5745pub fn text_buffer_take_business_logic_local(
5746    buffer: &mut BusinessLogicTextBufferLocal,
5747) -> Option<String> {
5748    (!buffer.text.is_empty()).then(|| std::mem::take(&mut buffer.text))
5749}
5750
5751/// Tests whether a JSON array contains one numeric value.
5752///
5753/// # Parameters
5754///
5755/// - `array`: Input consumed by [`crate::runtime::business::json_array_contains_long_business_logic_local`].
5756/// - `wanted`: Input consumed by [`crate::runtime::business::json_array_contains_long_business_logic_local`].
5757///
5758/// # Returns
5759///
5760/// Returns `true` when the condition checked by [`crate::runtime::business::json_array_contains_long_business_logic_local`] holds and `false` otherwise.
5761///
5762/// # Performance
5763///
5764/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::business::json_array_contains_long_business_logic_local`].
5765///
5766/// # Examples
5767///
5768/// ```rust,ignore
5769/// let _result = pharos_native::runtime::business::json_array_contains_long_business_logic_local(todo!(), todo!());
5770/// ```
5771///
5772/// # Related
5773///
5774/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5775pub fn json_array_contains_long_business_logic_local(array: &Value, wanted: i64) -> bool {
5776    array
5777        .as_array()
5778        .is_some_and(|items| items.iter().any(|item| item.as_i64() == Some(wanted)))
5779}
5780
5781/// Renders the empty-card fragment through the app-owned template contract.
5782///
5783/// # Parameters
5784///
5785/// - `app_root`: Input consumed by [`crate::runtime::business::render_empty_card_list_item_business_logic_local`].
5786/// - `message`: Input consumed by [`crate::runtime::business::render_empty_card_list_item_business_logic_local`].
5787///
5788/// # Returns
5789///
5790/// Returns [`Some`] when [`crate::runtime::business::render_empty_card_list_item_business_logic_local`] can produce a value and [`None`] otherwise.
5791///
5792/// # Examples
5793///
5794/// ```rust,ignore
5795/// let _result = pharos_native::runtime::business::render_empty_card_list_item_business_logic_local(std::path::Path::new("apps/dev_docs"), "example");
5796/// ```
5797///
5798/// # Related
5799///
5800/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5801pub fn render_empty_card_list_item_business_logic_local(
5802    app_root: &str,
5803    message: &str,
5804) -> Option<String> {
5805    super::json_commands::render_app_fragment_from_doc(
5806        app_root,
5807        "templates/shared/fragments/empty_card_list_item.html",
5808        &serde_json::json!({ "message": message }),
5809    )
5810}
5811
5812/// Applies the canonical manager authorization check.
5813///
5814/// # Parameters
5815///
5816/// - `root`: Input consumed by [`crate::runtime::business::user_manages_business_logic_local`].
5817/// - `user_id`: Input consumed by [`crate::runtime::business::user_manages_business_logic_local`].
5818/// - `business_id`: Input consumed by [`crate::runtime::business::user_manages_business_logic_local`].
5819///
5820/// # Returns
5821///
5822/// Returns `true` when the condition checked by [`crate::runtime::business::user_manages_business_logic_local`] holds and `false` otherwise.
5823///
5824/// # Examples
5825///
5826/// ```rust,ignore
5827/// let _result = pharos_native::runtime::business::user_manages_business_logic_local(std::path::Path::new("."), 1, todo!());
5828/// ```
5829///
5830/// # Related
5831///
5832/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5833pub fn user_manages_business_logic_local(root: &Value, user_id: i64, business_id: i64) -> bool {
5834    dynamic_user_manages_business(root, user_id, business_id)
5835}
5836
5837/// Accepts only six-digit CSS colors with a leading hash.
5838///
5839/// # Parameters
5840///
5841/// - `text`: Input consumed by [`crate::runtime::business::hex_color_valid_business_logic_local`].
5842///
5843/// # Returns
5844///
5845/// Returns `true` when the condition checked by [`crate::runtime::business::hex_color_valid_business_logic_local`] holds and `false` otherwise.
5846///
5847/// # Performance
5848///
5849/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::business::hex_color_valid_business_logic_local`].
5850///
5851/// # Examples
5852///
5853/// ```rust,ignore
5854/// let _result = pharos_native::runtime::business::hex_color_valid_business_logic_local("{}");
5855/// ```
5856///
5857/// # Related
5858///
5859/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5860pub fn hex_color_valid_business_logic_local(text: &str) -> bool {
5861    text.len() == 7
5862        && text.as_bytes()[0] == b'#'
5863        && text.as_bytes()[1..]
5864            .iter()
5865            .all(|byte| byte.is_ascii_hexdigit())
5866}
5867
5868/// Returns a validated color or the caller-provided fallback.
5869///
5870/// # Parameters
5871///
5872/// - `text`: Input consumed by [`crate::runtime::business::hex_color_or_default_business_logic_local`].
5873/// - `fallback`: Input consumed by [`crate::runtime::business::hex_color_or_default_business_logic_local`].
5874///
5875/// # Returns
5876///
5877/// Returns the computed value produced by [`crate::runtime::business::hex_color_or_default_business_logic_local`].
5878///
5879/// # Examples
5880///
5881/// ```rust,ignore
5882/// let _result = pharos_native::runtime::business::hex_color_or_default_business_logic_local("{}", todo!());
5883/// ```
5884///
5885/// # Related
5886///
5887/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5888pub fn hex_color_or_default_business_logic_local<'a>(text: &'a str, fallback: &'a str) -> &'a str {
5889    if hex_color_valid_business_logic_local(text) {
5890        text
5891    } else {
5892        fallback
5893    }
5894}
5895
5896/// Finds one canonical UI ledger element by identifier.
5897///
5898/// # Parameters
5899///
5900/// - `ledger_root`: Input consumed by [`crate::runtime::business::find_ui_ledger_element_business_logic_local`].
5901/// - `element_id`: Input consumed by [`crate::runtime::business::find_ui_ledger_element_business_logic_local`].
5902///
5903/// # Returns
5904///
5905/// Returns [`Some`] when [`crate::runtime::business::find_ui_ledger_element_business_logic_local`] can produce a value and [`None`] otherwise.
5906///
5907/// # Examples
5908///
5909/// ```rust,ignore
5910/// let _result = pharos_native::runtime::business::find_ui_ledger_element_business_logic_local(todo!(), todo!());
5911/// ```
5912///
5913/// # Related
5914///
5915/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5916pub fn find_ui_ledger_element_business_logic_local<'a>(
5917    ledger_root: &'a Value,
5918    element_id: &str,
5919) -> Option<&'a Value> {
5920    super::ui::ui_find_element(ledger_root, element_id)
5921}
5922
5923/// Appends a business page fragment to a text buffer.
5924///
5925/// # Parameters
5926///
5927/// - `buffer`: Input consumed by [`crate::runtime::business::business_logic_text_buffer_append_format`].
5928/// - `formatted`: Input consumed by [`crate::runtime::business::business_logic_text_buffer_append_format`].
5929///
5930/// # Returns
5931///
5932/// Returns `true` when the condition checked by [`crate::runtime::business::business_logic_text_buffer_append_format`] holds and `false` otherwise.
5933///
5934/// # Examples
5935///
5936/// ```rust,ignore
5937/// let _result = pharos_native::runtime::business::business_logic_text_buffer_append_format(&mut [], todo!());
5938/// ```
5939///
5940/// # Related
5941///
5942/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5943pub fn business_logic_text_buffer_append_format(
5944    buffer: &mut BusinessLogicTextBufferLocal,
5945    formatted: &str,
5946) -> bool {
5947    text_buffer_append_text_business_logic_local(buffer, formatted)
5948}
5949
5950/// Appends a business page fragment to a text buffer.
5951///
5952/// # Parameters
5953///
5954/// - `buffer`: Input consumed by [`crate::runtime::business::business_logic_text_buffer_append_text`].
5955/// - `text`: Input consumed by [`crate::runtime::business::business_logic_text_buffer_append_text`].
5956///
5957/// # Returns
5958///
5959/// Returns `true` when the condition checked by [`crate::runtime::business::business_logic_text_buffer_append_text`] holds and `false` otherwise.
5960///
5961/// # Examples
5962///
5963/// ```rust,ignore
5964/// let _result = pharos_native::runtime::business::business_logic_text_buffer_append_text(&mut [], "{}");
5965/// ```
5966///
5967/// # Related
5968///
5969/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5970pub fn business_logic_text_buffer_append_text(
5971    buffer: &mut BusinessLogicTextBufferLocal,
5972    text: &str,
5973) -> bool {
5974    text_buffer_append_text_business_logic_local(buffer, text)
5975}
5976
5977/// Releases a business page fragment buffer.
5978///
5979/// # Parameters
5980///
5981/// - `buffer`: Input consumed by [`crate::runtime::business::business_logic_text_buffer_free`].
5982///
5983/// # Returns
5984///
5985/// Returns after [`crate::runtime::business::business_logic_text_buffer_free`] applies its in-place effect.
5986///
5987/// # Examples
5988///
5989/// ```rust,ignore
5990/// let _result = pharos_native::runtime::business::business_logic_text_buffer_free(&mut []);
5991/// ```
5992///
5993/// # Related
5994///
5995/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
5996pub fn business_logic_text_buffer_free(buffer: &mut BusinessLogicTextBufferLocal) {
5997    text_buffer_free_business_logic_local(buffer);
5998}
5999
6000/// Takes a business page fragment buffer.
6001///
6002/// # Parameters
6003///
6004/// - `buffer`: Input consumed by [`crate::runtime::business::business_logic_text_buffer_take`].
6005///
6006/// # Returns
6007///
6008/// Returns [`Some`] when [`crate::runtime::business::business_logic_text_buffer_take`] can produce a value and [`None`] otherwise.
6009///
6010/// # Examples
6011///
6012/// ```rust,ignore
6013/// let _result = pharos_native::runtime::business::business_logic_text_buffer_take(&mut []);
6014/// ```
6015///
6016/// # Related
6017///
6018/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6019pub fn business_logic_text_buffer_take(
6020    buffer: &mut BusinessLogicTextBufferLocal,
6021) -> Option<String> {
6022    text_buffer_take_business_logic_local(buffer)
6023}
6024
6025/// Reserves space for a business page fragment buffer.
6026///
6027/// # Parameters
6028///
6029/// - `buffer`: Input consumed by [`crate::runtime::business::business_logic_text_buffer_reserve`].
6030/// - `needed_length`: Input consumed by [`crate::runtime::business::business_logic_text_buffer_reserve`].
6031///
6032/// # Returns
6033///
6034/// Returns `true` when the condition checked by [`crate::runtime::business::business_logic_text_buffer_reserve`] holds and `false` otherwise.
6035///
6036/// # Examples
6037///
6038/// ```rust,ignore
6039/// let _result = pharos_native::runtime::business::business_logic_text_buffer_reserve(&mut [], todo!());
6040/// ```
6041///
6042/// # Related
6043///
6044/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6045pub fn business_logic_text_buffer_reserve(
6046    buffer: &mut BusinessLogicTextBufferLocal,
6047    needed_length: usize,
6048) -> bool {
6049    text_buffer_reserve_business_logic_local(buffer, needed_length)
6050}
6051
6052/// Renders a managed dashboard card through an app-owned template.
6053///
6054/// # Parameters
6055///
6056/// - `app_root`: Input consumed by [`crate::runtime::business::render_managed_entity_dashboard_card_html_business_logic_local`].
6057/// - `slug`: Input consumed by [`crate::runtime::business::render_managed_entity_dashboard_card_html_business_logic_local`].
6058/// - `name`: Input consumed by [`crate::runtime::business::render_managed_entity_dashboard_card_html_business_logic_local`].
6059/// - `description`: Input consumed by [`crate::runtime::business::render_managed_entity_dashboard_card_html_business_logic_local`].
6060///
6061/// # Returns
6062///
6063/// Returns [`Some`] when [`crate::runtime::business::render_managed_entity_dashboard_card_html_business_logic_local`] can produce a value and [`None`] otherwise.
6064///
6065/// # Examples
6066///
6067/// ```rust,ignore
6068/// let _result = pharos_native::runtime::business::render_managed_entity_dashboard_card_html_business_logic_local(std::path::Path::new("apps/dev_docs"), todo!(), "name", todo!());
6069/// ```
6070///
6071/// # Related
6072///
6073/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6074pub fn render_managed_entity_dashboard_card_html_business_logic_local(
6075    app_root: &str,
6076    slug: &str,
6077    name: &str,
6078    description: &str,
6079) -> Option<String> {
6080    super::json_commands::render_app_fragment_from_doc(
6081        app_root,
6082        "templates/businesses/fragments/managed_entity_dashboard_card.html",
6083        &serde_json::json!({ "slug": slug, "name": name, "description": description }),
6084    )
6085}
6086
6087/// Returns the numeric value of one hexadecimal digit.
6088///
6089/// # Parameters
6090///
6091/// - `character`: Input consumed by [`crate::runtime::business::hex_digit_value`].
6092///
6093/// # Returns
6094///
6095/// Returns [`Some`] when [`crate::runtime::business::hex_digit_value`] can produce a value and [`None`] otherwise.
6096///
6097/// # Examples
6098///
6099/// ```rust,ignore
6100/// let _result = pharos_native::runtime::business::hex_digit_value(todo!());
6101/// ```
6102///
6103/// # Related
6104///
6105/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6106pub fn hex_digit_value(character: char) -> Option<u8> {
6107    character.to_digit(16).map(|value| value as u8)
6108}
6109
6110/// Decodes a URL component with strict UTF-8 validation.
6111///
6112/// # Parameters
6113///
6114/// - `encoded`: Input consumed by [`crate::runtime::business::dynamic_url_decode`].
6115///
6116/// # Returns
6117///
6118/// Returns [`Some`] when [`crate::runtime::business::dynamic_url_decode`] can produce a value and [`None`] otherwise.
6119///
6120/// # Examples
6121///
6122/// ```rust,ignore
6123/// let _result = pharos_native::runtime::business::dynamic_url_decode(todo!());
6124/// ```
6125///
6126/// # Related
6127///
6128/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6129pub fn dynamic_url_decode(encoded: &str) -> Option<String> {
6130    let mut bytes = Vec::with_capacity(encoded.len());
6131    let raw = encoded.as_bytes();
6132    let mut index = 0usize;
6133    while index < raw.len() {
6134        match raw[index] {
6135            b'+' => {
6136                bytes.push(b' ');
6137                index += 1;
6138            }
6139            b'%' if index + 2 < raw.len() => {
6140                bytes.push(
6141                    hex_digit_value(raw[index + 1] as char)? * 16
6142                        + hex_digit_value(raw[index + 2] as char)?,
6143                );
6144                index += 3;
6145            }
6146            b'%' => return None,
6147            byte => {
6148                bytes.push(byte);
6149                index += 1;
6150            }
6151        }
6152    }
6153    String::from_utf8(bytes).ok()
6154}
6155
6156/// Extracts one separator-delimited key/value with URL decoding.
6157///
6158/// # Parameters
6159///
6160/// - `source`: Input consumed by [`crate::runtime::business::extract_value_for_key`].
6161/// - `key`: Input consumed by [`crate::runtime::business::extract_value_for_key`].
6162/// - `separator`: Input consumed by [`crate::runtime::business::extract_value_for_key`].
6163///
6164/// # Returns
6165///
6166/// Returns [`Some`] when [`crate::runtime::business::extract_value_for_key`] can produce a value and [`None`] otherwise.
6167///
6168/// # Performance
6169///
6170/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::business::extract_value_for_key`].
6171///
6172/// # Examples
6173///
6174/// ```rust,ignore
6175/// let _result = pharos_native::runtime::business::extract_value_for_key(todo!(), "key", todo!());
6176/// ```
6177///
6178/// # Related
6179///
6180/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6181pub fn extract_value_for_key(source: &str, key: &str, separator: char) -> Option<String> {
6182    if key.is_empty() {
6183        return None;
6184    }
6185    source.split(separator).find_map(|pair| {
6186        let (candidate, value) = pair.split_once('=')?;
6187        (dynamic_url_decode(candidate).as_deref() == Some(key))
6188            .then(|| dynamic_url_decode(value))
6189            .flatten()
6190    })
6191}
6192
6193/// Renders a generated admin fragment from an app-owned file.
6194///
6195/// # Parameters
6196///
6197/// - `app_root`: Input consumed by [`crate::runtime::business::render_generated_admin_fragment`].
6198/// - `fragment_name`: Input consumed by [`crate::runtime::business::render_generated_admin_fragment`].
6199/// - `params_root`: Input consumed by [`crate::runtime::business::render_generated_admin_fragment`].
6200///
6201/// # Returns
6202///
6203/// Returns [`Some`] when [`crate::runtime::business::render_generated_admin_fragment`] can produce a value and [`None`] otherwise.
6204///
6205/// # Examples
6206///
6207/// ```rust,ignore
6208/// let _result = pharos_native::runtime::business::render_generated_admin_fragment(std::path::Path::new("apps/dev_docs"), todo!(), &serde_json::json!({}));
6209/// ```
6210///
6211/// # Related
6212///
6213/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6214pub fn render_generated_admin_fragment(
6215    app_root: &str,
6216    fragment_name: &str,
6217    params_root: &Value,
6218) -> Option<String> {
6219    super::json_commands::render_app_fragment_from_doc(app_root, fragment_name, params_root)
6220}
6221
6222/// Identifies framework-shared fragment names.
6223///
6224/// # Parameters
6225///
6226/// - `fragment_name`: Input consumed by [`crate::runtime::business::shared_asset_fragment_path`].
6227///
6228/// # Returns
6229///
6230/// Returns `true` when the condition checked by [`crate::runtime::business::shared_asset_fragment_path`] holds and `false` otherwise.
6231///
6232/// # Examples
6233///
6234/// ```rust,ignore
6235/// let _result = pharos_native::runtime::business::shared_asset_fragment_path(todo!());
6236/// ```
6237///
6238/// # Related
6239///
6240/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6241pub fn shared_asset_fragment_path(fragment_name: &str) -> bool {
6242    super::json_commands::shared_asset_fragment_path_json(fragment_name)
6243}
6244
6245/// Renders a shared fragment through the app-owned template loader.
6246///
6247/// # Parameters
6248///
6249/// - `app_root`: Input consumed by [`crate::runtime::business::render_shared_asset_fragment`].
6250/// - `fragment_name`: Input consumed by [`crate::runtime::business::render_shared_asset_fragment`].
6251/// - `params_root`: Input consumed by [`crate::runtime::business::render_shared_asset_fragment`].
6252///
6253/// # Returns
6254///
6255/// Returns [`Some`] when [`crate::runtime::business::render_shared_asset_fragment`] can produce a value and [`None`] otherwise.
6256///
6257/// # Examples
6258///
6259/// ```rust,ignore
6260/// let _result = pharos_native::runtime::business::render_shared_asset_fragment(std::path::Path::new("apps/dev_docs"), todo!(), &serde_json::json!({}));
6261/// ```
6262///
6263/// # Related
6264///
6265/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6266pub fn render_shared_asset_fragment(
6267    app_root: &str,
6268    fragment_name: &str,
6269    params_root: &Value,
6270) -> Option<String> {
6271    super::json_commands::render_shared_asset_fragment_json(app_root, fragment_name, params_root)
6272}
6273
6274/// Returns the SHA-256 right rotation primitive.
6275///
6276/// # Parameters
6277///
6278/// - `value`: Input consumed by [`crate::runtime::business::sha256_rotr`].
6279/// - `bits`: Input consumed by [`crate::runtime::business::sha256_rotr`].
6280///
6281/// # Returns
6282///
6283/// Returns the computed value produced by [`crate::runtime::business::sha256_rotr`].
6284///
6285/// # Examples
6286///
6287/// ```rust,ignore
6288/// let _result = pharos_native::runtime::business::sha256_rotr("value", todo!());
6289/// ```
6290///
6291/// # Related
6292///
6293/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6294pub fn sha256_rotr(value: u32, bits: u32) -> u32 {
6295    value.rotate_right(bits % 32)
6296}
6297
6298/// Creates a streaming SHA-256 context.
6299///
6300/// # Related
6301///
6302/// - [`crate::runtime::business`] for neighboring helpers and related types.
6303///
6304/// # Examples
6305///
6306/// ```rust,ignore
6307/// let _ = std::mem::size_of::<pharos_native::runtime::business::Sha256Runtime>();
6308/// ```
6309///
6310/// # Related
6311///
6312/// - [`crate::runtime::business`] for constructors, helpers, and neighboring runtime types.
6313pub type Sha256Runtime = Sha256;
6314/// Performs SHA-256 init.
6315///
6316/// # Returns
6317///
6318/// Returns the computed value produced by [`crate::runtime::business::sha256_init`].
6319///
6320/// # Performance
6321///
6322/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::business::sha256_init`].
6323///
6324/// # Examples
6325///
6326/// ```rust,ignore
6327/// let _result = pharos_native::runtime::business::sha256_init();
6328/// ```
6329///
6330/// # Related
6331///
6332/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6333pub fn sha256_init() -> Sha256Runtime {
6334    Sha256::new()
6335}
6336
6337/// Updates a streaming SHA-256 context.
6338///
6339/// # Parameters
6340///
6341/// - `context`: Input consumed by [`crate::runtime::business::sha256_update`].
6342/// - `data`: Input consumed by [`crate::runtime::business::sha256_update`].
6343///
6344/// # Returns
6345///
6346/// Returns after [`crate::runtime::business::sha256_update`] applies its in-place effect.
6347///
6348/// # Examples
6349///
6350/// ```rust,ignore
6351/// let _result = pharos_native::runtime::business::sha256_update(todo!(), b"");
6352/// ```
6353///
6354/// # Related
6355///
6356/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6357pub fn sha256_update(context: &mut Sha256Runtime, data: &[u8]) {
6358    context.update(data);
6359}
6360
6361/// Completes a streaming SHA-256 context.
6362///
6363/// # Parameters
6364///
6365/// - `context`: Input consumed by [`crate::runtime::business::sha256_final`].
6366///
6367/// # Returns
6368///
6369/// Returns the computed value produced by [`crate::runtime::business::sha256_final`].
6370///
6371/// # Examples
6372///
6373/// ```rust,ignore
6374/// let _result = pharos_native::runtime::business::sha256_final(todo!());
6375/// ```
6376///
6377/// # Related
6378///
6379/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6380pub fn sha256_final(context: Sha256Runtime) -> [u8; 32] {
6381    context.finalize().into()
6382}
6383
6384/// Applies one bounded SHA-256 transform chunk.
6385///
6386/// # Parameters
6387///
6388/// - `context`: Input consumed by [`crate::runtime::business::sha256_transform`].
6389/// - `data`: Input consumed by [`crate::runtime::business::sha256_transform`].
6390///
6391/// # Returns
6392///
6393/// Returns after [`crate::runtime::business::sha256_transform`] applies its in-place effect.
6394///
6395/// # Examples
6396///
6397/// ```rust,ignore
6398/// let _result = pharos_native::runtime::business::sha256_transform(todo!(), b"");
6399/// ```
6400///
6401/// # Related
6402///
6403/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6404pub fn sha256_transform(context: &mut Sha256Runtime, data: &[u8]) {
6405    context.update(data);
6406}
6407
6408/// Converts bytes to lowercase hexadecimal text.
6409///
6410/// # Parameters
6411///
6412/// - `bytes`: Input consumed by [`crate::runtime::business::bytes_to_hex`].
6413///
6414/// # Returns
6415///
6416/// Returns the computed value produced by [`crate::runtime::business::bytes_to_hex`].
6417///
6418/// # Performance
6419///
6420/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::business::bytes_to_hex`].
6421///
6422/// # Examples
6423///
6424/// ```rust,ignore
6425/// let _result = pharos_native::runtime::business::bytes_to_hex(b"");
6426/// ```
6427///
6428/// # Related
6429///
6430/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6431pub fn bytes_to_hex(bytes: &[u8]) -> String {
6432    pharos_runtime_core::support::hex_digest(bytes)
6433}
6434
6435/// Resolves one user-configured value from JSON configuration text.
6436///
6437/// # Parameters
6438///
6439/// - `path`: Input consumed by [`crate::runtime::business::conf_lookup_value`].
6440/// - `key`: Input consumed by [`crate::runtime::business::conf_lookup_value`].
6441///
6442/// # Returns
6443///
6444/// Returns [`Some`] when [`crate::runtime::business::conf_lookup_value`] can produce a value and [`None`] otherwise.
6445///
6446/// # Examples
6447///
6448/// ```rust,ignore
6449/// let _result = pharos_native::runtime::business::conf_lookup_value(std::path::Path::new("fixture.json"), "key");
6450/// ```
6451///
6452/// # Related
6453///
6454/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6455pub fn conf_lookup_value(path: &Path, key: &str) -> Option<String> {
6456    super::json_commands::conf_lookup_value(path, key)
6457}
6458
6459/// Validates a generated-surface UI data key against the declarative contract.
6460///
6461/// # Parameters
6462///
6463/// - `key`: Input consumed by [`crate::runtime::business::dynamic_business_ui_data_key_allowed`].
6464///
6465/// # Returns
6466///
6467/// Returns `true` when the condition checked by [`crate::runtime::business::dynamic_business_ui_data_key_allowed`] holds and `false` otherwise.
6468///
6469/// # Performance
6470///
6471/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::business::dynamic_business_ui_data_key_allowed`].
6472///
6473/// # Examples
6474///
6475/// ```rust,ignore
6476/// let _result = pharos_native::runtime::business::dynamic_business_ui_data_key_allowed("key");
6477/// ```
6478///
6479/// # Related
6480///
6481/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6482pub fn dynamic_business_ui_data_key_allowed(key: &str) -> bool {
6483    !key.is_empty()
6484        && key.len() <= 128
6485        && key
6486            .bytes()
6487            .all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'_' | b'-'))
6488}
6489
6490/// Checks for an active tenant membership row.
6491///
6492/// # Parameters
6493///
6494/// - `root`: Input consumed by [`crate::runtime::business::dynamic_user_has_active_tenant_membership`].
6495/// - `user_id`: Input consumed by [`crate::runtime::business::dynamic_user_has_active_tenant_membership`].
6496/// - `tenant_id`: Input consumed by [`crate::runtime::business::dynamic_user_has_active_tenant_membership`].
6497///
6498/// # Returns
6499///
6500/// Returns `true` when the condition checked by [`crate::runtime::business::dynamic_user_has_active_tenant_membership`] holds and `false` otherwise.
6501///
6502/// # Performance
6503///
6504/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::business::dynamic_user_has_active_tenant_membership`].
6505///
6506/// # Examples
6507///
6508/// ```rust,ignore
6509/// let _result = pharos_native::runtime::business::dynamic_user_has_active_tenant_membership(std::path::Path::new("."), 1, todo!());
6510/// ```
6511///
6512/// # Related
6513///
6514/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6515pub fn dynamic_user_has_active_tenant_membership(
6516    root: &Value,
6517    user_id: i64,
6518    tenant_id: i64,
6519) -> bool {
6520    if user_id <= 0 || tenant_id <= 0 {
6521        return false;
6522    }
6523    root.get("tenant_memberships")
6524        .and_then(Value::as_array)
6525        .is_some_and(|rows| {
6526            rows.iter().any(|row| {
6527                json_long(row, "user_id", 0) == user_id
6528                    && json_long(row, "tenant_id", 0) == tenant_id
6529                    && row
6530                        .get("membership_status")
6531                        .and_then(Value::as_str)
6532                        .is_none_or(|status| status.is_empty() || status == "active")
6533            })
6534        })
6535}
6536
6537/// Converts a JSON integer value and reports whether conversion succeeded.
6538///
6539/// # Parameters
6540///
6541/// - `value`: Input consumed by [`crate::runtime::business::long_from_value_business_logic_local`].
6542/// - `output`: Input consumed by [`crate::runtime::business::long_from_value_business_logic_local`].
6543///
6544/// # Returns
6545///
6546/// Returns `true` when the condition checked by [`crate::runtime::business::long_from_value_business_logic_local`] holds and `false` otherwise.
6547///
6548/// # Examples
6549///
6550/// ```rust,ignore
6551/// let _result = pharos_native::runtime::business::long_from_value_business_logic_local("value", todo!());
6552/// ```
6553///
6554/// # Related
6555///
6556/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6557pub fn long_from_value_business_logic_local(value: &Value, output: &mut i64) -> bool {
6558    let Some(number) = value.as_i64() else {
6559        return false;
6560    };
6561    *output = number;
6562    true
6563}
6564
6565/// Compares a JSON integer value with an expected value.
6566///
6567/// # Parameters
6568///
6569/// - `value`: Input consumed by [`crate::runtime::business::value_long_equals_business_logic_local`].
6570/// - `expected_value`: Input consumed by [`crate::runtime::business::value_long_equals_business_logic_local`].
6571///
6572/// # Returns
6573///
6574/// Returns `true` when the condition checked by [`crate::runtime::business::value_long_equals_business_logic_local`] holds and `false` otherwise.
6575///
6576/// # Examples
6577///
6578/// ```rust,ignore
6579/// let _result = pharos_native::runtime::business::value_long_equals_business_logic_local("value", todo!());
6580/// ```
6581///
6582/// # Related
6583///
6584/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6585pub fn value_long_equals_business_logic_local(value: &Value, expected_value: i64) -> bool {
6586    value.as_i64() == Some(expected_value)
6587}
6588
6589/// Parses an HH:MM clock value into minutes since midnight.
6590///
6591/// # Parameters
6592///
6593/// - `value`: Input consumed by [`crate::runtime::business::time_text_to_minutes_business_logic_local`].
6594/// - `minutes_out`: Input consumed by [`crate::runtime::business::time_text_to_minutes_business_logic_local`].
6595///
6596/// # Returns
6597///
6598/// Returns `true` when the condition checked by [`crate::runtime::business::time_text_to_minutes_business_logic_local`] holds and `false` otherwise.
6599///
6600/// # Performance
6601///
6602/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::business::time_text_to_minutes_business_logic_local`].
6603///
6604/// # Examples
6605///
6606/// ```rust,ignore
6607/// let _result = pharos_native::runtime::business::time_text_to_minutes_business_logic_local("value", todo!());
6608/// ```
6609///
6610/// # Related
6611///
6612/// - [`crate::runtime::business`] for adjacent helpers that share the same runtime surface.
6613pub fn time_text_to_minutes_business_logic_local(value: &str, minutes_out: &mut i32) -> bool {
6614    let mut parts = value.split(':');
6615    let hour = parts.next().and_then(|part| part.parse::<i32>().ok());
6616    let minute = parts.next().and_then(|part| part.parse::<i32>().ok());
6617    if parts.next().is_some()
6618        || hour.is_none_or(|hour| !(0..=23).contains(&hour))
6619        || minute.is_none_or(|minute| !(0..=59).contains(&minute))
6620    {
6621        return false;
6622    }
6623    *minutes_out = hour.unwrap_or_default() * 60 + minute.unwrap_or_default();
6624    true
6625}
6626
6627#[cfg(test)]
6628mod tests {
6629    use super::*;
6630    use serde_json::json;
6631
6632    #[test]
6633    fn assign_technician_skips_booked_technician_and_rejects_full_slots() {
6634        let mut root = json!({
6635            "technicians": [
6636                {
6637                    "id": 100,
6638                    "business_id": 5,
6639                    "name": "Mika"
6640                },
6641                {
6642                    "id": 101,
6643                    "business_id": 5,
6644                    "name": "Jun"
6645                },
6646                {
6647                    "id": 102,
6648                    "business_id": 5,
6649                    "name": "Priya"
6650                }
6651            ],
6652            "businesses": [
6653                {
6654                    "id": 5,
6655                    "slug": "lotus-studio",
6656                    "name": "Lotus Thai Massage"
6657                }
6658            ],
6659            "services": [
6660                {
6661                    "id": 10,
6662                    "business_id": 5,
6663                    "cost": "40",
6664                    "duration_minutes": 60,
6665                    "technician_ids": [100, 101],
6666                    "booking_options": [
6667                        {
6668                            "label": "Extended",
6669                            "duration_minutes": 90,
6670                            "cost": "115.00"
6671                        }
6672                    ]
6673                }
6674            ],
6675            "business_availability": [
6676                {
6677                    "business_id": 5,
6678                    "day_of_week": "Wed",
6679                    "start_time": "08:00",
6680                    "end_time": "16:00"
6681                }
6682            ],
6683            "technician_availability": [
6684                {
6685                    "technician_id": 100,
6686                    "day_of_week": "Wed",
6687                    "start_time": "08:00",
6688                    "end_time": "16:00"
6689                },
6690                {
6691                    "technician_id": 101,
6692                    "day_of_week": "Wed",
6693                    "start_time": "08:00",
6694                    "end_time": "16:00"
6695                }
6696            ],
6697            "appointments": [
6698                {
6699                    "id": 1,
6700                    "business_id": 5,
6701                    "service_id": 10,
6702                    "technician_id": 100,
6703                    "date": "2026-09-30",
6704                    "time": "08:00",
6705                    "status": "confirmed"
6706                }
6707            ]
6708        });
6709
6710        assert!(dynamic_business_open_for_slot(
6711            &json!({
6712                "business_availability": [
6713                    {
6714                        "business_id": 5,
6715                        "day_of_week": "Wed",
6716                        "start_time": "08:00",
6717                        "end_time": "16:00"
6718                    }
6719                ]
6720            }),
6721            5,
6722            "2026-09-30",
6723            "08:00",
6724            60,
6725        ));
6726        assert_eq!(
6727            dynamic_assign_technician_for_slot(&root, 5, 10, "2026-09-30", "08:00"),
6728            101
6729        );
6730        assert!(dynamic_technician_available_for_slot(
6731            &root,
6732            5,
6733            10,
6734            100,
6735            "2026-09-30",
6736            "08:00",
6737            1,
6738        ));
6739
6740        root["appointments"]
6741            .as_array_mut()
6742            .expect("appointment rows")
6743            .push(json!({
6744                "id": 2,
6745                "business_id": 5,
6746                "service_id": 10,
6747                "technician_id": 101,
6748                "date": "2026-09-30",
6749                "time": "08:00",
6750                "status": "confirmed"
6751            }));
6752
6753        assert_eq!(
6754            dynamic_assign_technician_for_slot(&root, 5, 10, "2026-09-30", "08:00"),
6755            0
6756        );
6757        assert!(!dynamic_technician_available_for_slot(
6758            &root,
6759            5,
6760            10,
6761            101,
6762            "2026-09-30",
6763            "08:00",
6764            1,
6765        ));
6766        assert!(dynamic_technician_unbooked_for_slot(
6767            &root,
6768            5,
6769            102,
6770            "2026-09-30",
6771            "08:00",
6772            60,
6773            1,
6774        ));
6775
6776        let mut assign_form = serde_json::Map::from_iter([
6777            ("appointment_id".to_owned(), Value::from(1)),
6778            ("technician_id".to_owned(), Value::from(102)),
6779        ]);
6780        handle_assign_appointment_technician_booking_local(&mut root, &assign_form)
6781            .expect("same-business unbooked technician is assignable");
6782        assert_eq!(row_i64(&root["appointments"][0], "technician_id"), 102);
6783
6784        assign_form.insert("technician_id".to_owned(), Value::from(101));
6785        assert_eq!(
6786            handle_assign_appointment_technician_booking_local(&mut root, &assign_form),
6787            Err(409)
6788        );
6789
6790        let create_form = serde_json::Map::from_iter([
6791            ("business_id".to_owned(), Value::from(5)),
6792            ("service_id".to_owned(), Value::from(10)),
6793            ("booking_option_index".to_owned(), Value::from(0)),
6794            ("user_id".to_owned(), Value::from(42)),
6795            ("technician_id".to_owned(), Value::from(101)),
6796            ("date".to_owned(), Value::from("2026-09-30")),
6797            ("time".to_owned(), Value::from("10:00")),
6798            ("notes".to_owned(), Value::from("Internal booking")),
6799        ]);
6800        handle_create_appointment_booking_local(&mut root, &create_form)
6801            .expect("internal appointment is created");
6802        let created = root["appointments"].as_array().unwrap().last().unwrap();
6803        assert_eq!(row_i64(created, "technician_id"), 101);
6804        assert_eq!(row_i64(created, "service_duration_minutes"), 90);
6805        assert_eq!(value_text(created.get("service_cost")), "115.00");
6806        assert_eq!(value_text(created.get("payment_mode")), "internal");
6807    }
6808
6809    #[test]
6810    fn update_business_preserves_hidden_public_state_and_saves_declared_fields() {
6811        let mut root = json!({
6812            "businesses": [
6813                {
6814                    "id": 5,
6815                    "name": "Lotus Thai Massage",
6816                    "slug": "lotus-studio",
6817                    "description": "Old description",
6818                    "address": "Old address",
6819                    "is_public": true,
6820                    "time_format": "am_pm",
6821                    "secondary_color": "#2563eb",
6822                    "image_url": "/media/businesses/old.png"
6823                }
6824            ]
6825        });
6826        let form = serde_json::Map::from_iter([
6827            ("business_id".to_owned(), Value::from(5)),
6828            ("name".to_owned(), Value::from("Lotus Thai Massage Updated")),
6829            ("description".to_owned(), Value::from("New description")),
6830            ("address".to_owned(), Value::from("New address")),
6831            ("time_format".to_owned(), Value::from("24_hour")),
6832            (
6833                "business_edit_secondary_color_hex".to_owned(),
6834                Value::from("#22c55e"),
6835            ),
6836        ]);
6837
6838        handle_update_business_identity_local(&mut root, &form).expect("business update");
6839
6840        let business = root["businesses"][0].as_object().expect("business object");
6841        assert_eq!(
6842            business.get("name").and_then(Value::as_str),
6843            Some("Lotus Thai Massage Updated")
6844        );
6845        assert_eq!(
6846            business.get("description").and_then(Value::as_str),
6847            Some("New description")
6848        );
6849        assert_eq!(
6850            business.get("address").and_then(Value::as_str),
6851            Some("New address")
6852        );
6853        assert_eq!(
6854            business.get("is_public").and_then(Value::as_bool),
6855            Some(true)
6856        );
6857        assert_eq!(
6858            business.get("time_format").and_then(Value::as_str),
6859            Some("24_hour")
6860        );
6861        assert_eq!(
6862            business.get("secondary_color").and_then(Value::as_str),
6863            Some("#22c55e")
6864        );
6865        assert_eq!(
6866            business.get("image_url").and_then(Value::as_str),
6867            Some("/media/businesses/old.png")
6868        );
6869    }
6870
6871    #[test]
6872    fn update_business_remove_logo_clears_image_url() {
6873        let mut root = json!({
6874            "businesses": [
6875                {
6876                    "id": 5,
6877                    "name": "Lotus Thai Massage",
6878                    "slug": "lotus-studio",
6879                    "description": "",
6880                    "address": "",
6881                    "is_public": true,
6882                    "time_format": "am_pm",
6883                    "secondary_color": "#2563eb",
6884                    "image_url": "/media/businesses/old.png"
6885                }
6886            ]
6887        });
6888        let form = serde_json::Map::from_iter([
6889            ("business_id".to_owned(), Value::from(5)),
6890            ("name".to_owned(), Value::from("Lotus Thai Massage")),
6891            ("remove_logo".to_owned(), Value::from("1")),
6892        ]);
6893
6894        handle_update_business_identity_local(&mut root, &form).expect("business update");
6895
6896        assert_eq!(
6897            root["businesses"][0]
6898                .get("image_url")
6899                .and_then(Value::as_str),
6900            Some("")
6901        );
6902    }
6903}