mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
68.69k stars 6.07k forks source link

Align generated MermaidConfig with schema #5515

Open sidharthv96 opened 1 month ago

sidharthv96 commented 1 month ago

:bookmark_tabs: Summary

This matches the generated MermaidConfig type with the schema.

Previously, we were removing required to make all fields optional.

Now, we're using a PartialMermaidConfig type using PartialDeep instead.

:straight_ruler: Design Decisions

Few alternatives considered.

  1. Use RequiredDeep internally Abandoned, as some types in the schema are actually undefined. So using RequiredDeep will cause runtime errors.

  2. Change all fields inside schema to not have undefined. Abandoned as it'll be a HUGE change, pulling in default values that are scattered throughout the code. This should be done later, and this PR can be considered as the first step to remove unnecessary default variables inside the code. This would also remove the ability of the authors to actually have undefined if they wanted to in the schema.

  3. Match Generated type with Schema, create fully optional type for external use.

Avoids all the problems above, we just need to coerce some test types internally, which is fine, as the test would fail if there are any issues.

Currently, there is a breaking change, that the type names differ. We can switch the names, so that MermaidConfig will be the exported type which has fully partial props.

Didn't do it now, as that would mean a larger diff, making it harder to review.

:clipboard: Tasks

Make sure you

netlify[bot] commented 1 month ago

Deploy Preview for mermaid-js ready!

Name Link
Latest commit ea7d28bf1c91fdd0e7cf93dcd67224d3cb29ca23
Latest deploy log https://app.netlify.com/sites/mermaid-js/deploys/664e38e01000e6000859f9e2
Deploy Preview https://deploy-preview-5515--mermaid-js.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 31.50685% with 50 lines in your changes are missing coverage. Please review.

Project coverage is 5.74%. Comparing base (0326d89) to head (159d85e). Report is 46 commits behind head on develop.

:exclamation: Current head 159d85e differs from pull request most recent head ea7d28b

