@kubb/core 1.4.0 → 1.4.1
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 +23 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +22 -10
- package/dist/index.js.map +1 -1
- package/globals.d.ts +1 -0
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -78,7 +78,7 @@ declare class Queue {
|
|
|
78
78
|
|
|
79
79
|
declare function getEncodedText(text?: string): string;
|
|
80
80
|
|
|
81
|
-
declare function renderTemplate<TData extends Record<string,
|
|
81
|
+
declare function renderTemplate<TData extends Record<string, unknown> = Record<string, unknown>>(template: string, data?: TData | undefined): string;
|
|
82
82
|
|
|
83
83
|
declare function clean(path: string): Promise<boolean>;
|
|
84
84
|
|
|
@@ -100,7 +100,7 @@ declare function transformReservedWord(word: string): string;
|
|
|
100
100
|
|
|
101
101
|
declare function getStackTrace(belowFn?: Function): NodeJS.CallSite[];
|
|
102
102
|
|
|
103
|
-
declare const
|
|
103
|
+
declare const uniqueIdFactory: (counter: number) => (str?: string) => string;
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
106
|
* Normalizes directories to have a trailing slash.
|
|
@@ -229,8 +229,12 @@ type Status = 'new' | 'success' | 'removed';
|
|
|
229
229
|
|
|
230
230
|
declare function getIndexes(root: string, options?: TreeNodeOptions): File[] | null;
|
|
231
231
|
declare function combineFiles(files: Array<File | null>): File[];
|
|
232
|
-
|
|
232
|
+
/**
|
|
233
|
+
* Support for js, ts and tsx(React)
|
|
234
|
+
*/
|
|
235
|
+
type Extension = '.ts' | '.js' | '.tsx';
|
|
233
236
|
declare const extensions: Array<Extension>;
|
|
237
|
+
declare function isExtensionAllowed(fileName: string): boolean;
|
|
234
238
|
declare function getFileSource(file: File): string;
|
|
235
239
|
|
|
236
240
|
declare class FileManager {
|
|
@@ -704,4 +708,4 @@ declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput>
|
|
|
704
708
|
abstract build(schema: TInput, name: string, description?: string): TOutput;
|
|
705
709
|
}
|
|
706
710
|
|
|
707
|
-
export { Argument0, BuildOutput, CLIOptions, Cache, CacheItem, CorePluginOptions, Executer, Extension, File, FileManager, FileName, Generator, KubbConfig, KubbJSONPlugins, KubbObjectPlugin, KubbObjectPlugins, KubbPlugin, KubbPluginKind, KubbUserConfig, KubbUserPlugin, LogLevel, LogLevels, LogType, Logger, OptionalPath, ParallelPluginError, ParseResult, Path, PathMode, PluginCache, PluginContext, PluginError, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, PossiblePromise, Queue, QueueJob, Register, ResolveNameParams, ResolvePathParams, ResolvedFile, SafeParseResult, SchemaGenerator, Source, Status, Strategy, SummaryError, TransformResult, TreeNode, TreeNodeOptions, URLPath, UUID, ValidationPluginError, Warning, build, canLogHierarchy, clean, combineFiles, createJSDocBlockText, createLogger, createPlugin, createPluginCache, build as default, defaultColours, defineConfig, extensions, getEncodedText, getFileSource, getIndexes, getLocation, getPathMode, getRelativePath, getStackTrace, getUniqueName, hooks, importModule, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, pluginName as name, nameSorter, normalizeDirectory, objectToParameters, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord,
|
|
711
|
+
export { Argument0, BuildOutput, CLIOptions, Cache, CacheItem, CorePluginOptions, Executer, Export, Extension, File, FileManager, FileName, Generator, Import, KubbConfig, KubbJSONPlugins, KubbObjectPlugin, KubbObjectPlugins, KubbPlugin, KubbPluginKind, KubbUserConfig, KubbUserPlugin, LogLevel, LogLevels, LogType, Logger, OptionalPath, ParallelPluginError, ParseResult, Path, PathMode, PluginCache, PluginContext, PluginError, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, PossiblePromise, Queue, QueueJob, Register, ResolveNameParams, ResolvePathParams, ResolvedFile, SafeParseResult, SchemaGenerator, Source, Status, Strategy, SummaryError, TransformResult, TreeNode, TreeNodeOptions, URLPath, UUID, ValidationPluginError, Warning, build, canLogHierarchy, clean, combineFiles, createJSDocBlockText, createLogger, createPlugin, createPluginCache, build as default, defaultColours, defineConfig, extensions, getEncodedText, getFileSource, getIndexes, getLocation, getPathMode, getRelativePath, getStackTrace, getUniqueName, hooks, importModule, isExtensionAllowed, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, pluginName as name, nameSorter, normalizeDirectory, objectToParameters, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord, uniqueIdFactory, validatePlugins, write };
|
package/dist/index.d.ts
CHANGED
|
@@ -78,7 +78,7 @@ declare class Queue {
|
|
|
78
78
|
|
|
79
79
|
declare function getEncodedText(text?: string): string;
|
|
80
80
|
|
|
81
|
-
declare function renderTemplate<TData extends Record<string,
|
|
81
|
+
declare function renderTemplate<TData extends Record<string, unknown> = Record<string, unknown>>(template: string, data?: TData | undefined): string;
|
|
82
82
|
|
|
83
83
|
declare function clean(path: string): Promise<boolean>;
|
|
84
84
|
|
|
@@ -100,7 +100,7 @@ declare function transformReservedWord(word: string): string;
|
|
|
100
100
|
|
|
101
101
|
declare function getStackTrace(belowFn?: Function): NodeJS.CallSite[];
|
|
102
102
|
|
|
103
|
-
declare const
|
|
103
|
+
declare const uniqueIdFactory: (counter: number) => (str?: string) => string;
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
106
|
* Normalizes directories to have a trailing slash.
|
|
@@ -229,8 +229,12 @@ type Status = 'new' | 'success' | 'removed';
|
|
|
229
229
|
|
|
230
230
|
declare function getIndexes(root: string, options?: TreeNodeOptions): File[] | null;
|
|
231
231
|
declare function combineFiles(files: Array<File | null>): File[];
|
|
232
|
-
|
|
232
|
+
/**
|
|
233
|
+
* Support for js, ts and tsx(React)
|
|
234
|
+
*/
|
|
235
|
+
type Extension = '.ts' | '.js' | '.tsx';
|
|
233
236
|
declare const extensions: Array<Extension>;
|
|
237
|
+
declare function isExtensionAllowed(fileName: string): boolean;
|
|
234
238
|
declare function getFileSource(file: File): string;
|
|
235
239
|
|
|
236
240
|
declare class FileManager {
|
|
@@ -704,4 +708,4 @@ declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput>
|
|
|
704
708
|
abstract build(schema: TInput, name: string, description?: string): TOutput;
|
|
705
709
|
}
|
|
706
710
|
|
|
707
|
-
export { Argument0, BuildOutput, CLIOptions, Cache, CacheItem, CorePluginOptions, Executer, Extension, File, FileManager, FileName, Generator, KubbConfig, KubbJSONPlugins, KubbObjectPlugin, KubbObjectPlugins, KubbPlugin, KubbPluginKind, KubbUserConfig, KubbUserPlugin, LogLevel, LogLevels, LogType, Logger, OptionalPath, ParallelPluginError, ParseResult, Path, PathMode, PluginCache, PluginContext, PluginError, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, PossiblePromise, Queue, QueueJob, Register, ResolveNameParams, ResolvePathParams, ResolvedFile, SafeParseResult, SchemaGenerator, Source, Status, Strategy, SummaryError, TransformResult, TreeNode, TreeNodeOptions, URLPath, UUID, ValidationPluginError, Warning, build, canLogHierarchy, clean, combineFiles, createJSDocBlockText, createLogger, createPlugin, createPluginCache, build as default, defaultColours, defineConfig, extensions, getEncodedText, getFileSource, getIndexes, getLocation, getPathMode, getRelativePath, getStackTrace, getUniqueName, hooks, importModule, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, pluginName as name, nameSorter, normalizeDirectory, objectToParameters, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord,
|
|
711
|
+
export { Argument0, BuildOutput, CLIOptions, Cache, CacheItem, CorePluginOptions, Executer, Export, Extension, File, FileManager, FileName, Generator, Import, KubbConfig, KubbJSONPlugins, KubbObjectPlugin, KubbObjectPlugins, KubbPlugin, KubbPluginKind, KubbUserConfig, KubbUserPlugin, LogLevel, LogLevels, LogType, Logger, OptionalPath, ParallelPluginError, ParseResult, Path, PathMode, PluginCache, PluginContext, PluginError, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, PossiblePromise, Queue, QueueJob, Register, ResolveNameParams, ResolvePathParams, ResolvedFile, SafeParseResult, SchemaGenerator, Source, Status, Strategy, SummaryError, TransformResult, TreeNode, TreeNodeOptions, URLPath, UUID, ValidationPluginError, Warning, build, canLogHierarchy, clean, combineFiles, createJSDocBlockText, createLogger, createPlugin, createPluginCache, build as default, defaultColours, defineConfig, extensions, getEncodedText, getFileSource, getIndexes, getLocation, getPathMode, getRelativePath, getStackTrace, getUniqueName, hooks, importModule, isExtensionAllowed, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, pluginName as name, nameSorter, normalizeDirectory, objectToParameters, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord, uniqueIdFactory, validatePlugins, write };
|
package/dist/index.js
CHANGED
|
@@ -218,13 +218,22 @@ function getEncodedText(text) {
|
|
|
218
218
|
|
|
219
219
|
// src/utils/renderTemplate.ts
|
|
220
220
|
function renderTemplate(template, data = void 0) {
|
|
221
|
-
if (!data) {
|
|
221
|
+
if (!data || !Object.keys(data).length) {
|
|
222
222
|
return template.replace(/{{(.*?)}}/g, "");
|
|
223
223
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
224
|
+
const matches = template.match(/{{(.*?)}}/g);
|
|
225
|
+
return matches?.reduce((prev, curr) => {
|
|
226
|
+
const value = data[curr.split(/{{|}}/).filter(Boolean)[0].trim()];
|
|
227
|
+
if (value === void 0) {
|
|
228
|
+
return prev;
|
|
229
|
+
}
|
|
230
|
+
return prev.replace(curr, () => {
|
|
231
|
+
if (typeof value === "boolean") {
|
|
232
|
+
return `${value.toString()}` || "false";
|
|
233
|
+
}
|
|
234
|
+
return value || "";
|
|
235
|
+
}).trim();
|
|
236
|
+
}, template) || "";
|
|
228
237
|
}
|
|
229
238
|
async function clean(path) {
|
|
230
239
|
return rimraf(path);
|
|
@@ -426,8 +435,8 @@ function getStackTrace(belowFn) {
|
|
|
426
435
|
return v8StackTrace;
|
|
427
436
|
}
|
|
428
437
|
|
|
429
|
-
// src/utils/
|
|
430
|
-
var
|
|
438
|
+
// src/utils/uniqueIdFactory.ts
|
|
439
|
+
var uniqueIdFactory = (counter) => (str = "") => `${str}${++counter}`;
|
|
431
440
|
var SLASHES = /* @__PURE__ */ new Set(["/", "\\"]);
|
|
432
441
|
function normalizeDirectory(directory) {
|
|
433
442
|
if (!SLASHES.has(directory[directory.length - 1])) {
|
|
@@ -699,10 +708,13 @@ ${curr.source}` : "",
|
|
|
699
708
|
return acc;
|
|
700
709
|
}, []);
|
|
701
710
|
}
|
|
702
|
-
var extensions = [".js", ".ts"];
|
|
711
|
+
var extensions = [".js", ".ts", ".tsx"];
|
|
712
|
+
function isExtensionAllowed(fileName) {
|
|
713
|
+
return extensions.some((extension) => fileName.endsWith(extension));
|
|
714
|
+
}
|
|
703
715
|
function getFileSource(file) {
|
|
704
716
|
let { source } = file;
|
|
705
|
-
if (!
|
|
717
|
+
if (!isExtensionAllowed(file.fileName)) {
|
|
706
718
|
return file.source;
|
|
707
719
|
}
|
|
708
720
|
const imports = [];
|
|
@@ -1514,6 +1526,6 @@ var SchemaGenerator = class extends Generator {
|
|
|
1514
1526
|
// src/index.ts
|
|
1515
1527
|
var src_default = build;
|
|
1516
1528
|
|
|
1517
|
-
export { FileManager, Generator, LogLevel, ParallelPluginError, PluginError, PluginManager, Queue, SchemaGenerator, SummaryError, TreeNode, URLPath, ValidationPluginError, Warning, build, canLogHierarchy, clean, combineFiles, createJSDocBlockText, createLogger, createPlugin, createPluginCache, src_default as default, defaultColours, defineConfig, extensions, getEncodedText, getFileSource, getIndexes, getLocation, getPathMode, getRelativePath, getStackTrace, getUniqueName, hooks, importModule, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, pluginName as name, nameSorter, normalizeDirectory, objectToParameters, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord,
|
|
1529
|
+
export { FileManager, Generator, LogLevel, ParallelPluginError, PluginError, PluginManager, Queue, SchemaGenerator, SummaryError, TreeNode, URLPath, ValidationPluginError, Warning, build, canLogHierarchy, clean, combineFiles, createJSDocBlockText, createLogger, createPlugin, createPluginCache, src_default as default, defaultColours, defineConfig, extensions, getEncodedText, getFileSource, getIndexes, getLocation, getPathMode, getRelativePath, getStackTrace, getUniqueName, hooks, importModule, isExtensionAllowed, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, pluginName as name, nameSorter, normalizeDirectory, objectToParameters, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord, uniqueIdFactory, validatePlugins, write };
|
|
1518
1530
|
//# sourceMappingURL=out.js.map
|
|
1519
1531
|
//# sourceMappingURL=index.js.map
|