prismadoc 1.0.29
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 +425 -0
- package/dist/config.type.js +38 -0
- package/dist/entities/dto-generator.js +69 -0
- package/dist/entities/enum.js +40 -0
- package/dist/entities/field.js +192 -0
- package/dist/entities/generic.js +24 -0
- package/dist/entities/model.js +83 -0
- package/dist/entities/response-generator.js +30 -0
- package/dist/entities/validator.js +16 -0
- package/dist/field.type.js +22 -0
- package/dist/fields.ts +138 -0
- package/dist/file.js +27 -0
- package/dist/generic.dto.ts +13 -0
- package/dist/index.js +1 -0
- package/dist/index.ts +40 -0
- package/dist/main.js +155 -0
- package/dist/rules.js +35 -0
- package/dist/schemas/config.schema.json +136 -0
- package/dist/static.js +3 -0
- package/dist/types/account-agenda.ts +68 -0
- package/dist/types/account-two-factor-auth-log.ts +127 -0
- package/dist/types/account-two-factor-auth.ts +145 -0
- package/dist/types/account.ts +126 -0
- package/dist/types/admin.ts +68 -0
- package/dist/types/agenda-day-time-config.ts +113 -0
- package/dist/types/agenda-week-day-config.ts +68 -0
- package/dist/types/customer.ts +99 -0
- package/dist/types/dummy-many.ts +71 -0
- package/dist/types/dummy-unique.ts +68 -0
- package/dist/types/dummy.ts +68 -0
- package/dist/types/email-auth-code.ts +136 -0
- package/dist/types/file.ts +299 -0
- package/dist/types/firebase-config.ts +140 -0
- package/dist/types/knowledge-base-category.ts +91 -0
- package/dist/types/knowledge-base-post.ts +262 -0
- package/dist/types/kyc-attempt-details.ts +273 -0
- package/dist/types/kyc-attempt.ts +365 -0
- package/dist/types/kyc-config.ts +199 -0
- package/dist/types/kyc-document.ts +260 -0
- package/dist/types/meeting-guest.ts +185 -0
- package/dist/types/meeting.ts +205 -0
- package/dist/types/member.ts +99 -0
- package/dist/types/notification.ts +193 -0
- package/dist/types/otp-auth-code-request-log.ts +116 -0
- package/dist/types/otp-auth-code.ts +136 -0
- package/dist/types/owner.ts +68 -0
- package/dist/types/policy.ts +169 -0
- package/dist/types/push-notification.ts +77 -0
- package/dist/types/smtp-config.ts +188 -0
- package/dist/types/staff-role.ts +121 -0
- package/dist/types/staff.ts +99 -0
- package/dist/types/tenant-plan.ts +177 -0
- package/dist/types/tenant-role.ts +152 -0
- package/dist/types/tenant.ts +149 -0
- package/dist/types/ticket-message.ts +177 -0
- package/dist/types/ticket.ts +177 -0
- package/dist/types/user.ts +281 -0
- package/dist/types.js +1 -0
- package/dist/utils/helpers.js +146 -0
- package/dist/utils/loader.js +81 -0
- package/dist/utils/prisma-utils.js +73 -0
- package/dist/utils/propeties.static.js +2 -0
- package/package.json +45 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
export class PrismaUtils {
|
|
4
|
+
static async fetchExternalSchemas(schemas) {
|
|
5
|
+
const results = [];
|
|
6
|
+
if (!schemas.length)
|
|
7
|
+
return results;
|
|
8
|
+
for (const schema of schemas) {
|
|
9
|
+
const apiKey = schema.resolveApiKey();
|
|
10
|
+
const headers = {};
|
|
11
|
+
if (apiKey) {
|
|
12
|
+
headers["api-key"] = apiKey;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const response = await fetch(schema.url, { headers });
|
|
16
|
+
if (!response.ok) {
|
|
17
|
+
console.error(`❌ Falha ao buscar schema externo (${response.status}): ${schema.url}`);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const json = await response.json();
|
|
21
|
+
const prismaSchema = json?.data?.prisma;
|
|
22
|
+
if (!prismaSchema || typeof prismaSchema !== "string") {
|
|
23
|
+
console.error(`❌ Schema externo '${schema.name}' não contém data.prisma válido.`);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
console.log(`📄 Schema externo '${schema.name}' carregado com sucesso.`);
|
|
27
|
+
results.push({ name: schema.name, prismaSchema });
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
console.error(`❌ Erro ao buscar schema externo '${schema.name}': ${schema.url}`, err);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return results;
|
|
34
|
+
}
|
|
35
|
+
static async readPrismaFolderDatamodel(dir) {
|
|
36
|
+
const prismaFiles = [];
|
|
37
|
+
// percorre recursivamente e guarda TODOS os .prisma (exceto dentro de migrations)
|
|
38
|
+
const walk = async (currentDir) => {
|
|
39
|
+
const entries = await fs.readdir(currentDir, { withFileTypes: true });
|
|
40
|
+
for (const entry of entries) {
|
|
41
|
+
if (entry.name === "migrations")
|
|
42
|
+
continue;
|
|
43
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
44
|
+
if (entry.isDirectory()) {
|
|
45
|
+
await walk(fullPath);
|
|
46
|
+
}
|
|
47
|
+
else if (entry.isFile() && entry.name.endsWith(".prisma")) {
|
|
48
|
+
prismaFiles.push(fullPath);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
await walk(dir);
|
|
53
|
+
if (!prismaFiles.length)
|
|
54
|
+
return "";
|
|
55
|
+
// garantir que main.prisma (se existir) venha primeiro
|
|
56
|
+
prismaFiles.sort((a, b) => {
|
|
57
|
+
const aIsMain = path.basename(a) === "main.prisma";
|
|
58
|
+
const bIsMain = path.basename(b) === "main.prisma";
|
|
59
|
+
if (aIsMain && !bIsMain)
|
|
60
|
+
return -1;
|
|
61
|
+
if (!aIsMain && bIsMain)
|
|
62
|
+
return 1;
|
|
63
|
+
// fallback: ordem alfabética estável
|
|
64
|
+
return a.localeCompare(b);
|
|
65
|
+
});
|
|
66
|
+
const chunks = [];
|
|
67
|
+
for (const file of prismaFiles) {
|
|
68
|
+
const content = await fs.readFile(file, "utf-8");
|
|
69
|
+
chunks.push(`\n// ---- ${file} ----\n${content}`);
|
|
70
|
+
}
|
|
71
|
+
return chunks.join("\n");
|
|
72
|
+
}
|
|
73
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "prismadoc",
|
|
3
|
+
"version": "1.0.29",
|
|
4
|
+
"description": "Auto generates ApiProperties from schema.prisma",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc && npm run copy-schemas",
|
|
10
|
+
"copy-schemas": "node scripts/copy-schemas.js"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/aleleppy/nest-prisma-doc-gen.git"
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"doc-gen": "dist/main.js"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"scalar",
|
|
21
|
+
"prisma",
|
|
22
|
+
"nestJS",
|
|
23
|
+
"documentation",
|
|
24
|
+
"swagger",
|
|
25
|
+
"automatic",
|
|
26
|
+
"generation"
|
|
27
|
+
],
|
|
28
|
+
"author": "Alessandro Lepore",
|
|
29
|
+
"license": "ISC",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@prisma/internals": "^7.0.0",
|
|
32
|
+
"ajv": "^8.17.1",
|
|
33
|
+
"ajv-formats": "^3.0.1",
|
|
34
|
+
"prettier": "^3.6.2",
|
|
35
|
+
"ts-node": "^10.9.2"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^24.7.2",
|
|
39
|
+
"typescript": "^5.6.3"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"src/schemas/config.schema.json"
|
|
44
|
+
]
|
|
45
|
+
}
|