@noego/proper 0.0.8 → 0.0.9

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/bin/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../framework/MigrationRunner.ts","../framework/MigrationDirectoryReader.ts","../framework/errors.ts","../framework/MigrationNode.ts","../framework/SqlMigrationBuilder.ts","../framework/MigrationSetup.ts","../framework/MigrationFilter.ts","../framework/MigrationDialectParser.ts","../framework/SQLRunner.ts","../framework/SeedRunner.ts"],"sourcesContent":["// Node built-in modules\nimport fs from 'fs';\n\n// Database drivers\nimport mysql from 'mysql2/promise';\nimport * as sqlite from 'sqlite';\nimport * as sqlite3 from 'sqlite3';\n\n// Helper function to convert any error to Error object\nfunction toError(error: unknown): Error {\n if (error instanceof Error) return error;\n return new Error(String(error));\n}\n\n// Migration framework\nimport { MigrationConfig } from \"./MigrationConfig\";\nimport { MigrationDirectoryReader } from './MigrationDirectoryReader';\nimport { MigrationNode } from './MigrationNode';\nimport { MigrationSetup } from './MigrationSetup';\nimport { migration_filter } from './MigrationFilter';\nimport * as dialect from \"./MigrationDialectParser\";\n\n\nimport { ISQLRunner,SQLRunner,SQLiteRunner } from './SQLRunner';\nimport { ErrorMessage } from './ErrorMessage';\nimport { \n ConfigurationError, \n DatabaseConnectionError, \n MigrationExecutionError,\n CLIError \n} from './errors';\n\n\nexport function loadMigrationConfig(configFile: string): MigrationConfig {\n const reader = new FileMigrationConfigReader(configFile);\n return reader.loadFile();\n}\n\nexport class MigrationRunnerFactory {\n\n private static isSQLRunner(conn: any): conn is ISQLRunner {\n return !!conn\n && typeof conn.query === \"function\"\n && typeof conn.execute === \"function\"\n && typeof conn.end === \"function\";\n }\n\n static async create(configFile:string,conn?:any){\n const configReader = new FileMigrationConfigReader(configFile);\n const config = configReader.loadFile();\n\n if(!conn){\n conn = await this.createConnection(config)\n }\n return new MigrationRunnerFactory().create(config,conn)\n }\n\n static async createConnection(config:MigrationConfig){\n let conn = null as any\n switch(config.database){\n case \"sql\":\n if (!config.sql){\n throw ConfigurationError.missingDatabaseConfiguration(\"sql\");\n }\n const settings = Object.assign({\n password:process.env.SQL_PASSWORD\n },config.sql);\n try {\n conn = await mysql.createConnection(settings);\n return conn;\n } catch (error) {\n throw DatabaseConnectionError.connectionFailed(\"sql\", toError(error).message);\n }\n case \"sqlite\":\n if (!config.sqlite){\n throw ConfigurationError.missingDatabaseConfiguration(\"sqlite\");\n }\n try {\n conn = await sqlite.open({\n filename:config.sqlite.database,\n driver:sqlite3.Database\n });\n return conn;\n } catch (error) {\n throw DatabaseConnectionError.connectionFailed(\"sqlite\", toError(error).message);\n }\n default:\n throw ConfigurationError.unknownDatabaseType(config.database);\n }\n \n }\n\n static async createEmpty(configFile:string){\n const configReader = new FileMigrationConfigReader(configFile);\n const config = configReader.loadFile();\n return new MigrationRunnerFactory().createEmpty(config)\n }\n\n\n async create(config:MigrationConfig,conn:any):Promise<MySQLMigrationRunner>{\n let sqlrunner:ISQLRunner;\n let driverConnection = conn;\n\n if (MigrationRunnerFactory.isSQLRunner(conn)) {\n sqlrunner = conn;\n driverConnection = null;\n } else {\n switch(config.database){\n case \"sql\":\n sqlrunner = new SQLRunner(conn)\n break;\n case \"sqlite\":\n sqlrunner = new SQLiteRunner(conn)\n break;\n default:\n throw ConfigurationError.unknownDatabaseType(config.database);\n }\n }\n const setup = new MigrationSetup(sqlrunner,config);\n const read_strategy = this.getReadStategy(config)\n\n const migration_files = new MigrationDirectoryReader(config.migration_folder,read_strategy,sqlrunner,config.database as 'sql' | 'sqlite')\n\n // Ensure the migrations infrastructure (i.e. the migrations table)\n // exists before we hand the runner back to the caller – most callers\n // expect the runner to be immediately usable without having to invoke\n // `setup()` manually. This is particularly important for projects\n // (like Groom) that directly call `getMigrations()` and\n // `migrate(...)` after obtaining the runner.\n await setup.setup();\n\n return new MySQLMigrationRunner(config,migration_files,setup,sqlrunner,driverConnection);\n }\n\n\n async createEmpty(config:MigrationConfig):Promise<MySQLMigrationRunner>{\n const conn = null as any\n let sqlrunner:ISQLRunner\n\n switch(config.database){\n case \"sql\":\n sqlrunner = new SQLRunner(conn)\n break;\n case \"sqlite\":\n sqlrunner = new SQLiteRunner(conn)\n break;\n default:\n throw ConfigurationError.unknownDatabaseType(config.database);\n }\n const setup = new MigrationSetup(sqlrunner,config);\n const read_strategy = this.getReadStategy(config)\n\n const migration_files = new MigrationDirectoryReader(config.migration_folder,read_strategy,sqlrunner,config.database as 'sql' | 'sqlite')\n return new MySQLMigrationRunner(config,migration_files,setup,sqlrunner,conn);\n }\n\n private getReadStategy(config:MigrationConfig){\n switch(config.database){\n case \"sql\":\n return dialect.MySqlDialectParser\n case \"sqlite\":\n return dialect.SqliteDialectParser\n default:\n throw ConfigurationError.unknownDatabaseType(config.database);\n }\n }\n}\n\n\nexport interface MigrationHistory{\n name:string\n up:string\n down:string\n}\n\nexport interface IMigrationRunner {\n setup(): Promise<void>;\n terminate(): Promise<void>;\n getMigrationsHistory(): Promise<MigrationHistory[]>;\n getMigrations(): Promise<MigrationNode[]>;\n getPendingMigrations(): Promise<MigrationNode[]>;\n getCompletedMigrations(): Promise<MigrationNode[]>;\n migrate(migrationNodes: MigrationNode[], forward: boolean): Promise<void>;\n reset(): Promise<void>;\n createMigration(name: string): void;\n close(): Promise<void>;\n init(config_file: string): Promise<void>;\n query(sql: string, params?: any[]): Promise<any>;\n}\n\nexport class MySQLMigrationRunner implements IMigrationRunner {\n constructor(\n private config:MigrationConfig,\n private directory:MigrationDirectoryReader,\n private setupRunner:MigrationSetup,\n private sqlrunner:ISQLRunner,\n private connection:mysql.Connection\n){\n\n }\n\n async setup(){\n try {\n await this.setupRunner.setup();\n } catch (error) {\n throw new MigrationExecutionError('Failed to set up migration database', undefined, undefined, toError(error));\n }\n }\n\n async terminate(){\n try {\n await this.setupRunner.teardown();\n } catch (error) {\n throw new MigrationExecutionError('Failed to tear down migration database', undefined, undefined, toError(error));\n }\n }\n\n async getMigrationsHistory():Promise<MigrationHistory[]>{\n try {\n const results = await this.sqlrunner.query(`\n select * \n from ${this.config.migration_table}\n `);\n return results[0] as any;\n } catch (error) {\n throw new MigrationExecutionError('Failed to get migration history', undefined, undefined, toError(error));\n }\n }\n\n\n async getMigrations(){\n try {\n return this.directory.loadMigrations(this.config.migration_table,this.connection);\n } catch (error) {\n throw new MigrationExecutionError('Failed to load migrations', undefined, undefined, toError(error));\n }\n }\n\n async getPendingMigrations(){\n try {\n const migrations = await this.getMigrations();\n return migration_filter(migrations,false);\n } catch (error) {\n if (error instanceof MigrationExecutionError) {\n throw error;\n }\n throw new MigrationExecutionError('Failed to get pending migrations', undefined, undefined, toError(error));\n }\n }\n\n async getCompletedMigrations(){\n try {\n const migrations = await this.getMigrations();\n return migration_filter(migrations,true);\n } catch (error) {\n if (error instanceof MigrationExecutionError) {\n throw error;\n }\n throw new MigrationExecutionError('Failed to get completed migrations', undefined, undefined, toError(error));\n }\n }\n\n async migrate(migrationNodes:MigrationNode[],forward:boolean):Promise<void>{\n for(let node of migrationNodes){\n try {\n if(forward){\n await node.up();\n }else{\n await node.down();\n }\n } catch (error) {\n throw new MigrationExecutionError(\n `Failed to ${forward ? 'apply' : 'rollback'} migration`,\n node.name || String(node),\n forward ? node.up_sql() : node.down_sql(),\n toError(error)\n );\n }\n }\n }\n\n\n async reset(){\n try {\n let migrations = await this.getMigrations();\n const rollback = await migration_filter(migrations,true);\n await this.migrate(rollback.reverse(),false);\n migrations = await this.getMigrations();\n const rollforward = await migration_filter(migrations,false);\n await this.migrate(rollforward,true);\n } catch (error) {\n if (error instanceof MigrationExecutionError) {\n throw error;\n }\n throw new MigrationExecutionError('Failed to reset migrations', undefined, undefined, toError(error));\n }\n }\n\n\n createMigration(name:string){\n try {\n const creator = new MigrationCreator(this.config);\n creator.create(name);\n } catch (error) {\n throw new MigrationExecutionError(`Failed to create migration: ${name}`, undefined, undefined, toError(error));\n }\n }\n\n\n async close(){\n if (this.sqlrunner) {\n try {\n await this.sqlrunner.end();\n } catch (error) {\n throw new DatabaseConnectionError(`Failed to close database connection: ${toError(error).message}`);\n }\n }\n }\n\n async query(sql: string, params?: any[]): Promise<any> {\n return await this.sqlrunner.query(sql, params);\n }\n\n async init(config_file:string){\n try {\n console.log(`Checking for ${config_file}`);\n const config_exist = fs.existsSync(config_file);\n\n if(!config_exist){\n console.log(`Creating ${config_file}`);\n const default_config = {\n \"migration_folder\":\"migrations\",\n \"migration_table\":\"proper_migrations\",\n \"database\": \"sql\",\n \"sql\":{\n \"host\":\"localhost\",\n \"user\":\"root\",\n \"database\":\"proper\",\n \"password\":\"\"\n }\n };\n fs.writeFileSync(config_file,JSON.stringify(default_config,null,2)); \n console.log(`Created ${config_file}`);\n }\n } catch (error) {\n throw new ConfigurationError(`Failed to initialize config file: ${toError(error).message}`);\n }\n }\n}\n\n\nexport class FileMigrationConfigReader{\n\n constructor(private configFile:string){\n\n }\n\n loadFile(){\n try {\n const fileContent = fs.readFileSync(this.configFile);\n const config:MigrationConfig = JSON.parse(fileContent.toString());\n \n // Validate required fields\n if (!config.migration_folder) {\n throw ConfigurationError.missingRequiredProperty('migration_folder');\n }\n \n if (!config.migration_table) {\n throw ConfigurationError.missingRequiredProperty('migration_table');\n }\n \n // For backward compatibility: if database type is omitted we derive\n // it from the presence of the dialect specific configuration\n // blocks. This keeps older `proper.json` files – that only defined\n // an \"sql\" or \"sqlite\" section – working without modification.\n if (!config.database) {\n if (config.sql) {\n config.database = 'sql';\n } else if (config.sqlite) {\n config.database = 'sqlite';\n } else {\n throw ConfigurationError.missingRequiredProperty('database');\n }\n }\n \n return config;\n } catch (error) {\n if (error instanceof ConfigurationError) {\n throw error;\n }\n const err = toError(error);\n if (err.message.includes('ENOENT')) {\n throw new ConfigurationError(`Config file not found: ${this.configFile}`);\n }\n throw new ConfigurationError(`Failed to load config file: ${err.message}`);\n }\n }\n}\n\n\nexport class MigrationCreator{\n constructor(private config:MigrationConfig){\n \n }\n\n\n create(name:string){\n if (!name) {\n throw new CLIError('Migration name is required');\n }\n\n try {\n // Ensure the migration folder exists\n if (!fs.existsSync(this.config.migration_folder)) {\n fs.mkdirSync(this.config.migration_folder, { recursive: true });\n }\n\n const now_timestamp = Date.now();\n\n const filename_up = `${now_timestamp}_${name}.up.sql`;\n const filename_down = `${now_timestamp}_${name}.down.sql`;\n\n fs.writeFileSync(`${this.config.migration_folder}/${filename_up}`,`\n-- Write your up migration here\n `.trim());\n\n fs.writeFileSync(`${this.config.migration_folder}/${filename_down}`,`\n-- Write your down migration here\n `.trim());\n \n console.log(`Created migration files:`);\n console.log(` ${filename_up}`);\n console.log(` ${filename_down}`);\n } catch (error) {\n if (error instanceof CLIError) {\n throw error;\n }\n throw new MigrationExecutionError(`Failed to create migration files: ${toError(error).message}`);\n }\n }\n}\n","import fs from \"fs\";\nimport path from \"path\";\nimport { MigrationNode } from './MigrationNode';\nimport { SqlMigrationBuilder } from './SqlMigrationBuilder';\nimport mysql from \"mysql2/promise\";\nimport { ISQLRunner } from \"./SQLRunner\";\n\n\nexport interface MigrationOptions{\n conn:mysql.Connection\n}\n\nexport class MigrationDirectoryReader {\n\n constructor(\n private directory: string,\n private read_strategy: any,\n private sqlrunner: ISQLRunner,\n private dialect: 'sql' | 'sqlite' = 'sql'\n ) {\n\n }\n\n /**\n * Resolves the appropriate file for a migration based on dialect.\n * Priority: dialect-specific file > generic file\n */\n private resolveFile(baseName: string, direction: 'up' | 'down'): string | null {\n const dialectExt = this.dialect === 'sql' ? 'mysql' : 'sqlite';\n\n // Priority 1: Dialect-specific file\n const dialectFile = path.join(this.directory, `${baseName}.${dialectExt}.${direction}.sql`);\n if (fs.existsSync(dialectFile)) return dialectFile;\n\n // Priority 2: Generic file\n const genericFile = path.join(this.directory, `${baseName}.${direction}.sql`);\n if (fs.existsSync(genericFile)) return genericFile;\n\n return null;\n }\n\n /**\n * Checks if a file path is dialect-specific (contains .mysql. or .sqlite. in the name)\n */\n private isDialectSpecific(filePath: string): boolean {\n return /\\.(mysql|sqlite)\\.(up|down)\\.sql$/i.test(filePath);\n }\n\n loadMigrations(table:string,connection:any):MigrationNode[] {\n\n fs.existsSync(this.directory) || fs.mkdirSync(this.directory);\n const dir_content = fs.readdirSync(this.directory,{withFileTypes:true}).filter(file=>file.isFile()).map(file=>file.name);\n\n // Extract unique migration keys (stripping dialect extensions)\n const uniqueKeys = new Set<string>();\n dir_content.forEach(file => {\n // Strip dialect extension (.mysql or .sqlite) and direction (.up or .down) to get base key\n const key = file.replace(/(?:\\.(mysql|sqlite))?\\.(up|down)\\.(sql|js)/i, \"\").toLowerCase();\n uniqueKeys.add(key);\n });\n\n const migration_sorter: any = {};\n\n // For each unique key, resolve the correct files based on dialect\n uniqueKeys.forEach((migration_key) => {\n const builder = new SqlMigrationBuilder(migration_key);\n\n const upFile = this.resolveFile(migration_key, 'up');\n const downFile = this.resolveFile(migration_key, 'down');\n\n if (upFile) {\n this.loadMigration(builder, upFile);\n }\n if (downFile) {\n this.loadMigration(builder, downFile);\n }\n\n migration_sorter[migration_key] = builder;\n });\n\n const keys = Object.keys(migration_sorter)\n\n keys.sort()\n\n const built = keys.map(key=>{\n return migration_sorter[key].build(table,this.sqlrunner)\n })\n return built\n\n }\n\n\n loadMigration(builder: SqlMigrationBuilder, file: string) {\n const is_sql = /sql$/i.test(file);\n const is_js = /js$/i.test(file);\n const is_up = /up\\.(js|sql)/i.test(file);\n const is_down = /down\\.(js|sql)/i.test(file);\n if (is_sql && is_up) {\n const content = this.sql_up(file);\n builder.set_up(file,content);\n } else if (is_sql && is_down) {\n const content = this.sql_down(file);\n builder.set_down(file,content);\n } else {\n throw new Error(`Invalid migration file: ${file}`);\n }\n return builder;\n }\n\n\n sql_up(file: string) {\n let content = fs.readFileSync(file).toString();\n // Dialect-specific files bypass read_strategy (no inline marker parsing needed)\n if (!this.isDialectSpecific(file)) {\n content = this.read_strategy(content);\n }\n return content.trim();\n }\n\n sql_down(file: string) {\n let content = fs.readFileSync(file).toString();\n // Dialect-specific files bypass read_strategy (no inline marker parsing needed)\n if (!this.isDialectSpecific(file)) {\n content = this.read_strategy(content);\n }\n return content.trim();\n }\n\n}\n","/**\n * Base class for all migration-related errors\n */\nexport class MigrationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'MigrationError';\n // This is needed to make instanceof work correctly in ES5\n Object.setPrototypeOf(this, MigrationError.prototype);\n }\n}\n\n/**\n * Error thrown when there is an issue with the configuration\n */\nexport class ConfigurationError extends MigrationError {\n constructor(message: string) {\n super(`Configuration Error: ${message}`);\n this.name = 'ConfigurationError';\n Object.setPrototypeOf(this, ConfigurationError.prototype);\n }\n\n /**\n * Helper method for missing database configuration\n * @param dbType The database type (e.g., 'sql', 'sqlite')\n * @returns A ConfigurationError with appropriate message\n */\n static missingDatabaseConfiguration(dbType: string): ConfigurationError {\n return new ConfigurationError(`Missing ${dbType} configuration`);\n }\n\n /**\n * Helper method for unknown database type\n * @param dbType The unknown database type\n * @returns A ConfigurationError with appropriate message\n */\n static unknownDatabaseType(dbType: string): ConfigurationError {\n return new ConfigurationError(`Unknown database type: ${dbType}`);\n }\n\n /**\n * Helper method for missing required configuration properties\n * @param property The name of the missing property\n * @returns A ConfigurationError with appropriate message\n */\n static missingRequiredProperty(property: string): ConfigurationError {\n return new ConfigurationError(`Missing required property: ${property}`);\n }\n}\n\n/**\n * Error thrown when there is an issue with the database connection\n */\nexport class DatabaseConnectionError extends MigrationError {\n constructor(message: string) {\n super(`Database Connection Error: ${message}`);\n this.name = 'DatabaseConnectionError';\n Object.setPrototypeOf(this, DatabaseConnectionError.prototype);\n }\n\n /**\n * Helper method for connection errors\n * @param dbType The database type (e.g., 'sql', 'sqlite')\n * @param details Additional error details\n * @returns A DatabaseConnectionError with appropriate message\n */\n static connectionFailed(dbType: string, details?: string): DatabaseConnectionError {\n const message = details \n ? `Failed to connect to ${dbType} database: ${details}`\n : `Failed to connect to ${dbType} database`;\n return new DatabaseConnectionError(message);\n }\n\n /**\n * Helper method for authentication errors\n * @param dbType The database type (e.g., 'sql', 'sqlite')\n * @returns A DatabaseConnectionError with appropriate message\n */\n static authenticationFailed(dbType: string): DatabaseConnectionError {\n return new DatabaseConnectionError(`Authentication failed for ${dbType} database`);\n }\n}\n\n/**\n * Error thrown when there is an issue with executing a migration\n */\nexport class MigrationExecutionError extends MigrationError {\n constructor(\n message: string,\n public readonly migrationName?: string,\n public readonly sql?: string,\n public readonly originalError?: Error\n ) {\n /*\n * The public `message` that gets surfaced to callers **must not** include the\n * raw SQL text. The SQL string is already exposed through the dedicated\n * `sql` property and adding it to the message makes it unnecessarily noisy\n * and difficult to assert against in unit-tests. Therefore we only embed\n * the essential information (error type, optional migration name and the\n * short error message) in the main message string while keeping the full\n * SQL available separately.\n */\n let fullMessage = `Migration Execution Error${migrationName ? ` in '${migrationName}'` : ''}: ${message}`;\n\n if(originalError){\n fullMessage += `\\nOriginal Error:\\n${originalError.message}`;\n }\n\n super(fullMessage);\n this.name = 'MigrationExecutionError';\n Object.setPrototypeOf(this, MigrationExecutionError.prototype);\n }\n\n /**\n * Helper method for SQL execution errors\n * @param migrationName The name of the migration\n * @param sql The SQL that caused the error\n * @param originalError The original error thrown by the database driver\n * @returns A MigrationExecutionError with appropriate message\n */\n static sqlExecutionFailed(migrationName: string, sql: string, originalError: Error): MigrationExecutionError {\n return new MigrationExecutionError(\n originalError.message,\n migrationName,\n sql,\n originalError\n );\n }\n\n /**\n * Helper method for missing migration file errors\n * @param filename The missing file\n * @returns A MigrationExecutionError with appropriate message\n */\n static missingMigrationFile(filename: string): MigrationExecutionError {\n return new MigrationExecutionError(`Migration file not found: ${filename}`);\n }\n\n /**\n * Helper method for invalid migration file format errors\n * @param filename The invalid file\n * @param details Additional error details\n * @returns A MigrationExecutionError with appropriate message\n */\n static invalidMigrationFile(filename: string, details?: string): MigrationExecutionError {\n const message = details\n ? `Invalid migration file format in ${filename}: ${details}`\n : `Invalid migration file format in ${filename}`;\n return new MigrationExecutionError(message);\n }\n}\n\n/**\n * Error thrown when there is an issue with the migration CLI\n */\nexport class CLIError extends MigrationError {\n constructor(message: string) {\n super(`CLI Error: ${message}`);\n this.name = 'CLIError';\n Object.setPrototypeOf(this, CLIError.prototype);\n }\n\n /**\n * Helper method for missing command errors\n * @returns A CLIError with appropriate message\n */\n static missingCommand(): CLIError {\n return new CLIError('No command specified. Run with --help for usage information.');\n }\n\n /**\n * Helper method for unknown command errors\n * @param command The unknown command\n * @returns A CLIError with appropriate message\n */\n static unknownCommand(command: string): CLIError {\n return new CLIError(`Unknown command: ${command}. Run with --help for usage information.`);\n }\n\n /**\n * Helper method for missing required argument errors\n * @param argument The missing argument\n * @returns A CLIError with appropriate message\n */\n static missingRequiredArgument(argument: string): CLIError {\n return new CLIError(`Missing required argument: ${argument}`);\n }\n}\n","import { Connection } from 'mysql2/promise';\nimport { MigrationStatus } from './MigrationStatus';\nimport { ISQLRunner } from './SQLRunner';\nimport { MigrationExecutionError } from './errors';\n\nexport abstract class MigrationNode {\n name: string;\n\n constructor(name?: string) {\n this.name = name || '';\n }\n\n abstract get_key():string;\n abstract status(): Promise<MigrationStatus>;\n abstract up(): Promise<void>;\n abstract down(): Promise<void>;\n abstract up_sql(): string;\n abstract down_sql(): string;\n}\n\n\nexport class SqlMigrationNode extends MigrationNode {\n up_sql(): string {\n return this.sql_up;\n }\n down_sql(): string {\n return this.sql_down;\n }\n get_key(): string {\n return this.key;\n }\n\n constructor(private conn:ISQLRunner,\n private table:string, \n private key:string,\n private up_file:string,\n private sql_up:string,\n private down_file:string,\n private sql_down:string) {\n super(key);\n }\n\n async status(): Promise<MigrationStatus> {\n try {\n const result = await this.conn.query(`\n select * \n from ${this.table}\n where migration_key = ?;\n `, [this.key]);\n\n if(result.length > 0 && result[0].length > 0){\n return {\n completed: true\n };\n } else {\n return {\n completed: false\n };\n }\n } catch (error) {\n throw new MigrationExecutionError(\n `Error checking status for migration`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n\n async up(): Promise<void> {\n try {\n await this.conn.execute(this.sql_up);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error executing UP migration`,\n this.key,\n this.sql_up,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n \n try {\n await this.conn.execute(`\n insert into ${this.table} (migration_key,up,down)\n values (?,?,?)\n `, [this.key, this.up_file, this.down_file]);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error recording migration completion`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n\n async down(): Promise<void> {\n try {\n await this.conn.execute(this.sql_down);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error executing DOWN migration`,\n this.key,\n this.sql_down,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n \n try {\n await this.conn.execute(`\n delete from ${this.table}\n where migration_key = ?\n `, [this.key]);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error removing migration record`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n}\n\n\nexport class SqliteMigrationNode extends MigrationNode {\n up_sql(): string {\n return this.sql_up;\n }\n down_sql(): string {\n return this.sql_down;\n }\n constructor(\n private conn: ISQLRunner, // your SQLite runner\n private table: string,\n private key: string,\n private up_file: string,\n private sql_up: string,\n private down_file: string,\n private sql_down: string\n ) {\n super(key);\n }\n\n /**\n * Returns the unique key for this migration (e.g. timestamp + name).\n */\n get_key(): string {\n return this.key;\n }\n\n /**\n * Check if this migration is already completed by looking in the migration table.\n */\n async status(): Promise<MigrationStatus> {\n try {\n // Usually `this.conn.query(...)` returns an array of rows.\n // The first element might be the row set, depending on your runner.\n const cursor = await this.conn.query(\n `SELECT * FROM ${this.table} WHERE migration_key = ?;`,\n [this.key]\n );\n\n // Usually, `cursor[0]` is the row array in many MySQL runners;\n // In a SQLite scenario, it may be just `cursor`\n // So adjust depending on your actual runner's return shape.\n const rows = cursor[0] as any[];\n\n if (rows && rows.length > 0) {\n return { completed: true };\n } else {\n return { completed: false };\n }\n } catch (error) {\n throw new MigrationExecutionError(\n `Error checking status for migration`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n\n /**\n * Run the 'up' SQL, then record this migration in the table.\n */\n async up(): Promise<void> {\n try {\n // Execute the 'up' script\n await this.conn.execute(this.sql_up);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error executing UP migration`,\n this.key,\n this.sql_up,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n\n // Insert a record of this migration having completed\n try {\n await this.conn.execute(\n `\n INSERT INTO ${this.table} (migration_key, up, down)\n VALUES (?, ?, ?)\n `,\n [this.key, this.up_file, this.down_file]\n );\n } catch (error) {\n throw new MigrationExecutionError(\n `Error recording migration completion`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n\n /**\n * Run the 'down' SQL, then remove this migration record from the table.\n */\n async down(): Promise<void> {\n try {\n // Execute the 'down' script\n await this.conn.execute(this.sql_down);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error executing DOWN migration`,\n this.key,\n this.sql_down,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n\n // Remove the migration from the table\n try {\n await this.conn.execute(\n `\n DELETE FROM ${this.table}\n WHERE migration_key = ?\n `,\n [this.key]\n );\n } catch (error) {\n throw new MigrationExecutionError(\n `Error removing migration record`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n}","import { Connection } from 'mysql2/promise';\nimport { SqlMigrationNode } from './MigrationNode';\nimport { ISQLRunner } from './SQLRunner';\n\n\n\nexport class SqlMigrationBuilder {\n\n private up: string = '';\n private up_file: string = '';\n private down: string = '';\n private down_file: string = '';\n\n constructor(private key: string) {\n }\n\n set_up(file:string,up: string) {\n this.up_file = file;\n this.up = up;\n }\n\n set_down(file:string,down: string) {\n this.down_file = file;\n this.down = down;\n }\n\n build(table:string,conn: ISQLRunner) {\n return new SqlMigrationNode(conn, table,this.key, this.up_file, this.up, this.down_file,this.down);\n }\n}\n","import { MigrationConfig } from \"./MigrationConfig\";\nimport fs from \"fs\";\nimport { ISQLRunner } from './SQLRunner';\n\nexport class MigrationSetup {\n constructor(private sqlrunner: ISQLRunner, private config: MigrationConfig) {}\n\n\n async setup() {\n\n fs.existsSync(this.config.migration_folder) || fs.mkdirSync(this.config.migration_folder);\n\n const tableName = this.config.migration_table;\n\n // Use dialect-specific DDL so that the migrations table can be created\n // both in MySQL/MariaDB and in SQLite. The two dialects differ mainly\n // in the auto-increment syntax and the column types.\n const createTableSql = this.config.database === 'sqlite'\n ? `CREATE TABLE IF NOT EXISTS ${tableName} (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n migration_key TEXT,\n up TEXT,\n down TEXT,\n created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n )`\n : `CREATE TABLE IF NOT EXISTS ${tableName} (\n id INT AUTO_INCREMENT PRIMARY KEY,\n migration_key VARCHAR(255),\n up VARCHAR(255),\n down VARCHAR(255),\n created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n )`;\n\n await this.sqlrunner.query(createTableSql);\n }\n\n async teardown() {\n await this.sqlrunner.execute(`DROP TABLE ${this.config.migration_table}`);\n }\n}\n\n\n\n\n","import { MigrationNode } from \"./MigrationNode\";\n\n\n\n\nexport async function migration_filter(migrations:MigrationNode[],completed:boolean=true,keep:MigrationNode[]=[]){\n if(migrations.length === 0){\n return keep\n }\n\n const [first,...rest] = migrations\n\n const status = await first.status()\n\n if(status.completed == completed){\n keep.push(first)\n }\n\n return migration_filter(rest,completed,keep)\n}","export function MySqlDialectParser(sql: string): string {\n const lines = sql.split('\\n');\n let result = '';\n \n // We start \"in MySQL\" so that lines before [sql] are kept.\n let isInMySQLBlock = true;\n \n // e.g. `-- [sql]`, `-- [ sql ]`, `-- [mysql]`, ignoring case/spaces\n const startSQLRegex = /^\\s*--\\s*\\[\\s*(sql|mysql)\\s*\\]\\s*$/i;\n // e.g. `-- [sqlite]`, `-- [ pg ]`, `-- [mydialect]` (any bracket means \"turn off MySQL\")\n const anyDialectRegex = /^\\s*--\\s*\\[\\s*\\w+\\s*\\]\\s*$/i;\n \n for (const line of lines) {\n const trimmed = line.trim();\n \n // If line is \" -- [sql] \" or \" -- [mysql] \", we *turn on* MySQL capturing:\n if (startSQLRegex.test(trimmed)) {\n isInMySQLBlock = true;\n // We also include this line in output\n result += line + '\\n';\n continue;\n }\n \n // If line is *some other* bracket, e.g. \" -- [sqlite] \"\n // then switch MySQL off, and do NOT keep that line\n if (anyDialectRegex.test(trimmed) && !startSQLRegex.test(trimmed)) {\n isInMySQLBlock = false;\n // Skip to next line\n continue;\n }\n \n // If we get here and see a line without a [dialect] marker,\n // and we were previously turned off because of non-mysql dialect,\n // then check if it's common SQL (like CREATE INDEX).\n // Turn MySQL back on for this line\n if (!isInMySQLBlock && line.toLowerCase().includes('create index')) {\n isInMySQLBlock = true;\n }\n \n // If we're in MySQL mode, keep the line\n if (isInMySQLBlock) {\n result += line + '\\n';\n }\n }\n \n return result;\n}\n\nexport function SqliteDialectParser(sql: string): string {\n const lines = sql.split('\\n');\n let result = '';\n let isInSqliteBlock = true;\n\n // Regex to detect a line that starts Sqlite code block:\n const startSqliteRegex = /^\\s*--\\s*\\[\\s*sqlite\\s*\\]\\s*$/i;\n const anyDialectRegex = /^\\s*--\\s*\\[\\s*\\w+\\s*\\]\\s*$/i;\n\n for (const line of lines) {\n const trimmed = line.trim();\n\n if (startSqliteRegex.test(trimmed)) {\n // If we see a \"-- [sqlite]\" line, start capturing\n isInSqliteBlock = true;\n result += line + '\\n';\n continue;\n } else if (anyDialectRegex.test(trimmed) && !startSqliteRegex.test(trimmed)) {\n // If we see a *different* bracket line, turn off capturing\n isInSqliteBlock = false;\n continue;\n }\n \n // If we get here and see a line without a [dialect] marker,\n // and we were previously turned off because of non-sqlite dialect,\n // then check if it's common SQL (like CREATE INDEX).\n // Turn SQLite back on for this line\n if (!isInSqliteBlock && line.toLowerCase().includes('create index')) {\n isInSqliteBlock = true;\n }\n \n // If we are in the Sqlite block, capture the line\n if (isInSqliteBlock) {\n result += line + '\\n';\n }\n }\n \n return result;\n}","\nimport * as sqlite from 'sqlite';\nimport { Statement } from 'sqlite3';\nimport mysql from 'mysql2/promise';\n\n\n\ntype QueryResult = {\n stmt: Statement;\n lastID: number;\n changes: number;\n}\n\nexport interface ISQLRunner {\n query(sql: string, params?: any[]): Promise<any>;\n execute(sql: string, params?: any[]): Promise<any>;\n end(): Promise<void>;\n}\n\n/**\n * Base class that implements the common contract and helper utilities that are\n * shared between the different dialect runners. The concrete subclasses only\n * need to implement the three primitive methods `_query`, `_execute` and\n * `_end` that perform the actual driver-specific interaction. Everything else\n * – such as ensuring a uniform return shape – is handled here once.\n */\nexport abstract class BaseSQLRunner implements ISQLRunner {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abstract _query(sql: string, params?: any[]): Promise<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abstract _execute(sql: string, params?: any[]): Promise<any>;\n abstract _end(): Promise<void>;\n\n /**\n * Ensures that both MySQL and SQLite return the same tuple shape that callers\n * expect: `[rowsOrResult, extra]`. For SQLite there is no `extra` metadata\n * comparable to MySQL's `FieldPacket[]`, so we just use `undefined`.\n */\n async query(sql: string, params: any[] = []): Promise<any> {\n const result = await this._query(sql, params);\n\n // MySQL already returns the desired tuple. For SQLite we need to wrap.\n return Array.isArray(result) && result.length === 2 ? result : [result, undefined];\n }\n\n async execute(sql: string, params: any[] = []): Promise<any> {\n const result = await this._execute(sql, params);\n return Array.isArray(result) && result.length === 2 ? result : [result, undefined];\n }\n\n async end(): Promise<void> {\n await this._end();\n }\n}\n\nfunction isPromiseLike<T>(value: unknown): value is Promise<T> {\n return !!value && typeof (value as Promise<T>).then === \"function\";\n}\n\nexport class SQLRunner extends BaseSQLRunner {\n constructor(private connection: mysql.Connection) {\n super();\n }\n\n // The MySQL driver already returns the correct tuple shapes.\n async _query(sql: string, params: any[] = []) {\n return await this.connection.query(sql, params);\n }\n\n async _execute(sql: string, params: any[] = []) {\n return await this.connection.execute(sql, params);\n }\n\n async _end() {\n if (this.connection) {\n await this.connection.end();\n }\n }\n}\n\nexport class SQLiteRunner extends BaseSQLRunner {\n constructor(private connection: sqlite.Database | any) {\n super();\n }\n\n private async prepareStatement(sql: string) {\n if (typeof this.connection.prepare !== \"function\") {\n throw new Error(\"SQLite connection does not support prepare()\");\n }\n const stmt = this.connection.prepare(sql);\n return isPromiseLike(stmt) ? await stmt : stmt;\n }\n\n private async finalizeStatement(stmt: any) {\n if (!stmt || typeof stmt.finalize !== \"function\") return;\n const result = stmt.finalize();\n if (isPromiseLike(result)) {\n await result;\n }\n }\n\n private async statementAll(stmt: any, params: any[]) {\n if (typeof stmt.all !== \"function\") {\n throw new Error(\"SQLite statement does not support all()\");\n }\n // sqlite3 callback-style API\n if (stmt.all.length >= 2) {\n return await new Promise((resolve, reject) => {\n const callback = (err: Error | null, rows: any[]) => {\n if (err) return reject(err);\n resolve(rows || []);\n };\n try {\n if (params.length > 0) {\n stmt.all(params, callback);\n } else {\n stmt.all(callback);\n }\n } catch (error) {\n reject(error);\n }\n });\n }\n const result = stmt.all(...params);\n return isPromiseLike(result) ? await result : result;\n }\n\n private async statementRun(stmt: any, params: any[]) {\n if (typeof stmt.run !== \"function\") {\n throw new Error(\"SQLite statement does not support run()\");\n }\n if (stmt.run.length >= 2) {\n return await new Promise((resolve, reject) => {\n const callback = function (this: any, err: Error | null) {\n if (err) return reject(err);\n resolve({ changes: this?.changes ?? 0, lastID: this?.lastID });\n };\n try {\n if (params.length > 0) {\n stmt.run(params, callback);\n } else {\n stmt.run(callback);\n }\n } catch (error) {\n reject(error);\n }\n });\n }\n const result = stmt.run(...params);\n return isPromiseLike(result) ? await result : result;\n }\n\n async _query(sql: string, params: any[] = []) {\n const stmt = await this.prepareStatement(sql);\n try {\n const rows = await this.statementAll(stmt, params);\n return rows;\n } finally {\n await this.finalizeStatement(stmt);\n }\n }\n\n async _execute(sql: string, params: any[] = []) {\n // Handle empty or comment-only SQL gracefully\n if (this.isEmptySQL(sql)) {\n return { changes: 0, lastID: 0 }; // No-op result\n }\n\n if (this.isMultiStatement(sql)) {\n return await this.executeMultiStatement(sql, params)\n .catch((err) => {\n console.error((\n \"Error executing multi-statement SQL:\\n\"+\n `${sql}\\n`\n ), err);\n throw err;\n });\n }\n\n const stmt = await this.prepareStatement(sql);\n try {\n const info = await this.statementRun(stmt, params);\n return info;\n } finally {\n await this.finalizeStatement(stmt);\n }\n }\n\n /**\n * Checks if SQL is empty or contains only comments/whitespace.\n * Returns true if there is no actual SQL to execute.\n */\n private isEmptySQL(sql: string): boolean {\n // Remove all comments and whitespace\n const withoutComments = sql\n .replace(/--.*$/gm, '') // Remove single-line comments\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '') // Remove multi-line comments\n .trim();\n return withoutComments.length === 0;\n }\n\n private isMultiStatement(sql: string): boolean {\n // SQLite does not support multiple statements in a single query.\n return sql.split(';').length > 1;\n }\n\n private async executeMultiStatement(sql: string, params: any[] = []) {\n const statements = sql.split(';')\n .map((s) => s.split('\\n')\n .map(\n s=>this.removeComments(s))\n .filter(s=>s.trim()!='')\n .join('\\n')\n )\n .filter((s) => s.trim() !== '');\n \n const infos = await statements.reduce(async (prev,statement) => {\n const infos = await prev;\n const stmt = await this.prepareStatement(`${statement};`);\n try {\n const info = await this.statementRun(stmt, params);\n infos.push(info);\n return infos;\n } finally {\n await this.finalizeStatement(stmt);\n }\n },Promise.resolve([null] as any[]))\n .then((infos:QueryResult[]) => {\n return infos.filter((info) => info !== null);\n })\n return infos.reduce((acc,latest)=>{\n if(latest){\n acc.stmt = latest.stmt;\n acc.lastID = latest.lastID;\n acc.changes += latest.changes;\n }\n return acc\n })\n }\n\n private removeComments(sql: string): string {\n // Remove single-line comments\n sql = sql.replace(/--.*$/gm, '');\n return sql;\n }\n\n\n async _end() {\n if (this.connection) {\n await this.connection.close();\n }\n }\n}\n","import fs from 'fs';\nimport path from 'path';\nimport Ajv from 'ajv';\nimport addFormats from 'ajv-formats';\n\nimport type { IMigrationRunner, MigrationHistory } from './MigrationRunner';\nimport { MigrationRunnerFactory, FileMigrationConfigReader, loadMigrationConfig } from './MigrationRunner';\nimport type { MigrationConfig } from './MigrationConfig';\n\nexport type SeedTransactionalMode = 'runner' | 'seed' | 'none';\n\nexport type SeedOptions = {\n migrationsDir?: string;\n dataDir?: string;\n validate?: boolean;\n transactional?: SeedTransactionalMode;\n aliasMap?: Record<string, string>;\n preloadedData?: Record<string, unknown>;\n log?: (msg: string) => void;\n names?: string[];\n};\n\nexport type ResolvedSeed = {\n kind: 'sql' | 'ts' | 'js';\n name: string;\n alias: string;\n upPath: string;\n downPath?: string;\n dataPath: string | null;\n schemaPath: string | null;\n};\n\nfunction resolveAlias(name: string, aliasMap?: Record<string, string>): string {\n if (!aliasMap) return name;\n return aliasMap[name] ?? name;\n}\n\nfunction walkForFile(rootDir: string, fileName: string): string | null {\n if (!fs.existsSync(rootDir)) return null;\n const entries = fs.readdirSync(rootDir, { withFileTypes: true });\n for (const entry of entries) {\n const full = path.join(rootDir, entry.name);\n if (entry.isDirectory()) {\n const found = walkForFile(full, fileName);\n if (found) return found;\n } else if (entry.isFile() && entry.name === fileName) {\n return full;\n }\n }\n return null;\n}\n\nfunction resolveMigrationsDir(migrationConfig: MigrationConfig, options: SeedOptions): string {\n const fromOptions = options.migrationsDir;\n const fromConfig = migrationConfig.seeds?.migrationsDir;\n\n const dir = fromOptions ?? fromConfig;\n if (!dir) {\n throw new Error('Seed migrationsDir not configured. Set seeds.migrationsDir in proper.json or pass it explicitly.');\n }\n return dir;\n}\n\nfunction mergeSeedConfig(\n migrationConfig: MigrationConfig,\n options: SeedOptions,\n): { names: string[]; finalOptions: SeedOptions & { migrationsDir: string; validate: boolean; transactional: SeedTransactionalMode } } {\n const names = options.names && options.names.length\n ? options.names\n : migrationConfig.seeds?.list && migrationConfig.seeds.list.length\n ? migrationConfig.seeds.list\n : [];\n\n if (!names.length) {\n throw new Error('No seed names provided and no seeds.list defined in proper config');\n }\n\n const migrationsDir = resolveMigrationsDir(migrationConfig, options);\n const dataDir = options.dataDir ?? migrationConfig.seeds?.dataDir;\n const validate = options.validate !== undefined ? options.validate : true;\n const transactional = options.transactional ?? 'none';\n\n const finalOptions: SeedOptions & { migrationsDir: string; validate: boolean; transactional: SeedTransactionalMode } = {\n ...options,\n migrationsDir,\n dataDir,\n validate,\n transactional,\n };\n\n return { names, finalOptions };\n}\n\n// export function loadMigrationConfig(configFile: string): MigrationConfig {\n// const reader = new FileMigrationConfigReader(configFile);\n// return reader.loadFile();\n// }\n\nfunction resolveSqlPair(name: string, migrationsDir: string): { upPath: string; downPath: string } | null {\n const up = walkForFile(migrationsDir, `${name}.up.sql`);\n const down = walkForFile(migrationsDir, `${name}.down.sql`);\n if (up && down) {\n return { upPath: up, downPath: down };\n }\n return null;\n}\n\nfunction resolveModule(name: string, migrationsDir: string): { kind: 'ts' | 'js'; modulePath: string } | null {\n const ts = walkForFile(migrationsDir, `${name}.ts`);\n if (ts) return { kind: 'ts', modulePath: ts };\n const js = walkForFile(migrationsDir, `${name}.js`);\n if (js) return { kind: 'js', modulePath: js };\n return null;\n}\n\nexport async function resolveSeed(\n name: string,\n migrationConfig: MigrationConfig,\n options: SeedOptions,\n): Promise<ResolvedSeed> {\n const migrationsDir = resolveMigrationsDir(migrationConfig, options);\n const alias = resolveAlias(name, options.aliasMap);\n\n const sqlPair = resolveSqlPair(name, migrationsDir);\n if (sqlPair) {\n return {\n kind: 'sql',\n name,\n alias,\n upPath: sqlPair.upPath,\n downPath: sqlPair.downPath,\n dataPath: null,\n schemaPath: null,\n };\n }\n\n const module = resolveModule(name, migrationsDir);\n if (!module) {\n throw new Error(`Seed implementation not found for \"${name}\" under ${migrationsDir}`);\n }\n\n const dataDir = options.dataDir ?? migrationConfig.seeds?.dataDir;\n let dataPath: string | null = null;\n let schemaPath: string | null = null;\n\n if (dataDir) {\n dataPath = walkForFile(dataDir, `${alias}.json`);\n schemaPath = walkForFile(dataDir, `${alias}.schema.json`);\n }\n\n return {\n kind: module.kind,\n name,\n alias,\n upPath: module.modulePath,\n downPath: module.modulePath,\n dataPath,\n schemaPath,\n };\n}\n\nasync function loadJson(filePath: string): Promise<unknown> {\n const content = await fs.promises.readFile(filePath, 'utf8');\n return JSON.parse(content);\n}\n\nfunction createValidator() {\n const ajv = new Ajv({ allErrors: true, strict: false });\n addFormats(ajv);\n return ajv;\n}\n\nasync function validateData(schemaPath: string | null, data: unknown, validate: boolean, log?: (msg: string) => void) {\n if (!validate || !schemaPath) return;\n const content = await fs.promises.readFile(schemaPath, 'utf8');\n const schema = JSON.parse(content);\n const ajv = createValidator();\n const validateFn = ajv.compile(schema);\n const ok = validateFn(data);\n if (!ok) {\n log?.(`Validation failed for seed data (${schemaPath})`);\n throw new Error(`Seed data validation failed: ${ajv.errorsText(validateFn.errors || [])}`);\n }\n}\n\nasync function runSqlSeed(\n runner: IMigrationRunner,\n resolved: ResolvedSeed,\n direction: 'up' | 'down',\n): Promise<void> {\n const sqlPath = direction === 'up' ? resolved.upPath : resolved.downPath!;\n const sql = await fs.promises.readFile(sqlPath, 'utf8');\n await runner.query(sql);\n}\n\nexport type SeedContext = {\n data: unknown;\n log?: (msg: string) => void;\n dialect: string;\n};\n\nasync function loadSeedModule(modulePath: string): Promise<any> {\n const resolved = path.resolve(modulePath);\n // Use dynamic import for all module types (works in both ESM and CJS contexts)\n return import(resolved);\n}\n\nasync function runModuleSeed(\n runner: IMigrationRunner,\n resolved: ResolvedSeed,\n migrationConfig: MigrationConfig,\n options: SeedOptions & { validate: boolean },\n direction: 'up' | 'down',\n): Promise<void> {\n const { log } = options;\n const module = await loadSeedModule(resolved.upPath);\n const handler = module[direction];\n if (typeof handler !== 'function') {\n throw new Error(`Seed module \"${resolved.name}\" does not export ${direction}()`);\n }\n\n let data: unknown = null;\n if (options.preloadedData && Object.prototype.hasOwnProperty.call(options.preloadedData, resolved.name)) {\n data = options.preloadedData[resolved.name];\n } else if (resolved.dataPath) {\n data = await loadJson(resolved.dataPath);\n }\n\n await validateData(resolved.schemaPath, data, options.validate, log);\n\n const ctx: SeedContext = {\n data,\n log,\n dialect: migrationConfig.database || 'sql',\n };\n\n await handler(runner, ctx);\n}\n\nasync function runSingleSeed(\n runner: IMigrationRunner,\n migrationConfig: MigrationConfig,\n name: string,\n options: SeedOptions & { validate: boolean; transactional: SeedTransactionalMode },\n direction: 'up' | 'down',\n): Promise<void> {\n const resolved = await resolveSeed(name, migrationConfig, options);\n\n if (resolved.kind === 'sql') {\n await runSqlSeed(runner, resolved, direction);\n } else {\n await runModuleSeed(runner, resolved, migrationConfig, options, direction);\n }\n}\n\nasync function withTransactionalMode(\n runner: IMigrationRunner,\n migrationConfig: MigrationConfig,\n names: string[],\n options: SeedOptions & { validate: boolean; transactional: SeedTransactionalMode },\n direction: 'up' | 'down',\n): Promise<void> {\n const mode = options.transactional;\n\n if (mode === 'runner') {\n await runner.query('BEGIN');\n try {\n for (const name of names) {\n await runSingleSeed(runner, migrationConfig, name, options, direction);\n }\n await runner.query('COMMIT');\n } catch (err) {\n try {\n await runner.query('ROLLBACK');\n } catch {\n }\n throw err;\n }\n return;\n }\n\n if (mode === 'seed') {\n for (const name of names) {\n await runner.query('BEGIN');\n try {\n await runSingleSeed(runner, migrationConfig, name, options, direction);\n await runner.query('COMMIT');\n } catch (err) {\n try {\n await runner.query('ROLLBACK');\n } catch {\n }\n throw err;\n }\n }\n return;\n }\n\n for (const name of names) {\n await runSingleSeed(runner, migrationConfig, name, options, direction);\n }\n}\n\nexport async function runSeedsWithRunner(\n runner: IMigrationRunner,\n migrationConfig: MigrationConfig,\n direction: 'up' | 'down',\n options: SeedOptions,\n): Promise<void> {\n const { names, finalOptions } = mergeSeedConfig(migrationConfig, options);\n await withTransactionalMode(runner, migrationConfig, names, finalOptions, direction);\n}\n\nexport type SeedFactoryOptions = SeedOptions & {\n configFile?: string;\n};\n\nexport type SeedFactory = {\n up(names?: string[]): Promise<void>;\n down(names?: string[]): Promise<void>;\n};\n\nexport function createSeedFactory(options: SeedFactoryOptions): SeedFactory {\n const configFile = options.configFile ?? 'proper.json';\n\n return {\n async up(names?: string[]) {\n const runner = await MigrationRunnerFactory.create(configFile);\n const migrationConfig = loadMigrationConfig(configFile);\n try {\n await runSeedsWithRunner(runner, migrationConfig, 'up', {\n ...options,\n names: names && names.length ? names : options.names,\n });\n } finally {\n await runner.close();\n }\n },\n\n async down(names?: string[]) {\n const runner = await MigrationRunnerFactory.create(configFile);\n const migrationConfig = loadMigrationConfig(configFile);\n try {\n await runSeedsWithRunner(runner, migrationConfig, 'down', {\n ...options,\n names: names && names.length ? names : options.names,\n });\n } finally {\n await runner.close();\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAOA,SAAQ;AAGf,OAAO,WAAW;AAClB,YAAY,YAAY;AACxB,YAAY,aAAa;;;ACNzB,OAAO,QAAQ;AACf,OAAO,UAAU;;;ACEV,IAAM,iBAAN,MAAM,wBAAuB,MAAM;AAAA,EACxC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAEZ,WAAO,eAAe,MAAM,gBAAe,SAAS;AAAA,EACtD;AACF;AAKO,IAAM,qBAAN,MAAM,4BAA2B,eAAe;AAAA,EACrD,YAAY,SAAiB;AAC3B,UAAM,wBAAwB,OAAO,EAAE;AACvC,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,oBAAmB,SAAS;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,6BAA6B,QAAoC;AACtE,WAAO,IAAI,oBAAmB,WAAW,MAAM,gBAAgB;AAAA,EACjE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,oBAAoB,QAAoC;AAC7D,WAAO,IAAI,oBAAmB,0BAA0B,MAAM,EAAE;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,wBAAwB,U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,iCACnD,UADmD;AAAA,YAEtD,OAAO,SAAS,MAAM,SAAS,QAAQ,QAAQ;AAAA,UACjD,EAAC;AAAA,QACH,UAAE;AACA,gBAAM,OAAO,MAAM;AAAA,QACrB;AAAA,MACF;AAAA;AAAA,IAEM,KAAK,OAAkB;AAAA;AAC3B,cAAM,SAAS,MAAM,uBAAuB,OAAO,UAAU;AAC7D,cAAM,kBAAkB,oBAAoB,UAAU;AACtD,YAAI;AACF,gBAAM,mBAAmB,QAAQ,iBAAiB,QAAQ,iCACrD,UADqD;AAAA,YAExD,OAAO,SAAS,MAAM,SAAS,QAAQ,QAAQ;AAAA,UACjD,EAAC;AAAA,QACH,UAAE;AACA,gBAAM,OAAO,MAAM;AAAA,QACrB;AAAA,MACF;AAAA;AAAA,EACF;AACF;","names":["fs","fs","fs","s","infos","fs","fs","path","fs","path"]}
1
+ {"version":3,"sources":["../framework/MigrationRunner.ts","../framework/MigrationDirectoryReader.ts","../framework/errors.ts","../framework/MigrationNode.ts","../framework/SqlMigrationBuilder.ts","../framework/MigrationSetup.ts","../framework/MigrationFilter.ts","../framework/MigrationDialectParser.ts","../framework/SQLRunner.ts","../framework/SeedRunner.ts"],"sourcesContent":["// Node built-in modules\nimport fs from 'fs';\n\n// Database drivers\nimport mysql from 'mysql2/promise';\nimport * as sqlite from 'sqlite';\nimport * as sqlite3 from 'sqlite3';\n\n// Helper function to convert any error to Error object\nfunction toError(error: unknown): Error {\n if (error instanceof Error) return error;\n return new Error(String(error));\n}\n\n// Migration framework\nimport { MigrationConfig } from \"./MigrationConfig\";\nimport { MigrationDirectoryReader } from './MigrationDirectoryReader';\nimport { MigrationNode } from './MigrationNode';\nimport { MigrationSetup } from './MigrationSetup';\nimport { migration_filter } from './MigrationFilter';\nimport * as dialect from \"./MigrationDialectParser\";\n\n\nimport { ISQLRunner,SQLRunner,SQLiteRunner } from './SQLRunner';\nimport { ErrorMessage } from './ErrorMessage';\nimport { \n ConfigurationError, \n DatabaseConnectionError, \n MigrationExecutionError,\n CLIError \n} from './errors';\n\n\nexport function loadMigrationConfig(configFile: string): MigrationConfig {\n const reader = new FileMigrationConfigReader(configFile);\n return reader.loadFile();\n}\n\nexport class MigrationRunnerFactory {\n\n private static isSQLRunner(conn: any): conn is ISQLRunner {\n return !!conn\n && typeof conn.query === \"function\"\n && typeof conn.execute === \"function\"\n && typeof conn.end === \"function\";\n }\n\n static async create(configFile:string,conn?:any){\n const configReader = new FileMigrationConfigReader(configFile);\n const config = configReader.loadFile();\n\n if(!conn){\n conn = await this.createConnection(config)\n }\n return new MigrationRunnerFactory().create(config,conn)\n }\n\n static async createConnection(config:MigrationConfig){\n let conn = null as any\n switch(config.database){\n case \"sql\":\n if (!config.sql){\n throw ConfigurationError.missingDatabaseConfiguration(\"sql\");\n }\n const settings = Object.assign({\n password:process.env.SQL_PASSWORD\n },config.sql);\n try {\n conn = await mysql.createConnection(settings);\n return conn;\n } catch (error) {\n throw DatabaseConnectionError.connectionFailed(\"sql\", toError(error).message);\n }\n case \"sqlite\":\n if (!config.sqlite){\n throw ConfigurationError.missingDatabaseConfiguration(\"sqlite\");\n }\n try {\n conn = await sqlite.open({\n filename:config.sqlite.database,\n driver:sqlite3.Database\n });\n return conn;\n } catch (error) {\n throw DatabaseConnectionError.connectionFailed(\"sqlite\", toError(error).message);\n }\n default:\n throw ConfigurationError.unknownDatabaseType(config.database);\n }\n \n }\n\n static async createEmpty(configFile:string){\n const configReader = new FileMigrationConfigReader(configFile);\n const config = configReader.loadFile();\n return new MigrationRunnerFactory().createEmpty(config)\n }\n\n\n async create(config:MigrationConfig,conn:any):Promise<MySQLMigrationRunner>{\n let sqlrunner:ISQLRunner;\n let driverConnection = conn;\n\n if (MigrationRunnerFactory.isSQLRunner(conn)) {\n sqlrunner = conn;\n driverConnection = null;\n } else {\n switch(config.database){\n case \"sql\":\n sqlrunner = new SQLRunner(conn)\n break;\n case \"sqlite\":\n sqlrunner = new SQLiteRunner(conn)\n break;\n default:\n throw ConfigurationError.unknownDatabaseType(config.database);\n }\n }\n const setup = new MigrationSetup(sqlrunner,config);\n const read_strategy = this.getReadStategy(config)\n\n const migration_files = new MigrationDirectoryReader(config.migration_folder,read_strategy,sqlrunner,config.database as 'sql' | 'sqlite')\n\n // Ensure the migrations infrastructure (i.e. the migrations table)\n // exists before we hand the runner back to the caller – most callers\n // expect the runner to be immediately usable without having to invoke\n // `setup()` manually. This is particularly important for projects\n // (like Groom) that directly call `getMigrations()` and\n // `migrate(...)` after obtaining the runner.\n await setup.setup();\n\n return new MySQLMigrationRunner(config,migration_files,setup,sqlrunner,driverConnection);\n }\n\n\n async createEmpty(config:MigrationConfig):Promise<MySQLMigrationRunner>{\n const conn = null as any\n let sqlrunner:ISQLRunner\n\n switch(config.database){\n case \"sql\":\n sqlrunner = new SQLRunner(conn)\n break;\n case \"sqlite\":\n sqlrunner = new SQLiteRunner(conn)\n break;\n default:\n throw ConfigurationError.unknownDatabaseType(config.database);\n }\n const setup = new MigrationSetup(sqlrunner,config);\n const read_strategy = this.getReadStategy(config)\n\n const migration_files = new MigrationDirectoryReader(config.migration_folder,read_strategy,sqlrunner,config.database as 'sql' | 'sqlite')\n return new MySQLMigrationRunner(config,migration_files,setup,sqlrunner,conn);\n }\n\n private getReadStategy(config:MigrationConfig){\n switch(config.database){\n case \"sql\":\n return dialect.MySqlDialectParser\n case \"sqlite\":\n return dialect.SqliteDialectParser\n default:\n throw ConfigurationError.unknownDatabaseType(config.database);\n }\n }\n}\n\n\nexport interface MigrationHistory{\n name:string\n up:string\n down:string\n}\n\nexport interface IMigrationRunner {\n setup(): Promise<void>;\n terminate(): Promise<void>;\n getMigrationsHistory(): Promise<MigrationHistory[]>;\n getMigrations(): Promise<MigrationNode[]>;\n getPendingMigrations(): Promise<MigrationNode[]>;\n getCompletedMigrations(): Promise<MigrationNode[]>;\n migrate(migrationNodes: MigrationNode[], forward: boolean): Promise<void>;\n reset(): Promise<void>;\n createMigration(name: string): void;\n close(): Promise<void>;\n init(config_file: string): Promise<void>;\n query(sql: string, params?: any[]): Promise<any>;\n}\n\nexport class MySQLMigrationRunner implements IMigrationRunner {\n constructor(\n private config:MigrationConfig,\n private directory:MigrationDirectoryReader,\n private setupRunner:MigrationSetup,\n private sqlrunner:ISQLRunner,\n private connection:mysql.Connection\n){\n\n }\n\n async setup(){\n try {\n await this.setupRunner.setup();\n } catch (error) {\n throw new MigrationExecutionError('Failed to set up migration database', undefined, undefined, toError(error));\n }\n }\n\n async terminate(){\n try {\n await this.setupRunner.teardown();\n } catch (error) {\n throw new MigrationExecutionError('Failed to tear down migration database', undefined, undefined, toError(error));\n }\n }\n\n async getMigrationsHistory():Promise<MigrationHistory[]>{\n try {\n const results = await this.sqlrunner.query(`\n select * \n from ${this.config.migration_table}\n `);\n return results[0] as any;\n } catch (error) {\n throw new MigrationExecutionError('Failed to get migration history', undefined, undefined, toError(error));\n }\n }\n\n\n async getMigrations(){\n try {\n return this.directory.loadMigrations(this.config.migration_table,this.connection);\n } catch (error) {\n throw new MigrationExecutionError('Failed to load migrations', undefined, undefined, toError(error));\n }\n }\n\n async getPendingMigrations(){\n try {\n const migrations = await this.getMigrations();\n return migration_filter(migrations,false);\n } catch (error) {\n if (error instanceof MigrationExecutionError) {\n throw error;\n }\n throw new MigrationExecutionError('Failed to get pending migrations', undefined, undefined, toError(error));\n }\n }\n\n async getCompletedMigrations(){\n try {\n const migrations = await this.getMigrations();\n return migration_filter(migrations,true);\n } catch (error) {\n if (error instanceof MigrationExecutionError) {\n throw error;\n }\n throw new MigrationExecutionError('Failed to get completed migrations', undefined, undefined, toError(error));\n }\n }\n\n async migrate(migrationNodes:MigrationNode[],forward:boolean):Promise<void>{\n for(let node of migrationNodes){\n try {\n if(forward){\n await node.up();\n }else{\n await node.down();\n }\n } catch (error) {\n throw new MigrationExecutionError(\n `Failed to ${forward ? 'apply' : 'rollback'} migration`,\n node.name || String(node),\n forward ? node.up_sql() : node.down_sql(),\n toError(error)\n );\n }\n }\n }\n\n\n async reset(){\n try {\n let migrations = await this.getMigrations();\n const rollback = await migration_filter(migrations,true);\n await this.migrate(rollback.reverse(),false);\n migrations = await this.getMigrations();\n const rollforward = await migration_filter(migrations,false);\n await this.migrate(rollforward,true);\n } catch (error) {\n if (error instanceof MigrationExecutionError) {\n throw error;\n }\n throw new MigrationExecutionError('Failed to reset migrations', undefined, undefined, toError(error));\n }\n }\n\n\n createMigration(name:string){\n try {\n const creator = new MigrationCreator(this.config);\n creator.create(name);\n } catch (error) {\n throw new MigrationExecutionError(`Failed to create migration: ${name}`, undefined, undefined, toError(error));\n }\n }\n\n\n async close(){\n if (this.sqlrunner) {\n try {\n await this.sqlrunner.end();\n } catch (error) {\n throw new DatabaseConnectionError(`Failed to close database connection: ${toError(error).message}`);\n }\n }\n }\n\n async query(sql: string, params?: any[]): Promise<any> {\n return await this.sqlrunner.query(sql, params);\n }\n\n async init(config_file:string){\n try {\n console.log(`Checking for ${config_file}`);\n const config_exist = fs.existsSync(config_file);\n\n if(!config_exist){\n console.log(`Creating ${config_file}`);\n const default_config = {\n \"migration_folder\":\"migrations\",\n \"migration_table\":\"proper_migrations\",\n \"database\": \"sql\",\n \"sql\":{\n \"host\":\"localhost\",\n \"user\":\"root\",\n \"database\":\"proper\",\n \"password\":\"\"\n }\n };\n fs.writeFileSync(config_file,JSON.stringify(default_config,null,2)); \n console.log(`Created ${config_file}`);\n }\n } catch (error) {\n throw new ConfigurationError(`Failed to initialize config file: ${toError(error).message}`);\n }\n }\n}\n\n\nexport class FileMigrationConfigReader{\n\n constructor(private configFile:string){\n\n }\n\n loadFile(){\n try {\n const fileContent = fs.readFileSync(this.configFile);\n const config:MigrationConfig = JSON.parse(fileContent.toString());\n \n // Validate required fields\n if (!config.migration_folder) {\n throw ConfigurationError.missingRequiredProperty('migration_folder');\n }\n \n if (!config.migration_table) {\n throw ConfigurationError.missingRequiredProperty('migration_table');\n }\n \n // For backward compatibility: if database type is omitted we derive\n // it from the presence of the dialect specific configuration\n // blocks. This keeps older `proper.json` files – that only defined\n // an \"sql\" or \"sqlite\" section – working without modification.\n if (!config.database) {\n if (config.sql) {\n config.database = 'sql';\n } else if (config.sqlite) {\n config.database = 'sqlite';\n } else {\n throw ConfigurationError.missingRequiredProperty('database');\n }\n }\n \n return config;\n } catch (error) {\n if (error instanceof ConfigurationError) {\n throw error;\n }\n const err = toError(error);\n if (err.message.includes('ENOENT')) {\n throw new ConfigurationError(`Config file not found: ${this.configFile}`);\n }\n throw new ConfigurationError(`Failed to load config file: ${err.message}`);\n }\n }\n}\n\n\nexport class MigrationCreator{\n constructor(private config:MigrationConfig){\n \n }\n\n\n create(name:string){\n if (!name) {\n throw new CLIError('Migration name is required');\n }\n\n try {\n // Ensure the migration folder exists\n if (!fs.existsSync(this.config.migration_folder)) {\n fs.mkdirSync(this.config.migration_folder, { recursive: true });\n }\n\n const now_timestamp = Date.now();\n\n const filename_up = `${now_timestamp}_${name}.up.sql`;\n const filename_down = `${now_timestamp}_${name}.down.sql`;\n\n fs.writeFileSync(`${this.config.migration_folder}/${filename_up}`,`\n-- Write your up migration here\n `.trim());\n\n fs.writeFileSync(`${this.config.migration_folder}/${filename_down}`,`\n-- Write your down migration here\n `.trim());\n \n console.log(`Created migration files:`);\n console.log(` ${filename_up}`);\n console.log(` ${filename_down}`);\n } catch (error) {\n if (error instanceof CLIError) {\n throw error;\n }\n throw new MigrationExecutionError(`Failed to create migration files: ${toError(error).message}`);\n }\n }\n}\n","import fs from \"fs\";\nimport path from \"path\";\nimport { MigrationNode } from './MigrationNode';\nimport { SqlMigrationBuilder } from './SqlMigrationBuilder';\nimport mysql from \"mysql2/promise\";\nimport { ISQLRunner } from \"./SQLRunner\";\n\n\nexport interface MigrationOptions{\n conn:mysql.Connection\n}\n\nexport class MigrationDirectoryReader {\n\n constructor(\n private directory: string,\n private read_strategy: any,\n private sqlrunner: ISQLRunner,\n private dialect: 'sql' | 'sqlite' = 'sql'\n ) {\n\n }\n\n /**\n * Resolves the appropriate file for a migration based on dialect.\n * Priority: dialect-specific file > generic file\n */\n private resolveFile(baseName: string, direction: 'up' | 'down'): string | null {\n const dialectExt = this.dialect === 'sql' ? 'mysql' : 'sqlite';\n\n // Priority 1: Dialect-specific file\n const dialectFile = path.join(this.directory, `${baseName}.${dialectExt}.${direction}.sql`);\n if (fs.existsSync(dialectFile)) return dialectFile;\n\n // Priority 2: Generic file\n const genericFile = path.join(this.directory, `${baseName}.${direction}.sql`);\n if (fs.existsSync(genericFile)) return genericFile;\n\n return null;\n }\n\n /**\n * Checks if a file path is dialect-specific (contains .mysql. or .sqlite. in the name)\n */\n private isDialectSpecific(filePath: string): boolean {\n return /\\.(mysql|sqlite)\\.(up|down)\\.sql$/i.test(filePath);\n }\n\n loadMigrations(table:string,connection:any):MigrationNode[] {\n\n fs.existsSync(this.directory) || fs.mkdirSync(this.directory);\n const dir_content = fs.readdirSync(this.directory,{withFileTypes:true}).filter(file=>file.isFile()).map(file=>file.name);\n\n // Extract unique migration keys (stripping dialect extensions)\n const uniqueKeys = new Set<string>();\n dir_content.forEach(file => {\n // Strip dialect extension (.mysql or .sqlite) and direction (.up or .down) to get base key\n const key = file.replace(/(?:\\.(mysql|sqlite))?\\.(up|down)\\.(sql|js)/i, \"\").toLowerCase();\n uniqueKeys.add(key);\n });\n\n const migration_sorter: any = {};\n\n // For each unique key, resolve the correct files based on dialect\n uniqueKeys.forEach((migration_key) => {\n const builder = new SqlMigrationBuilder(migration_key);\n\n const upFile = this.resolveFile(migration_key, 'up');\n const downFile = this.resolveFile(migration_key, 'down');\n\n if (upFile) {\n this.loadMigration(builder, upFile);\n }\n if (downFile) {\n this.loadMigration(builder, downFile);\n }\n\n migration_sorter[migration_key] = builder;\n });\n\n const keys = Object.keys(migration_sorter)\n\n keys.sort()\n\n const built = keys.map(key=>{\n return migration_sorter[key].build(table,this.sqlrunner)\n })\n return built\n\n }\n\n\n loadMigration(builder: SqlMigrationBuilder, file: string) {\n const is_sql = /sql$/i.test(file);\n const is_js = /js$/i.test(file);\n const is_up = /up\\.(js|sql)/i.test(file);\n const is_down = /down\\.(js|sql)/i.test(file);\n if (is_sql && is_up) {\n const content = this.sql_up(file);\n builder.set_up(file,content);\n } else if (is_sql && is_down) {\n const content = this.sql_down(file);\n builder.set_down(file,content);\n } else {\n throw new Error(`Invalid migration file: ${file}`);\n }\n return builder;\n }\n\n\n sql_up(file: string) {\n let content = fs.readFileSync(file).toString();\n // Dialect-specific files bypass read_strategy (no inline marker parsing needed)\n if (!this.isDialectSpecific(file)) {\n content = this.read_strategy(content);\n }\n return content.trim();\n }\n\n sql_down(file: string) {\n let content = fs.readFileSync(file).toString();\n // Dialect-specific files bypass read_strategy (no inline marker parsing needed)\n if (!this.isDialectSpecific(file)) {\n content = this.read_strategy(content);\n }\n return content.trim();\n }\n\n}\n","/**\n * Base class for all migration-related errors\n */\nexport class MigrationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'MigrationError';\n // This is needed to make instanceof work correctly in ES5\n Object.setPrototypeOf(this, MigrationError.prototype);\n }\n}\n\n/**\n * Error thrown when there is an issue with the configuration\n */\nexport class ConfigurationError extends MigrationError {\n constructor(message: string) {\n super(`Configuration Error: ${message}`);\n this.name = 'ConfigurationError';\n Object.setPrototypeOf(this, ConfigurationError.prototype);\n }\n\n /**\n * Helper method for missing database configuration\n * @param dbType The database type (e.g., 'sql', 'sqlite')\n * @returns A ConfigurationError with appropriate message\n */\n static missingDatabaseConfiguration(dbType: string): ConfigurationError {\n return new ConfigurationError(`Missing ${dbType} configuration`);\n }\n\n /**\n * Helper method for unknown database type\n * @param dbType The unknown database type\n * @returns A ConfigurationError with appropriate message\n */\n static unknownDatabaseType(dbType: string): ConfigurationError {\n return new ConfigurationError(`Unknown database type: ${dbType}`);\n }\n\n /**\n * Helper method for missing required configuration properties\n * @param property The name of the missing property\n * @returns A ConfigurationError with appropriate message\n */\n static missingRequiredProperty(property: string): ConfigurationError {\n return new ConfigurationError(`Missing required property: ${property}`);\n }\n}\n\n/**\n * Error thrown when there is an issue with the database connection\n */\nexport class DatabaseConnectionError extends MigrationError {\n constructor(message: string) {\n super(`Database Connection Error: ${message}`);\n this.name = 'DatabaseConnectionError';\n Object.setPrototypeOf(this, DatabaseConnectionError.prototype);\n }\n\n /**\n * Helper method for connection errors\n * @param dbType The database type (e.g., 'sql', 'sqlite')\n * @param details Additional error details\n * @returns A DatabaseConnectionError with appropriate message\n */\n static connectionFailed(dbType: string, details?: string): DatabaseConnectionError {\n const message = details \n ? `Failed to connect to ${dbType} database: ${details}`\n : `Failed to connect to ${dbType} database`;\n return new DatabaseConnectionError(message);\n }\n\n /**\n * Helper method for authentication errors\n * @param dbType The database type (e.g., 'sql', 'sqlite')\n * @returns A DatabaseConnectionError with appropriate message\n */\n static authenticationFailed(dbType: string): DatabaseConnectionError {\n return new DatabaseConnectionError(`Authentication failed for ${dbType} database`);\n }\n}\n\n/**\n * Error thrown when there is an issue with executing a migration\n */\nexport class MigrationExecutionError extends MigrationError {\n constructor(\n message: string,\n public readonly migrationName?: string,\n public readonly sql?: string,\n public readonly originalError?: Error\n ) {\n /*\n * The public `message` that gets surfaced to callers **must not** include the\n * raw SQL text. The SQL string is already exposed through the dedicated\n * `sql` property and adding it to the message makes it unnecessarily noisy\n * and difficult to assert against in unit-tests. Therefore we only embed\n * the essential information (error type, optional migration name and the\n * short error message) in the main message string while keeping the full\n * SQL available separately.\n */\n let fullMessage = `Migration Execution Error${migrationName ? ` in '${migrationName}'` : ''}: ${message}`;\n\n if(originalError){\n fullMessage += `\\nOriginal Error:\\n${originalError.message}`;\n }\n\n super(fullMessage);\n this.name = 'MigrationExecutionError';\n Object.setPrototypeOf(this, MigrationExecutionError.prototype);\n }\n\n /**\n * Helper method for SQL execution errors\n * @param migrationName The name of the migration\n * @param sql The SQL that caused the error\n * @param originalError The original error thrown by the database driver\n * @returns A MigrationExecutionError with appropriate message\n */\n static sqlExecutionFailed(migrationName: string, sql: string, originalError: Error): MigrationExecutionError {\n return new MigrationExecutionError(\n originalError.message,\n migrationName,\n sql,\n originalError\n );\n }\n\n /**\n * Helper method for missing migration file errors\n * @param filename The missing file\n * @returns A MigrationExecutionError with appropriate message\n */\n static missingMigrationFile(filename: string): MigrationExecutionError {\n return new MigrationExecutionError(`Migration file not found: ${filename}`);\n }\n\n /**\n * Helper method for invalid migration file format errors\n * @param filename The invalid file\n * @param details Additional error details\n * @returns A MigrationExecutionError with appropriate message\n */\n static invalidMigrationFile(filename: string, details?: string): MigrationExecutionError {\n const message = details\n ? `Invalid migration file format in ${filename}: ${details}`\n : `Invalid migration file format in ${filename}`;\n return new MigrationExecutionError(message);\n }\n}\n\n/**\n * Error thrown when there is an issue with the migration CLI\n */\nexport class CLIError extends MigrationError {\n constructor(message: string) {\n super(`CLI Error: ${message}`);\n this.name = 'CLIError';\n Object.setPrototypeOf(this, CLIError.prototype);\n }\n\n /**\n * Helper method for missing command errors\n * @returns A CLIError with appropriate message\n */\n static missingCommand(): CLIError {\n return new CLIError('No command specified. Run with --help for usage information.');\n }\n\n /**\n * Helper method for unknown command errors\n * @param command The unknown command\n * @returns A CLIError with appropriate message\n */\n static unknownCommand(command: string): CLIError {\n return new CLIError(`Unknown command: ${command}. Run with --help for usage information.`);\n }\n\n /**\n * Helper method for missing required argument errors\n * @param argument The missing argument\n * @returns A CLIError with appropriate message\n */\n static missingRequiredArgument(argument: string): CLIError {\n return new CLIError(`Missing required argument: ${argument}`);\n }\n}\n","import { Connection } from 'mysql2/promise';\nimport { MigrationStatus } from './MigrationStatus';\nimport { ISQLRunner } from './SQLRunner';\nimport { MigrationExecutionError } from './errors';\n\nexport abstract class MigrationNode {\n name: string;\n\n constructor(name?: string) {\n this.name = name || '';\n }\n\n abstract get_key():string;\n abstract status(): Promise<MigrationStatus>;\n abstract up(): Promise<void>;\n abstract down(): Promise<void>;\n abstract up_sql(): string;\n abstract down_sql(): string;\n}\n\n\nexport class SqlMigrationNode extends MigrationNode {\n up_sql(): string {\n return this.sql_up;\n }\n down_sql(): string {\n return this.sql_down;\n }\n get_key(): string {\n return this.key;\n }\n\n constructor(private conn:ISQLRunner,\n private table:string, \n private key:string,\n private up_file:string,\n private sql_up:string,\n private down_file:string,\n private sql_down:string) {\n super(key);\n }\n\n async status(): Promise<MigrationStatus> {\n try {\n const result = await this.conn.query(`\n select * \n from ${this.table}\n where migration_key = ?;\n `, [this.key]);\n\n if(result.length > 0 && result[0].length > 0){\n return {\n completed: true\n };\n } else {\n return {\n completed: false\n };\n }\n } catch (error) {\n throw new MigrationExecutionError(\n `Error checking status for migration`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n\n async up(): Promise<void> {\n try {\n await this.conn.execute(this.sql_up);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error executing UP migration`,\n this.key,\n this.sql_up,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n \n try {\n await this.conn.execute(`\n insert into ${this.table} (migration_key,up,down)\n values (?,?,?)\n `, [this.key, this.up_file, this.down_file]);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error recording migration completion`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n\n async down(): Promise<void> {\n try {\n await this.conn.execute(this.sql_down);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error executing DOWN migration`,\n this.key,\n this.sql_down,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n \n try {\n await this.conn.execute(`\n delete from ${this.table}\n where migration_key = ?\n `, [this.key]);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error removing migration record`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n}\n\n\nexport class SqliteMigrationNode extends MigrationNode {\n up_sql(): string {\n return this.sql_up;\n }\n down_sql(): string {\n return this.sql_down;\n }\n constructor(\n private conn: ISQLRunner, // your SQLite runner\n private table: string,\n private key: string,\n private up_file: string,\n private sql_up: string,\n private down_file: string,\n private sql_down: string\n ) {\n super(key);\n }\n\n /**\n * Returns the unique key for this migration (e.g. timestamp + name).\n */\n get_key(): string {\n return this.key;\n }\n\n /**\n * Check if this migration is already completed by looking in the migration table.\n */\n async status(): Promise<MigrationStatus> {\n try {\n // Usually `this.conn.query(...)` returns an array of rows.\n // The first element might be the row set, depending on your runner.\n const cursor = await this.conn.query(\n `SELECT * FROM ${this.table} WHERE migration_key = ?;`,\n [this.key]\n );\n\n // Usually, `cursor[0]` is the row array in many MySQL runners;\n // In a SQLite scenario, it may be just `cursor`\n // So adjust depending on your actual runner's return shape.\n const rows = cursor[0] as any[];\n\n if (rows && rows.length > 0) {\n return { completed: true };\n } else {\n return { completed: false };\n }\n } catch (error) {\n throw new MigrationExecutionError(\n `Error checking status for migration`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n\n /**\n * Run the 'up' SQL, then record this migration in the table.\n */\n async up(): Promise<void> {\n try {\n // Execute the 'up' script\n await this.conn.execute(this.sql_up);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error executing UP migration`,\n this.key,\n this.sql_up,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n\n // Insert a record of this migration having completed\n try {\n await this.conn.execute(\n `\n INSERT INTO ${this.table} (migration_key, up, down)\n VALUES (?, ?, ?)\n `,\n [this.key, this.up_file, this.down_file]\n );\n } catch (error) {\n throw new MigrationExecutionError(\n `Error recording migration completion`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n\n /**\n * Run the 'down' SQL, then remove this migration record from the table.\n */\n async down(): Promise<void> {\n try {\n // Execute the 'down' script\n await this.conn.execute(this.sql_down);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error executing DOWN migration`,\n this.key,\n this.sql_down,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n\n // Remove the migration from the table\n try {\n await this.conn.execute(\n `\n DELETE FROM ${this.table}\n WHERE migration_key = ?\n `,\n [this.key]\n );\n } catch (error) {\n throw new MigrationExecutionError(\n `Error removing migration record`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n}","import { Connection } from 'mysql2/promise';\nimport { SqlMigrationNode } from './MigrationNode';\nimport { ISQLRunner } from './SQLRunner';\n\n\n\nexport class SqlMigrationBuilder {\n\n private up: string = '';\n private up_file: string = '';\n private down: string = '';\n private down_file: string = '';\n\n constructor(private key: string) {\n }\n\n set_up(file:string,up: string) {\n this.up_file = file;\n this.up = up;\n }\n\n set_down(file:string,down: string) {\n this.down_file = file;\n this.down = down;\n }\n\n build(table:string,conn: ISQLRunner) {\n return new SqlMigrationNode(conn, table,this.key, this.up_file, this.up, this.down_file,this.down);\n }\n}\n","import { MigrationConfig } from \"./MigrationConfig\";\nimport fs from \"fs\";\nimport { ISQLRunner } from './SQLRunner';\n\nexport class MigrationSetup {\n constructor(private sqlrunner: ISQLRunner, private config: MigrationConfig) {}\n\n\n async setup() {\n\n fs.existsSync(this.config.migration_folder) || fs.mkdirSync(this.config.migration_folder);\n\n const tableName = this.config.migration_table;\n\n // Use dialect-specific DDL so that the migrations table can be created\n // both in MySQL/MariaDB and in SQLite. The two dialects differ mainly\n // in the auto-increment syntax and the column types.\n const createTableSql = this.config.database === 'sqlite'\n ? `CREATE TABLE IF NOT EXISTS ${tableName} (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n migration_key TEXT,\n up TEXT,\n down TEXT,\n created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n )`\n : `CREATE TABLE IF NOT EXISTS ${tableName} (\n id INT AUTO_INCREMENT PRIMARY KEY,\n migration_key VARCHAR(255),\n up VARCHAR(255),\n down VARCHAR(255),\n created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n )`;\n\n await this.sqlrunner.query(createTableSql);\n }\n\n async teardown() {\n await this.sqlrunner.execute(`DROP TABLE ${this.config.migration_table}`);\n }\n}\n\n\n\n\n","import { MigrationNode } from \"./MigrationNode\";\n\n\n\n\nexport async function migration_filter(migrations:MigrationNode[],completed:boolean=true,keep:MigrationNode[]=[]){\n if(migrations.length === 0){\n return keep\n }\n\n const [first,...rest] = migrations\n\n const status = await first.status()\n\n if(status.completed == completed){\n keep.push(first)\n }\n\n return migration_filter(rest,completed,keep)\n}","export function MySqlDialectParser(sql: string): string {\n const lines = sql.split('\\n');\n let result = '';\n \n // We start \"in MySQL\" so that lines before [sql] are kept.\n let isInMySQLBlock = true;\n \n // e.g. `-- [sql]`, `-- [ sql ]`, `-- [mysql]`, ignoring case/spaces\n const startSQLRegex = /^\\s*--\\s*\\[\\s*(sql|mysql)\\s*\\]\\s*$/i;\n // e.g. `-- [sqlite]`, `-- [ pg ]`, `-- [mydialect]` (any bracket means \"turn off MySQL\")\n const anyDialectRegex = /^\\s*--\\s*\\[\\s*\\w+\\s*\\]\\s*$/i;\n \n for (const line of lines) {\n const trimmed = line.trim();\n \n // If line is \" -- [sql] \" or \" -- [mysql] \", we *turn on* MySQL capturing:\n if (startSQLRegex.test(trimmed)) {\n isInMySQLBlock = true;\n // We also include this line in output\n result += line + '\\n';\n continue;\n }\n \n // If line is *some other* bracket, e.g. \" -- [sqlite] \"\n // then switch MySQL off, and do NOT keep that line\n if (anyDialectRegex.test(trimmed) && !startSQLRegex.test(trimmed)) {\n isInMySQLBlock = false;\n // Skip to next line\n continue;\n }\n \n // If we get here and see a line without a [dialect] marker,\n // and we were previously turned off because of non-mysql dialect,\n // then check if it's common SQL (like CREATE INDEX).\n // Turn MySQL back on for this line\n if (!isInMySQLBlock && line.toLowerCase().includes('create index')) {\n isInMySQLBlock = true;\n }\n \n // If we're in MySQL mode, keep the line\n if (isInMySQLBlock) {\n result += line + '\\n';\n }\n }\n \n return result;\n}\n\nexport function SqliteDialectParser(sql: string): string {\n const lines = sql.split('\\n');\n let result = '';\n let isInSqliteBlock = true;\n\n // Regex to detect a line that starts Sqlite code block:\n const startSqliteRegex = /^\\s*--\\s*\\[\\s*sqlite\\s*\\]\\s*$/i;\n const anyDialectRegex = /^\\s*--\\s*\\[\\s*\\w+\\s*\\]\\s*$/i;\n\n for (const line of lines) {\n const trimmed = line.trim();\n\n if (startSqliteRegex.test(trimmed)) {\n // If we see a \"-- [sqlite]\" line, start capturing\n isInSqliteBlock = true;\n result += line + '\\n';\n continue;\n } else if (anyDialectRegex.test(trimmed) && !startSqliteRegex.test(trimmed)) {\n // If we see a *different* bracket line, turn off capturing\n isInSqliteBlock = false;\n continue;\n }\n \n // If we get here and see a line without a [dialect] marker,\n // and we were previously turned off because of non-sqlite dialect,\n // then check if it's common SQL (like CREATE INDEX).\n // Turn SQLite back on for this line\n if (!isInSqliteBlock && line.toLowerCase().includes('create index')) {\n isInSqliteBlock = true;\n }\n \n // If we are in the Sqlite block, capture the line\n if (isInSqliteBlock) {\n result += line + '\\n';\n }\n }\n \n return result;\n}","\nimport * as sqlite from 'sqlite';\nimport { Statement } from 'sqlite3';\nimport mysql from 'mysql2/promise';\n\n\n\ntype QueryResult = {\n stmt: Statement;\n lastID: number;\n changes: number;\n}\n\nexport interface ISQLRunner {\n query(sql: string, params?: any[]): Promise<any>;\n execute(sql: string, params?: any[]): Promise<any>;\n end(): Promise<void>;\n}\n\n/**\n * Base class that implements the common contract and helper utilities that are\n * shared between the different dialect runners. The concrete subclasses only\n * need to implement the three primitive methods `_query`, `_execute` and\n * `_end` that perform the actual driver-specific interaction. Everything else\n * – such as ensuring a uniform return shape – is handled here once.\n */\nexport abstract class BaseSQLRunner implements ISQLRunner {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abstract _query(sql: string, params?: any[]): Promise<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abstract _execute(sql: string, params?: any[]): Promise<any>;\n abstract _end(): Promise<void>;\n\n /**\n * Ensures that both MySQL and SQLite return the same tuple shape that callers\n * expect: `[rowsOrResult, extra]`. For SQLite there is no `extra` metadata\n * comparable to MySQL's `FieldPacket[]`, so we just use `undefined`.\n */\n async query(sql: string, params: any[] = []): Promise<any> {\n const result = await this._query(sql, params);\n\n // MySQL already returns the desired tuple. For SQLite we need to wrap.\n return Array.isArray(result) && result.length === 2 ? result : [result, undefined];\n }\n\n async execute(sql: string, params: any[] = []): Promise<any> {\n const result = await this._execute(sql, params);\n return Array.isArray(result) && result.length === 2 ? result : [result, undefined];\n }\n\n async end(): Promise<void> {\n await this._end();\n }\n}\n\nfunction isPromiseLike<T>(value: unknown): value is Promise<T> {\n return !!value && typeof (value as Promise<T>).then === \"function\";\n}\n\nexport class SQLRunner extends BaseSQLRunner {\n constructor(private connection: mysql.Connection) {\n super();\n }\n\n // The MySQL driver already returns the correct tuple shapes.\n async _query(sql: string, params: any[] = []) {\n return await this.connection.query(sql, params);\n }\n\n async _execute(sql: string, params: any[] = []) {\n return await this.connection.execute(sql, params);\n }\n\n async _end() {\n if (this.connection) {\n await this.connection.end();\n }\n }\n}\n\nexport class SQLiteRunner extends BaseSQLRunner {\n constructor(private connection: sqlite.Database | any) {\n super();\n }\n\n private async prepareStatement(sql: string) {\n if (typeof this.connection.prepare !== \"function\") {\n throw new Error(\"SQLite connection does not support prepare()\");\n }\n const stmt = this.connection.prepare(sql);\n return isPromiseLike(stmt) ? await stmt : stmt;\n }\n\n private async finalizeStatement(stmt: any) {\n if (!stmt || typeof stmt.finalize !== \"function\") return;\n const result = stmt.finalize();\n if (isPromiseLike(result)) {\n await result;\n }\n }\n\n private async statementAll(stmt: any, params: any[]) {\n if (typeof stmt.all !== \"function\") {\n throw new Error(\"SQLite statement does not support all()\");\n }\n // sqlite3 callback-style API\n if (stmt.all.length >= 2) {\n return await new Promise((resolve, reject) => {\n const callback = (err: Error | null, rows: any[]) => {\n if (err) return reject(err);\n resolve(rows || []);\n };\n try {\n if (params.length > 0) {\n stmt.all(params, callback);\n } else {\n stmt.all(callback);\n }\n } catch (error) {\n reject(error);\n }\n });\n }\n const result = stmt.all(...params);\n return isPromiseLike(result) ? await result : result;\n }\n\n private async statementRun(stmt: any, params: any[]) {\n if (typeof stmt.run !== \"function\") {\n throw new Error(\"SQLite statement does not support run()\");\n }\n if (stmt.run.length >= 2) {\n return await new Promise((resolve, reject) => {\n const callback = function (this: any, err: Error | null) {\n if (err) return reject(err);\n resolve({ changes: this?.changes ?? 0, lastID: this?.lastID });\n };\n try {\n if (params.length > 0) {\n stmt.run(params, callback);\n } else {\n stmt.run(callback);\n }\n } catch (error) {\n reject(error);\n }\n });\n }\n const result = stmt.run(...params);\n return isPromiseLike(result) ? await result : result;\n }\n\n async _query(sql: string, params: any[] = []) {\n const stmt = await this.prepareStatement(sql);\n try {\n const rows = await this.statementAll(stmt, params);\n return rows;\n } finally {\n await this.finalizeStatement(stmt);\n }\n }\n\n async _execute(sql: string, params: any[] = []) {\n // Handle empty or comment-only SQL gracefully\n if (this.isEmptySQL(sql)) {\n return { changes: 0, lastID: 0 }; // No-op result\n }\n\n if (this.isMultiStatement(sql)) {\n return await this.executeMultiStatement(sql, params)\n .catch((err) => {\n console.error((\n \"Error executing multi-statement SQL:\\n\"+\n `${sql}\\n`\n ), err);\n throw err;\n });\n }\n\n const stmt = await this.prepareStatement(sql);\n try {\n const info = await this.statementRun(stmt, params);\n return info;\n } finally {\n await this.finalizeStatement(stmt);\n }\n }\n\n /**\n * Checks if SQL is empty or contains only comments/whitespace.\n * Returns true if there is no actual SQL to execute.\n */\n private isEmptySQL(sql: string): boolean {\n // Remove all comments and whitespace\n const withoutComments = sql\n .replace(/--.*$/gm, '') // Remove single-line comments\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '') // Remove multi-line comments\n .trim();\n return withoutComments.length === 0;\n }\n\n private isMultiStatement(sql: string): boolean {\n // SQLite does not support multiple statements in a single query.\n return sql.split(';').length > 1;\n }\n\n private async executeMultiStatement(sql: string, params: any[] = []) {\n const statements = sql.split(';')\n .map((s) => s.split('\\n')\n .map(\n s=>this.removeComments(s))\n .filter(s=>s.trim()!='')\n .join('\\n')\n )\n .filter((s) => s.trim() !== '');\n \n const infos = await statements.reduce(async (prev,statement) => {\n const infos = await prev;\n const stmt = await this.prepareStatement(`${statement};`);\n try {\n const info = await this.statementRun(stmt, params);\n infos.push(info);\n return infos;\n } finally {\n await this.finalizeStatement(stmt);\n }\n },Promise.resolve([null] as any[]))\n .then((infos:QueryResult[]) => {\n return infos.filter((info) => info !== null);\n })\n return infos.reduce((acc,latest)=>{\n if(latest){\n acc.stmt = latest.stmt;\n acc.lastID = latest.lastID;\n acc.changes += latest.changes;\n }\n return acc\n })\n }\n\n private removeComments(sql: string): string {\n // Remove single-line comments\n sql = sql.replace(/--.*$/gm, '');\n return sql;\n }\n\n\n async _end() {\n if (this.connection) {\n await this.connection.close();\n }\n }\n}\n","import fs from 'fs';\nimport path from 'path';\nimport { pathToFileURL } from 'url';\nimport Ajv from 'ajv';\nimport addFormats from 'ajv-formats';\nimport { tsImport } from 'tsx/esm/api';\n\nimport type { IMigrationRunner, MigrationHistory } from './MigrationRunner';\nimport { MigrationRunnerFactory, FileMigrationConfigReader, loadMigrationConfig } from './MigrationRunner';\nimport type { MigrationConfig } from './MigrationConfig';\n\nexport type SeedTransactionalMode = 'runner' | 'seed' | 'none';\n\nexport type SeedOptions = {\n migrationsDir?: string;\n dataDir?: string;\n validate?: boolean;\n transactional?: SeedTransactionalMode;\n aliasMap?: Record<string, string>;\n preloadedData?: Record<string, unknown>;\n log?: (msg: string) => void;\n names?: string[];\n};\n\nexport type ResolvedSeed = {\n kind: 'sql' | 'ts' | 'js';\n name: string;\n alias: string;\n upPath: string;\n downPath?: string;\n dataPath: string | null;\n schemaPath: string | null;\n};\n\nfunction resolveAlias(name: string, aliasMap?: Record<string, string>): string {\n if (!aliasMap) return name;\n return aliasMap[name] ?? name;\n}\n\nfunction walkForFile(rootDir: string, fileName: string): string | null {\n if (!fs.existsSync(rootDir)) return null;\n const entries = fs.readdirSync(rootDir, { withFileTypes: true });\n for (const entry of entries) {\n const full = path.join(rootDir, entry.name);\n if (entry.isDirectory()) {\n const found = walkForFile(full, fileName);\n if (found) return found;\n } else if (entry.isFile() && entry.name === fileName) {\n return full;\n }\n }\n return null;\n}\n\nfunction resolveMigrationsDir(migrationConfig: MigrationConfig, options: SeedOptions): string {\n const fromOptions = options.migrationsDir;\n const fromConfig = migrationConfig.seeds?.migrationsDir;\n\n const dir = fromOptions ?? fromConfig;\n if (!dir) {\n throw new Error('Seed migrationsDir not configured. Set seeds.migrationsDir in proper.json or pass it explicitly.');\n }\n return dir;\n}\n\nfunction mergeSeedConfig(\n migrationConfig: MigrationConfig,\n options: SeedOptions,\n): { names: string[]; finalOptions: SeedOptions & { migrationsDir: string; validate: boolean; transactional: SeedTransactionalMode } } {\n const names = options.names && options.names.length\n ? options.names\n : migrationConfig.seeds?.list && migrationConfig.seeds.list.length\n ? migrationConfig.seeds.list\n : [];\n\n if (!names.length) {\n throw new Error('No seed names provided and no seeds.list defined in proper config');\n }\n\n const migrationsDir = resolveMigrationsDir(migrationConfig, options);\n const dataDir = options.dataDir ?? migrationConfig.seeds?.dataDir;\n const validate = options.validate !== undefined ? options.validate : true;\n const transactional = options.transactional ?? 'none';\n\n const finalOptions: SeedOptions & { migrationsDir: string; validate: boolean; transactional: SeedTransactionalMode } = {\n ...options,\n migrationsDir,\n dataDir,\n validate,\n transactional,\n };\n\n return { names, finalOptions };\n}\n\n// export function loadMigrationConfig(configFile: string): MigrationConfig {\n// const reader = new FileMigrationConfigReader(configFile);\n// return reader.loadFile();\n// }\n\nfunction resolveSqlPair(name: string, migrationsDir: string): { upPath: string; downPath: string } | null {\n const up = walkForFile(migrationsDir, `${name}.up.sql`);\n const down = walkForFile(migrationsDir, `${name}.down.sql`);\n if (up && down) {\n return { upPath: up, downPath: down };\n }\n return null;\n}\n\nfunction resolveModule(name: string, migrationsDir: string): { kind: 'ts' | 'js'; modulePath: string } | null {\n const ts = walkForFile(migrationsDir, `${name}.ts`);\n if (ts) return { kind: 'ts', modulePath: ts };\n const js = walkForFile(migrationsDir, `${name}.js`);\n if (js) return { kind: 'js', modulePath: js };\n return null;\n}\n\nexport async function resolveSeed(\n name: string,\n migrationConfig: MigrationConfig,\n options: SeedOptions,\n): Promise<ResolvedSeed> {\n const migrationsDir = resolveMigrationsDir(migrationConfig, options);\n const alias = resolveAlias(name, options.aliasMap);\n\n const sqlPair = resolveSqlPair(name, migrationsDir);\n if (sqlPair) {\n return {\n kind: 'sql',\n name,\n alias,\n upPath: sqlPair.upPath,\n downPath: sqlPair.downPath,\n dataPath: null,\n schemaPath: null,\n };\n }\n\n const module = resolveModule(name, migrationsDir);\n if (!module) {\n throw new Error(`Seed implementation not found for \"${name}\" under ${migrationsDir}`);\n }\n\n const dataDir = options.dataDir ?? migrationConfig.seeds?.dataDir;\n let dataPath: string | null = null;\n let schemaPath: string | null = null;\n\n if (dataDir) {\n dataPath = walkForFile(dataDir, `${alias}.json`);\n schemaPath = walkForFile(dataDir, `${alias}.schema.json`);\n }\n\n return {\n kind: module.kind,\n name,\n alias,\n upPath: module.modulePath,\n downPath: module.modulePath,\n dataPath,\n schemaPath,\n };\n}\n\nasync function loadJson(filePath: string): Promise<unknown> {\n const content = await fs.promises.readFile(filePath, 'utf8');\n return JSON.parse(content);\n}\n\nfunction createValidator() {\n const ajv = new Ajv({ allErrors: true, strict: false });\n addFormats(ajv);\n return ajv;\n}\n\nasync function validateData(schemaPath: string | null, data: unknown, validate: boolean, log?: (msg: string) => void) {\n if (!validate || !schemaPath) return;\n const content = await fs.promises.readFile(schemaPath, 'utf8');\n const schema = JSON.parse(content);\n const ajv = createValidator();\n const validateFn = ajv.compile(schema);\n const ok = validateFn(data);\n if (!ok) {\n log?.(`Validation failed for seed data (${schemaPath})`);\n throw new Error(`Seed data validation failed: ${ajv.errorsText(validateFn.errors || [])}`);\n }\n}\n\nasync function runSqlSeed(\n runner: IMigrationRunner,\n resolved: ResolvedSeed,\n direction: 'up' | 'down',\n): Promise<void> {\n const sqlPath = direction === 'up' ? resolved.upPath : resolved.downPath!;\n const sql = await fs.promises.readFile(sqlPath, 'utf8');\n await runner.query(sql);\n}\n\nexport type SeedContext = {\n data: unknown;\n log?: (msg: string) => void;\n dialect: string;\n};\n\nasync function loadSeedModule(modulePath: string): Promise<any> {\n const resolved = path.resolve(modulePath);\n\n // For .ts files, use tsx's tsImport which handles TypeScript in both ESM and CJS contexts\n if (resolved.endsWith('.ts')) {\n const fileUrl = pathToFileURL(resolved).href;\n return tsImport(fileUrl, fileUrl);\n }\n\n // For .js files, use standard dynamic import\n return import(resolved);\n}\n\nasync function runModuleSeed(\n runner: IMigrationRunner,\n resolved: ResolvedSeed,\n migrationConfig: MigrationConfig,\n options: SeedOptions & { validate: boolean },\n direction: 'up' | 'down',\n): Promise<void> {\n const { log } = options;\n const module = await loadSeedModule(resolved.upPath);\n const handler = module[direction];\n if (typeof handler !== 'function') {\n throw new Error(`Seed module \"${resolved.name}\" does not export ${direction}()`);\n }\n\n let data: unknown = null;\n if (options.preloadedData && Object.prototype.hasOwnProperty.call(options.preloadedData, resolved.name)) {\n data = options.preloadedData[resolved.name];\n } else if (resolved.dataPath) {\n data = await loadJson(resolved.dataPath);\n }\n\n await validateData(resolved.schemaPath, data, options.validate, log);\n\n const ctx: SeedContext = {\n data,\n log,\n dialect: migrationConfig.database || 'sql',\n };\n\n await handler(runner, ctx);\n}\n\nasync function runSingleSeed(\n runner: IMigrationRunner,\n migrationConfig: MigrationConfig,\n name: string,\n options: SeedOptions & { validate: boolean; transactional: SeedTransactionalMode },\n direction: 'up' | 'down',\n): Promise<void> {\n const resolved = await resolveSeed(name, migrationConfig, options);\n\n if (resolved.kind === 'sql') {\n await runSqlSeed(runner, resolved, direction);\n } else {\n await runModuleSeed(runner, resolved, migrationConfig, options, direction);\n }\n}\n\nasync function withTransactionalMode(\n runner: IMigrationRunner,\n migrationConfig: MigrationConfig,\n names: string[],\n options: SeedOptions & { validate: boolean; transactional: SeedTransactionalMode },\n direction: 'up' | 'down',\n): Promise<void> {\n const mode = options.transactional;\n\n if (mode === 'runner') {\n await runner.query('BEGIN');\n try {\n for (const name of names) {\n await runSingleSeed(runner, migrationConfig, name, options, direction);\n }\n await runner.query('COMMIT');\n } catch (err) {\n try {\n await runner.query('ROLLBACK');\n } catch {\n }\n throw err;\n }\n return;\n }\n\n if (mode === 'seed') {\n for (const name of names) {\n await runner.query('BEGIN');\n try {\n await runSingleSeed(runner, migrationConfig, name, options, direction);\n await runner.query('COMMIT');\n } catch (err) {\n try {\n await runner.query('ROLLBACK');\n } catch {\n }\n throw err;\n }\n }\n return;\n }\n\n for (const name of names) {\n await runSingleSeed(runner, migrationConfig, name, options, direction);\n }\n}\n\nexport async function runSeedsWithRunner(\n runner: IMigrationRunner,\n migrationConfig: MigrationConfig,\n direction: 'up' | 'down',\n options: SeedOptions,\n): Promise<void> {\n const { names, finalOptions } = mergeSeedConfig(migrationConfig, options);\n await withTransactionalMode(runner, migrationConfig, names, finalOptions, direction);\n}\n\nexport type SeedFactoryOptions = SeedOptions & {\n configFile?: string;\n};\n\nexport type SeedFactory = {\n up(names?: string[]): Promise<void>;\n down(names?: string[]): Promise<void>;\n};\n\nexport function createSeedFactory(options: SeedFactoryOptions): SeedFactory {\n const configFile = options.configFile ?? 'proper.json';\n\n return {\n async up(names?: string[]) {\n const runner = await MigrationRunnerFactory.create(configFile);\n const migrationConfig = loadMigrationConfig(configFile);\n try {\n await runSeedsWithRunner(runner, migrationConfig, 'up', {\n ...options,\n names: names && names.length ? names : options.names,\n });\n } finally {\n await runner.close();\n }\n },\n\n async down(names?: string[]) {\n const runner = await MigrationRunnerFactory.create(configFile);\n const migrationConfig = loadMigrationConfig(configFile);\n try {\n await runSeedsWithRunner(runner, migrationConfig, 'down', {\n ...options,\n names: names && names.length ? names : options.names,\n });\n } finally {\n await runner.close();\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAOA,SAAQ;AAGf,OAAO,WAAW;AAClB,YAAY,YAAY;AACxB,YAAY,aAAa;;;ACNzB,OAAO,QAAQ;AACf,OAAO,UAAU;;;ACEV,IAAM,iBAAN,MAAM,wBAAuB,MAAM;AAAA,EACxC,YAAY,SAAiB;AAC3B,UAAM,OA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","path"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noego/proper",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "module": "bin/index.mjs",