@kubb/core 1.8.4 → 1.8.5

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.d.ts CHANGED
@@ -9,6 +9,7 @@ type Logger = {
9
9
  info: (message: string | null) => void;
10
10
  warn: (message: string | null) => void;
11
11
  spinner?: Ora;
12
+ logs: string[];
12
13
  };
13
14
  declare function createLogger(spinner?: Ora): Logger;
14
15
 
@@ -77,6 +78,10 @@ declare class Queue {
77
78
 
78
79
  declare function getEncodedText(text?: string): string;
79
80
 
81
+ declare function transformReservedWord(word: string): string;
82
+
83
+ declare function combineCodes(codes: string[]): string;
84
+
80
85
  declare function renderTemplate<TData extends Record<string, unknown> = Record<string, unknown>>(template: string, data?: TData | undefined): string;
81
86
 
82
87
  declare function clean(path: string): Promise<boolean>;
@@ -95,8 +100,6 @@ declare class TreeNode<T = unknown> {
95
100
  static build<T = unknown>(path: string, options?: TreeNodeOptions): TreeNode<T> | null;
96
101
  }
97
102
 
98
- declare function transformReservedWord(word: string): string;
99
-
100
103
  declare const uniqueIdFactory: (counter: number) => (str?: string) => string;
101
104
 
102
105
  /**
@@ -496,7 +499,7 @@ type CLIOptions = {
496
499
  * `debug` will show all information possible(related to the PluginManager), handy for seeing logs
497
500
  * @default `silent`
498
501
  */
499
- logLevel?: LogLevels;
502
+ logLevel?: LogLevel;
500
503
  };
501
504
  type BuildOutput = {
502
505
  files: FileManager['files'];
@@ -650,7 +653,7 @@ declare const LogLevel: {
650
653
  readonly info: "info";
651
654
  readonly debug: "debug";
652
655
  };
653
- type LogLevels = keyof typeof LogLevel;
656
+ type LogLevel = keyof typeof LogLevel;
654
657
 
655
658
  type BuildOptions = {
656
659
  config: PluginContext['config'];
@@ -658,7 +661,7 @@ type BuildOptions = {
658
661
  * @default Logger without the spinner
659
662
  */
660
663
  logger?: Logger;
661
- logLevel?: LogLevels;
664
+ logLevel?: LogLevel;
662
665
  };
663
666
  declare function build(options: BuildOptions): Promise<BuildOutput>;
664
667
 
@@ -702,4 +705,4 @@ declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput>
702
705
  abstract build(schema: TInput, name: string, description?: string): TOutput;
703
706
  }
704
707
 
705
- export { Argument0, BuildOutput, CLIOptions, Cache, CacheItem, 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, clean, combineFiles, createJSDocBlockText, createLogger, createPlugin, createPluginCache, build as default, defaultColours, defineConfig, extensions, getDependedPlugins, getEncodedText, getFileSource, getIndexes, getLocation, getPathMode, getRelativePath, getUniqueName, hooks, importModule, isExtensionAllowed, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, pluginName as name, nameSorter, normalizeDirectory, objectToParameters, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord, uniqueIdFactory, write };
708
+ export { Argument0, BuildOutput, CLIOptions, Cache, CacheItem, Executer, Export, Extension, File, FileManager, FileName, Generator, Import, KubbConfig, KubbJSONPlugins, KubbObjectPlugin, KubbObjectPlugins, KubbPlugin, KubbPluginKind, KubbUserConfig, KubbUserPlugin, LogLevel, 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, clean, combineCodes, combineFiles, createJSDocBlockText, createLogger, createPlugin, createPluginCache, build as default, defaultColours, defineConfig, extensions, getDependedPlugins, getEncodedText, getFileSource, getIndexes, getLocation, getPathMode, getRelativePath, getUniqueName, hooks, importModule, isExtensionAllowed, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, pluginName as name, nameSorter, normalizeDirectory, objectToParameters, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord, uniqueIdFactory, write };
package/dist/index.js CHANGED
@@ -157,12 +157,9 @@ function createJSDocBlockText({ comments }) {
157
157
  if (!filteredComments.length) {
158
158
  return "";
159
159
  }
160
- const text = filteredComments.reduce((acc, comment) => {
161
- return `${acc}
162
- * ${comment}`;
163
- }, "/**");
164
- return `${text}
165
- */`;
160
+ return `/**
161
+ * ${filteredComments.join("\n * ")}
162
+ */`;
166
163
  }
167
164
 
168
165
  // src/utils/getUniqueName.ts
@@ -240,11 +237,109 @@ var Queue = class {
240
237
  }
241
238
  };
