@orval/core 8.5.2 → 8.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -2018,14 +2018,16 @@ declare function toObjectString<T>(props: T[], path?: keyof T): string;
2018
2018
  */
2019
2019
  declare function getNumberWord(num: number): string;
2020
2020
  /**
2021
- * Escapes a specific character in a string by prefixing it with a backslash.
2021
+ * Escapes a specific character in a string by prefixing all of its occurrences with a backslash.
2022
2022
  *
2023
2023
  * @param str - The string to escape, or null.
2024
2024
  * @param char - The character to escape. Defaults to single quote (').
2025
2025
  * @returns The escaped string, or null if the input is null.
2026
2026
  * @example
2027
2027
  * escape("don't") // returns "don\'t"
2028
+ * escape("it's John's") // returns "it\'s John\'s"
2028
2029
  * escape('say "hello"', '"') // returns 'say \\"hello\\"'
2030
+ * escape("a'''b", "'") // returns "a\'\'\'b"
2029
2031
  */
2030
2032
  declare function escape(str: string | null, char?: string): string | undefined;
2031
2033
  /**
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { t as __exportAll } from "./chunk-C7Uep-_p.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";
@@ -134,7 +134,7 @@ function isReference(obj) {
134
134
  return !isNullish$1(obj) && Object.hasOwn(obj, "$ref");
135
135
  }
136
136
  function isDirectory(pathValue) {
137
- return !path.extname(pathValue);
137
+ return !nodePath.extname(pathValue);
138
138
  }
139
139
  function isObject(x) {
140
140
  return Object.prototype.toString.call(x) === "[object Object]";
@@ -461,14 +461,14 @@ async function dynamicImport(toImport, from = process.cwd(), takeDefault = true)
461
461
  if (!toImport) return toImport;
462
462
  try {
463
463
  if (isString(toImport)) {
464
- const fileUrl = pathToFileURL(path.resolve(from, toImport));
465
- const data = path.extname(fileUrl.href) === ".json" ? await import(fileUrl.href, { with: { type: "json" } }) : await import(fileUrl.href);
464
+ const fileUrl = pathToFileURL(nodePath.resolve(from, toImport));
465
+ const data = nodePath.extname(fileUrl.href) === ".json" ? await import(fileUrl.href, { with: { type: "json" } }) : await import(fileUrl.href);
466
466
  if (takeDefault && (isObject(data) || isModule(data)) && data.default) return data.default;
467
467
  return data;
468
468
  }
469
469
  return toImport;
470
470
  } catch (error) {
471
- throw new Error(`Oups... 🍻. Path: ${String(toImport)} => ${String(error)}`);
471
+ throw new Error(`Oups... 🍻. Path: ${String(toImport)} => ${String(error)}`, { cause: error });
472
472
  }
473
473
  }
474
474
 
@@ -482,14 +482,14 @@ function getExtension(path) {
482
482
  //#region src/utils/file.ts
483
483
  function getFileInfo(target = "", { backupFilename = "filename", extension = ".ts" } = {}) {
484
484
  const isDir = isDirectory(target);
485
- const filePath = isDir ? path.join(target, backupFilename + extension) : target;
485
+ const filePath = isDir ? nodePath.join(target, backupFilename + extension) : target;
486
486
  return {
487
487
  path: filePath,
488
488
  pathWithoutExtension: filePath.replace(/\.[^/.]+$/, ""),
489
489
  extension,
490
490
  isDirectory: isDir,
491
- dirname: path.dirname(filePath),
492
- filename: path.basename(filePath, extension.startsWith(".") ? extension : `.${extension}`)
491
+ dirname: nodePath.dirname(filePath),
492
+ filename: nodePath.basename(filePath, extension.startsWith(".") ? extension : `.${extension}`)
493
493
  };
494
494
  }
495
495
  async function removeFilesAndEmptyFolders(patterns, dir) {
@@ -565,7 +565,7 @@ function startMessage({ name, version, description }) {
565
565
  return `🍻 ${styleText(["cyan", "bold"], name)} ${styleText("green", `v${version}`)}${description ? ` - ${description}` : ""}`;
566
566
  }
567
567
  function logError(err, tag) {
568
- let message = "";
568
+ let message;
569
569
  if (err instanceof Error) {
570
570
  message = (err.message || err.stack) ?? "Unknown error";
571
571
  if (err.cause) {
@@ -693,13 +693,13 @@ function toUnix(value) {
693
693
  return value;
694
694
  }
695
695
  function join(...args) {
696
- return toUnix(path.join(...args.map((a) => toUnix(a))));
696
+ return toUnix(nodePath.join(...args.map((a) => toUnix(a))));
697
697
  }
698
698
  /**
699
699
  * Behaves exactly like `path.relative(from, to)`, but keeps the first meaningful "./"
700
700
  */
