The Dynamic Fields Framework is meant to be used with the Dynamic Results Stage. This framework is meant for UI only hence it requires that the UI project knows how to interpret properly the Dynamic Fields sent in the response.
Each Dynamic Field type has two Pydantic BaseModel, the _{type}FieldUI model which inherits from the BaseModel in the _DynamicFieldUI class and from the _DynamicFieldUI on the typed field sub classes, and the {type}Field which inherits from it's own _{type}FieldUI. The idea of that is to have separated models for the things that are required for UI which will affect the returned fields in the response, and the things required for data transformations in the backend which are going to modify the data before being sent in the response.
Parameter | Type | Default | Required | Description |
---|---|---|---|---|
field | str | ... | True | Path to field from which retrieve the value. Path with jmespath format (JMESPath documentation: https://github.com/jmespath/jmespath.py). |
field_highlight | Union[str, None] | None | False | Path to highlight field from which retrieve the value, in case it is not the same as the field parameter. Path with jmespath format (JMESPath documentation: https://github.com/jmespath/jmespath.py). |
default | Union[Any, None] | None | False | Default value to use in case no value was found for the field. |
transform | Optional[List[Transformation]] | None | True | List of transformations to be applied to the displayed values. The order in which the transformations are specified is the order in which the transformations will be applied. |
_label_transformed | bool | - | True | Internal parameter. |
suffix | Union[str, None] | None | False | Suffix to append to the value or values. |
prefix | Union[str, None] | None | False | Prefix to append to the value or values. |
suffix_label | Union[str, None] | None | False | Suffix to append to the label of the field. |
prefix_label | Union[str, None] | None | False | Prefix to append to the label of the field. |
sort | Union[SortOrder, bool] | False | True | Sort order for values in an array. |
unique | bool | False | True | If the values are in an array, remove duplicates. |
show_blank | bool | False | True | If there is no value, or value is none, and show_blank is true, keep the field. |
replacement | Optional[str] | - | False | Replacement to replace matches in the transformations (used in TRANSFORM_REPLACE_FIRST, TRANSFORM_REPLACE_LAST, and TRANSFORM_REPLACE_ALL). |
pattern | Optional[str] | - | False | Pattern used to look for matches in the transformations (used in TRANSFORM_REPLACE_FIRST, TRANSFORM_REPLACE_LAST, and TRANSFORM_REPLACE_ALL). |
Parameter | Type | Default | Required | Description |
---|---|---|---|---|
type | DynamicFieldType | DynamicFieldType.TEXT | True | Type of the dynamic field. |
label | Union[str, None] | None | False | Label to show for this field. |
css_style | Union[__CSSStyle, None] | None | False | Style to apply in the HTML of the UI. |
css_class | Union[str, None] | None | False | Style to apply in the HTML component. |
translate | Union[str, None] | None | False | (TODO: Implement translation) |
translate_label | Union[str, None] | None | False | Translation label. |
analytics | Union[dict, None] | None | False | Analytics information. |
if_not_exist | Optional[str] | None | False | Show only if the specified field doesn't exist. |
if_exist | Optional[str] | None | False | Show only if the specified field does exist. |
only_on_highlight | bool | False | False | Show only when the value is highlighted. |
display | Optional[Any] | - | False | Value from the field to display. |
Name | Value |
---|---|
LOWER_CASE | lowerCase |
UPPER_CASE | upperCase |
CAMEL_CASE | camelCase |
KEBAB_CASE | kebabCase |
CAPITALIZE | capitalize |
LOWER_FIRST | lowerFirst |
UPPER_FIRST | upperFirst |
SNAKE_CASE | snakeCase |
REPLACE_FIRST | replaceFirst |
REPLACE_LAST | replaceLast |
REPLACE_ALL | replaceAll |
Name | Value |
---|---|
TEXT | text |
URL | url |
DATE | date |
DATE_AGE | date_age |
NUMBER | number |
SIZE | size |
MIME_TYPE | mime_type |
IMAGE | image |
THUMBNAILS | thumbnails |
BOOL | bool |
NESTED | nested |
KEY_VALUE | key_value |
TABLE | table |
TAGS | tags |
COLUMN_ACTION | column_action |
CHIP | chip |
CARROUSEL | carrousel |
CARROUSEL_VALUE | carrousel_value |
INNER_HITS | inner_hits |
Parameter | Type | Required | Description |
---|---|---|---|
label | Dict[str, str] | True | Dictionary for labels. |
display | Dict[str, str] | True | Dictionary for display. |
container | Dict[str, str] | True | Dictionary for containers. |
The workflow is initiated when the Dynamic Results Stage is invoked. During this process, the Dynamic Results Stage proceeds to execute its configuration, going through each of the Dynamic Fields individually.
For each Dynamic Field, its implementation is determined based on the specified type. Subsequently, it generates a typed object that aligns with the configured type. This typed object serves as a representation of the data and enables further transformations.
In order to enhance the readability of the user-facing response, the Dynamic Field then calls its "transform_data" method. This method is responsible for modifying the data within the response, making it more user-friendly and easier to understand.