Gathering detailed insights and metrics for sizuku
Gathering detailed insights and metrics for sizuku
Gathering detailed insights and metrics for sizuku
Gathering detailed insights and metrics for sizuku
npm install sizuku
Typescript
Module System
Node Version
NPM Version
TypeScript (93.42%)
JavaScript (6.58%)
Total Downloads
562
Last Day
2
Last Week
18
Last Month
84
Last Year
562
MIT License
77 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Apr 20, 2025
Latest Version
0.0.7
Package Id
sizuku@0.0.7
Unpacked Size
61.11 kB
Size
12.78 kB
File Count
70
NPM Version
10.9.2
Node Version
22.14.0
Published on
Apr 06, 2025
Cumulative downloads
Total Downloads
Last Day
0%
2
Compared to previous day
Last Week
100%
18
Compared to previous week
Last Month
-82.4%
84
Compared to previous month
Last Year
0%
562
Compared to previous year
1
6
Sizuku is a tool that generates validation schemas for Zod and Valibot, as well as ER diagrams, from Drizzle schemas annotated with comments.
1npm install -D sizuku
input:
1import { sql } from 'drizzle-orm' 2import { mysqlTable, varchar, timestamp, unique } from 'drizzle-orm/mysql-core' 3 4export const user = mysqlTable('user', { 5 /// Unique identifier for the user. 6 /// @z.string().uuid() 7 /// @v.pipe(v.string(), v.uuid()) 8 id: varchar('id', { length: 36 }).primaryKey(), 9 /// Username of the user. 10 /// @z.string() 11 /// @v.string() 12 username: varchar('username', { length: 255 }).notNull(), 13 /// Email address of the user. 14 /// @z.string().email() 15 /// @v.pipe(v.string(), v.email()) 16 email: varchar('email', { length: 255 }).notNull().unique(), 17 /// Password for the user. 18 /// @z.string().min(8).max(100) 19 /// @v.pipe(v.string(), v.minLength(8), v.maxLength(100)) 20 password: varchar('password', { length: 100 }).notNull(), 21 /// Timestamp when the user was created. 22 /// @z.date() 23 /// @v.date() 24 createdAt: timestamp('created_at', { mode: 'string' }).notNull().default(sql`CURRENT_TIMESTAMP`), 25 /// Timestamp when the user was last updated. 26 /// @z.date() 27 /// @v.date() 28 updatedAt: timestamp('updated_at', { mode: 'string' }) 29 .notNull() 30 .default(sql`CURRENT_TIMESTAMP`) 31 .$onUpdate(() => sql`CURRENT_TIMESTAMP`), 32}) 33 34/// @relation user.id post.userId one-to-many 35export const post = mysqlTable('post', { 36 /// Unique identifier for the post. 37 /// @z.string().uuid() 38 /// @v.pipe(v.string(), v.uuid()) 39 id: varchar('id', { length: 36 }).primaryKey(), 40 /// ID of the user who created the post. 41 /// @z.string().uuid() 42 /// @v.pipe(v.string(), v.uuid()) 43 userId: varchar('user_id', { length: 36 }) 44 .notNull() 45 .references(() => user.id, { onDelete: 'cascade' }), 46 /// Content of the post. 47 /// @z.string() 48 /// @v.string() 49 content: varchar('content', { length: 500 }).notNull(), 50 /// Timestamp when the post was created. 51 /// @z.date() 52 /// @v.date() 53 createdAt: timestamp('created_at', { mode: 'string' }).notNull().default(sql`CURRENT_TIMESTAMP`), 54 /// Timestamp when the post was last updated. 55 /// @z.date() 56 /// @v.date() 57 updatedAt: timestamp('updated_at', { mode: 'string' }) 58 .notNull() 59 .default(sql`CURRENT_TIMESTAMP`) 60 .$onUpdate(() => sql`CURRENT_TIMESTAMP`), 61}) 62 63/// @relation post.id likes.postId one-to-many 64/// @relation user.id likes.userId one-to-many 65export const likes = mysqlTable( 66 'likes', 67 { 68 /// Unique identifier for the like. 69 /// @z.string().uuid() 70 /// @v.pipe(v.string(), v.uuid()) 71 id: varchar('id', { length: 36 }).primaryKey(), 72 /// ID of the post that is liked. 73 /// @z.string().uuid() 74 /// @v.pipe(v.string(), v.uuid()) 75 postId: varchar('post_id', { length: 36 }) 76 .notNull() 77 .references(() => post.id, { onDelete: 'cascade' }), 78 /// ID of the user who liked the post. 79 /// @z.string().uuid() 80 /// @v.pipe(v.string(), v.uuid()) 81 userId: varchar('user_id', { length: 36 }) 82 .notNull() 83 .references(() => user.id, { onDelete: 'cascade' }), 84 /// Timestamp when the like was created. 85 /// @z.date() 86 /// @v.date() 87 createdAt: timestamp('created_at', { mode: 'string' }) 88 .notNull() 89 .default(sql`CURRENT_TIMESTAMP`), 90 }, 91 (t) => [unique().on(t.userId, t.postId)], 92)
1npx sizuku-zod path/to/db/schema.ts -o path/to/output.ts
output:
1import { z } from 'zod' 2 3export const UserSchema = z.object({ 4 /** 5 * Unique identifier for the user. 6 */ 7 id: z.string().uuid(), 8 /** 9 * Username of the user. 10 */ 11 username: z.string(), 12 /** 13 * Email address of the user. 14 */ 15 email: z.string().email(), 16 /** 17 * Password for the user. 18 */ 19 password: z.string().min(8).max(100), 20 /** 21 * Timestamp when the user was created. 22 */ 23 createdAt: z.date(), 24 /** 25 * Timestamp when the user was last updated. 26 */ 27 updatedAt: z.date(), 28}) 29 30export const PostSchema = z.object({ 31 /** 32 * Unique identifier for the post. 33 */ 34 id: z.string().uuid(), 35 /** 36 * ID of the user who created the post. 37 */ 38 userId: z.string().uuid(), 39 /** 40 * Content of the post. 41 */ 42 content: z.string(), 43 /** 44 * Timestamp when the post was created. 45 */ 46 createdAt: z.date(), 47 /** 48 * Timestamp when the post was last updated. 49 */ 50 updatedAt: z.date(), 51}) 52 53export const LikesSchema = z.object({ 54 /** 55 * Unique identifier for the like. 56 */ 57 id: z.string().uuid(), 58 /** 59 * ID of the post that is liked. 60 */ 61 postId: z.string().uuid(), 62 /** 63 * ID of the user who liked the post. 64 */ 65 userId: z.string().uuid(), 66 /** 67 * Timestamp when the like was created. 68 */ 69 createdAt: z.date(), 70})
1npx sizuku-valibot path/to/db/schema.ts -o path/to/output.ts
output:
1import * as v from 'valibot' 2 3export const UserSchema = v.object({ 4 /** 5 * Unique identifier for the user. 6 */ 7 id: v.pipe(v.string(), v.uuid()), 8 /** 9 * Username of the user. 10 */ 11 username: v.string(), 12 /** 13 * Email address of the user. 14 */ 15 email: v.pipe(v.string(), v.email()), 16 /** 17 * Password for the user. 18 */ 19 password: v.pipe(v.string(), v.minLength(8), v.maxLength(100)), 20 /** 21 * Timestamp when the user was created. 22 */ 23 createdAt: v.date(), 24 /** 25 * Timestamp when the user was last updated. 26 */ 27 updatedAt: v.date(), 28}) 29 30export const PostSchema = v.object({ 31 /** 32 * Unique identifier for the post. 33 */ 34 id: v.pipe(v.string(), v.uuid()), 35 /** 36 * ID of the user who created the post. 37 */ 38 userId: v.pipe(v.string(), v.uuid()), 39 /** 40 * Content of the post. 41 */ 42 content: v.string(), 43 /** 44 * Timestamp when the post was created. 45 */ 46 createdAt: v.date(), 47 /** 48 * Timestamp when the post was last updated. 49 */ 50 updatedAt: v.date(), 51}) 52 53export const LikesSchema = v.object({ 54 /** 55 * Unique identifier for the like. 56 */ 57 id: v.pipe(v.string(), v.uuid()), 58 /** 59 * ID of the post that is liked. 60 */ 61 postId: v.pipe(v.string(), v.uuid()), 62 /** 63 * ID of the user who liked the post. 64 */ 65 userId: v.pipe(v.string(), v.uuid()), 66 /** 67 * Timestamp when the like was created. 68 */ 69 createdAt: v.date(), 70})
1npx sizuku-mermaid-er path/to/db/schema.ts -o path/to/output.md
output:
1erDiagram 2 user ||--}| post : "(id) - (userId)" 3 post ||--}| likes : "(id) - (postId)" 4 user ||--}| likes : "(id) - (userId)" 5 user { 6 varchar id "(PK) Unique identifier for the user." 7 varchar username "Username of the user." 8 varchar email "Email address of the user." 9 varchar password "Password for the user." 10 timestamp createdAt "Timestamp when the user was created." 11 timestamp updatedAt "Timestamp when the user was last updated." 12 } 13 post { 14 varchar id "(PK) Unique identifier for the post." 15 varchar userId "(FK) ID of the user who created the post." 16 varchar content "Content of the post." 17 timestamp createdAt "Timestamp when the post was created." 18 timestamp updatedAt "Timestamp when the post was last updated." 19 } 20 likes { 21 varchar id "(PK) Unique identifier for the like." 22 varchar postId "(FK) ID of the post that is liked." 23 varchar userId "(FK) ID of the user who liked the post." 24 timestamp createdAt "Timestamp when the like was created." 25 }
Option | Type | Default | Description |
---|---|---|---|
name | "PascalCase" | "camelCase" | "PascalCase" | Naming convention for generated schema variables |
export | boolean | false | When true, exports all schema definitions |
Option | Type | Default | Description |
---|---|---|---|
name | "PascalCase" | "camelCase" | "PascalCase" | Naming convention for generated type definitions |
export | boolean | false | When true, exports all type definitions |
Option | Type | Default | Description |
---|---|---|---|
name | boolean | false | If enabled, includes the element's original name in TSDoc comments. |
Option | Type | Default | Description |
---|---|---|---|
input | string | "" | Input file path |
output | string | "" | Output file path |
1{ 2 "schema": { 3 "name": "PascalCase" 4 }, 5 "type": { 6 "name": "PascalCase", 7 "export": false 8 }, 9 "comment": true, 10 "input": "db/schema.ts", 11 "output": "zod/index.ts" 12}
⚠️ When using a configuration file, command line arguments are not required. The configuration file settings take precedence over command line arguments.
When you have configured
sizuku-zod.json
, you can simply run:1npx sizuku-zod
Option | Type | Default | Description |
---|---|---|---|
name | "PascalCase" | "camelCase" | "PascalCase" | Naming convention for generated schema variables |
export | boolean | false | When true, exports all schema definitions |
Option | Type | Default | Description |
---|---|---|---|
name | "PascalCase" | "camelCase" | "PascalCase" | Naming convention for generated type definitions |
export | boolean | false | When true, exports all type definitions |
Option | Type | Default | Description |
---|---|---|---|
name | boolean | false | If enabled, includes the element's original name in TSDoc comments. |
Option | Type | Default | Description |
---|---|---|---|
input | string | "" | Input file path |
output | string | "" | Output file path |
1{ 2 "schema": { 3 "name": "PascalCase" 4 }, 5 "type": { 6 "name": "PascalCase", 7 "export": false 8 }, 9 "comment": true, 10 "input": "db/schema.ts", 11 "output": "valibot/index.ts" 12}
⚠️ When using a configuration file, command line arguments are not required. The configuration file settings take precedence over command line arguments.
When you have configured
sizuku-valibot.json
, you can simply run:1npx sizuku-valibot
Option | Type | Default | Description |
---|---|---|---|
input | string | "" | Input file path |
output | string | "" | Output file path |
1{ 2 "input": "db/schema.ts", 3 "output": "mermaid-er/ER.md" 4}
⚠️ When using a configuration file, command line arguments are not required. The configuration file settings take precedence over command line arguments.
When you have configured
sizuku-mermaid-er.json
, you can simply run:1npx sizuku-mermaid-er
This project is in early development and being maintained by a developer with about 2 years of experience. While I'm doing my best to create a useful tool:
**This package is in active development and may introduce breaking changes without prior notice.
Distributed under the MIT License. See LICENSE for more information.
No vulnerabilities found.
No security vulnerabilities found.