prisma-nestjs-graphql 15.3.1 → 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.
- package/LICENSE +1 -1
- package/README.md +4 -4
- package/index.js +59 -9
- package/package.json +29 -29
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -338,16 +338,16 @@ It will affect all inputs and outputs types (including models).
|
|
|
338
338
|
|
|
339
339
|
## Documentation and field options
|
|
340
340
|
|
|
341
|
-
Comments with
|
|
341
|
+
Comments with triple slash will projected to typescript code comments
|
|
342
342
|
and some `@Field()` decorator options
|
|
343
343
|
|
|
344
344
|
For example:
|
|
345
345
|
|
|
346
346
|
```prisma
|
|
347
347
|
model Product {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
oldName
|
|
348
|
+
/// Old description
|
|
349
|
+
/// @deprecated Use new name instead
|
|
350
|
+
oldName String
|
|
351
351
|
}
|
|
352
352
|
```
|
|
353
353
|
|
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
|
|
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
|
|
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 ((
|
|
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: (
|
|
811
|
+
arguments: (_c = decorate.arguments) == null ? void 0 : _c.map((x) => (0, import_pupa.default)(x, {
|
|
774
812
|
propertyType
|
|
775
813
|
}))
|
|
776
814
|
});
|
|
@@ -1328,10 +1366,13 @@ function noAtomicOperations(eventEmitter) {
|
|
|
1328
1366
|
}
|
|
1329
1367
|
__name(noAtomicOperations, "noAtomicOperations");
|
|
1330
1368
|
function beforeInputType2(args) {
|
|
1331
|
-
const { inputType: inputType1 } = args;
|
|
1369
|
+
const { inputType: inputType1, getModelName: getModelName2 } = args;
|
|
1332
1370
|
for (const field of inputType1.fields) {
|
|
1371
|
+
const fieldName = field.name;
|
|
1333
1372
|
field.inputTypes = field.inputTypes.filter((inputType2) => {
|
|
1334
|
-
|
|
1373
|
+
const inputTypeName = String(inputType2.type);
|
|
1374
|
+
const modelName = getModelName2(inputTypeName);
|
|
1375
|
+
if (isAtomicOperation(inputTypeName) || modelName && isListInput(inputTypeName, modelName, fieldName)) {
|
|
1335
1376
|
return false;
|
|
1336
1377
|
}
|
|
1337
1378
|
return true;
|
|
@@ -1350,10 +1391,17 @@ function beforeGenerateFiles(args) {
|
|
|
1350
1391
|
}
|
|
1351
1392
|
}
|
|
1352
1393
|
__name(beforeGenerateFiles, "beforeGenerateFiles");
|
|
1353
|
-
function isAtomicOperation(
|
|
1354
|
-
|
|
1394
|
+
function isAtomicOperation(typeName) {
|
|
1395
|
+
if (typeName.endsWith("FieldUpdateOperationsInput")) {
|
|
1396
|
+
return true;
|
|
1397
|
+
}
|
|
1398
|
+
return false;
|
|
1355
1399
|
}
|
|
1356
1400
|
__name(isAtomicOperation, "isAtomicOperation");
|
|
1401
|
+
function isListInput(typeName, model, field) {
|
|
1402
|
+
return typeName === `${model}Create${field}Input` || typeName === `${model}Update${field}Input`;
|
|
1403
|
+
}
|
|
1404
|
+
__name(isListInput, "isListInput");
|
|
1357
1405
|
|
|
1358
1406
|
// src/handlers/output-type.ts
|
|
1359
1407
|
var import_assert4 = require("assert");
|
|
@@ -1962,7 +2010,9 @@ var splitKeywords = [
|
|
|
1962
2010
|
"SumOrderBy",
|
|
1963
2011
|
"MinOrderBy",
|
|
1964
2012
|
"MaxOrderBy",
|
|
1965
|
-
"AvgOrderBy"
|
|
2013
|
+
"AvgOrderBy",
|
|
2014
|
+
"Create",
|
|
2015
|
+
"Update"
|
|
1966
2016
|
].sort((a, b) => b.length - a.length);
|
|
1967
2017
|
var endsWithKeywords = [
|
|
1968
2018
|
"Aggregate",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-nestjs-graphql",
|
|
3
|
-
"version": "
|
|
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
|
|
28
|
-
"test:w": "npm run test:r -- --watch-files src --watch
|
|
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
|
-
"
|
|
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,8 +52,7 @@
|
|
|
51
52
|
}
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|
|
54
|
-
"@
|
|
55
|
-
"@prisma/generator-helper": "^3.13.0",
|
|
55
|
+
"@prisma/generator-helper": "^3.14.0",
|
|
56
56
|
"await-event-emitter": "^2.0.2",
|
|
57
57
|
"filenamify": "4.X",
|
|
58
58
|
"flat": "^5.0.2",
|
|
@@ -65,34 +65,35 @@
|
|
|
65
65
|
"ts-morph": ">=11"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@commitlint/cli": "^
|
|
69
|
-
"@commitlint/config-conventional": "^
|
|
70
|
-
"@nestjs/
|
|
71
|
-
"@nestjs/
|
|
72
|
-
"@nestjs/
|
|
73
|
-
"@nestjs/
|
|
74
|
-
"@
|
|
75
|
-
"@
|
|
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",
|
|
75
|
+
"@paljs/plugins": "^4.1.0",
|
|
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.
|
|
79
|
-
"@swc/helpers": "^0.3.
|
|
79
|
+
"@swc/core": "^1.2.189",
|
|
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.
|
|
85
|
+
"@types/node": "^17.0.35",
|
|
85
86
|
"@types/pluralize": "^0.0.29",
|
|
86
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
87
|
-
"@typescript-eslint/parser": "^5.
|
|
88
|
-
"apollo-server-express": "^3.
|
|
89
|
-
"c8": "^7.11.
|
|
87
|
+
"@typescript-eslint/eslint-plugin": "^5.25.0",
|
|
88
|
+
"@typescript-eslint/parser": "^5.25.0",
|
|
89
|
+
"apollo-server-express": "^3.7.0",
|
|
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.
|
|
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",
|
|
@@ -103,26 +104,25 @@
|
|
|
103
104
|
"eslint-plugin-sort-class-members": "^1.14.1",
|
|
104
105
|
"eslint-plugin-unicorn": "^42.0.0",
|
|
105
106
|
"eslint-plugin-wix-editor": "^3.3.0",
|
|
106
|
-
"expect": "^28.0
|
|
107
|
+
"expect": "^28.1.0",
|
|
107
108
|
"ghooks": "^2.0.4",
|
|
108
109
|
"git-branch-is": "^4.0.0",
|
|
109
|
-
"graphql": "^16.
|
|
110
|
+
"graphql": "^16.5.0",
|
|
110
111
|
"graphql-scalars": "^1.17.0",
|
|
111
112
|
"graphql-type-json": "^0.3.2",
|
|
112
113
|
"mocha": "^10.0.0",
|
|
113
114
|
"ololog": "^1.1.175",
|
|
114
115
|
"precise-commits": "^1.0.2",
|
|
115
116
|
"prettier": "^2.6.2",
|
|
116
|
-
"prisma": "^3.
|
|
117
|
-
"prisma-graphql-type-decimal": "^2.0.
|
|
117
|
+
"prisma": "^3.14.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.
|
|
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"
|