prisma-nestjs-graphql 14.7.1 → 15.1.1
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/README.md +3 -23
- package/bin.js +2 -0
- package/index.js +59 -99
- package/package.json +18 -18
package/README.md
CHANGED
|
@@ -21,6 +21,8 @@ npm install --save-dev prisma-nestjs-graphql
|
|
|
21
21
|
```prisma
|
|
22
22
|
generator nestgraphql {
|
|
23
23
|
provider = "node node_modules/prisma-nestjs-graphql"
|
|
24
|
+
// for yarn monorepos
|
|
25
|
+
// provider = "prisma-nestjs-graphql"
|
|
24
26
|
output = "../src/@generated/prisma-nestjs-graphql"
|
|
25
27
|
}
|
|
26
28
|
```
|
|
@@ -556,29 +558,7 @@ Similar to `@FieldType()` but refer to TypeScript property (actually field too).
|
|
|
556
558
|
To override TypeScript type in specific classes, you can use glob pattern `match: string | string[]`
|
|
557
559
|
see [outmatch](https://github.com/axtgr/outmatch#usage) for details.
|
|
558
560
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
```prisma
|
|
562
|
-
model Transfer {
|
|
563
|
-
id String @id
|
|
564
|
-
/// @PropertyType({ name: 'Prisma.Decimal', from: '@prisma/client', namedImport: true })
|
|
565
|
-
money Decimal
|
|
566
|
-
}
|
|
567
|
-
```
|
|
568
|
-
|
|
569
|
-
May generate following:
|
|
570
|
-
|
|
571
|
-
```ts
|
|
572
|
-
import { Prisma } from '@prisma/client';
|
|
573
|
-
|
|
574
|
-
@ObjectType()
|
|
575
|
-
export class User {
|
|
576
|
-
@Field(() => GraphQLDecimal)
|
|
577
|
-
money!: Prisma.Decimal;
|
|
578
|
-
}
|
|
579
|
-
```
|
|
580
|
-
|
|
581
|
-
Another example:
|
|
561
|
+
Example:
|
|
582
562
|
|
|
583
563
|
```
|
|
584
564
|
generator nestgraphql {
|
package/bin.js
ADDED
package/index.js
CHANGED
|
@@ -1,39 +1,19 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
26
|
-
var
|
|
27
|
-
if (
|
|
28
|
-
for (let key of __getOwnPropNames(
|
|
29
|
-
if (!__hasOwnProp.call(
|
|
30
|
-
__defProp(
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
31
13
|
}
|
|
32
|
-
return
|
|
33
|
-
};
|
|
34
|
-
var __toESM = (module2, isNodeMode) => {
|
|
35
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
14
|
+
return to;
|
|
36
15
|
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
37
17
|
|
|
38
18
|
// src/index.ts
|
|
39
19
|
var import_generator_helper = require("@prisma/generator-helper");
|
|
@@ -49,7 +29,6 @@ var import_lodash = require("lodash");
|
|
|
49
29
|
function pascalCase(string) {
|
|
50
30
|
return (0, import_lodash.startCase)((0, import_lodash.camelCase)(string)).replace(/ /g, "");
|
|
51
31
|
}
|
|
52
|
-
__name(pascalCase, "pascalCase");
|
|
53
32
|
|
|
54
33
|
// src/handlers/args-type.ts
|
|
55
34
|
function argsType(field, args) {
|
|
@@ -115,27 +94,25 @@ function argsType(field, args) {
|
|
|
115
94
|
});
|
|
116
95
|
}
|
|
117
96
|
}
|
|
118
|
-
eventEmitter.emitSync("InputType",
|
|
97
|
+
eventEmitter.emitSync("InputType", {
|
|
98
|
+
...args,
|
|
119
99
|
inputType: inputType1,
|
|
120
100
|
fileType: "args",
|
|
121
101
|
classDecoratorName: "ArgsType"
|
|
122
|
-
})
|
|
102
|
+
});
|
|
123
103
|
}
|
|
124
|
-
__name(argsType, "argsType");
|
|
125
104
|
|
|
126
105
|
// src/handlers/combine-scalar-filters.ts
|
|
127
106
|
function combineScalarFilters(eventEmitter) {
|
|
128
107
|
eventEmitter.on("BeforeInputType", beforeInputType);
|
|
129
108
|
eventEmitter.on("BeforeGenerateField", beforeGenerateField);
|
|
130
109
|
}
|
|
131
|
-
__name(combineScalarFilters, "combineScalarFilters");
|
|
132
110
|
function beforeInputType(args) {
|
|
133
111
|
const { inputType: inputType2 } = args;
|
|
134
112
|
if (isContainBogus(inputType2.name) && isScalarFilter(inputType2)) {
|
|
135
113
|
inputType2.name = replaceBogus(String(inputType2.name));
|
|
136
114
|
}
|
|
137
115
|
}
|
|
138
|
-
__name(beforeInputType, "beforeInputType");
|
|
139
116
|
function beforeGenerateField(field) {
|
|
140
117
|
for (const fieldInput of field.inputTypes) {
|
|
141
118
|
if (fieldInput.location !== "inputObjectTypes") {
|
|
@@ -147,15 +124,12 @@ function beforeGenerateField(field) {
|
|
|
147
124
|
}
|
|
148
125
|
}
|
|
149
126
|
}
|
|
150
|
-
__name(beforeGenerateField, "beforeGenerateField");
|
|
151
127
|
function replaceBogus(name) {
|
|
152
128
|
return name.replace(/(Nullable|Nested)/g, "");
|
|
153
129
|
}
|
|
154
|
-
__name(replaceBogus, "replaceBogus");
|
|
155
130
|
function isContainBogus(name) {
|
|
156
131
|
return name.startsWith("Nested") || name.includes("Nullable") && name.endsWith("Filter") || name.endsWith("NullableFilter");
|
|
157
132
|
}
|
|
158
|
-
__name(isContainBogus, "isContainBogus");
|
|
159
133
|
function isScalarFilter(inputType2) {
|
|
160
134
|
if (!inputType2.name.endsWith("Filter")) {
|
|
161
135
|
return false;
|
|
@@ -172,7 +146,6 @@ function isScalarFilter(inputType2) {
|
|
|
172
146
|
}
|
|
173
147
|
return result;
|
|
174
148
|
}
|
|
175
|
-
__name(isScalarFilter, "isScalarFilter");
|
|
176
149
|
|
|
177
150
|
// src/handlers/create-aggregate-input.ts
|
|
178
151
|
function createAggregateInput(args) {
|
|
@@ -200,19 +173,18 @@ function createAggregateInput(args) {
|
|
|
200
173
|
};
|
|
201
174
|
})
|
|
202
175
|
};
|
|
203
|
-
eventEmitter.emitSync("InputType",
|
|
176
|
+
eventEmitter.emitSync("InputType", {
|
|
177
|
+
...args,
|
|
204
178
|
inputType: inputType2,
|
|
205
179
|
fileType: "input",
|
|
206
180
|
classDecoratorName: "InputType"
|
|
207
|
-
})
|
|
181
|
+
});
|
|
208
182
|
}
|
|
209
|
-
__name(createAggregateInput, "createAggregateInput");
|
|
210
183
|
|
|
211
184
|
// src/handlers/emit-single.ts
|
|
212
185
|
function emitSingle(emitter) {
|
|
213
186
|
emitter.on("ClassProperty", classProperty);
|
|
214
187
|
}
|
|
215
|
-
__name(emitSingle, "emitSingle");
|
|
216
188
|
function classProperty(property, eventArguments) {
|
|
217
189
|
const { location, isList, propertyType } = eventArguments;
|
|
218
190
|
if ([
|
|
@@ -226,7 +198,6 @@ function classProperty(property, eventArguments) {
|
|
|
226
198
|
}
|
|
227
199
|
}
|
|
228
200
|
}
|
|
229
|
-
__name(classProperty, "classProperty");
|
|
230
201
|
|
|
231
202
|
// src/handlers/generate-files.ts
|
|
232
203
|
var import_assert = require("assert");
|
|
@@ -283,14 +254,14 @@ var ImportDeclarationMap = class extends Map {
|
|
|
283
254
|
const iterator = this.values();
|
|
284
255
|
let result = iterator.next();
|
|
285
256
|
while (result.value) {
|
|
286
|
-
yield
|
|
257
|
+
yield {
|
|
258
|
+
...result.value,
|
|
287
259
|
kind: import_ts_morph.StructureKind.ImportDeclaration
|
|
288
|
-
}
|
|
260
|
+
};
|
|
289
261
|
result = iterator.next();
|
|
290
262
|
}
|
|
291
263
|
}
|
|
292
264
|
};
|
|
293
|
-
__name(ImportDeclarationMap, "ImportDeclarationMap");
|
|
294
265
|
|
|
295
266
|
// src/handlers/generate-files.ts
|
|
296
267
|
async function generateFiles(args) {
|
|
@@ -393,7 +364,6 @@ async function generateFiles(args) {
|
|
|
393
364
|
await project.save();
|
|
394
365
|
}
|
|
395
366
|
}
|
|
396
|
-
__name(generateFiles, "generateFiles");
|
|
397
367
|
|
|
398
368
|
// src/handlers/input-type.ts
|
|
399
369
|
var import_assert2 = require("assert");
|
|
@@ -414,7 +384,6 @@ function fileTypeByLocation(fieldLocation) {
|
|
|
414
384
|
}
|
|
415
385
|
return "object";
|
|
416
386
|
}
|
|
417
|
-
__name(fileTypeByLocation, "fileTypeByLocation");
|
|
418
387
|
|
|
419
388
|
// src/helpers/relative-path.ts
|
|
420
389
|
var import_get_relative_path = __toESM(require("get-relative-path"));
|
|
@@ -434,7 +403,6 @@ function relativePath(from, to) {
|
|
|
434
403
|
}
|
|
435
404
|
return result;
|
|
436
405
|
}
|
|
437
|
-
__name(relativePath, "relativePath");
|
|
438
406
|
|
|
439
407
|
// src/helpers/get-graphql-import.ts
|
|
440
408
|
function getGraphqlImport(args) {
|
|
@@ -500,7 +468,6 @@ function getGraphqlImport(args) {
|
|
|
500
468
|
specifier
|
|
501
469
|
};
|
|
502
470
|
}
|
|
503
|
-
__name(getGraphqlImport, "getGraphqlImport");
|
|
504
471
|
|
|
505
472
|
// src/helpers/get-graphql-input-type.ts
|
|
506
473
|
var import_lodash2 = require("lodash");
|
|
@@ -550,7 +517,6 @@ function getGraphqlInputType(inputTypes, pattern) {
|
|
|
550
517
|
}
|
|
551
518
|
throw new TypeError(`Cannot get matching input type from ${inputTypes.map((x) => x.type).join(", ") || "zero length inputTypes"}`);
|
|
552
519
|
}
|
|
553
|
-
__name(getGraphqlInputType, "getGraphqlInputType");
|
|
554
520
|
|
|
555
521
|
// src/helpers/get-property-type.ts
|
|
556
522
|
function getPropertyType(args) {
|
|
@@ -575,6 +541,9 @@ function getPropertyType(args) {
|
|
|
575
541
|
"string"
|
|
576
542
|
];
|
|
577
543
|
case "Decimal":
|
|
544
|
+
return [
|
|
545
|
+
"Decimal"
|
|
546
|
+
];
|
|
578
547
|
case "Json":
|
|
579
548
|
return [
|
|
580
549
|
"any"
|
|
@@ -615,7 +584,6 @@ function getPropertyType(args) {
|
|
|
615
584
|
"unknown"
|
|
616
585
|
];
|
|
617
586
|
}
|
|
618
|
-
__name(getPropertyType, "getPropertyType");
|
|
619
587
|
|
|
620
588
|
// src/helpers/property-structure.ts
|
|
621
589
|
var import_ts_morph3 = require("ts-morph");
|
|
@@ -632,7 +600,6 @@ function propertyStructure(args) {
|
|
|
632
600
|
leadingTrivia: "\n"
|
|
633
601
|
};
|
|
634
602
|
}
|
|
635
|
-
__name(propertyStructure, "propertyStructure");
|
|
636
603
|
|
|
637
604
|
// src/handlers/input-type.ts
|
|
638
605
|
function inputType(args) {
|
|
@@ -702,7 +669,11 @@ function inputType(args) {
|
|
|
702
669
|
});
|
|
703
670
|
classStructure.properties.push(property);
|
|
704
671
|
if (propertySettings) {
|
|
705
|
-
importDeclarations.create(
|
|
672
|
+
importDeclarations.create({
|
|
673
|
+
...propertySettings
|
|
674
|
+
});
|
|
675
|
+
} else if (!propertySettings && propertyType.includes("Decimal")) {
|
|
676
|
+
importDeclarations.add("Decimal", "@prisma/client/runtime");
|
|
706
677
|
}
|
|
707
678
|
let graphqlType;
|
|
708
679
|
const shouldHideField = settings == null ? void 0 : settings.shouldHideField({
|
|
@@ -715,7 +686,9 @@ function inputType(args) {
|
|
|
715
686
|
});
|
|
716
687
|
if (fieldType && isCustomsApplicable && !shouldHideField) {
|
|
717
688
|
graphqlType = fieldType.name;
|
|
718
|
-
importDeclarations.create(
|
|
689
|
+
importDeclarations.create({
|
|
690
|
+
...fieldType
|
|
691
|
+
});
|
|
719
692
|
} else {
|
|
720
693
|
const graphqlImport = getGraphqlImport({
|
|
721
694
|
config,
|
|
@@ -794,7 +767,6 @@ function inputType(args) {
|
|
|
794
767
|
]
|
|
795
768
|
});
|
|
796
769
|
}
|
|
797
|
-
__name(inputType, "inputType");
|
|
798
770
|
|
|
799
771
|
// src/helpers/object-settings.ts
|
|
800
772
|
var import_json52 = __toESM(require("json5"));
|
|
@@ -822,12 +794,18 @@ var ObjectSettings = class extends Array {
|
|
|
822
794
|
}
|
|
823
795
|
return fieldType;
|
|
824
796
|
}
|
|
825
|
-
getPropertyType({ name }) {
|
|
797
|
+
getPropertyType({ name, input, output }) {
|
|
826
798
|
const propertyType = this.find((s) => s.kind === "PropertyType");
|
|
827
799
|
if (!propertyType) {
|
|
828
800
|
return void 0;
|
|
829
801
|
}
|
|
830
|
-
if (propertyType.match
|
|
802
|
+
if (propertyType.match) {
|
|
803
|
+
return propertyType.match(name) ? propertyType : void 0;
|
|
804
|
+
}
|
|
805
|
+
if (input && !propertyType.input) {
|
|
806
|
+
return void 0;
|
|
807
|
+
}
|
|
808
|
+
if (output && !propertyType.output) {
|
|
831
809
|
return void 0;
|
|
832
810
|
}
|
|
833
811
|
return propertyType;
|
|
@@ -848,7 +826,6 @@ var ObjectSettings = class extends Array {
|
|
|
848
826
|
return resultArguments.map((x) => import_json52.default.stringify(x));
|
|
849
827
|
}
|
|
850
828
|
};
|
|
851
|
-
__name(ObjectSettings, "ObjectSettings");
|
|
852
829
|
function createObjectSettings(args) {
|
|
853
830
|
var _a, _b, _c, _d, _e;
|
|
854
831
|
const { config, text } = args;
|
|
@@ -921,7 +898,6 @@ function createObjectSettings(args) {
|
|
|
921
898
|
documentation: documentationLines.filter(Boolean).join("\\n") || void 0
|
|
922
899
|
};
|
|
923
900
|
}
|
|
924
|
-
__name(createObjectSettings, "createObjectSettings");
|
|
925
901
|
function customType(args) {
|
|
926
902
|
var _a;
|
|
927
903
|
const result = {};
|
|
@@ -944,7 +920,6 @@ function customType(args) {
|
|
|
944
920
|
}
|
|
945
921
|
return result;
|
|
946
922
|
}
|
|
947
|
-
__name(customType, "customType");
|
|
948
923
|
function hideFieldDecorator(match) {
|
|
949
924
|
var _a;
|
|
950
925
|
const result = {
|
|
@@ -978,7 +953,6 @@ function hideFieldDecorator(match) {
|
|
|
978
953
|
}
|
|
979
954
|
return result;
|
|
980
955
|
}
|
|
981
|
-
__name(hideFieldDecorator, "hideFieldDecorator");
|
|
982
956
|
function parseArgs(string) {
|
|
983
957
|
try {
|
|
984
958
|
return import_json52.default.parse(string);
|
|
@@ -990,7 +964,6 @@ function parseArgs(string) {
|
|
|
990
964
|
}
|
|
991
965
|
}
|
|
992
966
|
}
|
|
993
|
-
__name(parseArgs, "parseArgs");
|
|
994
967
|
function getNamespace(name) {
|
|
995
968
|
if (name === void 0) {
|
|
996
969
|
return void 0;
|
|
@@ -1001,7 +974,6 @@ function getNamespace(name) {
|
|
|
1001
974
|
}
|
|
1002
975
|
return result;
|
|
1003
976
|
}
|
|
1004
|
-
__name(getNamespace, "getNamespace");
|
|
1005
977
|
|
|
1006
978
|
// src/handlers/model-data.ts
|
|
1007
979
|
function modelData(model, args) {
|
|
@@ -1024,7 +996,6 @@ function modelData(model, args) {
|
|
|
1024
996
|
modelFieldsValue.set(field.name, field);
|
|
1025
997
|
}
|
|
1026
998
|
}
|
|
1027
|
-
__name(modelData, "modelData");
|
|
1028
999
|
|
|
1029
1000
|
// src/handlers/model-output-type.ts
|
|
1030
1001
|
var import_assert3 = require("assert");
|
|
@@ -1037,7 +1008,6 @@ var import_ts_morph5 = require("ts-morph");
|
|
|
1037
1008
|
function getOutputTypeName(name) {
|
|
1038
1009
|
return name.replace(/(?:OutputType|Output)$/, "");
|
|
1039
1010
|
}
|
|
1040
|
-
__name(getOutputTypeName, "getOutputTypeName");
|
|
1041
1011
|
|
|
1042
1012
|
// src/handlers/model-output-type.ts
|
|
1043
1013
|
var nestjsGraphql = "@nestjs/graphql";
|
|
@@ -1117,7 +1087,9 @@ function modelOutputType(outputType2, args) {
|
|
|
1117
1087
|
let graphqlType;
|
|
1118
1088
|
if (fieldType) {
|
|
1119
1089
|
graphqlType = fieldType.name;
|
|
1120
|
-
importDeclarations.create(
|
|
1090
|
+
importDeclarations.create({
|
|
1091
|
+
...fieldType
|
|
1092
|
+
});
|
|
1121
1093
|
} else {
|
|
1122
1094
|
const graphqlImport = getGraphqlImport({
|
|
1123
1095
|
config,
|
|
@@ -1148,7 +1120,11 @@ function modelOutputType(outputType2, args) {
|
|
|
1148
1120
|
}
|
|
1149
1121
|
(_c = classStructure.properties) == null ? void 0 : _c.push(property);
|
|
1150
1122
|
if (propertySettings) {
|
|
1151
|
-
importDeclarations.create(
|
|
1123
|
+
importDeclarations.create({
|
|
1124
|
+
...propertySettings
|
|
1125
|
+
});
|
|
1126
|
+
} else if (!propertySettings && propertyType.includes("Decimal")) {
|
|
1127
|
+
importDeclarations.add("Decimal", "@prisma/client/runtime");
|
|
1152
1128
|
}
|
|
1153
1129
|
(0, import_assert3.ok)(property.decorators, "property.decorators is undefined");
|
|
1154
1130
|
if (settings == null ? void 0 : settings.shouldHideField({
|
|
@@ -1237,24 +1213,20 @@ function modelOutputType(outputType2, args) {
|
|
|
1237
1213
|
});
|
|
1238
1214
|
}
|
|
1239
1215
|
}
|
|
1240
|
-
__name(modelOutputType, "modelOutputType");
|
|
1241
1216
|
function shouldBeDecorated(setting) {
|
|
1242
1217
|
return setting.kind === "Decorator" && (setting.output || setting.model) && !(setting.output && setting.model);
|
|
1243
1218
|
}
|
|
1244
|
-
__name(shouldBeDecorated, "shouldBeDecorated");
|
|
1245
1219
|
function getExportDeclaration(name, statements) {
|
|
1246
1220
|
return statements.find((structure) => {
|
|
1247
1221
|
return structure.kind === import_ts_morph5.StructureKind.ExportDeclaration && structure.namedExports.some((o) => (o.alias || o.name) === name);
|
|
1248
1222
|
});
|
|
1249
1223
|
}
|
|
1250
|
-
__name(getExportDeclaration, "getExportDeclaration");
|
|
1251
1224
|
|
|
1252
1225
|
// src/handlers/no-atomic-operations.ts
|
|
1253
1226
|
function noAtomicOperations(eventEmitter) {
|
|
1254
1227
|
eventEmitter.on("BeforeInputType", beforeInputType2);
|
|
1255
1228
|
eventEmitter.on("BeforeGenerateFiles", beforeGenerateFiles);
|
|
1256
1229
|
}
|
|
1257
|
-
__name(noAtomicOperations, "noAtomicOperations");
|
|
1258
1230
|
function beforeInputType2(args) {
|
|
1259
1231
|
const { inputType: inputType1 } = args;
|
|
1260
1232
|
for (const field of inputType1.fields) {
|
|
@@ -1277,11 +1249,9 @@ function beforeGenerateFiles(args) {
|
|
|
1277
1249
|
}
|
|
1278
1250
|
}
|
|
1279
1251
|
}
|
|
1280
|
-
__name(beforeGenerateFiles, "beforeGenerateFiles");
|
|
1281
1252
|
function isAtomicOperation(name) {
|
|
1282
1253
|
return name.endsWith("FieldUpdateOperationsInput");
|
|
1283
1254
|
}
|
|
1284
|
-
__name(isAtomicOperation, "isAtomicOperation");
|
|
1285
1255
|
|
|
1286
1256
|
// src/handlers/output-type.ts
|
|
1287
1257
|
var import_assert4 = require("assert");
|
|
@@ -1300,9 +1270,10 @@ function outputType(outputType1, args) {
|
|
|
1300
1270
|
const isCountOutput = (model == null ? void 0 : model.name) && outputType1.name === `${model.name}CountOutputType`;
|
|
1301
1271
|
outputType1.name = getOutputTypeName(outputType1.name);
|
|
1302
1272
|
if (isAggregateOutput) {
|
|
1303
|
-
eventEmitter.emitSync("AggregateOutput",
|
|
1273
|
+
eventEmitter.emitSync("AggregateOutput", {
|
|
1274
|
+
...args,
|
|
1304
1275
|
outputType: outputType1
|
|
1305
|
-
})
|
|
1276
|
+
});
|
|
1306
1277
|
}
|
|
1307
1278
|
const sourceFile = getSourceFile({
|
|
1308
1279
|
name: outputType1.name,
|
|
@@ -1345,7 +1316,11 @@ function outputType(outputType1, args) {
|
|
|
1345
1316
|
});
|
|
1346
1317
|
(_c = classStructure.properties) == null ? void 0 : _c.push(property);
|
|
1347
1318
|
if (propertySettings) {
|
|
1348
|
-
importDeclarations.create(
|
|
1319
|
+
importDeclarations.create({
|
|
1320
|
+
...propertySettings
|
|
1321
|
+
});
|
|
1322
|
+
} else if (!propertySettings && propertyType.includes("Decimal")) {
|
|
1323
|
+
importDeclarations.add("Decimal", "@prisma/client/runtime");
|
|
1349
1324
|
}
|
|
1350
1325
|
let graphqlType;
|
|
1351
1326
|
const shouldHideField = settings == null ? void 0 : settings.shouldHideField({
|
|
@@ -1358,7 +1333,9 @@ function outputType(outputType1, args) {
|
|
|
1358
1333
|
});
|
|
1359
1334
|
if (fieldType && isCustomsApplicable && !shouldHideField) {
|
|
1360
1335
|
graphqlType = fieldType.name;
|
|
1361
|
-
importDeclarations.create(
|
|
1336
|
+
importDeclarations.create({
|
|
1337
|
+
...fieldType
|
|
1338
|
+
});
|
|
1362
1339
|
} else {
|
|
1363
1340
|
const graphqlImport = getGraphqlImport({
|
|
1364
1341
|
config,
|
|
@@ -1428,7 +1405,6 @@ function outputType(outputType1, args) {
|
|
|
1428
1405
|
]
|
|
1429
1406
|
});
|
|
1430
1407
|
}
|
|
1431
|
-
__name(outputType, "outputType");
|
|
1432
1408
|
|
|
1433
1409
|
// src/handlers/purge-output.ts
|
|
1434
1410
|
var import_fs = require("fs");
|
|
@@ -1436,7 +1412,6 @@ function purgeOutput(emitter) {
|
|
|
1436
1412
|
emitter.on("Begin", begin);
|
|
1437
1413
|
emitter.on("End", end);
|
|
1438
1414
|
}
|
|
1439
|
-
__name(purgeOutput, "purgeOutput");
|
|
1440
1415
|
function begin({ project, output }) {
|
|
1441
1416
|
var _a;
|
|
1442
1417
|
const sourceFiles = (_a = project.getDirectory(output)) == null ? void 0 : _a.getDescendantSourceFiles();
|
|
@@ -1446,7 +1421,6 @@ function begin({ project, output }) {
|
|
|
1446
1421
|
}
|
|
1447
1422
|
}
|
|
1448
1423
|
}
|
|
1449
|
-
__name(begin, "begin");
|
|
1450
1424
|
async function end({ project, output }) {
|
|
1451
1425
|
var _a;
|
|
1452
1426
|
const directories = (_a = project.getDirectory(output)) == null ? void 0 : _a.getDescendantDirectories().filter((directory) => directory.getSourceFiles().length === 0).map((directory) => directory.getPath());
|
|
@@ -1457,7 +1431,6 @@ async function end({ project, output }) {
|
|
|
1457
1431
|
}
|
|
1458
1432
|
}
|
|
1459
1433
|
}
|
|
1460
|
-
__name(end, "end");
|
|
1461
1434
|
|
|
1462
1435
|
// src/handlers/re-export.ts
|
|
1463
1436
|
var import_ts_morph7 = require("ts-morph");
|
|
@@ -1471,7 +1444,6 @@ var ReExport;
|
|
|
1471
1444
|
function reExport(emitter) {
|
|
1472
1445
|
emitter.on("BeforeGenerateFiles", beforeGenerateFiles2);
|
|
1473
1446
|
}
|
|
1474
|
-
__name(reExport, "reExport");
|
|
1475
1447
|
function beforeGenerateFiles2(args) {
|
|
1476
1448
|
const { project, output, config } = args;
|
|
1477
1449
|
const rootDirectory = project.getDirectoryOrThrow(output);
|
|
@@ -1561,13 +1533,11 @@ function registerEnum(enumType, args) {
|
|
|
1561
1533
|
]
|
|
1562
1534
|
});
|
|
1563
1535
|
}
|
|
1564
|
-
__name(registerEnum, "registerEnum");
|
|
1565
1536
|
|
|
1566
1537
|
// src/handlers/require-single-fields-in-whereunique-input.ts
|
|
1567
1538
|
function requireSingleFieldsInWhereUniqueInput(eventEmitter) {
|
|
1568
1539
|
eventEmitter.on("BeforeInputType", beforeInputType3);
|
|
1569
1540
|
}
|
|
1570
|
-
__name(requireSingleFieldsInWhereUniqueInput, "requireSingleFieldsInWhereUniqueInput");
|
|
1571
1541
|
function beforeInputType3(args) {
|
|
1572
1542
|
const { inputType: inputType2 } = args;
|
|
1573
1543
|
if (!isWhereUniqueInputType(inputType2.name) || inputType2.fields.length !== 1) {
|
|
@@ -1582,7 +1552,6 @@ __name(beforeInputType3, "beforeInputType");
|
|
|
1582
1552
|
function isWhereUniqueInputType(name) {
|
|
1583
1553
|
return name.endsWith("WhereUniqueInput");
|
|
1584
1554
|
}
|
|
1585
|
-
__name(isWhereUniqueInputType, "isWhereUniqueInputType");
|
|
1586
1555
|
|
|
1587
1556
|
// src/handlers/warning.ts
|
|
1588
1557
|
function warning(message) {
|
|
@@ -1593,7 +1562,6 @@ function warning(message) {
|
|
|
1593
1562
|
console.log("prisma-nestjs-graphql:", message);
|
|
1594
1563
|
}
|
|
1595
1564
|
}
|
|
1596
|
-
__name(warning, "warning");
|
|
1597
1565
|
|
|
1598
1566
|
// src/helpers/create-config.ts
|
|
1599
1567
|
var import_assert5 = require("assert");
|
|
@@ -1676,7 +1644,6 @@ function createConfig(data) {
|
|
|
1676
1644
|
decorate
|
|
1677
1645
|
};
|
|
1678
1646
|
}
|
|
1679
|
-
__name(createConfig, "createConfig");
|
|
1680
1647
|
function createUseInputType(data) {
|
|
1681
1648
|
if (!data) {
|
|
1682
1649
|
return [];
|
|
@@ -1698,7 +1665,6 @@ function createUseInputType(data) {
|
|
|
1698
1665
|
}
|
|
1699
1666
|
return result;
|
|
1700
1667
|
}
|
|
1701
|
-
__name(createUseInputType, "createUseInputType");
|
|
1702
1668
|
function toBoolean(value) {
|
|
1703
1669
|
return [
|
|
1704
1670
|
"true",
|
|
@@ -1706,7 +1672,6 @@ function toBoolean(value) {
|
|
|
1706
1672
|
"on"
|
|
1707
1673
|
].includes(String(value));
|
|
1708
1674
|
}
|
|
1709
|
-
__name(toBoolean, "toBoolean");
|
|
1710
1675
|
|
|
1711
1676
|
// src/helpers/generate-file-name.ts
|
|
1712
1677
|
var import_lodash8 = require("lodash");
|
|
@@ -1741,12 +1706,11 @@ function generateFileName(args) {
|
|
|
1741
1706
|
}
|
|
1742
1707
|
});
|
|
1743
1708
|
}
|
|
1744
|
-
__name(generateFileName, "generateFileName");
|
|
1745
1709
|
|
|
1746
1710
|
// src/helpers/factory-get-source-file.ts
|
|
1747
1711
|
function factoryGetSourceFile(args1) {
|
|
1748
1712
|
const { outputFilePattern, output, getModelName: getModelName2, project } = args1;
|
|
1749
|
-
return
|
|
1713
|
+
return function getSourceFile(args) {
|
|
1750
1714
|
const { name, type } = args;
|
|
1751
1715
|
let filePath = generateFileName({
|
|
1752
1716
|
getModelName: getModelName2,
|
|
@@ -1758,9 +1722,8 @@ function factoryGetSourceFile(args1) {
|
|
|
1758
1722
|
return project.getSourceFile(filePath) || project.createSourceFile(filePath, void 0, {
|
|
1759
1723
|
overwrite: true
|
|
1760
1724
|
});
|
|
1761
|
-
}
|
|
1725
|
+
};
|
|
1762
1726
|
}
|
|
1763
|
-
__name(factoryGetSourceFile, "factoryGetSourceFile");
|
|
1764
1727
|
|
|
1765
1728
|
// src/helpers/get-model-name.ts
|
|
1766
1729
|
var import_lodash9 = require("lodash");
|
|
@@ -1772,9 +1735,7 @@ function createGetModelName(modelNames) {
|
|
|
1772
1735
|
name
|
|
1773
1736
|
});
|
|
1774
1737
|
}
|
|
1775
|
-
__name(tryGetName, "tryGetName");
|
|
1776
1738
|
}
|
|
1777
|
-
__name(createGetModelName, "createGetModelName");
|
|
1778
1739
|
function getModelName(args) {
|
|
1779
1740
|
const { name, modelNames } = args;
|
|
1780
1741
|
for (const keyword of splitKeywords) {
|
|
@@ -1812,7 +1773,6 @@ function getModelName(args) {
|
|
|
1812
1773
|
}
|
|
1813
1774
|
return void 0;
|
|
1814
1775
|
}
|
|
1815
|
-
__name(getModelName, "getModelName");
|
|
1816
1776
|
var splitKeywords = [
|
|
1817
1777
|
"CreateInput",
|
|
1818
1778
|
"CreateMany",
|
|
@@ -2018,11 +1978,12 @@ async function generate(args) {
|
|
|
2018
1978
|
}
|
|
2019
1979
|
const inputTypes = inputObjectTypes.prisma.concat(inputObjectTypes.model || []);
|
|
2020
1980
|
for (const inputType1 of inputTypes) {
|
|
2021
|
-
const event =
|
|
1981
|
+
const event = {
|
|
1982
|
+
...eventArguments,
|
|
2022
1983
|
inputType: inputType1,
|
|
2023
1984
|
fileType: "input",
|
|
2024
1985
|
classDecoratorName: "InputType"
|
|
2025
|
-
}
|
|
1986
|
+
};
|
|
2026
1987
|
if (inputType1.fields.length === 0) {
|
|
2027
1988
|
removeTypes.add(inputType1.name);
|
|
2028
1989
|
continue;
|
|
@@ -2042,7 +2003,6 @@ async function generate(args) {
|
|
|
2042
2003
|
eventEmitter.off(name);
|
|
2043
2004
|
}
|
|
2044
2005
|
}
|
|
2045
|
-
__name(generate, "generate");
|
|
2046
2006
|
|
|
2047
2007
|
// src/index.ts
|
|
2048
2008
|
(0, import_generator_helper.generatorHandler)({
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-nestjs-graphql",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.1.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Generate object types, inputs, args, etc. from prisma schema file for usage with @nestjs/graphql module",
|
|
6
6
|
"main": "index.js",
|
|
7
|
-
"bin": "
|
|
7
|
+
"bin": "bin.js",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/unlight/nestjs-graphql-prisma.git"
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@nestjs/apollo": "^10.0.
|
|
55
|
-
"@prisma/generator-helper": "^3.
|
|
54
|
+
"@nestjs/apollo": "^10.0.7",
|
|
55
|
+
"@prisma/generator-helper": "^3.11.0",
|
|
56
56
|
"await-event-emitter": "^2.0.2",
|
|
57
57
|
"filenamify": "4.X",
|
|
58
58
|
"flat": "^5.0.2",
|
|
@@ -65,26 +65,26 @@
|
|
|
65
65
|
"ts-morph": ">=11"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@commitlint/cli": "^16.2.
|
|
68
|
+
"@commitlint/cli": "^16.2.3",
|
|
69
69
|
"@commitlint/config-conventional": "^16.2.1",
|
|
70
|
-
"@nestjs/common": "^8.4.
|
|
71
|
-
"@nestjs/core": "^8.4.
|
|
72
|
-
"@nestjs/graphql": "^10.0.
|
|
73
|
-
"@nestjs/platform-express": "^8.4.
|
|
74
|
-
"@paljs/plugins": "^4.0.
|
|
75
|
-
"@prisma/client": "^3.
|
|
70
|
+
"@nestjs/common": "^8.4.1",
|
|
71
|
+
"@nestjs/core": "^8.4.1",
|
|
72
|
+
"@nestjs/graphql": "^10.0.7",
|
|
73
|
+
"@nestjs/platform-express": "^8.4.1",
|
|
74
|
+
"@paljs/plugins": "^4.0.18",
|
|
75
|
+
"@prisma/client": "^3.11.0",
|
|
76
76
|
"@semantic-release/changelog": "^6.0.1",
|
|
77
77
|
"@semantic-release/git": "^10.0.1",
|
|
78
|
-
"@swc/core": "^1.2.
|
|
79
|
-
"@swc/helpers": "^0.3.
|
|
78
|
+
"@swc/core": "^1.2.156",
|
|
79
|
+
"@swc/helpers": "^0.3.8",
|
|
80
80
|
"@swc/register": "^0.1.10",
|
|
81
81
|
"@types/flat": "^5.0.2",
|
|
82
|
-
"@types/lodash": "^4.14.
|
|
82
|
+
"@types/lodash": "^4.14.180",
|
|
83
83
|
"@types/mocha": "^9.1.0",
|
|
84
84
|
"@types/node": "^17.0.21",
|
|
85
85
|
"@types/pluralize": "^0.0.29",
|
|
86
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
87
|
-
"@typescript-eslint/parser": "^5.
|
|
86
|
+
"@typescript-eslint/eslint-plugin": "^5.15.0",
|
|
87
|
+
"@typescript-eslint/parser": "^5.15.0",
|
|
88
88
|
"apollo-server-express": "^3.6.4",
|
|
89
89
|
"c8": "^7.11.0",
|
|
90
90
|
"class-transformer": "^0.5.1",
|
|
@@ -112,8 +112,8 @@
|
|
|
112
112
|
"mocha": "^9.2.2",
|
|
113
113
|
"ololog": "^1.1.175",
|
|
114
114
|
"precise-commits": "^1.0.2",
|
|
115
|
-
"prettier": "^2.
|
|
116
|
-
"prisma": "^3.
|
|
115
|
+
"prettier": "^2.6.0",
|
|
116
|
+
"prisma": "^3.11.0",
|
|
117
117
|
"prisma-graphql-type-decimal": "^2.0.0",
|
|
118
118
|
"reflect-metadata": "^0.1.13",
|
|
119
119
|
"request": "^2.88.2",
|