@rdbms-erd/core 0.1.0 → 0.1.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/README.md +67 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @rdbms-erd/core
|
|
2
|
+
|
|
3
|
+
Core model and SQL utilities for relational ERD tooling.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @rdbms-erd/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What This Package Provides
|
|
12
|
+
|
|
13
|
+
- Design document types (`DesignDocument`, `DesignModel`, `TableModel`, `ColumnModel`, ...)
|
|
14
|
+
- Document lifecycle helpers (`createEmptyDesign`, `serializeDesign`, `parseDesign`, `validateDesignDocument`)
|
|
15
|
+
- SQL generation (`generateDdl`, `generateIndexDdl`)
|
|
16
|
+
- Diagnostic helpers (`analyzeDdlDocument`, `generateDdlWithDiagnostics`, `formatDdlDiagnostics`)
|
|
17
|
+
- Canvas alignment utility (`alignNodePositions`)
|
|
18
|
+
- Large sample generator (`createLargeDesign`)
|
|
19
|
+
|
|
20
|
+
## Quick Example
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import {
|
|
24
|
+
createEmptyDesign,
|
|
25
|
+
createColumn,
|
|
26
|
+
generateDdl,
|
|
27
|
+
type DesignDocument,
|
|
28
|
+
} from "@rdbms-erd/core";
|
|
29
|
+
|
|
30
|
+
const doc: DesignDocument = createEmptyDesign("postgres");
|
|
31
|
+
|
|
32
|
+
doc.model.tables.push({
|
|
33
|
+
id: "table-users",
|
|
34
|
+
logicalName: "Users",
|
|
35
|
+
physicalName: "users",
|
|
36
|
+
columns: [
|
|
37
|
+
createColumn("postgres", {
|
|
38
|
+
id: "col-users-id",
|
|
39
|
+
logicalName: "ID",
|
|
40
|
+
physicalName: "id",
|
|
41
|
+
logicalType: "NUMBER",
|
|
42
|
+
nullable: false,
|
|
43
|
+
isPrimaryKey: true,
|
|
44
|
+
}),
|
|
45
|
+
createColumn("postgres", {
|
|
46
|
+
id: "col-users-email",
|
|
47
|
+
logicalName: "Email",
|
|
48
|
+
physicalName: "email",
|
|
49
|
+
logicalType: "TEXT",
|
|
50
|
+
nullable: false,
|
|
51
|
+
}),
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const sql = generateDdl(doc);
|
|
56
|
+
console.log(sql);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## API Reference
|
|
60
|
+
|
|
61
|
+
See the repository docs for symbol-level details:
|
|
62
|
+
|
|
63
|
+
- `docs/API.md`
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
MIT
|