Giter Club home page Giter Club logo

floorplan's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

floorplan's Issues

Add support for column default values parsing

So far, dbml-parser doesn't properly handle column defaults defined in DBML, as such:

Table users {
    id integer [primary key]
    username varchar(255) [not null, unique]
    full_name varchar(255) [not null]
    gender varchar(1) [default: 'm']
    created_at timestamp [default: `now()`]
    rating integer [default: 10]
}

You can set default value as:

number value starts blank: default: 123 or default: 123.456
string value starts with single quotes: default: 'some string value'
expression value is wrapped with parenthesis: default: now() - interval '5 days'``
boolean (true/false/null): default: false or `default: null`

brew install not work anymore

I used to use floorplan-cli through Github Actions which worked well (thanks for your amazing work).

      - name: Install floorplan
        run: brew install julioz/tap/floorplan

For some months now, it's not working anymore, I get this error (also in local):

prompt ~ brew install julioz/tap/floorplan   
Error: julioz/tap/floorplan: wrong number of arguments (given 1, expected 0)

Does something change about the brew tap ? Does I have still the good path to floorplan ? I did not see any changes on the documentation

Thanks for your help

Floor plan Gradle Plugin

This would be cool as a Gradle Plugin to automatically find the latest Room schema files instead of having to pass their file path.

Optionally render nullable type

Instead of relying on the field note feature in DBML, we can also allow for static rendering of the ER diagrams in combination with nullable types by appending a marker to the type definition.

According to DBML's schema, we can append a (?) text suffix to the data types when they are nullable.

So, for example, when a command line argument is passed, FloorPlan can render

varchar(?)

for a nullable TEXT Room field.

Screenshot 2020-04-07 at 13 45 05

Change `output` in CLI arguments to point in directory

With the multi-output support planned for #45, running the CLI for FloorPlan with

./gradlew run --args="../samples/tivi-26.json --format=dbml,svg,png,dot --output=multi-test/a"

becomes cumbersome, since we are forced to specify a file (and its name) through the --output argument. We should change that to be in par with the Gradle Plugin, and instead expect a directory for the output. We can then reuse the input file name as the output files naming.

Support more data types

Currently, only INTEGER and TEXT types are translated; we need to add support for more of Room data type definitions, including dates, blobs and etc.

Associated resources:

SQLite Data types

SQL Data Types:

alt text

Remove duplication between `dbml-parser` and `core`

Pull out DBML model classes into shared module that Room translator can depend on, in that way we can rely on a single definition of the DBML models across all modules of the codebase.

