@orval/core 8.4.2 → 8.5.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,4 +1,4 @@
1
- import { t as __export } from "./chunk-1-as6MWF.mjs";
1
+ 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";
@@ -9,7 +9,7 @@ import { pathToFileURL } from "node:url";
9
9
  import fs, { existsSync, readFileSync } from "node:fs";
10
10
  import { globby } from "globby";
11
11
  import readline from "node:readline";
12
- import chalk from "chalk";
12
+ import { styleText } from "node:util";
13
13
  import { isDereferenced } from "@scalar/openapi-types/helpers";
14
14
  import fs$1 from "fs-extra";
15
15
  import { Parser } from "acorn";
@@ -195,10 +195,10 @@ const regexps = {
195
195
  sentence: new RegExp(String.raw`(^\s*|[\?\!\.]+"?\s+"?|,\s+")([` + lowers + "])", "g"),
196
196
  improper: new RegExp(String.raw`\b(` + impropers + String.raw`)\b`, "g"),
197
197
  relax: new RegExp("([^" + uppers + "])([" + uppers + "]*)([" + uppers + "])(?=[^" + uppers + "]|$)", "g"),
198
- upper: /* @__PURE__ */ new RegExp("^[^" + lowers + "]+$"),
198
+ upper: new RegExp("^[^" + lowers + "]+$"),
199
199
  hole: /[^\s]\s[^\s]/,
200
200
  apostrophe: /'/g,
201
- room: /* @__PURE__ */ new RegExp("[" + symbols + "]")
201
+ room: new RegExp("[" + symbols + "]")
202
202
  };
203
203
  const deapostrophe = (s) => {
204
204
  return s.replace(regexps.apostrophe, "");
@@ -350,11 +350,11 @@ function getFormDataFieldFileType(resolvedSchema, partContentType) {
350
350
  * filterByContentType(types, { exclude: ['text/xml'] });
351
351
  * ```
352
352
  */
353
- function filterByContentType(items, filter$1) {
354
- if (!filter$1) return items;
353
+ function filterByContentType(items, filter) {
354
+ if (!filter) return items;
355
355
  return items.filter((item) => {
356
- const shouldInclude = !filter$1.include || filter$1.include.includes(item.contentType);
357
- const shouldExclude = filter$1.exclude?.includes(item.contentType) ?? false;
356
+ const shouldInclude = !filter.include || filter.include.includes(item.contentType);
357
+ const shouldExclude = filter.exclude?.includes(item.contentType) ?? false;
358
358
  return shouldInclude && !shouldExclude;
359
359
  });
360
360
  }
@@ -364,13 +364,13 @@ function filterByContentType(items, filter$1) {
364
364
  const filter = process.env.ORVAL_DEBUG_FILTER;
365
365
  const DEBUG = process.env.DEBUG;
366
366
  function createDebugger(ns, options = {}) {
367
- const log$1 = debug(ns);
367
+ const log = debug(ns);
368
368
  const { onlyWhenFocused } = options;
369
369
  const focus = isString(onlyWhenFocused) ? onlyWhenFocused : ns;
370
370
  return (msg, ...args) => {
371
371
  if (filter && !msg.includes(filter)) return;
372
372
  if (onlyWhenFocused && !DEBUG?.includes(focus)) return;
373
- log$1(msg, ...args);
373
+ log(msg, ...args);
374
374
  };
375
375
  }
376
376
 
@@ -381,13 +381,13 @@ const replacement = String.raw`*\/`;
381
381
  const regex$1 = new RegExp(search, "g");
382
382
  function jsDoc(schema, tryOneLine = false, context) {
383
383
  if (context?.output.override.jsDoc) {
384
- const { filter: filter$1 } = context.output.override.jsDoc;
385
- if (filter$1) return keyValuePairsToJsDoc(filter$1(schema));
384
+ const { filter } = context.output.override.jsDoc;
385
+ if (filter) return keyValuePairsToJsDoc(filter(schema));
386
386
  }
387
387
  const { description, deprecated, summary, minLength, maxLength, minimum, maximum, exclusiveMinimum, exclusiveMaximum, minItems, maxItems, pattern } = schema;
388
388
  const isNullable = schema.type === "null" || Array.isArray(schema.type) && schema.type.includes("null");
389
389
  const lines = (Array.isArray(description) ? description.filter((d) => !d.includes("eslint-disable")) : [description ?? ""]).map((line) => line.replaceAll(regex$1, replacement));
390
- const count$1 = [
390
+ const count = [
391
391
  description,
392
392
  deprecated,
393
393
  summary,
@@ -402,8 +402,8 @@ function jsDoc(schema, tryOneLine = false, context) {
402
402
  isNullable ? "null" : "",
403
403
  pattern
404
404
  ].filter(Boolean).length;
405
- if (!count$1) return "";
406
- const oneLine = count$1 === 1 && tryOneLine;
405
+ if (!count) return "";
406
+ const oneLine = count === 1 && tryOneLine;
407
407
  const eslintDisable = Array.isArray(description) ? description.find((d) => d.includes("eslint-disable"))?.replaceAll(regex$1, replacement) : void 0;
408
408
  let doc = `${eslintDisable ? `/* ${eslintDisable} */\n` : ""}/**`;
409
409
  if (description) {
@@ -474,8 +474,8 @@ async function dynamicImport(toImport, from = process.cwd(), takeDefault = true)
474
474
 
475
475
  //#endregion
476
476
  //#region src/utils/extension.ts
477
- function getExtension(path$2) {
478
- return path$2.toLowerCase().includes(".yaml") || path$2.toLowerCase().includes(".yml") ? "yaml" : "json";
477
+ function getExtension(path) {
478
+ return path.toLowerCase().includes(".yaml") || path.toLowerCase().includes(".yml") ? "yaml" : "json";
479
479
  }
480
480
 
481
481
  //#endregion
@@ -562,7 +562,7 @@ const logVerbose = (...args) => {
562
562
  if (_verbose) log(...args);
563
563
  };
564
564
  function startMessage({ name, version, description }) {
565
- return `🍻 ${chalk.cyan.bold(name)} ${chalk.green(`v${version}`)}${description ? ` - ${description}` : ""}`;
565
+ return `🍻 ${styleText(["cyan", "bold"], name)} ${styleText("green", `v${version}`)}${description ? ` - ${description}` : ""}`;
566
566
  }
567
567
  function logError(err, tag) {
568
568
  let message = "";
@@ -573,17 +573,17 @@ function logError(err, tag) {
573
573
  message += `\n Cause: ${causeMsg}`;
574
574
  }
575
575
  } else message = String(err);
576
- log(chalk.red([
576
+ log(styleText("red", [
577
577
  "🛑",
578
578
  tag ? `${tag} -` : void 0,
579
579
  message
580
580
  ].filter(Boolean).join(" ")));
581
581
  }
582
582
  function mismatchArgsMessage(mismatchArgs) {
583
- log(chalk.yellow(`${mismatchArgs.join(", ")} ${mismatchArgs.length === 1 ? "is" : "are"} not defined in your configuration!`));
583
+ log(styleText("yellow", `${mismatchArgs.join(", ")} ${mismatchArgs.length === 1 ? "is" : "are"} not defined in your configuration!`));
584
584
  }
585
585
  function createSuccessMessage(backend) {
586
- log(`🎉 ${backend ? `${chalk.green(backend)} - ` : ""}Your OpenAPI spec has been converted into ready to use orval!`);
586
+ log(`🎉 ${backend ? `${styleText("green", backend)} - ` : ""}Your OpenAPI spec has been converted into ready to use orval!`);
587
587
  }
588
588
  const LogLevels = {
589
589
  silent: 0,
@@ -605,24 +605,24 @@ function createLogger(level = "info", options = {}) {
605
605
  const { prefix = "[vite]", allowClearScreen = true } = options;
606
606
  const thresh = LogLevels[level];
607
607
  const clear = allowClearScreen && process.stdout.isTTY && !process.env.CI ? clearScreen : () => {};
608
- function output(type, msg, options$1 = {}) {
608
+ function output(type, msg, options = {}) {
609
609
  if (thresh >= LogLevels[type]) {
610
610
  const method = type === "info" ? "log" : type;
611
611
  const format = () => {
612
- if (options$1.timestamp) {
613
- const tag = type === "info" ? chalk.cyan.bold(prefix) : type === "warn" ? chalk.yellow.bold(prefix) : chalk.red.bold(prefix);
614
- return `${chalk.dim((/* @__PURE__ */ new Date()).toLocaleTimeString())} ${tag} ${msg}`;
612
+ if (options.timestamp) {
613
+ const tag = type === "info" ? styleText(["cyan", "bold"], prefix) : type === "warn" ? styleText(["yellow", "bold"], prefix) : styleText(["red", "bold"], prefix);
614
+ return `${styleText("dim", (/* @__PURE__ */ new Date()).toLocaleTimeString())} ${tag} ${msg}`;
615
615
  } else return msg;
616
616
  };
617
617
  if (type === lastType && msg === lastMsg) {
618
618
  sameCount++;
619
619
  clear();
620
- console[method](format(), chalk.yellow(`(x${sameCount + 1})`));
620
+ console[method](format(), styleText("yellow", `(x${sameCount + 1})`));
621
621
  } else {
622
622
  sameCount = 0;
623
623
  lastMsg = msg;
624
624
  lastType = type;
625
- if (options$1.clear) clear();
625
+ if (options.clear) clear();
626
626
  console[method](format());
627
627
  }
628
628
  }
@@ -677,7 +677,7 @@ function count(str = "", key) {
677
677
 
678
678
  //#endregion
679
679
  //#region src/utils/path.ts
680
- var path_exports = /* @__PURE__ */ __export({
680
+ var path_exports = /* @__PURE__ */ __exportAll({
681
681
  basename: () => basename,
682
682
  dirname: () => dirname,
683
683
  extname: () => extname,
@@ -704,8 +704,8 @@ const { join, resolve, extname, dirname, basename, isAbsolute } = path$1;
704
704
  function relativeSafe(from, to) {
705
705
  return normalizeSafe(`.${separator}${path$1.relative(from, to)}`);
706
706
  }
707
- function getSchemaFileName(path$2) {
708
- return path$2.replace(`.${getExtension(path$2)}`, "").slice(path$2.lastIndexOf("/") + 1);
707
+ function getSchemaFileName(path) {
708
+ return path.replace(`.${getExtension(path)}`, "").slice(path.lastIndexOf("/") + 1);
709
709
  }
710
710
  const separator = "/";
711
711
  const toUnix = function(value) {
@@ -802,13 +802,13 @@ function stringify(data) {
802
802
  if (isString(data)) return `'${data.replaceAll("'", String.raw`\'`)}'`;
