prisma-nestjs-graphql 17.0.2 → 17.1.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/index.js +146 -61
- package/package.json +31 -31
package/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var import_generator_helper = require("@prisma/generator-helper");
|
|
|
25
25
|
// src/generate.ts
|
|
26
26
|
var import_assert6 = require("assert");
|
|
27
27
|
var import_await_event_emitter = __toESM(require("await-event-emitter"));
|
|
28
|
-
var
|
|
28
|
+
var import_lodash11 = require("lodash");
|
|
29
29
|
var import_ts_morph9 = require("ts-morph");
|
|
30
30
|
|
|
31
31
|
// src/helpers/pascal-case.ts
|
|
@@ -47,12 +47,14 @@ function argsType(field, args) {
|
|
|
47
47
|
let className = pascalCase(`${field.name}Args`);
|
|
48
48
|
const modelName = getModelName2(className) || "";
|
|
49
49
|
switch (className) {
|
|
50
|
-
case `Aggregate${modelName}Args`:
|
|
50
|
+
case `Aggregate${modelName}Args`: {
|
|
51
51
|
className = `${modelName}AggregateArgs`;
|
|
52
52
|
break;
|
|
53
|
-
|
|
53
|
+
}
|
|
54
|
+
case `GroupBy${modelName}Args`: {
|
|
54
55
|
className = `${modelName}GroupByArgs`;
|
|
55
56
|
break;
|
|
57
|
+
}
|
|
56
58
|
}
|
|
57
59
|
const inputType2 = {
|
|
58
60
|
constraints: {
|
|
@@ -109,15 +111,18 @@ function argsType(field, args) {
|
|
|
109
111
|
__name(argsType, "argsType");
|
|
110
112
|
|
|
111
113
|
// src/handlers/combine-scalar-filters.ts
|
|
114
|
+
var import_lodash2 = require("lodash");
|
|
112
115
|
function combineScalarFilters(eventEmitter) {
|
|
113
116
|
eventEmitter.on("BeforeInputType", beforeInputType);
|
|
114
117
|
eventEmitter.on("BeforeGenerateField", beforeGenerateField);
|
|
118
|
+
eventEmitter.on("PostBegin", postBegin);
|
|
115
119
|
}
|
|
116
120
|
__name(combineScalarFilters, "combineScalarFilters");
|
|
117
121
|
function beforeInputType(args) {
|
|
118
|
-
const { inputType: inputType2 } = args;
|
|
122
|
+
const { inputType: inputType2, removeTypes } = args;
|
|
119
123
|
if (isContainBogus(inputType2.name) && isScalarFilter(inputType2)) {
|
|
120
|
-
|
|
124
|
+
removeTypes.add(inputType2.name);
|
|
125
|
+
inputType2.name = replaceBogus(inputType2.name);
|
|
121
126
|
}
|
|
122
127
|
}
|
|
123
128
|
__name(beforeInputType, "beforeInputType");
|
|
@@ -158,6 +163,57 @@ function isScalarFilter(inputType2) {
|
|
|
158
163
|
return result;
|
|
159
164
|
}
|
|
160
165
|
__name(isScalarFilter, "isScalarFilter");
|
|
166
|
+
function postBegin(args) {
|
|
167
|
+
const { schema } = args;
|
|
168
|
+
const inputTypes = schema.inputObjectTypes.prisma;
|
|
169
|
+
const enumTypes = schema.enumTypes.model || [];
|
|
170
|
+
const types = [
|
|
171
|
+
"Bool",
|
|
172
|
+
"Int",
|
|
173
|
+
"String",
|
|
174
|
+
"DateTime",
|
|
175
|
+
"Decimal",
|
|
176
|
+
"Float",
|
|
177
|
+
"Json",
|
|
178
|
+
"Bytes",
|
|
179
|
+
"BigInt"
|
|
180
|
+
];
|
|
181
|
+
for (const enumType of enumTypes) {
|
|
182
|
+
const { name } = enumType;
|
|
183
|
+
types.push(`Enum${name}`);
|
|
184
|
+
}
|
|
185
|
+
const inputTypeByName = (0, import_lodash2.keyBy)(inputTypes, (inputType2) => inputType2.name);
|
|
186
|
+
const replaceBogusFilters = /* @__PURE__ */ __name((filterName, filterNameCandidates) => {
|
|
187
|
+
for (const filterNameCandidate of filterNameCandidates) {
|
|
188
|
+
const candidate = inputTypeByName[filterNameCandidate];
|
|
189
|
+
if (candidate) {
|
|
190
|
+
const inputType2 = (0, import_lodash2.cloneDeep)({
|
|
191
|
+
...candidate,
|
|
192
|
+
name: filterName
|
|
193
|
+
});
|
|
194
|
+
inputTypes.push(inputType2);
|
|
195
|
+
inputTypeByName[filterName] = inputType2;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}, "replaceBogusFilters");
|
|
200
|
+
for (const type of types) {
|
|
201
|
+
replaceBogusFilters(`${type}Filter`, [
|
|
202
|
+
`${type}NullableFilter`,
|
|
203
|
+
`Nested${type}NullableFilter`
|
|
204
|
+
]);
|
|
205
|
+
replaceBogusFilters(`${type}WithAggregatesFilter`, [
|
|
206
|
+
`${type}NullableWithAggregatesFilter`,
|
|
207
|
+
`Nested${type}NullableWithAggregatesFilter`
|
|
208
|
+
]);
|
|
209
|
+
replaceBogusFilters(`${type}ListFilter`, [
|
|
210
|
+
`${type}NullableListFilter`,
|
|
211
|
+
`Nested${type}NullableListFilter`
|
|
212
|
+
]);
|
|
213
|
+
}
|
|
214
|
+
(0, import_lodash2.remove)(inputTypes, (inputType2) => isContainBogus(inputType2.name));
|
|
215
|
+
}
|
|
216
|
+
__name(postBegin, "postBegin");
|
|
161
217
|
|
|
162
218
|
// src/handlers/create-aggregate-input.ts
|
|
163
219
|
function createAggregateInput(args) {
|
|
@@ -318,7 +374,7 @@ async function generateFiles(args) {
|
|
|
318
374
|
continue;
|
|
319
375
|
}
|
|
320
376
|
switch (statement.kind) {
|
|
321
|
-
case import_ts_morph2.StructureKind.ImportDeclaration:
|
|
377
|
+
case import_ts_morph2.StructureKind.ImportDeclaration: {
|
|
322
378
|
if (statement.moduleSpecifier.startsWith("./") || statement.moduleSpecifier.startsWith("..")) {
|
|
323
379
|
continue;
|
|
324
380
|
}
|
|
@@ -341,12 +397,15 @@ async function generateFiles(args) {
|
|
|
341
397
|
});
|
|
342
398
|
}
|
|
343
399
|
break;
|
|
344
|
-
|
|
400
|
+
}
|
|
401
|
+
case import_ts_morph2.StructureKind.Enum: {
|
|
345
402
|
enums.unshift(statement);
|
|
346
403
|
break;
|
|
347
|
-
|
|
404
|
+
}
|
|
405
|
+
case import_ts_morph2.StructureKind.Class: {
|
|
348
406
|
classes.push(statement);
|
|
349
407
|
break;
|
|
408
|
+
}
|
|
350
409
|
}
|
|
351
410
|
}
|
|
352
411
|
sourceFile.set({
|
|
@@ -381,19 +440,22 @@ __name(generateFiles, "generateFiles");
|
|
|
381
440
|
// src/handlers/input-type.ts
|
|
382
441
|
var import_assert2 = require("assert");
|
|
383
442
|
var import_json5 = __toESM(require("json5"));
|
|
384
|
-
var
|
|
443
|
+
var import_lodash4 = require("lodash");
|
|
385
444
|
var import_pupa = __toESM(require("pupa"));
|
|
386
445
|
var import_ts_morph4 = require("ts-morph");
|
|
387
446
|
|
|
388
447
|
// src/helpers/file-type-by-location.ts
|
|
389
448
|
function fileTypeByLocation(fieldLocation) {
|
|
390
449
|
switch (fieldLocation) {
|
|
391
|
-
case "inputObjectTypes":
|
|
450
|
+
case "inputObjectTypes": {
|
|
392
451
|
return "input";
|
|
393
|
-
|
|
452
|
+
}
|
|
453
|
+
case "outputObjectTypes": {
|
|
394
454
|
return "output";
|
|
395
|
-
|
|
455
|
+
}
|
|
456
|
+
case "enumTypes": {
|
|
396
457
|
return "enum";
|
|
458
|
+
}
|
|
397
459
|
}
|
|
398
460
|
return "object";
|
|
399
461
|
}
|
|
@@ -438,32 +500,37 @@ function getGraphqlImport(args) {
|
|
|
438
500
|
}
|
|
439
501
|
switch (typeName) {
|
|
440
502
|
case "Float":
|
|
441
|
-
case "Int":
|
|
503
|
+
case "Int": {
|
|
442
504
|
return {
|
|
443
505
|
name: typeName,
|
|
444
506
|
specifier: "@nestjs/graphql"
|
|
445
507
|
};
|
|
446
|
-
|
|
508
|
+
}
|
|
509
|
+
case "DateTime": {
|
|
447
510
|
return {
|
|
448
511
|
name: "Date",
|
|
449
512
|
specifier: void 0
|
|
450
513
|
};
|
|
514
|
+
}
|
|
451
515
|
case "true":
|
|
452
|
-
case "Boolean":
|
|
516
|
+
case "Boolean": {
|
|
453
517
|
return {
|
|
454
518
|
name: "Boolean",
|
|
455
519
|
specifier: void 0
|
|
456
520
|
};
|
|
457
|
-
|
|
521
|
+
}
|
|
522
|
+
case "Decimal": {
|
|
458
523
|
return {
|
|
459
524
|
name: "GraphQLDecimal",
|
|
460
525
|
specifier: "prisma-graphql-type-decimal"
|
|
461
526
|
};
|
|
462
|
-
|
|
527
|
+
}
|
|
528
|
+
case "Json": {
|
|
463
529
|
return {
|
|
464
530
|
name: "GraphQLJSON",
|
|
465
531
|
specifier: "graphql-type-json"
|
|
466
532
|
};
|
|
533
|
+
}
|
|
467
534
|
}
|
|
468
535
|
return {
|
|
469
536
|
name: "String",
|
|
@@ -486,7 +553,7 @@ function getGraphqlImport(args) {
|
|
|
486
553
|
__name(getGraphqlImport, "getGraphqlImport");
|
|
487
554
|
|
|
488
555
|
// src/helpers/get-graphql-input-type.ts
|
|
489
|
-
var
|
|
556
|
+
var import_lodash3 = require("lodash");
|
|
490
557
|
var import_outmatch = __toESM(require("outmatch"));
|
|
491
558
|
function getGraphqlInputType(inputTypes, pattern) {
|
|
492
559
|
let result;
|
|
@@ -494,11 +561,11 @@ function getGraphqlInputType(inputTypes, pattern) {
|
|
|
494
561
|
"null",
|
|
495
562
|
"Null"
|
|
496
563
|
].includes(String(t.type)));
|
|
497
|
-
inputTypes = (0,
|
|
564
|
+
inputTypes = (0, import_lodash3.uniqWith)(inputTypes, import_lodash3.isEqual);
|
|
498
565
|
if (inputTypes.length === 1) {
|
|
499
566
|
return inputTypes[0];
|
|
500
567
|
}
|
|
501
|
-
const countTypes = (0,
|
|
568
|
+
const countTypes = (0, import_lodash3.countBy)(inputTypes, (x) => x.location);
|
|
502
569
|
const isOneType = Object.keys(countTypes).length === 1;
|
|
503
570
|
if (isOneType) {
|
|
504
571
|
result = inputTypes.find((x) => x.isList);
|
|
@@ -532,6 +599,12 @@ function getGraphqlInputType(inputTypes, pattern) {
|
|
|
532
599
|
return result;
|
|
533
600
|
}
|
|
534
601
|
}
|
|
602
|
+
if ((countTypes.scalar === 1 || countTypes.enumTypes === 1) && countTypes.fieldRefTypes === 1) {
|
|
603
|
+
result = inputTypes.find((x) => x.location === "scalar" || x.location === "enumTypes");
|
|
604
|
+
if (result) {
|
|
605
|
+
return result;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
535
608
|
throw new TypeError(
|
|
536
609
|
`Cannot get matching input type from ${inputTypes.map((x) => x.type).join(", ") || "zero length inputTypes"}`
|
|
537
610
|
);
|
|
@@ -543,44 +616,53 @@ function getPropertyType(args) {
|
|
|
543
616
|
const { type, location } = args;
|
|
544
617
|
switch (type) {
|
|
545
618
|
case "Float":
|
|
546
|
-
case "Int":
|
|
619
|
+
case "Int": {
|
|
547
620
|
return [
|
|
548
621
|
"number"
|
|
549
622
|
];
|
|
550
|
-
|
|
623
|
+
}
|
|
624
|
+
case "String": {
|
|
551
625
|
return [
|
|
552
626
|
"string"
|
|
553
627
|
];
|
|
554
|
-
|
|
628
|
+
}
|
|
629
|
+
case "Boolean": {
|
|
555
630
|
return [
|
|
556
631
|
"boolean"
|
|
557
632
|
];
|
|
558
|
-
|
|
633
|
+
}
|
|
634
|
+
case "DateTime": {
|
|
559
635
|
return [
|
|
560
636
|
"Date",
|
|
561
637
|
"string"
|
|
562
638
|
];
|
|
563
|
-
|
|
639
|
+
}
|
|
640
|
+
case "Decimal": {
|
|
564
641
|
return [
|
|
565
642
|
"Decimal"
|
|
566
643
|
];
|
|
567
|
-
|
|
644
|
+
}
|
|
645
|
+
case "Json": {
|
|
568
646
|
return [
|
|
569
647
|
"any"
|
|
570
648
|
];
|
|
571
|
-
|
|
649
|
+
}
|
|
650
|
+
case "Null": {
|
|
572
651
|
return [
|
|
573
652
|
"null"
|
|
574
653
|
];
|
|
575
|
-
|
|
654
|
+
}
|
|
655
|
+
case "Bytes": {
|
|
576
656
|
return [
|
|
577
657
|
"Buffer"
|
|
578
658
|
];
|
|
579
|
-
|
|
659
|
+
}
|
|
660
|
+
case "BigInt": {
|
|
580
661
|
return [
|
|
581
662
|
"bigint",
|
|
582
663
|
"number"
|
|
583
664
|
];
|
|
665
|
+
}
|
|
584
666
|
}
|
|
585
667
|
if ([
|
|
586
668
|
"inputObjectTypes",
|
|
@@ -682,7 +764,7 @@ function inputType(args) {
|
|
|
682
764
|
});
|
|
683
765
|
const modelField = model?.fields.find((f) => f.name === name);
|
|
684
766
|
const isCustomsApplicable = typeName === modelField?.type;
|
|
685
|
-
const propertyType = (0,
|
|
767
|
+
const propertyType = (0, import_lodash4.castArray)(propertySettings?.name || getPropertyType({
|
|
686
768
|
location,
|
|
687
769
|
type: typeName
|
|
688
770
|
}));
|
|
@@ -725,7 +807,7 @@ function inputType(args) {
|
|
|
725
807
|
graphqlType = graphqlImport.name;
|
|
726
808
|
let referenceName = propertyType[0];
|
|
727
809
|
if (location === "enumTypes") {
|
|
728
|
-
referenceName = (0,
|
|
810
|
+
referenceName = (0, import_lodash4.last)(referenceName.split(" "));
|
|
729
811
|
}
|
|
730
812
|
if (graphqlImport.specifier && !importDeclarations.has(graphqlImport.name) && graphqlImport.name !== inputType2.name) {
|
|
731
813
|
importDeclarations.set(graphqlImport.name, {
|
|
@@ -835,7 +917,7 @@ __name(inputType, "inputType");
|
|
|
835
917
|
|
|
836
918
|
// src/helpers/object-settings.ts
|
|
837
919
|
var import_json52 = __toESM(require("json5"));
|
|
838
|
-
var
|
|
920
|
+
var import_lodash5 = require("lodash");
|
|
839
921
|
var import_outmatch2 = __toESM(require("outmatch"));
|
|
840
922
|
var ObjectSettings = class extends Array {
|
|
841
923
|
shouldHideField({ name, input = false, output = false }) {
|
|
@@ -875,14 +957,14 @@ var ObjectSettings = class extends Array {
|
|
|
875
957
|
return propertyType;
|
|
876
958
|
}
|
|
877
959
|
getObjectTypeArguments(options) {
|
|
878
|
-
const objectTypeOptions = (0,
|
|
960
|
+
const objectTypeOptions = (0, import_lodash5.merge)({}, options);
|
|
879
961
|
const resultArguments = [
|
|
880
962
|
objectTypeOptions
|
|
881
963
|
];
|
|
882
964
|
const objectType = this.find((s) => s.kind === "ObjectType");
|
|
883
|
-
if (objectType && (0,
|
|
965
|
+
if (objectType && (0, import_lodash5.isObject)(objectType.arguments)) {
|
|
884
966
|
const name = objectType.arguments.name;
|
|
885
|
-
(0,
|
|
967
|
+
(0, import_lodash5.merge)(objectTypeOptions, (0, import_lodash5.omit)(objectType.arguments, "name"));
|
|
886
968
|
if (name) {
|
|
887
969
|
resultArguments.unshift(name);
|
|
888
970
|
}
|
|
@@ -937,7 +1019,7 @@ function createSettingElement({ line, config, fieldElement, match }) {
|
|
|
937
1019
|
element: void 0
|
|
938
1020
|
};
|
|
939
1021
|
if (line.startsWith("@deprecated")) {
|
|
940
|
-
fieldElement.arguments["deprecationReason"] = (0,
|
|
1022
|
+
fieldElement.arguments["deprecationReason"] = (0, import_lodash5.trim)(line.slice(11));
|
|
941
1023
|
result.element = fieldElement;
|
|
942
1024
|
return result;
|
|
943
1025
|
}
|
|
@@ -965,7 +1047,7 @@ function createSettingElement({ line, config, fieldElement, match }) {
|
|
|
965
1047
|
"PropertyType"
|
|
966
1048
|
].includes(name) && match.groups?.args) {
|
|
967
1049
|
const options = customType(match.groups.args);
|
|
968
|
-
(0,
|
|
1050
|
+
(0, import_lodash5.merge)(element, options.namespace && config.fields[options.namespace], options, {
|
|
969
1051
|
kind: name
|
|
970
1052
|
});
|
|
971
1053
|
return result;
|
|
@@ -976,8 +1058,8 @@ function createSettingElement({ line, config, fieldElement, match }) {
|
|
|
976
1058
|
if (typeof options1[0] === "string" && options1[0]) {
|
|
977
1059
|
options1.name = options1[0];
|
|
978
1060
|
}
|
|
979
|
-
if ((0,
|
|
980
|
-
(0,
|
|
1061
|
+
if ((0, import_lodash5.isObject)(options1[1])) {
|
|
1062
|
+
(0, import_lodash5.merge)(options1, options1[1]);
|
|
981
1063
|
}
|
|
982
1064
|
element.arguments = {
|
|
983
1065
|
name: options1.name,
|
|
@@ -987,7 +1069,7 @@ function createSettingElement({ line, config, fieldElement, match }) {
|
|
|
987
1069
|
}
|
|
988
1070
|
if (name === "Directive" && match.groups?.args) {
|
|
989
1071
|
const options2 = customType(match.groups.args);
|
|
990
|
-
(0,
|
|
1072
|
+
(0, import_lodash5.merge)(element, {
|
|
991
1073
|
model: true,
|
|
992
1074
|
from: "@nestjs/graphql"
|
|
993
1075
|
}, options2, {
|
|
@@ -1002,9 +1084,9 @@ function createSettingElement({ line, config, fieldElement, match }) {
|
|
|
1002
1084
|
element.namespaceImport = namespace;
|
|
1003
1085
|
const options3 = {
|
|
1004
1086
|
name,
|
|
1005
|
-
arguments: (match.groups?.args || "").split(",").map((s) => (0,
|
|
1087
|
+
arguments: (match.groups?.args || "").split(",").map((s) => (0, import_lodash5.trim)(s)).filter(Boolean)
|
|
1006
1088
|
};
|
|
1007
|
-
(0,
|
|
1089
|
+
(0, import_lodash5.merge)(element, namespace && config.fields[namespace], options3);
|
|
1008
1090
|
return result;
|
|
1009
1091
|
}
|
|
1010
1092
|
__name(createSettingElement, "createSettingElement");
|
|
@@ -1116,7 +1198,7 @@ __name(modelData, "modelData");
|
|
|
1116
1198
|
// src/handlers/model-output-type.ts
|
|
1117
1199
|
var import_assert3 = require("assert");
|
|
1118
1200
|
var import_json53 = __toESM(require("json5"));
|
|
1119
|
-
var
|
|
1201
|
+
var import_lodash6 = require("lodash");
|
|
1120
1202
|
var import_pupa2 = __toESM(require("pupa"));
|
|
1121
1203
|
var import_ts_morph5 = require("ts-morph");
|
|
1122
1204
|
|
|
@@ -1209,7 +1291,7 @@ function modelOutputType(outputType2, args) {
|
|
|
1209
1291
|
name: outputType2.name,
|
|
1210
1292
|
output: true
|
|
1211
1293
|
});
|
|
1212
|
-
const propertyType = (0,
|
|
1294
|
+
const propertyType = (0, import_lodash6.castArray)(propertySettings?.name || getPropertyType({
|
|
1213
1295
|
location,
|
|
1214
1296
|
type: outputTypeName
|
|
1215
1297
|
}));
|
|
@@ -1259,10 +1341,11 @@ function modelOutputType(outputType2, args) {
|
|
|
1259
1341
|
importDeclarations.add("Decimal", "@prisma/client/runtime");
|
|
1260
1342
|
}
|
|
1261
1343
|
(0, import_assert3.ok)(property.decorators, "property.decorators is undefined");
|
|
1262
|
-
|
|
1344
|
+
const shouldHideField = settings1?.shouldHideField({
|
|
1263
1345
|
name: outputType2.name,
|
|
1264
1346
|
output: true
|
|
1265
|
-
}))
|
|
1347
|
+
}) || config.decorate.some((d) => d.name === "HideField" && d.from === "@nestjs/graphql" && d.isMatchField(field.name) && d.isMatchType(outputTypeName));
|
|
1348
|
+
if (shouldHideField) {
|
|
1266
1349
|
importDeclarations.add("HideField", nestjsGraphql);
|
|
1267
1350
|
property.decorators.push({
|
|
1268
1351
|
name: "HideField",
|
|
@@ -1404,7 +1487,7 @@ __name(isListInput, "isListInput");
|
|
|
1404
1487
|
// src/handlers/output-type.ts
|
|
1405
1488
|
var import_assert4 = require("assert");
|
|
1406
1489
|
var import_json54 = __toESM(require("json5"));
|
|
1407
|
-
var
|
|
1490
|
+
var import_lodash7 = require("lodash");
|
|
1408
1491
|
var import_ts_morph6 = require("ts-morph");
|
|
1409
1492
|
var nestjsGraphql2 = "@nestjs/graphql";
|
|
1410
1493
|
function outputType(outputType2, args) {
|
|
@@ -1450,7 +1533,7 @@ function outputType(outputType2, args) {
|
|
|
1450
1533
|
});
|
|
1451
1534
|
const isCustomsApplicable = outputTypeName === model?.fields.find((f) => f.name === field.name)?.type;
|
|
1452
1535
|
field.outputType.type = outputTypeName;
|
|
1453
|
-
const propertyType = (0,
|
|
1536
|
+
const propertyType = (0, import_lodash7.castArray)(propertySettings?.name || getPropertyType({
|
|
1454
1537
|
location,
|
|
1455
1538
|
type: outputTypeName
|
|
1456
1539
|
}));
|
|
@@ -1496,7 +1579,7 @@ function outputType(outputType2, args) {
|
|
|
1496
1579
|
graphqlType = graphqlImport.name;
|
|
1497
1580
|
let referenceName = propertyType[0];
|
|
1498
1581
|
if (location === "enumTypes") {
|
|
1499
|
-
referenceName = (0,
|
|
1582
|
+
referenceName = (0, import_lodash7.last)(referenceName.split(" "));
|
|
1500
1583
|
}
|
|
1501
1584
|
if (graphqlImport.specifier && !importDeclarations.has(graphqlImport.name) && (graphqlImport.name !== outputType2.name && !shouldHideField || shouldHideField && referenceName === graphqlImport.name)) {
|
|
1502
1585
|
importDeclarations.set(graphqlImport.name, {
|
|
@@ -1743,10 +1826,10 @@ var import_filenamify = __toESM(require("filenamify"));
|
|
|
1743
1826
|
var import_flat = require("flat");
|
|
1744
1827
|
var import_fs2 = require("fs");
|
|
1745
1828
|
var import_json55 = __toESM(require("json5"));
|
|
1746
|
-
var
|
|
1829
|
+
var import_lodash8 = require("lodash");
|
|
1747
1830
|
var import_outmatch3 = __toESM(require("outmatch"));
|
|
1748
1831
|
function createConfig(data) {
|
|
1749
|
-
const config = (0,
|
|
1832
|
+
const config = (0, import_lodash8.merge)({}, (0, import_flat.unflatten)(data, {
|
|
1750
1833
|
delimiter: "_"
|
|
1751
1834
|
}));
|
|
1752
1835
|
const $warnings = [];
|
|
@@ -1754,7 +1837,7 @@ function createConfig(data) {
|
|
|
1754
1837
|
let outputFilePattern = (0, import_filenamify.default)(configOutputFilePattern, {
|
|
1755
1838
|
replacement: "/"
|
|
1756
1839
|
}).replace(/\.\./g, "/").replace(/\/+/g, "/");
|
|
1757
|
-
outputFilePattern = (0,
|
|
1840
|
+
outputFilePattern = (0, import_lodash8.trim)(outputFilePattern, "/");
|
|
1758
1841
|
if (outputFilePattern !== configOutputFilePattern) {
|
|
1759
1842
|
$warnings.push(`Due to invalid filepath 'outputFilePattern' changed to '${outputFilePattern}'`);
|
|
1760
1843
|
}
|
|
@@ -1819,7 +1902,7 @@ function createConfig(data) {
|
|
|
1819
1902
|
};
|
|
1820
1903
|
}
|
|
1821
1904
|
__name(createConfig, "createConfig");
|
|
1822
|
-
var tsConfigFileExists = (0,
|
|
1905
|
+
var tsConfigFileExists = (0, import_lodash8.memoize)((filePath) => {
|
|
1823
1906
|
return (0, import_fs2.existsSync)(filePath);
|
|
1824
1907
|
});
|
|
1825
1908
|
function createTsConfigFilePathValue(value) {
|
|
@@ -1861,7 +1944,7 @@ function toBoolean(value) {
|
|
|
1861
1944
|
__name(toBoolean, "toBoolean");
|
|
1862
1945
|
|
|
1863
1946
|
// src/helpers/generate-file-name.ts
|
|
1864
|
-
var
|
|
1947
|
+
var import_lodash9 = require("lodash");
|
|
1865
1948
|
var import_pluralize = __toESM(require("pluralize"));
|
|
1866
1949
|
var import_pupa3 = __toESM(require("pupa"));
|
|
1867
1950
|
function generateFileName(args) {
|
|
@@ -1870,10 +1953,10 @@ function generateFileName(args) {
|
|
|
1870
1953
|
type,
|
|
1871
1954
|
get model() {
|
|
1872
1955
|
const result = getModelName2(name) || "prisma";
|
|
1873
|
-
return (0,
|
|
1956
|
+
return (0, import_lodash9.kebabCase)(result);
|
|
1874
1957
|
},
|
|
1875
1958
|
get name() {
|
|
1876
|
-
let result1 = (0,
|
|
1959
|
+
let result1 = (0, import_lodash9.kebabCase)(name);
|
|
1877
1960
|
for (const suffix of [
|
|
1878
1961
|
"input",
|
|
1879
1962
|
"args",
|
|
@@ -1915,9 +1998,9 @@ function factoryGetSourceFile(args) {
|
|
|
1915
1998
|
__name(factoryGetSourceFile, "factoryGetSourceFile");
|
|
1916
1999
|
|
|
1917
2000
|
// src/helpers/get-model-name.ts
|
|
1918
|
-
var
|
|
2001
|
+
var import_lodash10 = require("lodash");
|
|
1919
2002
|
function createGetModelName(modelNames) {
|
|
1920
|
-
return (0,
|
|
2003
|
+
return (0, import_lodash10.memoize)(tryGetName);
|
|
1921
2004
|
function tryGetName(name) {
|
|
1922
2005
|
return getModelName({
|
|
1923
2006
|
modelNames,
|
|
@@ -1954,7 +2037,7 @@ function getModelName(args) {
|
|
|
1954
2037
|
if (name.slice(-19) === "CompoundUniqueInput") {
|
|
1955
2038
|
const test3 = name.slice(0, -19);
|
|
1956
2039
|
const models = modelNames.filter((x) => test3.startsWith(x)).sort((a, b) => b.length - a.length);
|
|
1957
|
-
return (0,
|
|
2040
|
+
return (0, import_lodash10.first)(models);
|
|
1958
2041
|
}
|
|
1959
2042
|
if (name.slice(-5) === "Count") {
|
|
1960
2043
|
const test4 = name.slice(0, -5);
|
|
@@ -2135,9 +2218,10 @@ async function generate(args) {
|
|
|
2135
2218
|
outputFilePattern: config.outputFilePattern,
|
|
2136
2219
|
eventEmitter
|
|
2137
2220
|
});
|
|
2138
|
-
const { datamodel, schema
|
|
2221
|
+
const { datamodel, schema } = JSON.parse(JSON.stringify(dmmf));
|
|
2139
2222
|
const removeTypes = /* @__PURE__ */ new Set();
|
|
2140
2223
|
const eventArguments = {
|
|
2224
|
+
schema,
|
|
2141
2225
|
models,
|
|
2142
2226
|
config,
|
|
2143
2227
|
modelNames,
|
|
@@ -2148,7 +2232,7 @@ async function generate(args) {
|
|
|
2148
2232
|
getSourceFile,
|
|
2149
2233
|
eventEmitter,
|
|
2150
2234
|
typeNames: /* @__PURE__ */ new Set(),
|
|
2151
|
-
enums: (0,
|
|
2235
|
+
enums: (0, import_lodash11.mapKeys)(datamodel.enums, (x) => x.name),
|
|
2152
2236
|
getModelName: getModelName2,
|
|
2153
2237
|
removeTypes,
|
|
2154
2238
|
classTransformerTypeModels: /* @__PURE__ */ new Set()
|
|
@@ -2163,6 +2247,7 @@ async function generate(args) {
|
|
|
2163
2247
|
for (const model1 of datamodel.types || []) {
|
|
2164
2248
|
await eventEmitter.emit("Model", model1, eventArguments);
|
|
2165
2249
|
}
|
|
2250
|
+
const { inputObjectTypes, outputObjectTypes, enumTypes } = schema;
|
|
2166
2251
|
await eventEmitter.emit("PostBegin", eventArguments);
|
|
2167
2252
|
for (const enumType of enumTypes.prisma.concat(enumTypes.model || [])) {
|
|
2168
2253
|
await eventEmitter.emit("EnumType", enumType, eventArguments);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-nestjs-graphql",
|
|
3
|
-
"version": "17.0
|
|
3
|
+
"version": "17.1.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,7 +52,7 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@prisma/generator-helper": "^4.1
|
|
55
|
+
"@prisma/generator-helper": "^4.7.1",
|
|
56
56
|
"await-event-emitter": "^2.0.2",
|
|
57
57
|
"filenamify": "4.X",
|
|
58
58
|
"flat": "^5.0.2",
|
|
@@ -65,44 +65,44 @@
|
|
|
65
65
|
"ts-morph": ">=11 <=16"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@commitlint/cli": "^17.
|
|
69
|
-
"@commitlint/config-conventional": "^17.
|
|
70
|
-
"@nestjs/apollo": "^10.1.
|
|
71
|
-
"@nestjs/common": "^9.2.
|
|
72
|
-
"@nestjs/core": "^9.2.
|
|
73
|
-
"@nestjs/graphql": "^10.1.
|
|
74
|
-
"@nestjs/platform-express": "^9.2.
|
|
75
|
-
"@paljs/plugins": "^5.0
|
|
76
|
-
"@prisma/client": "^4.1
|
|
77
|
-
"@semantic-release/changelog": "^6.0.
|
|
68
|
+
"@commitlint/cli": "^17.3.0",
|
|
69
|
+
"@commitlint/config-conventional": "^17.3.0",
|
|
70
|
+
"@nestjs/apollo": "^10.1.7",
|
|
71
|
+
"@nestjs/common": "^9.2.1",
|
|
72
|
+
"@nestjs/core": "^9.2.1",
|
|
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",
|
|
78
78
|
"@semantic-release/git": "^10.0.1",
|
|
79
|
-
"@swc/core": "^1.3.
|
|
79
|
+
"@swc/core": "^1.3.23",
|
|
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.
|
|
84
|
-
"@types/mocha": "^10.0.
|
|
85
|
-
"@types/node": "^18.11.
|
|
83
|
+
"@types/lodash": "^4.14.191",
|
|
84
|
+
"@types/mocha": "^10.0.1",
|
|
85
|
+
"@types/node": "^18.11.15",
|
|
86
86
|
"@types/pluralize": "^0.0.29",
|
|
87
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
88
|
-
"@typescript-eslint/parser": "^5.
|
|
87
|
+
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
|
88
|
+
"@typescript-eslint/parser": "^5.46.1",
|
|
89
89
|
"apollo-server-express": "^3.10.0",
|
|
90
90
|
"c8": "^7.12.0",
|
|
91
91
|
"class-transformer": "^0.5.1",
|
|
92
|
-
"class-validator": "^0.
|
|
93
|
-
"commitizen": "^4.2.
|
|
92
|
+
"class-validator": "^0.14.0",
|
|
93
|
+
"commitizen": "^4.2.6",
|
|
94
94
|
"cz-customizable": "^7.0.0",
|
|
95
|
-
"decimal.js": "^10.4.
|
|
96
|
-
"eslint": "^8.
|
|
95
|
+
"decimal.js": "^10.4.3",
|
|
96
|
+
"eslint": "^8.29.0",
|
|
97
97
|
"eslint-import-resolver-node": "^0.3.6",
|
|
98
98
|
"eslint-plugin-etc": "^2.0.2",
|
|
99
99
|
"eslint-plugin-import": "^2.26.0",
|
|
100
|
-
"eslint-plugin-only-warn": "^1.0
|
|
100
|
+
"eslint-plugin-only-warn": "^1.1.0",
|
|
101
101
|
"eslint-plugin-prettier": "^4.2.1",
|
|
102
|
-
"eslint-plugin-regexp": "^1.
|
|
102
|
+
"eslint-plugin-regexp": "^1.11.0",
|
|
103
103
|
"eslint-plugin-simple-import-sort": "^8.0.0",
|
|
104
|
-
"eslint-plugin-sort-class-members": "^1.
|
|
105
|
-
"eslint-plugin-unicorn": "^
|
|
104
|
+
"eslint-plugin-sort-class-members": "^1.16.0",
|
|
105
|
+
"eslint-plugin-unicorn": "^45.0.2",
|
|
106
106
|
"eslint-plugin-wix-editor": "^3.3.0",
|
|
107
107
|
"expect": "^29.3.1",
|
|
108
108
|
"ghooks": "^2.0.4",
|
|
@@ -110,21 +110,21 @@
|
|
|
110
110
|
"graphql": "^16.6.0",
|
|
111
111
|
"graphql-scalars": "^1.20.1",
|
|
112
112
|
"graphql-type-json": "^0.3.2",
|
|
113
|
-
"mocha": "^10.
|
|
113
|
+
"mocha": "^10.2.0",
|
|
114
114
|
"ololog": "^1.1.175",
|
|
115
115
|
"precise-commits": "^1.0.2",
|
|
116
|
-
"prettier": "^2.
|
|
117
|
-
"prisma": "^4.1
|
|
116
|
+
"prettier": "^2.8.1",
|
|
117
|
+
"prisma": "^4.7.1",
|
|
118
118
|
"prisma-graphql-type-decimal": "^2.0.4",
|
|
119
119
|
"reflect-metadata": "^0.1.13",
|
|
120
120
|
"request": "^2.88.2",
|
|
121
|
-
"rxjs": "^7.
|
|
121
|
+
"rxjs": "^7.6.0",
|
|
122
122
|
"semantic-release": "^19.0.5",
|
|
123
123
|
"simplytyped": "^3.3.0",
|
|
124
124
|
"temp-dir": "2.X",
|
|
125
125
|
"ts-node": "^10.9.1",
|
|
126
126
|
"tslib": "^2.4.1",
|
|
127
|
-
"typescript": "^4.9.
|
|
127
|
+
"typescript": "^4.9.4",
|
|
128
128
|
"watchexec-bin": "^1.0.0"
|
|
129
129
|
}
|
|
130
130
|
}
|