@jackdbd/zod-to-doc
Advanced tools
Comparing version 1.0.4 to 1.0.5
# CHANGELOG | ||
## [1.0.5](https://github.com/jackdbd/zod-to-doc/compare/v1.0.4...v1.0.5) (2024-02-06) | ||
### Bug Fixes | ||
* add yargs as a dependency ([b1ea82c](https://github.com/jackdbd/zod-to-doc/commit/b1ea82c1d2dae30be2f9944f3fc3a7956fda3b8f)) | ||
## [1.0.4](https://github.com/jackdbd/zod-to-doc/compare/v1.0.3...v1.0.4) (2024-02-06) | ||
@@ -4,0 +11,0 @@ |
export const CLI_NAME = 'ztd'; | ||
// names to consider: | ||
// doc-zod-table, schema-to-doc, zod-to-doc, zod-to-table, ztd, ztt | ||
export const DEBUG_PREFIX = 'ztd'; | ||
//# sourceMappingURL=constants.js.map |
import { z } from 'zod'; | ||
/** | ||
* @internal | ||
*/ | ||
export declare const defaultZodValue: (value: any) => any; | ||
@@ -3,0 +6,0 @@ /** |
@@ -10,4 +10,8 @@ /** | ||
const debug = defDebug(`${DEBUG_PREFIX}:lib`); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// eslint-disable @typescript-eslint/no-explicit-any | ||
/** | ||
* @internal | ||
*/ | ||
export const defaultZodValue = (value) => { | ||
// eslint-enable @typescript-eslint/no-explicit-any | ||
if (value instanceof z.ZodDefault) { | ||
@@ -34,12 +38,3 @@ return value._def.defaultValue(); | ||
const val = value; | ||
// TODO: it would be cool to add a reference to another Zod schema whenever | ||
// we have a nested object. Something like a footnote or a link to another | ||
// markdown table. | ||
// | ||
// To make it work, I think we need to: | ||
// 1. ask the user an array of ES modules where this library should look for | ||
// Zod schemas; | ||
// 2. import each ESM dynamically; | ||
// 3. find the Zod schema that matches this nested object description (but | ||
// what if the nested object has no description?) | ||
// TODO: https://github.com/jackdbd/zod-to-doc/issues/4 | ||
// if (val instanceof z.ZodObject) { | ||
@@ -51,3 +46,2 @@ // console.log('=== val._def ===', val._def) | ||
if (val instanceof z.ZodArray) { | ||
// console.log('=== ZodArray ===', val) | ||
const exactLength = val._def.exactLength && val._def.exactLength.value; | ||
@@ -63,3 +57,2 @@ const minLength = val._def.minLength ? `${val._def.minLength.value}` : 0; | ||
if (val._def.type instanceof z.ZodObject) { | ||
// console.log('=== ZodObject ===', val._def.type) | ||
if (val.description) { | ||
@@ -66,0 +59,0 @@ description = exactLength |
{ | ||
"name": "@jackdbd/zod-to-doc", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Inject your [Zod](https://github.com/colinhacks/zod) schemas into your docs.", | ||
@@ -32,8 +32,8 @@ "author": { | ||
".": { | ||
"import": "./dist/lib.js", | ||
"types": "./dist/lib.d.ts" | ||
"types": "./dist/lib.d.ts", | ||
"import": "./dist/lib.js" | ||
}, | ||
"./lib": { | ||
"import": "./dist/lib.js", | ||
"types": "./dist/lib.d.ts" | ||
"types": "./dist/lib.d.ts", | ||
"import": "./dist/lib.js" | ||
}, | ||
@@ -60,7 +60,6 @@ "./package.json": "./package.json" | ||
"ae:local": "api-extractor run --config ./config/api-extractor.json --verbose --local", | ||
"build": "run-s 'build:ts' 'docs' 'readme' --print-label", | ||
"build": "run-s 'build:ts' 'docs' 'readme' 'publint' --print-label", | ||
"build:ts": "tsc -p tsconfig.json", | ||
"build:ts:watch": "tsc -p tsconfig.json --watch", | ||
"clean": "rimraf coverage/lcov.info dist/ tsconfig.tsbuildinfo", | ||
"cli": "ztd --help", | ||
"commitlint": "commitlint --config ./config/commitlint.cjs --to HEAD --verbose", | ||
@@ -78,2 +77,3 @@ "dev": "run-p 'build:ts:watch' 'test:watch'", | ||
"nuke": "npm run clean && rimraf node_modules 'package-lock.json'", | ||
"publint": "publint run .", | ||
"readme": "npm run example && tsm readme.ts", | ||
@@ -88,2 +88,3 @@ "release:dry": "semantic-release --debug --dry-run --no-ci", | ||
"debug": "^4.3.4", | ||
"yargs": "^17.7.2", | ||
"zod": "^3.22.4" | ||
@@ -109,2 +110,3 @@ }, | ||
"prettier": "^3.2.4", | ||
"publint": "^0.2.7", | ||
"rimraf": "^5.0.5", | ||
@@ -115,6 +117,4 @@ "semantic-release": "^23.0.0", | ||
"typedoc-plugin-zod": "^1.1.2", | ||
"typescript": "^5.3.3", | ||
"yargs": "^17.7.2", | ||
"zocker": "^1.4.1" | ||
"typescript": "^5.3.3" | ||
} | ||
} |
@@ -21,3 +21,2 @@ # Zod to Doc | ||
- [Car tire table](#car-tire-table) | ||
- [Dealership](#dealership) | ||
- [Troubleshooting](#troubleshooting) | ||
@@ -90,11 +89,2 @@ - [Dependencies](#dependencies) | ||
#### Dealership | ||
| Key | Default | Description | | ||
|---|---|---| | ||
| `owner` | `undefined` | Owner of the dealership | | ||
| `employees` | `undefined` | Employees of the dealership (1 to ∞ elements) | | ||
| `cars` | `[]` | Cars sold by the dealership | | ||
| `motorcycles` | `[]` | Motorcycles sold by the dealership | | ||
## Troubleshooting | ||
@@ -117,2 +107,3 @@ | ||
| [debug](https://www.npmjs.com/package/debug) | `^4.3.4` | | ||
| [yargs](https://www.npmjs.com/package/yargs) | `^17.7.2` | | ||
| [zod](https://www.npmjs.com/package/zod) | `^3.22.4` | | ||
@@ -119,0 +110,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
24
37042
3
497
111
+ Addedyargs@^17.7.2
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedcliui@8.0.1(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyargs@17.7.2(transitive)
+ Addedyargs-parser@21.1.1(transitive)