@kubb/core 1.1.6 → 1.1.8

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
@@ -13,7 +13,7 @@ interface Cache<T extends object = object> {
13
13
  }
14
14
  declare function createPluginCache<T extends Record<string, [number, unknown]>>(cache: T): Cache<T>;
15
15
 
16
- declare function getRelativePath(rootDir?: string | null, filePath?: string | null): string;
16
+ declare function getRelativePath(rootDir?: string | null, filePath?: string | null, platform?: 'windows' | 'mac' | 'linux'): string;
17
17
  type PathMode = 'file' | 'directory';
18
18
  declare function getPathMode(path: string | undefined | null): PathMode;
19
19
  declare function read(path: string): Promise<string>;
@@ -67,9 +67,9 @@ declare class TreeNode<T = unknown> {
67
67
  children: Array<TreeNode<T>>;
68
68
  constructor(data: T, parent?: TreeNode<T>);
69
69
  addChild(data: T): TreeNode<T>;
70
- find(data: T): {} | null;
71
- leaves(): TreeNode<T>[];
72
- root(): TreeNode<T>;
70
+ find(data?: T): TreeNode<T> | null;
71
+ get leaves(): TreeNode<T>[];
72
+ get root(): TreeNode<T>;
73
73
  forEach(callback: (treeNode: TreeNode<T>) => void): this;
74
74
  static build<T = unknown>(path: string, options?: TreeNodeOptions): TreeNode<T> | null;
75
75
  }
@@ -78,6 +78,8 @@ declare function transformReservedWord(word?: string | null): string | null | un
78
78
 
79
79
  declare function getStackTrace(belowFn?: Function): NodeJS.CallSite[];
80
80
 
81
+ declare const uniqueId: (str?: string) => string;
82
+
81
83
  type Import = {
82
84
  name: string | string[];
83
85
  path: string;
@@ -139,7 +141,7 @@ declare class FileManager {
139
141
  read(...params: Parameters<typeof read>): Promise<string>;
140
142
  }
141
143
 
142
- declare function writeIndexes(root: string, options: TreeNodeOptions): File[] | undefined;
144
+ declare function writeIndexes(root: string, options?: TreeNodeOptions): File[] | null;
143
145
  declare function combineFiles(files: Array<File | null>): File[];
144
146
  declare function getFileSource(file: File): string;
145
147
 
@@ -553,4 +555,4 @@ declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput>
553
555
  abstract build(schema: TInput, name: string, description?: string): TOutput;
554
556
  }
555
557
 
556
- export { Argument0, BuildOutput, CLIOptions, Cache, CacheStore, CorePluginOptions, Executer, File, FileManager, FileName, Generator, KubbConfig, KubbJSONPlugin, KubbObjectPlugin, KubbPlugin, KubbPluginKind, KubbUserConfig, LogLevel, Logger, MaybePromise, OnExecute, OptionalPath, ParallelPluginError, ParseResult, Path, PathMode, PluginContext, PluginError, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, Queue, QueueTask, Register, ResolveNameParams, ResolvePathParams, SafeParseResult, SchemaGenerator, Status, Strategy, TransformResult, TreeNode, TreeNodeOptions, UUID, ValidationPluginError, build, clean, combineFiles, createJSDocBlockText, createPlugin, createPluginCache, build as default, defineConfig, getEncodedText, getFileSource, getPathMode, getRelativePath, getStackTrace, getUniqueName, hooks, isPromise, isURL, name, nameSorter, objectToParameters, read, renderTemplate, timeout, transformReservedWord, validatePlugins, write, writeIndexes };
558
+ export { Argument0, BuildOutput, CLIOptions, Cache, CacheStore, CorePluginOptions, Executer, File, FileManager, FileName, Generator, KubbConfig, KubbJSONPlugin, KubbObjectPlugin, KubbPlugin, KubbPluginKind, KubbUserConfig, LogLevel, Logger, MaybePromise, OnExecute, OptionalPath, ParallelPluginError, ParseResult, Path, PathMode, PluginContext, PluginError, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, Queue, QueueTask, Register, ResolveNameParams, ResolvePathParams, SafeParseResult, SchemaGenerator, Status, Strategy, TransformResult, TreeNode, TreeNodeOptions, UUID, ValidationPluginError, build, clean, combineFiles, createJSDocBlockText, createPlugin, createPluginCache, build as default, defineConfig, getEncodedText, getFileSource, getPathMode, getRelativePath, getStackTrace, getUniqueName, hooks, isPromise, isURL, name, nameSorter, objectToParameters, read, renderTemplate, timeout, transformReservedWord, uniqueId, validatePlugins, write, writeIndexes };
package/dist/index.js CHANGED
@@ -1,34 +1,14 @@
1
1
  import { createRequire } from 'module';