803
803
  if (isNumber(data) || isBoolean(data) || isFunction(data)) return String(data);
804
804
  if (Array.isArray(data)) return `[${data.map((item) => stringify(item)).join(", ")}]`;
805
- const entries$1 = Object.entries(data);
805
+ const entries = Object.entries(data);
806
806
  let result = "";
807
- for (const [index, [key, value]] of entries$1.entries()) {
807
+ for (const [index, [key, value]] of entries.entries()) {
808
808
  const strValue = stringify(value);
809
- if (entries$1.length === 1) result = `{ ${key}: ${strValue}, }`;
809
+ if (entries.length === 1) result = `{ ${key}: ${strValue}, }`;
810
810
  else if (!index) result = `{ ${key}: ${strValue}, `;
811
- else if (entries$1.length - 1 === index) result += `${key}: ${strValue}, }`;
811
+ else if (entries.length - 1 === index) result += `${key}: ${strValue}, }`;
812
812
  else result += `${key}: ${strValue}, `;
813
813
  }
814
814
  return result;
@@ -858,11 +858,11 @@ function sanitize(value, options) {
858
858
  * toObjectString(['a', 'b', 'c'])
859
859
  * // returns "a,\n b,\n c,"
860
860
  */
861
- function toObjectString(props, path$2) {
861
+ function toObjectString(props, path) {
862
862
  if (props.length === 0) return "";
863
- return (isString(path$2) ? props.map((prop$1) => {
864
- let obj = prop$1;
865
- for (const key of path$2.split(".")) obj = obj && (isObject(obj) || Array.isArray(obj)) ? obj[key] : void 0;
863
+ return (isString(path) ? props.map((prop) => {
864
+ let obj = prop;
865
+ for (const key of path.split(".")) obj = obj && (isObject(obj) || Array.isArray(obj)) ? obj[key] : void 0;
866
866
  return obj;
867
867
  }) : props).join(",\n ") + ",";
868
868
  }
@@ -1134,7 +1134,7 @@ const RefComponentSuffix = {
1134
1134
  parameters: "Parameter",
1135
1135
  requestBodies: "Body"
1136
1136
  };
1137
- const regex = new RegExp("~1", "g");
1137
+ const regex = /* @__PURE__ */ new RegExp("~1", "g");
1138
1138
  /**
1139
1139
  * Return the output type from the $ref
1140
1140
  *
@@ -1488,12 +1488,12 @@ function getResReqContentTypes({ mediaType, propName, context, isFormData, conte
1488
1488
  function getResReqTypes(responsesOrRequests, name, context, defaultType = "unknown", uniqueKey = (item) => item.value) {
1489
1489
  return uniqueBy(responsesOrRequests.filter(([, res]) => Boolean(res)).map(([key, res]) => {
1490
1490
  if (isReference(res)) {
1491
- const { schema: bodySchema, imports: [{ name: name$1, schemaName }] } = resolveRef(res, context);
1491
+ const { schema: bodySchema, imports: [{ name, schemaName }] } = resolveRef(res, context);
1492
1492
  const firstEntry = Object.entries(bodySchema.content ?? {}).at(0);
1493
1493
  if (!firstEntry) return [{
1494
- value: name$1,
1494
+ value: name,
1495
1495
  imports: [{
1496
- name: name$1,
1496
+ name,
1497
1497
  schemaName
1498
1498
  }],
1499
1499
  schemas: [],
@@ -1511,9 +1511,9 @@ function getResReqTypes(responsesOrRequests, name, context, defaultType = "unkno
1511
1511
  const isFormData = formDataContentTypes.has(contentType);
1512
1512
  const isFormUrlEncoded = formUrlEncodedContentTypes.has(contentType);
1513
1513
  if (!isFormData && !isFormUrlEncoded || !mediaType.schema) return [{
1514
- value: name$1,
1514
+ value: name,
1515
1515
  imports: [{
1516
- name: name$1,
1516
+ name,
1517
1517
  schemaName
1518
1518
  }],
1519
1519
  schemas: [],
@@ -1528,7 +1528,7 @@ function getResReqTypes(responsesOrRequests, name, context, defaultType = "unkno
1528
1528
  contentType
1529
1529
  }];
1530
1530
  const formData = isFormData ? getSchemaFormDataAndUrlEncoded({
1531
- name: name$1,
1531
+ name,
1532
1532
  schemaObject: mediaType.schema,
1533
1533
  context,
1534
1534
  isRequestBodyOptional: "required" in bodySchema && bodySchema.required === false,
@@ -1536,7 +1536,7 @@ function getResReqTypes(responsesOrRequests, name, context, defaultType = "unkno
1536
1536
  encoding: mediaType.encoding
1537
1537
  }) : void 0;
1538
1538
  const formUrlEncoded = isFormUrlEncoded ? getSchemaFormDataAndUrlEncoded({
1539
- name: name$1,
1539
+ name,
1540
1540
  schemaObject: mediaType.schema,
1541
1541
  context,
1542
1542
  isRequestBodyOptional: "required" in bodySchema && bodySchema.required === false,
@@ -1549,9 +1549,9 @@ function getResReqTypes(responsesOrRequests, name, context, defaultType = "unkno
1549
1549
  context
1550
1550
  });
1551
1551
  return [{
1552
- value: name$1,
1552
+ value: name,
1553
1553
  imports: [{
1554
- name: name$1,
1554
+ name,
1555
1555
  schemaName
1556
1556
  }, ...additionalImports],
1557
1557
  schemas: [],
@@ -1718,13 +1718,13 @@ function getSchemaFormDataAndUrlEncoded({ name, schemaObject, context, isRequest
1718
1718
  if (combinedSchemas) {
1719
1719
  const shouldCast = !!getSchemaOneOf(schema) || !!getSchemaAnyOf(schema);
1720
1720
  const combinedSchemasFormData = combinedSchemas.map((subSchema) => {
1721
- const { schema: combinedSchema, imports: imports$1 } = resolveRef(subSchema, context);
1721
+ const { schema: combinedSchema, imports } = resolveRef(subSchema, context);
1722
1722
  let newPropName = propName;
1723
1723
  let newPropDefinition = "";
1724
- if (shouldCast && imports$1[0]) {
1725
- additionalImports.push(imports$1[0]);
1726
- newPropName = `${propName}${pascal(imports$1[0].name)}`;
1727
- newPropDefinition = `const ${newPropName} = (${propName} as ${imports$1[0].name}${isRequestBodyOptional ? " | undefined" : ""});\n`;
1724
+ if (shouldCast && imports[0]) {
1725
+ additionalImports.push(imports[0]);
1726
+ newPropName = `${propName}${pascal(imports[0].name)}`;
1727
+ newPropDefinition = `const ${newPropName} = (${propName} as ${imports[0].name}${isRequestBodyOptional ? " | undefined" : ""});\n`;
1728
1728
  }
1729
1729
  return newPropDefinition + resolveSchemaPropertiesToFormData({
1730
1730
  schema: combinedSchema,
@@ -1818,8 +1818,8 @@ function resolveSchemaPropertiesToFormData({ schema, variableName, propName, con
1818
1818
  if (!hasNonPrimitiveChild) formDataValue = `${valueKey}.forEach((value, index${depth > 0 ? depth : ""}) => ${variableName}.append(\`${keyPrefix}${key}[\${index${depth > 0 ? depth : ""}}]\`, ${valueStr}));\n`;
1819
1819
  } else formDataValue = `${valueKey}.forEach(value => ${variableName}.append(\`${keyPrefix}${key}${context.output.override.formData.arrayHandling === FormDataArrayHandling.SERIALIZE_WITH_BRACKETS ? "[]" : ""}\`, ${valueStr}));\n`;
1820
1820
  } else if ((() => {
1821
- const propType$1 = getSchemaType(property);
1822
- return propType$1 === "number" || Array.isArray(propType$1) && propType$1.includes("number") || propType$1 === "integer" || Array.isArray(propType$1) && propType$1.includes("integer") || propType$1 === "boolean" || Array.isArray(propType$1) && propType$1.includes("boolean");
1821
+ const propType = getSchemaType(property);
1822
+ return propType === "number" || Array.isArray(propType) && propType.includes("number") || propType === "integer" || Array.isArray(propType) && propType.includes("integer") || propType === "boolean" || Array.isArray(propType) && propType.includes("boolean");
1823
1823
  })()) formDataValue = `${variableName}.append(\`${keyPrefix}${key}\`, ${nonOptionalValueKey}.toString())\n`;
1824
1824
  else formDataValue = `${variableName}.append(\`${keyPrefix}${key}\`, ${nonOptionalValueKey});\n`;
1825
1825
  let existSubSchemaNullable = false;
@@ -1864,8 +1864,8 @@ function resolveSchemaPropertiesToFormData({ schema, variableName, propName, con
1864
1864
  //#region src/getters/body.ts
1865
1865
  function getBody({ requestBody, operationName, context, contentType }) {
1866
1866
  const filteredBodyTypes = filterByContentType(getResReqTypes([[context.output.override.components.requestBodies.suffix, requestBody]], operationName, context), contentType);
1867
- const imports = filteredBodyTypes.flatMap(({ imports: imports$1 }) => imports$1);
1868
- const schemas = filteredBodyTypes.flatMap(({ schemas: schemas$1 }) => schemas$1);
1867
+ const imports = filteredBodyTypes.flatMap(({ imports }) => imports);
1868
+ const schemas = filteredBodyTypes.flatMap(({ schemas }) => schemas);
1869
1869
  const definition = filteredBodyTypes.map(({ value }) => value).join(" | ");
1870
1870
  const nonReadonlyDefinition = filteredBodyTypes.some((x) => x.hasReadonlyProps) && definition ? `NonReadonly<${definition}>` : definition;
1871
1871
  let implementation = generalJSTypesWithArray.includes(definition.toLowerCase()) || filteredBodyTypes.length > 1 ? camel(operationName) + context.output.override.components.requestBodies.suffix : camel(definition);
@@ -1963,16 +1963,16 @@ function getPropertyNamesRecordType(item, valueType) {
1963
1963
  */
1964
1964
  function getObject({ item, name, context, nullable, formDataContext }) {
1965
1965
  if (isReference(item)) {
1966
- const { name: name$1 } = getRefInfo(item.$ref, context);
1966
+ const { name } = getRefInfo(item.$ref, context);
1967
1967
  return {
1968
- value: name$1 + nullable,
1969
- imports: [{ name: name$1 }],
1968
+ value: name + nullable,
1969
+ imports: [{ name }],
1970
1970
  schemas: [],
1971
1971
  isEnum: false,
1972
1972
  type: "object",
1973
1973
  isRef: true,
1974
1974
  hasReadonlyProps: item.readOnly ?? false,
1975
- dependencies: [name$1],
1975
+ dependencies: [name],
1976
1976
  example: item.example,
1977
1977
  examples: resolveExampleRefs(item.examples, context)
1978
1978
  };
@@ -2001,8 +2001,8 @@ function getObject({ item, name, context, nullable, formDataContext }) {
2001
2001
  }
2002
2002
  const itemProperties = item.properties;
2003
2003
  if (itemProperties && Object.entries(itemProperties).length > 0) {
2004
- const entries$1 = Object.entries(itemProperties);
2005
- if (context.output.propertySortOrder === PropertySortOrder.ALPHABETICAL) entries$1.sort((a, b) => {
2004
+ const entries = Object.entries(itemProperties);
2005
+ if (context.output.propertySortOrder === PropertySortOrder.ALPHABETICAL) entries.sort((a, b) => {
2006
2006
  return a[0].localeCompare(b[0]);
2007
2007
  });
2008
2008
  const acc = {
@@ -2020,7 +2020,7 @@ function getObject({ item, name, context, nullable, formDataContext }) {
2020
2020
  examples: resolveExampleRefs(item.examples, context)
2021
2021
  };
2022
2022
  const itemRequired = item.required;
2023
- for (const [index, [key, schema]] of entries$1.entries()) {
2023
+ for (const [index, [key, schema]] of entries.entries()) {
2024
2024
  const isRequired = (Array.isArray(itemRequired) ? itemRequired : []).includes(key);
2025
2025
  let propName = "";
2026
2026
  if (name) {
@@ -2043,12 +2043,12 @@ function getObject({ item, name, context, nullable, formDataContext }) {
2043
2043
  if (!index) acc.value += "{";
2044
2044
  const doc = jsDoc(schema, true, context);
2045
2045
  if (isReadOnly ?? false) acc.hasReadonlyProps = true;
2046
- const constValue$1 = "const" in schema ? schema.const : void 0;
2047
- const hasConst = constValue$1 !== void 0;
2046
+ const constValue = "const" in schema ? schema.const : void 0;
2047
+ const hasConst = constValue !== void 0;
2048
2048
  let constLiteral;
2049
2049
  if (!hasConst) constLiteral = void 0;
2050
- else if (isString(constValue$1)) constLiteral = `'${escape(constValue$1)}'`;
2051
- else constLiteral = JSON.stringify(constValue$1);
2050
+ else if (isString(constValue)) constLiteral = `'${escape(constValue)}'`;
2051
+ else constLiteral = JSON.stringify(constValue);
2052
2052
  const needsValueImport = hasConst && (resolvedValue.isEnum || resolvedValue.type === "enum");
2053
2053
  const aliasedImports = needsValueImport ? resolvedValue.imports.map((imp) => ({
2054
2054
  ...imp,
@@ -2069,34 +2069,34 @@ function getObject({ item, name, context, nullable, formDataContext }) {
2069
2069
  acc.value += `\n ${doc ? `${doc} ` : ""}${isReadOnly && !context.output.override.suppressReadonlyModifier ? "readonly " : ""}${getKey(key)}${isRequired ? "" : "?"}: ${finalPropValue};`;
2070
2070
  acc.schemas.push(...resolvedValue.schemas);
2071
2071
  acc.dependencies.push(...resolvedValue.dependencies);
2072
- if (entries$1.length - 1 === index) {
2072
+ if (entries.length - 1 === index) {
2073
2073
  const additionalProps = item.additionalProperties;
2074
2074
  if (additionalProps) if (isBoolean(additionalProps)) {
2075
- const recordType$1 = getPropertyNamesRecordType(item, "unknown");
2076
- if (recordType$1) {
2075
+ const recordType = getPropertyNamesRecordType(item, "unknown");
2076
+ if (recordType) {
2077
2077
  acc.value += "\n}";
2078
- acc.value += ` & ${recordType$1}`;
2078
+ acc.value += ` & ${recordType}`;
2079
2079
  acc.useTypeAlias = true;
2080
2080
  } else {
2081
- const keyType$1 = getIndexSignatureKey(item);
2082
- acc.value += `\n [key: ${keyType$1}]: unknown;\n }`;
2081
+ const keyType = getIndexSignatureKey(item);
2082
+ acc.value += `\n [key: ${keyType}]: unknown;\n }`;
2083
2083
  }
2084
2084
  } else {
2085
- const resolvedValue$1 = resolveValue({
2085
+ const resolvedValue = resolveValue({
2086
2086
  schema: additionalProps,
2087
2087
  name,
2088
2088
  context
2089
2089
  });
2090
- const recordType$1 = getPropertyNamesRecordType(item, resolvedValue$1.value);
2091
- if (recordType$1) {
2090
+ const recordType = getPropertyNamesRecordType(item, resolvedValue.value);
2091
+ if (recordType) {
2092
2092
  acc.value += "\n}";
2093
- acc.value += ` & ${recordType$1}`;
2093
+ acc.value += ` & ${recordType}`;
2094
2094
  acc.useTypeAlias = true;
2095
2095
  } else {
2096
- const keyType$1 = getIndexSignatureKey(item);
2097
- acc.value += `\n [key: ${keyType$1}]: ${resolvedValue$1.value};\n}`;
2096
+ const keyType = getIndexSignatureKey(item);
2097
+ acc.value += `\n [key: ${keyType}]: ${resolvedValue.value};\n}`;
2098
2098
  }
2099
- acc.dependencies.push(...resolvedValue$1.dependencies);
2099
+ acc.dependencies.push(...resolvedValue.dependencies);
2100
2100
  }
2101
2101
  else acc.value += "\n}";
2102
2102
  acc.value += nullable;
@@ -2108,9 +2108,9 @@ function getObject({ item, name, context, nullable, formDataContext }) {
2108
2108
  const readOnlyFlag = item.readOnly;
2109
2109
  if (outerAdditionalProps) {
2110
2110
  if (isBoolean(outerAdditionalProps)) {
2111
- const recordType$2 = getPropertyNamesRecordType(item, "unknown");
2112
- if (recordType$2) return {
2113
- value: recordType$2 + nullable,
2111
+ const recordType = getPropertyNamesRecordType(item, "unknown");
2112
+ if (recordType) return {
2113
+ value: recordType + nullable,
2114
2114
  imports: [],
2115
2115
  schemas: [],
2116
2116
  isEnum: false,
@@ -2137,9 +2137,9 @@ function getObject({ item, name, context, nullable, formDataContext }) {
2137
2137
  name,
2138
2138
  context
2139
2139
  });
2140
- const recordType$1 = getPropertyNamesRecordType(item, resolvedValue.value);
2141
- if (recordType$1) return {
2142
- value: recordType$1 + nullable,
2140
+ const recordType = getPropertyNamesRecordType(item, resolvedValue.value);
2141
+ if (recordType) return {
2142
+ value: recordType + nullable,
2143
2143
  imports: resolvedValue.imports,
2144
2144
  schemas: resolvedValue.schemas,
2145
2145
  isEnum: false,
@@ -2215,6 +2215,8 @@ function getScalar({ item, name, context, formDataContext }) {
2215
2215
  const schemaConst = item.const;
2216
2216
  const schemaFormat = item.format;
2217
2217
  const schemaNullable = item.nullable;
2218
+ const schemaContentMediaType = item.contentMediaType;
2219
+ const schemaContentEncoding = item.contentEncoding;
2218
2220
  const nullable = isArray(schemaType) && schemaType.includes("null") || schemaNullable === true ? " | null" : "";
2219
2221
  const enumItems = schemaEnum?.filter((enumItem) => enumItem !== null);
2220
2222
  let itemType = schemaType;
@@ -2290,7 +2292,7 @@ function getScalar({ item, name, context, formDataContext }) {
2290
2292
  else if (formDataContext?.atPart) {
2291
2293
  const fileType = getFormDataFieldFileType(item, formDataContext.partContentType);
2292
2294
  if (fileType) value = fileType === "binary" ? "Blob" : "Blob | string";
2293
- }
2295
+ } else if (schemaContentMediaType === "application/octet-stream" && !schemaContentEncoding) value = "Blob";
2294
2296
  if (context.output.override.useDates && (schemaFormat === "date" || schemaFormat === "date-time")) value = "Date";
2295
2297
  value += nullable;
2296
2298
  if (schemaConst) value = `'${schemaConst}'`;
@@ -2380,7 +2382,7 @@ function normalizeAllOfSchema(schema) {
2380
2382
  didMerge = true;
2381
2383
  if (subSchema.properties) Object.assign(mergedProperties, subSchema.properties);
2382
2384
  const subRequired = subSchema.required;
2383
- if (subRequired) for (const prop$1 of subRequired) mergedRequired.add(prop$1);
2385
+ if (subRequired) for (const prop of subRequired) mergedRequired.add(prop);
2384
2386
  continue;
2385
2387
  }
2386
2388
  remainingAllOf.push(subSchema);
@@ -2393,9 +2395,9 @@ function normalizeAllOfSchema(schema) {
2393
2395
  ...remainingAllOf.length > 0 && { allOf: remainingAllOf }
2394
2396
  };
2395
2397
  }
2396
- function combineValues({ resolvedData, resolvedValue, separator: separator$1, context, parentSchema }) {
2398
+ function combineValues({ resolvedData, resolvedValue, separator, context, parentSchema }) {
2397
2399
  if (resolvedData.isEnum.every(Boolean)) return `${resolvedData.values.join(` | `)}${resolvedValue ? ` | ${resolvedValue.value}` : ""}`;
2398
- if (separator$1 === "allOf") {
2400
+ if (separator === "allOf") {
2399
2401
  let resolvedDataValue = resolvedData.values.map((v) => v.includes(" | ") ? `(${v})` : v).join(` & `);
2400
2402
  if (resolvedData.originalSchema.length > 0 && resolvedValue) {
2401
2403
  const discriminatedPropertySchemas = resolvedData.originalSchema.filter((s) => {
@@ -2406,14 +2408,14 @@ function combineValues({ resolvedData, resolvedValue, separator: separator$1, co
2406
2408
  }
2407
2409
  const resolvedValueStr = resolvedValue?.value.includes(" | ") ? `(${resolvedValue.value})` : resolvedValue?.value;
2408
2410
  const joined = `${resolvedDataValue}${resolvedValue ? ` & ${resolvedValueStr}` : ""}`;
2409
- const overrideRequiredProperties = resolvedData.requiredProperties.filter((prop$1) => !resolvedData.originalSchema.some((schema) => {
2411
+ const overrideRequiredProperties = resolvedData.requiredProperties.filter((prop) => !resolvedData.originalSchema.some((schema) => {
2410
2412
  const props = schema?.properties;
2411
2413
  const req = schema?.required;
2412
- return props?.[prop$1] && req?.includes(prop$1);
2414
+ return props?.[prop] && req?.includes(prop);
2413
2415
  }) && !(() => {
2414
2416
  const parentProps = parentSchema?.properties;
2415
2417
  const parentReq = parentSchema?.required;
2416
- return !!(parentProps?.[prop$1] && parentReq?.includes(prop$1));
2418
+ return !!(parentProps?.[prop] && parentReq?.includes(prop));
2417
2419
  })());
2418
2420
  if (overrideRequiredProperties.length > 0) return `${joined} & Required<Pick<${joined}, '${overrideRequiredProperties.join("' | '")}'>>`;
2419
2421
  return joined;
@@ -2435,9 +2437,9 @@ function combineValues({ resolvedData, resolvedValue, separator: separator$1, co
2435
2437
  if (resolvedValue) return `(${values.join(` & ${resolvedValue.value}) | (`)} & ${resolvedValue.value})`;
2436
2438
  return values.join(" | ");
2437
2439
  }
2438
- function combineSchemas({ name, schema, separator: separator$1, context, nullable, formDataContext }) {
2439
- const normalizedSchema = separator$1 === "allOf" && !context.output.override.aliasCombinedTypes && !schema.oneOf && !schema.anyOf ? normalizeAllOfSchema(schema) : schema;
2440
- const items = normalizedSchema[separator$1] ?? [];
2440
+ function combineSchemas({ name, schema, separator, context, nullable, formDataContext }) {
2441
+ const normalizedSchema = separator === "allOf" && !context.output.override.aliasCombinedTypes && !schema.oneOf && !schema.anyOf ? normalizeAllOfSchema(schema) : schema;
2442
+ const items = normalizedSchema[separator] ?? [];
2441
2443
  const resolvedData = {
2442
2444
  values: [],
2443
2445
  imports: [],
@@ -2451,16 +2453,16 @@ function combineSchemas({ name, schema, separator: separator$1, context, nullabl
2451
2453
  hasReadonlyProps: false,
2452
2454
  example: schema.example,
2453
2455
  examples: resolveExampleRefs(schema.examples, context),
2454
- requiredProperties: separator$1 === "allOf" ? schema.required ?? [] : []
2456
+ requiredProperties: separator === "allOf" ? schema.required ?? [] : []
2455
2457
  };
2456
2458
  for (const subSchema of items) {
2457
2459
  let propName;
2458
2460
  if (context.output.override.aliasCombinedTypes) {
2459
- propName = name ? name + pascal(separator$1) : void 0;
2461
+ propName = name ? name + pascal(separator) : void 0;
2460
2462
  if (propName && resolvedData.schemas.length > 0) propName = propName + pascal(getNumberWord(resolvedData.schemas.length + 1));
2461
2463
  }
2462
- if (separator$1 === "allOf" && isSchema(subSchema) && subSchema.required) resolvedData.requiredProperties.push(...subSchema.required);
2463
- const resolvedValue$1 = resolveObject({
2464
+ if (separator === "allOf" && isSchema(subSchema) && subSchema.required) resolvedData.requiredProperties.push(...subSchema.required);
2465
+ const resolvedValue = resolveObject({
2464
2466
  schema: subSchema,
2465
2467
  propName,
2466
2468
  combined: true,
@@ -2470,24 +2472,24 @@ function combineSchemas({ name, schema, separator: separator$1, context, nullabl
2470
2472
  const aliasedImports = getAliasedImports({
2471
2473
  context,
2472
2474
  name,
2473
- resolvedValue: resolvedValue$1
2475
+ resolvedValue
2474
2476
  });
2475
2477
  const value = getImportAliasForRefOrValue({
2476
2478
  context,
2477
- resolvedValue: resolvedValue$1,
2479
+ resolvedValue,
2478
2480
  imports: aliasedImports
2479
2481
  });
2480
2482
  resolvedData.values.push(value);
2481
2483
  resolvedData.imports.push(...aliasedImports);
2482
- resolvedData.schemas.push(...resolvedValue$1.schemas);
2483
- resolvedData.dependencies.push(...resolvedValue$1.dependencies);
2484
- resolvedData.isEnum.push(resolvedValue$1.isEnum);
2485
- resolvedData.types.push(resolvedValue$1.type);
2486
- resolvedData.isRef.push(resolvedValue$1.isRef);
2487
- resolvedData.originalSchema.push(resolvedValue$1.originalSchema);
2488
- if (resolvedValue$1.hasReadonlyProps) resolvedData.hasReadonlyProps = true;
2489
- const originalProps = resolvedValue$1.originalSchema.properties;
2490
- if (resolvedValue$1.type === "object" && originalProps) resolvedData.allProperties.push(...Object.keys(originalProps));
2484
+ resolvedData.schemas.push(...resolvedValue.schemas);
2485
+ resolvedData.dependencies.push(...resolvedValue.dependencies);
2486
+ resolvedData.isEnum.push(resolvedValue.isEnum);
2487
+ resolvedData.types.push(resolvedValue.type);
2488
+ resolvedData.isRef.push(resolvedValue.isRef);
2489
+ resolvedData.originalSchema.push(resolvedValue.originalSchema);
2490
+ if (resolvedValue.hasReadonlyProps) resolvedData.hasReadonlyProps = true;
2491
+ const originalProps = resolvedValue.originalSchema.properties;
2492
+ if (resolvedValue.type === "object" && originalProps) resolvedData.allProperties.push(...Object.keys(originalProps));
2491
2493
  }
2492
2494
  if (resolvedData.isEnum.every(Boolean) && name && items.length > 1 && context.output.override.enumGenerationType !== EnumGeneration.UNION) {
2493
2495
  const { value: combinedEnumValue, valueImports, hasNull } = getCombinedEnumValue(resolvedData.values.map((value, index) => ({
@@ -2520,12 +2522,12 @@ function combineSchemas({ name, schema, separator: separator$1, context, nullabl
2520
2522
  }
2521
2523
  let resolvedValue;
2522
2524
  if (normalizedSchema.properties) resolvedValue = getScalar({
2523
- item: Object.fromEntries(Object.entries(normalizedSchema).filter(([key]) => key !== separator$1)),
2525
+ item: Object.fromEntries(Object.entries(normalizedSchema).filter(([key]) => key !== separator)),
2524
2526
  name,
2525
2527
  context,
2526
2528
  formDataContext
2527
2529
  });
2528
- else if (separator$1 === "allOf" && (schema.oneOf || schema.anyOf)) {
2530
+ else if (separator === "allOf" && (schema.oneOf || schema.anyOf)) {
2529
2531
  const siblingCombiner = schema.oneOf ? "oneOf" : "anyOf";
2530
2532
  const siblingSchemas = schema[siblingCombiner];
2531
2533
  resolvedValue = combineSchemas({
@@ -2539,7 +2541,7 @@ function combineSchemas({ name, schema, separator: separator$1, context, nullabl
2539
2541
  return {
2540
2542
  value: dedupeUnionType(combineValues({
2541
2543
  resolvedData,
2542
- separator: separator$1,
2544
+ separator,
2543
2545
  resolvedValue,
2544
2546
  context,
2545
2547
  parentSchema: normalizedSchema
@@ -2644,11 +2646,11 @@ function getParameters({ parameters, context }) {
2644
2646
  * ```
2645
2647
  * @param path
2646
2648
  */
2647
- function getParamsInPath(path$2) {
2649
+ function getParamsInPath(path) {
2648
2650
  let n;
2649
2651
  const output = [];
2650
2652
  const templatePathRegex = /\{(.*?)\}/g;
2651
- while ((n = templatePathRegex.exec(path$2)) !== null) output.push(n[1]);
2653
+ while ((n = templatePathRegex.exec(path)) !== null) output.push(n[1]);
2652
2654
  return output;
2653
2655
  }
2654
2656
  function getParams({ route, pathParams = [], operationId, context, output }) {
@@ -2831,12 +2833,12 @@ function getQueryParamsTypes(queryParams, operationName, context) {
2831
2833
  function getQueryParams({ queryParams, operationName, context, suffix = "params" }) {
2832
2834
  if (queryParams.length === 0) return;
2833
2835
  const types = getQueryParamsTypes(queryParams, operationName, context);
2834
- const imports = types.flatMap(({ imports: imports$1 }) => imports$1);
2835
- const schemas = types.flatMap(({ schemas: schemas$1 }) => schemas$1);
2836
+ const imports = types.flatMap(({ imports }) => imports);
2837
+ const schemas = types.flatMap(({ schemas }) => schemas);
2836
2838
  const name = `${pascal(operationName)}${pascal(suffix)}`;
2837
2839
  const type = types.map(({ definition }) => definition).join("\n");
2838
2840
  const allOptional = queryParams.every(({ parameter }) => !parameter.required);
2839
- const requiredNullableKeys = types.filter(({ required, originalSchema }) => required && isSchemaNullable(originalSchema)).map(({ name: name$1 }) => name$1);
2841
+ const requiredNullableKeys = types.filter(({ required, originalSchema }) => required && isSchemaNullable(originalSchema)).map(({ name }) => name);
2840
2842
  return {
2841
2843
  schema: {
2842
2844
  name,
@@ -2853,9 +2855,9 @@ function getQueryParams({ queryParams, operationName, context, suffix = "params"
2853
2855
  //#region src/getters/response.ts
2854
2856
  function getResponse({ responses, operationName, context, contentType }) {
2855
2857
  const filteredTypes = filterByContentType(getResReqTypes(Object.entries(responses), operationName, context, "void", (type) => `${type.key}-${type.value}-${type.contentType}`), contentType);
2856
- const imports = filteredTypes.flatMap(({ imports: imports$1 }) => imports$1);
2857
- const schemas = filteredTypes.flatMap(({ schemas: schemas$1 }) => schemas$1);
2858
- const contentTypes = [...new Set(filteredTypes.map(({ contentType: contentType$1 }) => contentType$1))];
2858
+ const imports = filteredTypes.flatMap(({ imports }) => imports);
2859
+ const schemas = filteredTypes.flatMap(({ schemas }) => schemas);
2860
+ const contentTypes = [...new Set(filteredTypes.map(({ contentType }) => contentType))];
2859
2861
  const groupedByStatus = {
2860
2862
  success: [],
2861
2863
  errors: []
@@ -2882,10 +2884,10 @@ function getResponse({ responses, operationName, context, contentType }) {
2882
2884
  //#endregion
2883
2885
  //#region src/getters/route.ts
2884
2886
  const TEMPLATE_TAG_IN_PATH_REGEX = /\/([\w]+)(?:\$\{)/g;
2885
- const hasParam = (path$2) => /[^{]*{[\w*_-]*}.*/.test(path$2);
2886
- const getRoutePath = (path$2) => {
2887
- const matches = /([^{]*){?([\w*_-]*)}?(.*)/.exec(path$2);
2888
- if (!matches?.length) return path$2;
2887
+ const hasParam = (path) => /[^{]*{[\w*_-]*}.*/.test(path);
2888
+ const getRoutePath = (path) => {
2889
+ const matches = /([^{]*){?([\w*_-]*)}?(.*)/.exec(path);
2890
+ if (!matches?.length) return path;
2889
2891
  const prev = matches[1];
2890
2892
  const param = sanitize(camel(matches[2]), {
2891
2893
  es5keyword: true,
@@ -2894,14 +2896,14 @@ const getRoutePath = (path$2) => {
2894
2896
  dot: true
2895
2897
  });
2896
2898
  const next = hasParam(matches[3]) ? getRoutePath(matches[3]) : matches[3];
2897
- return hasParam(path$2) ? `${prev}\${${param}}${next}` : `${prev}${param}${next}`;
2899
+ return hasParam(path) ? `${prev}\${${param}}${next}` : `${prev}${param}${next}`;
2898
2900
  };
2899
2901
  function getRoute(route) {
2900
2902
  const splittedRoute = route.split("/");
2901
2903
  let result = "";
2902
- for (const [i, path$2] of splittedRoute.entries()) {
2903
- if (!path$2 && !i) continue;
2904
- result += path$2.includes("{") ? `/${getRoutePath(path$2)}` : `/${path$2}`;
2904
+ for (const [i, path] of splittedRoute.entries()) {
2905
+ if (!path && !i) continue;
2906
+ result += path.includes("{") ? `/${getRoutePath(path)}` : `/${path}`;
2905
2907
  }
2906
2908
  return result;
2907
2909
  }
@@ -2946,8 +2948,8 @@ function generateComponentDefinition(responses = {}, context, suffix) {
2946
2948
  const generatorSchemas = [];
2947
2949
  for (const [name, response] of entries(responses)) {
2948
2950
  const allResponseTypes = getResReqTypes([[suffix, response]], name, context, "void");
2949
- const imports = allResponseTypes.flatMap(({ imports: imports$1 }) => imports$1);
2950
- const schemas = allResponseTypes.flatMap(({ schemas: schemas$1 }) => schemas$1);
2951
+ const imports = allResponseTypes.flatMap(({ imports }) => imports);
2952
+ const schemas = allResponseTypes.flatMap(({ schemas }) => schemas);
2951
2953
  const type = allResponseTypes.map(({ value }) => value).join(" | ");
2952
2954
  const modelName = sanitize(`${pascal(name)}${suffix}`, {
2953
2955
  underscore: "_",
@@ -2977,7 +2979,7 @@ function generateImports({ imports, namingConvention = NamingConvention.CAMEL_CA
2977
2979
  })), (imp) => !imp.default && !imp.namespaceImport && !imp.syntheticDefaultImport && !imp.values && !imp.isConstant ? `aggregate|${imp.importPath}` : `single|${imp.importPath}|${imp.name}|${imp.alias ?? ""}|${String(imp.default)}|${String(imp.namespaceImport)}|${String(imp.syntheticDefaultImport)}|${String(imp.values)}|${String(imp.isConstant)}`);
2978
2980
  return Object.entries(grouped).toSorted(([a], [b]) => a.localeCompare(b)).map(([, group]) => {
2979
2981
  const sample = group[0];
2980
- if (!sample.default && !sample.namespaceImport && !sample.syntheticDefaultImport && !sample.values && !sample.isConstant) return `import type { ${[...new Set(group.map(({ name: name$1, alias: alias$1 }) => `${name$1}${alias$1 ? ` as ${alias$1}` : ""}`))].toSorted().join(", ")} } from '${sample.importPath}';`;
2982
+ if (!sample.default && !sample.namespaceImport && !sample.syntheticDefaultImport && !sample.values && !sample.isConstant) return `import type { ${[...new Set(group.map(({ name, alias }) => `${name}${alias ? ` as ${alias}` : ""}`))].toSorted().join(", ")} } from '${sample.importPath}';`;
2981
2983
  const { name, values, alias, isConstant, importPath } = sample;
2982
2984
  return `import ${!values && !isConstant ? "type " : ""}{ ${name}${alias ? ` as ${alias}` : ""} } from '${importPath}';`;
2983
2985
  }).join("\n");
@@ -2985,9 +2987,9 @@ function generateImports({ imports, namingConvention = NamingConvention.CAMEL_CA
2985
2987
  function generateMutatorImports({ mutators, implementation, oneMore }) {
2986
2988
  let imports = "";
2987
2989
  for (const mutator of uniqueWith(mutators, (a, b) => a.name === b.name && a.default === b.default)) {
2988
- const path$2 = `${oneMore ? "../" : ""}${mutator.path}`;
2990
+ const path = `${oneMore ? "../" : ""}${mutator.path}`;
2989
2991
  const importDefault = mutator.default ? mutator.name : `{ ${mutator.name} }`;
2990
- imports += `import ${importDefault} from '${path$2}';`;
2992
+ imports += `import ${importDefault} from '${path}';`;
2991
2993
  imports += "\n";
2992
2994
  if (implementation && (mutator.hasErrorType || mutator.bodyTypeName)) {
2993
2995
  let errorImportName = "";
@@ -2997,7 +2999,7 @@ function generateMutatorImports({ mutators, implementation, oneMore }) {
2997
2999
  const targetBodyImportName = mutator.default ? `BodyType as ${mutator.bodyTypeName}` : mutator.bodyTypeName;
2998
3000
  if (mutator.bodyTypeName && implementation.includes(mutator.bodyTypeName) && !imports.includes(` ${targetBodyImportName} }`)) bodyImportName = targetBodyImportName ?? "";
2999
3001
  if (bodyImportName || errorImportName) {
3000
- imports += `import type { ${errorImportName}${errorImportName && bodyImportName ? " , " : ""}${bodyImportName} } from '${path$2}';`;
3002
+ imports += `import type { ${errorImportName}${errorImportName && bodyImportName ? " , " : ""}${bodyImportName} } from '${path}';`;
3001
3003
  imports += "\n";
3002
3004
  }
3003
3005
  }
@@ -3085,7 +3087,7 @@ function generateVerbImports({ response, body, queryParams, props, headers, para
3085
3087
  return [
3086
3088
  ...response.imports,
3087
3089
  ...body.imports,
3088
- ...props.flatMap((prop$1) => prop$1.type === GetterPropType.NAMED_PATH_PARAMS ? [{ name: prop$1.schema.name }] : []),
3090
+ ...props.flatMap((prop) => prop.type === GetterPropType.NAMED_PATH_PARAMS ? [{ name: prop.schema.name }] : []),
3089
3091
  ...queryParams ? [{ name: queryParams.schema.name }] : [],
3090
3092
  ...headers ? [{ name: headers.schema.name }] : [],
3091
3093
  ...params.flatMap(({ imports }) => imports)
@@ -3226,7 +3228,7 @@ async function generateMutator({ output, mutator, name, workspace, tsconfig }) {
3226
3228
  const importName = mutator.name ?? `${name}Mutator`;
3227
3229
  const importPath = mutator.path;
3228
3230
  const mutatorInfoName = isDefault ? "default" : mutator.name;
3229
- if (mutatorInfoName === void 0) throw new Error(chalk.red(`Mutator ${importPath} must have a named or default export.`));
3231
+ if (mutatorInfoName === void 0) throw new Error(styleText("red", `Mutator ${importPath} must have a named or default export.`));
3230
3232
  let rawFile = await fs$1.readFile(importPath, "utf8");
3231
3233
  rawFile = removeComments(rawFile);
3232
3234
  const hasErrorType = rawFile.includes("export type ErrorType") || rawFile.includes("export interface ErrorType");
@@ -3240,7 +3242,7 @@ async function generateMutator({ output, mutator, name, workspace, tsconfig }) {
3240
3242
  external: mutator.external,
3241
3243
  tsconfig
3242
3244
  });
3243
- if (!mutatorInfo) throw new Error(chalk.red(`Your mutator file doesn't have the ${mutatorInfoName} exported function`));
3245
+ if (!mutatorInfo) throw new Error(styleText("red", `Your mutator file doesn't have the ${mutatorInfoName} exported function`));
3244
3246
  const importStatementPath = getImport(output, mutator);
3245
3247
  const isHook = mutator.name ? mutator.name.startsWith("use") && !mutatorInfo.numberOfParams : !mutatorInfo.numberOfParams;
3246
3248
  return {
@@ -3557,7 +3559,7 @@ function generateSchemasDefinition(schemas = {}, context, suffix, filters) {
3557
3559
  const schemasFilters = filters.schemas;
3558
3560
  const mode = filters.mode ?? "include";
3559
3561
  generateSchemas = generateSchemas.filter(([schemaName]) => {
3560
- const isMatch = schemasFilters.some((filter$1) => isString(filter$1) ? filter$1 === schemaName : filter$1.test(schemaName));
3562
+ const isMatch = schemasFilters.some((filter) => isString(filter) ? filter === schemaName : filter.test(schemaName));
3561
3563
  return mode === "include" ? isMatch : !isMatch;
3562
3564
  });
3563
3565
  }
@@ -3643,23 +3645,23 @@ function generateSchemaDefinitions(schemaName, schema, context, suffix) {
3643
3645
  else if (sanitizedSchemaName === resolvedValue.value && resolvedValue.isRef) {
3644
3646
  const { schema: referredSchema } = resolveRef(schema, context);
3645
3647
  if (!shouldCreateInterface(referredSchema)) {
3646
- const imp = resolvedValue.imports.find((imp$1) => imp$1.name === sanitizedSchemaName);
3648
+ const imp = resolvedValue.imports.find((imp) => imp.name === sanitizedSchemaName);
3647
3649
  if (imp) {
3648
3650
  const alias = `${resolvedValue.value}Bis`;
3649
3651
  output += `export type ${sanitizedSchemaName} = ${alias};\n`;
3650
- imports = imports.map((imp$1) => imp$1.name === sanitizedSchemaName ? {
3651
- ...imp$1,
3652
+ imports = imports.map((imp) => imp.name === sanitizedSchemaName ? {
3653
+ ...imp,
3652
3654
  alias
3653
- } : imp$1);
3655
+ } : imp);
3654
3656
  resolvedValue.dependencies = [imp.name];
3655
3657
  } else output += `export type ${sanitizedSchemaName} = ${resolvedValue.value};\n`;
3656
3658
  }
3657
3659
  } else {
3658
- resolvedValue.schemas = resolvedValue.schemas.filter((schema$1) => {
3659
- if (schema$1.name !== sanitizedSchemaName) return true;
3660
- output += `${schema$1.model}\n`;
3661
- imports = [...imports, ...schema$1.imports];
3662
- resolvedValue.dependencies.push(...schema$1.dependencies ?? []);
3660
+ resolvedValue.schemas = resolvedValue.schemas.filter((schema) => {
3661
+ if (schema.name !== sanitizedSchemaName) return true;
3662
+ output += `${schema.model}\n`;
3663
+ imports = [...imports, ...schema.imports];
3664
+ resolvedValue.dependencies.push(...schema.dependencies ?? []);
3663
3665
  return false;
3664
3666
  });
3665
3667
  output += `export type ${sanitizedSchemaName} = ${resolvedValue.value};\n`;
@@ -3946,8 +3948,8 @@ function mergeSchemaGroup(schemas) {
3946
3948
  function resolveImportKey(schemaPath, importPath, fileExtension) {
3947
3949
  return join(schemaPath, `${importPath}${fileExtension}`).toLowerCase().replaceAll("\\", "/");
3948
3950
  }
3949
- function removeFileExtension(path$2, fileExtension) {
3950
- return path$2.endsWith(fileExtension) ? path$2.slice(0, path$2.length - fileExtension.length) : path$2;
3951
+ function removeFileExtension(path, fileExtension) {
3952
+ return path.endsWith(fileExtension) ? path.slice(0, path.length - fileExtension.length) : path;
3951
3953
  }
3952
3954
  function getSchema({ schema: { imports, model }, target, header, namingConvention = NamingConvention.CAMEL_CASE }) {
3953
3955
  let file = header;
@@ -3960,8 +3962,8 @@ function getSchema({ schema: { imports, model }, target, header, namingConventio
3960
3962
  file += model;
3961
3963
  return file;
3962
3964
  }
3963
- function getPath(path$2, name, fileExtension) {
3964
- return join(path$2, `/${name}${fileExtension}`);
3965
+ function getPath(path, name, fileExtension) {
3966
+ return join(path, `/${name}${fileExtension}`);
3965
3967
  }
3966
3968
  function writeModelInline(acc, model) {
3967
3969
  return acc + `${model}\n`;
@@ -3971,10 +3973,10 @@ function writeModelsInline(array) {
3971
3973
  for (const { model } of array) acc = writeModelInline(acc, model);
3972
3974
  return acc;
3973
3975
  }
3974
- async function writeSchema({ path: path$2, schema, target, namingConvention, fileExtension, header }) {
3976
+ async function writeSchema({ path, schema, target, namingConvention, fileExtension, header }) {
3975
3977
  const name = conventionName(schema.name, namingConvention);
3976
3978
  try {
3977
- await fs$1.outputFile(getPath(path$2, name, fileExtension), getSchema({
3979
+ await fs$1.outputFile(getPath(path, name, fileExtension), getSchema({
3978
3980
  schema,
3979
3981
  target,
3980
3982
  header,
@@ -4178,13 +4180,13 @@ interface TypedResponse<T> extends Response {
4178
4180
  //#region src/writers/single-mode.ts
4179
4181
  async function writeSingleMode({ builder, output, projectName, header, needSchema }) {
4180
4182
  try {
4181
- const { path: path$2, dirname: dirname$1 } = getFileInfo(output.target, {
4183
+ const { path, dirname } = getFileInfo(output.target, {
4182
4184
  backupFilename: conventionName(builder.info.title, output.namingConvention),
4183
4185
  extension: output.fileExtension
4184
4186
  });
4185
4187
  const { imports, importsMock, implementation, implementationMock, mutators, clientMutators, formData, formUrlEncoded, paramsSerializer, fetchReviver } = generateTarget(builder, output);
4186
4188
  let data = header;
4187
- const schemasPath = output.schemas ? relativeSafe(dirname$1, getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname) : void 0;
4189
+ const schemasPath = output.schemas ? relativeSafe(dirname, getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname) : void 0;
4188
4190
  const isAllowSyntheticDefaultImports = isSyntheticDefaultImportsAllow(output.tsconfig);
4189
4191
  const importsForBuilder = schemasPath ? generateImportsForBuilder(output, imports.filter((imp) => !importsMock.some((impMock) => imp.name === impMock.name)), schemasPath) : [];
4190
4192
  data += builder.imports({
@@ -4234,8 +4236,8 @@ async function writeSingleMode({ builder, output, projectName, header, needSchem
4234
4236
  data += "\n\n";
4235
4237
  data += implementationMock;
4236
4238
  }
4237
- await fs$1.outputFile(path$2, data);
4238
- return [path$2];
4239
+ await fs$1.outputFile(path, data);
4240
+ return [path];
4239
4241
  } catch (error) {
4240
4242
  const errorMsg = error instanceof Error ? error.message : "unknown error";
4241
4243
  throw new Error(`Oups... 🍻. An Error occurred while writing file => ${errorMsg}`);
@@ -4246,14 +4248,14 @@ async function writeSingleMode({ builder, output, projectName, header, needSchem
4246
4248
  //#region src/writers/split-mode.ts
4247
4249
  async function writeSplitMode({ builder, output, projectName, header, needSchema }) {
4248
4250
  try {
4249
- const { filename, dirname: dirname$1, extension } = getFileInfo(output.target, {
4251
+ const { filename, dirname, extension } = getFileInfo(output.target, {
4250
4252
  backupFilename: conventionName(builder.info.title, output.namingConvention),
4251
4253
  extension: output.fileExtension
4252
4254
  });
4253
4255
  const { imports, implementation, implementationMock, importsMock, mutators, clientMutators, formData, formUrlEncoded, paramsSerializer, fetchReviver } = generateTarget(builder, output);
4254
4256
  let implementationData = header;
4255
4257
  let mockData = header;
4256
- const relativeSchemasPath = output.schemas ? relativeSafe(dirname$1, getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname) : "./" + filename + ".schemas";
4258
+ const relativeSchemasPath = output.schemas ? relativeSafe(dirname, getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname) : "./" + filename + ".schemas";
4257
4259
  const isAllowSyntheticDefaultImports = isSyntheticDefaultImportsAllow(output.tsconfig);
4258
4260
  const importsForBuilder = generateImportsForBuilder(output, imports, relativeSchemasPath);
4259
4261
  implementationData += builder.imports({
@@ -4278,10 +4280,10 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
4278
4280
  isAllowSyntheticDefaultImports,
4279
4281
  options: isFunction(output.mock) ? void 0 : output.mock
4280
4282
  });
4281
- const schemasPath = output.schemas ? void 0 : join(dirname$1, filename + ".schemas" + extension);
4283
+ const schemasPath = output.schemas ? void 0 : join(dirname, filename + ".schemas" + extension);
4282
4284
  if (schemasPath && needSchema) {
4283
4285
  const schemasData = header + generateModelsInline(builder.schemas);
4284
- await fs$1.outputFile(join(dirname$1, filename + ".schemas" + extension), schemasData);
4286
+ await fs$1.outputFile(join(dirname, filename + ".schemas" + extension), schemasData);
4285
4287
  }
4286
4288
  if (mutators) implementationData += generateMutatorImports({
4287
4289
  mutators,
@@ -4303,9 +4305,9 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
4303
4305
  implementationData += `\n${implementation}`;
4304
4306
  mockData += `\n${implementationMock}`;
4305
4307
  const implementationFilename = filename + (OutputClient.ANGULAR === output.client ? ".service" : "") + extension;
4306
- const implementationPath = join(dirname$1, implementationFilename);
4307
- await fs$1.outputFile(join(dirname$1, implementationFilename), implementationData);
4308
- const mockPath = output.mock ? join(dirname$1, filename + "." + getMockFileExtensionByTypeName(output.mock) + extension) : void 0;
4308
+ const implementationPath = join(dirname, implementationFilename);
4309
+ await fs$1.outputFile(join(dirname, implementationFilename), implementationData);
4310
+ const mockPath = output.mock ? join(dirname, filename + "." + getMockFileExtensionByTypeName(output.mock) + extension) : void 0;
4309
4311
  if (mockPath) await fs$1.outputFile(mockPath, mockData);
4310
4312
  return [
4311
4313
  implementationPath,
@@ -4375,7 +4377,7 @@ function generateTargetForTags(builder, options) {
4375
4377
  const transformed = {};
4376
4378
  for (const [tag, target] of Object.entries(allTargetTags)) {
4377
4379
  const isMutator = !!target.mutators?.some((mutator) => isAngularClient ? mutator.hasThirdArg : mutator.hasSecondArg);
4378
- const operationNames = Object.values(builder.operations).filter(({ tags }) => tags.map((tag$1) => kebab(tag$1)).indexOf(kebab(tag)) === 0).map(({ operationName }) => operationName);
4380
+ const operationNames = Object.values(builder.operations).filter(({ tags }) => tags.map((tag) => kebab(tag)).indexOf(kebab(tag)) === 0).map(({ operationName }) => operationName);
4379
4381
  const hasAwaitedType = compareVersions(options.packageJson?.dependencies?.typescript ?? options.packageJson?.devDependencies?.typescript ?? "4.4.0", "4.5.0");
4380
4382
  const titles = builder.title({
4381
4383
  outputClient: options.client,
@@ -4435,22 +4437,22 @@ function generateTargetForTags(builder, options) {
4435
4437
  //#endregion
4436
4438
  //#region src/writers/split-tags-mode.ts
4437
4439
  async function writeSplitTagsMode({ builder, output, projectName, header, needSchema }) {
4438
- const { filename, dirname: dirname$1, extension } = getFileInfo(output.target, {
4440
+ const { filename, dirname, extension } = getFileInfo(output.target, {
4439
4441
  backupFilename: conventionName(builder.info.title, output.namingConvention),
4440
4442
  extension: output.fileExtension
4441
4443
  });
4442
4444
  const target = generateTargetForTags(builder, output);
4443
4445
  const isAllowSyntheticDefaultImports = isSyntheticDefaultImportsAllow(output.tsconfig);
4444
4446
  const mockOption = output.mock && !isFunction(output.mock) ? output.mock : void 0;
4445
- const indexFilePath = mockOption?.indexMockFiles ? join(dirname$1, "index." + getMockFileExtensionByTypeName(mockOption) + extension) : void 0;
4447
+ const indexFilePath = mockOption?.indexMockFiles ? join(dirname, "index." + getMockFileExtensionByTypeName(mockOption) + extension) : void 0;
4446
4448
  if (indexFilePath) await fs$1.outputFile(indexFilePath, "");
4447
4449
  const tagEntries = Object.entries(target);
4448
- const generatedFilePathsArray = await Promise.all(tagEntries.map(async ([tag, target$1]) => {
4450
+ const generatedFilePathsArray = await Promise.all(tagEntries.map(async ([tag, target]) => {
4449
4451
  try {
4450
- const { imports, implementation, implementationMock, importsMock, mutators, clientMutators, formData, fetchReviver, formUrlEncoded, paramsSerializer } = target$1;
4452
+ const { imports, implementation, implementationMock, importsMock, mutators, clientMutators, formData, fetchReviver, formUrlEncoded, paramsSerializer } = target;
4451
4453
  let implementationData = header;
4452
4454
  let mockData = header;
4453
- const relativeSchemasPath = output.schemas ? "../" + relativeSafe(dirname$1, getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname) : "../" + filename + ".schemas";
4455
+ const relativeSchemasPath = output.schemas ? "../" + relativeSafe(dirname, getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname) : "../" + filename + ".schemas";
4454
4456
  const importsForBuilder = generateImportsForBuilder(output, imports, relativeSchemasPath);
4455
4457
  implementationData += builder.imports({
4456
4458
  client: output.client,
@@ -4460,7 +4462,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
4460
4462
  hasSchemaDir: !!output.schemas,
4461
4463
  isAllowSyntheticDefaultImports,
4462
4464
  hasGlobalMutator: !!output.override.mutator,
4463
- hasTagsMutator: Object.values(output.override.tags).some((tag$1) => !!tag$1?.mutator),
4465
+ hasTagsMutator: Object.values(output.override.tags).some((tag) => !!tag?.mutator),
4464
4466
  hasParamsSerializerOptions: !!output.override.paramsSerializerOptions,
4465
4467
  packageJson: output.packageJson,
4466
4468
  output
@@ -4474,7 +4476,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
4474
4476
  isAllowSyntheticDefaultImports,
4475
4477
  options: isFunction(output.mock) ? void 0 : output.mock
4476
4478
  });
4477
- const schemasPath = output.schemas ? void 0 : join(dirname$1, filename + ".schemas" + extension);
4479
+ const schemasPath = output.schemas ? void 0 : join(dirname, filename + ".schemas" + extension);
4478
4480
  if (schemasPath && needSchema) {
4479
4481
  const schemasData = header + generateModelsInline(builder.schemas);
4480
4482
  await fs$1.outputFile(schemasPath, schemasData);
@@ -4515,9 +4517,9 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
4515
4517
  implementationData += `\n${implementation}`;
4516
4518
  mockData += `\n${implementationMock}`;
4517
4519
  const implementationFilename = tag + (OutputClient.ANGULAR === output.client ? ".service" : "") + extension;
4518
- const implementationPath = join(dirname$1, tag, implementationFilename);
4520
+ const implementationPath = join(dirname, tag, implementationFilename);
4519
4521
  await fs$1.outputFile(implementationPath, implementationData);
4520
- const mockPath = output.mock ? join(dirname$1, tag, tag + "." + getMockFileExtensionByTypeName(output.mock) + extension) : void 0;
4522
+ const mockPath = output.mock ? join(dirname, tag, tag + "." + getMockFileExtensionByTypeName(output.mock) + extension) : void 0;
4521
4523
  if (mockPath) await fs$1.outputFile(mockPath, mockData);
4522
4524
  return [
4523
4525
  implementationPath,
@@ -4541,17 +4543,17 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
4541
4543
  //#endregion
4542
4544
  //#region src/writers/tags-mode.ts
4543
4545
  async function writeTagsMode({ builder, output, projectName, header, needSchema }) {
4544
- const { filename, dirname: dirname$1, extension } = getFileInfo(output.target, {
4546
+ const { filename, dirname, extension } = getFileInfo(output.target, {
4545
4547
  backupFilename: conventionName(builder.info.title, output.namingConvention),
4546
4548
  extension: output.fileExtension
4547
4549
  });
4548
4550
  const target = generateTargetForTags(builder, output);
4549
4551
  const isAllowSyntheticDefaultImports = isSyntheticDefaultImportsAllow(output.tsconfig);
4550
- return (await Promise.all(Object.entries(target).map(async ([tag, target$1]) => {
4552
+ return (await Promise.all(Object.entries(target).map(async ([tag, target]) => {
4551
4553
  try {
4552
- const { imports, implementation, implementationMock, importsMock, mutators, clientMutators, formData, formUrlEncoded, fetchReviver, paramsSerializer } = target$1;
4554
+ const { imports, implementation, implementationMock, importsMock, mutators, clientMutators, formData, formUrlEncoded, fetchReviver, paramsSerializer } = target;
4553
4555
  let data = header;
4554
- const schemasPathRelative = output.schemas ? relativeSafe(dirname$1, getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname) : "./" + filename + ".schemas";
4556
+ const schemasPathRelative = output.schemas ? relativeSafe(dirname, getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname) : "./" + filename + ".schemas";
4555
4557
  const importsForBuilder = generateImportsForBuilder(output, imports.filter((imp) => !importsMock.some((impMock) => imp.name === impMock.name)), schemasPathRelative);
4556
4558
  data += builder.imports({
4557
4559
  client: output.client,
@@ -4561,7 +4563,7 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema
4561
4563
  hasSchemaDir: !!output.schemas,
4562
4564
  isAllowSyntheticDefaultImports,
4563
4565
  hasGlobalMutator: !!output.override.mutator,
4564
- hasTagsMutator: Object.values(output.override.tags).some((tag$1) => !!tag$1?.mutator),
4566
+ hasTagsMutator: Object.values(output.override.tags).some((tag) => !!tag?.mutator),
4565
4567
  hasParamsSerializerOptions: !!output.override.paramsSerializerOptions,
4566
4568
  packageJson: output.packageJson,
4567
4569
  output
@@ -4577,7 +4579,7 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema
4577
4579
  options: isFunction(output.mock) ? void 0 : output.mock
4578
4580
  });
4579
4581
  }
4580
- const schemasPath = output.schemas ? void 0 : join(dirname$1, filename + ".schemas" + extension);
4582
+ const schemasPath = output.schemas ? void 0 : join(dirname, filename + ".schemas" + extension);
4581
4583
  if (schemasPath && needSchema) {
4582
4584
  const schemasData = header + generateModelsInline(builder.schemas);
4583
4585
  await fs$1.outputFile(schemasPath, schemasData);
@@ -4605,7 +4607,7 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema
4605
4607
  data += "\n\n";
4606
4608
  data += implementationMock;
4607
4609
  }
4608
- const implementationPath = join(dirname$1, `${kebab(tag)}${extension}`);
4610
+ const implementationPath = join(dirname, `${kebab(tag)}${extension}`);
4609
4611
  await fs$1.outputFile(implementationPath, data);
4610
4612
  return [implementationPath, ...schemasPath ? [schemasPath] : []];
4611
4613
  } catch (error) {