hekireki 0.32.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.
Files changed (62) hide show
  1. package/README.md +168 -11
  2. package/dist/bin/activerecord.js +1 -1
  3. package/dist/bin/ajv.js +1 -1
  4. package/dist/bin/arktype.js +1 -1
  5. package/dist/bin/atlas.js +1 -1
  6. package/dist/bin/django.js +1 -1
  7. package/dist/bin/drizzle.js +1 -1
  8. package/dist/bin/ecto.js +1 -1
  9. package/dist/bin/efcore.js +1 -1
  10. package/dist/bin/effect.js +1 -1
  11. package/dist/bin/eloquent.js +1 -1
  12. package/dist/bin/er.js +1 -1
  13. package/dist/bin/exposed.js +1 -1
  14. package/dist/bin/gorm.js +1 -1
  15. package/dist/bin/hekireki.js +139 -149
  16. package/dist/bin/kysely.js +1 -1
  17. package/dist/bin/pydantic.js +1 -1
  18. package/dist/bin/sea-orm.js +1 -1
  19. package/dist/bin/seed.js +1 -1
  20. package/dist/bin/sqlalchemy.js +1 -1
  21. package/dist/bin/typebox.js +1 -1
  22. package/dist/bin/valibot.js +1 -1
  23. package/dist/bin/zod.js +1 -1
  24. package/dist/{bin-CmwdzyIR.js → bin-B2PLRVJb.js} +5098 -1837
  25. package/dist/{discover-DVB1eehy.js → discover-BNQ5gbRn.js} +1 -1
  26. package/dist/{emit-CdFQK71O.js → emit-BeblTVH8.js} +2 -2
  27. package/dist/{file-BPNqvwXD.js → file-Df9ykHXv.js} +1 -5
  28. package/dist/{migrate-B10ui4rh.js → migrate-Icu7Se0-.js} +4 -4
  29. package/dist/{plan-BDkcp2gn.js → plan-EKATG1WY.js} +118 -73
  30. package/dist/{run-DhCGgShc.js → run-C13eFGuX.js} +8 -10
  31. package/dist/{schema-B-2ni3YF.js → schema-RYU_i7qd.js} +2 -2
  32. package/dist/{sql-Bb3cwfJt.js → sql-F40UQMF6.js} +37 -54
  33. package/dist/{start-BhcpaMcT.js → start-HLOLxRBL.js} +162 -205
  34. package/dist/studio/assets/{client-Cml1DF4R.js → client-D-BDuDx5.js} +1 -1
  35. package/dist/studio/assets/{code-block-ON7BoQW2.js → code-block-Bo0pcw3d.js} +1 -1
  36. package/dist/studio/assets/{confirm-dialog-IdKC4Tr2.js → confirm-dialog-GIPt_m1h.js} +1 -1
  37. package/dist/studio/assets/{copy-D3Vc_bt4.js → copy-DVfEjDPw.js} +1 -1
  38. package/dist/studio/assets/{copy-button-CbaXuxba.js → copy-button-Di-sHQ2O.js} +1 -1
  39. package/dist/studio/assets/{dist-DmM7_t8o.js → dist-CebhqUaX.js} +5 -5
  40. package/dist/studio/assets/{docs-ExwrGDZu.js → docs-CnzWByuq.js} +1 -1
  41. package/dist/studio/assets/{enums._name-C9BGV9--.js → enums._name-I0mP3WCt.js} +1 -1
  42. package/dist/studio/assets/{index-ClVBmPHO.js → index-CMmzpMBz.js} +4 -4
  43. package/dist/studio/assets/{labels-C7nHuKvb.js → labels-DuphOVul.js} +1 -1
  44. package/dist/studio/assets/{lazyRouteComponent-CDmLrXMS.js → lazyRouteComponent-tS2t_LrD.js} +1 -1
  45. package/dist/studio/assets/{lu-BrVGIhAn.js → lu-cVORv6D3.js} +1 -1
  46. package/dist/studio/assets/{marked-text-BRnsKz9k.js → marked-text-tf7-IzXm.js} +1 -1
  47. package/dist/studio/assets/{models._name-ByPeXRmm.js → models._name-DsOwcKoe.js} +1 -1
  48. package/dist/studio/assets/{prisma-BnoDMkaK.js → prisma-CWAhnzN5.js} +1 -1
  49. package/dist/studio/assets/{result-table-CpErC1Pk.js → result-table-CGvil3pc.js} +1 -1
  50. package/dist/studio/assets/{routes-CKzRT8uT.js → routes-CBvE-Puz.js} +1 -1
  51. package/dist/studio/assets/{schema-gate-B50_6S0h.js → schema-gate-BC3i18Tp.js} +1 -1
  52. package/dist/studio/assets/schema-view-C2X5nwuH.js +9 -0
  53. package/dist/studio/assets/{sql-CRhtXB4v.js → sql-CMRDYX3Z.js} +1 -1
  54. package/dist/studio/assets/{table-Rze42PM3.js → table-bAwthXaP.js} +1 -1
  55. package/dist/studio/assets/{tabs-ClImdGQ1.js → tabs-DfoRK_ae.js} +1 -1
  56. package/dist/studio/assets/{useFormValidation-Bgjs6o3Q.js → useFormValidation-B7STfHY3.js} +1 -1
  57. package/dist/studio/assets/{useMultipleSelectionState-DUiRXMUh.js → useMultipleSelectionState-vASeYbQk.js} +1 -1
  58. package/dist/studio/assets/{useOverlayTriggerState-2DwfYtnL.js → useOverlayTriggerState-BO95y8NP.js} +1 -1
  59. package/dist/studio/index.html +6 -6
  60. package/dist/{utils-Cgi66Lfo.js → utils-ckthTWS0.js} +38 -2
  61. package/package.json +14 -14
  62. package/dist/studio/assets/schema-view-fqeCWRR2.js +0 -9
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { t as exists } from "../file-BPNqvwXD.js";
2
+ import { t as exists } from "../file-Df9ykHXv.js";
3
3
  import { NodeRuntime, NodeServices } from "@effect/platform-node";