242
239
 
243
- // src/utils/getEncodedText.ts
240
+ // src/utils/transformers/getEncodedText.ts
244
241
  function getEncodedText(text) {
245
242
  return text ? text.replaceAll("`", "\\`") : "";
246
243
  }
247
244
 
245
+ // src/utils/transformers/transformReservedWord.ts
246
+ var reservedWords = [
247
+ "abstract",
248
+ "arguments",
249
+ "boolean",
250
+ "break",
251
+ "byte",
252
+ "case",
253
+ "catch",
254
+ "char",
255
+ "class",
256
+ "const",
257
+ "continue",
258
+ "debugger",
259
+ "default",
260
+ "delete",
261
+ "do",
262
+ "double",
263
+ "else",
264
+ "enum",
265
+ "eval",
266
+ "export",
267
+ "extends",
268
+ "false",
269
+ "final",
270
+ "finally",
271
+ "float",
272
+ "for",
273
+ "function",
274
+ "goto",
275
+ "if",
276
+ "implements",
277
+ "import",
278
+ "in",
279
+ "instanceof",
280
+ "int",
281
+ "interface",
282
+ "let",
283
+ "long",
284
+ "native",
285
+ "new",
286
+ "null",
287
+ "package",
288
+ "private",
289
+ "protected",
290
+ "public",
291
+ "return",
292
+ "short",
293
+ "static",
294
+ "super",
295
+ "switch",
296
+ "synchronized",
297
+ "this",
298
+ "throw",
299
+ "throws",
300
+ "transient",
301
+ "true",
302
+ "try",
303
+ "typeof",
304
+ "var",
305
+ "void",
306
+ "volatile",
307
+ "while",
308
+ "with",
309
+ "yield",
310
+ "Array",
311
+ "Date",
312
+ "eval",
313
+ "function",
314
+ "hasOwnProperty",
315
+ "Infinity",
316
+ "isFinite",
317
+ "isNaN",
318
+ "isPrototypeOf",
319
+ "length",
320
+ "Math",
321
+ "name",
322
+ "NaN",
323
+ "Number",
324
+ "Object",
325
+ "prototype",
326
+ "String",
327
+ "toString",
328
+ "undefined",
329
+ "valueOf"
330
+ ];
331
+ function transformReservedWord(word) {
332
+ if (word && reservedWords.includes(word) || word?.match(/^\d/)) {
333
+ return `_${word}`;
334
+ }
335
+ return word;
336
+ }
337
+
338
+ // src/utils/transformers/combineCodes.ts
339
+ function combineCodes(codes) {
340
+ return codes.map((code) => code.replaceAll(/(^[ \t]*\n)/gm, "")).join("\n");
341
+ }
342
+
248
343
  // src/utils/renderTemplate.ts
