@orval/core 8.8.0 → 8.9.0

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.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { t as __exportAll } from "./chunk-C7Uep-_p.mjs";
1
+ import { t as __exportAll } from "./chunk-BpYLSNr0.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { entries, groupBy, isArray, isBoolean, isBoolean as isBoolean$1, isEmptyish, isFunction, isNullish, isNullish as isNullish$1, isNumber, isString, isString as isString$1, prop, unique, uniqueBy, uniqueWith } from "remeda";
4
4
  import { keyword } from "esutils";
5
- import path from "node:path";
5
+ import nodePath from "node:path";
6
6
  import { compare } from "compare-versions";
7
7
  import debug from "debug";
8
8
  import { pathToFileURL } from "node:url";
@@ -15,7 +15,6 @@ import { isDereferenced } from "@scalar/openapi-types/helpers";
15
15
  import fs$1 from "fs-extra";
16
16
  import { Parser } from "acorn";
17
17
  import { build } from "esbuild";
18
-
19
18
  //#region src/types.ts
20
19
  const SupportedFormatter = {
21
20
  PRETTIER: "prettier",
@@ -103,7 +102,6 @@ var ErrorWithTag = class extends Error {
103
102
  this.tag = tag;
104
103
  }
105
104
  };
106
-
107
105
  //#endregion
108
106
  //#region src/constants.ts
