@kubb/ast 5.0.0-alpha.36 → 5.0.0-alpha.38
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/index.cjs +17 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -16
- package/dist/index.js +18 -57
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/visitor.ts +0 -41
package/dist/index.cjs
CHANGED
|
@@ -193,23 +193,6 @@ function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
|
193
193
|
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
194
194
|
}
|
|
195
195
|
//#endregion
|
|
196
|
-
//#region ../../internals/utils/src/string.ts
|
|
197
|
-
/**
|
|
198
|
-
* Strips the file extension from a path or file name.
|
|
199
|
-
* Only removes the last `.ext` segment when the dot is not part of a directory name.
|
|
200
|
-
*
|
|
201
|
-
* @example
|
|
202
|
-
* trimExtName('petStore.ts') // 'petStore'
|
|
203
|
-
* trimExtName('/src/models/pet.ts') // '/src/models/pet'
|
|
204
|
-
* trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'
|
|
205
|
-
* trimExtName('noExtension') // 'noExtension'
|
|
206
|
-
*/
|
|
207
|
-
function trimExtName(text) {
|
|
208
|
-
const dotIndex = text.lastIndexOf(".");
|
|
209
|
-
if (dotIndex > 0 && !text.includes("/", dotIndex)) return text.slice(0, dotIndex);
|
|
210
|
-
return text;
|
|
211
|
-
}
|
|
212
|
-
//#endregion
|
|
213
196
|
//#region ../../internals/utils/src/reserved.ts
|
|
214
197
|
/**
|
|
215
198
|
* Returns `true` when `name` is a syntactically valid JavaScript variable name.
|
|
@@ -230,6 +213,23 @@ function isValidVarName(name) {
|
|
|
230
213
|
return true;
|
|
231
214
|
}
|
|
232
215
|
//#endregion
|
|
216
|
+
//#region ../../internals/utils/src/string.ts
|
|
217
|
+
/**
|
|
218
|
+
* Strips the file extension from a path or file name.
|
|
219
|
+
* Only removes the last `.ext` segment when the dot is not part of a directory name.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* trimExtName('petStore.ts') // 'petStore'
|
|
223
|
+
* trimExtName('/src/models/pet.ts') // '/src/models/pet'
|
|
224
|
+
* trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'
|
|
225
|
+
* trimExtName('noExtension') // 'noExtension'
|
|
226
|
+
*/
|
|
227
|
+
function trimExtName(text) {
|
|
228
|
+
const dotIndex = text.lastIndexOf(".");
|
|
229
|
+
if (dotIndex > 0 && !text.includes("/", dotIndex)) return text.slice(0, dotIndex);
|
|
230
|
+
return text;
|
|
231
|
+
}
|
|
232
|
+
//#endregion
|
|
233
233
|
//#region src/guards.ts
|
|
234
234
|
/**
|
|
235
235
|
* Narrows a `SchemaNode` to the variant that matches `type`.
|
|
@@ -1706,45 +1706,6 @@ function transform(node, options) {
|
|
|
1706
1706
|
}
|
|
1707
1707
|
}
|
|
1708
1708
|
/**
|
|
1709
|
-
* Composes multiple visitors into one visitor, applied left to right.
|
|
1710
|
-
*
|
|
1711
|
-
* For each node kind, output from one visitor is input to the next.
|
|
1712
|
-
* If a visitor returns `undefined`, the previous node value is kept.
|
|
1713
|
-
*
|
|
1714
|
-
* @example
|
|
1715
|
-
* ```ts
|
|
1716
|
-
* const visitor = composeTransformers(
|
|
1717
|
-
* { operation: (node) => ({ ...node, operationId: `a_${node.operationId}` }) },
|
|
1718
|
-
* { operation: (node) => ({ ...node, operationId: `b_${node.operationId}` }) },
|
|
1719
|
-
* )
|
|
1720
|
-
* ```
|
|
1721
|
-
*/
|
|
1722
|
-
function composeTransformers(...visitors) {
|
|
1723
|
-
return {
|
|
1724
|
-
input(node, context) {
|
|
1725
|
-
return visitors.reduce((acc, v) => v.input?.(acc, context) ?? acc, node);
|
|
1726
|
-
},
|
|
1727
|
-
output(node, context) {
|
|
1728
|
-
return visitors.reduce((acc, v) => v.output?.(acc, context) ?? acc, node);
|
|
1729
|
-
},
|
|
1730
|
-
operation(node, context) {
|
|
1731
|
-
return visitors.reduce((acc, v) => v.operation?.(acc, context) ?? acc, node);
|
|
1732
|
-
},
|
|
1733
|
-
schema(node, context) {
|
|
1734
|
-
return visitors.reduce((acc, v) => v.schema?.(acc, context) ?? acc, node);
|
|
1735
|
-
},
|
|
1736
|
-
property(node, context) {
|
|
1737
|
-
return visitors.reduce((acc, v) => v.property?.(acc, context) ?? acc, node);
|
|
1738
|
-
},
|
|
1739
|
-
parameter(node, context) {
|
|
1740
|
-
return visitors.reduce((acc, v) => v.parameter?.(acc, context) ?? acc, node);
|
|
1741
|
-
},
|
|
1742
|
-
response(node, context) {
|
|
1743
|
-
return visitors.reduce((acc, v) => v.response?.(acc, context) ?? acc, node);
|
|
1744
|
-
}
|
|
1745
|
-
};
|
|
1746
|
-
}
|
|
1747
|
-
/**
|
|
1748
1709
|
* Runs a depth-first synchronous collection pass.
|
|
1749
1710
|
*
|
|
1750
1711
|
* Non-`undefined` values returned by visitor callbacks are appended to the result.
|
|
@@ -1942,7 +1903,6 @@ exports.caseParams = caseParams;
|
|
|
1942
1903
|
exports.childName = childName;
|
|
1943
1904
|
exports.collect = collect;
|
|
1944
1905
|
exports.collectImports = collectImports;
|
|
1945
|
-
exports.composeTransformers = composeTransformers;
|
|
1946
1906
|
exports.createArrowFunction = createArrowFunction;
|
|
1947
1907
|
exports.createBreak = createBreak;
|
|
1948
1908
|
exports.createConst = createConst;
|