@kubb/adapter-oas 5.0.0-beta.38 → 5.0.0-beta.39

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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./chunk-C0LytTxp.js";
2
- import { DiagnosticError, Diagnostics, ast, createAdapter, diagnosticCode } from "@kubb/core";
2
+ import { Diagnostics, ast, createAdapter } from "@kubb/core";
3
3
  import BaseOas from "oas";
4
4
  import path from "node:path";
5
5
  import { access } from "node:fs/promises";
@@ -614,8 +614,8 @@ async function mergeDocuments(pathOrApi) {
614
614
  enablePaths: false,
615
615
  canBundle: false
616
616
  })));
617
- if (documents.length === 0) throw new DiagnosticError({
618
- code: diagnosticCode.inputRequired,
617
+ if (documents.length === 0) throw new Diagnostics.Error({
618
+ code: Diagnostics.code.inputRequired,
619
619
  severity: "error",
620
620
  message: "No OAS documents were provided for merging.",
621
621
  help: "Pass at least one path or document to `input.path`.",
@@ -664,8 +664,8 @@ async function parseFromConfig(source) {
664
664
  */
665
665
  async function assertInputExists(input) {
666
666
  if (new URLPath(input).isURL) return;
667
- if (!await exists(input)) throw new DiagnosticError({
668
- code: diagnosticCode.inputNotFound,
667
+ if (!await exists(input)) throw new Diagnostics.Error({
668
+ code: Diagnostics.code.inputNotFound,
669
669
  severity: "error",
670
670
  message: `Cannot read the file set in \`input.path\` (or via \`kubb generate PATH\`): ${input}`,
671
671
  help: "Check that the path exists and is readable, then set it in `input.path` or pass it as `kubb generate PATH`.",
@@ -719,7 +719,7 @@ function resolveRef(document, $ref) {
719
719
  const current = $ref.split("/").filter(Boolean).reduce((obj, key) => obj?.[key], document);
720
720
  if (!current) {
721
721
  const diagnostic = {
722
- code: diagnosticCode.refNotFound,
722
+ code: Diagnostics.code.refNotFound,
723
723
  severity: "error",
724
724
  message: `Could not find a definition for ${origRef}.`,
725
725
  help: "Add the schema under `components.schemas`, or fix the `$ref`. Run `kubb validate` to check the spec.",
@@ -729,7 +729,7 @@ function resolveRef(document, $ref) {
729
729
  ref: origRef
730
730
  }
731
731
  };
732
- if (!Diagnostics.report(diagnostic)) throw new DiagnosticError(diagnostic);
732
+ if (!Diagnostics.report(diagnostic)) throw new Diagnostics.Error(diagnostic);
733
733
  return null;
734
734
  }
735
735
  docCache.set($ref, current);
@@ -806,8 +806,8 @@ function resolveServerUrl(server, overrides) {
806
806
  for (const [key, variable] of Object.entries(server.variables)) {
807
807
  const value = overrides?.[key] ?? (variable.default != null ? String(variable.default) : void 0);
808
808
  if (value === void 0) continue;
809
- if (variable.enum?.length && !variable.enum.some((e) => String(e) === value)) throw new DiagnosticError({
810
- code: diagnosticCode.invalidServerVariable,
809
+ if (variable.enum?.length && !variable.enum.some((e) => String(e) === value)) throw new Diagnostics.Error({
810
+ code: Diagnostics.code.invalidServerVariable,
811
811
  severity: "error",
812
812
  message: `Invalid server variable value '${value}' for '${key}' when resolving ${server.url}. Valid values are: ${variable.enum.join(", ")}.`,
813
813
  help: `Use one of the allowed enum values, or drop the enum on the '${key}' server variable.`,
@@ -2149,7 +2149,7 @@ function escapePointerToken(token) {
2149
2149
  }
2150
2150
  function visit(node, pointer) {
2151
2151
  if (node.deprecated) Diagnostics.report({
2152
- code: diagnosticCode.deprecated,
2152
+ code: Diagnostics.code.deprecated,
2153
2153
  severity: "info",
2154
2154
  message: "This schema is marked as deprecated.",
2155
2155
  location: {
@@ -2158,7 +2158,7 @@ function visit(node, pointer) {
2158
2158
  }
2159
2159
  });
2160
2160
  if (typeof node.format === "string" && !isHandledFormat(node.format)) Diagnostics.report({
2161
- code: diagnosticCode.unsupportedFormat,
2161
+ code: Diagnostics.code.unsupportedFormat,
2162
2162
  severity: "warning",
2163
2163
  message: `Kubb does not map the format "${node.format}" to a specific type, so it falls back to the base type.`,
2164
2164
  help: `Use a format Kubb supports, or handle "${node.format}" with a custom parser or plugin.`,