nest-prisma_doc-gen 1.0.18 → 1.0.19
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/dist/entities/dto-generator.js +2 -1
- package/dist/entities/generic.js +2 -1
- package/dist/main.js +0 -9
- package/dist/rules.js +3 -1
- package/dist/schemas/config.schema.json +14 -16
- package/dist/utils/loader.js +3 -1
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { DocGenFile } from "../file.js";
|
|
|
2
2
|
import { Helper } from "../utils/helpers.js";
|
|
3
3
|
import { Static } from "../static.js";
|
|
4
4
|
import { DocGenField } from "./field.js";
|
|
5
|
+
import { config } from "../utils/loader.js";
|
|
5
6
|
export class DocGenDto {
|
|
6
7
|
name;
|
|
7
8
|
file;
|
|
@@ -46,7 +47,7 @@ export class DocGenDto {
|
|
|
46
47
|
this.classValidators.add("IsEnum");
|
|
47
48
|
this.imports.add(`import { ${Array.from(this.enums)} } from '@prisma/client';`);
|
|
48
49
|
}
|
|
49
|
-
this.imports.add(`import { ${Array.from(this.classValidators)} } from '
|
|
50
|
+
this.imports.add(`import { ${Array.from(this.classValidators)} } from '${config.validatorPath}';`);
|
|
50
51
|
return [
|
|
51
52
|
`${Array.from(this.imports).join("\n")}`,
|
|
52
53
|
`export class ${this.name}DtoDG {
|
package/dist/entities/generic.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { DocGenFile } from "../file.js";
|
|
2
|
+
import { config } from "../utils/loader.js";
|
|
2
3
|
export class DocGenGeneric {
|
|
3
4
|
file;
|
|
4
5
|
constructor() {
|
|
5
6
|
const imports = `
|
|
6
7
|
import { ApiProperty } from '@nestjs/swagger';
|
|
7
|
-
import { IsString, IsNotEmpty } from '
|
|
8
|
+
import { IsString, IsNotEmpty } from '${config.validatorPath}';
|
|
8
9
|
`;
|
|
9
10
|
const validatorProps = `
|
|
10
11
|
export class DefaultIdDtoDG {
|
package/dist/main.js
CHANGED
|
@@ -18,15 +18,6 @@ export class DocGen {
|
|
|
18
18
|
async init() {
|
|
19
19
|
const prismaDataModel = await PrismaUtils.readPrismaFolderDatamodel(PRISMA_DIR);
|
|
20
20
|
const { datamodel } = await getDMMF({ datamodel: prismaDataModel });
|
|
21
|
-
// this.enums = new DocEnums(
|
|
22
|
-
// datamodel.enums.map(({ dbName, name, values }) => {
|
|
23
|
-
// return new DocGenEnum({
|
|
24
|
-
// dbName: dbName ?? "",
|
|
25
|
-
// name,
|
|
26
|
-
// values: values as EnumValue[],
|
|
27
|
-
// });
|
|
28
|
-
// })
|
|
29
|
-
// );
|
|
30
21
|
const fieldSet = new Set();
|
|
31
22
|
for (const model of datamodel.models) {
|
|
32
23
|
for (const field of model.fields) {
|
package/dist/rules.js
CHANGED
|
@@ -2,9 +2,11 @@ export class DocGenRules {
|
|
|
2
2
|
ignore;
|
|
3
3
|
examples;
|
|
4
4
|
validators;
|
|
5
|
+
validatorPath;
|
|
5
6
|
constructor(params) {
|
|
6
|
-
const { examples, ignore, validators } = params;
|
|
7
|
+
const { examples, ignore, validators, validatorPath } = params;
|
|
7
8
|
this.ignore = ignore;
|
|
9
|
+
this.validatorPath = validatorPath;
|
|
8
10
|
if (!validators.length) {
|
|
9
11
|
console.warn("[doc-gen] Nenhum validator encontrado. Verifique seu docgen.config.ts*");
|
|
10
12
|
}
|
|
@@ -13,15 +13,18 @@
|
|
|
13
13
|
},
|
|
14
14
|
"fields": {
|
|
15
15
|
"type": "array",
|
|
16
|
-
"items": {
|
|
17
|
-
"type": "string"
|
|
18
|
-
},
|
|
16
|
+
"items": { "type": "string" },
|
|
19
17
|
"description": "Lista de nomes de campos onde o exemplo será aplicado."
|
|
20
18
|
}
|
|
21
19
|
},
|
|
22
20
|
"required": ["fields", "example"]
|
|
23
21
|
},
|
|
24
22
|
|
|
23
|
+
"ValidatorPath": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "Caminho (path) para o arquivo/pasta de validators usado pelo gerador."
|
|
26
|
+
},
|
|
27
|
+
|
|
25
28
|
"ValidatorBuilder": {
|
|
26
29
|
"additionalProperties": false,
|
|
27
30
|
"type": "object",
|
|
@@ -33,9 +36,7 @@
|
|
|
33
36
|
},
|
|
34
37
|
"fields": {
|
|
35
38
|
"type": "array",
|
|
36
|
-
"items": {
|
|
37
|
-
"type": "string"
|
|
38
|
-
},
|
|
39
|
+
"items": { "type": "string" },
|
|
39
40
|
"description": "Campos que recebem este validador."
|
|
40
41
|
}
|
|
41
42
|
},
|
|
@@ -53,27 +54,24 @@
|
|
|
53
54
|
},
|
|
54
55
|
"ignore": {
|
|
55
56
|
"type": "array",
|
|
56
|
-
"items": {
|
|
57
|
-
"type": "string"
|
|
58
|
-
},
|
|
57
|
+
"items": { "type": "string" },
|
|
59
58
|
"description": "Campos a serem ignorados durante a geração automática de DTOs."
|
|
60
59
|
},
|
|
60
|
+
"validatorPath": {
|
|
61
|
+
"$ref": "#/definitions/ValidatorPath"
|
|
62
|
+
},
|
|
61
63
|
"examples": {
|
|
62
64
|
"type": "array",
|
|
63
|
-
"items": {
|
|
64
|
-
"$ref": "#/definitions/ApiExampleBuilder"
|
|
65
|
-
},
|
|
65
|
+
"items": { "$ref": "#/definitions/ApiExampleBuilder" },
|
|
66
66
|
"description": "Lista de exemplos a serem aplicados a campos específicos."
|
|
67
67
|
},
|
|
68
68
|
"validators": {
|
|
69
69
|
"type": "array",
|
|
70
|
-
"items": {
|
|
71
|
-
"$ref": "#/definitions/ValidatorBuilder"
|
|
72
|
-
},
|
|
70
|
+
"items": { "$ref": "#/definitions/ValidatorBuilder" },
|
|
73
71
|
"description": "Lista de validadores associados a campos específicos."
|
|
74
72
|
}
|
|
75
73
|
},
|
|
76
|
-
"required": ["ignore", "examples", "validators"]
|
|
74
|
+
"required": ["ignore", "validatorPath", "examples", "validators"]
|
|
77
75
|
}
|
|
78
76
|
}
|
|
79
77
|
}
|
package/dist/utils/loader.js
CHANGED
|
@@ -14,11 +14,13 @@ export class DocGenConfig {
|
|
|
14
14
|
ignore;
|
|
15
15
|
examples;
|
|
16
16
|
validators;
|
|
17
|
+
validatorPath;
|
|
17
18
|
constructor(configs) {
|
|
18
|
-
const { examples, ignore, validators } = configs;
|
|
19
|
+
const { examples, ignore, validators, validatorPath } = configs;
|
|
19
20
|
this.ignore = ignore;
|
|
20
21
|
this.examples = examples;
|
|
21
22
|
this.validators = validators;
|
|
23
|
+
this.validatorPath = validatorPath;
|
|
22
24
|
}
|
|
23
25
|
static async readJson(filePath) {
|
|
24
26
|
const content = await fs.readFile(filePath, "utf8");
|