prisma-nestjs-graphql 14.7.0 → 15.1.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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/index.js +72 -113
  3. package/package.json +21 -21
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 User {
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 __reExport = (target, module2, copyDefault, desc) => {
27
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
28
- for (let key of __getOwnPropNames(module2))
29
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
30
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
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 target;
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", __spreadProps(__spreadValues({}, args), {
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", __spreadProps(__spreadValues({}, args), {
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,21 +254,23 @@ var ImportDeclarationMap = class extends Map {
283
254
  const iterator = this.values();
284
255
  let result = iterator.next();
285
256
  while (result.value) {
286
- yield __spreadProps(__spreadValues({}, result.value), {
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
- function beforeGenerateFiles(args) {
297
- const { config, project, output } = args;
267
+ async function generateFiles(args) {
268
+ const { project, config, output, eventEmitter } = args;
298
269
  if (config.emitSingle) {
299
270
  const rootDirectory = project.getDirectory(output) || project.createDirectory(output);
300
- const sourceFile = rootDirectory.getSourceFile("index.ts") || rootDirectory.createSourceFile("index.ts");
271
+ const sourceFile = rootDirectory.getSourceFile("index.ts") || rootDirectory.createSourceFile("index.ts", void 0, {
272
+ overwrite: true
273
+ });
301
274
  const statements1 = project.getSourceFiles().flatMap((s) => {
302
275
  var _a, _b;
303
276
  if (s === sourceFile) {
@@ -373,10 +346,6 @@ function beforeGenerateFiles(args) {
373
346
  ]
374
347
  });
375
348
  }
376
- }
377
- __name(beforeGenerateFiles, "beforeGenerateFiles");
378
- async function generateFiles(args) {
379
- const { project, config, output, eventEmitter } = args;
380
349
  if (config.emitCompiled) {
381
350
  project.compilerOptions.set({
382
351
  declaration: true,
@@ -395,7 +364,6 @@ async function generateFiles(args) {
395
364
  await project.save();
396
365
  }
397
366
  }
398
- __name(generateFiles, "generateFiles");
399
367
 
400
368
  // src/handlers/input-type.ts
401
369
  var import_assert2 = require("assert");
@@ -416,7 +384,6 @@ function fileTypeByLocation(fieldLocation) {
416
384
  }
417
385
  return "object";
418
386
  }
419
- __name(fileTypeByLocation, "fileTypeByLocation");
420
387
 
421
388
  // src/helpers/relative-path.ts
422
389
  var import_get_relative_path = __toESM(require("get-relative-path"));
@@ -436,7 +403,6 @@ function relativePath(from, to) {
436
403
  }
437
404
  return result;
438
405
  }
439
- __name(relativePath, "relativePath");
440
406
 
441
407
  // src/helpers/get-graphql-import.ts
442
408
  function getGraphqlImport(args) {
@@ -502,7 +468,6 @@ function getGraphqlImport(args) {
502
468
  specifier
503
469
  };
504
470
  }
505
- __name(getGraphqlImport, "getGraphqlImport");
506
471
 
507
472
  // src/helpers/get-graphql-input-type.ts
508
473
  var import_lodash2 = require("lodash");
@@ -552,7 +517,6 @@ function getGraphqlInputType(inputTypes, pattern) {
552
517
  }
553
518
  throw new TypeError(`Cannot get matching input type from ${inputTypes.map((x) => x.type).join(", ") || "zero length inputTypes"}`);
554
519
  }
555
- __name(getGraphqlInputType, "getGraphqlInputType");
556
520
 
557
521
  // src/helpers/get-property-type.ts
558
522
  function getPropertyType(args) {
@@ -577,6 +541,9 @@ function getPropertyType(args) {
577
541
  "string"
578
542
  ];
579
543
  case "Decimal":
544
+ return [
545
+ "Decimal"
546
+ ];
580
547
  case "Json":
581
548
  return [
582
549
  "any"
@@ -617,7 +584,6 @@ function getPropertyType(args) {
617
584
  "unknown"
618
585
  ];
619
586
  }
620
- __name(getPropertyType, "getPropertyType");
621
587
 
622
588
  // src/helpers/property-structure.ts
623
589
  var import_ts_morph3 = require("ts-morph");
@@ -634,7 +600,6 @@ function propertyStructure(args) {
634
600
  leadingTrivia: "\n"
635
601
  };
636
602
  }
637
- __name(propertyStructure, "propertyStructure");
638
603
 
639
604
  // src/handlers/input-type.ts
640
605
  function inputType(args) {
@@ -704,7 +669,11 @@ function inputType(args) {
704
669
  });
705
670
  classStructure.properties.push(property);
706
671
  if (propertySettings) {
707
- importDeclarations.create(__spreadValues({}, propertySettings));
672
+ importDeclarations.create({
673
+ ...propertySettings
674
+ });
675
+ } else if (!propertySettings && propertyType.includes("Decimal")) {
676
+ importDeclarations.add("Decimal", "@prisma/client/runtime");
708
677
  }
709
678
  let graphqlType;
710
679
  const shouldHideField = settings == null ? void 0 : settings.shouldHideField({
@@ -717,7 +686,9 @@ function inputType(args) {
717
686
  });
718
687
  if (fieldType && isCustomsApplicable && !shouldHideField) {
719
688
  graphqlType = fieldType.name;
720
- importDeclarations.create(__spreadValues({}, fieldType));
689
+ importDeclarations.create({
690
+ ...fieldType
691
+ });
721
692
  } else {
722
693
  const graphqlImport = getGraphqlImport({
723
694
  config,
@@ -796,7 +767,6 @@ function inputType(args) {
796
767
  ]
797
768
  });
798
769
  }
799
- __name(inputType, "inputType");
800
770
 
801
771
  // src/helpers/object-settings.ts
802
772
  var import_json52 = __toESM(require("json5"));
@@ -824,12 +794,18 @@ var ObjectSettings = class extends Array {
824
794
  }
825
795
  return fieldType;
826
796
  }
827
- getPropertyType({ name }) {
797
+ getPropertyType({ name, input, output }) {
828
798
  const propertyType = this.find((s) => s.kind === "PropertyType");
829
799
  if (!propertyType) {
830
800
  return void 0;
831
801
  }
832
- if (propertyType.match && !propertyType.match(name)) {
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) {
833
809
  return void 0;
834
810
  }
835
811
  return propertyType;
@@ -850,7 +826,6 @@ var ObjectSettings = class extends Array {
850
826
  return resultArguments.map((x) => import_json52.default.stringify(x));
851
827
  }
852
828
  };
853
- __name(ObjectSettings, "ObjectSettings");
854
829
  function createObjectSettings(args) {
855
830
  var _a, _b, _c, _d, _e;
856
831
  const { config, text } = args;
@@ -923,7 +898,6 @@ function createObjectSettings(args) {
923
898
  documentation: documentationLines.filter(Boolean).join("\\n") || void 0
924
899
  };
925
900
  }
926
- __name(createObjectSettings, "createObjectSettings");
927
901
  function customType(args) {
928
902
  var _a;
929
903
  const result = {};
@@ -946,7 +920,6 @@ function customType(args) {
946
920
  }
947
921
  return result;
948
922
  }
949
- __name(customType, "customType");
950
923
  function hideFieldDecorator(match) {
951
924
  var _a;
952
925
  const result = {
@@ -980,7 +953,6 @@ function hideFieldDecorator(match) {
980
953
  }
981
954
  return result;
982
955
  }
983
- __name(hideFieldDecorator, "hideFieldDecorator");
984
956
  function parseArgs(string) {
985
957
  try {
986
958
  return import_json52.default.parse(string);
@@ -992,7 +964,6 @@ function parseArgs(string) {
992
964
  }
993
965
  }
994
966
  }
995
- __name(parseArgs, "parseArgs");
996
967
  function getNamespace(name) {
997
968
  if (name === void 0) {
998
969
  return void 0;
@@ -1003,7 +974,6 @@ function getNamespace(name) {
1003
974
  }
1004
975
  return result;
1005
976
  }
1006
- __name(getNamespace, "getNamespace");
1007
977
 
1008
978
  // src/handlers/model-data.ts
1009
979
  function modelData(model, args) {
@@ -1026,7 +996,6 @@ function modelData(model, args) {
1026
996
  modelFieldsValue.set(field.name, field);
1027
997
  }
1028
998
  }
1029
- __name(modelData, "modelData");
1030
999
 
1031
1000
  // src/handlers/model-output-type.ts
1032
1001
  var import_assert3 = require("assert");
@@ -1039,7 +1008,6 @@ var import_ts_morph5 = require("ts-morph");
1039
1008
  function getOutputTypeName(name) {
1040
1009
  return name.replace(/(?:OutputType|Output)$/, "");
1041
1010
  }
1042
- __name(getOutputTypeName, "getOutputTypeName");
1043
1011
 
1044
1012
  // src/handlers/model-output-type.ts
1045
1013
  var nestjsGraphql = "@nestjs/graphql";
@@ -1119,7 +1087,9 @@ function modelOutputType(outputType2, args) {
1119
1087
  let graphqlType;
1120
1088
  if (fieldType) {
1121
1089
  graphqlType = fieldType.name;
1122
- importDeclarations.create(__spreadValues({}, fieldType));
1090
+ importDeclarations.create({
1091
+ ...fieldType
1092
+ });
1123
1093
  } else {
1124
1094
  const graphqlImport = getGraphqlImport({
1125
1095
  config,
@@ -1150,7 +1120,11 @@ function modelOutputType(outputType2, args) {
1150
1120
  }
1151
1121
  (_c = classStructure.properties) == null ? void 0 : _c.push(property);
1152
1122
  if (propertySettings) {
1153
- importDeclarations.create(__spreadValues({}, propertySettings));
1123
+ importDeclarations.create({
1124
+ ...propertySettings
1125
+ });
1126
+ } else if (!propertySettings && propertyType.includes("Decimal")) {
1127
+ importDeclarations.add("Decimal", "@prisma/client/runtime");
1154
1128
  }
1155
1129
  (0, import_assert3.ok)(property.decorators, "property.decorators is undefined");
1156
1130
  if (settings == null ? void 0 : settings.shouldHideField({
@@ -1239,24 +1213,20 @@ function modelOutputType(outputType2, args) {
1239
1213
  });
1240
1214
  }
1241
1215
  }
1242
- __name(modelOutputType, "modelOutputType");
1243
1216
  function shouldBeDecorated(setting) {
1244
1217
  return setting.kind === "Decorator" && (setting.output || setting.model) && !(setting.output && setting.model);
1245
1218
  }
1246
- __name(shouldBeDecorated, "shouldBeDecorated");
1247
1219
  function getExportDeclaration(name, statements) {
1248
1220
  return statements.find((structure) => {
1249
1221
  return structure.kind === import_ts_morph5.StructureKind.ExportDeclaration && structure.namedExports.some((o) => (o.alias || o.name) === name);
1250
1222
  });
1251
1223
  }
1252
- __name(getExportDeclaration, "getExportDeclaration");
1253
1224
 
1254
1225
  // src/handlers/no-atomic-operations.ts
1255
1226
  function noAtomicOperations(eventEmitter) {
1256
1227
  eventEmitter.on("BeforeInputType", beforeInputType2);
1257
- eventEmitter.on("BeforeGenerateFiles", beforeGenerateFiles2);
1228
+ eventEmitter.on("BeforeGenerateFiles", beforeGenerateFiles);
1258
1229
  }
1259
- __name(noAtomicOperations, "noAtomicOperations");
1260
1230
  function beforeInputType2(args) {
1261
1231
  const { inputType: inputType1 } = args;
1262
1232
  for (const field of inputType1.fields) {
@@ -1269,7 +1239,7 @@ function beforeInputType2(args) {
1269
1239
  }
1270
1240
  }
1271
1241
  __name(beforeInputType2, "beforeInputType");
1272
- function beforeGenerateFiles2(args) {
1242
+ function beforeGenerateFiles(args) {
1273
1243
  var _a;
1274
1244
  const { project } = args;
1275
1245
  for (const sourceFile of project.getSourceFiles()) {
@@ -1279,11 +1249,9 @@ function beforeGenerateFiles2(args) {
1279
1249
  }
1280
1250
  }
1281
1251
  }
1282
- __name(beforeGenerateFiles2, "beforeGenerateFiles");
1283
1252
  function isAtomicOperation(name) {
1284
1253
  return name.endsWith("FieldUpdateOperationsInput");
1285
1254
  }
1286
- __name(isAtomicOperation, "isAtomicOperation");
1287
1255
 
1288
1256
  // src/handlers/output-type.ts
1289
1257
  var import_assert4 = require("assert");
@@ -1302,9 +1270,10 @@ function outputType(outputType1, args) {
1302
1270
  const isCountOutput = (model == null ? void 0 : model.name) && outputType1.name === `${model.name}CountOutputType`;
1303
1271
  outputType1.name = getOutputTypeName(outputType1.name);
1304
1272
  if (isAggregateOutput) {
1305
- eventEmitter.emitSync("AggregateOutput", __spreadProps(__spreadValues({}, args), {
1273
+ eventEmitter.emitSync("AggregateOutput", {
1274
+ ...args,
1306
1275
  outputType: outputType1
1307
- }));
1276
+ });
1308
1277
  }
1309
1278
  const sourceFile = getSourceFile({
1310
1279
  name: outputType1.name,
@@ -1347,7 +1316,11 @@ function outputType(outputType1, args) {
1347
1316
  });
1348
1317
  (_c = classStructure.properties) == null ? void 0 : _c.push(property);
1349
1318
  if (propertySettings) {
1350
- importDeclarations.create(__spreadValues({}, propertySettings));
1319
+ importDeclarations.create({
1320
+ ...propertySettings
1321
+ });
1322
+ } else if (!propertySettings && propertyType.includes("Decimal")) {
1323
+ importDeclarations.add("Decimal", "@prisma/client/runtime");
1351
1324
  }
1352
1325
  let graphqlType;
1353
1326
  const shouldHideField = settings == null ? void 0 : settings.shouldHideField({
@@ -1360,7 +1333,9 @@ function outputType(outputType1, args) {
1360
1333
  });
1361
1334
  if (fieldType && isCustomsApplicable && !shouldHideField) {
1362
1335
  graphqlType = fieldType.name;
1363
- importDeclarations.create(__spreadValues({}, fieldType));
1336
+ importDeclarations.create({
1337
+ ...fieldType
1338
+ });
1364
1339
  } else {
1365
1340
  const graphqlImport = getGraphqlImport({
1366
1341
  config,
@@ -1430,7 +1405,6 @@ function outputType(outputType1, args) {
1430
1405
  ]
1431
1406
  });
1432
1407
  }
1433
- __name(outputType, "outputType");
1434
1408
 
1435
1409
  // src/handlers/purge-output.ts
1436
1410
  var import_fs = require("fs");
@@ -1438,7 +1412,6 @@ function purgeOutput(emitter) {
1438
1412
  emitter.on("Begin", begin);
1439
1413
  emitter.on("End", end);
1440
1414
  }
1441
- __name(purgeOutput, "purgeOutput");
1442
1415
  function begin({ project, output }) {
1443
1416
  var _a;
1444
1417
  const sourceFiles = (_a = project.getDirectory(output)) == null ? void 0 : _a.getDescendantSourceFiles();
@@ -1448,7 +1421,6 @@ function begin({ project, output }) {
1448
1421
  }
1449
1422
  }
1450
1423
  }
1451
- __name(begin, "begin");
1452
1424
  async function end({ project, output }) {
1453
1425
  var _a;
1454
1426
  const directories = (_a = project.getDirectory(output)) == null ? void 0 : _a.getDescendantDirectories().filter((directory) => directory.getSourceFiles().length === 0).map((directory) => directory.getPath());
@@ -1459,7 +1431,6 @@ async function end({ project, output }) {
1459
1431
  }
1460
1432
  }
1461
1433
  }
1462
- __name(end, "end");
1463
1434
 
1464
1435
  // src/handlers/re-export.ts
1465
1436
  var import_ts_morph7 = require("ts-morph");
@@ -1471,10 +1442,9 @@ var ReExport;
1471
1442
  ReExport2["All"] = "All";
1472
1443
  })(ReExport || (ReExport = {}));
1473
1444
  function reExport(emitter) {
1474
- emitter.on("BeforeGenerateFiles", beforeGenerateFiles3);
1445
+ emitter.on("BeforeGenerateFiles", beforeGenerateFiles2);
1475
1446
  }
1476
- __name(reExport, "reExport");
1477
- function beforeGenerateFiles3(args) {
1447
+ function beforeGenerateFiles2(args) {
1478
1448
  const { project, output, config } = args;
1479
1449
  const rootDirectory = project.getDirectoryOrThrow(output);
1480
1450
  if ([
@@ -1515,7 +1485,7 @@ function beforeGenerateFiles3(args) {
1515
1485
  });
1516
1486
  }
1517
1487
  }
1518
- __name(beforeGenerateFiles3, "beforeGenerateFiles");
1488
+ __name(beforeGenerateFiles2, "beforeGenerateFiles");
1519
1489
  function getExportDeclaration2(directory, sourceFile) {
1520
1490
  return {
1521
1491
  kind: import_ts_morph7.StructureKind.ExportDeclaration,
@@ -1563,13 +1533,11 @@ function registerEnum(enumType, args) {
1563
1533
  ]
1564
1534
  });
1565
1535
  }
1566
- __name(registerEnum, "registerEnum");
1567
1536
 
1568
1537
  // src/handlers/require-single-fields-in-whereunique-input.ts
1569
1538
  function requireSingleFieldsInWhereUniqueInput(eventEmitter) {
1570
1539
  eventEmitter.on("BeforeInputType", beforeInputType3);
1571
1540
  }
1572
- __name(requireSingleFieldsInWhereUniqueInput, "requireSingleFieldsInWhereUniqueInput");
1573
1541
  function beforeInputType3(args) {
1574
1542
  const { inputType: inputType2 } = args;
1575
1543
  if (!isWhereUniqueInputType(inputType2.name) || inputType2.fields.length !== 1) {
@@ -1584,7 +1552,6 @@ __name(beforeInputType3, "beforeInputType");
1584
1552
  function isWhereUniqueInputType(name) {
1585
1553
  return name.endsWith("WhereUniqueInput");
1586
1554
  }
1587
- __name(isWhereUniqueInputType, "isWhereUniqueInputType");
1588
1555
 
1589
1556
  // src/handlers/warning.ts
1590
1557
  function warning(message) {
@@ -1595,7 +1562,6 @@ function warning(message) {
1595
1562
  console.log("prisma-nestjs-graphql:", message);
1596
1563
  }
1597
1564
  }
1598
- __name(warning, "warning");
1599
1565
 
1600
1566
  // src/helpers/create-config.ts
1601
1567
  var import_assert5 = require("assert");
@@ -1678,7 +1644,6 @@ function createConfig(data) {
1678
1644
  decorate
1679
1645
  };
1680
1646
  }
1681
- __name(createConfig, "createConfig");
1682
1647
  function createUseInputType(data) {
1683
1648
  if (!data) {
1684
1649
  return [];
@@ -1700,7 +1665,6 @@ function createUseInputType(data) {
1700
1665
  }
1701
1666
  return result;
1702
1667
  }
1703
- __name(createUseInputType, "createUseInputType");
1704
1668
  function toBoolean(value) {
1705
1669
  return [
1706
1670
  "true",
@@ -1708,7 +1672,6 @@ function toBoolean(value) {
1708
1672
  "on"
1709
1673
  ].includes(String(value));
1710
1674
  }
1711
- __name(toBoolean, "toBoolean");
1712
1675
 
1713
1676
  // src/helpers/generate-file-name.ts
1714
1677
  var import_lodash8 = require("lodash");
@@ -1743,12 +1706,11 @@ function generateFileName(args) {
1743
1706
  }
1744
1707
  });
1745
1708
  }
1746
- __name(generateFileName, "generateFileName");
1747
1709
 
1748
1710
  // src/helpers/factory-get-source-file.ts
1749
1711
  function factoryGetSourceFile(args1) {
1750
1712
  const { outputFilePattern, output, getModelName: getModelName2, project } = args1;
1751
- return /* @__PURE__ */ __name(function getSourceFile(args) {
1713
+ return function getSourceFile(args) {
1752
1714
  const { name, type } = args;
1753
1715
  let filePath = generateFileName({
1754
1716
  getModelName: getModelName2,
@@ -1757,10 +1719,11 @@ function factoryGetSourceFile(args1) {
1757
1719
  template: outputFilePattern
1758
1720
  });
1759
1721
  filePath = `${output}/${filePath}`;
1760
- return project.getSourceFile(filePath) || project.createSourceFile(filePath);
1761
- }, "getSourceFile");
1722
+ return project.getSourceFile(filePath) || project.createSourceFile(filePath, void 0, {
1723
+ overwrite: true
1724
+ });
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",
@@ -1937,7 +1897,6 @@ async function generate(args) {
1937
1897
  eventEmitter.on("AggregateOutput", createAggregateInput);
1938
1898
  eventEmitter.on("InputType", inputType);
1939
1899
  eventEmitter.on("ArgsType", argsType);
1940
- eventEmitter.on("BeforeGenerateFiles", beforeGenerateFiles);
1941
1900
  eventEmitter.on("GenerateFiles", generateFiles);
1942
1901
  const config = createConfig(generator.config);
1943
1902
  for (const message of config.$warnings) {
@@ -2019,11 +1978,12 @@ async function generate(args) {
2019
1978
  }
2020
1979
  const inputTypes = inputObjectTypes.prisma.concat(inputObjectTypes.model || []);
2021
1980
  for (const inputType1 of inputTypes) {
2022
- const event = __spreadProps(__spreadValues({}, eventArguments), {
1981
+ const event = {
1982
+ ...eventArguments,
2023
1983
  inputType: inputType1,
2024
1984
  fileType: "input",
2025
1985
  classDecoratorName: "InputType"
2026
- });
1986
+ };
2027
1987
  if (inputType1.fields.length === 0) {
2028
1988
  removeTypes.add(inputType1.name);
2029
1989
  continue;
@@ -2043,7 +2003,6 @@ async function generate(args) {
2043
2003
  eventEmitter.off(name);
2044
2004
  }
2045
2005
  }
2046
- __name(generate, "generate");
2047
2006
 
2048
2007
  // src/index.ts
2049
2008
  (0, import_generator_helper.generatorHandler)({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-nestjs-graphql",
3
- "version": "14.7.0",
3
+ "version": "15.1.0",
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",
@@ -51,8 +51,8 @@
51
51
  }
52
52
  },
53
53
  "dependencies": {
54
- "@nestjs/apollo": "^10.0.6",
55
- "@prisma/generator-helper": "^3.10.0",
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,34 +65,34 @@
65
65
  "ts-morph": ">=11"
66
66
  },
67
67
  "devDependencies": {
68
- "@commitlint/cli": "^16.2.1",
68
+ "@commitlint/cli": "^16.2.3",
69
69
  "@commitlint/config-conventional": "^16.2.1",
70
- "@nestjs/common": "^8.4.0",
71
- "@nestjs/core": "^8.4.0",
72
- "@nestjs/graphql": "^10.0.6",
73
- "@nestjs/platform-express": "^8.4.0",
74
- "@paljs/plugins": "^4.0.16",
75
- "@prisma/client": "^3.10.0",
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.151",
79
- "@swc/helpers": "^0.3.6",
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.179",
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.14.0",
87
- "@typescript-eslint/parser": "^5.14.0",
88
- "apollo-server-express": "^3.6.3",
86
+ "@typescript-eslint/eslint-plugin": "^5.15.0",
87
+ "@typescript-eslint/parser": "^5.15.0",
88
+ "apollo-server-express": "^3.6.4",
89
89
  "c8": "^7.11.0",
90
90
  "class-transformer": "^0.5.1",
91
91
  "class-validator": "^0.13.2",
92
92
  "commitizen": "^4.2.4",
93
93
  "cz-customizable": "^6.3.0",
94
94
  "decimal.js": "^10.3.1",
95
- "eslint": "^8.10.0",
95
+ "eslint": "^8.11.0",
96
96
  "eslint-import-resolver-node": "^0.3.6",
97
97
  "eslint-plugin-etc": "^2.0.2",
98
98
  "eslint-plugin-import": "^2.25.4",
@@ -109,15 +109,15 @@
109
109
  "graphql": "^16.3.0",
110
110
  "graphql-scalars": "^1.15.0",
111
111
  "graphql-type-json": "^0.3.2",
112
- "mocha": "^9.2.1",
112
+ "mocha": "^9.2.2",
113
113
  "ololog": "^1.1.175",
114
114
  "precise-commits": "^1.0.2",
115
- "prettier": "^2.5.1",
116
- "prisma": "^3.10.0",
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",
120
- "rxjs": "^7.5.4",
120
+ "rxjs": "^7.5.5",
121
121
  "semantic-release": "^19.0.2",
122
122
  "simplytyped": "^3.3.0",
123
123
  "temp-dir": "^2.0.0",