701
701
  function relativeSafe(from, to) {
702
- return normalizeSafe(`.${separator}${toUnix(path.relative(toUnix(from), toUnix(to)))}`);
702
+ return normalizeSafe(`.${separator}${toUnix(nodePath.relative(toUnix(from), toUnix(to)))}`);
703
703
  }
704
704
  function getSchemaFileName(path) {
705
705
  return path.replace(`.${getExtension(path)}`, "").slice(path.lastIndexOf("/") + 1);
@@ -708,13 +708,13 @@ const separator = "/";
708
708
  function normalizeSafe(value) {
709
709
  let result;
710
710
  value = toUnix(value);
711
- result = toUnix(path.normalize(value));
711
+ result = toUnix(nodePath.normalize(value));
712
712
  if (value.startsWith("./") && !result.startsWith("./") && !result.startsWith("..")) result = "./" + result;
713
713
  else if (value.startsWith("//") && !result.startsWith("//")) result = value.startsWith("//./") ? "//." + result : "/" + result;
714
714
  return result;
715
715
  }
716
716
  function joinSafe(...values) {
717
- let result = toUnix(path.join(...values.map((v) => toUnix(v))));
717
+ let result = toUnix(nodePath.join(...values.map((v) => toUnix(v))));
718
718
  if (values.length > 0) {
719
719
  const firstValue = toUnix(values[0]);
720
720
  if (firstValue.startsWith("./") && !result.startsWith("./") && !result.startsWith("..")) result = "./" + result;
@@ -745,14 +745,14 @@ function joinSafe(...values) {
745
745
  * @returns The relative import path string.
746
746
  */
747
747
  function getRelativeImportPath(importerFilePath, exporterFilePath, includeFileExtension = false) {
748
- if (!path.isAbsolute(importerFilePath)) throw new Error(`'importerFilePath' is not an absolute path. "${importerFilePath}"`);
749
- if (!path.isAbsolute(exporterFilePath)) throw new Error(`'exporterFilePath' is not an absolute path. "${exporterFilePath}"`);
750
- const importerDir = path.dirname(importerFilePath);
751
- const relativePath = path.relative(importerDir, exporterFilePath);
752
- let posixPath = path.posix.join(...relativePath.split(path.sep));
748
+ if (!nodePath.isAbsolute(importerFilePath)) throw new Error(`'importerFilePath' is not an absolute path. "${importerFilePath}"`);
749
+ if (!nodePath.isAbsolute(exporterFilePath)) throw new Error(`'exporterFilePath' is not an absolute path. "${exporterFilePath}"`);
750
+ const importerDir = nodePath.dirname(importerFilePath);
751
+ const relativePath = nodePath.relative(importerDir, exporterFilePath);
752
+ let posixPath = nodePath.posix.join(...relativePath.split(nodePath.sep));
753
753
  if (!posixPath.startsWith("./") && !posixPath.startsWith("../")) posixPath = `./${posixPath}`;
754
754
  if (!includeFileExtension) {
755
- const ext = path.extname(posixPath);
755
+ const ext = nodePath.extname(posixPath);
756
756
  if (ext && posixPath.endsWith(ext)) posixPath = posixPath.slice(0, -ext.length);
757
757
  }
758
758
  return posixPath;
@@ -762,20 +762,20 @@ function getRelativeImportPath(importerFilePath, exporterFilePath, includeFileEx
762
762
  //#region src/utils/resolve-version.ts
763
763
  function resolveInstalledVersion(packageName, fromDir) {
764
764
  try {
765
- const require = createRequire(path.join(fromDir, "noop.js"));
765
+ const require = createRequire(nodePath.join(fromDir, "noop.js"));
766
766
  try {
767
767
  return require(`${packageName}/package.json`).version;
768
768
  } catch (directError) {
769
769
  if (directError instanceof Error && "code" in directError && directError.code === "ERR_PACKAGE_PATH_NOT_EXPORTED") {
770
770
  const entryPath = require.resolve(packageName);
771
- let dir = path.dirname(entryPath);
772
- while (dir !== path.parse(dir).root) {
773
- const pkgPath = path.join(dir, "package.json");
771
+ let dir = nodePath.dirname(entryPath);
772
+ while (dir !== nodePath.parse(dir).root) {
773
+ const pkgPath = nodePath.join(dir, "package.json");
774
774
  if (existsSync(pkgPath)) {
775
775
  const pkgData = JSON.parse(readFileSync(pkgPath, "utf8"));
776
776
  if (pkgData.name === packageName) return pkgData.version;
777
777
  }
778
- dir = path.dirname(dir);
778
+ dir = nodePath.dirname(dir);
779
779
  }
780
780
  return;
781
781
  }
@@ -918,17 +918,19 @@ function getNumberWord(num) {
918
918
  return [...num.toString()].reduce((acc, n) => acc + NUMBERS[n], "");
919
919
  }
920
920
  /**
921
- * Escapes a specific character in a string by prefixing it with a backslash.
921
+ * Escapes a specific character in a string by prefixing all of its occurrences with a backslash.
922
922
  *
923
923
  * @param str - The string to escape, or null.
924
924
  * @param char - The character to escape. Defaults to single quote (').
925
925
  * @returns The escaped string, or null if the input is null.
926
926
  * @example
927
927
  * escape("don't") // returns "don\'t"
928
+ * escape("it's John's") // returns "it\'s John\'s"
928
929
  * escape('say "hello"', '"') // returns 'say \\"hello\\"'
930
+ * escape("a'''b", "'") // returns "a\'\'\'b"
929
931
  */
930
932
  function escape(str, char = "'") {
931
- return str?.replace(char, `\\${char}`);
933
+ return str?.replaceAll(char, `\\${char}`);
932
934
  }
933
935
  /**
934
936
  * Escape all characters not included in SingleStringCharacters and
@@ -3969,19 +3971,26 @@ function getSchemaGroups(schemaPath, schemas, namingConvention, fileExtension) {
3969
3971
  }
3970
3972
  function getCanonicalMap(schemaGroups, schemaPath, namingConvention, fileExtension) {
3971
3973
  const canonicalPathMap = /* @__PURE__ */ new Map();
3974
+ const canonicalNameMap = /* @__PURE__ */ new Map();
3972
3975
  for (const [key, groupSchemas] of Object.entries(schemaGroups)) {
3973
- const canonicalPath = getPath(schemaPath, conventionName(groupSchemas[0].name, namingConvention), fileExtension);
3974
- canonicalPathMap.set(key, {
3975
- importPath: canonicalPath,
3976
+ const canonicalInfo = {
3977
+ importPath: getPath(schemaPath, conventionName(groupSchemas[0].name, namingConvention), fileExtension),
3976
3978
  name: groupSchemas[0].name
3977
- });
3979
+ };
3980
+ canonicalPathMap.set(key, canonicalInfo);
3981
+ for (const schema of groupSchemas) canonicalNameMap.set(schema.name, canonicalInfo);
3978
3982
  }
3979
- return canonicalPathMap;
3983
+ return {
3984
+ canonicalPathMap,
3985
+ canonicalNameMap
3986
+ };
3980
3987
  }
3981
- function normalizeCanonicalImportPaths(schemas, canonicalPathMap, schemaPath, namingConvention, fileExtension) {
3988
+ function normalizeCanonicalImportPaths(schemas, canonicalPathMap, canonicalNameMap, schemaPath, namingConvention, fileExtension) {
3982
3989
  for (const schema of schemas) schema.imports = schema.imports.map((imp) => {
3990
+ const canonicalByName = canonicalNameMap.get(imp.name);
3983
3991
  const resolvedImportKey = resolveImportKey(schemaPath, imp.importPath ?? `./${conventionName(imp.name, namingConvention)}`, fileExtension);
3984
- const canonical = canonicalPathMap.get(resolvedImportKey);
3992
+ const canonicalByPath = canonicalPathMap.get(resolvedImportKey);
3993
+ const canonical = canonicalByName ?? canonicalByPath;
3985
3994
  if (!canonical?.importPath) return imp;
3986
3995
  const importPath = removeFileExtension(relativeSafe(schemaPath, canonical.importPath.replaceAll("\\", "/")), fileExtension);
3987
3996
  return {
@@ -4020,8 +4029,8 @@ function getSchema({ schema: { imports, model }, target, header, namingConventio
4020
4029
  file += model;
4021
4030
  return file;
4022
4031
  }
4023
- function getPath(path$1, name, fileExtension) {
4024
- return path.join(path$1, `${name}${fileExtension}`);
4032
+ function getPath(path, name, fileExtension) {
4033
+ return nodePath.join(path, `${name}${fileExtension}`);
4025
4034
  }
4026
4035
  function writeModelInline(acc, model) {
4027
4036
  return acc + `${model}\n`;
@@ -4041,12 +4050,13 @@ async function writeSchema({ path, schema, target, namingConvention, fileExtensi
4041
4050
  namingConvention
4042
4051
  }));
4043
4052
  } catch (error) {
4044
- throw new Error(`Oups... 🍻. An Error occurred while writing schema ${name} => ${String(error)}`);
4053
+ throw new Error(`Oups... 🍻. An Error occurred while writing schema ${name} => ${String(error)}`, { cause: error });
4045
4054
  }
4046
4055
  }
4047
4056
  async function writeSchemas({ schemaPath, schemas, target, namingConvention, fileExtension, header, indexFiles }) {
4048
4057
  const schemaGroups = getSchemaGroups(schemaPath, schemas, namingConvention, fileExtension);
4049
- normalizeCanonicalImportPaths(schemas, getCanonicalMap(schemaGroups, schemaPath, namingConvention, fileExtension), schemaPath, namingConvention, fileExtension);
4058
+ const { canonicalPathMap, canonicalNameMap } = getCanonicalMap(schemaGroups, schemaPath, namingConvention, fileExtension);
4059
+ normalizeCanonicalImportPaths(schemas, canonicalPathMap, canonicalNameMap, schemaPath, namingConvention, fileExtension);
4050
4060
  for (const groupSchemas of Object.values(schemaGroups)) {
4051
4061
  if (groupSchemas.length === 1) {
4052
4062
  await writeSchema({
@@ -4069,7 +4079,7 @@ async function writeSchemas({ schemaPath, schemas, target, namingConvention, fil
4069
4079
  });
4070
4080
  }
4071
4081
  if (indexFiles) {
4072
- const schemaFilePath = path.join(schemaPath, `index${fileExtension}`);
4082
+ const schemaFilePath = nodePath.join(schemaPath, `index${fileExtension}`);
4073
4083
  await fs$1.ensureFile(schemaFilePath);
4074
4084
  const ext = fileExtension.endsWith(".ts") ? fileExtension.slice(0, -3) : fileExtension;
4075
4085
  const conventionNamesSet = new Set(Object.values(schemaGroups).map((group) => conventionName(group[0].name, namingConvention)));
@@ -4083,7 +4093,7 @@ async function writeSchemas({ schemaPath, schemas, target, namingConvention, fil
4083
4093
  const fileContent = `${header}\n${[...new Set([...existingExports, ...currentExports])].toSorted((a, b) => a.localeCompare(b)).join("\n")}`;
4084
4094
  await fs$1.writeFile(schemaFilePath, fileContent, { encoding: "utf8" });
4085
4095
  } catch (error) {
4086
- throw new Error(`Oups... 🍻. An Error occurred while writing schema index file ${schemaFilePath} => ${String(error)}`);
4096
+ throw new Error(`Oups... 🍻. An Error occurred while writing schema index file ${schemaFilePath} => ${String(error)}`, { cause: error });
4087
4097
  }
4088
4098
  }
4089
4099
  }
@@ -4092,7 +4102,7 @@ async function writeSchemas({ schemaPath, schemas, target, namingConvention, fil
4092
4102
  //#region src/writers/generate-imports-for-builder.ts
4093
4103
  function generateImportsForBuilder(output, imports, relativeSchemasPath) {
4094
4104
  const isZodSchemaOutput = isObject(output.schemas) && output.schemas.type === "zod";
4095
- let schemaImports = [];
4105
+ let schemaImports;
4096
4106
  if (output.indexFiles) schemaImports = isZodSchemaOutput ? [{
4097
4107
  exports: imports.filter((i) => !i.importPath),
4098
4108
  dependency: joinSafe(relativeSchemasPath, "index.zod")
@@ -4298,7 +4308,7 @@ async function writeSingleMode({ builder, output, projectName, header, needSchem
4298
4308
  return [path];
4299
4309
  } catch (error) {
4300
4310
  const errorMsg = error instanceof Error ? error.message : "unknown error";
4301
- throw new Error(`Oups... 🍻. An Error occurred while writing file => ${errorMsg}`);
4311
+ throw new Error(`Oups... 🍻. An Error occurred while writing file => ${errorMsg}`, { cause: error });
4302
4312
  }
4303
4313
  }
4304
4314
 
@@ -4338,7 +4348,7 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
4338
4348
  isAllowSyntheticDefaultImports,
4339
4349
  options: isFunction(output.mock) ? void 0 : output.mock
4340
4350
  });
4341
- const schemasPath = output.schemas ? void 0 : path.join(dirname, filename + ".schemas" + extension);
4351
+ const schemasPath = output.schemas ? void 0 : nodePath.join(dirname, filename + ".schemas" + extension);
4342
4352
  if (schemasPath && needSchema) {
4343
4353
  const schemasData = header + generateModelsInline(builder.schemas);
4344
4354
  await fs$1.outputFile(schemasPath, schemasData);
@@ -4363,9 +4373,9 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
4363
4373
  implementationData += `\n${implementation}`;
4364
4374
  mockData += `\n${implementationMock}`;
4365
4375
  const implementationFilename = filename + (OutputClient.ANGULAR === output.client ? ".service" : "") + extension;
4366
- const implementationPath = path.join(dirname, implementationFilename);
4376
+ const implementationPath = nodePath.join(dirname, implementationFilename);
4367
4377
  await fs$1.outputFile(implementationPath, implementationData);
4368
- const mockPath = output.mock ? path.join(dirname, filename + "." + getMockFileExtensionByTypeName(output.mock) + extension) : void 0;
4378
+ const mockPath = output.mock ? nodePath.join(dirname, filename + "." + getMockFileExtensionByTypeName(output.mock) + extension) : void 0;
4369
4379
  if (mockPath) await fs$1.outputFile(mockPath, mockData);
4370
4380
  return [
4371
4381
  implementationPath,
@@ -4373,7 +4383,7 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
4373
4383
  ...mockPath ? [mockPath] : []
4374
4384
  ];
4375
4385
  } catch (error) {
4376
- throw new Error(`Oups... 🍻. An Error occurred while splitting => ${String(error)}`);
4386
+ throw new Error(`Oups... 🍻. An Error occurred while splitting => ${String(error)}`, { cause: error });
4377
4387
  }
4378
4388
  }
4379
4389
 
@@ -4502,7 +4512,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
4502
4512
  const target = generateTargetForTags(builder, output);
4503
4513
  const isAllowSyntheticDefaultImports = isSyntheticDefaultImportsAllow(output.tsconfig);
4504
4514
  const mockOption = output.mock && !isFunction(output.mock) ? output.mock : void 0;
4505
- const indexFilePath = mockOption?.indexMockFiles ? path.join(dirname, "index." + getMockFileExtensionByTypeName(mockOption) + extension) : void 0;
4515
+ const indexFilePath = mockOption?.indexMockFiles ? nodePath.join(dirname, "index." + getMockFileExtensionByTypeName(mockOption) + extension) : void 0;
4506
4516
  if (indexFilePath) await fs$1.outputFile(indexFilePath, "");
4507
4517
  const tagEntries = Object.entries(target);
4508
4518
  const generatedFilePathsArray = await Promise.all(tagEntries.map(async ([tag, target]) => {
@@ -4510,7 +4520,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
4510
4520
  const { imports, implementation, implementationMock, importsMock, mutators, clientMutators, formData, fetchReviver, formUrlEncoded, paramsSerializer } = target;
4511
4521
  let implementationData = header;
4512
4522
  let mockData = header;
4513
- const importerPath = path.join(dirname, tag, tag + extension);
4523
+ const importerPath = nodePath.join(dirname, tag, tag + extension);
4514
4524
  const relativeSchemasPath = output.schemas ? getRelativeImportPath(importerPath, getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname) : "../" + filename + ".schemas";
4515
4525
  const importsForBuilder = generateImportsForBuilder(output, imports, relativeSchemasPath);
4516
4526
  implementationData += builder.imports({
@@ -4535,7 +4545,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
4535
4545
  isAllowSyntheticDefaultImports,
4536
4546
  options: isFunction(output.mock) ? void 0 : output.mock
4537
4547
  });
4538
- const schemasPath = output.schemas ? void 0 : path.join(dirname, filename + ".schemas" + extension);
4548
+ const schemasPath = output.schemas ? void 0 : nodePath.join(dirname, filename + ".schemas" + extension);
4539
4549
  if (schemasPath && needSchema) {
4540
4550
  const schemasData = header + generateModelsInline(builder.schemas);
4541
4551
  await fs$1.outputFile(schemasPath, schemasData);
@@ -4576,9 +4586,9 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
4576
4586
  implementationData += `\n${implementation}`;
4577
4587
  mockData += `\n${implementationMock}`;
4578
4588
  const implementationFilename = tag + (OutputClient.ANGULAR === output.client ? ".service" : "") + extension;
4579
- const implementationPath = path.join(dirname, tag, implementationFilename);
4589
+ const implementationPath = nodePath.join(dirname, tag, implementationFilename);
4580
4590
  await fs$1.outputFile(implementationPath, implementationData);
4581
- const mockPath = output.mock ? path.join(dirname, tag, tag + "." + getMockFileExtensionByTypeName(output.mock) + extension) : void 0;
4591
+ const mockPath = output.mock ? nodePath.join(dirname, tag, tag + "." + getMockFileExtensionByTypeName(output.mock) + extension) : void 0;
4582
4592
  if (mockPath) await fs$1.outputFile(mockPath, mockData);
4583
4593
  return [
4584
4594
  implementationPath,
@@ -4586,7 +4596,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
4586
4596
  ...mockPath ? [mockPath] : []
4587
4597
  ];
4588
4598
  } catch (error) {
4589
- throw new Error(`Oups... 🍻. An Error occurred while splitting tag ${tag} => ${String(error)}`);
4599
+ throw new Error(`Oups... 🍻. An Error occurred while splitting tag ${tag} => ${String(error)}`, { cause: error });
4590
4600
  }
4591
4601
  }));
4592
4602
  if (indexFilePath && mockOption) {
@@ -4638,7 +4648,7 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema
4638
4648
  options: isFunction(output.mock) ? void 0 : output.mock
4639
4649
  });
4640
4650
  }
4641
- const schemasPath = output.schemas ? void 0 : path.join(dirname, filename + ".schemas" + extension);
4651
+ const schemasPath = output.schemas ? void 0 : nodePath.join(dirname, filename + ".schemas" + extension);
4642
4652
  if (schemasPath && needSchema) {
4643
4653
  const schemasData = header + generateModelsInline(builder.schemas);
4644
4654
  await fs$1.outputFile(schemasPath, schemasData);
@@ -4666,11 +4676,11 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema
4666
4676
  data += "\n\n";
4667
4677
  data += implementationMock;
4668
4678
  }
4669
- const implementationPath = path.join(dirname, `${kebab(tag)}${extension}`);
4679
+ const implementationPath = nodePath.join(dirname, `${kebab(tag)}${extension}`);
4670
4680
  await fs$1.outputFile(implementationPath, data);
4671
4681
  return [implementationPath, ...schemasPath ? [schemasPath] : []];
4672
4682
  } catch (error) {
4673
- throw new Error(`Oups... 🍻. An Error occurred while writing tag ${tag} => ${String(error)}`);
4683
+ throw new Error(`Oups... 🍻. An Error occurred while writing tag ${tag} => ${String(error)}`, { cause: error });
4674
4684
  }
4675
4685
  }))).flat();
4676
4686
  }