hekireki 0.30.0 → 0.32.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
@@ -13,7 +13,10 @@ npm install -D hekireki
13
13
 
14
14
  ## Generators
15
15
 
16
- Add a generator to `schema.prisma` and run `npx prisma generate`. `output` is required.
16
+ Add a generator to `schema.prisma` and run `npx prisma generate`. `output` is required. Every
17
+ generator reads the tables and columns Prisma creates: a model or field without `@map` keeps the
18
+ name it has in the schema (`"Todo"`, `"authorId"`), and each ORM is told so where its own
19
+ convention would say otherwise.
17
20
 
18
21
  ```prisma
19
22
  generator Hekireki-Zod {
@@ -23,24 +26,25 @@ generator Hekireki-Zod {
23
26
  }
24
27
  ```
25
28
 
26
- | Provider | Generates | Options |
27
- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------ |
28
- | `hekireki-zod` | [Zod](https://zod.dev/) | `type`, `comment`, `relation`, `zod` (`"v4"`, `"mini"`, `"@hono/zod-openapi"`) |
29
- | `hekireki-valibot`, `hekireki-arktype`, `hekireki-effect`, `hekireki-typebox`, `hekireki-ajv` | Valibot, ArkType, Effect Schema, TypeBox, AJV | `type`, `comment`, `relation` |
30
- | `hekireki-pydantic` | Pydantic | `comment`, `relation` |
31
- | `hekireki-drizzle`, `hekireki-kysely`, `hekireki-sqlalchemy`, `hekireki-django`, `hekireki-activerecord` | Drizzle, Kysely, SQLAlchemy, Django, Active Record | |
32
- | `hekireki-gorm` | GORM | `package` |
33
- | `hekireki-sea-orm` | SeaORM | `renameAll` |
34
- | `hekireki-ecto` | Ecto | `app` |
35
- | `hekireki-eloquent` | Eloquent | `namespace` |
36
- | `hekireki-efcore` (PostgreSQL) | EF Core | `namespace`, `context` |
37
- | `hekireki-exposed` (PostgreSQL) | Exposed | `package`, `dao` |
38
- | `hekireki-atlas` | Atlas HCL | `schemaName`, `comment` |
39
- | `hekireki-er` | ER diagram | `outputs` (`.md`, `.dbml`, `.png`, `.svg`), `theme` |
40
- | `hekireki-seed` | The schema module `hekireki.config.ts` is typed against | |
41
-
42
- A `///` line starting with `@z.`, `@v.`, `@a.`, `@e.`, `@t.`, `@j.` or `@p.` is used as-is by Zod,
43
- Valibot, ArkType, Effect Schema, TypeBox, AJV or Pydantic:
29
+ | Provider | Generates | Options |
30
+ | --------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------ |
31
+ | `hekireki-zod` | [Zod](https://zod.dev/) | `type`, `comment`, `relation`, `zod` (`"v4"`, `"mini"`, `"@hono/zod-openapi"`) |
32
+ | `hekireki-valibot`, `hekireki-arktype`, `hekireki-effect`, `hekireki-typebox`, `hekireki-ajv` | Valibot, ArkType, Effect Schema, TypeBox, AJV | `type`, `comment`, `relation` |
33
+ | `hekireki-pydantic` | Pydantic | `comment`, `relation` |
34
+ | `hekireki-drizzle`, `hekireki-kysely`, `hekireki-sqlalchemy`, `hekireki-django` | Drizzle, Kysely, SQLAlchemy, Django | |
35
+ | `hekireki-activerecord` | Active Record | `locales` |
36
+ | `hekireki-gorm` | GORM | `package` |
37
+ | `hekireki-sea-orm` | SeaORM | `renameAll` |
38
+ | `hekireki-ecto` | Ecto | `app` |
39
+ | `hekireki-eloquent` | Eloquent | `namespace` |
40
+ | `hekireki-efcore` (PostgreSQL) | EF Core | `namespace`, `context` |
41
+ | `hekireki-exposed` (PostgreSQL) | Exposed | `package`, `dao` |
42
+ | `hekireki-atlas` | Atlas HCL | `schemaName`, `comment` |
43
+ | `hekireki-er` | ER diagram | `outputs` (`.md`, `.dbml`, `.png`, `.svg`), `theme` |
44
+ | `hekireki-seed` | The schema module `hekireki.config.ts` is typed against | |
45
+
46
+ A `///` line starting with `@z.`, `@v.`, `@a.`, `@e.`, `@t.`, `@j.`, `@p.` or `@ar.` is used
47
+ as-is by Zod, Valibot, ArkType, Effect Schema, TypeBox, AJV, Pydantic or Active Record:
44
48
 
45
49
  ```prisma
46
50
  model User {
@@ -50,6 +54,74 @@ model User {
50
54
  }
51
55
  ```
52
56
 
57
+ ### Rails
58
+
59
+ `hekireki-activerecord` writes `app/models` from the schema: `application_record.rb` and one model
60
+ per Prisma model, as a Rails developer would write them. What Rails works out on its own
61
+ (`table_name`, `class_name`, `foreign_key`, `inverse_of` where the names follow its conventions)
62
+ is left unsaid; what the schema promises is written: `attribute` defaults, `enum`, timestamps,
63
+ associations with `dependent:` from `onDelete`, and validations from the columns (`presence`,
64
+ `uniqueness`, `length`).
65
+
66
+ A `/// @ar.` line on a field is a validator (`presence`, `length(maximum: 255)`) added to that
67
+ field's `validates`; on a model it is a Ruby line written into the class as it is
68
+ (`has_secure_password`, `has_many :tags, through: :post_tags`, `scope ...`). A message or name
69
+ given per locale, `message: { ja: "...", en: "..." }` or `@ar.name(ja: "...")`, goes to
70
+ `config/locales/models/<model>/<locale>.yml` under the key Rails reads.
71
+
72
+ ```prisma
73
+ generator Hekireki-ActiveRecord {
74
+ provider = "hekireki-activerecord"
75
+ output = "../app/models"
76
+ }
77
+
78
+ /// @ar.name(ja: "やること", en: "Todo")
79
+ model Todo {
80
+ id Int @id @default(autoincrement())
81
+ /// @ar.name(ja: "タイトル", en: "Title")
82
+ /// @ar.presence(message: { ja: "を入力してください", en: "is required" })
83
+ /// @ar.length(maximum: 255, too_long: { ja: "%{count}文字以内で入力してください", en: "must be %{count} characters or less" })
84
+ title String @db.VarChar(255)
85
+ completed Boolean @default(false)
86
+ createdAt DateTime @default(now()) @map("created_at")
87
+ updatedAt DateTime @updatedAt @map("updated_at")
88
+
89
+ @@map("todos")
90
+ }
91
+ ```
92
+
93
+ ```ruby
94
+ # app/models/todo.rb
95
+ class Todo < ApplicationRecord
96
+ attribute :completed, default: false
97
+
98
+ validates :title, presence: true, length: { maximum: 255 }
99
+ end
100
+ ```
101
+
102
+ ```yaml
103
+ # config/locales/models/todo/ja.yml
104
+ ja:
105
+ activerecord:
106
+ models:
107
+ todo: 'やること'
108
+ attributes:
109
+ todo:
110
+ title: 'タイトル'
111
+ errors:
112
+ models:
113
+ todo:
114
+ attributes:
115
+ title:
116
+ blank: 'を入力してください'
117
+ too_long: '%{count}文字以内で入力してください'
118
+ ```
119
+
120
+ The tables stay Prisma's to create, so set `config.active_record.migration_error = false` and
121
+ create the test database with `prisma migrate deploy`. `examples/active-record` in the repository
122
+ runs a fuller schema against Active Record on SQLite, and is the place to read what each thing
123
+ becomes.
124
+
53
125
  ## Studio
54
126
 
55
127
  ```bash
@@ -57,8 +129,28 @@ npx hekireki studio # ./prisma/schema.prisma or ./schema.prisma
57
129
  npx hekireki studio --url file:./dev.db
58
130
  ```
59
131
 
60
- The ER diagram, the rows of each model, a schema editor, a SQL console and a Prisma Client
61
- playground, in the browser. SQLite, PostgreSQL and MySQL.
132
+ Your schema and database in the browser, on SQLite, PostgreSQL and MySQL.
133
+
134
+ **Browse the rows** of each model: search, add, edit and export them.
135
+
136
+ ![The rows of the User model](https://raw.githubusercontent.com/nakita628/hekireki/refs/heads/main/assets/img/studio-data.png)
137
+
138
+ **Run SQL** with completion from the schema. The ER diagram marks the tables a statement reads,
139
+ and the result comes with the TypeScript types of its rows.
140
+
141
+ ![A SELECT typed in the SQL console](https://raw.githubusercontent.com/nakita628/hekireki/refs/heads/main/assets/img/studio-sql.gif)
142
+
143
+ **Try Prisma Client calls** and see the SQL each one sends.
144
+
145
+ ![prisma.user.findMany() in the Prisma Client playground](https://raw.githubusercontent.com/nakita628/hekireki/refs/heads/main/assets/img/studio-prisma-client.gif)
146
+
147
+ **Edit the schema** beside its ER diagram, which follows the file as it changes.
148
+
149
+ ![The Prisma schema editor and the ER diagram](https://raw.githubusercontent.com/nakita628/hekireki/refs/heads/main/assets/img/studio-prisma-schema.png)
150
+
151
+ **Read the docs** of every model: its fields, and an example of each operation.
152
+
153
+ ![The generated docs of the User model](https://raw.githubusercontent.com/nakita628/hekireki/refs/heads/main/assets/img/studio-docs.png)
62
154
 
63
155
  ## Seed
64
156
 
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.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-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.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-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.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-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.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-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.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-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.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-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.js";
3
3
  //#region src/bin/ecto.ts
4
4
  registerGenerator("ecto");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.js";
3
3
  //#region src/bin/efcore.ts
4
4
  registerGenerator("efcore");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.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-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.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-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.js";
3
3
  //#region src/bin/er.ts
4
4
  registerGenerator("er");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.js";
3
3
  //#region src/bin/exposed.ts
4
4
  registerGenerator("exposed");
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-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.js";
3
3
  //#region src/bin/gorm.ts
4
4
  registerGenerator("gorm");
5
5
  //#endregion
@@ -5,7 +5,7 @@ import { 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.30.0";
8
+ var version = "0.32.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. */
@@ -82,7 +82,7 @@ const studioFlags = {
82
82
  function runStudio(args) {
83
83
  return Effect.gen(function* () {
84
84
  const schemaPath = yield* resolveSchemaPath(Option.getOrNull(args.schema), [COMMAND_NAME, "studio"]);
85
- const { startStudioServer } = yield* Effect.promise(() => import("../start-CHsK9ngN.js"));
85
+ const { startStudioServer } = yield* Effect.promise(() => import("../start-BhcpaMcT.js"));
86
86
  const started = yield* startStudioServer({
87
87
  schemaPath,
88
88
  port: args.port,
@@ -128,7 +128,7 @@ const seedFlags = {
128
128
  };
129
129
  function runSeedCommand(args) {
130
130
  return Effect.gen(function* () {
131
- const { runSeed, seedBanner } = yield* Effect.promise(() => import("../run-DBKTGE9q.js"));
131
+ const { runSeed, seedBanner } = yield* Effect.promise(() => import("../run-DhCGgShc.js"));
132
132
  const report = yield* runSeed({
133
133
  config: Option.getOrNull(args.config),
134
134
  schema: Option.getOrNull(args.schema),
@@ -189,7 +189,7 @@ function runMigrateCheckCommand(args) {
189
189
  "migrate",
190
190
  "check"
191
191
  ]);
192
- const { checkBanner, checkJson, runMigrateCheck, summarize } = yield* Effect.promise(() => import("../migrate-D_qSZohK.js"));
192
+ const { checkBanner, checkJson, runMigrateCheck, summarize } = yield* Effect.promise(() => import("../migrate-B10ui4rh.js"));
193
193
  const report = yield* runMigrateCheck(migrateInput(args, schemaPath)).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
194
194
  yield* Console.log(args.json ? checkJson(report) : checkBanner(report));
195
195
  const summary = summarize(report);
@@ -230,7 +230,7 @@ function runMigratePlanCommand(args) {
230
230
  "migrate",
231
231
  "plan"
232
232
  ]);
233
- const { checkBanner, planSql, readMigration, runMigrateCheck, summarize, writePlan } = yield* Effect.promise(() => import("../migrate-D_qSZohK.js"));
233
+ const { checkBanner, planSql, readMigration, runMigrateCheck, summarize, writePlan } = yield* Effect.promise(() => import("../migrate-B10ui4rh.js"));
234
234
  const report = yield* runMigrateCheck(migrateInput(args, schemaPath)).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
235
235
  const migrationPath = Option.getOrNull(args.migration);
236
236
  const migration = migrationPath === null ? null : yield* readMigration(path.resolve(migrationPath)).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.js";
3
3
  //#region src/bin/kysely.ts
4
4
  registerGenerator("kysely");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.js";
3
3
  //#region src/bin/pydantic.ts
4
4
  registerGenerator("pydantic");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.js";
3
3
  //#region src/bin/sea-orm.ts
4
4
  registerGenerator("sea-orm");
5
5
  //#endregion
package/dist/bin/seed.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.js";
3
3
  //#region src/bin/seed.ts
4
4
  registerGenerator("seed");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.js";
3
3
  //#region src/bin/sqlalchemy.ts
4
4
  registerGenerator("sqlalchemy");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.js";
3
3
  //#region src/bin/typebox.ts
4
4
  registerGenerator("typebox");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.js";
3
3
  //#region src/bin/valibot.ts
4
4
  registerGenerator("valibot");
5
5
  //#endregion
package/dist/bin/zod.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-_yRLzidS.js";
2
+ import { t as registerGenerator } from "../bin-CmwdzyIR.js";
3
3
  //#region src/bin/zod.ts
4
4
  registerGenerator("zod");
5
5
  //#endregion