prisma-nestjs-graphql 15.3.3 → 17.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +12 -3
  2. package/index.js +235 -208
  3. package/package.json +24 -24
package/README.md CHANGED
@@ -10,10 +10,18 @@ Generate object types, inputs, args, etc. from prisma schema file for usage with
10
10
 
11
11
  ## Install
12
12
 
13
+ Prisma v3
14
+
13
15
  ```sh
14
16
  npm install --save-dev prisma-nestjs-graphql
15
17
  ```
16
18
 
19
+ Prisma v4
20
+
21
+ ```
22
+ npm install --save-dev prisma-nestjs-graphql@next
23
+ ```
24
+
17
25
  ## Usage
18
26
 
19
27
  1. Add new generator section to `schema.prisma` file
@@ -23,7 +31,7 @@ generator nestgraphql {
23
31
  provider = "node node_modules/prisma-nestjs-graphql"
24
32
  // for yarn monorepos
25
33
  // provider = "prisma-nestjs-graphql"
26
- output = "../src/@generated/prisma-nestjs-graphql"
34
+ output = "../src/@generated"
27
35
  }
28
36
  ```
29
37
 
@@ -97,7 +105,7 @@ Example configuration:
97
105
  ```prisma
98
106
  generator nestgraphql {
99
107
  provider = "node node_modules/prisma-nestjs-graphql"
100
- output = "../src/@generated/prisma-nestjs-graphql"
108
+ output = "../src/@generated"
101
109
  reExport = Directories
102
110
  }
103
111
  ```
@@ -182,7 +190,7 @@ to set `UserWhereInput` need to configure generator the following way:
182
190
  ```prisma
183
191
  generator nestgraphql {
184
192
  provider = "node node_modules/prisma-nestjs-graphql"
185
- output = "../src/@generated/prisma-nestjs-graphql"
193
+ output = "../src/@generated"
186
194
  useInputType_WhereInput_ALL = "WhereInput"
187
195
  }
