hekireki 0.40.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/activerecord.js +1 -1
- package/dist/bin/ajv.js +1 -1
- package/dist/bin/arktype.js +1 -1
- package/dist/bin/atlas.js +1 -1
- package/dist/bin/django.js +1 -1
- package/dist/bin/drizzle.js +1 -1
- package/dist/bin/ecto.js +1 -1
- package/dist/bin/efcore.js +1 -1
- package/dist/bin/effect.js +1 -1
- package/dist/bin/eloquent.js +1 -1
- package/dist/bin/er.js +1 -1
- package/dist/bin/exposed.js +1 -1
- package/dist/bin/gorm.js +1 -1
- package/dist/bin/hekireki.js +6 -7
- 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.js +1 -1
- package/dist/{bin-CVNnCHYf.js → bin-T1le3lMh.js} +80 -49
- package/dist/{discover-BJMo8i2-.js → discover-BaDQsKnF.js} +1 -1
- package/dist/{migrate-BhCE-YSd.js → migrate-2xlj7ayX.js} +2 -2
- package/dist/{plan-D9axVHFD.js → plan-B8PRmVdV.js} +2 -2
- package/dist/{run-Be-2eG1y.js → run-BQlJs4wi.js} +3 -3
- package/dist/{sql-FGRCF9o4.js → sql-izRRI1Bi.js} +1 -1
- package/dist/{start-9gS-ABI-.js → start-C7m4KyUz.js} +234 -730
- package/dist/studio/assets/{chip-5pFaNmwL.js → chip-D4JuozFz.js} +1 -1
- package/dist/studio/assets/client-DTRYUhbF.js +2 -0
- package/dist/studio/assets/{code-block-B1wLRka8.js → code-block-B7oBDy4S.js} +1 -1
- package/dist/studio/assets/confirm-dialog-DgDjONHy.js +1 -0
- package/dist/studio/assets/{copy-DvJVuM56.js → copy-CO4Wewxa.js} +1 -1
- package/dist/studio/assets/{copy-button-D4zjbBc-.js → copy-button-DDzfUcsZ.js} +1 -1
- package/dist/studio/assets/{dist-DEp-MbCs.js → dist-gV8lABSq.js} +1 -1
- package/dist/studio/assets/{docs-Cg9xqNoX.js → docs-DyJ-qhu9.js} +1 -1
- package/dist/studio/assets/{enums._name-BhNYpcT7.js → enums._name-CcIWxnq0.js} +1 -1
- package/dist/studio/assets/field-icon-DwOxCe9v.js +55 -0
- package/dist/studio/assets/hooks-6J-1786l.js +2 -0
- package/dist/studio/assets/index-D2cpa83b.js +15 -0
- package/dist/studio/assets/index-Dn9oYAy5.css +2 -0
- package/dist/studio/assets/labels-BrdjOFB0.js +2 -0
- package/dist/studio/assets/{lazyRouteComponent-TkAX4iEA.js → lazyRouteComponent-CzElNsBd.js} +1 -1
- package/dist/studio/assets/lu-BwZ0uwaH.js +7 -0
- package/dist/studio/assets/marked-text-CRUtsVYt.js +3 -0
- package/dist/studio/assets/models._name-Drem1hqS.js +1 -0
- package/dist/studio/assets/{monaco-DFkSQFp9.js → monaco-CKCcdl6_.js} +1 -1
- package/dist/studio/assets/{monaco-BoT_UVCW.js → monaco-Doo5FK2W.js} +1 -1
- package/dist/studio/assets/{not-found-CTsERB3d.js → not-found-KT_nPOAU.js} +1 -1
- package/dist/studio/assets/{prisma-DZMNzXN7.js → prisma-4lQKwVn6.js} +1 -1
- package/dist/studio/assets/result-table-DY7sKJQq.js +1 -0
- package/dist/studio/assets/routes-D6hrrw5V.js +1 -0
- package/dist/studio/assets/{schema-gate-CXYSsT5T.js → schema-gate-Dq2l2Sh6.js} +1 -1
- package/dist/studio/assets/{schema-view-wADoyIFc.js → schema-view-CnitOLrD.js} +2 -2
- package/dist/studio/assets/sql-CjIkv--0.js +6 -0
- package/dist/studio/assets/table-BxRDQMeA.js +1 -0
- package/dist/studio/assets/tabs-BwlFa2ot.js +1 -0
- package/dist/studio/assets/useFormValidation-DifOycKN.js +1 -0
- package/dist/studio/assets/{useMatch-wXiBv0wx.js → useMatch-D2UWqcDy.js} +1 -1
- package/dist/studio/assets/useMultipleSelectionState-2b0OEWtf.js +1 -0
- package/dist/studio/index.html +10 -11
- package/package.json +12 -12
- package/dist/studio/assets/client-Cn44j_II.js +0 -2
- package/dist/studio/assets/confirm-dialog-C84-yLfM.js +0 -1
- package/dist/studio/assets/field-icon-j33Axyq4.js +0 -55
- package/dist/studio/assets/hooks-vFvEnsyJ.js +0 -2
- package/dist/studio/assets/index-6aoNJjln.css +0 -2
- package/dist/studio/assets/index-Cjy--gYX.js +0 -11
- package/dist/studio/assets/labels-Db1CHOpt.js +0 -2
- package/dist/studio/assets/lu-CUfSReIi.js +0 -7
- package/dist/studio/assets/marked-text-BNzjDVlk.js +0 -3
- package/dist/studio/assets/models._name-BgiyfSuj.js +0 -1
- package/dist/studio/assets/result-table-zFoiQlAu.js +0 -1
- package/dist/studio/assets/routes-Dpy0uL8H.js +0 -1
- package/dist/studio/assets/search-field-Dshrbbug.js +0 -5
- package/dist/studio/assets/sql-0uoTjX3O.js +0 -6
- package/dist/studio/assets/table-5cZklaSq.js +0 -1
- package/dist/studio/assets/tabs-B7UQa0vf.js +0 -1
- package/dist/studio/assets/useFormValidation-D0dsTzOi.js +0 -1
- package/dist/studio/assets/useMultipleSelectionState-CyThblbT.js +0 -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/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.
|
|
9
|
+
var version = "0.41.0";
|
|
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"];
|
|
@@ -84,7 +84,6 @@ var ClientUnavailableError = class extends Data.TaggedError("ClientUnavailableEr
|
|
|
84
84
|
var ClientQueryError = class extends Data.TaggedError("ClientQueryError") {};
|
|
85
85
|
var InvalidInputError = class extends Data.TaggedError("InvalidInputError") {};
|
|
86
86
|
var FormatError = class extends Data.TaggedError("FormatError") {};
|
|
87
|
-
var ContractViolationError = class extends Data.TaggedError("ContractViolationError") {};
|
|
88
87
|
var SchemaLoadError = class extends Data.TaggedError("SchemaLoadError") {};
|
|
89
88
|
var SchemaParseError = class extends Data.TaggedError("SchemaParseError") {};
|
|
90
89
|
var ServerListenError = class extends Data.TaggedError("ServerListenError") {};
|
|
@@ -136,7 +135,7 @@ const studioFlags = {
|
|
|
136
135
|
function runStudio(args) {
|
|
137
136
|
return Effect.gen(function* () {
|
|
138
137
|
const schemaPath = yield* resolveSchemaPath(args.schema, [COMMAND_NAME, "studio"]);
|
|
139
|
-
const { startStudioServer } = yield* Effect.promise(() => import("../start-
|
|
138
|
+
const { startStudioServer } = yield* Effect.promise(() => import("../start-C7m4KyUz.js"));
|
|
140
139
|
const started = yield* startStudioServer({
|
|
141
140
|
schemaPath,
|
|
142
141
|
port: args.port,
|
|
@@ -184,7 +183,7 @@ const seedFlags = {
|
|
|
184
183
|
};
|
|
185
184
|
function runSeedCommand(args) {
|
|
186
185
|
return Effect.gen(function* () {
|
|
187
|
-
const { runSeed, seedBanner } = yield* Effect.promise(() => import("../run-
|
|
186
|
+
const { runSeed, seedBanner } = yield* Effect.promise(() => import("../run-BQlJs4wi.js"));
|
|
188
187
|
const report = yield* runSeed(args, process.cwd()).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
|
|
189
188
|
yield* Console.log(seedBanner(report));
|
|
190
189
|
});
|
|
@@ -227,7 +226,7 @@ function runMigrateCheckCommand(args) {
|
|
|
227
226
|
"migrate",
|
|
228
227
|
"check"
|
|
229
228
|
]);
|
|
230
|
-
const { checkBanner, checkJson, runMigrateCheck, summarize } = yield* Effect.promise(() => import("../migrate-
|
|
229
|
+
const { checkBanner, checkJson, runMigrateCheck, summarize } = yield* Effect.promise(() => import("../migrate-2xlj7ayX.js"));
|
|
231
230
|
const report = yield* runMigrateCheck({
|
|
232
231
|
...args,
|
|
233
232
|
schemaPath,
|
|
@@ -274,7 +273,7 @@ function runMigratePlanCommand(args) {
|
|
|
274
273
|
"migrate",
|
|
275
274
|
"plan"
|
|
276
275
|
]);
|
|
277
|
-
const { checkBanner, planSql, readMigration, runMigrateCheck, summarize, writePlan } = yield* Effect.promise(() => import("../migrate-
|
|
276
|
+
const { checkBanner, planSql, readMigration, runMigrateCheck, summarize, writePlan } = yield* Effect.promise(() => import("../migrate-2xlj7ayX.js"));
|
|
278
277
|
const report = yield* runMigrateCheck({
|
|
279
278
|
...args,
|
|
280
279
|
schemaPath,
|
|
@@ -333,4 +332,4 @@ function hekireki() {
|
|
|
333
332
|
}
|
|
334
333
|
// src/bin/hekireki.ts
|
|
335
334
|
runMain(hekireki().pipe(Effect.provide(layer)));
|
|
336
|
-
export {
|
|
335
|
+
export { STUDIO_HOSTNAME as _, FileWriteError as a, readPrismaConfig as b, SchemaLoadError as c, UnknownFileError as d, UnknownModelError as f, SSE_PING_MS as g, PRISMA_FILE_URI as h, DatabaseUnavailableError as i, SchemaParseError as l, MIGRATIONS_POLL_MS as m, ClientUnavailableError as n, FormatError as o, FORBIDDEN_HOST_MESSAGE as p, DatabaseError as r, InvalidInputError as s, ClientQueryError as t, ServerListenError as u, DEFAULT_SCHEMA_PATHS as v, prismaSchemaPath as y };
|
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
|
@@ -3619,10 +3619,16 @@ function resolveDefaultValue(field, provider, enums) {
|
|
|
3619
3619
|
chain: `.default(sql\`${dflt}\`)`,
|
|
3620
3620
|
imports: [SQL_IMPORT]
|
|
3621
3621
|
};
|
|
3622
|
-
if (fieldType === "DateTime")
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3622
|
+
if (fieldType === "DateTime") {
|
|
3623
|
+
if (provider === "sqlite") return {
|
|
3624
|
+
chain: `.default(sql\`'${new Date(dflt).toISOString().replace("Z", "+00:00")}'\`)`,
|
|
3625
|
+
imports: [SQL_IMPORT]
|
|
3626
|
+
};
|
|
3627
|
+
return {
|
|
3628
|
+
chain: `.default(new Date(${tsString(dflt)}))`,
|
|
3629
|
+
imports: []
|
|
3630
|
+
};
|
|
3631
|
+
}
|
|
3626
3632
|
if (fieldType === "Json") return {
|
|
3627
3633
|
chain: `.default(${dflt})`,
|
|
3628
3634
|
imports: []
|
|
@@ -3683,7 +3689,8 @@ function makeColumn(field, model, models, provider, imports, enums) {
|
|
|
3683
3689
|
function makeTableConstraints(model, models, provider, imports, indexes, tableName) {
|
|
3684
3690
|
const pkLine = model.primaryKey ? (() => {
|
|
3685
3691
|
imports.core.add("primaryKey");
|
|
3686
|
-
|
|
3692
|
+
const columns = model.primaryKey.fields.map((f) => `table.${f}`).join(", ");
|
|
3693
|
+
return provider === "mysql" ? `primaryKey({ columns: [${columns}] })` : `primaryKey({ name: '${tableName}_pkey', columns: [${columns}] })`;
|
|
3687
3694
|
})() : null;
|
|
3688
3695
|
const indexLines = indexes.filter((idx) => idx.model === model.name && (idx.type === "unique" || idx.type === "normal" || idx.type === "fulltext")).map((idx) => {
|
|
3689
3696
|
const name = idx.dbName ?? constraintName(tableName, idx.fields.map((f) => fieldColumn(model, f.name)), idx.type === "unique" ? "key" : "idx", provider);
|
|
@@ -3762,68 +3769,93 @@ function makeM2MJoinTables(models, provider, imports) {
|
|
|
3762
3769
|
return `export const ${joinVarName(pair.relationName)} = ${tableFunc}('${tableName}', { ${columns.join(", ")} }, (table) => [${constraints.join(", ")}])`;
|
|
3763
3770
|
});
|
|
3764
3771
|
}
|
|
3765
|
-
function makeM2MJoinRelations(models, imports) {
|
|
3766
|
-
const pairs = implicitJoinTables(models);
|
|
3767
|
-
if (pairs.length > 0) imports.orm.add("relations");
|
|
3768
|
-
return pairs.map((pair) => {
|
|
3769
|
-
const varName = joinVarName(pair.relationName);
|
|
3770
|
-
const leftVar = resolveVarNameByType(pair.left, models);
|
|
3771
|
-
const rightVar = resolveVarNameByType(pair.right, models);
|
|
3772
|
-
const leftPk = models.find((m) => m.name === pair.left)?.fields.find((f) => f.isId);
|
|
3773
|
-
const rightPk = models.find((m) => m.name === pair.right)?.fields.find((f) => f.isId);
|
|
3774
|
-
const leftKey = uncapitalizeName(pair.left);
|
|
3775
|
-
const isSelf = pair.left === pair.right;
|
|
3776
|
-
const rightKey = isSelf ? `${uncapitalizeName(pair.right)}_` : uncapitalizeName(pair.right);
|
|
3777
|
-
const aName = isSelf ? `, relationName: '${pair.relationName}_A'` : "";
|
|
3778
|
-
const bName = isSelf ? `, relationName: '${pair.relationName}_B'` : "";
|
|
3779
|
-
return `export const ${varName}Relations = relations(${varName}, ({ one }) => ({ ${leftKey}: one(${leftVar}, { fields: [${varName}.A], references: [${leftVar}.${leftPk?.name ?? "id"}]${aName} }), ${rightKey}: one(${rightVar}, { fields: [${varName}.B], references: [${rightVar}.${rightPk?.name ?? "id"}]${bName} }) }))`;
|
|
3780
|
-
});
|
|
3781
|
-
}
|
|
3782
3772
|
function uncapitalizeName(name) {
|
|
3783
3773
|
const camel = snakeToCamel(makeSnakeCase(name));
|
|
3784
3774
|
return camel.charAt(0).toLowerCase() + camel.slice(1);
|
|
3785
3775
|
}
|
|
3776
|
+
function columnRefs(tableVar, columns) {
|
|
3777
|
+
const refs = columns.map((column) => `r.${tableVar}.${column}`);
|
|
3778
|
+
return refs.length > 1 ? `[${refs.join(", ")}]` : refs.join(", ");
|
|
3779
|
+
}
|
|
3780
|
+
function keyName(modelName, models) {
|
|
3781
|
+
return models.find((m) => m.name === modelName)?.fields.find((f) => f.isId)?.name ?? "id";
|
|
3782
|
+
}
|
|
3783
|
+
function call(options) {
|
|
3784
|
+
return options.length > 0 ? `({ ${options.join(", ")} })` : "()";
|
|
3785
|
+
}
|
|
3786
|
+
/**
|
|
3787
|
+
* One relation. The end that holds the foreign key names its columns and, where Prisma requires
|
|
3788
|
+
* the relation, `optional: false`; the other end of a one-to-one names them the other way round,
|
|
3789
|
+
* and the list end is `r.many.<table>()`, which drizzle pairs with the `one` through the alias
|
|
3790
|
+
* where a model has two relations to one table. An implicit many-to-many reads the join table
|
|
3791
|
+
* with `through` from both ends, so neither is inferred.
|
|
3792
|
+
*/
|
|
3786
3793
|
function makeRelationField(field, model, models, relFields) {
|
|
3787
3794
|
const targetVar = resolveVarNameByType(field.type, models);
|
|
3788
3795
|
const modelVar = resolveVarName(model);
|
|
3789
|
-
const
|
|
3796
|
+
const alias = relFields.filter((f) => f.type === field.type).length > 1 && field.relationName ? [`alias: '${field.relationName}'`] : [];
|
|
3790
3797
|
if (field.relationFromFields && field.relationFromFields.length > 0) {
|
|
3791
|
-
const
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
`
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
]
|
|
3798
|
-
return `${field.name}: one(${targetVar}, { ${configParts.join(", ")} })`;
|
|
3798
|
+
const toFields = field.relationToFields && field.relationToFields.length > 0 ? field.relationToFields : ["id"];
|
|
3799
|
+
return `${field.name}: r.one.${targetVar}${call([
|
|
3800
|
+
`from: ${columnRefs(modelVar, field.relationFromFields)}`,
|
|
3801
|
+
`to: ${columnRefs(targetVar, toFields)}`,
|
|
3802
|
+
...field.isRequired ? ["optional: false"] : [],
|
|
3803
|
+
...alias
|
|
3804
|
+
])}`;
|
|
3799
3805
|
}
|
|
3800
3806
|
if (field.isList) {
|
|
3801
3807
|
if (isImplicitManyToMany(field, model, models)) {
|
|
3802
3808
|
const [left, right] = model.name < field.type ? [model.name, field.type] : [field.type, model.name];
|
|
3803
|
-
const
|
|
3809
|
+
const joinVar = joinVarName(field.relationName ?? `${left}To${right}`);
|
|
3804
3810
|
const inverse = backRelation(field, model, models);
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
return `${field.name}: many(${joinVarName(relationName)}, { relationName: '${relationName}_${column}' })`;
|
|
3808
|
-
}
|
|
3809
|
-
return `${field.name}: many(${joinVarName(relationName)})`;
|
|
3811
|
+
const [own, other] = inverse && isJoinSideA(field, model, inverse) ? ["A", "B"] : ["B", "A"];
|
|
3812
|
+
return `${field.name}: r.many.${targetVar}${call([`from: r.${modelVar}.${keyName(model.name, models)}.through(r.${joinVar}.${own})`, `to: r.${targetVar}.${keyName(field.type, models)}.through(r.${joinVar}.${other})`])}`;
|
|
3810
3813
|
}
|
|
3811
|
-
return
|
|
3814
|
+
return `${field.name}: r.many.${targetVar}${call(alias)}`;
|
|
3812
3815
|
}
|
|
3813
|
-
|
|
3816
|
+
const inverse = backRelation(field, model, models);
|
|
3817
|
+
if (inverse?.relationFromFields && inverse.relationFromFields.length > 0) {
|
|
3818
|
+
const fromFields = inverse.relationToFields && inverse.relationToFields.length > 0 ? inverse.relationToFields : ["id"];
|
|
3819
|
+
return `${field.name}: r.one.${targetVar}${call([
|
|
3820
|
+
`from: ${columnRefs(modelVar, fromFields)}`,
|
|
3821
|
+
`to: ${columnRefs(targetVar, inverse.relationFromFields)}`,
|
|
3822
|
+
...alias
|
|
3823
|
+
])}`;
|
|
3824
|
+
}
|
|
3825
|
+
return `${field.name}: r.one.${targetVar}${call(alias)}`;
|
|
3814
3826
|
}
|
|
3827
|
+
/**
|
|
3828
|
+
* The relations as drizzle 1.0 reads them: one `defineRelations` over every table, the
|
|
3829
|
+
* join tables of the implicit many-to-many relations included, keyed by the table's variable.
|
|
3830
|
+
*
|
|
3831
|
+
* @example
|
|
3832
|
+
* ```ts
|
|
3833
|
+
* export const relations = defineRelations({ user, post }, (r) => ({
|
|
3834
|
+
* user: { posts: r.many.post() },
|
|
3835
|
+
* post: { author: r.one.user({ from: r.post.userId, to: r.user.id, optional: false }) },
|
|
3836
|
+
* }))
|
|
3837
|
+
* ```
|
|
3838
|
+
*/
|
|
3815
3839
|
function makeRelations$1(models, imports) {
|
|
3816
3840
|
const modelsWithRels = models.filter((model) => model.fields.some((f) => f.kind === "object"));
|
|
3817
3841
|
if (modelsWithRels.length === 0) return [];
|
|
3818
|
-
imports.orm.add("
|
|
3819
|
-
|
|
3842
|
+
imports.orm.add("defineRelations");
|
|
3843
|
+
const pairs = implicitJoinTables(models);
|
|
3844
|
+
const tables = [...models.map((model) => resolveVarName(model)), ...pairs.map((pair) => joinVarName(pair.relationName))];
|
|
3845
|
+
const entries = [...modelsWithRels.map((model) => {
|
|
3820
3846
|
const relFields = model.fields.filter((f) => f.kind === "object");
|
|
3821
3847
|
const fieldLines = relFields.map((field) => makeRelationField(field, model, models, relFields)).join(", ");
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
const
|
|
3825
|
-
|
|
3826
|
-
|
|
3848
|
+
return `${resolveVarName(model)}: { ${fieldLines} }`;
|
|
3849
|
+
}), ...pairs.map((pair) => {
|
|
3850
|
+
const joinVar = joinVarName(pair.relationName);
|
|
3851
|
+
const isSelf = pair.left === pair.right;
|
|
3852
|
+
return `${joinVar}: { ${["A", "B"].map((column) => {
|
|
3853
|
+
const modelName = column === "A" ? pair.left : pair.right;
|
|
3854
|
+
const key = uncapitalizeName(modelName);
|
|
3855
|
+
return `${isSelf && column === "B" ? `${key}_` : key}: r.one.${resolveVarNameByType(modelName, models)}({ from: r.${joinVar}.${column}, to: r.${resolveVarNameByType(modelName, models)}.${keyName(modelName, models)}, optional: false })`;
|
|
3856
|
+
}).join(", ")} }`;
|
|
3857
|
+
})];
|
|
3858
|
+
return [`export const relations = defineRelations({ ${tables.join(", ")} }, (r) => ({ ${entries.join(", ")} }))`];
|
|
3827
3859
|
}
|
|
3828
3860
|
// src/generator/drizzle.ts
|
|
3829
3861
|
function drizzleSchema(datamodel, provider, indexes) {
|
|
@@ -3831,10 +3863,9 @@ function drizzleSchema(datamodel, provider, indexes) {
|
|
|
3831
3863
|
const imports = createImports();
|
|
3832
3864
|
const enumLines = makeEnumDeclarations$1(datamodel.models, datamodel.enums, db, imports);
|
|
3833
3865
|
const tableLines = [...datamodel.models.map((model) => makeTable(model, datamodel.models, db, imports, datamodel.enums, indexes)), ...makeM2MJoinTables(datamodel.models, db, imports)];
|
|
3834
|
-
const relationsLines =
|
|
3866
|
+
const relationsLines = makeRelations$1(datamodel.models, imports);
|
|
3835
3867
|
const enumLinesWithGap = enumLines.flatMap((line, i) => i < enumLines.length - 1 ? [line, ""] : [line]);
|
|
3836
3868
|
const tableLinesWithGap = tableLines.flatMap((line, i) => i < tableLines.length - 1 ? [line, ""] : [line]);
|
|
3837
|
-
const relationsLinesWithGap = relationsLines.flatMap((line, i) => i < relationsLines.length - 1 ? [line, ""] : [line]);
|
|
3838
3869
|
const columnHelpers = makeColumnHelpers(imports);
|
|
3839
3870
|
return [
|
|
3840
3871
|
generateImports(imports, db),
|
|
@@ -3842,7 +3873,7 @@ function drizzleSchema(datamodel, provider, indexes) {
|
|
|
3842
3873
|
...columnHelpers.flatMap((helper) => [helper, ""]),
|
|
3843
3874
|
...enumLinesWithGap.length > 0 ? [...enumLinesWithGap, ""] : [],
|
|
3844
3875
|
...tableLinesWithGap,
|
|
3845
|
-
...
|
|
3876
|
+
...relationsLines.length > 0 ? ["", ...relationsLines] : []
|
|
3846
3877
|
].join("\n");
|
|
3847
3878
|
}
|
|
3848
3879
|
function parsePrismaProvider(raw) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as SeedDatabaseError, f as makePostgresSchema, m as makeSqliteFilePath } from "./sql-
|
|
1
|
+
import { b as SeedDatabaseError, f as makePostgresSchema, m as makeSqliteFilePath } from "./sql-izRRI1Bi.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { Effect } from "effect";
|
|
4
4
|
import path from "node:path";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { s as readFile } from "./file-BAVQ-zst.js";
|
|
2
2
|
import { r as emitRaw } from "./emit-C4CeSye3.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-
|
|
4
|
-
import "./sql-
|
|
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-B8PRmVdV.js";
|
|
4
|
+
import "./sql-izRRI1Bi.js";
|
|
5
5
|
import { Effect } from "effect";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
// src/migrate/adapter/plan-file.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { c as removePath, i as makeDirectory, r as isDirectory, s as readFile, t as exists, u as writeFile } from "./file-BAVQ-zst.js";
|
|
2
|
-
import {
|
|
2
|
+
import { i as DatabaseUnavailableError, r as DatabaseError } from "./bin/hekireki.js";
|
|
3
3
|
import { c as isJoinSideA, j as lowerFirst, t as backRelation } from "./prisma-model-DFq7AQgV.js";
|
|
4
4
|
import "./schema-CfxnFLAw.js";
|
|
5
|
-
import { C as parseSchema, S as dialectOf, T as schemaText, _ as readConfigUrl, a as placeholder, c as stringLiteral, d as makeDialect, f as makePostgresSchema, h as withTypeScriptImports, l as resolveDatabaseUrl, m as makeSqliteFilePath, n as renderLiteral, o as qualifiedName, p as makeRedactedUrl, s as quoteIdentifier, w as readSchemaFiles } from "./sql-
|
|
5
|
+
import { C as parseSchema, S as dialectOf, T as schemaText, _ as readConfigUrl, a as placeholder, c as stringLiteral, d as makeDialect, f as makePostgresSchema, h as withTypeScriptImports, l as resolveDatabaseUrl, m as makeSqliteFilePath, n as renderLiteral, o as qualifiedName, p as makeRedactedUrl, s as quoteIdentifier, w as readSchemaFiles } from "./sql-izRRI1Bi.js";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import { Data, Effect } from "effect";
|
|
8
8
|
import path from "node:path";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as exists } from "./file-BAVQ-zst.js";
|
|
2
|
-
import {
|
|
2
|
+
import { v as DEFAULT_SCHEMA_PATHS, y as prismaSchemaPath } from "./bin/hekireki.js";
|
|
3
3
|
import { c as isJoinSideA, j as lowerFirst, t as backRelation, y as chunks } from "./prisma-model-DFq7AQgV.js";
|
|
4
4
|
import { r as emitRaw } from "./emit-C4CeSye3.js";
|
|
5
|
-
import { C as parseSchema, S as dialectOf, T as schemaText, b as SeedDatabaseError, g as loadSeedConfig, h as withTypeScriptImports, l as resolveDatabaseUrl, r as sequenceSql, t as makeSeedSql, v as resolveConfigPath, w as readSchemaFiles, x as SeedGenerationError, y as SeedConfigError } from "./sql-
|
|
6
|
-
import { r as discoverClient, t as ADAPTERS } from "./discover-
|
|
5
|
+
import { C as parseSchema, S as dialectOf, T as schemaText, b as SeedDatabaseError, g as loadSeedConfig, h as withTypeScriptImports, l as resolveDatabaseUrl, r as sequenceSql, t as makeSeedSql, v as resolveConfigPath, w as readSchemaFiles, x as SeedGenerationError, y as SeedConfigError } from "./sql-izRRI1Bi.js";
|
|
6
|
+
import { r as discoverClient, t as ADAPTERS } from "./discover-BaDQsKnF.js";
|
|
7
7
|
import { Effect } from "effect";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import * as z from "zod";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as readDirectory, r as isDirectory, s as readFile, t as exists, u as writeFile } from "./file-BAVQ-zst.js";
|
|
2
|
-
import {
|
|
2
|
+
import { b as readPrismaConfig } from "./bin/hekireki.js";
|
|
3
3
|
import { y as chunks } from "./prisma-model-DFq7AQgV.js";
|
|
4
4
|
import nodeModule from "node:module";
|
|
5
5
|
import { Config, ConfigProvider, Data, Effect, FileSystem, Option, Schema, SchemaIssue } from "effect";
|