Skip to main content

Mapping Backend Schema to Frontend Data Model

Conscia's Schema Mapping Components allow you to restructure and/or merge the data from your backend sources into a data model that your applications can more easily consume. It involves identifying the data elements in the source systems and specifying how they should be transformed and mapped to the corresponding data elements in the target system(s).

Here is an example of what the Schema Mapping Components can be used for:

alt_text

Conscia provides the following Schema Mapping Components which allow you to specify the target structure and how the target structure's elements are populated by the various sources:

Component TypeDescription
Object MapperThe Object Mapper works with the current response object and allows you to remap the fields within the response. The configuration allows you to define a target structure in its entirety (using JSON or the drag and drop interface) and specify source expressions as values for each JSON property. The source expressions are either query or script notations that operate on source data that is provided as part of the component configuration.
Property MapperThe Property Mapper allows you to specify target properties using a string notation and source expressions that will populate the target properties using one of a few notations.
info

Schema Mapper Components may be chained together (like any other Component) for complicated transformations.

Object Mapper Component

Component Configuration

The Object Mapper Component can be configured via the Developer UI within DX Studio or via APIs like any other component.

Here is what the UI looks like:

alt_text

The Object Mapper enables you to individually define the mapping logic for each object within your target schema, using various expressions such as JSONPath, JMESPath, JavaScript, or JSONata. It provides you with the freedom and flexibility to map each object to different upstream data sources according to your unique business requirements.

Whether you're overwriting existing properties with new data, or adding entirely new properties, the Object Mapper streamlines the process, ensuring your final target schema is a customized representation of your target data model.

Here is how the Object Mapper is evaluated by the DX Engine:

  1. Initialization: The process commences with the construction of the initial JSON schema object. This beginning framework ultimately shapes up into the target schema.

  2. Sequential Evaluation: Each subsequent schema object in the sequence is evaluated, with the sequence order bearing significance as each new schema may adjust preceding entries.

  3. Configuring Mapping Logic: Here's where the power of customization comes into play. For each object in the target schema, you can individually define its mapping logic. Whether it's JSONPath, JMESPath, JavaScript, or JSONata, the choice is yours. This allows you to map each object to different upstream data sources based on your requirements.

  4. Overwriting Existing Properties: If the newly evaluated schema object contains properties that already exist in the evolving target schema, those existing properties are replaced with new values. This ensures that the most recent information takes priority.

  5. Adding New Properties: When the evaluated schema object introduces properties not yet included in the target schema, these new properties are seamlessly added.

  6. Progressive Refinement: The process of evaluating, customizing mapping logic, overwriting, and adding is iteratively applied to each schema object. This gradually refines the target schema, giving it shape and depth according to your specifications.

  7. Completion: After all schema objects in the sequence have been evaluated, merged, and customized, the result is the definitive target schema. This is a tailored integration of all individual schema objects, shaped according to your data model needs.

This process underscores the flexibility and control you have over your data structure using the target schema. By determining the mapping logic for each object, you ensure that your final schema fits your specific needs, regardless of the complexity or diversity of your upstream data sources.

Here are the configuration parameters required for this Component:

Parameter NameParameter PropertyDescription
Default SourcedefaultSourceData value to be used in the mapper expressions if not overridden within the mapper definition.
Default Expression TypedefaultExpressionTypeOne of: jmespath, jsonpath, jsonata, javascript
Object MapsobjectMapsArray objects that descrbe how to map sources to an JSON object. objectMaps: [{ source, expressionType, object }]
Object Maps / Source DatasourceThe data value to be used for the expressions in this set of property mappings.
Object Maps / Expression TypeexpressionTypeOne of: jmespath, jsonpath, jsonata, javascript
Object Maps / ObjectmappingsJSON Object to be mapped. Each property value is an expression

Source Expressions

JMESPath

JMESPath is an extremely flexible query language for JSON and its usage is described in detail on their website.

JSONPath

The JSONPath is another query language for JSON and is described here and here.

JSONata

JSONata allows for anything from simple JSON querying to more complicated scripting logic and is described here.

Conscia Javascript Expressions

A Javascript Expression allows for one JS expression that has access to the following variables and functions:

Variable/FunctionDescription
_Lodash utility
encodeURINative Javascript function
encodeURIComponentNative Javascript function
JSONNative Javascript Object
ArrayNative Javascript Object
PromiseNative Javascript Object
ObjectNative Javascript Object
DateTimeDate and Time manipulation utility from the luxon library
contextField(contextField)This function returns the value of the specified Context Field. By using this function anywhere in a Component's configuration, the Component will not execute until after any other Components (that populate the specified Context Field) have run.
componentResponse(componentCode)This function returns the response from the specified Component. By using this function anywhere in a Component's configuration, the Component will not execute until after the specified Component has completed.
componentStatus(componentCode)This function returns the status of the specified Component. By using this function anywhere in a Component's configuration, the Component will not execute until after the specified Component has completed.

Property Mapper Component

Property Mapper is another type of Schema Mapper offered by the DX Engine. This powerful tool allows you to hone in on specific properties within your target schema, enabling precise control over your data structure. With the Property Mapper, you can define 'target properties' through a straightforward string notation that pinpoints the exact path to any specific property within your target schema. What's more, you can populate these target properties using 'source expressions' from various expressions types. It's this granularity and flexibility that allows you to tailor your data model to your precise needs.

Component Configuration

Parameter NameParameter PropertyDescription
Default SourcedefaultSourceData value to be used in the mapper expressions if not overridden within the mapper definition.
Default Expression TypedefaultExpressionTypeOne of: jmespath, jsonpath, jsonata, javascript
Property MapspropertyMapsArray objects that descrbe how to map source to target properties. propertyMaps: [{ source, expressionType, mappings }]
Property Maps / Source DatasourceThe data value to be used for the expressions in this set of property mappings.
Property Maps / Expression TypeexpressionTypeOne of: jmespath, jsonpath, jsonata, javascript
Property Maps / MappingsmappingsArray of objects that map a target property to an expression to be evaluated. mappings: [{ targetProperty, sourceExpression }]
Property Maps / Mappings / Target PropertytargetPropertyThe path in the final object that should contain the evaluated source expression.
Property Maps / Mappings / Source ExpressionsourceExpressionExpression to be evaluated and mapped to the specified target property.
Important Note

The sequence of the mapping is non-deterministic. Therefore, it is important that the specied targetProperties are not overlapping in any way.

To see an example of how to use the Object Mapper, see the tutorial, How to Unify Product and CMS Records.