@kubb/core 5.13.1 → 5.14.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.
@@ -19,7 +19,7 @@ var __name = (target, value) => __defProp(target, "name", {
19
19
  });
20
20
  //#endregion
21
21
  //#region package.json
22
- var version = "5.13.1";
22
+ var version = "5.14.1";
23
23
  //#endregion
24
24
  //#region ../../internals/utils/src/casing.ts
25
25
  /**
@@ -489,6 +489,12 @@ const diagnosticCatalog = {
489
489
  cause: "A schema uses a `format` Kubb does not map to a specific type, so it falls back to the base type.",
490
490
  fix: "Use a format Kubb supports, or handle the custom format with a parser or plugin."
491
491
  },
492
+ aliasCycle: {
493
+ code: "KUBB_ALIAS_CYCLE",
494
+ title: "Alias cycle",
495
+ cause: "Schemas that only `$ref` each other form a loop, so none of them has a shape to generate. Kubb resolves them to `unknown`.",
496
+ fix: "Break the loop by giving one of the schemas a real definition, or remove the `$ref` that closes it."
497
+ },
492
498
  deprecated: {
493
499
  code: "KUBB_DEPRECATED",
494
500
  title: "Deprecated",
@@ -543,6 +549,12 @@ const diagnosticCatalog = {
543
549
  cause: "Two generated modules export the same name, so the barrel cannot re-export both.",
544
550
  fix: "Rename one of the colliding declarations, or configure the plugin resolver to produce distinct names."
545
551
  },
552
+ inlineFailed: {
553
+ code: "KUBB_INLINE_FAILED",
554
+ title: "Inline definition failed",
555
+ cause: "A file imports a name from a file whose sources are all inline, and that name could not be inlined.",
556
+ fix: "Give every name the file imports an inline definition, register a parser with inline support for its extension, or stop marking the source as inline."
557
+ },
546
558
  internalError: {
547
559
  code: "KUBB_INTERNAL_ERROR",
548
560
  title: "Internal error",
@@ -1743,7 +1755,7 @@ var Resolver = class Resolver {
1743
1755
  return null;
1744
1756
  }
1745
1757
  static #computeOptions(node, { options, exclude = [], include, override = [] }) {
1746
- if (node.kind === "Operation") {
1758
+ if (node.kind === ast.nodeKinds.operation) {
1747
1759
  if (exclude.some((filter) => Resolver.#matchesOperation(node, filter))) return null;
1748
1760
  if (include && !include.some((filter) => Resolver.#matchesOperation(node, filter))) return null;
1749
1761
  return {
@@ -1751,7 +1763,7 @@ var Resolver = class Resolver {
1751
1763
  ...override.find((filter) => Resolver.#matchesOperation(node, filter))?.options
1752
1764
  };
1753
1765
  }
1754
- if (node.kind === "Schema") {
1766
+ if (node.kind === ast.nodeKinds.schema) {
1755
1767
  if (exclude.some((filter) => Resolver.#matchesSchema(node, filter) === true)) return null;
1756
1768
  if (include) {
1757
1769
  const applicable = include.map((filter) => Resolver.#matchesSchema(node, filter)).filter((result) => result !== null);
@@ -2221,6 +2233,16 @@ var FileManager = class {
2221
2233
  return resolved;
2222
2234
  }
2223
2235
  /**
2236
+ * Removes the files at `paths`, so they are neither listed nor written.
2237
+ */
2238
+ delete(...paths) {
2239
+ for (const path of paths) {
2240
+ this.#cache.delete(path);
2241
+ this.#pending.delete(path);
2242
+ }
2243
+ if (paths.length > 0) this.#sorted = null;
2244
+ }
2245
+ /**
2224
2246
  * Releases all stored files. Called by the core after `kubb:build:end`.
2225
2247
  */
2226
2248
  dispose() {
@@ -2381,7 +2403,7 @@ function assertPluginEntry(entry, index) {
2381
2403
  * pointer into the input.
2382
2404
  */
2383
2405
  function getCrashSite(node) {
2384
- if (node.kind === "Schema") return {
2406
+ if (node.kind === ast.nodeKinds.schema) return {
2385
2407
  label: node.name ? `schema "${node.name}"` : "an inline schema",
2386
2408
  location: node.pointer ? {
2387
2409
  kind: "schema",
@@ -2671,6 +2693,7 @@ var KubbDriver = class {
2671
2693
  });
2672
2694
  }
2673
2695
  diagnostics.push(...await this.#runGenerators(generatorPlugins));
2696
+ this.#inlineFiles(parsersMap);
2674
2697
  await hooks.callHook("kubb:plugins:end", this.#withFiles({ config }));
2675
2698
  if (this.options.cleanPath) await config.storage.empty(this.options.cleanPath);
2676
2699
  await fileManager.write(fileManager.files, {
@@ -2696,6 +2719,22 @@ var KubbDriver = class {
2696
2719
  });
2697
2720
  }
2698
2721
  /**
2722
+ * Moves inline sources into the files that import them and drops the virtual files, before barrels
2723
+ * (`kubb:plugins:end`) and the write see them.
2724
+ */
2725
+ #inlineFiles(parsers) {
2726
+ const { files, virtualPaths, problems } = ast.inlineFiles(this.fileManager.files, { language: (file) => parsers.get(file.extname)?.inline });
2727
+ if (virtualPaths.length === 0) return;
2728
+ this.fileManager.add(...files);
2729
+ this.fileManager.delete(...virtualPaths);
2730
+ if (problems.length > 0) Diagnostics.report({
2731
+ code: Diagnostics.code.inlineFailed,
2732
+ severity: "error",
2733
+ message: problems.map(({ path, message }) => `${path}: ${message}`).join("\n"),
2734
+ help: "Give every name the file imports an inline definition, register a parser with inline support for its extension, or stop marking the source as inline."
2735
+ });
2736
+ }
2737
+ /**
2699
2738
  * Widens `extra` with the files present at emit time and a bound `upsertFile`, the shape every
2700
2739
  * file-carrying hook context shares. Building it here in one place keeps the `files` and
2701
2740
  * `upsertFile` keys from being dropped by a stray spread at the call site.
@@ -3150,4 +3189,4 @@ var Hookable = class {
3150
3189
  //#endregion
3151
3190
  export { formatMs as A, writeRaw as B, useConfig as C, defineExtension as D, checkCompatibility as E, isPathInside as F, camelCase as H, listFiles as I, read as L, inParallel as M, exists as N, resolveMeta as O, existsSync$1 as P, rm$1 as R, tryUseKubb as S, useOptions as T, __name as U, toError as V, kubbContext as _, FileManager as a, setOptions as b, Resolver as c, isPublicAddress as d, assertPluginOption as f, injectFile as g, addMacro as h, createNodeCache as i, getElapsedMs as j, Diagnostics as k, getInputKind as l, addGenerator as m, KubbDriver as n, _usingCtx as o, definePlugin as p, pluginNotFoundError as r, createResolver as s, Hookable as t, checkoutGitInput as u, requirePlugin as v, useKubb as w, setResolver as x, setMacros as y, write as z };
3152
3191
 
3153
- //# sourceMappingURL=Hookable-CNMSwKgf.js.map
3192
+ //# sourceMappingURL=Hookable-3xDhh0Fc.js.map