nest-prisma_doc-gen 1.0.10 → 1.0.12

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.
@@ -108,7 +108,7 @@ export class DocGenField {
108
108
  props.push(`example: true`);
109
109
  }
110
110
  else if (this.scalarField.kind === "enum") {
111
- props.push(`example: ${this.scalarField.type}[0]`);
111
+ props.push(`example: Object.values(${this.scalarField.type})[0]`);
112
112
  }
113
113
  else if (this.scalarField.type === "Int") {
114
114
  props.push(`example: 777`);
@@ -154,7 +154,7 @@ export class DocGenField {
154
154
  return this.type;
155
155
  }
156
156
  };
157
- const optionalFlag = this.isRequired ? "" : "?";
157
+ const optionalFlag = this.isRequired ? "!" : "?";
158
158
  const validators = this.sanitizeValidators();
159
159
  const apiExample = this.buildApiExample().join(", ");
160
160
  return {
package/dist/main.js CHANGED
@@ -17,7 +17,6 @@ export class DocGen {
17
17
  async init() {
18
18
  const prismaDataModel = await PrismaUtils.readPrismaFolderDatamodel(PRISMA_DIR);
19
19
  const { datamodel } = await getDMMF({ datamodel: prismaDataModel });
20
- console.log(datamodel);
21
20
  this.enums = new DocEnums(datamodel.enums.map(({ dbName, name, values }) => {
22
21
  return new DocGenEnum({
23
22
  dbName: dbName ?? "",
@@ -39,7 +38,6 @@ export class DocGen {
39
38
  }
40
39
  build() {
41
40
  this.fields.file.save();
42
- this.enums.file.save();
43
41
  for (const model of this.models) {
44
42
  model.save();
45
43
  }
@@ -1,5 +1,5 @@
1
- import { promises as fs } from "fs";
2
- import * as path from "path";
1
+ import { promises as fs } from "node:fs";
2
+ import * as path from "node:path";
3
3
  export class PrismaUtils {
4
4
  static async readPrismaFolderDatamodel(dir) {
5
5
  const prismaFiles = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nest-prisma_doc-gen",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Auto generates ApiProperties from schema.prisma",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "author": "Alessandro Lepore",
29
29
  "license": "ISC",
30
30
  "dependencies": {
31
- "@prisma/internals": "^6.17.1",
31
+ "@prisma/internals": "^7.0.0",
32
32
  "ajv": "^8.17.1",
33
33
  "ajv-formats": "^3.0.1",
34
34
  "prettier": "^3.6.2",
package/dist/testes.js DELETED
@@ -1,21 +0,0 @@
1
- // import { Ajv } from "ajv";
2
- // import schema from "./schemas/config.schema.json" with { type: "json" };
3
- export {};
4
- // const ajv = new Ajv();
5
- // const validate = ajv.compile(schema);
6
- // const data = {
7
- // ignore: ["senha", "id"],
8
- // examples: [
9
- // { fields: ["name"], example: "João" },
10
- // { fields: ["idade"], example: 30 },
11
- // ],
12
- // validators: [
13
- // { decorator: "IsString", fields: ["name"] },
14
- // { decorator: "IsInt", fields: ["idade"] },
15
- // ],
16
- // };
17
- // if (validate(data)) {
18
- // console.log("✅ JSON válido!");
19
- // } else {
20
- // console.error("❌ Erros:", validate.errors);
21
- // }
@@ -1,33 +0,0 @@
1
- // import * as fs from "node:fs/promises";
2
- // import * as path from "node:path";
3
- // import { fileURLToPath } from "node:url";
4
- // import Ajv from "ajv";
5
- // import addFormats from "ajv-formats";
6
- // import { DocGenRules } from "nest-prisma_doc-gen";
7
- export {};
8
- // // Caminho absoluto do diretório da lib (onde este arquivo está)
9
- // const __filename = fileURLToPath(import.meta.url);
10
- // const __dirname = path.dirname(__filename);
11
- // // Caminho para o schema dentro da lib
12
- // const SCHEMA_PATH = path.join(__dirname, "../schemas/config.schema.json");
13
- // // Caminho para o config do projeto (que será validado)
14
- // const CONFIG_PATH = path.join(process.cwd(), "doc-gen.config.json");
15
- // async function readJson(filePath: string) {
16
- // const content = await fs.readFile(filePath, "utf8");
17
- // return JSON.parse(content);
18
- // }
19
- // export async function loadDocGenConfig() {
20
- // // Lê os dois arquivos
21
- // const [schema, config] = (await Promise.all([readJson(SCHEMA_PATH), readJson(CONFIG_PATH)])) as [any, DocGenRules];
22
- // // Configura o validador
23
- // const ajv = new Ajv.Ajv({ allErrors: true, strict: false });
24
- // addFormats.default(ajv);
25
- // const validate = ajv.compile(schema);
26
- // const valid = validate(config);
27
- // if (!valid) {
28
- // const errors = (validate.errors ?? []).map((e) => `${e.instancePath || "(root)"} ${e.message}`).join("\n - ");
29
- // throw new Error(`❌ Config inválida em ${path.basename(CONFIG_PATH)}:\n - ${errors}`);
30
- // }
31
- // console.log("✅ Configuração válida!");
32
- // return { config, path: CONFIG_PATH };
33
- // }
@@ -1,10 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- const __filename = fileURLToPath(import.meta.url);
5
- const __dirname = path.dirname(__filename);
6
- const src = path.join(__dirname, "../schemas/config.schema.json");
7
- const destDir = path.join(__dirname, "../dist/schemas");
8
- fs.mkdirSync(destDir, { recursive: true });
9
- fs.copyFileSync(src, path.join(destDir, "config.schema.json"));
10
- console.log("✅ Copiado config.schema.json para dist/schemas/");