@chnak/zod-to-markdown 1.0.6 → 1.0.7

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.
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "permissions": {
3
3
  "allow": [
4
- "Bash(cd D:/Date/20260321/zod-to-markdown && npm test)"
4
+ "Bash(cd D:/Date/20260321/zod-to-markdown && npm test)",
5
+ "Bash(npm test:*)"
5
6
  ]
6
7
  }
7
8
  }
package/lib/index.js CHANGED
@@ -616,6 +616,40 @@ function zodSchemaToMarkdown(schema, indentLevel = 0) {
616
616
  else if (isZodType(schema, 'ZodVoid')) {
617
617
  markdown += `${indent}- Void\n`;
618
618
  }
619
+ else if (isZodType(schema, 'ZodAny')) {
620
+ markdown += `${indent}- Any\n`;
621
+ }
622
+ else if (isZodType(schema, 'ZodMap')) {
623
+ const mapSchema = schema;
624
+ markdown += `${indent}- Map\n`;
625
+ markdown += `${indent} Key:\n`;
626
+ markdown += zodSchemaToMarkdown(mapSchema.keySchema, indentLevel + 2);
627
+ markdown += `${indent} Value:\n`;
628
+ markdown += zodSchemaToMarkdown(mapSchema.valueSchema, indentLevel + 2);
629
+ }
630
+ else if (isZodType(schema, 'ZodSet')) {
631
+ markdown += `${indent}- Set\n`;
632
+ markdown += zodSchemaToMarkdown(schema._def.valueType, indentLevel + 1);
633
+ }
634
+ else if (isZodType(schema, 'ZodLazy')) {
635
+ markdown += `${indent}- Lazy\n`;
636
+ }
637
+ else if (isZodType(schema, 'ZodFunction')) {
638
+ const fnSchema = schema;
639
+ markdown += `${indent}- Function\n`;
640
+ if (fnSchema._def.args) {
641
+ markdown += `${indent} Args:\n`;
642
+ markdown += zodSchemaToMarkdown(fnSchema._def.args, indentLevel + 2);
643
+ }
644
+ if (fnSchema._def.returns) {
645
+ markdown += `${indent} Returns:\n`;
646
+ markdown += zodSchemaToMarkdown(fnSchema._def.returns, indentLevel + 2);
647
+ }
648
+ }
649
+ else if (isZodType(schema, 'ZodPromise')) {
650
+ markdown += `${indent}- Promise\n`;
651
+ markdown += zodSchemaToMarkdown(schema._def.type, indentLevel + 1);
652
+ }
619
653
  else {
620
654
  markdown += `${indent}- Type: ${schema._def.typeName || schema.constructor.name}\n`;
621
655
  }
package/lib/index.test.js CHANGED
@@ -127,6 +127,54 @@ describe('zodSchemaToMarkdown', () => {
127
127
  it('should convert ZodVoid to markdown', () => {
128
128
  const schema = zod_1.z.void();
129
129
  const expected = `- Void
130
+ `;
131
+ expect((0, index_1.zodSchemaToMarkdown)(schema)).toBe(expected);
132
+ });
133
+ it('should convert ZodAny to markdown', () => {
134
+ const schema = zod_1.z.any();
135
+ const expected = `- Any
136
+ `;
137
+ expect((0, index_1.zodSchemaToMarkdown)(schema)).toBe(expected);
138
+ });
139
+ it('should convert ZodMap to markdown', () => {
140
+ const schema = zod_1.z.map(zod_1.z.string(), zod_1.z.number());
141
+ const expected = `- Map
142
+ Key:
143
+ - String
144
+ Value:
145
+ - Number
146
+ `;
147
+ expect((0, index_1.zodSchemaToMarkdown)(schema)).toBe(expected);
148
+ });
149
+ it('should convert ZodSet to markdown', () => {
150
+ const schema = zod_1.z.set(zod_1.z.string());
151
+ const expected = `- Set
152
+ - String
153
+ `;
154
+ expect((0, index_1.zodSchemaToMarkdown)(schema)).toBe(expected);
155
+ });
156
+ it('should convert ZodLazy to markdown', () => {
157
+ const schema = zod_1.z.lazy(() => zod_1.z.string());
158
+ const expected = `- Lazy
159
+ `;
160
+ expect((0, index_1.zodSchemaToMarkdown)(schema)).toBe(expected);
161
+ });
162
+ it('should convert ZodFunction to markdown', () => {
163
+ const schema = zod_1.z.function().args(zod_1.z.string()).returns(zod_1.z.number());
164
+ const expected = `- Function
165
+ Args:
166
+ - Tuple
167
+ [0]:
168
+ - String
169
+ Returns:
170
+ - Number
171
+ `;
172
+ expect((0, index_1.zodSchemaToMarkdown)(schema)).toBe(expected);
173
+ });
174
+ it('should convert ZodPromise to markdown', () => {
175
+ const schema = zod_1.z.promise(zod_1.z.string());
176
+ const expected = `- Promise
177
+ - String
130
178
  `;
131
179
  expect((0, index_1.zodSchemaToMarkdown)(schema)).toBe(expected);
132
180
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chnak/zod-to-markdown",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "A utility function to convert Zod schemas to Markdown documentation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",