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 +113 -21
- 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.js +1 -1
- package/dist/bin/effect.js +1 -1
- package/dist/bin/eloquent.js +1 -1
- package/dist/bin/er.js +1 -1
- package/dist/bin/exposed.js +1 -1
- package/dist/bin/gorm.js +1 -1
- package/dist/bin/hekireki.js +5 -5
- 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/seed.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-_yRLzidS.js → bin-CmwdzyIR.js} +1469 -270
- package/dist/{discover-Dd4T0K--.js → discover-DVB1eehy.js} +1 -1
- package/dist/{emit-Cg7AiLfc.js → emit-CdFQK71O.js} +1 -1
- package/dist/{migrate-D_qSZohK.js → migrate-B10ui4rh.js} +3 -3
- package/dist/{plan-CYDx4rVr.js → plan-BDkcp2gn.js} +3 -3
- package/dist/{run-DBKTGE9q.js → run-DhCGgShc.js} +17 -13
- package/dist/{schema-n8EV8GwT.js → schema-B-2ni3YF.js} +1 -1
- package/dist/{sql-Bfp97prN.js → sql-Bb3cwfJt.js} +1 -1
- package/dist/{start-CHsK9ngN.js → start-BhcpaMcT.js} +5 -5
- package/dist/{utils-CH4KSdD_.js → utils-Cgi66Lfo.js} +9 -23
- package/package.json +1 -1
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
|
|
27
|
-
|
|
|
28
|
-
| `hekireki-zod`
|
|
29
|
-
| `hekireki-valibot`, `hekireki-arktype`, `hekireki-effect`, `hekireki-typebox`, `hekireki-ajv`
|
|
30
|
-
| `hekireki-pydantic`
|
|
31
|
-
| `hekireki-drizzle`, `hekireki-kysely`, `hekireki-sqlalchemy`, `hekireki-django
|
|
32
|
-
| `hekireki-
|
|
33
|
-
| `hekireki-
|
|
34
|
-
| `hekireki-
|
|
35
|
-
| `hekireki-
|
|
36
|
-
| `hekireki-
|
|
37
|
-
| `hekireki-
|
|
38
|
-
| `hekireki-
|
|
39
|
-
| `hekireki-
|
|
40
|
-
| `hekireki-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
61
|
-
|
|
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
|
+

|
|
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
|
+

|
|
142
|
+
|
|
143
|
+
**Try Prisma Client calls** and see the SQL each one sends.
|
|
144
|
+
|
|
145
|
+

|
|
146
|
+
|
|
147
|
+
**Edit the schema** beside its ER diagram, which follows the file as it changes.
|
|
148
|
+
|
|
149
|
+

|
|
150
|
+
|
|
151
|
+
**Read the docs** of every model: its fields, and an example of each operation.
|
|
152
|
+
|
|
153
|
+

|
|
62
154
|
|
|
63
155
|
## Seed
|
|
64
156
|
|
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
package/dist/bin/efcore.js
CHANGED
package/dist/bin/effect.js
CHANGED
package/dist/bin/eloquent.js
CHANGED
package/dist/bin/er.js
CHANGED
package/dist/bin/exposed.js
CHANGED
package/dist/bin/gorm.js
CHANGED
package/dist/bin/hekireki.js
CHANGED
|
@@ -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.
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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 })));
|
package/dist/bin/kysely.js
CHANGED
package/dist/bin/pydantic.js
CHANGED
package/dist/bin/sea-orm.js
CHANGED
package/dist/bin/seed.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