2
- import pathParser2 from 'node:path';
2
+ import crypto from 'node:crypto';
3
3
  import { promises } from 'node:fs';
4
+ import pathParser2 from 'node:path';
4
5
  import { camelCase, camelCaseTransformMerge } from 'change-case';
5
6
  import { rimraf } from 'rimraf';
6
7
  import dirTree from 'directory-tree';
7
- import crypto from 'node:crypto';
8
8
  import { createImportDeclaration, print, createExportDeclaration } from '@kubb/ts-codegen';
9
9
 
10
10
  createRequire(import.meta.url);
11
11
 
12
- // src/managers/pluginManager/PluginError.ts
13
- var PluginError = class extends Error {
14
- pluginManager;
15
- constructor(message, options) {
16
- super(message, { cause: options.cause });
17
- this.pluginManager = options.pluginManager;
18
- }
19
- };
20
-
21
- // src/managers/pluginManager/ParallelPluginError.ts
22
- var ParallelPluginError = class extends Error {
23
- errors;
24
- pluginManager;
25
- constructor(message, options) {
26
- super(message, { cause: options.cause });
27
- this.errors = options.errors;
28
- this.pluginManager = options.pluginManager;
29
- }
30
- };
31
-
32
12
  // src/utils/isPromise.ts
33
13
  function isPromise(result) {
34
14
  return typeof result?.then === "function";
@@ -76,19 +56,19 @@ function createPluginCache(cache) {
76
56
  }
77
57
  };
78
58
  }
