hekireki 0.52.3 → 0.52.4
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/docs.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 +3 -3
- package/dist/bin/kysely.js +1 -1
- package/dist/bin/openapi.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-openapi-hono.js +1 -1
- package/dist/bin/zod.js +1 -1
- package/dist/{bin-Brorqc9T.js → bin-Py9KRh1_.js} +74 -30
- package/dist/{case-D3JCqTLI.js → case-CCSiaowC.js} +3 -2
- package/dist/{run-DbZYkHVI.js → run-DMNh0Fmc.js} +1 -1
- package/dist/{start-Ba8wQAD1.js → start-zBekMHfh.js} +1 -1
- package/package.json +1 -1
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/docs.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
|
@@ -6,7 +6,7 @@ import { Console, Data, Effect, Schema } from "effect";
|
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { CliError, Command, Flag } from "effect/cli";
|
|
8
8
|
// package.json
|
|
9
|
-
var version = "0.52.
|
|
9
|
+
var version = "0.52.4";
|
|
10
10
|
// src/schema/path.ts
|
|
11
11
|
/** Where Prisma looks for a schema when neither the command nor prisma.config.ts names one. */
|
|
12
12
|
const DEFAULT_SCHEMA_PATHS = ["prisma/schema.prisma", "schema.prisma"];
|
|
@@ -149,7 +149,7 @@ const studioFlags = {
|
|
|
149
149
|
function runStudio(args) {
|
|
150
150
|
return Effect.gen(function* () {
|
|
151
151
|
const schemaPath = yield* resolveSchemaPath(args.schema, [COMMAND_NAME, "studio"]);
|
|
152
|
-
const { startStudioServer } = yield* Effect.promise(() => import("../start-
|
|
152
|
+
const { startStudioServer } = yield* Effect.promise(() => import("../start-zBekMHfh.js"));
|
|
153
153
|
const started = yield* startStudioServer({
|
|
154
154
|
schemaPath,
|
|
155
155
|
port: args.port,
|
|
@@ -201,7 +201,7 @@ const seedFlags = {
|
|
|
201
201
|
};
|
|
202
202
|
function runSeedCommand(args) {
|
|
203
203
|
return Effect.gen(function* () {
|
|
204
|
-
const { runSeed, seedBanner } = yield* Effect.promise(() => import("../run-
|
|
204
|
+
const { runSeed, seedBanner } = yield* Effect.promise(() => import("../run-DMNh0Fmc.js"));
|
|
205
205
|
const report = yield* runSeed(args, process.cwd()).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
|
|
206
206
|
yield* Console.log(seedBanner(report));
|
|
207
207
|
});
|
package/dist/bin/kysely.js
CHANGED
package/dist/bin/openapi.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
|
@@ -2,7 +2,7 @@ import { c as removePath, o as readDirectory, s as readFile, t as exists, u as w
|
|
|
2
2
|
import { A as primaryKeyFields$1, C as isJoinSideA, D as lengthArg, E as isUlidDefault, F as uuidDefaultVersion, L as isSameList, M as relationEnds, N as scalarFields, O as manyToManyRelations, P as tableName, R as fmt, S as isImplicitManyToMany, T as isNowDefault$1, _ as cuidDefaultVersion, a as schemaText, b as isAutoincrement, g as columnName, h as backRelation, i as readSchemaFiles, j as referentialActions, k as nanoidDefault, m as formatSql, t as dialectOf, v as fieldColumn, w as isListDefault, x as isFunctionDefault, y as implicitJoinTables, z as fmtMarkdown } from "./schema-CyJTUCF1.js";
|
|
3
3
|
import { n as emitMany, r as emitRaw, t as emit } from "./emit-DsCT5gLu.js";
|
|
4
4
|
import { _ as stripAnnotations, a as makeOfflineSchemaEngineAdapter, c as makeSchema, d as erRelations, f as inferredERRelations, g as makeValidationExtractor, h as isAnnotationLine, i as openSchemaEngine, l as annotatedERRelations, m as extractObjectType, n as openNativeSchemaEngine, p as docBlockLines, r as engineCommand, t as findSchemaEngineBinary, u as erKey } from "./native-engine-DeQEnJxi.js";
|
|
5
|
-
import { a as makeSnakeCase, i as makePascalCase, n as indexPrefix, r as lowerFirst, t as constraintName } from "./case-
|
|
5
|
+
import { a as makeSnakeCase, i as makePascalCase, n as indexPrefix, r as lowerFirst, t as constraintName } from "./case-CCSiaowC.js";
|
|
6
6
|
import { a as splitStatements, t as MigrateConfigError } from "./errors-CRIxtr-P.js";
|
|
7
7
|
import { createRequire } from "node:module";
|
|
8
8
|
import { Data, Effect } from "effect";
|
|
@@ -13611,8 +13611,13 @@ function resolveNativeType$1(field) {
|
|
|
13611
13611
|
}
|
|
13612
13612
|
return GORM_NATIVE_FIXED[nativeName] ?? null;
|
|
13613
13613
|
}
|
|
13614
|
-
/**
|
|
13615
|
-
|
|
13614
|
+
/**
|
|
13615
|
+
* A relation through the foreign key `fkField` holds, which is on either end of it. A referential
|
|
13616
|
+
* action the schema leaves out is Prisma's: `Restrict` on delete for a required relation (`NoAction`
|
|
13617
|
+
* on SQL Server, which has no RESTRICT) and `SetNull` for an optional one, `Cascade` on update.
|
|
13618
|
+
*/
|
|
13619
|
+
function foreignKeyAssociation(name, targetModel, fkField, provider) {
|
|
13620
|
+
const requiredOnDelete = provider === "sqlserver" ? "NoAction" : "Restrict";
|
|
13616
13621
|
const foreignKeys = fkField.relationFromFields ?? [];
|
|
13617
13622
|
return {
|
|
13618
13623
|
name,
|
|
@@ -13621,11 +13626,12 @@ function foreignKeyAssociation(name, targetModel, fkField) {
|
|
|
13621
13626
|
references: fkField.relationToFields?.[0] ?? "id",
|
|
13622
13627
|
foreignKeys,
|
|
13623
13628
|
referencesList: fkField.relationToFields ?? ["id"],
|
|
13624
|
-
|
|
13625
|
-
|
|
13629
|
+
fkFieldName: fkField.name,
|
|
13630
|
+
onDelete: fkField.relationOnDelete ?? (fkField.isRequired ? requiredOnDelete : "SetNull"),
|
|
13631
|
+
onUpdate: fkField.relationOnUpdate ?? "Cascade"
|
|
13626
13632
|
};
|
|
13627
13633
|
}
|
|
13628
|
-
function getAssociations$2(model, allModels) {
|
|
13634
|
+
function getAssociations$2(model, allModels, provider) {
|
|
13629
13635
|
const belongsTo = [];
|
|
13630
13636
|
const hasMany = [];
|
|
13631
13637
|
const hasOne = [];
|
|
@@ -13633,7 +13639,7 @@ function getAssociations$2(model, allModels) {
|
|
|
13633
13639
|
for (const end of relationEnds(model, allModels)) {
|
|
13634
13640
|
const { field } = end;
|
|
13635
13641
|
if (end.kind === "belongsTo") {
|
|
13636
|
-
belongsTo.push(foreignKeyAssociation(field.name, field.type, field));
|
|
13642
|
+
belongsTo.push(foreignKeyAssociation(field.name, field.type, field, provider));
|
|
13637
13643
|
continue;
|
|
13638
13644
|
}
|
|
13639
13645
|
if (end.kind === "manyToMany") {
|
|
@@ -13646,7 +13652,7 @@ function getAssociations$2(model, allModels) {
|
|
|
13646
13652
|
continue;
|
|
13647
13653
|
}
|
|
13648
13654
|
const association = {
|
|
13649
|
-
...foreignKeyAssociation(field.name, field.type, end.inverse),
|
|
13655
|
+
...foreignKeyAssociation(field.name, field.type, end.inverse, provider),
|
|
13650
13656
|
isList: end.kind === "hasMany"
|
|
13651
13657
|
};
|
|
13652
13658
|
if (end.kind === "hasMany") hasMany.push(association);
|
|
@@ -13704,14 +13710,18 @@ function dateTimeDefault$1(field, provider) {
|
|
|
13704
13710
|
if (goType === "TimeOfDay") return `'${iso.slice(11, 23)}'`;
|
|
13705
13711
|
return provider === "sqlite" ? `'${iso.replace("Z", "+00:00")}'` : `'${iso.slice(0, 10)} ${iso.slice(11, 23)}'`;
|
|
13706
13712
|
}
|
|
13713
|
+
function isPostgresFamily(provider) {
|
|
13714
|
+
return provider === "postgresql" || provider === "cockroachdb";
|
|
13715
|
+
}
|
|
13707
13716
|
function gormDefault(field, isPk, isCompositePk, enums, provider) {
|
|
13708
13717
|
const isNowDefault = field.type === "DateTime" && isFunctionDefault(field.default) && field.default.name === "now";
|
|
13709
|
-
|
|
13718
|
+
const nowDefault = isNowDefault && isPostgresFamily(provider) ? "CURRENT_TIMESTAMP" : null;
|
|
13719
|
+
return dbGeneratedDefault(field) ?? dateTimeDefault$1(field, provider) ?? nowDefault ?? ((!isPk || isCompositePk) && !isNowDefault && field.isUpdatedAt !== true ? enumMappedDefault$1(field, enums) ?? formatGoDefault(field.default, field.type, field.kind) : null);
|
|
13710
13720
|
}
|
|
13711
13721
|
function primaryKeyTags(field, isPk, provider) {
|
|
13712
13722
|
if (!isPk) return [];
|
|
13713
13723
|
const defaultName = isFunctionDefault(field.default) ? field.default.name : void 0;
|
|
13714
|
-
const fixedType = provider !== "mysql" && resolveNativeType$1(field) === null;
|
|
13724
|
+
const fixedType = provider !== "mysql" && !isPostgresFamily(provider) && resolveNativeType$1(field) === null;
|
|
13715
13725
|
return [
|
|
13716
13726
|
"primaryKey",
|
|
13717
13727
|
...isAutoincrement(field) ? ["autoIncrement"] : [],
|
|
@@ -13723,11 +13733,21 @@ function isMysqlDefaultString(field, provider) {
|
|
|
13723
13733
|
if (provider !== "mysql" || field.type !== "String" || field.kind !== "scalar") return false;
|
|
13724
13734
|
return !field.isList && !field.nativeType;
|
|
13725
13735
|
}
|
|
13736
|
+
const POSTGRES_DEFAULT_TYPES = {
|
|
13737
|
+
Float: "double precision",
|
|
13738
|
+
Decimal: "decimal(65,30)",
|
|
13739
|
+
DateTime: "timestamp(3)"
|
|
13740
|
+
};
|
|
13726
13741
|
function columnTypeTag(field, provider) {
|
|
13727
13742
|
const nativeType = resolveNativeType$1(field);
|
|
13728
13743
|
if (isDateTimeList(field)) return `type:${nativeType ?? "timestamp(3)"}[]`;
|
|
13729
13744
|
if (isMysqlDefaultString(field, provider)) return "type:varchar(191)";
|
|
13730
|
-
|
|
13745
|
+
if (nativeType !== null) return `type:${nativeType}`;
|
|
13746
|
+
const postgresType = isPostgresFamily(provider) && field.kind === "scalar" && !field.isList ? POSTGRES_DEFAULT_TYPES[field.type] : void 0;
|
|
13747
|
+
return postgresType === void 0 ? null : `type:${postgresType}`;
|
|
13748
|
+
}
|
|
13749
|
+
function sizeTag(field, provider) {
|
|
13750
|
+
return provider !== "cockroachdb" && field.kind === "scalar" && field.type === "Int" && !field.isList && !field.nativeType ? "size:32" : null;
|
|
13731
13751
|
}
|
|
13732
13752
|
function trackedTimeTags(field, fieldName) {
|
|
13733
13753
|
if (!(isDateTimeScalar(field) || ["Int", "BigInt"].includes(field.type))) return [];
|
|
@@ -13739,28 +13759,41 @@ function buildGormTags(field, isPk, isCompositePk, compositeIndexTags, enums, pr
|
|
|
13739
13759
|
return `\`gorm:"${[
|
|
13740
13760
|
`column:${columnName}`,
|
|
13741
13761
|
...primaryKeyTags(field, isPk, provider),
|
|
13742
|
-
field.isUnique ? "uniqueIndex" : null,
|
|
13762
|
+
field.isUnique && !compositeIndexTags.some((tag) => tag.startsWith("uniqueIndex:")) ? "uniqueIndex" : null,
|
|
13743
13763
|
...compositeIndexTags,
|
|
13744
13764
|
columnTypeTag(field, provider),
|
|
13765
|
+
sizeTag(field, provider),
|
|
13745
13766
|
field.isList && field.kind !== "object" && !isDateTimeList(field) ? "serializer:json" : null,
|
|
13746
13767
|
defaultVal !== null ? `default:${defaultVal}` : null,
|
|
13747
13768
|
...trackedTimeTags(field, fieldName),
|
|
13748
13769
|
field.isRequired && !isPk ? "not null" : null
|
|
13749
13770
|
].filter((p) => p !== null).join(";")}" json:"${columnName}"\``;
|
|
13750
13771
|
}
|
|
13751
|
-
function
|
|
13772
|
+
function readableTagName(name) {
|
|
13773
|
+
return name !== void 0 && !/[,;"`]/u.test(name) ? name : void 0;
|
|
13774
|
+
}
|
|
13775
|
+
function collectCompositeIndexTags(model, indexes, provider) {
|
|
13752
13776
|
const tableName = model.dbName ?? model.name;
|
|
13753
13777
|
const fieldByName = new Map(model.fields.map((mf) => [mf.name, mf]));
|
|
13778
|
+
const columnsOf = (fields) => fields.map((f) => fieldByName.get(f)?.dbName ?? f);
|
|
13779
|
+
const mappedUniques = new Map(indexes.filter((idx) => idx.model === model.name && idx.type === "unique").map((idx) => [idx.fields.map((f) => f.name).join(","), readableTagName(idx.dbName)]));
|
|
13780
|
+
const singleUniqueTags = model.fields.filter((f) => f.isUnique).map((f) => {
|
|
13781
|
+
const named = mappedUniques.get(f.name);
|
|
13782
|
+
return [f.name, `uniqueIndex:${named ?? constraintName(tableName, [f.dbName ?? f.name], "key", provider ?? "")}`];
|
|
13783
|
+
});
|
|
13754
13784
|
const uniqueTags = model.uniqueFields.filter((fields) => fields.length > 1).flatMap((fields) => {
|
|
13755
|
-
const
|
|
13756
|
-
const idxName = `${tableName}_${cols.join("_")}_key`;
|
|
13785
|
+
const idxName = mappedUniques.get(fields.join(",")) ?? constraintName(tableName, columnsOf(fields), "key", provider ?? "");
|
|
13757
13786
|
return fields.map((f) => [f, `uniqueIndex:${idxName}`]);
|
|
13758
13787
|
});
|
|
13759
13788
|
const indexTags = indexes.filter((idx) => idx.model === model.name && (idx.type === "normal" || idx.type === "fulltext")).flatMap((idx) => {
|
|
13760
|
-
const idxName = idx.dbName ?? idx.name ??
|
|
13789
|
+
const idxName = readableTagName(idx.dbName) ?? readableTagName(idx.name) ?? constraintName(tableName, columnsOf(idx.fields.map((f) => f.name)), "idx", provider ?? "");
|
|
13761
13790
|
return idx.fields.map((f) => [f.name, `index:${idxName}`]);
|
|
13762
13791
|
});
|
|
13763
|
-
return [
|
|
13792
|
+
return [
|
|
13793
|
+
...singleUniqueTags,
|
|
13794
|
+
...uniqueTags,
|
|
13795
|
+
...indexTags
|
|
13796
|
+
].reduce((map, [fieldName, tag]) => {
|
|
13764
13797
|
const existing = map.get(fieldName) ?? [];
|
|
13765
13798
|
map.set(fieldName, [...existing, tag]);
|
|
13766
13799
|
return map;
|
|
@@ -13960,9 +13993,20 @@ const SQL_ACTION$1 = {
|
|
|
13960
13993
|
NoAction: "NO ACTION",
|
|
13961
13994
|
SetDefault: "SET DEFAULT"
|
|
13962
13995
|
};
|
|
13963
|
-
function constraintTag(onDelete, onUpdate) {
|
|
13964
|
-
const
|
|
13965
|
-
|
|
13996
|
+
function constraintTag(name, onDelete, onUpdate) {
|
|
13997
|
+
const actions = [SQL_ACTION$1[onUpdate] === void 0 ? null : `OnUpdate:${SQL_ACTION$1[onUpdate]}`, SQL_ACTION$1[onDelete] === void 0 ? null : `OnDelete:${SQL_ACTION$1[onDelete]}`].filter((c) => c !== null);
|
|
13998
|
+
if (actions.length === 0) return null;
|
|
13999
|
+
return `constraint:${[.../^[\w-]+$/u.test(name) ? [name] : [], ...actions].join(",")}`;
|
|
14000
|
+
}
|
|
14001
|
+
/**
|
|
14002
|
+
* The name Prisma Migrate gives the foreign key `holder` holds in the named fields:
|
|
14003
|
+
* `<table>_<columns>_fkey`.
|
|
14004
|
+
*/
|
|
14005
|
+
function foreignKeyName(allModels, holder, fieldNames, provider) {
|
|
14006
|
+
const model = allModels.find((m) => m.name === holder);
|
|
14007
|
+
const columnOf = new Map(model?.fields.map((f) => [f.name, f.dbName ?? f.name]));
|
|
14008
|
+
const columns = fieldNames.map((name) => columnOf.get(name) ?? name);
|
|
14009
|
+
return constraintName(model?.dbName ?? holder, columns, "fkey", provider ?? "");
|
|
13966
14010
|
}
|
|
13967
14011
|
function buildRelationTag(parts) {
|
|
13968
14012
|
return `\`gorm:"${parts.join(";")}"\``;
|
|
@@ -13976,7 +14020,7 @@ function buildRelationTag(parts) {
|
|
|
13976
14020
|
function goCommentLines(text) {
|
|
13977
14021
|
return text === void 0 ? [] : text.split("\n").map((line) => `//${line.trimEnd() === "" ? "" : ` ${line.trimEnd()}`}`);
|
|
13978
14022
|
}
|
|
13979
|
-
function generateRelationFields(model, allModels, associations) {
|
|
14023
|
+
function generateRelationFields(model, allModels, associations, provider, foreignKeyNames) {
|
|
13980
14024
|
const of = (modelName) => (name) => goFieldNameIn(allModels, modelName, name);
|
|
13981
14025
|
const own = of(model.name);
|
|
13982
14026
|
const withDoc = (name, row) => [...goCommentLines(stripAnnotations(model.fields.find((f) => f.name === name)?.documentation)).map((line) => [line]), row];
|
|
@@ -14000,7 +14044,7 @@ function generateRelationFields(model, allModels, associations) {
|
|
|
14000
14044
|
const tagParts = [
|
|
14001
14045
|
`foreignKey:${assoc.foreignKeys.map(of(assoc.targetModel)).join(",")}`,
|
|
14002
14046
|
...assoc.foreignKeys.length > 1 || needsReferencesTag(assoc.references) ? [`references:${assoc.referencesList.map(own).join(",")}`] : [],
|
|
14003
|
-
...[constraintTag(assoc.onDelete, assoc.onUpdate)].filter((c) => c !== null)
|
|
14047
|
+
...[constraintTag(foreignKeyNames.get(`${assoc.targetModel}.${assoc.fkFieldName}`) ?? foreignKeyName(allModels, assoc.targetModel, assoc.foreignKeys, provider), assoc.onDelete, assoc.onUpdate)].filter((c) => c !== null)
|
|
14004
14048
|
];
|
|
14005
14049
|
return withDoc(assoc.name, [
|
|
14006
14050
|
own(assoc.name),
|
|
@@ -14012,7 +14056,7 @@ function generateRelationFields(model, allModels, associations) {
|
|
|
14012
14056
|
const tagParts = [
|
|
14013
14057
|
`foreignKey:${assoc.foreignKeys.map(of(assoc.targetModel)).join(",")}`,
|
|
14014
14058
|
...assoc.foreignKeys.length > 1 || needsReferencesTag(assoc.references) ? [`references:${assoc.referencesList.map(own).join(",")}`] : [],
|
|
14015
|
-
...[constraintTag(assoc.onDelete, assoc.onUpdate)].filter((c) => c !== null)
|
|
14059
|
+
...[constraintTag(foreignKeyNames.get(`${assoc.targetModel}.${assoc.fkFieldName}`) ?? foreignKeyName(allModels, assoc.targetModel, assoc.foreignKeys, provider), assoc.onDelete, assoc.onUpdate)].filter((c) => c !== null)
|
|
14016
14060
|
];
|
|
14017
14061
|
return withDoc(assoc.name, [
|
|
14018
14062
|
own(assoc.name),
|
|
@@ -14068,12 +14112,12 @@ function alignFields(rows) {
|
|
|
14068
14112
|
});
|
|
14069
14113
|
return rows.map((row, i) => `\t${row.map((cell, column) => column < row.length - 1 ? cell.padEnd(widths[column]?.(i) ?? 0) : cell).join("")}`);
|
|
14070
14114
|
}
|
|
14071
|
-
function generateModelStruct(model, allModels, enums, indexes, provider) {
|
|
14115
|
+
function generateModelStruct(model, allModels, enums, indexes, provider, foreignKeyNames = /* @__PURE__ */ new Map()) {
|
|
14072
14116
|
const idField = model.fields.find((f) => f.isId);
|
|
14073
14117
|
const compositePkFieldNames = new Set(idField ? [] : primaryKeyFields$1(model));
|
|
14074
14118
|
const isCompositePk = !idField && compositePkFieldNames.size > 0;
|
|
14075
|
-
const associations = getAssociations$2(model, allModels);
|
|
14076
|
-
const compositeTagMap = collectCompositeIndexTags(model, indexes);
|
|
14119
|
+
const associations = getAssociations$2(model, allModels, provider);
|
|
14120
|
+
const compositeTagMap = collectCompositeIndexTags(model, indexes, provider);
|
|
14077
14121
|
const tableName = model.dbName ?? model.name;
|
|
14078
14122
|
const scalarFields = model.fields.filter((f) => f.kind !== "object");
|
|
14079
14123
|
const names = goFieldNames(model);
|
|
@@ -14084,7 +14128,7 @@ function generateModelStruct(model, allModels, enums, indexes, provider) {
|
|
|
14084
14128
|
rows.push(generateStructField(field, names.get(field.name) ?? goFieldName(field.name), isPk, isCompositePk, fieldIndexTags, enums, provider));
|
|
14085
14129
|
return rows;
|
|
14086
14130
|
});
|
|
14087
|
-
const relationLines = generateRelationFields(model, allModels, associations);
|
|
14131
|
+
const relationLines = generateRelationFields(model, allModels, associations, provider, foreignKeyNames);
|
|
14088
14132
|
const tableNameMethod = [
|
|
14089
14133
|
"",
|
|
14090
14134
|
`func (${goModelName(model.name)}) TableName() string {`,
|
|
@@ -14404,9 +14448,9 @@ function formatImports(groups) {
|
|
|
14404
14448
|
];
|
|
14405
14449
|
}
|
|
14406
14450
|
// src/generator/gorm.ts
|
|
14407
|
-
function generateGormModels(models, enums, indexes, packageName = "model", provider) {
|
|
14451
|
+
function generateGormModels(models, enums, indexes, packageName = "model", provider, foreignKeyNames = /* @__PURE__ */ new Map()) {
|
|
14408
14452
|
const idx = indexes ?? [];
|
|
14409
|
-
const modelBodies = models.map((model) => generateModelStruct(model, models, enums, idx, provider));
|
|
14453
|
+
const modelBodies = models.map((model) => generateModelStruct(model, models, enums, idx, provider, foreignKeyNames));
|
|
14410
14454
|
return [
|
|
14411
14455
|
`package ${packageName}`,
|
|
14412
14456
|
...formatImports(collectImports(models)),
|
|
@@ -14427,7 +14471,7 @@ function gorm(options) {
|
|
|
14427
14471
|
const packageName = getString(options.generator.config["package"]) ?? "model";
|
|
14428
14472
|
const enums = options.dmmf.datamodel.enums;
|
|
14429
14473
|
const indexes = options.dmmf.datamodel.indexes;
|
|
14430
|
-
const code = generateGormModels(options.dmmf.datamodel.models, enums, indexes, packageName, options.datasources[0]?.activeProvider);
|
|
14474
|
+
const code = generateGormModels(options.dmmf.datamodel.models, enums, indexes, packageName, options.datasources[0]?.activeProvider, relationMaps(prismaBlocks(options.datamodel)));
|
|
14431
14475
|
return yield* emitRaw(code, resolved.dir, resolved.file);
|
|
14432
14476
|
});
|
|
14433
14477
|
}
|
|
@@ -7,7 +7,8 @@ function makePascalCase(name) {
|
|
|
7
7
|
}
|
|
8
8
|
const IDENTIFIER_LIMITS = {
|
|
9
9
|
sqlite: Infinity,
|
|
10
|
-
mysql: 64
|
|
10
|
+
mysql: 64,
|
|
11
|
+
sqlserver: 128
|
|
11
12
|
};
|
|
12
13
|
/** The text with its first character in lower case: a model's Prisma Client delegate, a label. */
|
|
13
14
|
function lowerFirst(text) {
|
|
@@ -16,7 +17,7 @@ function lowerFirst(text) {
|
|
|
16
17
|
/**
|
|
17
18
|
* The name Prisma Migrate gives a key, index or constraint the schema does not name: the table,
|
|
18
19
|
* the columns and a suffix, the first two cut to the database's longest identifier (63 on
|
|
19
|
-
* PostgreSQL, 64 on MySQL).
|
|
20
|
+
* PostgreSQL, 64 on MySQL, 128 on SQL Server).
|
|
20
21
|
*
|
|
21
22
|
* @example
|
|
22
23
|
* ```sql
|
|
@@ -2,7 +2,7 @@ import { t as exists } from "./file-DOGnu_Q2.js";
|
|
|
2
2
|
import { v as DEFAULT_SCHEMA_PATHS, y as prismaSchemaPath } from "./bin/hekireki.js";
|
|
3
3
|
import { C as isJoinSideA, I as chunks, a as schemaText, h as backRelation, i as readSchemaFiles, n as parseSchema, t as dialectOf } from "./schema-CyJTUCF1.js";
|
|
4
4
|
import { r as emitRaw } from "./emit-DsCT5gLu.js";
|
|
5
|
-
import { r as lowerFirst } from "./case-
|
|
5
|
+
import { r as lowerFirst } from "./case-CCSiaowC.js";
|
|
6
6
|
import { a as loadSeedConfig, c as SeedConfigError, d as resolveDatabaseUrl, i as withTypeScriptImports, l as SeedDatabaseError, r as sequenceSql, s as resolveConfigPath, t as makeSeedSql, u as SeedGenerationError } from "./sql-LMMCiAlf.js";
|
|
7
7
|
import { n as discoverClient, r as adapterOf } from "./discover-CLLycWcR.js";
|
|
8
8
|
import { Effect } from "effect";
|
|
@@ -2,7 +2,7 @@ import { c as removePath, i as makeDirectory, l as watch, n as fileStamp, o as r
|
|
|
2
2
|
import { _ as STUDIO_HOSTNAME, a as InvalidInputError, b as readPrismaConfig, c as ServerListenError, d as DatabaseError, g as SSE_PING_MS, h as PRISMA_FILE_URI, i as FormatError, l as UnknownFileError, m as MIGRATIONS_POLL_MS, n as ClientUnavailableError, o as SchemaLoadError, p as FORBIDDEN_HOST_MESSAGE, r as FileWriteError, s as SchemaParseError, t as ClientQueryError, u as UnknownModelError } from "./bin/hekireki.js";
|
|
3
3
|
import { R as fmt, d as makePostgresSchema, i as readSchemaFiles$1, m as formatSql, n as parseSchema, r as readConfig } from "./schema-CyJTUCF1.js";
|
|
4
4
|
import { c as makeSchema, i as openSchemaEngine, n as openNativeSchemaEngine, o as makeSchemaEngineAdapter, r as engineCommand, s as makeAnalysisSchema, t as findSchemaEngineBinary } from "./native-engine-DeQEnJxi.js";
|
|
5
|
-
import { r as lowerFirst } from "./case-
|
|
5
|
+
import { r as lowerFirst } from "./case-CCSiaowC.js";
|
|
6
6
|
import { a as splitStatements, i as MigrationNotFoundError, l as toTsType, n as MigrateDatabaseError, s as literalDataType, t as MigrateConfigError } from "./errors-CRIxtr-P.js";
|
|
7
7
|
import { f as placeholder, h as stringLiteral, i as withTypeScriptImports, m as quoteIdentifier, o as readConfigUrl, p as qualifiedName } from "./sql-LMMCiAlf.js";
|
|
8
8
|
import { _ as openSqliteCopy, a as makePlan$1, c as checkOpened, d as DECISIONS_FILE, f as readDecisions, g as openShadowDatabase, h as openMysqlCopy, m as connectDatabase, p as writeDecisions, u as introspectDatabase } from "./plan-8rsBBJcs.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hekireki",
|
|
3
|
-
"version": "0.52.
|
|
3
|
+
"version": "0.52.4",
|
|
4
4
|
"description": "Hekireki is a code generator from Prisma schema to validation schemas, ORM models, OpenAPI and ER diagrams, with a Studio for your schema and its data",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"activerecord",
|