air-dml 1.0.0
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 +90 -0
- package/README.md +270 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/parser/index.d.ts +4 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +441 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/types/index.d.ts +74 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
+
|
|
23
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
+
|
|
25
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
+
|
|
27
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
|
|
29
|
+
2. Grant of Copyright License.
|
|
30
|
+
|
|
31
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
32
|
+
|
|
33
|
+
3. Grant of Patent License.
|
|
34
|
+
|
|
35
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
36
|
+
|
|
37
|
+
4. Redistribution.
|
|
38
|
+
|
|
39
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
40
|
+
|
|
41
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
42
|
+
|
|
43
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
44
|
+
|
|
45
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
46
|
+
|
|
47
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
48
|
+
|
|
49
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
50
|
+
|
|
51
|
+
5. Submission of Contributions.
|
|
52
|
+
|
|
53
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
54
|
+
|
|
55
|
+
6. Trademarks.
|
|
56
|
+
|
|
57
|
+
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
58
|
+
|
|
59
|
+
7. Disclaimer of Warranty.
|
|
60
|
+
|
|
61
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
62
|
+
|
|
63
|
+
8. Limitation of Liability.
|
|
64
|
+
|
|
65
|
+
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
66
|
+
|
|
67
|
+
9. Accepting Warranty or Additional Liability.
|
|
68
|
+
|
|
69
|
+
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
70
|
+
|
|
71
|
+
END OF TERMS AND CONDITIONS
|
|
72
|
+
|
|
73
|
+
Copyright 2026 Data-mination Partners
|
|
74
|
+
|
|
75
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
76
|
+
you may not use this file except in compliance with the License.
|
|
77
|
+
You may obtain a copy of the License at
|
|
78
|
+
|
|
79
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
80
|
+
|
|
81
|
+
Unless required by applicable law or agreed to in writing, software
|
|
82
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
83
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
84
|
+
See the License for the specific language governing permissions and
|
|
85
|
+
limitations under the License.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
This project extends DBML (https://github.com/holistics/dbml)
|
|
90
|
+
which is also licensed under Apache-2.0.
|
package/README.md
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# AIR-DML
|
|
2
|
+
|
|
3
|
+
**AI-Ready Data Modeling Language**
|
|
4
|
+
|
|
5
|
+
AIR-DML is an extended DBML (Database Markup Language) parser designed for AI-driven development. It adds powerful features for modern data modeling while maintaining full backward compatibility with standard DBML.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/air-dml)
|
|
8
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
✨ **AI-Optimized**: Designed for AI language models to understand and generate database schemas
|
|
13
|
+
🏗️ **Domain-Driven Design**: Built-in support for bounded contexts via `Area`
|
|
14
|
+
🌍 **Multilingual**: Logical names (aliases) in any language
|
|
15
|
+
🎨 **Visual Design**: Coordinate and color information for diagram rendering
|
|
16
|
+
🔄 **Polyglot Persistence**: Different database types per area
|
|
17
|
+
📦 **Extends DBML**: Fully compatible with standard DBML, powered by `@dbml/core`
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install air-dml
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { parseAirDML, exportToAirDML } from 'air-dml';
|
|
29
|
+
|
|
30
|
+
// Parse AIR-DML text
|
|
31
|
+
const airDmlText = `
|
|
32
|
+
Project "My Project" {
|
|
33
|
+
database_type: 'PostgreSQL'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
Table users [alias: "ユーザー", pos_x: 100, pos_y: 100, color: "#1976D2"] {
|
|
37
|
+
id serial [pk, alias: "ユーザーID"]
|
|
38
|
+
username varchar(100) [not null, unique, alias: "ユーザー名"]
|
|
39
|
+
email varchar(255) [not null, unique, alias: "メールアドレス"]
|
|
40
|
+
created_at timestamp [not null, alias: "作成日時"]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
Area "User Management" [
|
|
44
|
+
pos_x: 50,
|
|
45
|
+
pos_y: 50,
|
|
46
|
+
width: 600,
|
|
47
|
+
height: 300,
|
|
48
|
+
color: "#1976D2",
|
|
49
|
+
database_type: "PostgreSQL"
|
|
50
|
+
] {
|
|
51
|
+
users
|
|
52
|
+
|
|
53
|
+
CommonColumns: [
|
|
54
|
+
created_at timestamp [not null, alias: "作成日時"]
|
|
55
|
+
updated_at timestamp [not null, alias: "更新日時"]
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
const diagram = parseAirDML(airDmlText);
|
|
61
|
+
console.log(diagram);
|
|
62
|
+
|
|
63
|
+
// Export back to AIR-DML
|
|
64
|
+
const output = exportToAirDML(diagram);
|
|
65
|
+
console.log(output);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## AIR-DML Extensions
|
|
69
|
+
|
|
70
|
+
AIR-DML extends standard DBML with the following features:
|
|
71
|
+
|
|
72
|
+
### 1. **Logical Names (Alias)**
|
|
73
|
+
|
|
74
|
+
Add human-readable names in any language:
|
|
75
|
+
|
|
76
|
+
```dbml
|
|
77
|
+
Table users [alias: "ユーザー"] {
|
|
78
|
+
id serial [pk, alias: "ユーザーID"]
|
|
79
|
+
name varchar(100) [alias: "名前"]
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 2. **Visual Coordinates**
|
|
84
|
+
|
|
85
|
+
Position tables on a canvas:
|
|
86
|
+
|
|
87
|
+
```dbml
|
|
88
|
+
Table users [pos_x: 100, pos_y: 200, color: "#1976D2"] {
|
|
89
|
+
// ...
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 3. **Area (Bounded Context)**
|
|
94
|
+
|
|
95
|
+
Group related tables into logical domains:
|
|
96
|
+
|
|
97
|
+
```dbml
|
|
98
|
+
Area "User Management" [
|
|
99
|
+
pos_x: 50,
|
|
100
|
+
pos_y: 50,
|
|
101
|
+
width: 600,
|
|
102
|
+
height: 300,
|
|
103
|
+
color: "#1976D2",
|
|
104
|
+
database_type: "PostgreSQL",
|
|
105
|
+
note: "User authentication and profile management"
|
|
106
|
+
] {
|
|
107
|
+
users
|
|
108
|
+
profiles
|
|
109
|
+
|
|
110
|
+
CommonColumns: [
|
|
111
|
+
created_at timestamp [not null]
|
|
112
|
+
updated_at timestamp [not null]
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 4. **CommonColumns**
|
|
118
|
+
|
|
119
|
+
Define shared columns for all tables in an area:
|
|
120
|
+
|
|
121
|
+
```dbml
|
|
122
|
+
Area "Content" {
|
|
123
|
+
posts
|
|
124
|
+
comments
|
|
125
|
+
|
|
126
|
+
CommonColumns: [
|
|
127
|
+
id serial [pk]
|
|
128
|
+
created_at timestamp [not null]
|
|
129
|
+
updated_at timestamp [not null]
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 5. **Polyglot Persistence**
|
|
135
|
+
|
|
136
|
+
Different database types per area:
|
|
137
|
+
|
|
138
|
+
```dbml
|
|
139
|
+
Area "User Data" [database_type: "PostgreSQL"] {
|
|
140
|
+
users
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
Area "Analytics" [database_type: "BigQuery"] {
|
|
144
|
+
events
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 6. **AI Relationship Type**
|
|
149
|
+
|
|
150
|
+
Use `~` for undetermined relationships (AI inference):
|
|
151
|
+
|
|
152
|
+
```dbml
|
|
153
|
+
Ref: users.id ~ profiles.user_id
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## API Reference
|
|
157
|
+
|
|
158
|
+
### `parseAirDML(airDmlText: string, diagramId?: string): Diagram`
|
|
159
|
+
|
|
160
|
+
Parse AIR-DML text into a Diagram object.
|
|
161
|
+
|
|
162
|
+
**Parameters:**
|
|
163
|
+
- `airDmlText` - AIR-DML formatted text
|
|
164
|
+
- `diagramId` - Optional diagram ID
|
|
165
|
+
|
|
166
|
+
**Returns:** `Diagram` object
|
|
167
|
+
|
|
168
|
+
### `exportToAirDML(diagram: Diagram): string`
|
|
169
|
+
|
|
170
|
+
Export a Diagram object to AIR-DML text.
|
|
171
|
+
|
|
172
|
+
**Parameters:**
|
|
173
|
+
- `diagram` - Diagram object
|
|
174
|
+
|
|
175
|
+
**Returns:** AIR-DML formatted text
|
|
176
|
+
|
|
177
|
+
## Type Definitions
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
interface Diagram {
|
|
181
|
+
id: string;
|
|
182
|
+
name: string;
|
|
183
|
+
project?: string;
|
|
184
|
+
database?: string;
|
|
185
|
+
tables: Table[];
|
|
186
|
+
references: Reference[];
|
|
187
|
+
areas?: Area[];
|
|
188
|
+
createdAt?: string;
|
|
189
|
+
updatedAt?: string;
|
|
190
|
+
note?: string;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
interface Table {
|
|
194
|
+
id: string;
|
|
195
|
+
name: string;
|
|
196
|
+
logicalName?: string; // AIR-DML extension
|
|
197
|
+
columns: Column[];
|
|
198
|
+
color?: string; // AIR-DML extension
|
|
199
|
+
pos?: Position; // AIR-DML extension
|
|
200
|
+
areaIds?: string[]; // AIR-DML extension
|
|
201
|
+
note?: string;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
interface Area {
|
|
205
|
+
id: string;
|
|
206
|
+
name: string;
|
|
207
|
+
color?: string;
|
|
208
|
+
pos?: Position;
|
|
209
|
+
width?: number;
|
|
210
|
+
height?: number;
|
|
211
|
+
databaseType?: string; // AIR-DML extension
|
|
212
|
+
commonColumns?: Column[]; // AIR-DML extension
|
|
213
|
+
note?: string;
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
See full type definitions in [src/types/index.ts](./src/types/index.ts).
|
|
218
|
+
|
|
219
|
+
## Comparison: DBML vs AIR-DML
|
|
220
|
+
|
|
221
|
+
| Feature | DBML | AIR-DML |
|
|
222
|
+
|---------|------|---------|
|
|
223
|
+
| **Focus** | Database schema | AI-ready + Business context |
|
|
224
|
+
| **Logical names** | ❌ | ✅ `alias` attribute |
|
|
225
|
+
| **Area management** | TableGroup (basic) | Area (extended: CommonColumns, database_type) |
|
|
226
|
+
| **Visual info** | ❌ | ✅ Coordinates, colors, sizes |
|
|
227
|
+
| **Multi-DB** | Project-level | Area-level (polyglot persistence) |
|
|
228
|
+
| **AI optimization** | ❌ | ✅ LLM-friendly design |
|
|
229
|
+
|
|
230
|
+
## Backward Compatibility
|
|
231
|
+
|
|
232
|
+
AIR-DML is fully compatible with standard DBML:
|
|
233
|
+
- All standard DBML syntax works in AIR-DML
|
|
234
|
+
- AIR-DML extensions are ignored by standard DBML parsers
|
|
235
|
+
- Powered by `@dbml/core` for core DBML parsing
|
|
236
|
+
|
|
237
|
+
## Use Cases
|
|
238
|
+
|
|
239
|
+
- **AI-Driven Development**: Generate database schemas from natural language
|
|
240
|
+
- **Domain-Driven Design**: Model bounded contexts with Areas
|
|
241
|
+
- **ER Diagram Tools**: Build visual database designers
|
|
242
|
+
- **Documentation**: Human-readable schema with multilingual support
|
|
243
|
+
- **Polyglot Persistence**: Manage multiple database types in one schema
|
|
244
|
+
|
|
245
|
+
## Specification
|
|
246
|
+
|
|
247
|
+
For the complete AIR-DML specification, see [AIR-DML Specification](https://github.com/hiroaki-handa/air-dml/blob/main/SPECIFICATION.md).
|
|
248
|
+
|
|
249
|
+
## License
|
|
250
|
+
|
|
251
|
+
Apache-2.0 License - see [LICENSE](./LICENSE) file for details.
|
|
252
|
+
|
|
253
|
+
AIR-DML extends [DBML](https://github.com/holistics/dbml) (also Apache-2.0).
|
|
254
|
+
|
|
255
|
+
## Credits
|
|
256
|
+
|
|
257
|
+
- **Created by**: Data-mination Partners
|
|
258
|
+
- **Technical collaboration**: Claude Sonnet 4.5 (Anthropic)
|
|
259
|
+
- **Based on**: [@dbml/core](https://www.npmjs.com/package/@dbml/core) by Holistics
|
|
260
|
+
|
|
261
|
+
## Links
|
|
262
|
+
|
|
263
|
+
- [GitHub Repository](https://github.com/hiroaki-handa/air-dml)
|
|
264
|
+
- [npm Package](https://www.npmjs.com/package/air-dml)
|
|
265
|
+
- [Issue Tracker](https://github.com/hiroaki-handa/air-dml/issues)
|
|
266
|
+
- [Mode-ai](https://github.com/data-mination/mode-ai) - Reference implementation
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
**AIR-DML™** (AI-Ready Data Modeling Language) is a trademark of Data-mination Partners.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACvD,YAAY,EACV,OAAO,EACP,KAAK,EACL,MAAM,EACN,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,WAAW,GACZ,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exportToAirDML = exports.parseAirDML = void 0;
|
|
4
|
+
var parser_1 = require("./parser");
|
|
5
|
+
Object.defineProperty(exports, "parseAirDML", { enumerable: true, get: function () { return parser_1.parseAirDML; } });
|
|
6
|
+
Object.defineProperty(exports, "exportToAirDML", { enumerable: true, get: function () { return parser_1.exportToAirDML; } });
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAOA,mCAAuD;AAA9C,qGAAA,WAAW,OAAA;AAAE,wGAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,OAAO,EAOR,MAAM,UAAU,CAAC;AAwBlB,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAkI3E;AAOD,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CA2JvD"}
|
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAirDML = parseAirDML;
|
|
4
|
+
exports.exportToAirDML = exportToAirDML;
|
|
5
|
+
const core_1 = require("@dbml/core");
|
|
6
|
+
function parseAirDML(airDmlText, diagramId) {
|
|
7
|
+
const parser = new core_1.Parser();
|
|
8
|
+
const database = parser.parse(airDmlText, 'dbml');
|
|
9
|
+
const project = database.name || 'Untitled Project';
|
|
10
|
+
const databaseType = database.databaseType || 'PostgreSQL';
|
|
11
|
+
const tableAttributes = parseTableAttributes(airDmlText);
|
|
12
|
+
const columnAttributes = parseColumnAttributes(airDmlText);
|
|
13
|
+
const referenceAttributes = parseReferenceAttributes(airDmlText);
|
|
14
|
+
const tables = database.schemas.flatMap((schema) => schema.tables.map((dbmlTable) => {
|
|
15
|
+
const tableAttrs = tableAttributes.get(dbmlTable.name) || {};
|
|
16
|
+
const columns = dbmlTable.fields.map((field) => {
|
|
17
|
+
const colAttrs = columnAttributes.get(`${dbmlTable.name}.${field.name}`) || {};
|
|
18
|
+
return {
|
|
19
|
+
name: field.name,
|
|
20
|
+
logicalName: colAttrs.alias,
|
|
21
|
+
type: mapDbmlTypeToDataType(field.type.type_name),
|
|
22
|
+
typeParams: field.type.args?.join(', '),
|
|
23
|
+
pk: field.pk || false,
|
|
24
|
+
fk: colAttrs.fk || false,
|
|
25
|
+
unique: field.unique || false,
|
|
26
|
+
notNull: field.not_null || false,
|
|
27
|
+
default: field.dbdefault?.value,
|
|
28
|
+
increment: field.increment || false,
|
|
29
|
+
note: field.note,
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
id: `table-${dbmlTable.name}`,
|
|
34
|
+
name: dbmlTable.name,
|
|
35
|
+
logicalName: tableAttrs.alias,
|
|
36
|
+
columns,
|
|
37
|
+
color: tableAttrs.color,
|
|
38
|
+
pos: tableAttrs.pos_x !== undefined && tableAttrs.pos_y !== undefined
|
|
39
|
+
? { x: tableAttrs.pos_x, y: tableAttrs.pos_y }
|
|
40
|
+
: undefined,
|
|
41
|
+
areaIds: [],
|
|
42
|
+
note: dbmlTable.note,
|
|
43
|
+
};
|
|
44
|
+
}));
|
|
45
|
+
const references = database.schemas.flatMap((schema) => schema.refs.map((ref) => {
|
|
46
|
+
const refId = `ref-${ref.endpoints[0].tableName}-${ref.endpoints[0].fieldNames[0]}`;
|
|
47
|
+
const refKey = `${ref.endpoints[0].tableName}.${ref.endpoints[0].fieldNames[0]}-${ref.endpoints[1].tableName}.${ref.endpoints[1].fieldNames[0]}`;
|
|
48
|
+
const refAttrs = referenceAttributes.get(refKey) || {};
|
|
49
|
+
const fromTableId = `table-${ref.endpoints[0].tableName}`;
|
|
50
|
+
const fromTable = tables.find((t) => t.id === fromTableId);
|
|
51
|
+
if (fromTable) {
|
|
52
|
+
const fromColumn = fromTable.columns.find((c) => c.name === ref.endpoints[0].fieldNames[0]);
|
|
53
|
+
if (fromColumn) {
|
|
54
|
+
fromColumn.fk = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
id: refId,
|
|
59
|
+
fromTable: fromTableId,
|
|
60
|
+
fromColumn: ref.endpoints[0].fieldNames[0],
|
|
61
|
+
toTable: `table-${ref.endpoints[1].tableName}`,
|
|
62
|
+
toColumn: ref.endpoints[1].fieldNames[0],
|
|
63
|
+
type: mapDbmlRelationType(ref.name),
|
|
64
|
+
swapEdge: refAttrs.swap_edge,
|
|
65
|
+
};
|
|
66
|
+
}));
|
|
67
|
+
const areaAttributes = parseAreaAttributes(airDmlText);
|
|
68
|
+
const areas = database.schemas.flatMap((schema) => (schema.tableGroups || []).map((group) => {
|
|
69
|
+
const areaAttrs = areaAttributes.get(group.name) || {};
|
|
70
|
+
const areaId = `area-${group.name}`;
|
|
71
|
+
if (group.tables) {
|
|
72
|
+
group.tables.forEach((tableRef) => {
|
|
73
|
+
const tableName = typeof tableRef === 'string' ? tableRef : tableRef.name;
|
|
74
|
+
const table = tables.find(t => t.name === tableName);
|
|
75
|
+
if (table && !table.areaIds?.includes(areaId)) {
|
|
76
|
+
table.areaIds = [...(table.areaIds || []), areaId];
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const commonColumns = parseAreaCommonColumns(airDmlText, group.name);
|
|
81
|
+
return {
|
|
82
|
+
id: areaId,
|
|
83
|
+
name: group.name,
|
|
84
|
+
color: areaAttrs.color,
|
|
85
|
+
pos: areaAttrs.pos_x !== undefined && areaAttrs.pos_y !== undefined
|
|
86
|
+
? { x: areaAttrs.pos_x, y: areaAttrs.pos_y }
|
|
87
|
+
: undefined,
|
|
88
|
+
width: areaAttrs.width,
|
|
89
|
+
height: areaAttrs.height,
|
|
90
|
+
databaseType: areaAttrs.database_type,
|
|
91
|
+
note: areaAttrs.note,
|
|
92
|
+
commonColumns,
|
|
93
|
+
};
|
|
94
|
+
}));
|
|
95
|
+
return {
|
|
96
|
+
id: diagramId || `diagram-${Date.now()}`,
|
|
97
|
+
name: project,
|
|
98
|
+
project,
|
|
99
|
+
database: databaseType,
|
|
100
|
+
tables,
|
|
101
|
+
references,
|
|
102
|
+
areas,
|
|
103
|
+
createdAt: new Date().toISOString(),
|
|
104
|
+
updatedAt: new Date().toISOString(),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function exportToAirDML(diagram) {
|
|
108
|
+
let airDml = '';
|
|
109
|
+
airDml += `// ${diagram.name}\n`;
|
|
110
|
+
const projectName = diagram.project || diagram.name || 'Untitled';
|
|
111
|
+
airDml += `Project ${escapeIdentifier(projectName)} {\n`;
|
|
112
|
+
airDml += ` database_type: '${diagram.database || 'PostgreSQL'}'\n`;
|
|
113
|
+
airDml += ` Note: "Generated with AIR-DML"\n`;
|
|
114
|
+
airDml += `}\n\n`;
|
|
115
|
+
diagram.tables.forEach((table) => {
|
|
116
|
+
const tableAttrs = [];
|
|
117
|
+
if (table.logicalName) {
|
|
118
|
+
tableAttrs.push(`alias: "${escapeString(table.logicalName)}"`);
|
|
119
|
+
}
|
|
120
|
+
if (table.pos) {
|
|
121
|
+
tableAttrs.push(`pos_x: ${table.pos.x}`);
|
|
122
|
+
tableAttrs.push(`pos_y: ${table.pos.y}`);
|
|
123
|
+
}
|
|
124
|
+
if (table.color) {
|
|
125
|
+
tableAttrs.push(`color: "${table.color}"`);
|
|
126
|
+
}
|
|
127
|
+
const attrStr = tableAttrs.length > 0 ? ` [${tableAttrs.join(', ')}]` : '';
|
|
128
|
+
airDml += `Table ${escapeIdentifier(table.name)}${attrStr} {\n`;
|
|
129
|
+
table.columns.forEach((column) => {
|
|
130
|
+
const constraints = [];
|
|
131
|
+
if (column.pk)
|
|
132
|
+
constraints.push('pk');
|
|
133
|
+
if (column.fk)
|
|
134
|
+
constraints.push('fk');
|
|
135
|
+
if (column.unique)
|
|
136
|
+
constraints.push('unique');
|
|
137
|
+
if (column.notNull)
|
|
138
|
+
constraints.push('not null');
|
|
139
|
+
if (column.increment)
|
|
140
|
+
constraints.push('increment');
|
|
141
|
+
if (column.default)
|
|
142
|
+
constraints.push(`default: ${column.default}`);
|
|
143
|
+
if (column.logicalName) {
|
|
144
|
+
constraints.push(`alias: "${escapeString(column.logicalName)}"`);
|
|
145
|
+
}
|
|
146
|
+
if (column.note) {
|
|
147
|
+
constraints.push(`note: "${escapeString(column.note)}"`);
|
|
148
|
+
}
|
|
149
|
+
const typeStr = column.typeParams
|
|
150
|
+
? `${column.type}(${column.typeParams})`
|
|
151
|
+
: column.type;
|
|
152
|
+
const constraintStr = constraints.length > 0 ? ` [${constraints.join(', ')}]` : '';
|
|
153
|
+
airDml += ` ${escapeIdentifier(column.name)} ${typeStr}${constraintStr}\n`;
|
|
154
|
+
});
|
|
155
|
+
if (table.note) {
|
|
156
|
+
airDml += `\n Note: "${escapeString(table.note)}"\n`;
|
|
157
|
+
}
|
|
158
|
+
airDml += `}\n\n`;
|
|
159
|
+
});
|
|
160
|
+
diagram.references.forEach((ref) => {
|
|
161
|
+
const fromTable = diagram.tables.find((t) => t.id === ref.fromTable);
|
|
162
|
+
const toTable = diagram.tables.find((t) => t.id === ref.toTable);
|
|
163
|
+
if (fromTable && toTable) {
|
|
164
|
+
const relSymbol = getRelationshipSymbol(ref.type);
|
|
165
|
+
const refAttrs = [];
|
|
166
|
+
if (ref.swapEdge) {
|
|
167
|
+
refAttrs.push('swap_edge: true');
|
|
168
|
+
}
|
|
169
|
+
const attrStr = refAttrs.length > 0 ? ` [${refAttrs.join(', ')}]` : '';
|
|
170
|
+
airDml += `Ref: ${escapeIdentifier(fromTable.name)}.${escapeIdentifier(ref.fromColumn)} ${relSymbol} ${escapeIdentifier(toTable.name)}.${escapeIdentifier(ref.toColumn)}${attrStr}\n`;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
airDml += '\n';
|
|
174
|
+
if (diagram.areas && diagram.areas.length > 0) {
|
|
175
|
+
diagram.areas.forEach((area) => {
|
|
176
|
+
const tablesInArea = diagram.tables.filter(t => t.areaIds?.includes(area.id));
|
|
177
|
+
const tableNames = tablesInArea
|
|
178
|
+
.map(table => escapeIdentifier(table.name))
|
|
179
|
+
.filter(Boolean);
|
|
180
|
+
if (tableNames.length > 0) {
|
|
181
|
+
const areaAttrs = [];
|
|
182
|
+
if (area.pos) {
|
|
183
|
+
areaAttrs.push(`pos_x: ${area.pos.x}`);
|
|
184
|
+
areaAttrs.push(`pos_y: ${area.pos.y}`);
|
|
185
|
+
}
|
|
186
|
+
if (area.width) {
|
|
187
|
+
areaAttrs.push(`width: ${area.width}`);
|
|
188
|
+
}
|
|
189
|
+
if (area.height) {
|
|
190
|
+
areaAttrs.push(`height: ${area.height}`);
|
|
191
|
+
}
|
|
192
|
+
if (area.color) {
|
|
193
|
+
areaAttrs.push(`color: "${area.color}"`);
|
|
194
|
+
}
|
|
195
|
+
if (area.databaseType) {
|
|
196
|
+
areaAttrs.push(`database_type: "${area.databaseType}"`);
|
|
197
|
+
}
|
|
198
|
+
if (area.note) {
|
|
199
|
+
areaAttrs.push(`note: "${area.note.replace(/"/g, '\\"')}"`);
|
|
200
|
+
}
|
|
201
|
+
const attrStr = areaAttrs.length > 0 ? ` [${areaAttrs.join(', ')}]` : '';
|
|
202
|
+
airDml += `Area ${escapeIdentifier(area.name)}${attrStr} {\n`;
|
|
203
|
+
tableNames.forEach((name) => {
|
|
204
|
+
airDml += ` ${name}\n`;
|
|
205
|
+
});
|
|
206
|
+
if (area.commonColumns && area.commonColumns.length > 0) {
|
|
207
|
+
airDml += `\n CommonColumns: [\n`;
|
|
208
|
+
area.commonColumns.forEach((column) => {
|
|
209
|
+
const constraints = [];
|
|
210
|
+
if (column.pk)
|
|
211
|
+
constraints.push('pk');
|
|
212
|
+
if (column.fk)
|
|
213
|
+
constraints.push('fk');
|
|
214
|
+
if (column.unique)
|
|
215
|
+
constraints.push('unique');
|
|
216
|
+
if (column.notNull)
|
|
217
|
+
constraints.push('not null');
|
|
218
|
+
if (column.increment)
|
|
219
|
+
constraints.push('increment');
|
|
220
|
+
if (column.default)
|
|
221
|
+
constraints.push(`default: ${column.default}`);
|
|
222
|
+
if (column.logicalName) {
|
|
223
|
+
constraints.push(`alias: "${escapeString(column.logicalName)}"`);
|
|
224
|
+
}
|
|
225
|
+
const typeStr = column.typeParams
|
|
226
|
+
? `${column.type}(${column.typeParams})`
|
|
227
|
+
: column.type;
|
|
228
|
+
const constraintStr = constraints.length > 0 ? ` [${constraints.join(', ')}]` : '';
|
|
229
|
+
airDml += ` ${escapeIdentifier(column.name)} ${typeStr}${constraintStr}\n`;
|
|
230
|
+
});
|
|
231
|
+
airDml += ` ]\n`;
|
|
232
|
+
}
|
|
233
|
+
airDml += `}\n\n`;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
return airDml.trim();
|
|
238
|
+
}
|
|
239
|
+
function parseTableAttributes(airDmlText) {
|
|
240
|
+
const result = new Map();
|
|
241
|
+
const tableRegex = /Table\s+(["`]?)(\w+)\1\s*\[([^\]]+)\]/g;
|
|
242
|
+
let match;
|
|
243
|
+
while ((match = tableRegex.exec(airDmlText)) !== null) {
|
|
244
|
+
const tableName = match[2];
|
|
245
|
+
const attrsStr = match[3];
|
|
246
|
+
const attrs = parseAttributesString(attrsStr);
|
|
247
|
+
result.set(tableName, attrs);
|
|
248
|
+
}
|
|
249
|
+
return result;
|
|
250
|
+
}
|
|
251
|
+
function parseColumnAttributes(airDmlText) {
|
|
252
|
+
const result = new Map();
|
|
253
|
+
const tableBlocks = airDmlText.split(/Table\s+/);
|
|
254
|
+
tableBlocks.forEach((block) => {
|
|
255
|
+
const tableNameMatch = block.match(/^(["`]?)(\w+)\1\s*(?:\[[^\]]*\])?\s*\{/);
|
|
256
|
+
if (!tableNameMatch)
|
|
257
|
+
return;
|
|
258
|
+
const tableName = tableNameMatch[2];
|
|
259
|
+
const columnRegex = /^\s*(["`]?)(\w+)\1\s+\w+(?:\([^)]*\))?\s*\[([^\]]+)\]/gm;
|
|
260
|
+
let colMatch;
|
|
261
|
+
while ((colMatch = columnRegex.exec(block)) !== null) {
|
|
262
|
+
const columnName = colMatch[2];
|
|
263
|
+
const attrsStr = colMatch[3];
|
|
264
|
+
const attrs = parseAttributesString(attrsStr);
|
|
265
|
+
if (attrs.alias || attrs.fk !== undefined) {
|
|
266
|
+
result.set(`${tableName}.${columnName}`, attrs);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
return result;
|
|
271
|
+
}
|
|
272
|
+
function parseAreaAttributes(airDmlText) {
|
|
273
|
+
const result = new Map();
|
|
274
|
+
const areaRegex = /Area\s+(["`]?)(\w+)\1\s*\[([^\]]+)\]/g;
|
|
275
|
+
let match;
|
|
276
|
+
while ((match = areaRegex.exec(airDmlText)) !== null) {
|
|
277
|
+
const areaName = match[2];
|
|
278
|
+
const attrsStr = match[3];
|
|
279
|
+
const attrs = parseAttributesString(attrsStr);
|
|
280
|
+
result.set(areaName, attrs);
|
|
281
|
+
}
|
|
282
|
+
return result;
|
|
283
|
+
}
|
|
284
|
+
function parseAreaCommonColumns(airDmlText, areaName) {
|
|
285
|
+
const areaBlockRegex = new RegExp(`Area\\s+(["\`]?)${areaName}\\1\\s*(?:\\[[^\\]]*\\])?\\s*\\{([^}]*)\\}`, 's');
|
|
286
|
+
const areaMatch = areaBlockRegex.exec(airDmlText);
|
|
287
|
+
if (!areaMatch)
|
|
288
|
+
return undefined;
|
|
289
|
+
const areaContent = areaMatch[2];
|
|
290
|
+
const commonColumnsRegex = /CommonColumns:?\s*\[([^\]]*)\]/s;
|
|
291
|
+
const commonColumnsMatch = commonColumnsRegex.exec(areaContent);
|
|
292
|
+
if (!commonColumnsMatch)
|
|
293
|
+
return undefined;
|
|
294
|
+
const columnsContent = commonColumnsMatch[1];
|
|
295
|
+
const columns = [];
|
|
296
|
+
const columnLines = columnsContent.split('\n').map(line => line.trim()).filter(line => line && !line.startsWith('//'));
|
|
297
|
+
for (const line of columnLines) {
|
|
298
|
+
const columnMatch = line.match(/^(["`]?)(\w+)\1\s+(\w+)(?:\(([^)]+)\))?\s*(?:\[([^\]]+)\])?/);
|
|
299
|
+
if (!columnMatch)
|
|
300
|
+
continue;
|
|
301
|
+
const columnName = columnMatch[2];
|
|
302
|
+
const typeName = columnMatch[3];
|
|
303
|
+
const typeParams = columnMatch[4];
|
|
304
|
+
const constraintsStr = columnMatch[5] || '';
|
|
305
|
+
const column = {
|
|
306
|
+
name: columnName,
|
|
307
|
+
type: mapDbmlTypeToDataType(typeName),
|
|
308
|
+
typeParams,
|
|
309
|
+
pk: /\bpk\b/.test(constraintsStr),
|
|
310
|
+
fk: /\bfk\b/.test(constraintsStr),
|
|
311
|
+
unique: /\bunique\b/.test(constraintsStr),
|
|
312
|
+
notNull: /\bnot\s+null\b/.test(constraintsStr),
|
|
313
|
+
increment: /\bincrement\b/.test(constraintsStr),
|
|
314
|
+
};
|
|
315
|
+
const aliasMatch = constraintsStr.match(/alias\s*:\s*"([^"]*)"/);
|
|
316
|
+
if (aliasMatch) {
|
|
317
|
+
column.logicalName = aliasMatch[1];
|
|
318
|
+
}
|
|
319
|
+
const defaultMatch = constraintsStr.match(/default\s*:\s*([^,\]]+)/);
|
|
320
|
+
if (defaultMatch) {
|
|
321
|
+
column.default = defaultMatch[1].trim();
|
|
322
|
+
}
|
|
323
|
+
columns.push(column);
|
|
324
|
+
}
|
|
325
|
+
return columns.length > 0 ? columns : undefined;
|
|
326
|
+
}
|
|
327
|
+
function parseReferenceAttributes(airDmlText) {
|
|
328
|
+
const result = new Map();
|
|
329
|
+
const refRegex = /Ref\s*:\s*(["`]?)(\w+)\1\.(["`]?)(\w+)\3\s*[<>\-~]+\s*(["`]?)(\w+)\5\.(["`]?)(\w+)\7\s*\[([^\]]+)\]/g;
|
|
330
|
+
let match;
|
|
331
|
+
while ((match = refRegex.exec(airDmlText)) !== null) {
|
|
332
|
+
const fromTable = match[2];
|
|
333
|
+
const fromColumn = match[4];
|
|
334
|
+
const toTable = match[6];
|
|
335
|
+
const toColumn = match[8];
|
|
336
|
+
const attrsStr = match[9];
|
|
337
|
+
const attrs = parseAttributesString(attrsStr);
|
|
338
|
+
const refKey = `${fromTable}.${fromColumn}-${toTable}.${toColumn}`;
|
|
339
|
+
result.set(refKey, attrs);
|
|
340
|
+
}
|
|
341
|
+
return result;
|
|
342
|
+
}
|
|
343
|
+
function parseAttributesString(attrsStr) {
|
|
344
|
+
const attrs = {};
|
|
345
|
+
const aliasMatch = attrsStr.match(/alias\s*:\s*"([^"]*)"/);
|
|
346
|
+
if (aliasMatch)
|
|
347
|
+
attrs.alias = aliasMatch[1];
|
|
348
|
+
const posXMatch = attrsStr.match(/pos_x\s*:\s*(-?\d+(?:\.\d+)?)/);
|
|
349
|
+
if (posXMatch)
|
|
350
|
+
attrs.pos_x = parseFloat(posXMatch[1]);
|
|
351
|
+
const posYMatch = attrsStr.match(/pos_y\s*:\s*(-?\d+(?:\.\d+)?)/);
|
|
352
|
+
if (posYMatch)
|
|
353
|
+
attrs.pos_y = parseFloat(posYMatch[1]);
|
|
354
|
+
const widthMatch = attrsStr.match(/width\s*:\s*(-?\d+(?:\.\d+)?)/);
|
|
355
|
+
if (widthMatch)
|
|
356
|
+
attrs.width = parseFloat(widthMatch[1]);
|
|
357
|
+
const heightMatch = attrsStr.match(/height\s*:\s*(-?\d+(?:\.\d+)?)/);
|
|
358
|
+
if (heightMatch)
|
|
359
|
+
attrs.height = parseFloat(heightMatch[1]);
|
|
360
|
+
const colorMatch = attrsStr.match(/color\s*:\s*"([^"]*)"/);
|
|
361
|
+
if (colorMatch)
|
|
362
|
+
attrs.color = colorMatch[1];
|
|
363
|
+
const databaseTypeMatch = attrsStr.match(/database_type\s*:\s*"([^"]*)"/);
|
|
364
|
+
if (databaseTypeMatch)
|
|
365
|
+
attrs.database_type = databaseTypeMatch[1];
|
|
366
|
+
const noteMatch = attrsStr.match(/note\s*:\s*"([^"]*)"/);
|
|
367
|
+
if (noteMatch)
|
|
368
|
+
attrs.note = noteMatch[1];
|
|
369
|
+
const swapEdgeMatch = attrsStr.match(/swap_edge\s*:\s*(true|false)/);
|
|
370
|
+
if (swapEdgeMatch)
|
|
371
|
+
attrs.swap_edge = swapEdgeMatch[1] === 'true';
|
|
372
|
+
if (/\bfk\b/.test(attrsStr))
|
|
373
|
+
attrs.fk = true;
|
|
374
|
+
return attrs;
|
|
375
|
+
}
|
|
376
|
+
function mapDbmlTypeToDataType(dbmlType) {
|
|
377
|
+
const typeMap = {
|
|
378
|
+
int: 'integer',
|
|
379
|
+
integer: 'integer',
|
|
380
|
+
bigint: 'bigint',
|
|
381
|
+
smallint: 'smallint',
|
|
382
|
+
serial: 'serial',
|
|
383
|
+
bigserial: 'bigserial',
|
|
384
|
+
varchar: 'varchar',
|
|
385
|
+
char: 'char',
|
|
386
|
+
text: 'text',
|
|
387
|
+
boolean: 'boolean',
|
|
388
|
+
bool: 'boolean',
|
|
389
|
+
date: 'date',
|
|
390
|
+
time: 'time',
|
|
391
|
+
timestamp: 'timestamp',
|
|
392
|
+
timestamptz: 'timestamptz',
|
|
393
|
+
numeric: 'numeric',
|
|
394
|
+
decimal: 'decimal',
|
|
395
|
+
real: 'real',
|
|
396
|
+
double: 'double precision',
|
|
397
|
+
json: 'json',
|
|
398
|
+
jsonb: 'jsonb',
|
|
399
|
+
uuid: 'uuid',
|
|
400
|
+
bytea: 'bytea',
|
|
401
|
+
};
|
|
402
|
+
return typeMap[dbmlType.toLowerCase()] || 'text';
|
|
403
|
+
}
|
|
404
|
+
function mapDbmlRelationType(relType) {
|
|
405
|
+
if (relType === '<')
|
|
406
|
+
return 'many-to-one';
|
|
407
|
+
if (relType === '>')
|
|
408
|
+
return 'one-to-many';
|
|
409
|
+
if (relType === '-')
|
|
410
|
+
return 'one-to-one';
|
|
411
|
+
if (relType === '<>' || relType === '><')
|
|
412
|
+
return 'many-to-many';
|
|
413
|
+
if (relType === '~')
|
|
414
|
+
return 'any';
|
|
415
|
+
return 'many-to-one';
|
|
416
|
+
}
|
|
417
|
+
function getRelationshipSymbol(relType) {
|
|
418
|
+
if (relType === 'many-to-one')
|
|
419
|
+
return '<';
|
|
420
|
+
if (relType === 'one-to-many')
|
|
421
|
+
return '>';
|
|
422
|
+
if (relType === 'one-to-one')
|
|
423
|
+
return '-';
|
|
424
|
+
if (relType === 'many-to-many')
|
|
425
|
+
return '><';
|
|
426
|
+
if (relType === 'any')
|
|
427
|
+
return '~';
|
|
428
|
+
return '<';
|
|
429
|
+
}
|
|
430
|
+
function escapeIdentifier(name) {
|
|
431
|
+
if (/[^a-zA-Z0-9_]/.test(name)) {
|
|
432
|
+
return `"${name.replace(/"/g, '\\"')}"`;
|
|
433
|
+
}
|
|
434
|
+
return name;
|
|
435
|
+
}
|
|
436
|
+
function escapeString(str) {
|
|
437
|
+
if (!str)
|
|
438
|
+
return '';
|
|
439
|
+
return str.replace(/'/g, "\\'").replace(/\n/g, '\\n');
|
|
440
|
+
}
|
|
441
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":";;AAuCA,kCAkIC;AAOD,wCA2JC;AArUD,qCAAoC;AAiCpC,SAAgB,WAAW,CAAC,UAAkB,EAAE,SAAkB;IAChE,MAAM,MAAM,GAAG,IAAI,aAAM,EAAE,CAAC;IAC5B,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAGlD,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,IAAI,kBAAkB,CAAC;IACpD,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,IAAI,YAAY,CAAC;IAG3D,MAAM,eAAe,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC;IACzD,MAAM,gBAAgB,GAAG,qBAAqB,CAAC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CAAC;IAC1C,IAAI,OAAO,KAAK,GAAG;QAAE,OAAO,YAAY,CAAC;IACzC,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,cAAc,CAAC;IAChE,IAAI,OAAO,KAAK,GAAG;QAAE,OAAO,KAAK,CAAC;IAClC,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,SAAS,qBAAqB,CAAC,OAA0B;IACvD,IAAI,OAAO,KAAK,aAAa;QAAE,OAAO,GAAG,CAAC;IAC1C,IAAI,OAAO,KAAK,aAAa;QAAE,OAAO,GAAG,CAAC;IAC1C,IAAI,OAAO,KAAK,YAAY;QAAE,OAAO,GAAG,CAAC;IACzC,IAAI,OAAO,KAAK,cAAc;QAAE,OAAO,IAAI,CAAC;IAC5C,IAAI,OAAO,KAAK,KAAK;QAAE,OAAO,GAAG,CAAC;IAClC,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY;IACpC,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC;IAC1C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,YAAY,CAAC,GAAuB;IAC3C,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export interface Position {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
export type DataType = 'integer' | 'bigint' | 'smallint' | 'serial' | 'bigserial' | 'varchar' | 'text' | 'char' | 'boolean' | 'date' | 'timestamp' | 'timestamptz' | 'time' | 'json' | 'jsonb' | 'uuid' | 'decimal' | 'numeric' | 'real' | 'double precision' | 'bytea' | string;
|
|
6
|
+
export interface Column {
|
|
7
|
+
name: string;
|
|
8
|
+
logicalName?: string;
|
|
9
|
+
type: DataType;
|
|
10
|
+
typeParams?: string;
|
|
11
|
+
pk?: boolean;
|
|
12
|
+
fk?: boolean;
|
|
13
|
+
unique?: boolean;
|
|
14
|
+
notNull?: boolean;
|
|
15
|
+
default?: string;
|
|
16
|
+
increment?: boolean;
|
|
17
|
+
note?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface Table {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
logicalName?: string;
|
|
23
|
+
columns: Column[];
|
|
24
|
+
color?: string;
|
|
25
|
+
pos?: Position;
|
|
26
|
+
areaIds?: string[];
|
|
27
|
+
note?: string;
|
|
28
|
+
}
|
|
29
|
+
export type Cardinality = '1' | 'n' | '0..1' | '1..n' | '0..n';
|
|
30
|
+
export type RelationshipType = 'one-to-one' | 'one-to-many' | 'many-to-one' | 'many-to-many' | 'any';
|
|
31
|
+
export interface Reference {
|
|
32
|
+
id: string;
|
|
33
|
+
fromTable: string;
|
|
34
|
+
fromColumn: string;
|
|
35
|
+
toTable: string;
|
|
36
|
+
toColumn: string;
|
|
37
|
+
type?: RelationshipType;
|
|
38
|
+
fromCardinality?: Cardinality;
|
|
39
|
+
toCardinality?: Cardinality;
|
|
40
|
+
swapEdge?: boolean;
|
|
41
|
+
note?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface Area {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
color?: string;
|
|
47
|
+
pos?: Position;
|
|
48
|
+
width?: number;
|
|
49
|
+
height?: number;
|
|
50
|
+
labelHorizontal?: 'left' | 'center' | 'right';
|
|
51
|
+
labelVertical?: 'top' | 'center' | 'bottom';
|
|
52
|
+
databaseType?: 'PostgreSQL' | 'MySQL' | 'SQLite' | 'SQL Server' | 'Oracle' | 'BigQuery' | 'Redshift' | string;
|
|
53
|
+
commonColumns?: Column[];
|
|
54
|
+
note?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface Diagram {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
project?: string;
|
|
60
|
+
database?: 'PostgreSQL' | 'MySQL' | 'SQLite' | 'SQL Server' | 'Oracle' | string;
|
|
61
|
+
tables: Table[];
|
|
62
|
+
references: Reference[];
|
|
63
|
+
areas?: Area[];
|
|
64
|
+
createdAt?: string;
|
|
65
|
+
updatedAt?: string;
|
|
66
|
+
note?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface ParseResult {
|
|
69
|
+
success: boolean;
|
|
70
|
+
diagram?: Diagram;
|
|
71
|
+
error?: string;
|
|
72
|
+
warnings?: string[];
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAMD,MAAM,MAAM,QAAQ,GAChB,SAAS,GACT,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,WAAW,GACX,SAAS,GACT,MAAM,GACN,MAAM,GACN,SAAS,GACT,MAAM,GACN,WAAW,GACX,aAAa,GACb,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,SAAS,GACT,SAAS,GACT,MAAM,GACN,kBAAkB,GAClB,OAAO,GACP,MAAM,CAAC;AAKX,MAAM,WAAW,MAAM;IAErB,IAAI,EAAE,MAAM,CAAC;IAGb,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,IAAI,EAAE,QAAQ,CAAC;IAGf,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,EAAE,CAAC,EAAE,OAAO,CAAC;IAGb,EAAE,CAAC,EAAE,OAAO,CAAC;IAGb,MAAM,CAAC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"description": "AI-Ready Data Modeling Language - Extended DBML parser for AI-driven development",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
15
|
+
"prepublishOnly": "npm run build",
|
|
16
|
+
"clean": "rm -rf dist"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"air-dml",
|
|
20
|
+
"dbml",
|
|
21
|
+
"database",
|
|
22
|
+
"erd",
|
|
23
|
+
"schema",
|
|
24
|
+
"ai",
|
|
25
|
+
"data-modeling",
|
|
26
|
+
"parser",
|
|
27
|
+
"database-design",
|
|
28
|
+
"ai-ready",
|
|
29
|
+
"llm",
|
|
30
|
+
"mode-ai"
|
|
31
|
+
],
|
|
32
|
+
"author": "Data-mination Partners",
|
|
33
|
+
"license": "Apache-2.0",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/hiroaki-handa/air-dml.git"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/hiroaki-handa/air-dml#readme",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/hiroaki-handa/air-dml/issues"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@dbml/core": "^5.3.1"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"typescript": "^5.0.0",
|
|
47
|
+
"@types/node": "^20.0.0"
|
|
48
|
+
},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=18.0.0"
|
|
51
|
+
}
|
|
52
|
+
}
|