mikro-orm-markdown 0.1.0-alpha.2 → 0.1.0-alpha.4
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/CHANGELOG.md +66 -0
- package/CODE_OF_CONDUCT.md +25 -0
- package/LICENSE +1 -1
- package/README.ko.md +248 -41
- package/README.md +248 -41
- package/SECURITY.md +28 -0
- package/dist/cli.cjs +729 -136
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +51 -0
- package/dist/cli.d.ts +51 -0
- package/dist/cli.js +709 -138
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +559 -121
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -17
- package/dist/index.d.ts +21 -17
- package/dist/index.js +548 -121
- package/dist/index.js.map +1 -1
- package/package.json +30 -6
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/docs/jsdoc.ts","../src/metadata/load.ts","../src/render/mermaid.ts","../src/model/build.ts","../src/render/markdown.ts"],"sourcesContent":["import type { Options } from '@mikro-orm/core';\nimport { loadJsDoc } from './docs/jsdoc.js';\nimport { loadEntityMetadata } from './metadata/load.js';\nimport { buildDocumentModel } from './model/build.js';\nimport { renderMarkdown } from './render/markdown.js';\n\nexport { MetadataLoadError } from './metadata/load.js';\nexport type { GenerateOptions } from './model/types.js';\n\n/** Options for the programmatic API. */\nexport interface GenerateMarkdownOptions {\n /** MikroORM configuration (driver, entities, dbName, …). */\n orm: Options;\n /** Title shown as the H1 heading in the generated document. */\n title?: string;\n /** Optional description paragraph rendered below the H1 heading. */\n description?: string;\n /**\n * Glob patterns for TypeScript entity source files.\n * Used for JSDoc extraction (@namespace, @hidden, descriptions).\n * Omit to skip JSDoc parsing — all entities go into the \"default\" section.\n */\n src?: string[];\n}\n\n/**\n * Generates a Mermaid ERD + markdown documentation document from MikroORM\n * entity metadata.\n *\n * @example\n * ```ts\n * import { generateMarkdown } from 'mikro-orm-markdown';\n * import ormConfig from './mikro-orm.config.js';\n *\n * const markdown = await generateMarkdown({\n * orm: ormConfig,\n * title: 'My Database',\n * src: ['src/entities/*.ts'],\n * });\n * ```\n */\nexport async function generateMarkdown(options: GenerateMarkdownOptions): Promise<string> {\n const { orm, title = 'Database Schema', description, src = [] } = options;\n\n const metas = await loadEntityMetadata(orm);\n const jsDocResult = loadJsDoc(src);\n const docModel = buildDocumentModel(metas, jsDocResult, title, description);\n return renderMarkdown(docModel);\n}\n","import type { JSDoc } from 'ts-morph';\nimport { Project } from 'ts-morph';\n\n/** JSDoc information extracted from an entity class. */\nexport interface EntityJsDocInfo {\n /** Class-level description (text before any @tags). */\n description?: string;\n /** Namespaces from @namespace tags — appears in both ERD and text table. */\n namespaces: string[];\n /** Namespaces from @erd tags — appears in ERD only. */\n erdNamespaces: string[];\n /** Namespaces from @describe tags — appears in text table only. */\n describeNamespaces: string[];\n /** True when @hidden tag is present — entity is excluded from all output. */\n hidden: boolean;\n}\n\n/** JSDoc information extracted from a single entity property. */\nexport interface PropJsDocInfo {\n /** Property description text. */\n description?: string;\n}\n\n/** Keyed by entity class name. */\nexport type EntityJsDocMap = Map<string, EntityJsDocInfo>;\n\n/** Outer key: entity class name. Inner key: property name. */\nexport type PropJsDocMap = Map<string, Map<string, PropJsDocInfo>>;\n\nexport interface JsDocResult {\n entities: EntityJsDocMap;\n props: PropJsDocMap;\n}\n\n/**\n * Parses TypeScript source files matched by the provided globs and extracts\n * JSDoc descriptions and custom tags (@namespace, @erd, @describe, @hidden)\n * from entity classes and their properties.\n *\n * Returns empty maps if no source files are matched or no JSDoc is found.\n * Never throws — errors are silently ignored so missing docs don't block generation.\n */\nexport function loadJsDoc(srcGlobs: string[]): JsDocResult {\n const entities: EntityJsDocMap = new Map();\n const props: PropJsDocMap = new Map();\n\n if (srcGlobs.length === 0) {\n return { entities, props };\n }\n\n const project = new Project({\n skipAddingFilesFromTsConfig: true,\n skipLoadingLibFiles: true,\n compilerOptions: {\n experimentalDecorators: true,\n skipLibCheck: true,\n },\n });\n\n project.addSourceFilesAtPaths(srcGlobs);\n\n for (const sourceFile of project.getSourceFiles()) {\n for (const cls of sourceFile.getClasses()) {\n const className = cls.getName();\n if (!className) {\n continue;\n }\n\n const classDocs = cls.getJsDocs();\n if (classDocs.length > 0) {\n entities.set(className, parseEntityJsDoc(classDocs));\n }\n\n const propMap = new Map<string, PropJsDocInfo>();\n for (const prop of cls.getProperties()) {\n const propDocs = prop.getJsDocs();\n if (propDocs.length === 0) {\n continue;\n }\n const desc = extractDescription(propDocs);\n if (desc !== undefined) {\n propMap.set(prop.getName(), { description: desc });\n }\n }\n if (propMap.size > 0) {\n props.set(className, propMap);\n }\n }\n }\n\n return { entities, props };\n}\n\nfunction parseEntityJsDoc(jsDocs: JSDoc[]): EntityJsDocInfo {\n const namespaces: string[] = [];\n const erdNamespaces: string[] = [];\n const describeNamespaces: string[] = [];\n let hidden = false;\n let description: string | undefined;\n\n for (const doc of jsDocs) {\n const desc = doc.getDescription().trim();\n if (desc && description === undefined) {\n description = desc;\n }\n\n for (const tag of doc.getTags()) {\n const tagName = tag.getTagName();\n const comment = tag.getCommentText()?.trim();\n\n if (tagName === 'namespace' && comment) {\n namespaces.push(comment);\n } else if (tagName === 'erd' && comment) {\n erdNamespaces.push(comment);\n } else if (tagName === 'describe' && comment) {\n describeNamespaces.push(comment);\n } else if (tagName === 'hidden') {\n hidden = true;\n }\n }\n }\n\n return {\n ...(description !== undefined && { description }),\n namespaces,\n erdNamespaces,\n describeNamespaces,\n hidden,\n };\n}\n\nfunction extractDescription(jsDocs: JSDoc[]): string | undefined {\n for (const doc of jsDocs) {\n const desc = doc.getDescription().trim();\n if (desc) {\n return desc;\n }\n }\n return undefined;\n}\n","import type { EntityMetadata, Options } from '@mikro-orm/core';\nimport { MikroORM } from '@mikro-orm/core';\n\n/** Errors thrown during metadata loading */\nexport class MetadataLoadError extends Error {\n constructor(\n message: string,\n public override readonly cause?: unknown\n ) {\n super(message);\n this.name = 'MetadataLoadError';\n }\n}\n\n/**\n * Runs MikroORM entity discovery without connecting to the database,\n * and returns all discovered EntityMetadata objects.\n *\n * The caller is responsible for filtering (e.g. excluding abstract,\n * embeddable, or pivot entities) based on rendering needs.\n */\nexport async function loadEntityMetadata(options: Options): Promise<EntityMetadata[]> {\n let orm: MikroORM;\n try {\n orm = await MikroORM.init({\n ...options,\n debug: false,\n connect: false,\n });\n } catch (cause) {\n throw new MetadataLoadError(\n 'Failed to initialize MikroORM and run entity discovery. ' +\n 'Make sure your config is valid and all entity files are accessible.',\n cause\n );\n }\n\n const all = Object.values(orm.getMetadata().getAll());\n\n if (all.length === 0) {\n throw new MetadataLoadError(\n 'No entities were discovered. ' + 'Check that your config specifies at least one entity path or class.'\n );\n }\n\n return all;\n}\n","import type { EntityMetadata, EntityProperty, FormulaTable } from '@mikro-orm/core';\nimport { ReferenceKind } from '@mikro-orm/core';\nimport type { ColumnModel, ConstraintModel, DiagramModel, EntityModel, RelationEdge } from '../model/types.js';\n\n// Dummy table descriptor used when resolving formula expressions for documentation.\n// String-based formulas ignore both arguments; function-based formulas use the alias.\nconst FORMULA_DUMMY_TABLE: FormulaTable = {\n alias: 'e0',\n name: '',\n qualifiedName: '',\n toString: () => 'e0',\n};\n\n/**\n * Converts raw MikroORM EntityMetadata array into a DiagramModel.\n *\n * Excluded from entity boxes:\n * - Pivot tables (auto-generated M:N join tables) — represented as edges\n * - @Embeddable classes — their columns appear inline inside the owning entity\n */\nexport function buildDiagramModel(metas: EntityMetadata[]): DiagramModel {\n const metaByClass = new Map(metas.map((m) => [m.className, m]));\n\n const entities: EntityModel[] = metas\n .filter((meta) => !meta.pivotTable && !meta.embeddable)\n .map((meta) => buildEntityModel(meta, metaByClass));\n\n const relations: RelationEdge[] = buildRelationEdges(metas);\n\n return { entities, relations };\n}\n\nfunction buildEntityModel(meta: EntityMetadata, metaByClass: Map<string, EntityMetadata>): EntityModel {\n // STI root: has discriminatorColumn, no discriminatorValue of its own.\n // Its properties list includes all child-only columns (marked inherited=true) — filter them out.\n const isStiRoot = meta.discriminatorColumn !== undefined && !meta.discriminatorValue;\n const isStiChild = Boolean(meta.extends) && meta.discriminatorValue !== undefined;\n\n const columns: ColumnModel[] = [];\n for (const prop of Object.values(meta.properties)) {\n if (isStiRoot && prop.inherited === true) {\n continue;\n }\n const col = buildColumn(prop, metaByClass, meta);\n if (col !== null) {\n columns.push(col);\n }\n }\n\n return {\n className: meta.className,\n tableName: meta.tableName,\n columns,\n isPivot: false,\n isEmbeddable: meta.embeddable === true,\n ...(isStiRoot && { discriminatorColumn: meta.discriminatorColumn as string }),\n ...(isStiChild && { extendsEntity: meta.extends }),\n constraints: buildConstraints(meta),\n };\n}\n\n/** Returns a ColumnModel for renderable properties, or null to skip. */\nfunction buildColumn(\n prop: EntityProperty,\n metaByClass: Map<string, EntityMetadata>,\n owningMeta: EntityMetadata\n): ColumnModel | null {\n // Skip the EMBEDDED group reference — individual flat columns appear as SCALAR entries\n if (prop.kind === ReferenceKind.EMBEDDED) {\n return null;\n }\n\n if (prop.kind === ReferenceKind.SCALAR) {\n // For @Formula columns, formula is set on a SCALAR-kinded property\n const formulaExpr: string | undefined =\n prop.formula !== undefined\n ? resolveFormulaExpr(prop.formula as (table: FormulaTable, cols: Record<string, string>) => string)\n : undefined;\n\n // Flat embedded columns carry `embedded: [ownerPropName, embeddedPropName]`\n let embeddedIn: string | undefined;\n if (prop.embedded !== undefined) {\n const parentPropName = prop.embedded[0];\n embeddedIn = owningMeta.properties[parentPropName]?.type;\n }\n\n const isDiscriminator =\n owningMeta.discriminatorColumn !== undefined && prop.name === owningMeta.discriminatorColumn;\n\n return {\n propName: prop.name,\n fieldName: prop.fieldNames?.[0] ?? prop.name,\n type: normalizeType(prop.type),\n isPrimary: prop.primary === true,\n isForeignKey: false,\n isUnique: prop.unique === true,\n isNullable: prop.nullable === true,\n ...(formulaExpr !== undefined && { formula: formulaExpr }),\n ...(embeddedIn !== undefined && { embeddedIn }),\n ...(isDiscriminator && { isDiscriminator: true }),\n };\n }\n\n // FK columns: m:1 always owns the FK; 1:1 only when owner === true\n if (prop.kind === ReferenceKind.MANY_TO_ONE || (prop.kind === ReferenceKind.ONE_TO_ONE && prop.owner === true)) {\n const fkType = resolveFkType(prop.type, metaByClass);\n return {\n propName: prop.name,\n fieldName: prop.fieldNames?.[0] ?? `${prop.name}_id`,\n type: fkType,\n isPrimary: false,\n isForeignKey: true,\n isUnique: prop.unique === true,\n isNullable: prop.nullable === true,\n };\n }\n\n // ONE_TO_MANY, MANY_TO_MANY (both owner and inverse) → no physical column\n return null;\n}\n\n/**\n * Calls the FormulaCallback with a dummy table and column proxy to extract the SQL expression.\n * String-based formulas (most common) ignore their arguments and return the literal string.\n * Function-based formulas use the alias/column names from the dummy objects.\n * Returns empty string on unexpected errors.\n */\nfunction resolveFormulaExpr(cb: (table: FormulaTable, cols: Record<string, string>) => string): string {\n try {\n const cols = new Proxy<Record<string, string>>(\n {},\n {\n get: (_target: Record<string, string>, key: string | symbol): string => (typeof key === 'string' ? key : ''),\n }\n );\n return cb(FORMULA_DUMMY_TABLE, cols);\n } catch {\n return '';\n }\n}\n\n/** Looks up the PK type of the referenced entity to use as FK column type. */\nfunction resolveFkType(referencedClassName: string, metaByClass: Map<string, EntityMetadata>): string {\n const refMeta = metaByClass.get(referencedClassName);\n if (!refMeta) {\n return 'integer';\n }\n const pkProp = Object.values(refMeta.properties).find((p) => p.primary === true);\n return pkProp ? normalizeType(pkProp.type) : 'integer';\n}\n\n/** Collects indexes, unique constraints, and check constraints from entity-level metadata. */\nfunction buildConstraints(meta: EntityMetadata): ConstraintModel[] {\n const result: ConstraintModel[] = [];\n\n for (const idx of meta.indexes ?? []) {\n const props = idx.properties;\n result.push({\n type: 'index',\n properties: Array.isArray(props) ? props.map(String) : props ? [String(props)] : [],\n ...(idx.name !== undefined && { name: idx.name }),\n });\n }\n\n for (const uniq of meta.uniques ?? []) {\n const props = uniq.properties;\n result.push({\n type: 'unique',\n properties: Array.isArray(props) ? props.map(String) : props ? [String(props)] : [],\n ...(uniq.name !== undefined && { name: uniq.name }),\n });\n }\n\n for (const check of meta.checks ?? []) {\n // Skip function-based check expressions (they require column reference objects at runtime)\n if (typeof check.expression !== 'string') {\n continue;\n }\n result.push({\n type: 'check',\n properties: [],\n expression: check.expression,\n ...(check.name !== undefined && { name: check.name }),\n });\n }\n\n return result;\n}\n\n/** Builds edges only from owning sides to avoid duplicate arrows. Includes STI inheritance. */\nfunction buildRelationEdges(metas: EntityMetadata[]): RelationEdge[] {\n const edges: RelationEdge[] = [];\n\n for (const meta of metas) {\n if (meta.pivotTable || meta.embeddable) {\n continue;\n }\n\n for (const prop of Object.values(meta.properties)) {\n const edge = buildEdge(meta.className, prop);\n if (edge !== null) {\n edges.push(edge);\n }\n }\n }\n\n return edges;\n}\n\nfunction buildEdge(fromEntity: string, prop: EntityProperty): RelationEdge | null {\n const isNullable = prop.nullable === true;\n\n if (prop.kind === ReferenceKind.MANY_TO_ONE) {\n return {\n fromEntity,\n toEntity: prop.type,\n fromCardinality: '}o',\n toCardinality: isNullable ? 'o|' : '||',\n label: prop.name,\n };\n }\n\n if (prop.kind === ReferenceKind.ONE_TO_ONE && prop.owner === true) {\n return {\n fromEntity,\n toEntity: prop.type,\n fromCardinality: '||',\n toCardinality: isNullable ? 'o|' : '||',\n label: prop.name,\n };\n }\n\n if (prop.kind === ReferenceKind.MANY_TO_MANY && prop.owner === true) {\n return {\n fromEntity,\n toEntity: prop.type,\n fromCardinality: '}o',\n toCardinality: 'o{',\n label: prop.name,\n };\n }\n\n return null;\n}\n\n/**\n * Renders a DiagramModel as a Mermaid erDiagram block string.\n * The returned string starts with \"erDiagram\" and is ready to embed in a\n * markdown code fence.\n */\nexport function renderErDiagram(model: DiagramModel): string {\n const lines: string[] = ['erDiagram'];\n\n for (const entity of model.entities) {\n lines.push(` ${entity.className} {`);\n for (const col of entity.columns) {\n lines.push(` ${renderColumnLine(col)}`);\n }\n lines.push(' }');\n }\n\n for (const rel of model.relations) {\n lines.push(` ${rel.fromEntity} ${rel.fromCardinality}--${rel.toCardinality} ${rel.toEntity} : \"${rel.label}\"`);\n }\n\n return lines.join('\\n');\n}\n\nfunction renderColumnLine(col: ColumnModel): string {\n // Priority: PK > FK > UK\n let qualifier = '';\n if (col.isPrimary) {\n qualifier = ' PK';\n } else if (col.isForeignKey) {\n qualifier = ' FK';\n } else if (col.isUnique) {\n qualifier = ' UK';\n }\n\n // Comment priority (v1 differentiators over prisma-markdown):\n // 1. @Formula SQL expression — \"formula: LENGTH(name)\"\n // 2. STI discriminator column — \"discriminator\"\n // 3. Embedded source type — \"[Address]\"\n // 4. DB/TS name mismatch — \"<tsPropName>\"\n let comment: string | undefined;\n if (col.formula !== undefined) {\n comment = col.formula ? `formula: ${col.formula}` : 'formula';\n } else if (col.isDiscriminator) {\n comment = 'discriminator';\n } else if (col.embeddedIn !== undefined) {\n comment = `[${col.embeddedIn}]`;\n } else if (col.fieldName !== col.propName) {\n comment = col.propName;\n }\n\n const commentStr = comment !== undefined ? ` \"${comment}\"` : '';\n return `${col.type} ${col.fieldName}${qualifier}${commentStr}`;\n}\n\n/** Strips characters that are invalid in Mermaid type identifiers. */\nfunction normalizeType(type: string): string {\n return type.replace(/[^a-zA-Z0-9_]/g, '_');\n}\n","import type { EntityMetadata } from '@mikro-orm/core';\nimport type { EntityJsDocInfo, JsDocResult, PropJsDocInfo } from '../docs/jsdoc.js';\nimport { buildDiagramModel } from '../render/mermaid.js';\nimport type { EntityModel, RelationEdge } from './types.js';\n\n/** An entity with its structural model and JSDoc info merged together. */\nexport interface EnrichedEntity {\n model: EntityModel;\n /** Undefined if the entity has no class-level JSDoc. */\n jsDoc: EntityJsDocInfo | undefined;\n /** Per-property description map (empty map if no property JSDoc). */\n propDocs: Map<string, PropJsDocInfo>;\n}\n\n/**\n * A single namespace group, ready to render as one section of the document.\n *\n * - `erdEntities`: shown in the Mermaid ERD block (@namespace + @erd)\n * - `textEntities`: shown in the column-table sections (@namespace + @describe)\n * - `erdRelations`: relation edges where both endpoints are in `erdEntities`\n */\nexport interface NamespaceGroup {\n name: string;\n erdEntities: EnrichedEntity[];\n textEntities: EnrichedEntity[];\n erdRelations: RelationEdge[];\n}\n\n/** Complete document model — input to the markdown renderer. */\nexport interface DocumentModel {\n title: string;\n /** Optional paragraph rendered below the H1 heading. */\n description?: string;\n groups: NamespaceGroup[];\n}\n\n/**\n * Merges MikroORM structural metadata with JSDoc information and organises the\n * result into namespace groups for rendering.\n *\n * Entities with @hidden are excluded.\n * Entities with no namespace tags fall into the \"default\" group.\n * Groups are ordered alphabetically, with \"default\" always last.\n */\nexport function buildDocumentModel(\n metas: EntityMetadata[],\n jsDocResult: JsDocResult,\n title: string,\n description?: string\n): DocumentModel {\n const { entities: diagramEntities, relations: allRelations } = buildDiagramModel(metas);\n\n // Build enriched entity map, filtering out @hidden entities.\n const enrichedByClass = new Map<string, EnrichedEntity>();\n for (const model of diagramEntities) {\n const jsDoc = jsDocResult.entities.get(model.className);\n if (jsDoc?.hidden) {\n continue;\n }\n const propDocs = jsDocResult.props.get(model.className) ?? new Map<string, PropJsDocInfo>();\n enrichedByClass.set(model.className, { model, jsDoc, propDocs });\n }\n\n // Collect all unique namespace names referenced by any entity.\n const groupNames = new Set<string>();\n let anyUntagged = false;\n for (const { jsDoc } of enrichedByClass.values()) {\n const allNs = [...(jsDoc?.namespaces ?? []), ...(jsDoc?.erdNamespaces ?? []), ...(jsDoc?.describeNamespaces ?? [])];\n if (allNs.length === 0) {\n anyUntagged = true;\n } else {\n for (const ns of allNs) {\n groupNames.add(ns);\n }\n }\n }\n if (anyUntagged) {\n groupNames.add('default');\n }\n\n const groups: NamespaceGroup[] = [];\n for (const groupName of groupNames) {\n const isDefault = groupName === 'default';\n\n const erdEntities = [...enrichedByClass.values()].filter(({ jsDoc }) =>\n belongsToGroupForErd(jsDoc, groupName, isDefault)\n );\n\n const textEntities = [...enrichedByClass.values()].filter(({ jsDoc }) =>\n belongsToGroupForText(jsDoc, groupName, isDefault)\n );\n\n const erdClassNames = new Set(erdEntities.map((e) => e.model.className));\n const erdRelations = allRelations.filter((r) => erdClassNames.has(r.fromEntity) && erdClassNames.has(r.toEntity));\n\n groups.push({ name: groupName, erdEntities, textEntities, erdRelations });\n }\n\n // Sort alphabetically; \"default\" is always last.\n groups.sort((a, b) => {\n if (a.name === 'default') {\n return 1;\n }\n if (b.name === 'default') {\n return -1;\n }\n return a.name.localeCompare(b.name);\n });\n\n return { title, groups, ...(description !== undefined && { description }) };\n}\n\nfunction hasNoNamespaceTags(jsDoc: EntityJsDocInfo | undefined): boolean {\n if (!jsDoc) {\n return true;\n }\n return jsDoc.namespaces.length === 0 && jsDoc.erdNamespaces.length === 0 && jsDoc.describeNamespaces.length === 0;\n}\n\nfunction belongsToGroupForErd(jsDoc: EntityJsDocInfo | undefined, groupName: string, isDefault: boolean): boolean {\n if (isDefault) {\n return hasNoNamespaceTags(jsDoc);\n }\n if (!jsDoc) {\n return false;\n }\n return jsDoc.namespaces.includes(groupName) || jsDoc.erdNamespaces.includes(groupName);\n}\n\nfunction belongsToGroupForText(jsDoc: EntityJsDocInfo | undefined, groupName: string, isDefault: boolean): boolean {\n if (isDefault) {\n return hasNoNamespaceTags(jsDoc);\n }\n if (!jsDoc) {\n return false;\n }\n return jsDoc.namespaces.includes(groupName) || jsDoc.describeNamespaces.includes(groupName);\n}\n","import type { DocumentModel, EnrichedEntity, NamespaceGroup } from '../model/build.js';\nimport type { ColumnModel, ConstraintModel, DiagramModel } from '../model/types.js';\nimport { renderErDiagram } from './mermaid.js';\n\n/**\n * Renders a DocumentModel as a markdown string.\n * Each namespace group becomes a level-2 section with a Mermaid ERD block\n * followed by per-entity column tables.\n */\nexport function renderMarkdown(docModel: DocumentModel): string {\n const sections: string[] = [`# ${docModel.title}`];\n\n if (docModel.description) {\n sections.push(docModel.description);\n }\n\n for (const group of docModel.groups) {\n sections.push(renderGroupSection(group));\n }\n\n return sections.join('\\n\\n');\n}\n\nfunction renderGroupSection(group: NamespaceGroup): string {\n const parts: string[] = [`## ${group.name}`];\n\n if (group.erdEntities.length > 0) {\n const diagramModel: DiagramModel = {\n entities: group.erdEntities.map((e) => e.model),\n relations: group.erdRelations,\n };\n parts.push('```mermaid\\n' + renderErDiagram(diagramModel) + '\\n```');\n }\n\n for (const entity of group.textEntities) {\n parts.push(renderEntitySection(entity));\n }\n\n return parts.join('\\n\\n');\n}\n\nfunction renderEntitySection(entity: EnrichedEntity): string {\n const parts: string[] = [`### ${entity.model.className}`];\n\n if (entity.jsDoc?.description) {\n parts.push(`> ${entity.jsDoc.description}`);\n }\n\n // STI metadata note\n if (entity.model.discriminatorColumn) {\n parts.push(`*STI root — discriminator column: \\`${entity.model.discriminatorColumn}\\`*`);\n } else if (entity.model.extendsEntity) {\n parts.push(`*Extends \\`${entity.model.extendsEntity}\\` (Single Table Inheritance)*`);\n }\n\n if (entity.model.columns.length > 0) {\n parts.push(renderColumnTable(entity));\n }\n\n if (entity.model.constraints.length > 0) {\n parts.push(renderConstraints(entity.model.constraints));\n }\n\n return parts.join('\\n\\n');\n}\n\nfunction renderColumnTable(entity: EnrichedEntity): string {\n const header = '| Column | Type | Key | Nullable | Description |';\n const sep = '|--------|------|-----|----------|-------------|';\n const rows = entity.model.columns.map((col) => {\n const key = resolveColumnKey(col);\n const nullable = col.isNullable && !col.isPrimary ? 'Y' : '';\n const desc = entity.propDocs.get(col.propName)?.description ?? '';\n return `| ${col.fieldName} | ${col.type} | ${key} | ${nullable} | ${desc} |`;\n });\n return [header, sep, ...rows].join('\\n');\n}\n\n/** Returns the \"Key\" cell value for the column table. */\nfunction resolveColumnKey(col: ColumnModel): string {\n if (col.isPrimary) {\n return 'PK';\n }\n if (col.isForeignKey) {\n // Show TS property name in parentheses if it differs from the DB column name\n return col.fieldName !== col.propName ? `FK (${col.propName})` : 'FK';\n }\n if (col.isUnique) {\n return 'UK';\n }\n if (col.formula !== undefined) {\n return `formula: ${col.formula}`;\n }\n if (col.isDiscriminator) {\n return 'discriminator';\n }\n if (col.embeddedIn !== undefined) {\n return `[${col.embeddedIn}]`;\n }\n return '';\n}\n\nfunction renderConstraints(constraints: ConstraintModel[]): string {\n const lines = ['**Constraints:**', ''];\n for (const c of constraints) {\n const name = c.name ? ` \\`${c.name}\\`` : '';\n if (c.type === 'index') {\n lines.push(`- Index${name}: (${c.properties.join(', ')})`);\n } else if (c.type === 'unique') {\n lines.push(`- Unique${name}: (${c.properties.join(', ')})`);\n } else if (c.type === 'check') {\n lines.push(`- Check${name}: \\`${c.expression ?? ''}\\``);\n }\n }\n return lines.join('\\n');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,sBAAwB;AAyCjB,SAAS,UAAU,UAAiC;AACzD,QAAM,WAA2B,oBAAI,IAAI;AACzC,QAAM,QAAsB,oBAAI,IAAI;AAEpC,MAAI,SAAS,WAAW,GAAG;AACzB,WAAO,EAAE,UAAU,MAAM;AAAA,EAC3B;AAEA,QAAM,UAAU,IAAI,wBAAQ;AAAA,IAC1B,6BAA6B;AAAA,IAC7B,qBAAqB;AAAA,IACrB,iBAAiB;AAAA,MACf,wBAAwB;AAAA,MACxB,cAAc;AAAA,IAChB;AAAA,EACF,CAAC;AAED,UAAQ,sBAAsB,QAAQ;AAEtC,aAAW,cAAc,QAAQ,eAAe,GAAG;AACjD,eAAW,OAAO,WAAW,WAAW,GAAG;AACzC,YAAM,YAAY,IAAI,QAAQ;AAC9B,UAAI,CAAC,WAAW;AACd;AAAA,MACF;AAEA,YAAM,YAAY,IAAI,UAAU;AAChC,UAAI,UAAU,SAAS,GAAG;AACxB,iBAAS,IAAI,WAAW,iBAAiB,SAAS,CAAC;AAAA,MACrD;AAEA,YAAM,UAAU,oBAAI,IAA2B;AAC/C,iBAAW,QAAQ,IAAI,cAAc,GAAG;AACtC,cAAM,WAAW,KAAK,UAAU;AAChC,YAAI,SAAS,WAA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,WAAW,EAAE,SAAS,SAAS;AAC7B,YAAM,KAAK,UAAU,IAAI,OAAO,EAAE,cAAc,EAAE,IAAI;AAAA,IACxD;AAAA,EACF;AACA,SAAO,MAAM,KAAK,IAAI;AACxB;;;AL1EA,eAAsB,iBAAiB,SAAmD;AACxF,QAAM,EAAE,KAAK,QAAQ,mBAAmB,aAAa,MAAM,CAAC,EAAE,IAAI;AAElE,QAAM,QAAQ,MAAM,mBAAmB,GAAG;AAC1C,QAAM,cAAc,UAAU,GAAG;AACjC,QAAM,WAAW,mBAAmB,OAAO,aAAa,OAAO,WAAW;AAC1E,SAAO,eAAe,QAAQ;AAChC;","names":["import_core"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/docs/jsdoc.ts","../src/metadata/load.ts","../src/model/build.ts","../src/render/mermaid.ts","../src/render/escape.ts","../src/provider.ts","../src/render/markdown.ts"],"sourcesContent":["import type { EntityMetadata, Options } from '@mikro-orm/core';\nimport { type JsDocResult, loadJsDoc } from './docs/jsdoc.js';\nimport { type LoadedEntityMetadata, loadEntityMetadata } from './metadata/load.js';\nimport { buildDocumentModel } from './model/build.js';\nimport { withTsMorphMetadataProvider } from './provider.js';\nimport { renderMarkdown } from './render/markdown.js';\n\nexport { MetadataLoadError } from './metadata/load.js';\n\n/** Options for the programmatic API. */\nexport interface GenerateMarkdownOptions {\n /** MikroORM configuration (driver, entities, dbName, …). */\n orm: Options;\n /** Title shown as the H1 heading in the generated document. */\n title?: string;\n /** Optional description paragraph rendered below the H1 heading. */\n description?: string;\n /**\n * Source globs/paths (`.ts`) to read JSDoc from. Use this when your entities\n * run from compiled JavaScript (`entities: ['./dist/**\\/*.js']`): build tools\n * strip comments, so descriptions and `@namespace`/`@hidden` tags would\n * otherwise be lost. Defaults to each entity's own discovered source file.\n */\n src?: string[];\n /** Receives non-fatal warnings (e.g. JSDoc cannot be read from compiled JS). */\n onWarn?: (message: string) => void;\n}\n\n/** File extensions produced by a TypeScript build, where comments are stripped. */\nconst COMPILED_JS = /\\.(c|m)?js$/i;\n\n/**\n * Decides which files JSDoc should be read from.\n *\n * When the caller provides `src`, those paths win. Otherwise we fall back to the\n * source files MikroORM discovered each entity from — and if those are compiled\n * JavaScript, JSDoc (descriptions, `@namespace`, and crucially `@hidden`) is\n * gone, so we warn the user and point them at `src`.\n */\nexport function resolveJsDocSources(\n sourcePaths: string[],\n src: string[] | undefined,\n onWarn?: (message: string) => void\n): string[] {\n if (src !== undefined && src.length > 0) {\n return src;\n }\n\n if (sourcePaths.some((p) => COMPILED_JS.test(p)) && onWarn) {\n onWarn(\n 'Entities were discovered from compiled JavaScript, so JSDoc descriptions ' +\n 'and @namespace/@hidden tags cannot be read (build tools strip comments). ' +\n 'Hidden entities may be exposed. Pass --src \"<glob to your .ts sources>\" ' +\n '(or the `src` option) to read JSDoc from the original TypeScript files.'\n );\n }\n\n return sourcePaths;\n}\n\nfunction assertExplicitJsDocSourceCoverage(\n metas: EntityMetadata[],\n jsDocResult: JsDocResult,\n src: string[],\n onWarn?: (message: string) => void\n): void {\n if (jsDocResult.sourceFileCount === 0) {\n throw new Error(\n `No source files matched the explicit src paths: ${src.join(', ')}\\n` +\n 'Check the --src glob/path (or the `src` option). Without matching TypeScript sources, ' +\n 'JSDoc tags such as @namespace and @hidden cannot be read.'\n );\n }\n\n const isRenderable = (meta: EntityMetadata): boolean => !meta.pivotTable && !meta.embeddable;\n\n const missingConcrete = metas\n .filter((meta) => isRenderable(meta) && !meta.abstract)\n .map((meta) => meta.className)\n .filter((className) => !jsDocResult.classNames.has(className));\n\n if (missingConcrete.length > 0) {\n throw new Error(\n `Explicit src paths did not include source declarations for discovered entities: ${missingConcrete.join(', ')}\\n` +\n 'Check that --src (or the `src` option) points at all TypeScript entity files. ' +\n 'JSDoc tags such as @namespace and @hidden for missing entities cannot be read.'\n );\n }\n\n // Abstract STI parents appear in the diagram but are often defined in a separate\n // base-class file that --src may not cover. Warn rather than error so the user\n // knows @hidden/@namespace won't apply to them.\n if (onWarn) {\n const missingAbstract = metas\n .filter((meta) => isRenderable(meta) && meta.abstract)\n .map((meta) => meta.className)\n .filter((className) => !jsDocResult.classNames.has(className));\n\n if (missingAbstract.length > 0) {\n onWarn(\n `Abstract STI parent entities were not found in the explicit src paths: ${missingAbstract.join(', ')}\\n` +\n '@hidden and @namespace tags for these entities will not be applied. ' +\n 'Include their source files in --src to enable JSDoc tags for them.'\n );\n }\n }\n}\n\nfunction errorMessages(err: unknown): string[] {\n const messages: string[] = [];\n const seen = new Set<unknown>();\n let current: unknown = err;\n\n while (current instanceof Error && !seen.has(current)) {\n seen.add(current);\n messages.push(current.message);\n current = (current as { cause?: unknown }).cause;\n }\n\n return messages;\n}\n\nfunction isMissingTsMorphSourceFile(err: unknown): boolean {\n return errorMessages(err).some((message) => message.includes('Source file') && message.includes('not found'));\n}\n\nasync function loadEntityMetadataWithTsMorphFallback(\n originalOrm: Options,\n effectiveOrm: Options\n): Promise<LoadedEntityMetadata> {\n try {\n return await loadEntityMetadata(effectiveOrm);\n } catch (err) {\n const wasAutoInjected = originalOrm.metadataProvider === undefined && effectiveOrm.metadataProvider !== undefined;\n if (!wasAutoInjected || !isMissingTsMorphSourceFile(err)) {\n throw err;\n }\n\n try {\n return await loadEntityMetadata(originalOrm);\n } catch {\n throw err;\n }\n }\n}\n\n/**\n * Generates a Mermaid ERD + markdown documentation document from MikroORM\n * entity metadata.\n *\n * JSDoc tags (@namespace, @erd, @describe, @hidden) and descriptions are\n * read directly from each entity's own source file — no separate path needs\n * to be specified. When entities run from compiled JavaScript (where comments\n * are stripped), pass `src` to read JSDoc from the original `.ts` files.\n *\n * @example\n * ```ts\n * import { generateMarkdown } from 'mikro-orm-markdown';\n * import ormConfig from './mikro-orm.config.js';\n *\n * const markdown = await generateMarkdown({\n * orm: ormConfig,\n * title: 'My Database',\n * });\n * ```\n */\nexport async function generateMarkdown(options: GenerateMarkdownOptions): Promise<string> {\n const { orm, title = 'Database Schema', description, src, onWarn } = options;\n\n const effectiveOrm = await withTsMorphMetadataProvider(orm, onWarn);\n const { metas, sourcePaths } = await loadEntityMetadataWithTsMorphFallback(orm, effectiveOrm);\n const jsDocResult = loadJsDoc(resolveJsDocSources(sourcePaths, src, onWarn));\n if (src !== undefined && src.length > 0) {\n assertExplicitJsDocSourceCoverage(metas, jsDocResult, src, onWarn);\n }\n const docModel = buildDocumentModel(metas, jsDocResult, title, description, onWarn);\n return renderMarkdown(docModel);\n}\n","import type { JSDoc } from 'ts-morph';\nimport { Project } from 'ts-morph';\n\n/** JSDoc information extracted from an entity class. */\nexport interface EntityJsDocInfo {\n /** Class-level description (text before any @tags). */\n description?: string;\n /** Namespaces from @namespace tags — appears in both ERD and text table. */\n namespaces: string[];\n /** Namespaces from @erd tags — appears in ERD only. */\n erdNamespaces: string[];\n /** Namespaces from @describe tags — appears in text table only. */\n describeNamespaces: string[];\n /** True when @hidden tag is present — entity is excluded from all output. */\n hidden: boolean;\n}\n\n/** JSDoc information extracted from a single entity property. */\nexport interface PropJsDocInfo {\n /** Property description text. */\n description?: string;\n /** True when the @atLeastOne tag is present — a collection relation that must hold ≥1 elements. */\n atLeastOne: boolean;\n}\n\n/** Keyed by entity class name. */\nexport type EntityJsDocMap = Map<string, EntityJsDocInfo>;\n\n/** Outer key: entity class name. Inner key: property name. */\nexport type PropJsDocMap = Map<string, Map<string, PropJsDocInfo>>;\n\nexport interface JsDocResult {\n entities: EntityJsDocMap;\n props: PropJsDocMap;\n /** Number of TypeScript source files matched and loaded for JSDoc parsing. */\n sourceFileCount: number;\n /** Class declarations found in the loaded source files, including classes without JSDoc. */\n classNames: Set<string>;\n}\n\n/**\n * Parses the given TypeScript source files and extracts JSDoc descriptions\n * and custom tags (@namespace, @erd, @describe, @hidden) from entity classes\n * and their properties.\n *\n * Returns empty maps if no source files are given or no JSDoc is found.\n * Never throws — errors are silently ignored so missing docs don't block generation.\n */\nexport function loadJsDoc(filePaths: string[]): JsDocResult {\n const entities: EntityJsDocMap = new Map();\n const props: PropJsDocMap = new Map();\n const classNames = new Set<string>();\n\n if (filePaths.length === 0) {\n return { entities, props, sourceFileCount: 0, classNames };\n }\n\n const project = new Project({\n skipAddingFilesFromTsConfig: true,\n skipLoadingLibFiles: true,\n compilerOptions: {\n experimentalDecorators: true,\n skipLibCheck: true,\n },\n });\n\n // Add each path independently so one unreadable file or bad glob (EACCES, a\n // directory, etc.) cannot abort the whole run — missing docs must never block\n // generation (the \"never throws\" contract).\n for (const filePath of filePaths) {\n try {\n project.addSourceFilesAtPaths(filePath);\n } catch {\n // Skip this path; other sources may still contribute JSDoc.\n }\n }\n\n const sourceFiles = project.getSourceFiles();\n for (const sourceFile of sourceFiles) {\n try {\n for (const cls of sourceFile.getClasses()) {\n const className = cls.getName();\n if (!className) {\n continue;\n }\n classNames.add(className);\n\n const classDocs = cls.getJsDocs();\n if (classDocs.length > 0) {\n entities.set(className, parseEntityJsDoc(classDocs));\n }\n\n const propMap = new Map<string, PropJsDocInfo>();\n for (const prop of cls.getProperties()) {\n const propDocs = prop.getJsDocs();\n if (propDocs.length === 0) {\n continue;\n }\n const info = parsePropJsDoc(propDocs);\n if (info.description !== undefined || info.atLeastOne) {\n propMap.set(prop.getName(), info);\n }\n }\n if (propMap.size > 0) {\n props.set(className, propMap);\n }\n }\n } catch {\n // Skip this file; a single unparseable source must not block generation.\n }\n }\n\n return { entities, props, sourceFileCount: sourceFiles.length, classNames };\n}\n\nfunction parseEntityJsDoc(jsDocs: JSDoc[]): EntityJsDocInfo {\n const namespaces: string[] = [];\n const erdNamespaces: string[] = [];\n const describeNamespaces: string[] = [];\n let hidden = false;\n let description: string | undefined;\n\n for (const doc of jsDocs) {\n const desc = doc.getDescription().trim();\n if (desc && description === undefined) {\n description = desc;\n }\n\n for (const tag of doc.getTags()) {\n const tagName = tag.getTagName();\n const comment = tag.getCommentText()?.trim();\n\n if (tagName === 'namespace' && comment) {\n namespaces.push(comment);\n } else if (tagName === 'erd' && comment) {\n erdNamespaces.push(comment);\n } else if (tagName === 'describe' && comment) {\n describeNamespaces.push(comment);\n } else if (tagName === 'hidden') {\n hidden = true;\n }\n }\n }\n\n return {\n ...(description !== undefined && { description }),\n namespaces,\n erdNamespaces,\n describeNamespaces,\n hidden,\n };\n}\n\nfunction parsePropJsDoc(jsDocs: JSDoc[]): PropJsDocInfo {\n let description: string | undefined;\n let atLeastOne = false;\n\n for (const doc of jsDocs) {\n const desc = doc.getDescription().trim();\n if (desc && description === undefined) {\n description = desc;\n }\n for (const tag of doc.getTags()) {\n if (tag.getTagName() === 'atLeastOne') {\n atLeastOne = true;\n }\n }\n }\n\n return { ...(description !== undefined && { description }), atLeastOne };\n}\n","import * as path from 'node:path';\nimport type { EntityMetadata, Options } from '@mikro-orm/core';\nimport { EntitySchema, MikroORM } from '@mikro-orm/core';\n\n/** Errors thrown during metadata loading */\nexport class MetadataLoadError extends Error {\n constructor(\n message: string,\n public override readonly cause?: unknown\n ) {\n super(message);\n this.name = 'MetadataLoadError';\n }\n}\n\nexport interface LoadedEntityMetadata {\n metas: EntityMetadata[];\n /** Absolute paths to the source files each entity class was declared in, deduped. */\n sourcePaths: string[];\n}\n\nasync function closeDiscoveryResources(orm: MikroORM): Promise<void> {\n // With connect=false, orm.close() can instantiate SQL clients just to close them.\n await orm.config.getMetadataCacheAdapter()?.close?.();\n await orm.config.getResultCacheAdapter()?.close?.();\n}\n\nfunction collectEntitySchemaNames(options: Options): string[] {\n const configuredEntities = [...(options.entities ?? []), ...(options.entitiesTs ?? [])];\n const names: string[] = [];\n\n for (const entity of configuredEntities) {\n if (entity instanceof EntitySchema) {\n names.push(entity.meta.className);\n continue;\n }\n\n if (entity !== null && typeof entity === 'object' && 'schema' in entity && entity.schema instanceof EntitySchema) {\n names.push(entity.schema.meta.className);\n }\n }\n\n return names;\n}\n\nfunction assertNoEntitySchemaEntities(options: Options): void {\n const schemaNames = collectEntitySchemaNames(options);\n if (schemaNames.length === 0) {\n return;\n }\n\n throw new MetadataLoadError(\n `EntitySchema-defined entities are not currently supported: ${schemaNames.join(', ')}.\\n` +\n 'Use decorator-based @Entity() classes instead.'\n );\n}\n\n/**\n * Runs MikroORM entity discovery without connecting to the database,\n * and returns all discovered EntityMetadata objects along with the\n * absolute source file paths they were declared in (for JSDoc extraction).\n *\n * The caller is responsible for filtering (e.g. excluding abstract,\n * embeddable, or pivot entities) based on rendering needs.\n */\nexport async function loadEntityMetadata(options: Options): Promise<LoadedEntityMetadata> {\n assertNoEntitySchemaEntities(options);\n\n let orm: MikroORM;\n try {\n orm = await MikroORM.init({\n ...options,\n debug: false,\n connect: false,\n // Always disable the metadata cache for one-shot doc runs so the project\n // is never littered with a temp/ folder, regardless of how metadataProvider\n // was configured.\n metadataCache: { ...options.metadataCache, enabled: false },\n });\n } catch (cause) {\n throw new MetadataLoadError(\n 'Failed to initialize MikroORM and run entity discovery. ' +\n 'Make sure your config is valid and all entity files are accessible.',\n cause\n );\n }\n\n try {\n const all = Object.values(orm.getMetadata().getAll());\n\n if (all.length === 0) {\n throw new MetadataLoadError(\n 'No entities were discovered. ' + 'Check that your config specifies at least one entity path or class.'\n );\n }\n\n const baseDir = orm.config.get('baseDir');\n const sourcePaths = [...new Set(all.filter((m) => m.path).map((m) => path.resolve(baseDir, m.path)))];\n\n return { metas: all, sourcePaths };\n } finally {\n await closeDiscoveryResources(orm);\n }\n}\n","import { type EntityMetadata, ReferenceKind } from '@mikro-orm/core';\nimport type { EntityJsDocInfo, JsDocResult, PropJsDocInfo, PropJsDocMap } from '../docs/jsdoc.js';\nimport { buildDiagramModel } from '../render/mermaid.js';\nimport type { ColumnModel, EntityModel, RelationEdge } from './types.js';\n\n// Mermaid cardinality tokens upgrading the \"many\" side from zero-or-more to one-or-more.\nconst FROM_ONE_OR_MORE = '}|';\nconst TO_ONE_OR_MORE = '|{';\n\n/** An entity with its structural model and JSDoc info merged together. */\nexport interface EnrichedEntity {\n model: EntityModel;\n /** Undefined if the entity has no class-level JSDoc. */\n jsDoc: EntityJsDocInfo | undefined;\n /** Per-property description map (empty map if no property JSDoc). */\n propDocs: Map<string, PropJsDocInfo>;\n}\n\n/**\n * A single namespace group, ready to render as one section of the document.\n *\n * - `erdEntities`: shown in the Mermaid ERD block (@namespace + @erd)\n * - `textEntities`: shown in the column-table sections (@namespace + @describe)\n * - `erdRelations`: relation edges where both endpoints are in `erdEntities`\n */\nexport interface NamespaceGroup {\n name: string;\n erdEntities: EnrichedEntity[];\n textEntities: EnrichedEntity[];\n erdRelations: RelationEdge[];\n}\n\n/** Complete document model — input to the markdown renderer. */\nexport interface DocumentModel {\n title: string;\n /** Optional paragraph rendered below the H1 heading. */\n description?: string;\n groups: NamespaceGroup[];\n}\n\n/**\n * Merges MikroORM structural metadata with JSDoc information and organises the\n * result into namespace groups for rendering.\n *\n * Entities with @hidden are excluded.\n * Entities with no namespace tags fall into the \"default\" group.\n * Groups are ordered alphabetically, with \"default\" always last.\n */\nexport function buildDocumentModel(\n metas: EntityMetadata[],\n jsDocResult: JsDocResult,\n title: string,\n description?: string,\n onWarn?: (message: string) => void\n): DocumentModel {\n const { entities: diagramEntities, relations } = buildDiagramModel(metas);\n const allRelations = applyAtLeastOne(relations, metas, jsDocResult.props, onWarn);\n\n // Classes excluded via @hidden — FK columns pointing at them would otherwise\n // dangle (their edge is dropped, but the column would still reference a target\n // that no longer appears anywhere).\n const hiddenClasses = new Set<string>();\n for (const model of diagramEntities) {\n if (jsDocResult.entities.get(model.className)?.hidden) {\n hiddenClasses.add(model.className);\n }\n }\n\n // Build enriched entity map, filtering out @hidden entities.\n const enrichedByClass = new Map<string, EnrichedEntity>();\n for (const model of diagramEntities) {\n const jsDoc = jsDocResult.entities.get(model.className);\n if (jsDoc?.hidden) {\n continue;\n }\n const columns = model.columns.filter(\n (col) => !(col.isForeignKey && col.referencedEntity !== undefined && hiddenClasses.has(col.referencedEntity))\n );\n const visibleModel = columns.length === model.columns.length ? model : { ...model, columns };\n const ownPropDocs = jsDocResult.props.get(model.className) ?? new Map<string, PropJsDocInfo>();\n const propDocs = withEmbeddedPropDocs(ownPropDocs, visibleModel.columns, jsDocResult.props);\n enrichedByClass.set(model.className, { model: visibleModel, jsDoc, propDocs });\n }\n\n // Collect all unique namespace names referenced by any entity.\n const groupNames = new Set<string>();\n let anyUntagged = false;\n for (const { jsDoc } of enrichedByClass.values()) {\n const allNs = [...(jsDoc?.namespaces ?? []), ...(jsDoc?.erdNamespaces ?? []), ...(jsDoc?.describeNamespaces ?? [])];\n if (allNs.length === 0) {\n anyUntagged = true;\n } else {\n for (const ns of allNs) {\n groupNames.add(ns);\n }\n }\n }\n if (anyUntagged) {\n groupNames.add('default');\n }\n\n const groups: NamespaceGroup[] = [];\n for (const groupName of groupNames) {\n const isDefault = groupName === 'default';\n\n const erdEntities = [...enrichedByClass.values()]\n .filter(({ jsDoc }) => belongsToGroupForErd(jsDoc, groupName, isDefault))\n .map((entity): EnrichedEntity | null => {\n if (isCrossNamespaceInGroup(entity.jsDoc, groupName, isDefault)) {\n const pkColumns = entity.model.columns.filter((col) => col.isPrimary);\n // If no PK columns remain (e.g. FK-as-PK to a @hidden entity was filtered out),\n // exclude the entity entirely: an empty box with dangling arrows is misleading.\n if (pkColumns.length === 0) {\n return null;\n }\n return { ...entity, model: { ...entity.model, columns: pkColumns } };\n }\n return entity;\n })\n .filter((entity): entity is EnrichedEntity => entity !== null);\n\n const textEntities = [...enrichedByClass.values()].filter(({ jsDoc }) =>\n belongsToGroupForText(jsDoc, groupName, isDefault)\n );\n\n const erdClassNames = new Set(erdEntities.map((e) => e.model.className));\n const erdRelations = allRelations.filter((r) => erdClassNames.has(r.fromEntity) && erdClassNames.has(r.toEntity));\n\n groups.push({ name: groupName, erdEntities, textEntities, erdRelations });\n }\n\n // Sort alphabetically; \"default\" is always last.\n groups.sort((a, b) => {\n if (a.name === 'default') {\n return 1;\n }\n if (b.name === 'default') {\n return -1;\n }\n return a.name.localeCompare(b.name);\n });\n\n return { title, groups, ...(description !== undefined && { description }) };\n}\n\n/**\n * Falls back to the @Embeddable class's own JSDoc for flattened embedded columns\n * (e.g. Customer's \"address_street\" picks up Address.street's JSDoc), since the\n * owning entity's source file never declares that synthetic property name.\n * Returns a new map; the input map is not mutated.\n */\nfunction withEmbeddedPropDocs(\n ownPropDocs: Map<string, PropJsDocInfo>,\n columns: ColumnModel[],\n allPropDocs: PropJsDocMap\n): Map<string, PropJsDocInfo> {\n const merged = new Map(ownPropDocs);\n for (const col of columns) {\n if (merged.has(col.propName) || col.embeddedIn === undefined || col.embeddedPropName === undefined) {\n continue;\n }\n const info = allPropDocs.get(col.embeddedIn)?.get(col.embeddedPropName);\n if (info) {\n merged.set(col.propName, info);\n }\n }\n return merged;\n}\n\n/**\n * Upgrades the \"many\" side of a relation edge to one-or-more for collection\n * properties tagged with @atLeastOne. The edge is always built from the owning\n * side, so a collection on the inverse side is matched back via its mappedBy.\n * Returns a new array; input edges are not mutated.\n */\nfunction applyAtLeastOne(\n relations: RelationEdge[],\n metas: EntityMetadata[],\n props: PropJsDocMap,\n onWarn?: (message: string) => void\n): RelationEdge[] {\n const adjusted = relations.map((edge) => ({ ...edge }));\n const metaByClass = new Map(metas.map((m) => [m.className, m]));\n\n for (const [className, propMap] of props) {\n const meta = metaByClass.get(className);\n if (!meta) {\n continue;\n }\n for (const [propName, info] of propMap) {\n if (!info.atLeastOne) {\n continue;\n }\n const prop = meta.properties[propName];\n if (!prop) {\n continue;\n }\n\n let edge: RelationEdge | undefined;\n // 1:N collection — the edge comes from the m:1 owning side; bump its \"many\" (from) side.\n if (prop.kind === ReferenceKind.ONE_TO_MANY && prop.mappedBy) {\n edge = adjusted.find(\n (e) => e.fromEntity === prop.type && e.toEntity === className && e.label === prop.mappedBy\n );\n if (edge) {\n edge.fromCardinality = FROM_ONE_OR_MORE;\n }\n }\n // M:N owning collection — edge built from this prop; the other (to) side becomes one-or-more.\n else if (prop.kind === ReferenceKind.MANY_TO_MANY && prop.owner === true) {\n edge = adjusted.find((e) => e.fromEntity === className && e.toEntity === prop.type && e.label === propName);\n if (edge) {\n edge.toCardinality = TO_ONE_OR_MORE;\n }\n }\n // M:N inverse collection — edge built from the owner; this (from) side becomes one-or-more.\n else if (prop.kind === ReferenceKind.MANY_TO_MANY && prop.mappedBy) {\n edge = adjusted.find(\n (e) => e.fromEntity === prop.type && e.toEntity === className && e.label === prop.mappedBy\n );\n if (edge) {\n edge.fromCardinality = FROM_ONE_OR_MORE;\n }\n }\n\n // No matching edge: a unidirectional @OneToMany (no mappedBy) or a label\n // mismatch leaves the cardinality unchanged. Warn instead of failing silently.\n if (!edge) {\n onWarn?.(\n `@atLeastOne on ${className}.${propName} had no effect: no matching relation edge was found. ` +\n 'It applies only to collection relations that can be matched to a rendered edge: ' +\n '@OneToMany with mappedBy, or @ManyToMany on either the owning side or an inverse mappedBy side.'\n );\n }\n }\n }\n\n return adjusted;\n}\n\nfunction hasNoNamespaceTags(jsDoc: EntityJsDocInfo | undefined): boolean {\n if (!jsDoc) {\n return true;\n }\n return jsDoc.namespaces.length === 0 && jsDoc.erdNamespaces.length === 0 && jsDoc.describeNamespaces.length === 0;\n}\n\nfunction belongsToGroupForErd(jsDoc: EntityJsDocInfo | undefined, groupName: string, isDefault: boolean): boolean {\n if (isDefault) {\n return hasNoNamespaceTags(jsDoc);\n }\n if (!jsDoc) {\n return false;\n }\n return jsDoc.namespaces.includes(groupName) || jsDoc.erdNamespaces.includes(groupName);\n}\n\nfunction belongsToGroupForText(jsDoc: EntityJsDocInfo | undefined, groupName: string, isDefault: boolean): boolean {\n if (isDefault) {\n return hasNoNamespaceTags(jsDoc);\n }\n if (!jsDoc) {\n return false;\n }\n return jsDoc.namespaces.includes(groupName) || jsDoc.describeNamespaces.includes(groupName);\n}\n\n/**\n * Returns true when an entity appears in a group's ERD only via @erd (not @namespace).\n * These entities are \"guests\" in the ERD: their home section is another namespace.\n */\nfunction isCrossNamespaceInGroup(jsDoc: EntityJsDocInfo | undefined, groupName: string, isDefault: boolean): boolean {\n if (isDefault || !jsDoc) {\n return false;\n }\n return (\n jsDoc.erdNamespaces.includes(groupName) &&\n !jsDoc.namespaces.includes(groupName) &&\n !jsDoc.describeNamespaces.includes(groupName)\n );\n}\n","import type { EntityMetadata, EntityProperty, FormulaTable } from '@mikro-orm/core';\nimport { ReferenceKind } from '@mikro-orm/core';\nimport type { ColumnModel, ConstraintModel, DiagramModel, EntityModel, RelationEdge } from '../model/types.js';\nimport { escapeMermaidQuotedText, toMermaidIdentifier } from './escape.js';\n\n// Dummy table descriptor used when resolving formula expressions for documentation.\n// String-based formulas ignore both arguments; function-based formulas use the alias.\nconst FORMULA_DUMMY_TABLE: FormulaTable = {\n alias: 'e0',\n name: '',\n qualifiedName: '',\n toString: () => 'e0',\n};\n\nconst UNRESOLVED_FORMULA = '<unresolved>';\n\n/**\n * Converts raw MikroORM EntityMetadata array into a DiagramModel.\n *\n * Excluded from entity boxes:\n * - Pivot tables (auto-generated M:N join tables) — represented as edges\n * - @Embeddable classes — their columns appear inline inside the owning entity\n */\nexport function buildDiagramModel(metas: EntityMetadata[]): DiagramModel {\n const metaByClass = new Map(metas.map((m) => [m.className, m]));\n\n const entities: EntityModel[] = metas\n .filter((meta) => !meta.pivotTable && !meta.embeddable)\n .map((meta) => buildEntityModel(meta, metaByClass));\n\n const relations: RelationEdge[] = buildRelationEdges(metas);\n\n return { entities, relations };\n}\n\nfunction buildEntityModel(meta: EntityMetadata, metaByClass: Map<string, EntityMetadata>): EntityModel {\n // STI root: defines the discriminatorColumn and does not itself extend a parent.\n // A *non-abstract* root is also assigned its own discriminatorValue by MikroORM,\n // so we must not key off the absence of discriminatorValue here — that would\n // misclassify non-abstract roots and leak every subclass column into them.\n // The root's properties list includes all child-only columns (inherited=true) — filter them out.\n const isStiRoot = meta.discriminatorColumn !== undefined && !meta.extends;\n const isStiChild = Boolean(meta.extends) && meta.discriminatorValue !== undefined;\n\n const columns: ColumnModel[] = [];\n for (const prop of Object.values(meta.properties)) {\n if (isStiRoot && prop.inherited === true) {\n continue;\n }\n columns.push(...buildColumns(prop, metaByClass, meta));\n }\n\n return {\n className: meta.className,\n tableName: meta.tableName,\n columns,\n isPivot: false,\n isEmbeddable: meta.embeddable === true,\n ...(isStiRoot && { discriminatorColumn: meta.discriminatorColumn as string }),\n ...(isStiChild && { extendsEntity: meta.extends }),\n ...(isStiChild && meta.discriminatorValue !== undefined && { discriminatorValue: String(meta.discriminatorValue) }),\n constraints: buildConstraints(meta),\n };\n}\n\n/** Returns ColumnModels for renderable properties, or an empty array to skip. */\nfunction buildColumns(\n prop: EntityProperty,\n metaByClass: Map<string, EntityMetadata>,\n owningMeta: EntityMetadata\n): ColumnModel[] {\n if (prop.kind === ReferenceKind.EMBEDDED) {\n // An object/array embedded is stored as a single JSON column, so render one\n // column for it. (`array: true` implies `object: true`.) A plain inline\n // embedded has no column of its own — its fields surface as flat SCALARs.\n if (prop.object === true || prop.array === true) {\n return [\n {\n propName: prop.name,\n fieldName: prop.fieldNames?.[0] ?? prop.name,\n type: 'json',\n isPrimary: false,\n isForeignKey: false,\n isUnique: prop.unique === true,\n isNullable: prop.nullable === true,\n ...(prop.comment !== undefined && { comment: prop.comment }),\n embeddedIn: prop.array === true ? `${prop.type}[]` : prop.type,\n },\n ];\n }\n return [];\n }\n\n if (prop.kind === ReferenceKind.SCALAR) {\n // Flat leaf of an object/array embedded: it lives inside the single JSON\n // column rendered above, so it is not a column of its own — skip it.\n if (prop.object === true && prop.embedded !== undefined) {\n return [];\n }\n\n // For @Formula columns, formula is set on a SCALAR-kinded property\n const formulaExpr: string | undefined =\n prop.formula !== undefined\n ? resolveFormulaExpr(prop.formula as (table: FormulaTable, cols: Record<string, string>) => string)\n : undefined;\n\n // Flat embedded columns carry `embedded: [ownerPropName, embeddedPropName]`\n let embeddedIn: string | undefined;\n let embeddedPropName: string | undefined;\n if (prop.embedded !== undefined) {\n const parentPropName = prop.embedded[0];\n embeddedIn = owningMeta.properties[parentPropName]?.type;\n embeddedPropName = prop.embedded[1];\n }\n\n const isDiscriminator =\n owningMeta.discriminatorColumn !== undefined && prop.name === owningMeta.discriminatorColumn;\n\n const enumItems =\n prop.enum === true && Array.isArray(prop.items) && prop.items.length > 0\n ? prop.items.map((item) => String(item))\n : undefined;\n\n return [\n {\n propName: prop.name,\n fieldName: prop.fieldNames?.[0] ?? prop.name,\n // Store the original type (e.g. `varchar(255)`); the Mermaid renderer\n // sanitizes it for diagram identifiers, while the markdown table shows\n // it verbatim. Guard against a missing type so downstream string\n // handling never sees undefined (matches the FK path's defaulting).\n type: prop.type ?? 'unknown',\n isPrimary: prop.primary === true,\n isForeignKey: false,\n isUnique: prop.unique === true,\n isNullable: prop.nullable === true,\n ...(prop.comment !== undefined && { comment: prop.comment }),\n ...(formulaExpr !== undefined && { formula: formulaExpr }),\n ...(embeddedIn !== undefined && { embeddedIn }),\n ...(embeddedPropName !== undefined && { embeddedPropName }),\n ...(isDiscriminator && { isDiscriminator: true }),\n ...(enumItems !== undefined && { enumItems }),\n },\n ];\n }\n\n // FK columns: m:1 always owns the FK; 1:1 only when owner === true\n if (prop.kind === ReferenceKind.MANY_TO_ONE || (prop.kind === ReferenceKind.ONE_TO_ONE && prop.owner === true)) {\n const cols = buildForeignKeyColumns(prop, metaByClass);\n if (prop.type === owningMeta.className) {\n return cols.map((col) => ({ ...col, isSelfReference: true }));\n }\n return cols;\n }\n\n // ONE_TO_MANY, MANY_TO_MANY (both owner and inverse) → no physical column\n return [];\n}\n\n/**\n * Calls the FormulaCallback with a dummy table and column proxy to extract the SQL expression.\n * String-based formulas (most common) ignore their arguments and return the literal string.\n * Function-based formulas use the alias/column names from the dummy objects.\n * Returns a visible fallback on unexpected errors so generated docs do not hide\n * that the expression could not be resolved.\n */\nfunction resolveFormulaExpr(cb: (table: FormulaTable, cols: Record<string, string>) => string): string {\n try {\n const cols = new Proxy<Record<string, string>>(\n {},\n {\n get: (_target: Record<string, string>, key: string | symbol): string => (typeof key === 'string' ? key : ''),\n }\n );\n const result = cb(FORMULA_DUMMY_TABLE, cols);\n // The callback is typed to return a string, but a misbehaving formula can\n // return anything; coerce so downstream string handling never crashes.\n return typeof result === 'string' ? result : String(result);\n } catch {\n return UNRESOLVED_FORMULA;\n }\n}\n\nfunction buildForeignKeyColumns(prop: EntityProperty, metaByClass: Map<string, EntityMetadata>): ColumnModel[] {\n const fieldNames = prop.fieldNames && prop.fieldNames.length > 0 ? prop.fieldNames : [`${prop.name}_id`];\n const fkTypes = resolveFkTypes(prop, metaByClass, fieldNames.length);\n\n return fieldNames.map((fieldName, index) => ({\n propName: prop.name,\n fieldName,\n type: fkTypes[index] ?? fkTypes[0] ?? 'integer',\n isPrimary: prop.primary === true,\n isForeignKey: true,\n isUnique: prop.unique === true,\n isNullable: prop.nullable === true,\n ...(prop.comment !== undefined && { comment: prop.comment }),\n referencedEntity: prop.type,\n }));\n}\n\n/** Looks up referenced PK types to use as FK column types, preserving composite key order. */\nfunction resolveFkTypes(\n prop: EntityProperty,\n metaByClass: Map<string, EntityMetadata>,\n fieldNameCount: number\n): string[] {\n const refMeta = metaByClass.get(prop.type);\n if (!refMeta) {\n return Array.from({ length: fieldNameCount }, () => 'integer');\n }\n\n const primaryProps = getPrimaryProps(refMeta);\n const referencedColumnNames = prop.referencedColumnNames ?? [];\n return Array.from({ length: fieldNameCount }, (_value, index) => {\n const referencedColumnName = referencedColumnNames[index];\n const pkProp =\n referencedColumnName !== undefined\n ? primaryProps.find((candidate) => candidate.fieldNames.includes(referencedColumnName))\n : undefined;\n\n const resolvedProp = pkProp ?? primaryProps[index] ?? primaryProps[0];\n const rawType = resolvedProp?.type ?? 'integer';\n // Pass the resolved prop's position so recursive calls follow the same column in\n // deeper entities (preserves composite-key alignment through FK-as-PK chains).\n const pkIndex = resolvedProp !== undefined ? primaryProps.indexOf(resolvedProp) : 0;\n return resolveScalarType(rawType, metaByClass, pkIndex);\n });\n}\n\n/**\n * Follows entity-class-name references until a non-entity scalar type is reached.\n * Handles supertype-subtype chains where B.id is FK to A, and C.id is FK to B.\n * pkIndex preserves composite-key column alignment at each level of the chain.\n */\nfunction resolveScalarType(type: string, metaByClass: Map<string, EntityMetadata>, pkIndex = 0, depth = 0): string {\n if (depth >= 5) {\n return 'integer';\n }\n const refMeta = metaByClass.get(type);\n if (!refMeta) {\n return type;\n }\n const primaryProps = getPrimaryProps(refMeta);\n if (primaryProps.length === 0) {\n return type;\n }\n const targetProp = primaryProps[pkIndex] ?? primaryProps[0];\n const nextType = targetProp?.type ?? type;\n if (nextType === type) {\n return type;\n }\n return resolveScalarType(nextType, metaByClass, pkIndex, depth + 1);\n}\n\nfunction getPrimaryProps(meta: EntityMetadata): EntityProperty[] {\n const primaryKeys = meta.primaryKeys ?? [];\n const orderedPrimaryProps = primaryKeys\n .map((key) => meta.properties[String(key)])\n .filter((prop): prop is EntityProperty => prop !== undefined);\n\n if (orderedPrimaryProps.length > 0) {\n return orderedPrimaryProps;\n }\n\n return Object.values(meta.properties).filter((prop) => prop.primary === true);\n}\n\n/** Collects indexes, unique constraints, and check constraints from entity-level metadata. */\nfunction buildConstraints(meta: EntityMetadata): ConstraintModel[] {\n const result: ConstraintModel[] = [];\n\n for (const idx of meta.indexes ?? []) {\n const props = idx.properties;\n result.push({\n type: 'index',\n properties: resolveConstraintProperties(meta, props),\n ...(idx.name !== undefined && { name: idx.name }),\n });\n }\n\n for (const uniq of meta.uniques ?? []) {\n const props = uniq.properties;\n result.push({\n type: 'unique',\n properties: resolveConstraintProperties(meta, props),\n ...(uniq.name !== undefined && { name: uniq.name }),\n });\n }\n\n for (const check of meta.checks ?? []) {\n // Skip function-based check expressions (they require column reference objects at runtime)\n if (typeof check.expression !== 'string') {\n continue;\n }\n result.push({\n type: 'check',\n properties: [],\n expression: check.expression,\n ...(check.name !== undefined && { name: check.name }),\n });\n }\n\n return result;\n}\n\nfunction resolveConstraintProperties(meta: EntityMetadata, props: string | string[] | undefined): string[] {\n const propNames = Array.isArray(props) ? props : props !== undefined ? [props] : [];\n\n return propNames.flatMap((propName) => {\n const prop = meta.properties[String(propName)];\n if (prop === undefined) {\n return [String(propName)];\n }\n\n if (prop.fieldNames !== undefined && prop.fieldNames.length > 0) {\n return prop.fieldNames;\n }\n\n return [prop.name];\n });\n}\n\n/**\n * Builds edges only from owning sides to avoid duplicate arrows.\n * STI inheritance is not drawn as an edge — it is conveyed through table captions instead.\n */\nfunction buildRelationEdges(metas: EntityMetadata[]): RelationEdge[] {\n const edges: RelationEdge[] = [];\n\n for (const meta of metas) {\n if (meta.pivotTable || meta.embeddable) {\n continue;\n }\n\n for (const prop of Object.values(meta.properties)) {\n const edge = buildEdge(meta.className, prop);\n if (edge !== null) {\n edges.push(edge);\n }\n }\n }\n\n return edges;\n}\n\nfunction buildEdge(fromEntity: string, prop: EntityProperty): RelationEdge | null {\n const isNullable = prop.nullable === true;\n\n if (prop.kind === ReferenceKind.MANY_TO_ONE) {\n if (prop.type === fromEntity) {\n return null; // self-reference: shown as column comment, not a relation line\n }\n return {\n fromEntity,\n toEntity: prop.type,\n fromCardinality: '}o',\n toCardinality: isNullable ? 'o|' : '||',\n label: prop.name,\n };\n }\n\n if (prop.kind === ReferenceKind.ONE_TO_ONE && prop.owner === true) {\n return {\n fromEntity,\n toEntity: prop.type,\n fromCardinality: '||',\n toCardinality: isNullable ? 'o|' : '||',\n label: prop.name,\n };\n }\n\n if (prop.kind === ReferenceKind.MANY_TO_MANY && prop.owner === true) {\n return {\n fromEntity,\n toEntity: prop.type,\n fromCardinality: '}o',\n toCardinality: 'o{',\n label: prop.name,\n };\n }\n\n return null;\n}\n\n/**\n * Maps DB-specific or ORM-internal type strings to RDBMS-agnostic generic types\n * so the generated docs are portable across PostgreSQL, MySQL, SQLite, etc.\n */\nexport function normalizeType(type: string): string {\n const t = type.toLowerCase().trim();\n if (t === 'uuid' || t === 'text' || t === 'string' || t.startsWith('varchar')) {\n return 'string';\n }\n if (t === 'timestamptz' || t === 'timestamp' || t === 'datetime') {\n return 'datetime';\n }\n if (t === 'integer' || t === 'int' || t === 'bigint' || t === 'smallint') {\n return 'integer';\n }\n if (t === 'doubletype' || t === 'double precision' || t === 'double' || t === 'float' || t === 'decimal') {\n return 'float';\n }\n if (t === 'boolean' || t === 'bool') {\n return 'boolean';\n }\n if (t === 'jsonb') {\n return 'json';\n }\n return type;\n}\n\n/**\n * Renders a DiagramModel as a Mermaid erDiagram block string.\n * The returned string starts with \"erDiagram\" and is ready to embed in a\n * markdown code fence.\n */\nexport function renderErDiagram(model: DiagramModel): string {\n const lines: string[] = ['erDiagram'];\n\n for (const entity of model.entities) {\n lines.push(` ${toMermaidIdentifier(entity.className)} {`);\n for (const col of entity.columns) {\n lines.push(` ${renderColumnLine(col)}`);\n }\n lines.push(' }');\n }\n\n for (const rel of model.relations) {\n lines.push(\n ` ${toMermaidIdentifier(rel.fromEntity)} ${rel.fromCardinality}--${rel.toCardinality} ${toMermaidIdentifier(rel.toEntity)} : \"${escapeMermaidQuotedText(rel.label)}\"`\n );\n }\n\n return lines.join('\\n');\n}\n\nfunction renderColumnLine(col: ColumnModel): string {\n // Priority: PK > UK (FK qualifier omitted — relationship lines already convey FK relationships)\n let qualifier = '';\n if (col.isPrimary) {\n qualifier = ' PK';\n } else if (col.isUnique) {\n qualifier = ' UK';\n }\n\n // Comment priority (MikroORM-specific markers only — keeps the diagram uncluttered).\n // Renamed columns: FK columns surface their TS name in the markdown table's Key\n // cell (\"FK (propName)\"); plain renamed scalars show only the DB column name.\n // 1. @Formula SQL expression — \"formula: LENGTH(name)\"\n // 2. STI discriminator column — \"discriminator\"\n // 3. Embedded source type — \"[Address]\"\n let comment: string | undefined;\n if (col.formula !== undefined) {\n comment = col.formula ? `formula: ${col.formula}` : 'formula';\n } else if (col.isDiscriminator) {\n comment = 'discriminator';\n } else if (col.embeddedIn !== undefined) {\n comment = `[${col.embeddedIn}]`;\n } else if (col.isSelfReference) {\n comment = 'self-ref';\n }\n\n const commentStr = comment !== undefined ? ` \"${escapeMermaidQuotedText(comment)}\"` : '';\n return `${toMermaidIdentifier(normalizeType(col.type))} ${toMermaidIdentifier(col.fieldName)}${qualifier}${commentStr}`;\n}\n","const MARKDOWN_INLINE_SPECIAL_CHARS = /[\\\\`|*#]/g;\nconst MERMAID_IDENTIFIER_INVALID_CHARS = /[^a-zA-Z0-9_]/g;\n\nfunction normalizeInlineText(value: string): string {\n return value\n .replace(/\\r\\n?/g, '\\n')\n .replace(/[\\n\\t]+/g, ' ')\n .replace(/\\s{2,}/g, ' ')\n .trim();\n}\n\nfunction splitNormalizedLines(value: string): string[] {\n return value.replace(/\\r\\n?/g, '\\n').split('\\n');\n}\n\nfunction escapeHtmlText(value: string): string {\n return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');\n}\n\nexport function escapeMarkdownInline(value: string): string {\n return escapeHtmlText(normalizeInlineText(value)).replace(MARKDOWN_INLINE_SPECIAL_CHARS, '\\\\$&');\n}\n\nexport function escapeMarkdownTableCell(value: string): string {\n return splitNormalizedLines(value)\n .map((line) => escapeMarkdownInline(line))\n .join('<br>');\n}\n\n/**\n * Escapes a multi-line paragraph for markdown body text, preserving line breaks\n * as hard breaks (two trailing spaces + newline) instead of collapsing them to\n * a single space. Used for the document description, which the programmatic API\n * accepts as free-form multi-line text.\n */\nexport function escapeMarkdownParagraph(value: string): string {\n return splitNormalizedLines(value)\n .map((line) => escapeMarkdownInline(line))\n .join(' \\n');\n}\n\nexport function renderMarkdownBlockQuote(value: string): string {\n return splitNormalizedLines(value)\n .map((line) => `> ${escapeMarkdownInline(line)}`)\n .join('\\n');\n}\n\nexport function renderMarkdownInlineCode(value: string): string {\n const normalized = normalizeInlineText(value);\n const backtickRuns = normalized.match(/`+/g) ?? [];\n const longestRun = Math.max(0, ...backtickRuns.map((run) => run.length));\n const fence = '`'.repeat(longestRun + 1);\n const needsPadding = normalized.startsWith('`') || normalized.endsWith('`');\n const content = needsPadding ? ` ${normalized} ` : normalized;\n return `${fence}${content}${fence}`;\n}\n\nexport function toMermaidIdentifier(value: string): string {\n const normalized = normalizeInlineText(value).replace(MERMAID_IDENTIFIER_INVALID_CHARS, '_').replace(/_+/g, '_');\n const identifier = normalized === '' ? '_' : normalized;\n return /^[a-zA-Z_]/.test(identifier) ? identifier : `_${identifier}`;\n}\n\nexport function escapeMermaidQuotedText(value: string): string {\n return normalizeInlineText(value).replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n}\n\n/**\n * Builds a GitHub-style heading anchor slug for in-document links.\n * Lowercases, drops characters other than letters / numbers / underscores /\n * spaces / hyphens, then turns spaces into hyphens. The letter/number classes\n * are Unicode-aware (\\p{L}, \\p{N}), so non-ASCII headings such as a Korean\n * namespace name keep their characters and match GitHub's generated anchor.\n */\nexport function toMarkdownAnchor(value: string): string {\n return normalizeInlineText(value)\n .toLowerCase()\n .replace(/[^\\p{L}\\p{N}\\s_-]/gu, '')\n .replace(/\\s+/g, '-');\n}\n","import type { Options } from '@mikro-orm/core';\n\n/**\n * When the config does not choose a metadata provider, opt into\n * `TsMorphMetadataProvider` if `@mikro-orm/reflection` is installed.\n *\n * The CLI loads `.ts` configs through `tsx` (esbuild), which strips\n * `emitDecoratorMetadata`, so MikroORM's default `ReflectMetadataProvider`\n * cannot infer types for entities that omit explicit `type:`/`entity:`\n * attributes. `TsMorphMetadataProvider` reads types from the TypeScript sources\n * instead. When the optional package is absent the original options are kept.\n */\nexport async function withTsMorphMetadataProvider(\n options: Options,\n onWarn?: (message: string) => void\n): Promise<Options> {\n if (options.metadataProvider !== undefined) {\n return options;\n }\n\n try {\n const { TsMorphMetadataProvider } = await import('@mikro-orm/reflection');\n return { ...options, metadataProvider: TsMorphMetadataProvider };\n } catch (err) {\n const code =\n err !== null && typeof err === 'object' && 'code' in err ? (err as NodeJS.ErrnoException).code : undefined;\n const isNotInstalled = code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND';\n\n if (!isNotInstalled && onWarn) {\n onWarn(\n `@mikro-orm/reflection is installed but failed to load: ${err instanceof Error ? err.message : String(err)}. ` +\n 'Ensure all @mikro-orm/* packages are installed at the same version.'\n );\n }\n\n return options;\n }\n}\n","import type { DocumentModel, EnrichedEntity, NamespaceGroup } from '../model/build.js';\nimport type { ColumnModel, ConstraintModel, DiagramModel } from '../model/types.js';\nimport {\n escapeMarkdownInline,\n escapeMarkdownParagraph,\n escapeMarkdownTableCell,\n renderMarkdownBlockQuote,\n renderMarkdownInlineCode,\n toMarkdownAnchor,\n} from './escape.js';\nimport { normalizeType, renderErDiagram } from './mermaid.js';\n\n/**\n * Renders a DocumentModel as a markdown string.\n * Each namespace group becomes a level-2 section with a Mermaid ERD block\n * followed by per-entity column tables.\n */\nexport function renderMarkdown(docModel: DocumentModel): string {\n const sections: string[] = [`# ${escapeMarkdownInline(docModel.title)}`];\n\n if (docModel.description) {\n sections.push(escapeMarkdownParagraph(docModel.description));\n }\n\n // A table of contents only helps when there is more than one namespace section.\n if (docModel.groups.length > 1) {\n sections.push(renderTableOfContents(docModel.groups));\n }\n\n for (const group of docModel.groups) {\n sections.push(renderGroupSection(group));\n }\n\n return sections.join('\\n\\n');\n}\n\n/**\n * Renders a bulleted markdown section: a header line, a blank line, then one\n * line per item. Shared by the Contents / Computed columns / Constraints\n * sections, which differ only in their header and per-item formatting.\n */\nfunction renderBulletSection<T>(header: string, items: T[], renderItem: (item: T) => string): string {\n const lines = [header, ''];\n for (const item of items) {\n lines.push(renderItem(item));\n }\n return lines.join('\\n');\n}\n\n/** Renders a namespace-level table of contents linking to each group's H2 section. */\nfunction renderTableOfContents(groups: NamespaceGroup[]): string {\n return renderBulletSection('## Contents', groups, (group) => {\n // escapeMarkdownInline does not touch brackets; escape them here so a name\n // containing `[` or `]` cannot prematurely close the link label `[...]`.\n const label = escapeMarkdownInline(group.name).replace(/[[\\]]/g, '\\\\$&');\n return `- [${label}](#${toMarkdownAnchor(group.name)})`;\n });\n}\n\nfunction renderGroupSection(group: NamespaceGroup): string {\n const parts: string[] = [`## ${escapeMarkdownInline(group.name)}`];\n\n if (group.erdEntities.length > 0) {\n const diagramModel: DiagramModel = {\n entities: group.erdEntities.map((e) => e.model),\n relations: group.erdRelations,\n };\n parts.push('```mermaid\\n' + renderErDiagram(diagramModel) + '\\n```');\n }\n\n for (const entity of group.textEntities) {\n parts.push(renderEntitySection(entity));\n }\n\n return parts.join('\\n\\n');\n}\n\nfunction renderEntitySection(entity: EnrichedEntity): string {\n const parts: string[] = [`### ${escapeMarkdownInline(entity.model.className)}`];\n\n // The actual DB table name is what readers of a schema doc look for first,\n // and it is not otherwise visible (the ERD and heading use the class name).\n parts.push(`*Table: ${renderMarkdownInlineCode(entity.model.tableName)}*`);\n\n if (entity.jsDoc?.description) {\n parts.push(renderMarkdownBlockQuote(entity.jsDoc.description));\n }\n\n // STI metadata note\n if (entity.model.discriminatorColumn) {\n parts.push(`*STI root — discriminator column: ${renderMarkdownInlineCode(entity.model.discriminatorColumn)}*`);\n } else if (entity.model.extendsEntity) {\n const discValue =\n entity.model.discriminatorValue !== undefined\n ? `, discriminator value: ${renderMarkdownInlineCode(entity.model.discriminatorValue)}`\n : '';\n parts.push(\n `*Extends ${renderMarkdownInlineCode(entity.model.extendsEntity)} (Single Table Inheritance${discValue})*`\n );\n }\n\n if (entity.model.columns.length > 0) {\n parts.push(renderColumnTable(entity));\n }\n\n if (entity.model.constraints.length > 0) {\n parts.push(renderConstraints(entity.model.constraints));\n }\n\n const computedColumns = entity.model.columns.filter((col) => col.formula !== undefined);\n if (computedColumns.length > 0) {\n parts.push(renderComputedColumns(computedColumns));\n }\n\n return parts.join('\\n\\n');\n}\n\nfunction renderColumnTable(entity: EnrichedEntity): string {\n const header = '| Column | Type | Key | Nullable | Description |';\n const sep = '|--------|------|-----|----------|-------------|';\n const rows = entity.model.columns.map((col) => {\n const key = resolveColumnKey(col);\n const nullable = col.isNullable && !col.isPrimary ? 'Y' : '';\n // JSDoc property description wins; fall back to the @Property({ comment }) DDL comment.\n const docDesc = entity.propDocs.get(col.propName)?.description ?? col.comment ?? '';\n // Surface @Enum allowed values; the table cell escapes backticks, so plain text.\n const enumDesc = col.enumItems !== undefined ? `One of: ${col.enumItems.join(', ')}` : '';\n const desc = [docDesc, enumDesc].filter((part) => part !== '').join('\\n');\n return `| ${escapeMarkdownTableCell(col.fieldName)} | ${escapeMarkdownTableCell(normalizeType(col.type))} | ${escapeMarkdownTableCell(key)} | ${nullable} | ${escapeMarkdownTableCell(desc)} |`;\n });\n return [header, sep, ...rows].join('\\n');\n}\n\n/** Returns the \"Key\" cell value for the column table. */\nfunction resolveColumnKey(col: ColumnModel): string {\n const fkKey = col.fieldName !== col.propName ? `FK (${col.propName})` : 'FK';\n\n if (col.isPrimary && col.isForeignKey) {\n return `PK, ${fkKey}`;\n }\n if (col.isPrimary) {\n return 'PK';\n }\n if (col.isForeignKey) {\n // Show TS property name in parentheses if it differs from the DB column name\n return fkKey;\n }\n if (col.isUnique) {\n return 'UK';\n }\n if (col.isDiscriminator) {\n return 'discriminator';\n }\n if (col.embeddedIn !== undefined) {\n return `[${col.embeddedIn}]`;\n }\n return '';\n}\n\nfunction renderComputedColumns(columns: ColumnModel[]): string {\n return renderBulletSection('**Computed columns:**', columns, (col) => {\n // An empty/unresolved formula expression renders as just the column name —\n // the \"Computed columns\" heading already conveys that it is computed, and\n // an empty inline-code span would be broken output.\n const expr = col.formula ? `: ${renderMarkdownInlineCode(col.formula)}` : '';\n return `- ${renderMarkdownInlineCode(col.fieldName)}${expr}`;\n });\n}\n\nfunction renderConstraints(constraints: ConstraintModel[]): string {\n return renderBulletSection('**Constraints:**', constraints, (c) => {\n const name = c.name ? ` ${renderMarkdownInlineCode(c.name)}` : '';\n const properties = c.properties.map(escapeMarkdownInline).join(', ');\n if (c.type === 'index') {\n return `- Index${name}: (${properties})`;\n }\n if (c.type === 'unique') {\n return `- Unique${name}: (${properties})`;\n }\n return `- Check${name}: ${renderMarkdownInlineCode(c.expression ?? '')}`;\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,sBA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SAAS,CAAC,KAAK,IAAI,OAAO,GAAG;AACrD,SAAK,IAAI,OAAO;AAChB,aAAS,KAAK,QAAQ,OAAO;AAC7B,cAAW,QAAgC;AAAA,EAC7C;AAEA,SAAO;AACT;AAEA,SAAS,2BAA2B,KAAuB;AACzD,SAAO,cAAc,GAAG,EAAE,KAAK,CAAC,YAAY,QAAQ,SAAS,aAAa,KAAK,QAAQ,SAAS,WAAW,CAAC;AAC9G;AAEA,eAAe,sCACb,aACA,cAC+B;AAC/B,MAAI;AACF,WAAO,MAAM,mBAAmB,YAAY;AAAA,EAC9C,SAAS,KAAK;AACZ,UAAM,kBAAkB,YAAY,qBAAqB,UAAa,aAAa,qBAAqB;AACxG,QAAI,CAAC,mBAAmB,CAAC,2BAA2B,GAAG,GAAG;AACxD,YAAM;AAAA,IACR;AAEA,QAAI;AACF,aAAO,MAAM,mBAAmB,WAAW;AAAA,IAC7C,QAAQ;AACN,YAAM;AAAA,IACR;AAAA,EACF;AACF;AAsBA,eAAsB,iBAAiB,SAAmD;AACxF,QAAM,EAAE,KAAK,QAAQ,mBAAmB,aAAa,KAAK,OAAO,IAAI;AAErE,QAAM,eAAe,MAAM,4BAA4B,KAAK,MAAM;AAClE,QAAM,EAAE,OAAO,YAAY,IAAI,MAAM,sCAAsC,KAAK,YAAY;AAC5F,QAAM,cAAc,UAAU,oBAAoB,aAAa,KAAK,MAAM,CAAC;AAC3E,MAAI,QAAQ,UAAa,IAAI,SAAS,GAAG;AACvC,sCAAkC,OAAO,aAAa,KAAK,MAAM;AAAA,EACnE;AACA,QAAM,WAAW,mBAAmB,OAAO,aAAa,OAAO,aAAa,MAAM;AAClF,SAAO,eAAe,QAAQ;AAChC;","names":["import_core","import_core"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -6,18 +6,6 @@ declare class MetadataLoadError extends Error {
|
|
|
6
6
|
constructor(message: string, cause?: unknown | undefined);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
/** Options accepted by the main generateMarkdown function and CLI. */
|
|
10
|
-
interface GenerateOptions {
|
|
11
|
-
/** Path to the MikroORM config file (default: mikro-orm.config.ts). */
|
|
12
|
-
config: string;
|
|
13
|
-
/** Output markdown file path (default: ERD.md). */
|
|
14
|
-
out: string;
|
|
15
|
-
/** Title shown at the top of the generated document. */
|
|
16
|
-
title: string;
|
|
17
|
-
/** Glob patterns for TypeScript entity source files (for JSDoc extraction). */
|
|
18
|
-
src?: string[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
9
|
/** Options for the programmatic API. */
|
|
22
10
|
interface GenerateMarkdownOptions {
|
|
23
11
|
/** MikroORM configuration (driver, entities, dbName, …). */
|
|
@@ -27,16 +15,33 @@ interface GenerateMarkdownOptions {
|
|
|
27
15
|
/** Optional description paragraph rendered below the H1 heading. */
|
|
28
16
|
description?: string;
|
|
29
17
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
18
|
+
* Source globs/paths (`.ts`) to read JSDoc from. Use this when your entities
|
|
19
|
+
* run from compiled JavaScript (`entities: ['./dist/**\/*.js']`): build tools
|
|
20
|
+
* strip comments, so descriptions and `@namespace`/`@hidden` tags would
|
|
21
|
+
* otherwise be lost. Defaults to each entity's own discovered source file.
|
|
33
22
|
*/
|
|
34
23
|
src?: string[];
|
|
24
|
+
/** Receives non-fatal warnings (e.g. JSDoc cannot be read from compiled JS). */
|
|
25
|
+
onWarn?: (message: string) => void;
|
|
35
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Decides which files JSDoc should be read from.
|
|
29
|
+
*
|
|
30
|
+
* When the caller provides `src`, those paths win. Otherwise we fall back to the
|
|
31
|
+
* source files MikroORM discovered each entity from — and if those are compiled
|
|
32
|
+
* JavaScript, JSDoc (descriptions, `@namespace`, and crucially `@hidden`) is
|
|
33
|
+
* gone, so we warn the user and point them at `src`.
|
|
34
|
+
*/
|
|
35
|
+
declare function resolveJsDocSources(sourcePaths: string[], src: string[] | undefined, onWarn?: (message: string) => void): string[];
|
|
36
36
|
/**
|
|
37
37
|
* Generates a Mermaid ERD + markdown documentation document from MikroORM
|
|
38
38
|
* entity metadata.
|
|
39
39
|
*
|
|
40
|
+
* JSDoc tags (@namespace, @erd, @describe, @hidden) and descriptions are
|
|
41
|
+
* read directly from each entity's own source file — no separate path needs
|
|
42
|
+
* to be specified. When entities run from compiled JavaScript (where comments
|
|
43
|
+
* are stripped), pass `src` to read JSDoc from the original `.ts` files.
|
|
44
|
+
*
|
|
40
45
|
* @example
|
|
41
46
|
* ```ts
|
|
42
47
|
* import { generateMarkdown } from 'mikro-orm-markdown';
|
|
@@ -45,10 +50,9 @@ interface GenerateMarkdownOptions {
|
|
|
45
50
|
* const markdown = await generateMarkdown({
|
|
46
51
|
* orm: ormConfig,
|
|
47
52
|
* title: 'My Database',
|
|
48
|
-
* src: ['src/entities/*.ts'],
|
|
49
53
|
* });
|
|
50
54
|
* ```
|
|
51
55
|
*/
|
|
52
56
|
declare function generateMarkdown(options: GenerateMarkdownOptions): Promise<string>;
|
|
53
57
|
|
|
54
|
-
export { type GenerateMarkdownOptions,
|
|
58
|
+
export { type GenerateMarkdownOptions, MetadataLoadError, generateMarkdown, resolveJsDocSources };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,18 +6,6 @@ declare class MetadataLoadError extends Error {
|
|
|
6
6
|
constructor(message: string, cause?: unknown | undefined);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
/** Options accepted by the main generateMarkdown function and CLI. */
|
|
10
|
-
interface GenerateOptions {
|
|
11
|
-
/** Path to the MikroORM config file (default: mikro-orm.config.ts). */
|
|
12
|
-
config: string;
|
|
13
|
-
/** Output markdown file path (default: ERD.md). */
|
|
14
|
-
out: string;
|
|
15
|
-
/** Title shown at the top of the generated document. */
|
|
16
|
-
title: string;
|
|
17
|
-
/** Glob patterns for TypeScript entity source files (for JSDoc extraction). */
|
|
18
|
-
src?: string[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
9
|
/** Options for the programmatic API. */
|
|
22
10
|
interface GenerateMarkdownOptions {
|
|
23
11
|
/** MikroORM configuration (driver, entities, dbName, …). */
|
|
@@ -27,16 +15,33 @@ interface GenerateMarkdownOptions {
|
|
|
27
15
|
/** Optional description paragraph rendered below the H1 heading. */
|
|
28
16
|
description?: string;
|
|
29
17
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
18
|
+
* Source globs/paths (`.ts`) to read JSDoc from. Use this when your entities
|
|
19
|
+
* run from compiled JavaScript (`entities: ['./dist/**\/*.js']`): build tools
|
|
20
|
+
* strip comments, so descriptions and `@namespace`/`@hidden` tags would
|
|
21
|
+
* otherwise be lost. Defaults to each entity's own discovered source file.
|
|
33
22
|
*/
|
|
34
23
|
src?: string[];
|
|
24
|
+
/** Receives non-fatal warnings (e.g. JSDoc cannot be read from compiled JS). */
|
|
25
|
+
onWarn?: (message: string) => void;
|
|
35
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Decides which files JSDoc should be read from.
|
|
29
|
+
*
|
|
30
|
+
* When the caller provides `src`, those paths win. Otherwise we fall back to the
|
|
31
|
+
* source files MikroORM discovered each entity from — and if those are compiled
|
|
32
|
+
* JavaScript, JSDoc (descriptions, `@namespace`, and crucially `@hidden`) is
|
|
33
|
+
* gone, so we warn the user and point them at `src`.
|
|
34
|
+
*/
|
|
35
|
+
declare function resolveJsDocSources(sourcePaths: string[], src: string[] | undefined, onWarn?: (message: string) => void): string[];
|
|
36
36
|
/**
|
|
37
37
|
* Generates a Mermaid ERD + markdown documentation document from MikroORM
|
|
38
38
|
* entity metadata.
|
|
39
39
|
*
|
|
40
|
+
* JSDoc tags (@namespace, @erd, @describe, @hidden) and descriptions are
|
|
41
|
+
* read directly from each entity's own source file — no separate path needs
|
|
42
|
+
* to be specified. When entities run from compiled JavaScript (where comments
|
|
43
|
+
* are stripped), pass `src` to read JSDoc from the original `.ts` files.
|
|
44
|
+
*
|
|
40
45
|
* @example
|
|
41
46
|
* ```ts
|
|
42
47
|
* import { generateMarkdown } from 'mikro-orm-markdown';
|
|
@@ -45,10 +50,9 @@ interface GenerateMarkdownOptions {
|
|
|
45
50
|
* const markdown = await generateMarkdown({
|
|
46
51
|
* orm: ormConfig,
|
|
47
52
|
* title: 'My Database',
|
|
48
|
-
* src: ['src/entities/*.ts'],
|
|
49
53
|
* });
|
|
50
54
|
* ```
|
|
51
55
|
*/
|
|
52
56
|
declare function generateMarkdown(options: GenerateMarkdownOptions): Promise<string>;
|
|
53
57
|
|
|
54
|
-
export { type GenerateMarkdownOptions,
|
|
58
|
+
export { type GenerateMarkdownOptions, MetadataLoadError, generateMarkdown, resolveJsDocSources };
|