prisma-nestjs-graphql 14.7.1 → 15.0.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/README.md +2 -2
- package/index.js +50 -99
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -561,7 +561,7 @@ Named import example:
|
|
|
561
561
|
```prisma
|
|
562
562
|
model Transfer {
|
|
563
563
|
id String @id
|
|
564
|
-
/// @PropertyType({ name: 'Prisma.Decimal', from: '@prisma/client', namedImport: true })
|
|
564
|
+
/// @PropertyType({ name: 'Prisma.Decimal', from: '@prisma/client', namedImport: true, input: true })
|
|
565
565
|
money Decimal
|
|
566
566
|
}
|
|
567
567
|
```
|
|
@@ -572,7 +572,7 @@ May generate following:
|
|
|
572
572
|
import { Prisma } from '@prisma/client';
|
|
573
573
|
|
|
574
574
|
@ObjectType()
|
|
575
|
-
export class
|
|
575
|
+
export class TransferCreateInput {
|
|
576
576
|
@Field(() => GraphQLDecimal)
|
|
577
577
|
money!: Prisma.Decimal;
|
|
578
578
|
}
|
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) {
|
|
@@ -615,7 +581,6 @@ function getPropertyType(args) {
|
|
|
615
581
|
"unknown"
|
|
616
582
|
];
|
|
617
583
|
}
|
|
618
|
-
__name(getPropertyType, "getPropertyType");
|
|
619
584
|
|
|
620
585
|
// src/helpers/property-structure.ts
|
|
621
586
|
var import_ts_morph3 = require("ts-morph");
|
|
@@ -632,7 +597,6 @@ function propertyStructure(args) {
|
|
|
632
597
|
leadingTrivia: "\n"
|
|
633
598
|
};
|
|
634
599
|
}
|
|
635
|
-
__name(propertyStructure, "propertyStructure");
|
|
636
600
|
|
|
637
601
|
// src/handlers/input-type.ts
|
|
638
602
|
function inputType(args) {
|
|
@@ -702,7 +666,9 @@ function inputType(args) {
|
|
|
702
666
|
});
|
|
703
667
|
classStructure.properties.push(property);
|
|
704
668
|
if (propertySettings) {
|
|
705
|
-
importDeclarations.create(
|
|
669
|
+
importDeclarations.create({
|
|
670
|
+
...propertySettings
|
|
671
|
+
});
|
|
706
672
|
}
|
|
707
673
|
let graphqlType;
|
|
708
674
|
const shouldHideField = settings == null ? void 0 : settings.shouldHideField({
|
|
@@ -715,7 +681,9 @@ function inputType(args) {
|
|
|
715
681
|
});
|
|
716
682
|
if (fieldType && isCustomsApplicable && !shouldHideField) {
|
|
717
683
|
graphqlType = fieldType.name;
|
|
718
|
-
importDeclarations.create(
|
|
684
|
+
importDeclarations.create({
|
|
685
|
+
...fieldType
|
|
686
|
+
});
|
|
719
687
|
} else {
|
|
720
688
|
const graphqlImport = getGraphqlImport({
|
|
721
689
|
config,
|
|
@@ -794,7 +762,6 @@ function inputType(args) {
|
|
|
794
762
|
]
|
|
795
763
|
});
|
|
796
764
|
}
|
|
797
|
-
__name(inputType, "inputType");
|
|
798
765
|
|
|
799
766
|
// src/helpers/object-settings.ts
|
|
800
767
|
var import_json52 = __toESM(require("json5"));
|
|
@@ -822,12 +789,18 @@ var ObjectSettings = class extends Array {
|
|
|
822
789
|
}
|
|
823
790
|
return fieldType;
|
|
824
791
|
}
|
|
825
|
-
getPropertyType({ name }) {
|
|
792
|
+
getPropertyType({ name, input, output }) {
|
|
826
793
|
const propertyType = this.find((s) => s.kind === "PropertyType");
|
|
827
794
|
if (!propertyType) {
|
|
828
795
|
return void 0;
|
|
829
796
|
}
|
|
830
|
-
if (propertyType.match
|
|
797
|
+
if (propertyType.match) {
|
|
798
|
+
return propertyType.match(name) ? propertyType : void 0;
|
|
799
|
+
}
|
|
800
|
+
if (input && !propertyType.input) {
|
|
801
|
+
return void 0;
|
|
802
|
+
}
|
|
803
|
+
if (output && !propertyType.output) {
|
|
831
804
|
return void 0;
|
|
832
805
|
}
|
|
833
806
|
return propertyType;
|
|
@@ -848,7 +821,6 @@ var ObjectSettings = class extends Array {
|
|
|
848
821
|
return resultArguments.map((x) => import_json52.default.stringify(x));
|
|
849
822
|
}
|
|
850
823
|
};
|
|
851
|
-
__name(ObjectSettings, "ObjectSettings");
|
|
852
824
|
function createObjectSettings(args) {
|
|
853
825
|
var _a, _b, _c, _d, _e;
|
|
854
826
|
const { config, text } = args;
|
|
@@ -921,7 +893,6 @@ function createObjectSettings(args) {
|
|
|
921
893
|
documentation: documentationLines.filter(Boolean).join("\\n") || void 0
|
|
922
894
|
};
|
|
923
895
|
}
|
|
924
|
-
__name(createObjectSettings, "createObjectSettings");
|
|
925
896
|
function customType(args) {
|
|
926
897
|
var _a;
|
|
927
898
|
const result = {};
|
|
@@ -944,7 +915,6 @@ function customType(args) {
|
|
|
944
915
|
}
|
|
945
916
|
return result;
|
|
946
917
|
}
|
|
947
|
-
__name(customType, "customType");
|
|
948
918
|
function hideFieldDecorator(match) {
|
|
949
919
|
var _a;
|
|
950
920
|
const result = {
|
|
@@ -978,7 +948,6 @@ function hideFieldDecorator(match) {
|
|
|
978
948
|
}
|
|
979
949
|
return result;
|
|
980
950
|
}
|
|
981
|
-
__name(hideFieldDecorator, "hideFieldDecorator");
|
|
982
951
|
function parseArgs(string) {
|
|
983
952
|
try {
|
|
984
953
|
return import_json52.default.parse(string);
|
|
@@ -990,7 +959,6 @@ function parseArgs(string) {
|
|
|
990
959
|
}
|
|
991
960
|
}
|
|
992
961
|
}
|
|
993
|
-
__name(parseArgs, "parseArgs");
|
|
994
962
|
function getNamespace(name) {
|
|
995
963
|
if (name === void 0) {
|
|
996
964
|
return void 0;
|
|
@@ -1001,7 +969,6 @@ function getNamespace(name) {
|
|
|
1001
969
|
}
|
|
1002
970
|
return result;
|
|
1003
971
|
}
|
|
1004
|
-
__name(getNamespace, "getNamespace");
|
|
1005
972
|
|
|
1006
973
|
// src/handlers/model-data.ts
|
|
1007
974
|
function modelData(model, args) {
|
|
@@ -1024,7 +991,6 @@ function modelData(model, args) {
|
|
|
1024
991
|
modelFieldsValue.set(field.name, field);
|
|
1025
992
|
}
|
|
1026
993
|
}
|
|
1027
|
-
__name(modelData, "modelData");
|
|
1028
994
|
|
|
1029
995
|
// src/handlers/model-output-type.ts
|
|
1030
996
|
var import_assert3 = require("assert");
|
|
@@ -1037,7 +1003,6 @@ var import_ts_morph5 = require("ts-morph");
|
|
|
1037
1003
|
function getOutputTypeName(name) {
|
|
1038
1004
|
return name.replace(/(?:OutputType|Output)$/, "");
|
|
1039
1005
|
}
|
|
1040
|
-
__name(getOutputTypeName, "getOutputTypeName");
|
|
1041
1006
|
|
|
1042
1007
|
// src/handlers/model-output-type.ts
|
|
1043
1008
|
var nestjsGraphql = "@nestjs/graphql";
|
|
@@ -1117,7 +1082,9 @@ function modelOutputType(outputType2, args) {
|
|
|
1117
1082
|
let graphqlType;
|
|
1118
1083
|
if (fieldType) {
|
|
1119
1084
|
graphqlType = fieldType.name;
|
|
1120
|
-
importDeclarations.create(
|
|
1085
|
+
importDeclarations.create({
|
|
1086
|
+
...fieldType
|
|
1087
|
+
});
|
|
1121
1088
|
} else {
|
|
1122
1089
|
const graphqlImport = getGraphqlImport({
|
|
1123
1090
|
config,
|
|
@@ -1148,7 +1115,9 @@ function modelOutputType(outputType2, args) {
|
|
|
1148
1115
|
}
|
|
1149
1116
|
(_c = classStructure.properties) == null ? void 0 : _c.push(property);
|
|
1150
1117
|
if (propertySettings) {
|
|
1151
|
-
importDeclarations.create(
|
|
1118
|
+
importDeclarations.create({
|
|
1119
|
+
...propertySettings
|
|
1120
|
+
});
|
|
1152
1121
|
}
|
|
1153
1122
|
(0, import_assert3.ok)(property.decorators, "property.decorators is undefined");
|
|
1154
1123
|
if (settings == null ? void 0 : settings.shouldHideField({
|
|
@@ -1237,24 +1206,20 @@ function modelOutputType(outputType2, args) {
|
|
|
1237
1206
|
});
|
|
1238
1207
|
}
|
|
1239
1208
|
}
|
|
1240
|
-
__name(modelOutputType, "modelOutputType");
|
|
1241
1209
|
function shouldBeDecorated(setting) {
|
|
1242
1210
|
return setting.kind === "Decorator" && (setting.output || setting.model) && !(setting.output && setting.model);
|
|
1243
1211
|
}
|
|
1244
|
-
__name(shouldBeDecorated, "shouldBeDecorated");
|
|
1245
1212
|
function getExportDeclaration(name, statements) {
|
|
1246
1213
|
return statements.find((structure) => {
|
|
1247
1214
|
return structure.kind === import_ts_morph5.StructureKind.ExportDeclaration && structure.namedExports.some((o) => (o.alias || o.name) === name);
|
|
1248
1215
|
});
|
|
1249
1216
|
}
|
|
1250
|
-
__name(getExportDeclaration, "getExportDeclaration");
|
|
1251
1217
|
|
|
1252
1218
|
// src/handlers/no-atomic-operations.ts
|
|
1253
1219
|
function noAtomicOperations(eventEmitter) {
|
|
1254
1220
|
eventEmitter.on("BeforeInputType", beforeInputType2);
|
|
1255
1221
|
eventEmitter.on("BeforeGenerateFiles", beforeGenerateFiles);
|
|
1256
1222
|
}
|
|
1257
|
-
__name(noAtomicOperations, "noAtomicOperations");
|
|
1258
1223
|
function beforeInputType2(args) {
|
|
1259
1224
|
const { inputType: inputType1 } = args;
|
|
1260
1225
|
for (const field of inputType1.fields) {
|
|
@@ -1277,11 +1242,9 @@ function beforeGenerateFiles(args) {
|
|
|
1277
1242
|
}
|
|
1278
1243
|
}
|
|
1279
1244
|
}
|
|
1280
|
-
__name(beforeGenerateFiles, "beforeGenerateFiles");
|
|
1281
1245
|
function isAtomicOperation(name) {
|
|
1282
1246
|
return name.endsWith("FieldUpdateOperationsInput");
|
|
1283
1247
|
}
|
|
1284
|
-
__name(isAtomicOperation, "isAtomicOperation");
|
|
1285
1248
|
|
|
1286
1249
|
// src/handlers/output-type.ts
|
|
1287
1250
|
var import_assert4 = require("assert");
|
|
@@ -1300,9 +1263,10 @@ function outputType(outputType1, args) {
|
|
|
1300
1263
|
const isCountOutput = (model == null ? void 0 : model.name) && outputType1.name === `${model.name}CountOutputType`;
|
|
1301
1264
|
outputType1.name = getOutputTypeName(outputType1.name);
|
|
1302
1265
|
if (isAggregateOutput) {
|
|
1303
|
-
eventEmitter.emitSync("AggregateOutput",
|
|
1266
|
+
eventEmitter.emitSync("AggregateOutput", {
|
|
1267
|
+
...args,
|
|
1304
1268
|
outputType: outputType1
|
|
1305
|
-
})
|
|
1269
|
+
});
|
|
1306
1270
|
}
|
|
1307
1271
|
const sourceFile = getSourceFile({
|
|
1308
1272
|
name: outputType1.name,
|
|
@@ -1345,7 +1309,9 @@ function outputType(outputType1, args) {
|
|
|
1345
1309
|
});
|
|
1346
1310
|
(_c = classStructure.properties) == null ? void 0 : _c.push(property);
|
|
1347
1311
|
if (propertySettings) {
|
|
1348
|
-
importDeclarations.create(
|
|
1312
|
+
importDeclarations.create({
|
|
1313
|
+
...propertySettings
|
|
1314
|
+
});
|
|
1349
1315
|
}
|
|
1350
1316
|
let graphqlType;
|
|
1351
1317
|
const shouldHideField = settings == null ? void 0 : settings.shouldHideField({
|
|
@@ -1358,7 +1324,9 @@ function outputType(outputType1, args) {
|
|
|
1358
1324
|
});
|
|
1359
1325
|
if (fieldType && isCustomsApplicable && !shouldHideField) {
|
|
1360
1326
|
graphqlType = fieldType.name;
|
|
1361
|
-
importDeclarations.create(
|
|
1327
|
+
importDeclarations.create({
|
|
1328
|
+
...fieldType
|
|
1329
|
+
});
|
|
1362
1330
|
} else {
|
|
1363
1331
|
const graphqlImport = getGraphqlImport({
|
|
1364
1332
|
config,
|
|
@@ -1428,7 +1396,6 @@ function outputType(outputType1, args) {
|
|
|
1428
1396
|
]
|
|
1429
1397
|
});
|
|
1430
1398
|
}
|
|
1431
|
-
__name(outputType, "outputType");
|
|
1432
1399
|
|
|
1433
1400
|
// src/handlers/purge-output.ts
|
|
1434
1401
|
var import_fs = require("fs");
|
|
@@ -1436,7 +1403,6 @@ function purgeOutput(emitter) {
|
|
|
1436
1403
|
emitter.on("Begin", begin);
|
|
1437
1404
|
emitter.on("End", end);
|
|
1438
1405
|
}
|
|
1439
|
-
__name(purgeOutput, "purgeOutput");
|
|
1440
1406
|
function begin({ project, output }) {
|
|
1441
1407
|
var _a;
|
|
1442
1408
|
const sourceFiles = (_a = project.getDirectory(output)) == null ? void 0 : _a.getDescendantSourceFiles();
|
|
@@ -1446,7 +1412,6 @@ function begin({ project, output }) {
|
|
|
1446
1412
|
}
|
|
1447
1413
|
}
|
|
1448
1414
|
}
|
|
1449
|
-
__name(begin, "begin");
|
|
1450
1415
|
async function end({ project, output }) {
|
|
1451
1416
|
var _a;
|
|
1452
1417
|
const directories = (_a = project.getDirectory(output)) == null ? void 0 : _a.getDescendantDirectories().filter((directory) => directory.getSourceFiles().length === 0).map((directory) => directory.getPath());
|
|
@@ -1457,7 +1422,6 @@ async function end({ project, output }) {
|
|
|
1457
1422
|
}
|
|
1458
1423
|
}
|
|
1459
1424
|
}
|
|
1460
|
-
__name(end, "end");
|
|
1461
1425
|
|
|
1462
1426
|
// src/handlers/re-export.ts
|
|
1463
1427
|
var import_ts_morph7 = require("ts-morph");
|
|
@@ -1471,7 +1435,6 @@ var ReExport;
|
|
|
1471
1435
|
function reExport(emitter) {
|
|
1472
1436
|
emitter.on("BeforeGenerateFiles", beforeGenerateFiles2);
|
|
1473
1437
|
}
|
|
1474
|
-
__name(reExport, "reExport");
|
|
1475
1438
|
function beforeGenerateFiles2(args) {
|
|
1476
1439
|
const { project, output, config } = args;
|
|
1477
1440
|
const rootDirectory = project.getDirectoryOrThrow(output);
|
|
@@ -1561,13 +1524,11 @@ function registerEnum(enumType, args) {
|
|
|
1561
1524
|
]
|
|
1562
1525
|
});
|
|
1563
1526
|
}
|
|
1564
|
-
__name(registerEnum, "registerEnum");
|
|
1565
1527
|
|
|
1566
1528
|
// src/handlers/require-single-fields-in-whereunique-input.ts
|
|
1567
1529
|
function requireSingleFieldsInWhereUniqueInput(eventEmitter) {
|
|
1568
1530
|
eventEmitter.on("BeforeInputType", beforeInputType3);
|
|
1569
1531
|
}
|
|
1570
|
-
__name(requireSingleFieldsInWhereUniqueInput, "requireSingleFieldsInWhereUniqueInput");
|
|
1571
1532
|
function beforeInputType3(args) {
|
|
1572
1533
|
const { inputType: inputType2 } = args;
|
|
1573
1534
|
if (!isWhereUniqueInputType(inputType2.name) || inputType2.fields.length !== 1) {
|
|
@@ -1582,7 +1543,6 @@ __name(beforeInputType3, "beforeInputType");
|
|
|
1582
1543
|
function isWhereUniqueInputType(name) {
|
|
1583
1544
|
return name.endsWith("WhereUniqueInput");
|
|
1584
1545
|
}
|
|
1585
|
-
__name(isWhereUniqueInputType, "isWhereUniqueInputType");
|
|
1586
1546
|
|
|
1587
1547
|
// src/handlers/warning.ts
|
|
1588
1548
|
function warning(message) {
|
|
@@ -1593,7 +1553,6 @@ function warning(message) {
|
|
|
1593
1553
|
console.log("prisma-nestjs-graphql:", message);
|
|
1594
1554
|
}
|
|
1595
1555
|
}
|
|
1596
|
-
__name(warning, "warning");
|
|
1597
1556
|
|
|
1598
1557
|
// src/helpers/create-config.ts
|
|
1599
1558
|
var import_assert5 = require("assert");
|
|
@@ -1676,7 +1635,6 @@ function createConfig(data) {
|
|
|
1676
1635
|
decorate
|
|
1677
1636
|
};
|
|
1678
1637
|
}
|
|
1679
|
-
__name(createConfig, "createConfig");
|
|
1680
1638
|
function createUseInputType(data) {
|
|
1681
1639
|
if (!data) {
|
|
1682
1640
|
return [];
|
|
@@ -1698,7 +1656,6 @@ function createUseInputType(data) {
|
|
|
1698
1656
|
}
|
|
1699
1657
|
return result;
|
|
1700
1658
|
}
|
|
1701
|
-
__name(createUseInputType, "createUseInputType");
|
|
1702
1659
|
function toBoolean(value) {
|
|
1703
1660
|
return [
|
|
1704
1661
|
"true",
|
|
@@ -1706,7 +1663,6 @@ function toBoolean(value) {
|
|
|
1706
1663
|
"on"
|
|
1707
1664
|
].includes(String(value));
|
|
1708
1665
|
}
|
|
1709
|
-
__name(toBoolean, "toBoolean");
|
|
1710
1666
|
|
|
1711
1667
|
// src/helpers/generate-file-name.ts
|
|
1712
1668
|
var import_lodash8 = require("lodash");
|
|
@@ -1741,12 +1697,11 @@ function generateFileName(args) {
|
|
|
1741
1697
|
}
|
|
1742
1698
|
});
|
|
1743
1699
|
}
|
|
1744
|
-
__name(generateFileName, "generateFileName");
|
|
1745
1700
|
|
|
1746
1701
|
// src/helpers/factory-get-source-file.ts
|
|
1747
1702
|
function factoryGetSourceFile(args1) {
|
|
1748
1703
|
const { outputFilePattern, output, getModelName: getModelName2, project } = args1;
|
|
1749
|
-
return
|
|
1704
|
+
return function getSourceFile(args) {
|
|
1750
1705
|
const { name, type } = args;
|
|
1751
1706
|
let filePath = generateFileName({
|
|
1752
1707
|
getModelName: getModelName2,
|
|
@@ -1758,9 +1713,8 @@ function factoryGetSourceFile(args1) {
|
|
|
1758
1713
|
return project.getSourceFile(filePath) || project.createSourceFile(filePath, void 0, {
|
|
1759
1714
|
overwrite: true
|
|
1760
1715
|
});
|
|
1761
|
-
}
|
|
1716
|
+
};
|
|
1762
1717
|
}
|
|
1763
|
-
__name(factoryGetSourceFile, "factoryGetSourceFile");
|
|
1764
1718
|
|
|
1765
1719
|
// src/helpers/get-model-name.ts
|
|
1766
1720
|
var import_lodash9 = require("lodash");
|
|
@@ -1772,9 +1726,7 @@ function createGetModelName(modelNames) {
|
|
|
1772
1726
|
name
|
|
1773
1727
|
});
|
|
1774
1728
|
}
|
|
1775
|
-
__name(tryGetName, "tryGetName");
|
|
1776
1729
|
}
|
|
1777
|
-
__name(createGetModelName, "createGetModelName");
|
|
1778
1730
|
function getModelName(args) {
|
|
1779
1731
|
const { name, modelNames } = args;
|
|
1780
1732
|
for (const keyword of splitKeywords) {
|
|
@@ -1812,7 +1764,6 @@ function getModelName(args) {
|
|
|
1812
1764
|
}
|
|
1813
1765
|
return void 0;
|
|
1814
1766
|
}
|
|
1815
|
-
__name(getModelName, "getModelName");
|
|
1816
1767
|
var splitKeywords = [
|
|
1817
1768
|
"CreateInput",
|
|
1818
1769
|
"CreateMany",
|
|
@@ -2018,11 +1969,12 @@ async function generate(args) {
|
|
|
2018
1969
|
}
|
|
2019
1970
|
const inputTypes = inputObjectTypes.prisma.concat(inputObjectTypes.model || []);
|
|
2020
1971
|
for (const inputType1 of inputTypes) {
|
|
2021
|
-
const event =
|
|
1972
|
+
const event = {
|
|
1973
|
+
...eventArguments,
|
|
2022
1974
|
inputType: inputType1,
|
|
2023
1975
|
fileType: "input",
|
|
2024
1976
|
classDecoratorName: "InputType"
|
|
2025
|
-
}
|
|
1977
|
+
};
|
|
2026
1978
|
if (inputType1.fields.length === 0) {
|
|
2027
1979
|
removeTypes.add(inputType1.name);
|
|
2028
1980
|
continue;
|
|
@@ -2042,7 +1994,6 @@ async function generate(args) {
|
|
|
2042
1994
|
eventEmitter.off(name);
|
|
2043
1995
|
}
|
|
2044
1996
|
}
|
|
2045
|
-
__name(generate, "generate");
|
|
2046
1997
|
|
|
2047
1998
|
// src/index.ts
|
|
2048
1999
|
(0, import_generator_helper.generatorHandler)({
|
package/package.json
CHANGED