Skip to content

Instantly share code, notes, and snippets.

@alcedoatthis2
Last active January 5, 2021 17:34
Show Gist options
  • Select an option

  • Save alcedoatthis2/137740e1dbbbb7cfab4789b1bd6e43c2 to your computer and use it in GitHub Desktop.

Select an option

Save alcedoatthis2/137740e1dbbbb7cfab4789b1bd6e43c2 to your computer and use it in GitHub Desktop.
pfx-mappers

Mappers

Components

name wrench inputmeta outputmeta locations packages note
MapperTable only converter expression accountApp/instances (new+edit - in MapperReduxTable)
IntegrationMapper oldest, free text
MapperTableWithCustomization advanced field editor with calculatedFields uploaded file (table example data) object type select -> meta accountApp/partitions/dataUpload(new+edit) PackageDataUploadFieldMappingContainer
IntegrationCsvMapper
MultilevelMapperTable Advanced field editor without calculated fields (need to sort out types on tree meta), but with Field tab OptionsResourceSelect OptionsResourceSelect - GeneralMapper new design, missing features

Object type select

  1. select entity type

  2. for some entity types, needs to select entity name - for which ones is defined on FE

  3. -> can fetch flat meta (options)

OptionsResourceSelect

Can provide metadata (I/O options) for either pricefx or non-pricefx connection

For pricefx:

  1. Select connection

  2. display object type select (entity type + for some entity types entity name)

  3. -> fetches flat options

For non-pricefx:

  1. Select connection
  2. display connection configuration select
  3. -> fetches tree options for cascader

AdvancedFieldEditor

  • modal with some tabs, opened on wrench click

CalculatedFields

  • FORMULA tab visible when number fields present
  • COMPOSED tab visible when string fields present

Field tab

  • Possibility to change input + inputType + converter combination
  • According to new story should be split into 2 tabs:
    1. converter only - input without input type (assumed to be body)
    2. expert options - textarea for input + dropdown for input type ("header", "property", "simple", "constant") + converter

State

Mapper

  • on most places mapper, sometimes called definition or initMapper when coming from api
  • array of object items, each item can have following properties:
property used by api note
id no? row identification
input yes name of input option or json path (e.g. productId or products[].id)
inputType yes e.g. body (value from input data), groovy, constant, header, ...
value NO used for calculated fields, only FE representation, which needs to be converted to e.g. groovy
valueType NO used for calculated fields, only FE representation, can be e.g. FORMULA, COMPOSED, used only in MapperTableWithCustomization
output yes same as input, but for output options
converterExpression yes can be added by the user or automatically by FE - e.g. when output type is number - uploaded file cell needs to be converted
outputType NO used for validation and in UI to inform user when available
  • Mapper update logic extracted to useMapperChangeHandlers(currentMapper: Mapper, setMapper: Function): MapperChangeHandlers hook, MapperChangeHandlers passed to mapper table
  • => decoupled from initialization

Initialization

  • is done async - input meta / output meta needs to be fetched for init, params to get I/O meta can be changed - mapper is Loadable
  • needs to cover two use cases - new mapper and edit mapper
    • new mapper is created from I/O meta (options)
    • edit mapper takes initMapper and adds output types from output meta (options) and ids

Testing

Current state

  • unit tested pure data transformations
  • stories with mocked services + cypress to cover behavior (with limitations)

Challenges

  1. Hard to setup data on qa, which would enable us to test all customizations/variants/edge cases, as the data are coming from multiple sources (including external systems), (mocking)
  2. Components from UC not prepared for implementation-details-independent testing (testIds, dropdowns targetting - rendered thru portals in body, ...)
  3. Evolving features group with wide range of use cases - need to support original free text mapper input in MapperTable as well as tree meta in MultilevelMapperTable (keeping free text impacts refactoring of state management a lot)
  4. FE transforms mapper before sending to API - UI uses data representations, which are lost when mapper is submitted (inconsistent for the user)

Issues

  • documented only in code

  • hard to setup proper testing data on qa in packages for all use cases (stronger mocking would help) Challenges 1.

  • testable components wanted, currently created only in PM - should be migrated to UC Challenges 2.

  • table layout instead of form layout makes it impossible to use current UC Forms Challenges 2.

  • state management - mapper contains value,valueType which needs to be converted by FE but is never got from BE (cannot be inverted, user enters e.g. formula, then on mapper edit sees groovy generated by FE) Challenges 4.

  • missing design for Field tab -> 2. expert options

  • Multilevel mapper still missing features (waiting for API) - Test row, test connection, test+real URI (which can require future refactoring of transformations done by FE), also need to test submission and maybe refactor mapping fn logic

*[MapperChangeHandlers]: e.g. handleInputChange, handleInputTypeChange, addMapperItem, onCustomizeField

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment