@kubb/agent 5.0.0-alpha.54 → 5.0.0-alpha.56

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "date": "2026-04-23T11:15:32.169Z",
2
+ "date": "2026-04-23T19:03:10.169Z",
3
3
  "preset": "node-server",
4
4
  "framework": {
5
5
  "name": "nitro",
@@ -7,7 +7,7 @@ import https, { Server } from 'node:https';
7
7
  import { EventEmitter } from 'node:events';
8
8
  import { Buffer as Buffer$1 } from 'node:buffer';
9
9
  import { promises, existsSync, readdirSync } from 'node:fs';
10
- import path$1, { resolve, dirname, relative, join, extname, posix } from 'node:path';
10
+ import path$1, { resolve, dirname, relative, join, extname } from 'node:path';
11
11
  import anymatch from 'anymatch';
12
12
  import { createHash, randomBytes } from 'node:crypto';
13
13
  import process$1, { version as version$2 } from 'node:process';
@@ -4672,7 +4672,7 @@ var __name = (target, value) => __defProp$2(target, "name", {
4672
4672
  const visitorDepths = {
4673
4673
  deep: "deep"
4674
4674
  };
4675
- function trimExtName$2(text) {
4675
+ function trimExtName(text) {
4676
4676
  const dotIndex = text.lastIndexOf(".");
4677
4677
  if (dotIndex > 0 && !text.includes("/", dotIndex)) return text.slice(0, dotIndex);
4678
4678
  return text;
@@ -4837,18 +4837,6 @@ function createParameter(props) {
4837
4837
  schema: syncOptionality(props.schema, required)
4838
4838
  };
4839
4839
  }
4840
- function createExport(props) {
4841
- return {
4842
- ...props,
4843
- kind: "Export"
4844
- };
4845
- }
4846
- function createSource(props) {
4847
- return {
4848
- ...props,
4849
- kind: "Source"
4850
- };
4851
- }
4852
4840
  function createFile(input) {
4853
4841
  var _a, _b, _c, _d, _e;
4854
4842
  const extname = path$1.extname(input.baseName) || (input.baseName.startsWith(".") ? input.baseName : "");
@@ -4864,7 +4852,7 @@ function createFile(input) {
4864
4852
  kind: "File",
4865
4853
  ...input,
4866
4854
  id: createHash("sha256").update(input.path).digest("hex"),
4867
- name: trimExtName$2(input.baseName),
4855
+ name: trimExtName(input.baseName),
4868
4856
  extname,
4869
4857
  imports: resolvedImports,
4870
4858
  exports: resolvedExports,
@@ -5134,14 +5122,7 @@ function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) {
5134
5122
  }) : camelCase(part));
5135
5123
  return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
5136
5124
  }
5137
- function trimExtName$1(text) {
5138
- const dotIndex = text.lastIndexOf(".");
5139
- if (dotIndex > 0 && !text.includes("/", dotIndex)) return text.slice(0, dotIndex);
5140
- return text;
5141
- }
5142
5125
  const DEFAULT_STUDIO_URL = "https://studio.kubb.dev";
5143
- const BARREL_BASENAME = "index";
5144
- const BARREL_FILENAME = `${BARREL_BASENAME}.ts`;
5145
5126
  const DEFAULT_BANNER = "simple";
5146
5127
  const DEFAULT_EXTENSION = { ".ts": ".ts" };
5147
5128
  const stringPatternCache = /* @__PURE__ */ new Map();
@@ -5396,30 +5377,19 @@ var FileManager = (_a$1 = class {
5396
5377
  }
5397
5378
  /**
5398
5379
  * All stored files, sorted by path length (shorter paths first).
5399
- * Barrel/index files (e.g. index.ts) are sorted last within each length bucket.
5400
5380
  */
5401
5381
  get files() {
5402
5382
  if (__privateGet$1(this, _filesCache)) return __privateGet$1(this, _filesCache);
5403
- const keys = [...__privateGet$1(this, _cache).keys()];
5404
- const meta = /* @__PURE__ */ new Map();
5405
- for (const key of keys) meta.set(key, {
5406
- length: key.length,
5407
- isIndex: trimExtName$1(key).endsWith(BARREL_BASENAME)
5408
- });
5409
- keys.sort((a, b) => {
5410
- const ma = meta.get(a);
5411
- const mb = meta.get(b);
5412
- if (ma.length !== mb.length) return ma.length - mb.length;
5413
- if (ma.isIndex !== mb.isIndex) return ma.isIndex ? 1 : -1;
5383
+ __privateSet$1(this, _filesCache, [...__privateGet$1(this, _cache).values()].sort((a, b) => {
5384
+ const lenDiff = a.path.length - b.path.length;
5385
+ if (lenDiff !== 0) return lenDiff;
5386
+ const aIsIndex = a.path.endsWith("/index.ts") || a.path === "index.ts";
5387
+ const bIsIndex = b.path.endsWith("/index.ts") || b.path === "index.ts";
5388
+ if (aIsIndex && !bIsIndex) return 1;
5389
+ if (!aIsIndex && bIsIndex) return -1;
5414
5390
  return 0;
5415
- });
5416
- const files = [];
5417
- for (const key of keys) {
5418
- const file = __privateGet$1(this, _cache).get(key);
5419
- if (file) files.push(file);
5420
- }
5421
- __privateSet$1(this, _filesCache, files);
5422
- return files;
5391
+ }));
5392
+ return __privateGet$1(this, _filesCache);
5423
5393
  }
5424
5394
  }, _cache = new WeakMap(), _filesCache = new WeakMap(), _a$1);
5425
5395
  async function applyHookResult(result, driver, rendererFactory) {
@@ -5434,6 +5404,9 @@ async function applyHookResult(result, driver, rendererFactory) {
5434
5404
  driver.fileManager.upsert(...renderer.files);
5435
5405
  renderer.unmount();
5436
5406
  }
5407
+ function enforceOrder(enforce) {
5408
+ return enforce === "pre" ? -1 : enforce === "post" ? 1 : 0;
5409
+ }
5437
5410
  var PluginDriver = (_b$1 = class {
5438
5411
  constructor(config, options) {
5439
5412
  __privateAdd$1(this, _PluginDriver_instances);
@@ -5470,7 +5443,7 @@ var PluginDriver = (_b$1 = class {
5470
5443
  var _a2, _b2;
5471
5444
  if ((_a2 = b.dependencies) == null ? void 0 : _a2.includes(a.name)) return -1;
5472
5445
  if ((_b2 = a.dependencies) == null ? void 0 : _b2.includes(b.name)) return 1;
5473
- return 0;
5446
+ return enforceOrder(a.enforce) - enforceOrder(b.enforce);
5474
5447
  }).forEach((plugin) => {
5475
5448
  this.plugins.set(plugin.name, plugin);
5476
5449
  });
@@ -5728,6 +5701,7 @@ normalizePlugin_fn = function(hookPlugin) {
5728
5701
  const normalizedPlugin = {
5729
5702
  name: hookPlugin.name,
5730
5703
  dependencies: hookPlugin.dependencies,
5704
+ enforce: hookPlugin.enforce,
5731
5705
  options: {
5732
5706
  output: { path: "." },
5733
5707
  exclude: [],
@@ -5773,7 +5747,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
5773
5747
  return __privateGet(obj, member, getter);
5774
5748
  }
5775
5749
  });
5776
- var _emitter, _a, _options, _URLPath_instances, transformParam_fn, eachParam_fn, _b, _c, _head, _tail, _size, _d, _limit, _e, _cachedLeaves, _f;
5750
+ var _emitter, _a, _options, _URLPath_instances, transformParam_fn, eachParam_fn, _b, _c, _head, _tail, _size, _d, _limit, _e;
5777
5751
  var BuildError = class extends Error {
5778
5752
  constructor(message, options) {
5779
5753
  super(message, { cause: options.cause });
@@ -5889,23 +5863,14 @@ function formatMs(ms) {
5889
5863
  if (ms >= 1e3) return `${(ms / 1e3).toFixed(2)}s`;
5890
5864
  return `${Math.round(ms)}ms`;
5891
5865
  }
5892
- function toSlash(p) {
5893
- if (p.startsWith("\\\\?\\")) return p;
5894
- return p.replaceAll("\\", "/");
5895
- }
5896
- function getRelativePath(rootDir, filePath) {
5897
- if (!rootDir || !filePath) throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
5898
- const relativePath = posix.relative(toSlash(rootDir), toSlash(filePath));
5899
- return relativePath.startsWith("../") ? relativePath : `./${relativePath}`;
5866
+ async function exists(path) {
5867
+ if (typeof Bun !== "undefined") return Bun.file(path).exists();
5868
+ return access(path).then(() => true, () => false);
5900
5869
  }
5901
- async function exists(path2) {
5902
- if (typeof Bun !== "undefined") return Bun.file(path2).exists();
5903
- return access(path2).then(() => true, () => false);
5904
- }
5905
- async function write(path2, data, options = {}) {
5870
+ async function write(path, data, options = {}) {
5906
5871
  const trimmed = data.trim();
5907
5872
  if (trimmed === "") return null;
5908
- const resolved = resolve(path2);
5873
+ const resolved = resolve(path);
5909
5874
  if (typeof Bun !== "undefined") {
5910
5875
  const file = Bun.file(resolved);
5911
5876
  if ((await file.exists() ? await file.text() : null) === trimmed) return null;
@@ -5920,7 +5885,7 @@ async function write(path2, data, options = {}) {
5920
5885
  await writeFile$1(resolved, trimmed, { encoding: "utf-8" });
5921
5886
  if (options.sanity) {
5922
5887
  const savedData = await readFile$1(resolved, { encoding: "utf-8" });
5923
- if (savedData !== trimmed) throw new Error(`Sanity check failed for ${path2}
5888
+ if (savedData !== trimmed) throw new Error(`Sanity check failed for ${path}
5924
5889
 
5925
5890
  Data[${data.length}]:
5926
5891
  ${data}
@@ -5932,8 +5897,8 @@ ${savedData}
5932
5897
  }
5933
5898
  return trimmed;
5934
5899
  }
5935
- async function clean(path2) {
5936
- return rm(path2, {
5900
+ async function clean(path) {
5901
+ return rm(path, {
5937
5902
  recursive: true,
5938
5903
  force: true
5939
5904
  });
@@ -5947,14 +5912,14 @@ function isValidVarName(name) {
5947
5912
  return true;
5948
5913
  }
5949
5914
  var URLPath = (_b = class {
5950
- constructor(path2, options = {}) {
5915
+ constructor(path, options = {}) {
5951
5916
  __privateAdd(this, _URLPath_instances);
5952
5917
  /**
5953
5918
  * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.
5954
5919
  */
5955
5920
  __publicField(this, "path");
5956
5921
  __privateAdd(this, _options);
5957
- this.path = path2;
5922
+ this.path = path;
5958
5923
  __privateSet(this, _options, options);
5959
5924
  }
5960
5925
  /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.
@@ -6300,7 +6265,7 @@ const fsStorage = createStorage(() => ({
6300
6265
  await clean(resolve(base));
6301
6266
  }
6302
6267
  }));
6303
- var version$1 = "5.0.0-alpha.54";
6268
+ var version$1 = "5.0.0-alpha.56";
6304
6269
  function getDiagnosticInfo() {
6305
6270
  return {
6306
6271
  nodeVersion: version$2,
@@ -6310,229 +6275,11 @@ function getDiagnosticInfo() {
6310
6275
  cwd: process.cwd()
6311
6276
  };
6312
6277
  }
6313
- var TreeNode = (_f = class {
6314
- constructor(data, parent) {
6315
- __publicField(this, "data");
6316
- __publicField(this, "parent");
6317
- __publicField(this, "children", []);
6318
- __privateAdd(this, _cachedLeaves);
6319
- this.data = data;
6320
- this.parent = parent;
6321
- }
6322
- addChild(data) {
6323
- const child = new _f(data, this);
6324
- if (!this.children) this.children = [];
6325
- this.children.push(child);
6326
- return child;
6327
- }
6328
- /**
6329
- * Returns the root ancestor of this node, walking up via `parent` links.
6330
- */
6331
- get root() {
6332
- if (!this.parent) return this;
6333
- return this.parent.root;
6334
- }
6335
- /**
6336
- * Returns all leaf descendants (nodes with no children) of this node.
6337
- *
6338
- * Results are cached after the first traversal.
6339
- */
6340
- get leaves() {
6341
- if (!this.children || this.children.length === 0) return [this];
6342
- if (__privateGet(this, _cachedLeaves)) return __privateGet(this, _cachedLeaves);
6343
- const leaves = [];
6344
- for (const child of this.children) leaves.push(...child.leaves);
6345
- __privateSet(this, _cachedLeaves, leaves);
6346
- return leaves;
6347
- }
6348
- /**
6349
- * Visits this node and every descendant in depth-first order.
6350
- */
6351
- forEach(callback) {
6352
- if (typeof callback !== "function") throw new TypeError("forEach() callback must be a function");
6353
- callback(this);
6354
- for (const child of this.children) child.forEach(callback);
6355
- return this;
6356
- }
6357
- /**
6358
- * Finds the first leaf that satisfies `predicate`, or `undefined` when none match.
6359
- */
6360
- findDeep(predicate) {
6361
- if (typeof predicate !== "function") throw new TypeError("find() predicate must be a function");
6362
- return this.leaves.find(predicate);
6363
- }
6364
- /**
6365
- * Calls `callback` for every leaf of this node.
6366
- */
6367
- forEachDeep(callback) {
6368
- if (typeof callback !== "function") throw new TypeError("forEach() callback must be a function");
6369
- this.leaves.forEach(callback);
6370
- }
6371
- /**
6372
- * Returns all leaves that satisfy `callback`.
6373
- */
6374
- filterDeep(callback) {
6375
- if (typeof callback !== "function") throw new TypeError("filter() callback must be a function");
6376
- return this.leaves.filter(callback);
6377
- }
6378
- /**
6379
- * Maps every leaf through `callback` and returns the resulting array.
6380
- */
6381
- mapDeep(callback) {
6382
- if (typeof callback !== "function") throw new TypeError("map() callback must be a function");
6383
- return this.leaves.map(callback);
6384
- }
6385
- /**
6386
- * Builds a {@link TreeNode} tree from a flat list of files.
6387
- *
6388
- * - Filters to files under `root` (when provided) and skips `.json` files.
6389
- * - Returns `null` when no files match.
6390
- */
6391
- static build(files, root) {
6392
- var _a2;
6393
- try {
6394
- const filteredTree = buildDirectoryTree(files, root);
6395
- if (!filteredTree) return null;
6396
- const treeNode = new _f({
6397
- name: filteredTree.name,
6398
- path: filteredTree.path,
6399
- file: filteredTree.file,
6400
- type: PluginDriver.getMode(filteredTree.path)
6401
- });
6402
- const recurse = (node, item) => {
6403
- var _a3, _b2;
6404
- const subNode = node.addChild({
6405
- name: item.name,
6406
- path: item.path,
6407
- file: item.file,
6408
- type: PluginDriver.getMode(item.path)
6409
- });
6410
- if ((_a3 = item.children) == null ? void 0 : _a3.length) (_b2 = item.children) == null ? void 0 : _b2.forEach((child) => {
6411
- recurse(subNode, child);
6412
- });
6413
- };
6414
- (_a2 = filteredTree.children) == null ? void 0 : _a2.forEach((child) => {
6415
- recurse(treeNode, child);
6416
- });
6417
- return treeNode;
6418
- } catch (error) {
6419
- throw new Error("Something went wrong with creating barrel files with the TreeNode class", { cause: error });
6420
- }
6421
- }
6422
- }, _cachedLeaves = new WeakMap(), _f);
6423
- const normalizePath = (p) => p.replaceAll("\\", "/");
6424
- function buildDirectoryTree(files, rootFolder = "") {
6425
- const normalizedRootFolder = normalizePath(rootFolder);
6426
- const rootPrefix = normalizedRootFolder.endsWith("/") ? normalizedRootFolder : `${normalizedRootFolder}/`;
6427
- const filteredFiles = files.filter((file) => {
6428
- const normalizedFilePath = normalizePath(file.path);
6429
- return rootFolder ? normalizedFilePath.startsWith(rootPrefix) && !normalizedFilePath.endsWith(".json") : !normalizedFilePath.endsWith(".json");
6430
- });
6431
- if (filteredFiles.length === 0) return null;
6432
- const root = {
6433
- name: rootFolder || "",
6434
- path: rootFolder || "",
6435
- children: []
6436
- };
6437
- filteredFiles.forEach((file) => {
6438
- const parts = file.path.slice(rootFolder.length).split("/").filter(Boolean);
6439
- let currentLevel = root.children;
6440
- let currentPath = normalizePath(rootFolder);
6441
- parts.forEach((part, index) => {
6442
- currentPath = path$1.posix.join(currentPath, part);
6443
- let existingNode = currentLevel.find((node) => node.name === part);
6444
- if (!existingNode) {
6445
- if (index === parts.length - 1) existingNode = {
6446
- name: part,
6447
- file,
6448
- path: currentPath
6449
- };
6450
- else existingNode = {
6451
- name: part,
6452
- path: currentPath,
6453
- children: []
6454
- };
6455
- currentLevel.push(existingNode);
6456
- }
6457
- if (!existingNode.file) currentLevel = existingNode.children;
6458
- });
6459
- });
6460
- return root;
6461
- }
6462
- function getBarrelFilesByRoot(root, files) {
6463
- var _a2;
6464
- const cachedFiles = /* @__PURE__ */ new Map();
6465
- (_a2 = TreeNode.build(files, root)) == null ? void 0 : _a2.forEach((treeNode) => {
6466
- var _a3, _b2;
6467
- if (!(treeNode == null ? void 0 : treeNode.children) || !((_a3 = treeNode.parent) == null ? void 0 : _a3.data.path)) return;
6468
- const barrelFile = createFile({
6469
- path: join((_b2 = treeNode.parent) == null ? void 0 : _b2.data.path, BARREL_FILENAME),
6470
- baseName: BARREL_FILENAME,
6471
- exports: [],
6472
- imports: [],
6473
- sources: []
6474
- });
6475
- const previousBarrelFile = cachedFiles.get(barrelFile.path);
6476
- treeNode.leaves.forEach((item) => {
6477
- var _a4;
6478
- if (!item.data.name) return;
6479
- (((_a4 = item.data.file) == null ? void 0 : _a4.sources) || []).forEach((source) => {
6480
- var _a5, _b3;
6481
- if (!((_a5 = item.data.file) == null ? void 0 : _a5.path) || !source.isIndexable || !source.name) return;
6482
- if (previousBarrelFile == null ? void 0 : previousBarrelFile.sources.some((item2) => item2.name === source.name && item2.isTypeOnly === source.isTypeOnly)) return;
6483
- barrelFile.exports.push(createExport({
6484
- name: [source.name],
6485
- path: getRelativePath((_b3 = treeNode.parent) == null ? void 0 : _b3.data.path, item.data.path),
6486
- isTypeOnly: source.isTypeOnly
6487
- }));
6488
- barrelFile.sources.push(createSource({
6489
- name: source.name,
6490
- isTypeOnly: source.isTypeOnly,
6491
- isExportable: false,
6492
- isIndexable: false
6493
- }));
6494
- });
6495
- });
6496
- if (previousBarrelFile) {
6497
- previousBarrelFile.sources.push(...barrelFile.sources);
6498
- previousBarrelFile.exports.push(...barrelFile.exports);
6499
- } else cachedFiles.set(barrelFile.path, barrelFile);
6500
- });
6501
- return [...cachedFiles.values()];
6502
- }
6503
- function trimExtName(text) {
6504
- const dotIndex = text.lastIndexOf(".");
6505
- if (dotIndex > 0 && !text.includes("/", dotIndex)) return text.slice(0, dotIndex);
6506
- return text;
6507
- }
6508
- async function getBarrelFiles(files, { type, meta = {}, root, output }) {
6509
- if (!type || type === "propagate") return [];
6510
- const pathToBuildFrom = join(root, output.path);
6511
- if (trimExtName(pathToBuildFrom).endsWith("index")) return [];
6512
- const barrelFiles = getBarrelFilesByRoot(pathToBuildFrom, files);
6513
- if (type === "all") return barrelFiles.map((file) => {
6514
- return {
6515
- ...file,
6516
- exports: file.exports.map((exportItem) => {
6517
- return {
6518
- ...exportItem,
6519
- name: void 0
6520
- };
6521
- })
6522
- };
6523
- });
6524
- return barrelFiles.map((indexFile) => {
6525
- return {
6526
- ...indexFile,
6527
- meta
6528
- };
6529
- });
6530
- }
6531
6278
  function isInputPath(config) {
6532
6279
  return typeof (config == null ? void 0 : config.input) === "object" && config.input !== null && "path" in config.input;
6533
6280
  }
6534
6281
  async function setup(userConfig, options = {}) {
6535
- var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i;
6282
+ var _a2, _b2, _c2, _d2, _e2, _f, _g, _h, _i, _j;
6536
6283
  const hooks = (_a2 = options.hooks) != null ? _a2 : new AsyncEventEmitter();
6537
6284
  const sources = /* @__PURE__ */ new Map();
6538
6285
  const diagnosticInfo = getDiagnosticInfo();
@@ -6547,7 +6294,7 @@ async function setup(userConfig, options = {}) {
6547
6294
  ` \u2022 Plugins: ${((_c2 = userConfig.plugins) == null ? void 0 : _c2.length) || 0}`,
6548
6295
  "Output Settings:",
6549
6296
  ` \u2022 Storage: ${((_d2 = userConfig.output) == null ? void 0 : _d2.storage) ? `custom(${userConfig.output.storage.name})` : ((_e2 = userConfig.output) == null ? void 0 : _e2.write) === false ? "disabled" : "filesystem (default)"}`,
6550
- ` \u2022 Formatter: ${((_f2 = userConfig.output) == null ? void 0 : _f2.format) || "none"}`,
6297
+ ` \u2022 Formatter: ${((_f = userConfig.output) == null ? void 0 : _f.format) || "none"}`,
6551
6298
  ` \u2022 Linter: ${((_g = userConfig.output) == null ? void 0 : _g.lint) || "none"}`,
6552
6299
  "Environment:",
6553
6300
  Object.entries(diagnosticInfo).map(([key, value]) => ` \u2022 ${key}: ${value}`).join("\n")
@@ -6575,7 +6322,6 @@ async function setup(userConfig, options = {}) {
6575
6322
  adapter: userConfig.adapter,
6576
6323
  output: {
6577
6324
  write: true,
6578
- barrelType: "named",
6579
6325
  extension: DEFAULT_EXTENSION,
6580
6326
  defaultBanner: DEFAULT_BANNER,
6581
6327
  ...userConfig.output
@@ -6595,6 +6341,7 @@ async function setup(userConfig, options = {}) {
6595
6341
  await (storage == null ? void 0 : storage.clear(resolve(config.root, config.output.path)));
6596
6342
  }
6597
6343
  const driver = new PluginDriver(config, { hooks });
6344
+ for (const middleware of (_j = config.middleware) != null ? _j : []) middleware.install(hooks);
6598
6345
  const adapter = config.adapter;
6599
6346
  if (!adapter) throw new Error("No adapter configured. Please provide an adapter in your kubb.config.ts.");
6600
6347
  const source = inputToAdapterSource(config);
@@ -6691,7 +6438,7 @@ async function runPluginAstHooks(plugin, context) {
6691
6438
  }
6692
6439
  }
6693
6440
  async function safeBuild(setupResult) {
6694
- var _a2, _b2, _c2, _d2, _e2, _f2;
6441
+ var _a2;
6695
6442
  const { driver, hooks, sources, storage } = setupResult;
6696
6443
  const failedPlugins = /* @__PURE__ */ new Set();
6697
6444
  const pluginTimings = /* @__PURE__ */ new Map();
@@ -6702,13 +6449,15 @@ async function safeBuild(setupResult) {
6702
6449
  config,
6703
6450
  adapter: driver.adapter,
6704
6451
  inputNode: driver.inputNode,
6705
- getPlugin: driver.getPlugin.bind(driver)
6452
+ getPlugin: driver.getPlugin.bind(driver),
6453
+ get files() {
6454
+ return driver.fileManager.files;
6455
+ },
6456
+ upsertFile: (...files2) => driver.fileManager.upsert(...files2)
6706
6457
  });
6707
6458
  for (const plugin of driver.plugins.values()) {
6708
6459
  const context = driver.getContext(plugin);
6709
6460
  const hrStart = process.hrtime();
6710
- const { output } = (_a2 = plugin.options) != null ? _a2 : {};
6711
- const root = resolve(config.root, config.output.path);
6712
6461
  try {
6713
6462
  const timestamp = /* @__PURE__ */ new Date();
6714
6463
  await hooks.emit("kubb:plugin:start", { plugin });
@@ -6716,16 +6465,7 @@ async function safeBuild(setupResult) {
6716
6465
  date: timestamp,
6717
6466
  logs: ["Starting plugin...", ` \u2022 Plugin Name: ${plugin.name}`]
6718
6467
  });
6719
- if (((_b2 = plugin.generators) == null ? void 0 : _b2.length) || driver.hasRegisteredGenerators(plugin.name)) await runPluginAstHooks(plugin, context);
6720
- if (output) {
6721
- const barrelFiles = await getBarrelFiles(driver.fileManager.files, {
6722
- type: (_c2 = output.barrelType) != null ? _c2 : "named",
6723
- root,
6724
- output,
6725
- meta: { pluginName: plugin.name }
6726
- });
6727
- await context.upsertFile(...barrelFiles);
6728
- }
6468
+ if (((_a2 = plugin.generators) == null ? void 0 : _a2.length) || driver.hasRegisteredGenerators(plugin.name)) await runPluginAstHooks(plugin, context);
6729
6469
  const duration = getElapsedMs(hrStart);
6730
6470
  pluginTimings.set(plugin.name, duration);
6731
6471
  await hooks.emit("kubb:plugin:end", {
@@ -6763,45 +6503,13 @@ async function safeBuild(setupResult) {
6763
6503
  });
6764
6504
  }
6765
6505
  }
6766
- if (config.output.barrelType) {
6767
- const rootPath = resolve(resolve(config.root), config.output.path, BARREL_FILENAME);
6768
- const rootDir = dirname(rootPath);
6769
- await hooks.emit("kubb:debug", {
6770
- date: /* @__PURE__ */ new Date(),
6771
- logs: [
6772
- "Generating barrel file",
6773
- ` \u2022 Type: ${config.output.barrelType}`,
6774
- ` \u2022 Path: ${rootPath}`
6775
- ]
6776
- });
6777
- const barrelFiles = driver.fileManager.files.filter((file) => {
6778
- return file.sources.some((source) => source.isIndexable);
6779
- });
6780
- await hooks.emit("kubb:debug", {
6781
- date: /* @__PURE__ */ new Date(),
6782
- logs: [`Found ${barrelFiles.length} indexable files for barrel export`]
6783
- });
6784
- const existingBarrel = driver.fileManager.files.find((f) => f.path === rootPath);
6785
- const rootFile = createFile({
6786
- path: rootPath,
6787
- baseName: BARREL_FILENAME,
6788
- exports: buildBarrelExports({
6789
- barrelFiles,
6790
- rootDir,
6791
- existingExports: new Set((_e2 = (_d2 = existingBarrel == null ? void 0 : existingBarrel.exports) == null ? void 0 : _d2.flatMap((e) => Array.isArray(e.name) ? e.name : [e.name]).filter((n) => Boolean(n))) != null ? _e2 : []),
6792
- config,
6793
- driver
6794
- }).map((e) => createExport(e)),
6795
- sources: [],
6796
- imports: [],
6797
- meta: {}
6798
- });
6799
- driver.fileManager.upsert(rootFile);
6800
- await hooks.emit("kubb:debug", {
6801
- date: /* @__PURE__ */ new Date(),
6802
- logs: [`\u2713 Generated barrel file (${((_f2 = rootFile.exports) == null ? void 0 : _f2.length) || 0} exports)`]
6803
- });
6804
- }
6506
+ await hooks.emit("kubb:plugins:end", {
6507
+ config,
6508
+ get files() {
6509
+ return driver.fileManager.files;
6510
+ },
6511
+ upsertFile: (...files2) => driver.fileManager.upsert(...files2)
6512
+ });
6805
6513
  const files = driver.fileManager.files;
6806
6514
  const parsersMap = /* @__PURE__ */ new Map();
6807
6515
  for (const parser of config.parsers) if (parser.extNames) for (const extname of parser.extNames) parsersMap.set(extname, parser);
@@ -6879,28 +6587,6 @@ async function build(setupResult) {
6879
6587
  sources
6880
6588
  };
6881
6589
  }
6882
- function buildBarrelExports({ barrelFiles, rootDir, existingExports, config, driver }) {
6883
- const pluginNameMap = /* @__PURE__ */ new Map();
6884
- for (const plugin of driver.plugins.values()) pluginNameMap.set(plugin.name, plugin);
6885
- return barrelFiles.flatMap((file) => {
6886
- var _a2, _b2;
6887
- const containsOnlyTypes = (_a2 = file.sources) == null ? void 0 : _a2.every((source) => source.isTypeOnly);
6888
- return ((_b2 = file.sources) != null ? _b2 : []).flatMap((source) => {
6889
- var _a3, _b3;
6890
- if (!file.path || !source.isIndexable) return [];
6891
- const meta = file.meta;
6892
- const pluginOptions = (_a3 = (meta == null ? void 0 : meta.pluginName) ? pluginNameMap.get(meta.pluginName) : void 0) == null ? void 0 : _a3.options;
6893
- if (!pluginOptions || ((_b3 = pluginOptions.output) == null ? void 0 : _b3.barrelType) === false) return [];
6894
- const exportName = config.output.barrelType === "all" ? void 0 : source.name ? [source.name] : void 0;
6895
- if (exportName == null ? void 0 : exportName.some((n) => existingExports.has(n))) return [];
6896
- return [createExport({
6897
- name: exportName,
6898
- path: getRelativePath(rootDir, file.path),
6899
- isTypeOnly: config.output.barrelType === "all" ? containsOnlyTypes : source.isTypeOnly
6900
- })];
6901
- });
6902
- });
6903
- }
6904
6590
  function inputToAdapterSource(config) {
6905
6591
  if (Array.isArray(config.input)) return {
6906
6592
  type: "paths",
@@ -6982,7 +6668,7 @@ const memoryStorage = createStorage(() => {
6982
6668
  };
6983
6669
  });
6984
6670
 
6985
- var version = "5.0.0-alpha.54";
6671
+ var version = "5.0.0-alpha.56";
6986
6672
 
6987
6673
  function isCommandMessage(msg) {
6988
6674
  return msg.type === "command";
@@ -1 +1 @@
1
- {"version":3,"file":"nitro.mjs","sources":["../../../../../../node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs","../../../../../../node_modules/.pnpm/ufo@1.6.3/node_modules/ufo/dist/index.mjs","../../../../../../node_modules/.pnpm/radix3@1.1.2/node_modules/radix3/dist/index.mjs","../../../../../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.mjs","../../../../../../node_modules/.pnpm/node-mock-http@1.0.4/node_modules/node-mock-http/dist/index.mjs","../../../../../../node_modules/.pnpm/h3@1.15.11/node_modules/h3/dist/index.mjs","../../../../../../node_modules/.pnpm/hookable@5.5.3/node_modules/hookable/dist/index.mjs","../../../../../../node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/native.mjs","../../../../../../node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs","../../../../../../node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/node.mjs","../../../../../../node_modules/.pnpm/unstorage@1.17.5_db0@0.3.4_ioredis@5.10.1/node_modules/unstorage/dist/shared/unstorage.zVDD2mZo.mjs","../../../../../../node_modules/.pnpm/unstorage@1.17.5_db0@0.3.4_ioredis@5.10.1/node_modules/unstorage/dist/index.mjs","../../../../../../node_modules/.pnpm/unstorage@1.17.5_db0@0.3.4_ioredis@5.10.1/node_modules/unstorage/drivers/utils/index.mjs","../../../../../../node_modules/.pnpm/unstorage@1.17.5_db0@0.3.4_ioredis@5.10.1/node_modules/unstorage/drivers/utils/node-fs.mjs","../../../../../../node_modules/.pnpm/unstorage@1.17.5_db0@0.3.4_ioredis@5.10.1/node_modules/unstorage/drivers/fs.mjs","../../../../../../node_modules/.pnpm/unstorage@1.17.5_db0@0.3.4_ioredis@5.10.1/node_modules/unstorage/drivers/fs-lite.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/storage.mjs","../../../../../../node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/node/index.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/hash.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/cache.mjs","../../../../../../node_modules/.pnpm/klona@2.0.6/node_modules/klona/dist/index.mjs","../../../../../../node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/utils.env.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/config.mjs","../../../../../../node_modules/.pnpm/unctx@2.5.0/node_modules/unctx/dist/index.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/context.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/route-rules.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/utils.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/error/utils.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/error/prod.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/plugin.mjs","../../../../server/utils/logger.ts","../../../../server/plugins/fetch-logger.ts","../../../../../../internals/utils/dist/index.js","../../../../server/plugins/heartbeat.ts","../../../../server/utils/token.ts","../../../../server/utils/api.ts","../../../../../core/dist/chunk--u3MIqq1.js","../../../../../ast/dist/index.js","../../../../../core/dist/PluginDriver-BU7faPiI.js","../../../../../core/dist/index.js","../../../../server/types/agent.ts","../../../../server/utils/agentCache.ts","../../../../server/utils/executeHooks.ts","../../../../server/utils/generate.ts","../../../../server/utils/getCosmiConfig.ts","../../../../server/utils/loadConfig.ts","../../../../server/utils/resolvePlugins.ts","../../../../server/utils/mergePlugins.ts","../../../../server/utils/publish.ts","../../../../server/utils/setupHookListener.ts","../../../../server/constants.ts","../../../../server/utils/ws.ts","../../../../server/utils/connectStudio.ts","../../../../server/utils/runtimeConfig.ts","../../../../server/plugins/studio.ts","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/app.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/lib/http-graceful-shutdown.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/shutdown.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/presets/node/runtime/node-server.mjs"],"names":["createRouter","f","h","i","l","createError","mergeHeaders","s","nodeFetch","Headers","Headers$1","AbortController$1","normalizeKey","defineDriver","DRIVER_NAME","createStorage","fsPromises","PATH_TRAVERSE_RE","fsp","_inlineAppConfig","createRadixRouter","formatMs","resolve","_a","process","__defProp","trimExtName","path","exports","_b","extname","__privateAdd","__privateGet","__privateSet","__publicField","__privateMethod","readFile","writeFile","build","walk","readdir","version","item","_c","_d","_e","_f","error","nitroApp","callNodeRequestHandler","fetchNodeRequestHandler","gracefulShutdown","HttpsServer","HttpServer"],"mappings":"","x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,56,57,58,59]}
1
+ {"version":3,"file":"nitro.mjs","sources":["../../../../../../node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs","../../../../../../node_modules/.pnpm/ufo@1.6.3/node_modules/ufo/dist/index.mjs","../../../../../../node_modules/.pnpm/radix3@1.1.2/node_modules/radix3/dist/index.mjs","../../../../../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.mjs","../../../../../../node_modules/.pnpm/node-mock-http@1.0.4/node_modules/node-mock-http/dist/index.mjs","../../../../../../node_modules/.pnpm/h3@1.15.11/node_modules/h3/dist/index.mjs","../../../../../../node_modules/.pnpm/hookable@5.5.3/node_modules/hookable/dist/index.mjs","../../../../../../node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/native.mjs","../../../../../../node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs","../../../../../../node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/node.mjs","../../../../../../node_modules/.pnpm/unstorage@1.17.5_db0@0.3.4_ioredis@5.10.1/node_modules/unstorage/dist/shared/unstorage.zVDD2mZo.mjs","../../../../../../node_modules/.pnpm/unstorage@1.17.5_db0@0.3.4_ioredis@5.10.1/node_modules/unstorage/dist/index.mjs","../../../../../../node_modules/.pnpm/unstorage@1.17.5_db0@0.3.4_ioredis@5.10.1/node_modules/unstorage/drivers/utils/index.mjs","../../../../../../node_modules/.pnpm/unstorage@1.17.5_db0@0.3.4_ioredis@5.10.1/node_modules/unstorage/drivers/utils/node-fs.mjs","../../../../../../node_modules/.pnpm/unstorage@1.17.5_db0@0.3.4_ioredis@5.10.1/node_modules/unstorage/drivers/fs.mjs","../../../../../../node_modules/.pnpm/unstorage@1.17.5_db0@0.3.4_ioredis@5.10.1/node_modules/unstorage/drivers/fs-lite.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/storage.mjs","../../../../../../node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/node/index.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/hash.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/cache.mjs","../../../../../../node_modules/.pnpm/klona@2.0.6/node_modules/klona/dist/index.mjs","../../../../../../node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/utils.env.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/config.mjs","../../../../../../node_modules/.pnpm/unctx@2.5.0/node_modules/unctx/dist/index.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/context.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/route-rules.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/utils.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/error/utils.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/error/prod.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/plugin.mjs","../../../../server/utils/logger.ts","../../../../server/plugins/fetch-logger.ts","../../../../../../internals/utils/dist/index.js","../../../../server/plugins/heartbeat.ts","../../../../server/utils/token.ts","../../../../server/utils/api.ts","../../../../../core/dist/chunk--u3MIqq1.js","../../../../../ast/dist/index.js","../../../../../core/dist/PluginDriver-Cn9cRX4m.js","../../../../../core/dist/index.js","../../../../server/types/agent.ts","../../../../server/utils/agentCache.ts","../../../../server/utils/executeHooks.ts","../../../../server/utils/generate.ts","../../../../server/utils/getCosmiConfig.ts","../../../../server/utils/loadConfig.ts","../../../../server/utils/resolvePlugins.ts","../../../../server/utils/mergePlugins.ts","../../../../server/utils/publish.ts","../../../../server/utils/setupHookListener.ts","../../../../server/constants.ts","../../../../server/utils/ws.ts","../../../../server/utils/connectStudio.ts","../../../../server/utils/runtimeConfig.ts","../../../../server/plugins/studio.ts","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/app.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/lib/http-graceful-shutdown.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/runtime/internal/shutdown.mjs","../../../../../../node_modules/.pnpm/nitropack@2.13.3_rolldown@1.0.0-rc.16/node_modules/nitropack/dist/presets/node/runtime/node-server.mjs"],"names":["createRouter","f","h","i","l","createError","mergeHeaders","s","nodeFetch","Headers","Headers$1","AbortController$1","normalizeKey","defineDriver","DRIVER_NAME","createStorage","fsPromises","PATH_TRAVERSE_RE","fsp","_inlineAppConfig","createRadixRouter","formatMs","resolve","_a","process","__defProp","path","exports","_b","extname","__privateAdd","__privateGet","__privateSet","__publicField","__privateMethod","readFile","writeFile","build","walk","readdir","version","_c","_d","_e","files","error","nitroApp","callNodeRequestHandler","fetchNodeRequestHandler","gracefulShutdown","HttpsServer","HttpServer"],"mappings":"","x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,56,57,58,59]}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/agent-prod",
3
- "version": "5.0.0-alpha.54",
3
+ "version": "5.0.0-alpha.56",
4
4
  "type": "module",
5
5
  "private": true,
6
6
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/agent",
3
- "version": "5.0.0-alpha.54",
3
+ "version": "5.0.0-alpha.56",
4
4
  "description": "Agent server for Kubb, enabling HTTP-based access to code generation capabilities.",
5
5
  "keywords": [
6
6
  "agent",
@@ -43,8 +43,8 @@
43
43
  "tinyexec": "^1.1.1",
44
44
  "unstorage": "^1.17.5",
45
45
  "ws": "^8.20.0",
46
- "@kubb/ast": "5.0.0-alpha.54",
47
- "@kubb/core": "5.0.0-alpha.54"
46
+ "@kubb/ast": "5.0.0-alpha.56",
47
+ "@kubb/core": "5.0.0-alpha.56"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/ws": "^8.18.1",
@@ -52,8 +52,8 @@
52
52
  "nitropack": "^2.13.3",
53
53
  "vite": "^8.0.9",
54
54
  "@internals/utils": "0.0.0",
55
- "@kubb/adapter-oas": "5.0.0-alpha.54",
56
- "@kubb/parser-ts": "5.0.0-alpha.54"
55
+ "@kubb/adapter-oas": "5.0.0-alpha.56",
56
+ "@kubb/parser-ts": "5.0.0-alpha.56"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">=22"