Registry / devops / atp-gen-mysql-entities-cli

atp-gen-mysql-entities-cli

JSON →
library0.4.0jsnpmunverified

CLI tool to auto-generate TypeScript entity functions from a MySQL database schema. Version 0.4.0, updates are occasional. Produces typed CRUD functions using @sinclair/typebox for schema validation and ajv/ajv-formats for runtime validation. Key differentiator: generates both types and validation logic from live database tables in one command, with support for MySQL 5.6 and 5.7. Relies on mariadb driver. Suitable for Node.js/TypeScript projects already using TypeBox and AJV.

npm install atp-gen-mysql-entities-cli
INSTALL
IMPORT
SIG · ATP-GEN-MYSQL-ENTI
A
atp-gen-mysql-entities-cli
devopsjavascriptv0.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

main function (CLI)
npx gen-mysql-entities -d mydb
import { genMysqlEntities } from 'atp-gen-mysql-entities-cli'
This package is a CLI tool; it is not meant to be imported. Use `npx` or install globally and run `gen-mysql-entities`.
Generated entities
import { UserEntity } from './entities/user'
import { UserEntity } from 'atp-gen-mysql-entities-cli'
Generated files are output to the specified directory (default './entities'). They are not part of the npm package.

Shows how to install and run the CLI to generate entity files into the default './entities' directory.

# Install globally npm install -g atp-gen-mysql-entities-cli # Generate entities for database 'mydb' with default host/user # (if running locally, adjust host if needed) gen-mysql-entities -d mydb -u root -x mypassword # Or use npx without global install npx atp-gen-mysql-entities-cli -d mydb -u root -x mypassword -o ./src/entities
Debug
Known issues
breakingVersion below 0.2.4 supports MySQL 5.6; version 0.3.0+ requires MySQL 5.7.
fix
If using MySQL 5.6, stick with versions <0.2.4. For 5.7+, use >=0.3.0.
affects: <0.3.0
deprecatedThe CLI options use short flags without double-dash. Standardization may change in future.
fix
Use short flags as documented. Check for future releases with long options.
affects: <=0.4.0
gotchaDatabase password is passed via command line argument '-x'. This can leak in process listings and shell history.
fix
Use environment variable MYSQL_PWD or a .env file instead of plaintext password argument.
affects: >=0.0.0
gotchaThe generated entities depend on @sinclair/typebox and ajv being installed separately. They are not bundled in the generated output.
fix
Add @sinclair/typebox, ajv, and ajv-formats as dependencies in your project.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Can't find any databases for user root or access denied for user 'root'@'localhost'
The CLI uses the provided credentials but the user lacks permissions or the host/port are incorrect.
fix
Verify MySQL host (--host), port (--port), username, and password. Grant SELECT on information_schema.TABLES and COLUMNS.
Error: getaddrinfo ENOTFOUND hostname
The provided hostname cannot be resolved.
fix
Use the correct IP or hostname. If local, use 'localhost' or '127.0.0.1'.
Module not found: Can't resolve '@sinclair/typebox' in generated entity file
The generated entities import @sinclair/typebox, but it is not installed in the user's project.
fix
Install the peer dependency: npm install @sinclair/typebox
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies
@sinclair/typeboxrequiredUsed to generate TypeScript schemas representing table row types.
ajvrequiredRequired for runtime validation of data against generated schemas.
ajv-formatsrequiredExtends AJV with format validators (e.g., date-time).
mariadbrequiredNode.js driver to connect to MySQL/MariaDB database for schema introspection.
Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
2
Resources
atp-gen-mysql-entities-cli — npm install atp-gen-mysql-entities-cli · libregistry