188
196
  ```
@@ -703,6 +711,7 @@ export class User {}
703
711
 
704
712
  ## Similar Projects
705
713
 
714
+ - https://github.com/jasonraimondi/prisma-generator-nestjs-graphql
706
715
  - https://github.com/omar-dulaimi/prisma-class-validator-generator
707
716
  - https://github.com/kimjbstar/prisma-class-generator
708
717
  - https://github.com/odroe/nest-gql-mix
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -50,7 +51,7 @@ function argsType(field, args) {
50
51
  className = `${modelName}GroupByArgs`;
51
52
  break;
52
53
  }
53
- const inputType1 = {
54
+ const inputType2 = {
54
55
  constraints: {
55
56
  maxNumFields: null,
56
57
  minNumFields: null
@@ -71,17 +72,17 @@ function argsType(field, args) {
71
72
  "Min",
72
73
  "Max"
73
74
  ];
74
- if (`${modelName}GroupByArgs` === inputType1.name) {
75
- const byField = inputType1.fields.find((f) => f.name === "by");
76
- if (byField == null ? void 0 : byField.inputTypes) {
77
- byField.inputTypes = byField.inputTypes.filter((inputType2) => inputType2.isList);
75
+ if (`${modelName}GroupByArgs` === inputType2.name) {
76
+ const byField = inputType2.fields.find((f) => f.name === "by");
77
+ if (byField?.inputTypes) {
78
+ byField.inputTypes = byField.inputTypes.filter((inputType3) => inputType3.isList);
78
79
  }
79
80
  }
80
81
  for (const name of names) {
81
82
  if (!typeNames.has(`${modelName}${name}AggregateInput`)) {
82
83
  continue;
83
84
  }
84
- inputType1.fields.push({
85
+ inputType2.fields.push({
85
86
  name: `_${name.toLowerCase()}`,
86
87
  isRequired: false,
87
88
  isNullable: true,
@@ -97,7 +98,7 @@ function argsType(field, args) {
97
98
  }
98
99
  eventEmitter.emitSync("InputType", {
99
100
  ...args,
100
- inputType: inputType1,
101
+ inputType: inputType2,
101
102
  fileType: "args",
102
103
  classDecoratorName: "ArgsType"
103
104
  });
@@ -165,21 +166,18 @@ function createAggregateInput(args) {
165
166
  minNumFields: null
166
167
  },
167
168
  name: className,
168
- fields: outputType2.fields.map((x) => {
169
- var _a;
170
- return {
171
- name: x.name,
172
- isNullable: (_a = x.isNullable) != null ? _a : true,
173
- isRequired: false,
174
- inputTypes: [
175
- {
176
- isList: false,
177
- type: "true",
178
- location: "scalar"
179
- }
180
- ]
181
- };
182
- })
169
+ fields: outputType2.fields.map((x) => ({
170
+ name: x.name,
171
+ isNullable: x.isNullable ?? true,
172
+ isRequired: false,
173
+ inputTypes: [
174
+ {
175
+ isList: false,
176
+ type: "true",
177
+ location: "scalar"
178
+ }
179
+ ]
180
+ }))
183
181
  };
184
182
  eventEmitter.emitSync("InputType", {
185
183
  ...args,
@@ -283,21 +281,20 @@ async function generateFiles(args) {
283
281
  const sourceFile = rootDirectory.getSourceFile("index.ts") || rootDirectory.createSourceFile("index.ts", void 0, {
284
282
  overwrite: true
285
283
  });
286
- const statements1 = project.getSourceFiles().flatMap((s) => {
287
- var _a, _b;
284
+ const statements = project.getSourceFiles().flatMap((s) => {
288
285
  if (s === sourceFile) {
289
286
  return [];
290
287
  }
291
288
  const classDeclaration = s.getClass(() => true);
292
- const statements = s.getStructure().statements;
293
- if (Array.isArray(statements)) {
294
- for (const statement of statements) {
289
+ const statements2 = s.getStructure().statements;
290
+ if (Array.isArray(statements2)) {
291
+ for (const statement of statements2) {
295
292
  if (!(typeof statement === "object" && statement.kind === import_ts_morph2.StructureKind.Class)) {
296
293
  continue;
297
294
  }
298
295
  for (const property of statement.properties || []) {
299
296
  for (const decorator of property.decorators || []) {
300
- const fullName = (_b = (_a = classDeclaration == null ? void 0 : classDeclaration.getProperty(property.name)) == null ? void 0 : _a.getDecorator(decorator.name)) == null ? void 0 : _b.getFullName();
297
+ const fullName = classDeclaration?.getProperty(property.name)?.getDecorator(decorator.name)?.getFullName();
301
298
  (0, import_assert.ok)(fullName, `Cannot get full name of decorator of class ${statement.name}`);
302
299
  decorator.name = fullName;
303
300
  }
@@ -305,47 +302,47 @@ async function generateFiles(args) {
305
302
  }
306
303
  }
307
304
  project.removeSourceFile(s);
308
- return statements;
305
+ return statements2;
309
306
  });
310
307
  const imports = new ImportDeclarationMap();
311
308
  const enums = [];
312
309
  const classes = [];
313
- for (const statement1 of statements1) {
314
- if (typeof statement1 === "string") {
315
- if (statement1.startsWith("registerEnumType")) {
316
- enums.push(statement1);
310
+ for (const statement of statements) {
311
+ if (typeof statement === "string") {
312
+ if (statement.startsWith("registerEnumType")) {
313
+ enums.push(statement);
317
314
  }
318
315
  continue;
319
316
  }
320
- switch (statement1.kind) {
317
+ switch (statement.kind) {
321
318
  case import_ts_morph2.StructureKind.ImportDeclaration:
322
- if (statement1.moduleSpecifier.startsWith("./") || statement1.moduleSpecifier.startsWith("..")) {
319
+ if (statement.moduleSpecifier.startsWith("./") || statement.moduleSpecifier.startsWith("..")) {
323
320
  continue;
324
321
  }
325
- for (const namedImport of statement1.namedImports) {
322
+ for (const namedImport of statement.namedImports) {
326
323
  const name = namedImport.alias || namedImport.name;
327
- imports.add(name, statement1.moduleSpecifier);
324
+ imports.add(name, statement.moduleSpecifier);
328
325
  }
329
- if (statement1.defaultImport) {
326
+ if (statement.defaultImport) {
330
327
  imports.create({
331
- from: statement1.moduleSpecifier,
332
- name: statement1.defaultImport,
333
- defaultImport: statement1.defaultImport
328
+ from: statement.moduleSpecifier,
329
+ name: statement.defaultImport,
330
+ defaultImport: statement.defaultImport
334
331
  });
335
332
  }
336
- if (statement1.namespaceImport) {
333
+ if (statement.namespaceImport) {
337
334
  imports.create({
338
- from: statement1.moduleSpecifier,
339
- name: statement1.namespaceImport,
340
- namespaceImport: statement1.namespaceImport
335
+ from: statement.moduleSpecifier,
336
+ name: statement.namespaceImport,
337
+ namespaceImport: statement.namespaceImport
341
338
  });
342
339
  }
343
340
  break;
344
341
  case import_ts_morph2.StructureKind.Enum:
345
- enums.unshift(statement1);
342
+ enums.unshift(statement);
346
343
  break;
347
344
  case import_ts_morph2.StructureKind.Class:
348
- classes.push(statement1);
345
+ classes.push(statement);
349
346
  break;
350
347
  }
351
348
  }
@@ -608,13 +605,13 @@ __name(getPropertyType, "getPropertyType");
608
605
  var import_ts_morph3 = require("ts-morph");
609
606
  function propertyStructure(args) {
610
607
  const { isNullable, propertyType, name, isList, hasQuestionToken, hasExclamationToken } = args;
611
- const type1 = propertyType.map((type) => isList ? `Array<${type}>` : type).join(" | ");
608
+ const type = propertyType.map((type2) => isList ? `Array<${type2}>` : type2).join(" | ");
612
609
  return {
613
610
  kind: import_ts_morph3.StructureKind.Property,
614
611
  name,
615
- type: type1,
616
- hasQuestionToken: hasQuestionToken != null ? hasQuestionToken : isNullable,
617
- hasExclamationToken: hasExclamationToken != null ? hasExclamationToken : !isNullable,
612
+ type,
613
+ hasQuestionToken: hasQuestionToken ?? isNullable,
614
+ hasExclamationToken: hasExclamationToken ?? !isNullable,
618
615
  decorators: [],
619
616
  leadingTrivia: "\n"
620
617
  };
@@ -623,18 +620,17 @@ __name(propertyStructure, "propertyStructure");
623
620
 
624
621
  // src/handlers/input-type.ts
625
622
  function inputType(args) {
626
- var _a, _b, _c, _d;
627
- const { inputType: inputType1, fileType, getSourceFile, config, eventEmitter, classDecoratorName, fieldSettings, getModelName: getModelName2, models, removeTypes, typeNames } = args;
628
- typeNames.add(inputType1.name);
623
+ const { classDecoratorName, classTransformerTypeModels, config, eventEmitter, fieldSettings, fileType, getModelName: getModelName2, getSourceFile, inputType: inputType2, models, removeTypes, typeNames } = args;
624
+ typeNames.add(inputType2.name);
629
625
  const importDeclarations = new ImportDeclarationMap();
630
626
  const sourceFile = getSourceFile({
631
- name: inputType1.name,
627
+ name: inputType2.name,
632
628
  type: fileType
633
629
  });
634
630
  const classStructure = {
635
631
  kind: import_ts_morph4.StructureKind.Class,
636
632
  isExported: true,
637
- name: inputType1.name,
633
+ name: inputType2.name,
638
634
  decorators: [
639
635
  {
640
636
  name: classDecoratorName,
@@ -643,7 +639,7 @@ function inputType(args) {
643
639
  ],
644
640
  properties: []
645
641
  };
646
- const modelName = getModelName2(inputType1.name) || "";
642
+ const modelName = getModelName2(inputType2.name) || "";
647
643
  const model = models.get(modelName);
648
644
  const modelFieldSettings = model && fieldSettings.get(model.name);
649
645
  const moduleSpecifier = "@nestjs/graphql";
@@ -662,25 +658,26 @@ function inputType(args) {
662
658
  ],
663
659
  moduleSpecifier
664
660
  });
665
- const useInputType = config.useInputType.find((x) => inputType1.name.includes(x.typeName));
666
- for (const field of inputType1.fields) {
661
+ const useInputType = config.useInputType.find((x) => inputType2.name.includes(x.typeName));
662
+ for (const field of inputType2.fields) {
667
663
  field.inputTypes = field.inputTypes.filter((t) => !removeTypes.has(String(t.type)));
668
664
  eventEmitter.emitSync("BeforeGenerateField", field, args);
669
665
  const { inputTypes, isRequired, name } = field;
670
666
  if (inputTypes.length === 0) {
671
667
  continue;
672
668
  }
673
- const usePattern = (useInputType == null ? void 0 : useInputType.ALL) || (useInputType == null ? void 0 : useInputType[name]);
669
+ const usePattern = useInputType?.ALL || useInputType?.[name];
674
670
  const graphqlInputType = getGraphqlInputType(inputTypes, usePattern);
675
671
  const { isList, location, type } = graphqlInputType;
676
672
  const typeName = String(type);
677
- const settings = modelFieldSettings == null ? void 0 : modelFieldSettings.get(name);
678
- const propertySettings = settings == null ? void 0 : settings.getPropertyType({
679
- name: inputType1.name,
673
+ const settings = modelFieldSettings?.get(name);
674
+ const propertySettings = settings?.getPropertyType({
675
+ name: inputType2.name,
680
676
  input: true
681
677
  });
682
- const isCustomsApplicable = typeName === ((_a = model == null ? void 0 : model.fields.find((f) => f.name === name)) == null ? void 0 : _a.type);
683
- const propertyType = (0, import_lodash3.castArray)((propertySettings == null ? void 0 : propertySettings.name) || getPropertyType({
678
+ const modelField = model?.fields.find((f) => f.name === name);
679
+ const isCustomsApplicable = typeName === modelField?.type;
680
+ const propertyType = (0, import_lodash3.castArray)(propertySettings?.name || getPropertyType({
684
681
  location,
685
682
  type: typeName
686
683
  }));
@@ -699,12 +696,12 @@ function inputType(args) {
699
696
  importDeclarations.add("Decimal", "@prisma/client/runtime");
700
697
  }
701
698
  let graphqlType;
702
- const shouldHideField = (settings == null ? void 0 : settings.shouldHideField({
703
- name: inputType1.name,
699
+ const shouldHideField = settings?.shouldHideField({
700
+ name: inputType2.name,
704
701
  input: true
705
- })) || config.decorate.some((d) => d.name === "HideField" && d.from === "@nestjs/graphql" && d.isMatchField(name) && d.isMatchType(inputType1.name));
706
- const fieldType = settings == null ? void 0 : settings.getFieldType({
707
- name: inputType1.name,
702
+ }) || config.decorate.some((d) => d.name === "HideField" && d.from === "@nestjs/graphql" && d.isMatchField(name) && d.isMatchType(inputType2.name));
703
+ const fieldType = settings?.getFieldType({
704
+ name: inputType2.name,
708
705
  input: true
709
706
  });
710
707
  if (fieldType && isCustomsApplicable && !shouldHideField) {
@@ -725,7 +722,7 @@ function inputType(args) {
725
722
  if (location === "enumTypes") {
726
723
  referenceName = (0, import_lodash3.last)(referenceName.split(" "));
727
724
  }
728
- if (graphqlImport.specifier && !importDeclarations.has(graphqlImport.name) && graphqlImport.name !== inputType1.name) {
725
+ if (graphqlImport.specifier && !importDeclarations.has(graphqlImport.name) && graphqlImport.name !== inputType2.name) {
729
726
  importDeclarations.set(graphqlImport.name, {
730
727
  namedImports: [
731
728
  {
@@ -749,14 +746,52 @@ function inputType(args) {
749
746
  arguments: [
750
747
  isList ? `() => [${graphqlType}]` : `() => ${graphqlType}`,
751
748
  import_json5.default.stringify({
752
- ...settings == null ? void 0 : settings.fieldArguments(),
749
+ ...settings?.fieldArguments(),
753
750
  nullable: !isRequired
754
751
  })
755
752
  ]
756
753
  });
754
+ if (graphqlType === "GraphQLDecimal") {
755
+ importDeclarations.add("transformToDecimal", "prisma-graphql-type-decimal");
756
+ importDeclarations.add("Transform", "class-transformer");
757
+ importDeclarations.add("Type", "class-transformer");
758
+ property.decorators.push({
759
+ name: "Type",
760
+ arguments: [
761
+ "() => Object"
762
+ ]
763
+ }, {
764
+ name: "Transform",
765
+ arguments: [
766
+ "transformToDecimal"
767
+ ]
768
+ });
769
+ } else if (location === "inputObjectTypes" && (modelField?.type === "Decimal" || [
770
+ "connect",
771
+ "connectOrCreate",
772
+ "create",
773
+ "createMany",
774
+ "data",
775
+ "delete",
776
+ "deleteMany",
777
+ "disconnect",
778
+ "set",
779
+ "update",
780
+ "updateMany",
781
+ "upsert",
782
+ "where"
783
+ ].includes(name) || classTransformerTypeModels.has(getModelName2(graphqlType) || ""))) {
784
+ importDeclarations.add("Type", "class-transformer");
785
+ property.decorators.push({
786
+ name: "Type",
787
+ arguments: [
788
+ `() => ${graphqlType}`
789
+ ]
790
+ });
791
+ }
757
792
  if (isCustomsApplicable) {
758
793
  for (const options of settings || []) {
759
- if ((_c = options.kind === "Decorator" && options.input && ((_b = options.match) == null ? void 0 : _b.call(options, name))) != null ? _c : true) {
794
+ if ((options.kind === "Decorator" && options.input && options.match?.(name)) ?? true) {
760
795
  property.decorators.push({
761
796
  name: options.name,
762
797
  arguments: options.arguments
@@ -767,10 +802,10 @@ function inputType(args) {
767
802
  }
768
803
  }
769
804
  for (const decorate of config.decorate) {
770
- if (decorate.isMatchField(name) && decorate.isMatchType(inputType1.name)) {
805
+ if (decorate.isMatchField(name) && decorate.isMatchType(inputType2.name)) {
771
806
  property.decorators.push({
772
807
  name: decorate.name,
773
- arguments: (_d = decorate.arguments) == null ? void 0 : _d.map((x) => (0, import_pupa.default)(x, {
808
+ arguments: decorate.arguments?.map((x) => (0, import_pupa.default)(x, {
774
809
  propertyType
775
810
  }))
776
811
  });
@@ -799,9 +834,8 @@ var import_lodash4 = require("lodash");
799
834
  var import_outmatch2 = __toESM(require("outmatch"));
800
835
  var ObjectSettings = class extends Array {
801
836
  shouldHideField({ name, input = false, output = false }) {
802
- var _a;
803
837
  const hideField = this.find((s) => s.name === "HideField");
804
- return Boolean((hideField == null ? void 0 : hideField.input) && input || (hideField == null ? void 0 : hideField.output) && output || ((_a = hideField == null ? void 0 : hideField.match) == null ? void 0 : _a.call(hideField, name)));
838
+ return Boolean(hideField?.input && input || hideField?.output && output || hideField?.match?.(name));
805
839
  }
806
840
  getFieldType({ name, input, output }) {
807
841
  const fieldType = this.find((s) => s.kind === "FieldType");
@@ -851,9 +885,9 @@ var ObjectSettings = class extends Array {
851
885
  return resultArguments.map((x) => import_json52.default.stringify(x));
852
886
  }
853
887
  fieldArguments() {
854
- const item1 = this.find((item) => item.kind === "Field");
855
- if (item1) {
856
- return item1.arguments;
888
+ const item = this.find((item2) => item2.kind === "Field");
889
+ if (item) {
890
+ return item.arguments;
857
891
  }
858
892
  }
859
893
  };
@@ -893,7 +927,6 @@ function createObjectSettings(args) {
893
927
  }
894
928
  __name(createObjectSettings, "createObjectSettings");
895
929
  function createSettingElement({ line, config, fieldElement, match }) {
896
- var _a, _b, _c, _d, _e;
897
930
  const result = {
898
931
  documentLine: "",
899
932
  element: void 0
@@ -903,7 +936,7 @@ function createSettingElement({ line, config, fieldElement, match }) {
903
936
  result.element = fieldElement;
904
937
  return result;
905
938
  }
906
- const name = (_a = match == null ? void 0 : match.groups) == null ? void 0 : _a.name;
939
+ const name = match?.groups?.name;
907
940
  if (!(match && name)) {
908
941
  result.documentLine = line;
909
942
  return result;
@@ -925,29 +958,29 @@ function createSettingElement({ line, config, fieldElement, match }) {
925
958
  if ([
926
959
  "FieldType",
927
960
  "PropertyType"
928
- ].includes(name) && ((_b = match.groups) == null ? void 0 : _b.args)) {
929
- const options2 = customType(match.groups.args);
930
- (0, import_lodash4.merge)(element, options2.namespace && config.fields[options2.namespace], options2, {
961
+ ].includes(name) && match.groups?.args) {
962
+ const options = customType(match.groups.args);
963
+ (0, import_lodash4.merge)(element, options.namespace && config.fields[options.namespace], options, {
931
964
  kind: name
932
965
  });
933
966
  return result;
934
967
  }
935
- if (name === "ObjectType" && ((_c = match.groups) == null ? void 0 : _c.args)) {
968
+ if (name === "ObjectType" && match.groups?.args) {
936
969
  element.kind = "ObjectType";
937
- const options2 = customType(match.groups.args);
938
- if (typeof options2[0] === "string" && options2[0]) {
939
- options2.name = options2[0];
970
+ const options1 = customType(match.groups.args);
971
+ if (typeof options1[0] === "string" && options1[0]) {
972
+ options1.name = options1[0];
940
973
  }
941
- if ((0, import_lodash4.isObject)(options2[1])) {
942
- (0, import_lodash4.merge)(options2, options2[1]);
974
+ if ((0, import_lodash4.isObject)(options1[1])) {
975
+ (0, import_lodash4.merge)(options1, options1[1]);
943
976
  }
944
977
  element.arguments = {
945
- name: options2.name,
946
- isAbstract: options2.isAbstract
978
+ name: options1.name,
979
+ isAbstract: options1.isAbstract
947
980
  };
948
981
  return result;
949
982
  }
950
- if (name === "Directive" && ((_d = match.groups) == null ? void 0 : _d.args)) {
983
+ if (name === "Directive" && match.groups?.args) {
951
984
  const options2 = customType(match.groups.args);
952
985
  (0, import_lodash4.merge)(element, {
953
986
  model: true,
@@ -962,16 +995,15 @@ function createSettingElement({ line, config, fieldElement, match }) {
962
995
  }
963
996
  const namespace = getNamespace(name);
964
997
  element.namespaceImport = namespace;
965
- const options = {
998
+ const options3 = {
966
999
  name,
967
- arguments: (((_e = match.groups) == null ? void 0 : _e.args) || "").split(",").map((s) => (0, import_lodash4.trim)(s)).filter(Boolean)
1000
+ arguments: (match.groups?.args || "").split(",").map((s) => (0, import_lodash4.trim)(s)).filter(Boolean)
968
1001
  };
969
- (0, import_lodash4.merge)(element, namespace && config.fields[namespace], options);
1002
+ (0, import_lodash4.merge)(element, namespace && config.fields[namespace], options3);
970
1003
  return result;
971
1004
  }
972
1005
  __name(createSettingElement, "createSettingElement");
973
1006
  function customType(args) {
974
- var _a;
975
1007
  const result = {};
976
1008
  let options = parseArgs(args);
977
1009
  if (typeof options === "string") {
@@ -982,7 +1014,7 @@ function customType(args) {
982
1014
  Object.assign(result, options);
983
1015
  const namespace = getNamespace(options.name);
984
1016
  result.namespace = namespace;
985
- if ((_a = options.name) == null ? void 0 : _a.includes(".")) {
1017
+ if (options.name?.includes(".")) {
986
1018
  result.namespaceImport = namespace;
987
1019
  }
988
1020
  if (typeof options.match === "string" || Array.isArray(options.match)) {
@@ -994,7 +1026,6 @@ function customType(args) {
994
1026
  }
995
1027
  __name(customType, "customType");
996
1028
  function hideFieldDecorator(match) {
997
- var _a;
998
1029
  const result = {
999
1030
  name: "HideField",
1000
1031
  arguments: [],
@@ -1003,7 +1034,7 @@ function hideFieldDecorator(match) {
1003
1034
  namespaceImport: void 0,
1004
1035
  match: void 0
1005
1036
  };
1006
- if (!((_a = match.groups) == null ? void 0 : _a.args)) {
1037
+ if (!match.groups?.args) {
1007
1038
  result.output = true;
1008
1039
  return result;
1009
1040
  }
@@ -1030,10 +1061,10 @@ __name(hideFieldDecorator, "hideFieldDecorator");
1030
1061
  function parseArgs(string) {
1031
1062
  try {
1032
1063
  return import_json52.default.parse(string);
1033
- } catch (e) {
1064
+ } catch {
1034
1065
  try {
1035
1066
  return import_json52.default.parse(`[${string}]`);
1036
- } catch (e2) {
1067
+ } catch {
1037
1068
  throw new Error(`Failed to parse: ${string}`);
1038
1069
  }
1039
1070
  }
@@ -1053,7 +1084,7 @@ __name(getNamespace, "getNamespace");
1053
1084
 
1054
1085
  // src/handlers/model-data.ts
1055
1086
  function modelData(model, args) {
1056
- const { config, modelNames, models, modelFields, fieldSettings } = args;
1087
+ const { config, modelNames, models, modelFields, fieldSettings, classTransformerTypeModels } = args;
1057
1088
  modelNames.push(model.name);
1058
1089
  models.set(model.name, model);
1059
1090
  const modelFieldsValue = /* @__PURE__ */ new Map();
@@ -1071,6 +1102,9 @@ function modelData(model, args) {
1071
1102
  }
1072
1103
  modelFieldsValue.set(field.name, field);
1073
1104
  }
1105
+ if (model.fields.some((field) => field.type === "Decimal")) {
1106
+ classTransformerTypeModels.add(model.name);
1107
+ }
1074
1108
  }
1075
1109
  __name(modelData, "modelData");
1076
1110
 
@@ -1083,7 +1117,6 @@ var import_ts_morph5 = require("ts-morph");
1083
1117
 
1084
1118
  // src/helpers/create-comment.ts
1085
1119
  function createComment(documentation, settings) {
1086
- var _a;
1087
1120
  const documentationLines = documentation.split("\n");
1088
1121
  const commentLines = [
1089
1122
  "/**"
@@ -1091,7 +1124,7 @@ function createComment(documentation, settings) {
1091
1124
  for (const line of documentationLines) {
1092
1125
  commentLines.push(` * ${line}`);
1093
1126
  }
1094
- const deprecationReason = (_a = settings == null ? void 0 : settings.fieldArguments()) == null ? void 0 : _a.deprecationReason;
1127
+ const deprecationReason = settings?.fieldArguments()?.deprecationReason;
1095
1128
  if (deprecationReason) {
1096
1129
  commentLines.push(` * @deprecated ${deprecationReason}`);
1097
1130
  }
@@ -1109,7 +1142,6 @@ __name(getOutputTypeName, "getOutputTypeName");
1109
1142
  // src/handlers/model-output-type.ts
1110
1143
  var nestjsGraphql = "@nestjs/graphql";
1111
1144
  function modelOutputType(outputType2, args) {
1112
- var _a, _b, _c, _d, _e, _f;
1113
1145
  const { getSourceFile, models, config, modelFields, fieldSettings, eventEmitter } = args;
1114
1146
  const model = models.get(outputType2.name);
1115
1147
  (0, import_assert3.ok)(model, `Cannot find model by name ${outputType2.name}`);
@@ -1162,17 +1194,17 @@ function modelOutputType(outputType2, args) {
1162
1194
  fileType = "output";
1163
1195
  outputTypeName = getOutputTypeName(outputTypeName);
1164
1196
  }
1165
- const modelField = (_a = modelFields.get(model.name)) == null ? void 0 : _a.get(field.name);
1166
- const settings = (_b = fieldSettings.get(model.name)) == null ? void 0 : _b.get(field.name);
1167
- const fieldType = settings == null ? void 0 : settings.getFieldType({
1197
+ const modelField = modelFields.get(model.name)?.get(field.name);
1198
+ const settings1 = fieldSettings.get(model.name)?.get(field.name);
1199
+ const fieldType = settings1?.getFieldType({
1168
1200
  name: outputType2.name,
1169
1201
  output: true
1170
1202
  });
1171
- const propertySettings = settings == null ? void 0 : settings.getPropertyType({
1203
+ const propertySettings = settings1?.getPropertyType({
1172
1204
  name: outputType2.name,
1173
1205
  output: true
1174
1206
  });
1175
- const propertyType = (0, import_lodash5.castArray)((propertySettings == null ? void 0 : propertySettings.name) || getPropertyType({
1207
+ const propertyType = (0, import_lodash5.castArray)(propertySettings?.name || getPropertyType({
1176
1208
  location,
1177
1209
  type: outputTypeName
1178
1210
  }));
@@ -1192,7 +1224,7 @@ function modelOutputType(outputType2, args) {
1192
1224
  sourceFile,
1193
1225
  fileType,
1194
1226
  location,
1195
- isId: modelField == null ? void 0 : modelField.isId,
1227
+ isId: modelField?.isId,
1196
1228
  noTypeId: config.noTypeId,
1197
1229
  typeName: outputTypeName,
1198
1230
  getSourceFile
@@ -1210,10 +1242,10 @@ function modelOutputType(outputType2, args) {
1210
1242
  propertyType,
1211
1243
  isList
1212
1244
  });
1213
- if (typeof property.leadingTrivia === "string" && (modelField == null ? void 0 : modelField.documentation)) {
1214
- property.leadingTrivia += createComment(modelField.documentation, settings);
1245
+ if (typeof property.leadingTrivia === "string" && modelField?.documentation) {
1246
+ property.leadingTrivia += createComment(modelField.documentation, settings1);
1215
1247
  }
1216
- (_c = classStructure.properties) == null ? void 0 : _c.push(property);
1248
+ classStructure.properties?.push(property);
1217
1249
  if (propertySettings) {
1218
1250
  importDeclarations.create({
1219
1251
  ...propertySettings
@@ -1222,7 +1254,7 @@ function modelOutputType(outputType2, args) {
1222
1254
  importDeclarations.add("Decimal", "@prisma/client/runtime");
1223
1255
  }
1224
1256
  (0, import_assert3.ok)(property.decorators, "property.decorators is undefined");
1225
- if (settings == null ? void 0 : settings.shouldHideField({
1257
+ if (settings1?.shouldHideField({
1226
1258
  name: outputType2.name,
1227
1259
  output: true
1228
1260
  })) {
@@ -1237,19 +1269,19 @@ function modelOutputType(outputType2, args) {
1237
1269
  arguments: [
1238
1270
  isList ? `() => [${graphqlType}]` : `() => ${graphqlType}`,
1239
1271
  import_json53.default.stringify({
1240
- ...settings == null ? void 0 : settings.fieldArguments(),
1272
+ ...settings1?.fieldArguments(),
1241
1273
  nullable: Boolean(field.isNullable),
1242
1274
  defaultValue: [
1243
1275
  "number",
1244
1276
  "string",
1245
1277
  "boolean"
1246
- ].includes(typeof (modelField == null ? void 0 : modelField.default)) ? modelField == null ? void 0 : modelField.default : void 0,
1247
- description: modelField == null ? void 0 : modelField.documentation
1278
+ ].includes(typeof modelField?.default) ? modelField?.default : void 0,
1279
+ description: modelField?.documentation
1248
1280
  })
1249
1281
  ]
1250
1282
  });
1251
- for (const setting of settings || []) {
1252
- if (shouldBeDecorated(setting) && ((_e = (_d = setting.match) == null ? void 0 : _d.call(setting, field.name)) != null ? _e : true)) {
1283
+ for (const setting of settings1 || []) {
1284
+ if (shouldBeDecorated(setting) && (setting.match?.(field.name) ?? true)) {
1253
1285
  property.decorators.push({
1254
1286
  name: setting.name,
1255
1287
  arguments: setting.arguments
@@ -1262,7 +1294,7 @@ function modelOutputType(outputType2, args) {
1262
1294
  if (decorate.isMatchField(field.name) && decorate.isMatchType(outputTypeName)) {
1263
1295
  property.decorators.push({
1264
1296
  name: decorate.name,
1265
- arguments: (_f = decorate.arguments) == null ? void 0 : _f.map((x) => (0, import_pupa2.default)(x, {
1297
+ arguments: decorate.arguments?.map((x) => (0, import_pupa2.default)(x, {
1266
1298
  propertyType
1267
1299
  }))
1268
1300
  });
@@ -1276,13 +1308,13 @@ function modelOutputType(outputType2, args) {
1276
1308
  propertyType
1277
1309
  });
1278
1310
  }
1279
- for (const setting of modelSettings || []) {
1280
- if (shouldBeDecorated(setting)) {
1311
+ for (const setting1 of modelSettings || []) {
1312
+ if (shouldBeDecorated(setting1)) {
1281
1313
  classStructure.decorators.push({
1282
- name: setting.name,
1283
- arguments: setting.arguments
1314
+ name: setting1.name,
1315
+ arguments: setting1.arguments
1284
1316
  });
1285
- importDeclarations.create(setting);
1317
+ importDeclarations.create(setting1);
1286
1318
  }
1287
1319
  }
1288
1320
  if (exportDeclaration) {
@@ -1328,11 +1360,11 @@ function noAtomicOperations(eventEmitter) {
1328
1360
  }
1329
1361
  __name(noAtomicOperations, "noAtomicOperations");
1330
1362
  function beforeInputType2(args) {
1331
- const { inputType: inputType1, getModelName: getModelName2 } = args;
1332
- for (const field of inputType1.fields) {
1363
+ const { inputType: inputType2, getModelName: getModelName2 } = args;
1364
+ for (const field of inputType2.fields) {
1333
1365
  const fieldName = field.name;
1334
- field.inputTypes = field.inputTypes.filter((inputType2) => {
1335
- const inputTypeName = String(inputType2.type);
1366
+ field.inputTypes = field.inputTypes.filter((inputType3) => {
1367
+ const inputTypeName = String(inputType3.type);
1336
1368
  const modelName = getModelName2(inputTypeName);
1337
1369
  if (isAtomicOperation(inputTypeName) || modelName && isListInput(inputTypeName, modelName, fieldName)) {
1338
1370
  return false;
@@ -1343,10 +1375,9 @@ function beforeInputType2(args) {
1343
1375
  }
1344
1376
  __name(beforeInputType2, "beforeInputType");
1345
1377
  function beforeGenerateFiles(args) {
1346
- var _a;
1347
1378
  const { project } = args;
1348
1379
  for (const sourceFile of project.getSourceFiles()) {
1349
- const className = (_a = sourceFile.getClass(() => true)) == null ? void 0 : _a.getName();
1380
+ const className = sourceFile.getClass(() => true)?.getName();
1350
1381
  if (className && isAtomicOperation(className)) {
1351
1382
  project.removeSourceFile(sourceFile);
1352
1383
  }
@@ -1371,30 +1402,29 @@ var import_json54 = __toESM(require("json5"));
1371
1402
  var import_lodash6 = require("lodash");
1372
1403
  var import_ts_morph6 = require("ts-morph");
1373
1404
  var nestjsGraphql2 = "@nestjs/graphql";
1374
- function outputType(outputType1, args) {
1375
- var _a, _b, _c, _d, _e;
1405
+ function outputType(outputType2, args) {
1376
1406
  const { getSourceFile, models, eventEmitter, fieldSettings, getModelName: getModelName2, config } = args;
1377
1407
  const importDeclarations = new ImportDeclarationMap();
1378
1408
  const fileType = "output";
1379
- const modelName = getModelName2(outputType1.name) || "";
1409
+ const modelName = getModelName2(outputType2.name) || "";
1380
1410
  const model = models.get(modelName);
1381
- const isAggregateOutput = model && /(?:Count|Avg|Sum|Min|Max)AggregateOutputType$/.test(outputType1.name) && String(outputType1.name).startsWith(model.name);
1382
- const isCountOutput = (model == null ? void 0 : model.name) && outputType1.name === `${model.name}CountOutputType`;
1383
- outputType1.name = getOutputTypeName(outputType1.name);
1411
+ const isAggregateOutput = model && /(?:Count|Avg|Sum|Min|Max)AggregateOutputType$/.test(outputType2.name) && String(outputType2.name).startsWith(model.name);
1412
+ const isCountOutput = model?.name && outputType2.name === `${model.name}CountOutputType`;
1413
+ outputType2.name = getOutputTypeName(outputType2.name);
1384
1414
  if (isAggregateOutput) {
1385
1415
  eventEmitter.emitSync("AggregateOutput", {
1386
1416
  ...args,
1387
- outputType: outputType1
1417
+ outputType: outputType2
1388
1418
  });
1389
1419
  }
1390
1420
  const sourceFile = getSourceFile({
1391
- name: outputType1.name,
1421
+ name: outputType2.name,
1392
1422
  type: fileType
1393
1423
  });
1394
1424
  const classStructure = {
1395
1425
  kind: import_ts_morph6.StructureKind.Class,
1396
1426
  isExported: true,
1397
- name: outputType1.name,
1427
+ name: outputType2.name,
1398
1428
  decorators: [
1399
1429
  {
1400
1430
  name: "ObjectType",
@@ -1405,17 +1435,17 @@ function outputType(outputType1, args) {
1405
1435
  };
1406
1436
  importDeclarations.add("Field", nestjsGraphql2);
1407
1437
  importDeclarations.add("ObjectType", nestjsGraphql2);
1408
- for (const field of outputType1.fields) {
1438
+ for (const field of outputType2.fields) {
1409
1439
  const { location, isList, type } = field.outputType;
1410
1440
  const outputTypeName = getOutputTypeName(String(type));
1411
- const settings = isCountOutput ? void 0 : model && ((_a = fieldSettings.get(model.name)) == null ? void 0 : _a.get(field.name));
1412
- const propertySettings = settings == null ? void 0 : settings.getPropertyType({
1413
- name: outputType1.name,
1441
+ const settings = isCountOutput ? void 0 : model && fieldSettings.get(model.name)?.get(field.name);
1442
+ const propertySettings = settings?.getPropertyType({
1443
+ name: outputType2.name,
1414
1444
  output: true
1415
1445
  });
1416
- const isCustomsApplicable = outputTypeName === ((_b = model == null ? void 0 : model.fields.find((f) => f.name === field.name)) == null ? void 0 : _b.type);
1446
+ const isCustomsApplicable = outputTypeName === model?.fields.find((f) => f.name === field.name)?.type;
1417
1447
  field.outputType.type = outputTypeName;
1418
- const propertyType = (0, import_lodash6.castArray)((propertySettings == null ? void 0 : propertySettings.name) || getPropertyType({
1448
+ const propertyType = (0, import_lodash6.castArray)(propertySettings?.name || getPropertyType({
1419
1449
  location,
1420
1450
  type: outputTypeName
1421
1451
  }));
@@ -1426,7 +1456,7 @@ function outputType(outputType1, args) {
1426
1456
  propertyType,
1427
1457
  isList
1428
1458
  });
1429
- (_c = classStructure.properties) == null ? void 0 : _c.push(property);
1459
+ classStructure.properties?.push(property);
1430
1460
  if (propertySettings) {
1431
1461
  importDeclarations.create({
1432
1462
  ...propertySettings
@@ -1435,12 +1465,12 @@ function outputType(outputType1, args) {
1435
1465
  importDeclarations.add("Decimal", "@prisma/client/runtime");
1436
1466
  }
1437
1467
  let graphqlType;
1438
- const shouldHideField = (settings == null ? void 0 : settings.shouldHideField({
1439
- name: outputType1.name,
1468
+ const shouldHideField = settings?.shouldHideField({
1469
+ name: outputType2.name,
1440
1470
  output: true
1441
- })) || config.decorate.some((d) => d.name === "HideField" && d.from === "@nestjs/graphql" && d.isMatchField(field.name) && d.isMatchType(outputTypeName));
1442
- const fieldType = settings == null ? void 0 : settings.getFieldType({
1443
- name: outputType1.name,
1471
+ }) || config.decorate.some((d) => d.name === "HideField" && d.from === "@nestjs/graphql" && d.isMatchField(field.name) && d.isMatchType(outputTypeName));
1472
+ const fieldType = settings?.getFieldType({
1473
+ name: outputType2.name,
1444
1474
  output: true
1445
1475
  });
1446
1476
  if (fieldType && isCustomsApplicable && !shouldHideField) {
@@ -1463,7 +1493,7 @@ function outputType(outputType1, args) {
1463
1493
  if (location === "enumTypes") {
1464
1494
  referenceName = (0, import_lodash6.last)(referenceName.split(" "));
1465
1495
  }
1466
- if (graphqlImport.specifier && !importDeclarations.has(graphqlImport.name) && (graphqlImport.name !== outputType1.name && !shouldHideField || shouldHideField && referenceName === graphqlImport.name)) {
1496
+ if (graphqlImport.specifier && !importDeclarations.has(graphqlImport.name) && (graphqlImport.name !== outputType2.name && !shouldHideField || shouldHideField && referenceName === graphqlImport.name)) {
1467
1497
  importDeclarations.set(graphqlImport.name, {
1468
1498
  namedImports: [
1469
1499
  {
@@ -1487,14 +1517,14 @@ function outputType(outputType1, args) {
1487
1517
  arguments: [
1488
1518
  isList ? `() => [${graphqlType}]` : `() => ${graphqlType}`,
1489
1519
  import_json54.default.stringify({
1490
- ...settings == null ? void 0 : settings.fieldArguments(),
1520
+ ...settings?.fieldArguments(),
1491
1521
  nullable: Boolean(field.isNullable)
1492
1522
  })
1493
1523
  ]
1494
1524
  });
1495
1525
  if (isCustomsApplicable) {
1496
1526
  for (const options of settings || []) {
1497
- if ((_e = options.kind === "Decorator" && options.output && ((_d = options.match) == null ? void 0 : _d.call(options, field.name))) != null ? _e : true) {
1527
+ if ((options.kind === "Decorator" && options.output && options.match?.(field.name)) ?? true) {
1498
1528
  property.decorators.push({
1499
1529
  name: options.name,
1500
1530
  arguments: options.arguments
@@ -1528,8 +1558,7 @@ function purgeOutput(emitter) {
1528
1558
  }
1529
1559
  __name(purgeOutput, "purgeOutput");
1530
1560
  function begin({ project, output }) {
1531
- var _a;
1532
- const sourceFiles = (_a = project.getDirectory(output)) == null ? void 0 : _a.getDescendantSourceFiles();
1561
+ const sourceFiles = project.getDirectory(output)?.getDescendantSourceFiles();
1533
1562
  if (sourceFiles) {
1534
1563
  for (const sourceFile of sourceFiles) {
1535
1564
  sourceFile.delete();
@@ -1538,12 +1567,11 @@ function begin({ project, output }) {
1538
1567
  }
1539
1568
  __name(begin, "begin");
1540
1569
  async function end({ project, output }) {
1541
- var _a;
1542
- const directories = (_a = project.getDirectory(output)) == null ? void 0 : _a.getDescendantDirectories().filter((directory) => directory.getSourceFiles().length === 0).map((directory) => directory.getPath());
1543
- for (const directory1 of directories || []) {
1570
+ const directories = project.getDirectory(output)?.getDescendantDirectories().filter((directory) => directory.getSourceFiles().length === 0).map((directory) => directory.getPath());
1571
+ for (const directory of directories || []) {
1544
1572
  try {
1545
- await import_fs.promises.rmdir(directory1);
1546
- } catch (e) {
1573
+ await import_fs.promises.rmdir(directory);
1574
+ } catch {
1547
1575
  }
1548
1576
  }
1549
1577
  }
@@ -1593,23 +1621,23 @@ function beforeGenerateFiles2(args) {
1593
1621
  }
1594
1622
  }
1595
1623
  if (config.reExport === ReExport.Single) {
1596
- const exportDeclarations = project.getSourceFiles().filter((sourceFile) => {
1624
+ const exportDeclarations1 = project.getSourceFiles().filter((sourceFile) => {
1597
1625
  return sourceFile.getBaseName() !== "index.ts";
1598
1626
  }).map((sourceFile) => getExportDeclaration2(rootDirectory, sourceFile));
1599
1627
  rootDirectory.createSourceFile("index.ts", {
1600
- statements: exportDeclarations
1628
+ statements: exportDeclarations1
1601
1629
  }, {
1602
1630
  overwrite: true
1603
1631
  });
1604
1632
  }
1605
1633
  if (config.reExport === ReExport.All) {
1606
- const exportDeclarations = [];
1607
- for (const directory of rootDirectory.getDirectories()) {
1608
- const sourceFile = directory.getSourceFileOrThrow("index.ts");
1609
- exportDeclarations.push(getExportDeclaration2(rootDirectory, sourceFile));
1634
+ const exportDeclarations2 = [];
1635
+ for (const directory1 of rootDirectory.getDirectories()) {
1636
+ const sourceFile = directory1.getSourceFileOrThrow("index.ts");
1637
+ exportDeclarations2.push(getExportDeclaration2(rootDirectory, sourceFile));
1610
1638
  }
1611
1639
  rootDirectory.createSourceFile("index.ts", {
1612
- statements: exportDeclarations
1640
+ statements: exportDeclarations2
1613
1641
  }, {
1614
1642
  overwrite: true
1615
1643
  });
@@ -1666,7 +1694,7 @@ function registerEnum(enumType, args) {
1666
1694
  ...importDeclarations.toStatements(),
1667
1695
  enumStructure,
1668
1696
  "\n",
1669
- `registerEnumType(${enumType.name}, { name: '${enumType.name}', description: ${JSON.stringify(dataModelEnum == null ? void 0 : dataModelEnum.documentation)} })`
1697
+ `registerEnumType(${enumType.name}, { name: '${enumType.name}', description: ${JSON.stringify(dataModelEnum?.documentation)} })`
1670
1698
  ]
1671
1699
  });
1672
1700
  }
@@ -1713,7 +1741,6 @@ var import_json55 = __toESM(require("json5"));
1713
1741
  var import_lodash7 = require("lodash");
1714
1742
  var import_outmatch3 = __toESM(require("outmatch"));
1715
1743
  function createConfig(data) {
1716
- var _a;
1717
1744
  const config = (0, import_lodash7.merge)({}, (0, import_flat.unflatten)(data, {
1718
1745
  delimiter: "_"
1719
1746
  }));
@@ -1732,7 +1759,7 @@ function createConfig(data) {
1732
1759
  config.reExport = "All";
1733
1760
  }
1734
1761
  }
1735
- const fields = Object.fromEntries(Object.entries((_a = config.fields) != null ? _a : {}).filter(({ 1: value }) => typeof value === "object").map(([name, value]) => {
1762
+ const fields = Object.fromEntries(Object.entries(config.fields ?? {}).filter(({ 1: value }) => typeof value === "object").map(([name, value]) => {
1736
1763
  const fieldSetting = {
1737
1764
  arguments: [],
1738
1765
  output: toBoolean(value.output),
@@ -1841,18 +1868,18 @@ function generateFileName(args) {
1841
1868
  return (0, import_lodash8.kebabCase)(result);
1842
1869
  },
1843
1870
  get name() {
1844
- let result = (0, import_lodash8.kebabCase)(name);
1871
+ let result1 = (0, import_lodash8.kebabCase)(name);
1845
1872
  for (const suffix of [
1846
1873
  "input",
1847
1874
  "args",
1848
1875
  "enum"
1849
1876
  ]) {
1850
1877
  const ending = `-${suffix}`;
1851
- if (type === suffix && result.endsWith(ending)) {
1852
- result = result.slice(0, -ending.length);
1878
+ if (type === suffix && result1.endsWith(ending)) {
1879
+ result1 = result1.slice(0, -ending.length);
1853
1880
  }
1854
1881
  }
1855
- return result;
1882
+ return result1;
1856
1883
  },
1857
1884
  plural: {
1858
1885
  get type() {
@@ -1864,10 +1891,10 @@ function generateFileName(args) {
1864
1891
  __name(generateFileName, "generateFileName");
1865
1892
 
1866
1893
  // src/helpers/factory-get-source-file.ts
1867
- function factoryGetSourceFile(args1) {
1868
- const { outputFilePattern, output, getModelName: getModelName2, project } = args1;
1869
- return /* @__PURE__ */ __name(function getSourceFile(args) {
1870
- const { name, type } = args;
1894
+ function factoryGetSourceFile(args) {
1895
+ const { outputFilePattern, output, getModelName: getModelName2, project } = args;
1896
+ return /* @__PURE__ */ __name(function getSourceFile(args2) {
1897
+ const { name, type } = args2;
1871
1898
  let filePath = generateFileName({
1872
1899
  getModelName: getModelName2,
1873
1900
  name,
@@ -1904,30 +1931,30 @@ function getModelName(args) {
1904
1931
  }
1905
1932
  }
1906
1933
  for (const keyword1 of endsWithKeywords) {
1907
- const [test] = name.split(keyword1).slice(-1);
1908
- if (modelNames.includes(test)) {
1909
- return test;
1934
+ const [test1] = name.split(keyword1).slice(-1);
1935
+ if (modelNames.includes(test1)) {
1936
+ return test1;
1910
1937
  }
1911
1938
  }
1912
1939
  for (const [start, end2] of middleKeywords) {
1913
- let test = name.slice(start.length).slice(0, -end2.length);
1914
- if (modelNames.includes(test)) {
1915
- return test;
1940
+ let test2 = name.slice(start.length).slice(0, -end2.length);
1941
+ if (modelNames.includes(test2)) {
1942
+ return test2;
1916
1943
  }
1917
- test = name.slice(0, -(start + end2).length);
1918
- if (modelNames.includes(test)) {
1919
- return test;
1944
+ test2 = name.slice(0, -(start + end2).length);
1945
+ if (modelNames.includes(test2)) {
1946
+ return test2;
1920
1947
  }
1921
1948
  }
1922
1949
  if (name.slice(-19) === "CompoundUniqueInput") {
1923
- const test = name.slice(0, -19);
1924
- const models = modelNames.filter((x) => test.startsWith(x)).sort((a, b) => b.length - a.length);
1950
+ const test3 = name.slice(0, -19);
1951
+ const models = modelNames.filter((x) => test3.startsWith(x)).sort((a, b) => b.length - a.length);
1925
1952
  return (0, import_lodash9.first)(models);
1926
1953
  }
1927
1954
  if (name.slice(-5) === "Count") {
1928
- const test = name.slice(0, -5);
1929
- if (modelNames.includes(test)) {
1930
- return test;
1955
+ const test4 = name.slice(0, -5);
1956
+ if (modelNames.includes(test4)) {
1957
+ return test4;
1931
1958
  }
1932
1959
  }
1933
1960
  return void 0;
@@ -2046,9 +2073,8 @@ var middleKeywords = [
2046
2073
 
2047
2074
  // src/generate.ts
2048
2075
  async function generate(args) {
2049
- var _a;
2050
2076
  const { connectCallback, generator, skipAddOutputSourceFiles, dmmf } = args;
2051
- const generatorOutputValue = (_a = generator.output) == null ? void 0 : _a.value;
2077
+ const generatorOutputValue = generator.output?.value;
2052
2078
  (0, import_assert6.ok)(generatorOutputValue, "Missing generator configuration: output");
2053
2079
  const eventEmitter = new import_await_event_emitter.default();
2054
2080
  eventEmitter.on("Warning", warning);
@@ -2111,7 +2137,8 @@ async function generate(args) {
2111
2137
  typeNames: /* @__PURE__ */ new Set(),
2112
2138
  enums: (0, import_lodash10.mapKeys)(datamodel.enums, (x) => x.name),
2113
2139
  getModelName: getModelName2,
2114
- removeTypes
2140
+ removeTypes,
2141
+ classTransformerTypeModels: /* @__PURE__ */ new Set()
2115
2142
  };
2116
2143
  if (connectCallback) {
2117
2144
  await connectCallback(eventEmitter, eventArguments);
@@ -2127,19 +2154,19 @@ async function generate(args) {
2127
2154
  for (const enumType of enumTypes.prisma.concat(enumTypes.model || [])) {
2128
2155
  await eventEmitter.emit("EnumType", enumType, eventArguments);
2129
2156
  }
2130
- for (const outputType3 of outputObjectTypes.model) {
2131
- await eventEmitter.emit("ModelOutputType", outputType3, eventArguments);
2157
+ for (const outputType1 of outputObjectTypes.model) {
2158
+ await eventEmitter.emit("ModelOutputType", outputType1, eventArguments);
2132
2159
  }
2133
2160
  const queryOutputTypes = [];
2134
- for (const outputType1 of outputObjectTypes.prisma) {
2161
+ for (const outputType2 of outputObjectTypes.prisma) {
2135
2162
  if ([
2136
2163
  "Query",
2137
2164
  "Mutation"
2138
- ].includes(outputType1.name)) {
2139
- queryOutputTypes.push(outputType1);
2165
+ ].includes(outputType2.name)) {
2166
+ queryOutputTypes.push(outputType2);
2140
2167
  continue;
2141
2168
  }
2142
- await eventEmitter.emit("OutputType", outputType1, eventArguments);
2169
+ await eventEmitter.emit("OutputType", outputType2, eventArguments);
2143
2170
  }
2144
2171
  const inputTypes = inputObjectTypes.prisma.concat(inputObjectTypes.model || []);
2145
2172
  for (const inputType1 of inputTypes) {
@@ -2156,8 +2183,8 @@ async function generate(args) {
2156
2183
  await eventEmitter.emit("BeforeInputType", event);
2157
2184
  await eventEmitter.emit("InputType", event);
2158
2185
  }
2159
- for (const outputType2 of queryOutputTypes) {
2160
- for (const field of outputType2.fields) {
2186
+ for (const outputType3 of queryOutputTypes) {
2187
+ for (const field of outputType3.fields) {
2161
2188
  await eventEmitter.emit("ArgsType", field, eventArguments);
2162
2189
  }
2163
2190
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-nestjs-graphql",
3
- "version": "15.3.3",
3
+ "version": "17.0.0",
4
4
  "license": "MIT",
5
5
  "description": "Generate object types, inputs, args, etc. from prisma schema file for usage with @nestjs/graphql module",
6
6
  "main": "index.js",
@@ -23,9 +23,9 @@
23
23
  "scripts": {
24
24
  "test": "npm run eslint && npm run tscheck && npm run test:cov",
25
25
  "mocha": "node node_modules/mocha/bin/mocha",
26
- "test:r": "npm run mocha -- -r ts-node/register src/**/*.spec.ts",
27
- "test:cov": "c8 --reporter text --exclude \"**/*.spec.ts\" --exclude \"**/test/**\" npm run test:r -- --no-timeouts",
28
- "test:w": "npm run test:r -- --watch-files src --watch --timeout=10s",
26
+ "test:r": "npm run mocha -- -r ts-node/register --no-timeouts src/**/*.spec.ts",
27
+ "test:cov": "c8 --reporter text --exclude \"**/*.spec.ts\" --exclude \"**/test/**\" npm run test:r",
28
+ "test:w": "npm run test:r -- --watch-files src --watch",
29
29
  "test:d": "ndb -r @swc/register node_modules/mocha/bin/_mocha --no-timeouts --watch-files src/**/*.ts --watch src/**/*.spec.ts",
30
30
  "tscheck": "tsc --noEmit",
31
31
  "tscheck:w": "npm run tscheck -- --watch",
@@ -36,7 +36,8 @@
36
36
  "prisma:g": "node node_modules/prisma/build/index.js generate",
37
37
  "format": "npx prettier ./@generated --write",
38
38
  "regen": "rm -rf @generated && npm run prisma:g && npm run format",
39
- "example": "ts-node-dev example/main.ts",
39
+ "rt": "npm run regen && npm test",
40
+ "example": "node-dev example/main.ts",
40
41
  "clean_cache": "rm -rf node_modules/.cache",
41
42
  "compatibilty_check": "sh Taskfile compatibilty_check",
42
43
  "commit": "cz"
@@ -51,7 +52,7 @@
51
52
  }
52
53
  },
53
54
  "dependencies": {
54
- "@prisma/generator-helper": "^3.14.0",
55
+ "@prisma/generator-helper": "^4.0.0",
55
56
  "await-event-emitter": "^2.0.2",
56
57
  "filenamify": "4.X",
57
58
  "flat": "^5.0.2",
@@ -64,35 +65,35 @@
64
65
  "ts-morph": ">=11"
65
66
  },
66
67
  "devDependencies": {
67
- "@nestjs/apollo": "^10.0.11",
68
- "@commitlint/cli": "^16.2.4",
69
- "@commitlint/config-conventional": "^16.2.4",
70
- "@nestjs/common": "^8.4.4",
71
- "@nestjs/core": "^8.4.4",
72
- "@nestjs/graphql": "^10.0.11",
73
- "@nestjs/platform-express": "^8.4.4",
68
+ "@commitlint/cli": "^17.0.0",
69
+ "@commitlint/config-conventional": "^17.0.0",
70
+ "@nestjs/apollo": "^10.0.12",
71
+ "@nestjs/common": "^8.4.5",
72
+ "@nestjs/core": "^8.4.5",
73
+ "@nestjs/graphql": "^10.0.12",
74
+ "@nestjs/platform-express": "^8.4.5",
74
75
  "@paljs/plugins": "^4.1.0",
75
- "@prisma/client": "^3.14.0",
76
+ "@prisma/client": "^4.0.0",
76
77
  "@semantic-release/changelog": "^6.0.1",
77
78
  "@semantic-release/git": "^10.0.1",
78
- "@swc/core": "^1.2.181",
79
+ "@swc/core": "^1.2.189",
79
80
  "@swc/helpers": "^0.3.13",
80
81
  "@swc/register": "^0.1.10",
81
82
  "@types/flat": "^5.0.2",
82
83
  "@types/lodash": "^4.14.182",
83
84
  "@types/mocha": "^9.1.1",
84
- "@types/node": "^17.0.31",
85
+ "@types/node": "^17.0.35",
85
86
  "@types/pluralize": "^0.0.29",
86
- "@typescript-eslint/eslint-plugin": "^5.23.0",
87
- "@typescript-eslint/parser": "^5.23.0",
87
+ "@typescript-eslint/eslint-plugin": "^5.25.0",
88
+ "@typescript-eslint/parser": "^5.25.0",
88
89
  "apollo-server-express": "^3.7.0",
89
- "c8": "^7.11.2",
90
+ "c8": "^7.11.3",
90
91
  "class-transformer": "^0.5.1",
91
92
  "class-validator": "^0.13.2",
92
93
  "commitizen": "^4.2.4",
93
94
  "cz-customizable": "^6.3.0",
94
95
  "decimal.js": "^10.3.1",
95
- "eslint": "^8.15.0",
96
+ "eslint": "^8.16.0",
96
97
  "eslint-import-resolver-node": "^0.3.6",
97
98
  "eslint-plugin-etc": "^2.0.2",
98
99
  "eslint-plugin-import": "^2.26.0",
@@ -113,16 +114,15 @@
113
114
  "ololog": "^1.1.175",
114
115
  "precise-commits": "^1.0.2",
115
116
  "prettier": "^2.6.2",
116
- "prisma": "^3.14.0",
117
- "prisma-graphql-type-decimal": "^2.0.0",
117
+ "prisma": "^4.0.0",
118
+ "prisma-graphql-type-decimal": "^2.0.2",
118
119
  "reflect-metadata": "^0.1.13",
119
120
  "request": "^2.88.2",
120
121
  "rxjs": "^7.5.5",
121
122
  "semantic-release": "^19.0.2",
122
123
  "simplytyped": "^3.3.0",
123
124
  "temp-dir": "^2.0.0",
124
- "ts-node": "^10.7.0",
125
- "ts-node-dev": "^1.1.8",
125
+ "ts-node": "^10.8.0",
126
126
  "tslib": "^2.4.0",
127
127
  "typescript": "^4.6.4",
128
128
  "watchexec-bin": "^1.0.0"