109
107
  const generalJSTypes = [
@@ -128,7 +126,6 @@ const VERBS_WITH_BODY = [
128
126
  ];
129
127
  const URL_REGEX = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/;
130
128
  const TEMPLATE_TAG_REGEX = /\${(.+?)}/g;
131
-
132
129
  //#endregion
133
130
  //#region src/utils/assertion.ts
134
131
  /**
@@ -140,7 +137,7 @@ function isReference(obj) {
140
137
  return !isNullish$1(obj) && Object.hasOwn(obj, "$ref");
141
138
  }
142
139
  function isDirectory(pathValue) {
143
- return !path.extname(pathValue);
140
+ return !nodePath.extname(pathValue);
144
141
  }
145
142
  function isObject(x) {
146
143
  return Object.prototype.toString.call(x) === "[object Object]";
@@ -176,7 +173,6 @@ function isUrl(str) {
176
173
  return false;
177
174
  }
178
175
  }
179
-
180
176
  //#endregion
181
177
  //#region src/utils/async-reduce.ts
182
178
  async function asyncReduce(array, reducer, initValue) {
@@ -184,7 +180,6 @@ async function asyncReduce(array, reducer, initValue) {
184
180
  for (const item of array) accumulate = await reducer(accumulate, item);
185
181
  return accumulate;
186
182
  }
187
-
188
183
  //#endregion
189
184
  //#region src/utils/case.ts
190
185
  const unicodes = function(s, prefix = "") {
@@ -275,7 +270,6 @@ function conventionName(name, convention) {
275
270
  }
276
271
  return nameConventionTransform(name);
277
272
  }
278
-
279
273
  //#endregion
280
274
  //#region src/utils/compare-version.ts
281
275
  function compareVersions(firstVersion, secondVersions, operator = ">=") {
@@ -283,10 +277,13 @@ function compareVersions(firstVersion, secondVersions, operator = ">=") {
283
277
  if (firstVersion.startsWith("catalog:")) return true;
284
278
  return compare(firstVersion.replace(/(\s(.*))/, ""), secondVersions, operator);
285
279
  }
286
-
287
280
  //#endregion
288
281
  //#region src/utils/content-type.ts
289
- const binaryApplicationTypes = new Set(["application/octet-stream", "application/pdf"]);
282
+ const binaryApplicationTypes = new Set([
283
+ "application/octet-stream",
284
+ "application/pdf",
285
+ "application/zip"
286
+ ]);
290
287
  /**
291
288
  * Determine if a content type is binary.
292
289
  * Only known binary types return true. Unknown types default to false (non-binary)
@@ -346,7 +343,6 @@ function filterByContentType(items, filter) {
346
343
  return shouldInclude && !shouldExclude;
347
344
  });
348
345
  }
349
-
350
346
  //#endregion
351
347
  //#region src/utils/debug.ts
352
348
  const filter = process.env.ORVAL_DEBUG_FILTER;
@@ -361,7 +357,6 @@ function createDebugger(ns, options = {}) {
361
357
  log(msg, ...args);
362
358
  };
363
359
  }
364
-
365
360
  //#endregion
366
361
  //#region src/utils/doc.ts
367
362
  const search = String.raw`\*/`;
@@ -442,7 +437,6 @@ function keyValuePairsToJsDoc(keyValues) {
442
437
  doc += " */\n";
443
438
  return doc;
444
439
  }
445
-
446
440
  //#endregion
447
441
  //#region src/utils/dynamic-import.ts
448
442
  const TS_MODULE_EXTENSIONS = new Set([
@@ -456,8 +450,8 @@ async function dynamicImport(toImport, from = process.cwd(), takeDefault = true)
456
450
  if (!toImport) return toImport;
457
451
  try {
458
452
  if (isString(toImport)) {
459
- const filePath = path.resolve(from, toImport);
460
- const extension = path.extname(filePath);
453
+ const filePath = nodePath.resolve(from, toImport);
454
+ const extension = nodePath.extname(filePath);
461
455
  if (TS_MODULE_EXTENSIONS.has(extension)) {
462
456
  const data = await createJiti(from, { interopDefault: true }).import(filePath);
463
457
  if (takeDefault && (isObject(data) || isModule(data)) && data.default) return data.default;
@@ -473,25 +467,23 @@ async function dynamicImport(toImport, from = process.cwd(), takeDefault = true)
473
467
  throw new Error(`Oups... 🍻. Path: ${String(toImport)} => ${String(error)}`, { cause: error });
474
468
  }
475
469
  }
476
-
477
470
  //#endregion
478
471
  //#region src/utils/extension.ts
479
472
  function getExtension(path) {
480
473
  return path.toLowerCase().includes(".yaml") || path.toLowerCase().includes(".yml") ? "yaml" : "json";
481
474
  }
482
-
483
475
  //#endregion
484
476
  //#region src/utils/file.ts
485
477
  function getFileInfo(target = "", { backupFilename = "filename", extension = ".ts" } = {}) {
486
478
  const isDir = isDirectory(target);
487
- const filePath = isDir ? path.join(target, backupFilename + extension) : target;
479
+ const filePath = isDir ? nodePath.join(target, backupFilename + extension) : target;
488
480
  return {
489
481
  path: filePath,
490
482
  pathWithoutExtension: filePath.replace(/\.[^/.]+$/, ""),
491
483
  extension,
492
484
  isDirectory: isDir,
493
- dirname: path.dirname(filePath),
494
- filename: path.basename(filePath, extension.startsWith(".") ? extension : `.${extension}`)
485
+ dirname: nodePath.dirname(filePath),
486
+ filename: nodePath.basename(filePath, extension.startsWith(".") ? extension : `.${extension}`)
495
487
  };
496
488
  }
497
489
  async function removeFilesAndEmptyFolders(patterns, dir) {
@@ -512,7 +504,6 @@ async function removeFilesAndEmptyFolders(patterns, dir) {
512
504
  if ((await fs.promises.readdir(directory)).length === 0) await fs.promises.rmdir(directory);
513
505
  } catch {}
514
506
  }
515
-
516
507
  //#endregion
517
508
  //#region src/utils/file-extensions.ts
518
509
  function getMockFileExtensionByTypeName(mock) {
@@ -521,7 +512,6 @@ function getMockFileExtensionByTypeName(mock) {
521
512
  default: return "msw";
522
513
  }
523
514
  }
524
-
525
515
  //#endregion
526
516
  //#region src/utils/get-property-safe.ts
527
517
  /**
@@ -543,13 +533,11 @@ function getPropertySafe(obj, propertyName) {
543
533
  value: void 0
544
534
  };
545
535
  }
546
-
547
536
  //#endregion
548
537
  //#region src/utils/is-body-verb.ts
549
538
  function getIsBodyVerb(verb) {
550
539
  return VERBS_WITH_BODY.includes(verb);
551
540
  }
552
-
553
541
  //#endregion
554
542
  //#region src/utils/logger.ts
555
543
  const log = console.log;
@@ -666,7 +654,6 @@ function createLogger(level = "info", options = {}) {
666
654
  };
667
655
  return logger;
668
656
  }
669
-
670
657
  //#endregion
671
658
  //#region src/utils/merge-deep.ts
672
659
  function mergeDeep(source, target) {
@@ -680,14 +667,12 @@ function mergeDeep(source, target) {
680
667
  }
681
668
  return acc;
682
669
  }
683
-
684
670
  //#endregion
685
671
  //#region src/utils/occurrence.ts
686
672
  function count(str = "", key) {
687
673
  if (!str) return 0;
688
674
  return (str.match(new RegExp(key, "g")) ?? []).length;
689
675
  }
690
-
691
676
  //#endregion
692
677
  //#region src/utils/path.ts
693
678
  var path_exports = /* @__PURE__ */ __exportAll({
@@ -697,7 +682,7 @@ var path_exports = /* @__PURE__ */ __exportAll({
697
682
  joinSafe: () => joinSafe,
698
683
  normalizeSafe: () => normalizeSafe,
699
684
  relativeSafe: () => relativeSafe,
700
- separator: () => separator,
685
+ separator: () => "/",
701
686
  toUnix: () => toUnix
702
687
  });
703
688
  function toUnix(value) {
@@ -706,28 +691,27 @@ function toUnix(value) {
706
691
  return value;
707
692
  }
708
693
  function join(...args) {
709
- return toUnix(path.join(...args.map((a) => toUnix(a))));
694
+ return toUnix(nodePath.join(...args.map((a) => toUnix(a))));
710
695
  }
711
696
  /**
712
697
  * Behaves exactly like `path.relative(from, to)`, but keeps the first meaningful "./"
713
698
  */
714
699
  function relativeSafe(from, to) {
715
- return normalizeSafe(`.${separator}${toUnix(path.relative(toUnix(from), toUnix(to)))}`);
700
+ return normalizeSafe(`./${toUnix(nodePath.relative(toUnix(from), toUnix(to)))}`);
716
701
  }
717
702
  function getSchemaFileName(path) {
718
703
  return path.replace(`.${getExtension(path)}`, "").slice(path.lastIndexOf("/") + 1);
719
704
  }
720
- const separator = "/";
721
705
  function normalizeSafe(value) {
722
706
  let result;
723
707
  value = toUnix(value);
724
- result = toUnix(path.normalize(value));
708
+ result = toUnix(nodePath.normalize(value));
725
709
  if (value.startsWith("./") && !result.startsWith("./") && !result.startsWith("..")) result = "./" + result;
726
710
  else if (value.startsWith("//") && !result.startsWith("//")) result = value.startsWith("//./") ? "//." + result : "/" + result;
727
711
  return result;
728
712
  }
729
713
  function joinSafe(...values) {
730
- let result = toUnix(path.join(...values.map((v) => toUnix(v))));
714
+ let result = toUnix(nodePath.join(...values.map((v) => toUnix(v))));
731
715
  if (values.length > 0) {
732
716
  const firstValue = toUnix(values[0]);
733
717
  if (firstValue.startsWith("./") && !result.startsWith("./") && !result.startsWith("..")) result = "./" + result;
@@ -758,37 +742,36 @@ function joinSafe(...values) {
758
742
  * @returns The relative import path string.
759
743
  */
760
744
  function getRelativeImportPath(importerFilePath, exporterFilePath, includeFileExtension = false) {
761
- if (!path.isAbsolute(importerFilePath)) throw new Error(`'importerFilePath' is not an absolute path. "${importerFilePath}"`);
762
- if (!path.isAbsolute(exporterFilePath)) throw new Error(`'exporterFilePath' is not an absolute path. "${exporterFilePath}"`);
763
- const importerDir = path.dirname(importerFilePath);
764
- const relativePath = path.relative(importerDir, exporterFilePath);
765
- let posixPath = path.posix.join(...relativePath.split(path.sep));
745
+ if (!nodePath.isAbsolute(importerFilePath)) throw new Error(`'importerFilePath' is not an absolute path. "${importerFilePath}"`);
746
+ if (!nodePath.isAbsolute(exporterFilePath)) throw new Error(`'exporterFilePath' is not an absolute path. "${exporterFilePath}"`);
747
+ const importerDir = nodePath.dirname(importerFilePath);
748
+ const relativePath = nodePath.relative(importerDir, exporterFilePath);
749
+ let posixPath = nodePath.posix.join(...relativePath.split(nodePath.sep));
766
750
  if (!posixPath.startsWith("./") && !posixPath.startsWith("../")) posixPath = `./${posixPath}`;
767
751
  if (!includeFileExtension) {
768
- const ext = path.extname(posixPath);
752
+ const ext = nodePath.extname(posixPath);
769
753
  if (ext && posixPath.endsWith(ext)) posixPath = posixPath.slice(0, -ext.length);
770
754
  }
771
755
  return posixPath;
772
756
  }
773
-
774
757
  //#endregion
775
758
  //#region src/utils/resolve-version.ts
776
759
  function resolveInstalledVersion(packageName, fromDir) {
777
760
  try {
778
- const require = createRequire(path.join(fromDir, "noop.js"));
761
+ const require = createRequire(nodePath.join(fromDir, "noop.js"));
779
762
  try {
780
763
  return require(`${packageName}/package.json`).version;
781
764
  } catch (directError) {
782
765
  if (directError instanceof Error && "code" in directError && directError.code === "ERR_PACKAGE_PATH_NOT_EXPORTED") {
783
766
  const entryPath = require.resolve(packageName);
784
- let dir = path.dirname(entryPath);
785
- while (dir !== path.parse(dir).root) {
786
- const pkgPath = path.join(dir, "package.json");
767
+ let dir = nodePath.dirname(entryPath);
768
+ while (dir !== nodePath.parse(dir).root) {
769
+ const pkgPath = nodePath.join(dir, "package.json");
787
770
  if (existsSync(pkgPath)) {
788
771
  const pkgData = JSON.parse(readFileSync(pkgPath, "utf8"));
789
772
  if (pkgData.name === packageName) return pkgData.version;
790
773
  }
791
- dir = path.dirname(dir);
774
+ dir = nodePath.dirname(dir);
792
775
  }
793
776
  return;
794
777
  }
@@ -811,7 +794,6 @@ function resolveInstalledVersions(packageJson, fromDir) {
811
794
  }
812
795
  return resolved;
813
796
  }
814
-
815
797
  //#endregion
816
798
  //#region src/utils/sort.ts
817
799
  const sortByPriority = (arr) => arr.toSorted((a, b) => {
@@ -822,7 +804,6 @@ const sortByPriority = (arr) => arr.toSorted((a, b) => {
822
804
  if (b.required) return 1;
823
805
  return 0;
824
806
  });
825
-
826
807
  //#endregion
827
808
  //#region src/utils/string.ts
828
809
  /**
@@ -1014,14 +995,12 @@ function dedupeUnionType(unionType) {
1014
995
  if (current.trim()) parts.push(current.trim());
1015
996
  return [...new Set(parts)].join(" | ");
1016
997
  }
1017
-
1018
998
  //#endregion
1019
999
  //#region src/utils/tsconfig.ts
1020
1000
  function isSyntheticDefaultImportsAllow(config) {
1021
1001
  if (!config) return true;
1022
1002
  return !!(config.compilerOptions?.allowSyntheticDefaultImports ?? config.compilerOptions?.esModuleInterop);
1023
1003
  }
1024
-
1025
1004
  //#endregion
1026
1005
  //#region src/getters/enum.ts
1027
1006
  /**
@@ -1221,7 +1200,6 @@ function getCombinedEnumValue(inputs) {
1221
1200
  hasNull
1222
1201
  };
1223
1202
  }
1224
-
1225
1203
  //#endregion
1226
1204
  //#region src/getters/ref.ts
1227
1205
  const RefComponentSuffix = {
@@ -1267,7 +1245,6 @@ function getRefInfo($ref, context) {
1267
1245
  refPaths
1268
1246
  };
1269
1247
  }
1270
-
1271
1248
  //#endregion
1272
1249
  //#region src/resolvers/ref.ts
1273
1250
  const REF_NOT_FOUND_PREFIX = "Oops... 🍻. Ref not found";
@@ -1369,7 +1346,6 @@ function resolveExampleRefs(examples, context) {
1369
1346
  return result;
1370
1347
  })();
1371
1348
  }
1372
-
1373
1349
  //#endregion
1374
1350
  //#region src/resolvers/value.ts
1375
1351
  function resolveValue({ schema, name, context, formDataContext }) {
@@ -1415,7 +1391,6 @@ function resolveValue({ schema, name, context, formDataContext }) {
1415
1391
  isRef: false
1416
1392
  };
1417
1393
  }
1418
-
1419
1394
  //#endregion
1420
1395
  //#region src/resolvers/object.ts
1421
1396
  /**
@@ -1509,7 +1484,6 @@ function resolveObject({ schema, propName, combined = false, context, formDataCo
1509
1484
  resolveObjectCacheMap.set(hashKey, result);
1510
1485
  return result;
1511
1486
  }
1512
-
1513
1487
  //#endregion
1514
1488
  //#region src/getters/array.ts
1515
1489
  /**
@@ -1584,7 +1558,6 @@ function getArray({ schema, name, context, formDataContext }) {
1584
1558
  };
1585
1559
  else throw new Error(`All arrays must have an \`items\` key defined (name=${name}, schema=${JSON.stringify(schema)})`);
