db-schema-visualizer icon indicating copy to clipboard operation
db-schema-visualizer copied to clipboard

Add support for AML language

Open loicknuchel opened this issue 1 year ago • 5 comments

Hi :wave:

I'm the creator of Azimutt, a database exploration tool using AML for the design part (similar to dbdiagram/DBML) and finally took time to create a VS Code extension for AML. That's when I found your extension that is 1. very nice (much more than the others I tried) and 2. already handles DBML and Prisma, being modular in term of source language. I was in the process to add a visualization panel to my extension but now I'm thinking I could focus on the editing experience (suggestions, go-to-definition...) and rely on yours for the visualization, both extension could reference each other.

If you want to have a look, AML is published as a npm package and you can already try it in online editors or in Azimutt.

What do you think?

loicknuchel avatar Nov 25 '24 16:11 loicknuchel

Hi @loicknuchel !

It's a pleasure to read you. I know Azimutt and its beautiful UI inspire the UI of this extension(s) ( the diagram ). Thank you a lot.

I get it. Indeed, this project is built in a way to easily support another DSL. Of course, we can do it. The idea behind this project is to provide a visualizer for as many DSLs as possible.

I toke a look at AML and there is possible to covert it to JSON. And that is the necessary to power a visualization extension using this project.

Let's do it 🚀 .

BOCOVO avatar Nov 27 '24 21:11 BOCOVO

Hi @BOCOVO

Awesome! Glad you already know Azimutt and loved its UI :smile:

Very happy you are ready for this. How do you plan the next steps? Do you need anything from me?

PS: if you want to support as many DSLs as possible, you can even add PostgreSQL with Azimutt SQL parser ;)

loicknuchel avatar Nov 28 '24 10:11 loicknuchel

Hi @loicknuchel ! Hope you are doing great.

Sorry for the delay in my response.

Here are the next steps

  1. Understanding the AML parser result in order to know how to convert it to the common parsing structure of this project
  2. Write the necessary code to convert the AML parser result to the common parsing structure of this project.
  3. Create and publish the extension

I began the first, looking at the docs. I'll certainly need your help on the second task. I'm going to let you know. I plan to make a few fixes to the projet this month and the new plugin ( AML's ) will be release in this month too.

You are doing a great job 🔥 . After the AML plugin creation with the SQL parser we can easily ship a PostgreSQL preview extension.

BOCOVO avatar Dec 01 '24 22:12 BOCOVO

Hey! Happy to hear that.

On the AML side it's quite easy (I believe).

  1. Add the @azimutt/aml to your project
  2. Use the parseAml(content: string): ParserResult<Database>. Check ParserResult and Database definitions.

Your conversion code will look like this:

const res = parseAml(content)
if (res.errors) res.errors.map(e => console.log('error', e))
if (res.result) {
  const db = res.result
  (db.entities || []).map(entity => {
    // TODO
    (entity.attrs || []).map(attr => {
      // TODO
    })
  })
  (db.relations || []).map(relation => {
    // TODO
  })
}

@azimutt/parser-sql is similar with parseSql(content: string, dialect: 'postgres'): ParserResult<Database>. There is several dialects available but only the 'postgres' one is good enough ^^

So it will be mostly the same between AML and SQL.

Let me know if you have more questions or need help for this. I can even make adjustments in libs (on code or doc) to help if needed, let me know.

loicknuchel avatar Dec 02 '24 10:12 loicknuchel

Hello @loicknuchel !

Thank you for the insights.

Good, I'll let you know if needed.

BOCOVO avatar Dec 02 '24 10:12 BOCOVO