2020-06-17 18:12:01 -04:00
|
|
|
import { assignWithDepth } from './utils';
|
2020-06-26 09:26:56 -04:00
|
|
|
import { logger } from './logger';
|
2019-07-13 22:50:53 -07:00
|
|
|
|
2020-06-26 09:26:56 -04:00
|
|
|
/**
|
2020-07-13 16:39:52 +02:00
|
|
|
* **Configuration methods in Mermaid version 8.6.0 have been updated, to learn more[[click here](8.6.0_docs.md)].**
|
|
|
|
*
|
|
|
|
* ## **What follows are config instructions for older versions**
|
2020-06-26 09:26:56 -04:00
|
|
|
* These are the default options which can be overridden with the initialization call like so:
|
|
|
|
* **Example 1:**
|
|
|
|
* <pre>
|
|
|
|
* mermaid.initialize({
|
|
|
|
* flowchart:{
|
|
|
|
* htmlLabels: false
|
|
|
|
* }
|
|
|
|
* });
|
|
|
|
* </pre>
|
|
|
|
*
|
|
|
|
* **Example 2:**
|
|
|
|
* <pre>
|
|
|
|
* <script>
|
2020-07-02 18:25:49 +02:00
|
|
|
* var config = {
|
2020-06-26 09:26:56 -04:00
|
|
|
* startOnLoad:true,
|
|
|
|
* flowchart:{
|
|
|
|
* useMaxWidth:true,
|
|
|
|
* htmlLabels:true,
|
|
|
|
* curve:'cardinal',
|
|
|
|
* },
|
|
|
|
*
|
|
|
|
* securityLevel:'loose',
|
|
|
|
* };
|
2020-07-02 18:25:49 +02:00
|
|
|
* mermaid.initialize(config);
|
2020-06-26 09:26:56 -04:00
|
|
|
* </script>
|
|
|
|
* </pre>
|
2020-07-13 16:39:52 +02:00
|
|
|
* A summary of all options and their defaults is found [here](#mermaidapi-configuration-defaults). A description of each option follows below.
|
2020-06-26 09:26:56 -04:00
|
|
|
*
|
|
|
|
* @name Configuration
|
|
|
|
*/
|
|
|
|
const config = {
|
|
|
|
/** theme , the CSS style sheet
|
|
|
|
*
|
2020-07-02 18:25:49 +02:00
|
|
|
* theme , the CSS style sheet
|
2020-07-13 16:39:52 +02:00
|
|
|
*
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| Theme |Built in Themes| String | Optional | Values include, default, forest, dark, neutral, null|
|
2020-07-13 16:39:52 +02:00
|
|
|
*
|
2020-07-02 18:25:49 +02:00
|
|
|
***Notes:**To disable any pre-defined mermaid theme, use "null".
|
2020-06-26 09:26:56 -04:00
|
|
|
* <pre>
|
|
|
|
* "theme": "forest",
|
|
|
|
* "themeCSS": ".node rect { fill: red; }"
|
|
|
|
* </pre>
|
|
|
|
*/
|
|
|
|
theme: 'default',
|
|
|
|
themeCSS: undefined,
|
|
|
|
/* **maxTextSize** - The maximum allowed size of the users text diamgram */
|
|
|
|
maxTextSize: 50000,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*|fontFamily | specifies the font to be used in the rendered diagrams| String | Required | Verdana, Arial, Trebuchet MS,|
|
|
|
|
*
|
|
|
|
***notes: Default value is \\"trebuchet ms\\".
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
fontFamily: '"trebuchet ms", verdana, arial;',
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| logLevel |This option decides the amount of logging to be used.| String | Required | 1, 2, 3, 4, 5 |
|
|
|
|
*
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
*- debug: 1.
|
|
|
|
*- info: 2.
|
|
|
|
*- warn: 3.
|
|
|
|
*- error: 4.
|
|
|
|
*- fatal: 5(default).
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
logLevel: 5,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
2020-07-05 23:04:22 +07:00
|
|
|
*| securitylevel | Level of trust for parsed diagram|String | Required | Strict, Loose, antiscript |
|
2020-07-02 18:25:49 +02:00
|
|
|
*
|
|
|
|
***Notes:
|
|
|
|
*- **strict**: (**default**) tags in text are encoded, click functionality is disabeled
|
|
|
|
*- **loose**: tags in text are allowed, click functionality is enabled
|
2020-07-05 23:04:22 +07:00
|
|
|
*- **antiscript**: html tags in text are allowed, (only script element is removed), click functionality is enabled
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
securityLevel: 'strict',
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| startOnLoad| Dictates whether mermaind starts on Page load | Boolean | Required | True, False |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value: true**
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
startOnLoad: true,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required |Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| arrowMarkerAbsolute | Controls whether or arrow markers in html code are absolute paths or anchors | Boolean | Required | True, False |
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*## Notes**: This matters if you are using base tag settings.
|
|
|
|
***Default value: false**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
arrowMarkerAbsolute: false,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This option controls which currentConfig keys are considered _secure_ and can only be changed via
|
|
|
|
* call to mermaidAPI.initialize. Calls to mermaidAPI.reinitialize cannot make changes to
|
|
|
|
* the `secure` keys in the current currentConfig. This prevents malicious graph directives from
|
|
|
|
* overriding a site's default security.
|
|
|
|
*/
|
|
|
|
secure: ['secure', 'securityLevel', 'startOnLoad', 'maxTextSize'],
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The object containing configurations specific for flowcharts
|
|
|
|
*/
|
|
|
|
flowchart: {
|
2020-07-11 16:54:00 +10:00
|
|
|
/**
|
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| diagramPadding | amount of padding around the diagram as a whole | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**The amount of padding around the diagram as a whole so that embedded diagrams have margins, expressed in pixels
|
|
|
|
***Default value: 8**.
|
|
|
|
*/
|
|
|
|
diagramPadding: 8,
|
|
|
|
|
2020-06-26 09:26:56 -04:00
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| htmlLabels | Flag for setting whether or not a html tag should be used for rendering labels on the edges. | Boolean| Required | True, False|
|
|
|
|
*
|
|
|
|
***Notes: Default value: true**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
htmlLabels: true,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| nodeSpacing | Defines the spacing between nodes on the same level | Integer| Required | Any positive Numbers |
|
|
|
|
*
|
|
|
|
***Notes:
|
|
|
|
*Pertains to horizontal spacing for TB (top to bottom) or BT (bottom to top) graphs, and the vertical spacing for LR as well as RL graphs.**
|
|
|
|
***Default value 50**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
nodeSpacing: 50,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| rankSpacing | Defines the spacing between nodes on different levels | Integer | Required| Any Positive Numbers |
|
|
|
|
*
|
|
|
|
***Notes: pertains to vertical spacing for TB (top to bottom) or BT (bottom to top), and the horizontal spacing for LR as well as RL graphs.
|
|
|
|
***Default value 50**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
rankSpacing: 50,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| curve | Defines how mermaid renders curves for flowcharts. | String | Required | Basis, Linear, Cardinal|
|
|
|
|
*
|
|
|
|
***Notes:
|
|
|
|
*Default Vaue: Linear**
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
curve: 'linear',
|
|
|
|
// Only used in new experimental rendering
|
|
|
|
// repreesents the padding between the labels and the shape
|
|
|
|
padding: 15
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The object containing configurations specific for sequence diagrams
|
|
|
|
*/
|
|
|
|
sequence: {
|
2020-06-26 10:17:13 -04:00
|
|
|
/**
|
|
|
|
* widt of the activation rect
|
|
|
|
* **Default value 10**.
|
|
|
|
*/
|
|
|
|
activationWidth: 10,
|
|
|
|
|
2020-06-26 09:26:56 -04:00
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| diagramMarginX | margin to the right and left of the sequence diagram | Integer | Required | Any Positive Values |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 50**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
diagramMarginX: 50,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| diagramMarginY | Margin to the over and under the sequence diagram | Integer | Required | Any Positive Values|
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 10**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
diagramMarginY: 10,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| actorMargin | Margin between actors. | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 50**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
actorMargin: 50,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| width | Width of actor boxes | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 150**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
width: 150,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| height | Height of actor boxes | Integer | Required | Any Positive Value|
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 65**..
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
height: 65,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| boxMargin | Margin around loop boxes | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
*
|
|
|
|
***Default value 10**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
boxMargin: 10,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| boxTextMargin| margin around the text in loop/alt/opt boxes | Integer | Required| Any Positive Value|
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
*
|
|
|
|
***Default value 5**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
boxTextMargin: 5,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| noteMargin | margin around notes. | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
*
|
|
|
|
***Default value 10**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
noteMargin: 10,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| messageMargin | Space between messages. | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
*
|
|
|
|
*Space between messages.
|
|
|
|
***Default value 35**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
messageMargin: 35,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| messageAlign | Multiline message alignment | Integer | Required | left, center, right |
|
|
|
|
*
|
|
|
|
***Notes:**center **default**
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
messageAlign: 'center',
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| mirrorActors | mirror actors under diagram. | Boolean| Required | True, False |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
*
|
|
|
|
***Default value true**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
mirrorActors: true,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| bottomMarginAdj | Prolongs the edge of the diagram downwards. | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**Depending on css styling this might need adjustment.
|
|
|
|
***Default value 1**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
bottomMarginAdj: 1,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| useMaxWidth | See Notes | Boolean | Required | True, False |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
*when this flag is set to true, the height and width is set to 100% and is then scaling with the
|
|
|
|
*available space. If set to false, the absolute space required is used.
|
|
|
|
***Default value: True**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
useMaxWidth: true,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| rightAngles | display curve arrows as right angles| Boolean | Required | True, False |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
*
|
|
|
|
*This will display arrows that start and begin at the same node as right angles, rather than a curve
|
|
|
|
***Default value false**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
rightAngles: false,
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| showSequenceNumbers | This will show the node numbers | Boolean | Required | True, False |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value false**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
showSequenceNumbers: false,
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| actorFontSize| This sets the font size of the actor's description | Integer | Require | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 14**..
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
actorFontSize: 14,
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| actorFontFamily |This sets the font family of the actor's description | 3 | 4 | Open-Sans, Sans-Serif |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value "Open-Sans", "sans-serif"**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
actorFontFamily: '"Open-Sans", "sans-serif"',
|
|
|
|
/**
|
|
|
|
* This sets the font weight of the actor's description
|
|
|
|
* **Default value 400.
|
|
|
|
*/
|
|
|
|
actorFontWeight: 400,
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| noteFontSize |This sets the font size of actor-attached notes. | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 14**..
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
noteFontSize: 14,
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| noteFontFamily| This sets the font family of actor-attached notes. | String | Required | trebuchet ms, verdana, arial |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value: trebuchet ms **.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
noteFontFamily: '"trebuchet ms", verdana, arial',
|
|
|
|
/**
|
|
|
|
* This sets the font weight of the note's description
|
|
|
|
* **Default value 400.
|
|
|
|
*/
|
|
|
|
noteFontWeight: 400,
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| noteAlign | This sets the text alignment of actor-attached notes. | string | required | left, center, right|
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value center**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
noteAlign: 'center',
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| messageFontSize | This sets the font size of actor messages. | Integer | Required | Any Positive Number |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 16**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
messageFontSize: 16,
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| messageFontFamily | This sets the font family of actor messages. | String| Required | trebuchet ms", verdana, aria |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value:"trebuchet ms**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
messageFontFamily: '"trebuchet ms", verdana, arial',
|
|
|
|
/**
|
|
|
|
* This sets the font weight of the message's description
|
|
|
|
* **Default value 400.
|
|
|
|
*/
|
|
|
|
messageFontWeight: 400,
|
|
|
|
/**
|
|
|
|
* This sets the auto-wrap state for the diagram
|
|
|
|
* **Default value false.
|
|
|
|
*/
|
|
|
|
wrap: false,
|
|
|
|
/**
|
|
|
|
* This sets the auto-wrap padding for the diagram (sides only)
|
2020-06-28 08:37:26 -04:00
|
|
|
* **Default value 10.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
2020-06-28 08:37:26 -04:00
|
|
|
wrapPadding: 10,
|
2020-06-26 09:26:56 -04:00
|
|
|
/**
|
|
|
|
* This sets the width of the loop-box (loop, alt, opt, par)
|
|
|
|
* **Default value 50.
|
|
|
|
*/
|
|
|
|
labelBoxWidth: 50,
|
|
|
|
/**
|
|
|
|
* This sets the height of the loop-box (loop, alt, opt, par)
|
|
|
|
* **Default value 20.
|
|
|
|
*/
|
|
|
|
labelBoxHeight: 20,
|
2020-07-01 04:34:29 -04:00
|
|
|
messageFont: function() {
|
2020-06-26 09:26:56 -04:00
|
|
|
return {
|
2020-07-01 04:34:29 -04:00
|
|
|
fontFamily: this.messageFontFamily,
|
|
|
|
fontSize: this.messageFontSize,
|
|
|
|
fontWeight: this.messageFontWeight
|
2020-06-26 09:26:56 -04:00
|
|
|
};
|
|
|
|
},
|
2020-07-01 04:34:29 -04:00
|
|
|
noteFont: function() {
|
2020-06-26 09:26:56 -04:00
|
|
|
return {
|
2020-07-01 04:34:29 -04:00
|
|
|
fontFamily: this.noteFontFamily,
|
|
|
|
fontSize: this.noteFontSize,
|
|
|
|
fontWeight: this.noteFontWeight
|
2020-06-26 09:26:56 -04:00
|
|
|
};
|
|
|
|
},
|
2020-07-01 04:34:29 -04:00
|
|
|
actorFont: function() {
|
2020-06-26 09:26:56 -04:00
|
|
|
return {
|
2020-07-01 04:34:29 -04:00
|
|
|
fontFamily: this.actorFontFamily,
|
|
|
|
fontSize: this.actorFontSize,
|
|
|
|
fontWeight: this.actorFontWeight
|
2020-06-26 09:26:56 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The object containing configurations specific for gantt diagrams*
|
|
|
|
*/
|
|
|
|
gantt: {
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*### titleTopMargin
|
|
|
|
*
|
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| titleTopMargin | Margin top for the text over the gantt diagram | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 25**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
titleTopMargin: 25,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| barHeight | The height of the bars in the graph | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 20**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
barHeight: 20,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| barGap | The margin between the different activities in the gantt diagram. | Integer | Optional |Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 4**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
barGap: 4,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| topPadding | Margin between title and gantt diagram and between axis and gantt diagram. | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 50**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
topPadding: 50,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| leftPadding | The space allocated for the section name to the left of the activities. | Integer| Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 75**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
leftPadding: 75,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| gridLineStartPadding | Vertical starting position of the grid lines. | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 35**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
gridLineStartPadding: 35,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| fontSize | Font size| Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 11**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
fontSize: 11,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| fontFamily | font Family | string | required |"Open-Sans", "sans-serif" |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
*
|
|
|
|
***Default value '"Open-Sans", "sans-serif"'**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
fontFamily: '"Open-Sans", "sans-serif"',
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| numberSectionStyles | The number of alternating section styles | Integer | 4 | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 4**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
numberSectionStyles: 4,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| axisFormat | Datetime format of the axis. | 3 | Required | Date in yy-mm-dd |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
*
|
|
|
|
* This might need adjustment to match your locale and preferences
|
|
|
|
***Default value '%Y-%m-%d'**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
axisFormat: '%Y-%m-%d'
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* The object containing configurations specific for sequence diagrams
|
|
|
|
*/
|
|
|
|
journey: {
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| diagramMarginX | margin to the right and left of the sequence diagram | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 50**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
diagramMarginX: 50,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| diagramMarginY | margin to the over and under the sequence diagram. | Integer | Required | Any Positive Value|
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 10**..
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
diagramMarginY: 10,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| actorMargin | Margin between actors. | Integer | Required | Any Positive Value|
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 50**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
actorMargin: 50,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| width | Width of actor boxes | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 150**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
width: 150,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| height | Height of actor boxes | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 65**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
height: 65,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| boxMargin | Margin around loop boxes | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 10**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
boxMargin: 10,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| boxTextMargin | margin around the text in loop/alt/opt boxes | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
boxTextMargin: 5,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| noteMargin | margin around notes. | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value 10**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
noteMargin: 10,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| messageMargin |Space between messages. | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
*
|
|
|
|
*Space between messages.
|
|
|
|
***Default value 35**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
messageMargin: 35,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| messageAlign |Multiline message alignment | 3 | 4 | left, center, right |
|
|
|
|
*
|
|
|
|
***Notes:**default:center**
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
messageAlign: 'center',
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| bottomMarginAdj | Prolongs the edge of the diagram downwards. | Integer | 4 | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**Depending on css styling this might need adjustment.
|
|
|
|
***Default value 1**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
bottomMarginAdj: 1,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| useMaxWidth | See notes | Boolean | 4 | True, False |
|
|
|
|
*
|
|
|
|
***Notes:**when this flag is set the height and width is set to 100% and is then scaling with the
|
|
|
|
*available space if not the absolute space required is used.
|
|
|
|
*
|
|
|
|
***Default value true**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
useMaxWidth: true,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| rightAngles | Curved Arrows become Right Angles, | 3 | 4 | True, False |
|
|
|
|
*
|
|
|
|
***Notes:**This will display arrows that start and begin at the same node as right angles, rather than a curves
|
|
|
|
***Default value false**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
rightAngles: false
|
|
|
|
},
|
|
|
|
class: {
|
|
|
|
arrowMarkerAbsolute: false
|
|
|
|
},
|
|
|
|
git: {
|
|
|
|
arrowMarkerAbsolute: false
|
|
|
|
},
|
|
|
|
state: {
|
|
|
|
dividerMargin: 10,
|
|
|
|
sizeUnit: 5,
|
|
|
|
padding: 8,
|
|
|
|
textHeight: 10,
|
|
|
|
titleShift: -15,
|
|
|
|
noteMargin: 10,
|
|
|
|
forkWidth: 70,
|
|
|
|
forkHeight: 7,
|
|
|
|
// Used
|
|
|
|
miniPadding: 2,
|
|
|
|
// Font size factor, this is used to guess the width of the edges labels before rendering by dagre
|
|
|
|
// layout. This might need updating if/when switching font
|
|
|
|
fontSizeFactor: 5.02,
|
|
|
|
fontSize: 24,
|
|
|
|
labelHeight: 16,
|
|
|
|
edgeLengthFactor: '20',
|
|
|
|
compositTitleSize: 35,
|
|
|
|
radius: 5
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The object containing configurations specific for entity relationship diagrams
|
|
|
|
*/
|
|
|
|
er: {
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| diagramPadding | amount of padding around the diagram as a whole | Integer | Required | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**The amount of padding around the diagram as a whole so that embedded diagrams have margins, expressed in pixels
|
|
|
|
***Default value: 20**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
diagramPadding: 20,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| layoutDirection | Directional bias for layout of entities. | String | Required | "TB", "BT","LR","RL" |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
*'TB' for Top-Bottom, 'BT'for Bottom-Top, 'LR' for Left-Right, or 'RL' for Right to Left.
|
|
|
|
* T = top, B = bottom, L = left, and R = right.
|
|
|
|
***Default value: TB **.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
layoutDirection: 'TB',
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| minEntityWidth | The mimimum width of an entity box, | Integer | Required| Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**expressed in pixels
|
|
|
|
***Default value: 100**.
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
minEntityWidth: 100,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| minEntityHeight| The minimum height of an entity box, | Integer | 4 | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**expressed in pixels
|
|
|
|
***Default value: 75 **
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
minEntityHeight: 75,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| entityPadding|minimum internal padding betweentext in box and box borders| Integer | 4 | Any Positive Value |
|
|
|
|
*
|
|
|
|
***Notes:**The minimum internal padding betweentext in an entity box and the enclosing box borders, expressed in pixels.
|
|
|
|
***Default value: 15 **
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
entityPadding: 15,
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| stroke | Stroke color of box edges and lines | String | 4 | Any recognized color |
|
|
|
|
***Default value: gray **
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
stroke: 'gray',
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| fill | Fill color of entity boxes | String | 4 | Any recognized color |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
***Default value:'honeydew'**
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
|
|
|
fill: 'honeydew',
|
|
|
|
|
|
|
|
/**
|
2020-07-02 18:25:49 +02:00
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| fontSize| Font Size in pixels| Integer | | Any Positive Value |
|
|
|
|
*
|
2020-07-11 18:54:26 +10:00
|
|
|
***Notes:**Font size (expressed as an integer representing a number of pixels)
|
2020-07-02 18:25:49 +02:00
|
|
|
***Default value: 12 **
|
2020-06-26 09:26:56 -04:00
|
|
|
*/
|
2020-07-11 18:54:26 +10:00
|
|
|
fontSize: 12,
|
|
|
|
|
|
|
|
/**
|
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| useMaxWidth | See Notes | Boolean | Required | true, false |
|
|
|
|
*
|
|
|
|
***Notes:**
|
|
|
|
*When this flag is set to true, the diagram width is locked to 100% and
|
|
|
|
*scaled based on available space. If set to false, the diagram reserves its
|
|
|
|
*absolute width.
|
|
|
|
***Default value: true**.
|
|
|
|
*/
|
|
|
|
useMaxWidth: true
|
2020-06-26 09:26:56 -04:00
|
|
|
}
|
2019-09-12 12:58:57 -07:00
|
|
|
};
|
2020-06-26 09:26:56 -04:00
|
|
|
config.class.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
|
|
|
|
config.git.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
|
|
|
|
export const defaultConfig = Object.freeze(config);
|
|
|
|
|
|
|
|
const siteConfig = assignWithDepth({}, defaultConfig);
|
|
|
|
const currentConfig = assignWithDepth({}, defaultConfig);
|
2019-10-11 15:39:50 +02:00
|
|
|
|
2020-06-26 09:26:56 -04:00
|
|
|
/**
|
2020-07-14 18:11:36 -07:00
|
|
|
*## setSiteConfig
|
|
|
|
|
|
|
|
*| Function | Description | Type | Values |
|
|
|
|
*| --------- | ------------------- | ------- | ------------------ |
|
|
|
|
*| setSiteConfig|Sets the siteConfig to desired values | Put Request | Any Values, except ones in secure array|
|
|
|
|
|
|
|
|
***Notes:**
|
|
|
|
*Sets the siteConfig. The siteConfig is a protected configuration for repeat use. Calls to reset() will reset
|
|
|
|
*the currentConfig to siteConfig. Calls to reset(configApi.defaultConfig) will reset siteConfig and currentConfig
|
|
|
|
*to the defaultConfig
|
|
|
|
*Note: currentConfig is set in this function
|
|
|
|
|
|
|
|
**Default value: At default, will mirror Global Config**
|
2020-06-26 09:26:56 -04:00
|
|
|
* @param conf - the base currentConfig to use as siteConfig
|
|
|
|
* @returns {*} - the siteConfig
|
|
|
|
*/
|
|
|
|
export const setSiteConfig = conf => {
|
|
|
|
assignWithDepth(currentConfig, conf, { clobber: true });
|
|
|
|
assignWithDepth(siteConfig, conf);
|
|
|
|
return getSiteConfig();
|
|
|
|
};
|
|
|
|
/**
|
2020-07-14 18:11:36 -07:00
|
|
|
*## getSiteConfig
|
|
|
|
*| Function | Description | Type | Values |
|
|
|
|
*| --------- | ------------------- | ------- | ------------------ |
|
|
|
|
*| setSiteConfig|Returns the current siteConfig base configuration | Get Request | Returns Any Values in siteConfig|
|
|
|
|
|
|
|
|
***Notes**:
|
|
|
|
*Returns **any** values in siteConfig.
|
2020-06-26 09:26:56 -04:00
|
|
|
* @returns {*}
|
|
|
|
*/
|
|
|
|
export const getSiteConfig = () => {
|
|
|
|
return assignWithDepth({}, siteConfig);
|
|
|
|
};
|
|
|
|
/**
|
2020-07-14 18:11:36 -07:00
|
|
|
*## setConfig
|
|
|
|
*| Function | Description | Type | Values |
|
|
|
|
*| --------- | ------------------- | ------- | ------------------ |
|
|
|
|
*| setSiteConfig|Sets the siteConfig to desired values | Put Request| Any Values, except ones in secure array|
|
|
|
|
|
|
|
|
|
|
|
|
***Notes**:
|
|
|
|
*Sets the currentConfig. The parameter conf is sanitized based on the siteConfig.secure keys. Any
|
|
|
|
*values found in conf with key found in siteConfig.secure will be replaced with the corresponding
|
|
|
|
*siteConfig value.
|
2020-06-26 09:26:56 -04:00
|
|
|
* @param conf - the potential currentConfig
|
|
|
|
* @returns {*} - the currentConfig merged with the sanitized conf
|
|
|
|
*/
|
|
|
|
export const setConfig = conf => {
|
|
|
|
sanitize(conf);
|
|
|
|
assignWithDepth(currentConfig, conf);
|
|
|
|
return getConfig();
|
|
|
|
};
|
|
|
|
/**
|
2020-07-14 18:11:36 -07:00
|
|
|
* ## getConfig
|
|
|
|
*| Function | Description | Type | Return Values |
|
|
|
|
*| --------- | ------------------- | ------- | ------------------ |
|
|
|
|
*| getConfig |Obtains the currentConfig | Get Request | Any Values from currentConfig|
|
|
|
|
|
|
|
|
***Notes**:
|
|
|
|
*Returns **any** the currentConfig
|
2020-06-26 09:26:56 -04:00
|
|
|
* @returns {*} - the currentConfig
|
|
|
|
*/
|
|
|
|
export const getConfig = () => {
|
|
|
|
return assignWithDepth({}, currentConfig);
|
|
|
|
};
|
|
|
|
/**
|
2020-07-14 18:11:36 -07:00
|
|
|
*## sanitize
|
|
|
|
*| Function | Description | Type | Values |
|
|
|
|
*| --------- | ------------------- | ------- | ------------------ |
|
|
|
|
*| sanitize |Sets the siteConfig to desired values. | Put Request |None|
|
|
|
|
|
|
|
|
*Ensures options parameter does not attempt to override siteConfig secure keys
|
|
|
|
*Note: modifies options in-place
|
2020-06-26 09:26:56 -04:00
|
|
|
* @param options - the potential setConfig parameter
|
|
|
|
*/
|
|
|
|
export const sanitize = options => {
|
|
|
|
Object.keys(siteConfig.secure).forEach(key => {
|
|
|
|
if (typeof options[siteConfig.secure[key]] !== 'undefined') {
|
|
|
|
// DO NOT attempt to print options[siteConfig.secure[key]] within `${}` as a malicious script
|
|
|
|
// can exploit the logger's attempt to stringify the value and execute arbitrary code
|
|
|
|
logger.warn(
|
|
|
|
`Denied attempt to modify a secure key ${siteConfig.secure[key]}`,
|
|
|
|
options[siteConfig.secure[key]]
|
|
|
|
);
|
|
|
|
delete options[siteConfig.secure[key]];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
/**
|
2020-07-14 18:15:42 -07:00
|
|
|
*## reset
|
2020-07-14 18:11:36 -07:00
|
|
|
|
|
|
|
*| Function | Description | Type | Required | Values |
|
|
|
|
*| --------- | ------------------- | ------- | -------- | ------------------ |
|
|
|
|
*| reset|Resets currentConfig to conf| Put Request | Required | None|
|
|
|
|
*
|
|
|
|
*| Parameter | Description |Type | Required | Values|
|
|
|
|
*| --- | --- | --- | --- | --- |
|
|
|
|
*| conf| base set of values, which currentConfig coul be **reset** to.| Dictionary | Required | Any Values, with respect to the secure Array|
|
|
|
|
*
|
|
|
|
**Notes :
|
|
|
|
(default: current siteConfig ) (optional, default `getSiteConfig()`)
|
2020-06-26 09:26:56 -04:00
|
|
|
* @param conf - the base currentConfig to reset to (default: current siteConfig )
|
|
|
|
*/
|
|
|
|
export const reset = (conf = getSiteConfig()) => {
|
|
|
|
Object.keys(siteConfig).forEach(key => delete siteConfig[key]);
|
|
|
|
Object.keys(currentConfig).forEach(key => delete currentConfig[key]);
|
|
|
|
assignWithDepth(siteConfig, conf, { clobber: true });
|
|
|
|
assignWithDepth(currentConfig, conf, { clobber: true });
|
2020-06-17 18:14:10 -04:00
|
|
|
};
|
|
|
|
|
2020-06-26 09:26:56 -04:00
|
|
|
const configApi = Object.freeze({
|
|
|
|
sanitize,
|
|
|
|
setSiteConfig,
|
|
|
|
getSiteConfig,
|
2019-10-11 15:39:50 +02:00
|
|
|
setConfig,
|
2020-06-17 18:14:10 -04:00
|
|
|
getConfig,
|
2020-06-26 09:26:56 -04:00
|
|
|
reset,
|
|
|
|
defaultConfig
|
|
|
|
});
|
2019-10-11 15:39:50 +02:00
|
|
|
export default configApi;
|