hekireki 0.20.1 → 0.20.2

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 (66) hide show
  1. package/README.md +27 -1
  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/effect.js +1 -1
  10. package/dist/bin/eloquent.js +1 -1
  11. package/dist/bin/er.js +1 -1
  12. package/dist/bin/gorm.js +1 -1
  13. package/dist/bin/hekireki.js +2 -2
  14. package/dist/bin/kysely.js +1 -1
  15. package/dist/bin/pydantic.js +1 -1
  16. package/dist/bin/sea-orm.js +1 -1
  17. package/dist/bin/sqlalchemy.js +1 -1
  18. package/dist/bin/typebox.js +1 -1
  19. package/dist/bin/valibot.js +1 -1
  20. package/dist/bin/zod.js +1 -1
  21. package/dist/{bin-CPb5ZV8W.js → bin-CjbhMZs0.js} +1 -1
  22. package/dist/{schema-DwMNeEei.js → schema-Ci19PgR9.js} +136 -1
  23. package/dist/{start-Blp4k61D.js → start-EKGd2Tvk.js} +4610 -197
  24. package/dist/studio/assets/chip-CLdO-gL5.js +1 -0
  25. package/dist/studio/assets/copy-CcAufM8p.js +1 -0
  26. package/dist/studio/assets/debounce-T36H3Pq5.js +3 -0
  27. package/dist/studio/assets/dist-Ax_1vG1u.js +12 -0
  28. package/dist/studio/assets/docs-DW8-viIy.js +24 -0
  29. package/dist/studio/assets/enums._name-C2s5pbQ3.js +1 -0
  30. package/dist/studio/assets/hooks-Ctp_pGlY.js +1 -0
  31. package/dist/studio/assets/index-BP1uJf2T.js +16 -0
  32. package/dist/studio/assets/index-CYncH7vk.css +2 -0
  33. package/dist/studio/assets/labels-BXtM_faz.js +1 -0
  34. package/dist/studio/assets/lazyRouteComponent-C6zg30cR.js +1 -0
  35. package/dist/studio/assets/lu-BKd2Ee9U.js +7 -0
  36. package/dist/studio/assets/models._name-BgQ9M7k3.js +1 -0
  37. package/dist/studio/assets/not-found-OmQoujxN.js +1 -0
  38. package/dist/studio/assets/prisma-BbI26USq.js +891 -0
  39. package/dist/studio/assets/routes-Bp4Bkwc2.js +1 -0
  40. package/dist/studio/assets/schema-gate-Dq_XVfAD.js +1 -0
  41. package/dist/studio/assets/schema-view-BuWOw5GX.js +8 -0
  42. package/dist/studio/assets/sql--CSU_IR2.js +7 -0
  43. package/dist/studio/assets/table-Dfy6EciQ.js +1 -0
  44. package/dist/studio/assets/tabs-Ce14hvOa.js +1 -0
  45. package/dist/studio/assets/useFormValidation-gdk4CRGT.js +1 -0
  46. package/dist/studio/assets/useMatch-CdyJXF1Q.js +1 -0
  47. package/dist/studio/assets/useMultipleSelectionState-a9-PqoPk.js +1 -0
  48. package/dist/studio/assets/useOverlayTriggerState-DCPjC07T.js +1 -0
  49. package/dist/studio/index.html +9 -5
  50. package/package.json +16 -3
  51. package/dist/studio/assets/cells-lAj-v64A.js +0 -2
  52. package/dist/studio/assets/docs-CpeTt3O2.js +0 -34
  53. package/dist/studio/assets/enums._name-My5PypWw.js +0 -1
  54. package/dist/studio/assets/hooks-CiUANSpJ.js +0 -1
  55. package/dist/studio/assets/index-C4wWEcwe.js +0 -188
  56. package/dist/studio/assets/index-ZSt1ppSG.css +0 -2
  57. package/dist/studio/assets/labels-DBXIkmbm.js +0 -1
  58. package/dist/studio/assets/lazyRouteComponent-DmCXXiGp.js +0 -1
  59. package/dist/studio/assets/models._name-oUX64rwK.js +0 -1
  60. package/dist/studio/assets/not-found-DxAsuyR5.js +0 -1
  61. package/dist/studio/assets/prisma-Bk53qnxm.js +0 -891
  62. package/dist/studio/assets/routes-ZmrohHNP.js +0 -1
  63. package/dist/studio/assets/schema-gate-DJ_-6NYR.js +0 -1
  64. package/dist/studio/assets/schema-view-BaoCWAL8.js +0 -8
  65. package/dist/studio/assets/sql-DpzkSc6F.js +0 -1
  66. package/dist/studio/assets/useMatch-D73HO_WB.js +0 -1
