Open lastlink opened 1 year ago
maybe related to
+1
@lastlink I have a similar use case, I'm generating Mermaid ERD diagrams to represent data relationships in CSV files: https://github.com/nharsch/mermaid-erd-generator
I'm looking into migrating this from python -> JS (maybe ClojureScript) and using the mermaid library parsers directly in order to getEntities
getRelationships
, etc. That way I could generate SQL output given an ERD string.
Would like to use mermaid internals from the npm module such as detectDirective from utils.ts as well as have the parsers exposed in an ala cart mode. So far it only looks like the mermaidAPI.ts methods are exposed.
My purpose is that I'm trying to create an erdiagram to sql exporter and would like to use mermaid js methods directly for serializing a markdown files and extracting models before the svg is generated.
it's looking like I might have to use mermaid.js as a git submodule b/c the methods aren't exposed in the npm package.
I'm having progress breaking out part, currently stuck on the jison lexer (which I believe I could get the erDiagram models that I need for serializing the sql create table statements).
Current Progress: (done)
success on getting erdiagram diagram,
got jison parser working
dist\mermaid.core.mjs
build and required it.export const registerDiagram = ( id: string, diagram: DiagramDefinition, detector: DiagramDetector ) => { if (diagrams[id]) { log.warn(
Diagram ${id} already registered.
); } diagram.parser.yy = diagram.db; diagrams[id] = diagram; addDetector(id, detector); }; registerDiagram( "er", { parser: parser, db: erDb, }, erDetector );// implementation var r = diag.parser.parse(md); var entities = diag.db.getEntities(); var relationships = diag.db.getRelationships();