prisma-nestjs-graphql 18.0.2 → 18.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.
@@ -1,55 +1,41 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
- // If the importer is in node compatibility mode or this is not an ESM
19
- // file that has been converted to a CommonJS file using a Babel-
20
- // compatible transform (i.e. "__esModule" has not been set), then set
21
- // "default" to the CommonJS "module.exports" for node compatibility.
22
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
- mod
24
- ));
1
+ 'use strict';
25
2
 
26
- // src/index.ts
27
- var import_generator_helper = require("@prisma/generator-helper");
3
+ Object.defineProperty(exports, '__esModule', { value: true });
28
4
 
29
- // src/generate.ts
30
- var import_assert6 = require("assert");
31
- var import_await_event_emitter = __toESM(require("await-event-emitter"));
32
- var import_lodash11 = require("lodash");
33
- var import_ts_morph9 = require("ts-morph");
5
+ var assert = require('assert');
6
+ var AwaitEventEmitter = require('await-event-emitter');
7
+ var lodash = require('lodash');
8
+ var tsMorph = require('ts-morph');
9
+ var JSON5 = require('json5');
10
+ var pupa = require('pupa');
11
+ var getRelativePath = require('get-relative-path');
12
+ var outmatch = require('outmatch');
13
+ var gracefulFs = require('graceful-fs');
14
+ var filenamify = require('filenamify');
15
+ var flat = require('flat');
16
+ var pluralize = require('pluralize');
17
+
18
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
+
20
+ var AwaitEventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(AwaitEventEmitter);
21
+ var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5);
22
+ var pupa__default = /*#__PURE__*/_interopDefaultLegacy(pupa);
23
+ var getRelativePath__default = /*#__PURE__*/_interopDefaultLegacy(getRelativePath);
24
+ var outmatch__default = /*#__PURE__*/_interopDefaultLegacy(outmatch);
25
+ var filenamify__default = /*#__PURE__*/_interopDefaultLegacy(filenamify);
26
+ var pluralize__default = /*#__PURE__*/_interopDefaultLegacy(pluralize);
34
27
 
35
- // src/helpers/pascal-case.ts
36
- var import_lodash = require("lodash");
37
28
  function pascalCase(string) {
38
- return (0, import_lodash.startCase)((0, import_lodash.camelCase)(string)).replace(/ /g, "");
29
+ return lodash.startCase(lodash.camelCase(string)).replace(/ /g, "");
39
30
  }
40
- __name(pascalCase, "pascalCase");
41
31
 