249
344
  function renderTemplate(template, data = void 0) {
250
345
  if (!data || !Object.keys(data).length) {
@@ -355,99 +450,6 @@ var TreeNode = class _TreeNode {
355
450
  }
356
451
  };
357
452
 
358
- // src/utils/transformReservedWord.ts
359
- var reservedWords = [
360
- "abstract",
361
- "arguments",
362
- "boolean",
363
- "break",
364
- "byte",
365
- "case",
366
- "catch",
367
- "char",
368
- "class",
369
- "const",
370
- "continue",
371
- "debugger",
372
- "default",
373
- "delete",
374
- "do",
375
- "double",
376
- "else",
377
- "enum",
378
- "eval",
379
- "export",
380
- "extends",
381
- "false",
382
- "final",
383
- "finally",
384
- "float",
385
- "for",
386
- "function",
387
- "goto",
388
- "if",
389
- "implements",
390
- "import",
391
- "in",
392
- "instanceof",
393
- "int",
394
- "interface",
395
- "let",
396
- "long",
397
- "native",
398
- "new",
399
- "null",
400
- "package",
401
- "private",
402
- "protected",
403
- "public",
404
- "return",
405
- "short",
406
- "static",
407
- "super",
408
- "switch",
409
- "synchronized",
410
- "this",
411
- "throw",
412
- "throws",
413
- "transient",
414
- "true",
415
- "try",
416
- "typeof",
417
- "var",
418
- "void",
419
- "volatile",
420
- "while",
421
- "with",
422
- "yield",
423
- "Array",
424
- "Date",
425
- "eval",
426
- "function",
427
- "hasOwnProperty",
428
- "Infinity",
429
- "isFinite",
430
- "isNaN",
431
- "isPrototypeOf",
432
- "length",
433
- "Math",
434
- "name",
435
- "NaN",
436
- "Number",
437
- "Object",
438
- "prototype",
439
- "String",
440
- "toString",
441
- "undefined",
442
- "valueOf"
443
- ];
444
- function transformReservedWord(word) {
445
- if (word && reservedWords.includes(word) || word?.match(/^\d/)) {
446
- return `_${word}`;
447
- }
448
- return word;
449
- }
450
-
451
453
  // src/utils/uniqueIdFactory.ts
452
454
  var uniqueIdFactory = (counter) => (str = "") => `${str}${++counter}`;
453
455
  var SLASHES = /* @__PURE__ */ new Set(["/", "\\"]);
@@ -524,9 +526,11 @@ var Warning = class extends Error {
524
526
  }
525
527
  };
526
528
  function createLogger(spinner) {
529
+ const logs = [];
527
530
  const log = (message) => {
528
531
  if (message && spinner) {
529
532
  spinner.text = message;
533
+ logs.push(message);
530
534
  }
531
535
  };
532
536
  const error = (message) => {
@@ -537,11 +541,13 @@ function createLogger(spinner) {
537
541
  const warn = (message) => {
538
542
  if (message && spinner) {
539
543
  spinner.warn(pc3.yellow(message));
544
+ logs.push(message);
540
545
  }
541
546
  };
542
547
  const info = (message) => {
543
548
  if (message && spinner) {
544
549
  spinner.info(message);
550
+ logs.push(message);
545
551
  }
546
552
  };
547
553
  const logger = {
@@ -549,7 +555,8 @@ function createLogger(spinner) {
549
555
  error,
550
556
  warn,
551
557
  info,
552
- spinner
558
+ spinner,
559
+ logs
553
560
  };
554
561
  return logger;
555
562
  }
@@ -1518,6 +1525,6 @@ var SchemaGenerator = class extends Generator {
1518
1525
  // src/index.ts
1519
1526
  var src_default = build;
1520
1527
 
1521
- export { FileManager, Generator, LogLevel, ParallelPluginError, PluginError, PluginManager, Queue, SchemaGenerator, SummaryError, TreeNode, URLPath, ValidationPluginError, Warning, build, clean, combineFiles, createJSDocBlockText, createLogger, createPlugin, createPluginCache, src_default as default, defaultColours, defineConfig, extensions, getDependedPlugins, getEncodedText, getFileSource, getIndexes, getLocation, getPathMode, getRelativePath, getUniqueName, hooks, importModule, isExtensionAllowed, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, pluginName as name, nameSorter, normalizeDirectory, objectToParameters, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord, uniqueIdFactory, write };
1528
+ export { FileManager, Generator, LogLevel, ParallelPluginError, PluginError, PluginManager, Queue, SchemaGenerator, SummaryError, TreeNode, URLPath, ValidationPluginError, Warning, build, clean, combineCodes, combineFiles, createJSDocBlockText, createLogger, createPlugin, createPluginCache, src_default as default, defaultColours, defineConfig, extensions, getDependedPlugins, getEncodedText, getFileSource, getIndexes, getLocation, getPathMode, getRelativePath, getUniqueName, hooks, importModule, isExtensionAllowed, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, pluginName as name, nameSorter, normalizeDirectory, objectToParameters, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord, uniqueIdFactory, write };
1522
1529
  //# sourceMappingURL=out.js.map
1523
1530
  //# sourceMappingURL=index.js.map