@tsed/prisma 7.27.2 → 7.29.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/lib/esm/cli/dev.js +9 -7
- package/lib/esm/cli/generator.js +8 -7
- package/lib/esm/cli/prismaGenerator.js +21 -23
- package/lib/esm/generator/domain/DmmfEnum.js +28 -30
- package/lib/esm/generator/domain/DmmfField.js +37 -40
- package/lib/esm/generator/domain/DmmfModel.js +68 -70
- package/lib/esm/generator/domain/ScalarTsTypes.js +43 -43
- package/lib/esm/generator/domain/TransformContext.js +2 -1
- package/lib/esm/generator/generateCode.js +27 -27
- package/lib/esm/generator/transform/transformEnumsToEnums.js +14 -13
- package/lib/esm/generator/transform/transformFieldToDecorators.js +45 -44
- package/lib/esm/generator/transform/transformFieldToProperty.js +9 -8
- package/lib/esm/generator/transform/transformModelToClass.js +12 -11
- package/lib/esm/generator/transform/transformScalarToType.js +33 -37
- package/lib/esm/generator/utils/generateClientIndex.js +7 -8
- package/lib/esm/generator/utils/generateDocuments.js +10 -11
- package/lib/esm/generator/utils/generateEnums.js +12 -13
- package/lib/esm/generator/utils/generateIndex.js +20 -15
- package/lib/esm/generator/utils/generateInterfaces.js +26 -23
- package/lib/esm/generator/utils/generateModels.js +14 -15
- package/lib/esm/generator/utils/generateOutputsBarrelFile.js +7 -6
- package/lib/esm/generator/utils/generatePrismaService.js +72 -55
- package/lib/esm/generator/utils/generateRepositories.js +161 -148
- package/lib/esm/generator/utils/isCircularRef.js +21 -20
- package/lib/esm/generator/utils/parseDocumentationAttributes.js +48 -37
- package/lib/esm/generator/utils/removeDir.js +10 -11
- package/lib/esm/generator/utils/saveProject.js +6 -7
- package/lib/esm/generator.js +2 -1
- package/lib/esm/index.js +2 -1
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -13
package/lib/esm/cli/dev.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
try {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
require("tsconfig-paths/register");
|
|
4
|
+
require("ts-node/register/transpile-only");
|
|
5
|
+
require("./generator");
|
|
6
|
+
}
|
|
7
|
+
catch (er) {
|
|
8
|
+
console.log(er);
|
|
9
|
+
process.exit(-1);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=dev.js.map
|
package/lib/esm/cli/generator.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { generatorHandler } from "@prisma/generator-helper";
|
|
2
2
|
import { generate, defaultOutput } from "./prismaGenerator.js";
|
|
3
3
|
generatorHandler({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
4
|
+
onManifest: () => ({
|
|
5
|
+
defaultOutput,
|
|
6
|
+
prettyName: "Ts.ED integration",
|
|
7
|
+
requiresGenerators: ["prisma-client-js"]
|
|
8
|
+
}),
|
|
9
|
+
onGenerate: generate
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
__dirname = "/home/runner/work/tsed/tsed/packages/orm/prisma/lib/esm/cli";
|
|
2
1
|
import { parseEnvValue } from "@prisma/internals";
|
|
3
2
|
import fs from "fs-extra";
|
|
4
3
|
import { generateCode } from "../generator/generateCode.js";
|
|
@@ -8,29 +7,28 @@ const rootDir = __dirname;
|
|
|
8
7
|
export const defaultOutput = join(rootDir, "..", ".schema");
|
|
9
8
|
export const packageDir = join(rootDir, "..", "..", "..");
|
|
10
9
|
function parseStringBoolean(stringBoolean) {
|
|
11
|
-
|
|
10
|
+
return Boolean(stringBoolean ? stringBoolean === "true" : undefined);
|
|
12
11
|
}
|
|
13
12
|
function toUnixPath(maybeWindowsPath) {
|
|
14
|
-
|
|
13
|
+
return maybeWindowsPath.split("\\").join("/");
|
|
15
14
|
}
|
|
16
15
|
export async function generate(options) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
16
|
+
const outputDir = parseEnvValue(options.generator.output);
|
|
17
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
18
|
+
await removeDir(outputDir, true);
|
|
19
|
+
const generatorConfig = options.generator.config;
|
|
20
|
+
const prismaClientProvider = options.otherGenerators.find((it) => parseEnvValue(it.provider) === "prisma-client-js");
|
|
21
|
+
const prismaClientPath = parseEnvValue(prismaClientProvider.output);
|
|
22
|
+
await generateCode(options.dmmf, {
|
|
23
|
+
emitTranspiledCode: parseStringBoolean(generatorConfig.emitTranspiledCode),
|
|
24
|
+
outputDirPath: outputDir,
|
|
25
|
+
prismaClientPath: prismaClientPath.includes("node_modules") ? "@prisma/client" : toUnixPath(path.relative(outputDir, prismaClientPath))
|
|
26
|
+
});
|
|
27
|
+
if (outputDir === defaultOutput) {
|
|
28
|
+
await fs.copy(join(packageDir, "scripts", "backup-index.cjs.js"), join(packageDir, "lib", "cjs", "index.js"));
|
|
29
|
+
await fs.copy(join(packageDir, "scripts", "backup-index.esm.js"), join(packageDir, "lib", "esm", "index.js"));
|
|
30
|
+
await fs.copy(join(packageDir, "scripts", "backup-index.d.ts"), join(packageDir, "lib", "types", "index.d.ts"));
|
|
31
|
+
}
|
|
32
|
+
return "";
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=prismaGenerator.js.map
|
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
export class DmmfEnum {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
}
|
|
2
|
+
model;
|
|
3
|
+
modelType;
|
|
4
|
+
#imports = new Map();
|
|
5
|
+
constructor({ model, modelType }) {
|
|
6
|
+
this.model = model;
|
|
7
|
+
this.modelType = modelType;
|
|
8
|
+
}
|
|
9
|
+
get name() {
|
|
10
|
+
return this.model.name;
|
|
11
|
+
}
|
|
12
|
+
get values() {
|
|
13
|
+
return this.modelType.values;
|
|
14
|
+
}
|
|
15
|
+
static getEnums(dmmf, enumsMap) {
|
|
16
|
+
const enums = dmmf.schema.enumTypes.model || [];
|
|
17
|
+
return enums.map((modelType) => new DmmfEnum({
|
|
18
|
+
modelType,
|
|
19
|
+
model: enumsMap.get(modelType.name)
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
static symbolName(name) {
|
|
23
|
+
return `${name}`;
|
|
24
|
+
}
|
|
25
|
+
toString() {
|
|
26
|
+
return DmmfEnum.symbolName(this.name);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=DmmfEnum.js.map
|
|
@@ -1,42 +1,39 @@
|
|
|
1
1
|
import { parseDocumentationAttributes } from "../utils/parseDocumentationAttributes.js";
|
|
2
2
|
export class DmmfField {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return this.name;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
3
|
+
model;
|
|
4
|
+
field;
|
|
5
|
+
schemaArg;
|
|
6
|
+
constructor({ field, schemaArg, model }) {
|
|
7
|
+
this.field = field;
|
|
8
|
+
this.model = model;
|
|
9
|
+
this.schemaArg = schemaArg;
|
|
10
|
+
}
|
|
11
|
+
get name() {
|
|
12
|
+
return this.field.name;
|
|
13
|
+
}
|
|
14
|
+
get isRequired() {
|
|
15
|
+
return this.field.isRequired;
|
|
16
|
+
}
|
|
17
|
+
get type() {
|
|
18
|
+
return this.field.type;
|
|
19
|
+
}
|
|
20
|
+
get isList() {
|
|
21
|
+
return this.field.isList;
|
|
22
|
+
}
|
|
23
|
+
get kind() {
|
|
24
|
+
return this.field.kind;
|
|
25
|
+
}
|
|
26
|
+
get isNullable() {
|
|
27
|
+
return this.schemaArg.isNullable;
|
|
28
|
+
}
|
|
29
|
+
get location() {
|
|
30
|
+
return this.field.kind === "enum" ? "enumTypes" : this.field.kind === "object" ? "inputObjectTypes" : "scalar";
|
|
31
|
+
}
|
|
32
|
+
getAdditionalDecorators() {
|
|
33
|
+
return parseDocumentationAttributes(this.field.documentation);
|
|
34
|
+
}
|
|
35
|
+
toString() {
|
|
36
|
+
return this.name;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=DmmfField.js.map
|
|
@@ -3,76 +3,74 @@ import { StructureKind } from "ts-morph";
|
|
|
3
3
|
import { DmmfField } from "./DmmfField.js";
|
|
4
4
|
import { pascalCase } from "change-case";
|
|
5
5
|
export class DmmfModel {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
model: this,
|
|
27
|
-
field,
|
|
28
|
-
schemaArg: dataField.get(field.name)
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
get importDeclarations() {
|
|
33
|
-
return [...this.#imports.values()];
|
|
34
|
-
}
|
|
35
|
-
static getModels(dmmf, modelsMap, typesMap) {
|
|
36
|
-
const inputObjectsTypes = dmmf.schema.inputObjectTypes.model || [];
|
|
37
|
-
const outputObjectTypes = dmmf.schema.outputObjectTypes.model || [];
|
|
38
|
-
const factory = isInputType => modelType => {
|
|
39
|
-
let model = modelsMap.get(modelType.name) || typesMap?.get(modelType.name);
|
|
40
|
-
if (model) {
|
|
41
|
-
return new DmmfModel({
|
|
42
|
-
modelType,
|
|
43
|
-
model,
|
|
44
|
-
isInputType
|
|
6
|
+
isInputType;
|
|
7
|
+
model;
|
|
8
|
+
modelType;
|
|
9
|
+
#imports = new Map();
|
|
10
|
+
constructor({ isInputType, model, modelType }) {
|
|
11
|
+
this.model = model;
|
|
12
|
+
this.modelType = modelType;
|
|
13
|
+
this.isInputType = isInputType;
|
|
14
|
+
}
|
|
15
|
+
get name() {
|
|
16
|
+
return this.model.name;
|
|
17
|
+
}
|
|
18
|
+
get fields() {
|
|
19
|
+
const dataField = toMap(this.modelType.fields, "name");
|
|
20
|
+
return this.model.fields.map((field) => {
|
|
21
|
+
return new DmmfField({
|
|
22
|
+
model: this,
|
|
23
|
+
field,
|
|
24
|
+
schemaArg: dataField.get(field.name)
|
|
25
|
+
});
|
|
45
26
|
});
|
|
46
|
-
}
|
|
47
|
-
return undefined;
|
|
48
|
-
};
|
|
49
|
-
const inputs = inputObjectsTypes.map(factory(true)).filter(Boolean);
|
|
50
|
-
const outputs = outputObjectTypes.map(factory(false)).filter(Boolean);
|
|
51
|
-
return [...inputs, ...outputs];
|
|
52
|
-
}
|
|
53
|
-
static symbolName(name) {
|
|
54
|
-
return pascalCase(`${name}Model`);
|
|
55
|
-
}
|
|
56
|
-
addImportDeclaration(moduleSpecifier, name, isDefault = false) {
|
|
57
|
-
if (!this.#imports.has(moduleSpecifier)) {
|
|
58
|
-
this.#imports.set(moduleSpecifier, {
|
|
59
|
-
kind: StructureKind.ImportDeclaration,
|
|
60
|
-
moduleSpecifier: moduleSpecifier,
|
|
61
|
-
namedImports: []
|
|
62
|
-
});
|
|
63
27
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
28
|
+
get importDeclarations() {
|
|
29
|
+
return [...this.#imports.values()];
|
|
30
|
+
}
|
|
31
|
+
static getModels(dmmf, modelsMap, typesMap) {
|
|
32
|
+
const inputObjectsTypes = dmmf.schema.inputObjectTypes.model || [];
|
|
33
|
+
const outputObjectTypes = dmmf.schema.outputObjectTypes.model || [];
|
|
34
|
+
const factory = (isInputType) => (modelType) => {
|
|
35
|
+
let model = modelsMap.get(modelType.name) || typesMap?.get(modelType.name);
|
|
36
|
+
if (model) {
|
|
37
|
+
return new DmmfModel({
|
|
38
|
+
modelType,
|
|
39
|
+
model,
|
|
40
|
+
isInputType
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
};
|
|
45
|
+
const inputs = inputObjectsTypes.map(factory(true)).filter(Boolean);
|
|
46
|
+
const outputs = outputObjectTypes.map(factory(false)).filter(Boolean);
|
|
47
|
+
return [...inputs, ...outputs];
|
|
48
|
+
}
|
|
49
|
+
static symbolName(name) {
|
|
50
|
+
return pascalCase(`${name}Model`);
|
|
51
|
+
}
|
|
52
|
+
addImportDeclaration(moduleSpecifier, name, isDefault = false) {
|
|
53
|
+
if (!this.#imports.has(moduleSpecifier)) {
|
|
54
|
+
this.#imports.set(moduleSpecifier, {
|
|
55
|
+
kind: StructureKind.ImportDeclaration,
|
|
56
|
+
moduleSpecifier: moduleSpecifier,
|
|
57
|
+
namedImports: []
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const moduleDeclaration = this.#imports.get(moduleSpecifier);
|
|
61
|
+
if (isDefault) {
|
|
62
|
+
moduleDeclaration.defaultImport = name;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const nameImports = moduleDeclaration.namedImports;
|
|
66
|
+
if (!nameImports.includes(name)) {
|
|
67
|
+
nameImports.push(name);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
toString() {
|
|
73
|
+
return DmmfModel.symbolName(this.name);
|
|
72
74
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
toString() {
|
|
76
|
-
return DmmfModel.symbolName(this.name);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=DmmfModel.js.map
|
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
export var PrismaScalars;
|
|
2
2
|
(function (PrismaScalars) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
PrismaScalars["String"] = "String";
|
|
4
|
+
PrismaScalars["Boolean"] = "Boolean";
|
|
5
|
+
PrismaScalars["Int"] = "Int";
|
|
6
|
+
PrismaScalars["Float"] = "Float";
|
|
7
|
+
PrismaScalars["BigInt"] = "BigInt";
|
|
8
|
+
PrismaScalars["Decimal"] = "Decimal";
|
|
9
|
+
PrismaScalars["DateTime"] = "DateTime";
|
|
10
|
+
PrismaScalars["Json"] = "Json";
|
|
11
|
+
PrismaScalars["Bytes"] = "Bytes";
|
|
12
12
|
})(PrismaScalars || (PrismaScalars = {}));
|
|
13
13
|
export const ScalarTsTypes = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
[PrismaScalars.String]: "string",
|
|
15
|
+
[PrismaScalars.Boolean]: "boolean",
|
|
16
|
+
[PrismaScalars.Int]: "number",
|
|
17
|
+
[PrismaScalars.Float]: "number",
|
|
18
|
+
[PrismaScalars.Decimal]: "number",
|
|
19
|
+
[PrismaScalars.BigInt]: "bigint",
|
|
20
|
+
[PrismaScalars.DateTime]: "Date",
|
|
21
|
+
[PrismaScalars.Json]: "any",
|
|
22
|
+
[PrismaScalars.Bytes]: "Buffer"
|
|
23
23
|
};
|
|
24
24
|
export const ScalarJsClasses = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
[PrismaScalars.String]: "String",
|
|
26
|
+
[PrismaScalars.Boolean]: "Boolean",
|
|
27
|
+
[PrismaScalars.Int]: "Number",
|
|
28
|
+
[PrismaScalars.Float]: "Number",
|
|
29
|
+
[PrismaScalars.Decimal]: "Number",
|
|
30
|
+
[PrismaScalars.BigInt]: "BigInt",
|
|
31
|
+
[PrismaScalars.DateTime]: "Date",
|
|
32
|
+
[PrismaScalars.Json]: "Object",
|
|
33
|
+
[PrismaScalars.Bytes]: "Buffer"
|
|
34
34
|
};
|
|
35
35
|
export const ScalarDecorators = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
arguments: ['"date-time"']
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
[PrismaScalars.String]: [],
|
|
37
|
+
[PrismaScalars.Boolean]: [],
|
|
38
|
+
[PrismaScalars.Int]: [
|
|
39
|
+
{
|
|
40
|
+
name: "Integer",
|
|
41
|
+
arguments: []
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
[PrismaScalars.Float]: [],
|
|
45
|
+
[PrismaScalars.BigInt]: [],
|
|
46
|
+
[PrismaScalars.Decimal]: [],
|
|
47
|
+
[PrismaScalars.DateTime]: [{ name: "Format", arguments: ['"date-time"'] }],
|
|
48
|
+
[PrismaScalars.Json]: [],
|
|
49
|
+
[PrismaScalars.Bytes]: []
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=ScalarTsTypes.js.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=TransformContext.js.map
|
|
@@ -8,33 +8,33 @@ import { generatePrismaService } from "./utils/generatePrismaService.js";
|
|
|
8
8
|
import { generateRepositories } from "./utils/generateRepositories.js";
|
|
9
9
|
import { saveProject } from "./utils/saveProject.js";
|
|
10
10
|
const baseCompilerOptions = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
target: ScriptTarget.ES2019,
|
|
12
|
+
module: ModuleKind.CommonJS,
|
|
13
|
+
emitDecoratorMetadata: true,
|
|
14
|
+
experimentalDecorators: true,
|
|
15
|
+
esModuleInterop: true
|
|
16
16
|
};
|
|
17
17
|
export async function generateCode(dmmf, options) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
const baseDirPath = options.outputDirPath;
|
|
19
|
+
const emitTranspiledCode = options.emitTranspiledCode ? true : options.outputDirPath.includes("node_modules");
|
|
20
|
+
const project = new Project({
|
|
21
|
+
compilerOptions: {
|
|
22
|
+
...baseCompilerOptions,
|
|
23
|
+
...(emitTranspiledCode && { declaration: true })
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const hasEnum = generateEnums(dmmf, project, baseDirPath);
|
|
27
|
+
generateModels(dmmf, project, baseDirPath);
|
|
28
|
+
generateInterfaces(project, baseDirPath);
|
|
29
|
+
generateClientIndex(project, baseDirPath, options);
|
|
30
|
+
generatePrismaService(project, baseDirPath);
|
|
31
|
+
generateRepositories(dmmf, project, baseDirPath);
|
|
32
|
+
generateIndex(project, baseDirPath, hasEnum);
|
|
33
|
+
if (emitTranspiledCode) {
|
|
34
|
+
await project.emit();
|
|
26
35
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
generatePrismaService(project, baseDirPath);
|
|
33
|
-
generateRepositories(dmmf, project, baseDirPath);
|
|
34
|
-
generateIndex(project, baseDirPath, hasEnum);
|
|
35
|
-
if (emitTranspiledCode) {
|
|
36
|
-
await project.emit();
|
|
37
|
-
} else {
|
|
38
|
-
await saveProject(project);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
36
|
+
else {
|
|
37
|
+
await saveProject(project);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=generateCode.js.map
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { StructureKind } from "ts-morph";
|
|
2
2
|
export function transformEnumsToEnums(enumModel) {
|
|
3
|
-
|
|
3
|
+
const members = enumModel.values.map((value) => {
|
|
4
|
+
return {
|
|
5
|
+
name: value,
|
|
6
|
+
value: value
|
|
7
|
+
};
|
|
8
|
+
});
|
|
4
9
|
return {
|
|
5
|
-
|
|
6
|
-
|
|
10
|
+
kind: StructureKind.Enum,
|
|
11
|
+
name: enumModel.toString(),
|
|
12
|
+
trailingTrivia: "\n",
|
|
13
|
+
leadingTrivia: "\n",
|
|
14
|
+
isExported: true,
|
|
15
|
+
members
|
|
7
16
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
kind: StructureKind.Enum,
|
|
11
|
-
name: enumModel.toString(),
|
|
12
|
-
trailingTrivia: "\n",
|
|
13
|
-
leadingTrivia: "\n",
|
|
14
|
-
isExported: true,
|
|
15
|
-
members
|
|
16
|
-
};
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=transformEnumsToEnums.js.map
|