prisma-nestjs-graphql 19.2.0 → 19.3.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.
package/README.md CHANGED
@@ -70,6 +70,12 @@ Path to `tsconfig.json` (absolute path or relative to current working directory)
70
70
  Type: `string | undefined`
71
71
  Default: `tsconfig.json` if exists, `undefined` otherwise
72
72
 
73
+ #### `prismaClientImport`
74
+
75
+ The path to use to import the Prisma Client package
76
+ Type: `string | undefined`
77
+ Default: `@prisma/client`
78
+
73
79
  #### `combineScalarFilters`
74
80
 
75
81
  Combine nested/nullable scalar filters to single
@@ -117,16 +123,19 @@ Type: `boolean`
117
123
  Default: `false`
118
124
 
119
125
  #### `emitBlocks`
126
+
120
127
  Emit only selected blocks. Be aware, that some blocks do depend on others, e.g. one can't emit `models` without emitting `enums`.
121
128
  Type: `("args" | "inputs" | "outputs" | "models" | "enums")[]`
122
129
  Default: `["args", "inputs", "outputs", "models", "enums"]`
123
130
 
124
131
  #### `omitModelsCount`
132
+
125
133
  Omit `_count` field from models.
126
134
  Type: `boolean`
127
135
  Default: `false`
128
136
 
129
137
  #### `purgeOutput`
138
+
130
139
  Delete all files in `output` folder.
131
140
  Type: `boolean`
132
141
  Default: `false`
@@ -147,7 +156,7 @@ Default: `false`
147
156
 
148
157
  #### `unsafeCompatibleWhereUniqueInput`
149
158
 
150
- This trick TypeScript and set property as non optional for all fields in `*WhereUniqueInput` classes.
159
+ Set TypeScript property type as non optional for all fields in `*WhereUniqueInput` classes.
151
160
  See [#177](https://github.com/unlight/prisma-nestjs-graphql/issues/177) for more details.
152
161
  Type: `boolean`
153
162
  Default: `false`
package/generate.cjs CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var assert = require('assert');
6
4
  var AwaitEventEmitter = require('await-event-emitter');
7
5
  var lodash = require('lodash');
@@ -15,16 +13,6 @@ var filenamify = require('filenamify');
15
13
  var flat = require('flat');
16
14
  var pluralize = require('pluralize');
17
15
 
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);
27
-
28
16
  function pascalCase(string) {
29
17
  return lodash.startCase(lodash.camelCase(string)).replaceAll(" ", "");
30
18
  }
