...
Settings Loaders
This document describes the different settings loaders used to load and merge settings for the ConfluenceSettings
configuration object. Each loader is responsible for loading settings from a specific source, and they can be combined to create a merged configuration.
DefaultSettingsLoader
Purpose: Load default settings from the DEFAULT_SETTINGS
object.
Settings source: DEFAULT_SETTINGS
object.
Example:
Code Block | ||
---|---|---|
| ||
const defaultLoader = new DefaultSettingsLoader();
const defaultSettings = defaultLoader.loadPartial(); |
StaticSettingsLoader
Purpose: Load settings provided as a static object.
Settings source: User-provided object.
Example:
Code Block | ||
---|---|---|
| ||
const staticSettings = {
confluenceBaseUrl: "https://example.com",
confluenceParentId: "12345",
};
const staticLoader = new StaticSettingsLoader(staticSettings);
const loadedSettings = staticLoader.loadPartial(); |
EnvironmentVariableSettingsLoader
Purpose: Load settings from environment variables.
Settings source: Environment variables.
Example:
Set the environment variables:
Code Block | ||
---|---|---|
| ||
export CONFLUENCE_BASE_URL=https://example.com
export CONFLUENCE_PARENT_ID=12345 |
Load settings from environment variables:
Code Block | ||
---|---|---|
| ||
const envLoader = new EnvironmentVariableSettingsLoader();
const envSettings = envLoader.loadPartial(); |
ConfigFileSettingsLoader
Purpose: Load settings from a JSON configuration file.
Settings source: User-specified JSON configuration file.
Example:
Create a JSON configuration file (.mermaid-confluence.json
):
Code Block | ||
---|---|---|
| ||
{
"confluenceBaseUrl": "https://example.com",
"confluenceParentId": "12345"
} |
Load settings from the configuration file:
Code Block | ||
---|---|---|
| ||
const configFileLoader = new ConfigFileSettingsLoader();
const configFileSettings = configFileLoader.loadPartial(); |
CommandLineArgumentSettingsLoader
Purpose: Load settings from command line arguments.
Settings source: Command line arguments.
Example:
Pass settings as command line arguments:
Code Block | ||
---|---|---|
| ||
node index.js --baseUrl https://example.com --parentId 12345 |
Load settings from command line arguments:
Code Block | ||
---|---|---|
| ||
const cmdLoader = new CommandLineArgumentSettingsLoader();
const cmdSettings = cmdLoader.loadPartial(); |
AutoSettingsLoader
Purpose: Automatically load and merge settings from multiple loaders.
Settings source: Multiple settings loaders.
Example:
Create an AutoSettingsLoader
with custom loaders:
Code Block | ||
---|---|---|
| ||
const loaders = [
new ConfigFileSettingsLoader(),
new EnvironmentVariableSettingsLoader(),
new CommandLineArgumentSettingsLoader(),
new DefaultSettingsLoader()
];
const autoLoader = new AutoSettingsLoader(loaders);
const autoSettings = autoLoader.load();
``` |