1586
1560
  }
1587
-
1588
1561
  //#endregion
1589
1562
  //#region src/getters/res-req-types.ts
1590
1563
  const getSchemaType = (s) => s.type;
@@ -1664,7 +1637,7 @@ function getResReqTypes(responsesOrRequests, name, context, defaultType = "unkno
1664
1637
  name,
1665
1638
  schemaObject: mediaType.schema,
1666
1639
  context,
1667
- isRequestBodyOptional: "required" in bodySchema && bodySchema.required === false,
1640
+ isRequestBodyOptional: bodySchema.required !== true,
1668
1641
  isRef: true,
1669
1642
  encoding: mediaType.encoding
1670
1643
  }) : void 0;
@@ -1672,7 +1645,7 @@ function getResReqTypes(responsesOrRequests, name, context, defaultType = "unkno
1672
1645
  name,
1673
1646
  schemaObject: mediaType.schema,
1674
1647
  context,
1675
- isRequestBodyOptional: "required" in bodySchema && bodySchema.required === false,
1648
+ isRequestBodyOptional: bodySchema.required !== true,
1676
1649
  isUrlEncoded: true,
1677
1650
  isRef: true,
1678
1651
  encoding: mediaType.encoding
@@ -1705,12 +1678,24 @@ function getResReqTypes(responsesOrRequests, name, context, defaultType = "unkno
1705
1678
  if (res.content) return Object.entries(res.content).map(([contentType, mediaType], index, arr) => {
1706
1679
  let propName = key ? pascal(name) + pascal(key) : void 0;
1707
1680
  if (propName && arr.length > 1) propName = propName + pascal(getNumberWord(index + 1));
1681
+ const isFormData = formDataContentTypes.has(contentType);
1682
+ const isFormUrlEncoded = formUrlEncodedContentTypes.has(contentType);
1708
1683
  let effectivePropName = propName;
1709
1684
  if (mediaType.schema && isReference(mediaType.schema)) {
1710
1685
  const { imports } = resolveSchemaRef(mediaType.schema, context);
1711
1686
  if (imports[0]?.name) effectivePropName = imports[0].name;
1687
+ } else if ((isFormData || isFormUrlEncoded) && mediaType.schema) {
1688
+ const combinedRefs = getSchemaOneOf(mediaType.schema) ?? getSchemaAnyOf(mediaType.schema);
1689
+ if (combinedRefs) {
1690
+ const names = [];
1691
+ for (const ref of combinedRefs) {
1692
+ if (!isReference(ref)) continue;
1693
+ const refName = resolveSchemaRef(ref, context).imports[0]?.name;
1694
+ if (refName) names.push(refName);
1695
+ }
1696
+ if (names.length > 0) effectivePropName = names.join("");
1697
+ }
1712
1698
  }
1713
- const isFormData = formDataContentTypes.has(contentType);
1714
1699
  const resolvedValue = getResReqContentTypes({
1715
1700
  mediaType,
1716
1701
  propName: effectivePropName,
@@ -1732,7 +1717,6 @@ function getResReqTypes(responsesOrRequests, name, context, defaultType = "unkno
1732
1717
  };
1733
1718
  return;
1734
1719
  }
1735
- const isFormUrlEncoded = formUrlEncodedContentTypes.has(contentType);
1736
1720
  if (!isFormData && !isFormUrlEncoded || !effectivePropName || !mediaType.schema) return {
1737
1721
  ...resolvedValue,
1738
1722
  imports: resolvedValue.imports,
@@ -1745,7 +1729,7 @@ function getResReqTypes(responsesOrRequests, name, context, defaultType = "unkno
1745
1729
  name: effectivePropName,
1746
1730
  schemaObject: mediaType.schema,
1747
1731
  context,
1748
- isRequestBodyOptional: "required" in res && res.required === false,
1732
+ isRequestBodyOptional: res.required !== true,
1749
1733
  isRef: true,
1750
1734
  encoding: mediaType.encoding
1751
1735
  }) : void 0;
@@ -1754,7 +1738,7 @@ function getResReqTypes(responsesOrRequests, name, context, defaultType = "unkno
1754
1738
  schemaObject: mediaType.schema,
1755
1739
  context,
1756
1740
  isUrlEncoded: true,
1757
- isRequestBodyOptional: "required" in res && res.required === false,
1741
+ isRequestBodyOptional: res.required !== true,
1758
1742
  isRef: true,
1759
1743
  encoding: mediaType.encoding
1760
1744
  }) : void 0;
@@ -1846,26 +1830,45 @@ function getFormDataAdditionalImports({ schemaObject, context }) {
1846
1830
  function getSchemaFormDataAndUrlEncoded({ name, schemaObject, context, isRequestBodyOptional, isUrlEncoded, isRef, encoding }) {
1847
1831
  const { schema, imports } = resolveSchemaRef(schemaObject, context);
1848
1832
  const propName = camel(!isRef && isReference(schemaObject) ? imports[0].name : name);
1849
- const additionalImports = [];
1850
1833
  const variableName = isUrlEncoded ? "formUrlEncoded" : "formData";
1851
1834
  let form = isUrlEncoded ? `const ${variableName} = new URLSearchParams();\n` : `const ${variableName} = new FormData();\n`;
1852
1835
  const combinedSchemas = getSchemaCombined(schema);
1853
1836
  if (schema.type === "object" || schema.type === void 0 && combinedSchemas) {
1854
- if (combinedSchemas) {
1855
- const shouldCast = !!getSchemaOneOf(schema) || !!getSchemaAnyOf(schema);
1837
+ if (combinedSchemas) if (!!getSchemaOneOf(schema) || !!getSchemaAnyOf(schema)) {
1838
+ const directProperties = getSchemaProperties(schema);
1839
+ const directKeys = directProperties ? Object.entries(directProperties).filter(([, value]) => !resolveSchemaRef(value, context).schema.readOnly).map(([key]) => key) : [];
1840
+ const skipLine = directKeys.length > 0 ? ` if ([${directKeys.map((k) => JSON.stringify(k)).join(", ")}].includes(key)) return;\n` : "";
1841
+ form += `Object.entries(${propName} ?? {}).forEach(([key, value]) => {\n`;
1842
+ form += skipLine;
1843
+ form += ` if (value !== undefined && value !== null) {\n`;
1844
+ form += ` if ((typeof File !== 'undefined' && value instanceof File) || value instanceof Blob) {\n`;
1845
+ form += ` ${variableName}.append(key, value);\n`;
1846
+ form += ` } else if (typeof Buffer !== 'undefined' && Buffer.isBuffer(value)) {\n`;
1847
+ form += ` ${variableName}.append(key, new Blob([Uint8Array.from(value)]));\n`;
1848
+ form += ` } else if (Array.isArray(value)) {\n`;
1849
+ form += ` value.forEach(v => {\n`;
1850
+ form += ` if ((typeof File !== 'undefined' && v instanceof File) || v instanceof Blob) {\n`;
1851
+ form += ` ${variableName}.append(key, v);\n`;
1852
+ form += ` } else if (typeof Buffer !== 'undefined' && Buffer.isBuffer(v)) {\n`;
1853
+ form += ` ${variableName}.append(key, new Blob([Uint8Array.from(v)]));\n`;
1854
+ form += ` } else {\n`;
1855
+ form += ` ${variableName}.append(key, typeof v === 'object' ? JSON.stringify(v) : String(v));\n`;
1856
+ form += ` }\n`;
1857
+ form += ` });\n`;
1858
+ form += ` } else if (typeof value === 'object') {\n`;
1859
+ form += ` ${variableName}.append(key, JSON.stringify(value));\n`;
1860
+ form += ` } else {\n`;
1861
+ form += ` ${variableName}.append(key, String(value));\n`;
1862
+ form += ` }\n`;
1863
+ form += ` }\n`;
1864
+ form += `});\n`;
1865
+ } else {
1856
1866
  const combinedSchemasFormData = combinedSchemas.map((subSchema) => {
1857
- const { schema: combinedSchema, imports } = resolveSchemaRef(subSchema, context);
1858
- let newPropName = propName;
1859
- let newPropDefinition = "";
1860
- if (shouldCast && imports[0]) {
1861
- additionalImports.push(imports[0]);
1862
- newPropName = `${propName}${pascal(imports[0].name)}`;
1863
- newPropDefinition = `const ${newPropName} = (${propName} as ${imports[0].name}${isRequestBodyOptional ? " | undefined" : ""});\n`;
1864
- }
1865
- return newPropDefinition + resolveSchemaPropertiesToFormData({
1867
+ const { schema: combinedSchema } = resolveSchemaRef(subSchema, context);
1868
+ return resolveSchemaPropertiesToFormData({
1866
1869
  schema: combinedSchema,
1867
1870
  variableName,
1868
- propName: newPropName,
1871
+ propName,
1869
1872
  context,
1870
1873
  isRequestBodyOptional,
1871
1874
  encoding
@@ -1924,7 +1927,7 @@ function resolveSchemaPropertiesToFormData({ schema, variableName, propName, con
1924
1927
  keyPrefix: `${keyPrefix}${key}.`,
1925
1928
  depth: depth + 1,
1926
1929
  encoding
1927
- }) : partContentType ? `${variableName}.append(\`${keyPrefix}${key}\`, new Blob([JSON.stringify(${nonOptionalValueKey})], { type: '${partContentType}' }));\n` : `${variableName}.append(\`${keyPrefix}${key}\`, JSON.stringify(${nonOptionalValueKey}));\n`;
1930
+ }) : `${variableName}.append(\`${keyPrefix}${key}\`, JSON.stringify(${nonOptionalValueKey}));\n`;
1928
1931
  else if (property.type === "array") {
1929
1932
  let valueStr = "value";
1930
1933
  let hasNonPrimitiveChild = false;
@@ -1995,7 +1998,6 @@ function resolveSchemaPropertiesToFormData({ schema, variableName, propName, con
1995
1998
  }
1996
1999
  return formDataValues;
1997
2000
  }
1998
-
1999
2001
  //#endregion
2000
2002
  //#region src/getters/body.ts
2001
2003
  function buildBody(filteredBodyTypes, requestBody, operationName, context) {
@@ -2015,8 +2017,8 @@ function buildBody(filteredBodyTypes, requestBody, operationName, context) {
2015
2017
  });
2016
2018
  if (isReference(requestBody)) {
2017
2019
  const { schema: bodySchema } = resolveRef(requestBody, context);
2018
- if (bodySchema.required !== void 0) isOptional = !bodySchema.required;
2019
- } else if (requestBody.required !== void 0) isOptional = !requestBody.required;
2020
+ isOptional = bodySchema.required !== true;
2021
+ } else isOptional = requestBody.required !== true;
2020
2022
  }
2021
2023
  return {
2022
2024
  originalSchema: requestBody,
@@ -2070,7 +2072,6 @@ function getContentTypeSuffix(contentType) {
2070
2072
  if (CONTENT_TYPE_SUFFIX_MAP[contentType]) return CONTENT_TYPE_SUFFIX_MAP[contentType];
2071
2073
  return (contentType.split("/")[1] ?? contentType).split(/[-+.]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
2072
2074
  }
2073
-
2074
2075
  //#endregion
2075
2076
  //#region src/getters/imports.ts
2076
2077
  function getAliasedImports({ name, resolvedValue, context }) {
@@ -2092,13 +2093,11 @@ function getImportAliasForRefOrValue({ context, imports, resolvedValue }) {
2092
2093
  if (!context.output.schemas || !resolvedValue.isRef) return resolvedValue.value;
2093
2094
  return imports.find((imp) => imp.name === resolvedValue.value)?.alias ?? resolvedValue.value;
2094
2095
  }
2095
-
2096
2096
  //#endregion
2097
2097
  //#region src/getters/keys.ts
2098
2098
  function getKey(key) {
2099
2099
  return keyword.isIdentifierNameES5(key) ? key : `'${key}'`;
2100
2100
  }
2101
-
2102
2101
  //#endregion
2103
2102
  //#region src/getters/object.ts
2104
2103
  /**
@@ -2384,7 +2383,6 @@ function getObject({ item, name, context, nullable, formDataContext }) {
2384
2383
  dependencies: []
2385
2384
  };
2386
2385
  }
2387
-
2388
2386
  //#endregion
2389
2387
  //#region src/getters/scalar.ts
2390
2388
  /**
@@ -2543,7 +2541,6 @@ function getScalar({ item, name, context, formDataContext }) {
2543
2541
  }
2544
2542
  }
2545
2543
  }
2546
-
2547
2544
  //#endregion
2548
2545
  //#region src/getters/combine.ts
2549
2546
  const mergeableAllOfKeys = new Set([
@@ -2749,7 +2746,6 @@ function combineSchemas({ name, schema, separator, context, nullable, formDataCo
2749
2746
  examples: resolveExampleRefs(schema.examples, context)
2750
2747
  };
2751
2748
  }
2752
-
2753
2749
  //#endregion
2754
2750
  //#region src/getters/discriminators.ts
2755
2751
  function resolveDiscriminators(schemas, context) {
@@ -2801,7 +2797,6 @@ function resolveDiscriminators(schemas, context) {
2801
2797
  }
2802
2798
  return transformedSchemas;
2803
2799
  }
2804
-
2805
2800
  //#endregion
2806
2801
  //#region src/getters/operation.ts
2807
2802
  function getOperationId(operation, route, verb) {
@@ -2813,7 +2808,6 @@ function getOperationId(operation, route, verb) {
2813
2808
  whitespace: "-"
2814
2809
  }))].join("-"));
2815
2810
  }
2816
-
2817
2811
  //#endregion
2818
2812
  //#region src/getters/parameters.ts
2819
2813
  function getParameters({ parameters, context }) {
@@ -2836,7 +2830,6 @@ function getParameters({ parameters, context }) {
2836
2830
  });
2837
2831
  return result;
2838
2832
  }
2839
-
2840
2833
  //#endregion
2841
2834
  //#region src/getters/params.ts
2842
2835
  /**
@@ -2893,7 +2886,6 @@ function getParams({ route, pathParams = [], operationId, context, output }) {
2893
2886
  };
2894
2887
  });
2895
2888
  }
2896
-
2897
2889
  //#endregion
2898
2890
  //#region src/getters/props.ts
2899
2891
  function getProps({ body, queryParams, params, operationName, headers, context }) {
@@ -2958,7 +2950,6 @@ function getQueryParamDefinition(queryParams, context) {
2958
2950
  const paramType = queryParams?.schema.name;
2959
2951
  return `params${(queryParams?.isOptional || context.output.allParamsOptional) && !context.output.optionsParamRequired ? "?" : ""}: ${paramType}`;
2960
2952
  }
2961
-
2962
2953
  //#endregion
2963
2954
  //#region src/getters/query-params.ts
2964
2955
  const isOpenApiSchemaObject = (value) => {
@@ -3053,7 +3044,6 @@ function getQueryParams({ queryParams, operationName, context, suffix = "params"
3053
3044
  requiredNullableKeys
3054
3045
  };
3055
3046
  }
3056
-
3057
3047
  //#endregion
3058
3048
  //#region src/getters/response.ts
3059
3049
  function getResponse({ responses, operationName, context, contentType }) {
@@ -3083,7 +3073,6 @@ function getResponse({ responses, operationName, context, contentType }) {
3083
3073
  originalSchema: responses
3084
3074
  };
3085
3075
  }
3086
-
3087
3076
  //#endregion
3088
3077
  //#region src/getters/route.ts
3089
3078
  function isBaseUrlRuntime(baseUrl) {
@@ -3157,11 +3146,18 @@ function getFullRoute(route, servers, baseUrl) {
3157
3146
  }
3158
3147
  /**
3159
3148
  * Returns `GeneratorImport` entries for {@link BaseUrlRuntime.imports} when `baseUrl` is a runtime config.
3149
+ *
3150
+ * Defaults `values` to true so symbols in `runtime` emit as value imports in the
3151
+ * generated client. Set `values: false` explicitly only for unusual cases (e.g.
3152
+ * type-only symbols referenced from the expression).
3160
3153
  */
3161
3154
  function getBaseUrlRuntimeImports(baseUrl) {
3162
3155
  if (!baseUrl) return [];
3163
3156
  if (!isBaseUrlRuntime(baseUrl)) return [];
3164
- return baseUrl.imports ?? [];
3157
+ return (baseUrl.imports ?? []).map((imp) => ({
3158
+ ...imp,
3159
+ values: imp.values ?? true
3160
+ }));
3165
3161
  }
3166
3162
  function getRouteAsArray(route) {
3167
3163
  return route.split("/").filter((i) => i !== "").flatMap((segment) => {
@@ -3172,7 +3168,6 @@ function getRouteAsArray(route) {
3172
3168
  });
3173
3169
  }).join(",");
3174
3170
  }
3175
-
3176
3171
  //#endregion
3177
3172
  //#region src/generators/component-definition.ts
3178
3173
  function generateComponentDefinition(responses = {}, context, suffix) {
@@ -3200,7 +3195,6 @@ function generateComponentDefinition(responses = {}, context, suffix) {
3200
3195
  }
3201
3196
  return generatorSchemas;
3202
3197
  }
3203
-
3204
3198
  //#endregion
3205
3199
  //#region src/generators/imports.ts
3206
3200
  function generateImports({ imports, namingConvention = NamingConvention.CAMEL_CASE }) {
@@ -3335,7 +3329,70 @@ function generateVerbImports({ response, body, queryParams, props, headers, para
3335
3329
  }];
3336
3330
  });
3337
3331
  }
3338
-
3332
+ //#endregion
3333
+ //#region src/generators/input-filters.ts
3334
+ const COMPONENT_TYPES = [
3335
+ "schemas",
3336
+ "responses",
3337
+ "parameters",
3338
+ "requestBodies"
3339
+ ];
3340
+ function filteredVerbs(verbs, filters) {
3341
+ if (filters?.tags === void 0) return Object.entries(verbs);
3342
+ const filterTags = filters.tags;
3343
+ const filterMode = filters.mode ?? "include";
3344
+ return Object.entries(verbs).filter(([, operation]) => {
3345
+ const isMatch = (operation.tags ?? []).some((tag) => filterTags.some((filterTag) => filterTag instanceof RegExp ? filterTag.test(tag) : filterTag === tag));
3346
+ return filterMode === "exclude" ? !isMatch : isMatch;
3347
+ });
3348
+ }
3349
+ function findRefs(value) {
3350
+ if (!value || typeof value !== "object") return [];
3351
+ if (Array.isArray(value)) return value.flatMap((item) => findRefs(item));
3352
+ const obj = value;
3353
+ if (typeof obj.$ref === "string") return [obj.$ref];
3354
+ return Object.values(obj).flatMap((val) => findRefs(val));
3355
+ }
3356
+ function parseComponentRef(ref) {
3357
+ const parts = ref.split("/");
3358
+ if (parts[0] !== "#" || parts[1] !== "components" || parts.length < 4) return;
3359
+ const type = parts[2];
3360
+ const name = parts[3];
3361
+ if (!COMPONENT_TYPES.includes(type)) return;
3362
+ return {
3363
+ type,
3364
+ name
3365
+ };
3366
+ }
3367
+ function getComponentNames(refs, spec) {
3368
+ return refs.map((ref) => parseComponentRef(ref)).filter((parsed) => !!parsed && !!spec.components?.[parsed.type]?.[parsed.name]);
3369
+ }
3370
+ function resolveReferencedComponents(refs, spec, resolved) {
3371
+ const newComponents = getComponentNames(refs, spec).filter(({ type, name }) => !resolved[type].includes(name));
3372
+ if (newComponents.length === 0) return resolved;
3373
+ const nextResolved = {
3374
+ schemas: [...resolved.schemas],
3375
+ responses: [...resolved.responses],
3376
+ parameters: [...resolved.parameters],
3377
+ requestBodies: [...resolved.requestBodies]
3378
+ };
3379
+ for (const { type, name } of newComponents) nextResolved[type].push(name);
3380
+ return resolveReferencedComponents(newComponents.flatMap(({ type, name }) => findRefs(spec.components?.[type]?.[name])), spec, nextResolved);
3381
+ }
3382
+ const collectReferencedComponents = (spec, tags, mode) => {
3383
+ const filters = {
3384
+ tags,
3385
+ mode
3386
+ };
3387
+ return resolveReferencedComponents(Object.values(spec.paths ?? {}).filter((pathItem) => !!pathItem).flatMap((pathItem) => {
3388
+ return [...filteredVerbs(pathItem, filters).flatMap(([, operation]) => findRefs(operation)), ...findRefs(pathItem.parameters)];
3389
+ }), spec, {
3390
+ schemas: [],
3391
+ responses: [],
3392
+ parameters: [],
3393
+ requestBodies: []
3394
+ });
3395
+ };
3339
3396
  //#endregion
3340
3397
  //#region src/generators/models-inline.ts
3341
3398
  function generateModelInline(acc, model) {
@@ -3347,7 +3404,6 @@ function generateModelsInline(obj) {
3347
3404
  for (const { model } of schemas) result = generateModelInline(result, model);
3348
3405
  return result;
3349
3406
  }
3350
-
3351
3407
  //#endregion
3352
3408
  //#region src/generators/mutator-info.ts
3353
3409
  async function getMutatorInfo(filePath, options) {
@@ -3444,7 +3500,6 @@ function getEcmaVersion(target) {
3444
3500
  return;
3445
3501
  }
3446
3502
  }
3447
-
3448
3503
  //#endregion
3449
3504
  //#region src/generators/mutator.ts
3450
3505
  const BODY_TYPE_NAME = "BodyType";
@@ -3462,7 +3517,7 @@ async function generateMutator({ output, mutator, name, workspace, tsconfig }) {
3462
3517
  let rawFile = await fs$1.readFile(importPath, "utf8");
3463
3518
  rawFile = removeComments(rawFile);
3464
3519
  const hasErrorType = rawFile.includes("export type ErrorType") || rawFile.includes("export interface ErrorType");
3465
- const hasBodyType = rawFile.includes(`export type ${BODY_TYPE_NAME}`) || rawFile.includes(`export interface ${BODY_TYPE_NAME}`);
3520
+ const hasBodyType = rawFile.includes(`export type BodyType`) || rawFile.includes(`export interface BodyType`);
3466
3521
  const errorTypeName = mutator.default ? `${pascal(name)}ErrorType` : "ErrorType";
3467
3522
  const bodyTypeName = mutator.default ? `${pascal(name)}${BODY_TYPE_NAME}` : BODY_TYPE_NAME;
3468
3523
  const mutatorInfo = await getMutatorInfo(importPath, {
@@ -3490,7 +3545,6 @@ async function generateMutator({ output, mutator, name, workspace, tsconfig }) {
3490
3545
  function removeComments(file) {
3491
3546
  return file.replaceAll(/\/\/.*|\/\*[\s\S]*?\*\//g, "");
3492
3547
  }
3493
-
3494
3548
  //#endregion
3495
3549
  //#region src/generators/options.ts
3496
3550
  /**
@@ -3692,7 +3746,8 @@ function generateQueryParamsAxiosConfig(response, isVue, isAngular, requiredNull
3692
3746
  function generateMutatorConfig({ route, body, headers, queryParams, response, verb, isFormData, isFormUrlEncoded, hasSignal, hasSignalParam = false, isExactOptionalPropertyTypes, isVue, isAngular }) {
3693
3747
  const bodyOptions = getIsBodyVerb(verb) ? generateBodyMutatorConfig(body, isFormData, isFormUrlEncoded) : "";
3694
3748
  const queryParamsOptions = generateQueryParamsAxiosConfig(response, isVue ?? false, isAngular ?? false, queryParams?.requiredNullableKeys, queryParams);
3695
- const headerOptions = body.contentType && !["multipart/form-data"].includes(body.contentType) ? `,\n headers: {'Content-Type': '${body.contentType}', ${headers ? "...headers" : ""}}` : headers ? ",\n headers" : "";
3749
+ const ignoreContentTypes = isAngular ? ["multipart/form-data"] : [];
3750
+ const headerOptions = body.contentType && !ignoreContentTypes.includes(body.contentType) ? `,\n headers: {'Content-Type': '${body.contentType}', ${headers ? "...headers" : ""}}` : headers ? ",\n headers" : "";
3696
3751
  const signalVar = hasSignalParam ? "querySignal" : "signal";
3697
3752
  const signalProp = hasSignalParam ? `signal: ${signalVar}` : "signal";
3698
3753
  return `{url: \`${route}\`, method: '${verb.toUpperCase()}'${headerOptions}${bodyOptions}${queryParamsOptions}${hasSignal ? `, ${isExactOptionalPropertyTypes ? `...(${signalVar} ? { ${signalProp} }: {})` : signalProp}` : ""}\n }`;
@@ -3713,7 +3768,6 @@ function generateFormDataAndUrlEncodedFunction({ body, formData, formUrlEncoded,
3713
3768
  }
3714
3769
  return "";
3715
3770
  }
3716
-
3717
3771
  //#endregion
3718
3772
  //#region src/generators/parameter-definition.ts
3719
3773
  function generateParameterDefinition(parameters = {}, context, suffix) {
@@ -3757,7 +3811,6 @@ function generateParameterDefinition(parameters = {}, context, suffix) {
3757
3811
  }
3758
3812
  return generatorSchemas;
3759
3813
  }
3760
-
3761
3814
  //#endregion
3762
3815
  //#region src/generators/interface.ts
3763
3816
  /**
@@ -3797,7 +3850,6 @@ function generateInterface({ name, schema, context }) {
3797
3850
  schema
3798
3851
  }];
3799
3852
  }
3800
-
3801
3853
  //#endregion
3802
3854
  //#region src/generators/schema-definition.ts
3803
3855
  /**
@@ -3926,7 +3978,6 @@ function generateSchemaDefinitions(schemaName, schema, context, suffix) {
3926
3978
  schema
3927
3979
  }];
3928
3980
  }
3929
-
3930
3981
  //#endregion
3931
3982
  //#region src/generators/verbs-options.ts
3932
3983
  async function buildVerbOption({ verb, output, operation, route, pathRoute, verbParameters = [], context, body, operationName, operationId, override, tags, deprecated, description, summary }) {
@@ -4104,7 +4155,7 @@ async function generateVerbOptions({ verb, output, operation, route, pathRoute,
4104
4155
  })];
4105
4156
  }
4106
4157
  function generateVerbsOptions({ verbs, input, output, route, pathRoute, context }) {
4107
- return asyncReduce(_filteredVerbs(verbs, input.filters), async (acc, [verb, operation]) => {
4158
+ return asyncReduce(filteredVerbs(verbs, input.filters), async (acc, [verb, operation]) => {
4108
4159
  if (isVerb(verb)) {
4109
4160
  const verbOptions = await generateVerbOptions({
4110
4161
  verb,
@@ -4120,16 +4171,6 @@ function generateVerbsOptions({ verbs, input, output, route, pathRoute, context
4120
4171
  return acc;
4121
4172
  }, []);
4122
4173
  }
4123
- function _filteredVerbs(verbs, filters) {
4124
- if (filters?.tags === void 0) return Object.entries(verbs);
4125
- const filterTags = filters.tags;
4126
- const filterMode = filters.mode ?? "include";
4127
- return Object.entries(verbs).filter(([, operation]) => {
4128
- const isMatch = (operation.tags ?? []).some((tag) => filterTags.some((filterTag) => filterTag instanceof RegExp ? filterTag.test(tag) : filterTag === tag));
4129
- return filterMode === "exclude" ? !isMatch : isMatch;
4130
- });
4131
- }
4132
-
4133
4174
  //#endregion
4134
4175
  //#region src/writers/file.ts
4135
4176
  const TRAILING_WHITESPACE_RE = /[^\S\r\n]+$/gm;
@@ -4143,7 +4184,6 @@ const TRAILING_WHITESPACE_RE = /[^\S\r\n]+$/gm;
4143
4184
  async function writeGeneratedFile(filePath, content) {
4144
4185
  await fs$1.outputFile(filePath, content.replaceAll(TRAILING_WHITESPACE_RE, ""));
4145
4186
  }
4146
-
4147
4187
  //#endregion
4148
4188
  //#region src/writers/schemas.ts
4149
4189
  /**
@@ -4283,8 +4323,8 @@ function getSchema({ schema: { imports, model }, header, namingConvention = Nami
4283
4323
  file += model;
4284
4324
  return file;
4285
4325
  }
4286
- function getPath(path$1, name, fileExtension) {
4287
- return path.join(path$1, `${name}${fileExtension}`);
4326
+ function getPath(path, name, fileExtension) {
4327
+ return nodePath.join(path, `${name}${fileExtension}`);
4288
4328
  }
4289
4329
  function writeModelInline(acc, model) {
4290
4330
  return acc + `${model}\n`;
@@ -4333,7 +4373,7 @@ async function writeSchemas({ schemaPath, schemas, target, namingConvention, fil
4333
4373
  });
4334
4374
  }
4335
4375
  if (indexFiles) {
4336
- const schemaFilePath = path.join(schemaPath, `index.ts`);
4376
+ const schemaFilePath = nodePath.join(schemaPath, `index.ts`);
4337
4377
  await fs$1.ensureFile(schemaFilePath);
4338
4378
  const ext = fileExtension.endsWith(".ts") ? fileExtension.slice(0, -3) : fileExtension;
4339
4379
  const conventionNamesSet = new Set(Object.values(schemaGroups).map((group) => conventionName(group[0].name, namingConvention)));
@@ -4344,7 +4384,6 @@ async function writeSchemas({ schemaPath, schemas, target, namingConvention, fil
4344
4384
  }
4345
4385
  }
4346
4386
  }
4347
-
4348
4387
  //#endregion
4349
4388
  //#region src/writers/generate-imports-for-builder.ts
4350
4389
  function generateImportsForBuilder(output, imports, relativeSchemasPath) {
@@ -4360,10 +4399,7 @@ function generateImportsForBuilder(output, imports, relativeSchemasPath) {
4360
4399
  else {
4361
4400
  const importsByDependency = /* @__PURE__ */ new Map();
4362
4401
  for (const schemaImport of imports.filter((i) => !i.importPath)) {
4363
- const normalizedName = conventionName(isZodSchemaOutput ? schemaImport.name : schemaImport.schemaName ?? schemaImport.name, output.namingConvention);
4364
- const suffix = isZodSchemaOutput ? ".zod" : "";
4365
- const importExtension = output.fileExtension.replace(/\.ts$/, "") || "";
4366
- const dependency = joinSafe(relativeSchemasPath, `${normalizedName}${suffix}${importExtension}`);
4402
+ const dependency = joinSafe(relativeSchemasPath, `${conventionName(isZodSchemaOutput ? schemaImport.name : schemaImport.schemaName ?? schemaImport.name, output.namingConvention)}${isZodSchemaOutput ? ".zod" : ""}${output.fileExtension.replace(/\.ts$/, "") || ""}`);
4367
4403
  if (!importsByDependency.has(dependency)) importsByDependency.set(dependency, []);
4368
4404
  importsByDependency.get(dependency)?.push(schemaImport);
4369
4405
  }
@@ -4380,7 +4416,6 @@ function generateImportsForBuilder(output, imports, relativeSchemasPath) {
4380
4416
  });
4381
4417
  return [...schemaImports, ...otherImports];
4382
4418
  }
4383
-
4384
4419
  //#endregion
4385
4420
  //#region src/writers/target.ts
4386
4421
  function generateTarget(builder, options) {
@@ -4457,7 +4492,6 @@ function generateTarget(builder, options) {
4457
4492
  implementationMock: target.implementationMock.function + target.implementationMock.handler
4458
4493
  };
4459
4494
  }
4460
-
4461
4495
  //#endregion
4462
4496
  //#region src/writers/types.ts
4463
4497
  function getOrvalGeneratedTypes() {
@@ -4496,7 +4530,6 @@ interface TypedResponse<T> extends Response {
4496
4530
  }
4497
4531
  `;
4498
4532
  }
4499
-
4500
4533
  //#endregion
4501
4534
  //#region src/writers/single-mode.ts
4502
4535
  async function writeSingleMode({ builder, output, projectName, header, needSchema, generateSchemasInline }) {
@@ -4519,7 +4552,7 @@ async function writeSingleMode({ builder, output, projectName, header, needSchem
4519
4552
  if (!matchingImport) continue;
4520
4553
  if (!!mockImport.values || !!mockImport.isConstant || !!mockImport.default || !!mockImport.namespaceImport || !!mockImport.syntheticDefaultImport) matchingImport.values = true;
4521
4554
  }
4522
- const importsForBuilder = schemasPath ? generateImportsForBuilder(output, normalizedImports, schemasPath) : [];
4555
+ const importsForBuilder = schemasPath ? generateImportsForBuilder(output, normalizedImports, schemasPath) : generateImportsForBuilder(output, normalizedImports.filter((imp) => !!imp.importPath), ".");
4523
4556
  data += builder.imports({
4524
4557
  client: output.client,
4525
4558
  implementation,
@@ -4534,7 +4567,8 @@ async function writeSingleMode({ builder, output, projectName, header, needSchem
4534
4567
  output
4535
4568
  });
4536
4569
  if (output.mock) {
4537
- const importsMockForBuilder = schemasPath ? generateImportsForBuilder(output, importsMock.filter((impMock) => !normalizedImports.some((imp) => imp.name === impMock.name && (imp.alias ?? "") === (impMock.alias ?? ""))), schemasPath) : [];
4570
+ const filteredMockImports = importsMock.filter((impMock) => !normalizedImports.some((imp) => imp.name === impMock.name && (imp.alias ?? "") === (impMock.alias ?? "")));
4571
+ const importsMockForBuilder = schemasPath ? generateImportsForBuilder(output, filteredMockImports, schemasPath) : generateImportsForBuilder(output, filteredMockImports.filter((imp) => !!imp.importPath), ".");
4538
4572
  data += builder.importsMock({
4539
4573
  implementation: implementationMock,
4540
4574
  imports: importsMockForBuilder,
@@ -4574,7 +4608,6 @@ async function writeSingleMode({ builder, output, projectName, header, needSchem
4574
4608
  throw new Error(`Oups... 🍻. An Error occurred while writing file => ${errorMsg}`, { cause: error });
4575
4609
  }
4576
4610
  }
4577
-
4578
4611
  //#endregion
4579
4612
  //#region src/writers/split-mode.ts
4580
4613
  async function writeSplitMode({ builder, output, projectName, header, needSchema, generateSchemasInline }) {
@@ -4611,7 +4644,7 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
4611
4644
  isAllowSyntheticDefaultImports,
4612
4645
  options: isFunction(output.mock) ? void 0 : output.mock
4613
4646
  });
4614
- const schemasPath = output.schemas ? void 0 : path.join(dirname, filename + ".schemas" + extension);
4647
+ const schemasPath = output.schemas ? void 0 : nodePath.join(dirname, filename + ".schemas" + extension);
4615
4648
  if (schemasPath && needSchema) await writeGeneratedFile(schemasPath, generateSchemasInline ? header + generateSchemasInline() : header + generateModelsInline(builder.schemas));
4616
4649
  if (mutators) implementationData += generateMutatorImports({
4617
4650
  mutators,
@@ -4633,9 +4666,9 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
4633
4666
  implementationData += `\n${implementation}`;
4634
4667
  mockData += `\n${implementationMock}`;
4635
4668
  const implementationFilename = filename + (OutputClient.ANGULAR === output.client ? ".service" : "") + extension;
4636
- const implementationPath = path.join(dirname, implementationFilename);
4669
+ const implementationPath = nodePath.join(dirname, implementationFilename);
4637
4670
  await writeGeneratedFile(implementationPath, implementationData);
4638
- const mockPath = output.mock ? path.join(dirname, filename + "." + getMockFileExtensionByTypeName(output.mock) + extension) : void 0;
4671
+ const mockPath = output.mock ? nodePath.join(dirname, filename + "." + getMockFileExtensionByTypeName(output.mock) + extension) : void 0;
4639
4672
  if (mockPath) await writeGeneratedFile(mockPath, mockData);
4640
4673
  return [
4641
4674
  implementationPath,
@@ -4646,7 +4679,6 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
4646
4679
  throw new Error(`Oups... 🍻. An Error occurred while splitting => ${String(error)}`, { cause: error });
4647
4680
  }
4648
4681
  }
4649
-
4650
4682
  //#endregion
4651
4683
  //#region src/writers/target-tags.ts
4652
4684
  function addDefaultTagIfEmpty(operation) {
@@ -4761,7 +4793,6 @@ function generateTargetForTags(builder, options) {
4761
4793
  };
4762
4794
  return result;
4763
4795
  }
4764
-
4765
4796
  //#endregion
4766
4797
  //#region src/writers/split-tags-mode.ts
4767
4798
  async function writeSplitTagsMode({ builder, output, projectName, header, needSchema, generateSchemasInline }) {
@@ -4772,7 +4803,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
4772
4803
  const target = generateTargetForTags(builder, output);
4773
4804
  const isAllowSyntheticDefaultImports = isSyntheticDefaultImportsAllow(output.tsconfig);
4774
4805
  const mockOption = output.mock && !isFunction(output.mock) ? output.mock : void 0;
4775
- const indexFilePath = mockOption?.indexMockFiles ? path.join(dirname, "index." + getMockFileExtensionByTypeName(mockOption) + extension) : void 0;
4806
+ const indexFilePath = mockOption?.indexMockFiles ? nodePath.join(dirname, "index." + getMockFileExtensionByTypeName(mockOption) + extension) : void 0;
4776
4807
  if (indexFilePath) await fs$1.outputFile(indexFilePath, "");
4777
4808
  const tagEntries = Object.entries(target);
4778
4809
  const generatedFilePathsArray = await Promise.all(tagEntries.map(async ([tag, target]) => {
@@ -4780,19 +4811,19 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
4780
4811
  const { imports, implementation, implementationMock, importsMock, mutators, clientMutators, formData, fetchReviver, formUrlEncoded, paramsSerializer } = target;
4781
4812
  let implementationData = header;
4782
4813
  let mockData = header;
4783
- const importerPath = path.join(dirname, tag, tag + extension);
4814
+ const importerPath = nodePath.join(dirname, tag, tag + extension);
4784
4815
  const relativeSchemasPath = output.schemas ? getRelativeImportPath(importerPath, getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname) : "../" + filename + ".schemas" + extension.replace(/\.ts$/, "");
4785
4816
  const tagNames = new Set(tagEntries.map(([t]) => t));
4786
4817
  const serviceSuffix = OutputClient.ANGULAR === output.client ? ".service" : "";
4787
4818
  const importsForBuilder = generateImportsForBuilder(output, imports.map((imp) => {
4788
4819
  if (!imp.importPath) return imp;
4789
4820
  if (!imp.importPath.startsWith(".")) return imp;
4790
- const resolvedPath = path.resolve(dirname, imp.importPath);
4791
- const targetBasename = path.basename(resolvedPath);
4821
+ const resolvedPath = nodePath.resolve(dirname, imp.importPath);
4822
+ const targetBasename = nodePath.basename(resolvedPath);
4792
4823
  let targetFile;
4793
4824
  if (tagNames.has(targetBasename)) {
4794
4825
  const tagFilename = targetBasename + serviceSuffix + extension;
4795
- targetFile = path.join(resolvedPath, tagFilename);
4826
+ targetFile = nodePath.join(resolvedPath, tagFilename);
4796
4827
  } else targetFile = resolvedPath + extension;
4797
4828
  const adjustedPath = getRelativeImportPath(importerPath, targetFile);
4798
4829
  return {
@@ -4822,7 +4853,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
4822
4853
  isAllowSyntheticDefaultImports,
4823
4854
  options: isFunction(output.mock) ? void 0 : output.mock
4824
4855
  });
4825
- const schemasPath = output.schemas ? void 0 : path.join(dirname, filename + ".schemas" + extension);
4856
+ const schemasPath = output.schemas ? void 0 : nodePath.join(dirname, filename + ".schemas" + extension);
4826
4857
  if (schemasPath && needSchema) await writeGeneratedFile(schemasPath, generateSchemasInline ? header + generateSchemasInline() : header + generateModelsInline(builder.schemas));
4827
4858
  if (mutators) implementationData += generateMutatorImports({
4828
4859
  mutators,
@@ -4860,9 +4891,9 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
4860
4891
  implementationData += `\n${implementation}`;
4861
4892
  mockData += `\n${implementationMock}`;
4862
4893
  const implementationFilename = tag + (OutputClient.ANGULAR === output.client ? ".service" : "") + extension;
4863
- const implementationPath = path.join(dirname, tag, implementationFilename);
4894
+ const implementationPath = nodePath.join(dirname, tag, implementationFilename);
4864
4895
  await writeGeneratedFile(implementationPath, implementationData);
4865
- const mockPath = output.mock ? path.join(dirname, tag, tag + "." + getMockFileExtensionByTypeName(output.mock) + extension) : void 0;
4896
+ const mockPath = output.mock ? nodePath.join(dirname, tag, tag + "." + getMockFileExtensionByTypeName(output.mock) + extension) : void 0;
4866
4897
  if (mockPath) await writeGeneratedFile(mockPath, mockData);
4867
4898
  return [
4868
4899
  implementationPath,
@@ -4882,7 +4913,6 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
4882
4913
  }
4883
4914
  return [...new Set([...indexFilePath ? [indexFilePath] : [], ...generatedFilePathsArray.flat()])];
4884
4915
  }
4885
-
4886
4916
  //#endregion
4887
4917
  //#region src/writers/tags-mode.ts
4888
4918
  async function writeTagsMode({ builder, output, projectName, header, needSchema, generateSchemasInline }) {
@@ -4932,7 +4962,7 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema,
4932
4962
  options: isFunction(output.mock) ? void 0 : output.mock
4933
4963
  });
4934
4964
  }
4935
- const schemasPath = output.schemas ? void 0 : path.join(dirname, filename + ".schemas" + extension);
4965
+ const schemasPath = output.schemas ? void 0 : nodePath.join(dirname, filename + ".schemas" + extension);
4936
4966
  if (schemasPath && needSchema) await writeGeneratedFile(schemasPath, generateSchemasInline ? header + generateSchemasInline() : header + generateModelsInline(builder.schemas));
4937
4967
  if (mutators) data += generateMutatorImports({
4938
4968
  mutators,
@@ -4957,7 +4987,7 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema,
4957
4987
  data += "\n\n";
4958
4988
  data += implementationMock;
4959
4989
  }
4960
- const implementationPath = path.join(dirname, `${kebab(tag)}${extension}`);
4990
+ const implementationPath = nodePath.join(dirname, `${kebab(tag)}${extension}`);
4961
4991
  await writeGeneratedFile(implementationPath, data);
4962
4992
  return [implementationPath, ...schemasPath ? [schemasPath] : []];
4963
4993
  } catch (error) {
@@ -4965,7 +4995,7 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema,
4965
4995
  }
4966
4996
  }))).flat();
4967
4997
  }
4968
-
4969
4998
  //#endregion
4970
- export { BODY_TYPE_NAME, EnumGeneration, ErrorWithTag, FormDataArrayHandling, GetterPropType, LogLevels, NamingConvention, OutputClient, OutputHttpClient, OutputMockType, OutputMode, PropertySortOrder, RefComponentSuffix, SchemaType, SupportedFormatter, TEMPLATE_TAG_REGEX, URL_REGEX, VERBS_WITH_BODY, Verbs, _filteredVerbs, addDependency, asyncReduce, camel, combineSchemas, compareVersions, conventionName, count, createDebugger, createLogger, createSuccessMessage, createTypeAliasIfNeeded, dedupeUnionType, dynamicImport, escape, escapeRegExp, filterByContentType, fixCrossDirectoryImports, fixRegularSchemaImports, generalJSTypes, generalJSTypesWithArray, generateAxiosOptions, generateBodyMutatorConfig, generateBodyOptions, generateComponentDefinition, generateDependencyImports, generateFormDataAndUrlEncodedFunction, generateImports, generateModelInline, generateModelsInline, generateMutator, generateMutatorConfig, generateMutatorImports, generateMutatorRequestOptions, generateOptions, generateParameterDefinition, generateQueryParamsAxiosConfig, generateSchemasDefinition, generateTarget, generateTargetForTags, generateVerbImports, generateVerbOptions, generateVerbsOptions, getAngularFilteredParamsCallExpression, getAngularFilteredParamsExpression, getAngularFilteredParamsHelperBody, getArray, getBaseUrlRuntimeImports, getBodiesByContentType, getBody, getCombinedEnumValue, getDefaultContentType, getEnum, getEnumDescriptions, getEnumImplementation, getEnumNames, getEnumUnionFromSchema, getExtension, getFileInfo, getFormDataFieldFileType, getFullRoute, getIsBodyVerb, getKey, getMockFileExtensionByTypeName, getNumberWord, getObject, getOperationId, getOrvalGeneratedTypes, getParameters, getParams, getParamsInPath, getPropertySafe, getProps, getQueryParams, getRefInfo, getResReqTypes, getResponse, getResponseTypeCategory, getRoute, getRouteAsArray, getScalar, getSuccessResponseType, getTypedResponse, getWarningCount, isBinaryContentType, isBoolean, isDirectory, isFunction, isModule, isNullish, isNumber, isNumeric, isObject, isReference, isSchema, isString, isStringLike, isSyntheticDefaultImportsAllow, isUrl, isVerb, isVerbose, jsDoc, jsStringEscape, kebab, keyValuePairsToJsDoc, log, logError, logVerbose, logWarning, mergeDeep, mismatchArgsMessage, pascal, removeFilesAndEmptyFolders, resetWarnings, resolveDiscriminators, resolveExampleRefs, resolveInstalledVersion, resolveInstalledVersions, resolveObject, resolveRef, resolveValue, sanitize, setVerbose, snake, sortByPriority, splitSchemasByType, startMessage, stringify, toObjectString, path_exports as upath, upper, writeModelInline, writeModelsInline, writeSchema, writeSchemas, writeSingleMode, writeSplitMode, writeSplitTagsMode, writeTagsMode };
4999
+ export { BODY_TYPE_NAME, EnumGeneration, ErrorWithTag, FormDataArrayHandling, GetterPropType, LogLevels, NamingConvention, OutputClient, OutputHttpClient, OutputMockType, OutputMode, PropertySortOrder, RefComponentSuffix, SchemaType, SupportedFormatter, TEMPLATE_TAG_REGEX, URL_REGEX, VERBS_WITH_BODY, Verbs, addDependency, asyncReduce, camel, collectReferencedComponents, combineSchemas, compareVersions, conventionName, count, createDebugger, createLogger, createSuccessMessage, createTypeAliasIfNeeded, dedupeUnionType, dynamicImport, escape, escapeRegExp, filterByContentType, filteredVerbs, fixCrossDirectoryImports, fixRegularSchemaImports, generalJSTypes, generalJSTypesWithArray, generateAxiosOptions, generateBodyMutatorConfig, generateBodyOptions, generateComponentDefinition, generateDependencyImports, generateFormDataAndUrlEncodedFunction, generateImports, generateModelInline, generateModelsInline, generateMutator, generateMutatorConfig, generateMutatorImports, generateMutatorRequestOptions, generateOptions, generateParameterDefinition, generateQueryParamsAxiosConfig, generateSchemasDefinition, generateTarget, generateTargetForTags, generateVerbImports, generateVerbOptions, generateVerbsOptions, getAngularFilteredParamsCallExpression, getAngularFilteredParamsExpression, getAngularFilteredParamsHelperBody, getArray, getBaseUrlRuntimeImports, getBodiesByContentType, getBody, getCombinedEnumValue, getDefaultContentType, getEnum, getEnumDescriptions, getEnumImplementation, getEnumNames, getEnumUnionFromSchema, getExtension, getFileInfo, getFormDataFieldFileType, getFullRoute, getIsBodyVerb, getKey, getMockFileExtensionByTypeName, getNumberWord, getObject, getOperationId, getOrvalGeneratedTypes, getParameters, getParams, getParamsInPath, getPropertySafe, getProps, getQueryParams, getRefInfo, getResReqTypes, getResponse, getResponseTypeCategory, getRoute, getRouteAsArray, getScalar, getSuccessResponseType, getTypedResponse, getWarningCount, isBinaryContentType, isBoolean, isDirectory, isFunction, isModule, isNullish, isNumber, isNumeric, isObject, isReference, isSchema, isString, isStringLike, isSyntheticDefaultImportsAllow, isUrl, isVerb, isVerbose, jsDoc, jsStringEscape, kebab, keyValuePairsToJsDoc, log, logError, logVerbose, logWarning, mergeDeep, mismatchArgsMessage, pascal, removeFilesAndEmptyFolders, resetWarnings, resolveDiscriminators, resolveExampleRefs, resolveInstalledVersion, resolveInstalledVersions, resolveObject, resolveRef, resolveValue, sanitize, setVerbose, snake, sortByPriority, splitSchemasByType, startMessage, stringify, toObjectString, path_exports as upath, upper, writeModelInline, writeModelsInline, writeSchema, writeSchemas, writeSingleMode, writeSplitMode, writeSplitTagsMode, writeTagsMode };
5000
+
4971
5001
  //# sourceMappingURL=index.mjs.map