@wisemen/typeorm-to-dbml 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,59 @@
1
+ # PolyForm Strict License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/strict/1.0.0>
4
+
5
+ ## Acceptance
6
+
7
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose, other than distributing the software or making changes or new works based on the software.
12
+
13
+ ## Patent License
14
+
15
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
16
+
17
+ ## Noncommercial Purposes
18
+
19
+ Any noncommercial purpose is a permitted purpose.
20
+
21
+ ## Personal Uses
22
+
23
+ Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
24
+
25
+ ## Noncommercial Organizations
26
+
27
+ Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
28
+
29
+ ## Fair Use
30
+
31
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
32
+
33
+ ## No Other Rights
34
+
35
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
36
+
37
+ ## Patent Defense
38
+
39
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
40
+
41
+ ## Violations
42
+
43
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
44
+
45
+ ## No Liability
46
+
47
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
48
+
49
+ ## Definitions
50
+
51
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
52
+
53
+ **You** refers to the individual or entity agreeing to these terms.
54
+
55
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
56
+
57
+ **Your licenses** are all the licenses granted to you for the software under these terms.
58
+
59
+ **Use** means anything you do with the software requiring one of your licenses.
package/README.md ADDED
@@ -0,0 +1,125 @@
1
+ # typeorm-to-dbml
2
+
3
+ Convert a TypeScript project using TypeORM decorators to a DBML diagram.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install
9
+ npm build
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ```bash
15
+ npm start <sourceGlob> [outputPath]
16
+ ```
17
+
18
+ ### Parameters
19
+
20
+ - `sourceGlob` (required): Glob pattern to match TypeORM entity files (e.g., `"src/entities/**/*.ts"`)
21
+ - `outputPath` (optional): Path to output DBML file (default: `./schema.dbml`)
22
+
23
+ ### Example
24
+
25
+ ```bash
26
+ npm start "examples/entities/**/*.ts" "./schema.dbml"
27
+ ```
28
+
29
+ ## Features
30
+
31
+ The tool supports the following TypeORM decorators:
32
+
33
+ - **`@Entity`**: Converts to a DBML table. The table name is derived from the class name or the argument passed to the decorator.
34
+
35
+ - **`@PrimaryColumn`**: Defines a primary key column.
36
+ - You can specify the column type using the `type` option (e.g., `{ type: 'uuid' }`).
37
+
38
+ - **`@PrimaryGeneratedColumn`**: Defines the primary key column.
39
+ - By default, it creates an `integer` column with `[pk, increment]`.
40
+ - If the `'uuid'` strategy is used, it generates a `varchar [pk]` column.
41
+
42
+ - **`@Column`**: Defines a regular table column.
43
+ - **Type Inference**: If no type is specified, it maps TypeScript types to DBML types (e.g., `string` to `varchar`).
44
+ - **Options**:
45
+ - `type`: Explicitly sets the column type (e.g., `{ type: 'jsonb' }`).
46
+ - `nullable`: Marks the column as nullable (e.g., `{ nullable: true }`).
47
+ - `default`: Sets a default value for the column (e.g., `{ default: true }`).- **`@ManyToOne`**: Extracts the target entity to create a foreign key relationship.
48
+
49
+ - **`@OneToOne`**: Extracts the target entity to create a one-to-one relationship.
50
+
51
+ - **`@JoinColumn`**: Used with `@ManyToOne` to specify the foreign key column name via the `name` option.
52
+
53
+ - **`@CreatedDateColumn`**: Creates a `timestamp` column for creation date.
54
+
55
+ - **`@UpdateDateColumn`**: Creates a `timestamp` column for last update date.
56
+
57
+ - **`@DeleteDateColumn`**: Creates a nullable `timestamp` column for soft delete date.
58
+
59
+ - All other properties that contain a decorator are documented as a column of type `unknown`.
60
+
61
+ ### Type Mapping (When type is not explicitly specified)
62
+
63
+ | TypeScript Type | DBML Type |
64
+ | --------------- | ----------- |
65
+ | `string` | `varchar` |
66
+ | `number` | `integer` |
67
+ | `boolean` | `boolean` |
68
+ | `Date` | `timestamp` |
69
+ | `any` | `text` |
70
+
71
+ ## Example Output
72
+
73
+ Given TypeORM entities like:
74
+
75
+ ```typescript
76
+ @Entity()
77
+ export class User {
78
+ @PrimaryGeneratedColumn()
79
+ id: number;
80
+
81
+ @Column()
82
+ name: string;
83
+
84
+ @Column({ nullable: true })
85
+ bio: string;
86
+
87
+ @Column({ type: "boolean", default: true })
88
+ isActive: boolean;
89
+
90
+ @Column({ type: "jsonb" })
91
+ customFields: object;
92
+ }
93
+
94
+ @Entity("posts")
95
+ export class Post {
96
+ @PrimaryGeneratedColumn()
97
+ id: number;
98
+
99
+ @Column()
100
+ title: string;
101
+
102
+ @ManyToOne(() => User)
103
+ author: User;
104
+ }
105
+ ```
106
+
107
+ The tool generates:
108
+
109
+ ```dbml
110
+ Table user {
111
+ id integer [pk, increment]
112
+ name varchar
113
+ bio varchar [null]
114
+ is_active boolean [default: true]
115
+ custom_fields jsonb
116
+ }
117
+
118
+ Table posts {
119
+ id integer [pk, increment]
120
+ title varchar
121
+ }
122
+
123
+ // relationships
124
+ Ref: posts.author_id > user.id
125
+ ```
@@ -0,0 +1,4 @@
1
+ export declare function parseArgs(): Promise<{
2
+ sourceGlob: string;
3
+ outputPath: string;
4
+ }>;
@@ -0,0 +1,36 @@
1
+ import yargs from 'yargs';
2
+ import { hideBin } from 'yargs/helpers';
3
+ export async function parseArgs() {
4
+ const argv = await yargs(hideBin(process.argv))
5
+ .command('$0 <sourceGlob> [outputPath]', 'generate DBML schema from TypeORM entities', (yargs) => {
6
+ return yargs
7
+ .positional('sourceGlob', {
8
+ describe: 'Glob pattern for your TypeORM entities',
9
+ type: 'string'
10
+ })
11
+ .positional('outputPath', {
12
+ describe: 'Path to the output DBML file',
13
+ type: 'string',
14
+ default: './schema.dbml'
15
+ });
16
+ })
17
+ .help()
18
+ .example('$0 "src/entities/**/*.ts"', 'Generate DBML from all entities in src/entities')
19
+ .parse();
20
+ if (argv.sourceGlob === null) {
21
+ console.error('Error: sourceGlob is required.');
22
+ process.exit(1);
23
+ }
24
+ // Safety check: specific to preventing overwrites when users forget quotes around globs
25
+ if (typeof argv.outputPath === 'string' && argv.outputPath.endsWith('.ts')) {
26
+ console.error(`Error: outputPath '${argv.outputPath}' looks like a TypeScript file.`);
27
+ console.error('Did you forget to quote your glob pattern? (e.g. "src/**/*.ts")');
28
+ console.error('Shell expansion causes the second matched file to be treated as the outputPath.');
29
+ process.exit(1);
30
+ }
31
+ return {
32
+ sourceGlob: argv.sourceGlob,
33
+ outputPath: argv.outputPath
34
+ };
35
+ }
36
+ //# sourceMappingURL=args.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.js","sourceRoot":"","sources":["../../lib/cli/args.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,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string;
@@ -0,0 +1,11 @@
1
+ export function mapTypeToDbml(tsType) {
2
+ const typeMap = {
3
+ string: 'varchar',
4
+ number: 'integer',
5
+ boolean: 'boolean',
6
+ Date: 'timestamp',
7
+ any: 'text'
8
+ };
9
+ return typeMap[tsType] || 'varchar';
10
+ }
11
+ //# sourceMappingURL=mapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapper.js","sourceRoot":"","sources":["../../lib/dbml/mapper.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,aAAa,CAAE,MAAc;IAC3C,MAAM,OAAO,GAA2B;QACtC,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,WAAW;QACjB,GAAG,EAAE,MAAM;KACZ,CAAA;IAED,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,SAAS,CAAA;AACrC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function toSnakeCase(str: string): string;
@@ -0,0 +1,7 @@
1
+ export function toSnakeCase(str) {
2
+ return str
3
+ .replace(/([A-Z])/g, '_$1')
4
+ .toLowerCase()
5
+ .replace(/^_/, '');
6
+ }
7
+ //# sourceMappingURL=to-snake-case.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-snake-case.js","sourceRoot":"","sources":["../../lib/helpers/to-snake-case.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAE,GAAW;IACtC,OAAO,GAAG;SACP,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;SAC1B,WAAW,EAAE;SACb,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;AACtB,CAAC"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export declare function generateDbml(sourceGlob: string, outputPath: string): void;
package/dist/index.js ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+ import { Project } from 'ts-morph';
5
+ import { getEntityName } from './typeorm/entity.js';
6
+ import { processEntity } from './typeorm/parser.js';
7
+ import { parseArgs } from './cli/args.js';
8
+ export function generateDbml(sourceGlob, outputPath) {
9
+ const project = new Project({
10
+ skipAddingFilesFromTsConfig: true
11
+ });
12
+ project.addSourceFilesAtPaths(sourceGlob);
13
+ const sourceFiles = project.getSourceFiles();
14
+ if (sourceFiles.length === 0) {
15
+ console.error(`No files found matching pattern: ${sourceGlob}`);
16
+ process.exit(1);
17
+ }
18
+ const classToEntityMap = new Map();
19
+ for (const sourceFile of sourceFiles) {
20
+ const classes = sourceFile.getClasses();
21
+ for (const classDecl of classes) {
22
+ if (classDecl.getDecorator('Entity')) {
23
+ const className = classDecl.getName();
24
+ const entityName = getEntityName(classDecl);
25
+ if (className !== undefined) {
26
+ classToEntityMap.set(className, entityName);
27
+ }
28
+ }
29
+ }
30
+ }
31
+ let dbmlContent = '';
32
+ for (const sourceFile of sourceFiles) {
33
+ const classes = sourceFile.getClasses();
34
+ for (const classDecl of classes) {
35
+ if (classDecl.getDecorator('Entity')) {
36
+ const { table, refs } = processEntity(classDecl, classToEntityMap);
37
+ dbmlContent += table + '\n';
38
+ if (refs.length > 0) {
39
+ dbmlContent += refs.join('\n') + '\n\n';
40
+ }
41
+ }
42
+ }
43
+ }
44
+ const resolvedPath = path.resolve(outputPath);
45
+ fs.writeFileSync(resolvedPath, dbmlContent.trim(), 'utf8');
46
+ console.log(`DBML schema generated successfully: ${resolvedPath}`);
47
+ console.log(`Processed ${sourceFiles.length} file(s)`);
48
+ }
49
+ async function main() {
50
+ const { sourceGlob, outputPath } = await parseArgs();
51
+ generateDbml(sourceGlob, outputPath);
52
+ }
53
+ await main();
54
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;A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CAAC;QACrC,MAAM,OAAO,GAAG,UAAU,CAAC,UAAU,EAAE,CAAA;QAEvC,KAAK,MAAM,SAAS,IAAI,OAAO,EAAE,CAAC;YAChC,IAAI,SAAS,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACrC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,aAAa,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAA;gBAElE,WAAW,IAAI,KAAK,GAAG,IAAI,CAAA;gBAE3B,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACpB,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,CAAA;gBACzC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAE7C,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,WAAW,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAA;IAE1D,OAAO,CAAC,GAAG,CAAC,uCAAuC,YAAY,EAAE,CAAC,CAAA;IAClE,OAAO,CAAC,GAAG,CAAC,aAAa,WAAW,CAAC,MAAM,UAAU,CAAC,CAAA;AACxD,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,MAAM,SAAS,EAAE,CAAA;IAEpD,YAAY,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;AACtC,CAAC;AAED,MAAM,IAAI,EAAE,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { ClassDeclaration } from 'ts-morph';
2
+ export declare function getEntityName(classDecl: ClassDeclaration): string;
@@ -0,0 +1,22 @@
1
+ import { toSnakeCase } from '#src/helpers/to-snake-case.js';
2
+ export function getEntityName(classDecl) {
3
+ const entityDecorator = classDecl.getDecorator('Entity');
4
+ if (entityDecorator) {
5
+ const args = entityDecorator.getArguments();
6
+ if (args.length > 0) {
7
+ const arg = args[0];
8
+ const argText = arg.getText();
9
+ if (argText.startsWith('\'') || argText.startsWith('"')) {
10
+ return argText.replace(/['"]/g, '');
11
+ }
12
+ if (argText.startsWith('{')) {
13
+ const nameMatch = argText.match(/name\s*:\s*['"]([^'"]+)['"]/);
14
+ if (nameMatch) {
15
+ return nameMatch[1];
16
+ }
17
+ }
18
+ }
19
+ }
20
+ return toSnakeCase(classDecl.getName() ?? 'UnknownEntity');
21
+ }
22
+ //# sourceMappingURL=entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.js","sourceRoot":"","sources":["../../lib/typeorm/entity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAE3D,MAAM,UAAU,aAAa,CAAE,SAA2B;IACxD,MAAM,eAAe,GAAG,SAAS,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;IAExD,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,IAAI,GAAG,eAAe,CAAC,YAAY,EAAE,CAAA;QAE3C,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;YACnB,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAA;YAE7B,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACxD,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;YACrC,CAAC;YAED,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC5B,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAA;gBAE9D,IAAI,SAAS,EAAE,CAAC;oBACd,OAAO,SAAS,CAAC,CAAC,CAAC,CAAA;gBACrB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,eAAe,CAAC,CAAA;AAC5D,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { ClassDeclaration } from 'ts-morph';
2
+ export declare function processEntity(classDecl: ClassDeclaration, classToEntityMap: Map<string, string>): {
3
+ table: string;
4
+ refs: string[];
5
+ };
@@ -0,0 +1,206 @@
1
+ import { ObjectLiteralExpression, PropertyAssignment } from 'ts-morph';
2
+ import { getEntityName } from './entity.js';
3
+ import { toSnakeCase } from '#src/helpers/to-snake-case.js';
4
+ import { mapTypeToDbml } from '#src/dbml/mapper.js';
5
+ function getPropertyTypeName(property) {
6
+ const typeNode = property.getTypeNode();
7
+ if (typeNode) {
8
+ return typeNode.getText();
9
+ }
10
+ return property.getType().getText();
11
+ }
12
+ function hasDecorator(property, decoratorName) {
13
+ return property.getDecorator(decoratorName) !== undefined;
14
+ }
15
+ function getDecorator(property, decoratorName) {
16
+ return property.getDecorator(decoratorName);
17
+ }
18
+ function getDecoratorOptions(decorator) {
19
+ const args = decorator.getArguments();
20
+ if (args.length > 0 && args[0] instanceof ObjectLiteralExpression) {
21
+ return args[0];
22
+ }
23
+ return undefined;
24
+ }
25
+ function getDecoratorProperty(decorator, propertyName) {
26
+ const options = getDecoratorOptions(decorator);
27
+ if (options) {
28
+ const property = options.getProperty(propertyName);
29
+ if (property && property instanceof PropertyAssignment) {
30
+ return property.getInitializer()?.getText().replace(/['"]/g, '') ?? null;
31
+ }
32
+ }
33
+ return null;
34
+ }
35
+ function getColumnDefault(property) {
36
+ const columnDecorator = getDecorator(property, 'Column');
37
+ if (!columnDecorator) {
38
+ return null;
39
+ }
40
+ const options = getDecoratorOptions(columnDecorator);
41
+ if (options) {
42
+ const defaultProperty = options.getProperty('default');
43
+ if (defaultProperty && defaultProperty instanceof PropertyAssignment) {
44
+ return defaultProperty.getInitializer()?.getText() ?? null;
45
+ }
46
+ }
47
+ return null;
48
+ }
49
+ function isNullable(property) {
50
+ const columnDecorator = getDecorator(property, 'Column');
51
+ if (!columnDecorator) {
52
+ return false;
53
+ }
54
+ const options = getDecoratorOptions(columnDecorator);
55
+ if (options) {
56
+ const nullableProperty = options.getProperty('nullable');
57
+ if (nullableProperty && nullableProperty instanceof PropertyAssignment) {
58
+ return nullableProperty.getInitializer()?.getText() === 'true';
59
+ }
60
+ }
61
+ return false;
62
+ }
63
+ function getJoinColumnName(property) {
64
+ const joinColumnDecorator = getDecorator(property, 'JoinColumn');
65
+ if (!joinColumnDecorator) {
66
+ return null;
67
+ }
68
+ const options = getDecoratorOptions(joinColumnDecorator);
69
+ if (options) {
70
+ const nameProperty = options.getProperty('name');
71
+ if (nameProperty && nameProperty instanceof PropertyAssignment) {
72
+ return nameProperty.getInitializer()?.getText().replace(/['"]/g, '') ?? null;
73
+ }
74
+ }
75
+ return null;
76
+ }
77
+ function getManyToOneTarget(property) {
78
+ const manyToOneDecorator = getDecorator(property, 'ManyToOne');
79
+ if (!manyToOneDecorator) {
80
+ return null;
81
+ }
82
+ const args = manyToOneDecorator.getArguments();
83
+ if (args.length > 0) {
84
+ const targetArg = args[0].getText();
85
+ // Matches: () => Entity, () => entities.Entity, () => module.Entity
86
+ const match = targetArg.match(/=>\s*([\w.]+)/);
87
+ if (match) {
88
+ const fullName = match[1];
89
+ const parts = fullName.split('.');
90
+ return parts[parts.length - 1];
91
+ }
92
+ }
93
+ return null;
94
+ }
95
+ function getOneToOneTarget(property) {
96
+ const oneToOneDecorator = getDecorator(property, 'OneToOne');
97
+ if (!oneToOneDecorator) {
98
+ return null;
99
+ }
100
+ const args = oneToOneDecorator.getArguments();
101
+ if (args.length > 0) {
102
+ const targetArg = args[0].getText();
103
+ // Matches: () => Entity, () => entities.Entity, () => module.Entity
104
+ const match = targetArg.match(/=>\s*([\w.]+)/);
105
+ if (match) {
106
+ const fullName = match[1];
107
+ const parts = fullName.split('.');
108
+ return parts[parts.length - 1];
109
+ }
110
+ }
111
+ return null;
112
+ }
113
+ export function processEntity(classDecl, classToEntityMap) {
114
+ const entityName = getEntityName(classDecl);
115
+ const properties = classDecl.getProperties();
116
+ let tableDefinition = `Table ${entityName} {\n`;
117
+ const refs = [];
118
+ for (const property of properties) {
119
+ const propertyName = toSnakeCase(property.getName());
120
+ if (hasDecorator(property, 'PrimaryColumn')) {
121
+ const decorator = property.getDecorator('PrimaryColumn');
122
+ const decoratorType = getDecoratorProperty(decorator, 'type');
123
+ const propertyType = getPropertyTypeName(property);
124
+ const dbmlType = decoratorType ?? mapTypeToDbml(propertyType);
125
+ tableDefinition += ` ${propertyName} ${dbmlType} [pk]\n`;
126
+ continue;
127
+ }
128
+ if (hasDecorator(property, 'PrimaryGeneratedColumn')) {
129
+ const decorator = property.getDecorator('PrimaryGeneratedColumn');
130
+ const args = decorator.getArguments();
131
+ if (args.length > 0 && args[0].getText() === '\'uuid\'') {
132
+ tableDefinition += ` ${propertyName} varchar [pk]\n`;
133
+ }
134
+ else {
135
+ tableDefinition += ` ${propertyName} integer [pk, increment]\n`;
136
+ }
137
+ continue;
138
+ }
139
+ if (hasDecorator(property, 'Column')) {
140
+ const decorator = property.getDecorator('Column');
141
+ const decoratorType = getDecoratorProperty(decorator, 'type');
142
+ const propertyType = getPropertyTypeName(property);
143
+ const dbmlType = decoratorType ?? mapTypeToDbml(propertyType);
144
+ const nullable = isNullable(property);
145
+ const defaultValue = getColumnDefault(property);
146
+ const settings = [];
147
+ if (nullable) {
148
+ settings.push('null');
149
+ }
150
+ if (defaultValue !== null) {
151
+ settings.push(`default: '${defaultValue}'`);
152
+ }
153
+ const settingsStr = settings.length > 0 ? ` [${settings.join(', ')}]` : '';
154
+ tableDefinition += ` ${propertyName} ${dbmlType}${settingsStr}\n`;
155
+ continue;
156
+ }
157
+ if (hasDecorator(property, 'ManyToOne')) {
158
+ const targetClassName = getManyToOneTarget(property);
159
+ if (targetClassName !== null) {
160
+ const fkColumnName = getJoinColumnName(property) ?? `${toSnakeCase(property.getName())}_id`;
161
+ const targetEntityName = classToEntityMap.get(targetClassName) ?? targetClassName;
162
+ refs.push(`Ref: ${entityName}.${fkColumnName} > ${targetEntityName}.uuid`);
163
+ }
164
+ continue;
165
+ }
166
+ if (hasDecorator(property, 'OneToMany')) {
167
+ // OneToMany is the inverse side of ManyToOne, so we don't create a reference here
168
+ continue;
169
+ }
170
+ if (hasDecorator(property, 'OneToOne')) {
171
+ const targetClassName = getOneToOneTarget(property);
172
+ if (targetClassName !== null) {
173
+ const fkColumnName = getJoinColumnName(property) ?? `${property.getName()}_id`;
174
+ const targetEntityName = classToEntityMap.get(targetClassName) ?? targetClassName;
175
+ refs.push(`Ref: ${entityName}.${fkColumnName} - ${targetEntityName}.uuid`);
176
+ }
177
+ continue;
178
+ }
179
+ if (hasDecorator(property, 'CreateDateColumn')) {
180
+ tableDefinition += ` ${propertyName} timestamp [default: 'now()']\n`;
181
+ continue;
182
+ }
183
+ if (hasDecorator(property, 'UpdateDateColumn')) {
184
+ tableDefinition += ` ${propertyName} timestamp [default: 'now()']\n`;
185
+ continue;
186
+ }
187
+ if (hasDecorator(property, 'DeleteDateColumn')) {
188
+ tableDefinition += ` ${propertyName} timestamp [null]\n`;
189
+ continue;
190
+ }
191
+ const nullable = isNullable(property);
192
+ const defaultValue = getColumnDefault(property);
193
+ const settings = [];
194
+ if (nullable) {
195
+ settings.push('null');
196
+ }
197
+ if (defaultValue !== null) {
198
+ settings.push(`default: '${defaultValue}'`);
199
+ }
200
+ const settingsStr = settings.length > 0 ? ` [${settings.join(', ')}]` : '';
201
+ tableDefinition += ` ${propertyName} unknown ${settingsStr}\n`;
202
+ }
203
+ tableDefinition += `}\n`;
204
+ return { table: tableDefinition, refs };
205
+ }
206
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../lib/typeorm/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,uBAAuB,EACvB,kBAAkB,EAEnB,MAAM,UAAU,CAAA;A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AE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,CAAA;AACzC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@wisemen/typeorm-to-dbml",
3
+ "version": "0.0.1",
4
+ "description": "Convert a TypeScript project using TypeORM decorators to a DBML diagram.",
5
+ "keywords": [
6
+ "typeorm",
7
+ "dbml",
8
+ "database",
9
+ "schema",
10
+ "diagram"
11
+ ],
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "imports": {
16
+ "#src/*": "./dist/*"
17
+ },
18
+ "main": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "type": "module",
21
+ "exports": {
22
+ "#src/*": "./dist/*"
23
+ },
24
+ "files": [
25
+ "dist/"
26
+ ],
27
+ "dependencies": {
28
+ "ts-morph": "^21.0.0",
29
+ "typeorm": "0.3.28",
30
+ "yargs": "^18.0.0"
31
+ },
32
+ "devDependencies": {
33
+ "@types/yargs": "^17.0.35",
34
+ "@types/node": "25.3.0",
35
+ "typescript": ">=4.8.4 <=5.9.3",
36
+ "@wisemen/eslint-config-nestjs": "0.2.13"
37
+ },
38
+ "author": "Pieter Pauwels",
39
+ "license": "SEE LICENSE IN LICENSE.md",
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "https://github.com/wisemen-digital/wisemen-core",
43
+ "directory": "packages/typeorm-to-dbml"
44
+ },
45
+ "scripts": {
46
+ "lint": "eslint lib",
47
+ "build": "tsc",
48
+ "clean": "rm -rf ./dist",
49
+ "start": "node dist/index.js",
50
+ "test": "echo \"Error: no test specified\" && exit 1"
51
+ }
52
+ }