hekireki 0.46.0 → 0.48.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 (39) hide show
  1. package/README.md +19 -6
  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/docs.d.ts +1 -0
  8. package/dist/bin/docs.js +5 -0
  9. package/dist/bin/drizzle.js +1 -1
  10. package/dist/bin/ecto.js +1 -1
  11. package/dist/bin/efcore.js +1 -1
  12. package/dist/bin/effect.js +1 -1
  13. package/dist/bin/eloquent.js +1 -1
  14. package/dist/bin/er.js +1 -1
  15. package/dist/bin/exposed.js +1 -1
  16. package/dist/bin/gorm.js +1 -1
  17. package/dist/bin/hekireki.js +5 -5
  18. package/dist/bin/kysely.js +1 -1
  19. package/dist/bin/openapi.js +1 -1
  20. package/dist/bin/pydantic.js +1 -1
  21. package/dist/bin/sea-orm.js +1 -1
  22. package/dist/bin/seed.js +1 -1
  23. package/dist/bin/sqlalchemy.js +1 -1
  24. package/dist/bin/typebox.js +1 -1
  25. package/dist/bin/valibot.js +1 -1
  26. package/dist/bin/zod.js +1 -1
  27. package/dist/{bin-Cqjn5U_r.js → bin-CVcdvi5w.js} +6311 -5388
  28. package/dist/{discover-Dyzb_7x-.js → discover-kVbu9DxT.js} +2 -1
  29. package/dist/{emit-CbBm_I0C.js → emit-DF8ehOFH.js} +1 -1
  30. package/dist/{schema-BRtObhQG.js → errors-0PjX4y1Z.js} +218 -2
  31. package/dist/{migrate-B-EMC7CC.js → migrate-U9pCkJTm.js} +4 -3
  32. package/dist/native-engine-D1iZDp41.js +537 -0
  33. package/dist/{plan-DVBOCKsd.js → plan-ChzbNv7_.js} +5 -220
  34. package/dist/{run-BKHmqvBJ.js → run-Caiu7ebD.js} +4 -4
  35. package/dist/schema-DzF7tKzG.js +571 -0
  36. package/dist/{sql-BYvD2bjK.js → sql-DciD3-lE.js} +30 -300
  37. package/dist/{start-KD0RjI3H.js → start-C1n6SWZ3.js} +8 -505
  38. package/package.json +2 -1
  39. package/dist/prisma-model-D98BBcmY.js +0 -287
@@ -1,4 +1,5 @@
1
- import { b as SeedDatabaseError, f as makePostgresSchema, m as makeSqliteFilePath } from "./sql-BYvD2bjK.js";
1
+ import { d as makeSqliteFilePath, l as makePostgresSchema } from "./schema-DzF7tKzG.js";
2
+ import { u as SeedDatabaseError } from "./sql-DciD3-lE.js";
2
3
  import { createRequire } from "node:module";
3
4
  import { Effect } from "effect";
4
5
  import path from "node:path";
@@ -1,5 +1,5 @@
1
1
  import { i as makeDirectory, u as writeFile } from "./file-BAVQ-zst.js";
2
- import { z as fmt } from "./prisma-model-D98BBcmY.js";
2
+ import { Z as fmt } from "./schema-DzF7tKzG.js";
3
3
  import { Effect } from "effect";
4
4
  import path from "node:path";
5
5
  // src/emit/index.ts
@@ -1,4 +1,5 @@
1
- import { I as parseRelation, O as isAnnotationLine, t as backRelation } from "./prisma-model-D98BBcmY.js";
1
+ import { B as isAnnotationLine, J as parseRelation, p as backRelation } from "./schema-DzF7tKzG.js";
2
+ import { Data } from "effect";
2
3
  import * as z from "zod";
3
4
  // src/utils/relation.ts
4
5
  function isCardinality(value) {
@@ -831,4 +832,219 @@ function makeAnalysisSchema(input) {
831
832
  }))
832
833
  };
833
834
  }
