Installation
Install the plugin using npm:Configuration & Parameters
The plugin accepts an optional configuration object with the following parameter:keepRequiredFields
- Type:
boolean
- Default:
false
- Description: Controls whether fields marked as “required” in the sheet’s configuration are kept visible after mapping, even if the user did not map any source data to them.
Default Behavior
By default, the plugin will hide all unmapped fields, including those that are required. Only fields that the user explicitly mapped will remain visible in the data review step.Usage Examples
Troubleshooting
Error Handling
The plugin includes built-in error handling. If an issue occurs while updating the sheet view, the job will fail and log the error to the console:Notes
Requirements
trackChanges
Required: The workbook being processed must have thetrackChanges
setting enabled. The plugin checks for this setting and will abort its operation if it is not enabled. This prevents race conditions between different data processing hooks and the workbook update.
Behavior Details
-
Foreground Job: The plugin creates a
foreground
job to update the sheet view. This means the user interface will be blocked with a progress indicator while columns are being hidden, preventing user interaction with a stale view of the data. - Commit Synchronization: The plugin includes logic to wait for all pending sheet commits to complete before attempting to update the workbook’s field configuration. This prevents race conditions and ensures data integrity.
API Reference
viewMappedPlugin(options?: ViewMappedOptions)
Initializes the View Mapped Data plugin and returns a configured listener that should be passed to listener.use()
. The plugin listens for the completion of a workbook:map
job and then creates a new job to update the destination sheet’s configuration, hiding any unmapped columns.
Parameters:
options
(optional): Configuration object withkeepRequiredFields
boolean property
(listener: FlatfileListener) => void