prisma-nestjs-graphql 14.1.0 → 14.2.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 +36 -0
- package/index.js +193 -141
- package/package.json +17 -17
package/README.md
CHANGED
|
@@ -520,8 +520,44 @@ export class User {
|
|
|
520
520
|
}
|
|
521
521
|
```
|
|
522
522
|
|
|
523
|
+
#### @ObjectType()
|
|
524
|
+
|
|
525
|
+
Allow rename type in schema and make mark as abstract.
|
|
526
|
+
|
|
527
|
+
Example 1:
|
|
528
|
+
|
|
529
|
+
```
|
|
530
|
+
// schema.prisma
|
|
531
|
+
/// @ObjectType({ isAbstract: true })
|
|
532
|
+
model User {
|
|
533
|
+
id Int @id
|
|
534
|
+
}
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
```ts
|
|
538
|
+
@ObjectType({ isAbstract: true })
|
|
539
|
+
export class User {}
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
Example 2:
|
|
543
|
+
|
|
544
|
+
```
|
|
545
|
+
// schema.prisma
|
|
546
|
+
/// @ObjectType('Human', { isAbstract: true })
|
|
547
|
+
model User {
|
|
548
|
+
id Int @id
|
|
549
|
+
}
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
```ts
|
|
553
|
+
@ObjectType('Human', { isAbstract: true })
|
|
554
|
+
export class User {}
|
|
555
|
+
```
|
|
556
|
+
|
|
523
557
|
## Similar Projects
|
|
524
558
|
|
|
559
|
+
- https://github.com/rfermann/nestjs-prisma-graphql-generator
|
|
560
|
+
- https://github.com/madscience/graphql-codegen-nestjs
|
|
525
561
|
- https://github.com/wSedlacek/prisma-generators/tree/master/libs/nestjs
|
|
526
562
|
- https://github.com/EndyKaufman/typegraphql-prisma-nestjs
|
|
527
563
|
- https://github.com/MichalLytek/typegraphql-prisma
|
package/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
2
3
|
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
5
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
7
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
10
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
11
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -17,23 +21,35 @@ var __spreadValues = (a, b) => {
|
|
|
17
21
|
return a;
|
|
18
22
|
};
|
|
19
23
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var
|
|
21
|
-
|
|
24
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
|
+
var __reExport = (target, module2, desc) => {
|
|
26
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
27
|
+
for (let key of __getOwnPropNames(module2))
|
|
28
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
29
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
22
32
|
};
|
|
33
|
+
var __toModule = (module2) => {
|
|
34
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// ../../../../.npm/_npx/7d72304e626f8399/node_modules/tsup/assets/cjs_shims.js
|
|
38
|
+
var importMetaUrlShim = typeof document === "undefined" ? new (require("url")).URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
23
39
|
|
|
24
40
|
// src/index.ts
|
|
25
|
-
var
|
|
41
|
+
var import_generator_helper = __toModule(require("@prisma/generator-helper"));
|
|
26
42
|
|
|
27
43
|
// src/generate.ts
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var
|
|
44
|
+
var import_assert6 = __toModule(require("assert"));
|
|
45
|
+
var import_await_event_emitter = __toModule(require("await-event-emitter"));
|
|
46
|
+
var import_lodash10 = __toModule(require("lodash"));
|
|
47
|
+
var import_ts_morph9 = __toModule(require("ts-morph"));
|
|
32
48
|
|
|
33
49
|
// src/helpers/pascal-case.ts
|
|
34
|
-
|
|
50
|
+
var import_lodash = __toModule(require("lodash"));
|
|
35
51
|
function pascalCase(string) {
|
|
36
|
-
return
|
|
52
|
+
return (0, import_lodash.startCase)((0, import_lodash.camelCase)(string)).replace(/ /g, "");
|
|
37
53
|
}
|
|
38
54
|
|
|
39
55
|
// src/handlers/args-type.ts
|
|
@@ -174,15 +190,11 @@ function classProperty(property, eventArguments) {
|
|
|
174
190
|
}
|
|
175
191
|
|
|
176
192
|
// src/handlers/generate-files.ts
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
193
|
+
var import_assert = __toModule(require("assert"));
|
|
194
|
+
var import_ts_morph2 = __toModule(require("ts-morph"));
|
|
181
195
|
|
|
182
196
|
// src/helpers/import-declaration-map.ts
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
197
|
+
var import_ts_morph = __toModule(require("ts-morph"));
|
|
186
198
|
var ImportDeclarationMap = class extends Map {
|
|
187
199
|
add(name, value) {
|
|
188
200
|
if (!this.has(name)) {
|
|
@@ -218,7 +230,7 @@ var ImportDeclarationMap = class extends Map {
|
|
|
218
230
|
let result = iterator.next();
|
|
219
231
|
while (result.value) {
|
|
220
232
|
yield __spreadProps(__spreadValues({}, result.value), {
|
|
221
|
-
kind:
|
|
233
|
+
kind: import_ts_morph.StructureKind.ImportDeclaration
|
|
222
234
|
});
|
|
223
235
|
result = iterator.next();
|
|
224
236
|
}
|
|
@@ -240,13 +252,13 @@ function beforeGenerateFiles(args) {
|
|
|
240
252
|
const statements2 = s.getStructure().statements;
|
|
241
253
|
if (Array.isArray(statements2)) {
|
|
242
254
|
for (const statement of statements2) {
|
|
243
|
-
if (!(typeof statement === "object" && statement.kind ===
|
|
255
|
+
if (!(typeof statement === "object" && statement.kind === import_ts_morph2.StructureKind.Class)) {
|
|
244
256
|
continue;
|
|
245
257
|
}
|
|
246
258
|
for (const property of statement.properties || []) {
|
|
247
259
|
for (const decorator of property.decorators || []) {
|
|
248
260
|
const fullName = (_b = (_a = classDeclaration == null ? void 0 : classDeclaration.getProperty(property.name)) == null ? void 0 : _a.getDecorator(decorator.name)) == null ? void 0 : _b.getFullName();
|
|
249
|
-
|
|
261
|
+
(0, import_assert.ok)(fullName, `Cannot get full name of decorator of class ${statement.name}`);
|
|
250
262
|
decorator.name = fullName;
|
|
251
263
|
}
|
|
252
264
|
}
|
|
@@ -266,7 +278,7 @@ function beforeGenerateFiles(args) {
|
|
|
266
278
|
continue;
|
|
267
279
|
}
|
|
268
280
|
switch (statement.kind) {
|
|
269
|
-
case
|
|
281
|
+
case import_ts_morph2.StructureKind.ImportDeclaration:
|
|
270
282
|
if (statement.moduleSpecifier.startsWith("./") || statement.moduleSpecifier.startsWith("..")) {
|
|
271
283
|
continue;
|
|
272
284
|
}
|
|
@@ -289,16 +301,16 @@ function beforeGenerateFiles(args) {
|
|
|
289
301
|
});
|
|
290
302
|
}
|
|
291
303
|
break;
|
|
292
|
-
case
|
|
304
|
+
case import_ts_morph2.StructureKind.Enum:
|
|
293
305
|
enums.unshift(statement);
|
|
294
306
|
break;
|
|
295
|
-
case
|
|
307
|
+
case import_ts_morph2.StructureKind.Class:
|
|
296
308
|
classes.push(statement);
|
|
297
309
|
break;
|
|
298
310
|
}
|
|
299
311
|
}
|
|
300
312
|
sourceFile.set({
|
|
301
|
-
kind:
|
|
313
|
+
kind: import_ts_morph2.StructureKind.SourceFile,
|
|
302
314
|
statements: [...imports.toStatements(), ...enums, ...classes]
|
|
303
315
|
});
|
|
304
316
|
}
|
|
@@ -325,11 +337,11 @@ async function generateFiles(args) {
|
|
|
325
337
|
}
|
|
326
338
|
|
|
327
339
|
// src/handlers/input-type.ts
|
|
328
|
-
|
|
329
|
-
var
|
|
330
|
-
|
|
331
|
-
var
|
|
332
|
-
|
|
340
|
+
var import_assert2 = __toModule(require("assert"));
|
|
341
|
+
var import_json5 = __toModule(require("json5"));
|
|
342
|
+
var import_lodash3 = __toModule(require("lodash"));
|
|
343
|
+
var import_pupa = __toModule(require("pupa"));
|
|
344
|
+
var import_ts_morph4 = __toModule(require("ts-morph"));
|
|
333
345
|
|
|
334
346
|
// src/helpers/file-type-by-location.ts
|
|
335
347
|
function fileTypeByLocation(fieldLocation) {
|
|
@@ -345,7 +357,7 @@ function fileTypeByLocation(fieldLocation) {
|
|
|
345
357
|
}
|
|
346
358
|
|
|
347
359
|
// src/helpers/relative-path.ts
|
|
348
|
-
var
|
|
360
|
+
var import_get_relative_path = __toModule(require("get-relative-path"));
|
|
349
361
|
function relativePath(from, to) {
|
|
350
362
|
if (!from.startsWith("/")) {
|
|
351
363
|
from = `/${from}`;
|
|
@@ -353,7 +365,7 @@ function relativePath(from, to) {
|
|
|
353
365
|
if (!to.startsWith("/")) {
|
|
354
366
|
to = `/${to}`;
|
|
355
367
|
}
|
|
356
|
-
let result =
|
|
368
|
+
let result = (0, import_get_relative_path.default)(from, to);
|
|
357
369
|
if (!result.startsWith(".")) {
|
|
358
370
|
result = `./${result}`;
|
|
359
371
|
}
|
|
@@ -401,15 +413,15 @@ function getGraphqlImport(args) {
|
|
|
401
413
|
}
|
|
402
414
|
|
|
403
415
|
// src/helpers/get-graphql-input-type.ts
|
|
404
|
-
|
|
405
|
-
var
|
|
416
|
+
var import_lodash2 = __toModule(require("lodash"));
|
|
417
|
+
var import_outmatch = __toModule(require("outmatch"));
|
|
406
418
|
function getGraphqlInputType(inputTypes, pattern) {
|
|
407
419
|
let result;
|
|
408
420
|
inputTypes = inputTypes.filter((t) => !["null", "Null"].includes(String(t.type)));
|
|
409
421
|
if (inputTypes.length === 1) {
|
|
410
422
|
return inputTypes[0];
|
|
411
423
|
}
|
|
412
|
-
const countTypes =
|
|
424
|
+
const countTypes = (0, import_lodash2.countBy)(inputTypes, (x) => x.location);
|
|
413
425
|
const isOneType = Object.keys(countTypes).length === 1;
|
|
414
426
|
if (isOneType) {
|
|
415
427
|
result = inputTypes.find((x) => x.isList);
|
|
@@ -420,7 +432,7 @@ function getGraphqlInputType(inputTypes, pattern) {
|
|
|
420
432
|
if (pattern) {
|
|
421
433
|
if (pattern.startsWith("matcher:") || pattern.startsWith("match:")) {
|
|
422
434
|
const { 1: patternValue } = pattern.split(":", 2);
|
|
423
|
-
const isMatch =
|
|
435
|
+
const isMatch = (0, import_outmatch.default)(patternValue, { separator: false });
|
|
424
436
|
result = inputTypes.find((x) => isMatch(String(x.type)));
|
|
425
437
|
if (result) {
|
|
426
438
|
return result;
|
|
@@ -480,7 +492,7 @@ function getPropertyType(args) {
|
|
|
480
492
|
}
|
|
481
493
|
|
|
482
494
|
// src/helpers/property-structure.ts
|
|
483
|
-
|
|
495
|
+
var import_ts_morph3 = __toModule(require("ts-morph"));
|
|
484
496
|
function propertyStructure(args) {
|
|
485
497
|
const {
|
|
486
498
|
isNullable,
|
|
@@ -492,7 +504,7 @@ function propertyStructure(args) {
|
|
|
492
504
|
} = args;
|
|
493
505
|
const type = propertyType.map((type2) => isList ? `Array<${type2}>` : type2).join(" | ");
|
|
494
506
|
return {
|
|
495
|
-
kind:
|
|
507
|
+
kind: import_ts_morph3.StructureKind.Property,
|
|
496
508
|
name,
|
|
497
509
|
type,
|
|
498
510
|
hasQuestionToken: hasQuestionToken != null ? hasQuestionToken : isNullable,
|
|
@@ -525,7 +537,7 @@ function inputType(args) {
|
|
|
525
537
|
type: fileType
|
|
526
538
|
});
|
|
527
539
|
const classStructure = {
|
|
528
|
-
kind:
|
|
540
|
+
kind: import_ts_morph4.StructureKind.Class,
|
|
529
541
|
isExported: true,
|
|
530
542
|
name: inputType2.name,
|
|
531
543
|
decorators: [
|
|
@@ -559,7 +571,7 @@ function inputType(args) {
|
|
|
559
571
|
const settings = modelFieldSettings == null ? void 0 : modelFieldSettings.get(name);
|
|
560
572
|
const propertySettings = settings == null ? void 0 : settings.getPropertyType();
|
|
561
573
|
const isCustomsApplicable = typeName === ((_a = model == null ? void 0 : model.fields.find((f) => f.name === name)) == null ? void 0 : _a.type);
|
|
562
|
-
const propertyType =
|
|
574
|
+
const propertyType = (0, import_lodash3.castArray)((propertySettings == null ? void 0 : propertySettings.name) || getPropertyType({
|
|
563
575
|
location,
|
|
564
576
|
type: typeName
|
|
565
577
|
}));
|
|
@@ -597,12 +609,12 @@ function inputType(args) {
|
|
|
597
609
|
importDeclarations.add("HideField", "@nestjs/graphql");
|
|
598
610
|
(_c = property.decorators) == null ? void 0 : _c.push({ name: "HideField", arguments: [] });
|
|
599
611
|
} else {
|
|
600
|
-
|
|
612
|
+
(0, import_assert2.ok)(property.decorators);
|
|
601
613
|
property.decorators.push({
|
|
602
614
|
name: "Field",
|
|
603
615
|
arguments: [
|
|
604
616
|
`() => ${isList ? `[${graphqlType}]` : graphqlType}`,
|
|
605
|
-
|
|
617
|
+
import_json5.default.stringify({
|
|
606
618
|
nullable: !isRequired
|
|
607
619
|
})
|
|
608
620
|
]
|
|
@@ -616,7 +628,7 @@ function inputType(args) {
|
|
|
616
628
|
name: options.name,
|
|
617
629
|
arguments: options.arguments
|
|
618
630
|
});
|
|
619
|
-
|
|
631
|
+
(0, import_assert2.ok)(options.from, "Missed 'from' part in configuration or field setting");
|
|
620
632
|
importDeclarations.create(options);
|
|
621
633
|
}
|
|
622
634
|
}
|
|
@@ -624,7 +636,7 @@ function inputType(args) {
|
|
|
624
636
|
if (decorate.isMatchField(name) && decorate.isMatchType(inputType2.name)) {
|
|
625
637
|
property.decorators.push({
|
|
626
638
|
name: decorate.name,
|
|
627
|
-
arguments: (_d = decorate.arguments) == null ? void 0 : _d.map((x) =>
|
|
639
|
+
arguments: (_d = decorate.arguments) == null ? void 0 : _d.map((x) => (0, import_pupa.default)(x, { propertyType }))
|
|
628
640
|
});
|
|
629
641
|
importDeclarations.create(decorate);
|
|
630
642
|
}
|
|
@@ -637,11 +649,11 @@ function inputType(args) {
|
|
|
637
649
|
});
|
|
638
650
|
}
|
|
639
651
|
|
|
640
|
-
// src/helpers/
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
var
|
|
652
|
+
// src/helpers/object-settings.ts
|
|
653
|
+
var import_json52 = __toModule(require("json5"));
|
|
654
|
+
var import_lodash4 = __toModule(require("lodash"));
|
|
655
|
+
var import_outmatch2 = __toModule(require("outmatch"));
|
|
656
|
+
var ObjectSettings = class extends Array {
|
|
645
657
|
shouldHideField({
|
|
646
658
|
name,
|
|
647
659
|
input = false,
|
|
@@ -657,11 +669,24 @@ var FieldSettings = class extends Array {
|
|
|
657
669
|
getPropertyType() {
|
|
658
670
|
return this.find((s) => s.kind === "PropertyType");
|
|
659
671
|
}
|
|
672
|
+
getObjectTypeArguments(options) {
|
|
673
|
+
const objectTypeOptions = (0, import_lodash4.merge)({}, options);
|
|
674
|
+
const resultArguments = [objectTypeOptions];
|
|
675
|
+
const objectType = this.find((s) => s.kind === "ObjectType");
|
|
676
|
+
if (objectType && (0, import_lodash4.isObject)(objectType.arguments)) {
|
|
677
|
+
const name = objectType.arguments.name;
|
|
678
|
+
(0, import_lodash4.merge)(objectTypeOptions, (0, import_lodash4.omit)(objectType.arguments, "name"));
|
|
679
|
+
if (name) {
|
|
680
|
+
resultArguments.unshift(name);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
return resultArguments.map((x) => import_json52.default.stringify(x));
|
|
684
|
+
}
|
|
660
685
|
};
|
|
661
|
-
function
|
|
662
|
-
var _a, _b, _c;
|
|
686
|
+
function createObjectSettings(args) {
|
|
687
|
+
var _a, _b, _c, _d;
|
|
663
688
|
const { config, text } = args;
|
|
664
|
-
const result = new
|
|
689
|
+
const result = new ObjectSettings();
|
|
665
690
|
const textLines = text.split("\n");
|
|
666
691
|
const documentationLines = [];
|
|
667
692
|
for (const line of textLines) {
|
|
@@ -671,7 +696,7 @@ function createFieldSettings(args) {
|
|
|
671
696
|
documentationLines.push(line);
|
|
672
697
|
continue;
|
|
673
698
|
}
|
|
674
|
-
const
|
|
699
|
+
const element = {
|
|
675
700
|
kind: "Decorator",
|
|
676
701
|
name: "",
|
|
677
702
|
arguments: [],
|
|
@@ -680,27 +705,44 @@ function createFieldSettings(args) {
|
|
|
680
705
|
from: ""
|
|
681
706
|
};
|
|
682
707
|
if (name === "TypeGraphQL.omit" || name === "HideField") {
|
|
683
|
-
Object.assign(
|
|
708
|
+
Object.assign(element, hideFieldDecorator(match));
|
|
684
709
|
} else if (["FieldType", "PropertyType"].includes(name) && ((_b = match.groups) == null ? void 0 : _b.args)) {
|
|
685
710
|
const options = customType(match.groups.args);
|
|
686
|
-
|
|
711
|
+
(0, import_lodash4.merge)(element, options.namespace && config.fields[options.namespace], options, { kind: name });
|
|
712
|
+
} else if (name === "IsAbstract") {
|
|
713
|
+
element.kind = "ObjectType";
|
|
714
|
+
element.arguments = { isAbstract: true };
|
|
715
|
+
} else if (name === "ObjectType" && ((_c = match.groups) == null ? void 0 : _c.args)) {
|
|
716
|
+
element.kind = "ObjectType";
|
|
717
|
+
const options = customType(match.groups.args);
|
|
718
|
+
if (typeof options[0] === "string" && options[0]) {
|
|
719
|
+
options.name = options[0];
|
|
720
|
+
}
|
|
721
|
+
if ((0, import_lodash4.isObject)(options[1])) {
|
|
722
|
+
(0, import_lodash4.merge)(options, options[1]);
|
|
723
|
+
}
|
|
724
|
+
element.arguments = {
|
|
725
|
+
name: options.name,
|
|
726
|
+
isAbstract: options.isAbstract
|
|
727
|
+
};
|
|
687
728
|
} else {
|
|
688
729
|
const namespace = getNamespace(name);
|
|
689
|
-
|
|
730
|
+
element.namespaceImport = namespace;
|
|
690
731
|
const options = {
|
|
691
732
|
name,
|
|
692
|
-
arguments: (((
|
|
733
|
+
arguments: (((_d = match.groups) == null ? void 0 : _d.args) || "").split(",").map((s) => (0, import_lodash4.trim)(s)).filter(Boolean)
|
|
693
734
|
};
|
|
694
|
-
|
|
735
|
+
(0, import_lodash4.merge)(element, config.fields[namespace], options);
|
|
695
736
|
}
|
|
696
|
-
result.push(
|
|
737
|
+
result.push(element);
|
|
697
738
|
}
|
|
698
739
|
return {
|
|
699
|
-
result,
|
|
740
|
+
settings: result,
|
|
700
741
|
documentation: documentationLines.filter(Boolean).join("\\n") || void 0
|
|
701
742
|
};
|
|
702
743
|
}
|
|
703
744
|
function customType(args) {
|
|
745
|
+
var _a;
|
|
704
746
|
const result = {};
|
|
705
747
|
let options = parseArgs(args);
|
|
706
748
|
if (typeof options === "string") {
|
|
@@ -709,7 +751,7 @@ function customType(args) {
|
|
|
709
751
|
Object.assign(result, options);
|
|
710
752
|
const namespace = getNamespace(options.name);
|
|
711
753
|
result.namespace = namespace;
|
|
712
|
-
if (options.name.includes(".")) {
|
|
754
|
+
if ((_a = options.name) == null ? void 0 : _a.includes(".")) {
|
|
713
755
|
result.namespaceImport = namespace;
|
|
714
756
|
}
|
|
715
757
|
return result;
|
|
@@ -733,7 +775,7 @@ function hideFieldDecorator(match) {
|
|
|
733
775
|
result.output = Boolean(options.output);
|
|
734
776
|
result.input = Boolean(options.input);
|
|
735
777
|
if (typeof options.match === "string" || Array.isArray(options.match)) {
|
|
736
|
-
result.match =
|
|
778
|
+
result.match = (0, import_outmatch2.default)(options.match, { separator: false });
|
|
737
779
|
}
|
|
738
780
|
} else {
|
|
739
781
|
if (/output:\s*true/.test(match.groups.args)) {
|
|
@@ -747,9 +789,13 @@ function hideFieldDecorator(match) {
|
|
|
747
789
|
}
|
|
748
790
|
function parseArgs(string) {
|
|
749
791
|
try {
|
|
750
|
-
return
|
|
792
|
+
return import_json52.default.parse(string);
|
|
751
793
|
} catch (e) {
|
|
752
|
-
|
|
794
|
+
try {
|
|
795
|
+
return import_json52.default.parse(`[${string}]`);
|
|
796
|
+
} catch (e2) {
|
|
797
|
+
throw new Error(`Failed to parse: ${string}`);
|
|
798
|
+
}
|
|
753
799
|
}
|
|
754
800
|
}
|
|
755
801
|
function getNamespace(name) {
|
|
@@ -771,25 +817,23 @@ function modelData(model, args) {
|
|
|
771
817
|
fieldSettings.set(model.name, fieldSettingsValue);
|
|
772
818
|
for (const field of model.fields) {
|
|
773
819
|
if (field.documentation) {
|
|
774
|
-
const { documentation,
|
|
820
|
+
const { documentation, settings } = createObjectSettings({
|
|
775
821
|
text: field.documentation,
|
|
776
822
|
config
|
|
777
823
|
});
|
|
778
824
|
field.documentation = documentation;
|
|
779
|
-
fieldSettingsValue.set(field.name,
|
|
825
|
+
fieldSettingsValue.set(field.name, settings);
|
|
780
826
|
}
|
|
781
827
|
modelFieldsValue.set(field.name, field);
|
|
782
828
|
}
|
|
783
829
|
}
|
|
784
830
|
|
|
785
831
|
// src/handlers/model-output-type.ts
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
832
|
+
var import_assert3 = __toModule(require("assert"));
|
|
833
|
+
var import_json53 = __toModule(require("json5"));
|
|
834
|
+
var import_lodash5 = __toModule(require("lodash"));
|
|
835
|
+
var import_pupa2 = __toModule(require("pupa"));
|
|
836
|
+
var import_ts_morph5 = __toModule(require("ts-morph"));
|
|
793
837
|
|
|
794
838
|
// src/helpers/get-output-type-name.ts
|
|
795
839
|
function getOutputTypeName(name) {
|
|
@@ -799,10 +843,10 @@ function getOutputTypeName(name) {
|
|
|
799
843
|
// src/handlers/model-output-type.ts
|
|
800
844
|
var nestjsGraphql = "@nestjs/graphql";
|
|
801
845
|
function modelOutputType(outputType2, args) {
|
|
802
|
-
var _a, _b, _c, _d, _e
|
|
846
|
+
var _a, _b, _c, _d, _e;
|
|
803
847
|
const { getSourceFile, models, config, modelFields, fieldSettings, eventEmitter } = args;
|
|
804
848
|
const model = models.get(outputType2.name);
|
|
805
|
-
|
|
849
|
+
(0, import_assert3.ok)(model, `Cannot find model by name ${outputType2.name}`);
|
|
806
850
|
const sourceFile = getSourceFile({
|
|
807
851
|
name: outputType2.name,
|
|
808
852
|
type: "model"
|
|
@@ -811,7 +855,7 @@ function modelOutputType(outputType2, args) {
|
|
|
811
855
|
const exportDeclaration = getExportDeclaration(model.name, sourceFileStructure.statements);
|
|
812
856
|
const importDeclarations = new ImportDeclarationMap();
|
|
813
857
|
const classStructure = {
|
|
814
|
-
kind:
|
|
858
|
+
kind: import_ts_morph5.StructureKind.Class,
|
|
815
859
|
isExported: true,
|
|
816
860
|
name: outputType2.name,
|
|
817
861
|
decorators: [
|
|
@@ -824,18 +868,22 @@ function modelOutputType(outputType2, args) {
|
|
|
824
868
|
};
|
|
825
869
|
sourceFileStructure.statements.push(classStructure);
|
|
826
870
|
const decorator = (_a = classStructure.decorators) == null ? void 0 : _a.find((d) => d.name === "ObjectType");
|
|
827
|
-
|
|
828
|
-
const decoratorArgument = ((_b = decorator.arguments) == null ? void 0 : _b[0]) ? _json52.default.parse(decorator.arguments[0]) : {};
|
|
871
|
+
(0, import_assert3.ok)(decorator, "ObjectType decorator not found");
|
|
829
872
|
if (model.documentation) {
|
|
830
|
-
|
|
831
|
-
|
|
873
|
+
const objectTypeOptions = {};
|
|
874
|
+
const { documentation, settings } = createObjectSettings({
|
|
875
|
+
text: model.documentation,
|
|
876
|
+
config
|
|
877
|
+
});
|
|
878
|
+
if (documentation) {
|
|
879
|
+
if (!classStructure.leadingTrivia) {
|
|
880
|
+
classStructure.leadingTrivia = `/** ${documentation} */
|
|
832
881
|
`;
|
|
882
|
+
}
|
|
883
|
+
objectTypeOptions.description = documentation;
|
|
833
884
|
}
|
|
834
|
-
|
|
835
|
-
} else {
|
|
836
|
-
delete decoratorArgument.description;
|
|
885
|
+
decorator.arguments = settings.getObjectTypeArguments(objectTypeOptions);
|
|
837
886
|
}
|
|
838
|
-
decorator.arguments = Object.keys(decoratorArgument).length > 0 ? [_json52.default.stringify(decoratorArgument)] : [];
|
|
839
887
|
importDeclarations.add("Field", nestjsGraphql);
|
|
840
888
|
importDeclarations.add("ObjectType", nestjsGraphql);
|
|
841
889
|
for (const field of outputType2.fields) {
|
|
@@ -846,11 +894,11 @@ function modelOutputType(outputType2, args) {
|
|
|
846
894
|
fileType = "output";
|
|
847
895
|
outputTypeName = getOutputTypeName(outputTypeName);
|
|
848
896
|
}
|
|
849
|
-
const modelField = (
|
|
850
|
-
const settings = (
|
|
897
|
+
const modelField = (_b = modelFields.get(model.name)) == null ? void 0 : _b.get(field.name);
|
|
898
|
+
const settings = (_c = fieldSettings.get(model.name)) == null ? void 0 : _c.get(field.name);
|
|
851
899
|
const fieldType = settings == null ? void 0 : settings.getFieldType();
|
|
852
900
|
const propertySettings = settings == null ? void 0 : settings.getPropertyType();
|
|
853
|
-
const propertyType =
|
|
901
|
+
const propertyType = (0, import_lodash5.castArray)((propertySettings == null ? void 0 : propertySettings.name) || getPropertyType({
|
|
854
902
|
location,
|
|
855
903
|
type: outputTypeName
|
|
856
904
|
}));
|
|
@@ -889,20 +937,20 @@ function modelOutputType(outputType2, args) {
|
|
|
889
937
|
property.leadingTrivia += `/** ${modelField.documentation} */
|
|
890
938
|
`;
|
|
891
939
|
}
|
|
892
|
-
|
|
940
|
+
classStructure.properties.push(property);
|
|
893
941
|
if (propertySettings) {
|
|
894
942
|
importDeclarations.create(__spreadValues({}, propertySettings));
|
|
895
943
|
}
|
|
896
944
|
if (settings == null ? void 0 : settings.shouldHideField({ name: outputType2.name, output: true })) {
|
|
897
945
|
importDeclarations.add("HideField", nestjsGraphql);
|
|
898
|
-
(
|
|
946
|
+
(_d = property.decorators) == null ? void 0 : _d.push({ name: "HideField", arguments: [] });
|
|
899
947
|
} else {
|
|
900
|
-
|
|
948
|
+
(0, import_assert3.ok)(property.decorators);
|
|
901
949
|
property.decorators.push({
|
|
902
950
|
name: "Field",
|
|
903
951
|
arguments: [
|
|
904
952
|
`() => ${isList ? `[${graphqlType}]` : graphqlType}`,
|
|
905
|
-
|
|
953
|
+
import_json53.default.stringify({
|
|
906
954
|
nullable: Boolean(field.isNullable),
|
|
907
955
|
defaultValue: ["number", "string", "boolean"].includes(typeof (modelField == null ? void 0 : modelField.default)) ? modelField == null ? void 0 : modelField.default : void 0,
|
|
908
956
|
description: modelField == null ? void 0 : modelField.documentation
|
|
@@ -917,14 +965,14 @@ function modelOutputType(outputType2, args) {
|
|
|
917
965
|
name: options.name,
|
|
918
966
|
arguments: options.arguments
|
|
919
967
|
});
|
|
920
|
-
|
|
968
|
+
(0, import_assert3.ok)(options.from, "Missed 'from' part in configuration or field setting");
|
|
921
969
|
importDeclarations.create(options);
|
|
922
970
|
}
|
|
923
971
|
for (const decorate of config.decorate) {
|
|
924
972
|
if (decorate.isMatchField(field.name) && decorate.isMatchType(outputTypeName)) {
|
|
925
973
|
property.decorators.push({
|
|
926
974
|
name: decorate.name,
|
|
927
|
-
arguments: (
|
|
975
|
+
arguments: (_e = decorate.arguments) == null ? void 0 : _e.map((x) => (0, import_pupa2.default)(x, { propertyType }))
|
|
928
976
|
});
|
|
929
977
|
importDeclarations.create(decorate);
|
|
930
978
|
}
|
|
@@ -948,7 +996,7 @@ function modelOutputType(outputType2, args) {
|
|
|
948
996
|
}
|
|
949
997
|
function getExportDeclaration(name, statements) {
|
|
950
998
|
return statements.find((structure) => {
|
|
951
|
-
return structure.kind ===
|
|
999
|
+
return structure.kind === import_ts_morph5.StructureKind.ExportDeclaration && structure.namedExports.some((o) => (o.alias || o.name) === name);
|
|
952
1000
|
});
|
|
953
1001
|
}
|
|
954
1002
|
|
|
@@ -983,13 +1031,13 @@ function isAtomicOperation(name) {
|
|
|
983
1031
|
}
|
|
984
1032
|
|
|
985
1033
|
// src/handlers/output-type.ts
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
1034
|
+
var import_assert4 = __toModule(require("assert"));
|
|
1035
|
+
var import_json54 = __toModule(require("json5"));
|
|
1036
|
+
var import_lodash6 = __toModule(require("lodash"));
|
|
1037
|
+
var import_ts_morph6 = __toModule(require("ts-morph"));
|
|
990
1038
|
var nestjsGraphql2 = "@nestjs/graphql";
|
|
991
1039
|
function outputType(outputType2, args) {
|
|
992
|
-
var _a, _b, _c, _d
|
|
1040
|
+
var _a, _b, _c, _d;
|
|
993
1041
|
const { getSourceFile, models, config, eventEmitter, fieldSettings, getModelName: getModelName2 } = args;
|
|
994
1042
|
const importDeclarations = new ImportDeclarationMap();
|
|
995
1043
|
const fileType = "output";
|
|
@@ -1006,7 +1054,7 @@ function outputType(outputType2, args) {
|
|
|
1006
1054
|
type: fileType
|
|
1007
1055
|
});
|
|
1008
1056
|
const classStructure = {
|
|
1009
|
-
kind:
|
|
1057
|
+
kind: import_ts_morph6.StructureKind.Class,
|
|
1010
1058
|
isExported: true,
|
|
1011
1059
|
name: outputType2.name,
|
|
1012
1060
|
decorators: [
|
|
@@ -1026,7 +1074,7 @@ function outputType(outputType2, args) {
|
|
|
1026
1074
|
const propertySettings = settings == null ? void 0 : settings.getPropertyType();
|
|
1027
1075
|
const isCustomsApplicable = outputTypeName === ((_b = model == null ? void 0 : model.fields.find((f) => f.name === field.name)) == null ? void 0 : _b.type);
|
|
1028
1076
|
field.outputType.type = outputTypeName;
|
|
1029
|
-
const propertyType =
|
|
1077
|
+
const propertyType = (0, import_lodash6.castArray)((propertySettings == null ? void 0 : propertySettings.name) || getPropertyType({
|
|
1030
1078
|
location,
|
|
1031
1079
|
type: outputTypeName
|
|
1032
1080
|
}));
|
|
@@ -1056,11 +1104,12 @@ function outputType(outputType2, args) {
|
|
|
1056
1104
|
importDeclarations.add("HideField", nestjsGraphql2);
|
|
1057
1105
|
(_d = property.decorators) == null ? void 0 : _d.push({ name: "HideField", arguments: [] });
|
|
1058
1106
|
} else {
|
|
1059
|
-
(
|
|
1107
|
+
(0, import_assert4.ok)(property.decorators, "Missing property.decorators");
|
|
1108
|
+
property.decorators.push({
|
|
1060
1109
|
name: "Field",
|
|
1061
1110
|
arguments: [
|
|
1062
1111
|
`() => ${isList ? `[${graphqlType}]` : graphqlType}`,
|
|
1063
|
-
|
|
1112
|
+
import_json54.default.stringify({
|
|
1064
1113
|
nullable: Boolean(field.isNullable)
|
|
1065
1114
|
})
|
|
1066
1115
|
]
|
|
@@ -1070,11 +1119,11 @@ function outputType(outputType2, args) {
|
|
|
1070
1119
|
if (!options.output || options.kind !== "Decorator") {
|
|
1071
1120
|
continue;
|
|
1072
1121
|
}
|
|
1073
|
-
|
|
1122
|
+
property.decorators.push({
|
|
1074
1123
|
name: options.name,
|
|
1075
1124
|
arguments: options.arguments
|
|
1076
1125
|
});
|
|
1077
|
-
|
|
1126
|
+
(0, import_assert4.ok)(options.from, "Missed 'from' part in configuration or field setting");
|
|
1078
1127
|
importDeclarations.create(options);
|
|
1079
1128
|
}
|
|
1080
1129
|
}
|
|
@@ -1087,7 +1136,7 @@ function outputType(outputType2, args) {
|
|
|
1087
1136
|
}
|
|
1088
1137
|
|
|
1089
1138
|
// src/handlers/purge-output.ts
|
|
1090
|
-
var
|
|
1139
|
+
var import_fs = __toModule(require("fs"));
|
|
1091
1140
|
function purgeOutput(emitter) {
|
|
1092
1141
|
emitter.on("Begin", begin);
|
|
1093
1142
|
emitter.on("End", end);
|
|
@@ -1106,16 +1155,14 @@ async function end({ project, output }) {
|
|
|
1106
1155
|
const directories = (_a = project.getDirectory(output)) == null ? void 0 : _a.getDescendantDirectories().filter((directory) => directory.getSourceFiles().length === 0).map((directory) => directory.getPath());
|
|
1107
1156
|
for (const directory of directories || []) {
|
|
1108
1157
|
try {
|
|
1109
|
-
await
|
|
1158
|
+
await import_fs.promises.rmdir(directory);
|
|
1110
1159
|
} catch (e) {
|
|
1111
1160
|
}
|
|
1112
1161
|
}
|
|
1113
1162
|
}
|
|
1114
1163
|
|
|
1115
1164
|
// src/handlers/re-export.ts
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1165
|
+
var import_ts_morph7 = __toModule(require("ts-morph"));
|
|
1119
1166
|
var ReExport;
|
|
1120
1167
|
(function(ReExport2) {
|
|
1121
1168
|
ReExport2["None"] = "None";
|
|
@@ -1166,14 +1213,14 @@ function beforeGenerateFiles3(args) {
|
|
|
1166
1213
|
}
|
|
1167
1214
|
function getExportDeclaration2(directory, sourceFile) {
|
|
1168
1215
|
return {
|
|
1169
|
-
kind:
|
|
1216
|
+
kind: import_ts_morph7.StructureKind.ExportDeclaration,
|
|
1170
1217
|
namedExports: sourceFile.getExportSymbols().map((s) => ({ name: s.getName() })),
|
|
1171
1218
|
moduleSpecifier: directory.getRelativePathAsModuleSpecifierTo(sourceFile)
|
|
1172
1219
|
};
|
|
1173
1220
|
}
|
|
1174
1221
|
|
|
1175
1222
|
// src/handlers/register-enum.ts
|
|
1176
|
-
|
|
1223
|
+
var import_ts_morph8 = __toModule(require("ts-morph"));
|
|
1177
1224
|
function registerEnum(enumType, args) {
|
|
1178
1225
|
const { getSourceFile, enums } = args;
|
|
1179
1226
|
const dataModelEnum = enums[enumType.name];
|
|
@@ -1187,7 +1234,7 @@ function registerEnum(enumType, args) {
|
|
|
1187
1234
|
moduleSpecifier: "@nestjs/graphql"
|
|
1188
1235
|
});
|
|
1189
1236
|
const enumStructure = {
|
|
1190
|
-
kind:
|
|
1237
|
+
kind: import_ts_morph8.StructureKind.Enum,
|
|
1191
1238
|
isExported: true,
|
|
1192
1239
|
name: enumType.name,
|
|
1193
1240
|
members: enumType.values.map((v) => ({
|
|
@@ -1216,21 +1263,21 @@ function warning(message) {
|
|
|
1216
1263
|
}
|
|
1217
1264
|
|
|
1218
1265
|
// src/helpers/create-config.ts
|
|
1219
|
-
|
|
1220
|
-
var
|
|
1221
|
-
var
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1266
|
+
var import_assert5 = __toModule(require("assert"));
|
|
1267
|
+
var import_filenamify = __toModule(require("filenamify"));
|
|
1268
|
+
var import_flat = __toModule(require("flat"));
|
|
1269
|
+
var import_json55 = __toModule(require("json5"));
|
|
1270
|
+
var import_lodash7 = __toModule(require("lodash"));
|
|
1271
|
+
var import_outmatch3 = __toModule(require("outmatch"));
|
|
1225
1272
|
function createConfig(data) {
|
|
1226
1273
|
var _a;
|
|
1227
|
-
const config =
|
|
1274
|
+
const config = (0, import_lodash7.merge)({}, (0, import_flat.unflatten)(data, { delimiter: "_" }));
|
|
1228
1275
|
const $warnings = [];
|
|
1229
1276
|
const configOutputFilePattern = String(config.outputFilePattern || `{model}/{name}.{type}.ts`);
|
|
1230
|
-
let outputFilePattern =
|
|
1277
|
+
let outputFilePattern = (0, import_filenamify.default)(configOutputFilePattern, {
|
|
1231
1278
|
replacement: "/"
|
|
1232
1279
|
}).replace(/\.\./g, "/").replace(/\/+/g, "/");
|
|
1233
|
-
outputFilePattern =
|
|
1280
|
+
outputFilePattern = (0, import_lodash7.trim)(outputFilePattern, "/");
|
|
1234
1281
|
if (outputFilePattern !== configOutputFilePattern) {
|
|
1235
1282
|
$warnings.push(`Due to invalid filepath 'outputFilePattern' changed to '${outputFilePattern}'`);
|
|
1236
1283
|
}
|
|
@@ -1256,16 +1303,16 @@ function createConfig(data) {
|
|
|
1256
1303
|
for (const element of configDecorate) {
|
|
1257
1304
|
if (!element)
|
|
1258
1305
|
continue;
|
|
1259
|
-
|
|
1306
|
+
(0, import_assert5.ok)(element.from && element.name, `Missed 'from' or 'name' part in configuration for decorate`);
|
|
1260
1307
|
decorate.push({
|
|
1261
|
-
isMatchField:
|
|
1262
|
-
isMatchType:
|
|
1308
|
+
isMatchField: (0, import_outmatch3.default)(element.field, { separator: false }),
|
|
1309
|
+
isMatchType: (0, import_outmatch3.default)(element.type, { separator: false }),
|
|
1263
1310
|
from: element.from,
|
|
1264
1311
|
name: element.name,
|
|
1265
1312
|
namedImport: toBoolean(element.namedImport),
|
|
1266
1313
|
defaultImport: toBoolean(element.defaultImport) ? true : element.defaultImport,
|
|
1267
1314
|
namespaceImport: element.namespaceImport,
|
|
1268
|
-
arguments: element.arguments ?
|
|
1315
|
+
arguments: element.arguments ? import_json55.default.parse(element.arguments) : void 0
|
|
1269
1316
|
});
|
|
1270
1317
|
}
|
|
1271
1318
|
return {
|
|
@@ -1310,19 +1357,19 @@ function toBoolean(value) {
|
|
|
1310
1357
|
}
|
|
1311
1358
|
|
|
1312
1359
|
// src/helpers/generate-file-name.ts
|
|
1313
|
-
|
|
1314
|
-
var
|
|
1315
|
-
|
|
1360
|
+
var import_lodash8 = __toModule(require("lodash"));
|
|
1361
|
+
var import_pluralize = __toModule(require("pluralize"));
|
|
1362
|
+
var import_pupa3 = __toModule(require("pupa"));
|
|
1316
1363
|
function generateFileName(args) {
|
|
1317
1364
|
const { template, type, name, getModelName: getModelName2 } = args;
|
|
1318
|
-
return
|
|
1365
|
+
return (0, import_pupa3.default)(template, {
|
|
1319
1366
|
type,
|
|
1320
1367
|
get model() {
|
|
1321
1368
|
const result = getModelName2(name) || "prisma";
|
|
1322
|
-
return
|
|
1369
|
+
return (0, import_lodash8.kebabCase)(result);
|
|
1323
1370
|
},
|
|
1324
1371
|
get name() {
|
|
1325
|
-
let result =
|
|
1372
|
+
let result = (0, import_lodash8.kebabCase)(name);
|
|
1326
1373
|
for (const suffix of ["input", "args", "enum"]) {
|
|
1327
1374
|
const ending = `-${suffix}`;
|
|
1328
1375
|
if (type === suffix && result.endsWith(ending)) {
|
|
@@ -1333,7 +1380,7 @@ function generateFileName(args) {
|
|
|
1333
1380
|
},
|
|
1334
1381
|
plural: {
|
|
1335
1382
|
get type() {
|
|
1336
|
-
return
|
|
1383
|
+
return (0, import_pluralize.default)(type);
|
|
1337
1384
|
}
|
|
1338
1385
|
}
|
|
1339
1386
|
});
|
|
@@ -1356,9 +1403,9 @@ function factoryGetSourceFile(args) {
|
|
|
1356
1403
|
}
|
|
1357
1404
|
|
|
1358
1405
|
// src/helpers/get-model-name.ts
|
|
1359
|
-
|
|
1406
|
+
var import_lodash9 = __toModule(require("lodash"));
|
|
1360
1407
|
function createGetModelName(modelNames) {
|
|
1361
|
-
return
|
|
1408
|
+
return (0, import_lodash9.memoize)(tryGetName);
|
|
1362
1409
|
function tryGetName(name) {
|
|
1363
1410
|
return getModelName({ modelNames, name });
|
|
1364
1411
|
}
|
|
@@ -1387,6 +1434,11 @@ function getModelName(args) {
|
|
|
1387
1434
|
return test;
|
|
1388
1435
|
}
|
|
1389
1436
|
}
|
|
1437
|
+
if (name.slice(-19) === "CompoundUniqueInput") {
|
|
1438
|
+
const test = name.slice(0, -19);
|
|
1439
|
+
const models = modelNames.filter((x) => test.startsWith(x)).sort((a, b) => b.length - a.length);
|
|
1440
|
+
return (0, import_lodash9.first)(models);
|
|
1441
|
+
}
|
|
1390
1442
|
if (name.slice(-5) === "Count") {
|
|
1391
1443
|
const test = name.slice(0, -5);
|
|
1392
1444
|
if (modelNames.includes(test)) {
|
|
@@ -1470,8 +1522,8 @@ async function generate(args) {
|
|
|
1470
1522
|
var _a;
|
|
1471
1523
|
const { connectCallback, generator, skipAddOutputSourceFiles, dmmf } = args;
|
|
1472
1524
|
const generatorOutputValue = (_a = generator.output) == null ? void 0 : _a.value;
|
|
1473
|
-
|
|
1474
|
-
const eventEmitter = new
|
|
1525
|
+
(0, import_assert6.ok)(generatorOutputValue, "Missing generator configuration: output");
|
|
1526
|
+
const eventEmitter = new import_await_event_emitter.default();
|
|
1475
1527
|
eventEmitter.on("Warning", warning);
|
|
1476
1528
|
eventEmitter.on("Model", modelData);
|
|
1477
1529
|
eventEmitter.on("EnumType", registerEnum);
|
|
@@ -1486,12 +1538,12 @@ async function generate(args) {
|
|
|
1486
1538
|
for (const message of config.$warnings) {
|
|
1487
1539
|
eventEmitter.emitSync("Warning", message);
|
|
1488
1540
|
}
|
|
1489
|
-
const project = new
|
|
1541
|
+
const project = new import_ts_morph9.Project({
|
|
1490
1542
|
tsConfigFilePath: config.tsConfigFilePath,
|
|
1491
1543
|
skipAddingFilesFromTsConfig: true,
|
|
1492
1544
|
skipLoadingLibFiles: !config.emitCompiled,
|
|
1493
1545
|
manipulationSettings: {
|
|
1494
|
-
quoteKind:
|
|
1546
|
+
quoteKind: import_ts_morph9.QuoteKind.Single
|
|
1495
1547
|
}
|
|
1496
1548
|
});
|
|
1497
1549
|
if (!skipAddOutputSourceFiles) {
|
|
@@ -1533,8 +1585,8 @@ async function generate(args) {
|
|
|
1533
1585
|
getSourceFile,
|
|
1534
1586
|
eventEmitter,
|
|
1535
1587
|
typeNames: new Set(),
|
|
1536
|
-
enums:
|
|
1537
|
-
getModelName:
|
|
1588
|
+
enums: (0, import_lodash10.mapKeys)(datamodel.enums, (x) => x.name),
|
|
1589
|
+
getModelName: getModelName2,
|
|
1538
1590
|
removeTypes
|
|
1539
1591
|
};
|
|
1540
1592
|
if (connectCallback) {
|
|
@@ -1587,7 +1639,7 @@ async function generate(args) {
|
|
|
1587
1639
|
}
|
|
1588
1640
|
|
|
1589
1641
|
// src/index.ts
|
|
1590
|
-
|
|
1642
|
+
(0, import_generator_helper.generatorHandler)({
|
|
1591
1643
|
async onGenerate(options) {
|
|
1592
1644
|
await generate(options);
|
|
1593
1645
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-nestjs-graphql",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.2.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",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@prisma/generator-helper": "^3.
|
|
50
|
+
"@prisma/generator-helper": "^3.1.1",
|
|
51
51
|
"await-event-emitter": "^2.0.2",
|
|
52
52
|
"filenamify": "4.X",
|
|
53
53
|
"flat": "^5.0.2",
|
|
@@ -68,18 +68,18 @@
|
|
|
68
68
|
"@nestjs/core": "^8.0.6",
|
|
69
69
|
"@nestjs/graphql": "^9.0.4",
|
|
70
70
|
"@nestjs/platform-express": "^8.0.6",
|
|
71
|
-
"@paljs/plugins": "^4.0.
|
|
72
|
-
"@prisma/client": "^3.
|
|
73
|
-
"@semantic-release/changelog": "^
|
|
74
|
-
"@semantic-release/git": "^
|
|
71
|
+
"@paljs/plugins": "^4.0.8",
|
|
72
|
+
"@prisma/client": "^3.1.1",
|
|
73
|
+
"@semantic-release/changelog": "^6.0.0",
|
|
74
|
+
"@semantic-release/git": "^10.0.0",
|
|
75
75
|
"@types/find-cache-dir": "^3.2.1",
|
|
76
76
|
"@types/flat": "^5.0.2",
|
|
77
|
-
"@types/lodash": "^4.14.
|
|
77
|
+
"@types/lodash": "^4.14.173",
|
|
78
78
|
"@types/mocha": "^9.0.0",
|
|
79
|
-
"@types/node": "^16.9.
|
|
79
|
+
"@types/node": "^16.9.6",
|
|
80
80
|
"@types/pluralize": "^0.0.29",
|
|
81
|
-
"@typescript-eslint/eslint-plugin": "^4.31.
|
|
82
|
-
"@typescript-eslint/parser": "^4.31.
|
|
81
|
+
"@typescript-eslint/eslint-plugin": "^4.31.2",
|
|
82
|
+
"@typescript-eslint/parser": "^4.31.2",
|
|
83
83
|
"apollo-server-express": "^3.3.0",
|
|
84
84
|
"c8": "^7.9.0",
|
|
85
85
|
"class-transformer": "^0.4.0",
|
|
@@ -99,28 +99,28 @@
|
|
|
99
99
|
"eslint-plugin-sonarjs": "^0.10.0",
|
|
100
100
|
"eslint-plugin-sort-class-members": "^1.11.0",
|
|
101
101
|
"eslint-plugin-total-functions": "^4.10.1",
|
|
102
|
-
"eslint-plugin-unicorn": "^
|
|
102
|
+
"eslint-plugin-unicorn": "^36.0.0",
|
|
103
103
|
"eslint-plugin-wix-editor": "^3.3.0",
|
|
104
|
-
"expect": "^27.
|
|
104
|
+
"expect": "^27.2.1",
|
|
105
105
|
"find-cache-dir": "^3.3.2",
|
|
106
106
|
"git-branch-is": "^4.0.0",
|
|
107
|
-
"graphql": "^15.
|
|
107
|
+
"graphql": "^15.6.0",
|
|
108
108
|
"graphql-scalars": "^1.10.1",
|
|
109
109
|
"graphql-type-json": "^0.3.2",
|
|
110
110
|
"mocha": "^9.1.1",
|
|
111
111
|
"ololog": "^1.1.175",
|
|
112
112
|
"precise-commits": "^1.0.2",
|
|
113
|
-
"prettier": "^2.4.
|
|
114
|
-
"prisma": "^3.
|
|
113
|
+
"prettier": "^2.4.1",
|
|
114
|
+
"prisma": "^3.1.1",
|
|
115
115
|
"prisma-graphql-type-decimal": "^1.0.0",
|
|
116
116
|
"reflect-metadata": "^0.1.13",
|
|
117
117
|
"rxjs": "^7.3.0",
|
|
118
|
-
"semantic-release": "^
|
|
118
|
+
"semantic-release": "^18.0.0",
|
|
119
119
|
"simplytyped": "^3.3.0",
|
|
120
120
|
"ts-node": "^10.2.1",
|
|
121
121
|
"ts-node-dev": "^1.1.8",
|
|
122
122
|
"tslib": "^2.3.1",
|
|
123
|
-
"typescript": "^4.4.
|
|
123
|
+
"typescript": "^4.4.3",
|
|
124
124
|
"watchexec-bin": "^1.0.0"
|
|
125
125
|
}
|
|
126
126
|
}
|