@@ -395,7 +383,7 @@ function relativePath(from, to) {
395
383
  if (!to.startsWith("/")) {
396
384
  to = `/${to}`;
397
385
  }
398
- let result = getRelativePath__default["default"](from, to);
386
+ let result = getRelativePath(from, to);
399
387
  if (!result.startsWith(".")) {
400
388
  result = `./${result}`;
401
389
  }
@@ -480,7 +468,7 @@ function getGraphqlInputType(inputTypes, pattern) {
480
468
  if (pattern) {
481
469
  if (pattern.startsWith("matcher:") || pattern.startsWith("match:")) {
482
470
  const { 1: patternValue } = pattern.split(":", 2);
483
- const isMatch = outmatch__default["default"](patternValue, { separator: false });
471
+ const isMatch = outmatch(patternValue, { separator: false });
484
472
  result = inputTypes.find((x) => isMatch(String(x.type)));
485
473
  if (result) {
486
474
  return result;
@@ -695,9 +683,9 @@ function inputType(args) {
695
683
  if (propertySettings) {
696
684
  importDeclarations.create({ ...propertySettings });
697
685
  } else if (propertyType.includes("Decimal")) {
698
- importDeclarations.add("Decimal", "@prisma/client/runtime/library");
686
+ importDeclarations.add("Decimal", `${config.prismaClientImport}/runtime/library`);
699
687
  } else if (propertyType.some((p) => p.startsWith("Prisma."))) {
700
- importDeclarations.add("Prisma", "@prisma/client");
688
+ importDeclarations.add("Prisma", config.prismaClientImport);
701
689
  }
702
690
  let graphqlType;
703
691
  const shouldHideField = (settings == null ? void 0 : settings.shouldHideField({
@@ -742,7 +730,7 @@ function inputType(args) {
742
730
  name: "Field",
743
731
  arguments: [
744
732
  isList ? `() => [${graphqlType}]` : `() => ${graphqlType}`,
745
- JSON5__default["default"].stringify({
733
+ JSON5.stringify({
746
734
  ...settings == null ? void 0 : settings.fieldArguments(),
747
735
  nullable: !isRequired
748
736
  })
@@ -798,7 +786,7 @@ function inputType(args) {
798
786
  if (decorate.isMatchField(name) && decorate.isMatchType(inputType2.name)) {
799
787
  property.decorators.push({
800
788
  name: decorate.name,
801
- arguments: (_d = decorate.arguments) == null ? void 0 : _d.map((x) => pupa__default["default"](x, { propertyType }))
789
+ arguments: (_d = decorate.arguments) == null ? void 0 : _d.map((x) => pupa(x, { propertyType }))
802
790
  });
803
791
  importDeclarations.create(decorate);
804
792
  }
@@ -878,7 +866,7 @@ class ObjectSettings extends Array {
878
866
  resultArguments.unshift(name);
879
867
  }
880
868
  }
881
- return resultArguments.map((x) => JSON5__default["default"].stringify(x));
869
+ return resultArguments.map((x) => JSON5.stringify(x));
882
870
  }
883
871
  fieldArguments() {
884
872
  const item = this.find((item2) => item2.kind === "Field");
@@ -983,7 +971,7 @@ function createSettingElement({
983
971
  name,
984
972
  namespace: false,
985
973
  kind: "Decorator",
986
- arguments: Array.isArray(options2.arguments) ? options2.arguments.map((s) => JSON5__default["default"].stringify(s)) : options2.arguments
974
+ arguments: Array.isArray(options2.arguments) ? options2.arguments.map((s) => JSON5.stringify(s)) : options2.arguments
987
975
  });
988
976
  return result;
989
977
  }
@@ -1010,7 +998,7 @@ function customType(args) {
1010
998
  result.namespaceImport = namespace;
1011
999
  }
1012
1000
  if (typeof options.match === "string" || Array.isArray(options.match)) {
1013
- result.match = outmatch__default["default"](options.match, { separator: false });
1001
+ result.match = outmatch(options.match, { separator: false });
1014
1002
  }
1015
1003
  return result;
1016
1004
  }
@@ -1033,7 +1021,7 @@ function hideFieldDecorator(match) {
1033
1021
  result.output = Boolean(options.output);
1034
1022
  result.input = Boolean(options.input);
1035
1023
  if (typeof options.match === "string" || Array.isArray(options.match)) {
1036
- result.match = outmatch__default["default"](options.match, { separator: false });
1024
+ result.match = outmatch(options.match, { separator: false });
1037
1025
  }
1038
1026
  } else {
1039
1027
  if (/output:\s*true/.test(match.groups.args)) {
@@ -1047,10 +1035,10 @@ function hideFieldDecorator(match) {
1047
1035
  }
1048
1036
  function parseArgs(string) {
1049
1037
  try {
1050
- return JSON5__default["default"].parse(string);
1038
+ return JSON5.parse(string);
1051
1039
  } catch {
1052
1040
  try {
1053
- return JSON5__default["default"].parse(`[${string}]`);
1041
+ return JSON5.parse(`[${string}]`);
1054
1042
  } catch {
1055
1043
  throw new Error(`Failed to parse: ${string}`);
1056
1044
  }
@@ -1232,7 +1220,7 @@ function modelOutputType(outputType, args) {
1232
1220
  if (propertySettings) {
1233
1221
  importDeclarations.create({ ...propertySettings });
1234
1222
  } else if (propertyType.includes("Decimal")) {
1235
- importDeclarations.add("Decimal", "@prisma/client/runtime/library");
1223
+ importDeclarations.add("Decimal", `${config.prismaClientImport}/runtime/library`);
1236
1224
  }
1237
1225
  assert.ok(property.decorators, "property.decorators is undefined");
1238
1226
  const shouldHideField = (settings == null ? void 0 : settings.shouldHideField({ name: outputType.name, output: true })) || config.decorate.some(
@@ -1246,7 +1234,7 @@ function modelOutputType(outputType, args) {
1246
1234
  name: "Field",
1247
1235
  arguments: [
1248
1236
  isList ? `() => [${graphqlType}]` : `() => ${graphqlType}`,
1249
- JSON5__default["default"].stringify({
1237
+ JSON5.stringify({
1250
1238
  ...settings == null ? void 0 : settings.fieldArguments(),
1251
1239
  nullable: Boolean(field.isNullable),
1252
1240
  defaultValue: ["number", "string", "boolean"].includes(
@@ -1270,7 +1258,7 @@ function modelOutputType(outputType, args) {
1270
1258
  if (decorate.isMatchField(field.name) && decorate.isMatchType(outputTypeName)) {
1271
1259
  property.decorators.push({
1272
1260
  name: decorate.name,
1273
- arguments: (_f = decorate.arguments) == null ? void 0 : _f.map((x) => pupa__default["default"](x, { propertyType }))
1261
+ arguments: (_f = decorate.arguments) == null ? void 0 : _f.map((x) => pupa(x, { propertyType }))
1274
1262
  });
1275
1263
  importDeclarations.create(decorate);
1276
1264
  }
@@ -1415,7 +1403,7 @@ function outputType(outputType2, args) {
1415
1403
  if (propertySettings) {
1416
1404
  importDeclarations.create({ ...propertySettings });
1417
1405
  } else if (propertyType.includes("Decimal")) {
1418
- importDeclarations.add("Decimal", "@prisma/client/runtime/library");
1406
+ importDeclarations.add("Decimal", `${config.prismaClientImport}/runtime/library`);
1419
1407
  }
1420
1408
  let graphqlType;
1421
1409
  const shouldHideField = (settings == null ? void 0 : settings.shouldHideField({
@@ -1462,7 +1450,7 @@ function outputType(outputType2, args) {
1462
1450
  name: "Field",
1463
1451
  arguments: [
1464
1452
  isList ? `() => [${graphqlType}]` : `() => ${graphqlType}`,
1465
- JSON5__default["default"].stringify({
1453
+ JSON5.stringify({
1466
1454
  ...settings == null ? void 0 : settings.fieldArguments(),
1467
1455
  nullable: Boolean(field.isNullable)
1468
1456
  })
@@ -1695,7 +1683,7 @@ function createConfig(data) {
1695
1683
  const configOutputFilePattern = String(
1696
1684
  config.outputFilePattern || `{model}/{name}.{type}.ts`
1697
1685
  );
1698
- let outputFilePattern = filenamify__default["default"](configOutputFilePattern, {
1686
+ let outputFilePattern = filenamify(configOutputFilePattern, {
1699
1687
  replacement: "/"
1700
1688
  }).replaceAll("..", "/").replaceAll(/\/+/g, "/");
1701
1689
  outputFilePattern = lodash.trim(outputFilePattern, "/");
@@ -1738,19 +1726,20 @@ function createConfig(data) {
1738
1726
  `Missed 'from' or 'name' part in configuration for decorate`
1739
1727
  );
1740
1728
  decorate.push({
1741
- isMatchField: outmatch__default["default"](element.field, { separator: false }),
1742
- isMatchType: outmatch__default["default"](element.type, { separator: false }),
1729
+ isMatchField: outmatch(element.field, { separator: false }),
1730
+ isMatchType: outmatch(element.type, { separator: false }),
1743
1731
  from: element.from,
1744
1732
  name: element.name,
1745
1733
  namedImport: toBoolean(element.namedImport),
1746
1734
  defaultImport: toBoolean(element.defaultImport) ? true : element.defaultImport,
1747
1735
  namespaceImport: element.namespaceImport,
1748
- arguments: element.arguments ? JSON5__default["default"].parse(element.arguments) : void 0
1736
+ arguments: element.arguments ? JSON5.parse(element.arguments) : void 0
1749
1737
  });
1750
1738
  }
1751
1739
  return {
1752
1740
  outputFilePattern,
1753
1741
  tsConfigFilePath: createTsConfigFilePathValue(config.tsConfigFilePath),
1742
+ prismaClientImport: createPrismaImport(config.prismaClientImport),
1754
1743
  combineScalarFilters: toBoolean(config.combineScalarFilters),
1755
1744
  noAtomicOperations: toBoolean(config.noAtomicOperations),
1756
1745
  reExport: ReExport[String(config.reExport)] || ReExport.None,
@@ -1782,6 +1771,11 @@ function createTsConfigFilePathValue(value) {
1782
1771
  if (tsConfigFileExists("tsconfig.json"))
1783
1772
  return "tsconfig.json";
1784
1773
  }
1774
+ function createPrismaImport(value) {
1775
+ if (typeof value === "string")
1776
+ return value;
1777
+ return "@prisma/client";
1778
+ }
1785
1779
  function createUseInputType(data) {
1786
1780
  if (!data) {
1787
1781
  return [];
@@ -1809,7 +1803,7 @@ function toBoolean(value) {
1809
1803
 
1810
1804
  function generateFileName(args) {
1811
1805
  const { template, type, name, getModelName } = args;
1812
- return pupa__default["default"](template, {
1806
+ return pupa(template, {
1813
1807
  type,
1814
1808
  get model() {
1815
1809
  const result = getModelName(name) || "prisma";
@@ -1827,7 +1821,7 @@ function generateFileName(args) {
1827
1821
  },
1828
1822
  plural: {
1829
1823
  get type() {
1830
- return pluralize__default["default"](type);
1824
+ return pluralize(type);
1831
1825
  }
1832
1826
  }
1833
1827
  });
@@ -1974,7 +1968,7 @@ async function generate(args) {
1974
1968
  const generatorOutputValue = (_a = generator.output) == null ? void 0 : _a.value;
1975
1969
  assert.ok(generatorOutputValue, "Missing generator configuration: output");
1976
1970
  const config = createConfig(generator.config);
1977
- const eventEmitter = new AwaitEventEmitter__default["default"]();
1971
+ const eventEmitter = new AwaitEventEmitter();
1978
1972
  eventEmitter.on("Warning", warning);
1979
1973
  config.emitBlocks.models && eventEmitter.on("Model", modelData);
1980
1974
  if (config.emitBlocks.prismaEnums || config.emitBlocks.schemaEnums) {
package/generate.d.ts CHANGED
@@ -78,7 +78,7 @@ declare namespace DMMF {
78
78
  hasDefaultValue: boolean;
79
79
  default?: FieldDefault | FieldDefaultScalar | FieldDefaultScalar[];
80
80
  relationFromFields?: string[];
81
- relationToFields?: any[];
81
+ relationToFields?: string[];
82
82
  relationOnDelete?: string;
83
83
  relationName?: string;
84
84
  documentation?: string;
@@ -230,6 +230,7 @@ type DecorateElement = {
230
230
  declare function createConfig(data: Record<string, unknown>): {
231
231
  outputFilePattern: string;
232
232
  tsConfigFilePath: string | undefined;
233
+ prismaClientImport: string;
233
234
  combineScalarFilters: boolean;
234
235
  noAtomicOperations: boolean;
235
236
  reExport: ReExport;
package/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
 
2
- export { }
2
+ export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-nestjs-graphql",
3
- "version": "19.2.0",
3
+ "version": "19.3.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
  "bin": "bin.js",
@@ -52,8 +52,10 @@
52
52
  "eslint:fix": "npm run eslint -- --fix",
53
53
  "build": "sh Taskfile build",
54
54
  "prisma:g": "node node_modules/prisma/build/index.js generate",
55
+ "prisma:custom:g": "node node_modules/prisma/build/index.js generate --schema=./custom-package-generator/schema.prisma",
55
56
  "format": "npx prettier ./@generated --write",
56
57
  "regen": "rm -rf @generated && npm run prisma:g && npm run format",
58
+ "regen:custom": "rm -rf @generated-custom && npm run prisma:custom:g && npm run format",
57
59
  "rt": "npm run regen && npm test",
58
60
  "example": "node-dev example/main.ts",
59
61
  "clean_cache": "rm -rf node_modules/.cache",
@@ -70,7 +72,7 @@
70
72
  }
71
73
  },
72
74
  "dependencies": {
73
- "@prisma/generator-helper": "^5.3.1",
75
+ "@prisma/generator-helper": "^5.6.0",
74
76
  "await-event-emitter": "^2.0.2",
75
77
  "filenamify": "4.X",
76
78
  "flat": "5.X",
@@ -84,66 +86,66 @@
84
86
  "ts-morph": ">=11 <=16"
85
87
  },
86
88
  "devDependencies": {
87
- "@commitlint/cli": "^17.7.1",
88
- "@commitlint/config-conventional": "^17.7.0",
89
- "@nestjs/apollo": "^12.0.9",
90
- "@nestjs/common": "^10.2.6",
91
- "@nestjs/core": "^10.2.6",
92
- "@nestjs/graphql": "^12.0.9",
93
- "@nestjs/platform-express": "^10.2.6",
89
+ "@commitlint/cli": "^18.4.3",
90
+ "@commitlint/config-conventional": "^18.4.3",
91
+ "@nestjs/apollo": "^12.0.11",
92
+ "@nestjs/common": "^10.2.10",
93
+ "@nestjs/core": "^10.2.10",
94
+ "@nestjs/graphql": "^12.0.11",
95
+ "@nestjs/platform-express": "^10.2.10",
94
96
  "@paljs/plugins": "^6.0.7",
95
- "@prisma/client": "^5.3.1",
97
+ "@prisma/client": "^5.6.0",
96
98
  "@semantic-release/changelog": "^6.0.3",
97
99
  "@semantic-release/git": "^10.0.1",
98
- "@swc/core": "^1.3.87",
99
- "@swc/helpers": "^0.5.2",
100
+ "@swc/core": "^1.3.99",
101
+ "@swc/helpers": "^0.5.3",
100
102
  "@swc/register": "^0.1.10",
101
- "@types/flat": "^5.0.3",
102
- "@types/graceful-fs": "^4.1.7",
103
- "@types/lodash": "^4.14.199",
104
- "@types/mocha": "^10.0.1",
105
- "@types/node": "^20.6.3",
106
- "@types/pluralize": "^0.0.30",
107
- "@typescript-eslint/eslint-plugin": "^6.7.2",
108
- "@typescript-eslint/parser": "^6.7.2",
109
- "apollo-server-express": "^3.10.0",
103
+ "@types/flat": "^5.0.5",
104
+ "@types/graceful-fs": "^4.1.9",
105
+ "@types/lodash": "^4.14.202",
106
+ "@types/mocha": "^10.0.6",
107
+ "@types/node": "^20.10.0",
108
+ "@types/pluralize": "^0.0.33",
109
+ "@typescript-eslint/eslint-plugin": "^6.12.0",
110
+ "@typescript-eslint/parser": "^6.12.0",
111
+ "apollo-server-express": "^3.13.0",
110
112
  "c8": "^8.0.1",
111
113
  "class-transformer": "^0.5.1",
112
114
  "class-validator": "^0.14.0",
113
115
  "commitizen": "^4.3.0",
114
116
  "cz-customizable": "^7.0.0",
115
117
  "decimal.js": "^10.4.3",
116
- "eslint": "^8.50.0",
118
+ "eslint": "^8.54.0",
117
119
  "eslint-import-resolver-node": "^0.3.9",
118
120
  "eslint-plugin-etc": "^2.0.3",
119
- "eslint-plugin-import": "^2.28.1",
121
+ "eslint-plugin-import": "^2.29.0",
120
122
  "eslint-plugin-only-warn": "^1.1.0",
121
- "eslint-plugin-prettier": "^5.0.0",
123
+ "eslint-plugin-prettier": "^5.0.1",
122
124
  "eslint-plugin-regexp": "^1.15.0",
123
125
  "eslint-plugin-simple-import-sort": "^10.0.0",
124
- "eslint-plugin-sort-class-members": "^1.18.0",
125
- "eslint-plugin-unicorn": "^48.0.1",
126
+ "eslint-plugin-sort-class-members": "^1.19.0",
127
+ "eslint-plugin-unicorn": "^49.0.0",
126
128
  "eslint-plugin-wix-editor": "^3.3.0",
127
129
  "expect": "^29.7.0",
128
130
  "git-branch-is": "^4.0.0",
129
131
  "graphql": "^16.8.1",
130
- "graphql-scalars": "^1.22.2",
132
+ "graphql-scalars": "^1.22.4",
131
133
  "graphql-type-json": "^0.3.2",
132
134
  "mocha": "^10.2.0",
133
135
  "ololog": "^1.1.175",
134
136
  "precise-commits": "^1.0.2",
135
- "prettier": "^3.0.3",
136
- "prisma": "^5.3.1",
137
+ "prettier": "^3.1.0",
138
+ "prisma": "^5.6.0",
137
139
  "prisma-graphql-type-decimal": "^3.0.0",
138
140
  "reflect-metadata": "^0.1.13",
139
141
  "request": "^2.88.2",
140
142
  "rxjs": "^7.8.1",
141
- "semantic-release": "^22.0.4",
143
+ "semantic-release": "^22.0.8",
142
144
  "simplytyped": "^3.3.0",
143
145
  "temp-dir": "2.X",
144
146
  "ts-node": "^10.9.1",
145
147
  "tslib": "^2.6.2",
146
- "typescript": "^5.2.2",
148
+ "typescript": "^5.3.2",
147
149
  "watchexec-bin": "^1.0.0"
148
150
  }
149
151
  }