@kubb/ast 5.0.0-beta.32 → 5.0.0-beta.33
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/README.md +2 -3
- package/dist/index.cjs +3 -96
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -3727
- package/dist/index.js +4 -85
- package/dist/index.js.map +1 -1
- package/dist/types-CE8VJ5_y.d.ts +3605 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.js +1 -0
- package/package.json +5 -1
- package/src/constants.ts +0 -50
- package/src/index.ts +5 -9
- package/src/infer.ts +0 -9
- package/src/refs.ts +0 -7
- package/src/types.ts +1 -2
- package/src/visitor.ts +8 -4
package/README.md
CHANGED
|
@@ -120,10 +120,9 @@ function process(node: Node) {
|
|
|
120
120
|
### Refs
|
|
121
121
|
|
|
122
122
|
```ts
|
|
123
|
-
import {
|
|
123
|
+
import { extractRefName } from '@kubb/ast'
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
const pet = resolveRef(refMap, 'Pet')
|
|
125
|
+
extractRefName('#/components/schemas/Pet') // 'Pet'
|
|
127
126
|
```
|
|
128
127
|
|
|
129
128
|
## Supporting Kubb
|
package/dist/index.cjs
CHANGED
|
@@ -29,25 +29,6 @@ const visitorDepths = {
|
|
|
29
29
|
shallow: "shallow",
|
|
30
30
|
deep: "deep"
|
|
31
31
|
};
|
|
32
|
-
const nodeKinds = {
|
|
33
|
-
input: "Input",
|
|
34
|
-
output: "Output",
|
|
35
|
-
operation: "Operation",
|
|
36
|
-
schema: "Schema",
|
|
37
|
-
property: "Property",
|
|
38
|
-
parameter: "Parameter",
|
|
39
|
-
response: "Response",
|
|
40
|
-
functionParameter: "FunctionParameter",
|
|
41
|
-
parameterGroup: "ParameterGroup",
|
|
42
|
-
functionParameters: "FunctionParameters",
|
|
43
|
-
type: "Type",
|
|
44
|
-
file: "File",
|
|
45
|
-
import: "Import",
|
|
46
|
-
export: "Export",
|
|
47
|
-
source: "Source",
|
|
48
|
-
text: "Text",
|
|
49
|
-
break: "Break"
|
|
50
|
-
};
|
|
51
32
|
/**
|
|
52
33
|
* Schema type discriminators used by all AST schema nodes.
|
|
53
34
|
*
|
|
@@ -196,33 +177,6 @@ const httpMethods = {
|
|
|
196
177
|
options: "OPTIONS",
|
|
197
178
|
trace: "TRACE"
|
|
198
179
|
};
|
|
199
|
-
/**
|
|
200
|
-
* Common MIME types used in request/response content negotiation.
|
|
201
|
-
*
|
|
202
|
-
* Covers JSON, XML, form data, PDFs, images, audio, and video formats.
|
|
203
|
-
* Use these as keys when serializing request/response bodies.
|
|
204
|
-
*/
|
|
205
|
-
const mediaTypes = {
|
|
206
|
-
applicationJson: "application/json",
|
|
207
|
-
applicationXml: "application/xml",
|
|
208
|
-
applicationFormUrlEncoded: "application/x-www-form-urlencoded",
|
|
209
|
-
applicationOctetStream: "application/octet-stream",
|
|
210
|
-
applicationPdf: "application/pdf",
|
|
211
|
-
applicationZip: "application/zip",
|
|
212
|
-
applicationGraphql: "application/graphql",
|
|
213
|
-
multipartFormData: "multipart/form-data",
|
|
214
|
-
textPlain: "text/plain",
|
|
215
|
-
textHtml: "text/html",
|
|
216
|
-
textCsv: "text/csv",
|
|
217
|
-
textXml: "text/xml",
|
|
218
|
-
imagePng: "image/png",
|
|
219
|
-
imageJpeg: "image/jpeg",
|
|
220
|
-
imageGif: "image/gif",
|
|
221
|
-
imageWebp: "image/webp",
|
|
222
|
-
imageSvgXml: "image/svg+xml",
|
|
223
|
-
audioMpeg: "audio/mpeg",
|
|
224
|
-
videoMp4: "video/mp4"
|
|
225
|
-
};
|
|
226
180
|
//#endregion
|
|
227
181
|
//#region ../../internals/utils/src/casing.ts
|
|
228
182
|
/**
|
|
@@ -465,28 +419,6 @@ function isKind(kind) {
|
|
|
465
419
|
return (node) => node.kind === kind;
|
|
466
420
|
}
|
|
467
421
|
/**
|
|
468
|
-
* Returns `true` when the input is an `InputNode`.
|
|
469
|
-
*
|
|
470
|
-
* @example
|
|
471
|
-
* ```ts
|
|
472
|
-
* if (isInputNode(node)) {
|
|
473
|
-
* console.log(node.schemas.length)
|
|
474
|
-
* }
|
|
475
|
-
* ```
|
|
476
|
-
*/
|
|
477
|
-
const isInputNode = isKind("Input");
|
|
478
|
-
/**
|
|
479
|
-
* Returns `true` when the input is an `OutputNode`.
|
|
480
|
-
*
|
|
481
|
-
* @example
|
|
482
|
-
* ```ts
|
|
483
|
-
* if (isOutputNode(node)) {
|
|
484
|
-
* console.log(node.files.length)
|
|
485
|
-
* }
|
|
486
|
-
* ```
|
|
487
|
-
*/
|
|
488
|
-
const isOutputNode = isKind("Output");
|
|
489
|
-
/**
|
|
490
422
|
* Returns `true` when the input is an `OperationNode`.
|
|
491
423
|
*
|
|
492
424
|
* @example
|
|
@@ -677,8 +609,9 @@ async function walk(node, options) {
|
|
|
677
609
|
}
|
|
678
610
|
async function _walk(node, visitor, recurse, limit, parent) {
|
|
679
611
|
await limit(() => applyVisitor(node, visitor, parent));
|
|
680
|
-
const children = getChildren(node, recurse);
|
|
681
|
-
|
|
612
|
+
const children = Array.from(getChildren(node, recurse));
|
|
613
|
+
if (children.length === 0) return;
|
|
614
|
+
await Promise.all(children.map((child) => _walk(child, visitor, recurse, limit, node)));
|
|
682
615
|
}
|
|
683
616
|
function transform(node, options) {
|
|
684
617
|
const { depth, parent, ...visitor } = options;
|
|
@@ -2356,17 +2289,6 @@ function signatureOf(node) {
|
|
|
2356
2289
|
function schemaSignature(node) {
|
|
2357
2290
|
return signatureOf(node);
|
|
2358
2291
|
}
|
|
2359
|
-
/**
|
|
2360
|
-
* Returns `true` when two schema nodes are structurally identical under shape-only equality.
|
|
2361
|
-
*
|
|
2362
|
-
* @example
|
|
2363
|
-
* ```ts
|
|
2364
|
-
* isSchemaEqual(a, b) // a and b produce the same TypeScript type
|
|
2365
|
-
* ```
|
|
2366
|
-
*/
|
|
2367
|
-
function isSchemaEqual(a, b) {
|
|
2368
|
-
return schemaSignature(a) === schemaSignature(b);
|
|
2369
|
-
}
|
|
2370
2292
|
//#endregion
|
|
2371
2293
|
//#region src/dedupe.ts
|
|
2372
2294
|
/**
|
|
@@ -2706,9 +2628,6 @@ function* mergeAdjacentObjectsLazy(members) {
|
|
|
2706
2628
|
}
|
|
2707
2629
|
if (acc !== void 0) yield acc;
|
|
2708
2630
|
}
|
|
2709
|
-
function mergeAdjacentObjects(members) {
|
|
2710
|
-
return [...mergeAdjacentObjectsLazy(members)];
|
|
2711
|
-
}
|
|
2712
2631
|
/**
|
|
2713
2632
|
* Removes enum members that are covered by broader scalar primitives in the same union.
|
|
2714
2633
|
*
|
|
@@ -2754,14 +2673,11 @@ exports.caseParams = caseParams;
|
|
|
2754
2673
|
exports.childName = childName;
|
|
2755
2674
|
exports.collect = collect;
|
|
2756
2675
|
exports.collectImports = collectImports;
|
|
2757
|
-
exports.collectLazy = collectLazy;
|
|
2758
|
-
exports.collectReferencedSchemaNames = collectReferencedSchemaNames;
|
|
2759
2676
|
exports.collectUsedSchemaNames = collectUsedSchemaNames;
|
|
2760
2677
|
exports.containsCircularRef = containsCircularRef;
|
|
2761
2678
|
exports.createArrowFunction = createArrowFunction;
|
|
2762
2679
|
exports.createBreak = createBreak;
|
|
2763
2680
|
exports.createConst = createConst;
|
|
2764
|
-
exports.createContent = createContent;
|
|
2765
2681
|
exports.createDiscriminantNode = createDiscriminantNode;
|
|
2766
2682
|
exports.createExport = createExport;
|
|
2767
2683
|
exports.createFile = createFile;
|
|
@@ -2779,7 +2695,6 @@ exports.createParameterGroup = createParameterGroup;
|
|
|
2779
2695
|
exports.createParamsType = createParamsType;
|
|
2780
2696
|
exports.createPrinterFactory = createPrinterFactory;
|
|
2781
2697
|
exports.createProperty = createProperty;
|
|
2782
|
-
exports.createRequestBody = createRequestBody;
|
|
2783
2698
|
exports.createResponse = createResponse;
|
|
2784
2699
|
exports.createSchema = createSchema;
|
|
2785
2700
|
exports.createSource = createSource;
|
|
@@ -2796,19 +2711,11 @@ exports.findCircularSchemas = findCircularSchemas;
|
|
|
2796
2711
|
exports.findDiscriminator = findDiscriminator;
|
|
2797
2712
|
exports.httpMethods = httpMethods;
|
|
2798
2713
|
exports.isHttpOperationNode = isHttpOperationNode;
|
|
2799
|
-
exports.isInputNode = isInputNode;
|
|
2800
2714
|
exports.isOperationNode = isOperationNode;
|
|
2801
|
-
exports.isOutputNode = isOutputNode;
|
|
2802
|
-
exports.isScalarPrimitive = isScalarPrimitive;
|
|
2803
|
-
exports.isSchemaEqual = isSchemaEqual;
|
|
2804
2715
|
exports.isSchemaNode = isSchemaNode;
|
|
2805
2716
|
exports.isStringType = isStringType;
|
|
2806
|
-
exports.mediaTypes = mediaTypes;
|
|
2807
|
-
exports.mergeAdjacentObjects = mergeAdjacentObjects;
|
|
2808
2717
|
exports.mergeAdjacentObjectsLazy = mergeAdjacentObjectsLazy;
|
|
2809
2718
|
exports.narrowSchema = narrowSchema;
|
|
2810
|
-
exports.nodeKinds = nodeKinds;
|
|
2811
|
-
exports.resolveRefName = resolveRefName;
|
|
2812
2719
|
exports.schemaSignature = schemaSignature;
|
|
2813
2720
|
exports.schemaTypes = schemaTypes;
|
|
2814
2721
|
exports.setDiscriminatorEnum = setDiscriminatorEnum;
|