Potentially rename :core to something specific to Room, since we want to allow for other input formats (see for example: #19).

Revamp CLI to use Clikt

Clikt (pronounced “clicked”) is a multiplatform Kotlin library that makes writing command line interfaces simple and intuitive. It’s the “Command Line Interface for Kotlin”.

https://ajalt.github.io/clikt/

By using clikt, we can simplify the floorplan-cli module. On top of that, we get some general command-line standardisation and potential for more features.

Gradle Plugin: Preserve directory structure

Output files stored within directories and preserve structure

  • For example, <input_dir>/com.mypackage.mydatabase/1.json should end up as <output_dir>/com.mypackage.mydatabase/1.dbml

IntelliJ plug-in

As an idea, would it be interesting to have an IntelliJ Plug-in, in which we can provide a way to run FloorPlan as an action in the IDE?

The Plug-in can detect file types that can be consumed by FloorPlan and provide a menu action / gutter action to generate the database schema in SVG/PNG and automatically render that in a new IDE tab.

Here is a great talk (slides) introducing the APIs and good sample projects to take inspiration from.

Optionally annotate tables with creation SQL

Add DBML table notes using the creation SQL script exposed by Room's exported schema.

This should be toggled as an optionally enabled command line argument since SQL can be quite verbose and would in anycase 'duplicate' what the UI rendering for the DBML potentially is.

Use the Provider API for the Gradle Plugin properties

Try out the Provider API

  • Example
  • instead of String for the directory we can declare the field as DirectoryProperty and then to pass it, use something like project.layout.projectDirectory.dir("schemas"), so that the actual file will be resolved when the task runs

Can the gradle plugin process DBML files as an input?

In short: can the gradle plugin be told to skip the json-consumption part and process dbml input files?

I've been able to get the CLI to process DBML files as an input just fine

git clone [email protected]:julioz/FloorPlan.git   
git checkout tags/v0.3
./gradlew run --args="/home/daniel/Downloads/sample.dbml --format=dbml,svg,png,dot --output /home/daniel/workspaces/plaything/FloorPlan/oot --notation crowsfoot" 

But I can't get the gradle plugin to do this. My build.gradle is as follows

(using gradle wrapper; distributionUrl=https://services.gradle.org/distributions/gradle-6.6-bin.zip)


buildscript {
    repositories {
        google()
        jcenter()
    }

}
plugins {   
    id "base"
    id "com.juliozynger.floorplan" version "0.3"
}

floorPlan {
    schemaLocation = "$projectDir/schemas".toString()
    outputLocation = "$projectDir/schema-diagrams".toString()
    notation = "crowsfoot"
    outputFormat {     
        dbml {
            enabled = true
            creationSqlAsTableNote = false
            renderNullableFields = true
        }        
        svg {
            enabled = true
        }
        dot {
            enabled = true
        }                
    }
}

I can see in the logs it's saying

FloorPlan could not find any schema in specified location /home/daniel/workspaces/plaything/dbml-renderer/schemas

I think, because, the underlying FloorPlanConsumerSniffer only accepts json / db files.

This page here https://julioz.github.io/FloorPlan says this:

DBML parser
With a few manual tweaks, DBML can also be used directly as an input to the rendering mechanism, by skipping the pipeline's JSON-consumption step.

I can't see how the gradle plugin can be told to skip the json-consumption part, can it?

Thanks.

Add support for Index parsing

So far, dbml-parser doesn't properly handle indexes defined in DBML tables, as such:

Table bookings {
  id integer
  country varchar
  booking_date date
  created_at timestamp

  indexes {
      (id, country) [pk] // composite primary key
      created_at [note: 'Date']
      booking_date
      (country, booking_date) [unique]
      booking_date [type: hash]
      (`id*2`)
      (`id*3`,`getdate()`)
      (`id*3`,id)
  }
}

There are 3 types of index definitions:

Index with single field (with index name): CREATE INDEX on users (created_at)
Index with multiple fields (composite index): CREATE INDEX on users (created_at, country)
Index with an expression: CREATE INDEX ON films ( first_name + last_name )
(bonus) Composite index with expression: CREATE INDEX ON users ( country, (lower(name)) )

Build version on CLI

Running

floorplan-cli -v

or

floorplan-cli --version

should output the version that was used to compile the build

Multi format output

Currently, FloorPlan only allows for outputting one format at a time.
We want to enable multi format output, so that users can mix-and-match renderings as they seem fit.

The gradle plugin interface will then allow for multiple output enablement:

floorPlan {
  schemaLocation = ...
  outputLocation = ...
  outputFormat {
    dbml {
      enabled = true
    }
    svg {
      enabled = true
    }
  }
}

The CLI interface needs to also be rethought, to extend the --format argument to receive a List instead of a String. The curious bit is how we can make "nested arguments", given DBML can receive its own sub-parameters for rendering.

Known vulnerabilities in shared library which floorplan-gradle-plugin depends on. Can you help upgrade to patch versions?

Hi, @julioz , @tomasz-moscicki-sonalake , I'd like to report a vulnerability issue in com.juliozynger.floorplan:floorplan-gradle-plugin:0.4.

Issue Description

com.juliozynger.floorplan:floorplan-gradle-plugin:0.4 directly or transitively depends on 26 C libraries (.so) cross many platforms(such as x86-64, x86, arm64, armhf). However, I noticed that one C library is vulnerable, containing the following CVEs:

libj2v8_linux_x86_64.so from C project openssl(version:1.0.2g) exposed 10 vulnerabilities:
CVE-2021-3712, CVE-2020-1968, CVE-2016-8610, CVE-2016-2182, CVE-2016-2181, CVE-2016-2179, CVE-2016-6302, CVE-2016-6303, CVE-2017-3738, CVE-2019-1552

Furthermore, the vulnerable methods in these vulnerable shared libraries can be actually invoked by Java code.
For instance, the following call chain starting from SSL_CTX_load_verify_locations() can reach the vulnerable method EC_GROUP_new_from_ecparameters() <EC_GROUP *EC_GROUP_new_from_ecparameters (const ECPARAMETERS *params) in crypto/ec/ec_asn1.c reported by CVE-2021-3712:

call chain -----
SSL_CTX_load_verify_locations() -> X509_STORE_load_locations() -> X509_STORE_add_lookup() -> STACK_OF() -> PEM_X509_INFO_read_bio() -> d2i_ECPrivateKey() -> EC_GROUP_new_from_ecpkparameters() -> EC_GROUP_new_from_ecparameters()

Suggested Vulnerability Patch Versions

openssl has fixed the vulnerabilities in versions >=1.1.1l

Java build tools cannot report vulnerable C libraries, which may induce potential security issues to many downstream Java projects.
Could you please upgrade the above shared libraries to their patch versions?

Thanks for your help~
Best regards,
Helen Parr

Ingest SQLDelight schemas

Besides Room, another popular library used in the Android ecosystem is SQLDelight. If we can generate schemas (or parse the .sq files) to use as input for generating DBML, we can increase the applicability of FloorPlan.

Write output to file

Instead of printing the conversion output, passing an output file path argument to the program will write the DBML result to disk.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.