@prisma/client-generator-ts 6.6.0-dev.65 → 6.6.0-dev.67
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/generator.d.ts +1 -2
- package/dist/index.d.mts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +30 -94
- package/dist/index.mjs +30 -94
- package/package.json +10 -10
package/dist/generator.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Generator, GeneratorConfig, GeneratorManifest, GeneratorOptions } from '@prisma/generator';
|
|
2
2
|
type PrismaClientTsGeneratorOptions = {
|
|
3
|
-
shouldResolvePrismaClient?: boolean;
|
|
4
3
|
runtimePath?: string;
|
|
5
4
|
};
|
|
6
5
|
export declare class PrismaClientTsGenerator implements Generator {
|
|
7
6
|
#private;
|
|
8
7
|
readonly name = "prisma-client-ts";
|
|
9
|
-
constructor({
|
|
8
|
+
constructor({ runtimePath }?: PrismaClientTsGeneratorOptions);
|
|
10
9
|
getManifest(config: GeneratorConfig): Promise<GeneratorManifest>;
|
|
11
10
|
generate(options: GeneratorOptions): Promise<void>;
|
|
12
11
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -54,13 +54,12 @@ export declare function getDMMF(options: GetDMMFOptions): Promise<DMMF.Document>
|
|
|
54
54
|
export declare class PrismaClientTsGenerator implements Generator_2 {
|
|
55
55
|
#private;
|
|
56
56
|
readonly name = "prisma-client-ts";
|
|
57
|
-
constructor({
|
|
57
|
+
constructor({ runtimePath }?: PrismaClientTsGeneratorOptions);
|
|
58
58
|
getManifest(config: GeneratorConfig): Promise<GeneratorManifest>;
|
|
59
59
|
generate(options: GeneratorOptions): Promise<void>;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
declare type PrismaClientTsGeneratorOptions = {
|
|
63
|
-
shouldResolvePrismaClient?: boolean;
|
|
64
63
|
runtimePath?: string;
|
|
65
64
|
};
|
|
66
65
|
|
package/dist/index.d.ts
CHANGED
|
@@ -54,13 +54,12 @@ export declare function getDMMF(options: GetDMMFOptions): Promise<DMMF.Document>
|
|
|
54
54
|
export declare class PrismaClientTsGenerator implements Generator_2 {
|
|
55
55
|
#private;
|
|
56
56
|
readonly name = "prisma-client-ts";
|
|
57
|
-
constructor({
|
|
57
|
+
constructor({ runtimePath }?: PrismaClientTsGeneratorOptions);
|
|
58
58
|
getManifest(config: GeneratorConfig): Promise<GeneratorManifest>;
|
|
59
59
|
generate(options: GeneratorOptions): Promise<void>;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
declare type PrismaClientTsGeneratorOptions = {
|
|
63
|
-
shouldResolvePrismaClient?: boolean;
|
|
64
63
|
runtimePath?: string;
|
|
65
64
|
};
|
|
66
65
|
|
package/dist/index.js
CHANGED
|
@@ -2228,7 +2228,6 @@ var import_fetch_engine = require("@prisma/fetch-engine");
|
|
|
2228
2228
|
var import_internals10 = require("@prisma/internals");
|
|
2229
2229
|
var import_crypto2 = require("crypto");
|
|
2230
2230
|
var import_env_paths = __toESM(require("env-paths"));
|
|
2231
|
-
var import_fs = require("fs");
|
|
2232
2231
|
var import_promises = __toESM(require("fs/promises"));
|
|
2233
2232
|
var import_fs_extra = __toESM(require_lib());
|
|
2234
2233
|
|
|
@@ -2500,7 +2499,7 @@ var package_default = {
|
|
|
2500
2499
|
"@prisma/dmmf": "workspace:*",
|
|
2501
2500
|
"@prisma/driver-adapter-utils": "workspace:*",
|
|
2502
2501
|
"@prisma/engines": "workspace:*",
|
|
2503
|
-
"@prisma/engines-version": "6.6.0-
|
|
2502
|
+
"@prisma/engines-version": "6.6.0-31.d26022ad3b55e2aa7e4ffc189436e4c59aae0c29",
|
|
2504
2503
|
"@prisma/fetch-engine": "workspace:*",
|
|
2505
2504
|
"@prisma/generator": "workspace:*",
|
|
2506
2505
|
"@prisma/generator-helper": "workspace:*",
|
|
@@ -2510,8 +2509,8 @@ var package_default = {
|
|
|
2510
2509
|
"@prisma/migrate": "workspace:*",
|
|
2511
2510
|
"@prisma/mini-proxy": "0.9.5",
|
|
2512
2511
|
"@prisma/pg-worker": "workspace:*",
|
|
2513
|
-
"@prisma/query-compiler-wasm": "6.6.0-
|
|
2514
|
-
"@prisma/query-engine-wasm": "6.6.0-
|
|
2512
|
+
"@prisma/query-compiler-wasm": "6.6.0-31.d26022ad3b55e2aa7e4ffc189436e4c59aae0c29",
|
|
2513
|
+
"@prisma/query-engine-wasm": "6.6.0-31.d26022ad3b55e2aa7e4ffc189436e4c59aae0c29",
|
|
2515
2514
|
"@prisma/ts-builders": "workspace:*",
|
|
2516
2515
|
"@snaplet/copycat": "6.0.0",
|
|
2517
2516
|
"@swc-node/register": "1.10.9",
|
|
@@ -6775,21 +6774,6 @@ function getTypedSqlRuntimeBase(runtimeBase) {
|
|
|
6775
6774
|
}
|
|
6776
6775
|
return `../${runtimeBase}`;
|
|
6777
6776
|
}
|
|
6778
|
-
async function getDefaultOutdir(outputDir) {
|
|
6779
|
-
if (outputDir.endsWith(import_path3.default.normalize("node_modules/@prisma/client"))) {
|
|
6780
|
-
return import_path3.default.join(outputDir, "../../.prisma/client");
|
|
6781
|
-
}
|
|
6782
|
-
if (process.env.INIT_CWD && process.env.npm_lifecycle_event === "postinstall" && !process.env.PWD?.includes(".pnpm")) {
|
|
6783
|
-
if ((0, import_fs.existsSync)(import_path3.default.join(process.env.INIT_CWD, "package.json"))) {
|
|
6784
|
-
return import_path3.default.join(process.env.INIT_CWD, "node_modules/.prisma/client");
|
|
6785
|
-
}
|
|
6786
|
-
const packagePath = await (0, import_pkg_up.default)({ cwd: process.env.INIT_CWD });
|
|
6787
|
-
if (packagePath) {
|
|
6788
|
-
return import_path3.default.join(import_path3.default.dirname(packagePath), "node_modules/.prisma/client");
|
|
6789
|
-
}
|
|
6790
|
-
}
|
|
6791
|
-
return import_path3.default.join(outputDir, "../../.prisma/client");
|
|
6792
|
-
}
|
|
6793
6777
|
async function generateClient(options) {
|
|
6794
6778
|
const {
|
|
6795
6779
|
datamodel,
|
|
@@ -6853,7 +6837,7 @@ To learn more about how to rename models, check out https://pris.ly/d/naming-mod
|
|
|
6853
6837
|
await (0, import_fs_extra.ensureDir)(import_path3.default.join(outputDir, "deno"));
|
|
6854
6838
|
}
|
|
6855
6839
|
await writeFileMap(outputDir, fileMap);
|
|
6856
|
-
if (copyRuntime
|
|
6840
|
+
if (copyRuntime) {
|
|
6857
6841
|
const copiedRuntimeDir = import_path3.default.join(outputDir, "runtime");
|
|
6858
6842
|
await (0, import_fs_extra.ensureDir)(copiedRuntimeDir);
|
|
6859
6843
|
await copyRuntimeFiles({
|
|
@@ -6997,79 +6981,20 @@ function validateDmmfAgainstDenylists(prismaClientDmmf) {
|
|
|
6997
6981
|
}
|
|
6998
6982
|
return errorArray.length > 0 ? errorArray : null;
|
|
6999
6983
|
}
|
|
7000
|
-
async function getGenerationDirs({
|
|
7001
|
-
runtimeBase,
|
|
7002
|
-
generator,
|
|
7003
|
-
outputDir,
|
|
7004
|
-
datamodel,
|
|
7005
|
-
schemaPath,
|
|
7006
|
-
testMode
|
|
7007
|
-
}) {
|
|
7008
|
-
const isCustomOutput = generator.isCustomOutput === true;
|
|
6984
|
+
async function getGenerationDirs({ runtimeBase, outputDir, testMode, copyRuntime }) {
|
|
7009
6985
|
const normalizedOutputDir = import_path3.default.normalize(outputDir);
|
|
7010
|
-
let userRuntimeImport =
|
|
7011
|
-
let userOutputDir = isCustomOutput ? normalizedOutputDir : await getDefaultOutdir(normalizedOutputDir);
|
|
6986
|
+
let userRuntimeImport = copyRuntime ? "./runtime" : "@prisma/client/runtime";
|
|
7012
6987
|
if (testMode && runtimeBase) {
|
|
7013
|
-
userOutputDir = outputDir;
|
|
7014
6988
|
userRuntimeImport = (0, import_internals10.pathToPosix)(runtimeBase);
|
|
7015
6989
|
}
|
|
7016
|
-
|
|
7017
|
-
await verifyOutputDirectory(userOutputDir, datamodel, schemaPath);
|
|
7018
|
-
}
|
|
7019
|
-
const userPackageRoot = await (0, import_pkg_up.default)({ cwd: import_path3.default.dirname(userOutputDir) });
|
|
6990
|
+
const userPackageRoot = await (0, import_pkg_up.default)({ cwd: import_path3.default.dirname(normalizedOutputDir) });
|
|
7020
6991
|
const userProjectRoot = userPackageRoot ? import_path3.default.dirname(userPackageRoot) : process.cwd();
|
|
7021
6992
|
return {
|
|
7022
6993
|
runtimeBase: userRuntimeImport,
|
|
7023
|
-
outputDir:
|
|
6994
|
+
outputDir: normalizedOutputDir,
|
|
7024
6995
|
projectRoot: userProjectRoot
|
|
7025
6996
|
};
|
|
7026
6997
|
}
|
|
7027
|
-
async function verifyOutputDirectory(directory, datamodel, schemaPath) {
|
|
7028
|
-
let content;
|
|
7029
|
-
try {
|
|
7030
|
-
content = await import_promises.default.readFile(import_path3.default.join(directory, "package.json"), "utf8");
|
|
7031
|
-
} catch (e) {
|
|
7032
|
-
if (e.code === "ENOENT") {
|
|
7033
|
-
return;
|
|
7034
|
-
}
|
|
7035
|
-
throw e;
|
|
7036
|
-
}
|
|
7037
|
-
const { name } = JSON.parse(content);
|
|
7038
|
-
if (name === package_default.name) {
|
|
7039
|
-
const message = [`Generating client into ${bold(directory)} is not allowed.`];
|
|
7040
|
-
message.push("This package is used by `prisma generate` and overwriting its content is dangerous.");
|
|
7041
|
-
message.push("");
|
|
7042
|
-
message.push("Suggestion:");
|
|
7043
|
-
const outputDeclaration = findOutputPathDeclaration(datamodel);
|
|
7044
|
-
if (outputDeclaration && outputDeclaration.content.includes(package_default.name)) {
|
|
7045
|
-
const outputLine = outputDeclaration.content;
|
|
7046
|
-
message.push(`In ${bold(schemaPath)} replace:`);
|
|
7047
|
-
message.push("");
|
|
7048
|
-
message.push(`${dim(outputDeclaration.lineNumber)} ${replacePackageName(outputLine, red(package_default.name))}`);
|
|
7049
|
-
message.push("with");
|
|
7050
|
-
message.push(`${dim(outputDeclaration.lineNumber)} ${replacePackageName(outputLine, green(".prisma/client"))}`);
|
|
7051
|
-
} else {
|
|
7052
|
-
message.push(`Generate client into ${bold(replacePackageName(directory, green(".prisma/client")))} instead`);
|
|
7053
|
-
}
|
|
7054
|
-
message.push("");
|
|
7055
|
-
message.push("You won't need to change your imports.");
|
|
7056
|
-
message.push("Imports from `@prisma/client` will be automatically forwarded to `.prisma/client`");
|
|
7057
|
-
const error = new Error(message.join("\n"));
|
|
7058
|
-
throw error;
|
|
7059
|
-
}
|
|
7060
|
-
}
|
|
7061
|
-
function replacePackageName(directoryPath, replacement) {
|
|
7062
|
-
return directoryPath.replace(package_default.name, replacement);
|
|
7063
|
-
}
|
|
7064
|
-
function findOutputPathDeclaration(datamodel) {
|
|
7065
|
-
const lines = datamodel.split(/\r?\n/);
|
|
7066
|
-
for (const [i, line] of lines.entries()) {
|
|
7067
|
-
if (/output\s*=/.test(line)) {
|
|
7068
|
-
return { lineNumber: i + 1, content: line.trim() };
|
|
7069
|
-
}
|
|
7070
|
-
}
|
|
7071
|
-
return null;
|
|
7072
|
-
}
|
|
7073
6998
|
function getNodeRuntimeName(engineType) {
|
|
7074
6999
|
if (engineType === import_internals10.ClientEngineType.Binary) {
|
|
7075
7000
|
return "binary";
|
|
@@ -7136,7 +7061,7 @@ var import_internals12 = require("@prisma/internals");
|
|
|
7136
7061
|
var import_ts_pattern = require("ts-pattern");
|
|
7137
7062
|
|
|
7138
7063
|
// package.json
|
|
7139
|
-
var version = "6.6.0-dev.
|
|
7064
|
+
var version = "6.6.0-dev.67";
|
|
7140
7065
|
|
|
7141
7066
|
// src/resolvePrismaClient.ts
|
|
7142
7067
|
var import_promises2 = __toESM(require("node:fs/promises"));
|
|
@@ -7178,36 +7103,47 @@ async function getPackageCmd(cwd, cmd, ...args) {
|
|
|
7178
7103
|
|
|
7179
7104
|
// src/generator.ts
|
|
7180
7105
|
var debug3 = (0, import_debug3.default)("prisma:client:generator");
|
|
7106
|
+
var missingOutputErrorMessage = `An output path is required for the \`prisma-client-ts\` generator. Please provide an output path in your schema file:
|
|
7107
|
+
|
|
7108
|
+
${dim(`generator client {
|
|
7109
|
+
provider = "prisma-client-ts"`)}
|
|
7110
|
+
${green(' output = "../src/generated"')}
|
|
7111
|
+
${dim("}")}
|
|
7112
|
+
|
|
7113
|
+
${bold("Note:")} the output path is relative to the schema directory.
|
|
7114
|
+
`;
|
|
7115
|
+
function getOutputPath(config) {
|
|
7116
|
+
if (!config.output) {
|
|
7117
|
+
throw new Error(missingOutputErrorMessage);
|
|
7118
|
+
}
|
|
7119
|
+
return (0, import_internals12.parseEnvValue)(config.output);
|
|
7120
|
+
}
|
|
7181
7121
|
var PrismaClientTsGenerator = class {
|
|
7182
7122
|
name = "prisma-client-ts";
|
|
7183
|
-
#shouldResolvePrismaClient = true;
|
|
7184
7123
|
#runtimePath;
|
|
7185
7124
|
#cachedPrismaClientPath;
|
|
7186
|
-
constructor({
|
|
7187
|
-
this.#shouldResolvePrismaClient = shouldResolvePrismaClient;
|
|
7125
|
+
constructor({ runtimePath } = {}) {
|
|
7188
7126
|
this.#runtimePath = runtimePath;
|
|
7189
7127
|
}
|
|
7190
|
-
|
|
7128
|
+
getManifest(config) {
|
|
7191
7129
|
const requiresEngines = (0, import_ts_pattern.match)((0, import_internals12.getClientEngineType)(config)).with(import_internals12.ClientEngineType.Library, () => ["libqueryEngine"]).with(import_internals12.ClientEngineType.Binary, () => ["queryEngine"]).with(import_internals12.ClientEngineType.Client, () => []).exhaustive();
|
|
7192
7130
|
debug3("requiresEngines", requiresEngines);
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
defaultOutput,
|
|
7131
|
+
return Promise.resolve({
|
|
7132
|
+
defaultOutput: getOutputPath(config),
|
|
7196
7133
|
prettyName: "Prisma Client",
|
|
7197
7134
|
version,
|
|
7198
7135
|
requiresEngines,
|
|
7199
7136
|
requiresEngineVersion: import_engines_version.enginesVersion
|
|
7200
|
-
};
|
|
7137
|
+
});
|
|
7201
7138
|
}
|
|
7202
7139
|
async generate(options) {
|
|
7203
|
-
const outputDir = (0, import_internals12.parseEnvValue)(options.generator.output);
|
|
7204
7140
|
await generateClient({
|
|
7205
7141
|
datamodel: options.datamodel,
|
|
7206
7142
|
schemaPath: options.schemaPath,
|
|
7207
7143
|
binaryPaths: options.binaryPaths,
|
|
7208
7144
|
datasources: options.datasources,
|
|
7209
7145
|
envPaths: options.envPaths,
|
|
7210
|
-
outputDir,
|
|
7146
|
+
outputDir: getOutputPath(options.generator),
|
|
7211
7147
|
copyRuntime: Boolean(options.generator.config.copyRuntime),
|
|
7212
7148
|
copyRuntimeSourceMaps: Boolean(process.env.PRISMA_COPY_RUNTIME_SOURCEMAPS),
|
|
7213
7149
|
runtimeSourcePath: await this.#getRuntimePath(options.generator),
|
package/dist/index.mjs
CHANGED
|
@@ -2224,7 +2224,6 @@ import {
|
|
|
2224
2224
|
} from "@prisma/internals";
|
|
2225
2225
|
import { createHash } from "crypto";
|
|
2226
2226
|
import paths from "env-paths";
|
|
2227
|
-
import { existsSync } from "fs";
|
|
2228
2227
|
import fs from "fs/promises";
|
|
2229
2228
|
|
|
2230
2229
|
// ../../node_modules/.pnpm/kleur@4.1.5/node_modules/kleur/colors.mjs
|
|
@@ -2495,7 +2494,7 @@ var package_default = {
|
|
|
2495
2494
|
"@prisma/dmmf": "workspace:*",
|
|
2496
2495
|
"@prisma/driver-adapter-utils": "workspace:*",
|
|
2497
2496
|
"@prisma/engines": "workspace:*",
|
|
2498
|
-
"@prisma/engines-version": "6.6.0-
|
|
2497
|
+
"@prisma/engines-version": "6.6.0-31.d26022ad3b55e2aa7e4ffc189436e4c59aae0c29",
|
|
2499
2498
|
"@prisma/fetch-engine": "workspace:*",
|
|
2500
2499
|
"@prisma/generator": "workspace:*",
|
|
2501
2500
|
"@prisma/generator-helper": "workspace:*",
|
|
@@ -2505,8 +2504,8 @@ var package_default = {
|
|
|
2505
2504
|
"@prisma/migrate": "workspace:*",
|
|
2506
2505
|
"@prisma/mini-proxy": "0.9.5",
|
|
2507
2506
|
"@prisma/pg-worker": "workspace:*",
|
|
2508
|
-
"@prisma/query-compiler-wasm": "6.6.0-
|
|
2509
|
-
"@prisma/query-engine-wasm": "6.6.0-
|
|
2507
|
+
"@prisma/query-compiler-wasm": "6.6.0-31.d26022ad3b55e2aa7e4ffc189436e4c59aae0c29",
|
|
2508
|
+
"@prisma/query-engine-wasm": "6.6.0-31.d26022ad3b55e2aa7e4ffc189436e4c59aae0c29",
|
|
2510
2509
|
"@prisma/ts-builders": "workspace:*",
|
|
2511
2510
|
"@snaplet/copycat": "6.0.0",
|
|
2512
2511
|
"@swc-node/register": "1.10.9",
|
|
@@ -6773,21 +6772,6 @@ function getTypedSqlRuntimeBase(runtimeBase) {
|
|
|
6773
6772
|
}
|
|
6774
6773
|
return `../${runtimeBase}`;
|
|
6775
6774
|
}
|
|
6776
|
-
async function getDefaultOutdir(outputDir) {
|
|
6777
|
-
if (outputDir.endsWith(path3.normalize("node_modules/@prisma/client"))) {
|
|
6778
|
-
return path3.join(outputDir, "../../.prisma/client");
|
|
6779
|
-
}
|
|
6780
|
-
if (process.env.INIT_CWD && process.env.npm_lifecycle_event === "postinstall" && !process.env.PWD?.includes(".pnpm")) {
|
|
6781
|
-
if (existsSync(path3.join(process.env.INIT_CWD, "package.json"))) {
|
|
6782
|
-
return path3.join(process.env.INIT_CWD, "node_modules/.prisma/client");
|
|
6783
|
-
}
|
|
6784
|
-
const packagePath = await pkgUp({ cwd: process.env.INIT_CWD });
|
|
6785
|
-
if (packagePath) {
|
|
6786
|
-
return path3.join(path3.dirname(packagePath), "node_modules/.prisma/client");
|
|
6787
|
-
}
|
|
6788
|
-
}
|
|
6789
|
-
return path3.join(outputDir, "../../.prisma/client");
|
|
6790
|
-
}
|
|
6791
6775
|
async function generateClient(options) {
|
|
6792
6776
|
const {
|
|
6793
6777
|
datamodel,
|
|
@@ -6851,7 +6835,7 @@ To learn more about how to rename models, check out https://pris.ly/d/naming-mod
|
|
|
6851
6835
|
await (0, import_fs_extra.ensureDir)(path3.join(outputDir, "deno"));
|
|
6852
6836
|
}
|
|
6853
6837
|
await writeFileMap(outputDir, fileMap);
|
|
6854
|
-
if (copyRuntime
|
|
6838
|
+
if (copyRuntime) {
|
|
6855
6839
|
const copiedRuntimeDir = path3.join(outputDir, "runtime");
|
|
6856
6840
|
await (0, import_fs_extra.ensureDir)(copiedRuntimeDir);
|
|
6857
6841
|
await copyRuntimeFiles({
|
|
@@ -6995,79 +6979,20 @@ function validateDmmfAgainstDenylists(prismaClientDmmf) {
|
|
|
6995
6979
|
}
|
|
6996
6980
|
return errorArray.length > 0 ? errorArray : null;
|
|
6997
6981
|
}
|
|
6998
|
-
async function getGenerationDirs({
|
|
6999
|
-
runtimeBase,
|
|
7000
|
-
generator,
|
|
7001
|
-
outputDir,
|
|
7002
|
-
datamodel,
|
|
7003
|
-
schemaPath,
|
|
7004
|
-
testMode
|
|
7005
|
-
}) {
|
|
7006
|
-
const isCustomOutput = generator.isCustomOutput === true;
|
|
6982
|
+
async function getGenerationDirs({ runtimeBase, outputDir, testMode, copyRuntime }) {
|
|
7007
6983
|
const normalizedOutputDir = path3.normalize(outputDir);
|
|
7008
|
-
let userRuntimeImport =
|
|
7009
|
-
let userOutputDir = isCustomOutput ? normalizedOutputDir : await getDefaultOutdir(normalizedOutputDir);
|
|
6984
|
+
let userRuntimeImport = copyRuntime ? "./runtime" : "@prisma/client/runtime";
|
|
7010
6985
|
if (testMode && runtimeBase) {
|
|
7011
|
-
userOutputDir = outputDir;
|
|
7012
6986
|
userRuntimeImport = pathToPosix4(runtimeBase);
|
|
7013
6987
|
}
|
|
7014
|
-
|
|
7015
|
-
await verifyOutputDirectory(userOutputDir, datamodel, schemaPath);
|
|
7016
|
-
}
|
|
7017
|
-
const userPackageRoot = await pkgUp({ cwd: path3.dirname(userOutputDir) });
|
|
6988
|
+
const userPackageRoot = await pkgUp({ cwd: path3.dirname(normalizedOutputDir) });
|
|
7018
6989
|
const userProjectRoot = userPackageRoot ? path3.dirname(userPackageRoot) : process.cwd();
|
|
7019
6990
|
return {
|
|
7020
6991
|
runtimeBase: userRuntimeImport,
|
|
7021
|
-
outputDir:
|
|
6992
|
+
outputDir: normalizedOutputDir,
|
|
7022
6993
|
projectRoot: userProjectRoot
|
|
7023
6994
|
};
|
|
7024
6995
|
}
|
|
7025
|
-
async function verifyOutputDirectory(directory, datamodel, schemaPath) {
|
|
7026
|
-
let content;
|
|
7027
|
-
try {
|
|
7028
|
-
content = await fs.readFile(path3.join(directory, "package.json"), "utf8");
|
|
7029
|
-
} catch (e) {
|
|
7030
|
-
if (e.code === "ENOENT") {
|
|
7031
|
-
return;
|
|
7032
|
-
}
|
|
7033
|
-
throw e;
|
|
7034
|
-
}
|
|
7035
|
-
const { name } = JSON.parse(content);
|
|
7036
|
-
if (name === package_default.name) {
|
|
7037
|
-
const message = [`Generating client into ${bold(directory)} is not allowed.`];
|
|
7038
|
-
message.push("This package is used by `prisma generate` and overwriting its content is dangerous.");
|
|
7039
|
-
message.push("");
|
|
7040
|
-
message.push("Suggestion:");
|
|
7041
|
-
const outputDeclaration = findOutputPathDeclaration(datamodel);
|
|
7042
|
-
if (outputDeclaration && outputDeclaration.content.includes(package_default.name)) {
|
|
7043
|
-
const outputLine = outputDeclaration.content;
|
|
7044
|
-
message.push(`In ${bold(schemaPath)} replace:`);
|
|
7045
|
-
message.push("");
|
|
7046
|
-
message.push(`${dim(outputDeclaration.lineNumber)} ${replacePackageName(outputLine, red(package_default.name))}`);
|
|
7047
|
-
message.push("with");
|
|
7048
|
-
message.push(`${dim(outputDeclaration.lineNumber)} ${replacePackageName(outputLine, green(".prisma/client"))}`);
|
|
7049
|
-
} else {
|
|
7050
|
-
message.push(`Generate client into ${bold(replacePackageName(directory, green(".prisma/client")))} instead`);
|
|
7051
|
-
}
|
|
7052
|
-
message.push("");
|
|
7053
|
-
message.push("You won't need to change your imports.");
|
|
7054
|
-
message.push("Imports from `@prisma/client` will be automatically forwarded to `.prisma/client`");
|
|
7055
|
-
const error = new Error(message.join("\n"));
|
|
7056
|
-
throw error;
|
|
7057
|
-
}
|
|
7058
|
-
}
|
|
7059
|
-
function replacePackageName(directoryPath, replacement) {
|
|
7060
|
-
return directoryPath.replace(package_default.name, replacement);
|
|
7061
|
-
}
|
|
7062
|
-
function findOutputPathDeclaration(datamodel) {
|
|
7063
|
-
const lines = datamodel.split(/\r?\n/);
|
|
7064
|
-
for (const [i, line] of lines.entries()) {
|
|
7065
|
-
if (/output\s*=/.test(line)) {
|
|
7066
|
-
return { lineNumber: i + 1, content: line.trim() };
|
|
7067
|
-
}
|
|
7068
|
-
}
|
|
7069
|
-
return null;
|
|
7070
|
-
}
|
|
7071
6996
|
function getNodeRuntimeName(engineType) {
|
|
7072
6997
|
if (engineType === ClientEngineType3.Binary) {
|
|
7073
6998
|
return "binary";
|
|
@@ -7134,7 +7059,7 @@ import { ClientEngineType as ClientEngineType4, getClientEngineType as getClient
|
|
|
7134
7059
|
import { match } from "ts-pattern";
|
|
7135
7060
|
|
|
7136
7061
|
// package.json
|
|
7137
|
-
var version = "6.6.0-dev.
|
|
7062
|
+
var version = "6.6.0-dev.67";
|
|
7138
7063
|
|
|
7139
7064
|
// src/resolvePrismaClient.ts
|
|
7140
7065
|
import fs2 from "node:fs/promises";
|
|
@@ -7176,36 +7101,47 @@ async function getPackageCmd(cwd, cmd, ...args) {
|
|
|
7176
7101
|
|
|
7177
7102
|
// src/generator.ts
|
|
7178
7103
|
var debug3 = Debug3("prisma:client:generator");
|
|
7104
|
+
var missingOutputErrorMessage = `An output path is required for the \`prisma-client-ts\` generator. Please provide an output path in your schema file:
|
|
7105
|
+
|
|
7106
|
+
${dim(`generator client {
|
|
7107
|
+
provider = "prisma-client-ts"`)}
|
|
7108
|
+
${green(' output = "../src/generated"')}
|
|
7109
|
+
${dim("}")}
|
|
7110
|
+
|
|
7111
|
+
${bold("Note:")} the output path is relative to the schema directory.
|
|
7112
|
+
`;
|
|
7113
|
+
function getOutputPath(config) {
|
|
7114
|
+
if (!config.output) {
|
|
7115
|
+
throw new Error(missingOutputErrorMessage);
|
|
7116
|
+
}
|
|
7117
|
+
return parseEnvValue(config.output);
|
|
7118
|
+
}
|
|
7179
7119
|
var PrismaClientTsGenerator = class {
|
|
7180
7120
|
name = "prisma-client-ts";
|
|
7181
|
-
#shouldResolvePrismaClient = true;
|
|
7182
7121
|
#runtimePath;
|
|
7183
7122
|
#cachedPrismaClientPath;
|
|
7184
|
-
constructor({
|
|
7185
|
-
this.#shouldResolvePrismaClient = shouldResolvePrismaClient;
|
|
7123
|
+
constructor({ runtimePath } = {}) {
|
|
7186
7124
|
this.#runtimePath = runtimePath;
|
|
7187
7125
|
}
|
|
7188
|
-
|
|
7126
|
+
getManifest(config) {
|
|
7189
7127
|
const requiresEngines = match(getClientEngineType3(config)).with(ClientEngineType4.Library, () => ["libqueryEngine"]).with(ClientEngineType4.Binary, () => ["queryEngine"]).with(ClientEngineType4.Client, () => []).exhaustive();
|
|
7190
7128
|
debug3("requiresEngines", requiresEngines);
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
defaultOutput,
|
|
7129
|
+
return Promise.resolve({
|
|
7130
|
+
defaultOutput: getOutputPath(config),
|
|
7194
7131
|
prettyName: "Prisma Client",
|
|
7195
7132
|
version,
|
|
7196
7133
|
requiresEngines,
|
|
7197
7134
|
requiresEngineVersion: enginesVersion
|
|
7198
|
-
};
|
|
7135
|
+
});
|
|
7199
7136
|
}
|
|
7200
7137
|
async generate(options) {
|
|
7201
|
-
const outputDir = parseEnvValue(options.generator.output);
|
|
7202
7138
|
await generateClient({
|
|
7203
7139
|
datamodel: options.datamodel,
|
|
7204
7140
|
schemaPath: options.schemaPath,
|
|
7205
7141
|
binaryPaths: options.binaryPaths,
|
|
7206
7142
|
datasources: options.datasources,
|
|
7207
7143
|
envPaths: options.envPaths,
|
|
7208
|
-
outputDir,
|
|
7144
|
+
outputDir: getOutputPath(options.generator),
|
|
7209
7145
|
copyRuntime: Boolean(options.generator.config.copyRuntime),
|
|
7210
7146
|
copyRuntimeSourceMaps: Boolean(process.env.PRISMA_COPY_RUNTIME_SOURCEMAPS),
|
|
7211
7147
|
runtimeSourcePath: await this.#getRuntimePath(options.generator),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/client-generator-ts",
|
|
3
|
-
"version": "6.6.0-dev.
|
|
3
|
+
"version": "6.6.0-dev.67",
|
|
4
4
|
"description": "This package is intended for Prisma's internal use",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@antfu/ni": "0.21.12",
|
|
28
|
-
"@prisma/engines-version": "6.6.0-
|
|
28
|
+
"@prisma/engines-version": "6.6.0-31.d26022ad3b55e2aa7e4ffc189436e4c59aae0c29",
|
|
29
29
|
"ci-info": "4.2.0",
|
|
30
30
|
"env-paths": "2.2.1",
|
|
31
31
|
"indent-string": "4.0.0",
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"pkg-up": "3.1.0",
|
|
34
34
|
"pluralize": "8.0.0",
|
|
35
35
|
"ts-pattern": "5.6.2",
|
|
36
|
-
"@prisma/client-common": "6.6.0-dev.
|
|
37
|
-
"@prisma/
|
|
38
|
-
"@prisma/
|
|
39
|
-
"@prisma/
|
|
40
|
-
"@prisma/
|
|
41
|
-
"@prisma/
|
|
42
|
-
"@prisma/internals": "6.6.0-dev.
|
|
43
|
-
"@prisma/ts-builders": "6.6.0-dev.
|
|
36
|
+
"@prisma/client-common": "6.6.0-dev.67",
|
|
37
|
+
"@prisma/debug": "6.6.0-dev.67",
|
|
38
|
+
"@prisma/dmmf": "6.6.0-dev.67",
|
|
39
|
+
"@prisma/fetch-engine": "6.6.0-dev.67",
|
|
40
|
+
"@prisma/generator": "6.6.0-dev.67",
|
|
41
|
+
"@prisma/get-platform": "6.6.0-dev.67",
|
|
42
|
+
"@prisma/internals": "6.6.0-dev.67",
|
|
43
|
+
"@prisma/ts-builders": "6.6.0-dev.67"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/pluralize": "0.0.33",
|