The Dynamic Fields Framework is meant designed to be used utilized in conjunction with the Dynamic Results Stage. This framework is meant for UI only hence it requires primarily intended for use in the user interface (UI) layer of the application. Therefore, it assumes that the UI project knows how to interpret properly is well-equipped to correctly interpret the Dynamic Fields that are sent as part of the response.
Each Dynamic Field type is associated with two Pydantic BaseModel classes:
_{type}FieldUI model: This model inherits from the BaseModel in the _DynamicFieldUI class and also from the _DynamicFieldUI on the typed subclasses. This model is primarily concerned with defining the attributes and characteristics of the Dynamic Field that are relevant to the UI. It essentially determines how the field will be presented in the UI and what information will be displayed to the user.
{type}Field model: This model inherits from its corresponding _{type}FieldUI model and also from the DynamicField model on the typed subclasses. It serves as an extension of the UI model, incorporating additional attributes and functionalities that are essential for data transformations in the backend. These transformations are carried out to modify the data before it is included in the response to be sent to the user. Essentially, this model defines how the data associated with the Dynamic Field is processed and transformed before being presented in the UI.
The separation of these two models, one for UI presentation and the other for backend data transformations, helps maintain clarity and modularity in the implementation of the Dynamic Fields Framework. It ensures that the concerns of the UI and data transformation are handled independently, allowing for flexibility and ease of maintenance in both areas.
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 |
False | Sort order for values in an array. | |
unique | bool | False |
False | If the values are in an array, remove duplicates. | |
show_blank | bool | False |
False | 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.
Finally, the objects replace the declaration of the Dynamic Fields in the configuration and this new configuration is the one used by the Dynamic Results Stage to provide the typed hits in the response.