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