hekireki 0.21.0 → 0.22.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.
Files changed (50) hide show
  1. package/README.md +161 -278
  2. package/dist/bin/activerecord.js +1 -1
  3. package/dist/bin/ajv.js +1 -1
  4. package/dist/bin/arktype.js +1 -1
  5. package/dist/bin/atlas.js +1 -1
  6. package/dist/bin/django.js +1 -1
  7. package/dist/bin/drizzle.js +1 -1
  8. package/dist/bin/ecto.js +1 -1
  9. package/dist/bin/efcore.d.ts +1 -0
  10. package/dist/bin/efcore.js +6 -0
  11. package/dist/bin/effect.js +1 -1
  12. package/dist/bin/eloquent.js +1 -1
  13. package/dist/bin/er.js +1 -1
  14. package/dist/bin/gorm.js +1 -1
  15. package/dist/bin/hekireki.js +1 -1
  16. package/dist/bin/kysely.js +1 -1
  17. package/dist/bin/pydantic.js +1 -1
  18. package/dist/bin/sea-orm.js +1 -1
  19. package/dist/bin/sqlalchemy.js +1 -1
  20. package/dist/bin/typebox.js +1 -1
  21. package/dist/bin/valibot.js +1 -1
  22. package/dist/bin/zod.js +1 -1
  23. package/dist/{bin-Ca0TR-Zh.js → bin-DxYpJikH.js} +1409 -10
  24. package/dist/studio/assets/{chip-CLdO-gL5.js → chip-B9UolvIl.js} +1 -1
  25. package/dist/studio/assets/{copy-CcAufM8p.js → copy-DiFFafx_.js} +1 -1
  26. package/dist/studio/assets/{debounce-T36H3Pq5.js → debounce-WjLaYdFF.js} +1 -1
  27. package/dist/studio/assets/{docs-DW8-viIy.js → docs-D2Vpbqbg.js} +1 -1
  28. package/dist/studio/assets/{enums._name-C2s5pbQ3.js → enums._name-t90NJ6-H.js} +1 -1
  29. package/dist/studio/assets/hooks-UJuF1mqe.js +1 -0
  30. package/dist/studio/assets/{index-BP1uJf2T.js → index-C29_CUjj.js} +3 -3
  31. package/dist/studio/assets/{labels-BXtM_faz.js → labels-D0IhxSmD.js} +1 -1
  32. package/dist/studio/assets/{lazyRouteComponent-C6zg30cR.js → lazyRouteComponent-G8mNaW9J.js} +1 -1
  33. package/dist/studio/assets/{lu-BKd2Ee9U.js → lu-DvK-u3Mx.js} +1 -1
  34. package/dist/studio/assets/{models._name-BgQ9M7k3.js → models._name-DUEsQrdC.js} +1 -1
  35. package/dist/studio/assets/{not-found-OmQoujxN.js → not-found-Dr2QuAjv.js} +1 -1
  36. package/dist/studio/assets/{prisma-BbI26USq.js → prisma-Co828tLd.js} +1 -1
  37. package/dist/studio/assets/routes-BIbzUF01.js +1 -0
  38. package/dist/studio/assets/{schema-gate-Dq_XVfAD.js → schema-gate-Bad9LKCZ.js} +1 -1
  39. package/dist/studio/assets/{schema-view-BuWOw5GX.js → schema-view-nCetSUyn.js} +1 -1
  40. package/dist/studio/assets/{sql--CSU_IR2.js → sql-Db9voX3l.js} +1 -1
  41. package/dist/studio/assets/{table-Dfy6EciQ.js → table-BfaXyuqp.js} +1 -1
  42. package/dist/studio/assets/{tabs-Ce14hvOa.js → tabs-BXvBDUhR.js} +1 -1
  43. package/dist/studio/assets/{useFormValidation-gdk4CRGT.js → useFormValidation-D6Nfw1Ec.js} +1 -1
  44. package/dist/studio/assets/{useMatch-CdyJXF1Q.js → useMatch-BZSBUGcY.js} +1 -1
  45. package/dist/studio/assets/{useMultipleSelectionState-a9-PqoPk.js → useMultipleSelectionState-Bz2aFLv7.js} +1 -1
  46. package/dist/studio/assets/{useOverlayTriggerState-DCPjC07T.js → useOverlayTriggerState-C-S92dgf.js} +1 -1
  47. package/dist/studio/index.html +8 -8
  48. package/package.json +7 -3
  49. package/dist/studio/assets/hooks-Ctp_pGlY.js +0 -1
  50. package/dist/studio/assets/routes-Bp4Bkwc2.js +0 -1