package/README.md CHANGED
@@ -307,7 +307,33 @@ hekireki studio -p 3000
307
307
  | `/models/<name>` | A model's rows, editable, next to its fields |
308
308
  | `/enums/<name>` | An enum with its members and the fields that hold it |
309
309
  | `/prisma` | The schema in a Prisma editor, with the language server's diagnostics |
310
- | `/sql` | A SQL console against the connected database |
310
+ | `/sql` | A SQL console: completion from the schema, a data-flow picture, the query plan |
311
+
312
+ **⌘K** / **Ctrl+K** opens a search over the whole schema — every page, model, enum and field, by
313
+ the letters of its name in order, so `usemail` finds `User.email`. Following a field opens its
314
+ model on that row.
315
+
316
+ On a model's page, **/** puts the cursor in the search box and every column is searched as you
317
+ type, with what matched marked in the rows that come back. Clicking a cell picks it and nothing
318
+ more; the two buttons that appear on it copy just that value or open it for editing, and **⌘C** /
319
+ **Ctrl+C** copies the picked cell. Tick rows to act on them together: **Copy** takes them as
320
+ tab-separated text — what a spreadsheet pastes — and **Delete** asks first, naming the rows it is
321
+ about to remove. **Export** downloads or copies the page as CSV or JSON. A SQL result is sorted and narrowed in the browser,
322
+ without asking the database a second question.
323
+
324
+ The SQL page completes table and column names from the schema — `@@map` / `@map` names, as the
325
+ database knows them — and reads the statement as you type: **Flow** draws where its rows come from
326
+ (every table, join, filter, grouping and the projection), **Columns** traces each result column back
327
+ to the base tables and lists every table touched with its alias and the columns read, and **Type**
328
+ shows the row and parameter types as TypeScript, and **Plan** asks the database for its execution
329
+ plan (`EXPLAIN`) as a tree. The models the statement touches light up on the
330
+ schema beside it, with the columns it reads marked; a `?` or `$1` placeholder gets a field typed
331
+ from the column it is compared with, and a name the schema does not know is underlined.
332
+
333
+ **Columns** in the toolbar says which columns the grid draws, remembered per model; what is on
334
+ screen is what **Copy** and **Export** take, so a copy of two columns out of forty is two ticks
335
+ away. A row is still written whole, so the Add row form brings every column back for as long as it
336
+ is open.
311
337
 
312
338
  `--schema` takes either a `schema.prisma` file or a directory — every `.prisma` file directly in the
313
339
  directory (subdirectories are not descended into) is read as one schema, which is how Prisma's
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.js";
3
3
  //#region src/bin/activerecord.ts
4
4
  registerGenerator("activerecord");
5
5
  //#endregion
package/dist/bin/ajv.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.js";
3
3
  //#region src/bin/ajv.ts
4
4
  registerGenerator("ajv");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.js";
3
3
  //#region src/bin/arktype.ts
4
4
  registerGenerator("arktype");
5
5
  //#endregion
package/dist/bin/atlas.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.js";
3
3
  //#region src/bin/atlas.ts
4
4
  registerGenerator("atlas");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.js";
3
3
  //#region src/bin/django.ts
4
4
  registerGenerator("django");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.js";
3
3
  //#region src/bin/drizzle.ts
4
4
  registerGenerator("drizzle");
5
5
  //#endregion
package/dist/bin/ecto.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.js";
3
3
  //#region src/bin/ecto.ts
4
4
  registerGenerator("ecto");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.js";
3
3
  //#region src/bin/effect.ts
4
4
  registerGenerator("effect");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.js";
3
3
  //#region src/bin/eloquent.ts
4
4
  registerGenerator("eloquent");
5
5
  //#endregion
package/dist/bin/er.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.js";
3
3
  //#region src/bin/er.ts
4
4
  registerGenerator("er");
5
5
  //#endregion
package/dist/bin/gorm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.js";
3
3
  //#region src/bin/gorm.ts
4
4
  registerGenerator("gorm");
5
5
  //#endregion
