New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prisma-markdown

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prisma-markdown - npm Package Compare versions

Comparing version

to
1.0.6

70

lib/writers/MarkdownWriter.js

@@ -15,29 +15,31 @@ "use strict";

findImplicits(modelList);
const emplace = (name) => MapUtil_1.MapUtil.take(dict)(name, () => ({
name,
descriptions: new Set(),
diagrams: new Set(),
}));
// TOP NAMESPACE
for (const model of modelList) {
const namespaces = takeTags("namespace")(model);
const describes = takeTags("describe")(model);
const erdList = takeTags("erd")(model);
if (namespaces.length === 0 &&
describes.length === 0 &&
erdList.length === 0) {
const basic = MapUtil_1.MapUtil.take(dict)("default", () => ({
name: "default",
descriptions: new Set(),
diagrams: new Set(),
}));
basic.descriptions.add(model);
basic.diagrams.add(model);
if (namespaces.length === 0)
continue;
}
for (const name of namespaces) {
const section = MapUtil_1.MapUtil.take(dict)(name, () => ({
name,
descriptions: new Set(),
diagrams: new Set(),
}));
const top = namespaces[0];
const chapter = emplace(top);
chapter.descriptions.add(model);
chapter.diagrams.add(model);
}
// REMAINING NAMESPACES
for (const model of modelList) {
const namespaces = takeTags("namespace")(model);
for (const name of namespaces.slice(1)) {
const section = emplace(name);
section.descriptions.add(model);
section.diagrams.add(model);
}
}
// DESCRIPTIONS
for (const model of modelList) {
const describes = takeTags("describe")(model);
for (const name of describes) {
const section = MapUtil_1.MapUtil.take(dict)(name, () => ({
const chapter = MapUtil_1.MapUtil.take(dict)(name, () => ({
name,

@@ -47,6 +49,10 @@ descriptions: new Set(),

}));
section.descriptions.add(model);
chapter.descriptions.add(model);
}
}
// ERD ONLY
for (const model of modelList) {
const erdList = takeTags("erd")(model);
for (const erd of erdList) {
const section = MapUtil_1.MapUtil.take(dict)(erd, () => ({
const chapter = MapUtil_1.MapUtil.take(dict)(erd, () => ({
name: erd,

@@ -56,5 +62,23 @@ descriptions: new Set(),

}));
section.diagrams.add(model);
chapter.diagrams.add(model);
}
}
// DEFAULTS
for (const model of modelList) {
const keywords = [
...takeTags("namespace")(model),
...takeTags("describe")(model),
...takeTags("erd")(model),
];
if (keywords.length !== 0)
continue;
const basic = MapUtil_1.MapUtil.take(dict)("default", () => ({
name: "default",
descriptions: new Set(),
diagrams: new Set(),
}));
basic.descriptions.add(model);
basic.diagrams.add(model);
}
// DO WRITE
const title = typeof (config === null || config === void 0 ? void 0 : config.title) === "string"

@@ -61,0 +85,0 @@ ? config.title

{
"name": "prisma-markdown",
"version": "1.0.5",
"version": "1.0.6",
"description": "Prisma Markdown documents generator including ERD diagrams and comment descriptions",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -19,33 +19,35 @@ import { DMMF } from "@prisma/generator-helper";

const emplace = (name: string) =>
MapUtil.take(dict)(name, () => ({
name,
descriptions: new Set(),
diagrams: new Set(),
}));
// TOP NAMESPACE
for (const model of modelList) {
const namespaces: string[] = takeTags("namespace")(model);
const describes: string[] = takeTags("describe")(model);
const erdList: string[] = takeTags("erd")(model);
if (namespaces.length === 0) continue;
if (
namespaces.length === 0 &&
describes.length === 0 &&
erdList.length === 0
) {
const basic = MapUtil.take(dict)("default", () => ({
name: "default",
descriptions: new Set(),
diagrams: new Set(),
}));
basic.descriptions.add(model);
basic.diagrams.add(model);
continue;
}
const top: string = namespaces[0];
const chapter: IChapter = emplace(top);
chapter.descriptions.add(model);
chapter.diagrams.add(model);
}
for (const name of namespaces) {
const section = MapUtil.take(dict)(name, () => ({
name,
descriptions: new Set(),
diagrams: new Set(),
}));
// REMAINING NAMESPACES
for (const model of modelList) {
const namespaces: string[] = takeTags("namespace")(model);
for (const name of namespaces.slice(1)) {
const section = emplace(name);
section.descriptions.add(model);
section.diagrams.add(model);
}
}
// DESCRIPTIONS
for (const model of modelList) {
const describes: string[] = takeTags("describe")(model);
for (const name of describes) {
const section = MapUtil.take(dict)(name, () => ({
const chapter: IChapter = MapUtil.take(dict)(name, () => ({
name,

@@ -55,6 +57,11 @@ descriptions: new Set(),

}));
section.descriptions.add(model);
chapter.descriptions.add(model);
}
}
// ERD ONLY
for (const model of modelList) {
const erdList: string[] = takeTags("erd")(model);
for (const erd of erdList) {
const section = MapUtil.take(dict)(erd, () => ({
const chapter: IChapter = MapUtil.take(dict)(erd, () => ({
name: erd,

@@ -64,6 +71,25 @@ descriptions: new Set(),

}));
section.diagrams.add(model);
chapter.diagrams.add(model);
}
}
// DEFAULTS
for (const model of modelList) {
const keywords: string[] = [
...takeTags("namespace")(model),
...takeTags("describe")(model),
...takeTags("erd")(model),
];
if (keywords.length !== 0) continue;
const basic: IChapter = MapUtil.take(dict)("default", () => ({
name: "default",
descriptions: new Set(),
diagrams: new Set(),
}));
basic.descriptions.add(model);
basic.diagrams.add(model);
}
// DO WRITE
const title: string =

@@ -70,0 +96,0 @@ typeof config?.title === "string"

Sorry, the diff of this file is not supported yet