drizzle-docs-generator 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +59 -15
- package/README.md +55 -11
- package/dist/adapter/types.d.ts +40 -0
- package/dist/adapter/types.d.ts.map +1 -0
- package/dist/adapter/v0-adapter.d.ts +73 -0
- package/dist/adapter/v0-adapter.d.ts.map +1 -0
- package/dist/adapter/v0-adapter.js +136 -0
- package/dist/adapter/v0-adapter.js.map +1 -0
- package/dist/adapter/v1-adapter.d.ts +40 -0
- package/dist/adapter/v1-adapter.d.ts.map +1 -0
- package/dist/adapter/v1-adapter.js +83 -0
- package/dist/adapter/v1-adapter.js.map +1 -0
- package/dist/cli/index.js +194 -71
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/integration-test-utils.d.ts +19 -0
- package/dist/cli/integration-test-utils.d.ts.map +1 -0
- package/dist/formatter/dbml-builder.d.ts +29 -0
- package/dist/formatter/dbml-builder.d.ts.map +1 -0
- package/dist/formatter/dbml-builder.js +39 -0
- package/dist/formatter/dbml-builder.js.map +1 -0
- package/dist/formatter/dbml.d.ts +81 -0
- package/dist/formatter/dbml.d.ts.map +1 -0
- package/dist/formatter/dbml.js +163 -0
- package/dist/formatter/dbml.js.map +1 -0
- package/dist/formatter/markdown.d.ts +126 -0
- package/dist/formatter/markdown.d.ts.map +1 -0
- package/dist/formatter/markdown.js +235 -0
- package/dist/formatter/markdown.js.map +1 -0
- package/dist/formatter/mermaid.d.ts +102 -0
- package/dist/formatter/mermaid.d.ts.map +1 -0
- package/dist/formatter/mermaid.js +177 -0
- package/dist/formatter/mermaid.js.map +1 -0
- package/dist/formatter/types.d.ts +37 -0
- package/dist/formatter/types.d.ts.map +1 -0
- package/dist/generator/common.d.ts +115 -208
- package/dist/generator/common.d.ts.map +1 -1
- package/dist/generator/common.js +260 -479
- package/dist/generator/common.js.map +1 -1
- package/dist/generator/mysql.js +3 -3
- package/dist/generator/pg.d.ts +8 -7
- package/dist/generator/pg.d.ts.map +1 -1
- package/dist/generator/pg.js +29 -31
- package/dist/generator/pg.js.map +1 -1
- package/dist/generator/sqlite.js +3 -3
- package/dist/index.d.ts +15 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -18
- package/dist/index.js.map +1 -1
- package/dist/test-utils/cli-runner.d.ts +4 -1
- package/dist/test-utils/cli-runner.d.ts.map +1 -1
- package/dist/test-utils/dbml-validator.d.ts +29 -0
- package/dist/test-utils/dbml-validator.d.ts.map +1 -1
- package/dist/types.d.ts +128 -16
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/generator/index.d.ts +0 -15
- package/dist/generator/index.d.ts.map +0 -1
- package/dist/parser/index.d.ts +0 -5
- package/dist/parser/index.d.ts.map +0 -1
- package/dist/test-utils/index.d.ts +0 -7
- package/dist/test-utils/index.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sources":["../../src/generator/common.ts"],"sourcesContent":["import {\n type AnyColumn,\n type Table,\n getTableColumns,\n getTableName,\n is,\n Relation,\n One,\n} from \"drizzle-orm\";\nimport type { AnyRelation, TableRelationalConfig } from \"drizzle-orm/relations\";\nimport { PgTable, getTableConfig as getPgTableConfig } from \"drizzle-orm/pg-core\";\n\n/**\n * Legacy v0 Relations type (for backward compatibility with relations())\n * This is a simplified type - the actual structure is more complex\n */\ntype LegacyRelations = {\n table: Table;\n config: Record<string, unknown>;\n};\nimport { MySqlTable, getTableConfig as getMySqlTableConfig } from \"drizzle-orm/mysql-core\";\nimport { SQLiteTable, getTableConfig as getSqliteTableConfig } from \"drizzle-orm/sqlite-core\";\nimport { writeFileSync, mkdirSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport type { GeneratedRef, GenerateOptions } from \"../types\";\nimport { extractComments, type SchemaComments } from \"../parser/comments\";\nimport { extractRelations, type SchemaRelations } from \"../parser/relations\";\n\n/**\n * Simple DBML string builder\n */\nexport class DbmlBuilder {\n private lines: string[] = [];\n private indentLevel = 0;\n\n /**\n * Increase the indentation level by one\n * @returns This instance for method chaining\n */\n indent(): this {\n this.indentLevel++;\n return this;\n }\n\n /**\n * Decrease the indentation level by one (minimum 0)\n * @returns This instance for method chaining\n */\n dedent(): this {\n this.indentLevel = Math.max(0, this.indentLevel - 1);\n return this;\n }\n\n /**\n * Add a line with the current indentation level\n * @param content - The content to add (empty string adds a blank line)\n * @returns This instance for method chaining\n */\n line(content: string = \"\"): this {\n const indent = \" \".repeat(this.indentLevel);\n this.lines.push(content ? `${indent}${content}` : \"\");\n return this;\n }\n\n /**\n * Build the final DBML string from all added lines\n * @returns The complete DBML content as a string\n */\n build(): string {\n return this.lines.join(\"\\n\");\n }\n}\n\n/**\n * Configuration for different database dialects\n */\nexport interface DialectConfig {\n escapeName: (name: string) => string;\n isIncrement: (column: AnyColumn) => boolean;\n}\n\n/**\n * Table configuration extracted from Drizzle tables\n * Using 'any' types for dialect-agnostic handling\n */\nexport interface TableConfig {\n indexes: unknown[];\n primaryKeys: unknown[];\n uniqueConstraints: unknown[];\n foreignKeys: unknown[];\n}\n\n// Use official v1 types from drizzle-orm/relations:\n// - TableRelationalConfig: { table, name, relations: Record<string, AnyRelation> }\n// - AnyRelation: Relation with sourceColumns, targetColumns, relationType, etc.\n\n/**\n * Base generator class for DBML generation\n */\nexport abstract class BaseGenerator<\n TSchema extends Record<string, unknown> = Record<string, unknown>,\n> {\n protected schema: TSchema;\n protected relational: boolean;\n protected generatedRefs: GeneratedRef[] = [];\n protected comments: SchemaComments | undefined;\n protected parsedRelations: SchemaRelations | undefined;\n protected source: string | undefined;\n protected abstract dialectConfig: DialectConfig;\n\n /**\n * Create a new generator instance\n * @param options - Configuration options including schema, relational mode, source code, and comments\n */\n constructor(options: GenerateOptions<TSchema>) {\n this.schema = options.schema;\n this.relational = options.relational ?? false;\n this.source = options.source;\n\n // Initialize comments from options\n if (options.comments) {\n this.comments = options.comments;\n } else if (this.source) {\n this.comments = extractComments(this.source);\n }\n\n // Extract relations from source if relational mode is enabled\n if (this.relational && this.source) {\n this.parsedRelations = extractRelations(this.source);\n }\n }\n\n /**\n * Generate complete DBML output from the schema\n *\n * Creates DBML representation including:\n * - Table definitions with columns, indexes, and constraints\n * - Foreign key references (from table config or relations)\n * - Comments for tables and columns\n *\n * @returns The complete DBML string\n */\n generate(): string {\n const dbml = new DbmlBuilder();\n const tables = this.getTables();\n const v0Relations = this.getV0Relations();\n const v1Entries = this.getV1RelationEntries();\n\n // Generate tables\n for (const table of tables) {\n this.generateTable(dbml, table);\n dbml.line();\n }\n\n // Generate references from relations\n if (this.relational) {\n // Try v1 defineRelations() first - runtime object parsing with official types\n if (v1Entries.length > 0) {\n this.generateRelationalRefsFromV1(v1Entries);\n }\n // Fall back to v0 relations() with AST parsing\n else if (v0Relations.length > 0 || this.parsedRelations) {\n this.generateRelationalRefsFromV0();\n }\n }\n\n // Add collected refs\n for (const ref of this.generatedRefs) {\n this.generateRef(dbml, ref);\n }\n\n return dbml.build().trim();\n }\n\n /**\n * Get all tables from schema\n *\n * Extracts all Drizzle table objects from the schema by checking each value\n * with isTable() method.\n *\n * @returns Array of table objects\n */\n protected getTables(): Table[] {\n const tables: Table[] = [];\n for (const value of Object.values(this.schema)) {\n if (this.isTable(value)) {\n tables.push(value as Table);\n }\n }\n return tables;\n }\n\n /**\n * Check if a value is a Drizzle table\n *\n * Validates whether a value is a table instance from any supported dialect\n * (PostgreSQL, MySQL, or SQLite).\n *\n * @param value - The value to check\n * @returns True if value is a Drizzle table\n */\n protected isTable(value: unknown): boolean {\n return is(value, PgTable) || is(value, MySqlTable) || is(value, SQLiteTable);\n }\n\n /**\n * Get all v0 relations from schema (legacy relations() API)\n *\n * Extracts legacy relations defined using the old relations() API.\n * These are identified by having 'table' and 'config' properties.\n *\n * @returns Array of legacy relation objects\n */\n protected getV0Relations(): LegacyRelations[] {\n const relations: LegacyRelations[] = [];\n for (const value of Object.values(this.schema)) {\n if (this.isV0Relations(value)) {\n relations.push(value as LegacyRelations);\n }\n }\n return relations;\n }\n\n /**\n * Check if a value is a Drizzle v0 relations object (from relations())\n *\n * Validates the legacy relations() format by checking for 'table' and 'config' properties.\n *\n * @param value - The value to check\n * @returns True if value is a legacy relations object\n */\n protected isV0Relations(value: unknown): boolean {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n // v0 Relations objects have 'table' and 'config' properties\n return (\n \"table\" in value &&\n \"config\" in value &&\n typeof (value as Record<string, unknown>).config === \"object\"\n );\n }\n\n /**\n * Check if a value is a v1 relation entry (from defineRelations())\n *\n * Uses official Drizzle v1 types: TableRelationalConfig with Relation instances.\n * Validates the structure has 'table', 'name', and 'relations' properties with valid types.\n *\n * @param value - The value to check\n * @returns True if value is a v1 relation entry\n */\n protected isV1RelationEntry(value: unknown): value is TableRelationalConfig {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n const obj = value as Record<string, unknown>;\n if (\n !(\"table\" in obj) ||\n !(\"name\" in obj) ||\n typeof obj.name !== \"string\" ||\n !(\"relations\" in obj) ||\n typeof obj.relations !== \"object\" ||\n obj.relations === null\n ) {\n return false;\n }\n // Check that 'relations' contains Relation instances (using drizzle-orm is())\n const relations = obj.relations as Record<string, unknown>;\n const relationValues = Object.values(relations);\n // Empty relations object is valid, but if there are entries, they must be Relations\n if (relationValues.length > 0) {\n return relationValues.some((rel) => is(rel, Relation));\n }\n // If no relations defined, also check table is valid\n return this.isTable(obj.table);\n }\n\n /**\n * Get all v1 relation entries from schema (defineRelations() API)\n *\n * Handles both individual entries and the full defineRelations() result object.\n * Extracts relation configurations that use the modern v1 API with official types.\n *\n * @returns Array of v1 relation entries\n */\n protected getV1RelationEntries(): TableRelationalConfig[] {\n const entries: TableRelationalConfig[] = [];\n for (const value of Object.values(this.schema)) {\n // Check if it's an individual relation entry\n if (this.isV1RelationEntry(value)) {\n entries.push(value);\n }\n // Check if it's the full defineRelations() result object\n // (an object where each value is a relation entry)\n else if (this.isV1DefineRelationsResult(value)) {\n for (const entry of Object.values(value as Record<string, unknown>)) {\n if (this.isV1RelationEntry(entry)) {\n entries.push(entry);\n }\n }\n }\n }\n return entries;\n }\n\n /**\n * Check if a value is a full v1 defineRelations() result object\n *\n * This is an object where all values are TableRelationalConfig objects.\n * Used to detect the full result of calling defineRelations() in v1.\n *\n * @param value - The value to check\n * @returns True if value is a full defineRelations() result\n */\n protected isV1DefineRelationsResult(value: unknown): boolean {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return false;\n }\n const obj = value as Record<string, unknown>;\n const values = Object.values(obj);\n // Must have at least one entry and all must be relation entries\n return values.length > 0 && values.every((v) => this.isV1RelationEntry(v));\n }\n\n /**\n * Generate a table definition in DBML format\n *\n * Creates the complete table definition including columns, indexes, constraints,\n * and table-level comments. Also collects foreign keys if not in relational mode.\n *\n * @param dbml - The DBML builder to add the table to\n * @param table - The Drizzle table to generate\n */\n protected generateTable(dbml: DbmlBuilder, table: Table): void {\n const tableName = getTableName(table);\n const columns = getTableColumns(table);\n const escapedName = this.dialectConfig.escapeName(tableName);\n\n dbml.line(`Table ${escapedName} {`);\n dbml.indent();\n\n // Generate columns\n for (const column of Object.values(columns)) {\n this.generateColumn(dbml, column, tableName);\n }\n\n // Get table configuration (indexes, constraints, etc.)\n const tableConfig = this.getTableConfig(table);\n\n // Generate indexes block if any\n if (tableConfig) {\n this.generateIndexesBlock(dbml, tableConfig);\n }\n\n // Add table-level Note if comment exists\n const tableComment = this.comments?.tables[tableName]?.comment;\n if (tableComment) {\n dbml.line();\n dbml.line(`Note: '${escapeDbmlString(tableComment)}'`);\n }\n\n dbml.dedent();\n dbml.line(\"}\");\n\n // Collect foreign keys if not using relational mode\n if (!this.relational && tableConfig && tableConfig.foreignKeys.length > 0) {\n this.collectForeignKeysFromConfig(tableName, tableConfig.foreignKeys);\n }\n }\n\n /**\n * Get table configuration from a Drizzle table\n *\n * Extracts indexes, primary keys, unique constraints, and foreign keys\n * from the table using the appropriate dialect-specific config getter.\n *\n * @param table - The Drizzle table to get configuration from\n * @returns Table configuration or undefined if dialect is not supported\n */\n protected getTableConfig(table: Table): TableConfig | undefined {\n // Detect dialect and use appropriate config getter\n if (is(table, PgTable)) {\n const config = getPgTableConfig(table);\n return {\n indexes: config.indexes || [],\n primaryKeys: config.primaryKeys || [],\n uniqueConstraints: config.uniqueConstraints || [],\n foreignKeys: config.foreignKeys || [],\n };\n }\n if (is(table, MySqlTable)) {\n const config = getMySqlTableConfig(table);\n return {\n indexes: config.indexes || [],\n primaryKeys: config.primaryKeys || [],\n uniqueConstraints: config.uniqueConstraints || [],\n foreignKeys: config.foreignKeys || [],\n };\n }\n if (is(table, SQLiteTable)) {\n const config = getSqliteTableConfig(table);\n return {\n indexes: config.indexes || [],\n primaryKeys: config.primaryKeys || [],\n uniqueConstraints: config.uniqueConstraints || [],\n foreignKeys: config.foreignKeys || [],\n };\n }\n return undefined;\n }\n\n /**\n * Generate a column definition in DBML format\n *\n * Creates a column line with type and attributes (primary key, not null, unique, etc.)\n * and includes column-level comments if available.\n *\n * @param dbml - The DBML builder to add the column to\n * @param column - The Drizzle column to generate\n * @param tableName - Optional table name for looking up comments\n */\n protected generateColumn(dbml: DbmlBuilder, column: AnyColumn, tableName?: string): void {\n const name = this.dialectConfig.escapeName(column.name);\n const type = this.getColumnType(column);\n const attrs = this.getColumnAttributes(column, tableName);\n const attrStr = this.formatAttributes(attrs);\n\n if (attrStr) {\n dbml.line(`${name} ${type} [${attrStr}]`);\n } else {\n dbml.line(`${name} ${type}`);\n }\n }\n\n /**\n * Get the SQL type for a column\n *\n * @param column - The column to get the SQL type from\n * @returns The SQL type string (e.g., \"varchar\", \"integer\")\n */\n protected getColumnType(column: AnyColumn): string {\n return column.getSQLType();\n }\n\n /**\n * Get column attributes for DBML\n *\n * Extracts attributes like primary key, not null, unique, increment, default value,\n * and note from the column. Uses column metadata and comments if available.\n *\n * @param column - The column to get attributes from\n * @param tableName - Optional table name for looking up comments\n * @returns Array of attribute strings for DBML format\n */\n protected getColumnAttributes(column: AnyColumn, tableName?: string): string[] {\n const attrs: string[] = [];\n\n if (column.primary) {\n attrs.push(\"primary key\");\n }\n if (column.notNull) {\n attrs.push(\"not null\");\n }\n if (column.isUnique) {\n attrs.push(\"unique\");\n }\n if (this.dialectConfig.isIncrement(column)) {\n attrs.push(\"increment\");\n }\n\n const defaultValue = this.getDefaultValue(column);\n if (defaultValue !== undefined) {\n attrs.push(`default: ${defaultValue}`);\n }\n\n // Add note attribute if column comment exists\n if (tableName) {\n const columnComment = this.comments?.tables[tableName]?.columns[column.name]?.comment;\n if (columnComment) {\n attrs.push(`note: '${escapeDbmlString(columnComment)}'`);\n }\n }\n\n return attrs;\n }\n\n /**\n * Format attributes into a string\n *\n * @param attrs - Array of attribute strings\n * @returns Comma-separated attribute string\n */\n protected formatAttributes(attrs: string[]): string {\n return attrs.join(\", \");\n }\n\n /**\n * Get the default value for a column\n *\n * Extracts and formats the default value from a column, handling SQL expressions,\n * objects, and primitive values. Returns undefined if no default value exists.\n *\n * @param column - The column to get the default value from\n * @returns Formatted default value string or undefined\n */\n protected getDefaultValue(column: AnyColumn): string | undefined {\n if (!column.hasDefault) {\n return undefined;\n }\n\n const defaultValue = column.default;\n\n if (defaultValue === null) {\n return \"null\";\n }\n\n if (defaultValue === undefined) {\n return undefined;\n }\n\n // Handle SQL expressions\n if (typeof defaultValue === \"object\" && defaultValue !== null) {\n if (\"queryChunks\" in defaultValue) {\n // It's a SQL template\n const chunks = (defaultValue as { queryChunks: unknown[] }).queryChunks;\n const sqlParts: string[] = [];\n for (const chunk of chunks) {\n if (typeof chunk === \"string\") {\n sqlParts.push(chunk);\n } else if (typeof chunk === \"object\" && chunk !== null && \"value\" in chunk) {\n sqlParts.push(String((chunk as { value: unknown }).value));\n }\n }\n return `\\`${sqlParts.join(\"\")}\\``;\n }\n if (\"sql\" in defaultValue) {\n return `\\`${(defaultValue as { sql: string }).sql}\\``;\n }\n // JSON object\n return `'${JSON.stringify(defaultValue)}'`;\n }\n\n // Handle primitives\n if (typeof defaultValue === \"string\") {\n return `'${defaultValue.replace(/'/g, \"\\\\'\")}'`;\n }\n if (typeof defaultValue === \"number\" || typeof defaultValue === \"boolean\") {\n return String(defaultValue);\n }\n\n return undefined;\n }\n\n /**\n * Generate indexes block from table configuration\n *\n * Creates the indexes block containing primary keys, unique constraints,\n * and regular indexes with their respective attributes.\n *\n * @param dbml - The DBML builder to add the indexes block to\n * @param tableConfig - The table configuration containing index information\n */\n protected generateIndexesBlock(dbml: DbmlBuilder, tableConfig: TableConfig): void {\n const { indexes, primaryKeys, uniqueConstraints } = tableConfig;\n\n if (indexes.length === 0 && primaryKeys.length === 0 && uniqueConstraints.length === 0) {\n return;\n }\n\n dbml.line();\n dbml.line(\"indexes {\");\n dbml.indent();\n\n // Primary keys\n for (const pk of primaryKeys) {\n const columns = this.getPrimaryKeyColumns(pk);\n if (columns.length > 0) {\n const colStr = columns.map((c) => this.dialectConfig.escapeName(c)).join(\", \");\n dbml.line(`(${colStr}) [pk]`);\n }\n }\n\n // Unique constraints\n for (const uc of uniqueConstraints) {\n const columns = this.getUniqueConstraintColumns(uc);\n if (columns.length > 0) {\n const colStr = columns.map((c) => this.dialectConfig.escapeName(c)).join(\", \");\n dbml.line(`(${colStr}) [unique]`);\n }\n }\n\n // Regular indexes\n for (const idx of indexes) {\n const columns = this.getIndexColumns(idx);\n if (columns.length > 0) {\n const colStr = columns.map((c) => this.dialectConfig.escapeName(c)).join(\", \");\n const attrs: string[] = [];\n if (this.isUniqueIndex(idx)) {\n attrs.push(\"unique\");\n }\n const attrStr = attrs.length > 0 ? ` [${attrs.join(\", \")}]` : \"\";\n dbml.line(`(${colStr})${attrStr}`);\n }\n }\n\n dbml.dedent();\n dbml.line(\"}\");\n }\n\n /**\n * Collect foreign keys from table configuration\n *\n * Parses all foreign key definitions from the table config and adds them\n * to the generatedRefs collection for later output.\n *\n * @param tableName - The name of the source table\n * @param foreignKeys - Array of foreign key definitions from table config\n */\n protected collectForeignKeysFromConfig(tableName: string, foreignKeys: unknown[]): void {\n for (const fk of foreignKeys) {\n const ref = this.parseForeignKey(tableName, fk);\n if (ref) {\n this.generatedRefs.push(ref);\n }\n }\n }\n\n /**\n * Parse a foreign key into a GeneratedRef\n *\n * Extracts foreign key information (source/target tables and columns, actions)\n * and converts it to a GeneratedRef object for DBML output.\n *\n * @param tableName - The name of the source table\n * @param fk - The foreign key definition to parse\n * @returns GeneratedRef object or undefined if parsing fails\n */\n protected parseForeignKey(tableName: string, fk: unknown): GeneratedRef | undefined {\n try {\n const fkObj = fk as {\n reference: () => {\n columns: Array<{ name: string }>;\n foreignColumns: Array<{ name: string }>;\n foreignTable: Table;\n };\n onDelete?: string;\n onUpdate?: string;\n };\n const reference = fkObj.reference();\n const fromColumns = reference.columns.map((c) => c.name);\n const toColumns = reference.foreignColumns.map((c) => c.name);\n const toTable = getTableName(reference.foreignTable);\n\n return {\n fromTable: tableName,\n fromColumns,\n toTable,\n toColumns,\n type: \">\",\n onDelete: fkObj.onDelete,\n onUpdate: fkObj.onUpdate,\n };\n } catch {\n return undefined;\n }\n }\n\n /**\n * Get a mapping from variable names to table names in the schema\n *\n * Creates a map from TypeScript variable names (e.g., \"usersTable\") to\n * actual database table names (e.g., \"users\").\n *\n * @returns Map of variable names to table names\n */\n protected getTableNameMapping(): Map<string, string> {\n const mapping = new Map<string, string>();\n for (const [varName, value] of Object.entries(this.schema)) {\n if (this.isTable(value)) {\n const tableName = getTableName(value as Table);\n mapping.set(varName, tableName);\n }\n }\n return mapping;\n }\n\n /**\n * Get a mapping from TypeScript property names to database column names for a table\n *\n * Creates a map from TypeScript property names (e.g., \"authorId\") to\n * actual database column names (e.g., \"author_id\").\n *\n * @param tableVarName - The variable name of the table in the schema\n * @returns Map of property names to column names\n */\n protected getColumnNameMapping(tableVarName: string): Map<string, string> {\n const mapping = new Map<string, string>();\n const table = this.schema[tableVarName];\n if (table && this.isTable(table)) {\n const columns = getTableColumns(table as Table);\n for (const [propName, column] of Object.entries(columns)) {\n mapping.set(propName, column.name);\n }\n }\n return mapping;\n }\n\n /**\n * Check if there's a reverse one() relation (B->A when we have A->B)\n *\n * Used to detect one-to-one relationships by checking if both tables\n * have one() relations pointing to each other.\n *\n * @param sourceTable - The source table variable name\n * @param targetTable - The target table variable name\n * @param sourceFields - The source table's field names\n * @param targetReferences - The target table's reference column names\n * @returns True if a reverse one() relation exists\n */\n protected hasReverseOneRelation(\n sourceTable: string,\n targetTable: string,\n sourceFields: string[],\n targetReferences: string[],\n ): boolean {\n if (!this.parsedRelations) return false;\n\n // Look for a one() relation from targetTable to sourceTable\n for (const relation of this.parsedRelations.relations) {\n if (\n relation.type === \"one\" &&\n relation.sourceTable === targetTable &&\n relation.targetTable === sourceTable &&\n relation.fields.length > 0 &&\n relation.references.length > 0\n ) {\n // Check if the fields/references are the reverse of each other\n // A->B: fields=[A.col], references=[B.col]\n // B->A: fields=[B.col], references=[A.col]\n const reverseFields = relation.fields;\n const reverseReferences = relation.references;\n\n // The reverse relation's fields should match our references\n // and the reverse relation's references should match our fields\n if (\n this.arraysEqual(reverseFields, targetReferences) &&\n this.arraysEqual(reverseReferences, sourceFields)\n ) {\n return true;\n }\n }\n }\n return false;\n }\n\n /**\n * Helper to check if two arrays are equal\n *\n * @param a - First array\n * @param b - Second array\n * @returns True if arrays have same length and same elements in order\n */\n private arraysEqual(a: string[], b: string[]): boolean {\n if (a.length !== b.length) return false;\n return a.every((val, i) => val === b[i]);\n }\n\n /**\n * Generate references from v0 relations() API\n *\n * Uses TypeScript Compiler API to parse relations() definitions from source file\n * and extract fields/references to generate DBML Ref lines.\n *\n * Detects one-to-one relationships when bidirectional one() relations exist.\n */\n protected generateRelationalRefsFromV0(): void {\n if (!this.parsedRelations || this.parsedRelations.relations.length === 0) {\n return;\n }\n\n const tableNameMapping = this.getTableNameMapping();\n const processedRefs = new Set<string>();\n\n for (const parsedRelation of this.parsedRelations.relations) {\n // Only process one() relations with fields and references\n // many() relations are typically the inverse and don't have field info\n if (parsedRelation.type !== \"one\") {\n continue;\n }\n\n if (parsedRelation.fields.length === 0 || parsedRelation.references.length === 0) {\n continue;\n }\n\n // Map variable names to actual table names\n const fromTableName = tableNameMapping.get(parsedRelation.sourceTable);\n const toTableName = tableNameMapping.get(parsedRelation.targetTable);\n\n if (!fromTableName || !toTableName) {\n continue;\n }\n\n // Get column name mappings (TypeScript property names -> database column names)\n const fromColumnMapping = this.getColumnNameMapping(parsedRelation.sourceTable);\n const toColumnMapping = this.getColumnNameMapping(parsedRelation.targetTable);\n\n // Map TypeScript field names to database column names\n const fromColumns = parsedRelation.fields.map(\n (field) => fromColumnMapping.get(field) || field,\n );\n const toColumns = parsedRelation.references.map((ref) => toColumnMapping.get(ref) || ref);\n\n // Create a unique key to avoid duplicate refs (bidirectional)\n const refKey = `${fromTableName}.${fromColumns.join(\",\")}-${toTableName}.${toColumns.join(\",\")}`;\n const reverseRefKey = `${toTableName}.${toColumns.join(\",\")}-${fromTableName}.${fromColumns.join(\",\")}`;\n\n if (processedRefs.has(refKey) || processedRefs.has(reverseRefKey)) {\n continue;\n }\n processedRefs.add(refKey);\n\n // Check if this is a one-to-one relationship (bidirectional one())\n const isOneToOne = this.hasReverseOneRelation(\n parsedRelation.sourceTable,\n parsedRelation.targetTable,\n parsedRelation.fields,\n parsedRelation.references,\n );\n\n // Create GeneratedRef\n // one-to-one: \"-\", many-to-one: \">\"\n const ref: GeneratedRef = {\n fromTable: fromTableName,\n fromColumns,\n toTable: toTableName,\n toColumns,\n type: isOneToOne ? \"-\" : \">\",\n };\n\n this.generatedRefs.push(ref);\n }\n }\n\n /**\n * Generate references from v1 defineRelations() entries\n *\n * Uses official Drizzle v1 types (TableRelationalConfig, Relation, One).\n * Processes One relations to extract foreign key information and generates\n * DBML Ref lines. Detects one-to-one relationships with bidirectional checks.\n *\n * @param entries - Array of v1 relation entries from defineRelations()\n */\n protected generateRelationalRefsFromV1(entries: TableRelationalConfig[]): void {\n const processedRefs = new Set<string>();\n\n for (const entry of entries) {\n const sourceTableName = getTableName(entry.table as Table);\n\n for (const relation of Object.values(entry.relations)) {\n // Only process One relations as they define the FK direction\n // Many relations are the inverse and don't add new information\n if (!is(relation, One)) {\n continue;\n }\n\n // Skip reversed relations (they are auto-generated inverse relations)\n if ((relation as AnyRelation).isReversed) {\n continue;\n }\n\n // Get source and target column names (using official Relation properties)\n const rel = relation as AnyRelation;\n const sourceColumns = rel.sourceColumns.map((col) => col.name);\n const targetColumns = rel.targetColumns.map((col) => col.name);\n\n if (sourceColumns.length === 0 || targetColumns.length === 0) {\n continue;\n }\n\n const targetTableName = getTableName(rel.targetTable as Table);\n\n // Create a unique key to avoid duplicate refs\n const refKey = `${sourceTableName}.${sourceColumns.join(\",\")}->${targetTableName}.${targetColumns.join(\",\")}`;\n const reverseRefKey = `${targetTableName}.${targetColumns.join(\",\")}->${sourceTableName}.${sourceColumns.join(\",\")}`;\n\n if (processedRefs.has(refKey) || processedRefs.has(reverseRefKey)) {\n continue;\n }\n processedRefs.add(refKey);\n\n // Check if there's a reverse one() relation (indicating one-to-one)\n const isOneToOne = this.hasV1ReverseOneRelation(\n entries,\n targetTableName,\n sourceTableName,\n targetColumns,\n sourceColumns,\n );\n\n const ref: GeneratedRef = {\n fromTable: sourceTableName,\n fromColumns: sourceColumns,\n toTable: targetTableName,\n toColumns: targetColumns,\n type: isOneToOne ? \"-\" : \">\",\n };\n\n this.generatedRefs.push(ref);\n }\n }\n }\n\n /**\n * Check if there's a reverse One relation in v1 entries\n *\n * Detects one-to-one relationships by checking if the target table\n * has a matching One relation pointing back to the source table.\n *\n * @param entries - All v1 relation entries\n * @param fromTableName - The table to search for reverse relation\n * @param toTableName - The expected target table of the reverse relation\n * @param fromColumns - The expected source columns of the reverse relation\n * @param toColumns - The expected target columns of the reverse relation\n * @returns True if a matching reverse One relation exists\n */\n protected hasV1ReverseOneRelation(\n entries: TableRelationalConfig[],\n fromTableName: string,\n toTableName: string,\n fromColumns: string[],\n toColumns: string[],\n ): boolean {\n const fromEntry = entries.find((e) => getTableName(e.table as Table) === fromTableName);\n if (!fromEntry) {\n return false;\n }\n\n for (const relation of Object.values(fromEntry.relations)) {\n if (!is(relation, One)) {\n continue;\n }\n\n const rel = relation as AnyRelation;\n const relTargetName = getTableName(rel.targetTable as Table);\n if (relTargetName !== toTableName) {\n continue;\n }\n\n const relSourceCols = rel.sourceColumns.map((col) => col.name);\n const relTargetCols = rel.targetColumns.map((col) => col.name);\n\n // Check if columns match in reverse\n if (\n relSourceCols.length === fromColumns.length &&\n relTargetCols.length === toColumns.length &&\n relSourceCols.every((col, i) => col === fromColumns[i]) &&\n relTargetCols.every((col, i) => col === toColumns[i])\n ) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Get unique key for a relation to avoid duplicates\n *\n * Creates a consistent key by sorting table names alphabetically.\n *\n * @param tableName - The source table name\n * @param relation - The relation object\n * @returns A unique key string for the relation\n */\n protected getRelationKey(tableName: string, relation: unknown): string {\n const rel = relation as { referencedTable?: Table };\n const referencedTable = rel.referencedTable ? getTableName(rel.referencedTable) : \"unknown\";\n const tables = [tableName, referencedTable].sort();\n return `${tables[0]}-${tables[1]}`;\n }\n\n /**\n * Parse a relation into a GeneratedRef\n *\n * Extracts relation information from a legacy relation object and converts\n * it to a GeneratedRef for DBML output.\n *\n * @param tableName - The source table name\n * @param relation - The relation object to parse\n * @returns GeneratedRef object or undefined if parsing fails\n */\n protected parseRelation(tableName: string, relation: unknown): GeneratedRef | undefined {\n try {\n const rel = relation as {\n referencedTable?: Table;\n sourceColumns?: AnyColumn[];\n referencedColumns?: AnyColumn[];\n relationType?: string;\n };\n\n if (!rel.referencedTable) {\n return undefined;\n }\n\n const referencedTable = getTableName(rel.referencedTable);\n\n // Try to get field info from the relation\n const fields = rel.sourceColumns || [];\n const references = rel.referencedColumns || [];\n\n if (fields.length === 0 || references.length === 0) {\n // Cannot generate ref without column info\n return undefined;\n }\n\n const fromColumns = fields.map((c: AnyColumn) => c.name);\n const toColumns = references.map((c: AnyColumn) => c.name);\n\n // Determine relation type\n let type: \"<\" | \">\" | \"-\" = \">\";\n if (rel.relationType === \"one\") {\n type = \"-\";\n }\n\n return {\n fromTable: tableName,\n fromColumns,\n toTable: referencedTable,\n toColumns,\n type,\n };\n } catch {\n return undefined;\n }\n }\n\n /**\n * Generate a reference line in DBML format\n *\n * Creates a Ref line showing the relationship between tables with optional\n * onDelete and onUpdate actions.\n *\n * @param dbml - The DBML builder to add the reference to\n * @param ref - The reference definition to generate\n */\n protected generateRef(dbml: DbmlBuilder, ref: GeneratedRef): void {\n const from = `${this.dialectConfig.escapeName(ref.fromTable)}.${ref.fromColumns.map((c) => this.dialectConfig.escapeName(c)).join(\", \")}`;\n const to = `${this.dialectConfig.escapeName(ref.toTable)}.${ref.toColumns.map((c) => this.dialectConfig.escapeName(c)).join(\", \")}`;\n\n let refLine = `Ref: ${from} ${ref.type} ${to}`;\n\n const attrs: string[] = [];\n if (ref.onDelete && ref.onDelete !== \"no action\") {\n attrs.push(`delete: ${ref.onDelete}`);\n }\n if (ref.onUpdate && ref.onUpdate !== \"no action\") {\n attrs.push(`update: ${ref.onUpdate}`);\n }\n\n if (attrs.length > 0) {\n refLine += ` [${attrs.join(\", \")}]`;\n }\n\n dbml.line(refLine);\n }\n\n // Helper methods for extracting column information from constraints\n\n /**\n * Get column names from an index definition\n *\n * @param idx - The index definition to extract columns from\n * @returns Array of column names in the index\n */\n protected getIndexColumns(idx: unknown): string[] {\n try {\n const config = (idx as { config: { columns: Array<{ name?: string }> } }).config;\n return config.columns\n .map((c) => {\n if (typeof c === \"object\" && c !== null && \"name\" in c) {\n return c.name as string;\n }\n return \"\";\n })\n .filter(Boolean);\n } catch {\n return [];\n }\n }\n\n /**\n * Check if an index is unique\n *\n * @param idx - The index definition to check\n * @returns True if the index has the unique flag\n */\n protected isUniqueIndex(idx: unknown): boolean {\n try {\n const config = (idx as { config: { unique?: boolean } }).config;\n return config.unique === true;\n } catch {\n return false;\n }\n }\n\n /**\n * Get column names from a primary key constraint\n *\n * @param pk - The primary key definition to extract columns from\n * @returns Array of column names in the primary key\n */\n protected getPrimaryKeyColumns(pk: unknown): string[] {\n try {\n const columns = (pk as { columns: Array<{ name: string }> }).columns;\n return columns.map((c) => c.name);\n } catch {\n return [];\n }\n }\n\n /**\n * Get column names from a unique constraint\n *\n * @param uc - The unique constraint definition to extract columns from\n * @returns Array of column names in the unique constraint\n */\n protected getUniqueConstraintColumns(uc: unknown): string[] {\n try {\n const columns = (uc as { columns: Array<{ name: string }> }).columns;\n return columns.map((c) => c.name);\n } catch {\n return [];\n }\n }\n}\n\n/**\n * Write DBML content to a file\n *\n * Creates the directory if it doesn't exist and writes the DBML content\n * to the specified file path.\n *\n * @param filePath - The path to write the DBML file to\n * @param content - The DBML content to write\n */\nexport function writeDbmlFile(filePath: string, content: string): void {\n const resolvedPath = resolve(filePath);\n const dir = dirname(resolvedPath);\n mkdirSync(dir, { recursive: true });\n writeFileSync(resolvedPath, content, \"utf-8\");\n}\n\n/**\n * Escape a string for use in DBML single-quoted strings\n *\n * Escapes backslashes, single quotes, and newlines for proper DBML formatting.\n *\n * @param str - The string to escape\n * @returns The escaped string safe for DBML\n */\nfunction escapeDbmlString(str: string): string {\n return str.replace(/\\\\/g, \"\\\\\\\\\").replace(/'/g, \"\\\\'\").replace(/\\n/g, \"\\\\n\");\n}\n"],"names":["DbmlBuilder","content","indent","BaseGenerator","options","extractComments","extractRelations","dbml","tables","v0Relations","v1Entries","table","ref","value","is","PgTable","MySqlTable","SQLiteTable","relations","obj","relationValues","rel","Relation","entries","entry","values","v","tableName","getTableName","columns","getTableColumns","escapedName","column","tableConfig","tableComment","escapeDbmlString","config","getPgTableConfig","getMySqlTableConfig","getSqliteTableConfig","name","type","attrs","attrStr","defaultValue","columnComment","chunks","sqlParts","chunk","indexes","primaryKeys","uniqueConstraints","pk","colStr","c","uc","idx","foreignKeys","fk","fkObj","reference","fromColumns","toColumns","toTable","mapping","varName","tableVarName","propName","sourceTable","targetTable","sourceFields","targetReferences","relation","reverseFields","reverseReferences","a","b","val","i","tableNameMapping","processedRefs","parsedRelation","fromTableName","toTableName","fromColumnMapping","toColumnMapping","field","refKey","reverseRefKey","isOneToOne","sourceTableName","One","sourceColumns","col","targetColumns","targetTableName","fromEntry","e","relSourceCols","relTargetCols","referencedTable","fields","references","from","to","refLine","writeDbmlFile","filePath","resolvedPath","resolve","dir","dirname","mkdirSync","writeFileSync","str"],"mappings":";;;;;;;;AA+BO,MAAMA,EAAY;AAAA,EACf,QAAkB,CAAA;AAAA,EAClB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA,EAMtB,SAAe;AACb,gBAAK,eACE;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAe;AACb,gBAAK,cAAc,KAAK,IAAI,GAAG,KAAK,cAAc,CAAC,GAC5C;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,KAAKC,IAAkB,IAAU;AAC/B,UAAMC,IAAS,KAAK,OAAO,KAAK,WAAW;AAC3C,gBAAK,MAAM,KAAKD,IAAU,GAAGC,CAAM,GAAGD,CAAO,KAAK,EAAE,GAC7C;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,QAAgB;AACd,WAAO,KAAK,MAAM,KAAK;AAAA,CAAI;AAAA,EAC7B;AACF;AA4BO,MAAeE,EAEpB;AAAA,EACU;AAAA,EACA;AAAA,EACA,gBAAgC,CAAA;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOV,YAAYC,GAAmC;AAC7C,SAAK,SAASA,EAAQ,QACtB,KAAK,aAAaA,EAAQ,cAAc,IACxC,KAAK,SAASA,EAAQ,QAGlBA,EAAQ,WACV,KAAK,WAAWA,EAAQ,WACf,KAAK,WACd,KAAK,WAAWC,EAAgB,KAAK,MAAM,IAIzC,KAAK,cAAc,KAAK,WAC1B,KAAK,kBAAkBC,EAAiB,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AAI;AAEF,aADgBA,EAA0D,OAC5D,QACX,IAAI,CAACF,MACA,OAAOA,KAAM,YAAYA,MAAM,QAAQ,UAAUA,IAC5CA,EAAE,OAEJ,EACR,EACA,OAAO,OAAO;AAAA,IACnB,QAAQ;AACN,aAAO,CAAA;AAAA,IACT;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQU,cAAcE,GAAuB;AAC7C,QAAI;AAEF,aADgBA,EAAyC,OAC3C,WAAW;AAAA,IAC3B,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQU,qBAAqBJ,GAAuB;AACpD,QAAI;AAEF,aADiBA,EAA4C,QAC9C,IAAI,CAACE,MAAMA,EAAE,IAAI;AAAA,IAClC,QAAQ;AACN,aAAO,CAAA;AAAA,IACT;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQU,2BAA2BC,GAAuB;AAC1D,QAAI;AAEF,aADiBA,EAA4C,QAC9C,IAAI,CAACD,MAAMA,EAAE,IAAI;AAAA,IAClC,QAAQ;AACN,aAAO,CAAA;AAAA,IACT;AAAA,EACF;AACF;AAWO,SAASoD,EAAcC,GAAkB1G,GAAuB;AACrE,QAAM2G,IAAeC,EAAQF,CAAQ,GAC/BG,IAAMC,EAAQH,CAAY;AAChC,EAAAI,EAAUF,GAAK,EAAE,WAAW,GAAA,CAAM,GAClCG,EAAcL,GAAc3G,GAAS,OAAO;AAC9C;AAUA,SAASkC,EAAiB+E,GAAqB;AAC7C,SAAOA,EAAI,QAAQ,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAK,EAAE,QAAQ,OAAO,KAAK;AAC7E;"}
|
|
1
|
+
{"version":3,"file":"common.js","sources":["../../src/generator/common.ts"],"sourcesContent":["import {\n type AnyColumn,\n type Table,\n getTableColumns,\n getTableName,\n is,\n Relation,\n} from \"drizzle-orm\";\nimport type { TableRelationalConfig } from \"drizzle-orm/relations\";\nimport { PgTable, getTableConfig as getPgTableConfig } from \"drizzle-orm/pg-core\";\nimport { MySqlTable, getTableConfig as getMySqlTableConfig } from \"drizzle-orm/mysql-core\";\nimport { SQLiteTable, getTableConfig as getSqliteTableConfig } from \"drizzle-orm/sqlite-core\";\nimport { writeFileSync, mkdirSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { DbmlFormatter } from \"../formatter/dbml\";\n\nimport type {\n GeneratedRef,\n GenerateOptions,\n IntermediateSchema,\n TableDefinition,\n ColumnDefinition,\n IndexDefinition,\n ConstraintDefinition,\n RelationDefinition,\n EnumDefinition,\n DatabaseType,\n IntermediateRelationType,\n} from \"../types\";\nimport { extractComments, type SchemaComments } from \"../parser/comments\";\nimport { extractRelations, type SchemaRelations } from \"../parser/relations\";\nimport { V0RelationAdapter } from \"../adapter/v0-adapter\";\nimport { V1RelationAdapter } from \"../adapter/v1-adapter\";\nimport type { UnifiedRelation } from \"../adapter/types\";\n\n/**\n * Configuration for different database dialects\n */\nexport interface DialectConfig {\n escapeName: (name: string) => string;\n isIncrement: (column: AnyColumn) => boolean;\n}\n\n/**\n * Configuration for an index definition\n */\ninterface IndexConfig {\n config: {\n columns: Array<{ name: string }>;\n name?: string;\n unique: boolean;\n using?: string;\n };\n}\n\n/**\n * Configuration for a primary key constraint\n */\ninterface PrimaryKeyConfig {\n columns: Array<{ name: string }>;\n name?: string;\n}\n\n/**\n * Configuration for a unique constraint\n */\ninterface UniqueConstraintConfig {\n columns: Array<{ name: string }>;\n name?: string;\n}\n\n/**\n * Configuration for a foreign key constraint\n */\nexport interface ForeignKeyConfig {\n reference: () => {\n columns: Array<{ name: string }>;\n foreignColumns: Array<{ name: string }>;\n foreignTable: Table;\n };\n name?: string;\n onDelete?: string;\n onUpdate?: string;\n}\n\n/**\n * Table configuration extracted from Drizzle tables\n */\nexport interface TableConfig {\n indexes: IndexConfig[];\n primaryKeys: PrimaryKeyConfig[];\n uniqueConstraints: UniqueConstraintConfig[];\n foreignKeys: ForeignKeyConfig[];\n}\n\n/**\n * Base generator class for DBML generation\n */\nexport abstract class BaseGenerator<\n TSchema extends Record<string, unknown> = Record<string, unknown>,\n> {\n protected schema: TSchema;\n protected generatedRefs: GeneratedRef[] = [];\n protected comments: SchemaComments | undefined;\n protected parsedRelations: SchemaRelations | undefined;\n protected source: string | undefined;\n protected abstract dialectConfig: DialectConfig;\n\n /**\n * Create a new generator instance\n * @param options - Configuration options including schema, source code, and comments\n */\n constructor(options: GenerateOptions<TSchema>) {\n this.schema = options.schema;\n this.source = options.source;\n\n // Initialize comments from options\n if (options.comments) {\n this.comments = options.comments;\n } else if (this.source) {\n this.comments = extractComments(this.source);\n }\n\n // Extract relations from source for v0 API detection\n if (this.source) {\n this.parsedRelations = extractRelations(this.source);\n }\n }\n\n /**\n * Generate complete DBML output from the schema\n *\n * Creates DBML representation including:\n * - Table definitions with columns, indexes, and constraints\n * - Foreign key references (from table config or relations)\n * - Comments for tables and columns\n *\n * @returns The complete DBML string\n */\n generate(): string {\n const schema = this.toIntermediateSchema();\n const formatter = new DbmlFormatter();\n return formatter.format(schema);\n }\n\n /**\n * Get all tables from schema\n *\n * Extracts all Drizzle table objects from the schema by checking each value\n * with isTable() method.\n *\n * @returns Array of table objects\n */\n protected getTables(): Table[] {\n const tables: Table[] = [];\n for (const value of Object.values(this.schema)) {\n if (this.isTable(value)) {\n tables.push(value as Table);\n }\n }\n return tables;\n }\n\n /**\n * Check if a value is a Drizzle table\n *\n * Validates whether a value is a table instance from any supported dialect\n * (PostgreSQL, MySQL, or SQLite).\n *\n * @param value - The value to check\n * @returns True if value is a Drizzle table\n */\n protected isTable(value: unknown): boolean {\n return is(value, PgTable) || is(value, MySqlTable) || is(value, SQLiteTable);\n }\n\n /**\n * Check if a value is a v1 relation entry (from defineRelations())\n *\n * Uses official Drizzle v1 types: TableRelationalConfig with Relation instances.\n * Validates the structure has 'table', 'name', and 'relations' properties with valid types.\n *\n * @param value - The value to check\n * @returns True if value is a v1 relation entry\n */\n protected isV1RelationEntry(value: unknown): value is TableRelationalConfig {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n const obj = value as Record<string, unknown>;\n if (\n !(\"table\" in obj) ||\n !(\"name\" in obj) ||\n typeof obj.name !== \"string\" ||\n !(\"relations\" in obj) ||\n typeof obj.relations !== \"object\" ||\n obj.relations === null\n ) {\n return false;\n }\n // Check that 'relations' contains Relation instances (using drizzle-orm is())\n const relations = obj.relations as Record<string, unknown>;\n const relationValues = Object.values(relations);\n // Empty relations object is valid, but if there are entries, they must be Relations\n if (relationValues.length > 0) {\n return relationValues.some((rel) => is(rel, Relation));\n }\n // If no relations defined, also check table is valid\n return this.isTable(obj.table);\n }\n\n /**\n * Get all v1 relation entries from schema (defineRelations() API)\n *\n * Handles both individual entries and the full defineRelations() result object.\n * Extracts relation configurations that use the modern v1 API with official types.\n *\n * @returns Array of v1 relation entries\n */\n protected getV1RelationEntries(): TableRelationalConfig[] {\n const entries: TableRelationalConfig[] = [];\n for (const value of Object.values(this.schema)) {\n // Check if it's an individual relation entry\n if (this.isV1RelationEntry(value)) {\n entries.push(value);\n }\n // Check if it's the full defineRelations() result object\n // (an object where each value is a relation entry)\n else if (this.isV1DefineRelationsResult(value)) {\n for (const entry of Object.values(value as Record<string, unknown>)) {\n if (this.isV1RelationEntry(entry)) {\n entries.push(entry);\n }\n }\n }\n }\n return entries;\n }\n\n /**\n * Check if a value is a full v1 defineRelations() result object\n *\n * This is an object where all values are TableRelationalConfig objects.\n * Used to detect the full result of calling defineRelations() in v1.\n *\n * @param value - The value to check\n * @returns True if value is a full defineRelations() result\n */\n protected isV1DefineRelationsResult(value: unknown): boolean {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return false;\n }\n const obj = value as Record<string, unknown>;\n const values = Object.values(obj);\n // Must have at least one entry and all must be relation entries\n return values.length > 0 && values.every((v) => this.isV1RelationEntry(v));\n }\n\n /**\n * Get table configuration from a Drizzle table\n *\n * Extracts indexes, primary keys, unique constraints, and foreign keys\n * from the table using the appropriate dialect-specific config getter.\n *\n * @param table - The Drizzle table to get configuration from\n * @returns Table configuration or undefined if dialect is not supported\n */\n protected getTableConfig(table: Table): TableConfig | undefined {\n // Detect dialect and use appropriate config getter\n // Cast is required at boundary due to Drizzle ORM's internal SQL<unknown> | Column union types\n if (is(table, PgTable)) {\n const config = getPgTableConfig(table);\n return this.mapTableConfig(config as Parameters<typeof this.mapTableConfig>[0]);\n }\n if (is(table, MySqlTable)) {\n const config = getMySqlTableConfig(table);\n return this.mapTableConfig(config as Parameters<typeof this.mapTableConfig>[0]);\n }\n if (is(table, SQLiteTable)) {\n const config = getSqliteTableConfig(table);\n return this.mapTableConfig(config as Parameters<typeof this.mapTableConfig>[0]);\n }\n return undefined;\n }\n\n /**\n * Map Drizzle's internal table config to our typed TableConfig\n *\n * Note: Drizzle ORM's columns type is `SQL<unknown> | IndexedColumn` union,\n * so we use `{ name?: string }` and cast to access the name property.\n * This is unavoidable due to Drizzle's internal type structure.\n */\n private mapTableConfig(config: {\n indexes: Array<{\n config: {\n columns: Array<{ name?: string }>;\n name?: string;\n unique?: boolean;\n using?: string;\n };\n }>;\n primaryKeys: Array<{ columns: Array<{ name?: string }>; name?: string }>;\n uniqueConstraints: Array<{ columns: Array<{ name?: string }>; name?: string }>;\n foreignKeys: Array<{\n reference: () => {\n columns: Array<{ name: string }>;\n foreignColumns: Array<{ name: string }>;\n foreignTable: Table;\n };\n name?: string;\n onDelete?: string;\n onUpdate?: string;\n }>;\n }): TableConfig {\n return {\n indexes: (config.indexes || []).map((idx) => ({\n config: {\n columns: idx.config.columns\n .filter((c): c is { name: string } => typeof c.name === \"string\")\n .map((c) => ({ name: c.name })),\n name: idx.config.name,\n unique: idx.config.unique ?? false,\n using: idx.config.using,\n },\n })),\n primaryKeys: (config.primaryKeys || []).map((pk) => ({\n columns: pk.columns\n .filter((c): c is { name: string } => typeof c.name === \"string\")\n .map((c) => ({ name: c.name })),\n name: pk.name,\n })),\n uniqueConstraints: (config.uniqueConstraints || []).map((uc) => ({\n columns: uc.columns\n .filter((c): c is { name: string } => typeof c.name === \"string\")\n .map((c) => ({ name: c.name })),\n name: uc.name,\n })),\n foreignKeys: (config.foreignKeys || []).map((fk) => ({\n reference: fk.reference,\n name: fk.name,\n onDelete: fk.onDelete,\n onUpdate: fk.onUpdate,\n })),\n };\n }\n\n /**\n * Get the default value for a column\n *\n * Extracts and formats the default value from a column, handling SQL expressions,\n * objects, and primitive values. Returns undefined if no default value exists.\n *\n * @param column - The column to get the default value from\n * @returns Formatted default value string or undefined\n */\n protected getDefaultValue(column: AnyColumn): string | undefined {\n if (!column.hasDefault) {\n return undefined;\n }\n\n const defaultValue = column.default;\n\n if (defaultValue === null) {\n return \"null\";\n }\n\n if (defaultValue === undefined) {\n return undefined;\n }\n\n // Handle SQL expressions\n if (typeof defaultValue === \"object\" && defaultValue !== null) {\n if (\"queryChunks\" in defaultValue) {\n // It's a SQL template\n const chunks = (defaultValue as { queryChunks: unknown[] }).queryChunks;\n const sqlParts: string[] = [];\n for (const chunk of chunks) {\n if (typeof chunk === \"string\") {\n sqlParts.push(chunk);\n } else if (typeof chunk === \"object\" && chunk !== null && \"value\" in chunk) {\n sqlParts.push(String((chunk as { value: unknown }).value));\n }\n }\n return sqlParts.join(\"\");\n }\n if (\"sql\" in defaultValue) {\n return (defaultValue as { sql: string }).sql;\n }\n // JSON object\n return JSON.stringify(defaultValue);\n }\n\n // Handle primitives\n if (typeof defaultValue === \"string\") {\n // Use '' escape (SQL standard)\n const escaped = defaultValue.replace(/'/g, \"''\");\n return `'${escaped}'`;\n }\n if (typeof defaultValue === \"number\" || typeof defaultValue === \"boolean\") {\n return String(defaultValue);\n }\n\n return undefined;\n }\n\n /**\n * Collect foreign keys from table configuration\n *\n * Parses all foreign key definitions from the table config and adds them\n * to the generatedRefs collection for later output.\n *\n * @param tableName - The name of the source table\n * @param foreignKeys - Array of foreign key definitions from table config\n */\n protected collectForeignKeysFromConfig(tableName: string, foreignKeys: ForeignKeyConfig[]): void {\n for (const fk of foreignKeys) {\n const ref = this.parseForeignKey(tableName, fk);\n this.generatedRefs.push(ref);\n }\n }\n\n /**\n * Parse a foreign key into a GeneratedRef\n *\n * Extracts foreign key information (source/target tables and columns, actions)\n * and converts it to a GeneratedRef object for DBML output.\n *\n * @param tableName - The name of the source table\n * @param fk - The foreign key definition to parse\n * @returns GeneratedRef object\n */\n protected parseForeignKey(tableName: string, fk: ForeignKeyConfig): GeneratedRef {\n const reference = fk.reference();\n const fromColumns = reference.columns.map((c) => c.name);\n const toColumns = reference.foreignColumns.map((c) => c.name);\n const toTable = getTableName(reference.foreignTable);\n\n return {\n fromTable: tableName,\n fromColumns,\n toTable,\n toColumns,\n type: \">\",\n onDelete: fk.onDelete,\n onUpdate: fk.onUpdate,\n };\n }\n\n /**\n * Detect if relation definitions are present in the schema\n *\n * Checks for both v1 (defineRelations()) and v0 (relations()) API usage.\n * Returns true if any relation definitions are found.\n *\n * @returns True if relations are defined, false otherwise\n */\n private hasRelationDefinitions(): boolean {\n // Check for v1 relation entries (defineRelations() API)\n const v1Entries = this.getV1RelationEntries();\n if (v1Entries.length > 0) {\n return true;\n }\n\n // Check for v0 relation definitions (relations() API)\n if (this.parsedRelations && this.parsedRelations.relations.length > 0) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Create the appropriate relation adapter based on schema contents\n *\n * Detects whether v1 or v0 relations are present and returns the\n * corresponding adapter implementation.\n *\n * @returns RelationAdapter instance (V1RelationAdapter or V0RelationAdapter)\n */\n private createRelationAdapter() {\n const v1Entries = this.getV1RelationEntries();\n if (v1Entries.length > 0) {\n return new V1RelationAdapter(v1Entries);\n }\n return new V0RelationAdapter(this.schema, this.parsedRelations);\n }\n\n /**\n * Convert a UnifiedRelation to a RelationDefinition\n *\n * Maps the unified relation format from adapters to the intermediate\n * schema's RelationDefinition format.\n *\n * @param unified - The unified relation from adapter\n * @returns RelationDefinition for intermediate schema\n */\n private unifiedRelationToDefinition(unified: UnifiedRelation): RelationDefinition {\n return {\n fromTable: unified.sourceTable,\n fromColumns: unified.sourceColumns,\n toTable: unified.targetTable,\n toColumns: unified.targetColumns,\n type: unified.relationType,\n onDelete: unified.onDelete,\n onUpdate: unified.onUpdate,\n };\n }\n\n /**\n * Convert the Drizzle schema to an intermediate schema representation\n *\n * Creates a database-agnostic intermediate representation that can be\n * used to generate various output formats (DBML, Markdown, JSON, etc.)\n *\n * @returns The intermediate schema representation\n */\n toIntermediateSchema(): IntermediateSchema {\n const tables = this.getTables();\n\n // Determine database type from the first table\n const databaseType = this.getDatabaseType(tables[0]);\n\n // Convert tables to intermediate format\n const tableDefinitions: TableDefinition[] = tables.map((table) =>\n this.tableToDefinition(table),\n );\n\n // Collect relations (auto-detect relation definitions vs foreign keys)\n let relations: RelationDefinition[] = [];\n\n if (this.hasRelationDefinitions()) {\n // Use adapter to extract relations in unified format (v1 or v0 API)\n const adapter = this.createRelationAdapter();\n const unifiedRelations = adapter.extract();\n relations = unifiedRelations.map((unified) => this.unifiedRelationToDefinition(unified));\n } else {\n // Fall back to foreign keys from table configs\n // Reset generatedRefs to collect fresh relations\n this.generatedRefs = [];\n for (const table of tables) {\n const tableName = getTableName(table);\n const tableConfig = this.getTableConfig(table);\n if (tableConfig && tableConfig.foreignKeys.length > 0) {\n this.collectForeignKeysFromConfig(tableName, tableConfig.foreignKeys);\n }\n }\n // Convert GeneratedRefs to RelationDefinitions\n relations = this.generatedRefs.map((ref) => this.refToRelationDefinition(ref));\n }\n\n // Collect enums (override in subclasses for dialect-specific behavior)\n const enums: EnumDefinition[] = this.collectEnumDefinitions();\n\n return {\n databaseType,\n tables: tableDefinitions,\n relations,\n enums,\n };\n }\n\n /**\n * Determine the database type from a Drizzle table\n *\n * @param table - The table to check (can be undefined for empty schemas)\n * @returns The database type\n */\n protected getDatabaseType(table: Table | undefined): DatabaseType {\n if (!table) {\n // Default to postgresql if no tables\n return \"postgresql\";\n }\n if (is(table, PgTable)) {\n return \"postgresql\";\n }\n if (is(table, MySqlTable)) {\n return \"mysql\";\n }\n if (is(table, SQLiteTable)) {\n return \"sqlite\";\n }\n // Fallback\n return \"postgresql\";\n }\n\n /**\n * Convert a Drizzle table to a TableDefinition\n *\n * @param table - The Drizzle table to convert\n * @returns The table definition\n */\n protected tableToDefinition(table: Table): TableDefinition {\n const tableName = getTableName(table);\n const columns = getTableColumns(table);\n const tableConfig = this.getTableConfig(table);\n\n // Convert columns\n const columnDefinitions: ColumnDefinition[] = Object.values(columns).map((column) =>\n this.columnToDefinition(column, tableName),\n );\n\n // Convert indexes\n const indexDefinitions: IndexDefinition[] = this.extractIndexDefinitions(tableConfig);\n\n // Convert constraints\n const constraintDefinitions: ConstraintDefinition[] =\n this.extractConstraintDefinitions(tableConfig);\n\n // Get table comment\n const tableComment = this.comments?.tables[tableName]?.comment;\n\n return {\n name: tableName,\n comment: tableComment,\n columns: columnDefinitions,\n indexes: indexDefinitions,\n constraints: constraintDefinitions,\n };\n }\n\n /**\n * Convert a Drizzle column to a ColumnDefinition\n *\n * @param column - The Drizzle column to convert\n * @param tableName - The name of the table containing the column\n * @returns The column definition\n */\n protected columnToDefinition(column: AnyColumn, tableName: string): ColumnDefinition {\n const columnComment = this.comments?.tables[tableName]?.columns[column.name]?.comment;\n const defaultValue = this.getDefaultValue(column);\n\n return {\n name: column.name,\n type: column.getSQLType(),\n nullable: !column.notNull,\n defaultValue,\n primaryKey: column.primary,\n unique: column.isUnique,\n autoIncrement: this.dialectConfig.isIncrement(column) || undefined,\n comment: columnComment,\n };\n }\n\n /**\n * Extract index definitions from table config\n *\n * @param tableConfig - The table configuration\n * @returns Array of index definitions\n */\n protected extractIndexDefinitions(tableConfig: TableConfig | undefined): IndexDefinition[] {\n if (!tableConfig) {\n return [];\n }\n\n const indexes: IndexDefinition[] = [];\n\n for (const idx of tableConfig.indexes) {\n const columns = idx.config.columns.map((c) => c.name);\n if (columns.length > 0) {\n indexes.push({\n name: idx.config.name || `idx_${columns.join(\"_\")}`,\n columns,\n unique: idx.config.unique,\n type: idx.config.using,\n });\n }\n }\n\n return indexes;\n }\n\n /**\n * Extract constraint definitions from table config\n *\n * @param tableConfig - The table configuration\n * @returns Array of constraint definitions\n */\n protected extractConstraintDefinitions(\n tableConfig: TableConfig | undefined,\n ): ConstraintDefinition[] {\n if (!tableConfig) {\n return [];\n }\n\n const constraints: ConstraintDefinition[] = [];\n\n // Primary keys\n for (const pk of tableConfig.primaryKeys) {\n const columns = pk.columns.map((c) => c.name);\n if (columns.length > 0) {\n constraints.push({\n name: pk.name || `pk_${columns.join(\"_\")}`,\n type: \"primary_key\",\n columns,\n });\n }\n }\n\n // Unique constraints\n for (const uc of tableConfig.uniqueConstraints) {\n const columns = uc.columns.map((c) => c.name);\n if (columns.length > 0) {\n constraints.push({\n name: uc.name || `uq_${columns.join(\"_\")}`,\n type: \"unique\",\n columns,\n });\n }\n }\n\n // Foreign keys\n for (const fk of tableConfig.foreignKeys) {\n const fkDef = this.parseForeignKeyForConstraint(fk);\n if (fkDef) {\n constraints.push(fkDef);\n }\n }\n\n return constraints;\n }\n\n /**\n * Parse a foreign key into a ConstraintDefinition\n *\n * @param fk - The foreign key definition\n * @returns ConstraintDefinition\n */\n protected parseForeignKeyForConstraint(fk: ForeignKeyConfig): ConstraintDefinition {\n const reference = fk.reference();\n const columns = reference.columns.map((c) => c.name);\n const referencedColumns = reference.foreignColumns.map((c) => c.name);\n const referencedTable = getTableName(reference.foreignTable);\n\n return {\n name: fk.name || `fk_${columns.join(\"_\")}_${referencedTable}`,\n type: \"foreign_key\",\n columns,\n referencedTable,\n referencedColumns,\n };\n }\n\n /**\n * Convert a GeneratedRef to a RelationDefinition\n *\n * @param ref - The generated reference\n * @returns The relation definition\n */\n protected refToRelationDefinition(ref: GeneratedRef): RelationDefinition {\n // Map DBML ref type to IntermediateRelationType\n let relationType: IntermediateRelationType;\n switch (ref.type) {\n case \"-\":\n relationType = \"one-to-one\";\n break;\n case \">\":\n relationType = \"many-to-one\";\n break;\n case \"<\":\n relationType = \"one-to-many\";\n break;\n default:\n relationType = \"many-to-one\";\n }\n\n return {\n fromTable: ref.fromTable,\n fromColumns: ref.fromColumns,\n toTable: ref.toTable,\n toColumns: ref.toColumns,\n type: relationType,\n onDelete: ref.onDelete,\n onUpdate: ref.onUpdate,\n };\n }\n\n /**\n * Collect enum definitions from the schema\n *\n * Override in subclasses for dialect-specific enum handling (e.g., PostgreSQL)\n *\n * @returns Array of enum definitions (empty by default)\n */\n protected collectEnumDefinitions(): EnumDefinition[] {\n // Default implementation returns empty array\n // Override in PgGenerator for PostgreSQL enum support\n return [];\n }\n}\n\n/**\n * Write DBML content to a file\n *\n * Creates the directory if it doesn't exist and writes the DBML content\n * to the specified file path.\n *\n * @param filePath - The path to write the DBML file to\n * @param content - The DBML content to write\n */\nexport function writeDbmlFile(filePath: string, content: string): void {\n const resolvedPath = resolve(filePath);\n const dir = dirname(resolvedPath);\n mkdirSync(dir, { recursive: true });\n writeFileSync(resolvedPath, content, \"utf-8\");\n}\n"],"names":["BaseGenerator","options","extractComments","extractRelations","schema","DbmlFormatter","tables","value","is","PgTable","MySqlTable","SQLiteTable","obj","relations","relationValues","rel","Relation","entries","entry","values","v","table","config","getPgTableConfig","getMySqlTableConfig","getSqliteTableConfig","idx","c","pk","uc","fk","column","defaultValue","chunks","sqlParts","chunk","tableName","foreignKeys","ref","reference","fromColumns","toColumns","toTable","getTableName","v1Entries","V1RelationAdapter","V0RelationAdapter","unified","databaseType","tableDefinitions","tableConfig","enums","columns","getTableColumns","columnDefinitions","indexDefinitions","constraintDefinitions","tableComment","columnComment","indexes","constraints","fkDef","referencedColumns","referencedTable","relationType","writeDbmlFile","filePath","content","resolvedPath","resolve","dir","dirname","mkdirSync","writeFileSync"],"mappings":";;;;;;;;;;;AAkGO,MAAeA,EAEpB;AAAA,EACU;AAAA,EACA,gBAAgC,CAAA;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAA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AAM0B;AAAA,MACN,UAAU1B,EAAI;AAAA,MACd,UAAUA,EAAI;AAAA,IAAA;AAAA,EAElB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASU,yBAA2C;AAGnD,WAAO,CAAA;AAAA,EACT;AACF;AAWO,SAAS2B,EAAcC,GAAkBC,GAAuB;AACrE,QAAMC,IAAeC,EAAQH,CAAQ,GAC/BI,IAAMC,EAAQH,CAAY;AAChC,EAAAI,EAAUF,GAAK,EAAE,WAAW,GAAA,CAAM,GAClCG,EAAcL,GAAcD,GAAS,OAAO;AAC9C;"}
|
package/dist/generator/mysql.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
class o extends
|
|
1
|
+
import { BaseGenerator as n, writeDbmlFile as a } from "./common.js";
|
|
2
|
+
class o extends n {
|
|
3
3
|
dialectConfig = {
|
|
4
4
|
escapeName: (r) => `\`${r}\``,
|
|
5
5
|
isIncrement: (r) => r.autoIncrement === !0
|
|
@@ -7,7 +7,7 @@ class o extends a {
|
|
|
7
7
|
}
|
|
8
8
|
function m(e) {
|
|
9
9
|
const t = new o(e).generate();
|
|
10
|
-
return e.out &&
|
|
10
|
+
return e.out && a(e.out, t), t;
|
|
11
11
|
}
|
|
12
12
|
export {
|
|
13
13
|
o as MySqlGenerator,
|
package/dist/generator/pg.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseGenerator, DialectConfig } from './common';
|
|
2
|
-
import { GenerateOptions } from '../types';
|
|
2
|
+
import { GenerateOptions, EnumDefinition } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* PostgreSQL-specific DBML generator
|
|
5
5
|
*
|
|
@@ -8,18 +8,19 @@ import { GenerateOptions } from '../types';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare class PgGenerator<TSchema extends Record<string, unknown> = Record<string, unknown>> extends BaseGenerator<TSchema> {
|
|
10
10
|
protected dialectConfig: DialectConfig;
|
|
11
|
-
/**
|
|
12
|
-
* Generate DBML including PostgreSQL-specific constructs like enums
|
|
13
|
-
*/
|
|
14
|
-
generate(): string;
|
|
15
11
|
/**
|
|
16
12
|
* Collect all enum types from the schema
|
|
17
13
|
*/
|
|
18
14
|
private collectEnums;
|
|
19
15
|
/**
|
|
20
|
-
*
|
|
16
|
+
* Collect enum definitions for intermediate schema
|
|
17
|
+
*
|
|
18
|
+
* Overrides the base implementation to extract PostgreSQL enum types
|
|
19
|
+
* from enum columns in the schema.
|
|
20
|
+
*
|
|
21
|
+
* @returns Array of enum definitions
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
+
protected collectEnumDefinitions(): EnumDefinition[];
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* Generate DBML from a PostgreSQL Drizzle schema
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg.d.ts","sourceRoot":"","sources":["../../src/generator/pg.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"pg.d.ts","sourceRoot":"","sources":["../../src/generator/pg.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAiB,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEhE;;;;;GAKG;AACH,qBAAa,WAAW,CACtB,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACjE,SAAQ,aAAa,CAAC,OAAO,CAAC;IAC9B,SAAS,CAAC,aAAa,EAAE,aAAa,CAMpC;IAEF;;OAEG;IACH,OAAO,CAAC,YAAY;IAsBpB;;;;;;;OAOG;cACgB,sBAAsB,IAAI,cAAc,EAAE;CAa9D;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,UAAU,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,GAChC,MAAM,CASR"}
|
package/dist/generator/pg.js
CHANGED
|
@@ -1,52 +1,50 @@
|
|
|
1
|
-
import { getTableColumns as
|
|
2
|
-
import { PgEnumColumn as
|
|
3
|
-
import {
|
|
4
|
-
class
|
|
1
|
+
import { getTableColumns as c } from "drizzle-orm";
|
|
2
|
+
import { PgEnumColumn as u } from "drizzle-orm/pg-core";
|
|
3
|
+
import { BaseGenerator as a, writeDbmlFile as l } from "./common.js";
|
|
4
|
+
class i extends a {
|
|
5
5
|
dialectConfig = {
|
|
6
6
|
escapeName: (e) => `"${e}"`,
|
|
7
7
|
isIncrement: (e) => e.getSQLType().toLowerCase().includes("serial")
|
|
8
8
|
};
|
|
9
|
-
/**
|
|
10
|
-
* Generate DBML including PostgreSQL-specific constructs like enums
|
|
11
|
-
*/
|
|
12
|
-
generate() {
|
|
13
|
-
const e = new i(), n = this.collectEnums();
|
|
14
|
-
for (const [s, r] of n)
|
|
15
|
-
this.generateEnum(e, s, r), e.line();
|
|
16
|
-
const t = super.generate();
|
|
17
|
-
return t && e.line(t), e.build().trim();
|
|
18
|
-
}
|
|
19
9
|
/**
|
|
20
10
|
* Collect all enum types from the schema
|
|
21
11
|
*/
|
|
22
12
|
collectEnums() {
|
|
23
13
|
const e = /* @__PURE__ */ new Map(), n = this.getTables();
|
|
24
|
-
for (const
|
|
25
|
-
const
|
|
26
|
-
for (const
|
|
27
|
-
if (
|
|
28
|
-
const
|
|
29
|
-
|
|
14
|
+
for (const s of n) {
|
|
15
|
+
const r = c(s);
|
|
16
|
+
for (const m of Object.values(r))
|
|
17
|
+
if (m instanceof u) {
|
|
18
|
+
const o = m.enum;
|
|
19
|
+
o && !e.has(o.enumName) && e.set(o.enumName, o.enumValues);
|
|
30
20
|
}
|
|
31
21
|
}
|
|
32
22
|
return e;
|
|
33
23
|
}
|
|
34
24
|
/**
|
|
35
|
-
*
|
|
25
|
+
* Collect enum definitions for intermediate schema
|
|
26
|
+
*
|
|
27
|
+
* Overrides the base implementation to extract PostgreSQL enum types
|
|
28
|
+
* from enum columns in the schema.
|
|
29
|
+
*
|
|
30
|
+
* @returns Array of enum definitions
|
|
36
31
|
*/
|
|
37
|
-
|
|
38
|
-
e
|
|
39
|
-
for (const s of
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
collectEnumDefinitions() {
|
|
33
|
+
const e = this.collectEnums(), n = [];
|
|
34
|
+
for (const [s, r] of e)
|
|
35
|
+
n.push({
|
|
36
|
+
name: s,
|
|
37
|
+
values: r
|
|
38
|
+
});
|
|
39
|
+
return n;
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
|
-
function
|
|
45
|
-
const n = new
|
|
46
|
-
return
|
|
42
|
+
function b(t) {
|
|
43
|
+
const n = new i(t).generate();
|
|
44
|
+
return t.out && l(t.out, n), n;
|
|
47
45
|
}
|
|
48
46
|
export {
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
i as PgGenerator,
|
|
48
|
+
b as pgGenerate
|
|
51
49
|
};
|
|
52
50
|
//# sourceMappingURL=pg.js.map
|
package/dist/generator/pg.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg.js","sources":["../../src/generator/pg.ts"],"sourcesContent":["import { type AnyColumn, getTableColumns } from \"drizzle-orm\";\nimport { PgEnumColumn } from \"drizzle-orm/pg-core\";\nimport { BaseGenerator,
|
|
1
|
+
{"version":3,"file":"pg.js","sources":["../../src/generator/pg.ts"],"sourcesContent":["import { type AnyColumn, getTableColumns } from \"drizzle-orm\";\nimport { PgEnumColumn } from \"drizzle-orm/pg-core\";\nimport { BaseGenerator, writeDbmlFile, type DialectConfig } from \"./common\";\nimport type { GenerateOptions, EnumDefinition } from \"../types\";\n\n/**\n * PostgreSQL-specific DBML generator\n *\n * Supports JSDoc comment extraction via `sourceFile` or `comments` options.\n * Comments are included as DBML Note clauses for tables and columns.\n */\nexport class PgGenerator<\n TSchema extends Record<string, unknown> = Record<string, unknown>,\n> extends BaseGenerator<TSchema> {\n protected dialectConfig: DialectConfig = {\n escapeName: (name: string) => `\"${name}\"`,\n isIncrement: (column: AnyColumn) => {\n const sqlType = column.getSQLType().toLowerCase();\n return sqlType.includes(\"serial\");\n },\n };\n\n /**\n * Collect all enum types from the schema\n */\n private collectEnums(): Map<string, string[]> {\n const enums = new Map<string, string[]>();\n const tables = this.getTables();\n\n for (const table of tables) {\n const columns = getTableColumns(table);\n\n for (const column of Object.values(columns)) {\n if (column instanceof PgEnumColumn) {\n const enumObj = (\n column as unknown as { enum: { enumName: string; enumValues: string[] } }\n ).enum;\n if (enumObj && !enums.has(enumObj.enumName)) {\n enums.set(enumObj.enumName, enumObj.enumValues);\n }\n }\n }\n }\n\n return enums;\n }\n\n /**\n * Collect enum definitions for intermediate schema\n *\n * Overrides the base implementation to extract PostgreSQL enum types\n * from enum columns in the schema.\n *\n * @returns Array of enum definitions\n */\n protected override collectEnumDefinitions(): EnumDefinition[] {\n const enums = this.collectEnums();\n const enumDefinitions: EnumDefinition[] = [];\n\n for (const [name, values] of enums) {\n enumDefinitions.push({\n name,\n values,\n });\n }\n\n return enumDefinitions;\n }\n}\n\n/**\n * Generate DBML from a PostgreSQL Drizzle schema\n *\n * @example\n * ```ts\n * import { pgTable, serial, text, varchar } from \"drizzle-orm/pg-core\";\n * import { pgGenerate } from \"drizzle-docs-generator\";\n *\n * const users = pgTable(\"users\", {\n * id: serial(\"id\").primaryKey(),\n * name: text(\"name\").notNull(),\n * email: varchar(\"email\", { length: 255 }).unique(),\n * });\n *\n * const dbml = pgGenerate({ schema: { users } });\n * console.log(dbml);\n * ```\n *\n * To include JSDoc comments as DBML Note clauses, use the `source` option:\n * ```typescript\n * const dbml = pgGenerate({ schema: { users }, source: \"./schema.ts\" });\n * ```\n */\nexport function pgGenerate<TSchema extends Record<string, unknown>>(\n options: GenerateOptions<TSchema>,\n): string {\n const generator = new PgGenerator(options);\n const dbml = generator.generate();\n\n if (options.out) {\n writeDbmlFile(options.out, dbml);\n }\n\n return dbml;\n}\n"],"names":["PgGenerator","BaseGenerator","name","column","enums","tables","table","columns","getTableColumns","PgEnumColumn","enumObj","enumDefinitions","values","pgGenerate","options","dbml","writeDbmlFile"],"mappings":";;;AAWO,MAAMA,UAEHC,EAAuB;AAAA,EACrB,gBAA+B;AAAA,IACvC,YAAY,CAACC,MAAiB,IAAIA,CAAI;AAAA,IACtC,aAAa,CAACC,MACIA,EAAO,WAAA,EAAa,YAAA,EACrB,SAAS,QAAQ;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA,EAMM,eAAsC;AAC5C,UAAMC,wBAAY,IAAA,GACZC,IAAS,KAAK,UAAA;AAEpB,eAAWC,KAASD,GAAQ;AAC1B,YAAME,IAAUC,EAAgBF,CAAK;AAErC,iBAAWH,KAAU,OAAO,OAAOI,CAAO;AACxC,YAAIJ,aAAkBM,GAAc;AAClC,gBAAMC,IACJP,EACA;AACF,UAAIO,KAAW,CAACN,EAAM,IAAIM,EAAQ,QAAQ,KACxCN,EAAM,IAAIM,EAAQ,UAAUA,EAAQ,UAAU;AAAA,QAElD;AAAA,IAEJ;AAEA,WAAON;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUmB,yBAA2C;AAC5D,UAAMA,IAAQ,KAAK,aAAA,GACbO,IAAoC,CAAA;AAE1C,eAAW,CAACT,GAAMU,CAAM,KAAKR;AAC3B,MAAAO,EAAgB,KAAK;AAAA,QACnB,MAAAT;AAAA,QACA,QAAAU;AAAA,MAAA,CACD;AAGH,WAAOD;AAAA,EACT;AACF;AAyBO,SAASE,EACdC,GACQ;AAER,QAAMC,IADY,IAAIf,EAAYc,CAAO,EAClB,SAAA;AAEvB,SAAIA,EAAQ,OACVE,EAAcF,EAAQ,KAAKC,CAAI,GAG1BA;AACT;"}
|
package/dist/generator/sqlite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
class o extends
|
|
1
|
+
import { BaseGenerator as n, writeDbmlFile as a } from "./common.js";
|
|
2
|
+
class o extends n {
|
|
3
3
|
dialectConfig = {
|
|
4
4
|
escapeName: (e) => `"${e}"`,
|
|
5
5
|
isIncrement: (e) => e.getSQLType().toLowerCase() === "integer" && e.primary
|
|
@@ -7,7 +7,7 @@ class o extends a {
|
|
|
7
7
|
}
|
|
8
8
|
function i(r) {
|
|
9
9
|
const t = new o(r).generate();
|
|
10
|
-
return r.out &&
|
|
10
|
+
return r.out && a(r.out, t), t;
|
|
11
11
|
}
|
|
12
12
|
export {
|
|
13
13
|
o as SqliteGenerator,
|
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,19 @@
|
|
|
6
6
|
* Supports extracting JSDoc comments from source files and including them
|
|
7
7
|
* as DBML Note clauses using the TypeScript Compiler API.
|
|
8
8
|
*/
|
|
9
|
-
export { extractComments } from './parser/
|
|
10
|
-
export type { SchemaComments, TableComment, ColumnComment } from './parser/
|
|
11
|
-
export { pgGenerate, PgGenerator
|
|
12
|
-
export
|
|
9
|
+
export { extractComments } from './parser/comments';
|
|
10
|
+
export type { SchemaComments, TableComment, ColumnComment } from './parser/comments';
|
|
11
|
+
export { pgGenerate, PgGenerator } from './generator/pg';
|
|
12
|
+
export { mysqlGenerate, MySqlGenerator } from './generator/mysql';
|
|
13
|
+
export { sqliteGenerate, SqliteGenerator } from './generator/sqlite';
|
|
14
|
+
export { BaseGenerator, writeDbmlFile } from './generator/common';
|
|
15
|
+
export { DbmlBuilder } from './formatter/dbml-builder';
|
|
16
|
+
export type { GenerateOptions, GeneratedRef } from './types';
|
|
17
|
+
export type { DatabaseType, ColumnDefinition, IndexDefinition, ConstraintType, ConstraintDefinition, TableDefinition, IntermediateRelationType, RelationDefinition, EnumDefinition, IntermediateSchema, } from './types';
|
|
18
|
+
export { DbmlFormatter } from './formatter/dbml';
|
|
19
|
+
export { MarkdownFormatter } from './formatter/markdown';
|
|
20
|
+
export { MermaidErDiagramFormatter } from './formatter/mermaid';
|
|
21
|
+
export type { OutputFormatter, FormatterOptions } from './formatter/types';
|
|
22
|
+
export type { MarkdownFormatterOptions } from './formatter/markdown';
|
|
23
|
+
export type { MermaidFormatterOptions } from './formatter/mermaid';
|
|
13
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGrF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG7D,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,GACnB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,YAAY,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE,YAAY,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
import { extractComments as
|
|
2
|
-
import "
|
|
3
|
-
import "
|
|
4
|
-
import "
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { extractComments as t } from "./parser/comments.js";
|
|
2
|
+
import { PgGenerator as m, pgGenerate as a } from "./generator/pg.js";
|
|
3
|
+
import { MySqlGenerator as x, mysqlGenerate as f } from "./generator/mysql.js";
|
|
4
|
+
import { SqliteGenerator as n, sqliteGenerate as i } from "./generator/sqlite.js";
|
|
5
|
+
import { BaseGenerator as q, writeDbmlFile as s } from "./generator/common.js";
|
|
6
|
+
import { DbmlBuilder as F } from "./formatter/dbml-builder.js";
|
|
7
|
+
import { DbmlFormatter as d } from "./formatter/dbml.js";
|
|
8
|
+
import { MarkdownFormatter as M } from "./formatter/markdown.js";
|
|
9
|
+
import { MermaidErDiagramFormatter as y } from "./formatter/mermaid.js";
|
|
9
10
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
q as BaseGenerator,
|
|
12
|
+
F as DbmlBuilder,
|
|
13
|
+
d as DbmlFormatter,
|
|
14
|
+
M as MarkdownFormatter,
|
|
15
|
+
y as MermaidErDiagramFormatter,
|
|
16
|
+
x as MySqlGenerator,
|
|
17
|
+
m as PgGenerator,
|
|
18
|
+
n as SqliteGenerator,
|
|
19
|
+
t as extractComments,
|
|
20
|
+
f as mysqlGenerate,
|
|
21
|
+
a as pgGenerate,
|
|
22
|
+
i as sqliteGenerate,
|
|
23
|
+
s as writeDbmlFile
|
|
20
24
|
};
|
|
21
25
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
|
@@ -29,7 +29,10 @@ export declare function runCli(args: string[], options?: {
|
|
|
29
29
|
*/
|
|
30
30
|
export declare function runGenerate(schemaPath: string, dialect: "postgresql" | "mysql" | "sqlite", options?: {
|
|
31
31
|
output?: string;
|
|
32
|
-
|
|
32
|
+
format?: "dbml" | "markdown";
|
|
33
|
+
singleFile?: boolean;
|
|
34
|
+
noErDiagram?: boolean;
|
|
35
|
+
force?: boolean;
|
|
33
36
|
cwd?: string;
|
|
34
37
|
}): Promise<CliResult>;
|
|
35
38
|
//# sourceMappingURL=cli-runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-runner.d.ts","sourceRoot":"","sources":["../../src/test-utils/cli-runner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/C,OAAO,CAAC,SAAS,CAAC,CA0CpB;AAED;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,YAAY,GAAG,OAAO,GAAG,QAAQ,EAC1C,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACT,GACL,OAAO,CAAC,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"cli-runner.d.ts","sourceRoot":"","sources":["../../src/test-utils/cli-runner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/C,OAAO,CAAC,SAAS,CAAC,CA0CpB;AAED;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,YAAY,GAAG,OAAO,GAAG,QAAQ,EAC1C,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACT,GACL,OAAO,CAAC,SAAS,CAAC,CAwBpB"}
|
|
@@ -67,4 +67,33 @@ export declare function countTables(dbml: string): number;
|
|
|
67
67
|
* @returns Number of references
|
|
68
68
|
*/
|
|
69
69
|
export declare function countRefs(dbml: string): number;
|
|
70
|
+
/**
|
|
71
|
+
* Check if Markdown output contains all expected table headings
|
|
72
|
+
*
|
|
73
|
+
* @param markdown - Markdown output string
|
|
74
|
+
* @param tableNames - Expected table names
|
|
75
|
+
* @returns true if all table headings are present
|
|
76
|
+
*/
|
|
77
|
+
export declare function hasAllMarkdownTables(markdown: string, tableNames: string[]): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Check if Markdown output contains an ER diagram
|
|
80
|
+
*
|
|
81
|
+
* @param markdown - Markdown output string
|
|
82
|
+
* @returns true if ER diagram exists
|
|
83
|
+
*/
|
|
84
|
+
export declare function hasErDiagram(markdown: string): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Check if Markdown output contains the Tables index
|
|
87
|
+
*
|
|
88
|
+
* @param markdown - Markdown output string
|
|
89
|
+
* @returns true if index exists
|
|
90
|
+
*/
|
|
91
|
+
export declare function hasTablesIndex(markdown: string): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Check if Markdown output contains a Columns section for a table
|
|
94
|
+
*
|
|
95
|
+
* @param markdown - Markdown output string
|
|
96
|
+
* @returns true if Columns section exists
|
|
97
|
+
*/
|
|
98
|
+
export declare function hasColumnsSection(markdown: string): boolean;
|
|
70
99
|
//# sourceMappingURL=dbml-validator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dbml-validator.d.ts","sourceRoot":"","sources":["../../src/test-utils/dbml-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAAE,EACpB,SAAS,GAAE,GAAG,GAAG,GAAS,GACzB,OAAO,CAET;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EAAE,EACrB,SAAS,GAAE,GAAG,GAAG,GAAS,GACzB,OAAO,CAqBT;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM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