@matserdam/prisma-neighborhood 0.1.0 → 0.3.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # prisma-neighbourhood
2
2
 
3
- Generate focused ERD diagrams from a Prisma schema by starting from one model and traversing relationships up to a configurable depth.
3
+ Generate focused ERD diagrams from a Prisma schema by starting from any entity (model, view, or enum) and traversing relationships up to a configurable depth.
4
4
 
5
5
  The npm package is **`@matserdam/prisma-neighborhood`** and it exposes two CLI commands:
6
6
 
@@ -20,6 +20,12 @@ bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m User
20
20
  # Limit to direct relationships only (depth 1)
21
21
  bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m User -d 1
22
22
 
23
+ # Start from a view (shows view + related enums/models)
24
+ bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m UserSummary -d 2
25
+
26
+ # Start from an enum (shows enum + all models/views using it)
27
+ bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m UserRole -d 2
28
+
23
29
  # Write Mermaid to a file (use .mmd or .md)
24
30
  bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m User -o erd.mmd
25
31
 
@@ -50,7 +56,7 @@ prisma-hood -s ./prisma/schema.prisma -m User
50
56
  | Option | Alias | Description | Default |
51
57
  |--------|-------|-------------|---------|
52
58
  | `--schema <path>` | `-s` | Path to the Prisma schema file | required |
53
- | `--model <name>` | `-m` | Model to start traversal from | required |
59
+ | `--model <name>` | `-m` | Entity to start traversal from (model, view, or enum) | required |
54
60
  | `--depth <n>` | `-d` | Relationship levels to traverse | `3` |
55
61
  | `--renderer <name>` | `-r` | Renderer to use | `vector` |
56
62
  | `--output <file>` | `-o` | Write to a file instead of stdout | stdout |
@@ -69,6 +75,32 @@ The output format is determined by the file extension:
69
75
  | `.png` | PNG image |
70
76
  | `.pdf` | PDF |
71
77
 
72
- ## No Puppeteer / Chromium
78
+ ## Entity types
79
+
80
+ ### Models
81
+ Standard Prisma models are rendered as plain ERD entities.
82
+
83
+ ### Views
84
+ Views (requires `previewFeatures = ["views"]`) are rendered with a `[view]` prefix:
85
+ ```
86
+ "[view] UserSummary" {
87
+ Int id UK
88
+ String email
89
+ }
90
+ ```
91
+
92
+ ### Enums
93
+ Enums are rendered with an `[enum]` prefix, with the enum name as the type for each value:
94
+ ```
95
+ "[enum] UserRole" {
96
+ UserRole ADMIN
97
+ UserRole USER
98
+ UserRole GUEST
99
+ }
100
+ ```
101
+
102
+ ## Traversal behavior
73
103
 
74
- SVG/PNG/PDF export is implemented without headless Chromium, so you no longer need to install OS-level Chromium dependencies.
104
+ - **From a model**: Traverses relations to other models/views, and enum fields to enums
105
+ - **From a view**: Traverses relations to models/views, and enum fields to enums
106
+ - **From an enum**: Finds all models/views using this enum, then traverses their relations
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @fileoverview Tests for the model traverser.
3
- * Tests cover BFS traversal, depth limiting, and cycle detection.
2
+ * @fileoverview Tests for the entity traverser.
3
+ * Tests cover BFS traversal of models, views, and enums with depth limiting.
4
4
  */
5
5
  export {};
6
6
  //# sourceMappingURL=traverser.test.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmCpC;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,OAAO,CA2BvC;AAqID;;;;GAIG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAG1D"}
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmCpC;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,OAAO,CA8BvC;AAqID;;;;GAIG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAG1D"}