hekireki 0.10.0 โ 0.10.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 +291 -21
- package/dist/bin/activerecord.d.ts +1 -1
- package/dist/bin/activerecord.js +1 -1
- package/dist/bin/ajv.d.ts +1 -1
- package/dist/bin/ajv.js +1 -1
- package/dist/bin/arktype.d.ts +1 -1
- package/dist/bin/arktype.js +1 -1
- package/dist/bin/atlas.d.ts +1 -0
- package/dist/bin/atlas.js +6 -0
- package/dist/bin/dbml.d.ts +1 -1
- package/dist/bin/dbml.js +1 -1
- package/dist/bin/docs.d.ts +1 -1
- package/dist/bin/docs.js +1 -1
- package/dist/bin/drizzle.d.ts +1 -1
- package/dist/bin/drizzle.js +1 -1
- package/dist/bin/ecto.d.ts +1 -1
- package/dist/bin/ecto.js +1 -1
- package/dist/bin/effect.d.ts +1 -1
- package/dist/bin/effect.js +1 -1
- package/dist/bin/eloquent.d.ts +1 -1
- package/dist/bin/eloquent.js +1 -1
- package/dist/bin/gorm.d.ts +1 -1
- package/dist/bin/gorm.js +1 -1
- package/dist/bin/kysely.d.ts +1 -0
- package/dist/bin/kysely.js +6 -0
- package/dist/bin/mermaid-er.d.ts +1 -1
- package/dist/bin/mermaid-er.js +1 -1
- package/dist/bin/pydantic.d.ts +1 -0
- package/dist/bin/pydantic.js +6 -0
- package/dist/bin/sea-orm.d.ts +1 -1
- package/dist/bin/sea-orm.js +1 -1
- package/dist/bin/sqlalchemy.d.ts +1 -1
- package/dist/bin/sqlalchemy.js +1 -1
- package/dist/bin/typebox.d.ts +1 -1
- package/dist/bin/typebox.js +1 -1
- package/dist/bin/valibot.d.ts +1 -1
- package/dist/bin/valibot.js +1 -1
- package/dist/bin/zod.d.ts +1 -1
- package/dist/bin/zod.js +1 -1
- package/dist/{bin-jiigoOO9.js โ bin-CR9GrJIk.js} +1463 -255
- package/dist/cli/index.d.ts +41 -41
- package/dist/cli/index.js +1 -1
- package/package.json +30 -20
package/README.md
CHANGED
|
@@ -15,15 +15,21 @@
|
|
|
15
15
|
- ๐ฆ Automatically generates [TypeBox](https://github.com/sinclairzx81/typebox) schemas from your Prisma schema
|
|
16
16
|
- ๐ Automatically generates [AJV](https://ajv.js.org/)-compatible JSON Schema objects from your Prisma schema
|
|
17
17
|
|
|
18
|
+
### Python Validation
|
|
19
|
+
|
|
20
|
+
- ๐ Automatically generates [Pydantic](https://docs.pydantic.dev/) v2 models from your Prisma schema โ with `@p.` field annotations, `Literal` enums, `@p.ConfigDict(...)` model config passthrough (`extra='forbid'` / `'ignore'` / `'allow'` and any other `ConfigDict` arguments), and `relation = true` for `<Model>Relations` subclasses
|
|
21
|
+
|
|
18
22
|
### ORM / Schema Generation (Multi-Language)
|
|
19
23
|
|
|
20
24
|
- ๐๏ธ Automatically generates [Drizzle ORM](https://orm.drizzle.team/) table schemas and relations from your Prisma schema
|
|
25
|
+
- ๐ Automatically generates [Kysely](https://kysely.dev/) type definitions (`DB` interface) from your Prisma schema โ with database-side-only `Generated` columns, enum value unions, `@map`/`@@map` support, and implicit m2m join tables
|
|
21
26
|
- ๐ Automatically generates [SQLAlchemy](https://www.sqlalchemy.org/) models (Python) โ with `Mapped[T]` type hints, relationships, enums, composite keys, and index support
|
|
22
27
|
- ๐น Automatically generates [GORM](https://gorm.io/) models (Go) โ with struct tags, JSON tags, relationships, enums, composite keys, and index support
|
|
23
28
|
- ๐ฆ Automatically generates [Sea-ORM](https://www.sea-ql.org/SeaORM/) entities (Rust) โ with `DeriveEntityModel`, relations, enums, serde support, and `rename_all`
|
|
24
29
|
- ๐งช Generates [Ecto](https://hexdocs.pm/ecto/Ecto.Schema.html) schemas (Elixir) โ with associations (`belongs_to`, `has_many`, `has_one`), composite primary keys, `@type t` typespecs, array fields, `@@map`/`@map` support, and `@moduledoc`
|
|
25
30
|
- ๐ Generates [Active Record](https://guides.rubyonrails.org/active_record_basics.html) models (Ruby on Rails) โ with associations (`belongs_to`, `has_one`, `has_many`, `has_and_belongs_to_many`), enums, composite primary keys, and `@@map`/`@map` support
|
|
26
31
|
- ๐ Generates [Eloquent](https://laravel.com/docs/eloquent) models (Laravel / PHP) โ with relations (`belongsTo`, `hasOne`, `hasMany`, `belongsToMany`), `$fillable`, `$casts`, string-backed PHP enums, timestamp constants, and `@@map`/`@map` support
|
|
32
|
+
- ๐ Generates [Atlas](https://atlasgo.io/) HCL database schemas โ with native `@db.*` type mapping (PostgreSQL / MySQL / SQLite), enum blocks, defaults (including `dbgenerated(...)` and scalar-list defaults), foreign keys with Prisma's referential-action defaults, unique / descending / fulltext indexes, implicit m2m join tables, and `@@schema` support โ output is `atlas schema fmt` canonical
|
|
27
33
|
|
|
28
34
|
### Diagrams & Documentation
|
|
29
35
|
|
|
@@ -47,6 +53,7 @@ datasource db {
|
|
|
47
53
|
|
|
48
54
|
generator Hekireki-Zod {
|
|
49
55
|
provider = "hekireki-zod"
|
|
56
|
+
output = "./zod"
|
|
50
57
|
type = true
|
|
51
58
|
comment = true
|
|
52
59
|
relation = true
|
|
@@ -54,6 +61,7 @@ generator Hekireki-Zod {
|
|
|
54
61
|
|
|
55
62
|
generator Hekireki-Valibot {
|
|
56
63
|
provider = "hekireki-valibot"
|
|
64
|
+
output = "./valibot"
|
|
57
65
|
type = true
|
|
58
66
|
comment = true
|
|
59
67
|
relation = true
|
|
@@ -61,6 +69,7 @@ generator Hekireki-Valibot {
|
|
|
61
69
|
|
|
62
70
|
generator Hekireki-ArkType {
|
|
63
71
|
provider = "hekireki-arktype"
|
|
72
|
+
output = "./arktype"
|
|
64
73
|
type = true
|
|
65
74
|
comment = true
|
|
66
75
|
relation = true
|
|
@@ -68,6 +77,7 @@ generator Hekireki-ArkType {
|
|
|
68
77
|
|
|
69
78
|
generator Hekireki-Effect {
|
|
70
79
|
provider = "hekireki-effect"
|
|
80
|
+
output = "./effect"
|
|
71
81
|
type = true
|
|
72
82
|
comment = true
|
|
73
83
|
relation = true
|
|
@@ -75,6 +85,7 @@ generator Hekireki-Effect {
|
|
|
75
85
|
|
|
76
86
|
generator Hekireki-TypeBox {
|
|
77
87
|
provider = "hekireki-typebox"
|
|
88
|
+
output = "./typebox"
|
|
78
89
|
type = true
|
|
79
90
|
comment = true
|
|
80
91
|
relation = true
|
|
@@ -82,13 +93,31 @@ generator Hekireki-TypeBox {
|
|
|
82
93
|
|
|
83
94
|
generator Hekireki-AJV {
|
|
84
95
|
provider = "hekireki-ajv"
|
|
96
|
+
output = "./ajv"
|
|
85
97
|
type = true
|
|
86
98
|
comment = true
|
|
87
99
|
relation = true
|
|
88
100
|
}
|
|
89
101
|
|
|
102
|
+
generator Hekireki-Pydantic {
|
|
103
|
+
provider = "hekireki-pydantic"
|
|
104
|
+
output = "./pydantic"
|
|
105
|
+
comment = true
|
|
106
|
+
}
|
|
107
|
+
|
|
90
108
|
generator Hekireki-Drizzle {
|
|
91
109
|
provider = "hekireki-drizzle"
|
|
110
|
+
output = "./drizzle"
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
generator Hekireki-Kysely {
|
|
114
|
+
provider = "hekireki-kysely"
|
|
115
|
+
output = "./kysely"
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
generator Hekireki-Atlas {
|
|
119
|
+
provider = "hekireki-atlas"
|
|
120
|
+
output = "./atlas"
|
|
92
121
|
}
|
|
93
122
|
|
|
94
123
|
generator Hekireki-SQLAlchemy {
|
|
@@ -127,6 +156,7 @@ generator Hekireki-Eloquent {
|
|
|
127
156
|
|
|
128
157
|
generator Hekireki-ER {
|
|
129
158
|
provider = "hekireki-mermaid-er"
|
|
159
|
+
output = "./mermaid-er"
|
|
130
160
|
}
|
|
131
161
|
|
|
132
162
|
generator Hekireki-DBML {
|
|
@@ -147,6 +177,7 @@ model User {
|
|
|
147
177
|
/// @e.Schema.UUID
|
|
148
178
|
/// @t.Type.String({ format: 'uuid' })
|
|
149
179
|
/// @j.{ type: 'string' as const, format: 'uuid' as const }
|
|
180
|
+
/// @p.UUID4
|
|
150
181
|
id String @id @default(uuid())
|
|
151
182
|
/// Display name
|
|
152
183
|
/// @z.string().min(1).max(50)
|
|
@@ -155,6 +186,7 @@ model User {
|
|
|
155
186
|
/// @e.Schema.String.pipe(Schema.minLength(1), Schema.maxLength(50))
|
|
156
187
|
/// @t.Type.String({ minLength: 1, maxLength: 50 })
|
|
157
188
|
/// @j.{ type: 'string' as const, minLength: 1, maxLength: 50 }
|
|
189
|
+
/// @p.Annotated[str, StringConstraints(min_length=1, max_length=50)]
|
|
158
190
|
name String
|
|
159
191
|
/// One-to-many relation to Post
|
|
160
192
|
posts Post[]
|
|
@@ -168,6 +200,7 @@ model Post {
|
|
|
168
200
|
/// @e.Schema.UUID
|
|
169
201
|
/// @t.Type.String({ format: 'uuid' })
|
|
170
202
|
/// @j.{ type: 'string' as const, format: 'uuid' as const }
|
|
203
|
+
/// @p.UUID4
|
|
171
204
|
id String @id @default(uuid())
|
|
172
205
|
/// Article title
|
|
173
206
|
/// @z.string().min(1).max(100)
|
|
@@ -176,6 +209,7 @@ model Post {
|
|
|
176
209
|
/// @e.Schema.String.pipe(Schema.minLength(1), Schema.maxLength(100))
|
|
177
210
|
/// @t.Type.String({ minLength: 1, maxLength: 100 })
|
|
178
211
|
/// @j.{ type: 'string' as const, minLength: 1, maxLength: 100 }
|
|
212
|
+
/// @p.Annotated[str, StringConstraints(min_length=1, max_length=100)]
|
|
179
213
|
title String
|
|
180
214
|
/// Body content (no length limit)
|
|
181
215
|
/// @z.string()
|
|
@@ -192,6 +226,7 @@ model Post {
|
|
|
192
226
|
/// @e.Schema.UUID
|
|
193
227
|
/// @t.Type.String({ format: 'uuid' })
|
|
194
228
|
/// @j.{ type: 'string' as const, format: 'uuid' as const }
|
|
229
|
+
/// @p.UUID4
|
|
195
230
|
userId String
|
|
196
231
|
/// Prisma relation definition
|
|
197
232
|
user User @relation(fields: [userId], references: [id])
|
|
@@ -346,6 +381,14 @@ export const PostSchema = type({
|
|
|
346
381
|
})
|
|
347
382
|
|
|
348
383
|
export type Post = typeof PostSchema.infer
|
|
384
|
+
|
|
385
|
+
export const UserRelationsSchema = type({ ...UserSchema.t, posts: PostSchema.array() })
|
|
386
|
+
|
|
387
|
+
export type UserRelations = typeof UserRelationsSchema.infer
|
|
388
|
+
|
|
389
|
+
export const PostRelationsSchema = type({ ...PostSchema.t, user: UserSchema })
|
|
390
|
+
|
|
391
|
+
export type PostRelations = typeof PostRelationsSchema.infer
|
|
349
392
|
```
|
|
350
393
|
|
|
351
394
|
### Effect Schema
|
|
@@ -364,7 +407,7 @@ export const UserSchema = Schema.Struct({
|
|
|
364
407
|
name: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(50)),
|
|
365
408
|
})
|
|
366
409
|
|
|
367
|
-
export type
|
|
410
|
+
export type User = typeof UserSchema.Type
|
|
368
411
|
|
|
369
412
|
export const PostSchema = Schema.Struct({
|
|
370
413
|
/**
|
|
@@ -385,7 +428,18 @@ export const PostSchema = Schema.Struct({
|
|
|
385
428
|
userId: Schema.UUID,
|
|
386
429
|
})
|
|
387
430
|
|
|
388
|
-
export type
|
|
431
|
+
export type Post = typeof PostSchema.Type
|
|
432
|
+
|
|
433
|
+
export const UserRelationsSchema = Schema.Struct({
|
|
434
|
+
...UserSchema.fields,
|
|
435
|
+
posts: Schema.Array(PostSchema),
|
|
436
|
+
})
|
|
437
|
+
|
|
438
|
+
export type UserRelations = typeof UserRelationsSchema.Type
|
|
439
|
+
|
|
440
|
+
export const PostRelationsSchema = Schema.Struct({ ...PostSchema.fields, user: UserSchema })
|
|
441
|
+
|
|
442
|
+
export type PostRelations = typeof PostRelationsSchema.Type
|
|
389
443
|
```
|
|
390
444
|
|
|
391
445
|
### TypeBox
|
|
@@ -533,7 +587,9 @@ export const post = sqliteTable('post', {
|
|
|
533
587
|
.$defaultFn(() => crypto.randomUUID()),
|
|
534
588
|
title: text('title').notNull(),
|
|
535
589
|
content: text('content').notNull(),
|
|
536
|
-
userId: text('userId')
|
|
590
|
+
userId: text('userId')
|
|
591
|
+
.notNull()
|
|
592
|
+
.references(() => user.id),
|
|
537
593
|
})
|
|
538
594
|
|
|
539
595
|
export const userRelations = relations(user, ({ many }) => ({ posts: many(post) }))
|
|
@@ -543,6 +599,141 @@ export const postRelations = relations(post, ({ one }) => ({
|
|
|
543
599
|
}))
|
|
544
600
|
```
|
|
545
601
|
|
|
602
|
+
### Kysely
|
|
603
|
+
|
|
604
|
+
Pure type definitions for the [Kysely](https://kysely.dev/) query builder. The `DB` interface is keyed by the actual database table names (`@@map` respected), columns use `@map`-ped names, and enums become value unions of their `@map`-ped database values. Reach for Kysely's own `Selectable` / `Insertable` / `Updateable` wrappers when you need to name a row type; query results are inferred and need no annotation.
|
|
605
|
+
|
|
606
|
+
Only **database-side** defaults become `Generated<T>`. `autoincrement()`, `now()` and `dbgenerated(...)` are evaluated by the database, so they are optional on insert; `uuid()`, `cuid()`, `ulid()` and `nanoid()` are evaluated by the Prisma Client and leave the column without a DDL default, so a raw Kysely insert must still supply them.
|
|
607
|
+
|
|
608
|
+
```ts
|
|
609
|
+
export interface User {
|
|
610
|
+
id: string
|
|
611
|
+
name: string
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
export interface Post {
|
|
615
|
+
id: string
|
|
616
|
+
title: string
|
|
617
|
+
content: string
|
|
618
|
+
userId: string
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
export interface DB {
|
|
622
|
+
User: User
|
|
623
|
+
Post: Post
|
|
624
|
+
}
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
Both ids above are `@default(uuid())`, which Prisma evaluates in the client โ hence plain `string`, required on insert. A database-side default instead emits `Generated<T>` (and, for `DateTime`, the `Timestamp` alias), which Kysely makes optional on insert:
|
|
628
|
+
|
|
629
|
+
```prisma
|
|
630
|
+
model Comment {
|
|
631
|
+
id Int @id @default(autoincrement())
|
|
632
|
+
createdAt DateTime @default(now())
|
|
633
|
+
}
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
```ts
|
|
637
|
+
import type { ColumnType } from 'kysely'
|
|
638
|
+
|
|
639
|
+
export type Generated<T> =
|
|
640
|
+
T extends ColumnType<infer S, infer I, infer U>
|
|
641
|
+
? ColumnType<S, I | undefined, U>
|
|
642
|
+
: ColumnType<T, T | undefined, T>
|
|
643
|
+
|
|
644
|
+
export type Timestamp = ColumnType<Date, Date | string, Date | string>
|
|
645
|
+
|
|
646
|
+
export interface Comment {
|
|
647
|
+
id: Generated<number>
|
|
648
|
+
createdAt: Generated<Timestamp>
|
|
649
|
+
}
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
```ts
|
|
653
|
+
import { Kysely, type Insertable } from 'kysely'
|
|
654
|
+
import type { DB, Post } from './kysely/types'
|
|
655
|
+
|
|
656
|
+
declare const db: Kysely<DB>
|
|
657
|
+
declare const userId: string
|
|
658
|
+
|
|
659
|
+
// Query results are inferred โ no annotation needed.
|
|
660
|
+
const posts = await db.selectFrom('Post').selectAll().execute()
|
|
661
|
+
|
|
662
|
+
const draft: Insertable<Post> = {
|
|
663
|
+
id: crypto.randomUUID(),
|
|
664
|
+
title: 'Hello',
|
|
665
|
+
content: '...',
|
|
666
|
+
userId,
|
|
667
|
+
}
|
|
668
|
+
await db.insertInto('Post').values(draft).execute()
|
|
669
|
+
```
|
|
670
|
+
|
|
671
|
+
### Atlas
|
|
672
|
+
|
|
673
|
+
A declarative [Atlas](https://atlasgo.io/) HCL schema (`schema.hcl`). Table and column names use their `@@map`/`@map` database names, foreign keys and indexes follow Prisma's naming conventions (`<table>_<columns>_fkey` / `_key` / `_idx`), referential actions fall back to Prisma's defaults (`onUpdate: Cascade`, `onDelete: Restrict` for required and `SetNull` for optional relations), and client-side defaults such as `uuid()` and `cuid()` emit no database `DEFAULT` โ the file describes exactly what `prisma migrate` would create. The output is already `atlas schema fmt` canonical.
|
|
674
|
+
|
|
675
|
+
The schema label defaults to `public` (PostgreSQL / MySQL) or `main` (SQLite); on MySQL, set `schemaName` to your database name since MySQL schemas are databases.
|
|
676
|
+
|
|
677
|
+
> [!WARNING]
|
|
678
|
+
> Declarative `atlas schema apply` drops whatever is missing from the HCL, and three things can never appear in it: Prisma's own `_prisma_migrations` table (exclude it with `--exclude '_prisma_migrations'`), and columns or tables marked `@ignore`/`@@ignore` or typed `Unsupported(...)` โ Prisma omits those from the DMMF that hekireki reads. When applying to an existing database, always dry-run first and keep Atlas's destructive-change linting enabled.
|
|
679
|
+
|
|
680
|
+
Known limitations: the implicit m2m primary key is an unnamed constraint (Prisma names it `_X_AB_pkey`; the column set is identical, so this only surfaces as a constraint rename if you later hand the database back to `prisma migrate`), all enum blocks land in the default schema under `multiSchema` (Prisma exposes no schema for enums), Prisma's 63-byte truncation of very long constraint names is not reproduced, and removing or renaming enum values is a type rebuild in Atlas, as in any PostgreSQL workflow.
|
|
681
|
+
|
|
682
|
+
```hcl
|
|
683
|
+
table "User" {
|
|
684
|
+
schema = schema.main
|
|
685
|
+
column "id" {
|
|
686
|
+
null = false
|
|
687
|
+
type = text
|
|
688
|
+
}
|
|
689
|
+
column "name" {
|
|
690
|
+
null = false
|
|
691
|
+
type = text
|
|
692
|
+
}
|
|
693
|
+
primary_key {
|
|
694
|
+
columns = [column.id]
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
table "Post" {
|
|
699
|
+
schema = schema.main
|
|
700
|
+
column "id" {
|
|
701
|
+
null = false
|
|
702
|
+
type = text
|
|
703
|
+
}
|
|
704
|
+
column "title" {
|
|
705
|
+
null = false
|
|
706
|
+
type = text
|
|
707
|
+
}
|
|
708
|
+
column "content" {
|
|
709
|
+
null = false
|
|
710
|
+
type = text
|
|
711
|
+
}
|
|
712
|
+
column "userId" {
|
|
713
|
+
null = false
|
|
714
|
+
type = text
|
|
715
|
+
}
|
|
716
|
+
primary_key {
|
|
717
|
+
columns = [column.id]
|
|
718
|
+
}
|
|
719
|
+
foreign_key "Post_userId_fkey" {
|
|
720
|
+
columns = [column.userId]
|
|
721
|
+
ref_columns = [table.User.column.id]
|
|
722
|
+
on_update = CASCADE
|
|
723
|
+
on_delete = RESTRICT
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
schema "main" {}
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
```bash
|
|
731
|
+
# Apply the schema declaratively (dry-run first), or diff versioned migrations from it
|
|
732
|
+
atlas schema apply --url "$DATABASE_URL" --to file://atlas/schema.hcl --exclude '_prisma_migrations' --dry-run
|
|
733
|
+
atlas schema apply --url "$DATABASE_URL" --to file://atlas/schema.hcl --exclude '_prisma_migrations'
|
|
734
|
+
atlas migrate diff --dev-url "docker://postgres/17/dev" --to file://atlas/schema.hcl
|
|
735
|
+
```
|
|
736
|
+
|
|
546
737
|
### Ecto
|
|
547
738
|
|
|
548
739
|
Each model is output as a separate `.ex` file (1 model = 1 file), following Elixir conventions.
|
|
@@ -717,6 +908,59 @@ class Post(Base):
|
|
|
717
908
|
user: Mapped["User"] = relationship(back_populates="posts")
|
|
718
909
|
```
|
|
719
910
|
|
|
911
|
+
### Pydantic
|
|
912
|
+
|
|
913
|
+
[Pydantic](https://docs.pydantic.dev/) v2 models (Python). `@p.` field annotations are used verbatim as the base type โ list fields wrap it in `list[...]` and optional fields append `| None = None` โ and imports for the known pydantic / typing names they reference (`EmailStr`, `Annotated`, `StringConstraints`, โฆ) are added automatically; names outside that set are emitted as-is without an import. Fields without an annotation fall back to the built-in Prisma โ Python type mapping, enums become `Literal[...]` of their Prisma-level value names, and relation fields are omitted.
|
|
914
|
+
|
|
915
|
+
```python
|
|
916
|
+
from pydantic import BaseModel, StringConstraints, UUID4
|
|
917
|
+
from typing import Annotated
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
class User(BaseModel):
|
|
921
|
+
id: UUID4
|
|
922
|
+
"""Primary key"""
|
|
923
|
+
name: Annotated[str, StringConstraints(min_length=1, max_length=50)]
|
|
924
|
+
"""Display name"""
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
class Post(BaseModel):
|
|
928
|
+
id: UUID4
|
|
929
|
+
"""Primary key"""
|
|
930
|
+
title: Annotated[str, StringConstraints(min_length=1, max_length=100)]
|
|
931
|
+
"""Article title"""
|
|
932
|
+
content: str
|
|
933
|
+
"""Body content (no length limit)"""
|
|
934
|
+
userId: UUID4
|
|
935
|
+
"""Foreign key referencing User.id"""
|
|
936
|
+
```
|
|
937
|
+
|
|
938
|
+
To configure the model itself, annotate it with pydantic's own `ConfigDict` โ the expression is passed through verbatim as `model_config`. `@p.ConfigDict(extra='forbid')` rejects unknown keys, `@p.ConfigDict(extra='allow')` keeps them, `@p.ConfigDict(extra='ignore')` states pydantic's default explicitly, and any other `ConfigDict` arguments (e.g. `frozen=True`) work the same way. No annotation leaves pydantic's default (`extra="ignore"`):
|
|
939
|
+
|
|
940
|
+
```prisma
|
|
941
|
+
/// @p.ConfigDict(extra='forbid')
|
|
942
|
+
model ApiKey {
|
|
943
|
+
id String @id
|
|
944
|
+
}
|
|
945
|
+
```
|
|
946
|
+
|
|
947
|
+
```python
|
|
948
|
+
from pydantic import BaseModel, ConfigDict
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
class ApiKey(BaseModel):
|
|
952
|
+
model_config = ConfigDict(extra='forbid')
|
|
953
|
+
|
|
954
|
+
id: str
|
|
955
|
+
```
|
|
956
|
+
|
|
957
|
+
With `relation = true`, each model that has relation fields also gets a `<Model>Relations` subclass โ the Pydantic counterpart of the validator generators' relation schemas. Relation fields reference the base classes, so a payload fetched with its relations validates in one call:
|
|
958
|
+
|
|
959
|
+
```python
|
|
960
|
+
class UserRelations(User):
|
|
961
|
+
posts: list[Post]
|
|
962
|
+
```
|
|
963
|
+
|
|
720
964
|
### GORM
|
|
721
965
|
|
|
722
966
|
```go
|
|
@@ -876,13 +1120,17 @@ generator Hekireki-Docs {
|
|
|
876
1120
|
|
|
877
1121
|
## Configuration
|
|
878
1122
|
|
|
879
|
-
Configure each generator directly in your `schema.prisma` file
|
|
1123
|
+
Configure each generator directly in your `schema.prisma` file.
|
|
1124
|
+
|
|
1125
|
+
> `output` is **required** for every generator โ there is no implicit default directory.
|
|
1126
|
+
> Point it at a directory to get the file name shown below, or at a path with an
|
|
1127
|
+
> extension to choose the file name yourself.
|
|
880
1128
|
|
|
881
1129
|
```prisma
|
|
882
1130
|
// Zod Generator
|
|
883
1131
|
generator Hekireki-Zod {
|
|
884
1132
|
provider = "hekireki-zod"
|
|
885
|
-
output = "./zod" //
|
|
1133
|
+
output = "./zod" // Required. A directory here yields ./zod/index.ts
|
|
886
1134
|
type = true // Generate TypeScript types (default: false)
|
|
887
1135
|
comment = true // Include schema documentation (default: false)
|
|
888
1136
|
zod = "v4" // Zod import: "v4", "mini", or "@hono/zod-openapi" (default: v4)
|
|
@@ -892,7 +1140,7 @@ generator Hekireki-Zod {
|
|
|
892
1140
|
// Valibot Generator
|
|
893
1141
|
generator Hekireki-Valibot {
|
|
894
1142
|
provider = "hekireki-valibot"
|
|
895
|
-
output = "./valibot" //
|
|
1143
|
+
output = "./valibot" // Required. A directory here yields ./valibot/index.ts
|
|
896
1144
|
type = true // Generate TypeScript types (default: false)
|
|
897
1145
|
comment = true // Include schema documentation (default: false)
|
|
898
1146
|
relation = true // Generate relation schemas (default: false)
|
|
@@ -901,7 +1149,7 @@ generator Hekireki-Valibot {
|
|
|
901
1149
|
// ArkType Generator
|
|
902
1150
|
generator Hekireki-ArkType {
|
|
903
1151
|
provider = "hekireki-arktype"
|
|
904
|
-
output = "./arktype" //
|
|
1152
|
+
output = "./arktype" // Required. A directory here yields ./arktype/index.ts
|
|
905
1153
|
type = true // Generate TypeScript types (default: false)
|
|
906
1154
|
comment = true // Include schema documentation (default: false)
|
|
907
1155
|
relation = true // Generate relation schemas (default: false)
|
|
@@ -910,7 +1158,7 @@ generator Hekireki-ArkType {
|
|
|
910
1158
|
// Effect Schema Generator
|
|
911
1159
|
generator Hekireki-Effect {
|
|
912
1160
|
provider = "hekireki-effect"
|
|
913
|
-
output = "./effect" //
|
|
1161
|
+
output = "./effect" // Required. A directory here yields ./effect/index.ts
|
|
914
1162
|
type = true // Generate TypeScript types (default: false)
|
|
915
1163
|
comment = true // Include schema documentation (default: false)
|
|
916
1164
|
relation = true // Generate relation schemas (default: false)
|
|
@@ -919,7 +1167,7 @@ generator Hekireki-Effect {
|
|
|
919
1167
|
// TypeBox Generator
|
|
920
1168
|
generator Hekireki-TypeBox {
|
|
921
1169
|
provider = "hekireki-typebox"
|
|
922
|
-
output = "./typebox" //
|
|
1170
|
+
output = "./typebox" // Required. A directory here yields ./typebox/index.ts
|
|
923
1171
|
type = true // Generate TypeScript types (default: false)
|
|
924
1172
|
comment = true // Include schema documentation (default: false)
|
|
925
1173
|
relation = true // Generate relation schemas (default: false)
|
|
@@ -928,7 +1176,7 @@ generator Hekireki-TypeBox {
|
|
|
928
1176
|
// AJV (JSON Schema) Generator
|
|
929
1177
|
generator Hekireki-AJV {
|
|
930
1178
|
provider = "hekireki-ajv"
|
|
931
|
-
output = "./ajv" //
|
|
1179
|
+
output = "./ajv" // Required. A directory here yields ./ajv/index.ts
|
|
932
1180
|
type = true // Generate TypeScript types (default: false)
|
|
933
1181
|
comment = true // Include schema documentation (default: false)
|
|
934
1182
|
relation = true // Generate relation schemas (default: false)
|
|
@@ -937,73 +1185,95 @@ generator Hekireki-AJV {
|
|
|
937
1185
|
// Drizzle ORM Schema Generator
|
|
938
1186
|
generator Hekireki-Drizzle {
|
|
939
1187
|
provider = "hekireki-drizzle"
|
|
940
|
-
output = "./drizzle" //
|
|
1188
|
+
output = "./drizzle" // Required. A directory here yields ./drizzle/schema.ts
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
// Kysely Type Definitions Generator
|
|
1192
|
+
generator Hekireki-Kysely {
|
|
1193
|
+
provider = "hekireki-kysely"
|
|
1194
|
+
output = "./kysely" // Required. A directory here yields ./kysely/types.ts
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
// Atlas HCL Schema Generator
|
|
1198
|
+
generator Hekireki-Atlas {
|
|
1199
|
+
provider = "hekireki-atlas"
|
|
1200
|
+
output = "./atlas" // Required. A directory here yields ./atlas/schema.hcl
|
|
1201
|
+
schemaName = "public" // Schema label (default: postgresql/mysql "public", sqlite "main")
|
|
1202
|
+
comment = true // Emit /// docs as comment attributes (default: false)
|
|
941
1203
|
}
|
|
942
1204
|
|
|
943
1205
|
// SQLAlchemy Generator (Python)
|
|
944
1206
|
generator Hekireki-SQLAlchemy {
|
|
945
1207
|
provider = "hekireki-sqlalchemy"
|
|
946
|
-
output = "./sqlalchemy" //
|
|
1208
|
+
output = "./sqlalchemy" // Required. A directory here yields ./sqlalchemy/models.py
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
// Pydantic Generator (Python)
|
|
1212
|
+
generator Hekireki-Pydantic {
|
|
1213
|
+
provider = "hekireki-pydantic"
|
|
1214
|
+
output = "./pydantic" // Required. A directory here yields ./pydantic/models.py
|
|
1215
|
+
comment = true // Include docstrings from /// comments (default: false)
|
|
1216
|
+
relation = true // Generate <Model>Relations subclasses (default: false)
|
|
947
1217
|
}
|
|
948
1218
|
|
|
949
1219
|
// GORM Generator (Go)
|
|
950
1220
|
generator Hekireki-GORM {
|
|
951
1221
|
provider = "hekireki-gorm"
|
|
952
|
-
output = "./gorm" //
|
|
1222
|
+
output = "./gorm" // Required. A directory here yields ./gorm/models.go
|
|
953
1223
|
package = "model" // Go package name (default: model)
|
|
954
1224
|
}
|
|
955
1225
|
|
|
956
1226
|
// Sea-ORM Generator (Rust)
|
|
957
1227
|
generator Hekireki-SeaORM {
|
|
958
1228
|
provider = "hekireki-sea-orm"
|
|
959
|
-
output = "./sea_orm" // Output directory for .rs files
|
|
1229
|
+
output = "./sea_orm" // Required. Output directory for .rs files
|
|
960
1230
|
renameAll = "camelCase" // #[serde(rename_all = "...")] attribute (optional)
|
|
961
1231
|
}
|
|
962
1232
|
|
|
963
1233
|
// Ecto Generator (Elixir)
|
|
964
1234
|
generator Hekireki-Ecto {
|
|
965
1235
|
provider = "hekireki-ecto"
|
|
966
|
-
output = "./ecto" //
|
|
1236
|
+
output = "./ecto" // Required. A directory here yields ./ecto/
|
|
967
1237
|
app = "MyApp" // App name (default: MyApp)
|
|
968
1238
|
}
|
|
969
1239
|
|
|
970
1240
|
// Active Record Generator (Ruby on Rails)
|
|
971
1241
|
generator Hekireki-ActiveRecord {
|
|
972
1242
|
provider = "hekireki-activerecord"
|
|
973
|
-
output = "./activerecord" // Output directory for .rb files
|
|
1243
|
+
output = "./activerecord" // Required. Output directory for .rb files
|
|
974
1244
|
}
|
|
975
1245
|
|
|
976
1246
|
// Eloquent Generator (Laravel / PHP)
|
|
977
1247
|
generator Hekireki-Eloquent {
|
|
978
1248
|
provider = "hekireki-eloquent"
|
|
979
|
-
output = "./eloquent" // Output directory for .php files
|
|
1249
|
+
output = "./eloquent" // Required. Output directory for .php files
|
|
980
1250
|
namespace = "App.Models" // PHP namespace, "." becomes "\" (default: App\Models)
|
|
981
1251
|
}
|
|
982
1252
|
|
|
983
1253
|
// Mermaid ER Generator
|
|
984
1254
|
generator Hekireki-ER {
|
|
985
1255
|
provider = "hekireki-mermaid-er"
|
|
986
|
-
output = "./mermaid-er" //
|
|
1256
|
+
output = "./mermaid-er" // Required. A directory here yields ./mermaid-er/ER.md
|
|
987
1257
|
}
|
|
988
1258
|
|
|
989
1259
|
// DBML Generator (output extension determines format: .dbml or .png)
|
|
990
1260
|
generator Hekireki-DBML {
|
|
991
1261
|
provider = "hekireki-dbml"
|
|
992
|
-
output = "docs/schema.dbml" // File path ending in .dbml or .png
|
|
1262
|
+
output = "docs/schema.dbml" // Required. File path ending in .dbml or .png
|
|
993
1263
|
mapToDbSchema = true // Map to DB schema names (default: true)
|
|
994
1264
|
}
|
|
995
1265
|
|
|
996
1266
|
// PNG output (same provider, different extension)
|
|
997
1267
|
generator Hekireki-PNG {
|
|
998
1268
|
provider = "hekireki-dbml"
|
|
999
|
-
output = "docs/er-diagram.png" // .png extension โ PNG output
|
|
1269
|
+
output = "docs/er-diagram.png" // Required. .png extension โ PNG output
|
|
1000
1270
|
mapToDbSchema = true // Map to DB schema names (default: true)
|
|
1001
1271
|
}
|
|
1002
1272
|
|
|
1003
1273
|
// Docs Generator
|
|
1004
1274
|
generator Hekireki-Docs {
|
|
1005
1275
|
provider = "hekireki-docs"
|
|
1006
|
-
output = "./docs" //
|
|
1276
|
+
output = "./docs" // Required. A directory here yields ./docs
|
|
1007
1277
|
}
|
|
1008
1278
|
```
|
|
1009
1279
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
package/dist/bin/activerecord.js
CHANGED
package/dist/bin/ajv.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
package/dist/bin/ajv.js
CHANGED
package/dist/bin/arktype.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
package/dist/bin/arktype.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/bin/dbml.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
package/dist/bin/dbml.js
CHANGED
package/dist/bin/docs.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
package/dist/bin/docs.js
CHANGED
package/dist/bin/drizzle.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
package/dist/bin/drizzle.js
CHANGED
package/dist/bin/ecto.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
package/dist/bin/ecto.js
CHANGED
package/dist/bin/effect.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|