hekireki 0.23.0 → 0.31.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 +171 -19
- 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 +29 -25
- 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-CiVKUVYM.js} +1443 -270
- package/dist/{discover-Dd4T0K--.js → discover-DVB1eehy.js} +1 -1
- package/dist/{emit-Cg7AiLfc.js → emit-CdFQK71O.js} +1 -1
- package/dist/index.d.ts +5 -5
- 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-BMAnuiJ1.js} +4 -4
- 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/studio/assets/chip-BasDLVHw.js +1 -0
- package/dist/studio/assets/client-Cml1DF4R.js +2 -0
- package/dist/studio/assets/{code-block-BjrKQVTG.js → code-block-ON7BoQW2.js} +1 -1
- package/dist/studio/assets/confirm-dialog-IdKC4Tr2.js +1 -0
- package/dist/studio/assets/copy-D3Vc_bt4.js +1 -0
- package/dist/studio/assets/copy-button-CbaXuxba.js +1 -0
- package/dist/studio/assets/dist-DmM7_t8o.js +13 -0
- package/dist/studio/assets/{docs-CkqYk8Me.js → docs-ExwrGDZu.js} +1 -1
- package/dist/studio/assets/editor.worker-BbVB3hfz.js +33 -0
- package/dist/studio/assets/{enums._name-Bgr8KpI7.js → enums._name-C9BGV9--.js} +1 -1
- package/dist/studio/assets/hooks-B5oExX5W.js +55 -0
- package/dist/studio/assets/index-6aoNJjln.css +2 -0
- package/dist/studio/assets/index-ClVBmPHO.js +16 -0
- package/dist/studio/assets/labels-C7nHuKvb.js +1 -0
- package/dist/studio/assets/lazyRouteComponent-CDmLrXMS.js +1 -0
- package/dist/studio/assets/lu-BrVGIhAn.js +7 -0
- package/dist/studio/assets/marked-text-BRnsKz9k.js +3 -0
- package/dist/studio/assets/models._name-ByPeXRmm.js +1 -0
- package/dist/studio/assets/{monaco-gMjyryJ5.js → monaco-DbPgUJqj.js} +45 -45
- package/dist/studio/assets/monaco-GJe6VaZ-.js +11 -0
- package/dist/studio/assets/{not-found-CeYHDNqo.js → not-found-yBWFg0rP.js} +1 -1
- package/dist/studio/assets/{prisma-BO0BCCER.js → prisma-BnoDMkaK.js} +2 -2
- package/dist/studio/assets/result-table-CpErC1Pk.js +1 -0
- package/dist/studio/assets/routes-CKzRT8uT.js +1 -0
- package/dist/studio/assets/{schema-gate-CsCy68T_.js → schema-gate-B50_6S0h.js} +1 -1
- package/dist/studio/assets/schema-view-fqeCWRR2.js +9 -0
- package/dist/studio/assets/sql-CRhtXB4v.js +6 -0
- package/dist/studio/assets/table-Rze42PM3.js +1 -0
- package/dist/studio/assets/tabs-ClImdGQ1.js +1 -0
- package/dist/studio/assets/useFormValidation-Bgjs6o3Q.js +1 -0
- package/dist/studio/assets/useMatch-DMTwaRaz.js +1 -0
- package/dist/studio/assets/useMultipleSelectionState-DUiRXMUh.js +1 -0
- package/dist/studio/assets/{useOverlayTriggerState-vyNglC3z.js → useOverlayTriggerState-2DwfYtnL.js} +1 -1
- package/dist/studio/index.html +10 -10
- package/dist/{utils-CH4KSdD_.js → utils-Cgi66Lfo.js} +9 -23
- package/package.json +37 -37
- package/dist/studio/assets/chip-DktDoVzE.js +0 -1
- package/dist/studio/assets/client-Dr3jviL4.js +0 -2
- package/dist/studio/assets/confirm-dialog-DyTVsQSX.js +0 -1
- package/dist/studio/assets/copy-BiNLD_lP.js +0 -1
- package/dist/studio/assets/copy-button-BVg2tjZ8.js +0 -1
- package/dist/studio/assets/dist-B67qd3Zz.js +0 -13
- package/dist/studio/assets/editor.worker-D9zwrD0f.js +0 -30
- package/dist/studio/assets/hooks-D5FHpZ7j.js +0 -50
- package/dist/studio/assets/index-DOc026EB.css +0 -2
- package/dist/studio/assets/index-S7nroM-z.js +0 -16
- package/dist/studio/assets/labels-BNvY0cN5.js +0 -1
- package/dist/studio/assets/lazyRouteComponent-CAes9Xsr.js +0 -1
- package/dist/studio/assets/lu-d7uRxrOD.js +0 -7
- package/dist/studio/assets/marked-text-BdD2j0fn.js +0 -3
- package/dist/studio/assets/models._name-D4_ZANEh.js +0 -1
- package/dist/studio/assets/monaco-DcZOWb7S.js +0 -11
- package/dist/studio/assets/result-table-88RDb-mF.js +0 -1
- package/dist/studio/assets/routes-CcWfWQAl.js +0 -1
- package/dist/studio/assets/schema-view-nvsbR-7o.js +0 -8
- package/dist/studio/assets/sql-Dz7KO9RT.js +0 -6
- package/dist/studio/assets/table-Dh7RyVup.js +0 -1
- package/dist/studio/assets/tabs-Den1DTwv.js +0 -1
- package/dist/studio/assets/useFormValidation-DYw-_Bbl.js +0 -1
- package/dist/studio/assets/useMatch-Bfhrp9go.js +0 -1
- package/dist/studio/assets/useMultipleSelectionState-7x90tUim.js +0 -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,154 @@ model User {
|
|
|
50
54
|
}
|
|
51
55
|
```
|
|
52
56
|
|
|
57
|
+
### Rails
|
|
58
|
+
|
|
59
|
+
`hekireki-activerecord` writes `app/models` whole, for Rails 7.1 or later: `application_record.rb`
|
|
60
|
+
as `rails new` writes it (when `output` is a directory named `models`) and one `.rb` file per
|
|
61
|
+
model, so the directory can go in `.gitignore` and be regenerated with `prisma generate`. Each
|
|
62
|
+
model is written as a Rails developer would write it, and what Rails derives on its own is left
|
|
63
|
+
unsaid: `table_name` appears only when the table is not the plural of the class (without `@@map`
|
|
64
|
+
it is the model's own name, `"Todo"`, as Prisma creates it), `class_name`, `foreign_key` and
|
|
65
|
+
`inverse_of` only where the names depart from Rails' conventions (`has_many :todos` over `user_id`
|
|
66
|
+
needs none of them; its `belongs_to :user` keeps `inverse_of: :todos`, the plural inverse Rails
|
|
67
|
+
infers only with `automatically_invert_plural_associations`), and no comment at all: the `///`
|
|
68
|
+
documentation stays in the schema. The files pass `rubocop-rails-omakase` and RuboCop's own
|
|
69
|
+
defaults with `rubocop-rails` as written.
|
|
70
|
+
|
|
71
|
+
What the model does carry: an `attribute` default for each literal `@default`, for `uuid()`,
|
|
72
|
+
`ulid()`, `cuid()`, `cuid(2)` and `nanoid()` (the `ulid`, `cuid`, `cuid2` and `nanoid` gems) and an
|
|
73
|
+
empty array for a list without one, as the Prisma client reads it; `implicit_order_column` on the
|
|
74
|
+
created timestamp when the primary key is random (`uuid()`, `cuid()`, `nanoid()`); `alias_attribute`
|
|
75
|
+
for a `createdAt` or `@updatedAt` column so Rails fills and bumps it as the Prisma client would;
|
|
76
|
+
`enum` with snake_case keys (`PENDING_REVIEW` gives `record.pending_review?` and the
|
|
77
|
+
`pending_review` scope, the stored value stays the database's), its `default:`, `prefix: true` when a
|
|
78
|
+
key is a method Ruby or Active Record already has, and `validate: true` so a value outside the enum
|
|
79
|
+
is a validation error rather than an `ArgumentError`; `dependent:` on every `has_many` and `has_one`
|
|
80
|
+
as the foreign key's `onDelete` acts (`Cascade` destroys, `SetNull` nullifies, `Restrict` and
|
|
81
|
+
`NoAction` refuse with an error); and validations from the columns: a required column without a
|
|
82
|
+
default is `presence` (`inclusion` in `[ true, false ]` for a `Boolean`, `exclusion` of `nil` for
|
|
83
|
+
`Json` and `Bytes`), `@unique` and `@@unique` are `uniqueness`, `@db.VarChar(n)` is `length`.
|
|
84
|
+
|
|
85
|
+
Validation stays in the model, as Active Record has it. A `/// @ar.` call on a field is one
|
|
86
|
+
validator on one `///` line, written as Rails spells it (`presence`, `length(maximum: 255)`), and
|
|
87
|
+
becomes an option of that field's `validates`, replacing the one the schema implied when it names
|
|
88
|
+
the same validator; a `/// @ar.` line on the model is written into the class as it is. A message
|
|
89
|
+
given per locale, `message: { ja: "...", en: "..." }` or `too_long: { ja: "...", en: "..." }`, is
|
|
90
|
+
not written into the model: it goes to `config/locales/models/todo/<locale>.yml` under the key the
|
|
91
|
+
[Rails i18n guide](https://guides.rubyonrails.org/i18n.html#error-message-scopes) lists for that
|
|
92
|
+
validator (`activerecord.errors.models.todo.attributes.title.blank`). `too_long` is a key already;
|
|
93
|
+
`message` stands for every key the validator can raise: `blank` for `presence`, all three of
|
|
94
|
+
`length`, and for `numericality` and `comparison` the keys of the options given
|
|
95
|
+
(`greater_than: 0` raises `greater_than`), so the one translation covers whichever fails. A locale's
|
|
96
|
+
value may be plural forms, `{ one: "...", other: "%{count} ..." }`, which I18n picks by `count`, and
|
|
97
|
+
`%{count}`, `%{value}`, `%{model}` and `%{attribute}` interpolate as Rails' own messages do.
|
|
98
|
+
`@ar.name(ja: "...", en: "...")` on a field or a model translates its name the same way
|
|
99
|
+
(`activerecord.attributes.todo.title`, `activerecord.models.todo`), plural forms included.
|
|
100
|
+
The files are laid out as the guide's
|
|
101
|
+
[organization of locale files](https://guides.rubyonrails.org/i18n.html#organization-of-locale-files)
|
|
102
|
+
has them, `models/<model>/<locale>.yml`, one directory per model and one file per locale it names,
|
|
103
|
+
so model and attribute names stay apart from the text of the views and from the defaults; Rails
|
|
104
|
+
loads `config/locales` through its subdirectories. `locales` names that directory; from
|
|
105
|
+
`app/models` it is `config/locales`. The comment has one shape: the description first, then the
|
|
106
|
+
`@ar.` calls, one to a `///` line. On a field each is `name` or `name(arguments)` with its
|
|
107
|
+
parentheses closed on that line; on the model each is a Ruby line as the class body would have it
|
|
108
|
+
(`validates :a, :b, presence: true`, `normalizes :title, with: ->(title) { title.strip }`), not
|
|
109
|
+
ending in a comma. A description line after a call, a call that runs on to the next `///` or a
|
|
110
|
+
call of another shape stops `prisma generate` with the model and field it is on. Rails joins attribute and message with a space (`errors.format`), which Japanese does not want: the
|
|
111
|
+
`rails-i18n` gem's `ja.yml` sets it to `%{attribute}%{message}`, and the generated files sit beside
|
|
112
|
+
it. Point `output` at `app/models`, and `todo.rb` is the model, nothing left to edit by hand:
|
|
113
|
+
|
|
114
|
+
```prisma
|
|
115
|
+
generator Hekireki-ActiveRecord {
|
|
116
|
+
provider = "hekireki-activerecord"
|
|
117
|
+
output = "../app/models"
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/// @ar.name(ja: "やること", en: "Todo")
|
|
121
|
+
model Todo {
|
|
122
|
+
id Int @id @default(autoincrement())
|
|
123
|
+
/// @ar.name(ja: "タイトル", en: "Title")
|
|
124
|
+
/// @ar.presence(message: { ja: "を入力してください", en: "is required" })
|
|
125
|
+
/// @ar.length(maximum: 255, too_long: { ja: "%{count}文字以内で入力してください", en: "must be %{count} characters or less" })
|
|
126
|
+
title String @db.VarChar(255)
|
|
127
|
+
completed Boolean @default(false)
|
|
128
|
+
createdAt DateTime @default(now()) @map("created_at")
|
|
129
|
+
updatedAt DateTime @updatedAt @map("updated_at")
|
|
130
|
+
|
|
131
|
+
@@map("todos")
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
```ruby
|
|
136
|
+
# app/models/application_record.rb
|
|
137
|
+
class ApplicationRecord < ActiveRecord::Base
|
|
138
|
+
primary_abstract_class
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# app/models/todo.rb
|
|
142
|
+
class Todo < ApplicationRecord
|
|
143
|
+
attribute :completed, default: false
|
|
144
|
+
|
|
145
|
+
validates :title, presence: true, length: { maximum: 255 }
|
|
146
|
+
end
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
```yaml
|
|
150
|
+
# config/locales/models/todo/ja.yml
|
|
151
|
+
ja:
|
|
152
|
+
activerecord:
|
|
153
|
+
models:
|
|
154
|
+
todo: 'やること'
|
|
155
|
+
attributes:
|
|
156
|
+
todo:
|
|
157
|
+
title: 'タイトル'
|
|
158
|
+
errors:
|
|
159
|
+
models:
|
|
160
|
+
todo:
|
|
161
|
+
attributes:
|
|
162
|
+
title:
|
|
163
|
+
blank: 'を入力してください'
|
|
164
|
+
too_long: '%{count}文字以内で入力してください'
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
```gitignore
|
|
168
|
+
/app/models/
|
|
169
|
+
/config/locales/models/
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Which file answers is the request's locale. The guide's
|
|
173
|
+
[managing the locale across requests](https://guides.rubyonrails.org/i18n.html#managing-the-locale-across-requests)
|
|
174
|
+
sets it once per request with `I18n.with_locale`, which puts it back when the action ends rather
|
|
175
|
+
than leaving it on the thread for the next request, and names the locales the application serves:
|
|
176
|
+
|
|
177
|
+
```ruby
|
|
178
|
+
# config/application.rb
|
|
179
|
+
config.i18n.available_locales = %i[ja en]
|
|
180
|
+
config.i18n.default_locale = :ja
|
|
181
|
+
|
|
182
|
+
# app/controllers/application_controller.rb
|
|
183
|
+
class ApplicationController < ActionController::Base
|
|
184
|
+
around_action :switch_locale
|
|
185
|
+
|
|
186
|
+
private
|
|
187
|
+
def switch_locale(&action)
|
|
188
|
+
locale = params[:locale] || I18n.default_locale
|
|
189
|
+
I18n.with_locale(locale, &action)
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
The tables stay Prisma's to create, so Rails must not run its own migrations against them:
|
|
195
|
+
|
|
196
|
+
```ruby
|
|
197
|
+
# config/application.rb
|
|
198
|
+
config.active_record.migration_error = false
|
|
199
|
+
config.active_record.maintain_test_schema = false
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Create the test database with `prisma migrate deploy` (from `test_helper.rb`, or before the test
|
|
203
|
+
run) rather than `db:test:prepare`.
|
|
204
|
+
|
|
53
205
|
## Studio
|
|
54
206
|
|
|
55
207
|
```bash
|
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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { t as exists } from "../file-BPNqvwXD.js";
|
|
3
3
|
import { NodeRuntime, NodeServices } from "@effect/platform-node";
|
|
4
|
-
import {
|
|
4
|
+
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.31.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. */
|
|
@@ -70,15 +70,19 @@ function studioBanner(options) {
|
|
|
70
70
|
...options.error === null ? [] : [` Schema has errors, fix them and Studio will reload:\n${options.error}`]
|
|
71
71
|
].join("\n");
|
|
72
72
|
}
|
|
73
|
+
const Port = Schema.Int.check(Schema.isBetween({
|
|
74
|
+
minimum: 1,
|
|
75
|
+
maximum: 65535
|
|
76
|
+
}));
|
|
73
77
|
const studioFlags = {
|
|
74
|
-
port: Flag.
|
|
75
|
-
schema: Flag.
|
|
76
|
-
url: Flag.
|
|
78
|
+
port: Flag.Int("port").pipe(Flag.withAlias("p"), Flag.withSchema(Port), Flag.withDescription(`Port to listen on (default: ${DEFAULT_PORT})`), Flag.withMetavar("port"), Flag.withDefault(DEFAULT_PORT)),
|
|
79
|
+
schema: Flag.String("schema").pipe(Flag.withAlias("s"), Flag.withDescription(`Path to schema.prisma or a directory of .prisma files (default: ${DEFAULT_SCHEMA_PATHS.join(", then ")})`), Flag.withMetavar("schema.prisma|dir"), Flag.optional),
|
|
80
|
+
url: Flag.String("url").pipe(Flag.withAlias("u"), Flag.withSchema(DatabaseUrl), Flag.withDescription("Database connection URL for browsing and editing data (default: `url` in hekireki.config.ts, then the variable datasource.url names in prisma.config.ts or the schema, read from the environment or .env; DATABASE_URL when it names none)"), Flag.withMetavar("connection-string"), Flag.optional)
|
|
77
81
|
};
|
|
78
82
|
function runStudio(args) {
|
|
79
83
|
return Effect.gen(function* () {
|
|
80
84
|
const schemaPath = yield* resolveSchemaPath(Option.getOrNull(args.schema), [COMMAND_NAME, "studio"]);
|
|
81
|
-
const { startStudioServer } = yield* Effect.promise(() => import("../start-
|
|
85
|
+
const { startStudioServer } = yield* Effect.promise(() => import("../start-BhcpaMcT.js"));
|
|
82
86
|
const started = yield* startStudioServer({
|
|
83
87
|
schemaPath,
|
|
84
88
|
port: args.port,
|
|
@@ -113,18 +117,18 @@ const studio = Command.make("studio", studioFlags, runStudio).pipe(Command.withD
|
|
|
113
117
|
}
|
|
114
118
|
]));
|
|
115
119
|
const seedFlags = {
|
|
116
|
-
config: Flag.
|
|
117
|
-
schema: Flag.
|
|
118
|
-
url: Flag.
|
|
119
|
-
sql: Flag.
|
|
120
|
-
seed: Flag.
|
|
121
|
-
count: Flag.
|
|
122
|
-
locale: Flag.
|
|
123
|
-
reset: Flag.
|
|
120
|
+
config: Flag.String("config").pipe(Flag.withAlias("c"), Flag.withDescription("Path to the config, a TypeScript file (default: hekireki.config.ts in the working directory)"), Flag.withMetavar("hekireki.config.ts"), Flag.optional),
|
|
121
|
+
schema: Flag.String("schema").pipe(Flag.withAlias("s"), Flag.withDescription(`Path to schema.prisma or a directory of .prisma files (default: \`schema\` in the config, then ${DEFAULT_SCHEMA_PATHS.join(", then ")})`), Flag.withMetavar("schema.prisma|dir"), Flag.optional),
|
|
122
|
+
url: Flag.String("url").pipe(Flag.withAlias("u"), Flag.withSchema(DatabaseUrl), Flag.withDescription("Database connection URL to insert into (default: `url` in hekireki.config.ts, then the variable datasource.url names in prisma.config.ts or the schema, read from the environment or .env; DATABASE_URL when it names none)"), Flag.withMetavar("connection-string"), Flag.optional),
|
|
123
|
+
sql: Flag.String("sql").pipe(Flag.withDescription("Write the rows to this SQL file instead of inserting them"), Flag.withMetavar("seed.sql"), Flag.optional),
|
|
124
|
+
seed: Flag.Int("seed").pipe(Flag.withDescription("The faker seed; the same seed always gives the same rows (left out: every run differs)"), Flag.withMetavar("n"), Flag.optional),
|
|
125
|
+
count: Flag.Int("count").pipe(Flag.withAlias("n"), Flag.withDescription("Rows for every faker model, over the per-model counts of the config; models given as data keep their rows (left out: the config decides, and only the configured models are seeded)"), Flag.withMetavar("rows"), Flag.optional),
|
|
126
|
+
locale: Flag.String("locale").pipe(Flag.withAlias("l"), Flag.withDescription("Faker locale, or a comma-separated list tried in order (left out: faker's English)"), Flag.withMetavar("ja,en"), Flag.optional),
|
|
127
|
+
reset: Flag.Boolean("reset").pipe(Flag.withDescription("Delete every row of the seeded tables before inserting"), Flag.withDefault(false))
|
|
124
128
|
};
|
|
125
129
|
function runSeedCommand(args) {
|
|
126
130
|
return Effect.gen(function* () {
|
|
127
|
-
const { runSeed, seedBanner } = yield* Effect.promise(() => import("../run-
|
|
131
|
+
const { runSeed, seedBanner } = yield* Effect.promise(() => import("../run-BMAnuiJ1.js"));
|
|
128
132
|
const report = yield* runSeed({
|
|
129
133
|
config: Option.getOrNull(args.config),
|
|
130
134
|
schema: Option.getOrNull(args.schema),
|
|
@@ -157,11 +161,11 @@ const seed = Command.make("seed", seedFlags, runSeedCommand).pipe(Command.withDe
|
|
|
157
161
|
}
|
|
158
162
|
]));
|
|
159
163
|
const migrateCheckFlags = {
|
|
160
|
-
schema: Flag.
|
|
161
|
-
url: Flag.
|
|
162
|
-
decisions: Flag.
|
|
163
|
-
timeout: Flag.
|
|
164
|
-
json: Flag.
|
|
164
|
+
schema: Flag.String("schema").pipe(Flag.withAlias("s"), Flag.withDescription(`Path to the schema about to be migrated: schema.prisma or a directory of .prisma files (default: ${DEFAULT_SCHEMA_PATHS.join(", then ")})`), Flag.withMetavar("schema.prisma|dir"), Flag.optional),
|
|
165
|
+
url: Flag.String("url").pipe(Flag.withAlias("u"), Flag.withSchema(DatabaseUrl), Flag.withDescription("Database connection URL to check, read only (default: `url` in hekireki.config.ts, then the variable datasource.url names in prisma.config.ts or the schema, read from the environment or .env; DATABASE_URL when it names none)"), Flag.withMetavar("connection-string"), Flag.optional),
|
|
166
|
+
decisions: Flag.String("decisions").pipe(Flag.withAlias("d"), Flag.withDescription("Path to the decisions made on the Migrate page of `hekireki studio`: what becomes of the rows that stand in the way (default: .hekireki/migrate.json beside the schema)"), Flag.withMetavar("migrate.json"), Flag.optional),
|
|
167
|
+
timeout: Flag.Int("timeout").pipe(Flag.withDescription("How long one query may run, in milliseconds, on PostgreSQL and MySQL (default: no limit)"), Flag.withMetavar("ms"), Flag.optional),
|
|
168
|
+
json: Flag.Boolean("json").pipe(Flag.withDescription("Print the report as JSON, every check with its count and SQL"), Flag.withDefault(false))
|
|
165
169
|
};
|
|
166
170
|
/** The command line of `migrate check` as the runner reads it. */
|
|
167
171
|
function migrateInput(args, schemaPath) {
|
|
@@ -185,7 +189,7 @@ function runMigrateCheckCommand(args) {
|
|
|
185
189
|
"migrate",
|
|
186
190
|
"check"
|
|
187
191
|
]);
|
|
188
|
-
const { checkBanner, checkJson, runMigrateCheck, summarize } = yield* Effect.promise(() => import("../migrate-
|
|
192
|
+
const { checkBanner, checkJson, runMigrateCheck, summarize } = yield* Effect.promise(() => import("../migrate-B10ui4rh.js"));
|
|
189
193
|
const report = yield* runMigrateCheck(migrateInput(args, schemaPath)).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
|
|
190
194
|
yield* Console.log(args.json ? checkJson(report) : checkBanner(report));
|
|
191
195
|
const summary = summarize(report);
|
|
@@ -215,9 +219,9 @@ const migratePlanFlags = {
|
|
|
215
219
|
url: migrateCheckFlags.url,
|
|
216
220
|
decisions: migrateCheckFlags.decisions,
|
|
217
221
|
timeout: migrateCheckFlags.timeout,
|
|
218
|
-
migration: Flag.
|
|
219
|
-
batch: Flag.
|
|
220
|
-
output: Flag.
|
|
222
|
+
migration: Flag.String("migration").pipe(Flag.withAlias("m"), Flag.withDescription("The migration.sql Prisma wrote for the schema (`prisma migrate dev --create-only`): the plan is then the whole migration, the fixes first and what the migration itself has to do written into Prisma's statements"), Flag.withMetavar("migration.sql"), Flag.optional),
|
|
223
|
+
batch: Flag.Int("batch").pipe(Flag.withDescription("Run a fix over more rows than this that many at a time, one statement after another, so none holds its locks for the whole table (default: every fix in one statement; no effect inside the one DO block of PostgreSQL)"), Flag.withMetavar("rows"), Flag.optional),
|
|
224
|
+
output: Flag.String("output").pipe(Flag.withAlias("o"), Flag.withDescription("Write the SQL to this file and print the report (default: the SQL to stdout)"), Flag.withMetavar("fixes.sql"), Flag.optional)
|
|
221
225
|
};
|
|
222
226
|
function runMigratePlanCommand(args) {
|
|
223
227
|
return Effect.gen(function* () {
|
|
@@ -226,7 +230,7 @@ function runMigratePlanCommand(args) {
|
|
|
226
230
|
"migrate",
|
|
227
231
|
"plan"
|
|
228
232
|
]);
|
|
229
|
-
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"));
|
|
230
234
|
const report = yield* runMigrateCheck(migrateInput(args, schemaPath)).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
|
|
231
235
|
const migrationPath = Option.getOrNull(args.migration);
|
|
232
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