Please upload reports for the commit ea7d28b to get more accurate results.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/mermaid-js/mermaid/pull/5515/graphs/tree.svg?width=650&height=150&src=pr&token=BaET4V1BdM&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mermaid-js)](https://app.codecov.io/gh/mermaid-js/mermaid/pull/5515?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mermaid-js) ```diff @@ Coverage Diff @@ ## develop #5515 +/- ## ======================================= Coverage 5.74% 5.74% ======================================= Files 277 277 Lines 41967 41955 -12 Branches 515 515 ======================================= Hits 2409 2409 + Misses 39558 39546 -12 ``` | [Flag](https://app.codecov.io/gh/mermaid-js/mermaid/pull/5515/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mermaid-js) | Coverage Δ | | |---|---|---| | [unit](https://app.codecov.io/gh/mermaid-js/mermaid/pull/5515/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mermaid-js) | `5.74% <31.50%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mermaid-js#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/mermaid-js/mermaid/pull/5515?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mermaid-js) | Coverage Δ | | |---|---|---| | [packages/mermaid/src/diagram-api/detectType.ts](https://app.codecov.io/gh/mermaid-js/mermaid/pull/5515?src=pr&el=tree&filepath=packages%2Fmermaid%2Fsrc%2Fdiagram-api%2FdetectType.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mermaid-js#diff-cGFja2FnZXMvbWVybWFpZC9zcmMvZGlhZ3JhbS1hcGkvZGV0ZWN0VHlwZS50cw==) | `67.07% <100.00%> (ø)` | | | [packages/mermaid/src/utils/subGraphTitleMargins.ts](https://app.codecov.io/gh/mermaid-js/mermaid/pull/5515?src=pr&el=tree&filepath=packages%2Fmermaid%2Fsrc%2Futils%2FsubGraphTitleMargins.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mermaid-js#diff-cGFja2FnZXMvbWVybWFpZC9zcmMvdXRpbHMvc3ViR3JhcGhUaXRsZU1hcmdpbnMudHM=) | `0.00% <0.00%> (ø)` | | | [packages/mermaid/src/diagram-api/frontmatter.ts](https://app.codecov.io/gh/mermaid-js/mermaid/pull/5515?src=pr&el=tree&filepath=packages%2Fmermaid%2Fsrc%2Fdiagram-api%2Ffrontmatter.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mermaid-js#diff-cGFja2FnZXMvbWVybWFpZC9zcmMvZGlhZ3JhbS1hcGkvZnJvbnRtYXR0ZXIudHM=) | `0.00% <0.00%> (ø)` | | | [packages/mermaid/src/preprocess.ts](https://app.codecov.io/gh/mermaid-js/mermaid/pull/5515?src=pr&el=tree&filepath=packages%2Fmermaid%2Fsrc%2Fpreprocess.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mermaid-js#diff-cGFja2FnZXMvbWVybWFpZC9zcmMvcHJlcHJvY2Vzcy50cw==) | `0.00% <0.00%> (ø)` | | | [.../mermaid/scripts/create-types-from-json-schema.mts](https://app.codecov.io/gh/mermaid-js/mermaid/pull/5515?src=pr&el=tree&filepath=packages%2Fmermaid%2Fscripts%2Fcreate-types-from-json-schema.mts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mermaid-js#diff-cGFja2FnZXMvbWVybWFpZC9zY3JpcHRzL2NyZWF0ZS10eXBlcy1mcm9tLWpzb24tc2NoZW1hLm10cw==) | `0.00% <0.00%> (ø)` | | | [packages/mermaid/src/config.ts](https://app.codecov.io/gh/mermaid-js/mermaid/pull/5515?src=pr&el=tree&filepath=packages%2Fmermaid%2Fsrc%2Fconfig.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mermaid-js#diff-cGFja2FnZXMvbWVybWFpZC9zcmMvY29uZmlnLnRz) | `51.60% <73.33%> (-0.63%)` | :arrow_down: | | [packages/mermaid/src/diagrams/c4/c4Diagram.ts](https://app.codecov.io/gh/mermaid-js/mermaid/pull/5515?src=pr&el=tree&filepath=packages%2Fmermaid%2Fsrc%2Fdiagrams%2Fc4%2Fc4Diagram.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mermaid-js#diff-cGFja2FnZXMvbWVybWFpZC9zcmMvZGlhZ3JhbXMvYzQvYzREaWFncmFtLnRz) | `0.00% <0.00%> (ø)` | | | [...s/mermaid/src/diagrams/flowchart/flowDiagram-v2.ts](https://app.codecov.io/gh/mermaid-js/mermaid/pull/5515?src=pr&el=tree&filepath=packages%2Fmermaid%2Fsrc%2Fdiagrams%2Fflowchart%2FflowDiagram-v2.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mermaid-js#diff-cGFja2FnZXMvbWVybWFpZC9zcmMvZGlhZ3JhbXMvZmxvd2NoYXJ0L2Zsb3dEaWFncmFtLXYyLnRz) | `0.00% <0.00%> (ø)` | | | [...ages/mermaid/src/diagrams/flowchart/flowDiagram.ts](https://app.codecov.io/gh/mermaid-js/mermaid/pull/5515?src=pr&el=tree&filepath=packages%2Fmermaid%2Fsrc%2Fdiagrams%2Fflowchart%2FflowDiagram.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mermaid-js#diff-cGFja2FnZXMvbWVybWFpZC9zcmMvZGlhZ3JhbXMvZmxvd2NoYXJ0L2Zsb3dEaWFncmFtLnRz) | `0.00% <0.00%> (ø)` | | | [packages/mermaid/src/utils.ts](https://app.codecov.io/gh/mermaid-js/mermaid/pull/5515?src=pr&el=tree&filepath=packages%2Fmermaid%2Fsrc%2Futils.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mermaid-js#diff-cGFja2FnZXMvbWVybWFpZC9zcmMvdXRpbHMudHM=) | `41.60% <62.50%> (ø)` | | | ... and [2 more](https://app.codecov.io/gh/mermaid-js/mermaid/pull/5515?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mermaid-js) | |