eugene-manuilov / typeorm-uml Goto Github PK
View Code? Open in Web Editor NEWGenerate Entity Relationship diagrams for Typeorm powered projects.
License: MIT License
Generate Entity Relationship diagrams for Typeorm powered projects.
License: MIT License
Hi, I generated a uml for my project, there are quite a lot of entities so the right side of the diagram was cut off.
I found a thread in PlantUML's forum where a parameter PLANTUML_LIMIT_SIZE
can be set up.
Is it possible to specify this option here?
It would be nice to include in the generated diagrams the (non-)nullability of some columns.
Hi,
Currently the plantuml server url is hardcoded, meaning we can only use the official plantuml server to generate diagrams:
From a security point-of-view, sending a whole database structure to an external server so that it generates a diagram is not a good practice.
There are ways of hosting a plantuml server (eg. using this docker image)
Once hosted, it can be made available on any custom url - may it be accessible on the world wide web or just within an internal infrastructure.
In order for such a custom server to be supported by this library, it would be nice to be able to specify the plantuml server url as an optional flag.
--plantuml-url: string
(default: http://www.plantuml.com/plantuml
)
Feel free to take the pull request into consideration
Do you think that we can use this tool to generate entity relationship diagrams as well? 👀
Since typeorm supports .ts
file for configuring ORM, is it possible to generate the ER diagram from that file too.. or just json file is supported.
I read about typeorm on some stackoverflow post.
I don't know why I am not able to install the package from npm. At same time I can install other packages with ease
Here is sinppet, I am using windows 10.
F:\rushikesh\website\maths163>npm install -D typeorm-uml
npm ERR! Unexpected end of JSON input while parsing near '...s://registry.npmjs.or'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\rushi\AppData\Roaming\npm-cache\_logs\2020-07-17T05_10_27_174Z-debug.log
Here is another command I tried
F:\rushikesh\website\maths163>npm install typeorm-uml
npm ERR! Unexpected end of JSON input while parsing near '...s://registry.npmjs.or'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\rushi\AppData\Roaming\npm-cache\_logs\2020-07-17T05_10_41_177Z-debug.log```
When using absolute path
for importing entities, I get the following error:
› Error: Cannot find module 'src/category/entities/category.entity'
› Require stack:
› - /usr/src/app/src/photo/entities/photo.entity.ts
› - /usr/src/app/node_modules/typeorm/util/DirectoryExportedClassesLoader.js
› - /usr/src/app/node_modules/typeorm/connection/ConnectionMetadataBuilder.js
› - /usr/src/app/node_modules/typeorm/connection/Connection.js
› - /usr/src/app/node_modules/typeorm/connection/ConnectionManager.js
› - /usr/src/app/node_modules/typeorm/index.js
› - /usr/src/app/node_modules/typeorm-uml/lib/TypeormUmlCommand.js
› - /usr/src/app/node_modules/typeorm-uml/bin/run
This is how I am importing category
import { CategoryEntity } from 'src/module-1/entities/category.entity';
I have not found a way to resolve this and the only way these works is using relative paths. Is it possible to have support for using absolute paths when importing entities?
Good job on the project @eugene-manuilov .
I appreciate you check OneToOne
relations. The arrows in diagram behave like ManyToOne
relation.
Example:
@OneToOne(() => StandardName, {
eager: true,
onDelete: "SET NULL"
})
@JoinColumn()
standardName!: StandardName;
In UML I have:
Actually the arrows should be -|---------
Fields using timestamptz
are being translated to TIMESTAMP WITHOUT TIMEZONE
. However, timestamptz
is an abbreviation for TIMESTAMP WITH TIMEZONE
: https://www.postgresql.org/docs/current/datatype-datetime.html
[redacted]\node_modules\.bin\typeorm-uml:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at main ([redacted]\node_modules\ts-node\src\bin.ts:198:14)
at Object.<anonymous> ([redacted]\node_modules\ts-node\src\bin.ts:288:3)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
what is going on here? is this my fault? could not figure it out...
Hi again,
The default plantuml url should probably be http://www.plantuml.com/plantuml
(http, not https)
With the current default, executing new TypeormUml().build(...)
produces the following error:
(node:12798) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"
at new ClientRequest (_http_client.js:155:11)
at request (http.js:50:10)
at Object.get (http.js:54:15)
at /myproject/node_modules/typeorm-uml/lib/builder/typeorm-uml.class.js:63:20
To be noted that when accessing http://www.plantuml.com/plantuml or https://www.plantuml.com/plantuml in a browser (chrome at least), it shows up 'Not Secure' in the status bar.
Hi,
I am trying to use your package to generate my diagram.
since my entities are using *.ts , I am using the following command :
ts-node ./node_modules/typeorm-uml/bin/run ormconfig.json --download=diagram.puml--format=puml
@startuml
!define table(x) class x << (T,#FFAAAA) >>
!define pkey(x) <b>x</b>
hide stereotypes
hide fields
@enduml
which render an empty png
Am I doing something wrong ?
I'm doing this on windows.
I know that the semver range below covers the v0.3.0 that was just released
Lines 66 to 67 in 583708a
but I'm not sure if typeorm-uml
will keeping working if I upgrade my typeorm
(which I cannot do for now)
Please, read this when you have time: https://github.com/typeorm/typeorm/releases/tag/0.3.0 and close this issue if you know that typeorm-urml
won't break if we use [email protected]
Since download and direction options have the same short option (-d
), I think you should rename the latest added one to disambiguate this. What about -D
?
What about add the --direction
option to allow us specify a connection direction?
--direction [default: TB] Arrows directions. TB=top to bottom, LR=left to right.
basically append the string 'left to right direction\n'
or 'top to bottom direction\n'
after '@startuml\n'
Lines 25 to 27 in 2eaa700
With DEBUG I do not really get anything useful
serge@test-pierre:~/eve/MyProject$ typeorm-uml
@oclif/config reading core plugin /usr/local/lib/node_modules/typeorm-uml +0ms
@oclif/config loadJSON /usr/local/lib/node_modules/typeorm-uml/package.json +0ms
@oclif/config loadJSON /usr/local/lib/node_modules/typeorm-uml/oclif.manifest.json +20ms
(node:28273) Error Plugin: typeorm-uml: files attribute must be specified in /usr/local/lib/node_modules/typeorm-uml/package.json
module: @oclif/[email protected]
plugin: typeorm-uml
root: /usr/local/lib/node_modules/typeorm-uml
See more details with DEBUG=*
Error Plugin: typeorm-uml: files attribute must be specified in /usr/local/lib/node_modules/typeorm-uml/package.json
at Plugin.warn (/usr/local/lib/node_modules/typeorm-uml/node_modules/@oclif/config/lib/plugin.js:243:19)
at Plugin.load (/usr/local/lib/node_modules/typeorm-uml/node_modules/@oclif/config/lib/plugin.js:100:18)
at <anonymous>
module: @oclif/[email protected]
plugin: typeorm-uml
root: /usr/local/lib/node_modules/typeorm-uml
See more details with DEBUG=*
@oclif/config loadJSON /usr/local/lib/node_modules/typeorm-uml/.oclif.manifest.json +0ms
@oclif/config reading user plugins pjson /home/serge/.local/share/typeorm-uml/package.json +0ms
@oclif/config loadJSON /home/serge/.local/share/typeorm-uml/package.json +1ms
@oclif/config config done +1ms
typeorm-uml init version: @oclif/[email protected] argv: [] +0ms
Error: Unexpected token import
at Object.error (/usr/local/lib/node_modules/typeorm-uml/node_modules/@oclif/errors/lib/index.js:22:17)
at TypeormUmlCommand.error (/usr/local/lib/node_modules/typeorm-uml/node_modules/@oclif/command/lib/command.js:60:23)
at TypeormUmlCommand.run (/usr/local/lib/node_modules/typeorm-uml/lib/TypeormUmlCommand.js:22:22)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
If you utilize the @ChildEntity(someEnum.VALUE)
feature of TypeORM on one or more entities, the diagram it creates for the table is incorrect. You will see the columns duplicated on the table in the diagram.
Parent class:
@Entity('table_name')
@TableInheritance({
column: { type: 'enum', enum: SomeEnum, name: 'type' },
})
export abstract class TableEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ type: 'text', nullable: true })
name: string | null;
...
Child class:
@ChildEntity(SomeEnum.VALUE)
export class ChildEntity extends TableEntity {
...
Hi,
Currently the colors of the diagram are hardcoded, for instance:
typeorm-uml/src/builder/uml-builder.class.ts
Lines 43 to 45 in 6bab2db
It would be nice to have a set of flags enabling their customization such as:
--primary-key-color #aaaaaa
--foreign-key-color #aaaaaa
--column-color #aaaaaa
--entity-background-color #aaaaaa
--entity-border-color #aaaaaa
--arrow-color #aaaaaa
The txt format generates diagram "as image" and it would be great to generate the PlantUML diagram directly in .puml
format.
Hi,
Currently, TypeormUml
exposes a method build
that has the following signature:
public async build( configName: string, flags: Flags )
where configName
is the path of the orm config file, usually something called ormconfig.json
However, there are projects where the json orm configuration is not into a json
file as it is built during runtime, for instance to allow the use of environment variables into the configuration.
It would be nice if typeorm-url could accept an orm config as json
instead of a path to a json file.
The signature could become:
public async build( flags: Flags )
There would be two new flags :
jsonConfigPath: string
jsonConfig: any
And users of this library would be required to either use jsonConfigPath
that is a path to a json config file or jsonConfig
that is the raw json object, not stored into any file
Hi! When we use the --with-table-names-only
flag, since entities names won't be displayed, I think it would be nice to remove them from the output puml diagram's code
Now ... -f puml --with-table-names-only
produces lines like table( UserEntity, User ) as User
To generate lines like table( User )
which will leads to the same image but with less bytes.
Note that this implies changing this following func as well
typeorm-uml/src/builder/styles.class.ts
Line 38 in ead09e7
Do you think this is feasible?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.