sizuku 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -91
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
# Sizuku
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**[Sizuku](https://www.npmjs.com/package/sizuku)** is a tool that generates Valibot validation schemas and ER diagrams from commented [Drizzle](https://orm.drizzle.team/) schemas.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Features
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
- **Clear Relationship Definitions:** Use the `@relation` annotation in your code to explicitly define how tables are linked (e.g., one-to-many, many-to-many). This ensures that both your ER diagrams and documentation accurately reflect your database relationships.
|
|
7
|
+
- 💎 Automatically generates [Zod](https://zod.dev/) schemas from your Drizzle schema
|
|
8
|
+
- 🤖 Automatically generates [Valibot](https://valibot.dev/) schemas from your Drizzle schema
|
|
9
|
+
- 📊 Creates [Mermaid](https://mermaid.js.org/) ER diagrams
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
## Getting Started
|
|
@@ -119,42 +118,6 @@ export const likes = mysqlTable(
|
|
|
119
118
|
)
|
|
120
119
|
```
|
|
121
120
|
|
|
122
|
-
### Mermaid ER
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
npx sizuku-mermaid-er path/to/db/schema.ts -o path/to/output.md
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
output:
|
|
129
|
-
|
|
130
|
-
```mermaid
|
|
131
|
-
erDiagram
|
|
132
|
-
user ||--o{ post : "(id) - (userId)"
|
|
133
|
-
post ||--o{ likes : "(id) - (postId)"
|
|
134
|
-
user ||--o{ likes : "(id) - (userId)"
|
|
135
|
-
user {
|
|
136
|
-
varchar id "(PK) Unique identifier for the user."
|
|
137
|
-
varchar username "Username of the user."
|
|
138
|
-
varchar email "Email address of the user."
|
|
139
|
-
varchar password "Password for the user."
|
|
140
|
-
timestamp createdAt "Timestamp when the user was created."
|
|
141
|
-
timestamp updatedAt "Timestamp when the user was last updated."
|
|
142
|
-
}
|
|
143
|
-
post {
|
|
144
|
-
varchar id "(PK) Unique identifier for the post."
|
|
145
|
-
varchar userId "(FK) ID of the user who created the post."
|
|
146
|
-
varchar content "Content of the post."
|
|
147
|
-
timestamp createdAt "Timestamp when the post was created."
|
|
148
|
-
timestamp updatedAt "Timestamp when the post was last updated."
|
|
149
|
-
}
|
|
150
|
-
likes {
|
|
151
|
-
varchar id "(PK) Unique identifier for the like."
|
|
152
|
-
varchar postId "(FK) ID of the post that is liked."
|
|
153
|
-
varchar userId "(FK) ID of the user who liked the post."
|
|
154
|
-
timestamp createdAt "Timestamp when the like was created."
|
|
155
|
-
}
|
|
156
|
-
```
|
|
157
|
-
|
|
158
121
|
### Zod
|
|
159
122
|
|
|
160
123
|
```bash
|
|
@@ -317,31 +280,44 @@ export const LikesSchema = v.object({
|
|
|
317
280
|
})
|
|
318
281
|
```
|
|
319
282
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
### sizuku-mermaid-er.json
|
|
323
|
-
|
|
324
|
-
| Option | Type | Default | Description |
|
|
325
|
-
|--------|------|---------|-------------|
|
|
326
|
-
| `input` | `string` | `""` | Input file path |
|
|
327
|
-
| `output` | `string` | `""` | Output file path |
|
|
283
|
+
### Mermaid ER
|
|
328
284
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
> ```bash
|
|
333
|
-
> npx sizuku-mermaid-er
|
|
334
|
-
> ```
|
|
285
|
+
```bash
|
|
286
|
+
npx sizuku-mermaid-er path/to/db/schema.ts -o path/to/output.md
|
|
287
|
+
```
|
|
335
288
|
|
|
336
|
-
|
|
289
|
+
output:
|
|
337
290
|
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
291
|
+
```mermaid
|
|
292
|
+
erDiagram
|
|
293
|
+
user ||--o{ post : "(id) - (userId)"
|
|
294
|
+
post ||--o{ likes : "(id) - (postId)"
|
|
295
|
+
user ||--o{ likes : "(id) - (userId)"
|
|
296
|
+
user {
|
|
297
|
+
varchar id "(PK) Unique identifier for the user."
|
|
298
|
+
varchar username "Username of the user."
|
|
299
|
+
varchar email "Email address of the user."
|
|
300
|
+
varchar password "Password for the user."
|
|
301
|
+
timestamp createdAt "Timestamp when the user was created."
|
|
302
|
+
timestamp updatedAt "Timestamp when the user was last updated."
|
|
303
|
+
}
|
|
304
|
+
post {
|
|
305
|
+
varchar id "(PK) Unique identifier for the post."
|
|
306
|
+
varchar userId "(FK) ID of the user who created the post."
|
|
307
|
+
varchar content "Content of the post."
|
|
308
|
+
timestamp createdAt "Timestamp when the post was created."
|
|
309
|
+
timestamp updatedAt "Timestamp when the post was last updated."
|
|
310
|
+
}
|
|
311
|
+
likes {
|
|
312
|
+
varchar id "(PK) Unique identifier for the like."
|
|
313
|
+
varchar postId "(FK) ID of the post that is liked."
|
|
314
|
+
varchar userId "(FK) ID of the user who liked the post."
|
|
315
|
+
timestamp createdAt "Timestamp when the like was created."
|
|
316
|
+
}
|
|
343
317
|
```
|
|
344
318
|
|
|
319
|
+
## Configuration
|
|
320
|
+
|
|
345
321
|
### sizuku-zod.json
|
|
346
322
|
|
|
347
323
|
#### Schema Options
|
|
@@ -399,30 +375,30 @@ export const LikesSchema = v.object({
|
|
|
399
375
|
|
|
400
376
|
#### Schema Options
|
|
401
377
|
|
|
402
|
-
| Option
|
|
403
|
-
|
|
404
|
-
| `name`
|
|
405
|
-
| `export` | `boolean`
|
|
378
|
+
| Option | Type | Default | Description |
|
|
379
|
+
|----------|---------------------------------|----------------|--------------------------------------------|
|
|
380
|
+
| `name` | `"PascalCase"` \| `"camelCase"` | `"PascalCase"` | Naming convention for generated schema variables |
|
|
381
|
+
| `export` | `boolean` | `false` | When true, exports all schema definitions |
|
|
406
382
|
|
|
407
383
|
#### Type Options
|
|
408
384
|
|
|
409
|
-
| Option
|
|
410
|
-
|
|
411
|
-
| `name`
|
|
412
|
-
| `export` | `boolean`
|
|
385
|
+
| Option | Type | Default | Description |
|
|
386
|
+
|----------|---------------------------------|----------------|-----------------------------------------|
|
|
387
|
+
| `name` | `"PascalCase"` \| `"camelCase"` | `"PascalCase"` | Naming convention for generated type definitions |
|
|
388
|
+
| `export` | `boolean` | `false` | When true, exports all type definitions |
|
|
413
389
|
|
|
414
390
|
#### Comment Options
|
|
415
391
|
|
|
416
|
-
| Option | Type
|
|
417
|
-
|
|
418
|
-
| `name` | `boolean`
|
|
392
|
+
| Option | Type | Default | Description |
|
|
393
|
+
|--------|----------------|---------|---------------------------------------------------------------------|
|
|
394
|
+
| `name` | `boolean` | `false` | If enabled, includes the element's original name in TSDoc comments. |
|
|
419
395
|
|
|
420
396
|
#### Input and Output
|
|
421
397
|
|
|
422
|
-
| Option | Type | Default
|
|
423
|
-
|
|
424
|
-
| `input` | `string` | `""`
|
|
425
|
-
| `output` | `string` | `""`
|
|
398
|
+
| Option | Type | Default | Description |
|
|
399
|
+
|--------|------|-------------|-------------|
|
|
400
|
+
| `input` | `string` | `""` | Input file path |
|
|
401
|
+
| `output` | `string` | `""` | Output file path |
|
|
426
402
|
|
|
427
403
|
#### Examples
|
|
428
404
|
|
|
@@ -443,28 +419,39 @@ export const LikesSchema = v.object({
|
|
|
443
419
|
|
|
444
420
|
> **⚠️** When using a configuration file, command line arguments are not required. The configuration file settings take precedence over command line arguments.
|
|
445
421
|
>
|
|
446
|
-
> When you have configured `sizuku-
|
|
422
|
+
> When you have configured `sizuku-valibot.json`, you can simply run:
|
|
447
423
|
> ```bash
|
|
448
424
|
> npx sizuku-valibot
|
|
449
425
|
> ```
|
|
450
426
|
|
|
451
|
-
|
|
427
|
+
### sizuku-mermaid-er.json
|
|
452
428
|
|
|
453
|
-
|
|
429
|
+
| Option | Type | Default | Description |
|
|
430
|
+
|--------|-------------------|------------------|
|
|
431
|
+
| `input` | `string` | `""` | Input file path |
|
|
432
|
+
| `output` | `string` | `""` | Output file path |
|
|
454
433
|
|
|
455
|
-
|
|
456
|
-
Specifically:
|
|
457
|
-
- Query parameter coercion behavior may change
|
|
458
|
-
- Schema generation logic might be updated
|
|
459
|
-
- Output code structure could be modified
|
|
460
|
-
- Example value handling might be altered
|
|
434
|
+
#### Example
|
|
461
435
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
-
|
|
436
|
+
```json
|
|
437
|
+
{
|
|
438
|
+
"input": "db/schema.ts",
|
|
439
|
+
"output": "mermaid-er/ER.md"
|
|
440
|
+
}
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
> **⚠️** When using a configuration file, command line arguments are not required. The configuration file settings take precedence over command line arguments.
|
|
444
|
+
>
|
|
445
|
+
> When you have configured `sizuku-mermaid-er.json`, you can simply run:
|
|
446
|
+
> ```bash
|
|
447
|
+
> npx sizuku-mermaid-er
|
|
448
|
+
> ```
|
|
449
|
+
|
|
450
|
+
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:
|
|
451
|
+
|
|
452
|
+
### ⚠️ WARNING: Potential Breaking Changes Without Notice
|
|
466
453
|
|
|
467
|
-
|
|
454
|
+
**This package is in active development and may introduce breaking changes without prior notice.
|
|
468
455
|
|
|
469
456
|
## License
|
|
470
457
|
|
package/package.json
CHANGED