4
- import { Console, Data, Effect, Option, Schema, Stdio } from "effect";
4
+ import { Console, Data, Effect, Schema } 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.32.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. */
@@ -34,12 +34,10 @@ var SchemaLoadError = class extends Data.TaggedError("SchemaLoadError") {};
34
34
  var SchemaParseError = class extends Data.TaggedError("SchemaParseError") {};
35
35
  var ServerListenError = class extends Data.TaggedError("ServerListenError") {};
36
36
  //#endregion
37
- //#region src/cli/constants.ts
38
- /** Where `--schema` looks when it is omitted, in order. */
39
- const DEFAULT_SCHEMA_PATHS = ["prisma/schema.prisma", "schema.prisma"];
40
- //#endregion
41
37
  //#region src/cli/index.ts
42
38
  const COMMAND_NAME = "hekireki";
39
+ /** Where `--schema` looks when it is omitted, in order. */
40
+ const DEFAULT_SCHEMA_PATHS = ["prisma/schema.prisma", "schema.prisma"];
43
41
  const STATIC_DIR = path.resolve(import.meta.dirname, "../studio");
44
42
  const DatabaseUrl = Schema.String.pipe(Schema.check(Schema.isPattern(/^(?:postgres|postgresql|mysql|file):/u, { message: "a postgres://, postgresql://, mysql:// or file: connection string" })));
