prisma-nestjs-graphql 15.2.0 → 15.2.3
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 +3 -3
- package/index.js +73 -3
- package/package.json +35 -35
package/README.md
CHANGED
|
@@ -66,9 +66,9 @@ Possible tokens:
|
|
|
66
66
|
|
|
67
67
|
#### `tsConfigFilePath`
|
|
68
68
|
|
|
69
|
-
Path to `tsconfig.json`
|
|
69
|
+
Path to `tsconfig.json` (absolute path or relative to current working directory)
|
|
70
70
|
Type: `string | undefined`
|
|
71
|
-
Default: `undefined`
|
|
71
|
+
Default: `tsconfig.json` if exists, `undefined` otherwise
|
|
72
72
|
|
|
73
73
|
#### `combineScalarFilters`
|
|
74
74
|
|
|
@@ -659,7 +659,7 @@ export class User {}
|
|
|
659
659
|
## Resources
|
|
660
660
|
|
|
661
661
|
- Todo - https://github.com/unlight/prisma-nestjs-graphql/issues/2
|
|
662
|
-
- https://github.com/prisma/prisma/blob/
|
|
662
|
+
- https://github.com/prisma/prisma/blob/main/packages/client/src/generation/TSClient/TSClient.ts
|
|
663
663
|
- https://ts-ast-viewer.com/
|
|
664
664
|
- https://github.com/unlight/nestjs-graphql-prisma-realworld-example-app
|
|
665
665
|
- https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-schema/data-model
|
package/index.js
CHANGED
|
@@ -29,6 +29,7 @@ var import_lodash = require("lodash");
|
|
|
29
29
|
function pascalCase(string) {
|
|
30
30
|
return (0, import_lodash.startCase)((0, import_lodash.camelCase)(string)).replace(/ /g, "");
|
|
31
31
|
}
|
|
32
|
+
__name(pascalCase, "pascalCase");
|
|
32
33
|
|
|
33
34
|
// src/handlers/args-type.ts
|
|
34
35
|
function argsType(field, args) {
|
|
@@ -101,18 +102,21 @@ function argsType(field, args) {
|
|
|
101
102
|
classDecoratorName: "ArgsType"
|
|
102
103
|
});
|
|
103
104
|
}
|
|
105
|
+
__name(argsType, "argsType");
|
|
104
106
|
|
|
105
107
|
// src/handlers/combine-scalar-filters.ts
|
|
106
108
|
function combineScalarFilters(eventEmitter) {
|
|
107
109
|
eventEmitter.on("BeforeInputType", beforeInputType);
|
|
108
110
|
eventEmitter.on("BeforeGenerateField", beforeGenerateField);
|
|
109
111
|
}
|
|
112
|
+
__name(combineScalarFilters, "combineScalarFilters");
|
|
110
113
|
function beforeInputType(args) {
|
|
111
114
|
const { inputType: inputType2 } = args;
|
|
112
115
|
if (isContainBogus(inputType2.name) && isScalarFilter(inputType2)) {
|
|
113
116
|
inputType2.name = replaceBogus(String(inputType2.name));
|
|
114
117
|
}
|
|
115
118
|
}
|
|
119
|
+
__name(beforeInputType, "beforeInputType");
|
|
116
120
|
function beforeGenerateField(field) {
|
|
117
121
|
for (const fieldInput of field.inputTypes) {
|
|
118
122
|
if (fieldInput.location !== "inputObjectTypes") {
|
|
@@ -124,12 +128,15 @@ function beforeGenerateField(field) {
|
|
|
124
128
|
}
|
|
125
129
|
}
|
|
126
130
|
}
|
|
131
|
+
__name(beforeGenerateField, "beforeGenerateField");
|
|
127
132
|
function replaceBogus(name) {
|
|
128
133
|
return name.replace(/(Nullable|Nested)/g, "");
|
|
129
134
|
}
|
|
135
|
+
__name(replaceBogus, "replaceBogus");
|
|
130
136
|
function isContainBogus(name) {
|
|
131
137
|
return name.startsWith("Nested") || name.includes("Nullable") && name.endsWith("Filter") || name.endsWith("NullableFilter");
|
|
132
138
|
}
|
|
139
|
+
__name(isContainBogus, "isContainBogus");
|
|
133
140
|
function isScalarFilter(inputType2) {
|
|
134
141
|
if (!inputType2.name.endsWith("Filter")) {
|
|
135
142
|
return false;
|
|
@@ -146,6 +153,7 @@ function isScalarFilter(inputType2) {
|
|
|
146
153
|
}
|
|
147
154
|
return result;
|
|
148
155
|
}
|
|
156
|
+
__name(isScalarFilter, "isScalarFilter");
|
|
149
157
|
|
|
150
158
|
// src/handlers/create-aggregate-input.ts
|
|
151
159
|
function createAggregateInput(args) {
|
|
@@ -180,11 +188,13 @@ function createAggregateInput(args) {
|
|
|
180
188
|
classDecoratorName: "InputType"
|
|
181
189
|
});
|
|
182
190
|
}
|
|
191
|
+
__name(createAggregateInput, "createAggregateInput");
|
|
183
192
|
|
|
184
193
|
// src/handlers/emit-single.ts
|
|
185
194
|
function emitSingle(emitter) {
|
|
186
195
|
emitter.on("ClassProperty", classProperty);
|
|
187
196
|
}
|
|
197
|
+
__name(emitSingle, "emitSingle");
|
|
188
198
|
function classProperty(property, eventArguments) {
|
|
189
199
|
const { location, isList, propertyType } = eventArguments;
|
|
190
200
|
if ([
|
|
@@ -198,6 +208,7 @@ function classProperty(property, eventArguments) {
|
|
|
198
208
|
}
|
|
199
209
|
}
|
|
200
210
|
}
|
|
211
|
+
__name(classProperty, "classProperty");
|
|
201
212
|
|
|
202
213
|
// src/handlers/generate-files.ts
|
|
203
214
|
var import_assert = require("assert");
|
|
@@ -262,6 +273,7 @@ var ImportDeclarationMap = class extends Map {
|
|
|
262
273
|
}
|
|
263
274
|
}
|
|
264
275
|
};
|
|
276
|
+
__name(ImportDeclarationMap, "ImportDeclarationMap");
|
|
265
277
|
|
|
266
278
|
// src/handlers/generate-files.ts
|
|
267
279
|
async function generateFiles(args) {
|
|
@@ -364,6 +376,7 @@ async function generateFiles(args) {
|
|
|
364
376
|
await project.save();
|
|
365
377
|
}
|
|
366
378
|
}
|
|
379
|
+
__name(generateFiles, "generateFiles");
|
|
367
380
|
|
|
368
381
|
// src/handlers/input-type.ts
|
|
369
382
|
var import_assert2 = require("assert");
|
|
@@ -384,6 +397,7 @@ function fileTypeByLocation(fieldLocation) {
|
|
|
384
397
|
}
|
|
385
398
|
return "object";
|
|
386
399
|
}
|
|
400
|
+
__name(fileTypeByLocation, "fileTypeByLocation");
|
|
387
401
|
|
|
388
402
|
// src/helpers/relative-path.ts
|
|
389
403
|
var import_get_relative_path = __toESM(require("get-relative-path"));
|
|
@@ -403,6 +417,7 @@ function relativePath(from, to) {
|
|
|
403
417
|
}
|
|
404
418
|
return result;
|
|
405
419
|
}
|
|
420
|
+
__name(relativePath, "relativePath");
|
|
406
421
|
|
|
407
422
|
// src/helpers/get-graphql-import.ts
|
|
408
423
|
function getGraphqlImport(args) {
|
|
@@ -468,6 +483,7 @@ function getGraphqlImport(args) {
|
|
|
468
483
|
specifier
|
|
469
484
|
};
|
|
470
485
|
}
|
|
486
|
+
__name(getGraphqlImport, "getGraphqlImport");
|
|
471
487
|
|
|
472
488
|
// src/helpers/get-graphql-input-type.ts
|
|
473
489
|
var import_lodash2 = require("lodash");
|
|
@@ -517,6 +533,7 @@ function getGraphqlInputType(inputTypes, pattern) {
|
|
|
517
533
|
}
|
|
518
534
|
throw new TypeError(`Cannot get matching input type from ${inputTypes.map((x) => x.type).join(", ") || "zero length inputTypes"}`);
|
|
519
535
|
}
|
|
536
|
+
__name(getGraphqlInputType, "getGraphqlInputType");
|
|
520
537
|
|
|
521
538
|
// src/helpers/get-property-type.ts
|
|
522
539
|
function getPropertyType(args) {
|
|
@@ -584,6 +601,7 @@ function getPropertyType(args) {
|
|
|
584
601
|
"unknown"
|
|
585
602
|
];
|
|
586
603
|
}
|
|
604
|
+
__name(getPropertyType, "getPropertyType");
|
|
587
605
|
|
|
588
606
|
// src/helpers/property-structure.ts
|
|
589
607
|
var import_ts_morph3 = require("ts-morph");
|
|
@@ -600,6 +618,7 @@ function propertyStructure(args) {
|
|
|
600
618
|
leadingTrivia: "\n"
|
|
601
619
|
};
|
|
602
620
|
}
|
|
621
|
+
__name(propertyStructure, "propertyStructure");
|
|
603
622
|
|
|
604
623
|
// src/handlers/input-type.ts
|
|
605
624
|
function inputType(args) {
|
|
@@ -647,6 +666,9 @@ function inputType(args) {
|
|
|
647
666
|
field.inputTypes = field.inputTypes.filter((t) => !removeTypes.has(String(t.type)));
|
|
648
667
|
eventEmitter.emitSync("BeforeGenerateField", field, args);
|
|
649
668
|
const { inputTypes, isRequired, name } = field;
|
|
669
|
+
if (inputTypes.length === 0) {
|
|
670
|
+
continue;
|
|
671
|
+
}
|
|
650
672
|
const usePattern = (useInputType == null ? void 0 : useInputType.ALL) || (useInputType == null ? void 0 : useInputType[name]);
|
|
651
673
|
const graphqlInputType = getGraphqlInputType(inputTypes, usePattern);
|
|
652
674
|
const { isList, location, type } = graphqlInputType;
|
|
@@ -767,6 +789,7 @@ function inputType(args) {
|
|
|
767
789
|
]
|
|
768
790
|
});
|
|
769
791
|
}
|
|
792
|
+
__name(inputType, "inputType");
|
|
770
793
|
|
|
771
794
|
// src/helpers/object-settings.ts
|
|
772
795
|
var import_json52 = __toESM(require("json5"));
|
|
@@ -826,6 +849,7 @@ var ObjectSettings = class extends Array {
|
|
|
826
849
|
return resultArguments.map((x) => import_json52.default.stringify(x));
|
|
827
850
|
}
|
|
828
851
|
};
|
|
852
|
+
__name(ObjectSettings, "ObjectSettings");
|
|
829
853
|
function createObjectSettings(args) {
|
|
830
854
|
var _a, _b, _c, _d, _e;
|
|
831
855
|
const { config, text } = args;
|
|
@@ -898,6 +922,7 @@ function createObjectSettings(args) {
|
|
|
898
922
|
documentation: documentationLines.filter(Boolean).join("\\n") || void 0
|
|
899
923
|
};
|
|
900
924
|
}
|
|
925
|
+
__name(createObjectSettings, "createObjectSettings");
|
|
901
926
|
function customType(args) {
|
|
902
927
|
var _a;
|
|
903
928
|
const result = {};
|
|
@@ -920,6 +945,7 @@ function customType(args) {
|
|
|
920
945
|
}
|
|
921
946
|
return result;
|
|
922
947
|
}
|
|
948
|
+
__name(customType, "customType");
|
|
923
949
|
function hideFieldDecorator(match) {
|
|
924
950
|
var _a;
|
|
925
951
|
const result = {
|
|
@@ -953,6 +979,7 @@ function hideFieldDecorator(match) {
|
|
|
953
979
|
}
|
|
954
980
|
return result;
|
|
955
981
|
}
|
|
982
|
+
__name(hideFieldDecorator, "hideFieldDecorator");
|
|
956
983
|
function parseArgs(string) {
|
|
957
984
|
try {
|
|
958
985
|
return import_json52.default.parse(string);
|
|
@@ -964,6 +991,7 @@ function parseArgs(string) {
|
|
|
964
991
|
}
|
|
965
992
|
}
|
|
966
993
|
}
|
|
994
|
+
__name(parseArgs, "parseArgs");
|
|
967
995
|
function getNamespace(name) {
|
|
968
996
|
if (name === void 0) {
|
|
969
997
|
return void 0;
|
|
@@ -974,6 +1002,7 @@ function getNamespace(name) {
|
|
|
974
1002
|
}
|
|
975
1003
|
return result;
|
|
976
1004
|
}
|
|
1005
|
+
__name(getNamespace, "getNamespace");
|
|
977
1006
|
|
|
978
1007
|
// src/handlers/model-data.ts
|
|
979
1008
|
function modelData(model, args) {
|
|
@@ -996,6 +1025,7 @@ function modelData(model, args) {
|
|
|
996
1025
|
modelFieldsValue.set(field.name, field);
|
|
997
1026
|
}
|
|
998
1027
|
}
|
|
1028
|
+
__name(modelData, "modelData");
|
|
999
1029
|
|
|
1000
1030
|
// src/handlers/model-output-type.ts
|
|
1001
1031
|
var import_assert3 = require("assert");
|
|
@@ -1008,6 +1038,7 @@ var import_ts_morph5 = require("ts-morph");
|
|
|
1008
1038
|
function getOutputTypeName(name) {
|
|
1009
1039
|
return name.replace(/(?:OutputType|Output)$/, "");
|
|
1010
1040
|
}
|
|
1041
|
+
__name(getOutputTypeName, "getOutputTypeName");
|
|
1011
1042
|
|
|
1012
1043
|
// src/handlers/model-output-type.ts
|
|
1013
1044
|
var nestjsGraphql = "@nestjs/graphql";
|
|
@@ -1213,20 +1244,24 @@ function modelOutputType(outputType2, args) {
|
|
|
1213
1244
|
});
|
|
1214
1245
|
}
|
|
1215
1246
|
}
|
|
1247
|
+
__name(modelOutputType, "modelOutputType");
|
|
1216
1248
|
function shouldBeDecorated(setting) {
|
|
1217
1249
|
return setting.kind === "Decorator" && (setting.output || setting.model) && !(setting.output && setting.model);
|
|
1218
1250
|
}
|
|
1251
|
+
__name(shouldBeDecorated, "shouldBeDecorated");
|
|
1219
1252
|
function getExportDeclaration(name, statements) {
|
|
1220
1253
|
return statements.find((structure) => {
|
|
1221
1254
|
return structure.kind === import_ts_morph5.StructureKind.ExportDeclaration && structure.namedExports.some((o) => (o.alias || o.name) === name);
|
|
1222
1255
|
});
|
|
1223
1256
|
}
|
|
1257
|
+
__name(getExportDeclaration, "getExportDeclaration");
|
|
1224
1258
|
|
|
1225
1259
|
// src/handlers/no-atomic-operations.ts
|
|
1226
1260
|
function noAtomicOperations(eventEmitter) {
|
|
1227
1261
|
eventEmitter.on("BeforeInputType", beforeInputType2);
|
|
1228
1262
|
eventEmitter.on("BeforeGenerateFiles", beforeGenerateFiles);
|
|
1229
1263
|
}
|
|
1264
|
+
__name(noAtomicOperations, "noAtomicOperations");
|
|
1230
1265
|
function beforeInputType2(args) {
|
|
1231
1266
|
const { inputType: inputType1 } = args;
|
|
1232
1267
|
for (const field of inputType1.fields) {
|
|
@@ -1249,9 +1284,11 @@ function beforeGenerateFiles(args) {
|
|
|
1249
1284
|
}
|
|
1250
1285
|
}
|
|
1251
1286
|
}
|
|
1287
|
+
__name(beforeGenerateFiles, "beforeGenerateFiles");
|
|
1252
1288
|
function isAtomicOperation(name) {
|
|
1253
1289
|
return name.endsWith("FieldUpdateOperationsInput");
|
|
1254
1290
|
}
|
|
1291
|
+
__name(isAtomicOperation, "isAtomicOperation");
|
|
1255
1292
|
|
|
1256
1293
|
// src/handlers/output-type.ts
|
|
1257
1294
|
var import_assert4 = require("assert");
|
|
@@ -1405,6 +1442,7 @@ function outputType(outputType1, args) {
|
|
|
1405
1442
|
]
|
|
1406
1443
|
});
|
|
1407
1444
|
}
|
|
1445
|
+
__name(outputType, "outputType");
|
|
1408
1446
|
|
|
1409
1447
|
// src/handlers/purge-output.ts
|
|
1410
1448
|
var import_fs = require("fs");
|
|
@@ -1412,6 +1450,7 @@ function purgeOutput(emitter) {
|
|
|
1412
1450
|
emitter.on("Begin", begin);
|
|
1413
1451
|
emitter.on("End", end);
|
|
1414
1452
|
}
|
|
1453
|
+
__name(purgeOutput, "purgeOutput");
|
|
1415
1454
|
function begin({ project, output }) {
|
|
1416
1455
|
var _a;
|
|
1417
1456
|
const sourceFiles = (_a = project.getDirectory(output)) == null ? void 0 : _a.getDescendantSourceFiles();
|
|
@@ -1421,6 +1460,7 @@ function begin({ project, output }) {
|
|
|
1421
1460
|
}
|
|
1422
1461
|
}
|
|
1423
1462
|
}
|
|
1463
|
+
__name(begin, "begin");
|
|
1424
1464
|
async function end({ project, output }) {
|
|
1425
1465
|
var _a;
|
|
1426
1466
|
const directories = (_a = project.getDirectory(output)) == null ? void 0 : _a.getDescendantDirectories().filter((directory) => directory.getSourceFiles().length === 0).map((directory) => directory.getPath());
|
|
@@ -1431,6 +1471,7 @@ async function end({ project, output }) {
|
|
|
1431
1471
|
}
|
|
1432
1472
|
}
|
|
1433
1473
|
}
|
|
1474
|
+
__name(end, "end");
|
|
1434
1475
|
|
|
1435
1476
|
// src/handlers/re-export.ts
|
|
1436
1477
|
var import_ts_morph7 = require("ts-morph");
|
|
@@ -1444,6 +1485,7 @@ var ReExport;
|
|
|
1444
1485
|
function reExport(emitter) {
|
|
1445
1486
|
emitter.on("BeforeGenerateFiles", beforeGenerateFiles2);
|
|
1446
1487
|
}
|
|
1488
|
+
__name(reExport, "reExport");
|
|
1447
1489
|
function beforeGenerateFiles2(args) {
|
|
1448
1490
|
const { project, output, config } = args;
|
|
1449
1491
|
const rootDirectory = project.getDirectoryOrThrow(output);
|
|
@@ -1514,6 +1556,7 @@ function getNamespaceExportDeclaration(directory, sourceDirectory) {
|
|
|
1514
1556
|
moduleSpecifier: directory.getRelativePathAsModuleSpecifierTo(sourceDirectory)
|
|
1515
1557
|
};
|
|
1516
1558
|
}
|
|
1559
|
+
__name(getNamespaceExportDeclaration, "getNamespaceExportDeclaration");
|
|
1517
1560
|
|
|
1518
1561
|
// src/handlers/register-enum.ts
|
|
1519
1562
|
var import_ts_morph8 = require("ts-morph");
|
|
@@ -1551,11 +1594,13 @@ function registerEnum(enumType, args) {
|
|
|
1551
1594
|
]
|
|
1552
1595
|
});
|
|
1553
1596
|
}
|
|
1597
|
+
__name(registerEnum, "registerEnum");
|
|
1554
1598
|
|
|
1555
1599
|
// src/handlers/require-single-fields-in-whereunique-input.ts
|
|
1556
1600
|
function requireSingleFieldsInWhereUniqueInput(eventEmitter) {
|
|
1557
1601
|
eventEmitter.on("BeforeInputType", beforeInputType3);
|
|
1558
1602
|
}
|
|
1603
|
+
__name(requireSingleFieldsInWhereUniqueInput, "requireSingleFieldsInWhereUniqueInput");
|
|
1559
1604
|
function beforeInputType3(args) {
|
|
1560
1605
|
const { inputType: inputType2 } = args;
|
|
1561
1606
|
if (!isWhereUniqueInputType(inputType2.name) || inputType2.fields.length !== 1) {
|
|
@@ -1570,6 +1615,7 @@ __name(beforeInputType3, "beforeInputType");
|
|
|
1570
1615
|
function isWhereUniqueInputType(name) {
|
|
1571
1616
|
return name.endsWith("WhereUniqueInput");
|
|
1572
1617
|
}
|
|
1618
|
+
__name(isWhereUniqueInputType, "isWhereUniqueInputType");
|
|
1573
1619
|
|
|
1574
1620
|
// src/handlers/warning.ts
|
|
1575
1621
|
function warning(message) {
|
|
@@ -1580,11 +1626,13 @@ function warning(message) {
|
|
|
1580
1626
|
console.log("prisma-nestjs-graphql:", message);
|
|
1581
1627
|
}
|
|
1582
1628
|
}
|
|
1629
|
+
__name(warning, "warning");
|
|
1583
1630
|
|
|
1584
1631
|
// src/helpers/create-config.ts
|
|
1585
1632
|
var import_assert5 = require("assert");
|
|
1586
1633
|
var import_filenamify = __toESM(require("filenamify"));
|
|
1587
1634
|
var import_flat = require("flat");
|
|
1635
|
+
var import_fs2 = require("fs");
|
|
1588
1636
|
var import_json55 = __toESM(require("json5"));
|
|
1589
1637
|
var import_lodash7 = require("lodash");
|
|
1590
1638
|
var import_outmatch3 = __toESM(require("outmatch"));
|
|
@@ -1646,7 +1694,7 @@ function createConfig(data) {
|
|
|
1646
1694
|
}
|
|
1647
1695
|
return {
|
|
1648
1696
|
outputFilePattern,
|
|
1649
|
-
tsConfigFilePath:
|
|
1697
|
+
tsConfigFilePath: createTsConfigFilePathValue(config.tsConfigFilePath),
|
|
1650
1698
|
combineScalarFilters: toBoolean(config.combineScalarFilters),
|
|
1651
1699
|
noAtomicOperations: toBoolean(config.noAtomicOperations),
|
|
1652
1700
|
reExport: ReExport[String(config.reExport)] || ReExport.None,
|
|
@@ -1662,6 +1710,17 @@ function createConfig(data) {
|
|
|
1662
1710
|
decorate
|
|
1663
1711
|
};
|
|
1664
1712
|
}
|
|
1713
|
+
__name(createConfig, "createConfig");
|
|
1714
|
+
var tsConfigFileExists = (0, import_lodash7.memoize)((filePath) => {
|
|
1715
|
+
return (0, import_fs2.existsSync)(filePath);
|
|
1716
|
+
});
|
|
1717
|
+
function createTsConfigFilePathValue(value) {
|
|
1718
|
+
if (typeof value === "string")
|
|
1719
|
+
return value;
|
|
1720
|
+
if (tsConfigFileExists("tsconfig.json"))
|
|
1721
|
+
return "tsconfig.json";
|
|
1722
|
+
}
|
|
1723
|
+
__name(createTsConfigFilePathValue, "createTsConfigFilePathValue");
|
|
1665
1724
|
function createUseInputType(data) {
|
|
1666
1725
|
if (!data) {
|
|
1667
1726
|
return [];
|
|
@@ -1683,6 +1742,7 @@ function createUseInputType(data) {
|
|
|
1683
1742
|
}
|
|
1684
1743
|
return result;
|
|
1685
1744
|
}
|
|
1745
|
+
__name(createUseInputType, "createUseInputType");
|
|
1686
1746
|
function toBoolean(value) {
|
|
1687
1747
|
return [
|
|
1688
1748
|
"true",
|
|
@@ -1690,6 +1750,7 @@ function toBoolean(value) {
|
|
|
1690
1750
|
"on"
|
|
1691
1751
|
].includes(String(value));
|
|
1692
1752
|
}
|
|
1753
|
+
__name(toBoolean, "toBoolean");
|
|
1693
1754
|
|
|
1694
1755
|
// src/helpers/generate-file-name.ts
|
|
1695
1756
|
var import_lodash8 = require("lodash");
|
|
@@ -1724,11 +1785,12 @@ function generateFileName(args) {
|
|
|
1724
1785
|
}
|
|
1725
1786
|
});
|
|
1726
1787
|
}
|
|
1788
|
+
__name(generateFileName, "generateFileName");
|
|
1727
1789
|
|
|
1728
1790
|
// src/helpers/factory-get-source-file.ts
|
|
1729
1791
|
function factoryGetSourceFile(args1) {
|
|
1730
1792
|
const { outputFilePattern, output, getModelName: getModelName2, project } = args1;
|
|
1731
|
-
return function getSourceFile(args) {
|
|
1793
|
+
return /* @__PURE__ */ __name(function getSourceFile(args) {
|
|
1732
1794
|
const { name, type } = args;
|
|
1733
1795
|
let filePath = generateFileName({
|
|
1734
1796
|
getModelName: getModelName2,
|
|
@@ -1740,8 +1802,9 @@ function factoryGetSourceFile(args1) {
|
|
|
1740
1802
|
return project.getSourceFile(filePath) || project.createSourceFile(filePath, void 0, {
|
|
1741
1803
|
overwrite: true
|
|
1742
1804
|
});
|
|
1743
|
-
};
|
|
1805
|
+
}, "getSourceFile");
|
|
1744
1806
|
}
|
|
1807
|
+
__name(factoryGetSourceFile, "factoryGetSourceFile");
|
|
1745
1808
|
|
|
1746
1809
|
// src/helpers/get-model-name.ts
|
|
1747
1810
|
var import_lodash9 = require("lodash");
|
|
@@ -1753,7 +1816,9 @@ function createGetModelName(modelNames) {
|
|
|
1753
1816
|
name
|
|
1754
1817
|
});
|
|
1755
1818
|
}
|
|
1819
|
+
__name(tryGetName, "tryGetName");
|
|
1756
1820
|
}
|
|
1821
|
+
__name(createGetModelName, "createGetModelName");
|
|
1757
1822
|
function getModelName(args) {
|
|
1758
1823
|
const { name, modelNames } = args;
|
|
1759
1824
|
for (const keyword of splitKeywords) {
|
|
@@ -1791,6 +1856,7 @@ function getModelName(args) {
|
|
|
1791
1856
|
}
|
|
1792
1857
|
return void 0;
|
|
1793
1858
|
}
|
|
1859
|
+
__name(getModelName, "getModelName");
|
|
1794
1860
|
var splitKeywords = [
|
|
1795
1861
|
"CreateInput",
|
|
1796
1862
|
"CreateMany",
|
|
@@ -1976,6 +2042,9 @@ async function generate(args) {
|
|
|
1976
2042
|
for (const model of datamodel.models) {
|
|
1977
2043
|
await eventEmitter.emit("Model", model, eventArguments);
|
|
1978
2044
|
}
|
|
2045
|
+
for (const model1 of datamodel.types) {
|
|
2046
|
+
await eventEmitter.emit("Model", model1, eventArguments);
|
|
2047
|
+
}
|
|
1979
2048
|
await eventEmitter.emit("PostBegin", eventArguments);
|
|
1980
2049
|
for (const enumType of enumTypes.prisma.concat(enumTypes.model || [])) {
|
|
1981
2050
|
await eventEmitter.emit("EnumType", enumType, eventArguments);
|
|
@@ -2021,6 +2090,7 @@ async function generate(args) {
|
|
|
2021
2090
|
eventEmitter.off(name);
|
|
2022
2091
|
}
|
|
2023
2092
|
}
|
|
2093
|
+
__name(generate, "generate");
|
|
2024
2094
|
|
|
2025
2095
|
// src/index.ts
|
|
2026
2096
|
(0, import_generator_helper.generatorHandler)({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-nestjs-graphql",
|
|
3
|
-
"version": "15.2.
|
|
3
|
+
"version": "15.2.3",
|
|
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",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
24
|
"test": "npm run eslint && npm run tscheck && npm run test:cov",
|
|
25
|
-
"mocha": "node node_modules/mocha/bin/
|
|
26
|
-
"test:r": "mocha -r
|
|
25
|
+
"mocha": "node node_modules/mocha/bin/mocha",
|
|
26
|
+
"test:r": "npm run mocha -- -r ts-node/register src/**/*.spec.ts",
|
|
27
27
|
"test:cov": "c8 --reporter text --exclude \"**/*.spec.ts\" --exclude \"**/test/**\" npm run test:r -- --no-timeouts",
|
|
28
|
-
"test:w": "
|
|
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",
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@nestjs/apollo": "^10.0.
|
|
55
|
-
"@prisma/generator-helper": "^3.
|
|
54
|
+
"@nestjs/apollo": "^10.0.9",
|
|
55
|
+
"@prisma/generator-helper": "^3.13.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.
|
|
60
|
+
"json5": "^2.2.1",
|
|
61
61
|
"lodash": "^4.17.21",
|
|
62
62
|
"outmatch": "^0.7.0",
|
|
63
63
|
"pluralize": "^8.0.0",
|
|
@@ -65,55 +65,55 @@
|
|
|
65
65
|
"ts-morph": ">=11"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@commitlint/cli": "^16.2.
|
|
69
|
-
"@commitlint/config-conventional": "^16.2.
|
|
70
|
-
"@nestjs/common": "^8.4.
|
|
71
|
-
"@nestjs/core": "^8.4.
|
|
72
|
-
"@nestjs/graphql": "^10.0.
|
|
73
|
-
"@nestjs/platform-express": "^8.4.
|
|
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.10",
|
|
73
|
+
"@nestjs/platform-express": "^8.4.4",
|
|
74
74
|
"@paljs/plugins": "^4.0.18",
|
|
75
|
-
"@prisma/client": "^3.
|
|
75
|
+
"@prisma/client": "^3.13.0",
|
|
76
76
|
"@semantic-release/changelog": "^6.0.1",
|
|
77
77
|
"@semantic-release/git": "^10.0.1",
|
|
78
|
-
"@swc/core": "^1.2.
|
|
79
|
-
"@swc/helpers": "^0.3.
|
|
78
|
+
"@swc/core": "^1.2.174",
|
|
79
|
+
"@swc/helpers": "^0.3.10",
|
|
80
80
|
"@swc/register": "^0.1.10",
|
|
81
81
|
"@types/flat": "^5.0.2",
|
|
82
|
-
"@types/lodash": "^4.14.
|
|
83
|
-
"@types/mocha": "^9.1.
|
|
84
|
-
"@types/node": "^17.0.
|
|
82
|
+
"@types/lodash": "^4.14.182",
|
|
83
|
+
"@types/mocha": "^9.1.1",
|
|
84
|
+
"@types/node": "^17.0.31",
|
|
85
85
|
"@types/pluralize": "^0.0.29",
|
|
86
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
87
|
-
"@typescript-eslint/parser": "^5.
|
|
88
|
-
"apollo-server-express": "^3.6.
|
|
89
|
-
"c8": "^7.11.
|
|
86
|
+
"@typescript-eslint/eslint-plugin": "^5.21.0",
|
|
87
|
+
"@typescript-eslint/parser": "^5.21.0",
|
|
88
|
+
"apollo-server-express": "^3.6.7",
|
|
89
|
+
"c8": "^7.11.2",
|
|
90
90
|
"class-transformer": "^0.5.1",
|
|
91
91
|
"class-validator": "^0.13.2",
|
|
92
92
|
"commitizen": "^4.2.4",
|
|
93
93
|
"cz-customizable": "^6.3.0",
|
|
94
94
|
"decimal.js": "^10.3.1",
|
|
95
|
-
"eslint": "^8.
|
|
95
|
+
"eslint": "^8.14.0",
|
|
96
96
|
"eslint-import-resolver-node": "^0.3.6",
|
|
97
97
|
"eslint-plugin-etc": "^2.0.2",
|
|
98
|
-
"eslint-plugin-import": "^2.
|
|
98
|
+
"eslint-plugin-import": "^2.26.0",
|
|
99
99
|
"eslint-plugin-only-warn": "^1.0.3",
|
|
100
100
|
"eslint-plugin-prettier": "^4.0.0",
|
|
101
|
-
"eslint-plugin-regexp": "^1.
|
|
101
|
+
"eslint-plugin-regexp": "^1.7.0",
|
|
102
102
|
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
103
103
|
"eslint-plugin-sort-class-members": "^1.14.1",
|
|
104
|
-
"eslint-plugin-unicorn": "^
|
|
104
|
+
"eslint-plugin-unicorn": "^42.0.0",
|
|
105
105
|
"eslint-plugin-wix-editor": "^3.3.0",
|
|
106
|
-
"expect": "^
|
|
106
|
+
"expect": "^28.0.2",
|
|
107
107
|
"ghooks": "^2.0.4",
|
|
108
108
|
"git-branch-is": "^4.0.0",
|
|
109
|
-
"graphql": "^16.
|
|
110
|
-
"graphql-scalars": "^1.
|
|
109
|
+
"graphql": "^16.4.0",
|
|
110
|
+
"graphql-scalars": "^1.17.0",
|
|
111
111
|
"graphql-type-json": "^0.3.2",
|
|
112
|
-
"mocha": "^
|
|
112
|
+
"mocha": "^10.0.0",
|
|
113
113
|
"ololog": "^1.1.175",
|
|
114
114
|
"precise-commits": "^1.0.2",
|
|
115
|
-
"prettier": "^2.6.
|
|
116
|
-
"prisma": "^3.
|
|
115
|
+
"prettier": "^2.6.2",
|
|
116
|
+
"prisma": "^3.13.0",
|
|
117
117
|
"prisma-graphql-type-decimal": "^2.0.0",
|
|
118
118
|
"reflect-metadata": "^0.1.13",
|
|
119
119
|
"request": "^2.88.2",
|
|
@@ -123,8 +123,8 @@
|
|
|
123
123
|
"temp-dir": "^2.0.0",
|
|
124
124
|
"ts-node": "^10.7.0",
|
|
125
125
|
"ts-node-dev": "^1.1.8",
|
|
126
|
-
"tslib": "^2.
|
|
127
|
-
"typescript": "^4.6.
|
|
126
|
+
"tslib": "^2.4.0",
|
|
127
|
+
"typescript": "^4.6.4",
|
|
128
128
|
"watchexec-bin": "^1.0.0"
|
|
129
129
|
}
|
|
130
130
|
}
|