package/README.md CHANGED
@@ -3,16 +3,8 @@
3
3
  # Hekireki
4
4
 
5
5
  **[Hekireki](https://www.npmjs.com/package/hekireki)** generates validation schemas, ORM models and
6
- ER diagrams from a [Prisma](https://www.prisma.io/) schema — for TypeScript, Python, Go, Rust,
7
- Elixir, Ruby and PHP — and opens the schema, its documentation and its data in the browser with
8
- [Hekireki Studio](#studio).
9
-
10
- ## Features
11
-
12
- - **Validation schemas** — [Zod](https://zod.dev/), [Valibot](https://valibot.dev/), [ArkType](https://arktype.io/), [Effect Schema](https://effect.website/docs/schema/introduction/), [TypeBox](https://github.com/sinclairzx81/typebox), [AJV](https://ajv.js.org/) (JSON Schema) and [Pydantic](https://docs.pydantic.dev/) v2, written from the `///` [annotations](#annotations) on each field
13
- - **ORM models and DDL** — [Drizzle](https://orm.drizzle.team/), [Kysely](https://kysely.dev/), [SQLAlchemy](https://www.sqlalchemy.org/), [Django](https://www.djangoproject.com/), [GORM](https://gorm.io/), [Sea-ORM](https://www.sea-ql.org/SeaORM/), [Ecto](https://hexdocs.pm/ecto/Ecto.Schema.html), [Active Record](https://guides.rubyonrails.org/active_record_basics.html), [Eloquent](https://laravel.com/docs/eloquent) and [Atlas](https://atlasgo.io/) HCL — with relations, enums, composite keys, indexes and `@@map` / `@map` throughout
14
- - **ER diagrams** — [Mermaid](https://mermaid.js.org/), [DBML](https://dbml.dbdiagram.io/), PNG and SVG from one generator block, with crow's-foot cardinality and `PK` / `FK` / `UK` markers
15
- - **[Hekireki Studio](#studio)** — the ER diagram, a reference docs page, every model's data, a Prisma editor and a SQL console, live from `schema.prisma`
6
+ ER diagrams from a [Prisma](https://www.prisma.io/) schema, and opens the schema and its data in the
7
+ browser with Hekireki Studio.
16
8
 
17
9
  ## Installation
18
10
 
@@ -22,22 +14,22 @@ npm install -D hekireki
22
14
 
23
15
  ## Usage
24
16
 
25
- Each generator is a `generator` block in `schema.prisma`. `output` is **required**: point it at a
26
- directory to get the default file name of that generator, or at a path with an extension to name
27
- the file yourself. `hekireki-er` is the exception: it has no default file name, so it only takes
28
- paths to files, extension included (see [ER diagrams](#er-diagrams)).
17
+ Add a generator to `schema.prisma` and run `npx prisma generate`. `output` is required.
29
18
 
30
19
  ```prisma
31
20
  datasource db {
32
- provider = "sqlite"
21
+ provider = "postgresql"
33
22
  }
34
23
 
35
24
  generator Hekireki-Zod {
36
25
  provider = "hekireki-zod"
37
26
  output = "./zod"
38
27
  type = true
39
- comment = true
40
- relation = true
28
+ }
29
+
30
+ generator Hekireki-Drizzle {
31
+ provider = "hekireki-drizzle"
32
+ output = "./drizzle"
41
33
  }
42
34
 
43
35
  model User {
@@ -57,135 +49,57 @@ model Post {
57
49
  /// Article title
58
50
  /// @z.string().min(1).max(100)
59
51
  title String
60
- /// Foreign key referencing User.id
61
- /// @z.uuid()
62
52
  userId String
63
53
  user User @relation(fields: [userId], references: [id])
64
54
  }
65
55
  ```
66
56
 
67
- `npx prisma generate` writes `./zod/index.ts`:
68
-
69
- ```ts
70
- import * as z from 'zod'
71
-
72
- export const UserSchema = z.object({
73
- /**
74
- * Primary key
75
- */
76
- id: z.uuid(),
77
- /**
78
- * Display name
79
- */
80
- name: z.string().min(1).max(50),
81
- })
82
-
83
- export type User = z.infer<typeof UserSchema>
84
-
85
- export const PostSchema = z.object({
86
- /**
87
- * Primary key
88
- */
89
- id: z.uuid(),
90
- /**
91
- * Article title
92
- */
93
- title: z.string().min(1).max(100),
94
- /**
95
- * Foreign key referencing User.id
96
- */
97
- userId: z.uuid(),
98
- })
99
-
100
- export type Post = z.infer<typeof PostSchema>
101
-
102
- export const UserRelationsSchema = z.object({
103
- ...UserSchema.shape,
104
- posts: z.array(PostSchema),
105
- })
106
-
107
- export type UserRelations = z.infer<typeof UserRelationsSchema>
108
-
109
- export const PostRelationsSchema = z.object({
110
- ...PostSchema.shape,
111
- user: UserSchema,
112
- })
113
-
114
- export type PostRelations = z.infer<typeof PostRelationsSchema>
115
- ```
116
-
117
- Every other generator reads the same schema. What each one writes is easiest to read as real
118
- output: [`example/schema.prisma`](https://github.com/nakita628/hekireki/blob/main/example/schema.prisma)
119
- exercises all of them at once — enums, `@@map`, composite keys, self-relations, implicit
120
- many-to-many, native `@db.*` types — and the output of every generator for it is committed under
121
- [`example/generated/`](https://github.com/nakita628/hekireki/tree/main/example/generated).
57
+ ## Generators
122
58
 
123
- ## Annotations
59
+ ### Validation schemas
124
60
 
125
- A `///` comment on a field is its documentation. A `///` line that begins with one of the prefixes
126
- below is the validation the matching generator emits for that field, used verbatim:
61
+ - `hekireki-zod` — [Zod](https://zod.dev/)
62
+ - `hekireki-valibot` — [Valibot](https://valibot.dev/)
63
+ - `hekireki-arktype` — [ArkType](https://arktype.io/)
64
+ - `hekireki-effect` — [Effect Schema](https://effect.website/docs/schema/introduction/)
65
+ - `hekireki-typebox` — [TypeBox](https://github.com/sinclairzx81/typebox)
66
+ - `hekireki-ajv` — [AJV](https://ajv.js.org/)
67
+ - `hekireki-pydantic` — [Pydantic](https://docs.pydantic.dev/)
127
68
 
128
- | Prefix | Generator | Example |
129
- | ------ | ----------------- | ----------------------------------------- |
130
- | `@z.` | Zod | `/// @z.string().min(1).max(50)` |
131
- | `@v.` | Valibot | `/// @v.pipe(v.string(), v.minLength(1))` |
132
- | `@a.` | ArkType | `/// @a."1 <= string <= 50"` |
133
- | `@e.` | Effect Schema | `/// @e.Schema.UUID` |
134
- | `@t.` | TypeBox | `/// @t.Type.String({ format: 'uuid' })` |
135
- | `@j.` | AJV / JSON Schema | `/// @j.{ type: 'string' as const }` |
136
- | `@p.` | Pydantic | `/// @p.EmailStr` |
69
+ ### ORM models
137
70
 
138
- A field without an annotation falls back to the Prisma type. `@p.ConfigDict(...)` on a **model** is
139
- passed through as Pydantic's `model_config`.
71
+ - `hekireki-drizzle` — [Drizzle](https://orm.drizzle.team/)
72
+ - `hekireki-kysely` — [Kysely](https://kysely.dev/)
73
+ - `hekireki-sqlalchemy` — [SQLAlchemy](https://www.sqlalchemy.org/)
74
+ - `hekireki-django` — [Django](https://www.djangoproject.com/)
75
+ - `hekireki-gorm` — [GORM](https://gorm.io/)
76
+ - `hekireki-sea-orm` — [SeaORM](https://www.sea-ql.org/SeaORM/)
77
+ - `hekireki-ecto` — [Ecto](https://hexdocs.pm/ecto/Ecto.Schema.html)
78
+ - `hekireki-activerecord` — [Active Record](https://guides.rubyonrails.org/active_record_basics.html)
79
+ - `hekireki-eloquent` — [Eloquent](https://laravel.com/docs/eloquent)
80
+ - `hekireki-efcore` — [EF Core](https://learn.microsoft.com/ef/core/)
81
+ - `hekireki-atlas` — [Atlas](https://atlasgo.io/) HCL
140
82
 
141
- `/// @relation <Parent>.<field> <Child>.<field> <cardinality>` on a **model** declares a relation
142
- that has no physical foreign key — it is drawn in the Mermaid, DBML and image output (dashed in the
143
- drawing) even though the column carries no `@relation(...)`:
83
+ ### ER diagrams
144
84
 
145
- ```prisma
146
- /// @relation User.id Post.userId one-to-many
147
- model Post {
148
- id String @id @default(uuid())
149
- userId String
150
- }
151
- ```
85
+ - `hekireki-er` — Mermaid, DBML, PNG and SVG
152
86
 
153
- ## Generators
87
+ ## Configuration
154
88
 
155
- | `provider` | Target | Default output | Options |
156
- | ----------------------- | -------------------------- | ------------------------------------------- | ------------------------------------ |
157
- | `hekireki-zod` | TypeScript | `index.ts` | `type`, `comment`, `relation`, `zod` |
158
- | `hekireki-valibot` | TypeScript | `index.ts` | `type`, `comment`, `relation` |
159
- | `hekireki-arktype` | TypeScript | `index.ts` | `type`, `comment`, `relation` |
160
- | `hekireki-effect` | TypeScript | `index.ts` | `type`, `comment`, `relation` |
161
- | `hekireki-typebox` | TypeScript | `index.ts` | `type`, `comment`, `relation` |
162
- | `hekireki-ajv` | TypeScript | `index.ts` | `type`, `comment`, `relation` |
163
- | `hekireki-drizzle` | TypeScript | `schema.ts` | — |
164
- | `hekireki-kysely` | TypeScript | `types.ts` | — |
165
- | `hekireki-pydantic` | Python | `models.py` | `comment`, `relation` |
166
- | `hekireki-sqlalchemy` | Python | `models.py` | — |
167
- | `hekireki-django` | Python (Django ≥ 5.2) | `models.py` | — |
168
- | `hekireki-gorm` | Go | `models.go` | `package` |
169
- | `hekireki-sea-orm` | Rust | one `.rs` per model, `mod.rs`, `prelude.rs` | `renameAll` |
170
- | `hekireki-ecto` | Elixir | one `.ex` per model | `app` |
171
- | `hekireki-activerecord` | Ruby (Rails ≥ 7.1) | one `.rb` per model | — |
172
- | `hekireki-eloquent` | PHP (Laravel, PHP ≥ 8.1) | one `.php` per model and enum | `namespace` |
173
- | `hekireki-atlas` | Atlas HCL | `schema.hcl` | `schemaName`, `comment` |
174
- | `hekireki-er` | Mermaid / DBML / PNG / SVG | — ([extension required](#er-diagrams)) | `outputs`, `theme` |
89
+ Every generator with every option. All options are optional.
175
90
 
176
- ## Configuration
91
+ ### Validation schemas
177
92
 
178
93
  ```prisma
179
94
  generator Hekireki-Zod {
180
95
  provider = "hekireki-zod"
181
- output = "./zod" // Required. A directory here yields ./zod/index.ts
182
- type = true // TypeScript types (default: false)
183
- comment = true // /// comments as doc comments (default: false)
184
- relation = true // <Model>Relations schemas (default: false)
185
- zod = "v4" // "v4" | "mini" | "@hono/zod-openapi" (default: v4)
96
+ output = "./zod"
97
+ type = true // Export TypeScript types
98
+ comment = true // Keep /// comments
99
+ relation = true // Add <Model>Relations schemas
100
+ zod = "v4" // "v4" (default), "mini" or "@hono/zod-openapi"
186
101
  }
187
102
 
188
- // Valibot, ArkType, Effect Schema, TypeBox and AJV take the same type / comment / relation options.
189
103
  generator Hekireki-Valibot {
190
104
  provider = "hekireki-valibot"
191
105
  output = "./valibot"
@@ -194,209 +108,178 @@ generator Hekireki-Valibot {
194
108
  relation = true
195
109
  }
196
110
 
111
+ generator Hekireki-ArkType {
112
+ provider = "hekireki-arktype"
113
+ output = "./arktype"
114
+ type = true
115
+ comment = true
116
+ relation = true
117
+ }
118
+
119
+ generator Hekireki-Effect {
120
+ provider = "hekireki-effect"
121
+ output = "./effect"
122
+ type = true
123
+ comment = true
124
+ relation = true
125
+ }
126
+
127
+ generator Hekireki-TypeBox {
128
+ provider = "hekireki-typebox"
129
+ output = "./typebox"
130
+ type = true
131
+ comment = true
132
+ relation = true
133
+ }
134
+
135
+ generator Hekireki-AJV {
136
+ provider = "hekireki-ajv"
137
+ output = "./ajv"
138
+ type = true
139
+ comment = true
140
+ relation = true
141
+ }
142
+
197
143
  generator Hekireki-Pydantic {
198
144
  provider = "hekireki-pydantic"
199
- output = "./pydantic" // A directory here yields ./pydantic/models.py
200
- comment = true // /// comments as docstrings (default: false)
201
- relation = true // <Model>Relations subclasses (default: false)
145
+ output = "./pydantic"
146
+ comment = true
147
+ relation = true
202
148
  }
149
+ ```
203
150
 
204
- // Drizzle, Kysely, SQLAlchemy, Django and Active Record take output alone.
151
+ ### ORM models
152
+
153
+ ```prisma
205
154
  generator Hekireki-Drizzle {
206
155
  provider = "hekireki-drizzle"
207
- output = "./drizzle" // A directory here yields ./drizzle/schema.ts
156
+ output = "./drizzle"
208
157
  }
209
158
 
210
- generator Hekireki-Atlas {
211
- provider = "hekireki-atlas"
212
- output = "./atlas" // A directory here yields ./atlas/schema.hcl
213
- schemaName = "public" // Schema label (default: postgresql/mysql "public", sqlite "main")
214
- comment = true // /// comments as comment attributes (default: false)
159
+ generator Hekireki-Kysely {
160
+ provider = "hekireki-kysely"
161
+ output = "./kysely"
162
+ }
163
+
164
+ generator Hekireki-SQLAlchemy {
165
+ provider = "hekireki-sqlalchemy"
166
+ output = "./sqlalchemy"
167
+ }
168
+
169
+ generator Hekireki-Django {
170
+ provider = "hekireki-django"
171
+ output = "./django"
215
172
  }
216
173
 
217
174
  generator Hekireki-GORM {
218
175
  provider = "hekireki-gorm"
219
- output = "./gorm" // A directory here yields ./gorm/models.go
220
- package = "model" // Go package name (default: model)
176
+ output = "./gorm"
177
+ package = "model" // Go package name (default: "model")
221
178
  }
222
179
 
223
180
  generator Hekireki-SeaORM {
224
181
  provider = "hekireki-sea-orm"
225
- output = "./sea_orm"
226
- renameAll = "camelCase" // #[serde(rename_all = "...")] (optional)
182
+ output = "./sea-orm"
183
+ renameAll = "camelCase" // #[serde(rename_all = "...")]
227
184
  }
228
185
 
229
186
  generator Hekireki-Ecto {
230
187
  provider = "hekireki-ecto"
231
188
  output = "./ecto"
232
- app = "MyApp" // Module prefix (default: MyApp)
189
+ app = "MyApp" // Module prefix (default: "MyApp")
190
+ }
191
+
192
+ generator Hekireki-ActiveRecord {
193
+ provider = "hekireki-activerecord"
194
+ output = "./activerecord"
233
195
  }
234
196
 
235
197
  generator Hekireki-Eloquent {
236
198
  provider = "hekireki-eloquent"
237
199
  output = "./eloquent"
238
- namespace = "App.Models" // PHP namespace, "." becomes "\" (default: App\Models)
200
+ namespace = "App.Models" // "." becomes "\" (default: "App\Models")
239
201
  }
240
202
 
241
- // ER takes output or outputs (not both). Every path is a file ending in .md, .dbml, .png or .svg,
242
- // never a directory, and its extension picks the format (see ER diagrams).
243
- generator Hekireki-ER {
244
- provider = "hekireki-er"
245
- // output = "docs/er.md" // One file: output alone is enough
246
- outputs = ["docs/er.md", "docs/schema.dbml", "docs/er.svg"] // Several files: list them here
247
- theme = "light" // .png / .svg only. "light" (default) or "dark"
203
+ // PostgreSQL only
204
+ generator Hekireki-EFCore {
205
+ provider = "hekireki-efcore"
206
+ output = "./efcore"
207
+ namespace = "MyApp.Models" // C# namespace (default: "Models")
208
+ context = "AppDbContext" // DbContext class name (default: "AppDbContext")
248
209
  }
249
- ```
250
210
 
251
- ## ER diagrams
252
-
253
- `hekireki-er` writes the ER model of the schema in four formats, and the extension of each file
254
- picks which — so the file you name is the file you get. Unlike the other generators it has no
255
- default file name, so every file has to be named with one of these extensions:
211
+ generator Hekireki-Atlas {
212
+ provider = "hekireki-atlas"
213
+ output = "./atlas"
214
+ schemaName = "public" // Default: "public" ("main" on SQLite)
215
+ comment = true // Keep /// comments
216
+ }
217
+ ```
256
218
 
257
- | Extension | Writes |
258
- | --------- | ---------------------- |
259
- | `.md` | A Mermaid `erDiagram` |
260
- | `.dbml` | DBML |
261
- | `.png` | The diagram, as a PNG |
262
- | `.svg` | The diagram, as an SVG |
219
+ ### ER diagrams
263
220
 
264
- Name the files with `output` or with `outputs` — one of the two, not both. When one file is all
265
- you need, `output` alone is enough:
221
+ The extension of each path picks the format: `.md` (Mermaid), `.dbml`, `.png` or `.svg`.
266
222
 
267
223
  ```prisma
268
224
  generator Hekireki-ER {
269
225
  provider = "hekireki-er"
270
- output = "docs/er.md" // Writes docs/er.md
226
+ outputs = ["docs/er.md", "docs/er.dbml", "docs/er.png", "docs/er.svg"] // One file: output = "docs/er.md"
227
+ theme = "dark" // .png / .svg: "light" (default) or "dark"
271
228
  }
272
229
  ```
273
230
 
274
- For several formats at once, list them in `outputs` instead:
231
+ ## Annotations
232
+
233
+ A `///` line starting with `@z.`, `@v.`, `@a.`, `@e.`, `@t.`, `@j.` or `@p.` is used as-is by Zod,
234
+ Valibot, ArkType, Effect Schema, TypeBox, AJV or Pydantic. Any other `///` line is documentation.
275
235
 
276
236
  ```prisma
277
- generator Hekireki-ER {
278
- provider = "hekireki-er"
279
- outputs = ["docs/er.md", "docs/er.svg"] // Writes docs/er.md and docs/er.svg
237
+ model User {
238
+ /// Display name
239
+ /// @z.string().min(1).max(50)
240
+ /// @v.pipe(v.string(), v.minLength(1), v.maxLength(50))
241
+ /// @a."1 <= string <= 50"
242
+ /// @e.Schema.String.pipe(Schema.minLength(1), Schema.maxLength(50))
243
+ /// @t.Type.String({ minLength: 1, maxLength: 50 })
244
+ /// @j.{ type: 'string' as const, minLength: 1, maxLength: 50 }
245
+ /// @p.Annotated[str, StringConstraints(min_length=1, max_length=50)]
246
+ name String
247
+ /// @z.email()
248
+ /// @v.pipe(v.string(), v.email())
249
+ /// @a."string.email"
250
+ /// @e.Schema.String.pipe(Schema.pattern(/^[^@]+@[^@]+\.[^@]+$/))
251
+ /// @t.Type.String({ format: 'email' })
252
+ /// @j.{ type: 'string' as const, format: 'email' as const }
253
+ /// @p.EmailStr
254
+ email String @unique
280
255
  }
281
256
  ```
282
257
 
283
- Every path is a whole file, directory and extension included, resolved the way Prisma resolves any
284
- `output`: against the directory of the schema file that declares the generator. Neither ever names
285
- a directory, so a path with no extension, or with one outside the four, is an error rather than a
286
- guess — `output = "docs"` fails.
287
-
288
- Every option belongs to a format (`theme` to `.png` and `.svg`), and setting one that no chosen
289
- format reads is an error — so an option never looks like it did something it did not.
290
-
291
- `.md` writes a Mermaid diagram:
292
-
293
- ```mermaid
294
- erDiagram
295
- User ||--o{ Post : "(id) - (userId)"
296
- User {
297
- string id PK "Primary key"
298
- string name "Display name"
299
- }
300
- Post {
301
- string id PK "Primary key"
302
- string title "Article title"
303
- string userId FK "Foreign key referencing User.id"
304
- }
305
- ```
258
+ On a model, `@p.ConfigDict(...)` becomes Pydantic's `model_config`, and
259
+ `@relation <Model>.<field> <Model>.<field> <type>` adds a relation without a foreign key to the ER
260
+ diagram (drawn dashed).
306
261
 
307
- `.dbml` writes the same model for [dbdiagram.io](https://dbml.dbdiagram.io/) as the database
308
- names it: tables, columns, enums and enum values under their `@@map` / `@map` names wherever the
309
- schema declares one. `.png` and `.svg`
310
- draw the diagram Hekireki Studio shows, laid out automatically: a card per model and enum, its
311
- fields with `🔑` / `🔗` / `UK` marks, the attributes and `///` prose under each, the `@@id` /
312
- `@@unique` / `@@index` block attributes, and an edge per relation in crow's-foot notation captioned
313
- with its cardinality and referential action. No external renderer is involved, and the PNG is
314
- rasterised at 2x. Use `.svg` for files in the repository and `.png` where images are embedded.
315
- Studio's Schema page exports both with the models where you dragged them.
262
+ ```prisma
263
+ /// @p.ConfigDict(extra='forbid')
264
+ /// @relation User.id Post.userId one-to-many
265
+ model Post {
266
+ id String @id @default(uuid())
267
+ userId String
268
+ }
269
+ ```
316
270
 
317
271
  ## Studio
318
272
 
319
- `hekireki studio` opens the schema in the browser, served locally by [Hono](https://hono.dev/).
320
- Nothing is generated first — Studio reads `schema.prisma` itself and reloads on every edit to it:
321
-
322
273
  ```bash
323
- # Open ./prisma/schema.prisma, then ./schema.prisma (default: http://localhost:5555)
324
- hekireki studio
325
-
326
- # Read a multi-file schema: every .prisma file directly in the directory, together
327
- hekireki studio --schema prisma/schema
328
-
329
- # Browse a database of your choosing
330
- hekireki studio --url file:./dev.db
331
-
332
- # Listen on another port
333
- hekireki studio -p 3000
274
+ hekireki studio # ./prisma/schema.prisma or ./schema.prisma
275
+ hekireki studio --schema prisma/schema # A multi-file schema
276
+ hekireki studio --url file:./dev.db # A database of your choice
277
+ hekireki studio -p 3000 # Another port (default: 5555)
334
278
  ```
335
279
 
336
- | Page | What it is |
337
- | ---------------- | --------------------------------------------------------------------------------- |
338
- | `/` — Schema | The ER diagram, laid out automatically, with **PNG** / **SVG** export |
339
- | `/docs` — Docs | The reference page: every model and enum with its fields, attributes and comments |
340
- | `/models/<name>` | A model's rows, editable, next to its fields |
341
- | `/enums/<name>` | An enum with its members and the fields that hold it |
342
- | `/prisma` | The schema in a Prisma editor, with the language server's diagnostics |
343
- | `/sql` | A SQL console: completion from the schema, a data-flow picture, the query plan |
344
-
345
- **⌘K** / **Ctrl+K** opens a search over the whole schema — every page, model, enum and field, by
346
- the letters of its name in order, so `usemail` finds `User.email`. Following a field opens its
347
- model on that row.
348
-
349
- On a model's page, **/** puts the cursor in the search box and every column is searched as you
350
- type, with what matched marked in the rows that come back. Clicking a cell picks it and nothing
351
- more; the two buttons that appear on it copy just that value or open it for editing, and **⌘C** /
352
- **Ctrl+C** copies the picked cell. Tick rows to act on them together: **Copy** takes them as
353
- tab-separated text — what a spreadsheet pastes — and **Delete** asks first, naming the rows it is
354
- about to remove. **Export** downloads or copies the page as CSV or JSON. A SQL result is sorted and narrowed in the browser,
355
- without asking the database a second question.
356
-
357
- The SQL page completes table and column names from the schema — `@@map` / `@map` names, as the
358
- database knows them — and reads the statement as you type: **Flow** draws where its rows come from
359
- (every table, join, filter, grouping and the projection), **Columns** traces each result column back
360
- to the base tables and lists every table touched with its alias and the columns read, and **Type**
361
- shows the row and parameter types as TypeScript, and **Plan** asks the database for its execution
362
- plan (`EXPLAIN`) as a tree. The models the statement touches light up on the
363
- schema beside it, with the columns it reads marked; a `?` or `$1` placeholder gets a field typed
364
- from the column it is compared with, and a name the schema does not know is underlined.
365
-
366
- **Columns** in the toolbar says which columns the grid draws, remembered per model; what is on
367
- screen is what **Copy** and **Export** take, so a copy of two columns out of forty is two ticks
368
- away. A row is still written whole, so the Add row form brings every column back for as long as it
369
- is open.
370
-
371
- `--schema` takes either a `schema.prisma` file or a directory — every `.prisma` file directly in the
372
- directory (subdirectories are not descended into) is read as one schema, which is how Prisma's
373
- [multi-file schema](https://www.prisma.io/docs/orm/prisma-schema/overview/location#multi-file-prisma-schema)
374
- (`prisma/schema/`) is opened. Without the flag, `./prisma/schema.prisma` then `./schema.prisma` are
375
- looked for — the same two paths the Prisma CLI defaults to. Either way the whole directory is
376
- watched, so a `.prisma` file added to it appears in Studio without a restart.
377
-
378
- The database is the one `--url` names, or `DATABASE_URL` from the environment or `.env`, then
379
- `datasource.url` in `prisma.config.ts`; `postgres://`, `mysql://` and `file:` are understood. A
380
- relative `file:` path is resolved from the schema directory, as Prisma resolves it — with the
381
- default `prisma/schema.prisma`, `file:./dev.db` is `prisma/dev.db`. Without a database, Studio
382
- serves the schema alone — the diagram, the docs and the editor still work.
383
-
384
- The HTTP API behind it is documented in [docs/studio-api.md](https://github.com/nakita628/hekireki/blob/main/packages/hekireki/docs/studio-api.md).
385
-
386
- ## Notes
387
-
388
- - **Atlas** — declarative `atlas schema apply` drops whatever is missing from the HCL, and Prisma's
389
- `_prisma_migrations` table, `@ignore`d columns and `Unsupported(...)` types can never appear in it.
390
- Dry-run first and exclude the migrations table: `--exclude '_prisma_migrations'`.
391
- - **Kysely** — only **database-side** defaults become `Generated<T>`. `uuid()`, `cuid()`, `ulid()`
392
- and `nanoid()` are evaluated by the Prisma Client, so a raw Kysely insert must still supply them.
393
- - **Django** — enums become `TextChoices` + `TextField(choices=…)` (Django has no native PostgreSQL
394
- enum type), a foreign key to a composite `@@id` / `@@unique` is emitted as the scalar columns
395
- without a relation, `onUpdate` is dropped, and a plain `DateTime` maps to `DateTimeField` while
396
- Prisma stores `timestamp` — annotate it `@db.Timestamptz` to keep `USE_TZ = True` reads aware.
397
- - **Eloquent** — a composite primary key is emitted as `protected $primaryKey = null;`, because
398
- Eloquent has no native support for one. Active Record writes the real
399
- `self.primary_key = [...]` (Rails ≥ 7.1).
280
+ Studio shows the ER diagram, the docs, each model's rows, a Prisma editor and a SQL console, and
281
+ reloads when the schema changes. The database comes from `--url`, `DATABASE_URL` or
282
+ `prisma.config.ts`.
400
283
 
401
284
  ## License
402
285
 
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-Ca0TR-Zh.js";
2
+ import { t as registerGenerator } from "../bin-DxYpJikH.js";
3
3
  //#region src/bin/activerecord.ts
4
4
  registerGenerator("activerecord");
5
5
  //#endregion
package/dist/bin/ajv.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-Ca0TR-Zh.js";
2
+ import { t as registerGenerator } from "../bin-DxYpJikH.js";
3
3
  //#region src/bin/ajv.ts
4
4
  registerGenerator("ajv");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-Ca0TR-Zh.js";
2
+ import { t as registerGenerator } from "../bin-DxYpJikH.js";
3
3
  //#region src/bin/arktype.ts
4
4
  registerGenerator("arktype");
5
5
  //#endregion
package/dist/bin/atlas.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-Ca0TR-Zh.js";
2
+ import { t as registerGenerator } from "../bin-DxYpJikH.js";
3
3
  //#region src/bin/atlas.ts
4
4
  registerGenerator("atlas");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-Ca0TR-Zh.js";
2
+ import { t as registerGenerator } from "../bin-DxYpJikH.js";
3
3
  //#region src/bin/django.ts
4
4
  registerGenerator("django");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-Ca0TR-Zh.js";
2
+ import { t as registerGenerator } from "../bin-DxYpJikH.js";
3
3
  //#region src/bin/drizzle.ts
4
4
  registerGenerator("drizzle");
5
5
  //#endregion
package/dist/bin/ecto.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-Ca0TR-Zh.js";
2
+ import { t as registerGenerator } from "../bin-DxYpJikH.js";
3
3
  //#region src/bin/ecto.ts
4
4
  registerGenerator("ecto");
5
5
  //#endregion
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import { t as registerGenerator } from "../bin-DxYpJikH.js";
3
+ //#region src/bin/efcore.ts
4
+ registerGenerator("efcore");
5
+ //#endregion
6
+ export {};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-Ca0TR-Zh.js";
2
+ import { t as registerGenerator } from "../bin-DxYpJikH.js";
3
3
  //#region src/bin/effect.ts
4
4
  registerGenerator("effect");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-Ca0TR-Zh.js";
2
+ import { t as registerGenerator } from "../bin-DxYpJikH.js";
3
3
  //#region src/bin/eloquent.ts
4
4
  registerGenerator("eloquent");
5
5
  //#endregion
package/dist/bin/er.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-Ca0TR-Zh.js";
2
+ import { t as registerGenerator } from "../bin-DxYpJikH.js";
3
3
  //#region src/bin/er.ts
4
4
  registerGenerator("er");
5
5
  //#endregion
package/dist/bin/gorm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-Ca0TR-Zh.js";
2
+ import { t as registerGenerator } from "../bin-DxYpJikH.js";
3
3
  //#region src/bin/gorm.ts
4
4
  registerGenerator("gorm");
5
5
  //#endregion