45
43
  /**
@@ -76,18 +74,18 @@ const Port = Schema.Int.check(Schema.isBetween({
76
74
  }));
77
75
  const studioFlags = {
78
76
  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
+ 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.withDefault(null)),
78
+ 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.withDefault(null))
81
79
  };
82
80
  function runStudio(args) {
83
81
  return Effect.gen(function* () {
84
- const schemaPath = yield* resolveSchemaPath(Option.getOrNull(args.schema), [COMMAND_NAME, "studio"]);
85
- const { startStudioServer } = yield* Effect.promise(() => import("../start-BhcpaMcT.js"));
82
+ const schemaPath = yield* resolveSchemaPath(args.schema, [COMMAND_NAME, "studio"]);
83
+ const { startStudioServer } = yield* Effect.promise(() => import("../start-HLOLxRBL.js"));
86
84
  const started = yield* startStudioServer({
87
85
  schemaPath,
88
86
  port: args.port,
89
87
  staticDir: STATIC_DIR,
90
- databaseUrl: Option.getOrNull(args.url)
88
+ databaseUrl: args.url
91
89
  }).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error instanceof ServerListenError && error.code === "EADDRINUSE" ? `Port ${error.port} is already in use. Pass -p <port> to use another port.` : error.message })));
92
90
  yield* Console.log(studioBanner({
93
91
  port: args.port,
@@ -98,153 +96,144 @@ function runStudio(args) {
98
96
  yield* Effect.never;
99
97
  }).pipe(Effect.scoped);
100
98
  }
101
- const studio = Command.make("studio", studioFlags, runStudio).pipe(Command.withDescription("Open Hekireki Studio: ER diagram, docs, model data and SQL for a Prisma schema"), Command.withExamples([
102
- {
103
- command: `${COMMAND_NAME} studio`,
104
- description: `Open ./${DEFAULT_SCHEMA_PATHS[0]}, with the database URL from .env`
105
- },
106
- {
107
- command: `${COMMAND_NAME} studio --schema prisma/schema`,
108
- description: "Read a multi-file schema: every .prisma file of the directory, together"
109
- },
110
- {
111
- command: `${COMMAND_NAME} studio --url file:./dev.db`,
112
- description: "Browse a SQLite file, resolved from the schema directory as Prisma resolves it"
113
- },
114
- {
115
- command: `${COMMAND_NAME} studio -p 3000`,
116
- description: "Listen on another port"
117
- }
118
- ]));
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
+ }
119
119
  const seedFlags = {
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),
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)),
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)),
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.withDefault(null)),
123
+ output: Flag.String("sql").pipe(Flag.withDescription("Write the rows to this SQL file instead of inserting them"), Flag.withMetavar("seed.sql"), Flag.withDefault(null)),
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.withDefault(null)),
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.withDefault(null)),
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.withDefault(null)),
127
127
  reset: Flag.Boolean("reset").pipe(Flag.withDescription("Delete every row of the seeded tables before inserting"), Flag.withDefault(false))
128
128
  };
129
129
  function runSeedCommand(args) {
130
130
  return Effect.gen(function* () {
131
- const { runSeed, seedBanner } = yield* Effect.promise(() => import("../run-DhCGgShc.js"));
132
- const report = yield* runSeed({
133
- config: Option.getOrNull(args.config),
134
- schema: Option.getOrNull(args.schema),
135
- url: Option.getOrNull(args.url),
136
- output: Option.getOrNull(args.sql),
137
- seed: Option.getOrNull(args.seed),
138
- count: Option.getOrNull(args.count),
139
- locale: Option.getOrNull(args.locale),
140
- reset: args.reset
141
- }, process.cwd()).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
131
+ const { runSeed, seedBanner } = yield* Effect.promise(() => import("../run-C13eFGuX.js"));
132
+ const report = yield* runSeed(args, process.cwd()).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
142
133
  yield* Console.log(seedBanner(report));
143
134
  });
144
135
  }
145
- const seed = 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([
146
- {
147
- command: `${COMMAND_NAME} seed`,
148
- description: "Read hekireki.config.ts and insert into the database named by DATABASE_URL"
149
- },
150
- {
151
- command: `${COMMAND_NAME} seed --sql prisma/seed.sql`,
152
- description: "Write the same rows as a SQL script instead of inserting them"
153
- },
154
- {
155
- command: `${COMMAND_NAME} seed --reset --seed 7 --count 100`,
156
- description: "Empty the seeded tables first, then insert 100 rows per model from seed 7"
157
- },
158
- {
159
- command: `${COMMAND_NAME} seed --locale ja`,
160
- description: "Japanese names, addresses and text"
161
- }
162
- ]));
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
+ }
163
156
  const migrateCheckFlags = {
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),
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)),
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)),
159
+ 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.withDefault(null)),
160
+ 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.withDefault(null)),
168
161
  json: Flag.Boolean("json").pipe(Flag.withDescription("Print the report as JSON, every check with its count and SQL"), Flag.withDefault(false))
169
162
  };
170
- /** The command line of `migrate check` as the runner reads it. */
171
- function migrateInput(args, schemaPath) {
172
- return {
173
- schemaPath,
174
- url: Option.getOrNull(args.url),
175
- decisions: Option.getOrNull(args.decisions),
176
- timeout: Option.getOrNull(args.timeout),
177
- cwd: process.cwd(),
178
- env: process.env
179
- };
180
- }
181
163
  /** Why the data is not ready, as the command fails with it. */
182
164
  function notReady(summary) {
183
165
  return summary.blocking > 0 ? `${summary.blocking} blocking problem${summary.blocking === 1 ? "" : "s"} in the data: fix the rows, or decide what becomes of them on the Migrate page of hekireki studio, before migrating.` : `${summary.failed} check${summary.failed === 1 ? "" : "s"} could not run.`;
184
166
  }
