feat: Remove forced optionality of fields inside MermaidConfig

This commit is contained in:
Sidharth Vinod
2024-05-13 09:56:50 +05:30
parent 70198ffefa
commit cee1cf0ce2
2 changed files with 161 additions and 179 deletions

View File

@@ -10,13 +10,13 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
import { readFile, writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import assert from 'node:assert'; import assert from 'node:assert';
import { execFile } from 'node:child_process'; import { execFile } from 'node:child_process';
import { readFile, writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import { promisify } from 'node:util'; import { promisify } from 'node:util';
import { load, JSON_SCHEMA } from 'js-yaml'; import { JSON_SCHEMA, load } from 'js-yaml';
import { compile, type JSONSchema } from 'json-schema-to-typescript'; import { compile, type JSONSchema } from 'json-schema-to-typescript';
import prettier from 'prettier'; import prettier from 'prettier';
@@ -131,23 +131,6 @@ async function generateTypescript(mermaidConfigSchema: JSONSchemaType<MermaidCon
return schema; return schema;
} }
/**
* For backwards compatibility with older Mermaid Typescript defs,
* we need to make all value optional instead of required.
*
* This is because the `MermaidConfig` type is used as an input, and everything is optional,
* since all the required values have default values.s
*
* In the future, we should make make the input to Mermaid `Partial<MermaidConfig>`.
*
* @todo TODO: Remove this function when Mermaid releases a new breaking change.
* @param schema - The input schema.
* @returns The schema with all required values removed.
*/
function removeRequired(schema: JSONSchemaType<Record<string, any>>) {
return { ...schema, required: [] };
}
/** /**
* This is a temporary hack to control the order the types are generated in. * This is a temporary hack to control the order the types are generated in.
* *
@@ -161,7 +144,7 @@ async function generateTypescript(mermaidConfigSchema: JSONSchemaType<MermaidCon
* @param schema - The input schema. * @param schema - The input schema.
* @returns The schema with all `$ref`s removed. * @returns The schema with all `$ref`s removed.
*/ */
function unrefSubschemas(schema: JSONSchemaType<Record<string, any>>) { function unrefSubschemas(schema: JSONSchemaType<MermaidConfig>) {
return { return {
...schema, ...schema,
properties: Object.fromEntries( properties: Object.fromEntries(
@@ -194,17 +177,16 @@ async function generateTypescript(mermaidConfigSchema: JSONSchemaType<MermaidCon
assert.ok(mermaidConfigSchema.$defs); assert.ok(mermaidConfigSchema.$defs);
const modifiedSchema = { const modifiedSchema = {
...unrefSubschemas(removeRequired(mermaidConfigSchema)), ...unrefSubschemas(mermaidConfigSchema),
$defs: Object.fromEntries( $defs: Object.fromEntries(
Object.entries(mermaidConfigSchema.$defs).map(([key, subSchema]) => { Object.entries(mermaidConfigSchema.$defs).map(([key, subSchema]) => {
return [key, removeRequired(replaceAllOfWithExtends(subSchema))]; return [key, replaceAllOfWithExtends(subSchema as JSONSchemaType<Record<string, any>>)];
}) })
), ),
}; };
const typescriptFile = await compile( const typescriptFile = await compile(
modifiedSchema as JSONSchema, // json-schema-to-typescript only allows JSON Schema 4 as input type modifiedSchema as unknown as JSONSchema, // json-schema-to-typescript only allows JSON Schema 4 as input type
'MermaidConfig', 'MermaidConfig',
{ {
additionalProperties: false, // in JSON Schema 2019-09, these are called `unevaluatedProperties` additionalProperties: false, // in JSON Schema 2019-09, these are called `unevaluatedProperties`

View File

@@ -81,27 +81,27 @@ export interface MermaidConfig {
* See https://developer.mozilla.org/en-US/docs/Web/CSS/font-family * See https://developer.mozilla.org/en-US/docs/Web/CSS/font-family
* *
*/ */
fontFamily?: string; fontFamily: string;
altFontFamily?: string; altFontFamily?: string;
/** /**
* This option decides the amount of logging to be used by mermaid. * This option decides the amount of logging to be used by mermaid.
* *
*/ */
logLevel?: 'trace' | 0 | 'debug' | 1 | 'info' | 2 | 'warn' | 3 | 'error' | 4 | 'fatal' | 5; logLevel: 'trace' | 0 | 'debug' | 1 | 'info' | 2 | 'warn' | 3 | 'error' | 4 | 'fatal' | 5;
/** /**
* Level of trust for parsed diagram * Level of trust for parsed diagram
*/ */
securityLevel?: 'strict' | 'loose' | 'antiscript' | 'sandbox'; securityLevel: 'strict' | 'loose' | 'antiscript' | 'sandbox';
/** /**
* Dictates whether mermaid starts on Page load * Dictates whether mermaid starts on Page load
*/ */
startOnLoad?: boolean; startOnLoad: boolean;
/** /**
* Controls whether or arrow markers in html code are absolute paths or anchors. * Controls whether or arrow markers in html code are absolute paths or anchors.
* This matters if you are using base tag settings. * This matters if you are using base tag settings.
* *
*/ */
arrowMarkerAbsolute?: boolean; arrowMarkerAbsolute: boolean;
/** /**
* This option controls which `currentConfig` keys are considered secure and * This option controls which `currentConfig` keys are considered secure and
* can only be changed via call to `mermaidAPI.initialize`. * can only be changed via call to `mermaidAPI.initialize`.
@@ -145,24 +145,24 @@ export interface MermaidConfig {
* *
*/ */
deterministicIDSeed?: string; deterministicIDSeed?: string;
flowchart?: FlowchartDiagramConfig; flowchart: FlowchartDiagramConfig;
sequence?: SequenceDiagramConfig; sequence: SequenceDiagramConfig;
gantt?: GanttDiagramConfig; gantt: GanttDiagramConfig;
journey?: JourneyDiagramConfig; journey: JourneyDiagramConfig;
timeline?: TimelineDiagramConfig; timeline?: TimelineDiagramConfig;
class?: ClassDiagramConfig; class: ClassDiagramConfig;
state?: StateDiagramConfig; state: StateDiagramConfig;
er?: ErDiagramConfig; er: ErDiagramConfig;
pie?: PieDiagramConfig; pie: PieDiagramConfig;
quadrantChart?: QuadrantChartConfig; quadrantChart: QuadrantChartConfig;
xyChart?: XYChartConfig; xyChart: XYChartConfig;
requirement?: RequirementDiagramConfig; requirement: RequirementDiagramConfig;
mindmap?: MindmapDiagramConfig; mindmap: MindmapDiagramConfig;
gitGraph?: GitGraphDiagramConfig; gitGraph: GitGraphDiagramConfig;
c4?: C4DiagramConfig; c4: C4DiagramConfig;
sankey?: SankeyDiagramConfig; sankey: SankeyDiagramConfig;
packet?: PacketDiagramConfig; packet: PacketDiagramConfig;
block?: BlockDiagramConfig; block: BlockDiagramConfig;
dompurifyConfig?: DOMPurifyConfiguration; dompurifyConfig?: DOMPurifyConfiguration;
wrap?: boolean; wrap?: boolean;
fontSize?: number; fontSize?: number;
@@ -240,41 +240,41 @@ export interface C4DiagramConfig extends BaseDiagramConfig {
* Margin to the right and left of the c4 diagram, must be a positive value. * Margin to the right and left of the c4 diagram, must be a positive value.
* *
*/ */
diagramMarginX?: number; diagramMarginX: number;
/** /**
* Margin to the over and under the c4 diagram, must be a positive value. * Margin to the over and under the c4 diagram, must be a positive value.
* *
*/ */
diagramMarginY?: number; diagramMarginY: number;
/** /**
* Margin between shapes * Margin between shapes
*/ */
c4ShapeMargin?: number; c4ShapeMargin: number;
/** /**
* Padding between shapes * Padding between shapes
*/ */
c4ShapePadding?: number; c4ShapePadding: number;
/** /**
* Width of person boxes * Width of person boxes
*/ */
width?: number; width: number;
/** /**
* Height of person boxes * Height of person boxes
*/ */
height?: number; height: number;
/** /**
* Margin around boxes * Margin around boxes
*/ */
boxMargin?: number; boxMargin: number;
/** /**
* How many shapes to place in each row. * How many shapes to place in each row.
*/ */
c4ShapeInRow?: number; c4ShapeInRow: number;
nextLinePaddingX?: number; nextLinePaddingX?: number;
/** /**
* How many boundaries to place in each row. * How many boundaries to place in each row.
*/ */
c4BoundaryInRow?: number; c4BoundaryInRow: number;
/** /**
* This sets the font size of Person shape for the diagram * This sets the font size of Person shape for the diagram
*/ */
@@ -618,7 +618,7 @@ export interface GitGraphDiagramConfig extends BaseDiagramConfig {
/** /**
* Margin top for the text over the diagram * Margin top for the text over the diagram
*/ */
titleTopMargin?: number; titleTopMargin: number;
diagramPadding?: number; diagramPadding?: number;
nodeLabel?: NodeLabel; nodeLabel?: NodeLabel;
mainBranchName?: string; mainBranchName?: string;
@@ -668,8 +668,8 @@ export interface RequirementDiagramConfig extends BaseDiagramConfig {
* via the `definition` "MindmapDiagramConfig". * via the `definition` "MindmapDiagramConfig".
*/ */
export interface MindmapDiagramConfig extends BaseDiagramConfig { export interface MindmapDiagramConfig extends BaseDiagramConfig {
padding?: number; padding: number;
maxNodeWidth?: number; maxNodeWidth: number;
} }
/** /**
* This interface was referenced by `MermaidConfig`'s JSON-Schema * This interface was referenced by `MermaidConfig`'s JSON-Schema
@@ -690,75 +690,75 @@ export interface QuadrantChartConfig extends BaseDiagramConfig {
/** /**
* Width of the chart * Width of the chart
*/ */
chartWidth?: number; chartWidth: number;
/** /**
* Height of the chart * Height of the chart
*/ */
chartHeight?: number; chartHeight: number;
/** /**
* Chart title top and bottom padding * Chart title top and bottom padding
*/ */
titleFontSize?: number; titleFontSize: number;
/** /**
* Padding around the quadrant square * Padding around the quadrant square
*/ */
titlePadding?: number; titlePadding: number;
/** /**
* quadrant title padding from top if the quadrant is rendered on top * quadrant title padding from top if the quadrant is rendered on top
*/ */
quadrantPadding?: number; quadrantPadding: number;
/** /**
* Padding around x-axis labels * Padding around x-axis labels
*/ */
xAxisLabelPadding?: number; xAxisLabelPadding: number;
/** /**
* Padding around y-axis labels * Padding around y-axis labels
*/ */
yAxisLabelPadding?: number; yAxisLabelPadding: number;
/** /**
* x-axis label font size * x-axis label font size
*/ */
xAxisLabelFontSize?: number; xAxisLabelFontSize: number;
/** /**
* y-axis label font size * y-axis label font size
*/ */
yAxisLabelFontSize?: number; yAxisLabelFontSize: number;
/** /**
* quadrant title font size * quadrant title font size
*/ */
quadrantLabelFontSize?: number; quadrantLabelFontSize: number;
/** /**
* quadrant title padding from top if the quadrant is rendered on top * quadrant title padding from top if the quadrant is rendered on top
*/ */
quadrantTextTopPadding?: number; quadrantTextTopPadding: number;
/** /**
* padding between point and point label * padding between point and point label
*/ */
pointTextPadding?: number; pointTextPadding: number;
/** /**
* point title font size * point title font size
*/ */
pointLabelFontSize?: number; pointLabelFontSize: number;
/** /**
* radius of the point to be drawn * radius of the point to be drawn
*/ */
pointRadius?: number; pointRadius: number;
/** /**
* position of x-axis labels * position of x-axis labels
*/ */
xAxisPosition?: 'top' | 'bottom'; xAxisPosition: 'top' | 'bottom';
/** /**
* position of y-axis labels * position of y-axis labels
*/ */
yAxisPosition?: 'left' | 'right'; yAxisPosition: 'left' | 'right';
/** /**
* stroke width of edges of the box that are inside the quadrant * stroke width of edges of the box that are inside the quadrant
*/ */
quadrantInternalBorderStrokeWidth?: number; quadrantInternalBorderStrokeWidth: number;
/** /**
* stroke width of edges of the box that are outside the quadrant * stroke width of edges of the box that are outside the quadrant
*/ */
quadrantExternalBorderStrokeWidth?: number; quadrantExternalBorderStrokeWidth: number;
} }
/** /**
* This object contains configuration for XYChart axis config * This object contains configuration for XYChart axis config
@@ -770,47 +770,47 @@ export interface XYChartAxisConfig {
/** /**
* Should show the axis labels (tick text) * Should show the axis labels (tick text)
*/ */
showLabel?: boolean; showLabel: boolean;
/** /**
* font size of the axis labels (tick text) * font size of the axis labels (tick text)
*/ */
labelFontSize?: number; labelFontSize: number;
/** /**
* top and bottom space from axis label (tick text) * top and bottom space from axis label (tick text)
*/ */
labelPadding?: number; labelPadding: number;
/** /**
* Should show the axis title * Should show the axis title
*/ */
showTitle?: boolean; showTitle: boolean;
/** /**
* font size of the axis title * font size of the axis title
*/ */
titleFontSize?: number; titleFontSize: number;
/** /**
* top and bottom space from axis title * top and bottom space from axis title
*/ */
titlePadding?: number; titlePadding: number;
/** /**
* Should show the axis tick lines * Should show the axis tick lines
*/ */
showTick?: boolean; showTick: boolean;
/** /**
* length of the axis tick lines * length of the axis tick lines
*/ */
tickLength?: number; tickLength: number;
/** /**
* width of the axis tick lines * width of the axis tick lines
*/ */
tickWidth?: number; tickWidth: number;
/** /**
* Show line across the axis * Show line across the axis
*/ */
showAxisLine?: boolean; showAxisLine: boolean;
/** /**
* Width of the axis line * Width of the axis line
*/ */
axisLineWidth?: number; axisLineWidth: number;
} }
/** /**
* This object contains configuration specific to XYCharts * This object contains configuration specific to XYCharts
@@ -822,33 +822,33 @@ export interface XYChartConfig extends BaseDiagramConfig {
/** /**
* width of the chart * width of the chart
*/ */
width?: number; width: number;
/** /**
* height of the chart * height of the chart
*/ */
height?: number; height: number;
/** /**
* Font size of the chart title * Font size of the chart title
*/ */
titleFontSize?: number; titleFontSize: number;
/** /**
* Top and bottom space from the chart title * Top and bottom space from the chart title
*/ */
titlePadding?: number; titlePadding: number;
/** /**
* Should show the chart title * Should show the chart title
*/ */
showTitle?: boolean; showTitle: boolean;
xAxis?: XYChartAxisConfig; xAxis: XYChartAxisConfig;
yAxis?: XYChartAxisConfig; yAxis: XYChartAxisConfig;
/** /**
* How to plot will be drawn horizontal or vertical * How to plot will be drawn horizontal or vertical
*/ */
chartOrientation?: 'vertical' | 'horizontal'; chartOrientation: 'vertical' | 'horizontal';
/** /**
* Minimum percent of space plots of the chart will take * Minimum percent of space plots of the chart will take
*/ */
plotReservedSpacePercent?: number; plotReservedSpacePercent: number;
} }
/** /**
* The object containing configurations specific for entity relationship diagrams * The object containing configurations specific for entity relationship diagrams
@@ -860,39 +860,39 @@ export interface ErDiagramConfig extends BaseDiagramConfig {
/** /**
* Margin top for the text over the diagram * Margin top for the text over the diagram
*/ */
titleTopMargin?: number; titleTopMargin: number;
/** /**
* The amount of padding around the diagram as a whole so that embedded * The amount of padding around the diagram as a whole so that embedded
* diagrams have margins, expressed in pixels. * diagrams have margins, expressed in pixels.
* *
*/ */
diagramPadding?: number; diagramPadding: number;
/** /**
* Directional bias for layout of entities * Directional bias for layout of entities
*/ */
layoutDirection?: 'TB' | 'BT' | 'LR' | 'RL'; layoutDirection: 'TB' | 'BT' | 'LR' | 'RL';
/** /**
* The minimum width of an entity box. Expressed in pixels. * The minimum width of an entity box. Expressed in pixels.
*/ */
minEntityWidth?: number; minEntityWidth: number;
/** /**
* The minimum height of an entity box. Expressed in pixels. * The minimum height of an entity box. Expressed in pixels.
*/ */
minEntityHeight?: number; minEntityHeight: number;
/** /**
* The minimum internal padding between text in an entity box and the enclosing box borders. * The minimum internal padding between text in an entity box and the enclosing box borders.
* Expressed in pixels. * Expressed in pixels.
* *
*/ */
entityPadding?: number; entityPadding: number;
/** /**
* Stroke color of box edges and lines. * Stroke color of box edges and lines.
*/ */
stroke?: string; stroke: string;
/** /**
* Fill color of entity boxes * Fill color of entity boxes
*/ */
fill?: string; fill: string;
/** /**
* Font size (expressed as an integer representing a number of pixels) * Font size (expressed as an integer representing a number of pixels)
*/ */
@@ -908,7 +908,7 @@ export interface StateDiagramConfig extends BaseDiagramConfig {
/** /**
* Margin top for the text over the diagram * Margin top for the text over the diagram
*/ */
titleTopMargin?: number; titleTopMargin: number;
arrowMarkerAbsolute?: boolean; arrowMarkerAbsolute?: boolean;
dividerMargin?: number; dividerMargin?: number;
sizeUnit?: number; sizeUnit?: number;
@@ -935,7 +935,7 @@ export interface StateDiagramConfig extends BaseDiagramConfig {
* Decides which rendering engine that is to be used for the rendering. * Decides which rendering engine that is to be used for the rendering.
* *
*/ */
defaultRenderer?: 'dagre-d3' | 'dagre-wrapper' | 'elk'; defaultRenderer: 'dagre-d3' | 'dagre-wrapper' | 'elk';
} }
/** /**
* This interface was referenced by `MermaidConfig`'s JSON-Schema * This interface was referenced by `MermaidConfig`'s JSON-Schema
@@ -945,7 +945,7 @@ export interface ClassDiagramConfig extends BaseDiagramConfig {
/** /**
* Margin top for the text over the diagram * Margin top for the text over the diagram
*/ */
titleTopMargin?: number; titleTopMargin: number;
/** /**
* Controls whether or arrow markers in html code are absolute paths or anchors. * Controls whether or arrow markers in html code are absolute paths or anchors.
* This matters if you are using base tag settings. * This matters if you are using base tag settings.
@@ -959,7 +959,7 @@ export interface ClassDiagramConfig extends BaseDiagramConfig {
* Decides which rendering engine that is to be used for the rendering. * Decides which rendering engine that is to be used for the rendering.
* *
*/ */
defaultRenderer?: 'dagre-d3' | 'dagre-wrapper' | 'elk'; defaultRenderer: 'dagre-d3' | 'dagre-wrapper' | 'elk';
nodeSpacing?: number; nodeSpacing?: number;
rankSpacing?: number; rankSpacing?: number;
/** /**
@@ -982,51 +982,51 @@ export interface JourneyDiagramConfig extends BaseDiagramConfig {
* Margin to the right and left of the c4 diagram, must be a positive value. * Margin to the right and left of the c4 diagram, must be a positive value.
* *
*/ */
diagramMarginX?: number; diagramMarginX: number;
/** /**
* Margin to the over and under the c4 diagram, must be a positive value. * Margin to the over and under the c4 diagram, must be a positive value.
* *
*/ */
diagramMarginY?: number; diagramMarginY: number;
/** /**
* Margin between actors * Margin between actors
*/ */
leftMargin?: number; leftMargin: number;
/** /**
* Width of actor boxes * Width of actor boxes
*/ */
width?: number; width: number;
/** /**
* Height of actor boxes * Height of actor boxes
*/ */
height?: number; height: number;
/** /**
* Margin around loop boxes * Margin around loop boxes
*/ */
boxMargin?: number; boxMargin: number;
/** /**
* Margin around the text in loop/alt/opt boxes * Margin around the text in loop/alt/opt boxes
*/ */
boxTextMargin?: number; boxTextMargin: number;
/** /**
* Margin around notes * Margin around notes
*/ */
noteMargin?: number; noteMargin: number;
/** /**
* Space between messages. * Space between messages.
*/ */
messageMargin?: number; messageMargin: number;
/** /**
* Multiline message alignment * Multiline message alignment
*/ */
messageAlign?: 'left' | 'center' | 'right'; messageAlign: 'left' | 'center' | 'right';
/** /**
* Prolongs the edge of the diagram downwards. * Prolongs the edge of the diagram downwards.
* *
* Depending on css styling this might need adjustment. * Depending on css styling this might need adjustment.
* *
*/ */
bottomMarginAdj?: number; bottomMarginAdj: number;
/** /**
* Curved Arrows become Right Angles * Curved Arrows become Right Angles
* *
@@ -1034,7 +1034,7 @@ export interface JourneyDiagramConfig extends BaseDiagramConfig {
* right angles, rather than as curves. * right angles, rather than as curves.
* *
*/ */
rightAngles?: boolean; rightAngles: boolean;
taskFontSize?: string | number; taskFontSize?: string | number;
taskFontFamily?: string; taskFontFamily?: string;
taskMargin?: number; taskMargin?: number;
@@ -1060,52 +1060,52 @@ export interface TimelineDiagramConfig extends BaseDiagramConfig {
* Margin to the right and left of the c4 diagram, must be a positive value. * Margin to the right and left of the c4 diagram, must be a positive value.
* *
*/ */
diagramMarginX?: number; diagramMarginX: number;
/** /**
* Margin to the over and under the c4 diagram, must be a positive value. * Margin to the over and under the c4 diagram, must be a positive value.
* *
*/ */
diagramMarginY?: number; diagramMarginY: number;
/** /**
* Margin between actors * Margin between actors
*/ */
leftMargin?: number; leftMargin: number;
/** /**
* Width of actor boxes * Width of actor boxes
*/ */
width?: number; width: number;
/** /**
* Height of actor boxes * Height of actor boxes
*/ */
height?: number; height: number;
padding?: number; padding?: number;
/** /**
* Margin around loop boxes * Margin around loop boxes
*/ */
boxMargin?: number; boxMargin: number;
/** /**
* Margin around the text in loop/alt/opt boxes * Margin around the text in loop/alt/opt boxes
*/ */
boxTextMargin?: number; boxTextMargin: number;
/** /**
* Margin around notes * Margin around notes
*/ */
noteMargin?: number; noteMargin: number;
/** /**
* Space between messages. * Space between messages.
*/ */
messageMargin?: number; messageMargin: number;
/** /**
* Multiline message alignment * Multiline message alignment
*/ */
messageAlign?: 'left' | 'center' | 'right'; messageAlign: 'left' | 'center' | 'right';
/** /**
* Prolongs the edge of the diagram downwards. * Prolongs the edge of the diagram downwards.
* *
* Depending on css styling this might need adjustment. * Depending on css styling this might need adjustment.
* *
*/ */
bottomMarginAdj?: number; bottomMarginAdj: number;
/** /**
* Curved Arrows become Right Angles * Curved Arrows become Right Angles
* *
@@ -1142,11 +1142,11 @@ export interface GanttDiagramConfig extends BaseDiagramConfig {
/** /**
* Margin top for the text over the diagram * Margin top for the text over the diagram
*/ */
titleTopMargin?: number; titleTopMargin: number;
/** /**
* The height of the bars in the graph * The height of the bars in the graph
*/ */
barHeight?: number; barHeight: number;
/** /**
* The margin between the different activities in the gantt diagram * The margin between the different activities in the gantt diagram
*/ */
@@ -1155,40 +1155,40 @@ export interface GanttDiagramConfig extends BaseDiagramConfig {
* Margin between title and gantt diagram and between axis and gantt diagram. * Margin between title and gantt diagram and between axis and gantt diagram.
* *
*/ */
topPadding?: number; topPadding: number;
/** /**
* The space allocated for the section name to the right of the activities * The space allocated for the section name to the right of the activities
* *
*/ */
rightPadding?: number; rightPadding: number;
/** /**
* The space allocated for the section name to the left of the activities * The space allocated for the section name to the left of the activities
* *
*/ */
leftPadding?: number; leftPadding: number;
/** /**
* Vertical starting position of the grid lines * Vertical starting position of the grid lines
*/ */
gridLineStartPadding?: number; gridLineStartPadding: number;
/** /**
* Font size * Font size
*/ */
fontSize?: number; fontSize: number;
/** /**
* Font size for sections * Font size for sections
*/ */
sectionFontSize?: string | number; sectionFontSize: string | number;
/** /**
* The number of alternating section styles * The number of alternating section styles
*/ */
numberSectionStyles?: number; numberSectionStyles: number;
/** /**
* Date/time format of the axis * Date/time format of the axis
* *
* This might need adjustment to match your locale and preferences. * This might need adjustment to match your locale and preferences.
* *
*/ */
axisFormat?: string; axisFormat: string;
/** /**
* axis ticks * axis ticks
* *
@@ -1204,7 +1204,7 @@ export interface GanttDiagramConfig extends BaseDiagramConfig {
* When this flag is set, date labels will be added to the top of the chart * When this flag is set, date labels will be added to the top of the chart
* *
*/ */
topAxis?: boolean; topAxis: boolean;
/** /**
* Controls the display mode. * Controls the display mode.
* *
@@ -1214,7 +1214,7 @@ export interface GanttDiagramConfig extends BaseDiagramConfig {
* On which day a week-based interval should start * On which day a week-based interval should start
* *
*/ */
weekday?: 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday'; weekday: 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday';
} }
/** /**
* The object containing configurations specific for sequence diagrams * The object containing configurations specific for sequence diagrams
@@ -1228,64 +1228,64 @@ export interface SequenceDiagramConfig extends BaseDiagramConfig {
/** /**
* Width of the activation rect * Width of the activation rect
*/ */
activationWidth?: number; activationWidth: number;
/** /**
* Margin to the right and left of the sequence diagram * Margin to the right and left of the sequence diagram
*/ */
diagramMarginX?: number; diagramMarginX: number;
/** /**
* Margin to the over and under the sequence diagram * Margin to the over and under the sequence diagram
*/ */
diagramMarginY?: number; diagramMarginY: number;
/** /**
* Margin between actors * Margin between actors
*/ */
actorMargin?: number; actorMargin: number;
/** /**
* Width of actor boxes * Width of actor boxes
*/ */
width?: number; width: number;
/** /**
* Height of actor boxes * Height of actor boxes
*/ */
height?: number; height: number;
/** /**
* Margin around loop boxes * Margin around loop boxes
*/ */
boxMargin?: number; boxMargin: number;
/** /**
* Margin around the text in loop/alt/opt boxes * Margin around the text in loop/alt/opt boxes
*/ */
boxTextMargin?: number; boxTextMargin: number;
/** /**
* Margin around notes * Margin around notes
*/ */
noteMargin?: number; noteMargin: number;
/** /**
* Space between messages. * Space between messages.
*/ */
messageMargin?: number; messageMargin: number;
/** /**
* Multiline message alignment * Multiline message alignment
*/ */
messageAlign?: 'left' | 'center' | 'right'; messageAlign: 'left' | 'center' | 'right';
/** /**
* Mirror actors under diagram * Mirror actors under diagram
* *
*/ */
mirrorActors?: boolean; mirrorActors: boolean;
/** /**
* forces actor popup menus to always be visible (to support E2E testing). * forces actor popup menus to always be visible (to support E2E testing).
* *
*/ */
forceMenus?: boolean; forceMenus: boolean;
/** /**
* Prolongs the edge of the diagram downwards. * Prolongs the edge of the diagram downwards.
* *
* Depending on css styling this might need adjustment. * Depending on css styling this might need adjustment.
* *
*/ */
bottomMarginAdj?: number; bottomMarginAdj: number;
/** /**
* Curved Arrows become Right Angles * Curved Arrows become Right Angles
* *
@@ -1293,51 +1293,51 @@ export interface SequenceDiagramConfig extends BaseDiagramConfig {
* right angles, rather than as curves. * right angles, rather than as curves.
* *
*/ */
rightAngles?: boolean; rightAngles: boolean;
/** /**
* This will show the node numbers * This will show the node numbers
*/ */
showSequenceNumbers?: boolean; showSequenceNumbers: boolean;
/** /**
* This sets the font size of the actor's description * This sets the font size of the actor's description
*/ */
actorFontSize?: string | number; actorFontSize: string | number;
/** /**
* This sets the font family of the actor's description * This sets the font family of the actor's description
*/ */
actorFontFamily?: string; actorFontFamily: string;
/** /**
* This sets the font weight of the actor's description * This sets the font weight of the actor's description
*/ */
actorFontWeight?: string | number; actorFontWeight: string | number;
/** /**
* This sets the font size of actor-attached notes * This sets the font size of actor-attached notes
*/ */
noteFontSize?: string | number; noteFontSize: string | number;
/** /**
* This sets the font family of actor-attached notes * This sets the font family of actor-attached notes
*/ */
noteFontFamily?: string; noteFontFamily: string;
/** /**
* This sets the font weight of actor-attached notes * This sets the font weight of actor-attached notes
*/ */
noteFontWeight?: string | number; noteFontWeight: string | number;
/** /**
* This sets the text alignment of actor-attached notes * This sets the text alignment of actor-attached notes
*/ */
noteAlign?: 'left' | 'center' | 'right'; noteAlign: 'left' | 'center' | 'right';
/** /**
* This sets the font size of actor messages * This sets the font size of actor messages
*/ */
messageFontSize?: string | number; messageFontSize: string | number;
/** /**
* This sets the font family of actor messages * This sets the font family of actor messages
*/ */
messageFontFamily?: string; messageFontFamily: string;
/** /**
* This sets the font weight of actor messages * This sets the font weight of actor messages
*/ */
messageFontWeight?: string | number; messageFontWeight: string | number;
/** /**
* This sets the auto-wrap state for the diagram * This sets the auto-wrap state for the diagram
*/ */
@@ -1368,12 +1368,12 @@ export interface FlowchartDiagramConfig extends BaseDiagramConfig {
/** /**
* Margin top for the text over the diagram * Margin top for the text over the diagram
*/ */
titleTopMargin?: number; titleTopMargin: number;
/** /**
* Defines a top/bottom margin for subgraph titles * Defines a top/bottom margin for subgraph titles
* *
*/ */
subGraphTitleMargin?: { subGraphTitleMargin: {
top?: number; top?: number;
bottom?: number; bottom?: number;
}; };
@@ -1383,12 +1383,12 @@ export interface FlowchartDiagramConfig extends BaseDiagramConfig {
* diagrams have margins, expressed in pixels. * diagrams have margins, expressed in pixels.
* *
*/ */
diagramPadding?: number; diagramPadding: number;
/** /**
* Flag for setting whether or not a html tag should be used for rendering labels on the edges. * Flag for setting whether or not a html tag should be used for rendering labels on the edges.
* *
*/ */
htmlLabels?: boolean; htmlLabels: boolean;
/** /**
* Defines the spacing between nodes on the same level * Defines the spacing between nodes on the same level
* *
@@ -1396,7 +1396,7 @@ export interface FlowchartDiagramConfig extends BaseDiagramConfig {
* and the vertical spacing for LR as well as RL graphs. * and the vertical spacing for LR as well as RL graphs.
* *
*/ */
nodeSpacing?: number; nodeSpacing: number;
/** /**
* Defines the spacing between nodes on different levels * Defines the spacing between nodes on different levels
* *
@@ -1404,12 +1404,12 @@ export interface FlowchartDiagramConfig extends BaseDiagramConfig {
* and the vertical spacing for LR as well as RL graphs. * and the vertical spacing for LR as well as RL graphs.
* *
*/ */
rankSpacing?: number; rankSpacing: number;
/** /**
* Defines how mermaid renders curves for flowcharts. * Defines how mermaid renders curves for flowcharts.
* *
*/ */
curve?: 'basis' | 'linear' | 'cardinal'; curve: 'basis' | 'linear' | 'cardinal';
/** /**
* Represents the padding between the labels and the shape * Represents the padding between the labels and the shape
* *
@@ -1421,7 +1421,7 @@ export interface FlowchartDiagramConfig extends BaseDiagramConfig {
* Decides which rendering engine that is to be used for the rendering. * Decides which rendering engine that is to be used for the rendering.
* *
*/ */
defaultRenderer?: 'dagre-d3' | 'dagre-wrapper' | 'elk'; defaultRenderer: 'dagre-d3' | 'dagre-wrapper' | 'elk';
/** /**
* Width of nodes where text is wrapped. * Width of nodes where text is wrapped.
* *
@@ -1429,7 +1429,7 @@ export interface FlowchartDiagramConfig extends BaseDiagramConfig {
* value sets the max width of a text before it continues on a new line. * value sets the max width of a text before it continues on a new line.
* *
*/ */
wrappingWidth?: number; wrappingWidth: number;
} }
/** /**
* The object containing configurations specific for sankey diagrams. * The object containing configurations specific for sankey diagrams.