prisma-nestjs-graphql 14.6.2 → 14.7.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 +32 -0
  2. package/index.js +483 -203
  3. package/package.json +24 -20
package/index.js CHANGED
@@ -22,6 +22,7 @@ var __spreadValues = (a, b) => {
22
22
  };
23
23
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
24
  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
25
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
25
26
  var __reExport = (target, module2, copyDefault, desc) => {
26
27
  if (module2 && typeof module2 === "object" || typeof module2 === "function") {
27
28
  for (let key of __getOwnPropNames(module2))
@@ -48,10 +49,14 @@ var import_lodash = require("lodash");
48
49
  function pascalCase(string) {
49
50
  return (0, import_lodash.startCase)((0, import_lodash.camelCase)(string)).replace(/ /g, "");
50
51
  }
52
+ __name(pascalCase, "pascalCase");
51
53
 
52
54
  // src/handlers/args-type.ts
53
55
  function argsType(field, args) {
54
- if (["queryRaw", "executeRaw"].includes(field.name)) {
56
+ if ([
57
+ "queryRaw",
58
+ "executeRaw"
59
+ ].includes(field.name)) {
55
60
  return;
56
61
  }
57
62
  const { eventEmitter, typeNames, getModelName: getModelName2 } = args;
@@ -65,24 +70,38 @@ function argsType(field, args) {
65
70
  className = `${modelName}GroupByArgs`;
66
71
  break;
67
72
  }
68
- const inputType2 = {
69
- constraints: { maxNumFields: null, minNumFields: null },
73
+ const inputType1 = {
74
+ constraints: {
75
+ maxNumFields: null,
76
+ minNumFields: null
77
+ },
70
78
  name: className,
71
- fields: [...field.args]
79
+ fields: [
80
+ ...field.args
81
+ ]
72
82
  };
73
- if (!field.args.some((x) => x.name === "_count") && [`${modelName}AggregateArgs`, `${modelName}GroupByArgs`].includes(className)) {
74
- const names = ["Count", "Avg", "Sum", "Min", "Max"];
75
- if (`${modelName}GroupByArgs` === inputType2.name) {
76
- const byField = inputType2.fields.find((f) => f.name === "by");
83
+ if (!field.args.some((x) => x.name === "_count") && [
84
+ `${modelName}AggregateArgs`,
85
+ `${modelName}GroupByArgs`
86
+ ].includes(className)) {
87
+ const names = [
88
+ "Count",
89
+ "Avg",
90
+ "Sum",
91
+ "Min",
92
+ "Max"
93
+ ];
94
+ if (`${modelName}GroupByArgs` === inputType1.name) {
95
+ const byField = inputType1.fields.find((f) => f.name === "by");
77
96
  if (byField == null ? void 0 : byField.inputTypes) {
78
- byField.inputTypes = byField.inputTypes.filter((inputType3) => inputType3.isList);
97
+ byField.inputTypes = byField.inputTypes.filter((inputType2) => inputType2.isList);
79
98
  }
80
99
  }
81
100
  for (const name of names) {
82
101
  if (!typeNames.has(`${modelName}${name}AggregateInput`)) {
83
102
  continue;
84
103
  }
85
- inputType2.fields.push({
104
+ inputType1.fields.push({
86
105
  name: `_${name.toLowerCase()}`,
87
106
  isRequired: false,
88
107
  isNullable: true,
@@ -97,23 +116,26 @@ function argsType(field, args) {
97
116
  }
98
117
  }
99
118
  eventEmitter.emitSync("InputType", __spreadProps(__spreadValues({}, args), {
100
- inputType: inputType2,
119
+ inputType: inputType1,
101
120
  fileType: "args",
102
121
  classDecoratorName: "ArgsType"
103
122
  }));
104
123
  }
124
+ __name(argsType, "argsType");
105
125
 
106
126
  // src/handlers/combine-scalar-filters.ts
107
127
  function combineScalarFilters(eventEmitter) {
108
128
  eventEmitter.on("BeforeInputType", beforeInputType);
109
129
  eventEmitter.on("BeforeGenerateField", beforeGenerateField);
110
130
  }
131
+ __name(combineScalarFilters, "combineScalarFilters");
111
132
  function beforeInputType(args) {
112
133
  const { inputType: inputType2 } = args;
113
134
  if (isContainBogus(inputType2.name) && isScalarFilter(inputType2)) {
114
135
  inputType2.name = replaceBogus(String(inputType2.name));
115
136
  }
116
137
  }
138
+ __name(beforeInputType, "beforeInputType");
117
139
  function beforeGenerateField(field) {
118
140
  for (const fieldInput of field.inputTypes) {
119
141
  if (fieldInput.location !== "inputObjectTypes") {
@@ -125,12 +147,15 @@ function beforeGenerateField(field) {
125
147
  }
126
148
  }
127
149
  }
150
+ __name(beforeGenerateField, "beforeGenerateField");
128
151
  function replaceBogus(name) {
129
152
  return name.replace(/(Nullable|Nested)/g, "");
130
153
  }
154
+ __name(replaceBogus, "replaceBogus");
131
155
  function isContainBogus(name) {
132
156
  return name.startsWith("Nested") || name.includes("Nullable") && name.endsWith("Filter") || name.endsWith("NullableFilter");
133
157
  }
158
+ __name(isContainBogus, "isContainBogus");
134
159
  function isScalarFilter(inputType2) {
135
160
  if (!inputType2.name.endsWith("Filter")) {
136
161
  return false;
@@ -139,18 +164,25 @@ function isScalarFilter(inputType2) {
139
164
  const equals = inputType2.fields.find((f) => f.name === "equals");
140
165
  if (equals) {
141
166
  result = equals.inputTypes.every((x) => {
142
- return ["enumTypes", "scalar"].includes(x.location);
167
+ return [
168
+ "enumTypes",
169
+ "scalar"
170
+ ].includes(x.location);
143
171
  });
144
172
  }
145
173
  return result;
146
174
  }
175
+ __name(isScalarFilter, "isScalarFilter");
147
176
 
148
177
  // src/handlers/create-aggregate-input.ts
149
178
  function createAggregateInput(args) {
150
179
  const { eventEmitter, outputType: outputType2 } = args;
151
180
  const className = `${outputType2.name}Input`;
152
181
  const inputType2 = {
153
- constraints: { maxNumFields: null, minNumFields: null },
182
+ constraints: {
183
+ maxNumFields: null,
184
+ minNumFields: null
185
+ },
154
186
  name: className,
155
187
  fields: outputType2.fields.map((x) => {
156
188
  var _a;
@@ -174,14 +206,19 @@ function createAggregateInput(args) {
174
206
  classDecoratorName: "InputType"
175
207
  }));
176
208
  }
209
+ __name(createAggregateInput, "createAggregateInput");
177
210
 
178
211
  // src/handlers/emit-single.ts
179
212
  function emitSingle(emitter) {
180
213
  emitter.on("ClassProperty", classProperty);
181
214
  }
215
+ __name(emitSingle, "emitSingle");
182
216
  function classProperty(property, eventArguments) {
183
217
  const { location, isList, propertyType } = eventArguments;
184
- if (["inputObjectTypes", "outputObjectTypes"].includes(location) && !isList) {
218
+ if ([
219
+ "inputObjectTypes",
220
+ "outputObjectTypes"
221
+ ].includes(location) && !isList) {
185
222
  const types = propertyType.filter((t) => t !== "null");
186
223
  property.type = types.map((t) => `InstanceType<typeof ${t}>`).join(" | ");
187
224
  if (types.length !== propertyType.length) {
@@ -189,6 +226,7 @@ function classProperty(property, eventArguments) {
189
226
  }
190
227
  }
191
228
  }
229
+ __name(classProperty, "classProperty");
192
230
 
193
231
  // src/handlers/generate-files.ts
194
232
  var import_assert = require("assert");
@@ -199,7 +237,14 @@ var import_ts_morph = require("ts-morph");
199
237
  var ImportDeclarationMap = class extends Map {
200
238
  add(name, value) {
201
239
  if (!this.has(name)) {
202
- const structure = typeof value === "string" ? { moduleSpecifier: value, namedImports: [{ name }] } : value;
240
+ const structure = typeof value === "string" ? {
241
+ moduleSpecifier: value,
242
+ namedImports: [
243
+ {
244
+ name
245
+ }
246
+ ]
247
+ } : value;
203
248
  this.set(name, structure);
204
249
  }
205
250
  }
@@ -213,7 +258,11 @@ var ImportDeclarationMap = class extends Map {
213
258
  namespaceImport: void 0
214
259
  };
215
260
  if (namedImport === true && namespaceImport) {
216
- value.namedImports = [{ name: namespaceImport }];
261
+ value.namedImports = [
262
+ {
263
+ name: namespaceImport
264
+ }
265
+ ];
217
266
  name = namespaceImport;
218
267
  } else if (defaultImport) {
219
268
  value.defaultImport = defaultImport === true ? name : defaultImport;
@@ -222,7 +271,11 @@ var ImportDeclarationMap = class extends Map {
222
271
  value.namespaceImport = namespaceImport;
223
272
  name = namespaceImport;
224
273
  } else {
225
- value.namedImports = [{ name }];
274
+ value.namedImports = [
275
+ {
276
+ name
277
+ }
278
+ ];
226
279
  }
227
280
  this.add(name, value);
228
281
  }
@@ -237,6 +290,7 @@ var ImportDeclarationMap = class extends Map {
237
290
  }
238
291
  }
239
292
  };
293
+ __name(ImportDeclarationMap, "ImportDeclarationMap");
240
294
 
241
295
  // src/handlers/generate-files.ts
242
296
  function beforeGenerateFiles(args) {
@@ -244,15 +298,15 @@ function beforeGenerateFiles(args) {
244
298
  if (config.emitSingle) {
245
299
  const rootDirectory = project.getDirectory(output) || project.createDirectory(output);
246
300
  const sourceFile = rootDirectory.getSourceFile("index.ts") || rootDirectory.createSourceFile("index.ts");
247
- const statements = project.getSourceFiles().flatMap((s) => {
301
+ const statements1 = project.getSourceFiles().flatMap((s) => {
248
302
  var _a, _b;
249
303
  if (s === sourceFile) {
250
304
  return [];
251
305
  }
252
306
  const classDeclaration = s.getClass(() => true);
253
- const statements2 = s.getStructure().statements;
254
- if (Array.isArray(statements2)) {
255
- for (const statement of statements2) {
307
+ const statements = s.getStructure().statements;
308
+ if (Array.isArray(statements)) {
309
+ for (const statement of statements) {
256
310
  if (!(typeof statement === "object" && statement.kind === import_ts_morph2.StructureKind.Class)) {
257
311
  continue;
258
312
  }
@@ -266,56 +320,61 @@ function beforeGenerateFiles(args) {
266
320
  }
267
321
  }
268
322
  project.removeSourceFile(s);
269
- return statements2;
323
+ return statements;
270
324
  });
271
325
  const imports = new ImportDeclarationMap();
272
326
  const enums = [];
273
327
  const classes = [];
274
- for (const statement of statements) {
275
- if (typeof statement === "string") {
276
- if (statement.startsWith("registerEnumType")) {
277
- enums.push(statement);
328
+ for (const statement1 of statements1) {
329
+ if (typeof statement1 === "string") {
330
+ if (statement1.startsWith("registerEnumType")) {
331
+ enums.push(statement1);
278
332
  }
279
333
  continue;
280
334
  }
281
- switch (statement.kind) {
335
+ switch (statement1.kind) {
282
336
  case import_ts_morph2.StructureKind.ImportDeclaration:
283
- if (statement.moduleSpecifier.startsWith("./") || statement.moduleSpecifier.startsWith("..")) {
337
+ if (statement1.moduleSpecifier.startsWith("./") || statement1.moduleSpecifier.startsWith("..")) {
284
338
  continue;
285
339
  }
286
- for (const namedImport of statement.namedImports) {
340
+ for (const namedImport of statement1.namedImports) {
287
341
  const name = namedImport.alias || namedImport.name;
288
- imports.add(name, statement.moduleSpecifier);
342
+ imports.add(name, statement1.moduleSpecifier);
289
343
  }
290
- if (statement.defaultImport) {
344
+ if (statement1.defaultImport) {
291
345
  imports.create({
292
- from: statement.moduleSpecifier,
293
- name: statement.defaultImport,
294
- defaultImport: statement.defaultImport
346
+ from: statement1.moduleSpecifier,
347
+ name: statement1.defaultImport,
348
+ defaultImport: statement1.defaultImport
295
349
  });
296
350
  }
297
- if (statement.namespaceImport) {
351
+ if (statement1.namespaceImport) {
298
352
  imports.create({
299
- from: statement.moduleSpecifier,
300
- name: statement.namespaceImport,
301
- namespaceImport: statement.namespaceImport
353
+ from: statement1.moduleSpecifier,
354
+ name: statement1.namespaceImport,
355
+ namespaceImport: statement1.namespaceImport
302
356
  });
303
357
  }
304
358
  break;
305
359
  case import_ts_morph2.StructureKind.Enum:
306
- enums.unshift(statement);
360
+ enums.unshift(statement1);
307
361
  break;
308
362
  case import_ts_morph2.StructureKind.Class:
309
- classes.push(statement);
363
+ classes.push(statement1);
310
364
  break;
311
365
  }
312
366
  }
313
367
  sourceFile.set({
314
368
  kind: import_ts_morph2.StructureKind.SourceFile,
315
- statements: [...imports.toStatements(), ...enums, ...classes]
369
+ statements: [
370
+ ...imports.toStatements(),
371
+ ...enums,
372
+ ...classes
373
+ ]
316
374
  });
317
375
  }
318
376
  }
377
+ __name(beforeGenerateFiles, "beforeGenerateFiles");
319
378
  async function generateFiles(args) {
320
379
  const { project, config, output, eventEmitter } = args;
321
380
  if (config.emitCompiled) {
@@ -336,6 +395,7 @@ async function generateFiles(args) {
336
395
  await project.save();
337
396
  }
338
397
  }
398
+ __name(generateFiles, "generateFiles");
339
399
 
340
400
  // src/handlers/input-type.ts
341
401
  var import_assert2 = require("assert");
@@ -356,6 +416,7 @@ function fileTypeByLocation(fieldLocation) {
356
416
  }
357
417
  return "object";
358
418
  }
419
+ __name(fileTypeByLocation, "fileTypeByLocation");
359
420
 
360
421
  // src/helpers/relative-path.ts
361
422
  var import_get_relative_path = __toESM(require("get-relative-path"));
@@ -375,32 +436,58 @@ function relativePath(from, to) {
375
436
  }
376
437
  return result;
377
438
  }
439
+ __name(relativePath, "relativePath");
378
440
 
379
441
  // src/helpers/get-graphql-import.ts
380
442
  function getGraphqlImport(args) {
381
- const { fileType, location, typeName, isId, noTypeId, sourceFile, getSourceFile } = args;
443
+ const { config, fileType, location, typeName, isId, noTypeId, sourceFile, getSourceFile } = args;
382
444
  if (location === "scalar") {
383
445
  if (isId && !noTypeId) {
384
- return { name: "ID", specifier: "@nestjs/graphql" };
446
+ return {
447
+ name: "ID",
448
+ specifier: "@nestjs/graphql"
449
+ };
450
+ }
451
+ const graphqlType = config.graphqlScalars[typeName];
452
+ if (graphqlType) {
453
+ return {
454
+ name: graphqlType.name,
455
+ specifier: graphqlType.specifier
456
+ };
385
457
  }
386
458
  switch (typeName) {
387
459
  case "Float":
388
460
  case "Int":
389
- return { name: typeName, specifier: "@nestjs/graphql" };
461
+ return {
462
+ name: typeName,
463
+ specifier: "@nestjs/graphql"
464
+ };
390
465
  case "DateTime":
391
- return { name: "Date", specifier: void 0 };
466
+ return {
467
+ name: "Date",
468
+ specifier: void 0
469
+ };
392
470
  case "true":
393
471
  case "Boolean":
394
- return { name: "Boolean", specifier: void 0 };
472
+ return {
473
+ name: "Boolean",
474
+ specifier: void 0
475
+ };
395
476
  case "Decimal":
396
477
  return {
397
478
  name: "GraphQLDecimal",
398
479
  specifier: "prisma-graphql-type-decimal"
399
480
  };
400
481
  case "Json":
401
- return { name: "GraphQLJSON", specifier: "graphql-type-json" };
482
+ return {
483
+ name: "GraphQLJSON",
484
+ specifier: "graphql-type-json"
485
+ };
402
486
  }
403
- return { name: "String", specifier: void 0 };
487
+ return {
488
+ name: "String",
489
+ specifier: void 0
490
+ };
404
491
  }
405
492
  let sourceFileType = fileTypeByLocation(location);
406
493
  if (sourceFileType === "output" && fileType === "model") {
@@ -410,15 +497,22 @@ function getGraphqlImport(args) {
410
497
  type: sourceFileType,
411
498
  name: typeName
412
499
  }).getFilePath());
413
- return { name: typeName, specifier };
500
+ return {
501
+ name: typeName,
502
+ specifier
503
+ };
414
504
  }
505
+ __name(getGraphqlImport, "getGraphqlImport");
415
506
 
416
507
  // src/helpers/get-graphql-input-type.ts
417
508
  var import_lodash2 = require("lodash");
418
509
  var import_outmatch = __toESM(require("outmatch"));
419
510
  function getGraphqlInputType(inputTypes, pattern) {
420
511
  let result;
421
- inputTypes = inputTypes.filter((t) => !["null", "Null"].includes(String(t.type)));
512
+ inputTypes = inputTypes.filter((t) => ![
513
+ "null",
514
+ "Null"
515
+ ].includes(String(t.type)));
422
516
  if (inputTypes.length === 1) {
423
517
  return inputTypes[0];
424
518
  }
@@ -433,7 +527,9 @@ function getGraphqlInputType(inputTypes, pattern) {
433
527
  if (pattern) {
434
528
  if (pattern.startsWith("matcher:") || pattern.startsWith("match:")) {
435
529
  const { 1: patternValue } = pattern.split(":", 2);
436
- const isMatch = (0, import_outmatch.default)(patternValue, { separator: false });
530
+ const isMatch = (0, import_outmatch.default)(patternValue, {
531
+ separator: false
532
+ });
437
533
  result = inputTypes.find((x) => isMatch(String(x.type)));
438
534
  if (result) {
439
535
  return result;
@@ -456,6 +552,7 @@ function getGraphqlInputType(inputTypes, pattern) {
456
552
  }
457
553
  throw new TypeError(`Cannot get matching input type from ${inputTypes.map((x) => x.type).join(", ") || "zero length inputTypes"}`);
458
554
  }
555
+ __name(getGraphqlInputType, "getGraphqlInputType");
459
556
 
460
557
  // src/helpers/get-property-type.ts
461
558
  function getPropertyType(args) {
@@ -463,84 +560,96 @@ function getPropertyType(args) {
463
560
  switch (type) {
464
561
  case "Float":
465
562
  case "Int":
466
- return ["number"];
563
+ return [
564
+ "number"
565
+ ];
467
566
  case "String":
468
- return ["string"];
567
+ return [
568
+ "string"
569
+ ];
469
570
  case "Boolean":
470
- return ["boolean"];
571
+ return [
572
+ "boolean"
573
+ ];
471
574
  case "DateTime":
472
- return ["Date", "string"];
575
+ return [
576
+ "Date",
577
+ "string"
578
+ ];
473
579
  case "Decimal":
474
580
  case "Json":
475
- return ["any"];
581
+ return [
582
+ "any"
583
+ ];
476
584
  case "Null":
477
- return ["null"];
585
+ return [
586
+ "null"
587
+ ];
478
588
  case "Bytes":
479
- return ["Buffer"];
589
+ return [
590
+ "Buffer"
591
+ ];
480
592
  case "BigInt":
481
- return ["bigint", "number"];
482
- }
483
- if (["inputObjectTypes", "outputObjectTypes"].includes(location)) {
484
- return [type];
593
+ return [
594
+ "bigint",
595
+ "number"
596
+ ];
597
+ }
598
+ if ([
599
+ "inputObjectTypes",
600
+ "outputObjectTypes"
601
+ ].includes(location)) {
602
+ return [
603
+ type
604
+ ];
485
605
  }
486
606
  if (location === "enumTypes") {
487
- return [`keyof typeof ${type}`];
607
+ return [
608
+ `keyof typeof ${type}`
609
+ ];
488
610
  }
489
611
  if (location === "scalar") {
490
- return [type];
612
+ return [
613
+ type
614
+ ];
491
615
  }
492
- return ["unknown"];
616
+ return [
617
+ "unknown"
618
+ ];
493
619
  }
620
+ __name(getPropertyType, "getPropertyType");
494
621
 
495
622
  // src/helpers/property-structure.ts
496
623
  var import_ts_morph3 = require("ts-morph");
497
624
  function propertyStructure(args) {
498
- const {
499
- isNullable,
500
- propertyType,
501
- name,
502
- isList,
503
- hasQuestionToken,
504
- hasExclamationToken
505
- } = args;
506
- const type = propertyType.map((type2) => isList ? `Array<${type2}>` : type2).join(" | ");
625
+ const { isNullable, propertyType, name, isList, hasQuestionToken, hasExclamationToken } = args;
626
+ const type1 = propertyType.map((type) => isList ? `Array<${type}>` : type).join(" | ");
507
627
  return {
508
628
  kind: import_ts_morph3.StructureKind.Property,
509
629
  name,
510
- type,
630
+ type: type1,
511
631
  hasQuestionToken: hasQuestionToken != null ? hasQuestionToken : isNullable,
512
632
  hasExclamationToken: hasExclamationToken != null ? hasExclamationToken : !isNullable,
513
633
  decorators: [],
514
634
  leadingTrivia: "\n"
515
635
  };
516
636
  }
637
+ __name(propertyStructure, "propertyStructure");
517
638
 
518
639
  // src/handlers/input-type.ts
519
640
  function inputType(args) {
520
641
  var _a, _b, _c, _d;
521
- const {
522
- inputType: inputType2,
523
- fileType,
524
- getSourceFile,
525
- config,
526
- eventEmitter,
527
- classDecoratorName,
528
- fieldSettings,
529
- getModelName: getModelName2,
530
- models,
531
- removeTypes,
532
- typeNames
533
- } = args;
534
- typeNames.add(inputType2.name);
642
+ const { inputType: inputType1, fileType, getSourceFile, config, eventEmitter, classDecoratorName, fieldSettings, getModelName: getModelName2, models, removeTypes, typeNames } = args;
643
+ typeNames.add(inputType1.name);
535
644
  const importDeclarations = new ImportDeclarationMap();
536
645
  const sourceFile = getSourceFile({
537
- name: inputType2.name,
646
+ name: inputType1.name,
538
647
  type: fileType
539
648
  });
540
649
  const classStructure = {
541
650
  kind: import_ts_morph4.StructureKind.Class,
542
651
  isExported: true,
543
- name: inputType2.name,
652
+ name: inputType1.name,
544
653
  decorators: [
545
654
  {
546
655
  name: classDecoratorName,
@@ -549,19 +658,27 @@ function inputType(args) {
549
658
  ],
550
659
  properties: []
551
660
  };
552
- const modelName = getModelName2(inputType2.name) || "";
661
+ const modelName = getModelName2(inputType1.name) || "";
553
662
  const model = models.get(modelName);
554
663
  const modelFieldSettings = model && fieldSettings.get(model.name);
555
664
  const moduleSpecifier = "@nestjs/graphql";
556
665
  importDeclarations.set("Field", {
557
- namedImports: [{ name: "Field" }],
666
+ namedImports: [
667
+ {
668
+ name: "Field"
669
+ }
670
+ ],
558
671
  moduleSpecifier
559
672
  }).set(classDecoratorName, {
560
- namedImports: [{ name: classDecoratorName }],
673
+ namedImports: [
674
+ {
675
+ name: classDecoratorName
676
+ }
677
+ ],
561
678
  moduleSpecifier
562
679
  });
563
- const useInputType = config.useInputType.find((x) => inputType2.name.includes(x.typeName));
564
- for (const field of inputType2.fields) {
680
+ const useInputType = config.useInputType.find((x) => inputType1.name.includes(x.typeName));
681
+ for (const field of inputType1.fields) {
565
682
  field.inputTypes = field.inputTypes.filter((t) => !removeTypes.has(String(t.type)));
566
683
  eventEmitter.emitSync("BeforeGenerateField", field, args);
567
684
  const { inputTypes, isRequired, name } = field;
@@ -571,7 +688,7 @@ function inputType(args) {
571
688
  const typeName = String(type);
572
689
  const settings = modelFieldSettings == null ? void 0 : modelFieldSettings.get(name);
573
690
  const propertySettings = settings == null ? void 0 : settings.getPropertyType({
574
- name: inputType2.name,
691
+ name: inputType1.name,
575
692
  input: true
576
693
  });
577
694
  const isCustomsApplicable = typeName === ((_a = model == null ? void 0 : model.fields.find((f) => f.name === name)) == null ? void 0 : _a.type);
@@ -591,11 +708,11 @@ function inputType(args) {
591
708
  }
592
709
  let graphqlType;
593
710
  const shouldHideField = settings == null ? void 0 : settings.shouldHideField({
594
- name: inputType2.name,
711
+ name: inputType1.name,
595
712
  input: true
596
713
  });
597
714
  const fieldType = settings == null ? void 0 : settings.getFieldType({
598
- name: inputType2.name,
715
+ name: inputType1.name,
599
716
  input: true
600
717
  });
601
718
  if (fieldType && isCustomsApplicable && !shouldHideField) {
@@ -603,6 +720,7 @@ function inputType(args) {
603
720
  importDeclarations.create(__spreadValues({}, fieldType));
604
721
  } else {
605
722
  const graphqlImport = getGraphqlImport({
723
+ config,
606
724
  sourceFile,
607
725
  location,
608
726
  typeName,
@@ -613,9 +731,13 @@ function inputType(args) {
613
731
  if (location === "enumTypes") {
614
732
  referenceName = (0, import_lodash3.last)(referenceName.split(" "));
615
733
  }
616
- if (graphqlImport.specifier && !importDeclarations.has(graphqlImport.name) && (graphqlImport.name !== inputType2.name && !shouldHideField || shouldHideField && referenceName === graphqlImport.name)) {
734
+ if (graphqlImport.specifier && !importDeclarations.has(graphqlImport.name) && (graphqlImport.name !== inputType1.name && !shouldHideField || shouldHideField && referenceName === graphqlImport.name)) {
617
735
  importDeclarations.set(graphqlImport.name, {
618
- namedImports: [{ name: graphqlImport.name }],
736
+ namedImports: [
737
+ {
738
+ name: graphqlImport.name
739
+ }
740
+ ],
619
741
  moduleSpecifier: graphqlImport.specifier
620
742
  });
621
743
  }
@@ -623,7 +745,10 @@ function inputType(args) {
623
745
  (0, import_assert2.ok)(property.decorators, "property.decorators is undefined");
624
746
  if (shouldHideField) {
625
747
  importDeclarations.add("HideField", "@nestjs/graphql");
626
- property.decorators.push({ name: "HideField", arguments: [] });
748
+ property.decorators.push({
749
+ name: "HideField",
750
+ arguments: []
751
+ });
627
752
  } else {
628
753
  property.decorators.push({
629
754
  name: "Field",
@@ -647,10 +772,12 @@ function inputType(args) {
647
772
  }
648
773
  }
649
774
  for (const decorate of config.decorate) {
650
- if (decorate.isMatchField(name) && decorate.isMatchType(inputType2.name)) {
775
+ if (decorate.isMatchField(name) && decorate.isMatchType(inputType1.name)) {
651
776
  property.decorators.push({
652
777
  name: decorate.name,
653
- arguments: (_d = decorate.arguments) == null ? void 0 : _d.map((x) => (0, import_pupa.default)(x, { propertyType }))
778
+ arguments: (_d = decorate.arguments) == null ? void 0 : _d.map((x) => (0, import_pupa.default)(x, {
779
+ propertyType
780
+ }))
654
781
  });
655
782
  importDeclarations.create(decorate);
656
783
  }
@@ -663,29 +790,25 @@ function inputType(args) {
663
790
  });
664
791
  }
665
792
  sourceFile.set({
666
- statements: [...importDeclarations.toStatements(), classStructure]
793
+ statements: [
794
+ ...importDeclarations.toStatements(),
795
+ classStructure
796
+ ]
667
797
  });
668
798
  }
799
+ __name(inputType, "inputType");
669
800
 
670
801
  // src/helpers/object-settings.ts
671
802
  var import_json52 = __toESM(require("json5"));
672
803
  var import_lodash4 = require("lodash");
673
804
  var import_outmatch2 = __toESM(require("outmatch"));
674
805
  var ObjectSettings = class extends Array {
675
- shouldHideField({
676
- name,
677
- input = false,
678
- output = false
679
- }) {
806
+ shouldHideField({ name, input = false, output = false }) {
680
807
  var _a;
681
808
  const hideField = this.find((s) => s.name === "HideField");
682
809
  return Boolean((hideField == null ? void 0 : hideField.input) && input || (hideField == null ? void 0 : hideField.output) && output || ((_a = hideField == null ? void 0 : hideField.match) == null ? void 0 : _a.call(hideField, name)));
683
810
  }
684
- getFieldType({
685
- name,
686
- input,
687
- output
688
- }) {
811
+ getFieldType({ name, input, output }) {
689
812
  const fieldType = this.find((s) => s.kind === "FieldType");
690
813
  if (!fieldType) {
691
814
  return void 0;
@@ -713,7 +836,9 @@ var ObjectSettings = class extends Array {
713
836
  }
714
837
  getObjectTypeArguments(options) {
715
838
  const objectTypeOptions = (0, import_lodash4.merge)({}, options);
716
- const resultArguments = [objectTypeOptions];
839
+ const resultArguments = [
840
+ objectTypeOptions
841
+ ];
717
842
  const objectType = this.find((s) => s.kind === "ObjectType");
718
843
  if (objectType && (0, import_lodash4.isObject)(objectType.arguments)) {
719
844
  const name = objectType.arguments.name;
@@ -725,6 +850,7 @@ var ObjectSettings = class extends Array {
725
850
  return resultArguments.map((x) => import_json52.default.stringify(x));
726
851
  }
727
852
  };
853
+ __name(ObjectSettings, "ObjectSettings");
728
854
  function createObjectSettings(args) {
729
855
  var _a, _b, _c, _d, _e;
730
856
  const { config, text } = args;
@@ -749,9 +875,14 @@ function createObjectSettings(args) {
749
875
  };
750
876
  if (name === "TypeGraphQL.omit" || name === "HideField") {
751
877
  Object.assign(element, hideFieldDecorator(match));
752
- } else if (["FieldType", "PropertyType"].includes(name) && ((_b = match.groups) == null ? void 0 : _b.args)) {
878
+ } else if ([
879
+ "FieldType",
880
+ "PropertyType"
881
+ ].includes(name) && ((_b = match.groups) == null ? void 0 : _b.args)) {
753
882
  const options = customType(match.groups.args);
754
- (0, import_lodash4.merge)(element, options.namespace && config.fields[options.namespace], options, { kind: name });
883
+ (0, import_lodash4.merge)(element, options.namespace && config.fields[options.namespace], options, {
884
+ kind: name
885
+ });
755
886
  } else if (name === "ObjectType" && ((_c = match.groups) == null ? void 0 : _c.args)) {
756
887
  element.kind = "ObjectType";
757
888
  const options = customType(match.groups.args);
@@ -767,7 +898,10 @@ function createObjectSettings(args) {
767
898
  };
768
899
  } else if (name === "Directive" && ((_d = match.groups) == null ? void 0 : _d.args)) {
769
900
  const options = customType(match.groups.args);
770
- (0, import_lodash4.merge)(element, { model: true, from: "@nestjs/graphql" }, options, {
901
+ (0, import_lodash4.merge)(element, {
902
+ model: true,
903
+ from: "@nestjs/graphql"
904
+ }, options, {
771
905
  name,
772
906
  namespace: false,
773
907
  kind: "Decorator",
@@ -789,12 +923,15 @@ function createObjectSettings(args) {
789
923
  documentation: documentationLines.filter(Boolean).join("\\n") || void 0
790
924
  };
791
925
  }
926
+ __name(createObjectSettings, "createObjectSettings");
792
927
  function customType(args) {
793
928
  var _a;
794
929
  const result = {};
795
930
  let options = parseArgs(args);
796
931
  if (typeof options === "string") {
797
- options = { name: options };
932
+ options = {
933
+ name: options
934
+ };
798
935
  }
799
936
  Object.assign(result, options);
800
937
  const namespace = getNamespace(options.name);
@@ -803,10 +940,13 @@ function customType(args) {
803
940
  result.namespaceImport = namespace;
804
941
  }
805
942
  if (typeof options.match === "string" || Array.isArray(options.match)) {
806
- result.match = (0, import_outmatch2.default)(options.match, { separator: false });
943
+ result.match = (0, import_outmatch2.default)(options.match, {
944
+ separator: false
945
+ });
807
946
  }
808
947
  return result;
809
948
  }
949
+ __name(customType, "customType");
810
950
  function hideFieldDecorator(match) {
811
951
  var _a;
812
952
  const result = {
@@ -826,7 +966,9 @@ function hideFieldDecorator(match) {
826
966
  result.output = Boolean(options.output);
827
967
  result.input = Boolean(options.input);
828
968
  if (typeof options.match === "string" || Array.isArray(options.match)) {
829
- result.match = (0, import_outmatch2.default)(options.match, { separator: false });
969
+ result.match = (0, import_outmatch2.default)(options.match, {
970
+ separator: false
971
+ });
830
972
  }
831
973
  } else {
832
974
  if (/output:\s*true/.test(match.groups.args)) {
@@ -838,6 +980,7 @@ function hideFieldDecorator(match) {
838
980
  }
839
981
  return result;
840
982
  }
983
+ __name(hideFieldDecorator, "hideFieldDecorator");
841
984
  function parseArgs(string) {
842
985
  try {
843
986
  return import_json52.default.parse(string);
@@ -849,6 +992,7 @@ function parseArgs(string) {
849
992
  }
850
993
  }
851
994
  }
995
+ __name(parseArgs, "parseArgs");
852
996
  function getNamespace(name) {
853
997
  if (name === void 0) {
854
998
  return void 0;
@@ -859,6 +1003,7 @@ function getNamespace(name) {
859
1003
  }
860
1004
  return result;
861
1005
  }
1006
+ __name(getNamespace, "getNamespace");
862
1007
 
863
1008
  // src/handlers/model-data.ts
864
1009
  function modelData(model, args) {
@@ -881,6 +1026,7 @@ function modelData(model, args) {
881
1026
  modelFieldsValue.set(field.name, field);
882
1027
  }
883
1028
  }
1029
+ __name(modelData, "modelData");
884
1030
 
885
1031
  // src/handlers/model-output-type.ts
886
1032
  var import_assert3 = require("assert");
@@ -893,6 +1039,7 @@ var import_ts_morph5 = require("ts-morph");
893
1039
  function getOutputTypeName(name) {
894
1040
  return name.replace(/(?:OutputType|Output)$/, "");
895
1041
  }
1042
+ __name(getOutputTypeName, "getOutputTypeName");
896
1043
 
897
1044
  // src/handlers/model-output-type.ts
898
1045
  var nestjsGraphql = "@nestjs/graphql";
@@ -975,6 +1122,7 @@ function modelOutputType(outputType2, args) {
975
1122
  importDeclarations.create(__spreadValues({}, fieldType));
976
1123
  } else {
977
1124
  const graphqlImport = getGraphqlImport({
1125
+ config,
978
1126
  sourceFile,
979
1127
  fileType,
980
1128
  location,
@@ -1005,9 +1153,15 @@ function modelOutputType(outputType2, args) {
1005
1153
  importDeclarations.create(__spreadValues({}, propertySettings));
1006
1154
  }
1007
1155
  (0, import_assert3.ok)(property.decorators, "property.decorators is undefined");
1008
- if (settings == null ? void 0 : settings.shouldHideField({ name: outputType2.name, output: true })) {
1156
+ if (settings == null ? void 0 : settings.shouldHideField({
1157
+ name: outputType2.name,
1158
+ output: true
1159
+ })) {
1009
1160
  importDeclarations.add("HideField", nestjsGraphql);
1010
- property.decorators.push({ name: "HideField", arguments: [] });
1161
+ property.decorators.push({
1162
+ name: "HideField",
1163
+ arguments: []
1164
+ });
1011
1165
  } else {
1012
1166
  property.decorators.push({
1013
1167
  name: "Field",
@@ -1015,7 +1169,11 @@ function modelOutputType(outputType2, args) {
1015
1169
  isList ? `() => [${graphqlType}]` : `() => ${graphqlType}`,
1016
1170
  import_json53.default.stringify({
1017
1171
  nullable: Boolean(field.isNullable),
1018
- defaultValue: ["number", "string", "boolean"].includes(typeof (modelField == null ? void 0 : modelField.default)) ? modelField == null ? void 0 : modelField.default : void 0,
1172
+ defaultValue: [
1173
+ "number",
1174
+ "string",
1175
+ "boolean"
1176
+ ].includes(typeof (modelField == null ? void 0 : modelField.default)) ? modelField == null ? void 0 : modelField.default : void 0,
1019
1177
  description: modelField == null ? void 0 : modelField.documentation
1020
1178
  })
1021
1179
  ]
@@ -1034,7 +1192,9 @@ function modelOutputType(outputType2, args) {
1034
1192
  if (decorate.isMatchField(field.name) && decorate.isMatchType(outputTypeName)) {
1035
1193
  property.decorators.push({
1036
1194
  name: decorate.name,
1037
- arguments: (_f = decorate.arguments) == null ? void 0 : _f.map((x) => (0, import_pupa2.default)(x, { propertyType }))
1195
+ arguments: (_f = decorate.arguments) == null ? void 0 : _f.map((x) => (0, import_pupa2.default)(x, {
1196
+ propertyType
1197
+ }))
1038
1198
  });
1039
1199
  importDeclarations.create(decorate);
1040
1200
  }
@@ -1057,43 +1217,58 @@ function modelOutputType(outputType2, args) {
1057
1217
  }
1058
1218
  if (exportDeclaration) {
1059
1219
  sourceFile.set({
1060
- statements: [exportDeclaration, "\n", classStructure]
1220
+ statements: [
1221
+ exportDeclaration,
1222
+ "\n",
1223
+ classStructure
1224
+ ]
1061
1225
  });
1062
1226
  const classDeclaration = sourceFile.getClassOrThrow(model.name);
1063
1227
  const commentedText = classDeclaration.getText().split("\n").map((x) => `// ${x}`);
1064
1228
  classDeclaration.remove();
1065
- sourceFile.addStatements(["\n", ...commentedText]);
1229
+ sourceFile.addStatements([
1230
+ "\n",
1231
+ ...commentedText
1232
+ ]);
1066
1233
  } else {
1067
1234
  sourceFile.set({
1068
- statements: [...importDeclarations.toStatements(), classStructure]
1235
+ statements: [
1236
+ ...importDeclarations.toStatements(),
1237
+ classStructure
1238
+ ]
1069
1239
  });
1070
1240
  }
1071
1241
  }
1242
+ __name(modelOutputType, "modelOutputType");
1072
1243
  function shouldBeDecorated(setting) {
1073
1244
  return setting.kind === "Decorator" && (setting.output || setting.model) && !(setting.output && setting.model);
1074
1245
  }
1246
+ __name(shouldBeDecorated, "shouldBeDecorated");
1075
1247
  function getExportDeclaration(name, statements) {
1076
1248
  return statements.find((structure) => {
1077
1249
  return structure.kind === import_ts_morph5.StructureKind.ExportDeclaration && structure.namedExports.some((o) => (o.alias || o.name) === name);
1078
1250
  });
1079
1251
  }
1252
+ __name(getExportDeclaration, "getExportDeclaration");
1080
1253
 
1081
1254
  // src/handlers/no-atomic-operations.ts
1082
1255
  function noAtomicOperations(eventEmitter) {
1083
1256
  eventEmitter.on("BeforeInputType", beforeInputType2);
1084
1257
  eventEmitter.on("BeforeGenerateFiles", beforeGenerateFiles2);
1085
1258
  }
1259
+ __name(noAtomicOperations, "noAtomicOperations");
1086
1260
  function beforeInputType2(args) {
1087
- const { inputType: inputType2 } = args;
1088
- for (const field of inputType2.fields) {
1089
- field.inputTypes = field.inputTypes.filter((inputType3) => {
1090
- if (isAtomicOperation(String(inputType3.type))) {
1261
+ const { inputType: inputType1 } = args;
1262
+ for (const field of inputType1.fields) {
1263
+ field.inputTypes = field.inputTypes.filter((inputType2) => {
1264
+ if (isAtomicOperation(String(inputType2.type))) {
1091
1265
  return false;
1092
1266
  }
1093
1267
  return true;
1094
1268
  });
1095
1269
  }
1096
1270
  }
1271
+ __name(beforeInputType2, "beforeInputType");
1097
1272
  function beforeGenerateFiles2(args) {
1098
1273
  var _a;
1099
1274
  const { project } = args;
@@ -1104,9 +1279,11 @@ function beforeGenerateFiles2(args) {
1104
1279
  }
1105
1280
  }
1106
1281
  }
1282
+ __name(beforeGenerateFiles2, "beforeGenerateFiles");
1107
1283
  function isAtomicOperation(name) {
1108
1284
  return name.endsWith("FieldUpdateOperationsInput");
1109
1285
  }
1286
+ __name(isAtomicOperation, "isAtomicOperation");
1110
1287
 
1111
1288
  // src/handlers/output-type.ts
1112
1289
  var import_assert4 = require("assert");
@@ -1114,27 +1291,29 @@ var import_json54 = __toESM(require("json5"));
1114
1291
  var import_lodash6 = require("lodash");
1115
1292
  var import_ts_morph6 = require("ts-morph");
1116
1293
  var nestjsGraphql2 = "@nestjs/graphql";
1117
- function outputType(outputType2, args) {
1294
+ function outputType(outputType1, args) {
1118
1295
  var _a, _b, _c, _d, _e;
1119
- const { getSourceFile, models, eventEmitter, fieldSettings, getModelName: getModelName2 } = args;
1296
+ const { getSourceFile, models, eventEmitter, fieldSettings, getModelName: getModelName2, config } = args;
1120
1297
  const importDeclarations = new ImportDeclarationMap();
1121
1298
  const fileType = "output";
1122
- const modelName = getModelName2(outputType2.name) || "";
1299
+ const modelName = getModelName2(outputType1.name) || "";
1123
1300
  const model = models.get(modelName);
1124
- const isAggregateOutput = model && /(?:Count|Avg|Sum|Min|Max)AggregateOutputType$/.test(outputType2.name) && String(outputType2.name).startsWith(model.name);
1125
- const isCountOutput = (model == null ? void 0 : model.name) && outputType2.name === `${model.name}CountOutputType`;
1126
- outputType2.name = getOutputTypeName(outputType2.name);
1301
+ const isAggregateOutput = model && /(?:Count|Avg|Sum|Min|Max)AggregateOutputType$/.test(outputType1.name) && String(outputType1.name).startsWith(model.name);
1302
+ const isCountOutput = (model == null ? void 0 : model.name) && outputType1.name === `${model.name}CountOutputType`;
1303
+ outputType1.name = getOutputTypeName(outputType1.name);
1127
1304
  if (isAggregateOutput) {
1128
- eventEmitter.emitSync("AggregateOutput", __spreadProps(__spreadValues({}, args), { outputType: outputType2 }));
1305
+ eventEmitter.emitSync("AggregateOutput", __spreadProps(__spreadValues({}, args), {
1306
+ outputType: outputType1
1307
+ }));
1129
1308
  }
1130
1309
  const sourceFile = getSourceFile({
1131
- name: outputType2.name,
1310
+ name: outputType1.name,
1132
1311
  type: fileType
1133
1312
  });
1134
1313
  const classStructure = {
1135
1314
  kind: import_ts_morph6.StructureKind.Class,
1136
1315
  isExported: true,
1137
- name: outputType2.name,
1316
+ name: outputType1.name,
1138
1317
  decorators: [
1139
1318
  {
1140
1319
  name: "ObjectType",
@@ -1145,12 +1324,12 @@ function outputType(outputType2, args) {
1145
1324
  };
1146
1325
  importDeclarations.add("Field", nestjsGraphql2);
1147
1326
  importDeclarations.add("ObjectType", nestjsGraphql2);
1148
- for (const field of outputType2.fields) {
1327
+ for (const field of outputType1.fields) {
1149
1328
  const { location, isList, type } = field.outputType;
1150
1329
  const outputTypeName = getOutputTypeName(String(type));
1151
1330
  const settings = isCountOutput ? void 0 : model && ((_a = fieldSettings.get(model.name)) == null ? void 0 : _a.get(field.name));
1152
1331
  const propertySettings = settings == null ? void 0 : settings.getPropertyType({
1153
- name: outputType2.name,
1332
+ name: outputType1.name,
1154
1333
  output: true
1155
1334
  });
1156
1335
  const isCustomsApplicable = outputTypeName === ((_b = model == null ? void 0 : model.fields.find((f) => f.name === field.name)) == null ? void 0 : _b.type);
@@ -1172,11 +1351,11 @@ function outputType(outputType2, args) {
1172
1351
  }
1173
1352
  let graphqlType;
1174
1353
  const shouldHideField = settings == null ? void 0 : settings.shouldHideField({
1175
- name: outputType2.name,
1354
+ name: outputType1.name,
1176
1355
  output: true
1177
1356
  });
1178
1357
  const fieldType = settings == null ? void 0 : settings.getFieldType({
1179
- name: outputType2.name,
1358
+ name: outputType1.name,
1180
1359
  output: true
1181
1360
  });
1182
1361
  if (fieldType && isCustomsApplicable && !shouldHideField) {
@@ -1184,6 +1363,7 @@ function outputType(outputType2, args) {
1184
1363
  importDeclarations.create(__spreadValues({}, fieldType));
1185
1364
  } else {
1186
1365
  const graphqlImport = getGraphqlImport({
1366
+ config,
1187
1367
  sourceFile,
1188
1368
  fileType,
1189
1369
  location,
@@ -1196,9 +1376,13 @@ function outputType(outputType2, args) {
1196
1376
  if (location === "enumTypes") {
1197
1377
  referenceName = (0, import_lodash6.last)(referenceName.split(" "));
1198
1378
  }
1199
- if (graphqlImport.specifier && !importDeclarations.has(graphqlImport.name) && (graphqlImport.name !== outputType2.name && !shouldHideField || shouldHideField && referenceName === graphqlImport.name)) {
1379
+ if (graphqlImport.specifier && !importDeclarations.has(graphqlImport.name) && (graphqlImport.name !== outputType1.name && !shouldHideField || shouldHideField && referenceName === graphqlImport.name)) {
1200
1380
  importDeclarations.set(graphqlImport.name, {
1201
- namedImports: [{ name: graphqlImport.name }],
1381
+ namedImports: [
1382
+ {
1383
+ name: graphqlImport.name
1384
+ }
1385
+ ],
1202
1386
  moduleSpecifier: graphqlImport.specifier
1203
1387
  });
1204
1388
  }
@@ -1206,7 +1390,10 @@ function outputType(outputType2, args) {
1206
1390
  (0, import_assert4.ok)(property.decorators, "property.decorators is undefined");
1207
1391
  if (shouldHideField) {
1208
1392
  importDeclarations.add("HideField", nestjsGraphql2);
1209
- property.decorators.push({ name: "HideField", arguments: [] });
1393
+ property.decorators.push({
1394
+ name: "HideField",
1395
+ arguments: []
1396
+ });
1210
1397
  } else {
1211
1398
  property.decorators.push({
1212
1399
  name: "Field",
@@ -1237,9 +1424,13 @@ function outputType(outputType2, args) {
1237
1424
  });
1238
1425
  }
1239
1426
  sourceFile.set({
1240
- statements: [...importDeclarations.toStatements(), classStructure]
1427
+ statements: [
1428
+ ...importDeclarations.toStatements(),
1429
+ classStructure
1430
+ ]
1241
1431
  });
1242
1432
  }
1433
+ __name(outputType, "outputType");
1243
1434
 
1244
1435
  // src/handlers/purge-output.ts
1245
1436
  var import_fs = require("fs");
@@ -1247,6 +1438,7 @@ function purgeOutput(emitter) {
1247
1438
  emitter.on("Begin", begin);
1248
1439
  emitter.on("End", end);
1249
1440
  }
1441
+ __name(purgeOutput, "purgeOutput");
1250
1442
  function begin({ project, output }) {
1251
1443
  var _a;
1252
1444
  const sourceFiles = (_a = project.getDirectory(output)) == null ? void 0 : _a.getDescendantSourceFiles();
@@ -1256,33 +1448,39 @@ function begin({ project, output }) {
1256
1448
  }
1257
1449
  }
1258
1450
  }
1451
+ __name(begin, "begin");
1259
1452
  async function end({ project, output }) {
1260
1453
  var _a;
1261
1454
  const directories = (_a = project.getDirectory(output)) == null ? void 0 : _a.getDescendantDirectories().filter((directory) => directory.getSourceFiles().length === 0).map((directory) => directory.getPath());
1262
- for (const directory of directories || []) {
1455
+ for (const directory1 of directories || []) {
1263
1456
  try {
1264
- await import_fs.promises.rmdir(directory);
1457
+ await import_fs.promises.rmdir(directory1);
1265
1458
  } catch (e) {
1266
1459
  }
1267
1460
  }
1268
1461
  }
1462
+ __name(end, "end");
1269
1463
 
1270
1464
  // src/handlers/re-export.ts
1271
1465
  var import_ts_morph7 = require("ts-morph");
1272
- var ReExport = /* @__PURE__ */ ((ReExport2) => {
1466
+ var ReExport;
1467
+ (function(ReExport2) {
1273
1468
  ReExport2["None"] = "None";
1274
1469
  ReExport2["Directories"] = "Directories";
1275
1470
  ReExport2["Single"] = "Single";
1276
1471
  ReExport2["All"] = "All";
1277
- return ReExport2;
1278
- })(ReExport || {});
1472
+ })(ReExport || (ReExport = {}));
1279
1473
  function reExport(emitter) {
1280
1474
  emitter.on("BeforeGenerateFiles", beforeGenerateFiles3);
1281
1475
  }
1476
+ __name(reExport, "reExport");
1282
1477
  function beforeGenerateFiles3(args) {
1283
1478
  const { project, output, config } = args;
1284
1479
  const rootDirectory = project.getDirectoryOrThrow(output);
1285
- if (["Directories" /* Directories */, "All" /* All */].includes(config.reExport)) {
1480
+ if ([
1481
+ ReExport.Directories,
1482
+ ReExport.All
1483
+ ].includes(config.reExport)) {
1286
1484
  for (const directory of rootDirectory.getDirectories()) {
1287
1485
  const exportDeclarations = directory.getSourceFiles().filter((sourceFile) => {
1288
1486
  return sourceFile.getBaseName() !== "index.ts";
@@ -1294,7 +1492,7 @@ function beforeGenerateFiles3(args) {
1294
1492
  });
1295
1493
  }
1296
1494
  }
1297
- if (config.reExport === "Single" /* Single */) {
1495
+ if (config.reExport === ReExport.Single) {
1298
1496
  const exportDeclarations = project.getSourceFiles().filter((sourceFile) => {
1299
1497
  return sourceFile.getBaseName() !== "index.ts";
1300
1498
  }).map((sourceFile) => getExportDeclaration2(rootDirectory, sourceFile));
@@ -1304,7 +1502,7 @@ function beforeGenerateFiles3(args) {
1304
1502
  overwrite: true
1305
1503
  });
1306
1504
  }
1307
- if (config.reExport === "All" /* All */) {
1505
+ if (config.reExport === ReExport.All) {
1308
1506
  const exportDeclarations = [];
1309
1507
  for (const directory of rootDirectory.getDirectories()) {
1310
1508
  const sourceFile = directory.getSourceFileOrThrow("index.ts");
@@ -1317,13 +1515,17 @@ function beforeGenerateFiles3(args) {
1317
1515
  });
1318
1516
  }
1319
1517
  }
1518
+ __name(beforeGenerateFiles3, "beforeGenerateFiles");
1320
1519
  function getExportDeclaration2(directory, sourceFile) {
1321
1520
  return {
1322
1521
  kind: import_ts_morph7.StructureKind.ExportDeclaration,
1323
- namedExports: sourceFile.getExportSymbols().map((s) => ({ name: s.getName() })),
1522
+ namedExports: sourceFile.getExportSymbols().map((s) => ({
1523
+ name: s.getName()
1524
+ })),
1324
1525
  moduleSpecifier: directory.getRelativePathAsModuleSpecifierTo(sourceFile)
1325
1526
  };
1326
1527
  }
1528
+ __name(getExportDeclaration2, "getExportDeclaration");
1327
1529
 
1328
1530
  // src/handlers/register-enum.ts
1329
1531
  var import_ts_morph8 = require("ts-morph");
@@ -1336,7 +1538,11 @@ function registerEnum(enumType, args) {
1336
1538
  });
1337
1539
  const importDeclarations = new ImportDeclarationMap();
1338
1540
  importDeclarations.set("registerEnumType", {
1339
- namedImports: [{ name: "registerEnumType" }],
1541
+ namedImports: [
1542
+ {
1543
+ name: "registerEnumType"
1544
+ }
1545
+ ],
1340
1546
  moduleSpecifier: "@nestjs/graphql"
1341
1547
  });
1342
1548
  const enumStructure = {
@@ -1357,11 +1563,13 @@ function registerEnum(enumType, args) {
1357
1563
  ]
1358
1564
  });
1359
1565
  }
1566
+ __name(registerEnum, "registerEnum");
1360
1567
 
1361
1568
  // src/handlers/require-single-fields-in-whereunique-input.ts
1362
1569
  function requireSingleFieldsInWhereUniqueInput(eventEmitter) {
1363
1570
  eventEmitter.on("BeforeInputType", beforeInputType3);
1364
1571
  }
1572
+ __name(requireSingleFieldsInWhereUniqueInput, "requireSingleFieldsInWhereUniqueInput");
1365
1573
  function beforeInputType3(args) {
1366
1574
  const { inputType: inputType2 } = args;
1367
1575
  if (!isWhereUniqueInputType(inputType2.name) || inputType2.fields.length !== 1) {
@@ -1372,9 +1580,11 @@ function beforeInputType3(args) {
1372
1580
  field.isNullable = false;
1373
1581
  }
1374
1582
  }
1583
+ __name(beforeInputType3, "beforeInputType");
1375
1584
  function isWhereUniqueInputType(name) {
1376
1585
  return name.endsWith("WhereUniqueInput");
1377
1586
  }
1587
+ __name(isWhereUniqueInputType, "isWhereUniqueInputType");
1378
1588
 
1379
1589
  // src/handlers/warning.ts
1380
1590
  function warning(message) {
@@ -1385,6 +1595,7 @@ function warning(message) {
1385
1595
  console.log("prisma-nestjs-graphql:", message);
1386
1596
  }
1387
1597
  }
1598
+ __name(warning, "warning");
1388
1599
 
1389
1600
  // src/helpers/create-config.ts
1390
1601
  var import_assert5 = require("assert");
@@ -1395,7 +1606,9 @@ var import_lodash7 = require("lodash");
1395
1606
  var import_outmatch3 = __toESM(require("outmatch"));
1396
1607
  function createConfig(data) {
1397
1608
  var _a;
1398
- const config = (0, import_lodash7.merge)({}, (0, import_flat.unflatten)(data, { delimiter: "_" }));
1609
+ const config = (0, import_lodash7.merge)({}, (0, import_flat.unflatten)(data, {
1610
+ delimiter: "_"
1611
+ }));
1399
1612
  const $warnings = [];
1400
1613
  const configOutputFilePattern = String(config.outputFilePattern || `{model}/{name}.{type}.ts`);
1401
1614
  let outputFilePattern = (0, import_filenamify.default)(configOutputFilePattern, {
@@ -1421,7 +1634,10 @@ function createConfig(data) {
1421
1634
  defaultImport: toBoolean(value.defaultImport) ? true : value.defaultImport,
1422
1635
  namespaceImport: value.namespaceImport
1423
1636
  };
1424
- return [name, fieldSetting];
1637
+ return [
1638
+ name,
1639
+ fieldSetting
1640
+ ];
1425
1641
  }));
1426
1642
  const decorate = [];
1427
1643
  const configDecorate = Object.values(config.decorate || {});
@@ -1430,8 +1646,12 @@ function createConfig(data) {
1430
1646
  continue;
1431
1647
  (0, import_assert5.ok)(element.from && element.name, `Missed 'from' or 'name' part in configuration for decorate`);
1432
1648
  decorate.push({
1433
- isMatchField: (0, import_outmatch3.default)(element.field, { separator: false }),
1434
- isMatchType: (0, import_outmatch3.default)(element.type, { separator: false }),
1649
+ isMatchField: (0, import_outmatch3.default)(element.field, {
1650
+ separator: false
1651
+ }),
1652
+ isMatchType: (0, import_outmatch3.default)(element.type, {
1653
+ separator: false
1654
+ }),
1435
1655
  from: element.from,
1436
1656
  name: element.name,
1437
1657
  namedImport: toBoolean(element.namedImport),
@@ -1445,7 +1665,7 @@ function createConfig(data) {
1445
1665
  tsConfigFilePath: void 0,
1446
1666
  combineScalarFilters: toBoolean(config.combineScalarFilters),
1447
1667
  noAtomicOperations: toBoolean(config.noAtomicOperations),
1448
- reExport: ReExport[String(config.reExport)] || "None" /* None */,
1668
+ reExport: ReExport[String(config.reExport)] || ReExport.None,
1449
1669
  emitSingle: toBoolean(config.emitSingle),
1450
1670
  emitCompiled: toBoolean(config.emitCompiled),
1451
1671
  $warnings,
@@ -1454,9 +1674,11 @@ function createConfig(data) {
1454
1674
  useInputType: createUseInputType(config.useInputType),
1455
1675
  noTypeId: toBoolean(config.noTypeId),
1456
1676
  requireSingleFieldsInWhereUniqueInput: toBoolean(config.requireSingleFieldsInWhereUniqueInput),
1677
+ graphqlScalars: config.graphqlScalars || {},
1457
1678
  decorate
1458
1679
  };
1459
1680
  }
1681
+ __name(createConfig, "createConfig");
1460
1682
  function createUseInputType(data) {
1461
1683
  if (!data) {
1462
1684
  return [];
@@ -1478,9 +1700,15 @@ function createUseInputType(data) {
1478
1700
  }
1479
1701
  return result;
1480
1702
  }
1703
+ __name(createUseInputType, "createUseInputType");
1481
1704
  function toBoolean(value) {
1482
- return ["true", "1", "on"].includes(String(value));
1705
+ return [
1706
+ "true",
1707
+ "1",
1708
+ "on"
1709
+ ].includes(String(value));
1483
1710
  }
1711
+ __name(toBoolean, "toBoolean");
1484
1712
 
1485
1713
  // src/helpers/generate-file-name.ts
1486
1714
  var import_lodash8 = require("lodash");
@@ -1496,7 +1724,11 @@ function generateFileName(args) {
1496
1724
  },
1497
1725
  get name() {
1498
1726
  let result = (0, import_lodash8.kebabCase)(name);
1499
- for (const suffix of ["input", "args", "enum"]) {
1727
+ for (const suffix of [
1728
+ "input",
1729
+ "args",
1730
+ "enum"
1731
+ ]) {
1500
1732
  const ending = `-${suffix}`;
1501
1733
  if (type === suffix && result.endsWith(ending)) {
1502
1734
  result = result.slice(0, -ending.length);
@@ -1511,12 +1743,13 @@ function generateFileName(args) {
1511
1743
  }
1512
1744
  });
1513
1745
  }
1746
+ __name(generateFileName, "generateFileName");
1514
1747
 
1515
1748
  // src/helpers/factory-get-source-file.ts
1516
- function factoryGetSourceFile(args) {
1517
- const { outputFilePattern, output, getModelName: getModelName2, project } = args;
1518
- return function getSourceFile(args2) {
1519
- const { name, type } = args2;
1749
+ function factoryGetSourceFile(args1) {
1750
+ const { outputFilePattern, output, getModelName: getModelName2, project } = args1;
1751
+ return /* @__PURE__ */ __name(function getSourceFile(args) {
1752
+ const { name, type } = args;
1520
1753
  let filePath = generateFileName({
1521
1754
  getModelName: getModelName2,
1522
1755
  name,
@@ -1525,17 +1758,23 @@ function factoryGetSourceFile(args) {
1525
1758
  });
1526
1759
  filePath = `${output}/${filePath}`;
1527
1760
  return project.getSourceFile(filePath) || project.createSourceFile(filePath);
1528
- };
1761
+ }, "getSourceFile");
1529
1762
  }
1763
+ __name(factoryGetSourceFile, "factoryGetSourceFile");
1530
1764
 
1531
1765
  // src/helpers/get-model-name.ts
1532
1766
  var import_lodash9 = require("lodash");
1533
1767
  function createGetModelName(modelNames) {
1534
1768
  return (0, import_lodash9.memoize)(tryGetName);
1535
1769
  function tryGetName(name) {
1536
- return getModelName({ modelNames, name });
1770
+ return getModelName({
1771
+ modelNames,
1772
+ name
1773
+ });
1537
1774
  }
1775
+ __name(tryGetName, "tryGetName");
1538
1776
  }
1777
+ __name(createGetModelName, "createGetModelName");
1539
1778
  function getModelName(args) {
1540
1779
  const { name, modelNames } = args;
1541
1780
  for (const keyword of splitKeywords) {
@@ -1544,8 +1783,8 @@ function getModelName(args) {
1544
1783
  return test;
1545
1784
  }
1546
1785
  }
1547
- for (const keyword of endsWithKeywords) {
1548
- const [test] = name.split(keyword).slice(-1);
1786
+ for (const keyword1 of endsWithKeywords) {
1787
+ const [test] = name.split(keyword1).slice(-1);
1549
1788
  if (modelNames.includes(test)) {
1550
1789
  return test;
1551
1790
  }
@@ -1573,6 +1812,7 @@ function getModelName(args) {
1573
1812
  }
1574
1813
  return void 0;
1575
1814
  }
1815
+ __name(getModelName, "getModelName");
1576
1816
  var splitKeywords = [
1577
1817
  "CreateInput",
1578
1818
  "CreateMany",
@@ -1628,19 +1868,58 @@ var endsWithKeywords = [
1628
1868
  "UpsertOne"
1629
1869
  ];
1630
1870
  var middleKeywords = [
1631
- ["Aggregate", "Args"],
1632
- ["CreateOne", "Args"],
1633
- ["DeleteMany", "Args"],
1634
- ["DeleteOne", "Args"],
1635
- ["FindMany", "Args"],
1636
- ["FindFirst", "Args"],
1637
- ["FindOne", "Args"],
1638
- ["FindUnique", "Args"],
1639
- ["UpdateMany", "Args"],
1640
- ["UpdateOne", "Args"],
1641
- ["UpsertOne", "Args"],
1642
- ["GroupBy", "Args"],
1643
- ["OrderBy", "Args"]
1871
+ [
1872
+ "Aggregate",
1873
+ "Args"
1874
+ ],
1875
+ [
1876
+ "CreateOne",
1877
+ "Args"
1878
+ ],
1879
+ [
1880
+ "DeleteMany",
1881
+ "Args"
1882
+ ],
1883
+ [
1884
+ "DeleteOne",
1885
+ "Args"
1886
+ ],
1887
+ [
1888
+ "FindMany",
1889
+ "Args"
1890
+ ],
1891
+ [
1892
+ "FindFirst",
1893
+ "Args"
1894
+ ],
1895
+ [
1896
+ "FindOne",
1897
+ "Args"
1898
+ ],
1899
+ [
1900
+ "FindUnique",
1901
+ "Args"
1902
+ ],
1903
+ [
1904
+ "UpdateMany",
1905
+ "Args"
1906
+ ],
1907
+ [
1908
+ "UpdateOne",
1909
+ "Args"
1910
+ ],
1911
+ [
1912
+ "UpsertOne",
1913
+ "Args"
1914
+ ],
1915
+ [
1916
+ "GroupBy",
1917
+ "Args"
1918
+ ],
1919
+ [
1920
+ "OrderBy",
1921
+ "Args"
1922
+ ]
1644
1923
  ];
1645
1924
 
1646
1925
  // src/generate.ts
@@ -1680,7 +1959,7 @@ async function generate(args) {
1680
1959
  }
1681
1960
  config.combineScalarFilters && combineScalarFilters(eventEmitter);
1682
1961
  config.noAtomicOperations && noAtomicOperations(eventEmitter);
1683
- config.reExport !== "None" /* None */ && reExport(eventEmitter);
1962
+ config.reExport !== ReExport.None && reExport(eventEmitter);
1684
1963
  config.emitSingle && emitSingle(eventEmitter);
1685
1964
  config.purgeOutput && purgeOutput(eventEmitter);
1686
1965
  config.requireSingleFieldsInWhereUniqueInput && requireSingleFieldsInWhereUniqueInput(eventEmitter);
@@ -1696,10 +1975,7 @@ async function generate(args) {
1696
1975
  outputFilePattern: config.outputFilePattern,
1697
1976
  eventEmitter
1698
1977
  });
1699
- const {
1700
- datamodel,
1701
- schema: { inputObjectTypes, outputObjectTypes, enumTypes }
1702
- } = JSON.parse(JSON.stringify(dmmf));
1978
+ const { datamodel, schema: { inputObjectTypes, outputObjectTypes, enumTypes } } = JSON.parse(JSON.stringify(dmmf));
1703
1979
  const removeTypes = /* @__PURE__ */ new Set();
1704
1980
  const eventArguments = {
1705
1981
  models,
@@ -1727,26 +2003,29 @@ async function generate(args) {
1727
2003
  for (const enumType of enumTypes.prisma.concat(enumTypes.model || [])) {
1728
2004
  await eventEmitter.emit("EnumType", enumType, eventArguments);
1729
2005
  }
1730
- for (const outputType2 of outputObjectTypes.model) {
1731
- await eventEmitter.emit("ModelOutputType", outputType2, eventArguments);
2006
+ for (const outputType3 of outputObjectTypes.model) {
2007
+ await eventEmitter.emit("ModelOutputType", outputType3, eventArguments);
1732
2008
  }
1733
2009
  const queryOutputTypes = [];
1734
- for (const outputType2 of outputObjectTypes.prisma) {
1735
- if (["Query", "Mutation"].includes(outputType2.name)) {
1736
- queryOutputTypes.push(outputType2);
2010
+ for (const outputType1 of outputObjectTypes.prisma) {
2011
+ if ([
2012
+ "Query",
2013
+ "Mutation"
2014
+ ].includes(outputType1.name)) {
2015
+ queryOutputTypes.push(outputType1);
1737
2016
  continue;
1738
2017
  }
1739
- await eventEmitter.emit("OutputType", outputType2, eventArguments);
2018
+ await eventEmitter.emit("OutputType", outputType1, eventArguments);
1740
2019
  }
1741
2020
  const inputTypes = inputObjectTypes.prisma.concat(inputObjectTypes.model || []);
1742
- for (const inputType2 of inputTypes) {
2021
+ for (const inputType1 of inputTypes) {
1743
2022
  const event = __spreadProps(__spreadValues({}, eventArguments), {
1744
- inputType: inputType2,
2023
+ inputType: inputType1,
1745
2024
  fileType: "input",
1746
2025
  classDecoratorName: "InputType"
1747
2026
  });
1748
- if (inputType2.fields.length === 0) {
1749
- removeTypes.add(inputType2.name);
2027
+ if (inputType1.fields.length === 0) {
2028
+ removeTypes.add(inputType1.name);
1750
2029
  continue;
1751
2030
  }
1752
2031
  await eventEmitter.emit("BeforeInputType", event);
@@ -1764,6 +2043,7 @@ async function generate(args) {
1764
2043
  eventEmitter.off(name);
1765
2044
  }
1766
2045
  }
2046
+ __name(generate, "generate");
1767
2047
 
1768
2048
  // src/index.ts
1769
2049
  (0, import_generator_helper.generatorHandler)({