@config-bound/schema-export 0.1.1 → 0.1.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/CHANGELOG.md +7 -0
- package/package.json +2 -2
- package/src/schemaExporter.ts +23 -10
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@config-bound/schema-export",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Schema export utilities for ConfigBound configuration library",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"author": "Robert Keyser",
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@config-bound/config-bound": "0.
|
|
36
|
+
"@config-bound/config-bound": "0.3.0",
|
|
37
37
|
"js-yaml": "^4.1.0",
|
|
38
38
|
"zod": "^4.4.1"
|
|
39
39
|
},
|
package/src/schemaExporter.ts
CHANGED
|
@@ -34,7 +34,10 @@ export interface ExportedSchema {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* Extracts type
|
|
37
|
+
* Extracts a human-readable type string from a Zod schema.
|
|
38
|
+
*
|
|
39
|
+
* @param validator - Zod validator to inspect.
|
|
40
|
+
* @returns Human-readable type string.
|
|
38
41
|
*/
|
|
39
42
|
function extractZodType(validator: z.ZodType): string {
|
|
40
43
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -85,7 +88,10 @@ function extractZodType(validator: z.ZodType): string {
|
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
/**
|
|
88
|
-
*
|
|
91
|
+
* Converts a Zod validator to a JSON Schema representation.
|
|
92
|
+
*
|
|
93
|
+
* @param validator - Zod validator to convert.
|
|
94
|
+
* @returns JSON Schema object.
|
|
89
95
|
*/
|
|
90
96
|
function extractZodValidation(validator: z.ZodType): unknown {
|
|
91
97
|
return z.toJSONSchema(validator, {
|
|
@@ -95,7 +101,10 @@ function extractZodValidation(validator: z.ZodType): unknown {
|
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
/**
|
|
98
|
-
* Exports an Element to the external schema format
|
|
104
|
+
* Exports an Element to the external schema format.
|
|
105
|
+
*
|
|
106
|
+
* @param element - Element to export.
|
|
107
|
+
* @returns Exported element representation.
|
|
99
108
|
*/
|
|
100
109
|
export function exportElement(element: Element<unknown>): ExportedElement {
|
|
101
110
|
return {
|
|
@@ -111,9 +120,11 @@ export function exportElement(element: Element<unknown>): ExportedElement {
|
|
|
111
120
|
}
|
|
112
121
|
|
|
113
122
|
/**
|
|
114
|
-
* Exports a Section to the external schema format
|
|
115
|
-
*
|
|
116
|
-
* @param
|
|
123
|
+
* Exports a Section to the external schema format.
|
|
124
|
+
*
|
|
125
|
+
* @param section - The section to export.
|
|
126
|
+
* @param includeOmitted - Whether to include elements marked with omitFromSchema (default: false).
|
|
127
|
+
* @returns Exported section representation.
|
|
117
128
|
*/
|
|
118
129
|
export function exportSection(
|
|
119
130
|
section: Section,
|
|
@@ -132,10 +143,12 @@ export function exportSection(
|
|
|
132
143
|
}
|
|
133
144
|
|
|
134
145
|
/**
|
|
135
|
-
* Exports the complete schema to a structured format
|
|
136
|
-
*
|
|
137
|
-
* @param
|
|
138
|
-
* @param
|
|
146
|
+
* Exports the complete schema to a structured format.
|
|
147
|
+
*
|
|
148
|
+
* @param name - Name of the configuration.
|
|
149
|
+
* @param sections - Sections to include in the export.
|
|
150
|
+
* @param includeOmitted - Whether to include elements marked with omitFromSchema (default: false).
|
|
151
|
+
* @returns Exported schema representation.
|
|
139
152
|
*/
|
|
140
153
|
export function exportSchema(
|
|
141
154
|
name: string,
|