{"id":43369,"library":"mysql-typebox","title":"mysql-typebox","description":"Generate Typebox schemas and TypeScript types from MySQL table definitions. Version 2.0.2 is stable, with an npm-based CLI tool. It maps MySQL column types to Typebox schema primitives, supports enums, nullables, and configurable naming conventions. Outputs TypeScript files with both schema objects and Static type exports, ready to use with @sinclair/typebox. Differentiators: automatic generation from live database schema, zero-config defaults, and optional camelCase and nullish transformations.","status":"active","version":"2.0.2","language":"javascript","source_language":"en","source_url":"git@github.com:erwinstone/mysql-typebox","tags":["javascript"],"install":[{"cmd":"npm install mysql-typebox","lang":"bash","label":"npm"},{"cmd":"yarn add mysql-typebox","lang":"bash","label":"yarn"},{"cmd":"pnpm add mysql-typebox","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Generated schemas depend on Typebox for runtime validation and type inference.","package":"@sinclair/typebox","optional":false}],"imports":[{"note":"Generated files use named exports for the schema object. Default export is not provided.","wrong":"import user from './path/to/generated/user'","symbol":"user (schema)","correct":"import { user } from './path/to/generated/user'"},{"note":"Type-only import avoids bundling runtime code. Use type import for static types.","wrong":"import { userType } from './path/to/generated/user'","symbol":"userType (type)","correct":"import type { userType } from './path/to/generated/user'"},{"note":"Static is a type-only export. Use type import to avoid runtime inclusion.","wrong":"import { Static } from '@sinclair/typebox'","symbol":"Static","correct":"import type { Static } from '@sinclair/typebox'"}],"quickstart":{"code":"// Install globally or as dev dependency\nnpm install mysql-typebox --save-dev\n\n// Create mysql-typebox.json\n{\n  \"host\": \"127.0.0.1\",\n  \"port\": 3306,\n  \"user\": \"root\",\n  \"password\": \"secret\",\n  \"database\": \"myapp\"\n}\n\n// Run CLI\nnpx mysql-typebox\n\n// Example output: user.ts\nimport { Type } from '@sinclair/typebox'\nimport type { Static } from '@sinclair/typebox'\n\nexport const user = Type.Object({\n  id: Type.Number(),\n  name: Type.String(),\n  username: Type.String(),\n  password: Type.String(),\n  profile_picture: Type.Union([Type.String(), Type.Null()]),\n  role: Type.Unsafe<'admin' | 'user'>({ type: 'string', enum: ['admin', 'user'] }),\n})\n\nexport type userType = Static<typeof user>","lang":"typescript","description":"Shows installation, config, CLI command, and sample output for generating Typebox schemas from MySQL database."},"warnings":[{"fix":"Run 'npm install @sinclair/typebox' as a regular dependency.","message":"Generated file imports from @sinclair/typebox at runtime; ensure it is installed as a dependency, not just devDependency.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Create mysql-typebox.json with required fields: host, port, user, password, database.","message":"CLI uses a config file named 'mysql-typebox.json' in the current directory. If missing, an error occurs.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Manually update the generated Unsafe schema if the database enum values change.","message":"Generated schemas for ENUM columns use Type.Unsafe with a hardcoded enum array; this does not validate against the database values at runtime.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update your project to use '@sinclair/typebox' and reinstall dependencies.","message":"Version 2.0.0 switched from 'typebox' (scoped) to '@sinclair/typebox' as the peer dependency.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2.0.2':15 'automat':58 'base':22 'camelcas':70 'cli':23 'column':28 'config':66 'configur':38 'convent':40 'databas':62 'default':67 'definit':13 'differenti':57 'enum':35 'export':51 'file':43 'generat':4,59 'javascript':74 'live':61 'map':26 'mysql':2,11,27 'mysql-typebox':1 'name':39 'npm':21 'npm-base':20 'nullabl':36 'nullish':72 'object':47 'option':69 'output':41 'primit':33 'readi':52 'schema':6,32,46,63 'sinclair/typebox':56 'stabl':17 'static':49 'support':34 'tabl':12 'tool':24 'transform':73 'type':9,29,50 'typebox':3,5,31 'typescript':8,42 'use':54 'version':14 'zero':65 'zero-config':64","created_at":"2026-06-05T16:59:28.256919+00:00","updated_at":"2026-06-05T16:59:28.256919+00:00","problems":[{"fix":"Start MySQL service or update mysql-typebox.json with correct connection details.","cause":"MySQL server not running or inaccessible at the configured host/port.","error":"Error: connect ECONNREFUSED 127.0.0.1:3306"},{"fix":"Run 'npm install @sinclair/typebox' in your project.","cause":"@sinclair/typebox is not installed as a runtime dependency.","error":"Error: Cannot find module '@sinclair/typebox'"},{"fix":"Create mysql-typebox.json in the project root with database credentials.","cause":"Config file missing in current working directory.","error":"Error: ENOENT: no such file or directory, open 'mysql-typebox.json'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"git@github.com:erwinstone/mysql-typebox","github":"git@github.com:erwinstone/mysql-typebox","docs":null,"changelog":null,"pypi":null,"npm":"mysql-typebox","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}