185
167
  function runMigrateCheckCommand(args) {
186
168
  return Effect.gen(function* () {
187
- const schemaPath = yield* resolveSchemaPath(Option.getOrNull(args.schema), [
169
+ const schemaPath = yield* resolveSchemaPath(args.schema, [
188
170
  COMMAND_NAME,
189
171
  "migrate",
190
172
  "check"
191
173
  ]);
192
- const { checkBanner, checkJson, runMigrateCheck, summarize } = yield* Effect.promise(() => import("../migrate-B10ui4rh.js"));
193
- const report = yield* runMigrateCheck(migrateInput(args, schemaPath)).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
174
+ const { checkBanner, checkJson, runMigrateCheck, summarize } = yield* Effect.promise(() => import("../migrate-Icu7Se0-.js"));
175
+ const report = yield* runMigrateCheck({
176
+ ...args,
177
+ schemaPath,
178
+ cwd: process.cwd()
179
+ }).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
194
180
  yield* Console.log(args.json ? checkJson(report) : checkBanner(report));
195
181
  const summary = summarize(report);
196
182
  if (!summary.ok) yield* new CliError.UserError({ cause: notReady(summary) });
197
183
  });
198
184
  }
199
- const migrateCheck = 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([
200
- {
201
- command: `${COMMAND_NAME} migrate check`,
202
- description: "Check the edited schema against the database named by DATABASE_URL"
203
- },
204
- {
205
- command: `${COMMAND_NAME} migrate check --url postgresql://readonly@prod/app`,
206
- description: "Check the production data before `prisma migrate deploy` runs on it"
207
- },
208
- {
209
- command: `${COMMAND_NAME} migrate check --json`,
210
- description: "A report for CI: every check, its count and the SQL that counted it"
211
- },
212
- {
213
- command: `${COMMAND_NAME} migrate check --timeout 30000`,
214
- description: "Stop any query that runs longer than 30 seconds"
215
- }
216
- ]));
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
+ }
217
205
  const migratePlanFlags = {
218
206
  schema: migrateCheckFlags.schema,
219
207
  url: migrateCheckFlags.url,
220
208
  decisions: migrateCheckFlags.decisions,
221
209
  timeout: migrateCheckFlags.timeout,
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)
210
+ 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.withDefault(null)),
211
+ 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.withDefault(null)),
212
+ 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.withDefault(null))
225
213
  };