@@ -5,7 +5,7 @@ import { Config, 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.20.1";
8
+ var version = "0.20.2";
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. */
@@ -103,7 +103,7 @@ const studioFlags = {
103
103
  function runStudio(args) {
104
104
  return Effect.gen(function* () {
105
105
  const schemaPath = yield* resolveSchemaPath(Option.getOrNull(args.schema), [COMMAND_NAME, "studio"]);
106
- const { startStudioServer } = yield* Effect.promise(() => import("../start-Blp4k61D.js"));
106
+ const { startStudioServer } = yield* Effect.promise(() => import("../start-EKGd2Tvk.js"));
107
107
  const started = yield* startStudioServer({
108
108
  schemaPath,
109
109
  port: args.port,
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.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-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.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-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.js";
3
3
  //#region src/bin/sea-orm.ts
4
4
  registerGenerator("sea-orm");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.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-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.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-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.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-CPb5ZV8W.js";
2
+ import { t as registerGenerator } from "../bin-CjbhMZs0.js";
3
3
  //#region src/bin/zod.ts
4
4
  registerGenerator("zod");
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { c as writeFile, i as makeDirectory, n as fileSystemLayer } from "./file-yN0By3gn.js";
2
- import { _ as parseDocumentWithoutAnnotations, a as inferredERRelations, c as getString, d as isFields, g as makeValidationExtractor, h as makeSnakeCase, i as erRelations, l as getStrings, m as makePascalCase, n as annotatedERRelations, o as extractObjectType, p as makeCommentBlock, r as erKey, s as getBool, t as makeSchema, u as groupByModel, v as schemaFromFields, y as stripAnnotations } from "./schema-DwMNeEei.js";
2
+ import { _ as makeValidationExtractor, a as erRelations, b as stripAnnotations, c as getBool, d as groupByModel, f as isFields, g as makeSnakeCase, h as makePascalCase, i as erKey, l as getString, m as makeCommentBlock, n as makeSchema, o as inferredERRelations, r as annotatedERRelations, s as extractObjectType, u as getStrings, v as parseDocumentWithoutAnnotations, y as schemaFromFields } from "./schema-Ci19PgR9.js";
3
3
  import { Data, Effect } from "effect";
4
4
  import path from "node:path";
5
5
  import pkg from "@prisma/generator-helper";
@@ -819,5 +819,140 @@ function makeSchema(input) {
819
819
  relations: makeRelations({ models })
820
820
  };
821
821
  }
822
+ const AnalysisDialect = z.enum([
823
+ "postgresql",
824
+ "mysql",
825
+ "sqlite"
826
+ ]).meta({
827
+ description: "The SQL dialect the analysis reads types for",
828
+ example: "postgresql"
829
+ });
830
+ z.object({
831
+ dialect: AnalysisDialect.nullable().meta({
832
+ description: "The dialect of the connected database, or null while none is connected.",
833
+ example: "sqlite"
834
+ }),
835
+ provider: z.string().nullable().meta({
836
+ description: "The datasource provider of the schema, the fallback for the dialect.",
837
+ example: "postgresql"
838
+ }),
839
+ models: z.array(z.object({
840
+ name: z.string().meta({
841
+ description: "The model name as declared.",
842
+ example: "User"
843
+ }),
844
+ dbName: z.string().nullable().meta({
845
+ description: "The @@map table name, when set.",
846
+ example: "users"
847
+ }),
848
+ fields: z.array(z.object({
849
+ name: z.string().meta({
850
+ description: "The Prisma field name.",
851
+ example: "createdAt"
852
+ }),
853
+ dbName: z.string().nullable().meta({
854
+ description: "The @map column name, when set.",
855
+ example: "created_at"
856
+ }),
857
+ kind: z.string().meta({
858
+ description: "scalar, object, enum or unsupported.",
859
+ example: "scalar"
860
+ }),
861
+ type: z.string().meta({
862
+ description: "The declared type.",
863
+ example: "DateTime"
864
+ }),
865
+ isList: z.boolean().meta({
866
+ description: "Whether the field is a list.",
867
+ example: false
868
+ }),
869
+ isRequired: z.boolean().meta({
870
+ description: "Whether the field is required.",
871
+ example: true
872
+ }),
873
+ nativeType: z.string().nullable().meta({
874
+ description: "The `@db.*` attribute as written, when declared.",
875
+ example: "@db.VarChar(255)"
876
+ })
877
+ }).readonly()).readonly().meta({ description: "The fields of the model, relations included." })
878
+ }).readonly()).readonly().meta({ description: "The models of the schema." })
879
+ }).readonly().meta({
880
+ description: "The Prisma models the SQL analysis reads its tables from",
881
+ example: {
882
+ dialect: "sqlite",
883
+ provider: "sqlite",
884
+ models: []
885
+ }
886
+ });
887
+ /** The column type Prisma migrates a scalar to when no `@db.*` attribute says otherwise. */
888
+ const PRISMA_COLUMN_TYPES = {
889
+ postgresql: {
890
+ Int: "int4",
891
+ BigInt: "int8",
892
+ Float: "float8",
893
+ Decimal: "numeric",
894
+ String: "text",
895
+ Boolean: "bool",
896
+ DateTime: "timestamp",
897
+ Json: "jsonb",
898
+ Bytes: "bytea"
899
+ },
900
+ mysql: {
901
+ Int: "int",
902
+ BigInt: "bigint",
903
+ Float: "double",
904
+ Decimal: "decimal",
905
+ String: "varchar",
906
+ Boolean: "tinyint",
907
+ DateTime: "datetime",
908
+ Json: "json",
909
+ Bytes: "longblob"
910
+ },
911
+ sqlite: {
912
+ Int: "INTEGER",
913
+ BigInt: "BIGINT",
914
+ Float: "REAL",
915
+ Decimal: "DECIMAL",
916
+ String: "TEXT",
917
+ Boolean: "BOOLEAN",
918
+ DateTime: "DATETIME",
919
+ Json: "JSONB",
920
+ Bytes: "BLOB"
921
+ }
922
+ };
923
+ /** An enum column is stored as text everywhere; MySQL has its own `enum` type for it. */
924
+ const ENUM_COLUMN_TYPES = {
925
+ postgresql: "text",
926
+ mysql: "enum",
927
+ sqlite: "TEXT"
928
+ };
929
+ function analysisDialect(input) {
930
+ if (input.dialect !== null) return input.dialect;
931
+ const provider = AnalysisDialect.safeParse(input.provider);
932
+ return provider.success ? provider.data : "sqlite";
933
+ }
934
+ function columnDataType(dialect, field) {
935
+ const base = (field.nativeType === null ? null : field.nativeType.replace(/^@db\./u, "")) ?? (field.kind === "enum" ? ENUM_COLUMN_TYPES[dialect] : PRISMA_COLUMN_TYPES[dialect][field.type] ?? "unknown");
936
+ return field.isList && dialect === "postgresql" ? `${base}[]` : base;
937
+ }
938
+ /**
939
+ * The tables the SQL analysis runs against, read off the Prisma models: `@@map` / `@map` give
940
+ * the names the database knows, relation fields are left out (they are not columns), and a
941
+ * scalar's column type is its `@db.*` attribute or the type Prisma migrates it to.
942
+ */
943
+ function makeAnalysisSchema(input) {
944
+ const dialect = analysisDialect(input);
945
+ return {
946
+ dialect,
947
+ tables: input.models.map((model) => ({
948
+ name: model.dbName ?? model.name,
949
+ columns: model.fields.filter((field) => field.kind !== "object").map((field) => ({
950
+ name: field.dbName ?? field.name,
951
+ dataType: columnDataType(dialect, field),
952
+ nullable: !field.isRequired
953
+ }))
954
+ }))
955
+ };
956
+ }
822
957
  //#endregion
823
- export { parseDocumentWithoutAnnotations as _, inferredERRelations as a, getString as c, isFields as d, isLoopbackHostname as f, makeValidationExtractor as g, makeSnakeCase as h, erRelations as i, getStrings as l, makePascalCase as m, annotatedERRelations as n, extractObjectType as o, makeCommentBlock as p, erKey as r, getBool as s, makeSchema as t, groupByModel as u, schemaFromFields as v, stripAnnotations as y };
958
+ export { makeValidationExtractor as _, erRelations as a, stripAnnotations as b, getBool as c, groupByModel as d, isFields as f, makeSnakeCase as g, makePascalCase as h, erKey as i, getString as l, makeCommentBlock as m, makeSchema as n, inferredERRelations as o, isLoopbackHostname as p, annotatedERRelations as r, extractObjectType as s, makeAnalysisSchema as t, getStrings as u, parseDocumentWithoutAnnotations as v, schemaFromFields as y };