79
- function slash(path) {
59
+ function slash(path, platform = "linux") {
80
60
  const isExtendedLengthPath = /^\\\\\?\\/.test(path);
81
- if (isExtendedLengthPath) {
82
- return path;
61
+ if (isExtendedLengthPath || platform === "linux" || platform === "mac") {
62
+ return path.replace("../", "").trimEnd();
83
63
  }
84
- return path.replace(/\\/g, "/");
64
+ return path.replace(/\\/g, "/").replace("../", "").trimEnd();
85
65
  }
86
- function getRelativePath(rootDir, filePath) {
66
+ function getRelativePath(rootDir, filePath, platform = "linux") {
87
67
  if (!rootDir || !filePath) {
88
68
  throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir} ${filePath}`);
89
69
  }
90
70
  const relativePath = pathParser2.relative(rootDir, filePath);
91
- const path = slash(relativePath).replace("../", "").trimEnd();
71
+ const path = slash(relativePath, platform);
92
72
  if (path.startsWith("../")) {
93
73
  return path.replace(pathParser2.basename(path), pathParser2.basename(path, pathParser2.extname(filePath)));
94
74
  }
@@ -101,12 +81,7 @@ function getPathMode(path) {
101
81
  return pathParser2.extname(path) ? "file" : "directory";
102
82
  }
103
83
  async function read(path) {
104
- try {
105
- return promises.readFile(path, { encoding: "utf8" });
106
- } catch (err) {
107
- console.error(err);
108
- throw err;
109
- }
84
+ return promises.readFile(path, { encoding: "utf8" });
110
85
  }
111
86
 
112
87
  // src/utils/isURL.ts
@@ -243,10 +218,13 @@ var TreeNode = class {
243
218
  return child;
244
219
  }
245
220
  find(data) {
221
+ if (!data) {
222
+ return null;
223
+ }
246
224
  if (data === this.data) {
247
225
  return this;
248
226
  }
249
- if (this.children) {
227
+ if (this.children?.length) {
250
228
  for (let i = 0, { length } = this.children, target = null; i < length; i++) {
251
229
  target = this.children[i].find(data);
252
230
  if (target) {
@@ -256,23 +234,23 @@ var TreeNode = class {
256
234
  }
257
235
  return null;
258
236
  }
259
- leaves() {
237
+ get leaves() {
260
238
  if (!this.children || this.children.length === 0) {
261
239
  return [this];
262
240
  }
263
241
  const leaves = [];
264
242
  if (this.children) {
265
243
  for (let i = 0, { length } = this.children; i < length; i++) {
266
- leaves.push.apply(leaves, this.children[i].leaves());
244
+ leaves.push.apply(leaves, this.children[i].leaves);
267
245
  }
268
246
  }
269
247
  return leaves;
270
248
  }
271
- root() {
249
+ get root() {
272
250
  if (!this.parent) {
273
251
  return this;
274
252
  }
275
- return this.parent.root();
253
+ return this.parent.root;
276
254
  }
277
255
  forEach(callback) {
278
256
  if (typeof callback !== "function") {
@@ -287,21 +265,26 @@ var TreeNode = class {
287
265
  return this;
288
266
  }
289
267
  static build(path, options = {}) {
290
- const filteredTree = dirTree(path, { extensions: options?.extensions, exclude: options.exclude });
291
- if (!filteredTree) {
292
- return null;
293
- }
294
- const treeNode = new TreeNode({ name: filteredTree.name, path: filteredTree.path, type: filteredTree.type });
295
- const recurse = (node, item) => {
296
- const subNode = node.addChild({ name: item.name, path: item.path, type: item.type });
297
- if (item.children?.length) {
298
- item.children?.forEach((child) => {
299
- recurse(subNode, child);
300
- });
268
+ try {
269
+ const exclude = Array.isArray(options.exclude) ? options.exclude : [options.exclude].filter(Boolean);
270
+ const filteredTree = dirTree(path, { extensions: options.extensions, exclude: [/node_modules/, ...exclude] });
271
+ if (!filteredTree) {
272
+ return null;
301
273
  }
302
- };
303
- filteredTree.children?.forEach((child) => recurse(treeNode, child));
304
- return treeNode;
274
+ const treeNode = new TreeNode({ name: filteredTree.name, path: filteredTree.path, type: filteredTree.type || getPathMode(filteredTree.path) });
275
+ const recurse = (node, item) => {
276
+ const subNode = node.addChild({ name: item.name, path: item.path, type: item.type || getPathMode(item.path) });
277
+ if (item.children?.length) {
278
+ item.children?.forEach((child) => {
279
+ recurse(subNode, child);
280
+ });
281
+ }
282
+ };
283
+ filteredTree.children?.forEach((child) => recurse(treeNode, child));
284
+ return treeNode;
285
+ } catch (e) {
286
+ throw new Error("Something went wrong with creating index files with the TreehNode class", { cause: e });
287
+ }
305
288
  }
306
289
  };
307
290
 
@@ -414,76 +397,10 @@ function getStackTrace(belowFn) {
414
397
  return v8StackTrace;
415
398
  }
416
399
 
417
- // src/plugin.ts
418
- function createPlugin(factory) {
419
- return (options) => {
420
- const plugin = factory(options);
421
- if (Array.isArray(plugin)) {
422
- throw new Error("Not implemented");
423
- }
424
- if (!plugin.transform) {
425
- plugin.transform = function transform(code) {
426
- return code;
427
- };
428
- }
429
- return plugin;
430
- };
431
- }
432
- var name = "core";
433
- var definePlugin = createPlugin((options) => {
434
- const { fileManager, resolvePath, resolveName, load } = options;
435
- const api = {
436
- get config() {
437
- return options.config;
438
- },
439
- fileManager,
440
- async addFile(...files) {
441
- const trace = getStackTrace();
442
- const plugins = options.config.plugins?.filter((plugin) => trace[1].getFileName()?.includes(plugin.name)).sort((a, b) => {
443
- if (a.name.length < b.name.length)
444
- return 1;
445
- if (a.name.length > b.name.length)
446
- return -1;
447
- return 0;
448
- });
449
- const pluginName = plugins?.[0].name;
450
- return Promise.all(
451
- files.map((file) => {
452
- const fileWithMeta = {
453
- ...file,
454
- meta: {
455
- ...file.meta || {},
456
- pluginName
457
- }
458
- };
459
- if (file.override) {
460
- return fileManager.add(fileWithMeta);
461
- }
462
- return fileManager.addOrAppend(fileWithMeta);
463
- })
464
- );
465
- },
466
- resolvePath,
467
- resolveName: (params) => {
468
- const name2 = resolveName(params);
469
- return transformReservedWord(name2);
470
- },
471
- load,
472
- cache: createPluginCache(/* @__PURE__ */ Object.create(null))
473
- };
474
- return {
475
- name,
476
- options,
477
- api,
478
- resolvePath(fileName) {
479
- const root = pathParser2.resolve(this.config.root, this.config.output.path);
480
- return pathParser2.resolve(root, fileName);
481
- },
482
- resolveName(name2) {
483
- return name2;
484
- }
485
- };
486
- });
400
+ // src/utils/uniqueId.ts
401
+ var uniqueId = ((counter) => (str = "") => `${str}${++counter}`)(0);
402
+
403
+ // src/managers/fileManager/FileManager.ts
487
404
  var FileManager = class {
488
405
  cache = /* @__PURE__ */ new Map();
489
406
  task;
@@ -575,6 +492,219 @@ ${file.source}`,
575
492
  return read(...params);
576
493
  }
577
494
  };
495
+ function writeIndexes(root, options = {}) {
496
+ const tree = TreeNode.build(root, { extensions: /\.ts/, ...options });
497
+ if (!tree) {
498
+ return null;
499
+ }
500
+ const fileReducer = (files2, currentTree) => {
501
+ if (!currentTree.children) {
502
+ return [];
503
+ }
504
+ if (currentTree.children?.length > 1) {
505
+ const path = pathParser2.resolve(currentTree.data.path, "index.ts");
506
+ const exports = currentTree.children.map((file) => {
507
+ if (!file) {
508
+ return void 0;
509
+ }
510
+ const importPath = file.data.type === "directory" ? `./${file.data.name}` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
511
+ if (importPath.includes("index") && path.includes("index")) {
512
+ return void 0;
513
+ }
514
+ return { path: importPath };
515
+ }).filter(Boolean);
516
+ files2.push({
517
+ path,
518
+ fileName: "index.ts",
519
+ source: "",
520
+ exports
521
+ });
522
+ } else {
523
+ currentTree.children?.forEach((child) => {
524
+ const path = pathParser2.resolve(currentTree.data.path, "index.ts");
525
+ const importPath = child.data.type === "directory" ? `./${child.data.name}` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
526
+ files2.push({
527
+ path,
528
+ fileName: "index.ts",
529
+ source: "",
530
+ exports: [{ path: importPath }]
531
+ });
532
+ });
533
+ }
534
+ currentTree.children.forEach((childItem) => {
535
+ fileReducer(files2, childItem);
536
+ });
537
+ return files2;
538
+ };
539
+ const files = fileReducer([], tree);
540
+ return files;
541
+ }
542
+ function combineFiles(files) {
543
+ return files.filter(Boolean).reduce((acc, curr) => {
544
+ const prevIndex = acc.findIndex((item) => item.path === curr.path);
545
+ if (prevIndex !== -1) {
546
+ const prev = acc[prevIndex];
547
+ acc[prevIndex] = {
548
+ ...curr,
549
+ source: `${prev.source}
550
+ ${curr.source}`,
551
+ imports: [...prev.imports || [], ...curr.imports || []],
552
+ exports: [...prev.exports || [], ...curr.exports || []]
553
+ };
554
+ } else {
555
+ acc.push(curr);
556
+ }
557
+ return acc;
558
+ }, []);
559
+ }
560
+ function getFileSource(file) {
561
+ let { source } = file;
562
+ if (!file.fileName.endsWith(".ts")) {
563
+ return file.source;
564
+ }
565
+ const imports = [];
566
+ const exports = [];
567
+ file.imports?.forEach((curr) => {
568
+ const existingImport = imports.find((imp) => imp.path === curr.path);
569
+ if (!existingImport) {
570
+ imports.push({
571
+ ...curr,
572
+ name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
573
+ });
574
+ }
575
+ if (existingImport && !Array.isArray(existingImport.name) && existingImport.name !== curr.name) {
576
+ imports.push(curr);
577
+ }
578
+ if (existingImport && Array.isArray(existingImport.name)) {
579
+ if (Array.isArray(curr.name)) {
580
+ existingImport.name = [.../* @__PURE__ */ new Set([...existingImport.name, ...curr.name])];
581
+ }
582
+ }
583
+ });
584
+ file.exports?.forEach((curr) => {
585
+ const exists = exports.find((imp) => imp.path === curr.path);
586
+ if (!exists) {
587
+ exports.push({
588
+ ...curr,
589
+ name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
590
+ });
591
+ }
592
+ if (exists && !Array.isArray(exists.name) && exists.name !== curr.name && exists.asAlias === curr.asAlias) {
593
+ exports.push(curr);
594
+ }
595
+ if (exists && Array.isArray(exists.name)) {
596
+ if (Array.isArray(curr.name)) {
597
+ exists.name = [.../* @__PURE__ */ new Set([...exists.name, ...curr.name])];
598
+ }
599
+ }
600
+ });
601
+ const importNodes = imports.reduce((prev, curr) => {
602
+ return [...prev, createImportDeclaration({ name: curr.name, path: curr.path, isTypeOnly: curr.isTypeOnly })];
603
+ }, []);
604
+ const importSource = print(importNodes);
605
+ const exportNodes = exports.reduce((prev, curr) => {
606
+ return [...prev, createExportDeclaration({ name: curr.name, path: curr.path, isTypeOnly: curr.isTypeOnly, asAlias: curr.asAlias })];
607
+ }, []);
608
+ const exportSource = print(exportNodes);
609
+ if (importSource) {
610
+ source = `${importSource}
611
+ ${source}`;
612
+ }
613
+ if (exportSource) {
614
+ source = `${exportSource}
615
+ ${source}`;
616
+ }
617
+ return source;
618
+ }
619
+ function createPlugin(factory) {
620
+ return (options) => {
621
+ const plugin = factory(options);
622
+ if (Array.isArray(plugin)) {
623
+ throw new Error("Not implemented");
624
+ }
625
+ if (!plugin.transform) {
626
+ plugin.transform = function transform(code) {
627
+ return code;
628
+ };
629
+ }
630
+ return plugin;
631
+ };
632
+ }
633
+ var name = "core";
634
+ var definePlugin = createPlugin((options) => {
635
+ const { fileManager, resolvePath, resolveName, load } = options;
636
+ const api = {
637
+ get config() {
638
+ return options.config;
639
+ },
640
+ fileManager,
641
+ async addFile(...files) {
642
+ const trace = getStackTrace();
643
+ const plugins = options.config.plugins?.filter((plugin) => trace[1].getFileName()?.includes(plugin.name)).sort((a, b) => {
644
+ if (a.name.length < b.name.length)
645
+ return 1;
646
+ if (a.name.length > b.name.length)
647
+ return -1;
648
+ return 0;
649
+ });
650
+ const pluginName = plugins?.[0].name;
651
+ return Promise.all(
652
+ files.map((file) => {
653
+ const fileWithMeta = {
654
+ ...file,
655
+ meta: {
656
+ ...file.meta || {},
657
+ pluginName
658
+ }
659
+ };
660
+ if (file.override) {
661
+ return fileManager.add(fileWithMeta);
662
+ }
663
+ return fileManager.addOrAppend(fileWithMeta);
664
+ })
665
+ );
666
+ },
667
+ resolvePath,
668
+ resolveName: (params) => {
669
+ const name2 = resolveName(params);
670
+ return transformReservedWord(name2);
671
+ },
672
+ load,
673
+ cache: createPluginCache(/* @__PURE__ */ Object.create(null))
674
+ };
675
+ return {
676
+ name,
677
+ options,
678
+ api,
679
+ resolvePath(fileName) {
680
+ const root = pathParser2.resolve(this.config.root, this.config.output.path);
681
+ return pathParser2.resolve(root, fileName);
682
+ },
683
+ resolveName(name2) {
684
+ return name2;
685
+ }
686
+ };
687
+ });
688
+
689
+ // src/managers/pluginManager/ParallelPluginError.ts
690
+ var ParallelPluginError = class extends Error {
691
+ errors;
692
+ pluginManager;
693
+ constructor(message, options) {
694
+ super(message, { cause: options.cause });
695
+ this.errors = options.errors;
696
+ this.pluginManager = options.pluginManager;
697
+ }
698
+ };
699
+
700
+ // src/managers/pluginManager/PluginError.ts
701
+ var PluginError = class extends Error {
702
+ pluginManager;
703
+ constructor(message, options) {
704
+ super(message, { cause: options.cause });
705
+ this.pluginManager = options.pluginManager;
706
+ }
707
+ };
578
708
 
579
709
  // src/managers/pluginManager/PluginManager.ts
580
710
  var hookNames = {
@@ -932,133 +1062,6 @@ function validatePlugins(plugins, dependedPluginNames) {
932
1062
  });
933
1063
  return true;
934
1064
  }
935
- function writeIndexes(root, options) {
936
- const tree = TreeNode.build(root, { extensions: /\.ts/, ...options });
937
- if (!tree) {
938
- return void 0;
939
- }
940
- const fileReducer = (files2, item) => {
941
- if (!item.children) {
942
- return [];
943
- }
944
- if (item.children?.length > 1) {
945
- const path = pathParser2.resolve(item.data.path, "index.ts");
946
- const exports = item.children.map((file) => {
947
- if (!file) {
948
- return void 0;
949
- }
950
- const importPath = file.data.type === "directory" ? `./${file.data.name}` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
951
- if (importPath.includes("index") && path.includes("index")) {
952
- return void 0;
953
- }
954
- return { path: importPath };
955
- }).filter(Boolean);
956
- files2.push({
957
- path,
958
- fileName: "index.ts",
959
- source: "",
960
- exports
961
- });
962
- } else {
963
- item.children?.forEach((child) => {
964
- const path = pathParser2.resolve(item.data.path, "index.ts");
965
- const importPath = child.data.type === "directory" ? `./${child.data.name}` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
966
- files2.push({
967
- path,
968
- fileName: "index.ts",
969
- source: "",
970
- exports: [{ path: importPath }]
971
- });
972
- });
973
- }
974
- item.children.forEach((childItem) => {
975
- fileReducer(files2, childItem);
976
- });
977
- return files2;
978
- };
979
- const files = fileReducer([], tree);
980
- return files;
981
- }
982
- function combineFiles(files) {
983
- return files.filter(Boolean).reduce((acc, curr) => {
984
- if (!curr) {
985
- return acc;
986
- }
987
- const prevIndex = acc.findIndex((item) => item.path === curr.path);
988
- if (prevIndex !== -1) {
989
- const prev = acc[prevIndex];
990
- acc[prevIndex] = {
991
- ...curr,
992
- source: `${prev.source}
993
- ${curr.source}`,
994
- imports: [...prev.imports || [], ...curr.imports || []],
995
- exports: [...prev.exports || [], ...curr.exports || []]
996
- };
997
- } else {
998
- acc.push(curr);
999
- }
1000
- return acc;
1001
- }, []);
1002
- }
1003
- function getFileSource(file) {
1004
- let { source } = file;
1005
- if (!file.fileName.endsWith(".ts")) {
1006
- return file.source;
1007
- }
1008
- const imports = [];
1009
- const exports = [];
1010
- file.imports?.forEach((curr) => {
1011
- const exists = imports.find((imp) => imp.path === curr.path);
1012
- if (!exists) {
1013
- imports.push({
1014
- ...curr,
1015
- name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
1016
- });
1017
- }
1018
- if (exists && !Array.isArray(exists.name) && exists.name !== curr.name) {
1019
- imports.push(curr);
1020
- }
1021
- if (exists && Array.isArray(exists.name)) {
1022
- if (Array.isArray(curr.name)) {
1023
- exists.name = [.../* @__PURE__ */ new Set([...exists.name, ...curr.name])];
1024
- }
1025
- }
1026
- });
1027
- file.exports?.forEach((curr) => {
1028
- const exists = exports.find((imp) => imp.path === curr.path);
1029
- if (!exists) {
1030
- exports.push({
1031
- ...curr,
1032
- name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
1033
- });
1034
- }
1035
- if (exists && !Array.isArray(exists.name) && exists.name !== curr.name && exists.asAlias === curr.asAlias) {
1036
- exports.push(curr);
1037
- }
1038
- if (exists && Array.isArray(exists.name)) {
1039
- if (Array.isArray(curr.name)) {
1040
- exists.name = [.../* @__PURE__ */ new Set([...exists.name, ...curr.name])];
1041
- }
1042
- }
1043
- });
1044
- const importNodes = imports.reduce((prev, curr) => {
1045
- return [...prev, createImportDeclaration({ name: curr.name, path: curr.path, isTypeOnly: curr.isTypeOnly })];
1046
- }, []);
1047
- const importSource = print(importNodes);
1048
- const exportNodes = exports.reduce((prev, curr) => {
1049
- return [...prev, createExportDeclaration({ name: curr.name, path: curr.path, asAlias: curr.asAlias })];
1050
- }, []);
1051
- const exportSource = print(exportNodes);
1052
- if (importSource) {
1053
- source = `${importSource}
1054
- ${source}`;
1055
- }
1056
- if (exportSource) {
1057
- source = `${exportSource}
1058
- ${source}`;
1059
- }
1060
- return source;
1061
- }
1062
1065
 
1063
1066
  // src/build.ts
1064
1067
  async function transformReducer(_previousCode, result, _plugin) {
@@ -1071,7 +1074,7 @@ async function build(options) {
1071
1074
  await read(config.input.path);
1072
1075
  }
1073
1076
  } catch (e) {
1074
- throw new Error("Cannot read file defined in `input.path` or set with --input in the CLI of your Kubb config", { cause: e });
1077
+ throw new Error("Cannot read file/URL defined in `input.path` or set with --input in the CLI of your Kubb config", { cause: e });
1075
1078
  }
1076
1079
  if (config.output.clean) {
1077
1080
  await clean(config.output.path);
@@ -1154,4 +1157,4 @@ var SchemaGenerator = class extends Generator {
1154
1157
  // src/index.ts
1155
1158
  var src_default = build;
1156
1159
 
1157
- export { FileManager, Generator, ParallelPluginError, PluginError, PluginManager, Queue, SchemaGenerator, TreeNode, ValidationPluginError, build, clean, combineFiles, createJSDocBlockText, createPlugin, createPluginCache, src_default as default, defineConfig, getEncodedText, getFileSource, getPathMode, getRelativePath, getStackTrace, getUniqueName, hooks, isPromise, isURL, name, nameSorter, objectToParameters, read, renderTemplate, timeout, transformReservedWord, validatePlugins, write, writeIndexes };
1160
+ export { FileManager, Generator, ParallelPluginError, PluginError, PluginManager, Queue, SchemaGenerator, TreeNode, ValidationPluginError, build, clean, combineFiles, createJSDocBlockText, createPlugin, createPluginCache, src_default as default, defineConfig, getEncodedText, getFileSource, getPathMode, getRelativePath, getStackTrace, getUniqueName, hooks, isPromise, isURL, name, nameSorter, objectToParameters, read, renderTemplate, timeout, transformReservedWord, uniqueId, validatePlugins, write, writeIndexes };