@kubb/ast 5.0.0-beta.62 → 5.0.0-beta.63
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/dist/{defineMacro-Vw-xQvq7.d.ts → defineMacro-BATi7xoC.d.ts} +4 -5
- package/dist/{defineMacro-BryDiuQl.cjs → defineMacro-CEZHaCXE.cjs} +5 -5
- package/dist/defineMacro-CEZHaCXE.cjs.map +1 -0
- package/dist/{defineMacro-CNkUpxia.js → defineMacro-Shz8f6SG.js} +3 -3
- package/dist/defineMacro-Shz8f6SG.js.map +1 -0
- package/dist/factory.cjs +56 -56
- package/dist/factory.cjs.map +1 -1
- package/dist/factory.d.ts +5 -5
- package/dist/factory.js +5 -5
- package/dist/factory.js.map +1 -1
- package/dist/{index-CTaN_ee_.d.ts → index-B9cc8MBS.d.ts} +46 -113
- package/dist/index.cjs +142 -271
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +12 -5
- package/dist/index.js +108 -236
- package/dist/index.js.map +1 -1
- package/dist/macros.cjs +12 -12
- package/dist/macros.cjs.map +1 -1
- package/dist/macros.d.ts +2 -2
- package/dist/macros.js +4 -4
- package/dist/macros.js.map +1 -1
- package/dist/{operationParams-B44p6EQy.d.ts → operationParams-k5CKwSWZ.d.ts} +9 -2
- package/dist/{visitor-DepQEKyp.js → refs-BjNDuCBD.js} +115 -120
- package/dist/refs-BjNDuCBD.js.map +1 -0
- package/dist/{visitor-B7Zlnp4c.cjs → refs-u5SDdyV7.cjs} +139 -144
- package/dist/refs-u5SDdyV7.cjs.map +1 -0
- package/dist/{response-BeG6hq2D.cjs → schema-BkvrrOAr.cjs} +171 -153
- package/dist/schema-BkvrrOAr.cjs.map +1 -0
- package/dist/{response-Rd1uisM1.js → schema-Cbnxmz4b.js} +166 -154
- package/dist/schema-Cbnxmz4b.js.map +1 -0
- package/dist/{types-DQTgVSwE.d.ts → types-BB_xgRJ3.d.ts} +55 -79
- package/dist/types.d.ts +5 -5
- package/dist/{utils-BDI3kXlb.cjs → utils-CEepwqmb.cjs} +74 -67
- package/dist/utils-CEepwqmb.cjs.map +1 -0
- package/dist/{utils-DW9rnfsD.js → utils-DaXkewb1.js} +56 -49
- package/dist/utils-DaXkewb1.js.map +1 -0
- package/dist/utils.cjs +11 -11
- package/dist/utils.d.ts +44 -29
- package/dist/utils.js +3 -3
- package/package.json +1 -1
- package/src/constants.ts +3 -6
- package/src/defineMacro.ts +1 -1
- package/src/defineNode.ts +6 -9
- package/src/definePrinter.ts +5 -3
- package/src/dialect.ts +23 -13
- package/src/factory.ts +4 -4
- package/src/index.ts +1 -1
- package/src/infer.ts +1 -1
- package/src/macros/macroEnumName.ts +1 -1
- package/src/nodes/code.ts +8 -5
- package/src/nodes/file.ts +5 -4
- package/src/nodes/operation.ts +3 -0
- package/src/nodes/parameter.ts +5 -5
- package/src/nodes/property.ts +5 -5
- package/src/nodes/schema.ts +4 -4
- package/src/optionality.ts +15 -0
- package/src/types.ts +1 -2
- package/src/utils/codegen.ts +6 -7
- package/src/utils/fileMerge.ts +7 -8
- package/src/utils/operationParams.ts +8 -8
- package/src/utils/refs.ts +14 -18
- package/src/utils/schemaGraph.ts +41 -33
- package/src/utils/schemaMerge.ts +2 -2
- package/src/visitor.ts +1 -1
- package/dist/defineMacro-BryDiuQl.cjs.map +0 -1
- package/dist/defineMacro-CNkUpxia.js.map +0 -1
- package/dist/response-BeG6hq2D.cjs.map +0 -1
- package/dist/response-Rd1uisM1.js.map +0 -1
- package/dist/utils-BDI3kXlb.cjs.map +0 -1
- package/dist/utils-DW9rnfsD.js.map +0 -1
- package/dist/visitor-B7Zlnp4c.cjs.map +0 -1
- package/dist/visitor-DepQEKyp.js.map +0 -1
- package/src/dedupe.ts +0 -231
|
@@ -19,7 +19,7 @@ const visitorKeys = [
|
|
|
19
19
|
* Builds a type guard that matches nodes of the given `kind`.
|
|
20
20
|
*/
|
|
21
21
|
function isKind(kind) {
|
|
22
|
-
return (node) => node
|
|
22
|
+
return (node) => node?.kind === kind;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Defines a node once and derives its `create` builder, `is` guard, and traversal
|
|
@@ -44,8 +44,8 @@ function isKind(kind) {
|
|
|
44
44
|
*/
|
|
45
45
|
function defineNode(config) {
|
|
46
46
|
const { kind, defaults, build, children, visitorKey } = config;
|
|
47
|
-
function create(input
|
|
48
|
-
const base = build ? build(input
|
|
47
|
+
function create(input) {
|
|
48
|
+
const base = build ? build(input) : input;
|
|
49
49
|
return {
|
|
50
50
|
...defaults,
|
|
51
51
|
...base,
|
|
@@ -61,142 +61,6 @@ function defineNode(config) {
|
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
//#endregion
|
|
64
|
-
//#region src/nodes/schema.ts
|
|
65
|
-
/**
|
|
66
|
-
* Maps schema `type` to its underlying `primitive`.
|
|
67
|
-
* Primitive types map to themselves. Special string formats map to `'string'`.
|
|
68
|
-
* Complex types (`ref`, `enum`, `union`, `intersection`, `tuple`, `blob`) are left unset.
|
|
69
|
-
*/
|
|
70
|
-
const TYPE_TO_PRIMITIVE = {
|
|
71
|
-
string: "string",
|
|
72
|
-
number: "number",
|
|
73
|
-
integer: "integer",
|
|
74
|
-
bigint: "bigint",
|
|
75
|
-
boolean: "boolean",
|
|
76
|
-
null: "null",
|
|
77
|
-
any: "any",
|
|
78
|
-
unknown: "unknown",
|
|
79
|
-
void: "void",
|
|
80
|
-
never: "never",
|
|
81
|
-
object: "object",
|
|
82
|
-
array: "array",
|
|
83
|
-
date: "date",
|
|
84
|
-
uuid: "string",
|
|
85
|
-
email: "string",
|
|
86
|
-
url: "string",
|
|
87
|
-
datetime: "string",
|
|
88
|
-
time: "string"
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Definition for the {@link SchemaNode}. Object schemas default `properties` to an
|
|
92
|
-
* empty array, and `primitive` is inferred from `type` when not explicitly provided.
|
|
93
|
-
*/
|
|
94
|
-
const schemaDef = defineNode({
|
|
95
|
-
kind: "Schema",
|
|
96
|
-
build: (props) => {
|
|
97
|
-
if (props.type === "object") return {
|
|
98
|
-
properties: [],
|
|
99
|
-
primitive: "object",
|
|
100
|
-
...props
|
|
101
|
-
};
|
|
102
|
-
return {
|
|
103
|
-
primitive: TYPE_TO_PRIMITIVE[props.type],
|
|
104
|
-
...props
|
|
105
|
-
};
|
|
106
|
-
},
|
|
107
|
-
children: [
|
|
108
|
-
"properties",
|
|
109
|
-
"items",
|
|
110
|
-
"members",
|
|
111
|
-
"additionalProperties"
|
|
112
|
-
],
|
|
113
|
-
visitorKey: "schema"
|
|
114
|
-
});
|
|
115
|
-
function createSchema(props) {
|
|
116
|
-
return schemaDef.create(props);
|
|
117
|
-
}
|
|
118
|
-
//#endregion
|
|
119
|
-
//#region ../../internals/utils/src/casing.ts
|
|
120
|
-
/**
|
|
121
|
-
* Shared implementation for camelCase and PascalCase conversion.
|
|
122
|
-
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
123
|
-
* and capitalizes each word according to `pascal`.
|
|
124
|
-
*
|
|
125
|
-
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
126
|
-
*/
|
|
127
|
-
function toCamelOrPascal(text, pascal) {
|
|
128
|
-
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
129
|
-
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
130
|
-
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
131
|
-
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Converts `text` to camelCase.
|
|
135
|
-
*
|
|
136
|
-
* @example Word boundaries
|
|
137
|
-
* `camelCase('hello-world') // 'helloWorld'`
|
|
138
|
-
*
|
|
139
|
-
* @example With a prefix
|
|
140
|
-
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
141
|
-
*/
|
|
142
|
-
function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
143
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Converts `text` to PascalCase.
|
|
147
|
-
*
|
|
148
|
-
* @example Word boundaries
|
|
149
|
-
* `pascalCase('hello-world') // 'HelloWorld'`
|
|
150
|
-
*
|
|
151
|
-
* @example With a suffix
|
|
152
|
-
* `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
|
|
153
|
-
*/
|
|
154
|
-
function pascalCase(text, { prefix = "", suffix = "" } = {}) {
|
|
155
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
156
|
-
}
|
|
157
|
-
//#endregion
|
|
158
|
-
//#region ../../internals/utils/src/fs.ts
|
|
159
|
-
/**
|
|
160
|
-
* Strips the file extension from a path or file name.
|
|
161
|
-
* Only removes the last `.ext` segment when the dot is not part of a directory name.
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
* trimExtName('petStore.ts') // 'petStore'
|
|
165
|
-
* trimExtName('/src/models/pet.ts') // '/src/models/pet'
|
|
166
|
-
* trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'
|
|
167
|
-
* trimExtName('noExtension') // 'noExtension'
|
|
168
|
-
*/
|
|
169
|
-
function trimExtName(text) {
|
|
170
|
-
const dotIndex = text.lastIndexOf(".");
|
|
171
|
-
if (dotIndex > 0 && !text.includes("/", dotIndex)) return text.slice(0, dotIndex);
|
|
172
|
-
return text;
|
|
173
|
-
}
|
|
174
|
-
//#endregion
|
|
175
|
-
//#region src/utils/extractStringsFromNodes.ts
|
|
176
|
-
/**
|
|
177
|
-
* Extracts all string content from a `CodeNode` tree recursively.
|
|
178
|
-
*
|
|
179
|
-
* Collects text node values, identifier references in string fields (`params`, `generics`, `returnType`, `type`),
|
|
180
|
-
* and nested node content. Used to build the full source string for import filtering.
|
|
181
|
-
*/
|
|
182
|
-
function extractStringsFromNodes(nodes) {
|
|
183
|
-
if (!nodes?.length) return "";
|
|
184
|
-
return nodes.map((node) => {
|
|
185
|
-
if (typeof node === "string") return node;
|
|
186
|
-
if (node.kind === "Text") return node.value;
|
|
187
|
-
if (node.kind === "Break") return "";
|
|
188
|
-
if (node.kind === "Jsx") return node.value;
|
|
189
|
-
const parts = [];
|
|
190
|
-
if ("params" in node && node.params) parts.push(node.params);
|
|
191
|
-
if ("generics" in node && node.generics) parts.push(Array.isArray(node.generics) ? node.generics.join(", ") : node.generics);
|
|
192
|
-
if ("returnType" in node && node.returnType) parts.push(node.returnType);
|
|
193
|
-
if ("type" in node && typeof node.type === "string") parts.push(node.type);
|
|
194
|
-
const nested = extractStringsFromNodes(node.nodes);
|
|
195
|
-
if (nested) parts.push(nested);
|
|
196
|
-
return parts.join("\n");
|
|
197
|
-
}).filter(Boolean).join("\n");
|
|
198
|
-
}
|
|
199
|
-
//#endregion
|
|
200
64
|
//#region src/nodes/code.ts
|
|
201
65
|
/**
|
|
202
66
|
* Definition for the {@link ConstNode}.
|
|
@@ -321,6 +185,87 @@ const contentDef = defineNode({
|
|
|
321
185
|
*/
|
|
322
186
|
const createContent = contentDef.create;
|
|
323
187
|
//#endregion
|
|
188
|
+
//#region ../../internals/utils/src/casing.ts
|
|
189
|
+
/**
|
|
190
|
+
* Shared implementation for camelCase and PascalCase conversion.
|
|
191
|
+
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
192
|
+
* and capitalizes each word according to `pascal`.
|
|
193
|
+
*
|
|
194
|
+
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
195
|
+
*/
|
|
196
|
+
function toCamelOrPascal(text, pascal) {
|
|
197
|
+
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
198
|
+
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
199
|
+
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
200
|
+
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Converts `text` to camelCase.
|
|
204
|
+
*
|
|
205
|
+
* @example Word boundaries
|
|
206
|
+
* `camelCase('hello-world') // 'helloWorld'`
|
|
207
|
+
*
|
|
208
|
+
* @example With a prefix
|
|
209
|
+
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
210
|
+
*/
|
|
211
|
+
function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
212
|
+
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Converts `text` to PascalCase.
|
|
216
|
+
*
|
|
217
|
+
* @example Word boundaries
|
|
218
|
+
* `pascalCase('hello-world') // 'HelloWorld'`
|
|
219
|
+
*
|
|
220
|
+
* @example With a suffix
|
|
221
|
+
* `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
|
|
222
|
+
*/
|
|
223
|
+
function pascalCase(text, { prefix = "", suffix = "" } = {}) {
|
|
224
|
+
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
225
|
+
}
|
|
226
|
+
//#endregion
|
|
227
|
+
//#region ../../internals/utils/src/fs.ts
|
|
228
|
+
/**
|
|
229
|
+
* Strips the file extension from a path or file name.
|
|
230
|
+
* Only removes the last `.ext` segment when the dot is not part of a directory name.
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* trimExtName('petStore.ts') // 'petStore'
|
|
234
|
+
* trimExtName('/src/models/pet.ts') // '/src/models/pet'
|
|
235
|
+
* trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'
|
|
236
|
+
* trimExtName('noExtension') // 'noExtension'
|
|
237
|
+
*/
|
|
238
|
+
function trimExtName(text) {
|
|
239
|
+
const dotIndex = text.lastIndexOf(".");
|
|
240
|
+
if (dotIndex > 0 && !text.includes("/", dotIndex)) return text.slice(0, dotIndex);
|
|
241
|
+
return text;
|
|
242
|
+
}
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/utils/extractStringsFromNodes.ts
|
|
245
|
+
/**
|
|
246
|
+
* Extracts all string content from a `CodeNode` tree recursively.
|
|
247
|
+
*
|
|
248
|
+
* Collects text node values, identifier references in string fields (`params`, `generics`, `returnType`, `type`),
|
|
249
|
+
* and nested node content. Used to build the full source string for import filtering.
|
|
250
|
+
*/
|
|
251
|
+
function extractStringsFromNodes(nodes) {
|
|
252
|
+
if (!nodes?.length) return "";
|
|
253
|
+
return nodes.map((node) => {
|
|
254
|
+
if (typeof node === "string") return node;
|
|
255
|
+
if (node.kind === "Text") return node.value;
|
|
256
|
+
if (node.kind === "Break") return "";
|
|
257
|
+
if (node.kind === "Jsx") return node.value;
|
|
258
|
+
const parts = [];
|
|
259
|
+
if ("params" in node && node.params) parts.push(node.params);
|
|
260
|
+
if ("generics" in node && node.generics) parts.push(Array.isArray(node.generics) ? node.generics.join(", ") : node.generics);
|
|
261
|
+
if ("returnType" in node && node.returnType) parts.push(node.returnType);
|
|
262
|
+
if ("type" in node && typeof node.type === "string") parts.push(node.type);
|
|
263
|
+
const nested = extractStringsFromNodes(node.nodes);
|
|
264
|
+
if (nested) parts.push(nested);
|
|
265
|
+
return parts.join("\n");
|
|
266
|
+
}).filter(Boolean).join("\n");
|
|
267
|
+
}
|
|
268
|
+
//#endregion
|
|
324
269
|
//#region src/utils/fileMerge.ts
|
|
325
270
|
function sourceKey(source) {
|
|
326
271
|
return `${source.name ?? extractStringsFromNodes(source.nodes)}:${source.isExportable ?? false}:${source.isTypeOnly ?? false}`;
|
|
@@ -346,9 +291,9 @@ function sortKey(node) {
|
|
|
346
291
|
return `${isArray}:${typeOnly}:${node.path}:${hasName}:${name}`;
|
|
347
292
|
}
|
|
348
293
|
/**
|
|
349
|
-
* Deduplicates
|
|
350
|
-
*
|
|
351
|
-
*
|
|
294
|
+
* Deduplicates `SourceNode` objects by `name + isExportable + isTypeOnly`, keeping the first of each
|
|
295
|
+
* key. Unnamed sources fall back to their extracted node strings as the name part of the key. Returns
|
|
296
|
+
* the deduplicated array in original order.
|
|
352
297
|
*/
|
|
353
298
|
function combineSources(sources) {
|
|
354
299
|
const seen = /* @__PURE__ */ new Map();
|
|
@@ -790,20 +735,33 @@ function createOutput(overrides = {}) {
|
|
|
790
735
|
return outputDef.create(overrides);
|
|
791
736
|
}
|
|
792
737
|
//#endregion
|
|
738
|
+
//#region src/optionality.ts
|
|
739
|
+
/**
|
|
740
|
+
* Generic JSON Schema optionality: a non-required field is optional, and a
|
|
741
|
+
* non-required nullable field is nullish.
|
|
742
|
+
*/
|
|
743
|
+
function optionality(schema, required) {
|
|
744
|
+
const nullable = schema.nullable ?? false;
|
|
745
|
+
return {
|
|
746
|
+
...schema,
|
|
747
|
+
optional: !required && !nullable ? true : void 0,
|
|
748
|
+
nullish: !required && nullable ? true : void 0
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
//#endregion
|
|
793
752
|
//#region src/nodes/parameter.ts
|
|
794
753
|
/**
|
|
795
|
-
* Definition for the {@link ParameterNode}. `required` defaults to `false
|
|
796
|
-
*
|
|
797
|
-
* `optionality`; without one, the schema is left as-is.
|
|
754
|
+
* Definition for the {@link ParameterNode}. `required` defaults to `false`, and the schema's
|
|
755
|
+
* `optional`/`nullish` flags are derived from it through {@link optionality}.
|
|
798
756
|
*/
|
|
799
757
|
const parameterDef = defineNode({
|
|
800
758
|
kind: "Parameter",
|
|
801
|
-
build: (props
|
|
759
|
+
build: (props) => {
|
|
802
760
|
const required = props.required ?? false;
|
|
803
761
|
return {
|
|
804
762
|
...props,
|
|
805
763
|
required,
|
|
806
|
-
schema:
|
|
764
|
+
schema: optionality(props.schema, required)
|
|
807
765
|
};
|
|
808
766
|
},
|
|
809
767
|
children: ["schema"],
|
|
@@ -826,18 +784,17 @@ const createParameter = parameterDef.create;
|
|
|
826
784
|
//#endregion
|
|
827
785
|
//#region src/nodes/property.ts
|
|
828
786
|
/**
|
|
829
|
-
* Definition for the {@link PropertyNode}. `required` defaults to `false
|
|
830
|
-
*
|
|
831
|
-
* `optionality`; without one, the schema is left as-is.
|
|
787
|
+
* Definition for the {@link PropertyNode}. `required` defaults to `false`, and the schema's
|
|
788
|
+
* `optional`/`nullish` flags are derived from it through {@link optionality}.
|
|
832
789
|
*/
|
|
833
790
|
const propertyDef = defineNode({
|
|
834
791
|
kind: "Property",
|
|
835
|
-
build: (props
|
|
792
|
+
build: (props) => {
|
|
836
793
|
const required = props.required ?? false;
|
|
837
794
|
return {
|
|
838
795
|
...props,
|
|
839
796
|
required,
|
|
840
|
-
schema:
|
|
797
|
+
schema: optionality(props.schema, required)
|
|
841
798
|
};
|
|
842
799
|
},
|
|
843
800
|
children: ["schema"],
|
|
@@ -893,6 +850,61 @@ const responseDef = defineNode({
|
|
|
893
850
|
*/
|
|
894
851
|
const createResponse = responseDef.create;
|
|
895
852
|
//#endregion
|
|
896
|
-
|
|
853
|
+
//#region src/nodes/schema.ts
|
|
854
|
+
/**
|
|
855
|
+
* Maps schema `type` to its underlying `primitive`.
|
|
856
|
+
* Primitive types map to themselves and special string formats map to `'string'`.
|
|
857
|
+
* Any type not listed here (such as `ref`, `enum`, `union`, `intersection`, `tuple`, `ipv4`, `ipv6`, `blob`) has no `primitive`.
|
|
858
|
+
*/
|
|
859
|
+
const TYPE_TO_PRIMITIVE = {
|
|
860
|
+
string: "string",
|
|
861
|
+
number: "number",
|
|
862
|
+
integer: "integer",
|
|
863
|
+
bigint: "bigint",
|
|
864
|
+
boolean: "boolean",
|
|
865
|
+
null: "null",
|
|
866
|
+
any: "any",
|
|
867
|
+
unknown: "unknown",
|
|
868
|
+
void: "void",
|
|
869
|
+
never: "never",
|
|
870
|
+
object: "object",
|
|
871
|
+
array: "array",
|
|
872
|
+
date: "date",
|
|
873
|
+
uuid: "string",
|
|
874
|
+
email: "string",
|
|
875
|
+
url: "string",
|
|
876
|
+
datetime: "string",
|
|
877
|
+
time: "string"
|
|
878
|
+
};
|
|
879
|
+
/**
|
|
880
|
+
* Definition for the {@link SchemaNode}. Object schemas default `properties` to an
|
|
881
|
+
* empty array, and `primitive` is inferred from `type` when not explicitly provided.
|
|
882
|
+
*/
|
|
883
|
+
const schemaDef = defineNode({
|
|
884
|
+
kind: "Schema",
|
|
885
|
+
build: (props) => {
|
|
886
|
+
if (props.type === "object") return {
|
|
887
|
+
properties: [],
|
|
888
|
+
primitive: "object",
|
|
889
|
+
...props
|
|
890
|
+
};
|
|
891
|
+
return {
|
|
892
|
+
primitive: TYPE_TO_PRIMITIVE[props.type],
|
|
893
|
+
...props
|
|
894
|
+
};
|
|
895
|
+
},
|
|
896
|
+
children: [
|
|
897
|
+
"properties",
|
|
898
|
+
"items",
|
|
899
|
+
"members",
|
|
900
|
+
"additionalProperties"
|
|
901
|
+
],
|
|
902
|
+
visitorKey: "schema"
|
|
903
|
+
});
|
|
904
|
+
function createSchema(props) {
|
|
905
|
+
return schemaDef.create(props);
|
|
906
|
+
}
|
|
907
|
+
//#endregion
|
|
908
|
+
export { textDef as $, createImport as A, createContent as B, functionParameterDef as C, typeLiteralDef as D, objectBindingPatternDef as E, sourceDef as F, createBreak as G, breakDef as H, extractStringsFromNodes as I, createJsx as J, createConst as K, camelCase as L, exportDef as M, fileDef as N, createExport as O, importDef as P, jsxDef as Q, pascalCase as R, createTypeLiteral as S, indexedAccessTypeDef as T, constDef as U, arrowFunctionDef as V, createArrowFunction as W, createType as X, createText as Y, functionDef as Z, inputDef as _, createProperty as a, createIndexedAccessType as b, parameterDef as c, outputDef as d, typeDef as et, createOperation as f, createInput as g, requestBodyDef as h, responseDef as i, createSource as j, createFile as k, optionality as l, createRequestBody as m, schemaDef as n, visitorKeys as nt, propertyDef as o, operationDef as p, createFunction as q, createResponse as r, createParameter as s, createSchema as t, defineNode as tt, createOutput as u, createFunctionParameter as v, functionParametersDef as w, createObjectBindingPattern as x, createFunctionParameters as y, contentDef as z };
|
|
897
909
|
|
|
898
|
-
//# sourceMappingURL=
|
|
910
|
+
//# sourceMappingURL=schema-Cbnxmz4b.js.map
|