hekireki 0.33.0 → 0.34.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/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 +103 -89
- 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-BedDciI4.js → bin-B2PLRVJb.js} +928 -578
- package/dist/{discover-C_OWaNiu.js → discover-BNQ5gbRn.js} +1 -1
- package/dist/{migrate-CvfrvM4u.js → migrate-Icu7Se0-.js} +2 -2
- package/dist/{plan-dRHRS5pw.js → plan-EKATG1WY.js} +108 -66
- package/dist/{run-BKGjRYpT.js → run-C13eFGuX.js} +3 -4
- package/dist/{sql-MFsOi3_t.js → sql-F40UQMF6.js} +34 -51
- package/dist/{start-Crxh2c9d.js → start-HLOLxRBL.js} +151 -191
- package/dist/studio/assets/{client-DjOVdm86.js → client-D-BDuDx5.js} +1 -1
- package/dist/studio/assets/{confirm-dialog-BQVcIkfP.js → confirm-dialog-GIPt_m1h.js} +1 -1
- package/dist/studio/assets/{docs-BpQXqPH3.js → docs-CnzWByuq.js} +1 -1
- package/dist/studio/assets/{enums._name-BufcpUnz.js → enums._name-I0mP3WCt.js} +1 -1
- package/dist/studio/assets/{index-CXzs-Au7.js → index-CMmzpMBz.js} +2 -2
- package/dist/studio/assets/{marked-text-DtpHRSKt.js → marked-text-tf7-IzXm.js} +1 -1
- package/dist/studio/assets/{models._name-BNMTjU6P.js → models._name-DsOwcKoe.js} +1 -1
- package/dist/studio/assets/{prisma-CBc_VcSl.js → prisma-CWAhnzN5.js} +1 -1
- package/dist/studio/assets/{result-table-CrTPC-aR.js → result-table-CGvil3pc.js} +1 -1
- package/dist/studio/assets/{routes-B3m6jQHR.js → routes-CBvE-Puz.js} +1 -1
- package/dist/studio/assets/schema-view-C2X5nwuH.js +9 -0
- package/dist/studio/assets/{sql-B3t2pCf4.js → sql-CMRDYX3Z.js} +1 -1
- package/dist/studio/assets/{tabs-Bj63lLvK.js → tabs-DfoRK_ae.js} +1 -1
- package/dist/studio/index.html +1 -1
- package/package.json +1 -1
- package/dist/studio/assets/schema-view-C427B7Jc.js +0 -9
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
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { t as exists } from "../file-Df9ykHXv.js";
|
|
3
3
|
import { NodeRuntime, NodeServices } from "@effect/platform-node";
|
|
4
4
|
import { Console, Data, Effect, Schema } from "effect";
|
|
5
|
-
import { CliError, Command, Flag } from "effect/unstable/cli";
|
|
6
5
|
import path from "node:path";
|
|
6
|
+
import { CliError, Command, Flag } from "effect/unstable/cli";
|
|
7
7
|
//#region package.json
|
|
8
|
-
var version = "0.
|
|
8
|
+
var version = "0.34.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. */
|
|
@@ -80,7 +80,7 @@ const studioFlags = {
|
|
|
80
80
|
function runStudio(args) {
|
|
81
81
|
return Effect.gen(function* () {
|
|
82
82
|
const schemaPath = yield* resolveSchemaPath(args.schema, [COMMAND_NAME, "studio"]);
|
|
83
|
-
const { startStudioServer } = yield* Effect.promise(() => import("../start-
|
|
83
|
+
const { startStudioServer } = yield* Effect.promise(() => import("../start-HLOLxRBL.js"));
|
|
84
84
|
const started = yield* startStudioServer({
|
|
85
85
|
schemaPath,
|
|
86
86
|
port: args.port,
|
|
@@ -96,24 +96,26 @@ function runStudio(args) {
|
|
|
96
96
|
yield* Effect.never;
|
|
97
97
|
}).pipe(Effect.scoped);
|
|
98
98
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
99
|
+
function studio() {
|
|
100
|
+
return Command.make("studio", studioFlags, runStudio).pipe(Command.withDescription("Open Hekireki Studio: ER diagram, docs, model data and SQL for a Prisma schema"), Command.withExamples([
|
|
101
|
+
{
|
|
102
|
+
command: `${COMMAND_NAME} studio`,
|
|
103
|
+
description: `Open ./${DEFAULT_SCHEMA_PATHS[0]}, with the database URL from .env`
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
command: `${COMMAND_NAME} studio --schema prisma/schema`,
|
|
107
|
+
description: "Read a multi-file schema: every .prisma file of the directory, together"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
command: `${COMMAND_NAME} studio --url file:./dev.db`,
|
|
111
|
+
description: "Browse a SQLite file, resolved from the schema directory as Prisma resolves it"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
command: `${COMMAND_NAME} studio -p 3000`,
|
|
115
|
+
description: "Listen on another port"
|
|
116
|
+
}
|
|
117
|
+
]));
|
|
118
|
+
}
|
|
117
119
|
const seedFlags = {
|
|
118
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.withDefault(null)),
|
|
119
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.withDefault(null)),
|
|
@@ -126,29 +128,31 @@ const seedFlags = {
|
|
|
126
128
|
};
|
|
127
129
|
function runSeedCommand(args) {
|
|
128
130
|
return Effect.gen(function* () {
|
|
129
|
-
const { runSeed, seedBanner } = yield* Effect.promise(() => import("../run-
|
|
131
|
+
const { runSeed, seedBanner } = yield* Effect.promise(() => import("../run-C13eFGuX.js"));
|
|
130
132
|
const report = yield* runSeed(args, process.cwd()).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
|
|
131
133
|
yield* Console.log(seedBanner(report));
|
|
132
134
|
});
|
|
133
135
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
136
|
+
function seed() {
|
|
137
|
+
return Command.make("seed", seedFlags, runSeedCommand).pipe(Command.withDescription("Fill the database with faker rows that follow the schema: relations, enums, unique keys and date ranges"), Command.withExamples([
|
|
138
|
+
{
|
|
139
|
+
command: `${COMMAND_NAME} seed`,
|
|
140
|
+
description: "Read hekireki.config.ts and insert into the database named by DATABASE_URL"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
command: `${COMMAND_NAME} seed --sql prisma/seed.sql`,
|
|
144
|
+
description: "Write the same rows as a SQL script instead of inserting them"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
command: `${COMMAND_NAME} seed --reset --seed 7 --count 100`,
|
|
148
|
+
description: "Empty the seeded tables first, then insert 100 rows per model from seed 7"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
command: `${COMMAND_NAME} seed --locale ja`,
|
|
152
|
+
description: "Japanese names, addresses and text"
|
|
153
|
+
}
|
|
154
|
+
]));
|
|
155
|
+
}
|
|
152
156
|
const migrateCheckFlags = {
|
|
153
157
|
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.withDefault(null)),
|
|
154
158
|
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.withDefault(null)),
|
|
@@ -167,36 +171,37 @@ function runMigrateCheckCommand(args) {
|
|
|
167
171
|
"migrate",
|
|
168
172
|
"check"
|
|
169
173
|
]);
|
|
170
|
-
const { checkBanner, checkJson, runMigrateCheck, summarize } = yield* Effect.promise(() => import("../migrate-
|
|
174
|
+
const { checkBanner, checkJson, runMigrateCheck, summarize } = yield* Effect.promise(() => import("../migrate-Icu7Se0-.js"));
|
|
171
175
|
const report = yield* runMigrateCheck({
|
|
172
176
|
...args,
|
|
173
177
|
schemaPath,
|
|
174
|
-
cwd: process.cwd()
|
|
175
|
-
env: process.env
|
|
178
|
+
cwd: process.cwd()
|
|
176
179
|
}).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
|
|
177
180
|
yield* Console.log(args.json ? checkJson(report) : checkBanner(report));
|
|
178
181
|
const summary = summarize(report);
|
|
179
182
|
if (!summary.ok) yield* new CliError.UserError({ cause: notReady(summary) });
|
|
180
183
|
});
|
|
181
184
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
185
|
+
function migrateCheck() {
|
|
186
|
+
return Command.make("check", migrateCheckFlags, runMigrateCheckCommand).pipe(Command.withDescription("Check the rows of the database against the schema about to be migrated: NULLs in a column turning required, duplicates under a new unique key, orphans of a foreign key, values an enum drops, and the data a dropped table or column takes with it. Read only; fails when something blocks."), Command.withExamples([
|
|
187
|
+
{
|
|
188
|
+
command: `${COMMAND_NAME} migrate check`,
|
|
189
|
+
description: "Check the edited schema against the database named by DATABASE_URL"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
command: `${COMMAND_NAME} migrate check --url postgresql://readonly@prod/app`,
|
|
193
|
+
description: "Check the production data before `prisma migrate deploy` runs on it"
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
command: `${COMMAND_NAME} migrate check --json`,
|
|
197
|
+
description: "A report for CI: every check, its count and the SQL that counted it"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
command: `${COMMAND_NAME} migrate check --timeout 30000`,
|
|
201
|
+
description: "Stop any query that runs longer than 30 seconds"
|
|
202
|
+
}
|
|
203
|
+
]));
|
|
204
|
+
}
|
|
200
205
|
const migratePlanFlags = {
|
|
201
206
|
schema: migrateCheckFlags.schema,
|
|
202
207
|
url: migrateCheckFlags.url,
|
|
@@ -213,12 +218,11 @@ function runMigratePlanCommand(args) {
|
|
|
213
218
|
"migrate",
|
|
214
219
|
"plan"
|
|
215
220
|
]);
|
|
216
|
-
const { checkBanner, planSql, readMigration, runMigrateCheck, summarize, writePlan } = yield* Effect.promise(() => import("../migrate-
|
|
221
|
+
const { checkBanner, planSql, readMigration, runMigrateCheck, summarize, writePlan } = yield* Effect.promise(() => import("../migrate-Icu7Se0-.js"));
|
|
217
222
|
const report = yield* runMigrateCheck({
|
|
218
223
|
...args,
|
|
219
224
|
schemaPath,
|
|
220
|
-
cwd: process.cwd()
|
|
221
|
-
env: process.env
|
|
225
|
+
cwd: process.cwd()
|
|
222
226
|
}).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
|
|
223
227
|
const migration = args.migration === null ? null : yield* readMigration(path.resolve(args.migration)).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
|
|
224
228
|
if (args.batch !== null && args.batch < 1) yield* new CliError.UserError({ cause: "--batch takes a number of rows, 1 or more." });
|
|
@@ -237,32 +241,42 @@ function runMigratePlanCommand(args) {
|
|
|
237
241
|
if (!summary.ok) yield* new CliError.UserError({ cause: notReady(summary) });
|
|
238
242
|
});
|
|
239
243
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
244
|
+
function migratePlan() {
|
|
245
|
+
return Command.make("plan", migratePlanFlags, runMigratePlanCommand).pipe(Command.withDescription("Write the fixes decided on the Migrate page of hekireki studio as SQL to run before the migration: the UPDATEs and DELETEs `migrate check` counted them by. With --migration, the whole migration Prisma wrote, the fixes first and the renames, conversions, fills and new enum members written into it. Reads the database, writes nothing to it; fails when something still blocks."), Command.withExamples([
|
|
246
|
+
{
|
|
247
|
+
command: `${COMMAND_NAME} migrate plan > fixes.sql`,
|
|
248
|
+
description: "The SQL on stdout, to paste at the top of the migration Prisma writes"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
command: `${COMMAND_NAME} migrate plan -o prisma/fixes.sql`,
|
|
252
|
+
description: "Write it to a file and print the report of the check"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
command: `${COMMAND_NAME} migrate plan -m prisma/migrations/20260915_rename/migration.sql -o prisma/migrations/20260915_rename/migration.sql`,
|
|
256
|
+
description: "Rewrite the migration Prisma wrote: the fixes first, renames, conversions and fills in its statements"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
command: `${COMMAND_NAME} migrate plan --batch 10000 -o prisma/fixes.sql`,
|
|
260
|
+
description: "On a large table in use: a fix over more than 10000 rows runs 10000 at a time"
|
|
261
|
+
}
|
|
262
|
+
]));
|
|
263
|
+
}
|
|
264
|
+
function migrate() {
|
|
265
|
+
return Command.make("migrate").pipe(Command.withDescription("Data checks and fixes for a schema migration"), Command.withSubcommands([migrateCheck(), migratePlan()]));
|
|
266
|
+
}
|
|
267
|
+
function cli() {
|
|
268
|
+
return Command.make(COMMAND_NAME).pipe(Command.withDescription("⚡️ Prisma schema tools"), Command.withSubcommands([
|
|
269
|
+
studio(),
|
|
270
|
+
seed(),
|
|
271
|
+
migrate()
|
|
272
|
+
]));
|
|
273
|
+
}
|
|
274
|
+
/** The `hekireki` command line, run with the arguments the `Stdio` service supplies. */
|
|
275
|
+
function hekireki() {
|
|
276
|
+
return Command.run(cli(), { version });
|
|
277
|
+
}
|
|
264
278
|
//#endregion
|
|
265
279
|
//#region src/bin/hekireki.ts
|
|
266
|
-
NodeRuntime.runMain(
|
|
280
|
+
NodeRuntime.runMain(hekireki().pipe(Effect.provide(NodeServices.layer)));
|
|
267
281
|
//#endregion
|
|
268
282
|
export { SSE_PING_MS as _, DatabaseUnavailableError as a, InvalidInputError as c, ServerListenError as d, UnknownFileError as f, PRISMA_FILE_URI as g, MIGRATIONS_POLL_MS as h, DatabaseError as i, SchemaLoadError as l, FORBIDDEN_HOST_MESSAGE as m, ClientUnavailableError as n, FileWriteError as o, UnknownModelError as p, ContractViolationError as r, FormatError as s, ClientQueryError as t, SchemaParseError as u, STUDIO_HOSTNAME as v };
|
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