@kubb/ast 5.0.0-beta.67 → 5.0.0-beta.69
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-BxfaP1iL.cjs → defineMacro-Bh5E_Il6.cjs} +4 -4
- package/dist/{defineMacro-BxfaP1iL.cjs.map → defineMacro-Bh5E_Il6.cjs.map} +1 -1
- package/dist/{defineMacro-D2vgAdoH.js → defineMacro-CVrU3ajV.js} +2 -2
- package/dist/{defineMacro-D2vgAdoH.js.map → defineMacro-CVrU3ajV.js.map} +1 -1
- package/dist/{defineMacro-BQpu6Ags.d.ts → defineMacro-D9ekmTW5.d.ts} +2 -2
- package/dist/{index-CeJAFegf.d.ts → index-q_ldM1YP.d.ts} +20 -1
- package/dist/index.cjs +97 -354
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +20 -36
- package/dist/index.js +3 -259
- package/dist/index.js.map +1 -1
- package/dist/macros.cjs +10 -9
- package/dist/macros.cjs.map +1 -1
- package/dist/macros.d.ts +1 -1
- package/dist/macros.js +3 -2
- package/dist/macros.js.map +1 -1
- package/dist/{operationParams-DCY3q4C7.d.ts → operationParams-Dme8H-sR.d.ts} +2 -2
- package/dist/refs-8IwpesXW.cjs +157 -0
- package/dist/refs-8IwpesXW.cjs.map +1 -0
- package/dist/refs-D2qwT5ck.js +117 -0
- package/dist/refs-D2qwT5ck.js.map +1 -0
- package/dist/{types-CkgvnJBm.d.ts → types-Df1jVmRy.d.ts} +7 -24
- package/dist/types.d.ts +5 -5
- package/dist/utils.cjs +800 -27
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +776 -2
- package/dist/utils.js.map +1 -0
- package/dist/{refs-DDIY_Tpn.cjs → visitor-CLLDwBvv.cjs} +16 -155
- package/dist/visitor-CLLDwBvv.cjs.map +1 -0
- package/dist/{refs-CXp6uOHL.js → visitor-DG5ROqRx.js} +11 -114
- package/dist/visitor-DG5ROqRx.js.map +1 -0
- package/package.json +2 -1
- package/dist/refs-CXp6uOHL.js.map +0 -1
- package/dist/refs-DDIY_Tpn.cjs.map +0 -1
- package/dist/utils-C2kwfetT.js +0 -776
- package/dist/utils-C2kwfetT.js.map +0 -1
- package/dist/utils-DYhjlv0E.cjs +0 -918
- package/dist/utils-DYhjlv0E.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
require("./
|
|
4
|
-
const require_defineMacro = require("./defineMacro-BxfaP1iL.cjs");
|
|
5
|
-
let node_crypto = require("node:crypto");
|
|
2
|
+
const require_visitor = require("./visitor-CLLDwBvv.cjs");
|
|
3
|
+
const require_defineMacro = require("./defineMacro-Bh5E_Il6.cjs");
|
|
6
4
|
//#region src/defineDialect.ts
|
|
7
5
|
/**
|
|
8
6
|
* Types a {@link Dialect} for an adapter. Adds no runtime behavior and only pins the
|
|
@@ -19,7 +17,6 @@ let node_crypto = require("node:crypto");
|
|
|
19
17
|
* isBinary: (schema) => schema.type === 'string' && schema.contentMediaType === 'application/octet-stream',
|
|
20
18
|
* resolveRef,
|
|
21
19
|
* },
|
|
22
|
-
* dedupe: { plan },
|
|
23
20
|
* })
|
|
24
21
|
* ```
|
|
25
22
|
*/
|
|
@@ -87,285 +84,33 @@ function createPrinter(build) {
|
|
|
87
84
|
};
|
|
88
85
|
}
|
|
89
86
|
//#endregion
|
|
90
|
-
//#region src/signature.ts
|
|
91
|
-
/**
|
|
92
|
-
* The flags shared by every node kind that affect its type: `primitive`, `format`, `nullable`.
|
|
93
|
-
*/
|
|
94
|
-
function flagsDescriptor(node) {
|
|
95
|
-
return `${node.primitive ?? ""};${node.format ?? ""};${node.nullable ? 1 : 0}`;
|
|
96
|
-
}
|
|
97
|
-
function refTargetName(node) {
|
|
98
|
-
if (node.ref) return require_refs.extractRefName(node.ref);
|
|
99
|
-
return node.name ?? "";
|
|
100
|
-
}
|
|
101
|
-
const arrayTupleFields = [
|
|
102
|
-
{
|
|
103
|
-
kind: "children",
|
|
104
|
-
key: "items",
|
|
105
|
-
prefix: "i"
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
kind: "child",
|
|
109
|
-
key: "rest",
|
|
110
|
-
prefix: "r"
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
kind: "scalar",
|
|
114
|
-
key: "min",
|
|
115
|
-
prefix: "mn"
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
kind: "scalar",
|
|
119
|
-
key: "max",
|
|
120
|
-
prefix: "mx"
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
kind: "bool",
|
|
124
|
-
key: "unique",
|
|
125
|
-
prefix: "u"
|
|
126
|
-
}
|
|
127
|
-
];
|
|
128
|
-
const numericFields = [
|
|
129
|
-
{
|
|
130
|
-
kind: "scalar",
|
|
131
|
-
key: "min",
|
|
132
|
-
prefix: "mn"
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
kind: "scalar",
|
|
136
|
-
key: "max",
|
|
137
|
-
prefix: "mx"
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
kind: "scalar",
|
|
141
|
-
key: "exclusiveMinimum",
|
|
142
|
-
prefix: "emn"
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
kind: "scalar",
|
|
146
|
-
key: "exclusiveMaximum",
|
|
147
|
-
prefix: "emx"
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
kind: "scalar",
|
|
151
|
-
key: "multipleOf",
|
|
152
|
-
prefix: "mo"
|
|
153
|
-
}
|
|
154
|
-
];
|
|
155
|
-
const rangeFields = [{
|
|
156
|
-
kind: "scalar",
|
|
157
|
-
key: "min",
|
|
158
|
-
prefix: "mn"
|
|
159
|
-
}, {
|
|
160
|
-
kind: "scalar",
|
|
161
|
-
key: "max",
|
|
162
|
-
prefix: "mx"
|
|
163
|
-
}];
|
|
164
|
-
/**
|
|
165
|
-
* Maps each node `type` to its ordered shape-contributing fields. Types absent from the map
|
|
166
|
-
* (boolean, null, any, and other scalars) fall back to `${type}|${flags}`.
|
|
167
|
-
*/
|
|
168
|
-
const SHAPE_KEYS = {
|
|
169
|
-
object: [
|
|
170
|
-
{ kind: "objectProps" },
|
|
171
|
-
{ kind: "additionalProps" },
|
|
172
|
-
{ kind: "patternProps" },
|
|
173
|
-
{
|
|
174
|
-
kind: "scalar",
|
|
175
|
-
key: "minProperties",
|
|
176
|
-
prefix: "mn"
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
kind: "scalar",
|
|
180
|
-
key: "maxProperties",
|
|
181
|
-
prefix: "mx"
|
|
182
|
-
}
|
|
183
|
-
],
|
|
184
|
-
array: arrayTupleFields,
|
|
185
|
-
tuple: arrayTupleFields,
|
|
186
|
-
union: [
|
|
187
|
-
{
|
|
188
|
-
kind: "scalar",
|
|
189
|
-
key: "strategy",
|
|
190
|
-
prefix: "s"
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
kind: "scalar",
|
|
194
|
-
key: "discriminatorPropertyName",
|
|
195
|
-
prefix: "d"
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
kind: "children",
|
|
199
|
-
key: "members",
|
|
200
|
-
prefix: "m"
|
|
201
|
-
}
|
|
202
|
-
],
|
|
203
|
-
intersection: [{
|
|
204
|
-
kind: "children",
|
|
205
|
-
key: "members",
|
|
206
|
-
prefix: "m"
|
|
207
|
-
}],
|
|
208
|
-
enum: [{ kind: "enumValues" }],
|
|
209
|
-
ref: [{ kind: "refTarget" }],
|
|
210
|
-
string: [
|
|
211
|
-
{
|
|
212
|
-
kind: "scalar",
|
|
213
|
-
key: "min",
|
|
214
|
-
prefix: "mn"
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
kind: "scalar",
|
|
218
|
-
key: "max",
|
|
219
|
-
prefix: "mx"
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
kind: "scalar",
|
|
223
|
-
key: "pattern",
|
|
224
|
-
prefix: "pt"
|
|
225
|
-
}
|
|
226
|
-
],
|
|
227
|
-
number: numericFields,
|
|
228
|
-
integer: numericFields,
|
|
229
|
-
bigint: numericFields,
|
|
230
|
-
url: [
|
|
231
|
-
{
|
|
232
|
-
kind: "scalar",
|
|
233
|
-
key: "path",
|
|
234
|
-
prefix: "path"
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
kind: "scalar",
|
|
238
|
-
key: "min",
|
|
239
|
-
prefix: "mn"
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
kind: "scalar",
|
|
243
|
-
key: "max",
|
|
244
|
-
prefix: "mx"
|
|
245
|
-
}
|
|
246
|
-
],
|
|
247
|
-
uuid: rangeFields,
|
|
248
|
-
email: rangeFields,
|
|
249
|
-
datetime: [{
|
|
250
|
-
kind: "bool",
|
|
251
|
-
key: "offset",
|
|
252
|
-
prefix: "o"
|
|
253
|
-
}, {
|
|
254
|
-
kind: "bool",
|
|
255
|
-
key: "local",
|
|
256
|
-
prefix: "l"
|
|
257
|
-
}],
|
|
258
|
-
date: [{
|
|
259
|
-
kind: "scalar",
|
|
260
|
-
key: "representation",
|
|
261
|
-
prefix: "rep"
|
|
262
|
-
}],
|
|
263
|
-
time: [{
|
|
264
|
-
kind: "scalar",
|
|
265
|
-
key: "representation",
|
|
266
|
-
prefix: "rep"
|
|
267
|
-
}]
|
|
268
|
-
};
|
|
269
|
-
function serializeShapeField(field, node, record) {
|
|
270
|
-
switch (field.kind) {
|
|
271
|
-
case "scalar": return `${field.prefix}:${record[field.key] ?? ""}`;
|
|
272
|
-
case "bool": return `${field.prefix}:${record[field.key] ? 1 : 0}`;
|
|
273
|
-
case "child": {
|
|
274
|
-
const child = record[field.key];
|
|
275
|
-
return `${field.prefix}:${child ? signatureOf(child) : ""}`;
|
|
276
|
-
}
|
|
277
|
-
case "children": {
|
|
278
|
-
const children = record[field.key] ?? [];
|
|
279
|
-
return `${field.prefix}[${children.map((c) => signatureOf(c)).join(",")}]`;
|
|
280
|
-
}
|
|
281
|
-
case "objectProps": return `p[${(node.properties ?? []).map((prop) => `${prop.name}${prop.required ? "!" : "?"}${signatureOf(prop.schema)}`).join(",")}]`;
|
|
282
|
-
case "additionalProps": {
|
|
283
|
-
const obj = node;
|
|
284
|
-
if (typeof obj.additionalProperties === "boolean") return `ab:${obj.additionalProperties}`;
|
|
285
|
-
if (obj.additionalProperties) return `as:${signatureOf(obj.additionalProperties)}`;
|
|
286
|
-
return "";
|
|
287
|
-
}
|
|
288
|
-
case "patternProps": {
|
|
289
|
-
const obj = node;
|
|
290
|
-
return `pp[${obj.patternProperties ? Object.keys(obj.patternProperties).sort().map((key) => `${key}=${signatureOf(obj.patternProperties[key])}`).join(",") : ""}]`;
|
|
291
|
-
}
|
|
292
|
-
case "enumValues": {
|
|
293
|
-
const en = node;
|
|
294
|
-
let values = "";
|
|
295
|
-
if (en.namedEnumValues?.length) values = en.namedEnumValues.map((entry) => `${entry.name}=${entry.primitive}:${String(entry.value)}`).join(",");
|
|
296
|
-
else if (en.enumValues?.length) values = en.enumValues.map((value) => `${value === null ? "null" : typeof value}:${String(value)}`).join(",");
|
|
297
|
-
return `v[${values}]`;
|
|
298
|
-
}
|
|
299
|
-
case "refTarget": return `->${refTargetName(node)}`;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Builds the local shape descriptor that {@link signatureOf} hashes: the node's kind, flags,
|
|
304
|
-
* constraints, and its children's signatures.
|
|
305
|
-
*/
|
|
306
|
-
function describeShape(node) {
|
|
307
|
-
const flags = flagsDescriptor(node);
|
|
308
|
-
const fields = SHAPE_KEYS[node.type];
|
|
309
|
-
if (!fields) return `${node.type}|${flags}`;
|
|
310
|
-
const record = node;
|
|
311
|
-
const parts = [`${node.type}|${flags}`];
|
|
312
|
-
for (const field of fields) parts.push(serializeShapeField(field, node, record));
|
|
313
|
-
return parts.join("|");
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Caches the digest per node, keyed by identity. A `WeakMap` so entries die with the node, and so
|
|
317
|
-
* a tree hashed during dedupe planning is not walked again when it is rewritten during streaming.
|
|
318
|
-
* Reuse is safe because a signature depends only on content, and nodes are immutable once created.
|
|
319
|
-
*/
|
|
320
|
-
const signatureCache = /* @__PURE__ */ new WeakMap();
|
|
321
|
-
/**
|
|
322
|
-
* Computes a deterministic, shape-only signature (a content hash) for a schema node. Two schemas
|
|
323
|
-
* share a signature when they are structurally identical, ignoring documentation (`name`, `title`,
|
|
324
|
-
* `description`, `examples`, `default`, `deprecated`) and usage-slot flags (`optional`, `nullish`,
|
|
325
|
-
* `readOnly`, `writeOnly`). `nullable` is kept because it changes the produced type, and `ref`
|
|
326
|
-
* nodes compare by target name, which also terminates on circular shapes.
|
|
327
|
-
*
|
|
328
|
-
* @example Two enums with different descriptions share a signature
|
|
329
|
-
* ```ts
|
|
330
|
-
* signatureOf(createSchema({ type: 'enum', primitive: 'string', enumValues: ['a', 'b'], description: 'x' })) ===
|
|
331
|
-
* signatureOf(createSchema({ type: 'enum', primitive: 'string', enumValues: ['a', 'b'] }))
|
|
332
|
-
* ```
|
|
333
|
-
*/
|
|
334
|
-
function signatureOf(node) {
|
|
335
|
-
const cached = signatureCache.get(node);
|
|
336
|
-
if (cached !== void 0) return cached;
|
|
337
|
-
const signature = (0, node_crypto.hash)("sha256", describeShape(node), "hex");
|
|
338
|
-
signatureCache.set(node, signature);
|
|
339
|
-
return signature;
|
|
340
|
-
}
|
|
341
|
-
//#endregion
|
|
342
87
|
//#region src/factory.ts
|
|
343
|
-
var factory_exports = /* @__PURE__ */
|
|
344
|
-
createArrowFunction: () =>
|
|
345
|
-
createBreak: () =>
|
|
346
|
-
createConst: () =>
|
|
347
|
-
createContent: () =>
|
|
348
|
-
createExport: () =>
|
|
349
|
-
createFile: () =>
|
|
350
|
-
createFunction: () =>
|
|
351
|
-
createFunctionParameter: () =>
|
|
352
|
-
createFunctionParameters: () =>
|
|
353
|
-
createImport: () =>
|
|
354
|
-
createIndexedAccessType: () =>
|
|
355
|
-
createInput: () =>
|
|
356
|
-
createJsx: () =>
|
|
357
|
-
createObjectBindingPattern: () =>
|
|
358
|
-
createOperation: () =>
|
|
359
|
-
createOutput: () =>
|
|
360
|
-
createParameter: () =>
|
|
361
|
-
createProperty: () =>
|
|
362
|
-
createRequestBody: () =>
|
|
363
|
-
createResponse: () =>
|
|
364
|
-
createSchema: () =>
|
|
365
|
-
createSource: () =>
|
|
366
|
-
createText: () =>
|
|
367
|
-
createType: () =>
|
|
368
|
-
createTypeLiteral: () =>
|
|
88
|
+
var factory_exports = /* @__PURE__ */ require_visitor.__exportAll({
|
|
89
|
+
createArrowFunction: () => require_visitor.createArrowFunction,
|
|
90
|
+
createBreak: () => require_visitor.createBreak,
|
|
91
|
+
createConst: () => require_visitor.createConst,
|
|
92
|
+
createContent: () => require_visitor.createContent,
|
|
93
|
+
createExport: () => require_visitor.createExport,
|
|
94
|
+
createFile: () => require_visitor.createFile,
|
|
95
|
+
createFunction: () => require_visitor.createFunction,
|
|
96
|
+
createFunctionParameter: () => require_visitor.createFunctionParameter,
|
|
97
|
+
createFunctionParameters: () => require_visitor.createFunctionParameters,
|
|
98
|
+
createImport: () => require_visitor.createImport,
|
|
99
|
+
createIndexedAccessType: () => require_visitor.createIndexedAccessType,
|
|
100
|
+
createInput: () => require_visitor.createInput,
|
|
101
|
+
createJsx: () => require_visitor.createJsx,
|
|
102
|
+
createObjectBindingPattern: () => require_visitor.createObjectBindingPattern,
|
|
103
|
+
createOperation: () => require_visitor.createOperation,
|
|
104
|
+
createOutput: () => require_visitor.createOutput,
|
|
105
|
+
createParameter: () => require_visitor.createParameter,
|
|
106
|
+
createProperty: () => require_visitor.createProperty,
|
|
107
|
+
createRequestBody: () => require_visitor.createRequestBody,
|
|
108
|
+
createResponse: () => require_visitor.createResponse,
|
|
109
|
+
createSchema: () => require_visitor.createSchema,
|
|
110
|
+
createSource: () => require_visitor.createSource,
|
|
111
|
+
createText: () => require_visitor.createText,
|
|
112
|
+
createType: () => require_visitor.createType,
|
|
113
|
+
createTypeLiteral: () => require_visitor.createTypeLiteral,
|
|
369
114
|
update: () => update
|
|
370
115
|
});
|
|
371
116
|
/**
|
|
@@ -393,101 +138,99 @@ function update(node, changes) {
|
|
|
393
138
|
}
|
|
394
139
|
//#endregion
|
|
395
140
|
//#region src/exports.ts
|
|
396
|
-
var exports_exports = /* @__PURE__ */
|
|
141
|
+
var exports_exports = /* @__PURE__ */ require_visitor.__exportAll({
|
|
397
142
|
applyMacros: () => require_defineMacro.applyMacros,
|
|
398
|
-
arrowFunctionDef: () =>
|
|
399
|
-
breakDef: () =>
|
|
400
|
-
collect: () =>
|
|
143
|
+
arrowFunctionDef: () => require_visitor.arrowFunctionDef,
|
|
144
|
+
breakDef: () => require_visitor.breakDef,
|
|
145
|
+
collect: () => require_visitor.collect,
|
|
401
146
|
composeMacros: () => require_defineMacro.composeMacros,
|
|
402
|
-
constDef: () =>
|
|
403
|
-
contentDef: () =>
|
|
147
|
+
constDef: () => require_visitor.constDef,
|
|
148
|
+
contentDef: () => require_visitor.contentDef,
|
|
404
149
|
createPrinter: () => createPrinter,
|
|
405
150
|
defineDialect: () => defineDialect,
|
|
406
151
|
defineMacro: () => require_defineMacro.defineMacro,
|
|
407
|
-
defineNode: () =>
|
|
408
|
-
exportDef: () =>
|
|
152
|
+
defineNode: () => require_visitor.defineNode,
|
|
153
|
+
exportDef: () => require_visitor.exportDef,
|
|
409
154
|
factory: () => factory_exports,
|
|
410
|
-
fileDef: () =>
|
|
411
|
-
functionDef: () =>
|
|
412
|
-
functionParameterDef: () =>
|
|
413
|
-
functionParametersDef: () =>
|
|
414
|
-
importDef: () =>
|
|
415
|
-
indexedAccessTypeDef: () =>
|
|
416
|
-
inputDef: () =>
|
|
417
|
-
isHttpOperationNode: () =>
|
|
418
|
-
jsxDef: () =>
|
|
419
|
-
narrowSchema: () =>
|
|
420
|
-
nodeDefs: () =>
|
|
421
|
-
objectBindingPatternDef: () =>
|
|
422
|
-
operationDef: () =>
|
|
423
|
-
optionality: () =>
|
|
424
|
-
outputDef: () =>
|
|
425
|
-
parameterDef: () =>
|
|
426
|
-
propertyDef: () =>
|
|
427
|
-
requestBodyDef: () =>
|
|
428
|
-
responseDef: () =>
|
|
429
|
-
schemaDef: () =>
|
|
430
|
-
schemaTypes: () =>
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
walk: () => require_refs.walk
|
|
155
|
+
fileDef: () => require_visitor.fileDef,
|
|
156
|
+
functionDef: () => require_visitor.functionDef,
|
|
157
|
+
functionParameterDef: () => require_visitor.functionParameterDef,
|
|
158
|
+
functionParametersDef: () => require_visitor.functionParametersDef,
|
|
159
|
+
importDef: () => require_visitor.importDef,
|
|
160
|
+
indexedAccessTypeDef: () => require_visitor.indexedAccessTypeDef,
|
|
161
|
+
inputDef: () => require_visitor.inputDef,
|
|
162
|
+
isHttpOperationNode: () => require_visitor.isHttpOperationNode,
|
|
163
|
+
jsxDef: () => require_visitor.jsxDef,
|
|
164
|
+
narrowSchema: () => require_visitor.narrowSchema,
|
|
165
|
+
nodeDefs: () => require_visitor.nodeDefs,
|
|
166
|
+
objectBindingPatternDef: () => require_visitor.objectBindingPatternDef,
|
|
167
|
+
operationDef: () => require_visitor.operationDef,
|
|
168
|
+
optionality: () => require_visitor.optionality,
|
|
169
|
+
outputDef: () => require_visitor.outputDef,
|
|
170
|
+
parameterDef: () => require_visitor.parameterDef,
|
|
171
|
+
propertyDef: () => require_visitor.propertyDef,
|
|
172
|
+
requestBodyDef: () => require_visitor.requestBodyDef,
|
|
173
|
+
responseDef: () => require_visitor.responseDef,
|
|
174
|
+
schemaDef: () => require_visitor.schemaDef,
|
|
175
|
+
schemaTypes: () => require_visitor.schemaTypes,
|
|
176
|
+
sourceDef: () => require_visitor.sourceDef,
|
|
177
|
+
textDef: () => require_visitor.textDef,
|
|
178
|
+
transform: () => require_visitor.transform,
|
|
179
|
+
typeDef: () => require_visitor.typeDef,
|
|
180
|
+
typeLiteralDef: () => require_visitor.typeLiteralDef,
|
|
181
|
+
walk: () => require_visitor.walk
|
|
438
182
|
});
|
|
439
183
|
//#endregion
|
|
440
184
|
exports.applyMacros = require_defineMacro.applyMacros;
|
|
441
|
-
exports.arrowFunctionDef =
|
|
185
|
+
exports.arrowFunctionDef = require_visitor.arrowFunctionDef;
|
|
442
186
|
Object.defineProperty(exports, "ast", {
|
|
443
187
|
enumerable: true,
|
|
444
188
|
get: function() {
|
|
445
189
|
return exports_exports;
|
|
446
190
|
}
|
|
447
191
|
});
|
|
448
|
-
exports.breakDef =
|
|
449
|
-
exports.collect =
|
|
192
|
+
exports.breakDef = require_visitor.breakDef;
|
|
193
|
+
exports.collect = require_visitor.collect;
|
|
450
194
|
exports.composeMacros = require_defineMacro.composeMacros;
|
|
451
|
-
exports.constDef =
|
|
452
|
-
exports.contentDef =
|
|
195
|
+
exports.constDef = require_visitor.constDef;
|
|
196
|
+
exports.contentDef = require_visitor.contentDef;
|
|
453
197
|
exports.createPrinter = createPrinter;
|
|
454
198
|
exports.defineDialect = defineDialect;
|
|
455
199
|
exports.defineMacro = require_defineMacro.defineMacro;
|
|
456
|
-
exports.defineNode =
|
|
457
|
-
exports.exportDef =
|
|
200
|
+
exports.defineNode = require_visitor.defineNode;
|
|
201
|
+
exports.exportDef = require_visitor.exportDef;
|
|
458
202
|
Object.defineProperty(exports, "factory", {
|
|
459
203
|
enumerable: true,
|
|
460
204
|
get: function() {
|
|
461
205
|
return factory_exports;
|
|
462
206
|
}
|
|
463
207
|
});
|
|
464
|
-
exports.fileDef =
|
|
465
|
-
exports.functionDef =
|
|
466
|
-
exports.functionParameterDef =
|
|
467
|
-
exports.functionParametersDef =
|
|
468
|
-
exports.importDef =
|
|
469
|
-
exports.indexedAccessTypeDef =
|
|
470
|
-
exports.inputDef =
|
|
471
|
-
exports.isHttpOperationNode =
|
|
472
|
-
exports.jsxDef =
|
|
473
|
-
exports.narrowSchema =
|
|
474
|
-
exports.nodeDefs =
|
|
475
|
-
exports.objectBindingPatternDef =
|
|
476
|
-
exports.operationDef =
|
|
477
|
-
exports.optionality =
|
|
478
|
-
exports.outputDef =
|
|
479
|
-
exports.parameterDef =
|
|
480
|
-
exports.propertyDef =
|
|
481
|
-
exports.requestBodyDef =
|
|
482
|
-
exports.responseDef =
|
|
483
|
-
exports.schemaDef =
|
|
484
|
-
exports.schemaTypes =
|
|
485
|
-
exports.
|
|
486
|
-
exports.
|
|
487
|
-
exports.
|
|
488
|
-
exports.
|
|
489
|
-
exports.
|
|
490
|
-
exports.
|
|
491
|
-
exports.walk = require_refs.walk;
|
|
208
|
+
exports.fileDef = require_visitor.fileDef;
|
|
209
|
+
exports.functionDef = require_visitor.functionDef;
|
|
210
|
+
exports.functionParameterDef = require_visitor.functionParameterDef;
|
|
211
|
+
exports.functionParametersDef = require_visitor.functionParametersDef;
|
|
212
|
+
exports.importDef = require_visitor.importDef;
|
|
213
|
+
exports.indexedAccessTypeDef = require_visitor.indexedAccessTypeDef;
|
|
214
|
+
exports.inputDef = require_visitor.inputDef;
|
|
215
|
+
exports.isHttpOperationNode = require_visitor.isHttpOperationNode;
|
|
216
|
+
exports.jsxDef = require_visitor.jsxDef;
|
|
217
|
+
exports.narrowSchema = require_visitor.narrowSchema;
|
|
218
|
+
exports.nodeDefs = require_visitor.nodeDefs;
|
|
219
|
+
exports.objectBindingPatternDef = require_visitor.objectBindingPatternDef;
|
|
220
|
+
exports.operationDef = require_visitor.operationDef;
|
|
221
|
+
exports.optionality = require_visitor.optionality;
|
|
222
|
+
exports.outputDef = require_visitor.outputDef;
|
|
223
|
+
exports.parameterDef = require_visitor.parameterDef;
|
|
224
|
+
exports.propertyDef = require_visitor.propertyDef;
|
|
225
|
+
exports.requestBodyDef = require_visitor.requestBodyDef;
|
|
226
|
+
exports.responseDef = require_visitor.responseDef;
|
|
227
|
+
exports.schemaDef = require_visitor.schemaDef;
|
|
228
|
+
exports.schemaTypes = require_visitor.schemaTypes;
|
|
229
|
+
exports.sourceDef = require_visitor.sourceDef;
|
|
230
|
+
exports.textDef = require_visitor.textDef;
|
|
231
|
+
exports.transform = require_visitor.transform;
|
|
232
|
+
exports.typeDef = require_visitor.typeDef;
|
|
233
|
+
exports.typeLiteralDef = require_visitor.typeLiteralDef;
|
|
234
|
+
exports.walk = require_visitor.walk;
|
|
492
235
|
|
|
493
236
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["extractRefName","obj"],"sources":["../src/defineDialect.ts","../src/createPrinter.ts","../src/signature.ts","../src/factory.ts","../src/exports.ts"],"sourcesContent":["import type { Node } from './nodes/index.ts'\n\n/**\n * The spec-specific questions a schema parser answers while turning a source document into Kubb\n * AST nodes. The rest of the pipeline is generic JSON Schema, so this is the one seam where\n * OpenAPI, AsyncAPI, and plain JSON Schema differ.\n */\nexport type SchemaDialect<TSchema = unknown, TRef = TSchema, TDiscriminated = TSchema, TDocument = unknown> = {\n /**\n * Whether the schema is nullable.\n */\n isNullable(schema?: TSchema): boolean\n /**\n * Whether the value is a `$ref` pointer.\n */\n isReference(value?: unknown): value is TRef\n /**\n * Whether the schema carries a discriminator for polymorphism.\n */\n isDiscriminator(value?: unknown): value is TDiscriminated\n /**\n * Whether the schema is binary data, converted to a `blob` node.\n */\n isBinary(schema: TSchema): boolean\n /**\n * Resolves a local `$ref` against the document, or nullish when it cannot.\n */\n resolveRef<TResolved>(document: TDocument, ref: string): TResolved | null | undefined\n}\n\n/**\n * How a dialect collapses structurally identical schemas into shared definitions. The contract is\n * generic over the plan and context types, which the adapter supplies. The mechanics live in the\n * adapter, not here, so `@kubb/ast` carries no dedupe logic. The returned plan owns the rewriting\n * behavior, so callers interact with one object.\n */\nexport type Dedupe<TPlan = unknown, TContext = unknown> = {\n /**\n * Scans a forest of nodes and produces a plan describing which shapes to share.\n */\n plan(roots: ReadonlyArray<Node>, context: TContext): TPlan\n}\n\n/**\n * A spec adapter's dialect. `name` identifies it in logs and diagnostics, `schema` holds the\n * spec-specific schema questions the parser answers, and `dedupe` is the schema-sharing seam.\n */\nexport type Dialect<TSchema = unknown, TRef = TSchema, TDiscriminated = TSchema, TDocument = unknown, TDedupe extends Dedupe = Dedupe> = {\n /**\n * Identifies the dialect in logs and diagnostics.\n */\n name: string\n /**\n * The spec-specific schema behavior. See {@link SchemaDialect}.\n */\n schema: SchemaDialect<TSchema, TRef, TDiscriminated, TDocument>\n /**\n * The schema-sharing behavior. See {@link Dedupe}.\n */\n dedupe: TDedupe\n}\n\n/**\n * Types a {@link Dialect} for an adapter. Adds no runtime behavior and only pins the\n * dialect's type for inference.\n *\n * @example\n * ```ts\n * export const oasDialect = defineDialect({\n * name: 'oas',\n * schema: {\n * isNullable,\n * isReference,\n * isDiscriminator,\n * isBinary: (schema) => schema.type === 'string' && schema.contentMediaType === 'application/octet-stream',\n * resolveRef,\n * },\n * dedupe: { plan },\n * })\n * ```\n */\nexport function defineDialect<TSchema, TRef, TDiscriminated, TDocument, TDedupe extends Dedupe>(\n dialect: Dialect<TSchema, TRef, TDiscriminated, TDocument, TDedupe>,\n): Dialect<TSchema, TRef, TDiscriminated, TDocument, TDedupe> {\n return dialect\n}\n","import type { SchemaNode, SchemaNodeByType, SchemaType } from './nodes/index.ts'\n\n/**\n * Runtime context passed as `this` to printer handlers.\n *\n * `this.transform` dispatches to node-level handlers from `nodes`.\n *\n * @example\n * ```ts\n * const context: PrinterHandlerContext<string, {}> = {\n * options: {},\n * transform: () => 'value',\n * }\n * ```\n */\ntype PrinterHandlerContext<TOutput, TOptions extends object> = {\n /**\n * Recursively transform a nested `SchemaNode` to `TOutput` using the node-level handlers.\n * Use `this.transform` inside `nodes` handlers and inside the `print` override.\n */\n transform: (node: SchemaNode) => TOutput | null\n /**\n * Options for this printer instance.\n */\n options: TOptions\n}\n\n/**\n * Handler for one schema node type.\n *\n * Use a regular function (not an arrow function) if you need `this`.\n *\n * @example\n * ```ts\n * const handler: PrinterHandler<string, {}, 'string'> = function () {\n * return 'string'\n * }\n * ```\n */\ntype PrinterHandler<TOutput, TOptions extends object, T extends SchemaType = SchemaType> = (\n this: PrinterHandlerContext<TOutput, TOptions>,\n node: SchemaNodeByType[T],\n) => TOutput | null\n\n/**\n * Partial map of per-node-type handler overrides for a printer.\n *\n * Each key is a `SchemaType` string (e.g. `'date'`, `'string'`).\n * Supply only the handlers you want to replace. The printer's built-in\n * defaults fill in the rest.\n *\n * @example\n * ```ts\n * pluginZod({\n * printer: {\n * nodes: {\n * date(): string {\n * return 'z.string().date()'\n * },\n * } satisfies PrinterPartial<string, PrinterZodOptions>,\n * },\n * })\n * ```\n */\nexport type PrinterPartial<TOutput, TOptions extends object> = Partial<{\n [K in SchemaType]: PrinterHandler<TOutput, TOptions, K>\n}>\n\n/**\n * Generic shape used by `definePrinter`.\n *\n * - `TName` unique string identifier (e.g. `'zod'`, `'ts'`)\n * - `TOptions` options passed to and stored on the printer instance\n * - `TOutput` the type emitted by node handlers\n * - `TPrintOutput` type returned by public `print` (defaults to `TOutput`)\n *\n * @example\n * ```ts\n * type MyPrinter = PrinterFactoryOptions<'my', { strict: boolean }, string>\n * ```\n */\nexport type PrinterFactoryOptions<TName extends string = string, TOptions extends object = object, TOutput = unknown, TPrintOutput = TOutput> = {\n name: TName\n options: TOptions\n output: TOutput\n printOutput: TPrintOutput\n}\n\n/**\n * Printer instance returned by a printer factory.\n *\n * @example\n * ```ts\n * const printer = definePrinter((options: {}) => ({ name: 'x', options, nodes: {} }))({})\n * ```\n */\nexport type Printer<T extends PrinterFactoryOptions = PrinterFactoryOptions> = {\n /**\n * Unique identifier supplied at creation time.\n */\n name: T['name']\n /**\n * Options for this printer instance.\n */\n options: T['options']\n /**\n * Node-level dispatcher, converts a `SchemaNode` directly to `TOutput` using the `nodes` handlers.\n * Always dispatches through the `nodes` map. Never calls the `print` override.\n * Reach for it when you need the raw output (e.g. `ts.TypeNode`) without declaration wrapping.\n */\n transform: (node: SchemaNode) => T['output'] | null\n /**\n * Public printer. If the builder provides a root-level `print`, this calls that\n * higher-level function (which may produce full declarations).\n * Otherwise, falls back to the node-level dispatcher.\n */\n print: (node: SchemaNode) => T['printOutput'] | null\n}\n\n/**\n * Builder function passed to `definePrinter`.\n *\n * It receives resolved options and returns:\n * - `name`\n * - `options`\n * - `nodes` handlers\n * - optional top-level `print` override\n *\n * @example\n * ```ts\n * const build = (options: {}) => ({ name: 'x' as const, options, nodes: {} })\n * ```\n */\ntype PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) => {\n name: T['name']\n /**\n * Options to store on the printer.\n */\n options: T['options']\n nodes: Partial<{\n [K in SchemaType]: PrinterHandler<T['output'], T['options'], K>\n }>\n /**\n * Optional root-level print override. When provided, becomes the public `printer.print`.\n * Use `this.transform(node)` inside this function to dispatch to the node-level handlers (`nodes`),\n * not the override itself, so recursion is safe.\n */\n print?: (this: PrinterHandlerContext<T['output'], T['options']>, node: SchemaNode) => T['printOutput'] | null\n}\n/**\n * Creates a schema printer: a function that takes a `SchemaNode` and emits\n * code in your target language. Each plugin that produces code from schemas\n * (TypeScript types, Zod schemas, Faker factories) ships a printer built\n * with this helper.\n *\n * The builder receives resolved options and returns:\n *\n * - `name` unique identifier for the printer.\n * - `options` stored on the returned printer instance.\n * - `nodes` map of `SchemaType` → handler. Handlers return the rendered\n * output (a string, a TypeScript AST node, ...) for that schema type.\n * - `print` (optional), top-level override exposed as `printer.print`.\n * Use `this.transform(node)` inside it to dispatch to `nodes` recursively.\n *\n * Without a `print` override, `printer.print` falls back to `printer.transform`\n * (the node-level dispatcher).\n *\n * @example Tiny Zod printer\n * ```ts\n * import { createPrinter, type PrinterFactoryOptions } from '@kubb/ast'\n *\n * type PrinterZod = PrinterFactoryOptions<'zod', { strict?: boolean }, string>\n *\n * export const zodPrinter = createPrinter<PrinterZod>((options) => ({\n * name: 'zod',\n * options: { strict: options.strict ?? true },\n * nodes: {\n * string: () => 'z.string()',\n * object(node) {\n * const props = node.properties\n * .map((p) => `${p.name}: ${this.transform(p.schema)}`)\n * .join(', ')\n * return `z.object({ ${props} })`\n * },\n * },\n * }))\n * ```\n */\nexport function createPrinter<T extends PrinterFactoryOptions = PrinterFactoryOptions>(build: PrinterBuilder<T>): (options?: T['options']) => Printer<T> {\n return (options) => {\n const { name, options: resolvedOptions, nodes, print: printOverride } = build(options ?? ({} as T['options']))\n\n const context = {\n options: resolvedOptions,\n transform: (node: SchemaNode): T['output'] | null => {\n const handler = nodes[node.type]\n if (!handler) return null\n\n return (handler as (this: typeof context, node: SchemaNode) => T['output'] | null).call(context, node)\n },\n }\n\n return {\n name,\n options: resolvedOptions,\n transform: context.transform,\n print: (printOverride ? printOverride.bind(context) : context.transform) as (node: SchemaNode) => T['printOutput'] | null,\n }\n }\n}\n","import { hash } from 'node:crypto'\nimport type { SchemaNode } from './nodes/index.ts'\nimport { extractRefName } from './utils/index.ts'\n\n/**\n * The flags shared by every node kind that affect its type: `primitive`, `format`, `nullable`.\n */\nfunction flagsDescriptor(node: SchemaNode): string {\n return `${node.primitive ?? ''};${node.format ?? ''};${node.nullable ? 1 : 0}`\n}\n\nfunction refTargetName(node: Extract<SchemaNode, { type: 'ref' }>): string {\n if (node.ref) return extractRefName(node.ref)\n return node.name ?? ''\n}\n\ntype ScalarField = { kind: 'scalar'; key: string; prefix: string }\ntype BoolField = { kind: 'bool'; key: string; prefix: string }\ntype ChildField = { kind: 'child'; key: string; prefix: string }\ntype ChildrenField = { kind: 'children'; key: string; prefix: string }\ntype ObjectPropsField = { kind: 'objectProps' }\ntype AdditionalPropsField = { kind: 'additionalProps' }\ntype PatternPropsField = { kind: 'patternProps' }\ntype EnumValuesField = { kind: 'enumValues' }\ntype RefTargetField = { kind: 'refTarget' }\n\ntype ShapeField =\n | ScalarField\n | BoolField\n | ChildField\n | ChildrenField\n | ObjectPropsField\n | AdditionalPropsField\n | PatternPropsField\n | EnumValuesField\n | RefTargetField\n\nconst arrayTupleFields: ReadonlyArray<ShapeField> = [\n { kind: 'children', key: 'items', prefix: 'i' },\n { kind: 'child', key: 'rest', prefix: 'r' },\n { kind: 'scalar', key: 'min', prefix: 'mn' },\n { kind: 'scalar', key: 'max', prefix: 'mx' },\n { kind: 'bool', key: 'unique', prefix: 'u' },\n]\n\nconst numericFields: ReadonlyArray<ShapeField> = [\n { kind: 'scalar', key: 'min', prefix: 'mn' },\n { kind: 'scalar', key: 'max', prefix: 'mx' },\n { kind: 'scalar', key: 'exclusiveMinimum', prefix: 'emn' },\n { kind: 'scalar', key: 'exclusiveMaximum', prefix: 'emx' },\n { kind: 'scalar', key: 'multipleOf', prefix: 'mo' },\n]\n\nconst rangeFields: ReadonlyArray<ShapeField> = [\n { kind: 'scalar', key: 'min', prefix: 'mn' },\n { kind: 'scalar', key: 'max', prefix: 'mx' },\n]\n\n/**\n * Maps each node `type` to its ordered shape-contributing fields. Types absent from the map\n * (boolean, null, any, and other scalars) fall back to `${type}|${flags}`.\n */\nconst SHAPE_KEYS: Partial<Record<SchemaNode['type'], ReadonlyArray<ShapeField>>> = {\n object: [\n { kind: 'objectProps' },\n { kind: 'additionalProps' },\n { kind: 'patternProps' },\n { kind: 'scalar', key: 'minProperties', prefix: 'mn' },\n { kind: 'scalar', key: 'maxProperties', prefix: 'mx' },\n ],\n array: arrayTupleFields,\n tuple: arrayTupleFields,\n union: [\n { kind: 'scalar', key: 'strategy', prefix: 's' },\n { kind: 'scalar', key: 'discriminatorPropertyName', prefix: 'd' },\n { kind: 'children', key: 'members', prefix: 'm' },\n ],\n intersection: [{ kind: 'children', key: 'members', prefix: 'm' }],\n enum: [{ kind: 'enumValues' }],\n ref: [{ kind: 'refTarget' }],\n string: [\n { kind: 'scalar', key: 'min', prefix: 'mn' },\n { kind: 'scalar', key: 'max', prefix: 'mx' },\n { kind: 'scalar', key: 'pattern', prefix: 'pt' },\n ],\n number: numericFields,\n integer: numericFields,\n bigint: numericFields,\n url: [\n { kind: 'scalar', key: 'path', prefix: 'path' },\n { kind: 'scalar', key: 'min', prefix: 'mn' },\n { kind: 'scalar', key: 'max', prefix: 'mx' },\n ],\n uuid: rangeFields,\n email: rangeFields,\n datetime: [\n { kind: 'bool', key: 'offset', prefix: 'o' },\n { kind: 'bool', key: 'local', prefix: 'l' },\n ],\n date: [{ kind: 'scalar', key: 'representation', prefix: 'rep' }],\n time: [{ kind: 'scalar', key: 'representation', prefix: 'rep' }],\n}\n\nfunction serializeShapeField(field: ShapeField, node: SchemaNode, record: Record<string, unknown>): string {\n switch (field.kind) {\n case 'scalar':\n return `${field.prefix}:${record[field.key] ?? ''}`\n case 'bool':\n return `${field.prefix}:${record[field.key] ? 1 : 0}`\n case 'child': {\n const child = record[field.key] as SchemaNode | undefined\n return `${field.prefix}:${child ? signatureOf(child) : ''}`\n }\n case 'children': {\n const children = (record[field.key] as Array<SchemaNode> | undefined) ?? []\n return `${field.prefix}[${children.map((c) => signatureOf(c)).join(',')}]`\n }\n case 'objectProps': {\n const obj = node as Extract<SchemaNode, { type: 'object' }>\n const props = (obj.properties ?? []).map((prop) => `${prop.name}${prop.required ? '!' : '?'}${signatureOf(prop.schema)}`).join(',')\n return `p[${props}]`\n }\n case 'additionalProps': {\n const obj = node as Extract<SchemaNode, { type: 'object' }>\n if (typeof obj.additionalProperties === 'boolean') return `ab:${obj.additionalProperties}`\n if (obj.additionalProperties) return `as:${signatureOf(obj.additionalProperties)}`\n return ''\n }\n case 'patternProps': {\n const obj = node as Extract<SchemaNode, { type: 'object' }>\n const pattern = obj.patternProperties\n ? Object.keys(obj.patternProperties)\n .sort()\n .map((key) => `${key}=${signatureOf(obj.patternProperties![key]!)}`)\n .join(',')\n : ''\n return `pp[${pattern}]`\n }\n case 'enumValues': {\n const en = node as Extract<SchemaNode, { type: 'enum' }>\n let values = ''\n if (en.namedEnumValues?.length) {\n values = en.namedEnumValues.map((entry) => `${entry.name}=${entry.primitive}:${String(entry.value)}`).join(',')\n } else if (en.enumValues?.length) {\n values = en.enumValues.map((value) => `${value === null ? 'null' : typeof value}:${String(value)}`).join(',')\n }\n return `v[${values}]`\n }\n case 'refTarget': {\n return `->${refTargetName(node as Extract<SchemaNode, { type: 'ref' }>)}`\n }\n }\n}\n\n/**\n * Builds the local shape descriptor that {@link signatureOf} hashes: the node's kind, flags,\n * constraints, and its children's signatures.\n */\nfunction describeShape(node: SchemaNode): string {\n const flags = flagsDescriptor(node)\n const fields = SHAPE_KEYS[node.type]\n if (!fields) return `${node.type}|${flags}`\n\n const record = node as unknown as Record<string, unknown>\n const parts: Array<string> = [`${node.type}|${flags}`]\n for (const field of fields) {\n parts.push(serializeShapeField(field, node, record))\n }\n return parts.join('|')\n}\n\n/**\n * Caches the digest per node, keyed by identity. A `WeakMap` so entries die with the node, and so\n * a tree hashed during dedupe planning is not walked again when it is rewritten during streaming.\n * Reuse is safe because a signature depends only on content, and nodes are immutable once created.\n */\nconst signatureCache = new WeakMap<SchemaNode, string>()\n\n/**\n * Computes a deterministic, shape-only signature (a content hash) for a schema node. Two schemas\n * share a signature when they are structurally identical, ignoring documentation (`name`, `title`,\n * `description`, `examples`, `default`, `deprecated`) and usage-slot flags (`optional`, `nullish`,\n * `readOnly`, `writeOnly`). `nullable` is kept because it changes the produced type, and `ref`\n * nodes compare by target name, which also terminates on circular shapes.\n *\n * @example Two enums with different descriptions share a signature\n * ```ts\n * signatureOf(createSchema({ type: 'enum', primitive: 'string', enumValues: ['a', 'b'], description: 'x' })) ===\n * signatureOf(createSchema({ type: 'enum', primitive: 'string', enumValues: ['a', 'b'] }))\n * ```\n */\nexport function signatureOf(node: SchemaNode): string {\n const cached = signatureCache.get(node)\n if (cached !== undefined) return cached\n const signature = hash('sha256', describeShape(node), 'hex')\n signatureCache.set(node, signature)\n\n return signature\n}\n\n/**\n * Returns `true` when two schema nodes are structurally identical under shape-only equality,\n * meaning they produce the same TypeScript type.\n */\nexport function isSchemaEqual(a: SchemaNode, b: SchemaNode): boolean {\n return signatureOf(a) === signatureOf(b)\n}\n","import type { Node } from './nodes/index.ts'\n\n// Node constructors, grouped under the `factory` namespace the way the TypeScript compiler exposes\n// `ts.factory.createX`. Aggregating them here lets `export * as factory from './factory.ts'` in the\n// barrel surface every `createX` alongside the `createFile`/`update` helpers from a single module.\nexport { createArrowFunction, createBreak, createConst, createFunction, createJsx, createText, createType } from './nodes/code.ts'\nexport { createContent } from './nodes/content.ts'\nexport { createExport, createFile, createImport, createSource } from './nodes/file.ts'\nexport type { UserFileNode } from './nodes/file.ts'\nexport { createFunctionParameter, createFunctionParameters, createIndexedAccessType, createObjectBindingPattern, createTypeLiteral } from './nodes/function.ts'\nexport { createInput } from './nodes/input.ts'\nexport { createOperation } from './nodes/operation.ts'\nexport { createOutput } from './nodes/output.ts'\nexport { createParameter } from './nodes/parameter.ts'\nexport { createProperty } from './nodes/property.ts'\nexport { createRequestBody } from './nodes/requestBody.ts'\nexport { createResponse } from './nodes/response.ts'\nexport { createSchema } from './nodes/schema.ts'\n\n/**\n * Identity-preserving node update: returns `node` unchanged when every field in\n * `changes` already equals (by reference) the current value, otherwise a new node\n * with the changes applied.\n *\n * Mirrors the TypeScript compiler's `factory.updateX` contract. Pair it with the\n * structural sharing in {@link transform} so a no-op rewrite does not allocate and\n * downstream passes can detect \"nothing changed\" by identity. Comparison is shallow,\n * so a structurally equal but newly allocated array or object counts as a change.\n *\n * @example\n * ```ts\n * update(node, { name: node.name }) // -> same `node` reference\n * update(node, { name: 'renamed' }) // -> new node, `name` replaced\n * ```\n */\nexport function update<T extends Node>(node: T, changes: Partial<T>): T {\n for (const key in changes) {\n if (changes[key] !== node[key as keyof T]) {\n return { ...node, ...changes }\n }\n }\n\n return node\n}\n","export { schemaTypes } from './constants.ts'\nexport { defineDialect } from './defineDialect.ts'\nexport { isHttpOperationNode, narrowSchema } from './guards.ts'\nexport { applyMacros, composeMacros, defineMacro } from './defineMacro.ts'\nexport { defineNode } from './defineNode.ts'\nexport { optionality } from './optionality.ts'\nexport { createPrinter } from './createPrinter.ts'\nexport { signatureOf } from './signature.ts'\nexport { collect, transform, walk } from './visitor.ts'\n\nexport * as factory from './factory.ts'\nexport * from './registry.ts'\nexport type * from './types.ts'\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/defineDialect.ts","../src/createPrinter.ts","../src/factory.ts","../src/exports.ts"],"sourcesContent":["/**\n * The spec-specific questions a schema parser answers while turning a source document into Kubb\n * AST nodes. The rest of the pipeline is generic JSON Schema, so this is the one seam where\n * OpenAPI, AsyncAPI, and plain JSON Schema differ.\n */\nexport type SchemaDialect<TSchema = unknown, TRef = TSchema, TDiscriminated = TSchema, TDocument = unknown> = {\n /**\n * Whether the schema is nullable.\n */\n isNullable(schema?: TSchema): boolean\n /**\n * Whether the value is a `$ref` pointer.\n */\n isReference(value?: unknown): value is TRef\n /**\n * Whether the schema carries a discriminator for polymorphism.\n */\n isDiscriminator(value?: unknown): value is TDiscriminated\n /**\n * Whether the schema is binary data, converted to a `blob` node.\n */\n isBinary(schema: TSchema): boolean\n /**\n * Resolves a local `$ref` against the document, or nullish when it cannot.\n */\n resolveRef<TResolved>(document: TDocument, ref: string): TResolved | null | undefined\n}\n\n/**\n * A spec adapter's dialect. `name` identifies it in logs and diagnostics, and `schema` holds the\n * spec-specific schema questions the parser answers.\n */\nexport type Dialect<TSchema = unknown, TRef = TSchema, TDiscriminated = TSchema, TDocument = unknown> = {\n /**\n * Identifies the dialect in logs and diagnostics.\n */\n name: string\n /**\n * The spec-specific schema behavior. See {@link SchemaDialect}.\n */\n schema: SchemaDialect<TSchema, TRef, TDiscriminated, TDocument>\n}\n\n/**\n * Types a {@link Dialect} for an adapter. Adds no runtime behavior and only pins the\n * dialect's type for inference.\n *\n * @example\n * ```ts\n * export const oasDialect = defineDialect({\n * name: 'oas',\n * schema: {\n * isNullable,\n * isReference,\n * isDiscriminator,\n * isBinary: (schema) => schema.type === 'string' && schema.contentMediaType === 'application/octet-stream',\n * resolveRef,\n * },\n * })\n * ```\n */\nexport function defineDialect<TSchema, TRef, TDiscriminated, TDocument>(\n dialect: Dialect<TSchema, TRef, TDiscriminated, TDocument>,\n): Dialect<TSchema, TRef, TDiscriminated, TDocument> {\n return dialect\n}\n","import type { SchemaNode, SchemaNodeByType, SchemaType } from './nodes/index.ts'\n\n/**\n * Runtime context passed as `this` to printer handlers.\n *\n * `this.transform` dispatches to node-level handlers from `nodes`.\n *\n * @example\n * ```ts\n * const context: PrinterHandlerContext<string, {}> = {\n * options: {},\n * transform: () => 'value',\n * }\n * ```\n */\ntype PrinterHandlerContext<TOutput, TOptions extends object> = {\n /**\n * Recursively transform a nested `SchemaNode` to `TOutput` using the node-level handlers.\n * Use `this.transform` inside `nodes` handlers and inside the `print` override.\n */\n transform: (node: SchemaNode) => TOutput | null\n /**\n * Options for this printer instance.\n */\n options: TOptions\n}\n\n/**\n * Handler for one schema node type.\n *\n * Use a regular function (not an arrow function) if you need `this`.\n *\n * @example\n * ```ts\n * const handler: PrinterHandler<string, {}, 'string'> = function () {\n * return 'string'\n * }\n * ```\n */\ntype PrinterHandler<TOutput, TOptions extends object, T extends SchemaType = SchemaType> = (\n this: PrinterHandlerContext<TOutput, TOptions>,\n node: SchemaNodeByType[T],\n) => TOutput | null\n\n/**\n * Partial map of per-node-type handler overrides for a printer.\n *\n * Each key is a `SchemaType` string (e.g. `'date'`, `'string'`).\n * Supply only the handlers you want to replace. The printer's built-in\n * defaults fill in the rest.\n *\n * @example\n * ```ts\n * pluginZod({\n * printer: {\n * nodes: {\n * date(): string {\n * return 'z.string().date()'\n * },\n * } satisfies PrinterPartial<string, PrinterZodOptions>,\n * },\n * })\n * ```\n */\nexport type PrinterPartial<TOutput, TOptions extends object> = Partial<{\n [K in SchemaType]: PrinterHandler<TOutput, TOptions, K>\n}>\n\n/**\n * Generic shape used by `definePrinter`.\n *\n * - `TName` unique string identifier (e.g. `'zod'`, `'ts'`)\n * - `TOptions` options passed to and stored on the printer instance\n * - `TOutput` the type emitted by node handlers\n * - `TPrintOutput` type returned by public `print` (defaults to `TOutput`)\n *\n * @example\n * ```ts\n * type MyPrinter = PrinterFactoryOptions<'my', { strict: boolean }, string>\n * ```\n */\nexport type PrinterFactoryOptions<TName extends string = string, TOptions extends object = object, TOutput = unknown, TPrintOutput = TOutput> = {\n name: TName\n options: TOptions\n output: TOutput\n printOutput: TPrintOutput\n}\n\n/**\n * Printer instance returned by a printer factory.\n *\n * @example\n * ```ts\n * const printer = definePrinter((options: {}) => ({ name: 'x', options, nodes: {} }))({})\n * ```\n */\nexport type Printer<T extends PrinterFactoryOptions = PrinterFactoryOptions> = {\n /**\n * Unique identifier supplied at creation time.\n */\n name: T['name']\n /**\n * Options for this printer instance.\n */\n options: T['options']\n /**\n * Node-level dispatcher, converts a `SchemaNode` directly to `TOutput` using the `nodes` handlers.\n * Always dispatches through the `nodes` map. Never calls the `print` override.\n * Reach for it when you need the raw output (e.g. `ts.TypeNode`) without declaration wrapping.\n */\n transform: (node: SchemaNode) => T['output'] | null\n /**\n * Public printer. If the builder provides a root-level `print`, this calls that\n * higher-level function (which may produce full declarations).\n * Otherwise, falls back to the node-level dispatcher.\n */\n print: (node: SchemaNode) => T['printOutput'] | null\n}\n\n/**\n * Builder function passed to `definePrinter`.\n *\n * It receives resolved options and returns:\n * - `name`\n * - `options`\n * - `nodes` handlers\n * - optional top-level `print` override\n *\n * @example\n * ```ts\n * const build = (options: {}) => ({ name: 'x' as const, options, nodes: {} })\n * ```\n */\ntype PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) => {\n name: T['name']\n /**\n * Options to store on the printer.\n */\n options: T['options']\n nodes: Partial<{\n [K in SchemaType]: PrinterHandler<T['output'], T['options'], K>\n }>\n /**\n * Optional root-level print override. When provided, becomes the public `printer.print`.\n * Use `this.transform(node)` inside this function to dispatch to the node-level handlers (`nodes`),\n * not the override itself, so recursion is safe.\n */\n print?: (this: PrinterHandlerContext<T['output'], T['options']>, node: SchemaNode) => T['printOutput'] | null\n}\n/**\n * Creates a schema printer: a function that takes a `SchemaNode` and emits\n * code in your target language. Each plugin that produces code from schemas\n * (TypeScript types, Zod schemas, Faker factories) ships a printer built\n * with this helper.\n *\n * The builder receives resolved options and returns:\n *\n * - `name` unique identifier for the printer.\n * - `options` stored on the returned printer instance.\n * - `nodes` map of `SchemaType` → handler. Handlers return the rendered\n * output (a string, a TypeScript AST node, ...) for that schema type.\n * - `print` (optional), top-level override exposed as `printer.print`.\n * Use `this.transform(node)` inside it to dispatch to `nodes` recursively.\n *\n * Without a `print` override, `printer.print` falls back to `printer.transform`\n * (the node-level dispatcher).\n *\n * @example Tiny Zod printer\n * ```ts\n * import { createPrinter, type PrinterFactoryOptions } from '@kubb/ast'\n *\n * type PrinterZod = PrinterFactoryOptions<'zod', { strict?: boolean }, string>\n *\n * export const zodPrinter = createPrinter<PrinterZod>((options) => ({\n * name: 'zod',\n * options: { strict: options.strict ?? true },\n * nodes: {\n * string: () => 'z.string()',\n * object(node) {\n * const props = node.properties\n * .map((p) => `${p.name}: ${this.transform(p.schema)}`)\n * .join(', ')\n * return `z.object({ ${props} })`\n * },\n * },\n * }))\n * ```\n */\nexport function createPrinter<T extends PrinterFactoryOptions = PrinterFactoryOptions>(build: PrinterBuilder<T>): (options?: T['options']) => Printer<T> {\n return (options) => {\n const { name, options: resolvedOptions, nodes, print: printOverride } = build(options ?? ({} as T['options']))\n\n const context = {\n options: resolvedOptions,\n transform: (node: SchemaNode): T['output'] | null => {\n const handler = nodes[node.type]\n if (!handler) return null\n\n return (handler as (this: typeof context, node: SchemaNode) => T['output'] | null).call(context, node)\n },\n }\n\n return {\n name,\n options: resolvedOptions,\n transform: context.transform,\n print: (printOverride ? printOverride.bind(context) : context.transform) as (node: SchemaNode) => T['printOutput'] | null,\n }\n }\n}\n","import type { Node } from './nodes/index.ts'\n\n// Node constructors, grouped under the `factory` namespace the way the TypeScript compiler exposes\n// `ts.factory.createX`. Aggregating them here lets `export * as factory from './factory.ts'` in the\n// barrel surface every `createX` alongside the `createFile`/`update` helpers from a single module.\nexport { createArrowFunction, createBreak, createConst, createFunction, createJsx, createText, createType } from './nodes/code.ts'\nexport { createContent } from './nodes/content.ts'\nexport { createExport, createFile, createImport, createSource } from './nodes/file.ts'\nexport type { UserFileNode } from './nodes/file.ts'\nexport { createFunctionParameter, createFunctionParameters, createIndexedAccessType, createObjectBindingPattern, createTypeLiteral } from './nodes/function.ts'\nexport { createInput } from './nodes/input.ts'\nexport { createOperation } from './nodes/operation.ts'\nexport { createOutput } from './nodes/output.ts'\nexport { createParameter } from './nodes/parameter.ts'\nexport { createProperty } from './nodes/property.ts'\nexport { createRequestBody } from './nodes/requestBody.ts'\nexport { createResponse } from './nodes/response.ts'\nexport { createSchema } from './nodes/schema.ts'\n\n/**\n * Identity-preserving node update: returns `node` unchanged when every field in\n * `changes` already equals (by reference) the current value, otherwise a new node\n * with the changes applied.\n *\n * Mirrors the TypeScript compiler's `factory.updateX` contract. Pair it with the\n * structural sharing in {@link transform} so a no-op rewrite does not allocate and\n * downstream passes can detect \"nothing changed\" by identity. Comparison is shallow,\n * so a structurally equal but newly allocated array or object counts as a change.\n *\n * @example\n * ```ts\n * update(node, { name: node.name }) // -> same `node` reference\n * update(node, { name: 'renamed' }) // -> new node, `name` replaced\n * ```\n */\nexport function update<T extends Node>(node: T, changes: Partial<T>): T {\n for (const key in changes) {\n if (changes[key] !== node[key as keyof T]) {\n return { ...node, ...changes }\n }\n }\n\n return node\n}\n","export { schemaTypes } from './constants.ts'\nexport { defineDialect } from './defineDialect.ts'\nexport { isHttpOperationNode, narrowSchema } from './guards.ts'\nexport { applyMacros, composeMacros, defineMacro } from './defineMacro.ts'\nexport { defineNode } from './defineNode.ts'\nexport { optionality } from './optionality.ts'\nexport { createPrinter } from './createPrinter.ts'\nexport { collect, transform, walk } from './visitor.ts'\n\nexport * as factory from './factory.ts'\nexport * from './registry.ts'\nexport type * from './types.ts'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6DA,SAAgB,cACd,SACmD;CACnD,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC2HA,SAAgB,cAAuE,OAAkE;CACvJ,QAAQ,YAAY;EAClB,MAAM,EAAE,MAAM,SAAS,iBAAiB,OAAO,OAAO,kBAAkB,MAAM,WAAY,CAAC,CAAkB;EAE7G,MAAM,UAAU;GACd,SAAS;GACT,YAAY,SAAyC;IACnD,MAAM,UAAU,MAAM,KAAK;IAC3B,IAAI,CAAC,SAAS,OAAO;IAErB,OAAQ,QAA2E,KAAK,SAAS,IAAI;GACvG;EACF;EAEA,OAAO;GACL;GACA,SAAS;GACT,WAAW,QAAQ;GACnB,OAAQ,gBAAgB,cAAc,KAAK,OAAO,IAAI,QAAQ;EAChE;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC9KA,SAAgB,OAAuB,MAAS,SAAwB;CACtE,KAAK,MAAM,OAAO,SAChB,IAAI,QAAQ,SAAS,KAAK,MACxB,OAAO;EAAE,GAAG;EAAM,GAAG;CAAQ;CAIjC,OAAO;AACT"}
|