42
- // src/handlers/args-type.ts
43
32
  function argsType(field, args) {
44
- if ([
45
- "queryRaw",
46
- "executeRaw"
47
- ].includes(field.name)) {
33
+ if (["queryRaw", "executeRaw"].includes(field.name)) {
48
34
  return;
49
35
  }
50
- const { eventEmitter, typeNames, getModelName: getModelName2 } = args;
36
+ const { eventEmitter, typeNames, getModelName } = args;
51
37
  let className = pascalCase(`${field.name}Args`);
52
- const modelName = getModelName2(className) || "";
38
+ const modelName = getModelName(className) || "";
53
39
  switch (className) {
54
40
  case `Aggregate${modelName}Args`: {
55
41
  className = `${modelName}AggregateArgs`;
@@ -60,39 +46,25 @@ function argsType(field, args) {
60
46
  break;
61
47
  }
62
48
  }
63
- const inputType2 = {
49
+ const inputType = {
64
50
  // eslint-disable-next-line unicorn/no-null
65
- constraints: {
66
- maxNumFields: null,
67
- minNumFields: null
68
- },
51
+ constraints: { maxNumFields: null, minNumFields: null },
69
52
  name: className,
70
- fields: [
71
- ...field.args
72
- ]
53
+ fields: [...field.args]
73
54
  };
74
- if (!field.args.some((x) => x.name === "_count") && [
75
- `${modelName}AggregateArgs`,
76
- `${modelName}GroupByArgs`
77
- ].includes(className)) {
78
- const names = [
79
- "Count",
80
- "Avg",
81
- "Sum",
82
- "Min",
83
- "Max"
84
- ];
85
- if (`${modelName}GroupByArgs` === inputType2.name) {
86
- const byField = inputType2.fields.find((f) => f.name === "by");
87
- if (byField?.inputTypes) {
88
- byField.inputTypes = byField.inputTypes.filter((inputType3) => inputType3.isList);
55
+ if (!field.args.some((x) => x.name === "_count") && [`${modelName}AggregateArgs`, `${modelName}GroupByArgs`].includes(className)) {
56
+ const names = ["Count", "Avg", "Sum", "Min", "Max"];
57
+ if (`${modelName}GroupByArgs` === inputType.name) {
58
+ const byField = inputType.fields.find((f) => f.name === "by");
59
+ if (byField == null ? void 0 : byField.inputTypes) {
60
+ byField.inputTypes = byField.inputTypes.filter((inputType2) => inputType2.isList);
89
61
  }
90
62
  }
91
63
  for (const name of names) {
92
64
  if (!typeNames.has(`${modelName}${name}AggregateInput`)) {
93
65
  continue;
94
66
  }
95
- inputType2.fields.push({
67
+ inputType.fields.push({
96
68
  name: `_${name.toLowerCase()}`,
97
69
  isRequired: false,
98
70
  isNullable: true,
@@ -108,29 +80,24 @@ function argsType(field, args) {
108
80
  }
109
81
  eventEmitter.emitSync("InputType", {
110
82
  ...args,
111
- inputType: inputType2,
83
+ inputType,
112
84
  fileType: "args",
113
85
  classDecoratorName: "ArgsType"
114
86
  });
115
87
  }
116
- __name(argsType, "argsType");
117
88
 
118
- // src/handlers/combine-scalar-filters.ts
119
- var import_lodash2 = require("lodash");
120
89
  function combineScalarFilters(eventEmitter) {
121
- eventEmitter.on("BeforeInputType", beforeInputType);
90
+ eventEmitter.on("BeforeInputType", beforeInputType$2);
122
91
  eventEmitter.on("BeforeGenerateField", beforeGenerateField);
123
92
  eventEmitter.on("PostBegin", postBegin);
124
93
  }
125
- __name(combineScalarFilters, "combineScalarFilters");
126
- function beforeInputType(args) {
127
- const { inputType: inputType2, removeTypes } = args;
128
- if (isContainBogus(inputType2.name) && isScalarFilter(inputType2)) {
129
- removeTypes.add(inputType2.name);
130
- inputType2.name = replaceBogus(inputType2.name);
94
+ function beforeInputType$2(args) {
95
+ const { inputType, removeTypes } = args;
96
+ if (isContainBogus(inputType.name) && isScalarFilter(inputType)) {
97
+ removeTypes.add(inputType.name);
98
+ inputType.name = replaceBogus(inputType.name);
131
99
  }
132
100
  }
133
- __name(beforeInputType, "beforeInputType");
134
101
  function beforeGenerateField(field) {
135
102
  for (const fieldInput of field.inputTypes) {
136
103
  if (fieldInput.location !== "inputObjectTypes") {
@@ -142,32 +109,25 @@ function beforeGenerateField(field) {
142
109
  }
143
110
  }
144
111
  }
145
- __name(beforeGenerateField, "beforeGenerateField");
146
112
  function replaceBogus(name) {
147
113
  return name.replace(/(Nullable|Nested)/g, "");
148
114
  }
149
- __name(replaceBogus, "replaceBogus");
150
115
  function isContainBogus(name) {
151
116
  return name.startsWith("Nested") || name.includes("Nullable") && name.endsWith("Filter") || name.endsWith("NullableFilter");
152
117
  }
153
- __name(isContainBogus, "isContainBogus");
154
- function isScalarFilter(inputType2) {
155
- if (!inputType2.name.endsWith("Filter")) {
118
+ function isScalarFilter(inputType) {
119
+ if (!inputType.name.endsWith("Filter")) {
156
120
  return false;
157
121
  }
158
122
  let result = false;
159
- const equals = inputType2.fields.find((f) => f.name === "equals");
123
+ const equals = inputType.fields.find((f) => f.name === "equals");
160
124
  if (equals) {
161
125
  result = equals.inputTypes.every((x) => {
162
- return [
163
- "enumTypes",
164
- "scalar"
165
- ].includes(x.location);
126
+ return ["enumTypes", "scalar"].includes(x.location);
166
127
  });
167
128
  }
168
129
  return result;
169
130
  }
170
- __name(isScalarFilter, "isScalarFilter");
171
131
  function postBegin(args) {
172
132
  const { schema } = args;
173
133
  const inputTypes = schema.inputObjectTypes.prisma;
@@ -187,21 +147,18 @@ function postBegin(args) {
187
147
  const { name } = enumType;
188
148
  types.push(`Enum${name}`);
189
149
  }
190
- const inputTypeByName = (0, import_lodash2.keyBy)(inputTypes, (inputType2) => inputType2.name);
191
- const replaceBogusFilters = /* @__PURE__ */ __name((filterName, filterNameCandidates) => {
150
+ const inputTypeByName = lodash.keyBy(inputTypes, (inputType) => inputType.name);
151
+ const replaceBogusFilters = (filterName, filterNameCandidates) => {
192
152
  for (const filterNameCandidate of filterNameCandidates) {
193
153
  const candidate = inputTypeByName[filterNameCandidate];
194
154
  if (candidate) {
195
- const inputType2 = (0, import_lodash2.cloneDeep)({
196
- ...candidate,
197
- name: filterName
198
- });
199
- inputTypes.push(inputType2);
200
- inputTypeByName[filterName] = inputType2;
155
+ const inputType = lodash.cloneDeep({ ...candidate, name: filterName });
156
+ inputTypes.push(inputType);
157
+ inputTypeByName[filterName] = inputType;
201
158
  break;
202
159
  }
203
160
  }
204
- }, "replaceBogusFilters");
161
+ };
205
162
  for (const type of types) {
206
163
  replaceBogusFilters(`${type}Filter`, [
207
164
  `${type}NullableFilter`,
@@ -216,54 +173,46 @@ function postBegin(args) {
216
173
  `Nested${type}NullableListFilter`
217
174
  ]);
218
175
  }
219
- (0, import_lodash2.remove)(inputTypes, (inputType2) => isContainBogus(inputType2.name));
176
+ lodash.remove(inputTypes, (inputType) => isContainBogus(inputType.name));
220
177
  }
221
- __name(postBegin, "postBegin");
222
178
 
223
- // src/handlers/create-aggregate-input.ts
224
179
  function createAggregateInput(args) {
225
- const { eventEmitter, outputType: outputType2 } = args;
226
- const className = `${outputType2.name}Input`;
227
- const inputType2 = {
180
+ const { eventEmitter, outputType } = args;
181
+ const className = `${outputType.name}Input`;
182
+ const inputType = {
228
183
  // eslint-disable-next-line unicorn/no-null
229
- constraints: {
230
- maxNumFields: null,
231
- minNumFields: null
232
- },
184
+ constraints: { maxNumFields: null, minNumFields: null },
233
185
  name: className,
234
- fields: outputType2.fields.map((x) => ({
235
- name: x.name,
236
- isNullable: x.isNullable ?? true,
237
- isRequired: false,
238
- inputTypes: [
239
- {
240
- isList: false,
241
- type: "true",
242
- location: "scalar"
243
- }
244
- ]
245
- }))
186
+ fields: outputType.fields.map((x) => {
187
+ var _a;
188
+ return {
189
+ name: x.name,
190
+ isNullable: (_a = x.isNullable) != null ? _a : true,
191
+ isRequired: false,
192
+ inputTypes: [
193
+ {
194
+ isList: false,
195
+ type: "true",
196
+ location: "scalar"
197
+ }
198
+ ]
199
+ };
200
+ })
246
201
  };
247
202
  eventEmitter.emitSync("InputType", {
248
203
  ...args,
249
- inputType: inputType2,
204
+ inputType,
250
205
  fileType: "input",
251
206
  classDecoratorName: "InputType"
252
207
  });
253
208
  }
254
- __name(createAggregateInput, "createAggregateInput");
255
209
 
256
- // src/handlers/emit-single.ts
257
210
  function emitSingle(emitter) {
258
211
  emitter.on("ClassProperty", classProperty);
259
212
  }
260
- __name(emitSingle, "emitSingle");
261
213
  function classProperty(property, eventArguments) {
262
214
  const { location, isList, propertyType } = eventArguments;
263
- if ([
264
- "inputObjectTypes",
265
- "outputObjectTypes"
266
- ].includes(location) && !isList) {
215
+ if (["inputObjectTypes", "outputObjectTypes"].includes(location) && !isList) {
267
216
  const types = propertyType.filter((t) => t !== "null");
268
217
  property.type = types.map((t) => `InstanceType<typeof ${t}>`).join(" | ");
269
218
  if (types.length !== propertyType.length) {
@@ -271,25 +220,11 @@ function classProperty(property, eventArguments) {
271
220
  }
272
221
  }
273
222
  }
274
- __name(classProperty, "classProperty");
275
-
276
- // src/handlers/generate-files.ts
277
- var import_assert = require("assert");
278
- var import_ts_morph2 = require("ts-morph");
279
223
 
280
- // src/helpers/import-declaration-map.ts
281
- var import_ts_morph = require("ts-morph");
282
- var ImportDeclarationMap = class extends Map {
224
+ class ImportDeclarationMap extends Map {
283
225
  add(name, value) {
284
226
  if (!this.has(name)) {
285
- const structure = typeof value === "string" ? {
286
- moduleSpecifier: value,
287
- namedImports: [
288
- {
289
- name
290
- }
291
- ]
292
- } : value;
227
+ const structure = typeof value === "string" ? { moduleSpecifier: value, namedImports: [{ name }] } : value;
293
228
  this.set(name, structure);
294
229
  }
295
230
  }
@@ -303,11 +238,7 @@ var ImportDeclarationMap = class extends Map {
303
238
  namespaceImport: void 0
304
239
  };
305
240
  if (namedImport === true && namespaceImport) {
306
- value.namedImports = [
307
- {
308
- name: namespaceImport
309
- }
310
- ];
241
+ value.namedImports = [{ name: namespaceImport }];
311
242
  name = namespaceImport;
312
243
  } else if (defaultImport) {
313
244
  value.defaultImport = defaultImport === true ? name : defaultImport;
@@ -316,11 +247,7 @@ var ImportDeclarationMap = class extends Map {
316
247
  value.namespaceImport = namespaceImport;
317
248
  name = namespaceImport;
318
249
  } else {
319
- value.namedImports = [
320
- {
321
- name
322
- }
323
- ];
250
+ value.namedImports = [{ name }];
324
251
  }
325
252
  this.add(name, value);
326
253
  }
@@ -330,23 +257,20 @@ var ImportDeclarationMap = class extends Map {
330
257
  while (result.value) {
331
258
  yield {
332
259
  ...result.value,
333
- kind: import_ts_morph.StructureKind.ImportDeclaration
260
+ kind: tsMorph.StructureKind.ImportDeclaration
334
261
  };
335
262
  result = iterator.next();
336
263
  }
337
264
  }
338
- };
339
- __name(ImportDeclarationMap, "ImportDeclarationMap");
265
+ }
340
266
 
341
- // src/handlers/generate-files.ts
342
267
  async function generateFiles(args) {
343
268
  const { project, config, output, eventEmitter } = args;
344
269
  if (config.emitSingle) {
345
270
  const rootDirectory = project.getDirectory(output) || project.createDirectory(output);
346
- const sourceFile = rootDirectory.getSourceFile("index.ts") || rootDirectory.createSourceFile("index.ts", void 0, {
347
- overwrite: true
348
- });
271
+ const sourceFile = rootDirectory.getSourceFile("index.ts") || rootDirectory.createSourceFile("index.ts", void 0, { overwrite: true });
349
272
  const statements = project.getSourceFiles().flatMap((s) => {
273
+ var _a, _b;
350
274
  if (s === sourceFile) {
351
275
  return [];
352
276
  }
@@ -354,13 +278,16 @@ async function generateFiles(args) {
354
278
  const statements2 = s.getStructure().statements;
355
279
  if (Array.isArray(statements2)) {
356
280
  for (const statement of statements2) {
357
- if (!(typeof statement === "object" && statement.kind === import_ts_morph2.StructureKind.Class)) {
281
+ if (!(typeof statement === "object" && statement.kind === tsMorph.StructureKind.Class)) {
358
282
  continue;
359
283
  }
360
284
  for (const property of statement.properties || []) {
361
285
  for (const decorator of property.decorators || []) {
362
- const fullName = classDeclaration?.getProperty(property.name)?.getDecorator(decorator.name)?.getFullName();
363
- (0, import_assert.ok)(fullName, `Cannot get full name of decorator of class ${statement.name}`);
286
+ const fullName = (_b = (_a = classDeclaration == null ? void 0 : classDeclaration.getProperty(property.name)) == null ? void 0 : _a.getDecorator(decorator.name)) == null ? void 0 : _b.getFullName();
287
+ assert.ok(
288
+ fullName,
289
+ `Cannot get full name of decorator of class ${statement.name}`
290
+ );
364
291
  decorator.name = fullName;
365
292
  }
366
293
  }
@@ -380,7 +307,7 @@ async function generateFiles(args) {
380
307
  continue;
381
308
  }
382
309
  switch (statement.kind) {
383
- case import_ts_morph2.StructureKind.ImportDeclaration: {
310
+ case tsMorph.StructureKind.ImportDeclaration: {
384
311
  if (statement.moduleSpecifier.startsWith("./") || statement.moduleSpecifier.startsWith("..")) {
385
312
  continue;
386
313
  }
@@ -404,23 +331,19 @@ async function generateFiles(args) {
404
331
  }
405
332
  break;
406
333
  }
407
- case import_ts_morph2.StructureKind.Enum: {
334
+ case tsMorph.StructureKind.Enum: {
408
335
  enums.unshift(statement);
409
336
  break;
410
337
  }
411
- case import_ts_morph2.StructureKind.Class: {
338
+ case tsMorph.StructureKind.Class: {
412
339
  classes.push(statement);
413
340
  break;
414
341
  }
415
342
  }
416
343
  }
417
344
  sourceFile.set({
418
- kind: import_ts_morph2.StructureKind.SourceFile,
419
- statements: [
420
- ...imports.toStatements(),
421
- ...enums,
422
- ...classes
423
- ]
345
+ kind: tsMorph.StructureKind.SourceFile,
346
+ statements: [...imports.toStatements(), ...enums, ...classes]
424
347
  });
425
348
  }
426
349
  if (config.emitCompiled) {
@@ -441,16 +364,7 @@ async function generateFiles(args) {
441
364
  await project.save();
442
365
  }
443
366
  }
444
- __name(generateFiles, "generateFiles");
445
367
 
446
- // src/handlers/input-type.ts
447
- var import_assert2 = require("assert");
448
- var import_json5 = __toESM(require("json5"));
449
- var import_lodash4 = require("lodash");
450
- var import_pupa = __toESM(require("pupa"));
451
- var import_ts_morph4 = require("ts-morph");
452
-
453
- // src/helpers/file-type-by-location.ts
454
368
  function fileTypeByLocation(fieldLocation) {
455
369
  switch (fieldLocation) {
456
370
  case "inputObjectTypes": {
@@ -465,10 +379,7 @@ function fileTypeByLocation(fieldLocation) {
465
379
  }
466
380
  return "object";
467
381
  }
468
- __name(fileTypeByLocation, "fileTypeByLocation");
469
382
 
470
- // src/helpers/relative-path.ts
471
- var import_get_relative_path = __toESM(require("get-relative-path"));
472
383
  function relativePath(from, to) {
473
384
  if (!from.startsWith("/")) {
474
385
  from = `/${from}`;
@@ -476,7 +387,7 @@ function relativePath(from, to) {
476
387
  if (!to.startsWith("/")) {
477
388
  to = `/${to}`;
478
389
  }
479
- let result = (0, import_get_relative_path.default)(from, to);
390
+ let result = getRelativePath__default["default"](from, to);
480
391
  if (!result.startsWith(".")) {
481
392
  result = `./${result}`;
482
393
  }
@@ -485,45 +396,37 @@ function relativePath(from, to) {
485
396
  }
486
397
  return result;
487
398
  }
488
- __name(relativePath, "relativePath");
489
399
 
490
- // src/helpers/get-graphql-import.ts
491
400
  function getGraphqlImport(args) {
492
- const { config, fileType, location, typeName, isId, noTypeId, sourceFile, getSourceFile } = args;
401
+ const {
402
+ config,
403
+ fileType,
404
+ location,
405
+ typeName,
406
+ isId,
407
+ noTypeId,
408
+ sourceFile,
409
+ getSourceFile
410
+ } = args;
493
411
  if (location === "scalar") {
494
412
  if (isId && !noTypeId) {
495
- return {
496
- name: "ID",
497
- specifier: "@nestjs/graphql"
498
- };
413
+ return { name: "ID", specifier: "@nestjs/graphql" };
499
414
  }
500
415
  const graphqlType = config.graphqlScalars[typeName];
501
416
  if (graphqlType) {
502
- return {
503
- name: graphqlType.name,
504
- specifier: graphqlType.specifier
505
- };
417
+ return { name: graphqlType.name, specifier: graphqlType.specifier };
506
418
  }
507
419
  switch (typeName) {
508
420
  case "Float":
509
421
  case "Int": {
510
- return {
511
- name: typeName,
512
- specifier: "@nestjs/graphql"
513
- };
422
+ return { name: typeName, specifier: "@nestjs/graphql" };
514
423
  }
515
424
  case "DateTime": {
516
- return {
517
- name: "Date",
518
- specifier: void 0
519
- };
425
+ return { name: "Date", specifier: void 0 };
520
426
  }
521
427
  case "true":
522
428
  case "Boolean": {
523
- return {
524
- name: "Boolean",
525
- specifier: void 0
526
- };
429
+ return { name: "Boolean", specifier: void 0 };
527
430
  }
528
431
  case "Decimal": {
529
432
  return {
@@ -532,46 +435,33 @@ function getGraphqlImport(args) {
532
435
  };
533
436
  }
534
437
  case "Json": {
535
- return {
536
- name: "GraphQLJSON",
537
- specifier: "graphql-type-json"
538
- };
438
+ return { name: "GraphQLJSON", specifier: "graphql-type-json" };
539
439
  }
540
440
  }
541
- return {
542
- name: "String",
543
- specifier: void 0
544
- };
441
+ return { name: "String", specifier: void 0 };
545
442
  }
546
443
  let sourceFileType = fileTypeByLocation(location);
547
444
  if (sourceFileType === "output" && fileType === "model") {
548
445
  sourceFileType = "model";
549
446
  }
550
- const specifier = relativePath(sourceFile.getFilePath(), getSourceFile({
551
- type: sourceFileType,
552
- name: typeName
553
- }).getFilePath());
554
- return {
555
- name: typeName,
556
- specifier
557
- };
447
+ const specifier = relativePath(
448
+ sourceFile.getFilePath(),
449
+ getSourceFile({
450
+ type: sourceFileType,
451
+ name: typeName
452
+ }).getFilePath()
453
+ );
454
+ return { name: typeName, specifier };
558
455
  }
559
- __name(getGraphqlImport, "getGraphqlImport");
560
456
 
561
- // src/helpers/get-graphql-input-type.ts
562
- var import_lodash3 = require("lodash");
563
- var import_outmatch = __toESM(require("outmatch"));
564
457
  function getGraphqlInputType(inputTypes, pattern) {
565
458
  let result;
566
- inputTypes = inputTypes.filter((t) => ![
567
- "null",
568
- "Null"
569
- ].includes(String(t.type)));
570
- inputTypes = (0, import_lodash3.uniqWith)(inputTypes, import_lodash3.isEqual);
459
+ inputTypes = inputTypes.filter((t) => !["null", "Null"].includes(String(t.type)));
460
+ inputTypes = lodash.uniqWith(inputTypes, lodash.isEqual);
571
461
  if (inputTypes.length === 1) {
572
462
  return inputTypes[0];
573
463
  }
574
- const countTypes = (0, import_lodash3.countBy)(inputTypes, (x) => x.location);
464
+ const countTypes = lodash.countBy(inputTypes, (x) => x.location);
575
465
  const isOneType = Object.keys(countTypes).length === 1;
576
466
  if (isOneType) {
577
467
  result = inputTypes.find((x) => x.isList);
@@ -582,9 +472,7 @@ function getGraphqlInputType(inputTypes, pattern) {
582
472
  if (pattern) {
583
473
  if (pattern.startsWith("matcher:") || pattern.startsWith("match:")) {
584
474
  const { 1: patternValue } = pattern.split(":", 2);
585
- const isMatch = (0, import_outmatch.default)(patternValue, {
586
- separator: false
587
- });
475
+ const isMatch = outmatch__default["default"](patternValue, { separator: false });
588
476
  result = inputTypes.find((x) => isMatch(String(x.type)));
589
477
  if (result) {
590
478
  return result;
@@ -606,11 +494,15 @@ function getGraphqlInputType(inputTypes, pattern) {
606
494
  }
607
495
  }
608
496
  if ((countTypes.scalar >= 1 || countTypes.enumTypes >= 1) && countTypes.fieldRefTypes === 1) {
609
- result = inputTypes.find((x) => (x.location === "scalar" || x.location === "enumTypes") && x.isList);
497
+ result = inputTypes.find(
498
+ (x) => (x.location === "scalar" || x.location === "enumTypes") && x.isList
499
+ );
610
500
  if (result) {
611
501
  return result;
612
502
  }
613
- result = inputTypes.find((x) => x.location === "scalar" || x.location === "enumTypes");
503
+ result = inputTypes.find(
504
+ (x) => x.location === "scalar" || x.location === "enumTypes"
505
+ );
614
506
  if (result) {
615
507
  return result;
616
508
  }
@@ -620,105 +512,88 @@ function getGraphqlInputType(inputTypes, pattern) {
620
512
  `Cannot get matching input type from ${inputTypes.map((x) => x.type).join(", ") || "zero length inputTypes"}`
621
513
  );
622
514
  }
623
- __name(getGraphqlInputType, "getGraphqlInputType");
624
515
 
625
- // src/helpers/get-property-type.ts
626
516
  function getPropertyType(args) {
627
517
  const { type, location } = args;
628
518
  switch (type) {
629
519
  case "Float":
630
520
  case "Int": {
631
- return [
632
- "number"
633
- ];
521
+ return ["number"];
634
522
  }
635
523
  case "String": {
636
- return [
637
- "string"
638
- ];
524
+ return ["string"];
639
525
  }
640
526
  case "Boolean": {
641
- return [
642
- "boolean"
643
- ];
527
+ return ["boolean"];
644
528
  }
645
529
  case "DateTime": {
646
- return [
647
- "Date",
648
- "string"
649
- ];
530
+ return ["Date", "string"];
650
531
  }
651
532
  case "Decimal": {
652
- return [
653
- "Decimal"
654
- ];
533
+ return ["Decimal"];
655
534
  }
656
535
  case "Json": {
657
- return [
658
- "any"
659
- ];
536
+ return ["any"];
660
537
  }
661
538
  case "Null": {
662
- return [
663
- "null"
664
- ];
539
+ return ["null"];
665
540
  }
666
541
  case "Bytes": {
667
- return [
668
- "Buffer"
669
- ];
542
+ return ["Buffer"];
670
543
  }
671
544
  case "BigInt": {
672
- return [
673
- "bigint",
674
- "number"
675
- ];
545
+ return ["bigint", "number"];
676
546
  }
677
547
  }
678
- if ([
679
- "inputObjectTypes",
680
- "outputObjectTypes"
681
- ].includes(location)) {
682
- return [
683
- type
684
- ];
548
+ if (["inputObjectTypes", "outputObjectTypes"].includes(location)) {
549
+ return [type];
685
550
  }
686
551
  if (location === "enumTypes") {
687
- return [
688
- `keyof typeof ${type}`
689
- ];
552
+ return [`keyof typeof ${type}`];
690
553
  }
691
554
  if (location === "scalar") {
692
- return [
693
- type
694
- ];
555
+ return [type];
695
556
  }
696
- return [
697
- "unknown"
698
- ];
557
+ return ["unknown"];
699
558
  }
700
- __name(getPropertyType, "getPropertyType");
701
559
 
702
- // src/helpers/property-structure.ts
703
- var import_ts_morph3 = require("ts-morph");
704
560
  function propertyStructure(args) {
705
- const { isNullable, propertyType, name, isList, hasQuestionToken, hasExclamationToken } = args;
561
+ const {
562
+ isNullable,
563
+ propertyType,
564
+ name,
565
+ isList,
566
+ hasQuestionToken,
567
+ hasExclamationToken
568
+ } = args;
706
569
  const type = propertyType.map((type2) => isList ? `Array<${type2}>` : type2).join(" | ");
707
570
  return {
708
- kind: import_ts_morph3.StructureKind.Property,
571
+ kind: tsMorph.StructureKind.Property,
709
572
  name,
710
573
  type,
711
- hasQuestionToken: hasQuestionToken ?? isNullable,
712
- hasExclamationToken: hasExclamationToken ?? !isNullable,
574
+ hasQuestionToken: hasQuestionToken != null ? hasQuestionToken : isNullable,
575
+ hasExclamationToken: hasExclamationToken != null ? hasExclamationToken : !isNullable,
713
576
  decorators: [],
714
577
  leadingTrivia: "\n"
715
578
  };
716
579
  }
717
- __name(propertyStructure, "propertyStructure");
718
580
 
719
- // src/handlers/input-type.ts
720
581
  function inputType(args) {
721
- const { classDecoratorName, classTransformerTypeModels, config, eventEmitter, fieldSettings, fileType, getModelName: getModelName2, getSourceFile, inputType: inputType2, models, removeTypes, typeNames } = args;
582
+ var _a, _b, _c, _d;
583
+ const {
584
+ classDecoratorName,
585
+ classTransformerTypeModels,
586
+ config,
587
+ eventEmitter,
588
+ fieldSettings,
589
+ fileType,
590
+ getModelName,
591
+ getSourceFile,
592
+ inputType: inputType2,
593
+ models,
594
+ removeTypes,
595
+ typeNames
596
+ } = args;
722
597
  typeNames.add(inputType2.name);
723
598
  const importDeclarations = new ImportDeclarationMap();
724
599
  const sourceFile = getSourceFile({
@@ -726,7 +601,7 @@ function inputType(args) {
726
601
  type: fileType
727
602
  });
728
603
  const classStructure = {
729
- kind: import_ts_morph4.StructureKind.Class,
604
+ kind: tsMorph.StructureKind.Class,
730
605
  isExported: true,
731
606
  name: inputType2.name,
732
607
  decorators: [
@@ -737,26 +612,20 @@ function inputType(args) {
737
612
  ],
738
613
  properties: []
739
614
  };
740
- const modelName = getModelName2(inputType2.name) || "";
615
+ const modelName = getModelName(inputType2.name) || "";
741
616
  const model = models.get(modelName);
742
617
  const modelFieldSettings = model && fieldSettings.get(model.name);
743
618
  const moduleSpecifier = "@nestjs/graphql";
744
619
  importDeclarations.set("Field", {
745
- namedImports: [
746
- {
747
- name: "Field"
748
- }
749
- ],
620
+ namedImports: [{ name: "Field" }],
750
621
  moduleSpecifier
751
622
  }).set(classDecoratorName, {
752
- namedImports: [
753
- {
754
- name: classDecoratorName
755
- }
756
- ],
623
+ namedImports: [{ name: classDecoratorName }],
757
624
  moduleSpecifier
758
625
  });
759
- const useInputType = config.useInputType.find((x) => inputType2.name.includes(x.typeName));
626
+ const useInputType = config.useInputType.find(
627
+ (x) => inputType2.name.includes(x.typeName)
628
+ );
760
629
  for (const field of inputType2.fields) {
761
630
  field.inputTypes = field.inputTypes.filter((t) => !removeTypes.has(String(t.type)));
762
631
  eventEmitter.emitSync("BeforeGenerateField", field, args);
@@ -764,21 +633,23 @@ function inputType(args) {
764
633
  if (inputTypes.length === 0) {
765
634
  continue;
766
635
  }
767
- const usePattern = useInputType?.ALL || useInputType?.[name];
636
+ const usePattern = (useInputType == null ? void 0 : useInputType.ALL) || (useInputType == null ? void 0 : useInputType[name]);
768
637
  const graphqlInputType = getGraphqlInputType(inputTypes, usePattern);
769
638
  const { isList, location, type } = graphqlInputType;
770
639
  const typeName = String(type);
771
- const settings = modelFieldSettings?.get(name);
772
- const propertySettings = settings?.getPropertyType({
640
+ const settings = modelFieldSettings == null ? void 0 : modelFieldSettings.get(name);
641
+ const propertySettings = settings == null ? void 0 : settings.getPropertyType({
773
642
  name: inputType2.name,
774
643
  input: true
775
644
  });
776
- const modelField = model?.fields.find((f) => f.name === name);
777
- const isCustomsApplicable = typeName === modelField?.type;
778
- const propertyType = (0, import_lodash4.castArray)(propertySettings?.name || getPropertyType({
779
- location,
780
- type: typeName
781
- }));
645
+ const modelField = model == null ? void 0 : model.fields.find((f) => f.name === name);
646
+ const isCustomsApplicable = typeName === (modelField == null ? void 0 : modelField.type);
647
+ const propertyType = lodash.castArray(
648
+ (propertySettings == null ? void 0 : propertySettings.name) || getPropertyType({
649
+ location,
650
+ type: typeName
651
+ })
652
+ );
782
653
  const property = propertyStructure({
783
654
  name,
784
655
  isNullable: !isRequired,
@@ -787,26 +658,24 @@ function inputType(args) {
787
658
  });
788
659
  classStructure.properties.push(property);
789
660
  if (propertySettings) {
790
- importDeclarations.create({
791
- ...propertySettings
792
- });
661
+ importDeclarations.create({ ...propertySettings });
793
662
  } else if (propertyType.includes("Decimal")) {
794
663
  importDeclarations.add("Decimal", "@prisma/client/runtime/library");
795
664
  }
796
665
  let graphqlType;
797
- const shouldHideField = settings?.shouldHideField({
666
+ const shouldHideField = (settings == null ? void 0 : settings.shouldHideField({
798
667
  name: inputType2.name,
799
668
  input: true
800
- }) || config.decorate.some((d) => d.name === "HideField" && d.from === "@nestjs/graphql" && d.isMatchField(name) && d.isMatchType(inputType2.name));
801
- const fieldType = settings?.getFieldType({
669
+ })) || config.decorate.some(
670
+ (d) => d.name === "HideField" && d.from === "@nestjs/graphql" && d.isMatchField(name) && d.isMatchType(inputType2.name)
671
+ );
672
+ const fieldType = settings == null ? void 0 : settings.getFieldType({
802
673
  name: inputType2.name,
803
674
  input: true
804
675
  });
805
676
  if (fieldType && isCustomsApplicable && !shouldHideField) {
806
677
  graphqlType = fieldType.name;
807
- importDeclarations.create({
808
- ...fieldType
809
- });
678
+ importDeclarations.create({ ...fieldType });
810
679
  } else {
811
680
  const graphqlImport = getGraphqlImport({
812
681
  config,
@@ -818,33 +687,26 @@ function inputType(args) {
818
687
  graphqlType = graphqlImport.name;
819
688
  let referenceName = propertyType[0];
820
689
  if (location === "enumTypes") {
821
- referenceName = (0, import_lodash4.last)(referenceName.split(" "));
690
+ referenceName = lodash.last(referenceName.split(" "));
822
691
  }
823
692
  if (graphqlImport.specifier && !importDeclarations.has(graphqlImport.name) && graphqlImport.name !== inputType2.name) {
824
693
  importDeclarations.set(graphqlImport.name, {
825
- namedImports: [
826
- {
827
- name: graphqlImport.name
828
- }
829
- ],
694
+ namedImports: [{ name: graphqlImport.name }],
830
695
  moduleSpecifier: graphqlImport.specifier
831
696
  });
832
697
  }
833
698
  }
834
- (0, import_assert2.ok)(property.decorators, "property.decorators is undefined");
699
+ assert.ok(property.decorators, "property.decorators is undefined");
835
700
  if (shouldHideField) {
836
701
  importDeclarations.add("HideField", "@nestjs/graphql");
837
- property.decorators.push({
838
- name: "HideField",
839
- arguments: []
840
- });
702
+ property.decorators.push({ name: "HideField", arguments: [] });
841
703
  } else {
842
704
  property.decorators.push({
843
705
  name: "Field",
844
706
  arguments: [
845
707
  isList ? `() => [${graphqlType}]` : `() => ${graphqlType}`,
846
- import_json5.default.stringify({
847
- ...settings?.fieldArguments(),
708
+ JSON5__default["default"].stringify({
709
+ ...settings == null ? void 0 : settings.fieldArguments(),
848
710
  nullable: !isRequired
849
711
  })
850
712
  ]
@@ -853,18 +715,17 @@ function inputType(args) {
853
715
  importDeclarations.add("transformToDecimal", "prisma-graphql-type-decimal");
854
716
  importDeclarations.add("Transform", "class-transformer");
855
717
  importDeclarations.add("Type", "class-transformer");
856
- property.decorators.push({
857
- name: "Type",
858
- arguments: [
859
- "() => Object"
860
- ]
861
- }, {
862
- name: "Transform",
863
- arguments: [
864
- "transformToDecimal"
865
- ]
866
- });
867
- } else if (location === "inputObjectTypes" && (modelField?.type === "Decimal" || [
718
+ property.decorators.push(
719
+ {
720
+ name: "Type",
721
+ arguments: ["() => Object"]
722
+ },
723
+ {
724
+ name: "Transform",
725
+ arguments: ["transformToDecimal"]
726
+ }
727
+ );
728
+ } else if (location === "inputObjectTypes" && ((modelField == null ? void 0 : modelField.type) === "Decimal" || [
868
729
  "connect",
869
730
  "connectOrCreate",
870
731
  "create",
@@ -878,23 +739,20 @@ function inputType(args) {
878
739
  "updateMany",
879
740
  "upsert",
880
741
  "where"
881
- ].includes(name) || classTransformerTypeModels.has(getModelName2(graphqlType) || "") || modelField?.kind === "object" && models.get(modelField.type) && models.get(modelField.type)?.fields.some((field2) => field2.kind === "object" && classTransformerTypeModels.has(field2.type)))) {
742
+ ].includes(name) || classTransformerTypeModels.has(getModelName(graphqlType) || "") || (modelField == null ? void 0 : modelField.kind) === "object" && models.get(modelField.type) && ((_a = models.get(modelField.type)) == null ? void 0 : _a.fields.some(
743
+ (field2) => field2.kind === "object" && classTransformerTypeModels.has(field2.type)
744
+ )))) {
882
745
  importDeclarations.add("Type", "class-transformer");
883
- property.decorators.push({
884
- name: "Type",
885
- arguments: [
886
- `() => ${graphqlType}`
887
- ]
888
- });
746
+ property.decorators.push({ name: "Type", arguments: [`() => ${graphqlType}`] });
889
747
  }
890
748
  if (isCustomsApplicable) {
891
749
  for (const options of settings || []) {
892
- if ((options.kind === "Decorator" && options.input && options.match?.(name)) ?? true) {
750
+ if ((_c = options.kind === "Decorator" && options.input && ((_b = options.match) == null ? void 0 : _b.call(options, name))) != null ? _c : true) {
893
751
  property.decorators.push({
894
752
  name: options.name,
895
753
  arguments: options.arguments
896
754
  });
897
- (0, import_assert2.ok)(options.from, "Missed 'from' part in configuration or field setting");
755
+ assert.ok(options.from, "Missed 'from' part in configuration or field setting");
898
756
  importDeclarations.create(options);
899
757
  }
900
758
  }
@@ -903,9 +761,7 @@ function inputType(args) {
903
761
  if (decorate.isMatchField(name) && decorate.isMatchType(inputType2.name)) {
904
762
  property.decorators.push({
905
763
  name: decorate.name,
906
- arguments: decorate.arguments?.map((x) => (0, import_pupa.default)(x, {
907
- propertyType
908
- }))
764
+ arguments: (_d = decorate.arguments) == null ? void 0 : _d.map((x) => pupa__default["default"](x, { propertyType }))
909
765
  });
910
766
  importDeclarations.create(decorate);
911
767
  }
@@ -918,24 +774,27 @@ function inputType(args) {
918
774
  });
919
775
  }
920
776
  sourceFile.set({
921
- statements: [
922
- ...importDeclarations.toStatements(),
923
- classStructure
924
- ]
777
+ statements: [...importDeclarations.toStatements(), classStructure]
925
778
  });
926
779
  }
927
- __name(inputType, "inputType");
928
780
 
929
- // src/helpers/object-settings.ts
930
- var import_json52 = __toESM(require("json5"));
931
- var import_lodash5 = require("lodash");
932
- var import_outmatch2 = __toESM(require("outmatch"));
933
- var ObjectSettings = class extends Array {
934
- shouldHideField({ name, input = false, output = false }) {
781
+ class ObjectSettings extends Array {
782
+ shouldHideField({
783
+ name,
784
+ input = false,
785
+ output = false
786
+ }) {
787
+ var _a;
935
788
  const hideField = this.find((s) => s.name === "HideField");
936
- return Boolean(hideField?.input && input || hideField?.output && output || hideField?.match?.(name));
789
+ return Boolean(
790
+ (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))
791
+ );
937
792
  }
938
- getFieldType({ name, input, output }) {
793
+ getFieldType({
794
+ name,
795
+ input,
796
+ output
797
+ }) {
939
798
  const fieldType = this.find((s) => s.kind === "FieldType");
940
799
  if (!fieldType) {
941
800
  return void 0;
@@ -951,7 +810,11 @@ var ObjectSettings = class extends Array {
951
810
  }
952
811
  return fieldType;
953
812
  }
954
- getPropertyType({ name, input, output }) {
813
+ getPropertyType({
814
+ name,
815
+ input,
816
+ output
817
+ }) {
955
818
  const propertyType = this.find((s) => s.kind === "PropertyType");
956
819
  if (!propertyType) {
957
820
  return void 0;
@@ -968,19 +831,17 @@ var ObjectSettings = class extends Array {
968
831
  return propertyType;
969
832
  }
970
833
  getObjectTypeArguments(options) {
971
- const objectTypeOptions = (0, import_lodash5.merge)({}, options);
972
- const resultArguments = [
973
- objectTypeOptions
974
- ];
834
+ const objectTypeOptions = lodash.merge({}, options);
835
+ const resultArguments = [objectTypeOptions];
975
836
  const objectType = this.find((s) => s.kind === "ObjectType");
976
- if (objectType && (0, import_lodash5.isObject)(objectType.arguments)) {
837
+ if (objectType && lodash.isObject(objectType.arguments)) {
977
838
  const name = objectType.arguments.name;
978
- (0, import_lodash5.merge)(objectTypeOptions, (0, import_lodash5.omit)(objectType.arguments, "name"));
839
+ lodash.merge(objectTypeOptions, lodash.omit(objectType.arguments, "name"));
979
840
  if (name) {
980
841
  resultArguments.unshift(name);
981
842
  }
982
843
  }
983
- return resultArguments.map((x) => import_json52.default.stringify(x));
844
+ return resultArguments.map((x) => JSON5__default["default"].stringify(x));
984
845
  }
985
846
  fieldArguments() {
986
847
  const item = this.find((item2) => item2.kind === "Field");
@@ -988,8 +849,7 @@ var ObjectSettings = class extends Array {
988
849
  return item.arguments;
989
850
  }
990
851
  }
991
- };
992
- __name(ObjectSettings, "ObjectSettings");
852
+ }
993
853
  function createObjectSettings(args) {
994
854
  const { config, text } = args;
995
855
  const result = new ObjectSettings();
@@ -1023,18 +883,23 @@ function createObjectSettings(args) {
1023
883
  documentation: documentationLines.filter(Boolean).join("\n") || void 0
1024
884
  };
1025
885
  }
1026
- __name(createObjectSettings, "createObjectSettings");
1027
- function createSettingElement({ line, config, fieldElement, match }) {
886
+ function createSettingElement({
887
+ line,
888
+ config,
889
+ fieldElement,
890
+ match
891
+ }) {
892
+ var _a, _b, _c, _d, _e;
1028
893
  const result = {
1029
894
  documentLine: "",
1030
895
  element: void 0
1031
896
  };
1032
897
  if (line.startsWith("@deprecated")) {
1033
- fieldElement.arguments["deprecationReason"] = (0, import_lodash5.trim)(line.slice(11));
898
+ fieldElement.arguments["deprecationReason"] = lodash.trim(line.slice(11));
1034
899
  result.element = fieldElement;
1035
900
  return result;
1036
901
  }
1037
- const name = match?.groups?.name;
902
+ const name = (_a = match == null ? void 0 : match.groups) == null ? void 0 : _a.name;
1038
903
  if (!(match && name)) {
1039
904
  result.documentLine = line;
1040
905
  return result;
@@ -1053,24 +918,21 @@ function createSettingElement({ line, config, fieldElement, match }) {
1053
918
  Object.assign(element, hideFieldDecorator(match));
1054
919
  return result;
1055
920
  }
1056
- if ([
1057
- "FieldType",
1058
- "PropertyType"
1059
- ].includes(name) && match.groups?.args) {
921
+ if (["FieldType", "PropertyType"].includes(name) && ((_b = match.groups) == null ? void 0 : _b.args)) {
1060
922
  const options2 = customType(match.groups.args);
1061
- (0, import_lodash5.merge)(element, options2.namespace && config.fields[options2.namespace], options2, {
923
+ lodash.merge(element, options2.namespace && config.fields[options2.namespace], options2, {
1062
924
  kind: name
1063
925
  });
1064
926
  return result;
1065
927
  }
1066
- if (name === "ObjectType" && match.groups?.args) {
928
+ if (name === "ObjectType" && ((_c = match.groups) == null ? void 0 : _c.args)) {
1067
929
  element.kind = "ObjectType";
1068
930
  const options2 = customType(match.groups.args);
1069
931
  if (typeof options2[0] === "string" && options2[0]) {
1070
932
  options2.name = options2[0];
1071
933
  }
1072
- if ((0, import_lodash5.isObject)(options2[1])) {
1073
- (0, import_lodash5.merge)(options2, options2[1]);
934
+ if (lodash.isObject(options2[1])) {
935
+ lodash.merge(options2, options2[1]);
1074
936
  }
1075
937
  element.arguments = {
1076
938
  name: options2.name,
@@ -1078,16 +940,13 @@ function createSettingElement({ line, config, fieldElement, match }) {
1078
940
  };
1079
941
  return result;
1080
942
  }
1081
- if (name === "Directive" && match.groups?.args) {
943
+ if (name === "Directive" && ((_d = match.groups) == null ? void 0 : _d.args)) {
1082
944
  const options2 = customType(match.groups.args);
1083
- (0, import_lodash5.merge)(element, {
1084
- model: true,
1085
- from: "@nestjs/graphql"
1086
- }, options2, {
945
+ lodash.merge(element, { model: true, from: "@nestjs/graphql" }, options2, {
1087
946
  name,
1088
947
  namespace: false,
1089
948
  kind: "Decorator",
1090
- arguments: Array.isArray(options2.arguments) ? options2.arguments.map((s) => import_json52.default.stringify(s)) : options2.arguments
949
+ arguments: Array.isArray(options2.arguments) ? options2.arguments.map((s) => JSON5__default["default"].stringify(s)) : options2.arguments
1091
950
  });
1092
951
  return result;
1093
952
  }
@@ -1095,35 +954,31 @@ function createSettingElement({ line, config, fieldElement, match }) {
1095
954
  element.namespaceImport = namespace;
1096
955
  const options = {
1097
956
  name,
1098
- arguments: (match.groups?.args || "").split(",").map((s) => (0, import_lodash5.trim)(s)).filter(Boolean)
957
+ arguments: (((_e = match.groups) == null ? void 0 : _e.args) || "").split(",").map((s) => lodash.trim(s)).filter(Boolean)
1099
958
  };
1100
- (0, import_lodash5.merge)(element, namespace && config.fields[namespace], options);
959
+ lodash.merge(element, namespace && config.fields[namespace], options);
1101
960
  return result;
1102
961
  }
1103
- __name(createSettingElement, "createSettingElement");
1104
962
  function customType(args) {
963
+ var _a;
1105
964
  const result = {};
1106
965
  let options = parseArgs(args);
1107
966
  if (typeof options === "string") {
1108
- options = {
1109
- name: options
1110
- };
967
+ options = { name: options };
1111
968
  }
1112
969
  Object.assign(result, options);
1113
970
  const namespace = getNamespace(options.name);
1114
971
  result.namespace = namespace;
1115
- if (options.name?.includes(".")) {
972
+ if ((_a = options.name) == null ? void 0 : _a.includes(".")) {
1116
973
  result.namespaceImport = namespace;
1117
974
  }
1118
975
  if (typeof options.match === "string" || Array.isArray(options.match)) {
1119
- result.match = (0, import_outmatch2.default)(options.match, {
1120
- separator: false
1121
- });
976
+ result.match = outmatch__default["default"](options.match, { separator: false });
1122
977
  }
1123
978
  return result;
1124
979
  }
1125
- __name(customType, "customType");
1126
980
  function hideFieldDecorator(match) {
981
+ var _a;
1127
982
  const result = {
1128
983
  name: "HideField",
1129
984
  arguments: [],
@@ -1132,7 +987,7 @@ function hideFieldDecorator(match) {
1132
987
  namespaceImport: void 0,
1133
988
  match: void 0
1134
989
  };
1135
- if (!match.groups?.args) {
990
+ if (!((_a = match.groups) == null ? void 0 : _a.args)) {
1136
991
  result.output = true;
1137
992
  return result;
1138
993
  }
@@ -1141,9 +996,7 @@ function hideFieldDecorator(match) {
1141
996
  result.output = Boolean(options.output);
1142
997
  result.input = Boolean(options.input);
1143
998
  if (typeof options.match === "string" || Array.isArray(options.match)) {
1144
- result.match = (0, import_outmatch2.default)(options.match, {
1145
- separator: false
1146
- });
999
+ result.match = outmatch__default["default"](options.match, { separator: false });
1147
1000
  }
1148
1001
  } else {
1149
1002
  if (/output:\s*true/.test(match.groups.args)) {
@@ -1155,19 +1008,17 @@ function hideFieldDecorator(match) {
1155
1008
  }
1156
1009
  return result;
1157
1010
  }
1158
- __name(hideFieldDecorator, "hideFieldDecorator");
1159
1011
  function parseArgs(string) {
1160
1012
  try {
1161
- return import_json52.default.parse(string);
1013
+ return JSON5__default["default"].parse(string);
1162
1014
  } catch {
1163
1015
  try {
1164
- return import_json52.default.parse(`[${string}]`);
1016
+ return JSON5__default["default"].parse(`[${string}]`);
1165
1017
  } catch {
1166
1018
  throw new Error(`Failed to parse: ${string}`);
1167
1019
  }
1168
1020
  }
1169
1021
  }
1170
- __name(parseArgs, "parseArgs");
1171
1022
  function getNamespace(name) {
1172
1023
  if (name === void 0) {
1173
1024
  return void 0;
@@ -1178,11 +1029,16 @@ function getNamespace(name) {
1178
1029
  }
1179
1030
  return result;
1180
1031
  }
1181
- __name(getNamespace, "getNamespace");
1182
1032
 
1183
- // src/handlers/model-data.ts
1184
1033
  function modelData(model, args) {
1185
- const { config, modelNames, models, modelFields, fieldSettings, classTransformerTypeModels } = args;
1034
+ const {
1035
+ config,
1036
+ modelNames,
1037
+ models,
1038
+ modelFields,
1039
+ fieldSettings,
1040
+ classTransformerTypeModels
1041
+ } = args;
1186
1042
  modelNames.push(model.name);
1187
1043
  models.set(model.name, model);
1188
1044
  const modelFieldsValue = /* @__PURE__ */ new Map();
@@ -1204,56 +1060,46 @@ function modelData(model, args) {
1204
1060
  classTransformerTypeModels.add(model.name);
1205
1061
  }
1206
1062
  }
1207
- __name(modelData, "modelData");
1208
-
1209
- // src/handlers/model-output-type.ts
1210
- var import_assert3 = require("assert");
1211
- var import_json53 = __toESM(require("json5"));
1212
- var import_lodash6 = require("lodash");
1213
- var import_pupa2 = __toESM(require("pupa"));
1214
- var import_ts_morph5 = require("ts-morph");
1215
1063
 
1216
- // src/helpers/create-comment.ts
1217
1064
  function createComment(documentation, settings) {
1065
+ var _a;
1218
1066
  const documentationLines = documentation.split("\n");
1219
- const commentLines = [
1220
- "/**"
1221
- ];
1067
+ const commentLines = ["/**"];
1222
1068
  for (const line of documentationLines) {
1223
1069
  commentLines.push(` * ${line}`);
1224
1070
  }
1225
- const deprecationReason = settings?.fieldArguments()?.deprecationReason;
1071
+ const deprecationReason = (_a = settings == null ? void 0 : settings.fieldArguments()) == null ? void 0 : _a.deprecationReason;
1226
1072
  if (deprecationReason) {
1227
1073
  commentLines.push(` * @deprecated ${deprecationReason}`);
1228
1074
  }
1229
1075
  commentLines.push(" */\n");
1230
1076
  return commentLines.join("\n");
1231
1077
  }
1232
- __name(createComment, "createComment");
1233
1078
 
1234
- // src/helpers/get-output-type-name.ts
1235
1079
  function getOutputTypeName(name) {
1236
1080
  return name.replace(/(?:OutputType|Output)$/, "");
1237
1081
  }
1238
- __name(getOutputTypeName, "getOutputTypeName");
1239
1082
 
1240
- // src/handlers/model-output-type.ts
1241
- var nestjsGraphql = "@nestjs/graphql";
1242
- function modelOutputType(outputType2, args) {
1083
+ const nestjsGraphql$1 = "@nestjs/graphql";
1084
+ function modelOutputType(outputType, args) {
1085
+ var _a, _b, _c, _d, _e, _f;
1243
1086
  const { getSourceFile, models, config, modelFields, fieldSettings, eventEmitter } = args;
1244
- const model = models.get(outputType2.name);
1245
- (0, import_assert3.ok)(model, `Cannot find model by name ${outputType2.name}`);
1087
+ const model = models.get(outputType.name);
1088
+ assert.ok(model, `Cannot find model by name ${outputType.name}`);
1246
1089
  const sourceFile = getSourceFile({
1247
- name: outputType2.name,
1090
+ name: outputType.name,
1248
1091
  type: "model"
1249
1092
  });
1250
1093
  const sourceFileStructure = sourceFile.getStructure();
1251
- const exportDeclaration = getExportDeclaration(model.name, sourceFileStructure.statements);
1094
+ const exportDeclaration = getExportDeclaration$1(
1095
+ model.name,
1096
+ sourceFileStructure.statements
1097
+ );
1252
1098
  const importDeclarations = new ImportDeclarationMap();
1253
1099
  const classStructure = {
1254
- kind: import_ts_morph5.StructureKind.Class,
1100
+ kind: tsMorph.StructureKind.Class,
1255
1101
  isExported: true,
1256
- name: outputType2.name,
1102
+ name: outputType.name,
1257
1103
  decorators: [
1258
1104
  {
1259
1105
  name: "ObjectType",
@@ -1263,9 +1109,9 @@ function modelOutputType(outputType2, args) {
1263
1109
  properties: []
1264
1110
  };
1265
1111
  sourceFileStructure.statements.push(classStructure);
1266
- (0, import_assert3.ok)(classStructure.decorators, "classStructure.decorators is undefined");
1112
+ assert.ok(classStructure.decorators, "classStructure.decorators is undefined");
1267
1113
  const decorator = classStructure.decorators.find((d) => d.name === "ObjectType");
1268
- (0, import_assert3.ok)(decorator, "ObjectType decorator not found");
1114
+ assert.ok(decorator, "ObjectType decorator not found");
1269
1115
  let modelSettings;
1270
1116
  if (model.documentation) {
1271
1117
  const objectTypeOptions = {};
@@ -1282,9 +1128,9 @@ function modelOutputType(outputType2, args) {
1282
1128
  decorator.arguments = settings.getObjectTypeArguments(objectTypeOptions);
1283
1129
  modelSettings = settings;
1284
1130
  }
1285
- importDeclarations.add("Field", nestjsGraphql);
1286
- importDeclarations.add("ObjectType", nestjsGraphql);
1287
- for (const field of outputType2.fields) {
1131
+ importDeclarations.add("Field", nestjsGraphql$1);
1132
+ importDeclarations.add("ObjectType", nestjsGraphql$1);
1133
+ for (const field of outputType.fields) {
1288
1134
  let fileType = "model";
1289
1135
  const { location, isList, type, namespace } = field.outputType;
1290
1136
  let outputTypeName = String(type);
@@ -1292,20 +1138,22 @@ function modelOutputType(outputType2, args) {
1292
1138
  fileType = "output";
1293
1139
  outputTypeName = getOutputTypeName(outputTypeName);
1294
1140
  }
1295
- const modelField = modelFields.get(model.name)?.get(field.name);
1296
- const settings = fieldSettings.get(model.name)?.get(field.name);
1297
- const fieldType = settings?.getFieldType({
1298
- name: outputType2.name,
1141
+ const modelField = (_a = modelFields.get(model.name)) == null ? void 0 : _a.get(field.name);
1142
+ const settings = (_b = fieldSettings.get(model.name)) == null ? void 0 : _b.get(field.name);
1143
+ const fieldType = settings == null ? void 0 : settings.getFieldType({
1144
+ name: outputType.name,
1299
1145
  output: true
1300
1146
  });
1301
- const propertySettings = settings?.getPropertyType({
1302
- name: outputType2.name,
1147
+ const propertySettings = settings == null ? void 0 : settings.getPropertyType({
1148
+ name: outputType.name,
1303
1149
  output: true
1304
1150
  });
1305
- const propertyType = (0, import_lodash6.castArray)(propertySettings?.name || getPropertyType({
1306
- location,
1307
- type: outputTypeName
1308
- }));
1151
+ const propertyType = lodash.castArray(
1152
+ (propertySettings == null ? void 0 : propertySettings.name) || getPropertyType({
1153
+ location,
1154
+ type: outputTypeName
1155
+ })
1156
+ );
1309
1157
  propertyType.splice(1, propertyType.length);
1310
1158
  if (field.isNullable && !isList) {
1311
1159
  propertyType.push("null");
@@ -1313,22 +1161,20 @@ function modelOutputType(outputType2, args) {
1313
1161
  let graphqlType;
1314
1162
  if (fieldType) {
1315
1163
  graphqlType = fieldType.name;
1316
- importDeclarations.create({
1317
- ...fieldType
1318
- });
1164
+ importDeclarations.create({ ...fieldType });
1319
1165
  } else {
1320
1166
  const graphqlImport = getGraphqlImport({
1321
1167
  config,
1322
1168
  sourceFile,
1323
1169
  fileType,
1324
1170
  location,
1325
- isId: modelField?.isId,
1171
+ isId: modelField == null ? void 0 : modelField.isId,
1326
1172
  noTypeId: config.noTypeId,
1327
1173
  typeName: outputTypeName,
1328
1174
  getSourceFile
1329
1175
  });
1330
1176
  graphqlType = graphqlImport.name;
1331
- if (graphqlImport.name !== outputType2.name && graphqlImport.specifier) {
1177
+ if (graphqlImport.name !== outputType.name && graphqlImport.specifier) {
1332
1178
  importDeclarations.add(graphqlImport.name, graphqlImport.specifier);
1333
1179
  }
1334
1180
  }
@@ -1340,52 +1186,44 @@ function modelOutputType(outputType2, args) {
1340
1186
  propertyType,
1341
1187
  isList
1342
1188
  });
1343
- if (typeof property.leadingTrivia === "string" && modelField?.documentation) {
1189
+ if (typeof property.leadingTrivia === "string" && (modelField == null ? void 0 : modelField.documentation)) {
1344
1190
  property.leadingTrivia += createComment(modelField.documentation, settings);
1345
1191
  }
1346
- classStructure.properties?.push(property);
1192
+ (_c = classStructure.properties) == null ? void 0 : _c.push(property);
1347
1193
  if (propertySettings) {
1348
- importDeclarations.create({
1349
- ...propertySettings
1350
- });
1194
+ importDeclarations.create({ ...propertySettings });
1351
1195
  } else if (propertyType.includes("Decimal")) {
1352
1196
  importDeclarations.add("Decimal", "@prisma/client/runtime/library");
1353
1197
  }
1354
- (0, import_assert3.ok)(property.decorators, "property.decorators is undefined");
1355
- const shouldHideField = settings?.shouldHideField({
1356
- name: outputType2.name,
1357
- output: true
1358
- }) || config.decorate.some((d) => d.name === "HideField" && d.from === "@nestjs/graphql" && d.isMatchField(field.name) && d.isMatchType(outputTypeName));
1198
+ assert.ok(property.decorators, "property.decorators is undefined");
1199
+ const shouldHideField = (settings == null ? void 0 : settings.shouldHideField({ name: outputType.name, output: true })) || config.decorate.some(
1200
+ (d) => d.name === "HideField" && d.from === "@nestjs/graphql" && d.isMatchField(field.name) && d.isMatchType(outputTypeName)
1201
+ );
1359
1202
  if (shouldHideField) {
1360
- importDeclarations.add("HideField", nestjsGraphql);
1361
- property.decorators.push({
1362
- name: "HideField",
1363
- arguments: []
1364
- });
1203
+ importDeclarations.add("HideField", nestjsGraphql$1);
1204
+ property.decorators.push({ name: "HideField", arguments: [] });
1365
1205
  } else {
1366
1206
  property.decorators.push({
1367
1207
  name: "Field",
1368
1208
  arguments: [
1369
1209
  isList ? `() => [${graphqlType}]` : `() => ${graphqlType}`,
1370
- import_json53.default.stringify({
1371
- ...settings?.fieldArguments(),
1210
+ JSON5__default["default"].stringify({
1211
+ ...settings == null ? void 0 : settings.fieldArguments(),
1372
1212
  nullable: Boolean(field.isNullable),
1373
- defaultValue: [
1374
- "number",
1375
- "string",
1376
- "boolean"
1377
- ].includes(typeof modelField?.default) ? modelField?.default : void 0,
1378
- description: modelField?.documentation
1213
+ defaultValue: ["number", "string", "boolean"].includes(
1214
+ typeof (modelField == null ? void 0 : modelField.default)
1215
+ ) ? modelField == null ? void 0 : modelField.default : void 0,
1216
+ description: modelField == null ? void 0 : modelField.documentation
1379
1217
  })
1380
1218
  ]
1381
1219
  });
1382
1220
  for (const setting of settings || []) {
1383
- if (shouldBeDecorated(setting) && (setting.match?.(field.name) ?? true)) {
1221
+ if (shouldBeDecorated(setting) && ((_e = (_d = setting.match) == null ? void 0 : _d.call(setting, field.name)) != null ? _e : true)) {
1384
1222
  property.decorators.push({
1385
1223
  name: setting.name,
1386
1224
  arguments: setting.arguments
1387
1225
  });
1388
- (0, import_assert3.ok)(setting.from, "Missed 'from' part in configuration or field setting");
1226
+ assert.ok(setting.from, "Missed 'from' part in configuration or field setting");
1389
1227
  importDeclarations.create(setting);
1390
1228
  }
1391
1229
  }
@@ -1393,9 +1231,7 @@ function modelOutputType(outputType2, args) {
1393
1231
  if (decorate.isMatchField(field.name) && decorate.isMatchType(outputTypeName)) {
1394
1232
  property.decorators.push({
1395
1233
  name: decorate.name,
1396
- arguments: decorate.arguments?.map((x) => (0, import_pupa2.default)(x, {
1397
- propertyType
1398
- }))
1234
+ arguments: (_f = decorate.arguments) == null ? void 0 : _f.map((x) => pupa__default["default"](x, { propertyType }))
1399
1235
  });
1400
1236
  importDeclarations.create(decorate);
1401
1237
  }
@@ -1418,53 +1254,40 @@ function modelOutputType(outputType2, args) {
1418
1254
  }
1419
1255
  if (exportDeclaration) {
1420
1256
  sourceFile.set({
1421
- statements: [
1422
- exportDeclaration,
1423
- "\n",
1424
- classStructure
1425
- ]
1257
+ statements: [exportDeclaration, "\n", classStructure]
1426
1258
  });
1427
1259
  const classDeclaration = sourceFile.getClassOrThrow(model.name);
1428
1260
  const commentedText = classDeclaration.getText().split("\n").map((x) => `// ${x}`);
1429
1261
  classDeclaration.remove();
1430
- sourceFile.addStatements([
1431
- "\n",
1432
- ...commentedText
1433
- ]);
1262
+ sourceFile.addStatements(["\n", ...commentedText]);
1434
1263
  } else {
1435
1264
  sourceFile.set({
1436
- statements: [
1437
- ...importDeclarations.toStatements(),
1438
- classStructure
1439
- ]
1265
+ statements: [...importDeclarations.toStatements(), classStructure]
1440
1266
  });
1441
1267
  }
1442
1268
  }
1443
- __name(modelOutputType, "modelOutputType");
1444
1269
  function shouldBeDecorated(setting) {
1445
1270
  return setting.kind === "Decorator" && (setting.output || setting.model) && !(setting.output && setting.model);
1446
1271
  }
1447
- __name(shouldBeDecorated, "shouldBeDecorated");
1448
- function getExportDeclaration(name, statements) {
1272
+ function getExportDeclaration$1(name, statements) {
1449
1273
  return statements.find((structure) => {
1450
- return structure.kind === import_ts_morph5.StructureKind.ExportDeclaration && structure.namedExports.some((o) => (o.alias || o.name) === name);
1274
+ return structure.kind === tsMorph.StructureKind.ExportDeclaration && structure.namedExports.some(
1275
+ (o) => (o.alias || o.name) === name
1276
+ );
1451
1277
  });
1452
1278
  }
1453
- __name(getExportDeclaration, "getExportDeclaration");
1454
1279
 
1455
- // src/handlers/no-atomic-operations.ts
1456
1280
  function noAtomicOperations(eventEmitter) {
1457
- eventEmitter.on("BeforeInputType", beforeInputType2);
1458
- eventEmitter.on("BeforeGenerateFiles", beforeGenerateFiles);
1281
+ eventEmitter.on("BeforeInputType", beforeInputType$1);
1282
+ eventEmitter.on("BeforeGenerateFiles", beforeGenerateFiles$1);
1459
1283
  }
1460
- __name(noAtomicOperations, "noAtomicOperations");
1461
- function beforeInputType2(args) {
1462
- const { inputType: inputType2, getModelName: getModelName2 } = args;
1463
- for (const field of inputType2.fields) {
1284
+ function beforeInputType$1(args) {
1285
+ const { inputType, getModelName } = args;
1286
+ for (const field of inputType.fields) {
1464
1287
  const fieldName = field.name;
1465
- field.inputTypes = field.inputTypes.filter((inputType3) => {
1466
- const inputTypeName = String(inputType3.type);
1467
- const modelName = getModelName2(inputTypeName);
1288
+ field.inputTypes = field.inputTypes.filter((inputType2) => {
1289
+ const inputTypeName = String(inputType2.type);
1290
+ const modelName = getModelName(inputTypeName);
1468
1291
  if (isAtomicOperation(inputTypeName) || modelName && isListInput(inputTypeName, modelName, fieldName)) {
1469
1292
  return false;
1470
1293
  }
@@ -1472,56 +1295,46 @@ function beforeInputType2(args) {
1472
1295
  });
1473
1296
  }
1474
1297
  }
1475
- __name(beforeInputType2, "beforeInputType");
1476
- function beforeGenerateFiles(args) {
1298
+ function beforeGenerateFiles$1(args) {
1299
+ var _a;
1477
1300
  const { project } = args;
1478
1301
  for (const sourceFile of project.getSourceFiles()) {
1479
- const className = sourceFile.getClass(() => true)?.getName();
1302
+ const className = (_a = sourceFile.getClass(() => true)) == null ? void 0 : _a.getName();
1480
1303
  if (className && isAtomicOperation(className)) {
1481
1304
  project.removeSourceFile(sourceFile);
1482
1305
  }
1483
1306
  }
1484
1307
  }
1485
- __name(beforeGenerateFiles, "beforeGenerateFiles");
1486
1308
  function isAtomicOperation(typeName) {
1487
1309
  if (typeName.endsWith("FieldUpdateOperationsInput")) {
1488
1310
  return true;
1489
1311
  }
1490
1312
  return false;
1491
1313
  }
1492
- __name(isAtomicOperation, "isAtomicOperation");
1493
1314
  function isListInput(typeName, model, field) {
1494
1315
  return typeName === `${model}Create${field}Input` || typeName === `${model}Update${field}Input`;
1495
1316
  }
1496
- __name(isListInput, "isListInput");
1497
1317
 
1498
- // src/handlers/output-type.ts
1499
- var import_assert4 = require("assert");
1500
- var import_json54 = __toESM(require("json5"));
1501
- var import_lodash7 = require("lodash");
1502
- var import_ts_morph6 = require("ts-morph");
1503
- var nestjsGraphql2 = "@nestjs/graphql";
1318
+ const nestjsGraphql = "@nestjs/graphql";
1504
1319
  function outputType(outputType2, args) {
1505
- const { getSourceFile, models, eventEmitter, fieldSettings, getModelName: getModelName2, config } = args;
1320
+ var _a, _b, _c, _d, _e;
1321
+ const { getSourceFile, models, eventEmitter, fieldSettings, getModelName, config } = args;
1506
1322
  const importDeclarations = new ImportDeclarationMap();
1507
1323
  const fileType = "output";
1508
- const modelName = getModelName2(outputType2.name) || "";
1324
+ const modelName = getModelName(outputType2.name) || "";
1509
1325
  const model = models.get(modelName);
1510
1326
  const isAggregateOutput = model && /(?:Count|Avg|Sum|Min|Max)AggregateOutputType$/.test(outputType2.name) && String(outputType2.name).startsWith(model.name);
1511
- const isCountOutput = model?.name && outputType2.name === `${model.name}CountOutputType`;
1327
+ const isCountOutput = (model == null ? void 0 : model.name) && outputType2.name === `${model.name}CountOutputType`;
1512
1328
  outputType2.name = getOutputTypeName(outputType2.name);
1513
1329
  if (isAggregateOutput) {
1514
- eventEmitter.emitSync("AggregateOutput", {
1515
- ...args,
1516
- outputType: outputType2
1517
- });
1330
+ eventEmitter.emitSync("AggregateOutput", { ...args, outputType: outputType2 });
1518
1331
  }
1519
1332
  const sourceFile = getSourceFile({
1520
1333
  name: outputType2.name,
1521
1334
  type: fileType
1522
1335
  });
1523
1336
  const classStructure = {
1524
- kind: import_ts_morph6.StructureKind.Class,
1337
+ kind: tsMorph.StructureKind.Class,
1525
1338
  isExported: true,
1526
1339
  name: outputType2.name,
1527
1340
  decorators: [
@@ -1532,22 +1345,24 @@ function outputType(outputType2, args) {
1532
1345
  ],
1533
1346
  properties: []
1534
1347
  };
1535
- importDeclarations.add("Field", nestjsGraphql2);
1536
- importDeclarations.add("ObjectType", nestjsGraphql2);
1348
+ importDeclarations.add("Field", nestjsGraphql);
1349
+ importDeclarations.add("ObjectType", nestjsGraphql);
1537
1350
  for (const field of outputType2.fields) {
1538
1351
  const { location, isList, type } = field.outputType;
1539
1352
  const outputTypeName = getOutputTypeName(String(type));
1540
- const settings = isCountOutput ? void 0 : model && fieldSettings.get(model.name)?.get(field.name);
1541
- const propertySettings = settings?.getPropertyType({
1353
+ const settings = isCountOutput ? void 0 : model && ((_a = fieldSettings.get(model.name)) == null ? void 0 : _a.get(field.name));
1354
+ const propertySettings = settings == null ? void 0 : settings.getPropertyType({
1542
1355
  name: outputType2.name,
1543
1356
  output: true
1544
1357
  });
1545
- const isCustomsApplicable = outputTypeName === model?.fields.find((f) => f.name === field.name)?.type;
1358
+ const isCustomsApplicable = outputTypeName === ((_b = model == null ? void 0 : model.fields.find((f) => f.name === field.name)) == null ? void 0 : _b.type);
1546
1359
  field.outputType.type = outputTypeName;
1547
- const propertyType = (0, import_lodash7.castArray)(propertySettings?.name || getPropertyType({
1548
- location,
1549
- type: outputTypeName
1550
- }));
1360
+ const propertyType = lodash.castArray(
1361
+ (propertySettings == null ? void 0 : propertySettings.name) || getPropertyType({
1362
+ location,
1363
+ type: outputTypeName
1364
+ })
1365
+ );
1551
1366
  const property = propertyStructure({
1552
1367
  name: field.name,
1553
1368
  isNullable: field.isNullable,
@@ -1555,28 +1370,26 @@ function outputType(outputType2, args) {
1555
1370
  propertyType,
1556
1371
  isList
1557
1372
  });
1558
- classStructure.properties?.push(property);
1373
+ (_c = classStructure.properties) == null ? void 0 : _c.push(property);
1559
1374
  if (propertySettings) {
1560
- importDeclarations.create({
1561
- ...propertySettings
1562
- });
1375
+ importDeclarations.create({ ...propertySettings });
1563
1376
  } else if (propertyType.includes("Decimal")) {
1564
1377
  importDeclarations.add("Decimal", "@prisma/client/runtime/library");
1565
1378
  }
1566
1379
  let graphqlType;
1567
- const shouldHideField = settings?.shouldHideField({
1380
+ const shouldHideField = (settings == null ? void 0 : settings.shouldHideField({
1568
1381
  name: outputType2.name,
1569
1382
  output: true
1570
- }) || config.decorate.some((d) => d.name === "HideField" && d.from === "@nestjs/graphql" && d.isMatchField(field.name) && d.isMatchType(outputTypeName));
1571
- const fieldType = settings?.getFieldType({
1383
+ })) || config.decorate.some(
1384
+ (d) => d.name === "HideField" && d.from === "@nestjs/graphql" && d.isMatchField(field.name) && d.isMatchType(outputTypeName)
1385
+ );
1386
+ const fieldType = settings == null ? void 0 : settings.getFieldType({
1572
1387
  name: outputType2.name,
1573
1388
  output: true
1574
1389
  });
1575
1390
  if (fieldType && isCustomsApplicable && !shouldHideField) {
1576
1391
  graphqlType = fieldType.name;
1577
- importDeclarations.create({
1578
- ...fieldType
1579
- });
1392
+ importDeclarations.create({ ...fieldType });
1580
1393
  } else {
1581
1394
  const graphqlImport = getGraphqlImport({
1582
1395
  config,
@@ -1590,45 +1403,38 @@ function outputType(outputType2, args) {
1590
1403
  graphqlType = graphqlImport.name;
1591
1404
  let referenceName = propertyType[0];
1592
1405
  if (location === "enumTypes") {
1593
- referenceName = (0, import_lodash7.last)(referenceName.split(" "));
1406
+ referenceName = lodash.last(referenceName.split(" "));
1594
1407
  }
1595
1408
  if (graphqlImport.specifier && !importDeclarations.has(graphqlImport.name) && (graphqlImport.name !== outputType2.name && !shouldHideField || shouldHideField && referenceName === graphqlImport.name)) {
1596
1409
  importDeclarations.set(graphqlImport.name, {
1597
- namedImports: [
1598
- {
1599
- name: graphqlImport.name
1600
- }
1601
- ],
1410
+ namedImports: [{ name: graphqlImport.name }],
1602
1411
  moduleSpecifier: graphqlImport.specifier
1603
1412
  });
1604
1413
  }
1605
1414
  }
1606
- (0, import_assert4.ok)(property.decorators, "property.decorators is undefined");
1415
+ assert.ok(property.decorators, "property.decorators is undefined");
1607
1416
  if (shouldHideField) {
1608
- importDeclarations.add("HideField", nestjsGraphql2);
1609
- property.decorators.push({
1610
- name: "HideField",
1611
- arguments: []
1612
- });
1417
+ importDeclarations.add("HideField", nestjsGraphql);
1418
+ property.decorators.push({ name: "HideField", arguments: [] });
1613
1419
  } else {
1614
1420
  property.decorators.push({
1615
1421
  name: "Field",
1616
1422
  arguments: [
1617
1423
  isList ? `() => [${graphqlType}]` : `() => ${graphqlType}`,
1618
- import_json54.default.stringify({
1619
- ...settings?.fieldArguments(),
1424
+ JSON5__default["default"].stringify({
1425
+ ...settings == null ? void 0 : settings.fieldArguments(),
1620
1426
  nullable: Boolean(field.isNullable)
1621
1427
  })
1622
1428
  ]
1623
1429
  });
1624
1430
  if (isCustomsApplicable) {
1625
1431
  for (const options of settings || []) {
1626
- if ((options.kind === "Decorator" && options.output && options.match?.(field.name)) ?? true) {
1432
+ if ((_e = options.kind === "Decorator" && options.output && ((_d = options.match) == null ? void 0 : _d.call(options, field.name))) != null ? _e : true) {
1627
1433
  property.decorators.push({
1628
1434
  name: options.name,
1629
1435
  arguments: options.arguments
1630
1436
  });
1631
- (0, import_assert4.ok)(options.from, "Missed 'from' part in configuration or field setting");
1437
+ assert.ok(options.from, "Missed 'from' part in configuration or field setting");
1632
1438
  importDeclarations.create(options);
1633
1439
  }
1634
1440
  }
@@ -1641,128 +1447,126 @@ function outputType(outputType2, args) {
1641
1447
  });
1642
1448
  }
1643
1449
  sourceFile.set({
1644
- statements: [
1645
- ...importDeclarations.toStatements(),
1646
- classStructure
1647
- ]
1450
+ statements: [...importDeclarations.toStatements(), classStructure]
1648
1451
  });
1649
1452
  }
1650
- __name(outputType, "outputType");
1651
1453
 
1652
- // src/handlers/purge-output.ts
1653
- var import_graceful_fs = require("graceful-fs");
1654
1454
  function purgeOutput(emitter) {
1655
1455
  emitter.on("Begin", begin);
1656
1456
  emitter.on("End", end);
1657
1457
  }
1658
- __name(purgeOutput, "purgeOutput");
1659
1458
  function begin({ project, output }) {
1660
- const sourceFiles = project.getDirectory(output)?.getDescendantSourceFiles();
1459
+ var _a;
1460
+ const sourceFiles = (_a = project.getDirectory(output)) == null ? void 0 : _a.getDescendantSourceFiles();
1661
1461
  if (sourceFiles) {
1662
1462
  for (const sourceFile of sourceFiles) {
1663
1463
  sourceFile.delete();
1664
1464
  }
1665
1465
  }
1666
1466
  }
1667
- __name(begin, "begin");
1668
1467
  function end({ project, output }) {
1669
- const directories = project.getDirectory(output)?.getDescendantDirectories().filter((directory) => directory.getSourceFiles().length === 0).map((directory) => directory.getPath());
1468
+ var _a;
1469
+ const directories = (_a = project.getDirectory(output)) == null ? void 0 : _a.getDescendantDirectories().filter((directory) => directory.getSourceFiles().length === 0).map((directory) => directory.getPath());
1670
1470
  for (const directory of directories || []) {
1671
1471
  try {
1672
- (0, import_graceful_fs.rmdirSync)(directory);
1472
+ gracefulFs.rmdirSync(directory);
1673
1473
  } catch {
1674
1474
  }
1675
1475
  }
1676
1476
  }
1677
- __name(end, "end");
1678
1477
 
1679
- // src/handlers/re-export.ts
1680
- var import_ts_morph7 = require("ts-morph");
1681
- var ReExport;
1682
- (function(ReExport2) {
1478
+ var ReExport = /* @__PURE__ */ ((ReExport2) => {
1683
1479
  ReExport2["None"] = "None";
1684
1480
  ReExport2["Directories"] = "Directories";
1685
1481
  ReExport2["Single"] = "Single";
1686
1482
  ReExport2["All"] = "All";
1687
- })(ReExport || (ReExport = {}));
1483
+ return ReExport2;
1484
+ })(ReExport || {});
1688
1485
  function reExport(emitter) {
1689
- emitter.on("BeforeGenerateFiles", beforeGenerateFiles2);
1486
+ emitter.on("BeforeGenerateFiles", beforeGenerateFiles);
1690
1487
  }
1691
- __name(reExport, "reExport");
1692
- function beforeGenerateFiles2(args) {
1488
+ function beforeGenerateFiles(args) {
1693
1489
  const { project, output, config } = args;
1694
1490
  const rootDirectory = project.getDirectoryOrThrow(output);
1695
- if ([
1696
- ReExport.Directories,
1697
- ReExport.All
1698
- ].includes(config.reExport)) {
1491
+ if (["Directories" /* Directories */, "All" /* All */].includes(config.reExport)) {
1699
1492
  for (const directory of rootDirectory.getDescendantDirectories()) {
1700
1493
  let indexSourceFile;
1701
1494
  const exportDeclarations = directory.getSourceFiles().filter((sourceFile) => {
1702
1495
  return sourceFile.getBaseName() !== "index.ts";
1703
- }).map((sourcesFile) => getExportDeclaration2(directory, sourcesFile));
1496
+ }).map((sourcesFile) => getExportDeclaration(directory, sourcesFile));
1704
1497
  if (exportDeclarations.length > 0) {
1705
- indexSourceFile = directory.createSourceFile("index.ts", {
1706
- statements: exportDeclarations
1707
- }, {
1708
- overwrite: true
1709
- });
1498
+ indexSourceFile = directory.createSourceFile(
1499
+ "index.ts",
1500
+ {
1501
+ statements: exportDeclarations
1502
+ },
1503
+ {
1504
+ overwrite: true
1505
+ }
1506
+ );
1710
1507
  }
1711
1508
  if (indexSourceFile) {
1712
1509
  continue;
1713
1510
  }
1714
- const namespaceExportDeclarations = directory.getDirectories().map((sourceDirectory) => getNamespaceExportDeclaration(directory, sourceDirectory));
1715
- project.createSourceFile(`${directory.getPath()}/index.ts`, {
1716
- statements: namespaceExportDeclarations
1717
- }, {
1718
- overwrite: true
1719
- });
1511
+ const namespaceExportDeclarations = directory.getDirectories().map(
1512
+ (sourceDirectory) => getNamespaceExportDeclaration(directory, sourceDirectory)
1513
+ );
1514
+ project.createSourceFile(
1515
+ `${directory.getPath()}/index.ts`,
1516
+ {
1517
+ statements: namespaceExportDeclarations
1518
+ },
1519
+ {
1520
+ overwrite: true
1521
+ }
1522
+ );
1720
1523
  }
1721
1524
  }
1722
- if (config.reExport === ReExport.Single) {
1525
+ if (config.reExport === "Single" /* Single */) {
1723
1526
  const exportDeclarations = project.getSourceFiles().filter((sourceFile) => {
1724
1527
  return sourceFile.getBaseName() !== "index.ts";
1725
- }).map((sourceFile) => getExportDeclaration2(rootDirectory, sourceFile));
1726
- rootDirectory.createSourceFile("index.ts", {
1727
- statements: exportDeclarations
1728
- }, {
1729
- overwrite: true
1730
- });
1528
+ }).map((sourceFile) => getExportDeclaration(rootDirectory, sourceFile));
1529
+ rootDirectory.createSourceFile(
1530
+ "index.ts",
1531
+ {
1532
+ statements: exportDeclarations
1533
+ },
1534
+ {
1535
+ overwrite: true
1536
+ }
1537
+ );
1731
1538
  }
1732
- if (config.reExport === ReExport.All) {
1539
+ if (config.reExport === "All" /* All */) {
1733
1540
  const exportDeclarations = [];
1734
1541
  for (const directory of rootDirectory.getDirectories()) {
1735
1542
  const sourceFile = directory.getSourceFileOrThrow("index.ts");
1736
- exportDeclarations.push(getExportDeclaration2(rootDirectory, sourceFile));
1543
+ exportDeclarations.push(getExportDeclaration(rootDirectory, sourceFile));
1737
1544
  }
1738
- rootDirectory.createSourceFile("index.ts", {
1739
- statements: exportDeclarations
1740
- }, {
1741
- overwrite: true
1742
- });
1545
+ rootDirectory.createSourceFile(
1546
+ "index.ts",
1547
+ {
1548
+ statements: exportDeclarations
1549
+ },
1550
+ {
1551
+ overwrite: true
1552
+ }
1553
+ );
1743
1554
  }
1744
1555
  }
1745
- __name(beforeGenerateFiles2, "beforeGenerateFiles");
1746
- function getExportDeclaration2(directory, sourceFile) {
1556
+ function getExportDeclaration(directory, sourceFile) {
1747
1557
  return {
1748
- kind: import_ts_morph7.StructureKind.ExportDeclaration,
1749
- namedExports: sourceFile.getExportSymbols().map((s) => ({
1750
- name: s.getName()
1751
- })),
1558
+ kind: tsMorph.StructureKind.ExportDeclaration,
1559
+ namedExports: sourceFile.getExportSymbols().map((s) => ({ name: s.getName() })),
1752
1560
  moduleSpecifier: directory.getRelativePathAsModuleSpecifierTo(sourceFile)
1753
1561
  };
1754
1562
  }
1755
- __name(getExportDeclaration2, "getExportDeclaration");
1756
1563
  function getNamespaceExportDeclaration(directory, sourceDirectory) {
1757
1564
  return {
1758
- kind: import_ts_morph7.StructureKind.ExportDeclaration,
1565
+ kind: tsMorph.StructureKind.ExportDeclaration,
1759
1566
  moduleSpecifier: directory.getRelativePathAsModuleSpecifierTo(sourceDirectory)
1760
1567
  };
1761
1568
  }
1762
- __name(getNamespaceExportDeclaration, "getNamespaceExportDeclaration");
1763
1569
 
1764
- // src/handlers/register-enum.ts
1765
- var import_ts_morph8 = require("ts-morph");
1766
1570
  function registerEnum(enumType, args) {
1767
1571
  const { getSourceFile, enums } = args;
1768
1572
  const dataModelEnum = enums[enumType.name];
@@ -1772,15 +1576,11 @@ function registerEnum(enumType, args) {
1772
1576
  });
1773
1577
  const importDeclarations = new ImportDeclarationMap();
1774
1578
  importDeclarations.set("registerEnumType", {
1775
- namedImports: [
1776
- {
1777
- name: "registerEnumType"
1778
- }
1779
- ],
1579
+ namedImports: [{ name: "registerEnumType" }],
1780
1580
  moduleSpecifier: "@nestjs/graphql"
1781
1581
  });
1782
1582
  const enumStructure = {
1783
- kind: import_ts_morph8.StructureKind.Enum,
1583
+ kind: tsMorph.StructureKind.Enum,
1784
1584
  isExported: true,
1785
1585
  name: enumType.name,
1786
1586
  members: enumType.values.map((v) => ({
@@ -1793,34 +1593,28 @@ function registerEnum(enumType, args) {
1793
1593
  ...importDeclarations.toStatements(),
1794
1594
  enumStructure,
1795
1595
  "\n",
1796
- `registerEnumType(${enumType.name}, { name: '${enumType.name}', description: ${JSON.stringify(dataModelEnum?.documentation)} })`
1596
+ `registerEnumType(${enumType.name}, { name: '${enumType.name}', description: ${JSON.stringify(dataModelEnum == null ? void 0 : dataModelEnum.documentation)} })`
1797
1597
  ]
1798
1598
  });
1799
1599
  }
1800
- __name(registerEnum, "registerEnum");
1801
1600
 
1802
- // src/handlers/require-single-fields-in-whereunique-input.ts
1803
1601
  function requireSingleFieldsInWhereUniqueInput(eventEmitter) {
1804
- eventEmitter.on("BeforeInputType", beforeInputType3);
1602
+ eventEmitter.on("BeforeInputType", beforeInputType);
1805
1603
  }
1806
- __name(requireSingleFieldsInWhereUniqueInput, "requireSingleFieldsInWhereUniqueInput");
1807
- function beforeInputType3(args) {
1808
- const { inputType: inputType2 } = args;
1809
- if (!isWhereUniqueInputType(inputType2.name) || inputType2.fields.length !== 1) {
1604
+ function beforeInputType(args) {
1605
+ const { inputType } = args;
1606
+ if (!isWhereUniqueInputType(inputType.name) || inputType.fields.length !== 1) {
1810
1607
  return;
1811
1608
  }
1812
- for (const field of inputType2.fields) {
1609
+ for (const field of inputType.fields) {
1813
1610
  field.isRequired = true;
1814
1611
  field.isNullable = false;
1815
1612
  }
1816
1613
  }
1817
- __name(beforeInputType3, "beforeInputType");
1818
1614
  function isWhereUniqueInputType(name) {
1819
1615
  return name.endsWith("WhereUniqueInput");
1820
1616
  }
1821
- __name(isWhereUniqueInputType, "isWhereUniqueInputType");
1822
1617
 
1823
- // src/handlers/warning.ts
1824
1618
  function warning(message) {
1825
1619
  if (Array.isArray(message)) {
1826
1620
  console.log("prisma-nestjs-graphql:");
@@ -1829,28 +1623,22 @@ function warning(message) {
1829
1623
  console.log("prisma-nestjs-graphql:", message);
1830
1624
  }
1831
1625
  }
1832
- __name(warning, "warning");
1833
1626
 
1834
- // src/helpers/create-config.ts
1835
- var import_assert5 = require("assert");
1836
- var import_filenamify = __toESM(require("filenamify"));
1837
- var import_flat = require("flat");
1838
- var import_graceful_fs2 = require("graceful-fs");
1839
- var import_json55 = __toESM(require("json5"));
1840
- var import_lodash8 = require("lodash");
1841
- var import_outmatch3 = __toESM(require("outmatch"));
1842
1627
  function createConfig(data) {
1843
- const config = (0, import_lodash8.merge)({}, (0, import_flat.unflatten)(data, {
1844
- delimiter: "_"
1845
- }));
1628
+ var _a;
1629
+ const config = lodash.merge({}, flat.unflatten(data, { delimiter: "_" }));
1846
1630
  const $warnings = [];
1847
- const configOutputFilePattern = String(config.outputFilePattern || `{model}/{name}.{type}.ts`);
1848
- let outputFilePattern = (0, import_filenamify.default)(configOutputFilePattern, {
1631
+ const configOutputFilePattern = String(
1632
+ config.outputFilePattern || `{model}/{name}.{type}.ts`
1633
+ );
1634
+ let outputFilePattern = filenamify__default["default"](configOutputFilePattern, {
1849
1635
  replacement: "/"
1850
1636
  }).replace(/\.\./g, "/").replace(/\/+/g, "/");
1851
- outputFilePattern = (0, import_lodash8.trim)(outputFilePattern, "/");
1637
+ outputFilePattern = lodash.trim(outputFilePattern, "/");
1852
1638
  if (outputFilePattern !== configOutputFilePattern) {
1853
- $warnings.push(`Due to invalid filepath 'outputFilePattern' changed to '${outputFilePattern}'`);
1639
+ $warnings.push(
1640
+ `Due to invalid filepath 'outputFilePattern' changed to '${outputFilePattern}'`
1641
+ );
1854
1642
  }
1855
1643
  if (config.reExportAll) {
1856
1644
  $warnings.push(`Option 'reExportAll' is deprecated, use 'reExport' instead`);
@@ -1858,40 +1646,42 @@ function createConfig(data) {
1858
1646
  config.reExport = "All";
1859
1647
  }
1860
1648
  }
1861
- const fields = Object.fromEntries(Object.entries(config.fields ?? {}).filter(({ 1: value }) => typeof value === "object").map(([name, value]) => {
1862
- const fieldSetting = {
1863
- arguments: [],
1864
- output: toBoolean(value.output),
1865
- input: toBoolean(value.input),
1866
- model: toBoolean(value.model),
1867
- from: value.from,
1868
- defaultImport: toBoolean(value.defaultImport) ? true : value.defaultImport,
1869
- namespaceImport: value.namespaceImport
1870
- };
1871
- return [
1872
- name,
1873
- fieldSetting
1874
- ];
1875
- }));
1649
+ const fields = Object.fromEntries(
1650
+ Object.entries(
1651
+ (_a = config.fields) != null ? _a : {}
1652
+ ).filter(({ 1: value }) => typeof value === "object").map(([name, value]) => {
1653
+ const fieldSetting = {
1654
+ arguments: [],
1655
+ output: toBoolean(value.output),
1656
+ input: toBoolean(value.input),
1657
+ model: toBoolean(value.model),
1658
+ from: value.from,
1659
+ defaultImport: toBoolean(value.defaultImport) ? true : value.defaultImport,
1660
+ namespaceImport: value.namespaceImport
1661
+ };
1662
+ return [name, fieldSetting];
1663
+ })
1664
+ );
1876
1665
  const decorate = [];
1877
- const configDecorate = Object.values(config.decorate || {});
1666
+ const configDecorate = Object.values(
1667
+ config.decorate || {}
1668
+ );
1878
1669
  for (const element of configDecorate) {
1879
1670
  if (!element)
1880
1671
  continue;
1881
- (0, import_assert5.ok)(element.from && element.name, `Missed 'from' or 'name' part in configuration for decorate`);
1672
+ assert.ok(
1673
+ element.from && element.name,
1674
+ `Missed 'from' or 'name' part in configuration for decorate`
1675
+ );
1882
1676
  decorate.push({
1883
- isMatchField: (0, import_outmatch3.default)(element.field, {
1884
- separator: false
1885
- }),
1886
- isMatchType: (0, import_outmatch3.default)(element.type, {
1887
- separator: false
1888
- }),
1677
+ isMatchField: outmatch__default["default"](element.field, { separator: false }),
1678
+ isMatchType: outmatch__default["default"](element.type, { separator: false }),
1889
1679
  from: element.from,
1890
1680
  name: element.name,
1891
1681
  namedImport: toBoolean(element.namedImport),
1892
1682
  defaultImport: toBoolean(element.defaultImport) ? true : element.defaultImport,
1893
1683
  namespaceImport: element.namespaceImport,
1894
- arguments: element.arguments ? import_json55.default.parse(element.arguments) : void 0
1684
+ arguments: element.arguments ? JSON5__default["default"].parse(element.arguments) : void 0
1895
1685
  });
1896
1686
  }
1897
1687
  return {
@@ -1907,14 +1697,15 @@ function createConfig(data) {
1907
1697
  purgeOutput: toBoolean(config.purgeOutput),
1908
1698
  useInputType: createUseInputType(config.useInputType),
1909
1699
  noTypeId: toBoolean(config.noTypeId),
1910
- requireSingleFieldsInWhereUniqueInput: toBoolean(config.requireSingleFieldsInWhereUniqueInput),
1700
+ requireSingleFieldsInWhereUniqueInput: toBoolean(
1701
+ config.requireSingleFieldsInWhereUniqueInput
1702
+ ),
1911
1703
  graphqlScalars: config.graphqlScalars || {},
1912
1704
  decorate
1913
1705
  };
1914
1706
  }
1915
- __name(createConfig, "createConfig");
1916
- var tsConfigFileExists = (0, import_lodash8.memoize)((filePath) => {
1917
- return (0, import_graceful_fs2.existsSync)(filePath);
1707
+ const tsConfigFileExists = lodash.memoize((filePath) => {
1708
+ return gracefulFs.existsSync(filePath);
1918
1709
  });
1919
1710
  function createTsConfigFilePathValue(value) {
1920
1711
  if (typeof value === "string")
@@ -1922,7 +1713,6 @@ function createTsConfigFilePathValue(value) {
1922
1713
  if (tsConfigFileExists("tsconfig.json"))
1923
1714
  return "tsconfig.json";
1924
1715
  }
1925
- __name(createTsConfigFilePathValue, "createTsConfigFilePathValue");
1926
1716
  function createUseInputType(data) {
1927
1717
  if (!data) {
1928
1718
  return [];
@@ -1944,35 +1734,21 @@ function createUseInputType(data) {
1944
1734
  }
1945
1735
  return result;
1946
1736
  }
1947
- __name(createUseInputType, "createUseInputType");
1948
1737
  function toBoolean(value) {
1949
- return [
1950
- "true",
1951
- "1",
1952
- "on"
1953
- ].includes(String(value));
1738
+ return ["true", "1", "on"].includes(String(value));
1954
1739
  }
1955
- __name(toBoolean, "toBoolean");
1956
1740
 
1957
- // src/helpers/generate-file-name.ts
1958
- var import_lodash9 = require("lodash");
1959
- var import_pluralize = __toESM(require("pluralize"));
1960
- var import_pupa3 = __toESM(require("pupa"));
1961
1741
  function generateFileName(args) {
1962
- const { template, type, name, getModelName: getModelName2 } = args;
1963
- return (0, import_pupa3.default)(template, {
1742
+ const { template, type, name, getModelName } = args;
1743
+ return pupa__default["default"](template, {
1964
1744
  type,
1965
1745
  get model() {
1966
- const result = getModelName2(name) || "prisma";
1967
- return (0, import_lodash9.kebabCase)(result);
1746
+ const result = getModelName(name) || "prisma";
1747
+ return lodash.kebabCase(result);
1968
1748
  },
1969
1749
  get name() {
1970
- let result = (0, import_lodash9.kebabCase)(name);
1971
- for (const suffix of [
1972
- "input",
1973
- "args",
1974
- "enum"
1975
- ]) {
1750
+ let result = lodash.kebabCase(name);
1751
+ for (const suffix of ["input", "args", "enum"]) {
1976
1752
  const ending = `-${suffix}`;
1977
1753
  if (type === suffix && result.endsWith(ending)) {
1978
1754
  result = result.slice(0, -ending.length);
@@ -1982,45 +1758,33 @@ function generateFileName(args) {
1982
1758
  },
1983
1759
  plural: {
1984
1760
  get type() {
1985
- return (0, import_pluralize.default)(type);
1761
+ return pluralize__default["default"](type);
1986
1762
  }
1987
1763
  }
1988
1764
  });
1989
1765
  }
1990
- __name(generateFileName, "generateFileName");
1991
1766
 
1992
- // src/helpers/factory-get-source-file.ts
1993
1767
  function factoryGetSourceFile(args) {
1994
- const { outputFilePattern, output, getModelName: getModelName2, project } = args;
1995
- return /* @__PURE__ */ __name(function getSourceFile(args2) {
1768
+ const { outputFilePattern, output, getModelName, project } = args;
1769
+ return function getSourceFile(args2) {
1996
1770
  const { name, type } = args2;
1997
1771
  let filePath = generateFileName({
1998
- getModelName: getModelName2,
1772
+ getModelName,
1999
1773
  name,
2000
1774
  type,
2001
1775
  template: outputFilePattern
2002
1776
  });
2003
1777
  filePath = `${output}/${filePath}`;
2004
- return project.getSourceFile(filePath) || project.createSourceFile(filePath, void 0, {
2005
- overwrite: true
2006
- });
2007
- }, "getSourceFile");
1778
+ return project.getSourceFile(filePath) || project.createSourceFile(filePath, void 0, { overwrite: true });
1779
+ };
2008
1780
  }
2009
- __name(factoryGetSourceFile, "factoryGetSourceFile");
2010
1781
 
2011
- // src/helpers/get-model-name.ts
2012
- var import_lodash10 = require("lodash");
2013
1782
  function createGetModelName(modelNames) {
2014
- return (0, import_lodash10.memoize)(tryGetName);
1783
+ return lodash.memoize(tryGetName);
2015
1784
  function tryGetName(name) {
2016
- return getModelName({
2017
- modelNames,
2018
- name
2019
- });
1785
+ return getModelName({ modelNames, name });
2020
1786
  }
2021
- __name(tryGetName, "tryGetName");
2022
1787
  }
2023
- __name(createGetModelName, "createGetModelName");
2024
1788
  function getModelName(args) {
2025
1789
  const { name, modelNames } = args;
2026
1790
  for (const keyword of splitKeywords) {
@@ -2035,12 +1799,12 @@ function getModelName(args) {
2035
1799
  return test;
2036
1800
  }
2037
1801
  }
2038
- for (const [start, end2] of middleKeywords) {
2039
- let test = name.slice(start.length).slice(0, -end2.length);
1802
+ for (const [start, end] of middleKeywords) {
1803
+ let test = name.slice(start.length).slice(0, -end.length);
2040
1804
  if (modelNames.includes(test)) {
2041
1805
  return test;
2042
1806
  }
2043
- test = name.slice(0, -(start + end2).length);
1807
+ test = name.slice(0, -(start + end).length);
2044
1808
  if (modelNames.includes(test)) {
2045
1809
  return test;
2046
1810
  }
@@ -2048,7 +1812,7 @@ function getModelName(args) {
2048
1812
  if (name.slice(-19) === "CompoundUniqueInput") {
2049
1813
  const test = name.slice(0, -19);
2050
1814
  const models = modelNames.filter((x) => test.startsWith(x)).sort((a, b) => b.length - a.length);
2051
- return (0, import_lodash10.first)(models);
1815
+ return lodash.first(models);
2052
1816
  }
2053
1817
  if (name.slice(-5) === "Count") {
2054
1818
  const test = name.slice(0, -5);
@@ -2058,8 +1822,7 @@ function getModelName(args) {
2058
1822
  }
2059
1823
  return void 0;
2060
1824
  }
2061
- __name(getModelName, "getModelName");
2062
- var splitKeywords = [
1825
+ const splitKeywords = [
2063
1826
  "CreateInput",
2064
1827
  "CreateMany",
2065
1828
  "CreateNested",
@@ -2102,7 +1865,7 @@ var splitKeywords = [
2102
1865
  "Create",
2103
1866
  "Update"
2104
1867
  ].sort((a, b) => b.length - a.length);
2105
- var endsWithKeywords = [
1868
+ const endsWithKeywords = [
2106
1869
  "Aggregate",
2107
1870
  "GroupBy",
2108
1871
  "CreateOne",
@@ -2115,75 +1878,30 @@ var endsWithKeywords = [
2115
1878
  "UpdateOne",
2116
1879
  "UpsertOne"
2117
1880
  ];
2118
- var middleKeywords = [
2119
- [
2120
- "FindFirst",
2121
- "OrThrowArgs"
2122
- ],
2123
- [
2124
- "FindUnique",
2125
- "OrThrowArgs"
2126
- ],
2127
- [
2128
- "Aggregate",
2129
- "Args"
2130
- ],
2131
- [
2132
- "CreateOne",
2133
- "Args"
2134
- ],
2135
- [
2136
- "DeleteMany",
2137
- "Args"
2138
- ],
2139
- [
2140
- "DeleteOne",
2141
- "Args"
2142
- ],
2143
- [
2144
- "FindMany",
2145
- "Args"
2146
- ],
2147
- [
2148
- "FindFirst",
2149
- "Args"
2150
- ],
2151
- [
2152
- "FindOne",
2153
- "Args"
2154
- ],
2155
- [
2156
- "FindUnique",
2157
- "Args"
2158
- ],
2159
- [
2160
- "UpdateMany",
2161
- "Args"
2162
- ],
2163
- [
2164
- "UpdateOne",
2165
- "Args"
2166
- ],
2167
- [
2168
- "UpsertOne",
2169
- "Args"
2170
- ],
2171
- [
2172
- "GroupBy",
2173
- "Args"
2174
- ],
2175
- [
2176
- "OrderBy",
2177
- "Args"
2178
- ]
1881
+ const middleKeywords = [
1882
+ ["FindFirst", "OrThrowArgs"],
1883
+ ["FindUnique", "OrThrowArgs"],
1884
+ ["Aggregate", "Args"],
1885
+ ["CreateOne", "Args"],
1886
+ ["DeleteMany", "Args"],
1887
+ ["DeleteOne", "Args"],
1888
+ ["FindMany", "Args"],
1889
+ ["FindFirst", "Args"],
1890
+ ["FindOne", "Args"],
1891
+ ["FindUnique", "Args"],
1892
+ ["UpdateMany", "Args"],
1893
+ ["UpdateOne", "Args"],
1894
+ ["UpsertOne", "Args"],
1895
+ ["GroupBy", "Args"],
1896
+ ["OrderBy", "Args"]
2179
1897
  ];
2180
1898
 
2181
- // src/generate.ts
2182
1899
  async function generate(args) {
1900
+ var _a;
2183
1901
  const { connectCallback, generator, skipAddOutputSourceFiles, dmmf } = args;
2184
- const generatorOutputValue = generator.output?.value;
2185
- (0, import_assert6.ok)(generatorOutputValue, "Missing generator configuration: output");
2186
- const eventEmitter = new import_await_event_emitter.default();
1902
+ const generatorOutputValue = (_a = generator.output) == null ? void 0 : _a.value;
1903
+ assert.ok(generatorOutputValue, "Missing generator configuration: output");
1904
+ const eventEmitter = new AwaitEventEmitter__default["default"]();
2187
1905
  eventEmitter.on("Warning", warning);
2188
1906
  eventEmitter.on("Model", modelData);
2189
1907
  eventEmitter.on("EnumType", registerEnum);
@@ -2197,12 +1915,12 @@ async function generate(args) {
2197
1915
  for (const message of config.$warnings) {
2198
1916
  eventEmitter.emitSync("Warning", message);
2199
1917
  }
2200
- const project = new import_ts_morph9.Project({
1918
+ const project = new tsMorph.Project({
2201
1919
  tsConfigFilePath: config.tsConfigFilePath,
2202
1920
  skipAddingFilesFromTsConfig: true,
2203
1921
  skipLoadingLibFiles: !config.emitCompiled,
2204
1922
  manipulationSettings: {
2205
- quoteKind: import_ts_morph9.QuoteKind.Single
1923
+ quoteKind: tsMorph.QuoteKind.Single
2206
1924
  }
2207
1925
  });
2208
1926
  if (!skipAddOutputSourceFiles) {
@@ -2221,11 +1939,11 @@ async function generate(args) {
2221
1939
  const modelNames = [];
2222
1940
  const modelFields = /* @__PURE__ */ new Map();
2223
1941
  const fieldSettings = /* @__PURE__ */ new Map();
2224
- const getModelName2 = createGetModelName(modelNames);
1942
+ const getModelName = createGetModelName(modelNames);
2225
1943
  const getSourceFile = factoryGetSourceFile({
2226
1944
  output: generatorOutputValue,
2227
1945
  project,
2228
- getModelName: getModelName2,
1946
+ getModelName,
2229
1947
  outputFilePattern: config.outputFilePattern,
2230
1948
  eventEmitter
2231
1949
  });
@@ -2243,8 +1961,8 @@ async function generate(args) {
2243
1961
  getSourceFile,
2244
1962
  eventEmitter,
2245
1963
  typeNames: /* @__PURE__ */ new Set(),
2246
- enums: (0, import_lodash11.mapKeys)(datamodel.enums, (x) => x.name),
2247
- getModelName: getModelName2,
1964
+ enums: lodash.mapKeys(datamodel.enums, (x) => x.name),
1965
+ getModelName,
2248
1966
  removeTypes,
2249
1967
  classTransformerTypeModels: /* @__PURE__ */ new Set()
2250
1968
  };
@@ -2268,10 +1986,7 @@ async function generate(args) {
2268
1986
  }
2269
1987
  const queryOutputTypes = [];
2270
1988
  for (const outputType2 of outputObjectTypes.prisma) {
2271
- if ([
2272
- "Query",
2273
- "Mutation"
2274
- ].includes(outputType2.name)) {
1989
+ if (["Query", "Mutation"].includes(outputType2.name)) {
2275
1990
  queryOutputTypes.push(outputType2);
2276
1991
  continue;
2277
1992
  }
@@ -2304,17 +2019,5 @@ async function generate(args) {
2304
2019
  eventEmitter.off(name);
2305
2020
  }
2306
2021
  }
2307
- __name(generate, "generate");
2308
2022
 
2309
- // src/index.ts
2310
- (0, import_generator_helper.generatorHandler)({
2311
- async onGenerate(options) {
2312
- await generate(options);
2313
- },
2314
- onManifest() {
2315
- return {
2316
- defaultOutput: ".",
2317
- prettyName: "Prisma NestJS/GraphQL"
2318
- };
2319
- }
2320
- });
2023
+ exports.generate = generate;