prisma-nestjs-graphql 17.0.3 → 18.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 (2) hide show
  1. package/index.js +71 -63
  2. package/package.json +33 -33
package/index.js CHANGED
@@ -15,6 +15,10 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
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.
18
22
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
19
23
  mod
20
24
  ));
@@ -57,6 +61,7 @@ function argsType(field, args) {
57
61
  }
58
62
  }
59
63
  const inputType2 = {
64
+ // eslint-disable-next-line unicorn/no-null
60
65
  constraints: {
61
66
  maxNumFields: null,
62
67
  minNumFields: null
@@ -220,6 +225,7 @@ function createAggregateInput(args) {
220
225
  const { eventEmitter, outputType: outputType2 } = args;
221
226
  const className = `${outputType2.name}Input`;
222
227
  const inputType2 = {
228
+ // eslint-disable-next-line unicorn/no-null
223
229
  constraints: {
224
230
  maxNumFields: null,
225
231
  minNumFields: null
@@ -606,6 +612,7 @@ function getGraphqlInputType(inputTypes, pattern) {
606
612
  }
607
613
  }
608
614
  throw new TypeError(
615
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
609
616
  `Cannot get matching input type from ${inputTypes.map((x) => x.type).join(", ") || "zero length inputTypes"}`
610
617
  );
611
618
  }
@@ -780,7 +787,7 @@ function inputType(args) {
780
787
  ...propertySettings
781
788
  });
782
789
  } else if (propertyType.includes("Decimal")) {
783
- importDeclarations.add("Decimal", "@prisma/client/runtime");
790
+ importDeclarations.add("Decimal", "@prisma/client/runtime/library");
784
791
  }
785
792
  let graphqlType;
786
793
  const shouldHideField = settings?.shouldHideField({
@@ -1046,24 +1053,24 @@ function createSettingElement({ line, config, fieldElement, match }) {
1046
1053
  "FieldType",
1047
1054
  "PropertyType"
1048
1055
  ].includes(name) && match.groups?.args) {
1049
- const options = customType(match.groups.args);
1050
- (0, import_lodash5.merge)(element, options.namespace && config.fields[options.namespace], options, {
1056
+ const options2 = customType(match.groups.args);
1057
+ (0, import_lodash5.merge)(element, options2.namespace && config.fields[options2.namespace], options2, {
1051
1058
  kind: name
1052
1059
  });
1053
1060
  return result;
1054
1061
  }
1055
1062
  if (name === "ObjectType" && match.groups?.args) {
1056
1063
  element.kind = "ObjectType";
1057
- const options1 = customType(match.groups.args);
1058
- if (typeof options1[0] === "string" && options1[0]) {
1059
- options1.name = options1[0];
1064
+ const options2 = customType(match.groups.args);
1065
+ if (typeof options2[0] === "string" && options2[0]) {
1066
+ options2.name = options2[0];
1060
1067
  }
1061
- if ((0, import_lodash5.isObject)(options1[1])) {
1062
- (0, import_lodash5.merge)(options1, options1[1]);
1068
+ if ((0, import_lodash5.isObject)(options2[1])) {
1069
+ (0, import_lodash5.merge)(options2, options2[1]);
1063
1070
  }
1064
1071
  element.arguments = {
1065
- name: options1.name,
1066
- isAbstract: options1.isAbstract
1072
+ name: options2.name,
1073
+ isAbstract: options2.isAbstract
1067
1074
  };
1068
1075
  return result;
1069
1076
  }
@@ -1082,11 +1089,11 @@ function createSettingElement({ line, config, fieldElement, match }) {
1082
1089
  }
1083
1090
  const namespace = getNamespace(name);
1084
1091
  element.namespaceImport = namespace;
1085
- const options3 = {
1092
+ const options = {
1086
1093
  name,
1087
1094
  arguments: (match.groups?.args || "").split(",").map((s) => (0, import_lodash5.trim)(s)).filter(Boolean)
1088
1095
  };
1089
- (0, import_lodash5.merge)(element, namespace && config.fields[namespace], options3);
1096
+ (0, import_lodash5.merge)(element, namespace && config.fields[namespace], options);
1090
1097
  return result;
1091
1098
  }
1092
1099
  __name(createSettingElement, "createSettingElement");
@@ -1282,12 +1289,12 @@ function modelOutputType(outputType2, args) {
1282
1289
  outputTypeName = getOutputTypeName(outputTypeName);
1283
1290
  }
1284
1291
  const modelField = modelFields.get(model.name)?.get(field.name);
1285
- const settings1 = fieldSettings.get(model.name)?.get(field.name);
1286
- const fieldType = settings1?.getFieldType({
1292
+ const settings = fieldSettings.get(model.name)?.get(field.name);
1293
+ const fieldType = settings?.getFieldType({
1287
1294
  name: outputType2.name,
1288
1295
  output: true
1289
1296
  });
1290
- const propertySettings = settings1?.getPropertyType({
1297
+ const propertySettings = settings?.getPropertyType({
1291
1298
  name: outputType2.name,
1292
1299
  output: true
1293
1300
  });
@@ -1330,7 +1337,7 @@ function modelOutputType(outputType2, args) {
1330
1337
  isList
1331
1338
  });
1332
1339
  if (typeof property.leadingTrivia === "string" && modelField?.documentation) {
1333
- property.leadingTrivia += createComment(modelField.documentation, settings1);
1340
+ property.leadingTrivia += createComment(modelField.documentation, settings);
1334
1341
  }
1335
1342
  classStructure.properties?.push(property);
1336
1343
  if (propertySettings) {
@@ -1338,13 +1345,14 @@ function modelOutputType(outputType2, args) {
1338
1345
  ...propertySettings
1339
1346
  });
1340
1347
  } else if (propertyType.includes("Decimal")) {
1341
- importDeclarations.add("Decimal", "@prisma/client/runtime");
1348
+ importDeclarations.add("Decimal", "@prisma/client/runtime/library");
1342
1349
  }
1343
1350
  (0, import_assert3.ok)(property.decorators, "property.decorators is undefined");
1344
- if (settings1?.shouldHideField({
1351
+ const shouldHideField = settings?.shouldHideField({
1345
1352
  name: outputType2.name,
1346
1353
  output: true
1347
- })) {
1354
+ }) || config.decorate.some((d) => d.name === "HideField" && d.from === "@nestjs/graphql" && d.isMatchField(field.name) && d.isMatchType(outputTypeName));
1355
+ if (shouldHideField) {
1348
1356
  importDeclarations.add("HideField", nestjsGraphql);
1349
1357
  property.decorators.push({
1350
1358
  name: "HideField",
@@ -1356,7 +1364,7 @@ function modelOutputType(outputType2, args) {
1356
1364
  arguments: [
1357
1365
  isList ? `() => [${graphqlType}]` : `() => ${graphqlType}`,
1358
1366
  import_json53.default.stringify({
1359
- ...settings1?.fieldArguments(),
1367
+ ...settings?.fieldArguments(),
1360
1368
  nullable: Boolean(field.isNullable),
1361
1369
  defaultValue: [
1362
1370
  "number",
@@ -1367,7 +1375,7 @@ function modelOutputType(outputType2, args) {
1367
1375
  })
1368
1376
  ]
1369
1377
  });
1370
- for (const setting of settings1 || []) {
1378
+ for (const setting of settings || []) {
1371
1379
  if (shouldBeDecorated(setting) && (setting.match?.(field.name) ?? true)) {
1372
1380
  property.decorators.push({
1373
1381
  name: setting.name,
@@ -1395,13 +1403,13 @@ function modelOutputType(outputType2, args) {
1395
1403
  propertyType
1396
1404
  });
1397
1405
  }
1398
- for (const setting1 of modelSettings || []) {
1399
- if (shouldBeDecorated(setting1)) {
1406
+ for (const setting of modelSettings || []) {
1407
+ if (shouldBeDecorated(setting)) {
1400
1408
  classStructure.decorators.push({
1401
- name: setting1.name,
1402
- arguments: setting1.arguments
1409
+ name: setting.name,
1410
+ arguments: setting.arguments
1403
1411
  });
1404
- importDeclarations.create(setting1);
1412
+ importDeclarations.create(setting);
1405
1413
  }
1406
1414
  }
1407
1415
  if (exportDeclaration) {
@@ -1549,7 +1557,7 @@ function outputType(outputType2, args) {
1549
1557
  ...propertySettings
1550
1558
  });
1551
1559
  } else if (propertyType.includes("Decimal")) {
1552
- importDeclarations.add("Decimal", "@prisma/client/runtime");
1560
+ importDeclarations.add("Decimal", "@prisma/client/runtime/library");
1553
1561
  }
1554
1562
  let graphqlType;
1555
1563
  const shouldHideField = settings?.shouldHideField({
@@ -1708,23 +1716,23 @@ function beforeGenerateFiles2(args) {
1708
1716
  }
1709
1717
  }
1710
1718
  if (config.reExport === ReExport.Single) {
1711
- const exportDeclarations1 = project.getSourceFiles().filter((sourceFile) => {
1719
+ const exportDeclarations = project.getSourceFiles().filter((sourceFile) => {
1712
1720
  return sourceFile.getBaseName() !== "index.ts";
1713
1721
  }).map((sourceFile) => getExportDeclaration2(rootDirectory, sourceFile));
1714
1722
  rootDirectory.createSourceFile("index.ts", {
1715
- statements: exportDeclarations1
1723
+ statements: exportDeclarations
1716
1724
  }, {
1717
1725
  overwrite: true
1718
1726
  });
1719
1727
  }
1720
1728
  if (config.reExport === ReExport.All) {
1721
- const exportDeclarations2 = [];
1722
- for (const directory1 of rootDirectory.getDirectories()) {
1723
- const sourceFile = directory1.getSourceFileOrThrow("index.ts");
1724
- exportDeclarations2.push(getExportDeclaration2(rootDirectory, sourceFile));
1729
+ const exportDeclarations = [];
1730
+ for (const directory of rootDirectory.getDirectories()) {
1731
+ const sourceFile = directory.getSourceFileOrThrow("index.ts");
1732
+ exportDeclarations.push(getExportDeclaration2(rootDirectory, sourceFile));
1725
1733
  }
1726
1734
  rootDirectory.createSourceFile("index.ts", {
1727
- statements: exportDeclarations2
1735
+ statements: exportDeclarations
1728
1736
  }, {
1729
1737
  overwrite: true
1730
1738
  });
@@ -1955,18 +1963,18 @@ function generateFileName(args) {
1955
1963
  return (0, import_lodash9.kebabCase)(result);
1956
1964
  },
1957
1965
  get name() {
1958
- let result1 = (0, import_lodash9.kebabCase)(name);
1966
+ let result = (0, import_lodash9.kebabCase)(name);
1959
1967
  for (const suffix of [
1960
1968
  "input",
1961
1969
  "args",
1962
1970
  "enum"
1963
1971
  ]) {
1964
1972
  const ending = `-${suffix}`;
1965
- if (type === suffix && result1.endsWith(ending)) {
1966
- result1 = result1.slice(0, -ending.length);
1973
+ if (type === suffix && result.endsWith(ending)) {
1974
+ result = result.slice(0, -ending.length);
1967
1975
  }
1968
1976
  }
1969
- return result1;
1977
+ return result;
1970
1978
  },
1971
1979
  plural: {
1972
1980
  get type() {
@@ -2017,31 +2025,31 @@ function getModelName(args) {
2017
2025
  return test;
2018
2026
  }
2019
2027
  }
2020
- for (const keyword1 of endsWithKeywords) {
2021
- const [test1] = name.split(keyword1).slice(-1);
2022
- if (modelNames.includes(test1)) {
2023
- return test1;
2028
+ for (const keyword of endsWithKeywords) {
2029
+ const [test] = name.split(keyword).slice(-1);
2030
+ if (modelNames.includes(test)) {
2031
+ return test;
2024
2032
  }
2025
2033
  }
2026
2034
  for (const [start, end2] of middleKeywords) {
2027
- let test2 = name.slice(start.length).slice(0, -end2.length);
2028
- if (modelNames.includes(test2)) {
2029
- return test2;
2035
+ let test = name.slice(start.length).slice(0, -end2.length);
2036
+ if (modelNames.includes(test)) {
2037
+ return test;
2030
2038
  }
2031
- test2 = name.slice(0, -(start + end2).length);
2032
- if (modelNames.includes(test2)) {
2033
- return test2;
2039
+ test = name.slice(0, -(start + end2).length);
2040
+ if (modelNames.includes(test)) {
2041
+ return test;
2034
2042
  }
2035
2043
  }
2036
2044
  if (name.slice(-19) === "CompoundUniqueInput") {
2037
- const test3 = name.slice(0, -19);
2038
- const models = modelNames.filter((x) => test3.startsWith(x)).sort((a, b) => b.length - a.length);
2045
+ const test = name.slice(0, -19);
2046
+ const models = modelNames.filter((x) => test.startsWith(x)).sort((a, b) => b.length - a.length);
2039
2047
  return (0, import_lodash10.first)(models);
2040
2048
  }
2041
2049
  if (name.slice(-5) === "Count") {
2042
- const test4 = name.slice(0, -5);
2043
- if (modelNames.includes(test4)) {
2044
- return test4;
2050
+ const test = name.slice(0, -5);
2051
+ if (modelNames.includes(test)) {
2052
+ return test;
2045
2053
  }
2046
2054
  }
2047
2055
  return void 0;
@@ -2243,16 +2251,16 @@ async function generate(args) {
2243
2251
  for (const model of datamodel.models) {
2244
2252
  await eventEmitter.emit("Model", model, eventArguments);
2245
2253
  }
2246
- for (const model1 of datamodel.types || []) {
2247
- await eventEmitter.emit("Model", model1, eventArguments);
2254
+ for (const model of datamodel.types || []) {
2255
+ await eventEmitter.emit("Model", model, eventArguments);
2248
2256
  }
2249
2257
  const { inputObjectTypes, outputObjectTypes, enumTypes } = schema;
2250
2258
  await eventEmitter.emit("PostBegin", eventArguments);
2251
2259
  for (const enumType of enumTypes.prisma.concat(enumTypes.model || [])) {
2252
2260
  await eventEmitter.emit("EnumType", enumType, eventArguments);
2253
2261
  }
2254
- for (const outputType1 of outputObjectTypes.model) {
2255
- await eventEmitter.emit("ModelOutputType", outputType1, eventArguments);
2262
+ for (const outputType2 of outputObjectTypes.model) {
2263
+ await eventEmitter.emit("ModelOutputType", outputType2, eventArguments);
2256
2264
  }
2257
2265
  const queryOutputTypes = [];
2258
2266
  for (const outputType2 of outputObjectTypes.prisma) {
@@ -2266,22 +2274,22 @@ async function generate(args) {
2266
2274
  await eventEmitter.emit("OutputType", outputType2, eventArguments);
2267
2275
  }
2268
2276
  const inputTypes = inputObjectTypes.prisma.concat(inputObjectTypes.model || []);
2269
- for (const inputType1 of inputTypes) {
2277
+ for (const inputType2 of inputTypes) {
2270
2278
  const event = {
2271
2279
  ...eventArguments,
2272
- inputType: inputType1,
2280
+ inputType: inputType2,
2273
2281
  fileType: "input",
2274
2282
  classDecoratorName: "InputType"
2275
2283
  };
2276
- if (inputType1.fields.length === 0) {
2277
- removeTypes.add(inputType1.name);
2284
+ if (inputType2.fields.length === 0) {
2285
+ removeTypes.add(inputType2.name);
2278
2286
  continue;
2279
2287
  }
2280
2288
  await eventEmitter.emit("BeforeInputType", event);
2281
2289
  await eventEmitter.emit("InputType", event);
2282
2290
  }
2283
- for (const outputType3 of queryOutputTypes) {
2284
- for (const field of outputType3.fields) {
2291
+ for (const outputType2 of queryOutputTypes) {
2292
+ for (const field of outputType2.fields) {
2285
2293
  await eventEmitter.emit("ArgsType", field, eventArguments);
2286
2294
  }
2287
2295
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-nestjs-graphql",
3
- "version": "17.0.3",
3
+ "version": "18.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",
@@ -52,12 +52,12 @@
52
52
  }
53
53
  },
54
54
  "dependencies": {
55
- "@prisma/generator-helper": "^4.7.1",
55
+ "@prisma/generator-helper": "^4.12.0",
56
56
  "await-event-emitter": "^2.0.2",
57
57
  "filenamify": "4.X",
58
58
  "flat": "^5.0.2",
59
59
  "get-relative-path": "^1.0.2",
60
- "json5": "^2.2.1",
60
+ "json5": "^2.2.3",
61
61
  "lodash": "^4.17.21",
62
62
  "outmatch": "^0.7.0",
63
63
  "pluralize": "^8.0.0",
@@ -65,66 +65,66 @@
65
65
  "ts-morph": ">=11 <=16"
66
66
  },
67
67
  "devDependencies": {
68
- "@commitlint/cli": "^17.3.0",
69
- "@commitlint/config-conventional": "^17.3.0",
68
+ "@commitlint/cli": "^17.5.1",
69
+ "@commitlint/config-conventional": "^17.4.4",
70
70
  "@nestjs/apollo": "^10.1.7",
71
- "@nestjs/common": "^9.2.1",
72
- "@nestjs/core": "^9.2.1",
71
+ "@nestjs/common": "^9.3.12",
72
+ "@nestjs/core": "^9.3.12",
73
73
  "@nestjs/graphql": "^10.1.7",
74
- "@nestjs/platform-express": "^9.2.1",
75
- "@paljs/plugins": "^5.1.0",
76
- "@prisma/client": "^4.7.1",
77
- "@semantic-release/changelog": "^6.0.2",
74
+ "@nestjs/platform-express": "^9.3.12",
75
+ "@paljs/plugins": "^5.3.0",
76
+ "@prisma/client": "^4.12.0",
77
+ "@semantic-release/changelog": "^6.0.3",
78
78
  "@semantic-release/git": "^10.0.1",
79
- "@swc/core": "^1.3.23",
79
+ "@swc/core": "^1.3.44",
80
80
  "@swc/helpers": "^0.4.14",
81
81
  "@swc/register": "^0.1.10",
82
82
  "@types/flat": "^5.0.2",
83
- "@types/lodash": "^4.14.191",
83
+ "@types/lodash": "^4.14.192",
84
84
  "@types/mocha": "^10.0.1",
85
- "@types/node": "^18.11.15",
85
+ "@types/node": "^18.15.11",
86
86
  "@types/pluralize": "^0.0.29",
87
- "@typescript-eslint/eslint-plugin": "^5.46.1",
88
- "@typescript-eslint/parser": "^5.46.1",
87
+ "@typescript-eslint/eslint-plugin": "^5.57.0",
88
+ "@typescript-eslint/parser": "^5.57.0",
89
89
  "apollo-server-express": "^3.10.0",
90
- "c8": "^7.12.0",
90
+ "c8": "^7.13.0",
91
91
  "class-transformer": "^0.5.1",
92
92
  "class-validator": "^0.14.0",
93
- "commitizen": "^4.2.6",
93
+ "commitizen": "^4.3.0",
94
94
  "cz-customizable": "^7.0.0",
95
95
  "decimal.js": "^10.4.3",
96
- "eslint": "^8.29.0",
97
- "eslint-import-resolver-node": "^0.3.6",
96
+ "eslint": "^8.37.0",
97
+ "eslint-import-resolver-node": "^0.3.7",
98
98
  "eslint-plugin-etc": "^2.0.2",
99
- "eslint-plugin-import": "^2.26.0",
99
+ "eslint-plugin-import": "^2.27.5",
100
100
  "eslint-plugin-only-warn": "^1.1.0",
101
101
  "eslint-plugin-prettier": "^4.2.1",
102
- "eslint-plugin-regexp": "^1.11.0",
103
- "eslint-plugin-simple-import-sort": "^8.0.0",
102
+ "eslint-plugin-regexp": "^1.14.0",
103
+ "eslint-plugin-simple-import-sort": "^10.0.0",
104
104
  "eslint-plugin-sort-class-members": "^1.16.0",
105
- "eslint-plugin-unicorn": "^45.0.2",
105
+ "eslint-plugin-unicorn": "^46.0.0",
106
106
  "eslint-plugin-wix-editor": "^3.3.0",
107
- "expect": "^29.3.1",
107
+ "expect": "^29.5.0",
108
108
  "ghooks": "^2.0.4",
109
109
  "git-branch-is": "^4.0.0",
110
110
  "graphql": "^16.6.0",
111
- "graphql-scalars": "^1.20.1",
111
+ "graphql-scalars": "^1.21.3",
112
112
  "graphql-type-json": "^0.3.2",
113
113
  "mocha": "^10.2.0",
114
114
  "ololog": "^1.1.175",
115
115
  "precise-commits": "^1.0.2",
116
- "prettier": "^2.8.1",
117
- "prisma": "^4.7.1",
118
- "prisma-graphql-type-decimal": "^2.0.4",
116
+ "prettier": "^2.8.7",
117
+ "prisma": "^4.12.0",
118
+ "prisma-graphql-type-decimal": "^3.0.0",
119
119
  "reflect-metadata": "^0.1.13",
120
120
  "request": "^2.88.2",
121
- "rxjs": "^7.6.0",
122
- "semantic-release": "^19.0.5",
121
+ "rxjs": "^7.8.0",
122
+ "semantic-release": "^21.0.1",
123
123
  "simplytyped": "^3.3.0",
124
124
  "temp-dir": "2.X",
125
125
  "ts-node": "^10.9.1",
126
- "tslib": "^2.4.1",
127
- "typescript": "^4.9.4",
126
+ "tslib": "^2.5.0",
127
+ "typescript": "^5.0.3",
128
128
  "watchexec-bin": "^1.0.0"
129
129
  }
130
130
  }