prisma-nestjs-graphql 17.1.0 → 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 +69 -62
  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,10 +1345,10 @@ 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
- const shouldHideField = 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));
@@ -1357,7 +1364,7 @@ function modelOutputType(outputType2, args) {
1357
1364
  arguments: [
1358
1365
  isList ? `() => [${graphqlType}]` : `() => ${graphqlType}`,
1359
1366
  import_json53.default.stringify({
1360
- ...settings1?.fieldArguments(),
1367
+ ...settings?.fieldArguments(),
1361
1368
  nullable: Boolean(field.isNullable),
1362
1369
  defaultValue: [
1363
1370
  "number",
@@ -1368,7 +1375,7 @@ function modelOutputType(outputType2, args) {
1368
1375
  })
1369
1376
  ]
1370
1377
  });
1371
- for (const setting of settings1 || []) {
1378
+ for (const setting of settings || []) {
1372
1379
  if (shouldBeDecorated(setting) && (setting.match?.(field.name) ?? true)) {
1373
1380
  property.decorators.push({
1374
1381
  name: setting.name,
@@ -1396,13 +1403,13 @@ function modelOutputType(outputType2, args) {
1396
1403
  propertyType
1397
1404
  });
1398
1405
  }
1399
- for (const setting1 of modelSettings || []) {
1400
- if (shouldBeDecorated(setting1)) {
1406
+ for (const setting of modelSettings || []) {
1407
+ if (shouldBeDecorated(setting)) {
1401
1408
  classStructure.decorators.push({
1402
- name: setting1.name,
1403
- arguments: setting1.arguments
1409
+ name: setting.name,
1410
+ arguments: setting.arguments
1404
1411
  });
1405
- importDeclarations.create(setting1);
1412
+ importDeclarations.create(setting);
1406
1413
  }
1407
1414
  }
1408
1415
  if (exportDeclaration) {
@@ -1550,7 +1557,7 @@ function outputType(outputType2, args) {
1550
1557
  ...propertySettings
1551
1558
  });
1552
1559
  } else if (propertyType.includes("Decimal")) {
1553
- importDeclarations.add("Decimal", "@prisma/client/runtime");
1560
+ importDeclarations.add("Decimal", "@prisma/client/runtime/library");
1554
1561
  }
1555
1562
  let graphqlType;
1556
1563
  const shouldHideField = settings?.shouldHideField({
@@ -1709,23 +1716,23 @@ function beforeGenerateFiles2(args) {
1709
1716
  }
1710
1717
  }
1711
1718
  if (config.reExport === ReExport.Single) {
1712
- const exportDeclarations1 = project.getSourceFiles().filter((sourceFile) => {
1719
+ const exportDeclarations = project.getSourceFiles().filter((sourceFile) => {
1713
1720
  return sourceFile.getBaseName() !== "index.ts";
1714
1721
  }).map((sourceFile) => getExportDeclaration2(rootDirectory, sourceFile));
1715
1722
  rootDirectory.createSourceFile("index.ts", {
1716
- statements: exportDeclarations1
1723
+ statements: exportDeclarations
1717
1724
  }, {
1718
1725
  overwrite: true
1719
1726
  });
1720
1727
  }
1721
1728
  if (config.reExport === ReExport.All) {
1722
- const exportDeclarations2 = [];
1723
- for (const directory1 of rootDirectory.getDirectories()) {
1724
- const sourceFile = directory1.getSourceFileOrThrow("index.ts");
1725
- 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));
1726
1733
  }
1727
1734
  rootDirectory.createSourceFile("index.ts", {
1728
- statements: exportDeclarations2
1735
+ statements: exportDeclarations
1729
1736
  }, {
1730
1737
  overwrite: true
1731
1738
  });
@@ -1956,18 +1963,18 @@ function generateFileName(args) {
1956
1963
  return (0, import_lodash9.kebabCase)(result);
1957
1964
  },
1958
1965
  get name() {
1959
- let result1 = (0, import_lodash9.kebabCase)(name);
1966
+ let result = (0, import_lodash9.kebabCase)(name);
1960
1967
  for (const suffix of [
1961
1968
  "input",
1962
1969
  "args",
1963
1970
  "enum"
1964
1971
  ]) {
1965
1972
  const ending = `-${suffix}`;
1966
- if (type === suffix && result1.endsWith(ending)) {
1967
- result1 = result1.slice(0, -ending.length);
1973
+ if (type === suffix && result.endsWith(ending)) {
1974
+ result = result.slice(0, -ending.length);
1968
1975
  }
1969
1976
  }
1970
- return result1;
1977
+ return result;
1971
1978
  },
1972
1979
  plural: {
1973
1980
  get type() {
@@ -2018,31 +2025,31 @@ function getModelName(args) {
2018
2025
  return test;
2019
2026
  }
2020
2027
  }
2021
- for (const keyword1 of endsWithKeywords) {
2022
- const [test1] = name.split(keyword1).slice(-1);
2023
- if (modelNames.includes(test1)) {
2024
- return test1;
2028
+ for (const keyword of endsWithKeywords) {
2029
+ const [test] = name.split(keyword).slice(-1);
2030
+ if (modelNames.includes(test)) {
2031
+ return test;
2025
2032
  }
2026
2033
  }
2027
2034
  for (const [start, end2] of middleKeywords) {
2028
- let test2 = name.slice(start.length).slice(0, -end2.length);
2029
- if (modelNames.includes(test2)) {
2030
- return test2;
2035
+ let test = name.slice(start.length).slice(0, -end2.length);
2036
+ if (modelNames.includes(test)) {
2037
+ return test;
2031
2038
  }
2032
- test2 = name.slice(0, -(start + end2).length);
2033
- if (modelNames.includes(test2)) {
2034
- return test2;
2039
+ test = name.slice(0, -(start + end2).length);
2040
+ if (modelNames.includes(test)) {
2041
+ return test;
2035
2042
  }
2036
2043
  }
2037
2044
  if (name.slice(-19) === "CompoundUniqueInput") {
2038
- const test3 = name.slice(0, -19);
2039
- 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);
2040
2047
  return (0, import_lodash10.first)(models);
2041
2048
  }
2042
2049
  if (name.slice(-5) === "Count") {
2043
- const test4 = name.slice(0, -5);
2044
- if (modelNames.includes(test4)) {
2045
- return test4;
2050
+ const test = name.slice(0, -5);
2051
+ if (modelNames.includes(test)) {
2052
+ return test;
2046
2053
  }
2047
2054
  }
2048
2055
  return void 0;
@@ -2244,16 +2251,16 @@ async function generate(args) {
2244
2251
  for (const model of datamodel.models) {
2245
2252
  await eventEmitter.emit("Model", model, eventArguments);
2246
2253
  }
2247
- for (const model1 of datamodel.types || []) {
2248
- await eventEmitter.emit("Model", model1, eventArguments);
2254
+ for (const model of datamodel.types || []) {
2255
+ await eventEmitter.emit("Model", model, eventArguments);
2249
2256
  }
2250
2257
  const { inputObjectTypes, outputObjectTypes, enumTypes } = schema;
2251
2258
  await eventEmitter.emit("PostBegin", eventArguments);
2252
2259
  for (const enumType of enumTypes.prisma.concat(enumTypes.model || [])) {
2253
2260
  await eventEmitter.emit("EnumType", enumType, eventArguments);
2254
2261
  }
2255
- for (const outputType1 of outputObjectTypes.model) {
2256
- await eventEmitter.emit("ModelOutputType", outputType1, eventArguments);
2262
+ for (const outputType2 of outputObjectTypes.model) {
2263
+ await eventEmitter.emit("ModelOutputType", outputType2, eventArguments);
2257
2264
  }
2258
2265
  const queryOutputTypes = [];
2259
2266
  for (const outputType2 of outputObjectTypes.prisma) {
@@ -2267,22 +2274,22 @@ async function generate(args) {
2267
2274
  await eventEmitter.emit("OutputType", outputType2, eventArguments);
2268
2275
  }
2269
2276
  const inputTypes = inputObjectTypes.prisma.concat(inputObjectTypes.model || []);
2270
- for (const inputType1 of inputTypes) {
2277
+ for (const inputType2 of inputTypes) {
2271
2278
  const event = {
2272
2279
  ...eventArguments,
2273
- inputType: inputType1,
2280
+ inputType: inputType2,
2274
2281
  fileType: "input",
2275
2282
  classDecoratorName: "InputType"
2276
2283
  };
2277
- if (inputType1.fields.length === 0) {
2278
- removeTypes.add(inputType1.name);
2284
+ if (inputType2.fields.length === 0) {
2285
+ removeTypes.add(inputType2.name);
2279
2286
  continue;
2280
2287
  }
2281
2288
  await eventEmitter.emit("BeforeInputType", event);
2282
2289
  await eventEmitter.emit("InputType", event);
2283
2290
  }
2284
- for (const outputType3 of queryOutputTypes) {
2285
- for (const field of outputType3.fields) {
2291
+ for (const outputType2 of queryOutputTypes) {
2292
+ for (const field of outputType2.fields) {
2286
2293
  await eventEmitter.emit("ArgsType", field, eventArguments);
2287
2294
  }
2288
2295
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-nestjs-graphql",
3
- "version": "17.1.0",
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
  }