YAML Schema to Flatfile Blueprint Converter
Automates the creation of a Flatfile Blueprint (Workbook and Sheets) from one or more YAML schema definitions, streamlining the setup of a Flatfile Space by converting existing data models into a Flatfile-compatible format.
Installation
Install the plugin using npm:
Configuration & Parameters
ModelToSheetConfig
Configuration object for each Sheet to be created from a YAML schema:
Parameter | Type | Required | Description |
---|---|---|---|
sourceUrl | string | Yes | The URL where the YAML schema file is hosted |
name | string | No | A custom name for the generated Sheet. If not provided, the title from the YAML schema is used |
Additional properties | - | No | Other Flatfile.SheetConfig properties (e.g., actions ) can be included to customize the Sheet |
Options
Optional configuration object for the Workbook and plugin behavior:
Parameter | Type | Default | Description |
---|---|---|---|
workbookConfig | PartialWorkbookConfig | - | Configuration for the generated Workbook (name, actions, etc.) |
debug | boolean | false | When set to true , prints the generated Blueprint configuration object to the console |
PartialWorkbookConfig
Configuration for the parent Workbook:
Parameter | Type | Description |
---|---|---|
name | string | Custom name for the Workbook. Defaults to “YAML Schema Workbook” if not provided |
actions | array | Custom actions for the Workbook |
Additional properties | - | Other properties from Flatfile.CreateWorkbookConfig |
Callback Function
Optional function executed after Space and Workbook configuration:
Usage Examples
Basic Usage
Advanced Configuration
Using Callback Function
Troubleshooting
Debug Mode
The most effective troubleshooting tool is the debug: true
option. When enabled, the complete generated Blueprint object is printed to the console where the listener is running. This allows you to inspect the exact Workbook, Sheet, and Field configuration that the plugin produced.
Common Error Scenarios
Network/URL Issues: If the plugin fails to fetch a schema from a sourceUrl
(e.g., due to a network error, 404 Not Found, or invalid URL), it will throw an error with a message like:
Error: Error fetching external reference: API returned status 404: Not Found
YAML Parsing Errors: Errors during YAML parsing will bubble up and cause the configuration to fail. Ensure your YAML schema files are valid and properly formatted.
Notes
Requirements and Limitations
- This plugin must be used in a server-side listener environment
- It is designed to run on the
space:configure
event - The YAML schema must be publicly accessible via the provided
sourceUrl
- The plugin internally converts YAML to JSON and uses
@flatfile/plugin-convert-json-schema
, so supported YAML schema features are limited to what the underlying JSON Schema converter supports
Default Behavior
- If no
name
is provided for a Sheet, thetitle
from the YAML schema is used - If no
name
is provided for the Workbook, it defaults to “YAML Schema Workbook” - The
debug
option defaults tofalse
Error Handling
The plugin’s external fetching logic includes error handling for network failures and HTTP errors. When errors occur, they are caught by the Flatfile listener runner and reported in the corresponding Job’s execution history.