prisma-nestjs-graphql 15.3.3 → 16.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 +42 -4
  2. package/package.json +21 -21
package/index.js CHANGED
@@ -623,7 +623,7 @@ __name(propertyStructure, "propertyStructure");
623
623
 
624
624
  // src/handlers/input-type.ts
625
625
  function inputType(args) {
626
- var _a, _b, _c, _d;
626
+ var _a, _b, _c;
627
627
  const { inputType: inputType1, fileType, getSourceFile, config, eventEmitter, classDecoratorName, fieldSettings, getModelName: getModelName2, models, removeTypes, typeNames } = args;
628
628
  typeNames.add(inputType1.name);
629
629
  const importDeclarations = new ImportDeclarationMap();
@@ -679,7 +679,8 @@ function inputType(args) {
679
679
  name: inputType1.name,
680
680
  input: true
681
681
  });
682
- const isCustomsApplicable = typeName === ((_a = model == null ? void 0 : model.fields.find((f) => f.name === name)) == null ? void 0 : _a.type);
682
+ const modelField = model == null ? void 0 : model.fields.find((f) => f.name === name);
683
+ const isCustomsApplicable = typeName === (modelField == null ? void 0 : modelField.type);
683
684
  const propertyType = (0, import_lodash3.castArray)((propertySettings == null ? void 0 : propertySettings.name) || getPropertyType({
684
685
  location,
685
686
  type: typeName
@@ -754,9 +755,46 @@ function inputType(args) {
754
755
  })
755
756
  ]
756
757
  });
758
+ if (graphqlType === "GraphQLDecimal") {
759
+ importDeclarations.add("transformToDecimal", "prisma-graphql-type-decimal");
760
+ importDeclarations.add("Transform", "class-transformer");
761
+ importDeclarations.add("Type", "class-transformer");
762
+ property.decorators.push({
763
+ name: "Type",
764
+ arguments: [
765
+ "() => Object"
766
+ ]
767
+ }, {
768
+ name: "Transform",
769
+ arguments: [
770
+ "transformToDecimal"
771
+ ]
772
+ });
773
+ } else if (location === "inputObjectTypes" && ((modelField == null ? void 0 : modelField.type) === "Decimal" || [
774
+ "data",
775
+ "where",
776
+ "create",
777
+ "connectOrCreate",
778
+ "upsert",
779
+ "set",
780
+ "disconnect",
781
+ "delete",
782
+ "connect",
783
+ "update",
784
+ "updateMany",
785
+ "deleteMany"
786
+ ].includes(name))) {
787
+ importDeclarations.add("Type", "class-transformer");
788
+ property.decorators.push({
789
+ name: "Type",
790
+ arguments: [
791
+ `() => ${graphqlType}`
792
+ ]
793
+ });
794
+ }
757
795
  if (isCustomsApplicable) {
758
796
  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) {
797
+ if ((_b = options.kind === "Decorator" && options.input && ((_a = options.match) == null ? void 0 : _a.call(options, name))) != null ? _b : true) {
760
798
  property.decorators.push({
761
799
  name: options.name,
762
800
  arguments: options.arguments
@@ -770,7 +808,7 @@ function inputType(args) {
770
808
  if (decorate.isMatchField(name) && decorate.isMatchType(inputType1.name)) {
771
809
  property.decorators.push({
772
810
  name: decorate.name,
773
- arguments: (_d = decorate.arguments) == null ? void 0 : _d.map((x) => (0, import_pupa.default)(x, {
811
+ arguments: (_c = decorate.arguments) == null ? void 0 : _c.map((x) => (0, import_pupa.default)(x, {
774
812
  propertyType
775
813
  }))
776
814
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-nestjs-graphql",
3
- "version": "15.3.3",
3
+ "version": "16.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"
@@ -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
76
  "@prisma/client": "^3.14.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",
@@ -114,15 +115,14 @@
114
115
  "precise-commits": "^1.0.2",
115
116
  "prettier": "^2.6.2",
116
117
  "prisma": "^3.14.0",
117
- "prisma-graphql-type-decimal": "^2.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"