air-dml 1.2.3 → 1.2.4
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/README.md +140 -80
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
**AI-Ready Data Modeling Language**
|
|
4
4
|
|
|
5
|
+
*The Open Standard for AI-Ready Data Modeling*
|
|
6
|
+
|
|
5
7
|
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
8
|
|
|
7
9
|
[](https://www.npmjs.com/package/air-dml)
|
|
@@ -15,6 +17,7 @@ AIR-DML is an extended DBML (Database Markup Language) parser designed for AI-dr
|
|
|
15
17
|
🎨 **Visual Design**: Coordinate and color information for diagram rendering
|
|
16
18
|
🔄 **Polyglot Persistence**: Different database types per area
|
|
17
19
|
📦 **Extends DBML**: Fully compatible with standard DBML, powered by `@dbml/core`
|
|
20
|
+
💬 **Comment Preservation**: Leading comments are preserved and associated with elements
|
|
18
21
|
|
|
19
22
|
## Installation
|
|
20
23
|
|
|
@@ -33,6 +36,7 @@ Project "My Project" {
|
|
|
33
36
|
database_type: 'PostgreSQL'
|
|
34
37
|
}
|
|
35
38
|
|
|
39
|
+
// ユーザー管理
|
|
36
40
|
Table users [alias: "ユーザー", pos_x: 100, pos_y: 100, color: "#1976D2"] {
|
|
37
41
|
id serial [pk, alias: "ユーザーID"]
|
|
38
42
|
username varchar(100) [not null, unique, alias: "ユーザー名"]
|
|
@@ -40,20 +44,34 @@ Table users [alias: "ユーザー", pos_x: 100, pos_y: 100, color: "#1976D2"] {
|
|
|
40
44
|
created_at timestamp [not null, alias: "作成日時"]
|
|
41
45
|
}
|
|
42
46
|
|
|
47
|
+
// プロフィール情報
|
|
48
|
+
Table profiles [alias: "プロフィール", pos_x: 500, pos_y: 100] {
|
|
49
|
+
id serial [pk, alias: "プロフィールID"]
|
|
50
|
+
user_id integer [fk, not null, unique, alias: "ユーザーID"]
|
|
51
|
+
full_name varchar(200) [alias: "氏名"]
|
|
52
|
+
bio text [alias: "自己紹介"]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
Ref: profiles.user_id - users.id
|
|
56
|
+
|
|
43
57
|
Area "User Management" [
|
|
44
58
|
pos_x: 50,
|
|
45
59
|
pos_y: 50,
|
|
46
60
|
width: 600,
|
|
47
61
|
height: 300,
|
|
48
|
-
color: "#1976D2"
|
|
49
|
-
database_type: "PostgreSQL"
|
|
62
|
+
color: "#1976D2"
|
|
50
63
|
] {
|
|
51
64
|
users
|
|
65
|
+
profiles
|
|
66
|
+
|
|
67
|
+
database_type: "PostgreSQL"
|
|
52
68
|
|
|
53
69
|
CommonColumns: [
|
|
54
70
|
created_at timestamp [not null, alias: "作成日時"]
|
|
55
71
|
updated_at timestamp [not null, alias: "更新日時"]
|
|
56
72
|
]
|
|
73
|
+
|
|
74
|
+
Note: "ユーザー管理領域"
|
|
57
75
|
}
|
|
58
76
|
`;
|
|
59
77
|
|
|
@@ -65,93 +83,93 @@ const output = exportToAirDML(diagram);
|
|
|
65
83
|
console.log(output);
|
|
66
84
|
```
|
|
67
85
|
|
|
68
|
-
## AIR-DML
|
|
69
|
-
|
|
70
|
-
AIR-DML extends standard DBML with the following features:
|
|
86
|
+
## AIR-DML Syntax
|
|
71
87
|
|
|
72
|
-
###
|
|
73
|
-
|
|
74
|
-
Add human-readable names in any language:
|
|
88
|
+
### Table Definition
|
|
75
89
|
|
|
76
90
|
```dbml
|
|
77
|
-
Table
|
|
78
|
-
|
|
79
|
-
|
|
91
|
+
Table table_name [alias: "論理名", pos_x: 100, pos_y: 200, color: "#1976D2"] {
|
|
92
|
+
column_name data_type [constraints, alias: "カラム論理名"]
|
|
93
|
+
|
|
94
|
+
Note: "テーブルの説明"
|
|
80
95
|
}
|
|
81
96
|
```
|
|
82
97
|
|
|
83
|
-
###
|
|
98
|
+
### Column Constraints
|
|
84
99
|
|
|
85
|
-
|
|
100
|
+
| Constraint | Description | Example |
|
|
101
|
+
|------------|-------------|---------|
|
|
102
|
+
| `pk` | Primary Key | `id serial [pk]` |
|
|
103
|
+
| `fk` | Foreign Key (use with Ref) | `user_id integer [fk]` |
|
|
104
|
+
| `unique` | Unique constraint | `email varchar [unique]` |
|
|
105
|
+
| `not null` | NOT NULL constraint | `name varchar [not null]` |
|
|
106
|
+
| `increment` | Auto increment | `id integer [pk, increment]` |
|
|
107
|
+
| `default: value` | Default value | `status text [default: 'active']` |
|
|
108
|
+
| `alias: "name"` | Logical name | `[alias: "ユーザーID"]` |
|
|
109
|
+
| `note: "desc"` | Column description | `[note: "説明"]` |
|
|
110
|
+
|
|
111
|
+
### Relationships
|
|
86
112
|
|
|
87
113
|
```dbml
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
114
|
+
Ref: table_a.column > table_b.column // Many-to-One (A → B)
|
|
115
|
+
Ref: table_a.column < table_b.column // One-to-Many (A ← B)
|
|
116
|
+
Ref: table_a.column - table_b.column // One-to-One
|
|
117
|
+
Ref: table_a.column >< table_b.column // Many-to-Many
|
|
118
|
+
Ref: table_a.column ~ table_b.column // AI-inferred (undetermined)
|
|
91
119
|
```
|
|
92
120
|
|
|
93
|
-
###
|
|
94
|
-
|
|
95
|
-
Group related tables into logical domains:
|
|
121
|
+
### Area (Bounded Context)
|
|
96
122
|
|
|
97
123
|
```dbml
|
|
98
|
-
Area "
|
|
124
|
+
Area "Area Name" [
|
|
99
125
|
pos_x: 50,
|
|
100
126
|
pos_y: 50,
|
|
101
127
|
width: 600,
|
|
102
128
|
height: 300,
|
|
103
|
-
color: "#1976D2"
|
|
104
|
-
database_type: "PostgreSQL",
|
|
105
|
-
note: "User authentication and profile management"
|
|
129
|
+
color: "#1976D2"
|
|
106
130
|
] {
|
|
107
|
-
|
|
108
|
-
|
|
131
|
+
table1
|
|
132
|
+
table2
|
|
133
|
+
|
|
134
|
+
database_type: "PostgreSQL"
|
|
109
135
|
|
|
110
136
|
CommonColumns: [
|
|
111
|
-
created_at timestamp [not null]
|
|
112
|
-
updated_at timestamp [not null]
|
|
137
|
+
created_at timestamp [not null, alias: "作成日時"]
|
|
138
|
+
updated_at timestamp [not null, alias: "更新日時"]
|
|
113
139
|
]
|
|
140
|
+
|
|
141
|
+
Note: "Area description"
|
|
114
142
|
}
|
|
115
143
|
```
|
|
116
144
|
|
|
117
|
-
|
|
145
|
+
## AI Generation Guidelines
|
|
118
146
|
|
|
119
|
-
|
|
147
|
+
When using AI to generate AIR-DML, follow these rules:
|
|
120
148
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
149
|
+
**Required:**
|
|
150
|
+
- Use **double quotes** for alias values: `alias: "論理名"` ✅
|
|
151
|
+
- Do NOT use single quotes: `alias: '論理名'` ❌
|
|
152
|
+
- Mark foreign key columns with `[fk]`
|
|
153
|
+
- Define relationships separately with `Ref:`
|
|
154
|
+
- Do NOT add inline comments after column definitions
|
|
125
155
|
|
|
126
|
-
|
|
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:
|
|
156
|
+
**Example Output:**
|
|
137
157
|
|
|
138
158
|
```dbml
|
|
139
|
-
|
|
140
|
-
|
|
159
|
+
// 定期購入機能
|
|
160
|
+
Table subscriptions [alias: "定期購入"] {
|
|
161
|
+
id serial [pk, alias: "定期購入ID"]
|
|
162
|
+
user_id integer [fk, not null, alias: "ユーザーID"]
|
|
163
|
+
product_id integer [fk, not null, alias: "商品ID"]
|
|
164
|
+
status text [not null, default: 'active', alias: "ステータス"]
|
|
165
|
+
created_at timestamp [not null, alias: "作成日時"]
|
|
141
166
|
}
|
|
142
167
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
168
|
+
Ref: subscriptions.user_id > users.id
|
|
169
|
+
Ref: subscriptions.product_id > products.id
|
|
146
170
|
```
|
|
147
171
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
Use `~` for undetermined relationships (AI inference):
|
|
151
|
-
|
|
152
|
-
```dbml
|
|
153
|
-
Ref: users.id ~ profiles.user_id
|
|
154
|
-
```
|
|
172
|
+
For complete AI generation guidelines, see [SPECIFICATION.md Section 5](./SPECIFICATION.md#5-ai生成時のガイドライン).
|
|
155
173
|
|
|
156
174
|
## API Reference
|
|
157
175
|
|
|
@@ -193,29 +211,57 @@ interface Diagram {
|
|
|
193
211
|
interface Table {
|
|
194
212
|
id: string;
|
|
195
213
|
name: string;
|
|
196
|
-
logicalName?: string;
|
|
214
|
+
logicalName?: string; // alias
|
|
197
215
|
columns: Column[];
|
|
198
|
-
color?: string;
|
|
199
|
-
pos?: Position;
|
|
200
|
-
areaIds?: string[];
|
|
216
|
+
color?: string;
|
|
217
|
+
pos?: Position;
|
|
218
|
+
areaIds?: string[];
|
|
219
|
+
note?: string;
|
|
220
|
+
leadingComments?: string[]; // v1.2.0+
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
interface Column {
|
|
224
|
+
name: string;
|
|
225
|
+
logicalName?: string; // alias
|
|
226
|
+
type: DataType;
|
|
227
|
+
typeParams?: string;
|
|
228
|
+
pk: boolean;
|
|
229
|
+
fk: boolean;
|
|
230
|
+
unique: boolean;
|
|
231
|
+
notNull: boolean;
|
|
232
|
+
increment: boolean;
|
|
233
|
+
default?: string;
|
|
201
234
|
note?: string;
|
|
202
235
|
}
|
|
203
236
|
|
|
237
|
+
interface Reference {
|
|
238
|
+
id: string;
|
|
239
|
+
fromTable: string;
|
|
240
|
+
fromColumn: string;
|
|
241
|
+
toTable: string;
|
|
242
|
+
toColumn: string;
|
|
243
|
+
type: RelationshipType;
|
|
244
|
+
swapEdge?: boolean;
|
|
245
|
+
leadingComments?: string[]; // v1.2.0+
|
|
246
|
+
}
|
|
247
|
+
|
|
204
248
|
interface Area {
|
|
205
249
|
id: string;
|
|
206
250
|
name: string;
|
|
251
|
+
tables: string[];
|
|
207
252
|
color?: string;
|
|
208
253
|
pos?: Position;
|
|
209
254
|
width?: number;
|
|
210
255
|
height?: number;
|
|
211
|
-
|
|
212
|
-
|
|
256
|
+
labelHorizontal?: 'left' | 'center' | 'right';
|
|
257
|
+
labelVertical?: 'top' | 'center' | 'bottom';
|
|
258
|
+
databaseType?: string;
|
|
259
|
+
commonColumns?: Column[];
|
|
213
260
|
note?: string;
|
|
261
|
+
leadingComments?: string[]; // v1.2.0+
|
|
214
262
|
}
|
|
215
263
|
```
|
|
216
264
|
|
|
217
|
-
See full type definitions in [src/types/index.ts](./src/types/index.ts).
|
|
218
|
-
|
|
219
265
|
## Comparison: DBML vs AIR-DML
|
|
220
266
|
|
|
221
267
|
| Feature | DBML | AIR-DML |
|
|
@@ -226,25 +272,34 @@ See full type definitions in [src/types/index.ts](./src/types/index.ts).
|
|
|
226
272
|
| **Visual info** | ❌ | ✅ Coordinates, colors, sizes |
|
|
227
273
|
| **Multi-DB** | Project-level | Area-level (polyglot persistence) |
|
|
228
274
|
| **AI optimization** | ❌ | ✅ LLM-friendly design |
|
|
275
|
+
| **Comment preservation** | ❌ | ✅ Leading comments (v1.2.0+) |
|
|
229
276
|
|
|
230
|
-
##
|
|
277
|
+
## Changelog
|
|
231
278
|
|
|
232
|
-
|
|
233
|
-
-
|
|
234
|
-
-
|
|
235
|
-
-
|
|
279
|
+
### v1.2.3 (2025-01)
|
|
280
|
+
- Bug fixes for Area parsing with Japanese names
|
|
281
|
+
- Improved comment preservation
|
|
282
|
+
- Added AI generation guidelines to specification
|
|
236
283
|
|
|
237
|
-
|
|
284
|
+
### v1.2.0 (2025-01)
|
|
285
|
+
- Added leading comment preservation for Tables, References, and Areas
|
|
286
|
+
- Added `leadingComments` field to type definitions
|
|
287
|
+
- Export comments back to AIR-DML format
|
|
238
288
|
|
|
239
|
-
|
|
240
|
-
-
|
|
241
|
-
-
|
|
242
|
-
-
|
|
243
|
-
|
|
289
|
+
### v1.1.0 (2025-01)
|
|
290
|
+
- Added `labelHorizontal` and `labelVertical` attributes for Areas
|
|
291
|
+
- Added `swapEdge` attribute for References
|
|
292
|
+
- Improved Area attribute parsing
|
|
293
|
+
|
|
294
|
+
### v1.0.0 (2025-01)
|
|
295
|
+
- Initial release
|
|
296
|
+
- Core AIR-DML parsing and export
|
|
297
|
+
- Support for alias, pos_x, pos_y, color attributes
|
|
298
|
+
- Area with CommonColumns and database_type
|
|
244
299
|
|
|
245
300
|
## Specification
|
|
246
301
|
|
|
247
|
-
For the complete AIR-DML specification, see [
|
|
302
|
+
For the complete AIR-DML specification, see [SPECIFICATION.md](./SPECIFICATION.md).
|
|
248
303
|
|
|
249
304
|
## License
|
|
250
305
|
|
|
@@ -255,16 +310,21 @@ AIR-DML extends [DBML](https://github.com/holistics/dbml) (also Apache-2.0).
|
|
|
255
310
|
## Credits
|
|
256
311
|
|
|
257
312
|
- **Created by**: Data-mination Partners
|
|
258
|
-
- **Technical collaboration**: Claude
|
|
313
|
+
- **Technical collaboration**: Claude Opus 4.5 (Anthropic)
|
|
259
314
|
- **Based on**: [@dbml/core](https://www.npmjs.com/package/@dbml/core) by Holistics
|
|
260
315
|
|
|
261
316
|
## Links
|
|
262
317
|
|
|
263
318
|
- [GitHub Repository](https://github.com/hiroaki-handa/air-dml)
|
|
264
319
|
- [npm Package](https://www.npmjs.com/package/air-dml)
|
|
265
|
-
- [
|
|
266
|
-
- [Mode-ai](https://
|
|
320
|
+
- [AIR-DML Specification](./SPECIFICATION.md)
|
|
321
|
+
- [Mode-ai](https://mode-ai.net) - Reference implementation
|
|
267
322
|
|
|
268
323
|
---
|
|
269
324
|
|
|
270
|
-
|
|
325
|
+
## Trademarks
|
|
326
|
+
|
|
327
|
+
**AIR-DML™** (AI-Ready Data Modeling Language) is a trademark of Datamination Partners Co., Ltd.
|
|
328
|
+
Trademark Application No. 2026-000274 (Japan)
|
|
329
|
+
|
|
330
|
+
*AIR-DML™ — The Open Standard for AI-Ready Data Modeling.*
|