834
- export { erRelations as a, erKey as i, makeSchema as n, inferredERRelations as o, annotatedERRelations as r, makeAnalysisSchema as t };
835
+ // src/sql/types.ts
836
+ /**
837
+ * The affinity SQLite gives a declared type by what its name holds
838
+ * (https://www.sqlite.org/datatype3.html#affname), in the order the rules are tried: INTEGER
839
+ * for `INT` anywhere in it, TEXT for `CHAR`, `CLOB` or `TEXT`, REAL for `REAL`, `FLOA` or
840
+ * `DOUB`; null for a name those rules say nothing about, which every reader decides for itself.
841
+ *
842
+ * @param upper - the declared type in upper case, as `sqlite_master` and `PRAGMA table_info` spell it
843
+ */
844
+ function sqliteAffinity(upper) {
845
+ if (upper.includes("INT")) return "integer";
846
+ if (upper.includes("CHAR") || upper.includes("CLOB") || upper.includes("TEXT")) return "text";
847
+ if (upper.includes("REAL") || upper.includes("FLOA") || upper.includes("DOUB")) return "real";
848
+ return null;
849
+ }
850
+ /** SQLite's type affinity rules, plus the conventional date/time and JSON spellings that store text. */
851
+ function sqliteTsType(dataType) {
852
+ const upper = dataType.toUpperCase();
853
+ if (upper === "") return "unknown";
854
+ const affinity = sqliteAffinity(upper);
855
+ if (affinity === "integer") return "number";
856
+ if (affinity === "text") return "string";
857
+ if (upper.includes("BLOB")) return "Uint8Array";
858
+ if (affinity === "real") return "number";
859
+ if (upper.includes("BOOL")) return "number";
860
+ if (upper.includes("DATE") || upper.includes("TIME") || upper.includes("JSON")) return "string";
861
+ if (upper.includes("DEC") || upper.includes("NUM")) return "number";
862
+ return "number";
863
+ }
864
+ const POSTGRES_TYPES = {
865
+ int2: "number",
866
+ smallint: "number",
867
+ int4: "number",
868
+ int: "number",
869
+ integer: "number",
870
+ serial: "number",
871
+ serial4: "number",
872
+ smallserial: "number",
873
+ float4: "number",
874
+ real: "number",
875
+ float8: "number",
876
+ "double precision": "number",
877
+ oid: "number",
878
+ int8: "string",
879
+ bigint: "string",
880
+ bigserial: "string",
881
+ serial8: "string",
882
+ numeric: "string",
883
+ decimal: "string",
884
+ money: "string",
885
+ text: "string",
886
+ varchar: "string",
887
+ "character varying": "string",
888
+ bpchar: "string",
889
+ char: "string",
890
+ character: "string",
891
+ name: "string",
892
+ citext: "string",
893
+ uuid: "string",
894
+ time: "string",
895
+ timetz: "string",
896
+ "time without time zone": "string",
897
+ "time with time zone": "string",
898
+ interval: "string",
899
+ inet: "string",
900
+ cidr: "string",
901
+ macaddr: "string",
902
+ xml: "string",
903
+ tsvector: "string",
904
+ tsquery: "string",
905
+ bit: "string",
906
+ varbit: "string",
907
+ bool: "boolean",
908
+ boolean: "boolean",
909
+ date: "Date",
910
+ timestamp: "Date",
911
+ timestamptz: "Date",
912
+ "timestamp without time zone": "Date",
913
+ "timestamp with time zone": "Date",
914
+ bytea: "Uint8Array",
915
+ json: "unknown",
916
+ jsonb: "unknown"
917
+ };
918
+ function postgresTsType(dataType) {
919
+ const lower = dataType.toLowerCase().trim();
920
+ if (lower.endsWith("[]")) return `${postgresTsType(lower.slice(0, -2))}[]`;
921
+ if (lower.startsWith("_")) return `${postgresTsType(lower.slice(1))}[]`;
922
+ const base = lower.replace(/\(.*\)$/u, "").trim();
923
+ return POSTGRES_TYPES[base] ?? "unknown";
924
+ }
925
+ const MYSQL_TYPES = {
926
+ tinyint: "number",
927
+ smallint: "number",
928
+ mediumint: "number",
929
+ int: "number",
930
+ integer: "number",
931
+ bigint: "number",
932
+ year: "number",
933
+ float: "number",
934
+ double: "number",
935
+ real: "number",
936
+ decimal: "string",
937
+ numeric: "string",
938
+ varchar: "string",
939
+ char: "string",
940
+ text: "string",
941
+ tinytext: "string",
942
+ mediumtext: "string",
943
+ longtext: "string",
944
+ enum: "string",
945
+ set: "string",
946
+ time: "string",
947
+ date: "Date",
948
+ datetime: "Date",
949
+ timestamp: "Date",
950
+ bit: "Uint8Array",
951
+ binary: "Uint8Array",
952
+ varbinary: "Uint8Array",
953
+ blob: "Uint8Array",
954
+ tinyblob: "Uint8Array",
955
+ mediumblob: "Uint8Array",
956
+ longblob: "Uint8Array",
957
+ geometry: "Uint8Array",
958
+ json: "unknown",
959
+ boolean: "number",
960
+ bool: "number"
961
+ };
962
+ function mysqlTsType(dataType) {
963
+ const base = dataType.toLowerCase().replace(/\(.*\)$/u, "").replace(/\s+unsigned$/u, "").trim();
964
+ return MYSQL_TYPES[base] ?? "unknown";
965
+ }
966
+ /** The TypeScript type a driver hands back for a column of the declared type. */
967
+ function toTsType(dialect, dataType) {
968
+ switch (dialect) {
969
+ case "sqlite": return sqliteTsType(dataType);
970
+ case "postgresql": return postgresTsType(dataType);
971
+ case "mysql": return mysqlTsType(dataType);
972
+ default: return "unknown";
973
+ }
974
+ }
975
+ /** The declared type a literal of the expression kind would have in the dialect, for the type column of the picture. */
976
+ function literalDataType(dialect, kind) {
977
+ if (kind === "string") return dialect === "sqlite" ? "TEXT" : dialect === "mysql" ? "varchar" : "text";
978
+ if (kind === "number") return dialect === "sqlite" ? "INTEGER" : dialect === "mysql" ? "int" : "int4";
979
+ return dialect === "postgresql" ? "bool" : dialect === "mysql" ? "tinyint" : "INTEGER";
980
+ }
981
+ // src/sql/split.ts
982
+ /**
983
+ * Splits SQL text into statements at the `;` that sit outside quotes and comments. A driver runs
984
+ * one statement per call, and the result a console shows belongs to the last one.
985
+ */
986
+ function splitStatements(text) {
987
+ const ends = [];
988
+ let mode = "code";
989
+ let quote = "";
990
+ for (let index = 0; index < text.length; index += 1) {
991
+ const char = text[index] ?? "";
992
+ const next = text[index + 1] ?? "";
993
+ if (mode === "line-comment") {
994
+ if (char === "\n") mode = "code";
995
+ } else if (mode === "block-comment") {
996
+ if (char === "*" && next === "/") {
997
+ mode = "code";
998
+ index += 1;
999
+ }
1000
+ } else if (mode === "quoted") {
1001
+ if (char === quote) {
1002
+ if (next === quote) index += 1;
1003
+ else {
1004
+ mode = "code";
1005
+ quote = "";
1006
+ }
1007
+ }
1008
+ } else if (char === "-" && next === "-") mode = "line-comment";
1009
+ else if (char === "/" && next === "*") mode = "block-comment";
1010
+ else if (char === "'" || char === "\"" || char === "`") {
1011
+ mode = "quoted";
1012
+ quote = char;
1013
+ } else if (char === ";") ends.push(index);
1014
+ }
1015
+ const bounds = [...ends, text.length];
1016
+ return bounds.map((end, index) => text.slice(index === 0 ? 0 : (bounds[index - 1] ?? 0) + 1, end).trim()).filter((statement) => statement !== "");
1017
+ }
1018
+ /**
1019
+ * Splits at the commas outside parentheses and quotes: the clauses of an ALTER TABLE, the items
1020
+ * of a list.
1021
+ */
1022
+ function splitTopLevel(text) {
1023
+ const parts = [];
1024
+ let current = "";
1025
+ let depth = 0;
1026
+ let quote = "";
1027
+ for (const char of text) {
1028
+ current += char;
1029
+ if (quote !== "") {
1030
+ if (char === quote) quote = "";
1031
+ } else if (char === "'" || char === "\"" || char === "`") quote = char;
1032
+ else if (char === "(") depth += 1;
1033
+ else if (char === ")") depth -= 1;
1034
+ else if (char === "," && depth === 0) {
1035
+ parts.push(current.slice(0, -1).trim());
1036
+ current = "";
1037
+ }
1038
+ }
1039
+ return [...parts, current.trim()].filter((part) => part !== "");
1040
+ }
1041
+ // src/migrate/errors.ts
1042
+ /** The schema cannot be read, or the command line names something the check cannot use. */
1043
+ var MigrateConfigError = class extends Data.TaggedError("MigrateConfigError") {};
1044
+ /** The database could not be opened, or refused one of the check's queries. */
1045
+ var MigrateDatabaseError = class extends Data.TaggedError("MigrateDatabaseError") {};
1046
+ /** The migrations directory holds no migration of the name asked for. */
1047
+ var MigrationNotFoundError = class extends Data.TaggedError("MigrationNotFoundError") {};
1048
+ /** The Prisma schema engine could not be started, or refused a command. */
1049
+ var MigrateEngineError = class extends Data.TaggedError("MigrateEngineError") {};
1050
+ export { splitStatements as a, sqliteAffinity as c, makeSchema as d, annotatedERRelations as f, inferredERRelations as h, MigrationNotFoundError as i, toTsType as l, erRelations as m, MigrateDatabaseError as n, splitTopLevel as o, erKey as p, MigrateEngineError as r, literalDataType as s, MigrateConfigError as t, makeAnalysisSchema as u };
@@ -1,7 +1,8 @@
1
1
  import { s as readFile } from "./file-BAVQ-zst.js";
2
- import { r as emitRaw } from "./emit-CbBm_I0C.js";
3
- import { L as splitStatements, V as MigrateConfigError, i as lostInRebuild, l as runMigrateCheck, n as isDestructiveStep, o as BLOCK_QUOTE, r as isLossyFix, s as rewriteMigration, t as batchedStatements } from "./plan-DVBOCKsd.js";
4
- import "./sql-BYvD2bjK.js";
2
+ import "./schema-DzF7tKzG.js";
3
+ import { r as emitRaw } from "./emit-DF8ehOFH.js";
4
+ import { a as splitStatements, t as MigrateConfigError } from "./errors-0PjX4y1Z.js";
5
+ import { i as lostInRebuild, l as runMigrateCheck, n as isDestructiveStep, o as BLOCK_QUOTE, r as isLossyFix, s as rewriteMigration, t as batchedStatements } from "./plan-ChzbNv7_.js";
5
6
  import { Effect } from "effect";
6
7
  import path from "node:path";
7
8
  // src/migrate/adapter/plan-file.ts