Skip to content

Commit b1a295f

Browse files
committed
Restore dataschema diagram generation
1 parent b9e18db commit b1a295f

File tree

4 files changed

+86
-2
lines changed

4 files changed

+86
-2
lines changed

internal/datastore/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
"testcontainers": "^11.4.0",
2020
"ts-jest": "^29.4.0",
2121
"ts-node": "^10.9.2",
22-
"typescript": "^5.8.3"
22+
"typescript": "^5.8.3",
23+
"zod-mermaid": "^1.0.9"
2324
},
2425
"license": "MIT",
2526
"main": "src/index.ts",
2627
"name": "@internal/datastore",
2728
"private": true,
2829
"scripts": {
30+
"diagrams": "tsx src/cli/diagrams.ts",
2931
"lint": "eslint .",
3032
"lint:fix": "eslint . --fix",
3133
"test:unit": "jest",
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { LetterSchema, MISchema } from '../types';
2+
import { generateMermaidDiagram } from 'zod-mermaid';
3+
import * as fs from 'node:fs';
4+
5+
const out = fs.openSync('src/types.md', 'w');
6+
7+
fs.writeSync(out, `# Data Store Schemas
8+
9+
This document contains the mermaid diagrams for the data store schemas used in the application.
10+
11+
The schemas are generated from Zod definitions and provide a visual representation of the data structure.
12+
`);
13+
14+
for (const [name, schema] of Object.entries({ Letter: [LetterSchema], MI: [MISchema] })) {
15+
const mermaid = generateMermaidDiagram(schema);
16+
fs.writeSync(out, `
17+
## ${name} schema
18+
19+
\`\`\`mermaid
20+
${mermaid}
21+
\`\`\`
22+
`);
23+
}
24+
25+
fs.closeSync(out);

internal/datastore/src/types.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Data Store Schemas
2+
3+
This document contains the mermaid diagrams for the data store schemas used in the application.
4+
5+
The schemas are generated from Zod definitions and provide a visual representation of the data structure.
6+
7+
## Letter schema
8+
9+
```mermaid
10+
erDiagram
11+
Letter {
12+
string id
13+
string status "enum: PENDING, ACCEPTED, REJECTED, PRINTED, ENCLOSED, CANCELLED, DISPATCHED, FAILED, RETURNED, DESTROYED, FORWARDED, DELIVERED"
14+
string specificationId
15+
string groupId
16+
number reasonCode
17+
string reasonText
18+
string supplierId
19+
string url "url"
20+
string createdAt
21+
string updatedAt
22+
string supplierStatus
23+
string supplierStatusSk
24+
number ttl "min: -9007199254740991, max: 9007199254740991"
25+
}
26+
```
27+
28+
## MI schema
29+
30+
```mermaid
31+
erDiagram
32+
MI {
33+
string id
34+
string supplierId
35+
string specificationId
36+
string groupId
37+
string lineItem
38+
number quantity
39+
number stockRemaining
40+
string createdAt
41+
string updatedAt
42+
}
43+
```

package-lock.json

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)