@kubb/core
Advanced tools
Comparing version 1.0.0-alpha.7 to 1.0.0-alpha.8
import { DirectoryTreeOptions } from 'directory-tree'; | ||
interface Cache<TCache = any> { | ||
delete(id: string): boolean; | ||
get<T = TCache>(id: string): T; | ||
has(id: string): boolean; | ||
set<T = TCache>(id: string, value: T): void; | ||
interface Cache<T extends object = object> { | ||
delete(id: keyof T): boolean; | ||
get(id: keyof T): T[keyof T] | null; | ||
has(id: keyof T): boolean; | ||
set(id: keyof T, value: unknown): void; | ||
} | ||
declare function createPluginCache(cache: any): Cache; | ||
declare function createPluginCache<T extends Record<string, [number, unknown]>>(cache: T): Cache<T>; | ||
@@ -214,5 +214,5 @@ type MaybePromise<T> = Promise<T> | T; | ||
interface QueueTask<T> { | ||
(...args: any): Promise<T>; | ||
} | ||
type QueueTask<T = unknown> = { | ||
(...args: unknown[]): Promise<T>; | ||
}; | ||
declare class Queue { | ||
@@ -274,2 +274,3 @@ private readonly queue; | ||
type TreeNodeOptions = DirectoryTreeOptions; | ||
declare class TreeNode<T = unknown> { | ||
@@ -280,12 +281,8 @@ data: T; | ||
constructor(data: T, parent?: TreeNode<T>); | ||
addChild(data: T): any; | ||
find(data: T): any; | ||
leaves(): this[]; | ||
root(): any; | ||
addChild(data: T): TreeNode<T>; | ||
find(data: T): {} | null; | ||
leaves(): TreeNode<T>[]; | ||
root(): TreeNode<T>; | ||
forEach(callback: (treeNode: TreeNode<T>) => void): this; | ||
static build(path: string, options?: DirectoryTreeOptions): TreeNode<{ | ||
name: string; | ||
path: string; | ||
type: "directory" | "file"; | ||
}> | undefined; | ||
static build<T = unknown>(path: string, options?: TreeNodeOptions): TreeNode<T> | null; | ||
} | ||
@@ -353,3 +350,3 @@ | ||
logger?: Logger; | ||
task: QueueTask<unknown>; | ||
task: QueueTask; | ||
}); | ||
@@ -404,2 +401,2 @@ resolveId: (params: ResolveIdParams) => Promise<OptionalPath>; | ||
export { Argument0, CLIOptions, Cache, CacheStore, CorePluginOptions, File, FileManager, FileName, Generator, KubbBuild, KubbConfig, KubbJSONPlugin, KubbPlugin, KubbPluginKind, KubbUserConfig, LogLevel, LogType, Logger, MaybePromise, OptionalPath, Path, PathMode, PluginContext, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, Queue, QueueTask, ResolveIdParams, SchemaGenerator, Status, Strategy, TransformResult, TreeNode, UUID, ValidationPluginError, build, clean, createJSDocBlockText, createPlugin, createPluginCache, build as default, defineConfig, getPathMode, getRelativePath, getUniqueName, hooks, isPromise, isURL, name, nameSorter, objectToParameters, read, timeout, validatePlugins, write }; | ||
export { Argument0, CLIOptions, Cache, CacheStore, CorePluginOptions, File, FileManager, FileName, Generator, KubbBuild, KubbConfig, KubbJSONPlugin, KubbPlugin, KubbPluginKind, KubbUserConfig, LogLevel, LogType, Logger, MaybePromise, OptionalPath, Path, PathMode, PluginContext, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, Queue, QueueTask, ResolveIdParams, SchemaGenerator, Status, Strategy, TransformResult, TreeNode, TreeNodeOptions, UUID, ValidationPluginError, build, clean, createJSDocBlockText, createPlugin, createPluginCache, build as default, defineConfig, getPathMode, getRelativePath, getUniqueName, hooks, isPromise, isURL, name, nameSorter, objectToParameters, read, timeout, validatePlugins, write }; |
@@ -66,3 +66,3 @@ import { createRequire } from 'module'; | ||
if (!item) | ||
return; | ||
return null; | ||
item[0] = 0; | ||
@@ -183,3 +183,4 @@ return item[1]; | ||
return new Promise((resolve, reject) => { | ||
this.queue.push({ reject, resolve, task }); | ||
const item = { reject, resolve, task }; | ||
this.queue.push(item); | ||
this.work(); | ||
@@ -326,2 +327,5 @@ }); | ||
return files.filter(Boolean).reduce((acc, curr) => { | ||
if (!curr) { | ||
return acc; | ||
} | ||
const prevIndex = acc.findIndex((item) => item.path === curr.path); | ||
@@ -371,3 +375,3 @@ if (prevIndex !== -1) { | ||
parent; | ||
children; | ||
children = []; | ||
constructor(data, parent) { | ||
@@ -433,3 +437,3 @@ this.data = data; | ||
if (!filteredTree) { | ||
return; | ||
return null; | ||
} | ||
@@ -436,0 +440,0 @@ const treeNode = new TreeNode({ name: filteredTree.name, path: filteredTree.path, type: filteredTree.type }); |
{ | ||
"name": "@kubb/core", | ||
"version": "1.0.0-alpha.7", | ||
"version": "1.0.0-alpha.8", | ||
"description": "Generator core", | ||
@@ -37,2 +37,3 @@ "repository": { | ||
"dist", | ||
"src", | ||
"schemas", | ||
@@ -51,3 +52,5 @@ "!/**/**.test.**", | ||
"@types/lodash.uniq": "^4.5.7", | ||
"tsup": "^6.6.3", | ||
"@types/rimraf": "^3.0.2", | ||
"@types/uuid": "^9.0.1", | ||
"tsup": "^6.7.0", | ||
"typescript": "^5.0.2" | ||
@@ -54,0 +57,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
188734
38
2952
5