refactor!: remove MermaidConfig type enum fallback

Currently (in Mermaid v10), pretty much all enum types in the
MermaidConfig have generic `string` or `number` fallbacks,
for backwards compatibility.

This commit drops this. The MermaidConfig TypeScript types now expects
a limited amount of values.

BREAKING-CHANGE: Remove `MermaidConfig` generic type fallbacks for
                 enum values.
This commit is contained in:
Alois Klink 2023-09-02 19:25:29 +01:00
parent 77ba7c987a
commit b48136d994
2 changed files with 13 additions and 49 deletions

View File

@ -61,7 +61,7 @@ export interface MermaidConfig {
* You may also use `themeCSS` to override this value. * You may also use `themeCSS` to override this value.
* *
*/ */
theme?: string | 'default' | 'forest' | 'dark' | 'neutral' | 'null'; theme?: 'default' | 'forest' | 'dark' | 'neutral' | 'null';
themeVariables?: any; themeVariables?: any;
themeCSS?: string; themeCSS?: string;
/** /**
@ -82,26 +82,11 @@ export interface MermaidConfig {
* 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?: logLevel?: 'trace' | 0 | 'debug' | 1 | 'info' | 2 | 'warn' | 3 | 'error' | 4 | 'fatal' | 5;
| number
| string
| 0
| 2
| 1
| 'trace'
| 'debug'
| 'info'
| 'warn'
| 'error'
| 'fatal'
| 3
| 4
| 5
| undefined;
/** /**
* Level of trust for parsed diagram * Level of trust for parsed diagram
*/ */
securityLevel?: string | 'strict' | 'loose' | 'antiscript' | 'sandbox' | undefined; securityLevel?: 'strict' | 'loose' | 'antiscript' | 'sandbox';
/** /**
* Dictates whether mermaid starts on Page load * Dictates whether mermaid starts on Page load
*/ */
@ -723,7 +708,7 @@ export interface ErDiagramConfig extends BaseDiagramConfig {
/** /**
* Directional bias for layout of entities * Directional bias for layout of entities
*/ */
layoutDirection?: string | '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.
*/ */
@ -788,7 +773,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?: string | '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
@ -812,7 +797,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?: string | 'dagre-d3' | 'dagre-wrapper' | 'elk'; defaultRenderer?: 'dagre-d3' | 'dagre-wrapper' | 'elk';
nodeSpacing?: number; nodeSpacing?: number;
rankSpacing?: number; rankSpacing?: number;
/** /**
@ -872,7 +857,7 @@ export interface JourneyDiagramConfig extends BaseDiagramConfig {
/** /**
* Multiline message alignment * Multiline message alignment
*/ */
messageAlign?: string | 'left' | 'center' | 'right'; messageAlign?: 'left' | 'center' | 'right';
/** /**
* Prolongs the edge of the diagram downwards. * Prolongs the edge of the diagram downwards.
* *
@ -951,7 +936,7 @@ export interface TimelineDiagramConfig extends BaseDiagramConfig {
/** /**
* Multiline message alignment * Multiline message alignment
*/ */
messageAlign?: string | 'left' | 'center' | 'right'; messageAlign?: 'left' | 'center' | 'right';
/** /**
* Prolongs the edge of the diagram downwards. * Prolongs the edge of the diagram downwards.
* *
@ -1062,7 +1047,7 @@ export interface GanttDiagramConfig extends BaseDiagramConfig {
* Controls the display mode. * Controls the display mode.
* *
*/ */
displayMode?: string | 'compact'; displayMode?: '' | 'compact';
/** /**
* On which day a week-based interval should start * On which day a week-based interval should start
* *
@ -1121,7 +1106,7 @@ export interface SequenceDiagramConfig extends BaseDiagramConfig {
/** /**
* Multiline message alignment * Multiline message alignment
*/ */
messageAlign?: string | 'left' | 'center' | 'right'; messageAlign?: 'left' | 'center' | 'right';
/** /**
* Mirror actors under diagram * Mirror actors under diagram
* *
@ -1178,7 +1163,7 @@ export interface SequenceDiagramConfig extends BaseDiagramConfig {
/** /**
* This sets the text alignment of actor-attached notes * This sets the text alignment of actor-attached notes
*/ */
noteAlign?: string | 'left' | 'center' | 'right'; noteAlign?: 'left' | 'center' | 'right';
/** /**
* This sets the font size of actor messages * This sets the font size of actor messages
*/ */
@ -1254,7 +1239,7 @@ export interface FlowchartDiagramConfig extends BaseDiagramConfig {
* Defines how mermaid renders curves for flowcharts. * Defines how mermaid renders curves for flowcharts.
* *
*/ */
curve?: string | '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
* *
@ -1266,7 +1251,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?: string | '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.
* *

View File

@ -63,8 +63,6 @@ properties:
meta:enum: meta:enum:
'null': Can be set to disable any pre-defined mermaid theme 'null': Can be set to disable any pre-defined mermaid theme
default: 'default' default: 'default'
# Allow any string for typescript backwards compatibility (fix in Mermaid v10)
tsType: 'string | "default" | "forest" | "dark" | "neutral" | "null"'
themeVariables: themeVariables:
tsType: any tsType: any
themeCSS: themeCSS:
@ -115,8 +113,6 @@ properties:
error: Equivalent to 4 error: Equivalent to 4
fatal: Equivalent to 5 (default) fatal: Equivalent to 5 (default)
default: 5 default: 5
# Allow any number or string for typescript backwards compatibility (fix in Mermaid v10)
tsType: 'number | string | 0 | 2 | 1 | "trace" | "debug" | "info" | "warn" | "error" | "fatal" | 3 | 4 | 5 | undefined'
securityLevel: securityLevel:
description: Level of trust for parsed diagram description: Level of trust for parsed diagram
type: string type: string
@ -134,8 +130,6 @@ properties:
This prevent any JavaScript from running in the context. This prevent any JavaScript from running in the context.
This may hinder interactive functionality of the diagram, like scripts, popups in the sequence diagram, or links to other tabs or targets, etc. This may hinder interactive functionality of the diagram, like scripts, popups in the sequence diagram, or links to other tabs or targets, etc.
default: strict default: strict
# Allow any string for typescript backwards compatibility (fix in Mermaid v10)
tsType: 'string | "strict" | "loose" | "antiscript" | "sandbox" | undefined'
startOnLoad: startOnLoad:
description: Dictates whether mermaid starts on Page load description: Dictates whether mermaid starts on Page load
type: boolean type: boolean
@ -1021,8 +1015,6 @@ $defs: # JSON Schema definition (maybe we should move these to a seperate file)
LR: Left-Right LR: Left-Right
RL: Right to Left RL: Right to Left
default: TB default: TB
# Allow any string for typescript backwards compatibility (fix in Mermaid v10)
tsType: 'string | "TB" | "BT" | "LR" | "RL"'
minEntityWidth: minEntityWidth:
description: The minimum width of an entity box. Expressed in pixels. description: The minimum width of an entity box. Expressed in pixels.
type: integer type: integer
@ -1135,8 +1127,6 @@ $defs: # JSON Schema definition (maybe we should move these to a seperate file)
dagre-d3: The [dagre-d3-es](https://www.npmjs.com/package/dagre-d3-es) library. dagre-d3: The [dagre-d3-es](https://www.npmjs.com/package/dagre-d3-es) library.
dagre-wrapper: wrapper for dagre implemented in mermaid dagre-wrapper: wrapper for dagre implemented in mermaid
elk: Layout using [elkjs](https://github.com/kieler/elkjs) elk: Layout using [elkjs](https://github.com/kieler/elkjs)
# Allow any string for typescript backwards compatibility (fix in Mermaid v10)
tsType: 'string | "dagre-d3" | "dagre-wrapper" | "elk"'
ClassDiagramConfig: ClassDiagramConfig:
title: Class Diagram Config title: Class Diagram Config
@ -1252,8 +1242,6 @@ $defs: # JSON Schema definition (maybe we should move these to a seperate file)
- center - center
- right - right
default: center default: center
# Allow any string for typescript backwards compatibility (fix in Mermaid v10)
tsType: 'string | "left" | "center" | "right"'
bottomMarginAdj: bottomMarginAdj:
description: | description: |
Prolongs the edge of the diagram downwards. Prolongs the edge of the diagram downwards.
@ -1378,8 +1366,6 @@ $defs: # JSON Schema definition (maybe we should move these to a seperate file)
- center - center
- right - right
default: center default: center
# Allow any string for typescript backwards compatibility (fix in Mermaid v10)
tsType: 'string | "left" | "center" | "right"'
bottomMarginAdj: bottomMarginAdj:
description: | description: |
Prolongs the edge of the diagram downwards. Prolongs the edge of the diagram downwards.
@ -1543,13 +1529,10 @@ $defs: # JSON Schema definition (maybe we should move these to a seperate file)
meta:enum: meta:enum:
compact: Enables displaying multiple tasks on the same row. compact: Enables displaying multiple tasks on the same row.
default: '' default: ''
# Allow any string for typescript backwards compatibility (fix in Mermaid v10)
tsType: 'string | "compact"'
weekday: weekday:
description: | description: |
On which day a week-based interval should start On which day a week-based interval should start
type: string type: string
tsType: '"monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday" | "sunday"'
enum: enum:
- monday - monday
- tuesday - tuesday
@ -1691,8 +1674,6 @@ $defs: # JSON Schema definition (maybe we should move these to a seperate file)
type: string type: string
enum: ['left', 'center', 'right'] enum: ['left', 'center', 'right']
default: 'center' default: 'center'
# Allow any string for typescript backwards compatibility (fix in Mermaid v10)
tsType: 'string | "left" | "center" | "right"'
messageFontSize: messageFontSize:
description: This sets the font size of actor messages description: This sets the font size of actor messages
@ -1780,8 +1761,6 @@ $defs: # JSON Schema definition (maybe we should move these to a seperate file)
type: string type: string
enum: ['basis', 'linear', 'cardinal'] enum: ['basis', 'linear', 'cardinal']
default: 'basis' default: 'basis'
# Allow any string for typescript backwards compatibility (fix in Mermaid v10)
tsType: 'string | "basis" | "linear" | "cardinal"'
padding: padding:
description: | description: |
Represents the padding between the labels and the shape Represents the padding between the labels and the shape