schema-to-library 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 - present, Schema to Library Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # Schema to Library
2
+
3
+ ```bash
4
+ npm install -D schema-to-library
5
+ ```
6
+
7
+ ## What is schema-to-library?
8
+
9
+ **schema-to-library** is a CLI tool that converts JSON Schema into code for validation libraries like Zod,
10
+ It helps you automatically generate type-safe validation schemas and TypeScript types from your existing schema definitions.
11
+
12
+ ## Upcoming Support
13
+
14
+ Support for additional libraries is planned:
15
+
16
+ - **Valibot**: Coming soon
17
+
18
+ ## Usage
19
+
20
+
21
+
22
+ ### CLI Usage
23
+
24
+ ```bash
25
+ npx schema-to-zod path/to/input.{json,yaml} -o path/to/output.ts
26
+ ```
27
+
28
+ ### Example
29
+
30
+ input:
31
+
32
+ ```json
33
+ {
34
+ "type": "object",
35
+ "properties": {
36
+ "first_name": { "type": "string" },
37
+ "last_name": { "type": "string" },
38
+ "birthday": { "type": "string", "format": "date" },
39
+ "address": {
40
+ "type": "object",
41
+ "properties": {
42
+ "street_address": { "type": "string" },
43
+ "city": { "type": "string" },
44
+ "state": { "type": "string" },
45
+ "country": { "type": "string" }
46
+ }
47
+ }
48
+ }
49
+ }
50
+ ```
51
+
52
+ output:
53
+
54
+ ```ts
55
+ import * as z from 'zod'
56
+
57
+ export const Schema = z
58
+ .object({
59
+ first_name: z.string(),
60
+ last_name: z.string(),
61
+ birthday: z.iso.date(),
62
+ address: z
63
+ .object({
64
+ street_address: z.string(),
65
+ city: z.string(),
66
+ state: z.string(),
67
+ country: z.string(),
68
+ })
69
+ .partial(),
70
+ })
71
+ .partial()
72
+
73
+ export type Schema = z.infer<typeof Schema>
74
+ ```
75
+
76
+ ## License
77
+
78
+ Distributed under the MIT License. See [LICENSE](https://github.com/nakita628/schema-to-library?tab=MIT-1-ov-file) for more information.
package/dist/zod.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/zod.js ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ import { cli } from '@schema-to-library/cli';
3
+ import { schemaToZod } from '@schema-to-library/zod';
4
+ const HELP_TEXT = `Usage: schema-to-zod <input.{json,yaml}> -o <output.ts>
5
+
6
+ Options:
7
+ -h, --help display help for command`;
8
+ cli(schemaToZod, HELP_TEXT).then((result) => {
9
+ if (result?.ok) {
10
+ console.log(result.value);
11
+ }
12
+ else {
13
+ console.error(result?.error);
14
+ }
15
+ });
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "schema-to-library",
3
+ "description": "Generate Zod schemas from JSON or YAML files",
4
+ "version": "0.0.1",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "zod"
9
+ ],
10
+ "homepage": "https://github.com/nakita628/schema-to-libray",
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/nakita628/schema-to-libray.git"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/nakita628/schema-to-libray/issues"
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "main": "dist/index.js",
25
+ "bin": {
26
+ "schema-to-zod": "dist/zod.js"
27
+ },
28
+ "dependencies": {
29
+ "@schema-to-library/cli": "file:../../privates/cli",
30
+ "@schema-to-library/zod": "file:../../privates/zod"
31
+ },
32
+ "scripts": {
33
+ "deps": "rm -rf node_modules && rm -rf pnpm-lock.yaml && pnpm install",
34
+ "build": "rm -rf ./dist/* && tsc",
35
+ "typecheck": "tsc --noEmit",
36
+ "release": "pnpm publish"
37
+ }
38
+ }