226
214
  function runMigratePlanCommand(args) {
227
215
  return Effect.gen(function* () {
228
- const schemaPath = yield* resolveSchemaPath(Option.getOrNull(args.schema), [
216
+ const schemaPath = yield* resolveSchemaPath(args.schema, [
229
217
  COMMAND_NAME,
230
218
  "migrate",
231
219
  "plan"
232
220
  ]);
233
- const { checkBanner, planSql, readMigration, runMigrateCheck, summarize, writePlan } = yield* Effect.promise(() => import("../migrate-B10ui4rh.js"));
234
- const report = yield* runMigrateCheck(migrateInput(args, schemaPath)).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
235
- const migrationPath = Option.getOrNull(args.migration);
236
- const migration = migrationPath === null ? null : yield* readMigration(path.resolve(migrationPath)).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
237
- const batch = Option.getOrNull(args.batch);
238
- if (batch !== null && batch < 1) yield* new CliError.UserError({ cause: "--batch takes a number of rows, 1 or more." });
239
- const { sql, errors, notes } = planSql(report, migration, batch);
221
+ const { checkBanner, planSql, readMigration, runMigrateCheck, summarize, writePlan } = yield* Effect.promise(() => import("../migrate-Icu7Se0-.js"));
222
+ const report = yield* runMigrateCheck({
223
+ ...args,
224
+ schemaPath,
225
+ cwd: process.cwd()
226
+ }).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
227
+ const migration = args.migration === null ? null : yield* readMigration(path.resolve(args.migration)).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
228
+ if (args.batch !== null && args.batch < 1) yield* new CliError.UserError({ cause: "--batch takes a number of rows, 1 or more." });
229
+ const { sql, errors, notes } = planSql(report, migration, args.batch);
240
230
  if (errors.length > 0) yield* new CliError.UserError({ cause: errors.join("\n") });
241
- const output = Option.getOrNull(args.output);
242
231
  const noted = notes.map((note) => ` ${note}`).join("\n");
243
- if (output === null) {
232
+ if (args.output === null) {
244
233
  yield* Console.log(sql.trimEnd());
245
234
  yield* Console.error(noted);
246
235
  } else {
247
- const file = path.resolve(output);
236
+ const file = path.resolve(args.output);
248
237
  yield* writePlan(sql, file).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
249
238
  yield* Console.log(`${checkBanner(report)}\n\n Plan: ${file}\n${noted}`);
250
239
  }
@@ -252,41 +241,42 @@ function runMigratePlanCommand(args) {
252
241
  if (!summary.ok) yield* new CliError.UserError({ cause: notReady(summary) });
253
242
  });
254
243
  }
255
- const migratePlan = 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([
256
- {
257
- command: `${COMMAND_NAME} migrate plan > fixes.sql`,
258
- description: "The SQL on stdout, to paste at the top of the migration Prisma writes"
259
- },
260
- {
261
- command: `${COMMAND_NAME} migrate plan -o prisma/fixes.sql`,
262
- description: "Write it to a file and print the report of the check"
263
- },
264
- {
265
- command: `${COMMAND_NAME} migrate plan -m prisma/migrations/20260915_rename/migration.sql -o prisma/migrations/20260915_rename/migration.sql`,
266
- description: "Rewrite the migration Prisma wrote: the fixes first, renames, conversions and fills in its statements"
267
- },
268
- {
269
- command: `${COMMAND_NAME} migrate plan --batch 10000 -o prisma/fixes.sql`,
270
- description: "On a large table in use: a fix over more than 10000 rows runs 10000 at a time"
271
- }
272
- ]));
273
- const migrate = Command.make("migrate").pipe(Command.withDescription("Data checks and fixes for a schema migration"), Command.withSubcommands([migrateCheck, migratePlan]));
274
- const cli = Command.make(COMMAND_NAME).pipe(Command.withDescription("⚡️ Prisma schema tools"), Command.withSubcommands([
275
- studio,
276
- seed,
277
- migrate
278
- ]));
279
- function hekirekiCli(argv, config) {
280
- return Command.runWith(cli, config)(argv);
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
+ ]));
281
263
  }
282
- /** The entry point the bin runs, reading its arguments the way `Command.run` does. */
283
- function hekireki(config) {
284
- return Effect.gen(function* () {
285
- return yield* hekirekiCli(yield* (yield* Stdio.Stdio).args, config);
286
- });
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 });
287
277
  }
288
278
  //#endregion
289
279
  //#region src/bin/hekireki.ts
290
- NodeRuntime.runMain(hekireki({ version }).pipe(Effect.provide(NodeServices.layer)));
280
+ NodeRuntime.runMain(hekireki().pipe(Effect.provide(NodeServices.layer)));
291
281
  //#endregion
292
- export { PRISMA_FILE_URI as _, DatabaseError as a, FormatError as c, SchemaParseError as d, ServerListenError as f, MIGRATIONS_POLL_MS as g, FORBIDDEN_HOST_MESSAGE as h, ContractViolationError as i, InvalidInputError as l, UnknownModelError as m, ClientQueryError as n, DatabaseUnavailableError as o, UnknownFileError as p, ClientUnavailableError as r, FileWriteError as s, DEFAULT_SCHEMA_PATHS as t, SchemaLoadError as u, SSE_PING_MS as v, STUDIO_HOSTNAME as y };
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 };
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-CmwdzyIR.js";
2
+ import { t as registerGenerator } from "../bin-B2PLRVJb.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-CmwdzyIR.js";
2
+ import { t as registerGenerator } from "../bin-B2PLRVJb.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-CmwdzyIR.js";
2
+ import { t as registerGenerator } from "../bin-B2PLRVJb.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-CmwdzyIR.js";
2
+ import { t as registerGenerator } from "../bin-B2PLRVJb.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-CmwdzyIR.js";
2
+ import { t as registerGenerator } from "../bin-B2PLRVJb.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-CmwdzyIR.js";
2
+ import { t as registerGenerator } from "../bin-B2PLRVJb.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-CmwdzyIR.js";
2
+ import { t as registerGenerator } from "../bin-B2PLRVJb.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-CmwdzyIR.js";
2
+ import { t as registerGenerator } from "../bin-B2PLRVJb.js";
3
3
  //#region src/bin/zod.ts
4
4
  registerGenerator("zod");
5
5
  //#endregion