fiftyone_javascript_builder/constants.rs
1/* *********************************************************************
2 * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3 * Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House,
4 * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5 *
6 * This Original Work is licensed under the European Union Public Licence
7 * (EUPL) v.1.2 and is subject to its terms as set out below.
8 *
9 * If a copy of the EUPL was not distributed with this file, You can obtain
10 * one at https://opensource.org/licenses/EUPL-1.2.
11 *
12 * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
13 * amended by the European Commission) shall be deemed incompatible for
14 * the purposes of the Work and the provisions of the compatibility
15 * clause in Article 5 of the EUPL shall not apply.
16 *
17 * If using the Work as, or as part of, a network application, by
18 * including the attribution notice(s) required under Article 5 of the EUPL
19 * in the end user terms of the application under an appropriate heading,
20 * such notice(s) shall fulfill the requirements of that article.
21 * ********************************************************************* */
22
23//! String and boolean constants shared across the JavaScript builder.
24//!
25//! These define the generated JavaScript, the evidence keys it reads and the
26//! defaults it applies.
27
28/// The element data key under which the JavaScript builder stores its element
29/// data.
30///
31/// This is the element's own key, returned from
32/// [`fiftyone_pipeline_core::FlowElement::data_key`]. The generated JavaScript
33/// string itself is held under the [`JAVASCRIPT_PROPERTY_KEY`] property of that
34/// data.
35pub const JAVASCRIPT_BUILDER_ELEMENT_DATA_KEY: &str = "javascriptbuilderelement";
36
37/// The name of the single property the JavaScript builder populates: the
38/// generated JavaScript, as a string.
39///
40/// The property name is `"javascript"`, which the
41/// [`crate::JavaScriptBuilderElementData`] exposes. Read it
42/// from the element data with [`crate::JavaScriptBuilderElementData::javascript`]
43/// or by string key through [`fiftyone_pipeline_core::ElementData::get`].
44pub const JAVASCRIPT_PROPERTY_KEY: &str = "javascript";
45
46/// The complete key to use when the `Host` HTTP header is passed as evidence
47/// (`header.host`).
48pub const EVIDENCE_HOST_KEY: &str = "header.host";
49
50/// The suffix used when the JavaScript builder 'object name' parameter is
51/// supplied as evidence.
52pub const EVIDENCE_OBJECT_NAME_SUFFIX: &str = "fod-js-object-name";
53
54/// The suffix used when the JavaScript builder 'enable cookies' parameter is
55/// supplied as evidence.
56pub const EVIDENCE_ENABLE_COOKIES_SUFFIX: &str = "fod-js-enable-cookies";
57
58/// The complete `query.fod-js-object-name` evidence key.
59pub const EVIDENCE_OBJECT_NAME: &str = "query.fod-js-object-name";
60
61/// The complete `query.fod-js-enable-cookies` evidence key.
62pub const EVIDENCE_ENABLE_COOKIES: &str = "query.fod-js-enable-cookies";
63
64/// The protocol used when creating a callback URL if no other protocol value
65/// was found or specified.
66pub const FALLBACK_PROTOCOL: &str = "https";
67
68/// The default value for the JavaScript 'object name'.
69pub const BUILDER_DEFAULT_OBJECT_NAME: &str = "fod";
70
71/// The default protocol for the builder. An empty string means the protocol from
72/// the evidence collection (the protocol the original request used) is applied.
73pub const BUILDER_DEFAULT_PROTOCOL: &str = "";
74
75/// The default host for the builder. An empty string means the host from the
76/// evidence collection (the host the original request used) is applied.
77pub const BUILDER_DEFAULT_HOST: &str = "";
78
79/// The default value of the flag that controls minification.
80pub const BUILDER_DEFAULT_MINIFY: bool = true;
81
82/// The default value of the flag that controls whether client-side processing
83/// stores results in cookies.
84pub const BUILDER_DEFAULT_ENABLE_COOKIES: bool = true;
85
86/// The placeholder JSON used when no JSON payload is available, applied as a
87/// fallback when the JSON is missing.
88pub const MISSING_JSON_OBJECT: &str = "{\"errors\":[\"Json data missing.\"]}";
89
90/// The marker substring that, when present in the JSON payload, indicates the
91/// payload contains at least one delayed-execution JavaScript property. The
92/// payload is checked for the substring `delayexecution`.
93pub const DELAY_EXECUTION_MARKER: &str = "delayexecution";
94
95/// The device-detection property consulted to decide whether the client browser
96/// supports JavaScript promises. The builder treats a value of
97/// [`PROMISE_FULL_VALUE`] as full support.
98pub const PROMISE_PROPERTY: &str = "Promise";
99
100/// The device-detection property value that indicates full promise support.
101pub const PROMISE_FULL_VALUE: &str = "Full";
102
103/// The device-detection property consulted to decide whether the client browser
104/// supports the fetch API.
105pub const FETCH_PROPERTY: &str = "Fetch";