orval 8.9.1 → 8.11.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/bin/orval.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as description, i as startWatcher, l as name, n as loadConfigFile, r as generateSpec, s as normalizeOptions, t as findConfigFile, u as version } from "../config-
|
|
2
|
+
import { c as description, i as startWatcher, l as name, n as loadConfigFile, r as generateSpec, s as normalizeOptions, t as findConfigFile, u as version } from "../config-D0MzallH.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { Option, program } from "@commander-js/extra-typings";
|
|
5
5
|
import { ErrorWithTag, OutputClient, OutputMode, SupportedFormatter, getWarningCount, isString, log, logError, resetWarnings, setVerbose, startMessage } from "@orval/core";
|
|
@@ -22,13 +22,13 @@ import { styleText } from "node:util";
|
|
|
22
22
|
import { parseArgsStringToArgv } from "string-argv";
|
|
23
23
|
import { findUp, findUpMultiple } from "find-up";
|
|
24
24
|
import yaml from "js-yaml";
|
|
25
|
-
import {
|
|
25
|
+
import { parseTsconfig } from "get-tsconfig";
|
|
26
26
|
import fs$2 from "node:fs";
|
|
27
27
|
import { createJiti } from "jiti";
|
|
28
28
|
//#region package.json
|
|
29
29
|
var name = "orval";
|
|
30
30
|
var description = "A swagger client generator for typescript";
|
|
31
|
-
var version = "8.
|
|
31
|
+
var version = "8.11.0";
|
|
32
32
|
//#endregion
|
|
33
33
|
//#region src/client.ts
|
|
34
34
|
const DEFAULT_CLIENT = OutputClient.AXIOS;
|
|
@@ -73,7 +73,7 @@ const generateClientImports = ({ client, implementation, imports, projectName, h
|
|
|
73
73
|
const { dependencies } = getGeneratorClient(client, output);
|
|
74
74
|
return generateDependencyImports(implementation, dependencies ? [...dependencies(hasGlobalMutator, hasParamsSerializerOptions, packageJson, output.httpClient, hasTagsMutator, output.override), ...imports] : imports, projectName, hasSchemaDir, isAllowSyntheticDefaultImports);
|
|
75
75
|
};
|
|
76
|
-
const generateClientHeader = ({ outputClient = DEFAULT_CLIENT, isRequestOptions, isGlobalMutator, isMutator, provideIn, hasAwaitedType, titles, output, verbOptions, tag, clientImplementation }) => {
|
|
76
|
+
const generateClientHeader = ({ outputClient = DEFAULT_CLIENT, isRequestOptions, isGlobalMutator, isMutator, provideIn, hasAwaitedType, titles, output, verbOptions, tag, isDefaultTagBucket, clientImplementation }) => {
|
|
77
77
|
const { header } = getGeneratorClient(outputClient, output);
|
|
78
78
|
return {
|
|
79
79
|
implementation: header ? header({
|
|
@@ -86,6 +86,7 @@ const generateClientHeader = ({ outputClient = DEFAULT_CLIENT, isRequestOptions,
|
|
|
86
86
|
output,
|
|
87
87
|
verbOptions,
|
|
88
88
|
tag,
|
|
89
|
+
isDefaultTagBucket,
|
|
89
90
|
clientImplementation
|
|
90
91
|
}) : "",
|
|
91
92
|
implementationMock: `export const ${titles.implementationMock} = () => [\n`
|
|
@@ -178,6 +179,7 @@ const generateOperations = (outputClient = DEFAULT_CLIENT, verbsOptions, options
|
|
|
178
179
|
formData: verbOption.formData,
|
|
179
180
|
formUrlEncoded: verbOption.formUrlEncoded,
|
|
180
181
|
paramsSerializer: verbOption.paramsSerializer,
|
|
182
|
+
paramsFilter: verbOption.paramsFilter,
|
|
181
183
|
operationName: verbOption.operationName,
|
|
182
184
|
fetchReviver: verbOption.fetchReviver
|
|
183
185
|
};
|
|
@@ -271,7 +273,7 @@ function filterSpecComponents(spec, input) {
|
|
|
271
273
|
};
|
|
272
274
|
}
|
|
273
275
|
async function importOpenApi({ spec, input, output, target, workspace, projectName }) {
|
|
274
|
-
const filteredSpec = filterSpecComponents(
|
|
276
|
+
const filteredSpec = filterSpecComponents(spec, input);
|
|
275
277
|
const schemas = getApiSchemas({
|
|
276
278
|
input,
|
|
277
279
|
output,
|
|
@@ -298,16 +300,6 @@ async function importOpenApi({ spec, input, output, target, workspace, projectNa
|
|
|
298
300
|
spec: filteredSpec
|
|
299
301
|
};
|
|
300
302
|
}
|
|
301
|
-
async function applyTransformer(openApi, transformer, workspace, unsafeDisableValidation = false) {
|
|
302
|
-
const transformerFn = transformer ? await dynamicImport(transformer, workspace) : void 0;
|
|
303
|
-
if (!transformerFn) return openApi;
|
|
304
|
-
const transformedOpenApi = transformerFn(openApi);
|
|
305
|
-
if (!unsafeDisableValidation) {
|
|
306
|
-
const { valid, errors } = await validate(transformedOpenApi);
|
|
307
|
-
if (!valid) throw new Error(`Validation failed`, { cause: errors });
|
|
308
|
-
}
|
|
309
|
-
return transformedOpenApi;
|
|
310
|
-
}
|
|
311
303
|
function getApiSchemas({ input, output, target, workspace, spec }) {
|
|
312
304
|
const context = {
|
|
313
305
|
target,
|
|
@@ -330,7 +322,7 @@ function getApiSchemas({ input, output, target, workspace, spec }) {
|
|
|
330
322
|
}
|
|
331
323
|
//#endregion
|
|
332
324
|
//#region src/import-specs.ts
|
|
333
|
-
async function resolveSpec(input, parserOptions, unsafeDisableValidation = false) {
|
|
325
|
+
async function resolveSpec(input, { parserOptions, transformer, workspace, unsafeDisableValidation = false }) {
|
|
334
326
|
const dereferencedData = dereferenceExternalRef(await bundle(input, {
|
|
335
327
|
plugins: [
|
|
336
328
|
readFiles(),
|
|
@@ -340,19 +332,34 @@ async function resolveSpec(input, parserOptions, unsafeDisableValidation = false
|
|
|
340
332
|
],
|
|
341
333
|
treeShake: false
|
|
342
334
|
}));
|
|
335
|
+
const transformedData = transformer ? await applyInputTransformer(dereferencedData, transformer, workspace) : dereferencedData;
|
|
343
336
|
if (unsafeDisableValidation) logWarning("🚨 OpenAPI spec validation is disabled.\n Code generation with invalid specs is not guaranteed to work and may break in minor updates.\n Bug reports with validation disabled will not be accepted.");
|
|
344
337
|
else {
|
|
345
|
-
validateComponentKeys(
|
|
346
|
-
const { valid, errors } = await validate(
|
|
338
|
+
validateComponentKeys(transformedData);
|
|
339
|
+
const { valid, errors } = await validate(transformedData);
|
|
347
340
|
if (!valid) throw new Error(`OpenAPI spec validation failed:\n${JSON.stringify(errors, void 0, 2)}`);
|
|
348
341
|
}
|
|
349
|
-
const { specification } = upgrade(
|
|
342
|
+
const { specification } = upgrade(transformedData);
|
|
350
343
|
return specification;
|
|
351
344
|
}
|
|
345
|
+
async function applyInputTransformer(data, transformer, workspace) {
|
|
346
|
+
const transformerFn = await dynamicImport(transformer, workspace);
|
|
347
|
+
const result = await transformerFn(data);
|
|
348
|
+
if (!isObject(result)) {
|
|
349
|
+
const source = isString(transformer) ? transformer : transformerFn.name || "<inline function>";
|
|
350
|
+
throw new Error(`input.override.transformer must return an OpenAPI document object; got ${result === void 0 ? "undefined" : typeof result} from ${source}. Ensure your transformer returns the (possibly modified) spec.`);
|
|
351
|
+
}
|
|
352
|
+
return result;
|
|
353
|
+
}
|
|
352
354
|
async function importSpecs(workspace, options, projectName) {
|
|
353
355
|
const { input, output } = options;
|
|
354
356
|
return importOpenApi({
|
|
355
|
-
spec: await resolveSpec(input.target,
|
|
357
|
+
spec: await resolveSpec(input.target, {
|
|
358
|
+
parserOptions: input.parserOptions,
|
|
359
|
+
transformer: input.override.transformer,
|
|
360
|
+
workspace,
|
|
361
|
+
unsafeDisableValidation: input.unsafeDisableValidation
|
|
362
|
+
}),
|
|
356
363
|
input,
|
|
357
364
|
output,
|
|
358
365
|
target: isString(input.target) ? input.target : workspace,
|
|
@@ -480,11 +487,13 @@ function updateInternalRefs(obj, extKey, schemaNameMappings) {
|
|
|
480
487
|
return obj;
|
|
481
488
|
}
|
|
482
489
|
/**
|
|
483
|
-
* Replace x-ext refs with
|
|
490
|
+
* Replace x-ext refs with standard component refs, or inline the content.
|
|
491
|
+
* `inliningRefs` tracks the inline chain to break cycles in recursive
|
|
492
|
+
* external schemas that aren't under `components.schemas` (#1642).
|
|
484
493
|
*/
|
|
485
|
-
function replaceXExtRefs(obj, extensions, schemaNameMappings) {
|
|
494
|
+
function replaceXExtRefs(obj, extensions, schemaNameMappings, inliningRefs = /* @__PURE__ */ new Set()) {
|
|
486
495
|
if (isNullish$1(obj)) return obj;
|
|
487
|
-
if (Array.isArray(obj)) return obj.map((element) => replaceXExtRefs(element, extensions, schemaNameMappings));
|
|
496
|
+
if (Array.isArray(obj)) return obj.map((element) => replaceXExtRefs(element, extensions, schemaNameMappings, inliningRefs));
|
|
488
497
|
if (isObject(obj)) {
|
|
489
498
|
const record = obj;
|
|
490
499
|
if ("$ref" in record && isString(record.$ref)) {
|
|
@@ -497,18 +506,27 @@ function replaceXExtRefs(obj, extensions, schemaNameMappings) {
|
|
|
497
506
|
const schemaName = parts.slice(2).join("/");
|
|
498
507
|
return { $ref: `#/components/schemas/${schemaNameMappings[extKey][schemaName] || schemaName}` };
|
|
499
508
|
}
|
|
509
|
+
if (inliningRefs.has(refValue)) {
|
|
510
|
+
logWarning(`Detected a circular external $ref while inlining "${refValue}". Replacing with an empty schema to avoid infinite recursion. Move the schema under "components.schemas" in its source file or pre-bundle the spec to keep the recursion intact.`);
|
|
511
|
+
return {};
|
|
512
|
+
}
|
|
500
513
|
let refObj = extensions[extKey];
|
|
501
514
|
for (const p of parts) if (refObj && (isObject(refObj) || Array.isArray(refObj)) && p in refObj) refObj = refObj[p];
|
|
502
515
|
else {
|
|
503
516
|
refObj = void 0;
|
|
504
517
|
break;
|
|
505
518
|
}
|
|
506
|
-
if (refObj)
|
|
519
|
+
if (refObj) {
|
|
520
|
+
const cleaned = scrubUnwantedKeys(refObj);
|
|
521
|
+
const nextInlining = new Set(inliningRefs);
|
|
522
|
+
nextInlining.add(refValue);
|
|
523
|
+
return replaceXExtRefs(cleaned, extensions, schemaNameMappings, nextInlining);
|
|
524
|
+
}
|
|
507
525
|
}
|
|
508
526
|
}
|
|
509
527
|
}
|
|
510
528
|
const result = {};
|
|
511
|
-
for (const [key, value] of Object.entries(record)) result[key] = replaceXExtRefs(value, extensions, schemaNameMappings);
|
|
529
|
+
for (const [key, value] of Object.entries(record)) result[key] = replaceXExtRefs(value, extensions, schemaNameMappings, inliningRefs);
|
|
512
530
|
return result;
|
|
513
531
|
}
|
|
514
532
|
return obj;
|
|
@@ -725,18 +743,30 @@ const performSubstitution = (dependencies, catalogData) => {
|
|
|
725
743
|
};
|
|
726
744
|
//#endregion
|
|
727
745
|
//#region src/utils/tsconfig.ts
|
|
746
|
+
const convertTarget = (config) => {
|
|
747
|
+
if (!config.compilerOptions?.target) return {
|
|
748
|
+
baseUrl: config.compilerOptions?.baseUrl,
|
|
749
|
+
...config
|
|
750
|
+
};
|
|
751
|
+
const lowercaseTarget = config.compilerOptions.target.toLowerCase();
|
|
752
|
+
return {
|
|
753
|
+
baseUrl: config.compilerOptions.baseUrl,
|
|
754
|
+
...config,
|
|
755
|
+
compilerOptions: {
|
|
756
|
+
...config.compilerOptions,
|
|
757
|
+
target: lowercaseTarget
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
};
|
|
728
761
|
const loadTsconfig = async (tsconfig, workspace = process.cwd()) => {
|
|
729
762
|
if (isNullish(tsconfig)) {
|
|
730
763
|
const configPath = await findUp(["tsconfig.json", "jsconfig.json"], { cwd: workspace });
|
|
731
|
-
if (configPath) return (
|
|
764
|
+
if (configPath) return convertTarget(parseTsconfig(configPath));
|
|
732
765
|
return;
|
|
733
766
|
}
|
|
734
767
|
if (isString(tsconfig)) {
|
|
735
768
|
const normalizedPath = normalizePath(tsconfig, workspace);
|
|
736
|
-
if (fs.existsSync(normalizedPath))
|
|
737
|
-
const config = await parse(normalizedPath);
|
|
738
|
-
return config.referenced?.find(({ tsconfigFile }) => tsconfigFile === normalizedPath)?.tsconfig ?? config.tsconfig;
|
|
739
|
-
}
|
|
769
|
+
if (fs.existsSync(normalizedPath)) return convertTarget(parseTsconfig(normalizedPath));
|
|
740
770
|
return;
|
|
741
771
|
}
|
|
742
772
|
if (isObject(tsconfig)) return tsconfig;
|
|
@@ -813,8 +843,6 @@ async function normalizeOptions(optionsExport, workspace = process.cwd(), global
|
|
|
813
843
|
else mock = void 0;
|
|
814
844
|
const defaultFileExtension = ".ts";
|
|
815
845
|
const globalQueryOptions = {
|
|
816
|
-
useQuery: true,
|
|
817
|
-
useMutation: true,
|
|
818
846
|
signal: true,
|
|
819
847
|
shouldExportMutatorHooks: true,
|
|
820
848
|
shouldExportHttpClient: true,
|
|
@@ -866,6 +894,7 @@ async function normalizeOptions(optionsExport, workspace = process.cwd(), global
|
|
|
866
894
|
formData: createFormData(outputWorkspace, outputOptions.override?.formData),
|
|
867
895
|
formUrlEncoded: (isBoolean(outputOptions.override?.formUrlEncoded) ? outputOptions.override.formUrlEncoded : normalizeMutator(outputWorkspace, outputOptions.override?.formUrlEncoded)) ?? true,
|
|
868
896
|
paramsSerializer: normalizeMutator(outputWorkspace, outputOptions.override?.paramsSerializer),
|
|
897
|
+
paramsFilter: normalizeMutator(outputWorkspace, outputOptions.override?.paramsFilter),
|
|
869
898
|
header: outputOptions.override?.header === false ? false : isFunction(outputOptions.override?.header) ? outputOptions.override.header : getDefaultFilesHeader,
|
|
870
899
|
requestOptions: outputOptions.override?.requestOptions ?? true,
|
|
871
900
|
namingConvention: outputOptions.override?.namingConvention ?? {},
|
|
@@ -961,6 +990,14 @@ async function normalizeOptions(optionsExport, workspace = process.cwd(), global
|
|
|
961
990
|
};
|
|
962
991
|
if (!normalizedOptions.input.target) throw new Error(styleText("red", `Config requires an input target.`));
|
|
963
992
|
if (!normalizedOptions.output.target && !normalizedOptions.output.schemas) throw new Error(styleText("red", `Config requires an output target or schemas.`));
|
|
993
|
+
const usesAngularGenerator = normalizedOptions.output.client === OutputClient.ANGULAR || normalizedOptions.output.client === OutputClient.ANGULAR_QUERY && normalizedOptions.output.httpClient === OutputHttpClient.ANGULAR;
|
|
994
|
+
if (normalizedOptions.output.override.paramsFilter && !usesAngularGenerator) throw new Error(styleText("red", `\`override.paramsFilter\` is only supported by the Angular generator (the \`angular\` client, or \`angular-query\` with \`httpClient: 'angular'\`). It has no effect for other clients — use \`override.paramsSerializer\` instead.`));
|
|
995
|
+
if (!usesAngularGenerator) {
|
|
996
|
+
const offendingOperation = Object.entries(normalizedOptions.output.override.operations).find(([, opOverride]) => opOverride?.paramsFilter)?.[0];
|
|
997
|
+
if (offendingOperation) throw new Error(styleText("red", `\`override.operations["${offendingOperation}"].paramsFilter\` is only supported by the Angular generator (the \`angular\` client, or \`angular-query\` with \`httpClient: 'angular'\`). It has no effect for other clients — use \`override.paramsSerializer\` instead.`));
|
|
998
|
+
const offendingTag = Object.entries(normalizedOptions.output.override.tags).find(([, tagOverride]) => tagOverride?.paramsFilter)?.[0];
|
|
999
|
+
if (offendingTag) throw new Error(styleText("red", `\`override.tags["${offendingTag}"].paramsFilter\` is only supported by the Angular generator (the \`angular\` client, or \`angular-query\` with \`httpClient: 'angular'\`). It has no effect for other clients — use \`override.paramsSerializer\` instead.`));
|
|
1000
|
+
}
|
|
964
1001
|
if (normalizedOptions.output.httpClient === OutputHttpClient.FETCH && normalizedOptions.output.optionsParamRequired && normalizedOptions.output.override.requestOptions !== false) logWarning(`⚠️ With \`httpClient: 'fetch'\`, \`optionsParamRequired: true\` cannot make the generated \`options\` parameter required. The fetch \`options\` parameter remains optional with type \`RequestInit\` (\`optionsParamRequired\` may still affect other generated parameters). Set \`httpClient: 'axios'\` to make the \`options\` parameter required.`);
|
|
965
1002
|
return normalizedOptions;
|
|
966
1003
|
}
|
|
@@ -1043,7 +1080,7 @@ function normalizePath(path$1, workspace) {
|
|
|
1043
1080
|
return path.resolve(workspace, path$1);
|
|
1044
1081
|
}
|
|
1045
1082
|
function normalizeOperationsAndTags(operationsOrTags, workspace, global) {
|
|
1046
|
-
return Object.fromEntries(Object.entries(operationsOrTags).map(([key, { transformer, mutator, formData, formUrlEncoded, paramsSerializer, query, angular, zod, ...rest }]) => {
|
|
1083
|
+
return Object.fromEntries(Object.entries(operationsOrTags).map(([key, { transformer, mutator, formData, formUrlEncoded, paramsSerializer, paramsFilter, query, angular, zod, ...rest }]) => {
|
|
1047
1084
|
return [key, {
|
|
1048
1085
|
...rest,
|
|
1049
1086
|
...angular ? { angular: {
|
|
@@ -1091,7 +1128,8 @@ function normalizeOperationsAndTags(operationsOrTags, workspace, global) {
|
|
|
1091
1128
|
...mutator ? { mutator: normalizeMutator(workspace, mutator) } : {},
|
|
1092
1129
|
...formData === void 0 ? {} : { formData: createFormData(workspace, formData) },
|
|
1093
1130
|
...formUrlEncoded ? { formUrlEncoded: isBoolean(formUrlEncoded) ? formUrlEncoded : normalizeMutator(workspace, formUrlEncoded) } : {},
|
|
1094
|
-
...paramsSerializer ? { paramsSerializer: normalizeMutator(workspace, paramsSerializer) } : {}
|
|
1131
|
+
...paramsSerializer ? { paramsSerializer: normalizeMutator(workspace, paramsSerializer) } : {},
|
|
1132
|
+
...paramsFilter ? { paramsFilter: normalizeMutator(workspace, paramsFilter) } : {}
|
|
1095
1133
|
}];
|
|
1096
1134
|
}));
|
|
1097
1135
|
}
|
|
@@ -1255,7 +1293,7 @@ const groupSchemasByFilePath = (schemas) => {
|
|
|
1255
1293
|
if (existingGroup) existingGroup.push(schema);
|
|
1256
1294
|
else grouped.set(key, [schema]);
|
|
1257
1295
|
}
|
|
1258
|
-
return [...grouped.values()].map((group) => [...group].toSorted((a, b) => a.filePath.localeCompare(b.filePath))).toSorted((a, b) => a[0].filePath.localeCompare(b[0].filePath));
|
|
1296
|
+
return [...grouped.values()].map((group) => [...group].toSorted((a, b) => a.filePath.localeCompare(b.filePath, "en", { numeric: true }))).toSorted((a, b) => a[0].filePath.localeCompare(b[0].filePath, "en", { numeric: true }));
|
|
1259
1297
|
};
|
|
1260
1298
|
async function writeZodSchemaIndex(schemasPath, fileExtension, header, schemaNames, namingConvention, shouldMergeExisting = false) {
|
|
1261
1299
|
const importFileExtension = fileExtension.replace(/\.ts$/, "");
|
|
@@ -1466,8 +1504,8 @@ async function writeSpecs(builder, workspace, options, projectName) {
|
|
|
1466
1504
|
const { regularSchemas, operationSchemas: opSchemas } = splitSchemasByType(schemas);
|
|
1467
1505
|
const regularSchemaNames = new Set(regularSchemas.map((s) => s.name));
|
|
1468
1506
|
const operationSchemaNames = new Set(opSchemas.map((s) => s.name));
|
|
1469
|
-
fixCrossDirectoryImports(opSchemas, regularSchemaNames, schemaPath, output.operationSchemas, output.namingConvention, fileExtension);
|
|
1470
|
-
fixRegularSchemaImports(regularSchemas, operationSchemaNames, schemaPath, output.operationSchemas, output.namingConvention, fileExtension);
|
|
1507
|
+
fixCrossDirectoryImports(opSchemas, regularSchemaNames, schemaPath, output.operationSchemas, output.namingConvention, fileExtension, output.tsconfig);
|
|
1508
|
+
fixRegularSchemaImports(regularSchemas, operationSchemaNames, schemaPath, output.operationSchemas, output.namingConvention, fileExtension, output.tsconfig);
|
|
1471
1509
|
if (regularSchemas.length > 0) await writeSchemas({
|
|
1472
1510
|
schemaPath,
|
|
1473
1511
|
schemas: regularSchemas,
|
|
@@ -1475,7 +1513,8 @@ async function writeSpecs(builder, workspace, options, projectName) {
|
|
|
1475
1513
|
namingConvention: output.namingConvention,
|
|
1476
1514
|
fileExtension,
|
|
1477
1515
|
header,
|
|
1478
|
-
indexFiles: output.indexFiles
|
|
1516
|
+
indexFiles: output.indexFiles,
|
|
1517
|
+
tsconfig: output.tsconfig
|
|
1479
1518
|
});
|
|
1480
1519
|
if (opSchemas.length > 0) {
|
|
1481
1520
|
await writeSchemas({
|
|
@@ -1485,7 +1524,8 @@ async function writeSpecs(builder, workspace, options, projectName) {
|
|
|
1485
1524
|
namingConvention: output.namingConvention,
|
|
1486
1525
|
fileExtension,
|
|
1487
1526
|
header,
|
|
1488
|
-
indexFiles: output.indexFiles
|
|
1527
|
+
indexFiles: output.indexFiles,
|
|
1528
|
+
tsconfig: output.tsconfig
|
|
1489
1529
|
});
|
|
1490
1530
|
if (output.indexFiles) await addOperationSchemasReExport(schemaPath, output.operationSchemas, header);
|
|
1491
1531
|
}
|
|
@@ -1496,7 +1536,8 @@ async function writeSpecs(builder, workspace, options, projectName) {
|
|
|
1496
1536
|
namingConvention: output.namingConvention,
|
|
1497
1537
|
fileExtension,
|
|
1498
1538
|
header,
|
|
1499
|
-
indexFiles: output.indexFiles
|
|
1539
|
+
indexFiles: output.indexFiles,
|
|
1540
|
+
tsconfig: output.tsconfig
|
|
1500
1541
|
});
|
|
1501
1542
|
} else if (output.schemas.type === "typescript") {
|
|
1502
1543
|
const fileExtension = output.fileExtension || ".ts";
|
|
@@ -1504,8 +1545,8 @@ async function writeSpecs(builder, workspace, options, projectName) {
|
|
|
1504
1545
|
const { regularSchemas, operationSchemas: opSchemas } = splitSchemasByType(schemas);
|
|
1505
1546
|
const regularSchemaNames = new Set(regularSchemas.map((s) => s.name));
|
|
1506
1547
|
const operationSchemaNames = new Set(opSchemas.map((s) => s.name));
|
|
1507
|
-
fixCrossDirectoryImports(opSchemas, regularSchemaNames, output.schemas.path, output.operationSchemas, output.namingConvention, fileExtension);
|
|
1508
|
-
fixRegularSchemaImports(regularSchemas, operationSchemaNames, output.schemas.path, output.operationSchemas, output.namingConvention, fileExtension);
|
|
1548
|
+
fixCrossDirectoryImports(opSchemas, regularSchemaNames, output.schemas.path, output.operationSchemas, output.namingConvention, fileExtension, output.tsconfig);
|
|
1549
|
+
fixRegularSchemaImports(regularSchemas, operationSchemaNames, output.schemas.path, output.operationSchemas, output.namingConvention, fileExtension, output.tsconfig);
|
|
1509
1550
|
if (regularSchemas.length > 0) await writeSchemas({
|
|
1510
1551
|
schemaPath: output.schemas.path,
|
|
1511
1552
|
schemas: regularSchemas,
|
|
@@ -1513,7 +1554,8 @@ async function writeSpecs(builder, workspace, options, projectName) {
|
|
|
1513
1554
|
namingConvention: output.namingConvention,
|
|
1514
1555
|
fileExtension,
|
|
1515
1556
|
header,
|
|
1516
|
-
indexFiles: output.indexFiles
|
|
1557
|
+
indexFiles: output.indexFiles,
|
|
1558
|
+
tsconfig: output.tsconfig
|
|
1517
1559
|
});
|
|
1518
1560
|
if (opSchemas.length > 0) {
|
|
1519
1561
|
await writeSchemas({
|
|
@@ -1523,7 +1565,8 @@ async function writeSpecs(builder, workspace, options, projectName) {
|
|
|
1523
1565
|
namingConvention: output.namingConvention,
|
|
1524
1566
|
fileExtension,
|
|
1525
1567
|
header,
|
|
1526
|
-
indexFiles: output.indexFiles
|
|
1568
|
+
indexFiles: output.indexFiles,
|
|
1569
|
+
tsconfig: output.tsconfig
|
|
1527
1570
|
});
|
|
1528
1571
|
if (output.indexFiles) await addOperationSchemasReExport(output.schemas.path, output.operationSchemas, header);
|
|
1529
1572
|
}
|
|
@@ -1534,7 +1577,8 @@ async function writeSpecs(builder, workspace, options, projectName) {
|
|
|
1534
1577
|
namingConvention: output.namingConvention,
|
|
1535
1578
|
fileExtension,
|
|
1536
1579
|
header,
|
|
1537
|
-
indexFiles: output.indexFiles
|
|
1580
|
+
indexFiles: output.indexFiles,
|
|
1581
|
+
tsconfig: output.tsconfig
|
|
1538
1582
|
});
|
|
1539
1583
|
} else {
|
|
1540
1584
|
const fileExtension = ".zod.ts";
|
|
@@ -1605,6 +1649,7 @@ async function writeSpecs(builder, workspace, options, projectName) {
|
|
|
1605
1649
|
const app = await (await getTypedocApplication()).bootstrapWithPlugins({
|
|
1606
1650
|
entryPoints: paths.map((x) => upath.toUnix(x)),
|
|
1607
1651
|
theme: "markdown",
|
|
1652
|
+
skipErrorChecking: true,
|
|
1608
1653
|
...config,
|
|
1609
1654
|
plugin: ["typedoc-plugin-markdown", ...config.plugin ?? []]
|
|
1610
1655
|
});
|
|
@@ -1715,4 +1760,4 @@ async function loadConfigFile(configFilePath) {
|
|
|
1715
1760
|
//#endregion
|
|
1716
1761
|
export { defineConfig as a, description as c, startWatcher as i, name as l, loadConfigFile as n, defineTransformer as o, generateSpec as r, normalizeOptions as s, findConfigFile as t, version as u };
|
|
1717
1762
|
|
|
1718
|
-
//# sourceMappingURL=config-
|
|
1763
|
+
//# sourceMappingURL=config-D0MzallH.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-D0MzallH.mjs","names":["validateSpec","isNullish","fs","nodePath","path","pkg.name","pkg.version","version","fs"],"sources":["../package.json","../src/client.ts","../src/api.ts","../src/import-open-api.ts","../src/import-specs.ts","../src/formatters/prettier.ts","../src/utils/execute-hook.ts","../src/utils/package-json.ts","../src/utils/tsconfig.ts","../src/utils/options.ts","../src/utils/watcher.ts","../src/write-zod-specs.ts","../src/write-specs.ts","../src/generate-spec.ts","../src/utils/config.ts"],"sourcesContent":["","import angular from '@orval/angular';\nimport axios from '@orval/axios';\nimport type {\n AngularOptions,\n ClientFileBuilder,\n ClientGeneratorsBuilder,\n ClientMockBuilder,\n ClientMockGeneratorBuilder,\n ContextSpec,\n GeneratorClientFooter,\n GeneratorClientHeader,\n GeneratorClientImports,\n GeneratorClients,\n GeneratorClientTitle,\n GeneratorOperations,\n GeneratorOptions,\n GeneratorVerbOptions,\n GeneratorVerbsOptions,\n NormalizedOutputOptions,\n OutputClientFunc,\n} from '@orval/core';\nimport {\n asyncReduce,\n generateDependencyImports,\n getBaseUrlRuntimeImports,\n isFunction,\n logWarning,\n OutputClient,\n pascal,\n} from '@orval/core';\nimport fetchClient from '@orval/fetch';\nimport hono from '@orval/hono';\nimport mcp from '@orval/mcp';\nimport * as mock from '@orval/mock';\nimport query from '@orval/query';\nimport solidStart from '@orval/solid-start';\nimport swr from '@orval/swr';\nimport zod from '@orval/zod';\n\nconst DEFAULT_CLIENT = OutputClient.AXIOS;\n\nconst getGeneratorClient = (\n outputClient: OutputClient | OutputClientFunc,\n output: NormalizedOutputOptions,\n) => {\n const angularBuilder = angular() as (\n options?: AngularOptions,\n ) => ClientGeneratorsBuilder;\n const GENERATOR_CLIENT: GeneratorClients = {\n axios: axios({ type: 'axios' })(),\n 'axios-functions': axios({ type: 'axios-functions' })(),\n angular: angularBuilder(output.override.angular),\n 'angular-query': query({ output, type: 'angular-query' })(),\n 'react-query': query({ output, type: 'react-query' })(),\n 'solid-start': solidStart()(),\n 'solid-query': query({ output, type: 'solid-query' })(),\n 'svelte-query': query({ output, type: 'svelte-query' })(),\n 'vue-query': query({ output, type: 'vue-query' })(),\n swr: swr()(),\n zod: zod()(),\n hono: hono()(),\n fetch: fetchClient()(),\n mcp: mcp()(),\n };\n\n const generator = isFunction(outputClient)\n ? outputClient(GENERATOR_CLIENT)\n : GENERATOR_CLIENT[outputClient];\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- defensive guard for custom OutputClientFunc returning unexpected values\n if (!generator) {\n throw new Error(\n `Unknown output client provided to getGeneratorClient: ${String(outputClient)}`,\n );\n }\n\n return generator;\n};\n\nexport const generateClientImports: GeneratorClientImports = ({\n client,\n implementation,\n imports,\n projectName,\n hasSchemaDir,\n isAllowSyntheticDefaultImports,\n hasGlobalMutator,\n hasTagsMutator,\n hasParamsSerializerOptions,\n packageJson,\n output,\n}) => {\n const { dependencies } = getGeneratorClient(client, output);\n return generateDependencyImports(\n implementation,\n dependencies\n ? [\n ...dependencies(\n hasGlobalMutator,\n hasParamsSerializerOptions,\n packageJson,\n output.httpClient,\n hasTagsMutator,\n output.override,\n ),\n ...imports,\n ]\n : (imports as Parameters<typeof generateDependencyImports>[1]),\n projectName,\n hasSchemaDir,\n isAllowSyntheticDefaultImports,\n );\n};\n\nexport const generateClientHeader: GeneratorClientHeader = ({\n outputClient = DEFAULT_CLIENT,\n isRequestOptions,\n isGlobalMutator,\n isMutator,\n provideIn,\n hasAwaitedType,\n titles,\n output,\n verbOptions,\n tag,\n isDefaultTagBucket,\n clientImplementation,\n}) => {\n const { header } = getGeneratorClient(outputClient, output);\n return {\n implementation: header\n ? header({\n title: titles.implementation,\n isRequestOptions,\n isGlobalMutator,\n isMutator,\n provideIn,\n hasAwaitedType,\n output,\n verbOptions,\n tag,\n isDefaultTagBucket,\n clientImplementation,\n })\n : '',\n implementationMock: `export const ${titles.implementationMock} = () => [\\n`,\n };\n};\n\nexport const generateClientFooter: GeneratorClientFooter = ({\n outputClient,\n operationNames,\n hasMutator,\n hasAwaitedType,\n titles,\n output,\n}) => {\n const { footer } = getGeneratorClient(outputClient, output);\n\n if (!footer) {\n return {\n implementation: '',\n implementationMock: `\\n]\\n`,\n };\n }\n\n let implementation: string;\n try {\n if (isFunction(outputClient)) {\n implementation = (\n footer as unknown as (operationNames: string[]) => string\n )(operationNames);\n // being here means that the previous call worked\n logWarning(\n '⚠️ Passing an array of strings for operations names to the footer function is deprecated and will be removed in a future major release. Please pass them in an object instead: { operationNames: string[] }.',\n );\n } else {\n implementation = footer({\n operationNames,\n title: titles.implementation,\n hasMutator,\n hasAwaitedType,\n });\n }\n } catch {\n implementation = footer({\n operationNames,\n title: titles.implementation,\n hasMutator,\n hasAwaitedType,\n });\n }\n\n return {\n implementation,\n implementationMock: `]\\n`,\n };\n};\n\nexport const generateClientTitle: GeneratorClientTitle = ({\n outputClient = DEFAULT_CLIENT,\n title,\n customTitleFunc,\n output,\n}) => {\n const { title: generatorTitle } = getGeneratorClient(outputClient, output);\n\n if (!generatorTitle) {\n return {\n implementation: '',\n implementationMock: `get${pascal(title)}Mock`,\n };\n }\n\n if (customTitleFunc) {\n const customTitle = customTitleFunc(title);\n return {\n implementation: generatorTitle(customTitle),\n implementationMock: `get${pascal(customTitle)}Mock`,\n };\n }\n return {\n implementation: generatorTitle(title),\n implementationMock: `get${pascal(title)}Mock`,\n };\n};\n\nconst generateMock = (\n verbOption: GeneratorVerbOptions,\n options: GeneratorOptions,\n): ClientMockGeneratorBuilder => {\n if (!options.mock) {\n return {\n implementation: {\n function: '',\n handler: '',\n handlerName: '',\n },\n imports: [],\n };\n }\n\n if (isFunction(options.mock)) {\n return options.mock(verbOption, options);\n }\n\n return mock.generateMock(\n verbOption,\n options as typeof options & {\n mock: Exclude<(typeof options)['mock'], ClientMockBuilder | undefined>;\n },\n );\n};\n\nexport const generateOperations = (\n outputClient: OutputClient | OutputClientFunc = DEFAULT_CLIENT,\n verbsOptions: GeneratorVerbsOptions,\n options: GeneratorOptions,\n output: NormalizedOutputOptions,\n): Promise<GeneratorOperations> => {\n const baseUrlImports = getBaseUrlRuntimeImports(output.baseUrl);\n\n return asyncReduce(\n verbsOptions,\n async (acc, verbOption) => {\n const { client: generatorClient } = getGeneratorClient(\n outputClient,\n output,\n );\n const client = await generatorClient(\n verbOption,\n options,\n outputClient,\n output,\n );\n\n if (!client.implementation) {\n return acc;\n }\n\n const generatedMock = generateMock(verbOption, options);\n\n const hasImplementation = client.implementation.trim().length > 0;\n const preferredOperationKey = verbOption.operationName;\n const baseOperationKey = verbOption.operationId\n ? `${verbOption.operationId}::${verbOption.operationName}`\n : verbOption.operationName;\n let operationKey = Object.hasOwn(acc, preferredOperationKey)\n ? baseOperationKey\n : preferredOperationKey;\n let collisionIndex = 1;\n\n while (Object.hasOwn(acc, operationKey)) {\n collisionIndex += 1;\n operationKey = `${baseOperationKey}::${collisionIndex}`;\n }\n\n acc[operationKey] = {\n implementation: hasImplementation\n ? (client.docComment ?? verbOption.doc) + client.implementation\n : client.implementation,\n imports: [...baseUrlImports, ...client.imports],\n implementationMock: generatedMock.implementation,\n importsMock: generatedMock.imports,\n tags: verbOption.tags,\n mutator: verbOption.mutator,\n clientMutators: client.mutators,\n formData: verbOption.formData,\n formUrlEncoded: verbOption.formUrlEncoded,\n paramsSerializer: verbOption.paramsSerializer,\n paramsFilter: verbOption.paramsFilter,\n operationName: verbOption.operationName,\n fetchReviver: verbOption.fetchReviver,\n };\n\n return acc;\n },\n {} as GeneratorOperations,\n );\n};\n\nexport const generateExtraFiles = (\n outputClient: OutputClient | OutputClientFunc = DEFAULT_CLIENT,\n verbsOptions: Record<string, GeneratorVerbOptions>,\n output: NormalizedOutputOptions,\n context: ContextSpec,\n): Promise<ClientFileBuilder[]> => {\n const { extraFiles: generateExtraFiles } = getGeneratorClient(\n outputClient,\n output,\n );\n\n if (!generateExtraFiles) {\n return Promise.resolve([]);\n }\n\n return generateExtraFiles(verbsOptions, output, context);\n};\n","import {\n asyncReduce,\n type ContextSpec,\n generateVerbsOptions,\n type GeneratorApiBuilder,\n type GeneratorApiOperations,\n type GeneratorSchema,\n getFullRoute,\n getRoute,\n GetterPropType,\n isReference,\n type NormalizedInputOptions,\n type NormalizedOutputOptions,\n type OpenApiPathItemObject,\n resolveRef,\n} from '@orval/core';\nimport { generateMockImports } from '@orval/mock';\n\nimport {\n generateClientFooter,\n generateClientHeader,\n generateClientImports,\n generateClientTitle,\n generateExtraFiles,\n generateOperations,\n} from './client';\n\nexport async function getApiBuilder({\n input,\n output,\n context,\n}: {\n input: NormalizedInputOptions;\n output: NormalizedOutputOptions;\n context: ContextSpec;\n}): Promise<GeneratorApiBuilder> {\n const api = await asyncReduce(\n Object.entries(context.spec.paths ?? {}),\n async (acc, [pathRoute, verbs]) => {\n if (!verbs) {\n return acc;\n }\n\n const route = getRoute(pathRoute);\n\n let resolvedVerbs: OpenApiPathItemObject = verbs;\n\n if (isReference(verbs)) {\n const { schema }: { schema: OpenApiPathItemObject } = resolveRef(\n verbs,\n context,\n );\n\n resolvedVerbs = schema;\n }\n\n let verbsOptions = await generateVerbsOptions({\n verbs: resolvedVerbs,\n input,\n output,\n route,\n pathRoute,\n context,\n });\n\n // GitHub #564 check if we want to exclude deprecated operations\n if (output.override.useDeprecatedOperations === false) {\n verbsOptions = verbsOptions.filter((verb) => {\n return !verb.deprecated;\n });\n }\n\n const schemas: GeneratorSchema[] = [];\n for (const {\n queryParams,\n headers,\n body,\n response,\n props,\n } of verbsOptions) {\n schemas.push(\n ...props.flatMap((param) =>\n param.type === GetterPropType.NAMED_PATH_PARAMS ? param.schema : [],\n ),\n );\n if (queryParams) {\n schemas.push(queryParams.schema, ...queryParams.deps);\n }\n if (headers) {\n schemas.push(headers.schema, ...headers.deps);\n }\n\n schemas.push(...body.schemas, ...response.schemas);\n }\n\n const fullRoute = getFullRoute(\n route,\n resolvedVerbs.servers ?? context.spec.servers,\n output.baseUrl,\n );\n if (!output.target) {\n throw new Error('Output does not have a target');\n }\n const pathOperations = await generateOperations(\n output.client,\n verbsOptions,\n {\n route: fullRoute,\n pathRoute,\n override: output.override,\n context,\n mock: output.mock,\n output: output.target,\n },\n output,\n );\n\n for (const verbOption of verbsOptions) {\n acc.verbOptions[verbOption.operationId] = verbOption;\n }\n acc.schemas.push(...schemas);\n acc.operations = { ...acc.operations, ...pathOperations };\n\n return acc;\n },\n {\n operations: {},\n verbOptions: {},\n schemas: [],\n } as GeneratorApiOperations,\n );\n\n const extraFiles = await generateExtraFiles(\n output.client,\n api.verbOptions,\n output,\n context,\n );\n\n return {\n operations: api.operations,\n schemas: api.schemas,\n verbOptions: api.verbOptions,\n title: generateClientTitle,\n header: generateClientHeader,\n footer: generateClientFooter,\n imports: generateClientImports,\n importsMock: generateMockImports,\n extraFiles,\n };\n}\n","import {\n collectReferencedComponents,\n type ContextSpec,\n generateComponentDefinition,\n generateParameterDefinition,\n generateSchemasDefinition,\n type ImportOpenApi,\n type InputOptions,\n type NormalizedOutputOptions,\n type OpenApiComponentsObject,\n type OpenApiDocument,\n type WriteSpecBuilder,\n} from '@orval/core';\nimport { pick } from 'remeda';\n\nimport { getApiBuilder } from './api';\n\nfunction filterSpecComponents(\n spec: OpenApiDocument,\n input: InputOptions,\n): OpenApiDocument {\n const filters = input.filters;\n if (!filters?.tags || filters.schemas) return spec;\n\n const referenced = collectReferencedComponents(\n spec,\n filters.tags,\n filters.mode,\n );\n\n return {\n ...spec,\n components: {\n ...spec.components,\n schemas: pick(spec.components?.schemas ?? {}, referenced.schemas),\n responses: pick(spec.components?.responses ?? {}, referenced.responses),\n parameters: pick(\n spec.components?.parameters ?? {},\n referenced.parameters,\n ),\n requestBodies: pick(\n spec.components?.requestBodies ?? {},\n referenced.requestBodies,\n ),\n },\n };\n}\n\nexport async function importOpenApi({\n spec,\n input,\n output,\n target,\n workspace,\n projectName,\n}: ImportOpenApi): Promise<WriteSpecBuilder> {\n // The transformer has already been applied (pre-validation) in `resolveSpec`.\n const filteredSpec = filterSpecComponents(spec, input);\n\n const schemas = getApiSchemas({\n input,\n output,\n target,\n workspace,\n spec: filteredSpec,\n });\n\n const api = await getApiBuilder({\n input,\n output,\n context: {\n projectName,\n target,\n workspace,\n spec: filteredSpec,\n output,\n } satisfies ContextSpec,\n });\n\n return {\n ...api,\n schemas: [...schemas, ...api.schemas],\n target,\n // a valid spec will have info\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n info: filteredSpec.info!,\n spec: filteredSpec,\n };\n}\n\ninterface GetApiSchemasOptions {\n input: InputOptions;\n output: NormalizedOutputOptions;\n workspace: string;\n target: string;\n spec: OpenApiDocument;\n}\n\nfunction getApiSchemas({\n input,\n output,\n target,\n workspace,\n spec,\n}: GetApiSchemasOptions) {\n const context: ContextSpec = {\n target,\n workspace,\n spec,\n output,\n };\n\n const schemaDefinition = generateSchemasDefinition(\n spec.components?.schemas,\n context,\n output.override.components.schemas.suffix,\n input.filters,\n );\n\n const responseDefinition = generateComponentDefinition(\n spec.components?.responses,\n context,\n output.override.components.responses.suffix,\n );\n\n const swaggerResponseDefinition = generateComponentDefinition(\n 'responses' in spec\n ? (spec as { responses?: OpenApiComponentsObject['responses'] }).responses\n : undefined,\n context,\n '',\n );\n\n const bodyDefinition = generateComponentDefinition(\n spec.components?.requestBodies,\n context,\n output.override.components.requestBodies.suffix,\n );\n\n const parameters = generateParameterDefinition(\n spec.components?.parameters,\n context,\n output.override.components.parameters.suffix,\n );\n\n const schemas = [\n ...schemaDefinition,\n ...responseDefinition,\n ...swaggerResponseDefinition,\n ...bodyDefinition,\n ...parameters,\n ];\n\n return schemas;\n}\n","import {\n dynamicImport,\n isObject,\n isString,\n logWarning,\n type NormalizedOptions,\n type OpenApiDocument,\n type OverrideInput,\n type WriteSpecBuilder,\n} from '@orval/core';\nimport { bundle } from '@scalar/json-magic/bundle';\nimport {\n fetchUrls,\n parseJson,\n parseYaml,\n readFiles,\n} from '@scalar/json-magic/bundle/plugins/node';\nimport { upgrade, validate as validateSpec } from '@scalar/openapi-parser';\nimport { isNullish } from 'remeda';\n\nimport { importOpenApi } from './import-open-api';\n\ninterface ResolveSpecOptions {\n parserOptions?: {\n headers?: {\n domains: string[];\n headers: Record<string, string>;\n }[];\n };\n transformer?: OverrideInput['transformer'];\n workspace: string;\n unsafeDisableValidation?: boolean;\n}\n\nasync function resolveSpec(\n input: string | Record<string, unknown>,\n {\n parserOptions,\n transformer,\n workspace,\n unsafeDisableValidation = false,\n }: ResolveSpecOptions,\n): Promise<OpenApiDocument> {\n const data = await bundle(input, {\n plugins: [\n readFiles(),\n fetchUrls({\n headers: parserOptions?.headers,\n }),\n parseJson(),\n parseYaml(),\n ],\n treeShake: false,\n });\n const dereferencedData = dereferenceExternalRef(\n data as Record<string, unknown>,\n );\n\n // Apply user-provided transformer before validation so users can repair\n // malformed specs in-place. The transformer is typed against\n // `OpenApiDocument`, but we pass the raw bundled object — repairing a spec\n // necessarily means it does not yet conform to the type at call time.\n const transformedData = transformer\n ? await applyInputTransformer(dereferencedData, transformer, workspace)\n : dereferencedData;\n\n if (unsafeDisableValidation) {\n logWarning(\n `🚨 OpenAPI spec validation is disabled.\\n` +\n ` Code generation with invalid specs is not guaranteed to work and may break in minor updates.\\n` +\n ` Bug reports with validation disabled will not be accepted.`,\n );\n } else {\n validateComponentKeys(transformedData);\n\n const { valid, errors } = await validateSpec(transformedData);\n if (!valid) {\n throw new Error(\n `OpenAPI spec validation failed:\\n${JSON.stringify(errors, undefined, 2)}`,\n );\n }\n }\n\n const { specification } = upgrade(transformedData);\n\n return specification;\n}\n\nasync function applyInputTransformer(\n data: Record<string, unknown>,\n transformer: NonNullable<OverrideInput['transformer']>,\n workspace: string,\n): Promise<Record<string, unknown>> {\n const transformerFn = await dynamicImport(transformer, workspace);\n const result: unknown = await transformerFn(\n data as unknown as OpenApiDocument,\n );\n if (!isObject(result)) {\n const source = isString(transformer)\n ? transformer\n : transformerFn.name || '<inline function>';\n throw new Error(\n `input.override.transformer must return an OpenAPI document object; ` +\n `got ${result === undefined ? 'undefined' : typeof result} from ${source}. ` +\n `Ensure your transformer returns the (possibly modified) spec.`,\n );\n }\n return result;\n}\n\nexport async function importSpecs(\n workspace: string,\n options: NormalizedOptions,\n projectName?: string,\n): Promise<WriteSpecBuilder> {\n const { input, output } = options;\n\n const spec = await resolveSpec(input.target, {\n parserOptions: input.parserOptions,\n transformer: input.override.transformer,\n workspace,\n unsafeDisableValidation: input.unsafeDisableValidation,\n });\n\n return importOpenApi({\n spec,\n input,\n output,\n target: isString(input.target) ? input.target : workspace,\n workspace,\n projectName,\n });\n}\n\nconst COMPONENT_KEY_PATTERN = /^[a-zA-Z0-9.\\-_]+$/;\n\nconst COMPONENT_SECTIONS = [\n 'schemas',\n 'responses',\n 'parameters',\n 'examples',\n 'requestBodies',\n 'headers',\n 'securitySchemes',\n 'links',\n 'callbacks',\n 'pathItems', // OAS 3.1.0+\n] as const;\n\n/**\n * Validate that all component keys conform to the OAS regex: ^[a-zA-Z0-9.\\-_]+$\n * @see https://spec.openapis.org/oas/v3.0.3.html#fixed-fields-5\n * @see https://spec.openapis.org/oas/v3.1.0#fixed-fields-5\n */\nexport function validateComponentKeys(data: Record<string, unknown>): void {\n const components = data.components;\n if (!isObject(components)) return;\n\n const invalidKeys: string[] = [];\n\n for (const section of COMPONENT_SECTIONS) {\n const sectionObj = components[section];\n if (!isObject(sectionObj)) continue;\n\n for (const key of Object.keys(sectionObj)) {\n if (!COMPONENT_KEY_PATTERN.test(key)) {\n invalidKeys.push(`components.${section}.${key}`);\n }\n }\n }\n\n if (invalidKeys.length > 0) {\n throw new Error(\n `Invalid component key${invalidKeys.length > 1 ? 's' : ''} found. ` +\n `OpenAPI component keys must match the pattern ${COMPONENT_KEY_PATTERN} ` +\n `(non-ASCII characters are not allowed per the spec).\\n` +\n ` See: https://spec.openapis.org/oas/v3.0.3.html#components-object\\n` +\n ` Invalid keys:\\n` +\n invalidKeys.map((k) => ` - ${k}`).join('\\n'),\n );\n }\n}\n\n/**\n * The plugins from `@scalar/json-magic` does not dereference $ref.\n * Instead it fetches them and puts them under x-ext, and changes the $ref to point to #x-ext/<name>.\n * This function:\n * 1. Merges external schemas into main spec's components.schemas (with collision handling)\n * 2. Replaces x-ext refs with standard component refs or inlined content\n */\nexport function dereferenceExternalRef(\n data: Record<string, unknown>,\n): Record<string, unknown> {\n const extensions = (data['x-ext'] ?? {}) as Record<string, unknown>;\n\n // Step 1: Merge external schemas into main spec with collision handling\n const schemaNameMappings = mergeExternalSchemas(data, extensions);\n\n // Step 2: Replace all x-ext refs throughout the document\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(data)) {\n if (key !== 'x-ext') {\n result[key] = replaceXExtRefs(value, extensions, schemaNameMappings);\n }\n }\n\n return result;\n}\n\n/**\n * Merge external document schemas into main spec's components.schemas\n * Returns mapping of original schema names to final names (with suffixes for collisions)\n */\nfunction mergeExternalSchemas(\n data: Record<string, unknown>,\n extensions: Record<string, unknown>,\n): Record<string, Record<string, string>> {\n const schemaNameMappings: Record<string, Record<string, string>> = {};\n\n if (Object.keys(extensions).length === 0) return schemaNameMappings;\n\n data.components ??= {};\n const mainComponents = data.components as Record<string, unknown>;\n mainComponents.schemas ??= {};\n const mainSchemas = mainComponents.schemas as Record<string, unknown>;\n\n // Merge schemas from each external doc\n // Collision handling:\n // - If schema already exists in main spec, add x-ext key as suffix (e.g., User -> User_external1)\n // - x-ext refs in main spec get replaced by actual schema from external doc\n for (const [extKey, extDoc] of Object.entries(extensions)) {\n schemaNameMappings[extKey] = {};\n\n if (isObject(extDoc) && 'components' in extDoc) {\n const extComponents = extDoc.components as Record<string, unknown>;\n if (isObject(extComponents) && 'schemas' in extComponents) {\n const extSchemas = extComponents.schemas as Record<string, unknown>;\n for (const [schemaName, schema] of Object.entries(extSchemas)) {\n // Check if main schema is just an x-ext ref - if so, replace it without suffix\n const existingSchema = mainSchemas[schemaName];\n const isXExtRef =\n isObject(existingSchema) &&\n '$ref' in existingSchema &&\n isString(existingSchema.$ref) &&\n existingSchema.$ref.startsWith('#/x-ext/');\n\n let finalSchemaName = schemaName;\n\n if (schemaName in mainSchemas && !isXExtRef) {\n // Collision: add suffix to external schema\n const suffix = extKey.replaceAll(/[^a-zA-Z0-9]/g, '_');\n finalSchemaName = `${schemaName}_${suffix}`;\n schemaNameMappings[extKey][schemaName] = finalSchemaName;\n } else {\n // No collision or replacing x-ext ref\n schemaNameMappings[extKey][schemaName] = schemaName;\n }\n\n mainSchemas[finalSchemaName] = scrubUnwantedKeys(schema);\n }\n }\n }\n }\n\n // Apply internal ref updates to all schemas from external docs\n for (const [extKey, mapping] of Object.entries(schemaNameMappings)) {\n for (const [, finalName] of Object.entries(mapping)) {\n const schema = mainSchemas[finalName];\n if (schema) {\n mainSchemas[finalName] = updateInternalRefs(\n schema,\n extKey,\n schemaNameMappings,\n ) as Record<string, unknown>;\n }\n }\n }\n\n return schemaNameMappings;\n}\n\n/**\n * Remove unwanted keys like $schema and $id from objects\n */\nfunction scrubUnwantedKeys(obj: unknown): unknown {\n const UNWANTED_KEYS = new Set(['$schema', '$id']);\n\n if (obj === null || obj === undefined) return obj;\n if (Array.isArray(obj)) return obj.map((x) => scrubUnwantedKeys(x));\n if (isObject(obj)) {\n const rec = obj;\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(rec)) {\n if (UNWANTED_KEYS.has(k)) continue;\n out[k] = scrubUnwantedKeys(v);\n }\n return out;\n }\n return obj;\n}\n\n/**\n * Update internal refs within an external schema to use suffixed names\n */\nfunction updateInternalRefs(\n obj: unknown,\n extKey: string,\n schemaNameMappings: Record<string, Record<string, string>>,\n): unknown {\n if (obj === null || obj === undefined) return obj;\n\n if (Array.isArray(obj)) {\n return obj.map((element) =>\n updateInternalRefs(element, extKey, schemaNameMappings),\n );\n }\n\n if (isObject(obj)) {\n const record = obj;\n\n // Check if this is a $ref to #/components/schemas/...\n if ('$ref' in record && isString(record.$ref)) {\n const refValue = record.$ref;\n if (refValue.startsWith('#/components/schemas/')) {\n const schemaName = refValue.replace('#/components/schemas/', '');\n // If this schema was mapped to a suffixed name, update the ref\n const mappedName = schemaNameMappings[extKey][schemaName];\n if (mappedName) {\n return {\n $ref: `#/components/schemas/${mappedName}`,\n };\n }\n }\n }\n\n // Recursively process all properties\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(record)) {\n result[key] = updateInternalRefs(value, extKey, schemaNameMappings);\n }\n return result;\n }\n\n return obj;\n}\n\n/**\n * Replace x-ext refs with standard component refs, or inline the content.\n * `inliningRefs` tracks the inline chain to break cycles in recursive\n * external schemas that aren't under `components.schemas` (#1642).\n */\nfunction replaceXExtRefs(\n obj: unknown,\n extensions: Record<string, unknown>,\n schemaNameMappings: Record<string, Record<string, string>>,\n inliningRefs = new Set<string>(),\n): unknown {\n if (isNullish(obj)) return obj;\n\n if (Array.isArray(obj)) {\n return obj.map((element) =>\n replaceXExtRefs(element, extensions, schemaNameMappings, inliningRefs),\n );\n }\n\n if (isObject(obj)) {\n const record = obj;\n\n // Check if this object is a $ref to x-ext\n if ('$ref' in record && isString(record.$ref)) {\n const refValue = record.$ref;\n if (refValue.startsWith('#/x-ext/')) {\n // Parse the x-ext ref\n const pathStr = refValue.replace('#/x-ext/', '');\n const parts = pathStr.split('/');\n const extKey = parts.shift();\n\n if (extKey) {\n // Check if this is a ref to components/schemas - if so, replace with standard ref\n if (\n parts.length >= 3 &&\n parts[0] === 'components' &&\n parts[1] === 'schemas'\n ) {\n const schemaName = parts.slice(2).join('/');\n // Use the mapped name (which may include suffix for collisions)\n const finalName =\n schemaNameMappings[extKey][schemaName] || schemaName;\n return { $ref: `#/components/schemas/${finalName}` };\n }\n\n // Otherwise inline the content; break cycles with `{}`.\n if (inliningRefs.has(refValue)) {\n logWarning(\n `Detected a circular external $ref while inlining \"${refValue}\". ` +\n `Replacing with an empty schema to avoid infinite recursion. ` +\n `Move the schema under \"components.schemas\" in its source file ` +\n `or pre-bundle the spec to keep the recursion intact.`,\n );\n return {};\n }\n\n const extDoc = extensions[extKey];\n let refObj: unknown = extDoc;\n for (const p of parts) {\n if (\n refObj &&\n (isObject(refObj) || Array.isArray(refObj)) &&\n p in (refObj as Record<string, unknown>)\n ) {\n refObj = (refObj as Record<string, unknown>)[p];\n } else {\n refObj = undefined;\n break;\n }\n }\n\n if (refObj) {\n const cleaned = scrubUnwantedKeys(refObj);\n const nextInlining = new Set(inliningRefs);\n nextInlining.add(refValue);\n return replaceXExtRefs(\n cleaned,\n extensions,\n schemaNameMappings,\n nextInlining,\n );\n }\n }\n }\n }\n\n // Recursively process all properties\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(record)) {\n result[key] = replaceXExtRefs(\n value,\n extensions,\n schemaNameMappings,\n inliningRefs,\n );\n }\n return result;\n }\n\n return obj;\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { logWarning } from '@orval/core';\nimport { execa } from 'execa';\n\n/**\n * Format files with prettier.\n * Tries the programmatic API first (project dependency),\n * then falls back to the globally installed CLI.\n */\nexport async function formatWithPrettier(\n paths: string[],\n projectTitle?: string,\n): Promise<void> {\n const prettier = await tryImportPrettier();\n\n if (prettier) {\n const filePaths = [...new Set(await collectFilePaths(paths))];\n if (filePaths.length === 0) {\n return;\n }\n\n const config = (await prettier.resolveConfig(filePaths[0])) ?? {};\n await Promise.all(\n filePaths.map(async (filePath) => {\n try {\n const content = await fs.readFile(filePath, 'utf8');\n const formatted = await prettier.format(content, {\n ...config,\n // options.filepath can be specified for Prettier to infer the parser from the file extension\n filepath: filePath,\n });\n await fs.writeFile(filePath, formatted);\n } catch (error) {\n if (isMissingFileError(error)) {\n return;\n }\n\n if (error instanceof Error) {\n // prettier currently doesn't export UndefinedParserError, so having to do it the crude way\n if (error.name === 'UndefinedParserError') {\n // skip files with unsupported parsers\n // https://prettier.io/docs/options#parser\n } else {\n logWarning(\n `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}Failed to format file ${filePath}: ${error.toString()}`,\n );\n }\n } else {\n logWarning(\n `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}Failed to format file ${filePath}: unknown error`,\n );\n }\n }\n }),\n );\n\n return;\n }\n\n // fallback to globally installed prettier\n try {\n await execa('prettier', ['--write', ...paths]);\n } catch {\n logWarning(\n `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}prettier not found. Install it as a project dependency or globally.`,\n );\n }\n}\n\nfunction isMissingFileError(error: unknown): error is NodeJS.ErrnoException {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'code' in error &&\n error.code === 'ENOENT'\n );\n}\n\n/**\n * Try to import prettier from the project's dependencies.\n * Returns undefined if prettier is not installed.\n */\nasync function tryImportPrettier() {\n try {\n return await import('prettier');\n } catch {\n return;\n }\n}\n\n/**\n * Recursively collect absolute file paths from a mix of files and directories.\n */\nasync function collectFilePaths(paths: string[]): Promise<string[]> {\n const results: string[] = [];\n\n for (const p of paths) {\n const absolute = path.resolve(p);\n try {\n const stat = await fs.stat(absolute);\n if (stat.isFile()) {\n results.push(absolute);\n } else if (stat.isDirectory()) {\n const entries = await fs.readdir(absolute);\n const subPaths = entries.map((entry) => path.join(absolute, entry));\n const subFiles = await collectFilePaths(subPaths);\n results.push(...subFiles);\n }\n } catch {\n // Skip paths that don't exist or can't be accessed\n }\n }\n\n return results;\n}\n","import { styleText } from 'node:util';\n\nimport {\n type Hook,\n type HookOption,\n isFunction,\n isObject,\n isString,\n log,\n logError,\n type NormalizedHookCommand,\n} from '@orval/core';\nimport { execa } from 'execa';\nimport { parseArgsStringToArgv } from 'string-argv';\n\nexport const executeHook = async (\n name: Hook,\n commands: NormalizedHookCommand = [],\n args: string[] = [],\n) => {\n log(styleText('white', `Running ${name} hook...`));\n\n for (const command of commands) {\n try {\n if (isString(command)) {\n await executeCommand(command, args);\n } else if (isFunction(command)) {\n await command(args);\n } else if (isObject(command)) {\n await executeObjectCommand(command as HookOption, args);\n }\n } catch (error) {\n logError(error, `Failed to run ${name} hook`);\n }\n }\n};\n\nasync function executeCommand(command: string, args: string[]) {\n const [cmd, ..._args] = [...parseArgsStringToArgv(command), ...args];\n\n await execa(cmd, _args);\n}\n\nasync function executeObjectCommand(command: HookOption, args: string[]) {\n if (command.injectGeneratedDirsAndFiles === false) {\n args = [];\n }\n\n if (isString(command.command)) {\n await executeCommand(command.command, args);\n } else if (isFunction(command.command)) {\n await command.command();\n }\n}\n","import { styleText } from 'node:util';\n\nimport {\n dynamicImport,\n isObject,\n isString,\n logVerbose,\n logWarning,\n type PackageJson,\n resolveInstalledVersions,\n} from '@orval/core';\nimport { findUp, findUpMultiple } from 'find-up';\nimport fs from 'fs-extra';\nimport yaml from 'js-yaml';\n\nimport { normalizePath } from './options';\n\ntype CatalogData = Pick<PackageJson, 'catalog' | 'catalogs'>;\n\nexport const loadPackageJson = async (\n packageJson?: string,\n workspace = process.cwd(),\n): Promise<PackageJson | undefined> => {\n if (!packageJson) {\n const pkgPath = await findUp(['package.json'], { cwd: workspace });\n if (pkgPath) {\n const pkg = await dynamicImport<unknown>(pkgPath, workspace);\n\n if (isPackageJson(pkg)) {\n return resolveAndAttachVersions(\n await maybeReplaceCatalog(pkg, workspace),\n workspace,\n pkgPath,\n );\n } else {\n throw new Error('Invalid package.json file');\n }\n }\n return;\n }\n\n const normalizedPath = normalizePath(packageJson, workspace);\n if (fs.existsSync(normalizedPath)) {\n const pkg = await dynamicImport<unknown>(normalizedPath);\n\n if (isPackageJson(pkg)) {\n return resolveAndAttachVersions(\n await maybeReplaceCatalog(pkg, workspace),\n workspace,\n normalizedPath,\n );\n } else {\n throw new Error(`Invalid package.json file: ${normalizedPath}`);\n }\n }\n return;\n};\n\nconst isPackageJson = (obj: unknown): obj is PackageJson => isObject(obj);\n\nconst resolvedCache = new Map<string, Record<string, string>>();\n\n/** @internal visible for testing */\nexport const _resetResolvedCache = () => {\n resolvedCache.clear();\n};\n\nconst resolveAndAttachVersions = (\n pkg: PackageJson,\n workspace: string,\n cacheKey: string,\n): PackageJson => {\n const cached = resolvedCache.get(cacheKey);\n if (cached) {\n pkg.resolvedVersions = cached;\n return pkg;\n }\n\n const resolved = resolveInstalledVersions(pkg, workspace);\n if (Object.keys(resolved).length > 0) {\n pkg.resolvedVersions = resolved;\n resolvedCache.set(cacheKey, resolved);\n for (const [name, version] of Object.entries(resolved)) {\n logVerbose(\n styleText(\n 'dim',\n `Detected ${styleText('white', name)} v${styleText('white', version)}`,\n ),\n );\n }\n }\n return pkg;\n};\n\nconst hasCatalogReferences = (pkg: PackageJson): boolean => {\n return [\n ...Object.entries(pkg.dependencies ?? {}),\n ...Object.entries(pkg.devDependencies ?? {}),\n ...Object.entries(pkg.peerDependencies ?? {}),\n ].some(([, value]) => isString(value) && value.startsWith('catalog:'));\n};\n\nconst loadPnpmWorkspaceCatalog = async (\n workspace: string,\n): Promise<CatalogData | undefined> => {\n const filePath = await findUp('pnpm-workspace.yaml', { cwd: workspace });\n if (!filePath) return undefined;\n try {\n const file = await fs.readFile(filePath, 'utf8');\n const data = yaml.load(file) as Record<string, unknown> | undefined;\n if (!data?.catalog && !data?.catalogs) return undefined;\n return {\n catalog: data.catalog as CatalogData['catalog'],\n catalogs: data.catalogs as CatalogData['catalogs'],\n };\n } catch {\n return undefined;\n }\n};\n\nconst loadPackageJsonCatalog = async (\n workspace: string,\n): Promise<CatalogData | undefined> => {\n const filePaths = await findUpMultiple('package.json', { cwd: workspace });\n\n for (const filePath of filePaths) {\n try {\n const pkg = (await fs.readJson(filePath)) as Record<string, unknown>;\n if (pkg.catalog || pkg.catalogs) {\n return {\n catalog: pkg.catalog as CatalogData['catalog'],\n catalogs: pkg.catalogs as CatalogData['catalogs'],\n };\n }\n } catch {\n // Continue to next file\n }\n }\n return undefined;\n};\n\nconst loadYarnrcCatalog = async (\n workspace: string,\n): Promise<CatalogData | undefined> => {\n const filePath = await findUp('.yarnrc.yml', { cwd: workspace });\n if (!filePath) return undefined;\n try {\n const file = await fs.readFile(filePath, 'utf8');\n const data = yaml.load(file) as Record<string, unknown> | undefined;\n if (!data?.catalog && !data?.catalogs) return undefined;\n return {\n catalog: data.catalog as CatalogData['catalog'],\n catalogs: data.catalogs as CatalogData['catalogs'],\n };\n } catch {\n return undefined;\n }\n};\n\nconst maybeReplaceCatalog = async (\n pkg: PackageJson,\n workspace: string,\n): Promise<PackageJson> => {\n if (!hasCatalogReferences(pkg)) {\n return pkg;\n }\n\n const catalogData =\n (await loadPnpmWorkspaceCatalog(workspace)) ??\n (await loadPackageJsonCatalog(workspace)) ??\n (await loadYarnrcCatalog(workspace));\n\n if (!catalogData) {\n logWarning(\n '⚠️ package.json contains catalog: references, but no catalog source was found (checked: pnpm-workspace.yaml, package.json, .yarnrc.yml).',\n );\n return pkg;\n }\n\n performSubstitution(pkg.dependencies, catalogData);\n performSubstitution(pkg.devDependencies, catalogData);\n performSubstitution(pkg.peerDependencies, catalogData);\n\n return pkg;\n};\n\nconst performSubstitution = (\n dependencies: Record<string, string> | undefined,\n catalogData: CatalogData,\n) => {\n if (!dependencies) return;\n for (const [packageName, version] of Object.entries(dependencies)) {\n if (version === 'catalog:' || version === 'catalog:default') {\n if (!catalogData.catalog) {\n logWarning(\n `⚠️ catalog: substitution for the package '${packageName}' failed as there is no default catalog.`,\n );\n continue;\n }\n const sub = catalogData.catalog[packageName];\n if (!sub) {\n logWarning(\n `⚠️ catalog: substitution for the package '${packageName}' failed as there is no matching package in the default catalog.`,\n );\n continue;\n }\n dependencies[packageName] = sub;\n } else if (version.startsWith('catalog:')) {\n const catalogName = version.slice('catalog:'.length);\n const catalog = catalogData.catalogs?.[catalogName];\n if (!catalog) {\n logWarning(\n `⚠️ '${version}' substitution for the package '${packageName}' failed as there is no matching catalog named '${catalogName}'. (available named catalogs are: ${Object.keys(catalogData.catalogs ?? {}).join(', ')})`,\n );\n continue;\n }\n const sub = catalog[packageName];\n if (!sub) {\n logWarning(\n `⚠️ '${version}' substitution for the package '${packageName}' failed as there is no package in the catalog named '${catalogName}'. (packages in the catalog are: ${Object.keys(catalog).join(', ')})`,\n );\n continue;\n }\n dependencies[packageName] = sub;\n }\n }\n};\n","import { isNullish, isObject, isString, type Tsconfig } from '@orval/core';\nimport { findUp } from 'find-up';\nimport fs from 'fs-extra';\nimport {\n parseTsconfig,\n type TsConfigJson,\n type TsConfigJsonResolved,\n} from 'get-tsconfig';\n\nimport { normalizePath } from './options';\n\ntype LowercaseString<T extends string> = T extends `${infer First}${infer Rest}`\n ? `${Lowercase<First>}${LowercaseString<Rest>}`\n : T;\n\nconst convertTarget = (config: TsConfigJsonResolved): Tsconfig => {\n if (!config.compilerOptions?.target) {\n return {\n baseUrl: config.compilerOptions?.baseUrl,\n ...config,\n } as Tsconfig;\n }\n const lowercaseTarget =\n config.compilerOptions.target.toLowerCase() as LowercaseString<TsConfigJson.CompilerOptions.Target>;\n return {\n baseUrl: config.compilerOptions.baseUrl,\n ...config,\n compilerOptions: { ...config.compilerOptions, target: lowercaseTarget },\n };\n};\n\nexport const loadTsconfig = async (\n tsconfig?: Tsconfig | string,\n workspace = process.cwd(),\n): Promise<Tsconfig | undefined> => {\n if (isNullish(tsconfig)) {\n const configPath = await findUp(['tsconfig.json', 'jsconfig.json'], {\n cwd: workspace,\n });\n if (configPath) {\n const config = parseTsconfig(configPath);\n return convertTarget(config);\n }\n return;\n }\n\n if (isString(tsconfig)) {\n const normalizedPath = normalizePath(tsconfig, workspace);\n if (fs.existsSync(normalizedPath)) {\n const config = parseTsconfig(normalizedPath);\n return convertTarget(config);\n }\n return;\n }\n\n if (isObject(tsconfig)) {\n return tsconfig;\n }\n return;\n};\n","import { access } from 'node:fs/promises';\nimport nodePath from 'node:path';\nimport { styleText } from 'node:util';\n\nimport {\n type ClientMockBuilder,\n type ConfigExternal,\n FormDataArrayHandling,\n type GlobalMockOptions,\n type GlobalOptions,\n type HonoOptions,\n type Hook,\n type HookFunction,\n type HookOption,\n type HooksOptions,\n type InputOptions,\n type InputTransformerFn,\n isBoolean,\n isFunction,\n isNullish,\n isObject,\n isString,\n isUrl,\n type JsDocOptions,\n logWarning,\n type McpOptions,\n type McpServerOptions,\n type Mutator,\n NamingConvention,\n type NormalizedHonoOptions,\n type NormalizedHookOptions,\n type NormalizedJsDocOptions,\n type NormalizedMcpOptions,\n type NormalizedMcpServerOptions,\n type NormalizedMutator,\n type NormalizedOperationOptions,\n type NormalizedOptions,\n type NormalizedOverrideOutput,\n type NormalizedQueryOptions,\n type NormalizedSchemaOptions,\n type OperationOptions,\n type OptionsExport,\n OutputClient,\n OutputHttpClient,\n OutputMode,\n type OverrideOutput,\n PropertySortOrder,\n type QueryOptions,\n RefComponentSuffix,\n type SchemaOptions,\n} from '@orval/core';\nimport { DEFAULT_MOCK_OPTIONS } from '@orval/mock';\n\nimport pkg from '../../package.json';\nimport { loadPackageJson } from './package-json';\nimport { loadTsconfig } from './tsconfig';\n\nconst INPUT_TARGET_FETCH_TIMEOUT_MS = 10_000;\n/**\n * Type helper to make it easier to use orval.config.ts\n * accepts a direct {@link ConfigExternal} object.\n */\nexport function defineConfig(options: ConfigExternal): ConfigExternal {\n return options;\n}\n\n/**\n * Type helper to make it easier to write input transformers.\n * accepts a direct {@link InputTransformerFn} function.\n */\nexport function defineTransformer(\n transformer: InputTransformerFn,\n): InputTransformerFn {\n return transformer;\n}\n\nfunction createFormData(\n workspace: string,\n formData: OverrideOutput['formData'],\n): NormalizedOverrideOutput['formData'] {\n const defaultArrayHandling = FormDataArrayHandling.SERIALIZE;\n if (formData === undefined)\n return { disabled: false, arrayHandling: defaultArrayHandling };\n if (isBoolean(formData))\n return { disabled: !formData, arrayHandling: defaultArrayHandling };\n if (isString(formData))\n return {\n disabled: false,\n mutator: normalizeMutator(workspace, formData),\n arrayHandling: defaultArrayHandling,\n };\n if ('mutator' in formData || 'arrayHandling' in formData)\n return {\n disabled: false,\n mutator: normalizeMutator(workspace, formData.mutator),\n arrayHandling: formData.arrayHandling ?? defaultArrayHandling,\n };\n return {\n disabled: false,\n mutator: normalizeMutator(workspace, formData),\n arrayHandling: defaultArrayHandling,\n };\n}\n\nfunction normalizeSchemasOption(\n schemas: string | SchemaOptions | false | undefined,\n workspace: string,\n): string | NormalizedSchemaOptions | undefined {\n if (!schemas) {\n return undefined;\n }\n\n if (isString(schemas)) {\n return normalizePath(schemas, workspace);\n }\n\n return {\n path: normalizePath(schemas.path, workspace),\n type: schemas.type,\n };\n}\n\nexport async function normalizeOptions(\n optionsExport: OptionsExport,\n workspace = process.cwd(),\n globalOptions: GlobalOptions = {},\n): Promise<NormalizedOptions> {\n const options = await (isFunction(optionsExport)\n ? optionsExport()\n : optionsExport);\n\n if (!options.input) {\n throw new Error(styleText('red', `Config requires an input.`));\n }\n\n if (!options.output) {\n throw new Error(styleText('red', `Config requires an output.`));\n }\n\n const inputOptions: InputOptions =\n isString(options.input) || Array.isArray(options.input)\n ? { target: options.input }\n : options.input;\n\n const outputOptions = isString(options.output)\n ? { target: options.output }\n : options.output;\n\n const outputWorkspace = normalizePath(\n outputOptions.workspace ?? '',\n workspace,\n );\n\n const { clean, client, httpClient, mode } = globalOptions;\n\n const tsconfig = await loadTsconfig(\n outputOptions.tsconfig ?? globalOptions.tsconfig,\n workspace,\n );\n\n const packageJson = await loadPackageJson(\n outputOptions.packageJson ?? globalOptions.packageJson,\n workspace,\n );\n\n const mockOption = outputOptions.mock ?? globalOptions.mock;\n let mock: GlobalMockOptions | ClientMockBuilder | undefined;\n if (isBoolean(mockOption) && mockOption) {\n mock = DEFAULT_MOCK_OPTIONS;\n } else if (isFunction(mockOption)) {\n mock = mockOption;\n } else if (mockOption) {\n mock = {\n ...DEFAULT_MOCK_OPTIONS,\n ...mockOption,\n };\n } else {\n mock = undefined;\n }\n\n const defaultFileExtension = '.ts';\n\n // `useQuery` / `useMutation` defaults are applied per-verb in\n // `query-generator.ts` so we can tell \"unset\" from \"explicit true\" (#2376).\n const globalQueryOptions: NormalizedQueryOptions = {\n signal: true,\n shouldExportMutatorHooks: true,\n shouldExportHttpClient: true,\n shouldExportQueryKey: true,\n shouldSplitQueryKey: false,\n ...normalizeQueryOptions(outputOptions.override?.query, workspace),\n };\n\n const normalizedOptions: NormalizedOptions = {\n input: {\n target: globalOptions.input\n ? Array.isArray(globalOptions.input)\n ? await resolveFirstValidTarget(\n globalOptions.input,\n process.cwd(),\n inputOptions.parserOptions,\n )\n : normalizePathOrUrl(globalOptions.input, process.cwd())\n : Array.isArray(inputOptions.target)\n ? await resolveFirstValidTarget(\n inputOptions.target,\n workspace,\n inputOptions.parserOptions,\n )\n : normalizePathOrUrl(inputOptions.target, workspace),\n override: {\n transformer: normalizePath(\n inputOptions.override?.transformer,\n workspace,\n ),\n },\n unsafeDisableValidation: inputOptions.unsafeDisableValidation ?? false,\n filters: inputOptions.filters,\n parserOptions: inputOptions.parserOptions,\n },\n output: {\n target: globalOptions.output\n ? normalizePath(globalOptions.output, process.cwd())\n : normalizePath(outputOptions.target, outputWorkspace),\n schemas: normalizeSchemasOption(outputOptions.schemas, outputWorkspace),\n operationSchemas: outputOptions.operationSchemas\n ? normalizePath(outputOptions.operationSchemas, outputWorkspace)\n : undefined,\n namingConvention:\n outputOptions.namingConvention ?? NamingConvention.CAMEL_CASE,\n fileExtension: outputOptions.fileExtension ?? defaultFileExtension,\n workspace: outputOptions.workspace ? outputWorkspace : undefined,\n client: outputOptions.client ?? client ?? OutputClient.AXIOS_FUNCTIONS,\n httpClient:\n outputOptions.httpClient ??\n httpClient ??\n // Auto-detect: use Angular HttpClient for angular-query by default\n ((outputOptions.client ?? client) === OutputClient.ANGULAR_QUERY\n ? OutputHttpClient.ANGULAR\n : OutputHttpClient.FETCH),\n mode: normalizeOutputMode(outputOptions.mode ?? mode),\n mock,\n clean: outputOptions.clean ?? clean ?? false,\n docs: outputOptions.docs ?? false,\n formatter: outputOptions.formatter ?? globalOptions.formatter,\n tsconfig,\n packageJson,\n headers: outputOptions.headers ?? false,\n indexFiles: outputOptions.indexFiles ?? true,\n baseUrl: outputOptions.baseUrl,\n unionAddMissingProperties:\n outputOptions.unionAddMissingProperties ?? false,\n override: {\n ...outputOptions.override,\n mock: {\n arrayMin: outputOptions.override?.mock?.arrayMin ?? 1,\n arrayMax: outputOptions.override?.mock?.arrayMax ?? 10,\n stringMin: outputOptions.override?.mock?.stringMin ?? 10,\n stringMax: outputOptions.override?.mock?.stringMax ?? 20,\n fractionDigits: outputOptions.override?.mock?.fractionDigits ?? 2,\n ...outputOptions.override?.mock,\n },\n operations: normalizeOperationsAndTags(\n outputOptions.override?.operations ?? {},\n outputWorkspace,\n {\n query: globalQueryOptions,\n },\n ),\n tags: normalizeOperationsAndTags(\n outputOptions.override?.tags ?? {},\n outputWorkspace,\n {\n query: globalQueryOptions,\n },\n ),\n mutator: normalizeMutator(\n outputWorkspace,\n outputOptions.override?.mutator,\n ),\n formData: createFormData(\n outputWorkspace,\n outputOptions.override?.formData,\n ),\n formUrlEncoded:\n (isBoolean(outputOptions.override?.formUrlEncoded)\n ? outputOptions.override.formUrlEncoded\n : normalizeMutator(\n outputWorkspace,\n outputOptions.override?.formUrlEncoded,\n )) ?? true,\n paramsSerializer: normalizeMutator(\n outputWorkspace,\n outputOptions.override?.paramsSerializer,\n ),\n paramsFilter: normalizeMutator(\n outputWorkspace,\n outputOptions.override?.paramsFilter,\n ),\n header:\n outputOptions.override?.header === false\n ? false\n : isFunction(outputOptions.override?.header)\n ? outputOptions.override.header\n : getDefaultFilesHeader,\n requestOptions: outputOptions.override?.requestOptions ?? true,\n namingConvention: outputOptions.override?.namingConvention ?? {},\n components: {\n schemas: {\n suffix: RefComponentSuffix.schemas,\n itemSuffix:\n outputOptions.override?.components?.schemas?.itemSuffix ?? 'Item',\n ...outputOptions.override?.components?.schemas,\n },\n responses: {\n suffix: RefComponentSuffix.responses,\n ...outputOptions.override?.components?.responses,\n },\n parameters: {\n suffix: RefComponentSuffix.parameters,\n ...outputOptions.override?.components?.parameters,\n },\n requestBodies: {\n suffix: RefComponentSuffix.requestBodies,\n ...outputOptions.override?.components?.requestBodies,\n },\n },\n hono: normalizeHonoOptions(outputOptions.override?.hono, workspace),\n mcp: normalizeMcpOptions(outputOptions.override?.mcp, workspace),\n jsDoc: normalizeJSDocOptions(outputOptions.override?.jsDoc),\n query: globalQueryOptions,\n zod: {\n strict: {\n param: outputOptions.override?.zod?.strict?.param ?? false,\n query: outputOptions.override?.zod?.strict?.query ?? false,\n header: outputOptions.override?.zod?.strict?.header ?? false,\n body: outputOptions.override?.zod?.strict?.body ?? false,\n response: outputOptions.override?.zod?.strict?.response ?? false,\n },\n generate: {\n param: outputOptions.override?.zod?.generate?.param ?? true,\n query: outputOptions.override?.zod?.generate?.query ?? true,\n header: outputOptions.override?.zod?.generate?.header ?? true,\n body: outputOptions.override?.zod?.generate?.body ?? true,\n response: outputOptions.override?.zod?.generate?.response ?? true,\n },\n coerce: {\n param: outputOptions.override?.zod?.coerce?.param ?? false,\n query: outputOptions.override?.zod?.coerce?.query ?? false,\n header: outputOptions.override?.zod?.coerce?.header ?? false,\n body: outputOptions.override?.zod?.coerce?.body ?? false,\n response: outputOptions.override?.zod?.coerce?.response ?? false,\n },\n preprocess: {\n ...(outputOptions.override?.zod?.preprocess?.param\n ? {\n param: normalizeMutator(\n workspace,\n outputOptions.override.zod.preprocess.param,\n ),\n }\n : {}),\n ...(outputOptions.override?.zod?.preprocess?.query\n ? {\n query: normalizeMutator(\n workspace,\n outputOptions.override.zod.preprocess.query,\n ),\n }\n : {}),\n ...(outputOptions.override?.zod?.preprocess?.header\n ? {\n header: normalizeMutator(\n workspace,\n outputOptions.override.zod.preprocess.header,\n ),\n }\n : {}),\n ...(outputOptions.override?.zod?.preprocess?.body\n ? {\n body: normalizeMutator(\n workspace,\n outputOptions.override.zod.preprocess.body,\n ),\n }\n : {}),\n ...(outputOptions.override?.zod?.preprocess?.response\n ? {\n response: normalizeMutator(\n workspace,\n outputOptions.override.zod.preprocess.response,\n ),\n }\n : {}),\n },\n generateEachHttpStatus:\n outputOptions.override?.zod?.generateEachHttpStatus ?? false,\n useBrandedTypes:\n outputOptions.override?.zod?.useBrandedTypes ?? false,\n dateTimeOptions: outputOptions.override?.zod?.dateTimeOptions ?? {\n offset: true,\n },\n timeOptions: outputOptions.override?.zod?.timeOptions ?? {},\n },\n swr: {\n generateErrorTypes: false,\n ...outputOptions.override?.swr,\n },\n angular: {\n provideIn: outputOptions.override?.angular?.provideIn ?? 'root',\n client:\n outputOptions.override?.angular?.retrievalClient ??\n outputOptions.override?.angular?.client ??\n 'httpClient',\n runtimeValidation:\n outputOptions.override?.angular?.runtimeValidation ?? false,\n ...(outputOptions.override?.angular?.httpResource\n ? { httpResource: outputOptions.override.angular.httpResource }\n : {}),\n },\n fetch: {\n includeHttpResponseReturnType:\n outputOptions.override?.fetch?.includeHttpResponseReturnType ??\n true,\n forceSuccessResponse:\n outputOptions.override?.fetch?.forceSuccessResponse ?? false,\n runtimeValidation:\n outputOptions.override?.fetch?.runtimeValidation ?? false,\n useRuntimeFetcher:\n outputOptions.override?.fetch?.useRuntimeFetcher ?? false,\n ...outputOptions.override?.fetch,\n ...(outputOptions.override?.fetch?.jsonReviver\n ? {\n jsonReviver: normalizeMutator(\n outputWorkspace,\n outputOptions.override.fetch.jsonReviver,\n ),\n }\n : {}),\n },\n useDates: outputOptions.override?.useDates ?? false,\n useDeprecatedOperations:\n outputOptions.override?.useDeprecatedOperations ?? true,\n enumGenerationType:\n outputOptions.override?.enumGenerationType ?? 'const',\n suppressReadonlyModifier:\n outputOptions.override?.suppressReadonlyModifier ?? false,\n preserveReadonlyRequestBodies:\n outputOptions.override?.preserveReadonlyRequestBodies ?? 'strip',\n splitByContentType: outputOptions.override?.splitByContentType ?? false,\n aliasCombinedTypes: outputOptions.override?.aliasCombinedTypes ?? false,\n },\n allParamsOptional: outputOptions.allParamsOptional ?? false,\n urlEncodeParameters: outputOptions.urlEncodeParameters ?? false,\n optionsParamRequired: outputOptions.optionsParamRequired ?? false,\n propertySortOrder:\n outputOptions.propertySortOrder ?? PropertySortOrder.SPECIFICATION,\n },\n hooks: options.hooks ? normalizeHooks(options.hooks) : {},\n };\n\n if (!normalizedOptions.input.target) {\n throw new Error(styleText('red', `Config requires an input target.`));\n }\n\n if (!normalizedOptions.output.target && !normalizedOptions.output.schemas) {\n throw new Error(\n styleText('red', `Config requires an output target or schemas.`),\n );\n }\n\n // `paramsFilter` is only consumed by the Angular generator. That runs for\n // the `angular` client (regardless of `httpClient`, which stays at its\n // `fetch` default there) and for `angular-query` when it resolves to the\n // Angular HttpClient. For any other client the mutator would be imported\n // but never called, so fail fast instead of emitting a dead import.\n const usesAngularGenerator =\n normalizedOptions.output.client === OutputClient.ANGULAR ||\n (normalizedOptions.output.client === OutputClient.ANGULAR_QUERY &&\n normalizedOptions.output.httpClient === OutputHttpClient.ANGULAR);\n if (normalizedOptions.output.override.paramsFilter && !usesAngularGenerator) {\n throw new Error(\n styleText(\n 'red',\n `\\`override.paramsFilter\\` is only supported by the Angular generator (the \\`angular\\` client, or \\`angular-query\\` with \\`httpClient: 'angular'\\`). It has no effect for other clients — use \\`override.paramsSerializer\\` instead.`,\n ),\n );\n }\n if (!usesAngularGenerator) {\n const offendingOperation = Object.entries(\n normalizedOptions.output.override.operations,\n ).find(([, opOverride]) => opOverride?.paramsFilter)?.[0];\n if (offendingOperation) {\n throw new Error(\n styleText(\n 'red',\n `\\`override.operations[\"${offendingOperation}\"].paramsFilter\\` is only supported by the Angular generator (the \\`angular\\` client, or \\`angular-query\\` with \\`httpClient: 'angular'\\`). It has no effect for other clients — use \\`override.paramsSerializer\\` instead.`,\n ),\n );\n }\n const offendingTag = Object.entries(\n normalizedOptions.output.override.tags,\n ).find(([, tagOverride]) => tagOverride?.paramsFilter)?.[0];\n if (offendingTag) {\n throw new Error(\n styleText(\n 'red',\n `\\`override.tags[\"${offendingTag}\"].paramsFilter\\` is only supported by the Angular generator (the \\`angular\\` client, or \\`angular-query\\` with \\`httpClient: 'angular'\\`). It has no effect for other clients — use \\`override.paramsSerializer\\` instead.`,\n ),\n );\n }\n }\n\n if (\n normalizedOptions.output.httpClient === OutputHttpClient.FETCH &&\n normalizedOptions.output.optionsParamRequired &&\n normalizedOptions.output.override.requestOptions !== false\n ) {\n logWarning(\n `⚠️ With \\`httpClient: 'fetch'\\`, \\`optionsParamRequired: true\\` cannot make the generated \\`options\\` parameter required. The fetch \\`options\\` parameter remains optional with type \\`RequestInit\\` (\\`optionsParamRequired\\` may still affect other generated parameters). Set \\`httpClient: 'axios'\\` to make the \\`options\\` parameter required.`,\n );\n }\n\n return normalizedOptions;\n}\n\nfunction normalizeMutator(\n workspace: string,\n mutator?: Mutator,\n): NormalizedMutator | undefined {\n if (isObject(mutator)) {\n const m = mutator as Exclude<Mutator, string>;\n if (!m.path) {\n throw new Error(styleText('red', `Mutator requires a path.`));\n }\n\n return {\n path: nodePath.resolve(workspace, m.path),\n name: m.name,\n default: m.default ?? !m.name,\n alias: m.alias,\n external: m.external,\n extension: m.extension,\n };\n }\n\n if (isString(mutator)) {\n return {\n path: nodePath.resolve(workspace, mutator),\n default: true,\n };\n }\n\n return undefined;\n}\n\nasync function resolveFirstValidTarget(\n targets: string[],\n workspace: string,\n parserOptions?: InputOptions['parserOptions'],\n): Promise<string> {\n for (const target of targets) {\n if (isUrl(target)) {\n try {\n const headers = getHeadersForUrl(target, parserOptions?.headers);\n const headResponse = await fetchWithTimeout(target, {\n method: 'HEAD',\n headers,\n });\n\n if (headResponse.ok) {\n return target;\n }\n\n if (headResponse.status === 405 || headResponse.status === 501) {\n const getResponse = await fetchWithTimeout(target, {\n method: 'GET',\n headers,\n });\n\n if (getResponse.ok) {\n return target;\n }\n }\n } catch {\n continue;\n }\n\n continue;\n }\n\n const resolvedTarget = normalizePath(target, workspace);\n\n try {\n await access(resolvedTarget);\n return resolvedTarget;\n } catch {\n continue;\n }\n }\n\n throw new Error(\n styleText(\n 'red',\n `None of the input targets could be resolved:\\n${targets.map((target) => ` - ${target}`).join('\\n')}`,\n ),\n );\n}\n\nfunction getHeadersForUrl(\n url: string,\n headersConfig?: NonNullable<InputOptions['parserOptions']>['headers'],\n): Record<string, string> {\n if (!headersConfig) return {};\n\n const { hostname } = new URL(url);\n const matchedHeaders: Record<string, string> = {};\n\n for (const headerEntry of headersConfig) {\n if (\n headerEntry.domains.some(\n (domain) => hostname === domain || hostname.endsWith(`.${domain}`),\n )\n ) {\n Object.assign(matchedHeaders, headerEntry.headers);\n }\n }\n\n return matchedHeaders;\n}\n\nasync function fetchWithTimeout(\n target: string,\n init: RequestInit,\n): Promise<Response> {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => {\n controller.abort();\n }, INPUT_TARGET_FETCH_TIMEOUT_MS);\n\n try {\n return await fetch(target, {\n ...init,\n signal: controller.signal,\n });\n } finally {\n clearTimeout(timeoutId);\n }\n}\n\nfunction normalizePathOrUrl<T>(path: T, workspace: string) {\n if (isString(path) && !isUrl(path)) {\n return normalizePath(path, workspace);\n }\n\n return path;\n}\n\nexport function normalizePath<T>(path: T, workspace: string) {\n if (!isString(path)) {\n return path;\n }\n return nodePath.resolve(workspace, path);\n}\n\nfunction normalizeOperationsAndTags(\n operationsOrTags: Record<string, OperationOptions>,\n workspace: string,\n global: {\n query: NormalizedQueryOptions;\n },\n): Record<string, NormalizedOperationOptions> {\n return Object.fromEntries(\n Object.entries(operationsOrTags).map(\n ([\n key,\n {\n transformer,\n mutator,\n formData,\n formUrlEncoded,\n paramsSerializer,\n paramsFilter,\n query,\n angular,\n zod,\n ...rest\n },\n ]) => {\n return [\n key,\n {\n ...rest,\n ...(angular\n ? {\n angular: {\n provideIn: angular.provideIn ?? 'root',\n client:\n angular.retrievalClient ?? angular.client ?? 'httpClient',\n runtimeValidation: angular.runtimeValidation ?? false,\n ...(angular.httpResource\n ? { httpResource: angular.httpResource }\n : {}),\n },\n }\n : {}),\n ...(query\n ? {\n query: normalizeQueryOptions(query, workspace, global.query),\n }\n : {}),\n ...(zod\n ? {\n zod: {\n strict: {\n param: zod.strict?.param ?? false,\n query: zod.strict?.query ?? false,\n header: zod.strict?.header ?? false,\n body: zod.strict?.body ?? false,\n response: zod.strict?.response ?? false,\n },\n generate: {\n param: zod.generate?.param ?? true,\n query: zod.generate?.query ?? true,\n header: zod.generate?.header ?? true,\n body: zod.generate?.body ?? true,\n response: zod.generate?.response ?? true,\n },\n coerce: {\n param: zod.coerce?.param ?? false,\n query: zod.coerce?.query ?? false,\n header: zod.coerce?.header ?? false,\n body: zod.coerce?.body ?? false,\n response: zod.coerce?.response ?? false,\n },\n preprocess: {\n ...(zod.preprocess?.param\n ? {\n param: normalizeMutator(\n workspace,\n zod.preprocess.param,\n ),\n }\n : {}),\n ...(zod.preprocess?.query\n ? {\n query: normalizeMutator(\n workspace,\n zod.preprocess.query,\n ),\n }\n : {}),\n ...(zod.preprocess?.header\n ? {\n header: normalizeMutator(\n workspace,\n zod.preprocess.header,\n ),\n }\n : {}),\n ...(zod.preprocess?.body\n ? {\n body: normalizeMutator(\n workspace,\n zod.preprocess.body,\n ),\n }\n : {}),\n ...(zod.preprocess?.response\n ? {\n response: normalizeMutator(\n workspace,\n zod.preprocess.response,\n ),\n }\n : {}),\n },\n generateEachHttpStatus: zod.generateEachHttpStatus ?? false,\n useBrandedTypes: zod.useBrandedTypes ?? false,\n dateTimeOptions: zod.dateTimeOptions ?? { offset: true },\n timeOptions: zod.timeOptions ?? {},\n },\n }\n : {}),\n ...(transformer\n ? { transformer: normalizePath(transformer, workspace) }\n : {}),\n ...(mutator\n ? { mutator: normalizeMutator(workspace, mutator) }\n : {}),\n ...(formData === undefined\n ? {}\n : { formData: createFormData(workspace, formData) }),\n ...(formUrlEncoded\n ? {\n formUrlEncoded: isBoolean(formUrlEncoded)\n ? formUrlEncoded\n : normalizeMutator(workspace, formUrlEncoded),\n }\n : {}),\n ...(paramsSerializer\n ? {\n paramsSerializer: normalizeMutator(\n workspace,\n paramsSerializer,\n ),\n }\n : {}),\n ...(paramsFilter\n ? {\n paramsFilter: normalizeMutator(workspace, paramsFilter),\n }\n : {}),\n },\n ];\n },\n ),\n );\n}\n\nfunction normalizeOutputMode(mode?: OutputMode): OutputMode {\n if (!mode) {\n return OutputMode.SINGLE;\n }\n\n if (!Object.values(OutputMode).includes(mode)) {\n logWarning(`⚠️ Unknown provided mode => ${mode}`);\n return OutputMode.SINGLE;\n }\n\n return mode;\n}\n\nfunction normalizeHooks(hooks: HooksOptions): NormalizedHookOptions {\n const keys = Object.keys(hooks) as unknown as Hook[];\n\n const result: NormalizedHookOptions = {};\n for (const key of keys) {\n if (isString(hooks[key])) {\n result[key] = [hooks[key]] as string[];\n } else if (Array.isArray(hooks[key])) {\n result[key] = hooks[key] as string[];\n } else if (isFunction(hooks[key])) {\n result[key] = [hooks[key]] as HookFunction[];\n } else if (isObject(hooks[key])) {\n result[key] = [hooks[key]] as HookOption[];\n }\n }\n return result;\n}\n\nfunction normalizeHonoOptions(\n hono: HonoOptions = {},\n workspace: string,\n): NormalizedHonoOptions {\n return {\n ...(hono.handlers\n ? { handlers: nodePath.resolve(workspace, hono.handlers) }\n : {}),\n compositeRoute: hono.compositeRoute\n ? nodePath.resolve(workspace, hono.compositeRoute)\n : '',\n validator: hono.validator ?? true,\n validatorOutputPath: hono.validatorOutputPath\n ? nodePath.resolve(workspace, hono.validatorOutputPath)\n : '',\n };\n}\n\nfunction normalizeMcpServerOptions(\n server: McpServerOptions,\n workspace: string,\n): NormalizedMcpServerOptions {\n return {\n path: nodePath.resolve(workspace, server.path),\n name: server.name,\n default: server.default ?? !server.name,\n };\n}\n\nfunction normalizeMcpOptions(\n mcp: McpOptions = {},\n workspace: string,\n): NormalizedMcpOptions {\n return {\n ...(mcp.server\n ? { server: normalizeMcpServerOptions(mcp.server, workspace) }\n : {}),\n };\n}\n\nfunction normalizeJSDocOptions(\n jsdoc: JsDocOptions = {},\n): NormalizedJsDocOptions {\n return {\n ...jsdoc,\n };\n}\n\nfunction normalizeQueryOptions(\n queryOptions: QueryOptions = {},\n outputWorkspace: string,\n globalOptions: NormalizedQueryOptions = {},\n): NormalizedQueryOptions {\n if (queryOptions.options) {\n logWarning(\n '⚠️ Using query options is deprecated and will be removed in a future major release. Please use queryOptions or mutationOptions instead.',\n );\n }\n\n return {\n ...(isNullish(queryOptions.usePrefetch)\n ? {}\n : { usePrefetch: queryOptions.usePrefetch }),\n ...(isNullish(queryOptions.useInvalidate)\n ? {}\n : { useInvalidate: queryOptions.useInvalidate }),\n ...(isNullish(queryOptions.useSetQueryData)\n ? {}\n : { useSetQueryData: queryOptions.useSetQueryData }),\n ...(isNullish(queryOptions.useGetQueryData)\n ? {}\n : { useGetQueryData: queryOptions.useGetQueryData }),\n ...(isNullish(queryOptions.useQuery)\n ? {}\n : { useQuery: queryOptions.useQuery }),\n ...(isNullish(queryOptions.useSuspenseQuery)\n ? {}\n : { useSuspenseQuery: queryOptions.useSuspenseQuery }),\n ...(isNullish(queryOptions.useMutation)\n ? {}\n : { useMutation: queryOptions.useMutation }),\n ...(isNullish(queryOptions.useInfinite)\n ? {}\n : { useInfinite: queryOptions.useInfinite }),\n ...(isNullish(queryOptions.useSuspenseInfiniteQuery)\n ? {}\n : { useSuspenseInfiniteQuery: queryOptions.useSuspenseInfiniteQuery }),\n ...(queryOptions.useInfiniteQueryParam\n ? { useInfiniteQueryParam: queryOptions.useInfiniteQueryParam }\n : {}),\n ...(queryOptions.options ? { options: queryOptions.options } : {}),\n ...(globalOptions.queryKey\n ? {\n queryKey: globalOptions.queryKey,\n }\n : {}),\n ...(queryOptions.queryKey\n ? {\n queryKey: normalizeMutator(outputWorkspace, queryOptions.queryKey),\n }\n : {}),\n ...(globalOptions.queryOptions\n ? {\n queryOptions: globalOptions.queryOptions,\n }\n : {}),\n ...(queryOptions.queryOptions\n ? {\n queryOptions: normalizeMutator(\n outputWorkspace,\n queryOptions.queryOptions,\n ),\n }\n : {}),\n ...(globalOptions.mutationOptions\n ? {\n mutationOptions: globalOptions.mutationOptions,\n }\n : {}),\n ...(queryOptions.mutationOptions\n ? {\n mutationOptions: normalizeMutator(\n outputWorkspace,\n queryOptions.mutationOptions,\n ),\n }\n : {}),\n ...(isNullish(globalOptions.shouldExportQueryKey)\n ? {}\n : {\n shouldExportQueryKey: globalOptions.shouldExportQueryKey,\n }),\n ...(isNullish(queryOptions.shouldExportQueryKey)\n ? {}\n : { shouldExportQueryKey: queryOptions.shouldExportQueryKey }),\n ...(isNullish(globalOptions.shouldExportHttpClient)\n ? {}\n : {\n shouldExportHttpClient: globalOptions.shouldExportHttpClient,\n }),\n ...(isNullish(queryOptions.shouldExportHttpClient)\n ? {}\n : { shouldExportHttpClient: queryOptions.shouldExportHttpClient }),\n ...(isNullish(globalOptions.shouldExportMutatorHooks)\n ? {}\n : {\n shouldExportMutatorHooks: globalOptions.shouldExportMutatorHooks,\n }),\n ...(isNullish(queryOptions.shouldExportMutatorHooks)\n ? {}\n : { shouldExportMutatorHooks: queryOptions.shouldExportMutatorHooks }),\n ...(isNullish(globalOptions.shouldSplitQueryKey)\n ? {}\n : {\n shouldSplitQueryKey: globalOptions.shouldSplitQueryKey,\n }),\n ...(isNullish(queryOptions.shouldSplitQueryKey)\n ? {}\n : { shouldSplitQueryKey: queryOptions.shouldSplitQueryKey }),\n ...(isNullish(globalOptions.signal)\n ? {}\n : {\n signal: globalOptions.signal,\n }),\n ...(isNullish(globalOptions.useOperationIdAsQueryKey)\n ? {}\n : {\n useOperationIdAsQueryKey: globalOptions.useOperationIdAsQueryKey,\n }),\n ...(isNullish(queryOptions.useOperationIdAsQueryKey)\n ? {}\n : { useOperationIdAsQueryKey: queryOptions.useOperationIdAsQueryKey }),\n ...(isNullish(globalOptions.signal)\n ? {}\n : {\n signal: globalOptions.signal,\n }),\n ...(isNullish(queryOptions.signal) ? {} : { signal: queryOptions.signal }),\n ...(isNullish(globalOptions.version)\n ? {}\n : {\n version: globalOptions.version,\n }),\n ...(isNullish(queryOptions.version)\n ? {}\n : { version: queryOptions.version }),\n ...(queryOptions.mutationInvalidates\n ? { mutationInvalidates: queryOptions.mutationInvalidates }\n : {}),\n ...(isNullish(globalOptions.runtimeValidation)\n ? {}\n : {\n runtimeValidation: globalOptions.runtimeValidation,\n }),\n ...(isNullish(queryOptions.runtimeValidation)\n ? {}\n : { runtimeValidation: queryOptions.runtimeValidation }),\n };\n}\n\nexport function getDefaultFilesHeader({\n title,\n description,\n version,\n}: {\n title?: string;\n description?: string;\n version?: string;\n} = {}) {\n return [\n `Generated by ${pkg.name} v${pkg.version} 🍺`,\n `Do not edit manually.`,\n ...(title ? [title] : []),\n ...(description ? [description] : []),\n ...(version ? [`OpenAPI spec version: ${version}`] : []),\n ];\n}\n","import { isBoolean, log, logError } from '@orval/core';\n\n/**\n * Start a file watcher and invoke an async callback on file changes.\n *\n * If `watchOptions` is falsy the watcher is not started. Supported shapes:\n * - boolean: when true the `defaultTarget` is watched\n * - string: a single path to watch\n * - string[]: an array of paths to watch\n *\n * @param watchOptions - false to disable watching, or a path/paths to watch\n * @param watchFn - async callback executed on change events\n * @param defaultTarget - path(s) to watch when `watchOptions` is `true` (default: '.')\n * @returns Resolves once the watcher has been started (or immediately if disabled)\n *\n * @example\n * await startWatcher(true, async () => { await buildProject(); }, 'src');\n */\nexport async function startWatcher(\n watchOptions: boolean | string | string[],\n watchFn: () => Promise<void>,\n defaultTarget: string | string[] = '.',\n) {\n if (!watchOptions) return;\n const { watch } = await import('chokidar');\n\n const ignored = ['**/{.git,node_modules}/**'];\n\n const watchPaths = isBoolean(watchOptions) ? defaultTarget : watchOptions;\n\n log(\n `Watching for changes in ${\n Array.isArray(watchPaths)\n ? watchPaths.map((v) => '\"' + v + '\"').join(' | ')\n : '\"' + watchPaths + '\"'\n }`,\n );\n\n const watcher = watch(watchPaths, {\n ignorePermissionErrors: true,\n ignored,\n });\n watcher.on('ready', () => {\n log('Initial scan complete. Watching for changes...');\n watcher.on('all', (type, file) => {\n log(`Change detected: ${type} ${file}`);\n\n watchFn().catch((error: unknown) => {\n logError(error);\n });\n });\n });\n}\n","import path from 'node:path';\n\nimport {\n type ContextSpec,\n conventionName,\n type NamingConvention,\n type NormalizedOutputOptions,\n type OpenApiParameterObject,\n type OpenApiReferenceObject,\n type OpenApiRequestBodyObject,\n type OpenApiSchemaObject,\n pascal,\n type ZodCoerceType,\n} from '@orval/core';\nimport {\n dereference,\n generateFormDataZodSchema,\n generateZodValidationSchemaDefinition,\n isZodVersionV4,\n parseZodValidationSchemaDefinition,\n type ZodValidationSchemaDefinition,\n} from '@orval/zod';\nimport fs from 'fs-extra';\n\ninterface ZodSchemaFileEntry {\n schemaName: string;\n consts: string;\n zodExpression: string;\n}\n\ntype ZodSchemaFileToWrite = ZodSchemaFileEntry & {\n filePath: string;\n};\n\ninterface WriteZodOutputOptions {\n namingConvention: NamingConvention;\n indexFiles: boolean;\n packageJson?: NormalizedOutputOptions['packageJson'];\n override: {\n zod: {\n strict: {\n body: boolean;\n };\n coerce: {\n body: boolean | ZodCoerceType[];\n };\n };\n };\n}\n\ninterface WriteZodSchemasInput {\n spec: ContextSpec['spec'];\n target: string;\n schemas: {\n name: string;\n schema?: OpenApiSchemaObject | OpenApiReferenceObject;\n }[];\n}\n\ninterface WriteZodVerbResponseType {\n value: string;\n isRef?: boolean;\n originalSchema?: OpenApiSchemaObject;\n}\n\ntype WriteZodSchemasFromVerbsInput = Record<\n string,\n {\n operationName: string;\n originalOperation: {\n requestBody?: OpenApiRequestBodyObject | OpenApiReferenceObject;\n parameters?: (OpenApiParameterObject | OpenApiReferenceObject)[];\n };\n response: {\n types: {\n success: WriteZodVerbResponseType[];\n errors: WriteZodVerbResponseType[];\n };\n };\n }\n>;\n\ninterface WriteZodSchemasFromVerbsContext {\n output: {\n override: {\n useDates?: NormalizedOutputOptions['override']['useDates'];\n zod: Pick<\n NormalizedOutputOptions['override']['zod'],\n 'dateTimeOptions' | 'timeOptions'\n >;\n };\n };\n spec: ContextSpec['spec'];\n target: string;\n workspace: string;\n}\n\nfunction generateZodSchemaFileContent(\n header: string,\n schemas: ZodSchemaFileEntry[],\n): string {\n const schemaContent = schemas\n .map(({ schemaName, consts, zodExpression }) => {\n const schemaConsts = consts ? `${consts}\\n` : '';\n\n return `${schemaConsts}export const ${schemaName} = ${zodExpression}\n\nexport type ${schemaName} = zod.input<typeof ${schemaName}>;\nexport type ${schemaName}Output = zod.output<typeof ${schemaName}>;`;\n })\n .join('\\n\\n');\n\n return `${header}import { z as zod } from 'zod';\n\n${schemaContent}\n`;\n}\n\nconst isValidSchemaIdentifier = (name: string) =>\n /^[A-Za-z_][A-Za-z0-9_]*$/.test(name);\n\nconst isPrimitiveSchemaName = (name: string) =>\n ['string', 'number', 'boolean', 'void', 'unknown', 'Blob'].includes(name);\n\nconst dedupeSchemasByName = <T extends { name: string }>(schemas: T[]) => {\n const uniqueSchemas = new Map<string, T>();\n\n for (const schema of schemas) {\n if (!uniqueSchemas.has(schema.name)) {\n uniqueSchemas.set(schema.name, schema);\n }\n }\n\n return [...uniqueSchemas.values()];\n};\n\nconst groupSchemasByFilePath = <T extends { filePath: string }>(\n schemas: T[],\n) => {\n const grouped = new Map<string, T[]>();\n\n for (const schema of schemas) {\n const key = schema.filePath.toLowerCase();\n const existingGroup = grouped.get(key);\n\n if (existingGroup) {\n existingGroup.push(schema);\n } else {\n grouped.set(key, [schema]);\n }\n }\n\n const sortedGroups = [...grouped.values()].map((group) =>\n [...group].toSorted((a, b) =>\n a.filePath.localeCompare(b.filePath, 'en', { numeric: true }),\n ),\n );\n\n return sortedGroups.toSorted((a, b) =>\n a[0].filePath.localeCompare(b[0].filePath, 'en', { numeric: true }),\n );\n};\n\nasync function writeZodSchemaIndex(\n schemasPath: string,\n fileExtension: string,\n header: string,\n schemaNames: string[],\n namingConvention: NamingConvention,\n shouldMergeExisting = false,\n) {\n const importFileExtension = fileExtension.replace(/\\.ts$/, '');\n const indexPath = path.join(schemasPath, `index.ts`);\n\n let existingExports = '';\n if (shouldMergeExisting && (await fs.pathExists(indexPath))) {\n const existingContent = await fs.readFile(indexPath, 'utf8');\n const headerMatch = /^(\\/\\*\\*[\\s\\S]*?\\*\\/\\n)?/.exec(existingContent);\n const headerPart = headerMatch ? headerMatch[0] : '';\n existingExports = existingContent.slice(headerPart.length).trim();\n }\n\n const newExports = schemaNames\n .map((schemaName) => {\n const fileName = conventionName(schemaName, namingConvention);\n return `export * from './${fileName}${importFileExtension}';`;\n })\n .toSorted()\n .join('\\n');\n\n const allExports = existingExports\n ? `${existingExports}\\n${newExports}`\n : newExports;\n\n const uniqueExports = [...new Set(allExports.split('\\n'))]\n .filter((line) => line.trim())\n .toSorted()\n .join('\\n');\n\n await fs.outputFile(indexPath, `${header}\\n${uniqueExports}\\n`);\n}\n\nexport function generateZodSchemasInline(\n builder: WriteZodSchemasInput,\n output: WriteZodOutputOptions,\n): string {\n const schemasWithOpenApiDef = builder.schemas.filter((s) => s.schema);\n\n if (schemasWithOpenApiDef.length === 0) {\n return '';\n }\n\n const isZodV4 = !!output.packageJson && isZodVersionV4(output.packageJson);\n const strict = output.override.zod.strict.body;\n const coerce = output.override.zod.coerce.body;\n const schemas: ZodSchemaFileEntry[] = [];\n\n for (const { name, schema: schemaObject } of schemasWithOpenApiDef) {\n if (!schemaObject) {\n continue;\n }\n\n const context: ContextSpec = {\n spec: builder.spec,\n target: builder.target,\n workspace: '',\n output: output as ContextSpec['output'],\n };\n\n const dereferencedSchema = dereference(schemaObject, context);\n\n const zodDefinition = generateZodValidationSchemaDefinition(\n dereferencedSchema,\n context,\n name,\n strict,\n isZodV4,\n {\n required: true,\n },\n );\n\n const parsedZodDefinition = parseZodValidationSchemaDefinition(\n zodDefinition,\n context,\n coerce,\n strict,\n isZodV4,\n );\n\n schemas.push({\n schemaName: name,\n consts: parsedZodDefinition.consts,\n zodExpression: parsedZodDefinition.zod,\n });\n }\n\n if (schemas.length === 0) {\n return '';\n }\n\n return generateZodSchemaFileContent('', schemas);\n}\n\nexport async function writeZodSchemas(\n builder: WriteZodSchemasInput,\n schemasPath: string,\n fileExtension: string,\n header: string,\n output: WriteZodOutputOptions,\n) {\n const schemasWithOpenApiDef = builder.schemas.filter((s) => s.schema);\n const schemasToWrite: ZodSchemaFileToWrite[] = [];\n const isZodV4 = !!output.packageJson && isZodVersionV4(output.packageJson);\n const strict = output.override.zod.strict.body;\n const coerce = output.override.zod.coerce.body;\n\n for (const generatorSchema of schemasWithOpenApiDef) {\n const { name, schema: schemaObject } = generatorSchema;\n\n if (!schemaObject) {\n continue;\n }\n\n const fileName = conventionName(name, output.namingConvention);\n const filePath = path.join(schemasPath, `${fileName}${fileExtension}`);\n const context: ContextSpec = {\n spec: builder.spec,\n target: builder.target,\n workspace: '',\n output: output as ContextSpec['output'],\n };\n\n // Dereference the schema to resolve $ref\n const dereferencedSchema = dereference(schemaObject, context);\n\n const zodDefinition = generateZodValidationSchemaDefinition(\n dereferencedSchema,\n context,\n name,\n strict,\n isZodV4,\n {\n required: true,\n },\n );\n\n const parsedZodDefinition = parseZodValidationSchemaDefinition(\n zodDefinition,\n context,\n coerce,\n strict,\n isZodV4,\n );\n\n schemasToWrite.push({\n schemaName: name,\n filePath,\n consts: parsedZodDefinition.consts,\n zodExpression: parsedZodDefinition.zod,\n });\n }\n\n const groupedSchemasToWrite = groupSchemasByFilePath(schemasToWrite);\n\n for (const schemaGroup of groupedSchemasToWrite) {\n const fileContent = generateZodSchemaFileContent(header, schemaGroup);\n\n await fs.outputFile(schemaGroup[0].filePath, fileContent);\n }\n\n if (output.indexFiles) {\n const schemaNames = groupedSchemasToWrite.map(\n (schemaGroup) => schemaGroup[0].schemaName,\n );\n await writeZodSchemaIndex(\n schemasPath,\n fileExtension,\n header,\n schemaNames,\n output.namingConvention,\n false,\n );\n }\n}\n\nexport async function writeZodSchemasFromVerbs(\n verbOptions: WriteZodSchemasFromVerbsInput,\n schemasPath: string,\n fileExtension: string,\n header: string,\n output: WriteZodOutputOptions,\n context: WriteZodSchemasFromVerbsContext,\n) {\n const zodContext = context as unknown as ContextSpec;\n const verbOptionsArray = Object.values(verbOptions);\n\n if (verbOptionsArray.length === 0) {\n return;\n }\n\n const isZodV4 = !!output.packageJson && isZodVersionV4(output.packageJson);\n const strict = output.override.zod.strict.body;\n const coerce = output.override.zod.coerce.body;\n\n const generateVerbsSchemas = verbOptionsArray.flatMap((verbOption) => {\n const operation = verbOption.originalOperation;\n\n const requestBody = operation.requestBody;\n const requestBodyContent =\n requestBody && 'content' in requestBody\n ? (requestBody as OpenApiRequestBodyObject).content\n : undefined;\n // Pick the first available body media type. JSON wins; otherwise fall back\n // to form-data / urlencoded so we still generate a `*Body` schema for\n // operations whose only payload is multipart (e.g. file uploads). Without\n // this, endpoints that import `${OperationName}Body` from the zod schemas\n // path resolve to a missing export. (issue #3066)\n const jsonBodyMedia = requestBodyContent?.['application/json'];\n const formDataBodyMedia = requestBodyContent?.['multipart/form-data'];\n const formUrlEncodedBodyMedia =\n requestBodyContent?.['application/x-www-form-urlencoded'];\n const [bodyContentType, bodyMedia] = jsonBodyMedia\n ? (['application/json', jsonBodyMedia] as const)\n : formDataBodyMedia\n ? (['multipart/form-data', formDataBodyMedia] as const)\n : formUrlEncodedBodyMedia\n ? ([\n 'application/x-www-form-urlencoded',\n formUrlEncodedBodyMedia,\n ] as const)\n : [undefined, undefined];\n const bodySchema = bodyMedia?.schema as OpenApiSchemaObject | undefined;\n\n const bodySchemas = bodySchema\n ? [\n {\n name: `${pascal(verbOption.operationName)}Body`,\n schema: dereference(bodySchema, zodContext),\n bodyContentType,\n encoding: bodyMedia?.encoding,\n },\n ]\n : [];\n\n const parameters = operation.parameters;\n\n const queryParams = parameters?.filter(\n (p): p is OpenApiParameterObject => 'in' in p && p.in === 'query',\n );\n\n const queryParamsSchemas =\n queryParams && queryParams.length > 0\n ? [\n {\n name: `${pascal(verbOption.operationName)}Params`,\n schema: {\n type: 'object' as const,\n properties: Object.fromEntries(\n queryParams\n .filter((p) => 'schema' in p && p.schema)\n .map((p) => [\n p.name,\n dereference(p.schema as OpenApiSchemaObject, zodContext),\n ]),\n ) as Record<string, OpenApiSchemaObject>,\n required: queryParams\n .filter((p) => p.required)\n .map((p) => p.name)\n .filter((name): name is string => name !== undefined),\n },\n },\n ]\n : [];\n\n const headerParams = parameters?.filter(\n (p): p is OpenApiParameterObject => 'in' in p && p.in === 'header',\n );\n\n const headerParamsSchemas =\n headerParams && headerParams.length > 0\n ? [\n {\n name: `${pascal(verbOption.operationName)}Headers`,\n schema: {\n type: 'object' as const,\n properties: Object.fromEntries(\n headerParams\n .filter((p) => 'schema' in p && p.schema)\n .map((p) => [\n p.name,\n dereference(p.schema as OpenApiSchemaObject, zodContext),\n ]),\n ) as Record<string, OpenApiSchemaObject>,\n required: headerParams\n .filter((p) => p.required)\n .map((p) => p.name)\n .filter((name): name is string => name !== undefined),\n },\n },\n ]\n : [];\n\n const responseSchemas = [\n ...verbOption.response.types.success,\n ...verbOption.response.types.errors,\n ]\n .filter(\n (\n responseType,\n ): responseType is typeof responseType & {\n originalSchema: OpenApiSchemaObject;\n } =>\n !!responseType.originalSchema &&\n !responseType.isRef &&\n isValidSchemaIdentifier(responseType.value) &&\n !isPrimitiveSchemaName(responseType.value),\n )\n .map((responseType) => ({\n name: responseType.value,\n schema: dereference(responseType.originalSchema, zodContext),\n }));\n\n return dedupeSchemasByName([\n ...bodySchemas,\n ...queryParamsSchemas,\n ...headerParamsSchemas,\n ...responseSchemas,\n ]);\n });\n\n const uniqueVerbsSchemas = dedupeSchemasByName(generateVerbsSchemas);\n const schemasToWrite: ZodSchemaFileToWrite[] = [];\n\n for (const entry of uniqueVerbsSchemas) {\n const { name, schema } = entry;\n const fileName = conventionName(name, output.namingConvention);\n const filePath = path.join(schemasPath, `${fileName}${fileExtension}`);\n\n // multipart/form-data bodies need file-aware overrides so binary fields\n // become `z.instanceof(File)` instead of plain strings.\n const isFormDataBody =\n 'bodyContentType' in entry &&\n entry.bodyContentType === 'multipart/form-data';\n\n const zodDefinition: ZodValidationSchemaDefinition = isFormDataBody\n ? generateFormDataZodSchema(\n schema,\n zodContext,\n name,\n strict,\n isZodV4,\n 'encoding' in entry\n ? (entry.encoding as\n | Record<string, { contentType?: string }>\n | undefined)\n : undefined,\n )\n : generateZodValidationSchemaDefinition(\n schema,\n zodContext,\n name,\n strict,\n isZodV4,\n {\n required: true,\n },\n );\n\n const parsedZodDefinition = parseZodValidationSchemaDefinition(\n zodDefinition,\n zodContext,\n coerce,\n strict,\n isZodV4,\n );\n\n schemasToWrite.push({\n schemaName: name,\n filePath,\n consts: parsedZodDefinition.consts,\n zodExpression: parsedZodDefinition.zod,\n });\n }\n\n const groupedSchemasToWrite = groupSchemasByFilePath(schemasToWrite);\n\n for (const schemaGroup of groupedSchemasToWrite) {\n const fileContent = generateZodSchemaFileContent(header, schemaGroup);\n\n await fs.outputFile(schemaGroup[0].filePath, fileContent);\n }\n\n if (output.indexFiles && uniqueVerbsSchemas.length > 0) {\n const schemaNames = groupedSchemasToWrite.map(\n (schemaGroup) => schemaGroup[0].schemaName,\n );\n await writeZodSchemaIndex(\n schemasPath,\n fileExtension,\n header,\n schemaNames,\n output.namingConvention,\n true,\n );\n }\n}\n","import path from 'node:path';\n\nimport {\n createSuccessMessage,\n fixCrossDirectoryImports,\n fixRegularSchemaImports,\n getFileInfo,\n getMockFileExtensionByTypeName,\n isObject,\n isString,\n jsDoc,\n logWarning,\n type NormalizedOptions,\n type OpenApiInfoObject,\n OutputMode,\n splitSchemasByType,\n SupportedFormatter,\n upath,\n writeSchemas,\n writeSingleMode,\n type WriteSpecBuilder,\n writeSplitMode,\n writeSplitTagsMode,\n writeTagsMode,\n} from '@orval/core';\nimport { execa, ExecaError } from 'execa';\nimport fs from 'fs-extra';\nimport { unique } from 'remeda';\nimport type { TypeDocOptions } from 'typedoc';\n\nimport { formatWithPrettier } from './formatters/prettier';\nimport { executeHook } from './utils';\nimport {\n generateZodSchemasInline,\n writeZodSchemas,\n writeZodSchemasFromVerbs,\n} from './write-zod-specs';\n\nasync function runExternalFormatter(\n bin: string,\n args: string[],\n projectTitle?: string,\n): Promise<void> {\n try {\n await execa(bin, args);\n } catch (error) {\n let message: string;\n if (error instanceof ExecaError) {\n message =\n error.code === 'ENOENT'\n ? `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}${bin} not found`\n : error.message;\n } else if (error instanceof Error) {\n message = error.message;\n } else {\n message = `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}${bin} failed`;\n }\n logWarning(message);\n }\n}\n\nexport async function runFormatter(\n formatter: SupportedFormatter | undefined,\n paths: string[],\n projectTitle?: string,\n): Promise<void> {\n switch (formatter) {\n case SupportedFormatter.PRETTIER: {\n await formatWithPrettier(paths, projectTitle);\n break;\n }\n case SupportedFormatter.BIOME: {\n await runExternalFormatter(\n SupportedFormatter.BIOME,\n ['check', '--write', ...paths],\n projectTitle,\n );\n break;\n }\n case SupportedFormatter.OXFMT: {\n await runExternalFormatter(SupportedFormatter.OXFMT, paths, projectTitle);\n break;\n }\n }\n}\n\nfunction getHeader(\n option: false | ((info: OpenApiInfoObject) => string | string[]),\n info: OpenApiInfoObject,\n): string {\n if (!option) {\n return '';\n }\n\n const header = option(info);\n return Array.isArray(header) ? jsDoc({ description: header }) : header;\n}\n\n/**\n * Add re-export of operation schemas from the main schemas index file.\n * Handles the case where the index file doesn't exist (no regular schemas).\n */\nasync function addOperationSchemasReExport(\n schemaPath: string,\n operationSchemasPath: string,\n header: string,\n): Promise<void> {\n const schemaIndexPath = path.join(schemaPath, `index.ts`);\n const esmImportPath = upath.getRelativeImportPath(\n schemaIndexPath,\n operationSchemasPath,\n );\n const exportLine = `export * from '${esmImportPath}';\\n`;\n\n const indexExists = await fs.pathExists(schemaIndexPath);\n if (indexExists) {\n // Check if export already exists to prevent duplicates on re-runs\n // Use regex to handle both single and double quotes\n const existingContent = await fs.readFile(schemaIndexPath, 'utf8');\n const exportPattern = new RegExp(\n String.raw`export\\s*\\*\\s*from\\s*['\"]${esmImportPath.replaceAll(/[.*+?^${}()|[\\]\\\\]/g, String.raw`\\$&`)}['\"]`,\n );\n if (!exportPattern.test(existingContent)) {\n await fs.appendFile(schemaIndexPath, exportLine);\n }\n } else {\n // Create index with header if file doesn't exist (no regular schemas case)\n const content =\n header && header.trim().length > 0\n ? `${header}\\n${exportLine}`\n : exportLine;\n await fs.outputFile(schemaIndexPath, content);\n }\n}\n\nexport async function writeSpecs(\n builder: WriteSpecBuilder,\n workspace: string,\n options: NormalizedOptions,\n projectName?: string,\n) {\n const { info, schemas, target } = builder;\n const { output } = options;\n const projectTitle = projectName ?? info.title;\n\n const header = getHeader(output.override.header, info);\n\n if (output.schemas) {\n if (isString(output.schemas)) {\n const fileExtension = output.fileExtension || '.ts';\n const schemaPath = output.schemas;\n\n // Split schemas if operationSchemas path is configured\n if (output.operationSchemas) {\n const { regularSchemas, operationSchemas: opSchemas } =\n splitSchemasByType(schemas);\n\n // Fix cross-directory imports before writing (both directions)\n const regularSchemaNames = new Set(regularSchemas.map((s) => s.name));\n const operationSchemaNames = new Set(opSchemas.map((s) => s.name));\n fixCrossDirectoryImports(\n opSchemas,\n regularSchemaNames,\n schemaPath,\n output.operationSchemas,\n output.namingConvention,\n fileExtension,\n output.tsconfig,\n );\n fixRegularSchemaImports(\n regularSchemas,\n operationSchemaNames,\n schemaPath,\n output.operationSchemas,\n output.namingConvention,\n fileExtension,\n output.tsconfig,\n );\n\n // Write regular schemas to schemas path\n if (regularSchemas.length > 0) {\n await writeSchemas({\n schemaPath,\n schemas: regularSchemas,\n target,\n namingConvention: output.namingConvention,\n fileExtension,\n header,\n indexFiles: output.indexFiles,\n tsconfig: output.tsconfig,\n });\n }\n\n // Write operation schemas to operationSchemas path\n if (opSchemas.length > 0) {\n await writeSchemas({\n schemaPath: output.operationSchemas,\n schemas: opSchemas,\n target,\n namingConvention: output.namingConvention,\n fileExtension,\n header,\n indexFiles: output.indexFiles,\n tsconfig: output.tsconfig,\n });\n\n // Add re-export from operations in the main schemas index\n if (output.indexFiles) {\n await addOperationSchemasReExport(\n schemaPath,\n output.operationSchemas,\n header,\n );\n }\n }\n } else {\n await writeSchemas({\n schemaPath,\n schemas,\n target,\n namingConvention: output.namingConvention,\n fileExtension,\n header,\n indexFiles: output.indexFiles,\n tsconfig: output.tsconfig,\n });\n }\n } else {\n const schemaType = output.schemas.type;\n\n if (schemaType === 'typescript') {\n const fileExtension = output.fileExtension || '.ts';\n\n // Split schemas if operationSchemas path is configured\n if (output.operationSchemas) {\n const { regularSchemas, operationSchemas: opSchemas } =\n splitSchemasByType(schemas);\n\n // Fix cross-directory imports before writing (both directions)\n const regularSchemaNames = new Set(regularSchemas.map((s) => s.name));\n const operationSchemaNames = new Set(opSchemas.map((s) => s.name));\n fixCrossDirectoryImports(\n opSchemas,\n regularSchemaNames,\n output.schemas.path,\n output.operationSchemas,\n output.namingConvention,\n fileExtension,\n output.tsconfig,\n );\n fixRegularSchemaImports(\n regularSchemas,\n operationSchemaNames,\n output.schemas.path,\n output.operationSchemas,\n output.namingConvention,\n fileExtension,\n output.tsconfig,\n );\n\n if (regularSchemas.length > 0) {\n await writeSchemas({\n schemaPath: output.schemas.path,\n schemas: regularSchemas,\n target,\n namingConvention: output.namingConvention,\n fileExtension,\n header,\n indexFiles: output.indexFiles,\n tsconfig: output.tsconfig,\n });\n }\n\n if (opSchemas.length > 0) {\n await writeSchemas({\n schemaPath: output.operationSchemas,\n schemas: opSchemas,\n target,\n namingConvention: output.namingConvention,\n fileExtension,\n header,\n indexFiles: output.indexFiles,\n tsconfig: output.tsconfig,\n });\n\n // Add re-export from operations in the main schemas index\n if (output.indexFiles) {\n await addOperationSchemasReExport(\n output.schemas.path,\n output.operationSchemas,\n header,\n );\n }\n }\n } else {\n await writeSchemas({\n schemaPath: output.schemas.path,\n schemas,\n target,\n namingConvention: output.namingConvention,\n fileExtension,\n header,\n indexFiles: output.indexFiles,\n tsconfig: output.tsconfig,\n });\n }\n } else {\n // schemaType === 'zod'\n const fileExtension = '.zod.ts';\n\n await writeZodSchemas(\n builder,\n output.schemas.path,\n fileExtension,\n header,\n output,\n );\n\n await writeZodSchemasFromVerbs(\n builder.verbOptions,\n output.schemas.path,\n fileExtension,\n header,\n output,\n {\n spec: builder.spec,\n target: builder.target,\n workspace,\n output,\n },\n );\n }\n }\n }\n\n let implementationPaths: string[] = [];\n\n if (output.target) {\n const writeMode = getWriteMode(output.mode);\n const isZodClient = output.client === 'zod';\n const hasOperations = Object.keys(builder.operations).length > 0;\n const needZodSchemasInline =\n isZodClient && !output.schemas && !hasOperations;\n\n implementationPaths = await writeMode({\n builder,\n workspace,\n output,\n projectName,\n header,\n needSchema: (!output.schemas && !isZodClient) || needZodSchemasInline,\n generateSchemasInline: needZodSchemasInline\n ? () => generateZodSchemasInline(builder, output)\n : undefined,\n });\n }\n\n if (output.workspace) {\n const workspacePath = output.workspace;\n const indexFile = path.join(workspacePath, 'index.ts');\n const imports = implementationPaths\n .filter(\n (p) =>\n !output.mock ||\n !p.endsWith(`.${getMockFileExtensionByTypeName(output.mock)}.ts`),\n )\n .map((p) =>\n upath.getRelativeImportPath(\n indexFile,\n getFileInfo(p).pathWithoutExtension,\n true,\n ),\n );\n\n if (output.schemas) {\n const schemasPath = isString(output.schemas)\n ? output.schemas\n : output.schemas.path;\n imports.push(\n upath.getRelativeImportPath(\n indexFile,\n getFileInfo(schemasPath).dirname,\n ),\n );\n }\n\n if (output.operationSchemas) {\n imports.push(\n upath.getRelativeImportPath(\n indexFile,\n getFileInfo(output.operationSchemas).dirname,\n ),\n );\n }\n\n if (output.indexFiles) {\n if (await fs.pathExists(indexFile)) {\n const data = await fs.readFile(indexFile, 'utf8');\n const importsNotDeclared = imports.filter((imp) => !data.includes(imp));\n await fs.appendFile(\n indexFile,\n unique(importsNotDeclared)\n .map((imp) => `export * from '${imp}';\\n`)\n .join(''),\n );\n } else {\n await fs.outputFile(\n indexFile,\n unique(imports)\n .map((imp) => `export * from '${imp}';`)\n .join('\\n') + '\\n',\n );\n }\n\n implementationPaths = [indexFile, ...implementationPaths];\n }\n }\n\n if (builder.extraFiles.length > 0) {\n await Promise.all(\n builder.extraFiles.map(async (file) =>\n fs.outputFile(file.path, file.content),\n ),\n );\n\n implementationPaths = [\n ...implementationPaths,\n ...builder.extraFiles.map((file) => file.path),\n ];\n }\n\n const paths = [\n ...(output.schemas\n ? [\n getFileInfo(\n isString(output.schemas) ? output.schemas : output.schemas.path,\n ).dirname,\n ]\n : []),\n ...(output.operationSchemas\n ? [getFileInfo(output.operationSchemas).dirname]\n : []),\n ...implementationPaths,\n ];\n\n if (options.hooks.afterAllFilesWrite) {\n await executeHook(\n 'afterAllFilesWrite',\n options.hooks.afterAllFilesWrite,\n paths,\n );\n }\n\n await runFormatter(output.formatter, paths, projectTitle);\n\n if (output.docs) {\n try {\n let config: Partial<TypeDocOptions> = {};\n let configPath: string | undefined;\n if (isObject(output.docs)) {\n ({ configPath, ...config } = output.docs);\n if (configPath) {\n config.options = configPath;\n }\n }\n\n const getTypedocApplication = async () => {\n const { Application } = await import('typedoc');\n return Application;\n };\n\n const Application = await getTypedocApplication();\n const app = await Application.bootstrapWithPlugins({\n entryPoints: paths.map((x) => upath.toUnix(x)),\n theme: 'markdown',\n // Skip TypeScript diagnostics on the consuming project: TypeDoc would\n // otherwise pick up the user's tsconfig and surface errors from files\n // unrelated to the generated entry points (e.g. a demo `App.tsx`\n // with an unused `React` default import under the new JSX transform —\n // see #3338). User-overridable via the `docs` option below.\n skipErrorChecking: true,\n // Set the custom config location if it has been provided.\n ...config,\n plugin: ['typedoc-plugin-markdown', ...(config.plugin ?? [])],\n });\n // Set defaults if the have not been provided by the external config.\n if (!app.options.isSet('readme')) {\n app.options.setValue('readme', 'none');\n }\n if (!app.options.isSet('logLevel')) {\n app.options.setValue('logLevel', 'None');\n }\n const project = await app.convert();\n if (project) {\n const outputPath = app.options.getValue('out');\n await app.generateDocs(project, outputPath);\n\n await runFormatter(output.formatter, [outputPath], projectTitle);\n } else {\n throw new Error('TypeDoc not initialized');\n }\n } catch (error) {\n const message =\n error instanceof Error\n ? error.message\n : `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}Unable to generate docs`;\n\n logWarning(message);\n }\n }\n\n createSuccessMessage(projectTitle);\n}\n\nfunction getWriteMode(mode: OutputMode) {\n switch (mode) {\n case OutputMode.SPLIT: {\n return writeSplitMode;\n }\n case OutputMode.TAGS: {\n return writeTagsMode;\n }\n case OutputMode.TAGS_SPLIT: {\n return writeSplitTagsMode;\n }\n default: {\n return writeSingleMode;\n }\n }\n}\n","import {\n getFileInfo,\n isString,\n log,\n type NormalizedOptions,\n removeFilesAndEmptyFolders,\n} from '@orval/core';\n\nimport { importSpecs } from './import-specs';\nimport { writeSpecs } from './write-specs';\n\n/**\n * Generate client/spec files for a single Orval project.\n *\n * @param workspace - Absolute or relative workspace path used to resolve imports.\n * @param options - Normalized generation options for this project.\n * @param projectName - Optional project name used in logging output.\n * @returns A promise that resolves once generation (and optional cleaning) completes.\n *\n * @example\n * await generateSpec(process.cwd(), normalizedOptions, 'my-project');\n */\nexport async function generateSpec(\n workspace: string,\n options: NormalizedOptions,\n projectName?: string,\n) {\n if (options.output.clean) {\n const extraPatterns = Array.isArray(options.output.clean)\n ? options.output.clean\n : [];\n\n if (options.output.target) {\n await removeFilesAndEmptyFolders(\n ['**/*', '!**/*.d.ts', ...extraPatterns],\n getFileInfo(options.output.target).dirname,\n );\n }\n if (options.output.schemas) {\n const schemasPath = isString(options.output.schemas)\n ? options.output.schemas\n : options.output.schemas.path;\n await removeFilesAndEmptyFolders(\n ['**/*', '!**/*.d.ts', ...extraPatterns],\n getFileInfo(schemasPath).dirname,\n );\n }\n log(`${projectName} Cleaning output folder`);\n }\n\n const writeSpecBuilder = await importSpecs(workspace, options, projectName);\n await writeSpecs(writeSpecBuilder, workspace, options, projectName);\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { type Config, type ConfigExternal, isFunction } from '@orval/core';\nimport { createJiti } from 'jiti';\n\n/**\n * Resolve the Orval config file path.\n *\n * @param configFilePath - Optional path to the config file (absolute or relative).\n * @returns The absolute path to the resolved config file.\n * @throws If a provided path does not exist or if no config file is found.\n *\n * @example\n * // explicit path\n * const p = findConfigFile('./orval.config.ts');\n *\n * @example\n * // automatic discovery (searches process.cwd())\n * const p = findConfigFile();\n */\nexport function findConfigFile(configFilePath?: string) {\n if (configFilePath) {\n const absolutePath = path.isAbsolute(configFilePath)\n ? configFilePath\n : path.resolve(process.cwd(), configFilePath);\n\n if (!fs.existsSync(absolutePath))\n throw new Error(`Config file ${configFilePath} does not exist`);\n\n return absolutePath;\n }\n\n const root = process.cwd();\n const exts = ['.ts', '.js', '.mjs', '.mts'];\n for (const ext of exts) {\n const fullPath = path.resolve(root, `orval.config${ext}`);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n\n throw new Error(`No config file found in ${root}`);\n}\n\n/**\n * Load an Orval config file\n * @param configFilePath - Path to the config file (absolute or relative).\n * @returns The resolved Orval `Config` object.\n * @throws If the module does not provide a default export or the default export resolves to `undefined`.\n *\n * @example\n * // load a config object\n * const cfg = await loadConfigFile('./orval.config.ts');\n */\nexport async function loadConfigFile(configFilePath: string): Promise<Config> {\n const jiti = createJiti(process.cwd(), {\n interopDefault: true,\n });\n\n const configExternal = await jiti.import<ConfigExternal | undefined>(\n configFilePath,\n {\n default: true,\n },\n );\n\n if (configExternal === undefined) {\n throw new Error(`${configFilePath} doesn't have a default export`);\n }\n\n const config = await (isFunction(configExternal)\n ? configExternal()\n : configExternal);\n\n return config;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACuCA,MAAM,iBAAiB,aAAa;AAEpC,MAAM,sBACJ,cACA,WACG;CACH,MAAM,iBAAiB,SAAS;CAGhC,MAAM,mBAAqC;EACzC,OAAO,MAAM,EAAE,MAAM,SAAS,CAAC,EAAE;EACjC,mBAAmB,MAAM,EAAE,MAAM,mBAAmB,CAAC,EAAE;EACvD,SAAS,eAAe,OAAO,SAAS,QAAQ;EAChD,iBAAiB,MAAM;GAAE;GAAQ,MAAM;GAAiB,CAAC,EAAE;EAC3D,eAAe,MAAM;GAAE;GAAQ,MAAM;GAAe,CAAC,EAAE;EACvD,eAAe,YAAY,EAAE;EAC7B,eAAe,MAAM;GAAE;GAAQ,MAAM;GAAe,CAAC,EAAE;EACvD,gBAAgB,MAAM;GAAE;GAAQ,MAAM;GAAgB,CAAC,EAAE;E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,SAAS,YAAY;;;;;;;;;;;;;;;;;;;AC9BrE,SAAgB,eAAe,gBAAyB;AACtD,KAAI,gBAAgB;EAClB,MAAM,eAAe,KAAK,WAAW,eAAe,GAChD,iBACA,KAAK,QAAQ,QAAQ,KAAK,EAAE,eAAe;AAE/C,MAAI,CAACC,KAAG,WAAW,aAAa,CAC9B,OAAM,IAAI,MAAM,eAAe,eAAe,iBAAiB;AAEjE,SAAO;;CAGT,MAAM,OAAO,QAAQ,KAAK;AAE1B,MAAK,MAAM,OADE;EAAC;EAAO;EAAO;EAAQ;EAAO,EACnB;EACtB,MAAM,WAAW,KAAK,QAAQ,MAAM,eAAe,MAAM;AACzD,MAAIA,KAAG,WAAW,SAAS,CACzB,QAAO;;AAIX,OAAM,IAAI,MAAM,2BAA2B,OAAO;;;;;;;;;;;;AAapD,eAAsB,eAAe,gBAAyC;CAK5E,MAAM,iBAAiB,MAJV,WAAW,QAAQ,KAAK,EAAE,EACrC,gBAAgB,MACjB,CAAC,CAEgC,OAChC,gBACA,EACE,SAAS,MACV,CACF;AAED,KAAI,mBAAmB,KAAA,EACrB,OAAM,IAAI,MAAM,GAAG,eAAe,gCAAgC;AAOpE,QAJe,OAAO,WAAW,eAAe,GAC5C,gBAAgB,GAChB"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as defineConfig, i as startWatcher, n as loadConfigFile, o as defineTransformer, r as generateSpec, s as normalizeOptions, t as findConfigFile } from "./config-
|
|
1
|
+
import { a as defineConfig, i as startWatcher, n as loadConfigFile, o as defineTransformer, r as generateSpec, s as normalizeOptions, t as findConfigFile } from "./config-D0MzallH.mjs";
|
|
2
2
|
import { getWarningCount, isString, logError, resetWarnings, setVerbose } from "@orval/core";
|
|
3
3
|
export * from "@orval/core";
|
|
4
4
|
//#region src/generate.ts
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orval",
|
|
3
3
|
"description": "A swagger client generator for typescript",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.11.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -72,17 +72,17 @@
|
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@commander-js/extra-typings": "^14.0.0",
|
|
75
|
-
"@orval/angular": "8.
|
|
76
|
-
"@orval/axios": "8.
|
|
77
|
-
"@orval/core": "8.
|
|
78
|
-
"@orval/fetch": "8.
|
|
79
|
-
"@orval/hono": "8.
|
|
80
|
-
"@orval/mcp": "8.
|
|
81
|
-
"@orval/mock": "8.
|
|
82
|
-
"@orval/query": "8.
|
|
83
|
-
"@orval/solid-start": "8.
|
|
84
|
-
"@orval/swr": "8.
|
|
85
|
-
"@orval/zod": "8.
|
|
75
|
+
"@orval/angular": "8.11.0",
|
|
76
|
+
"@orval/axios": "8.11.0",
|
|
77
|
+
"@orval/core": "8.11.0",
|
|
78
|
+
"@orval/fetch": "8.11.0",
|
|
79
|
+
"@orval/hono": "8.11.0",
|
|
80
|
+
"@orval/mcp": "8.11.0",
|
|
81
|
+
"@orval/mock": "8.11.0",
|
|
82
|
+
"@orval/query": "8.11.0",
|
|
83
|
+
"@orval/solid-start": "8.11.0",
|
|
84
|
+
"@orval/swr": "8.11.0",
|
|
85
|
+
"@orval/zod": "8.11.0",
|
|
86
86
|
"@scalar/json-magic": "^0.12.8",
|
|
87
87
|
"@scalar/openapi-parser": "^0.25.12",
|
|
88
88
|
"@scalar/openapi-types": "0.8.0",
|
|
@@ -92,12 +92,12 @@
|
|
|
92
92
|
"execa": "^9.6.1",
|
|
93
93
|
"find-up": "8.0.0",
|
|
94
94
|
"fs-extra": "^11.3.2",
|
|
95
|
+
"get-tsconfig": "^4.14.0",
|
|
95
96
|
"jiti": "^2.6.1",
|
|
96
97
|
"js-yaml": "4.1.1",
|
|
97
98
|
"remeda": "^2.33.6",
|
|
98
99
|
"string-argv": "^0.3.2",
|
|
99
|
-
"
|
|
100
|
-
"typedoc": "^0.28.17",
|
|
100
|
+
"typedoc": "^0.28.19",
|
|
101
101
|
"typedoc-plugin-coverage": "^4.0.2",
|
|
102
102
|
"typedoc-plugin-markdown": "^4.10.0"
|
|
103
103
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-DHMhmS0P.mjs","names":["validateSpec","isNullish","fs","nodePath","path","pkg.name","pkg.version","version","fs"],"sources":["../package.json","../src/client.ts","../src/api.ts","../src/import-open-api.ts","../src/import-specs.ts","../src/formatters/prettier.ts","../src/utils/execute-hook.ts","../src/utils/package-json.ts","../src/utils/tsconfig.ts","../src/utils/options.ts","../src/utils/watcher.ts","../src/write-zod-specs.ts","../src/write-specs.ts","../src/generate-spec.ts","../src/utils/config.ts"],"sourcesContent":["","import angular from '@orval/angular';\nimport axios from '@orval/axios';\nimport type {\n AngularOptions,\n ClientFileBuilder,\n ClientGeneratorsBuilder,\n ClientMockBuilder,\n ClientMockGeneratorBuilder,\n ContextSpec,\n GeneratorClientFooter,\n GeneratorClientHeader,\n GeneratorClientImports,\n GeneratorClients,\n GeneratorClientTitle,\n GeneratorOperations,\n GeneratorOptions,\n GeneratorVerbOptions,\n GeneratorVerbsOptions,\n NormalizedOutputOptions,\n OutputClientFunc,\n} from '@orval/core';\nimport {\n asyncReduce,\n generateDependencyImports,\n getBaseUrlRuntimeImports,\n isFunction,\n logWarning,\n OutputClient,\n pascal,\n} from '@orval/core';\nimport fetchClient from '@orval/fetch';\nimport hono from '@orval/hono';\nimport mcp from '@orval/mcp';\nimport * as mock from '@orval/mock';\nimport query from '@orval/query';\nimport solidStart from '@orval/solid-start';\nimport swr from '@orval/swr';\nimport zod from '@orval/zod';\n\nconst DEFAULT_CLIENT = OutputClient.AXIOS;\n\nconst getGeneratorClient = (\n outputClient: OutputClient | OutputClientFunc,\n output: NormalizedOutputOptions,\n) => {\n const angularBuilder = angular() as (\n options?: AngularOptions,\n ) => ClientGeneratorsBuilder;\n const GENERATOR_CLIENT: GeneratorClients = {\n axios: axios({ type: 'axios' })(),\n 'axios-functions': axios({ type: 'axios-functions' })(),\n angular: angularBuilder(output.override.angular),\n 'angular-query': query({ output, type: 'angular-query' })(),\n 'react-query': query({ output, type: 'react-query' })(),\n 'solid-start': solidStart()(),\n 'solid-query': query({ output, type: 'solid-query' })(),\n 'svelte-query': query({ output, type: 'svelte-query' })(),\n 'vue-query': query({ output, type: 'vue-query' })(),\n swr: swr()(),\n zod: zod()(),\n hono: hono()(),\n fetch: fetchClient()(),\n mcp: mcp()(),\n };\n\n const generator = isFunction(outputClient)\n ? outputClient(GENERATOR_CLIENT)\n : GENERATOR_CLIENT[outputClient];\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- defensive guard for custom OutputClientFunc returning unexpected values\n if (!generator) {\n throw new Error(\n `Unknown output client provided to getGeneratorClient: ${String(outputClient)}`,\n );\n }\n\n return generator;\n};\n\nexport const generateClientImports: GeneratorClientImports = ({\n client,\n implementation,\n imports,\n projectName,\n hasSchemaDir,\n isAllowSyntheticDefaultImports,\n hasGlobalMutator,\n hasTagsMutator,\n hasParamsSerializerOptions,\n packageJson,\n output,\n}) => {\n const { dependencies } = getGeneratorClient(client, output);\n return generateDependencyImports(\n implementation,\n dependencies\n ? [\n ...dependencies(\n hasGlobalMutator,\n hasParamsSerializerOptions,\n packageJson,\n output.httpClient,\n hasTagsMutator,\n output.override,\n ),\n ...imports,\n ]\n : (imports as Parameters<typeof generateDependencyImports>[1]),\n projectName,\n hasSchemaDir,\n isAllowSyntheticDefaultImports,\n );\n};\n\nexport const generateClientHeader: GeneratorClientHeader = ({\n outputClient = DEFAULT_CLIENT,\n isRequestOptions,\n isGlobalMutator,\n isMutator,\n provideIn,\n hasAwaitedType,\n titles,\n output,\n verbOptions,\n tag,\n clientImplementation,\n}) => {\n const { header } = getGeneratorClient(outputClient, output);\n return {\n implementation: header\n ? header({\n title: titles.implementation,\n isRequestOptions,\n isGlobalMutator,\n isMutator,\n provideIn,\n hasAwaitedType,\n output,\n verbOptions,\n tag,\n clientImplementation,\n })\n : '',\n implementationMock: `export const ${titles.implementationMock} = () => [\\n`,\n };\n};\n\nexport const generateClientFooter: GeneratorClientFooter = ({\n outputClient,\n operationNames,\n hasMutator,\n hasAwaitedType,\n titles,\n output,\n}) => {\n const { footer } = getGeneratorClient(outputClient, output);\n\n if (!footer) {\n return {\n implementation: '',\n implementationMock: `\\n]\\n`,\n };\n }\n\n let implementation: string;\n try {\n if (isFunction(outputClient)) {\n implementation = (\n footer as unknown as (operationNames: string[]) => string\n )(operationNames);\n // being here means that the previous call worked\n logWarning(\n '⚠️ Passing an array of strings for operations names to the footer function is deprecated and will be removed in a future major release. Please pass them in an object instead: { operationNames: string[] }.',\n );\n } else {\n implementation = footer({\n operationNames,\n title: titles.implementation,\n hasMutator,\n hasAwaitedType,\n });\n }\n } catch {\n implementation = footer({\n operationNames,\n title: titles.implementation,\n hasMutator,\n hasAwaitedType,\n });\n }\n\n return {\n implementation,\n implementationMock: `]\\n`,\n };\n};\n\nexport const generateClientTitle: GeneratorClientTitle = ({\n outputClient = DEFAULT_CLIENT,\n title,\n customTitleFunc,\n output,\n}) => {\n const { title: generatorTitle } = getGeneratorClient(outputClient, output);\n\n if (!generatorTitle) {\n return {\n implementation: '',\n implementationMock: `get${pascal(title)}Mock`,\n };\n }\n\n if (customTitleFunc) {\n const customTitle = customTitleFunc(title);\n return {\n implementation: generatorTitle(customTitle),\n implementationMock: `get${pascal(customTitle)}Mock`,\n };\n }\n return {\n implementation: generatorTitle(title),\n implementationMock: `get${pascal(title)}Mock`,\n };\n};\n\nconst generateMock = (\n verbOption: GeneratorVerbOptions,\n options: GeneratorOptions,\n): ClientMockGeneratorBuilder => {\n if (!options.mock) {\n return {\n implementation: {\n function: '',\n handler: '',\n handlerName: '',\n },\n imports: [],\n };\n }\n\n if (isFunction(options.mock)) {\n return options.mock(verbOption, options);\n }\n\n return mock.generateMock(\n verbOption,\n options as typeof options & {\n mock: Exclude<(typeof options)['mock'], ClientMockBuilder | undefined>;\n },\n );\n};\n\nexport const generateOperations = (\n outputClient: OutputClient | OutputClientFunc = DEFAULT_CLIENT,\n verbsOptions: GeneratorVerbsOptions,\n options: GeneratorOptions,\n output: NormalizedOutputOptions,\n): Promise<GeneratorOperations> => {\n const baseUrlImports = getBaseUrlRuntimeImports(output.baseUrl);\n\n return asyncReduce(\n verbsOptions,\n async (acc, verbOption) => {\n const { client: generatorClient } = getGeneratorClient(\n outputClient,\n output,\n );\n const client = await generatorClient(\n verbOption,\n options,\n outputClient,\n output,\n );\n\n if (!client.implementation) {\n return acc;\n }\n\n const generatedMock = generateMock(verbOption, options);\n\n const hasImplementation = client.implementation.trim().length > 0;\n const preferredOperationKey = verbOption.operationName;\n const baseOperationKey = verbOption.operationId\n ? `${verbOption.operationId}::${verbOption.operationName}`\n : verbOption.operationName;\n let operationKey = Object.hasOwn(acc, preferredOperationKey)\n ? baseOperationKey\n : preferredOperationKey;\n let collisionIndex = 1;\n\n while (Object.hasOwn(acc, operationKey)) {\n collisionIndex += 1;\n operationKey = `${baseOperationKey}::${collisionIndex}`;\n }\n\n acc[operationKey] = {\n implementation: hasImplementation\n ? (client.docComment ?? verbOption.doc) + client.implementation\n : client.implementation,\n imports: [...baseUrlImports, ...client.imports],\n implementationMock: generatedMock.implementation,\n importsMock: generatedMock.imports,\n tags: verbOption.tags,\n mutator: verbOption.mutator,\n clientMutators: client.mutators,\n formData: verbOption.formData,\n formUrlEncoded: verbOption.formUrlEncoded,\n paramsSerializer: verbOption.paramsSerializer,\n operationName: verbOption.operationName,\n fetchReviver: verbOption.fetchReviver,\n };\n\n return acc;\n },\n {} as GeneratorOperations,\n );\n};\n\nexport const generateExtraFiles = (\n outputClient: OutputClient | OutputClientFunc = DEFAULT_CLIENT,\n verbsOptions: Record<string, GeneratorVerbOptions>,\n output: NormalizedOutputOptions,\n context: ContextSpec,\n): Promise<ClientFileBuilder[]> => {\n const { extraFiles: generateExtraFiles } = getGeneratorClient(\n outputClient,\n output,\n );\n\n if (!generateExtraFiles) {\n return Promise.resolve([]);\n }\n\n return generateExtraFiles(verbsOptions, output, context);\n};\n","import {\n asyncReduce,\n type ContextSpec,\n generateVerbsOptions,\n type GeneratorApiBuilder,\n type GeneratorApiOperations,\n type GeneratorSchema,\n getFullRoute,\n getRoute,\n GetterPropType,\n isReference,\n type NormalizedInputOptions,\n type NormalizedOutputOptions,\n type OpenApiPathItemObject,\n resolveRef,\n} from '@orval/core';\nimport { generateMockImports } from '@orval/mock';\n\nimport {\n generateClientFooter,\n generateClientHeader,\n generateClientImports,\n generateClientTitle,\n generateExtraFiles,\n generateOperations,\n} from './client';\n\nexport async function getApiBuilder({\n input,\n output,\n context,\n}: {\n input: NormalizedInputOptions;\n output: NormalizedOutputOptions;\n context: ContextSpec;\n}): Promise<GeneratorApiBuilder> {\n const api = await asyncReduce(\n Object.entries(context.spec.paths ?? {}),\n async (acc, [pathRoute, verbs]) => {\n if (!verbs) {\n return acc;\n }\n\n const route = getRoute(pathRoute);\n\n let resolvedVerbs: OpenApiPathItemObject = verbs;\n\n if (isReference(verbs)) {\n const { schema }: { schema: OpenApiPathItemObject } = resolveRef(\n verbs,\n context,\n );\n\n resolvedVerbs = schema;\n }\n\n let verbsOptions = await generateVerbsOptions({\n verbs: resolvedVerbs,\n input,\n output,\n route,\n pathRoute,\n context,\n });\n\n // GitHub #564 check if we want to exclude deprecated operations\n if (output.override.useDeprecatedOperations === false) {\n verbsOptions = verbsOptions.filter((verb) => {\n return !verb.deprecated;\n });\n }\n\n const schemas: GeneratorSchema[] = [];\n for (const {\n queryParams,\n headers,\n body,\n response,\n props,\n } of verbsOptions) {\n schemas.push(\n ...props.flatMap((param) =>\n param.type === GetterPropType.NAMED_PATH_PARAMS ? param.schema : [],\n ),\n );\n if (queryParams) {\n schemas.push(queryParams.schema, ...queryParams.deps);\n }\n if (headers) {\n schemas.push(headers.schema, ...headers.deps);\n }\n\n schemas.push(...body.schemas, ...response.schemas);\n }\n\n const fullRoute = getFullRoute(\n route,\n resolvedVerbs.servers ?? context.spec.servers,\n output.baseUrl,\n );\n if (!output.target) {\n throw new Error('Output does not have a target');\n }\n const pathOperations = await generateOperations(\n output.client,\n verbsOptions,\n {\n route: fullRoute,\n pathRoute,\n override: output.override,\n context,\n mock: output.mock,\n output: output.target,\n },\n output,\n );\n\n for (const verbOption of verbsOptions) {\n acc.verbOptions[verbOption.operationId] = verbOption;\n }\n acc.schemas.push(...schemas);\n acc.operations = { ...acc.operations, ...pathOperations };\n\n return acc;\n },\n {\n operations: {},\n verbOptions: {},\n schemas: [],\n } as GeneratorApiOperations,\n );\n\n const extraFiles = await generateExtraFiles(\n output.client,\n api.verbOptions,\n output,\n context,\n );\n\n return {\n operations: api.operations,\n schemas: api.schemas,\n verbOptions: api.verbOptions,\n title: generateClientTitle,\n header: generateClientHeader,\n footer: generateClientFooter,\n imports: generateClientImports,\n importsMock: generateMockImports,\n extraFiles,\n };\n}\n","import {\n collectReferencedComponents,\n type ContextSpec,\n dynamicImport,\n generateComponentDefinition,\n generateParameterDefinition,\n generateSchemasDefinition,\n type ImportOpenApi,\n type InputOptions,\n type NormalizedOutputOptions,\n type OpenApiComponentsObject,\n type OpenApiDocument,\n type OverrideInput,\n type WriteSpecBuilder,\n} from '@orval/core';\nimport { validate } from '@scalar/openapi-parser';\nimport { pick } from 'remeda';\n\nimport { getApiBuilder } from './api';\n\nfunction filterSpecComponents(\n spec: OpenApiDocument,\n input: InputOptions,\n): OpenApiDocument {\n const filters = input.filters;\n if (!filters?.tags || filters.schemas) return spec;\n\n const referenced = collectReferencedComponents(\n spec,\n filters.tags,\n filters.mode,\n );\n\n return {\n ...spec,\n components: {\n ...spec.components,\n schemas: pick(spec.components?.schemas ?? {}, referenced.schemas),\n responses: pick(spec.components?.responses ?? {}, referenced.responses),\n parameters: pick(\n spec.components?.parameters ?? {},\n referenced.parameters,\n ),\n requestBodies: pick(\n spec.components?.requestBodies ?? {},\n referenced.requestBodies,\n ),\n },\n };\n}\n\nexport async function importOpenApi({\n spec,\n input,\n output,\n target,\n workspace,\n projectName,\n}: ImportOpenApi): Promise<WriteSpecBuilder> {\n const transformedOpenApi = await applyTransformer(\n spec,\n input.override.transformer,\n workspace,\n input.unsafeDisableValidation,\n );\n\n const filteredSpec = filterSpecComponents(transformedOpenApi, input);\n\n const schemas = getApiSchemas({\n input,\n output,\n target,\n workspace,\n spec: filteredSpec,\n });\n\n const api = await getApiBuilder({\n input,\n output,\n context: {\n projectName,\n target,\n workspace,\n spec: filteredSpec,\n output,\n } satisfies ContextSpec,\n });\n\n return {\n ...api,\n schemas: [...schemas, ...api.schemas],\n target,\n // a valid spec will have info\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n info: filteredSpec.info!,\n spec: filteredSpec,\n };\n}\n\nasync function applyTransformer(\n openApi: OpenApiDocument,\n transformer: OverrideInput['transformer'],\n workspace: string,\n unsafeDisableValidation = false,\n): Promise<OpenApiDocument> {\n const transformerFn = transformer\n ? await dynamicImport(transformer, workspace)\n : undefined;\n\n if (!transformerFn) {\n return openApi;\n }\n\n const transformedOpenApi = transformerFn(openApi);\n\n if (!unsafeDisableValidation) {\n const { valid, errors } = await validate(transformedOpenApi);\n if (!valid) {\n throw new Error(`Validation failed`, { cause: errors });\n }\n }\n\n return transformedOpenApi;\n}\n\ninterface GetApiSchemasOptions {\n input: InputOptions;\n output: NormalizedOutputOptions;\n workspace: string;\n target: string;\n spec: OpenApiDocument;\n}\n\nfunction getApiSchemas({\n input,\n output,\n target,\n workspace,\n spec,\n}: GetApiSchemasOptions) {\n const context: ContextSpec = {\n target,\n workspace,\n spec,\n output,\n };\n\n const schemaDefinition = generateSchemasDefinition(\n spec.components?.schemas,\n context,\n output.override.components.schemas.suffix,\n input.filters,\n );\n\n const responseDefinition = generateComponentDefinition(\n spec.components?.responses,\n context,\n output.override.components.responses.suffix,\n );\n\n const swaggerResponseDefinition = generateComponentDefinition(\n 'responses' in spec\n ? (spec as { responses?: OpenApiComponentsObject['responses'] }).responses\n : undefined,\n context,\n '',\n );\n\n const bodyDefinition = generateComponentDefinition(\n spec.components?.requestBodies,\n context,\n output.override.components.requestBodies.suffix,\n );\n\n const parameters = generateParameterDefinition(\n spec.components?.parameters,\n context,\n output.override.components.parameters.suffix,\n );\n\n const schemas = [\n ...schemaDefinition,\n ...responseDefinition,\n ...swaggerResponseDefinition,\n ...bodyDefinition,\n ...parameters,\n ];\n\n return schemas;\n}\n","import {\n isObject,\n isString,\n logWarning,\n type NormalizedOptions,\n type OpenApiDocument,\n type WriteSpecBuilder,\n} from '@orval/core';\nimport { bundle } from '@scalar/json-magic/bundle';\nimport {\n fetchUrls,\n parseJson,\n parseYaml,\n readFiles,\n} from '@scalar/json-magic/bundle/plugins/node';\nimport { upgrade, validate as validateSpec } from '@scalar/openapi-parser';\nimport { isNullish } from 'remeda';\n\nimport { importOpenApi } from './import-open-api';\n\nasync function resolveSpec(\n input: string | Record<string, unknown>,\n parserOptions?: {\n headers?: {\n domains: string[];\n headers: Record<string, string>;\n }[];\n },\n unsafeDisableValidation = false,\n): Promise<OpenApiDocument> {\n const data = await bundle(input, {\n plugins: [\n readFiles(),\n fetchUrls({\n headers: parserOptions?.headers,\n }),\n parseJson(),\n parseYaml(),\n ],\n treeShake: false,\n });\n const dereferencedData = dereferenceExternalRef(\n data as Record<string, unknown>,\n );\n\n if (unsafeDisableValidation) {\n logWarning(\n `🚨 OpenAPI spec validation is disabled.\\n` +\n ` Code generation with invalid specs is not guaranteed to work and may break in minor updates.\\n` +\n ` Bug reports with validation disabled will not be accepted.`,\n );\n } else {\n validateComponentKeys(dereferencedData);\n\n const { valid, errors } = await validateSpec(dereferencedData);\n if (!valid) {\n throw new Error(\n `OpenAPI spec validation failed:\\n${JSON.stringify(errors, undefined, 2)}`,\n );\n }\n }\n\n const { specification } = upgrade(dereferencedData);\n\n return specification;\n}\n\nexport async function importSpecs(\n workspace: string,\n options: NormalizedOptions,\n projectName?: string,\n): Promise<WriteSpecBuilder> {\n const { input, output } = options;\n\n const spec = await resolveSpec(\n input.target,\n input.parserOptions,\n input.unsafeDisableValidation,\n );\n\n return importOpenApi({\n spec,\n input,\n output,\n target: isString(input.target) ? input.target : workspace,\n workspace,\n projectName,\n });\n}\n\nconst COMPONENT_KEY_PATTERN = /^[a-zA-Z0-9.\\-_]+$/;\n\nconst COMPONENT_SECTIONS = [\n 'schemas',\n 'responses',\n 'parameters',\n 'examples',\n 'requestBodies',\n 'headers',\n 'securitySchemes',\n 'links',\n 'callbacks',\n 'pathItems', // OAS 3.1.0+\n] as const;\n\n/**\n * Validate that all component keys conform to the OAS regex: ^[a-zA-Z0-9.\\-_]+$\n * @see https://spec.openapis.org/oas/v3.0.3.html#fixed-fields-5\n * @see https://spec.openapis.org/oas/v3.1.0#fixed-fields-5\n */\nexport function validateComponentKeys(data: Record<string, unknown>): void {\n const components = data.components;\n if (!isObject(components)) return;\n\n const invalidKeys: string[] = [];\n\n for (const section of COMPONENT_SECTIONS) {\n const sectionObj = components[section];\n if (!isObject(sectionObj)) continue;\n\n for (const key of Object.keys(sectionObj)) {\n if (!COMPONENT_KEY_PATTERN.test(key)) {\n invalidKeys.push(`components.${section}.${key}`);\n }\n }\n }\n\n if (invalidKeys.length > 0) {\n throw new Error(\n `Invalid component key${invalidKeys.length > 1 ? 's' : ''} found. ` +\n `OpenAPI component keys must match the pattern ${COMPONENT_KEY_PATTERN} ` +\n `(non-ASCII characters are not allowed per the spec).\\n` +\n ` See: https://spec.openapis.org/oas/v3.0.3.html#components-object\\n` +\n ` Invalid keys:\\n` +\n invalidKeys.map((k) => ` - ${k}`).join('\\n'),\n );\n }\n}\n\n/**\n * The plugins from `@scalar/json-magic` does not dereference $ref.\n * Instead it fetches them and puts them under x-ext, and changes the $ref to point to #x-ext/<name>.\n * This function:\n * 1. Merges external schemas into main spec's components.schemas (with collision handling)\n * 2. Replaces x-ext refs with standard component refs or inlined content\n */\nexport function dereferenceExternalRef(\n data: Record<string, unknown>,\n): Record<string, unknown> {\n const extensions = (data['x-ext'] ?? {}) as Record<string, unknown>;\n\n // Step 1: Merge external schemas into main spec with collision handling\n const schemaNameMappings = mergeExternalSchemas(data, extensions);\n\n // Step 2: Replace all x-ext refs throughout the document\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(data)) {\n if (key !== 'x-ext') {\n result[key] = replaceXExtRefs(value, extensions, schemaNameMappings);\n }\n }\n\n return result;\n}\n\n/**\n * Merge external document schemas into main spec's components.schemas\n * Returns mapping of original schema names to final names (with suffixes for collisions)\n */\nfunction mergeExternalSchemas(\n data: Record<string, unknown>,\n extensions: Record<string, unknown>,\n): Record<string, Record<string, string>> {\n const schemaNameMappings: Record<string, Record<string, string>> = {};\n\n if (Object.keys(extensions).length === 0) return schemaNameMappings;\n\n data.components ??= {};\n const mainComponents = data.components as Record<string, unknown>;\n mainComponents.schemas ??= {};\n const mainSchemas = mainComponents.schemas as Record<string, unknown>;\n\n // Merge schemas from each external doc\n // Collision handling:\n // - If schema already exists in main spec, add x-ext key as suffix (e.g., User -> User_external1)\n // - x-ext refs in main spec get replaced by actual schema from external doc\n for (const [extKey, extDoc] of Object.entries(extensions)) {\n schemaNameMappings[extKey] = {};\n\n if (isObject(extDoc) && 'components' in extDoc) {\n const extComponents = extDoc.components as Record<string, unknown>;\n if (isObject(extComponents) && 'schemas' in extComponents) {\n const extSchemas = extComponents.schemas as Record<string, unknown>;\n for (const [schemaName, schema] of Object.entries(extSchemas)) {\n // Check if main schema is just an x-ext ref - if so, replace it without suffix\n const existingSchema = mainSchemas[schemaName];\n const isXExtRef =\n isObject(existingSchema) &&\n '$ref' in existingSchema &&\n isString(existingSchema.$ref) &&\n existingSchema.$ref.startsWith('#/x-ext/');\n\n let finalSchemaName = schemaName;\n\n if (schemaName in mainSchemas && !isXExtRef) {\n // Collision: add suffix to external schema\n const suffix = extKey.replaceAll(/[^a-zA-Z0-9]/g, '_');\n finalSchemaName = `${schemaName}_${suffix}`;\n schemaNameMappings[extKey][schemaName] = finalSchemaName;\n } else {\n // No collision or replacing x-ext ref\n schemaNameMappings[extKey][schemaName] = schemaName;\n }\n\n mainSchemas[finalSchemaName] = scrubUnwantedKeys(schema);\n }\n }\n }\n }\n\n // Apply internal ref updates to all schemas from external docs\n for (const [extKey, mapping] of Object.entries(schemaNameMappings)) {\n for (const [, finalName] of Object.entries(mapping)) {\n const schema = mainSchemas[finalName];\n if (schema) {\n mainSchemas[finalName] = updateInternalRefs(\n schema,\n extKey,\n schemaNameMappings,\n ) as Record<string, unknown>;\n }\n }\n }\n\n return schemaNameMappings;\n}\n\n/**\n * Remove unwanted keys like $schema and $id from objects\n */\nfunction scrubUnwantedKeys(obj: unknown): unknown {\n const UNWANTED_KEYS = new Set(['$schema', '$id']);\n\n if (obj === null || obj === undefined) return obj;\n if (Array.isArray(obj)) return obj.map((x) => scrubUnwantedKeys(x));\n if (isObject(obj)) {\n const rec = obj;\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(rec)) {\n if (UNWANTED_KEYS.has(k)) continue;\n out[k] = scrubUnwantedKeys(v);\n }\n return out;\n }\n return obj;\n}\n\n/**\n * Update internal refs within an external schema to use suffixed names\n */\nfunction updateInternalRefs(\n obj: unknown,\n extKey: string,\n schemaNameMappings: Record<string, Record<string, string>>,\n): unknown {\n if (obj === null || obj === undefined) return obj;\n\n if (Array.isArray(obj)) {\n return obj.map((element) =>\n updateInternalRefs(element, extKey, schemaNameMappings),\n );\n }\n\n if (isObject(obj)) {\n const record = obj;\n\n // Check if this is a $ref to #/components/schemas/...\n if ('$ref' in record && isString(record.$ref)) {\n const refValue = record.$ref;\n if (refValue.startsWith('#/components/schemas/')) {\n const schemaName = refValue.replace('#/components/schemas/', '');\n // If this schema was mapped to a suffixed name, update the ref\n const mappedName = schemaNameMappings[extKey][schemaName];\n if (mappedName) {\n return {\n $ref: `#/components/schemas/${mappedName}`,\n };\n }\n }\n }\n\n // Recursively process all properties\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(record)) {\n result[key] = updateInternalRefs(value, extKey, schemaNameMappings);\n }\n return result;\n }\n\n return obj;\n}\n\n/**\n * Replace x-ext refs with either standard component refs or inlined content\n */\nfunction replaceXExtRefs(\n obj: unknown,\n extensions: Record<string, unknown>,\n schemaNameMappings: Record<string, Record<string, string>>,\n): unknown {\n if (isNullish(obj)) return obj;\n\n if (Array.isArray(obj)) {\n return obj.map((element) =>\n replaceXExtRefs(element, extensions, schemaNameMappings),\n );\n }\n\n if (isObject(obj)) {\n const record = obj;\n\n // Check if this object is a $ref to x-ext\n if ('$ref' in record && isString(record.$ref)) {\n const refValue = record.$ref;\n if (refValue.startsWith('#/x-ext/')) {\n // Parse the x-ext ref\n const pathStr = refValue.replace('#/x-ext/', '');\n const parts = pathStr.split('/');\n const extKey = parts.shift();\n\n if (extKey) {\n // Check if this is a ref to components/schemas - if so, replace with standard ref\n if (\n parts.length >= 3 &&\n parts[0] === 'components' &&\n parts[1] === 'schemas'\n ) {\n const schemaName = parts.slice(2).join('/');\n // Use the mapped name (which may include suffix for collisions)\n const finalName =\n schemaNameMappings[extKey][schemaName] || schemaName;\n return { $ref: `#/components/schemas/${finalName}` };\n }\n\n // Otherwise, inline the referenced content\n const extDoc = extensions[extKey];\n let refObj: unknown = extDoc;\n for (const p of parts) {\n if (\n refObj &&\n (isObject(refObj) || Array.isArray(refObj)) &&\n p in (refObj as Record<string, unknown>)\n ) {\n refObj = (refObj as Record<string, unknown>)[p];\n } else {\n refObj = undefined;\n break;\n }\n }\n\n if (refObj) {\n const cleaned = scrubUnwantedKeys(refObj);\n return replaceXExtRefs(cleaned, extensions, schemaNameMappings);\n }\n }\n }\n }\n\n // Recursively process all properties\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(record)) {\n result[key] = replaceXExtRefs(value, extensions, schemaNameMappings);\n }\n return result;\n }\n\n return obj;\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { logWarning } from '@orval/core';\nimport { execa } from 'execa';\n\n/**\n * Format files with prettier.\n * Tries the programmatic API first (project dependency),\n * then falls back to the globally installed CLI.\n */\nexport async function formatWithPrettier(\n paths: string[],\n projectTitle?: string,\n): Promise<void> {\n const prettier = await tryImportPrettier();\n\n if (prettier) {\n const filePaths = [...new Set(await collectFilePaths(paths))];\n if (filePaths.length === 0) {\n return;\n }\n\n const config = (await prettier.resolveConfig(filePaths[0])) ?? {};\n await Promise.all(\n filePaths.map(async (filePath) => {\n try {\n const content = await fs.readFile(filePath, 'utf8');\n const formatted = await prettier.format(content, {\n ...config,\n // options.filepath can be specified for Prettier to infer the parser from the file extension\n filepath: filePath,\n });\n await fs.writeFile(filePath, formatted);\n } catch (error) {\n if (isMissingFileError(error)) {\n return;\n }\n\n if (error instanceof Error) {\n // prettier currently doesn't export UndefinedParserError, so having to do it the crude way\n if (error.name === 'UndefinedParserError') {\n // skip files with unsupported parsers\n // https://prettier.io/docs/options#parser\n } else {\n logWarning(\n `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}Failed to format file ${filePath}: ${error.toString()}`,\n );\n }\n } else {\n logWarning(\n `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}Failed to format file ${filePath}: unknown error`,\n );\n }\n }\n }),\n );\n\n return;\n }\n\n // fallback to globally installed prettier\n try {\n await execa('prettier', ['--write', ...paths]);\n } catch {\n logWarning(\n `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}prettier not found. Install it as a project dependency or globally.`,\n );\n }\n}\n\nfunction isMissingFileError(error: unknown): error is NodeJS.ErrnoException {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'code' in error &&\n error.code === 'ENOENT'\n );\n}\n\n/**\n * Try to import prettier from the project's dependencies.\n * Returns undefined if prettier is not installed.\n */\nasync function tryImportPrettier() {\n try {\n return await import('prettier');\n } catch {\n return;\n }\n}\n\n/**\n * Recursively collect absolute file paths from a mix of files and directories.\n */\nasync function collectFilePaths(paths: string[]): Promise<string[]> {\n const results: string[] = [];\n\n for (const p of paths) {\n const absolute = path.resolve(p);\n try {\n const stat = await fs.stat(absolute);\n if (stat.isFile()) {\n results.push(absolute);\n } else if (stat.isDirectory()) {\n const entries = await fs.readdir(absolute);\n const subPaths = entries.map((entry) => path.join(absolute, entry));\n const subFiles = await collectFilePaths(subPaths);\n results.push(...subFiles);\n }\n } catch {\n // Skip paths that don't exist or can't be accessed\n }\n }\n\n return results;\n}\n","import { styleText } from 'node:util';\n\nimport {\n type Hook,\n type HookOption,\n isFunction,\n isObject,\n isString,\n log,\n logError,\n type NormalizedHookCommand,\n} from '@orval/core';\nimport { execa } from 'execa';\nimport { parseArgsStringToArgv } from 'string-argv';\n\nexport const executeHook = async (\n name: Hook,\n commands: NormalizedHookCommand = [],\n args: string[] = [],\n) => {\n log(styleText('white', `Running ${name} hook...`));\n\n for (const command of commands) {\n try {\n if (isString(command)) {\n await executeCommand(command, args);\n } else if (isFunction(command)) {\n await command(args);\n } else if (isObject(command)) {\n await executeObjectCommand(command as HookOption, args);\n }\n } catch (error) {\n logError(error, `Failed to run ${name} hook`);\n }\n }\n};\n\nasync function executeCommand(command: string, args: string[]) {\n const [cmd, ..._args] = [...parseArgsStringToArgv(command), ...args];\n\n await execa(cmd, _args);\n}\n\nasync function executeObjectCommand(command: HookOption, args: string[]) {\n if (command.injectGeneratedDirsAndFiles === false) {\n args = [];\n }\n\n if (isString(command.command)) {\n await executeCommand(command.command, args);\n } else if (isFunction(command.command)) {\n await command.command();\n }\n}\n","import { styleText } from 'node:util';\n\nimport {\n dynamicImport,\n isObject,\n isString,\n logVerbose,\n logWarning,\n type PackageJson,\n resolveInstalledVersions,\n} from '@orval/core';\nimport { findUp, findUpMultiple } from 'find-up';\nimport fs from 'fs-extra';\nimport yaml from 'js-yaml';\n\nimport { normalizePath } from './options';\n\ntype CatalogData = Pick<PackageJson, 'catalog' | 'catalogs'>;\n\nexport const loadPackageJson = async (\n packageJson?: string,\n workspace = process.cwd(),\n): Promise<PackageJson | undefined> => {\n if (!packageJson) {\n const pkgPath = await findUp(['package.json'], { cwd: workspace });\n if (pkgPath) {\n const pkg = await dynamicImport<unknown>(pkgPath, workspace);\n\n if (isPackageJson(pkg)) {\n return resolveAndAttachVersions(\n await maybeReplaceCatalog(pkg, workspace),\n workspace,\n pkgPath,\n );\n } else {\n throw new Error('Invalid package.json file');\n }\n }\n return;\n }\n\n const normalizedPath = normalizePath(packageJson, workspace);\n if (fs.existsSync(normalizedPath)) {\n const pkg = await dynamicImport<unknown>(normalizedPath);\n\n if (isPackageJson(pkg)) {\n return resolveAndAttachVersions(\n await maybeReplaceCatalog(pkg, workspace),\n workspace,\n normalizedPath,\n );\n } else {\n throw new Error(`Invalid package.json file: ${normalizedPath}`);\n }\n }\n return;\n};\n\nconst isPackageJson = (obj: unknown): obj is PackageJson => isObject(obj);\n\nconst resolvedCache = new Map<string, Record<string, string>>();\n\n/** @internal visible for testing */\nexport const _resetResolvedCache = () => {\n resolvedCache.clear();\n};\n\nconst resolveAndAttachVersions = (\n pkg: PackageJson,\n workspace: string,\n cacheKey: string,\n): PackageJson => {\n const cached = resolvedCache.get(cacheKey);\n if (cached) {\n pkg.resolvedVersions = cached;\n return pkg;\n }\n\n const resolved = resolveInstalledVersions(pkg, workspace);\n if (Object.keys(resolved).length > 0) {\n pkg.resolvedVersions = resolved;\n resolvedCache.set(cacheKey, resolved);\n for (const [name, version] of Object.entries(resolved)) {\n logVerbose(\n styleText(\n 'dim',\n `Detected ${styleText('white', name)} v${styleText('white', version)}`,\n ),\n );\n }\n }\n return pkg;\n};\n\nconst hasCatalogReferences = (pkg: PackageJson): boolean => {\n return [\n ...Object.entries(pkg.dependencies ?? {}),\n ...Object.entries(pkg.devDependencies ?? {}),\n ...Object.entries(pkg.peerDependencies ?? {}),\n ].some(([, value]) => isString(value) && value.startsWith('catalog:'));\n};\n\nconst loadPnpmWorkspaceCatalog = async (\n workspace: string,\n): Promise<CatalogData | undefined> => {\n const filePath = await findUp('pnpm-workspace.yaml', { cwd: workspace });\n if (!filePath) return undefined;\n try {\n const file = await fs.readFile(filePath, 'utf8');\n const data = yaml.load(file) as Record<string, unknown> | undefined;\n if (!data?.catalog && !data?.catalogs) return undefined;\n return {\n catalog: data.catalog as CatalogData['catalog'],\n catalogs: data.catalogs as CatalogData['catalogs'],\n };\n } catch {\n return undefined;\n }\n};\n\nconst loadPackageJsonCatalog = async (\n workspace: string,\n): Promise<CatalogData | undefined> => {\n const filePaths = await findUpMultiple('package.json', { cwd: workspace });\n\n for (const filePath of filePaths) {\n try {\n const pkg = (await fs.readJson(filePath)) as Record<string, unknown>;\n if (pkg.catalog || pkg.catalogs) {\n return {\n catalog: pkg.catalog as CatalogData['catalog'],\n catalogs: pkg.catalogs as CatalogData['catalogs'],\n };\n }\n } catch {\n // Continue to next file\n }\n }\n return undefined;\n};\n\nconst loadYarnrcCatalog = async (\n workspace: string,\n): Promise<CatalogData | undefined> => {\n const filePath = await findUp('.yarnrc.yml', { cwd: workspace });\n if (!filePath) return undefined;\n try {\n const file = await fs.readFile(filePath, 'utf8');\n const data = yaml.load(file) as Record<string, unknown> | undefined;\n if (!data?.catalog && !data?.catalogs) return undefined;\n return {\n catalog: data.catalog as CatalogData['catalog'],\n catalogs: data.catalogs as CatalogData['catalogs'],\n };\n } catch {\n return undefined;\n }\n};\n\nconst maybeReplaceCatalog = async (\n pkg: PackageJson,\n workspace: string,\n): Promise<PackageJson> => {\n if (!hasCatalogReferences(pkg)) {\n return pkg;\n }\n\n const catalogData =\n (await loadPnpmWorkspaceCatalog(workspace)) ??\n (await loadPackageJsonCatalog(workspace)) ??\n (await loadYarnrcCatalog(workspace));\n\n if (!catalogData) {\n logWarning(\n '⚠️ package.json contains catalog: references, but no catalog source was found (checked: pnpm-workspace.yaml, package.json, .yarnrc.yml).',\n );\n return pkg;\n }\n\n performSubstitution(pkg.dependencies, catalogData);\n performSubstitution(pkg.devDependencies, catalogData);\n performSubstitution(pkg.peerDependencies, catalogData);\n\n return pkg;\n};\n\nconst performSubstitution = (\n dependencies: Record<string, string> | undefined,\n catalogData: CatalogData,\n) => {\n if (!dependencies) return;\n for (const [packageName, version] of Object.entries(dependencies)) {\n if (version === 'catalog:' || version === 'catalog:default') {\n if (!catalogData.catalog) {\n logWarning(\n `⚠️ catalog: substitution for the package '${packageName}' failed as there is no default catalog.`,\n );\n continue;\n }\n const sub = catalogData.catalog[packageName];\n if (!sub) {\n logWarning(\n `⚠️ catalog: substitution for the package '${packageName}' failed as there is no matching package in the default catalog.`,\n );\n continue;\n }\n dependencies[packageName] = sub;\n } else if (version.startsWith('catalog:')) {\n const catalogName = version.slice('catalog:'.length);\n const catalog = catalogData.catalogs?.[catalogName];\n if (!catalog) {\n logWarning(\n `⚠️ '${version}' substitution for the package '${packageName}' failed as there is no matching catalog named '${catalogName}'. (available named catalogs are: ${Object.keys(catalogData.catalogs ?? {}).join(', ')})`,\n );\n continue;\n }\n const sub = catalog[packageName];\n if (!sub) {\n logWarning(\n `⚠️ '${version}' substitution for the package '${packageName}' failed as there is no package in the catalog named '${catalogName}'. (packages in the catalog are: ${Object.keys(catalog).join(', ')})`,\n );\n continue;\n }\n dependencies[packageName] = sub;\n }\n }\n};\n","import { isNullish, isObject, isString, type Tsconfig } from '@orval/core';\nimport { findUp } from 'find-up';\nimport fs from 'fs-extra';\nimport { parse } from 'tsconfck';\n\nimport { normalizePath } from './options';\n\nexport const loadTsconfig = async (\n tsconfig?: Tsconfig | string,\n workspace = process.cwd(),\n): Promise<Tsconfig | undefined> => {\n if (isNullish(tsconfig)) {\n const configPath = await findUp(['tsconfig.json', 'jsconfig.json'], {\n cwd: workspace,\n });\n if (configPath) {\n const config = await parse(configPath);\n return config.tsconfig as Tsconfig;\n }\n return;\n }\n\n if (isString(tsconfig)) {\n const normalizedPath = normalizePath(tsconfig, workspace);\n if (fs.existsSync(normalizedPath)) {\n const config = await parse(normalizedPath);\n\n const tsconfig = (config.referenced?.find(\n ({ tsconfigFile }) => tsconfigFile === normalizedPath,\n )?.tsconfig ?? config.tsconfig) as Tsconfig;\n\n return tsconfig;\n }\n return;\n }\n\n if (isObject(tsconfig)) {\n return tsconfig;\n }\n return;\n};\n","import { access } from 'node:fs/promises';\nimport nodePath from 'node:path';\nimport { styleText } from 'node:util';\n\nimport {\n type ClientMockBuilder,\n type ConfigExternal,\n FormDataArrayHandling,\n type GlobalMockOptions,\n type GlobalOptions,\n type HonoOptions,\n type Hook,\n type HookFunction,\n type HookOption,\n type HooksOptions,\n type InputOptions,\n type InputTransformerFn,\n isBoolean,\n isFunction,\n isNullish,\n isObject,\n isString,\n isUrl,\n type JsDocOptions,\n logWarning,\n type McpOptions,\n type McpServerOptions,\n type Mutator,\n NamingConvention,\n type NormalizedHonoOptions,\n type NormalizedHookOptions,\n type NormalizedJsDocOptions,\n type NormalizedMcpOptions,\n type NormalizedMcpServerOptions,\n type NormalizedMutator,\n type NormalizedOperationOptions,\n type NormalizedOptions,\n type NormalizedOverrideOutput,\n type NormalizedQueryOptions,\n type NormalizedSchemaOptions,\n type OperationOptions,\n type OptionsExport,\n OutputClient,\n OutputHttpClient,\n OutputMode,\n type OverrideOutput,\n PropertySortOrder,\n type QueryOptions,\n RefComponentSuffix,\n type SchemaOptions,\n} from '@orval/core';\nimport { DEFAULT_MOCK_OPTIONS } from '@orval/mock';\n\nimport pkg from '../../package.json';\nimport { loadPackageJson } from './package-json';\nimport { loadTsconfig } from './tsconfig';\n\nconst INPUT_TARGET_FETCH_TIMEOUT_MS = 10_000;\n/**\n * Type helper to make it easier to use orval.config.ts\n * accepts a direct {@link ConfigExternal} object.\n */\nexport function defineConfig(options: ConfigExternal): ConfigExternal {\n return options;\n}\n\n/**\n * Type helper to make it easier to write input transformers.\n * accepts a direct {@link InputTransformerFn} function.\n */\nexport function defineTransformer(\n transformer: InputTransformerFn,\n): InputTransformerFn {\n return transformer;\n}\n\nfunction createFormData(\n workspace: string,\n formData: OverrideOutput['formData'],\n): NormalizedOverrideOutput['formData'] {\n const defaultArrayHandling = FormDataArrayHandling.SERIALIZE;\n if (formData === undefined)\n return { disabled: false, arrayHandling: defaultArrayHandling };\n if (isBoolean(formData))\n return { disabled: !formData, arrayHandling: defaultArrayHandling };\n if (isString(formData))\n return {\n disabled: false,\n mutator: normalizeMutator(workspace, formData),\n arrayHandling: defaultArrayHandling,\n };\n if ('mutator' in formData || 'arrayHandling' in formData)\n return {\n disabled: false,\n mutator: normalizeMutator(workspace, formData.mutator),\n arrayHandling: formData.arrayHandling ?? defaultArrayHandling,\n };\n return {\n disabled: false,\n mutator: normalizeMutator(workspace, formData),\n arrayHandling: defaultArrayHandling,\n };\n}\n\nfunction normalizeSchemasOption(\n schemas: string | SchemaOptions | false | undefined,\n workspace: string,\n): string | NormalizedSchemaOptions | undefined {\n if (!schemas) {\n return undefined;\n }\n\n if (isString(schemas)) {\n return normalizePath(schemas, workspace);\n }\n\n return {\n path: normalizePath(schemas.path, workspace),\n type: schemas.type,\n };\n}\n\nexport async function normalizeOptions(\n optionsExport: OptionsExport,\n workspace = process.cwd(),\n globalOptions: GlobalOptions = {},\n): Promise<NormalizedOptions> {\n const options = await (isFunction(optionsExport)\n ? optionsExport()\n : optionsExport);\n\n if (!options.input) {\n throw new Error(styleText('red', `Config requires an input.`));\n }\n\n if (!options.output) {\n throw new Error(styleText('red', `Config requires an output.`));\n }\n\n const inputOptions: InputOptions =\n isString(options.input) || Array.isArray(options.input)\n ? { target: options.input }\n : options.input;\n\n const outputOptions = isString(options.output)\n ? { target: options.output }\n : options.output;\n\n const outputWorkspace = normalizePath(\n outputOptions.workspace ?? '',\n workspace,\n );\n\n const { clean, client, httpClient, mode } = globalOptions;\n\n const tsconfig = await loadTsconfig(\n outputOptions.tsconfig ?? globalOptions.tsconfig,\n workspace,\n );\n\n const packageJson = await loadPackageJson(\n outputOptions.packageJson ?? globalOptions.packageJson,\n workspace,\n );\n\n const mockOption = outputOptions.mock ?? globalOptions.mock;\n let mock: GlobalMockOptions | ClientMockBuilder | undefined;\n if (isBoolean(mockOption) && mockOption) {\n mock = DEFAULT_MOCK_OPTIONS;\n } else if (isFunction(mockOption)) {\n mock = mockOption;\n } else if (mockOption) {\n mock = {\n ...DEFAULT_MOCK_OPTIONS,\n ...mockOption,\n };\n } else {\n mock = undefined;\n }\n\n const defaultFileExtension = '.ts';\n\n const globalQueryOptions: NormalizedQueryOptions = {\n useQuery: true,\n useMutation: true,\n signal: true,\n shouldExportMutatorHooks: true,\n shouldExportHttpClient: true,\n shouldExportQueryKey: true,\n shouldSplitQueryKey: false,\n ...normalizeQueryOptions(outputOptions.override?.query, workspace),\n };\n\n const normalizedOptions: NormalizedOptions = {\n input: {\n target: globalOptions.input\n ? Array.isArray(globalOptions.input)\n ? await resolveFirstValidTarget(\n globalOptions.input,\n process.cwd(),\n inputOptions.parserOptions,\n )\n : normalizePathOrUrl(globalOptions.input, process.cwd())\n : Array.isArray(inputOptions.target)\n ? await resolveFirstValidTarget(\n inputOptions.target,\n workspace,\n inputOptions.parserOptions,\n )\n : normalizePathOrUrl(inputOptions.target, workspace),\n override: {\n transformer: normalizePath(\n inputOptions.override?.transformer,\n workspace,\n ),\n },\n unsafeDisableValidation: inputOptions.unsafeDisableValidation ?? false,\n filters: inputOptions.filters,\n parserOptions: inputOptions.parserOptions,\n },\n output: {\n target: globalOptions.output\n ? normalizePath(globalOptions.output, process.cwd())\n : normalizePath(outputOptions.target, outputWorkspace),\n schemas: normalizeSchemasOption(outputOptions.schemas, outputWorkspace),\n operationSchemas: outputOptions.operationSchemas\n ? normalizePath(outputOptions.operationSchemas, outputWorkspace)\n : undefined,\n namingConvention:\n outputOptions.namingConvention ?? NamingConvention.CAMEL_CASE,\n fileExtension: outputOptions.fileExtension ?? defaultFileExtension,\n workspace: outputOptions.workspace ? outputWorkspace : undefined,\n client: outputOptions.client ?? client ?? OutputClient.AXIOS_FUNCTIONS,\n httpClient:\n outputOptions.httpClient ??\n httpClient ??\n // Auto-detect: use Angular HttpClient for angular-query by default\n ((outputOptions.client ?? client) === OutputClient.ANGULAR_QUERY\n ? OutputHttpClient.ANGULAR\n : OutputHttpClient.FETCH),\n mode: normalizeOutputMode(outputOptions.mode ?? mode),\n mock,\n clean: outputOptions.clean ?? clean ?? false,\n docs: outputOptions.docs ?? false,\n formatter: outputOptions.formatter ?? globalOptions.formatter,\n tsconfig,\n packageJson,\n headers: outputOptions.headers ?? false,\n indexFiles: outputOptions.indexFiles ?? true,\n baseUrl: outputOptions.baseUrl,\n unionAddMissingProperties:\n outputOptions.unionAddMissingProperties ?? false,\n override: {\n ...outputOptions.override,\n mock: {\n arrayMin: outputOptions.override?.mock?.arrayMin ?? 1,\n arrayMax: outputOptions.override?.mock?.arrayMax ?? 10,\n stringMin: outputOptions.override?.mock?.stringMin ?? 10,\n stringMax: outputOptions.override?.mock?.stringMax ?? 20,\n fractionDigits: outputOptions.override?.mock?.fractionDigits ?? 2,\n ...outputOptions.override?.mock,\n },\n operations: normalizeOperationsAndTags(\n outputOptions.override?.operations ?? {},\n outputWorkspace,\n {\n query: globalQueryOptions,\n },\n ),\n tags: normalizeOperationsAndTags(\n outputOptions.override?.tags ?? {},\n outputWorkspace,\n {\n query: globalQueryOptions,\n },\n ),\n mutator: normalizeMutator(\n outputWorkspace,\n outputOptions.override?.mutator,\n ),\n formData: createFormData(\n outputWorkspace,\n outputOptions.override?.formData,\n ),\n formUrlEncoded:\n (isBoolean(outputOptions.override?.formUrlEncoded)\n ? outputOptions.override.formUrlEncoded\n : normalizeMutator(\n outputWorkspace,\n outputOptions.override?.formUrlEncoded,\n )) ?? true,\n paramsSerializer: normalizeMutator(\n outputWorkspace,\n outputOptions.override?.paramsSerializer,\n ),\n header:\n outputOptions.override?.header === false\n ? false\n : isFunction(outputOptions.override?.header)\n ? outputOptions.override.header\n : getDefaultFilesHeader,\n requestOptions: outputOptions.override?.requestOptions ?? true,\n namingConvention: outputOptions.override?.namingConvention ?? {},\n components: {\n schemas: {\n suffix: RefComponentSuffix.schemas,\n itemSuffix:\n outputOptions.override?.components?.schemas?.itemSuffix ?? 'Item',\n ...outputOptions.override?.components?.schemas,\n },\n responses: {\n suffix: RefComponentSuffix.responses,\n ...outputOptions.override?.components?.responses,\n },\n parameters: {\n suffix: RefComponentSuffix.parameters,\n ...outputOptions.override?.components?.parameters,\n },\n requestBodies: {\n suffix: RefComponentSuffix.requestBodies,\n ...outputOptions.override?.components?.requestBodies,\n },\n },\n hono: normalizeHonoOptions(outputOptions.override?.hono, workspace),\n mcp: normalizeMcpOptions(outputOptions.override?.mcp, workspace),\n jsDoc: normalizeJSDocOptions(outputOptions.override?.jsDoc),\n query: globalQueryOptions,\n zod: {\n strict: {\n param: outputOptions.override?.zod?.strict?.param ?? false,\n query: outputOptions.override?.zod?.strict?.query ?? false,\n header: outputOptions.override?.zod?.strict?.header ?? false,\n body: outputOptions.override?.zod?.strict?.body ?? false,\n response: outputOptions.override?.zod?.strict?.response ?? false,\n },\n generate: {\n param: outputOptions.override?.zod?.generate?.param ?? true,\n query: outputOptions.override?.zod?.generate?.query ?? true,\n header: outputOptions.override?.zod?.generate?.header ?? true,\n body: outputOptions.override?.zod?.generate?.body ?? true,\n response: outputOptions.override?.zod?.generate?.response ?? true,\n },\n coerce: {\n param: outputOptions.override?.zod?.coerce?.param ?? false,\n query: outputOptions.override?.zod?.coerce?.query ?? false,\n header: outputOptions.override?.zod?.coerce?.header ?? false,\n body: outputOptions.override?.zod?.coerce?.body ?? false,\n response: outputOptions.override?.zod?.coerce?.response ?? false,\n },\n preprocess: {\n ...(outputOptions.override?.zod?.preprocess?.param\n ? {\n param: normalizeMutator(\n workspace,\n outputOptions.override.zod.preprocess.param,\n ),\n }\n : {}),\n ...(outputOptions.override?.zod?.preprocess?.query\n ? {\n query: normalizeMutator(\n workspace,\n outputOptions.override.zod.preprocess.query,\n ),\n }\n : {}),\n ...(outputOptions.override?.zod?.preprocess?.header\n ? {\n header: normalizeMutator(\n workspace,\n outputOptions.override.zod.preprocess.header,\n ),\n }\n : {}),\n ...(outputOptions.override?.zod?.preprocess?.body\n ? {\n body: normalizeMutator(\n workspace,\n outputOptions.override.zod.preprocess.body,\n ),\n }\n : {}),\n ...(outputOptions.override?.zod?.preprocess?.response\n ? {\n response: normalizeMutator(\n workspace,\n outputOptions.override.zod.preprocess.response,\n ),\n }\n : {}),\n },\n generateEachHttpStatus:\n outputOptions.override?.zod?.generateEachHttpStatus ?? false,\n useBrandedTypes:\n outputOptions.override?.zod?.useBrandedTypes ?? false,\n dateTimeOptions: outputOptions.override?.zod?.dateTimeOptions ?? {\n offset: true,\n },\n timeOptions: outputOptions.override?.zod?.timeOptions ?? {},\n },\n swr: {\n generateErrorTypes: false,\n ...outputOptions.override?.swr,\n },\n angular: {\n provideIn: outputOptions.override?.angular?.provideIn ?? 'root',\n client:\n outputOptions.override?.angular?.retrievalClient ??\n outputOptions.override?.angular?.client ??\n 'httpClient',\n runtimeValidation:\n outputOptions.override?.angular?.runtimeValidation ?? false,\n ...(outputOptions.override?.angular?.httpResource\n ? { httpResource: outputOptions.override.angular.httpResource }\n : {}),\n },\n fetch: {\n includeHttpResponseReturnType:\n outputOptions.override?.fetch?.includeHttpResponseReturnType ??\n true,\n forceSuccessResponse:\n outputOptions.override?.fetch?.forceSuccessResponse ?? false,\n runtimeValidation:\n outputOptions.override?.fetch?.runtimeValidation ?? false,\n useRuntimeFetcher:\n outputOptions.override?.fetch?.useRuntimeFetcher ?? false,\n ...outputOptions.override?.fetch,\n ...(outputOptions.override?.fetch?.jsonReviver\n ? {\n jsonReviver: normalizeMutator(\n outputWorkspace,\n outputOptions.override.fetch.jsonReviver,\n ),\n }\n : {}),\n },\n useDates: outputOptions.override?.useDates ?? false,\n useDeprecatedOperations:\n outputOptions.override?.useDeprecatedOperations ?? true,\n enumGenerationType:\n outputOptions.override?.enumGenerationType ?? 'const',\n suppressReadonlyModifier:\n outputOptions.override?.suppressReadonlyModifier ?? false,\n preserveReadonlyRequestBodies:\n outputOptions.override?.preserveReadonlyRequestBodies ?? 'strip',\n splitByContentType: outputOptions.override?.splitByContentType ?? false,\n aliasCombinedTypes: outputOptions.override?.aliasCombinedTypes ?? false,\n },\n allParamsOptional: outputOptions.allParamsOptional ?? false,\n urlEncodeParameters: outputOptions.urlEncodeParameters ?? false,\n optionsParamRequired: outputOptions.optionsParamRequired ?? false,\n propertySortOrder:\n outputOptions.propertySortOrder ?? PropertySortOrder.SPECIFICATION,\n },\n hooks: options.hooks ? normalizeHooks(options.hooks) : {},\n };\n\n if (!normalizedOptions.input.target) {\n throw new Error(styleText('red', `Config requires an input target.`));\n }\n\n if (!normalizedOptions.output.target && !normalizedOptions.output.schemas) {\n throw new Error(\n styleText('red', `Config requires an output target or schemas.`),\n );\n }\n\n if (\n normalizedOptions.output.httpClient === OutputHttpClient.FETCH &&\n normalizedOptions.output.optionsParamRequired &&\n normalizedOptions.output.override.requestOptions !== false\n ) {\n logWarning(\n `⚠️ With \\`httpClient: 'fetch'\\`, \\`optionsParamRequired: true\\` cannot make the generated \\`options\\` parameter required. The fetch \\`options\\` parameter remains optional with type \\`RequestInit\\` (\\`optionsParamRequired\\` may still affect other generated parameters). Set \\`httpClient: 'axios'\\` to make the \\`options\\` parameter required.`,\n );\n }\n\n return normalizedOptions;\n}\n\nfunction normalizeMutator(\n workspace: string,\n mutator?: Mutator,\n): NormalizedMutator | undefined {\n if (isObject(mutator)) {\n const m = mutator as Exclude<Mutator, string>;\n if (!m.path) {\n throw new Error(styleText('red', `Mutator requires a path.`));\n }\n\n return {\n path: nodePath.resolve(workspace, m.path),\n name: m.name,\n default: m.default ?? !m.name,\n alias: m.alias,\n external: m.external,\n extension: m.extension,\n };\n }\n\n if (isString(mutator)) {\n return {\n path: nodePath.resolve(workspace, mutator),\n default: true,\n };\n }\n\n return undefined;\n}\n\nasync function resolveFirstValidTarget(\n targets: string[],\n workspace: string,\n parserOptions?: InputOptions['parserOptions'],\n): Promise<string> {\n for (const target of targets) {\n if (isUrl(target)) {\n try {\n const headers = getHeadersForUrl(target, parserOptions?.headers);\n const headResponse = await fetchWithTimeout(target, {\n method: 'HEAD',\n headers,\n });\n\n if (headResponse.ok) {\n return target;\n }\n\n if (headResponse.status === 405 || headResponse.status === 501) {\n const getResponse = await fetchWithTimeout(target, {\n method: 'GET',\n headers,\n });\n\n if (getResponse.ok) {\n return target;\n }\n }\n } catch {\n continue;\n }\n\n continue;\n }\n\n const resolvedTarget = normalizePath(target, workspace);\n\n try {\n await access(resolvedTarget);\n return resolvedTarget;\n } catch {\n continue;\n }\n }\n\n throw new Error(\n styleText(\n 'red',\n `None of the input targets could be resolved:\\n${targets.map((target) => ` - ${target}`).join('\\n')}`,\n ),\n );\n}\n\nfunction getHeadersForUrl(\n url: string,\n headersConfig?: NonNullable<InputOptions['parserOptions']>['headers'],\n): Record<string, string> {\n if (!headersConfig) return {};\n\n const { hostname } = new URL(url);\n const matchedHeaders: Record<string, string> = {};\n\n for (const headerEntry of headersConfig) {\n if (\n headerEntry.domains.some(\n (domain) => hostname === domain || hostname.endsWith(`.${domain}`),\n )\n ) {\n Object.assign(matchedHeaders, headerEntry.headers);\n }\n }\n\n return matchedHeaders;\n}\n\nasync function fetchWithTimeout(\n target: string,\n init: RequestInit,\n): Promise<Response> {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => {\n controller.abort();\n }, INPUT_TARGET_FETCH_TIMEOUT_MS);\n\n try {\n return await fetch(target, {\n ...init,\n signal: controller.signal,\n });\n } finally {\n clearTimeout(timeoutId);\n }\n}\n\nfunction normalizePathOrUrl<T>(path: T, workspace: string) {\n if (isString(path) && !isUrl(path)) {\n return normalizePath(path, workspace);\n }\n\n return path;\n}\n\nexport function normalizePath<T>(path: T, workspace: string) {\n if (!isString(path)) {\n return path;\n }\n return nodePath.resolve(workspace, path);\n}\n\nfunction normalizeOperationsAndTags(\n operationsOrTags: Record<string, OperationOptions>,\n workspace: string,\n global: {\n query: NormalizedQueryOptions;\n },\n): Record<string, NormalizedOperationOptions> {\n return Object.fromEntries(\n Object.entries(operationsOrTags).map(\n ([\n key,\n {\n transformer,\n mutator,\n formData,\n formUrlEncoded,\n paramsSerializer,\n query,\n angular,\n zod,\n ...rest\n },\n ]) => {\n return [\n key,\n {\n ...rest,\n ...(angular\n ? {\n angular: {\n provideIn: angular.provideIn ?? 'root',\n client:\n angular.retrievalClient ?? angular.client ?? 'httpClient',\n runtimeValidation: angular.runtimeValidation ?? false,\n ...(angular.httpResource\n ? { httpResource: angular.httpResource }\n : {}),\n },\n }\n : {}),\n ...(query\n ? {\n query: normalizeQueryOptions(query, workspace, global.query),\n }\n : {}),\n ...(zod\n ? {\n zod: {\n strict: {\n param: zod.strict?.param ?? false,\n query: zod.strict?.query ?? false,\n header: zod.strict?.header ?? false,\n body: zod.strict?.body ?? false,\n response: zod.strict?.response ?? false,\n },\n generate: {\n param: zod.generate?.param ?? true,\n query: zod.generate?.query ?? true,\n header: zod.generate?.header ?? true,\n body: zod.generate?.body ?? true,\n response: zod.generate?.response ?? true,\n },\n coerce: {\n param: zod.coerce?.param ?? false,\n query: zod.coerce?.query ?? false,\n header: zod.coerce?.header ?? false,\n body: zod.coerce?.body ?? false,\n response: zod.coerce?.response ?? false,\n },\n preprocess: {\n ...(zod.preprocess?.param\n ? {\n param: normalizeMutator(\n workspace,\n zod.preprocess.param,\n ),\n }\n : {}),\n ...(zod.preprocess?.query\n ? {\n query: normalizeMutator(\n workspace,\n zod.preprocess.query,\n ),\n }\n : {}),\n ...(zod.preprocess?.header\n ? {\n header: normalizeMutator(\n workspace,\n zod.preprocess.header,\n ),\n }\n : {}),\n ...(zod.preprocess?.body\n ? {\n body: normalizeMutator(\n workspace,\n zod.preprocess.body,\n ),\n }\n : {}),\n ...(zod.preprocess?.response\n ? {\n response: normalizeMutator(\n workspace,\n zod.preprocess.response,\n ),\n }\n : {}),\n },\n generateEachHttpStatus: zod.generateEachHttpStatus ?? false,\n useBrandedTypes: zod.useBrandedTypes ?? false,\n dateTimeOptions: zod.dateTimeOptions ?? { offset: true },\n timeOptions: zod.timeOptions ?? {},\n },\n }\n : {}),\n ...(transformer\n ? { transformer: normalizePath(transformer, workspace) }\n : {}),\n ...(mutator\n ? { mutator: normalizeMutator(workspace, mutator) }\n : {}),\n ...(formData === undefined\n ? {}\n : { formData: createFormData(workspace, formData) }),\n ...(formUrlEncoded\n ? {\n formUrlEncoded: isBoolean(formUrlEncoded)\n ? formUrlEncoded\n : normalizeMutator(workspace, formUrlEncoded),\n }\n : {}),\n ...(paramsSerializer\n ? {\n paramsSerializer: normalizeMutator(\n workspace,\n paramsSerializer,\n ),\n }\n : {}),\n },\n ];\n },\n ),\n );\n}\n\nfunction normalizeOutputMode(mode?: OutputMode): OutputMode {\n if (!mode) {\n return OutputMode.SINGLE;\n }\n\n if (!Object.values(OutputMode).includes(mode)) {\n logWarning(`⚠️ Unknown provided mode => ${mode}`);\n return OutputMode.SINGLE;\n }\n\n return mode;\n}\n\nfunction normalizeHooks(hooks: HooksOptions): NormalizedHookOptions {\n const keys = Object.keys(hooks) as unknown as Hook[];\n\n const result: NormalizedHookOptions = {};\n for (const key of keys) {\n if (isString(hooks[key])) {\n result[key] = [hooks[key]] as string[];\n } else if (Array.isArray(hooks[key])) {\n result[key] = hooks[key] as string[];\n } else if (isFunction(hooks[key])) {\n result[key] = [hooks[key]] as HookFunction[];\n } else if (isObject(hooks[key])) {\n result[key] = [hooks[key]] as HookOption[];\n }\n }\n return result;\n}\n\nfunction normalizeHonoOptions(\n hono: HonoOptions = {},\n workspace: string,\n): NormalizedHonoOptions {\n return {\n ...(hono.handlers\n ? { handlers: nodePath.resolve(workspace, hono.handlers) }\n : {}),\n compositeRoute: hono.compositeRoute\n ? nodePath.resolve(workspace, hono.compositeRoute)\n : '',\n validator: hono.validator ?? true,\n validatorOutputPath: hono.validatorOutputPath\n ? nodePath.resolve(workspace, hono.validatorOutputPath)\n : '',\n };\n}\n\nfunction normalizeMcpServerOptions(\n server: McpServerOptions,\n workspace: string,\n): NormalizedMcpServerOptions {\n return {\n path: nodePath.resolve(workspace, server.path),\n name: server.name,\n default: server.default ?? !server.name,\n };\n}\n\nfunction normalizeMcpOptions(\n mcp: McpOptions = {},\n workspace: string,\n): NormalizedMcpOptions {\n return {\n ...(mcp.server\n ? { server: normalizeMcpServerOptions(mcp.server, workspace) }\n : {}),\n };\n}\n\nfunction normalizeJSDocOptions(\n jsdoc: JsDocOptions = {},\n): NormalizedJsDocOptions {\n return {\n ...jsdoc,\n };\n}\n\nfunction normalizeQueryOptions(\n queryOptions: QueryOptions = {},\n outputWorkspace: string,\n globalOptions: NormalizedQueryOptions = {},\n): NormalizedQueryOptions {\n if (queryOptions.options) {\n logWarning(\n '⚠️ Using query options is deprecated and will be removed in a future major release. Please use queryOptions or mutationOptions instead.',\n );\n }\n\n return {\n ...(isNullish(queryOptions.usePrefetch)\n ? {}\n : { usePrefetch: queryOptions.usePrefetch }),\n ...(isNullish(queryOptions.useInvalidate)\n ? {}\n : { useInvalidate: queryOptions.useInvalidate }),\n ...(isNullish(queryOptions.useSetQueryData)\n ? {}\n : { useSetQueryData: queryOptions.useSetQueryData }),\n ...(isNullish(queryOptions.useGetQueryData)\n ? {}\n : { useGetQueryData: queryOptions.useGetQueryData }),\n ...(isNullish(queryOptions.useQuery)\n ? {}\n : { useQuery: queryOptions.useQuery }),\n ...(isNullish(queryOptions.useSuspenseQuery)\n ? {}\n : { useSuspenseQuery: queryOptions.useSuspenseQuery }),\n ...(isNullish(queryOptions.useMutation)\n ? {}\n : { useMutation: queryOptions.useMutation }),\n ...(isNullish(queryOptions.useInfinite)\n ? {}\n : { useInfinite: queryOptions.useInfinite }),\n ...(isNullish(queryOptions.useSuspenseInfiniteQuery)\n ? {}\n : { useSuspenseInfiniteQuery: queryOptions.useSuspenseInfiniteQuery }),\n ...(queryOptions.useInfiniteQueryParam\n ? { useInfiniteQueryParam: queryOptions.useInfiniteQueryParam }\n : {}),\n ...(queryOptions.options ? { options: queryOptions.options } : {}),\n ...(globalOptions.queryKey\n ? {\n queryKey: globalOptions.queryKey,\n }\n : {}),\n ...(queryOptions.queryKey\n ? {\n queryKey: normalizeMutator(outputWorkspace, queryOptions.queryKey),\n }\n : {}),\n ...(globalOptions.queryOptions\n ? {\n queryOptions: globalOptions.queryOptions,\n }\n : {}),\n ...(queryOptions.queryOptions\n ? {\n queryOptions: normalizeMutator(\n outputWorkspace,\n queryOptions.queryOptions,\n ),\n }\n : {}),\n ...(globalOptions.mutationOptions\n ? {\n mutationOptions: globalOptions.mutationOptions,\n }\n : {}),\n ...(queryOptions.mutationOptions\n ? {\n mutationOptions: normalizeMutator(\n outputWorkspace,\n queryOptions.mutationOptions,\n ),\n }\n : {}),\n ...(isNullish(globalOptions.shouldExportQueryKey)\n ? {}\n : {\n shouldExportQueryKey: globalOptions.shouldExportQueryKey,\n }),\n ...(isNullish(queryOptions.shouldExportQueryKey)\n ? {}\n : { shouldExportQueryKey: queryOptions.shouldExportQueryKey }),\n ...(isNullish(globalOptions.shouldExportHttpClient)\n ? {}\n : {\n shouldExportHttpClient: globalOptions.shouldExportHttpClient,\n }),\n ...(isNullish(queryOptions.shouldExportHttpClient)\n ? {}\n : { shouldExportHttpClient: queryOptions.shouldExportHttpClient }),\n ...(isNullish(globalOptions.shouldExportMutatorHooks)\n ? {}\n : {\n shouldExportMutatorHooks: globalOptions.shouldExportMutatorHooks,\n }),\n ...(isNullish(queryOptions.shouldExportMutatorHooks)\n ? {}\n : { shouldExportMutatorHooks: queryOptions.shouldExportMutatorHooks }),\n ...(isNullish(globalOptions.shouldSplitQueryKey)\n ? {}\n : {\n shouldSplitQueryKey: globalOptions.shouldSplitQueryKey,\n }),\n ...(isNullish(queryOptions.shouldSplitQueryKey)\n ? {}\n : { shouldSplitQueryKey: queryOptions.shouldSplitQueryKey }),\n ...(isNullish(globalOptions.signal)\n ? {}\n : {\n signal: globalOptions.signal,\n }),\n ...(isNullish(globalOptions.useOperationIdAsQueryKey)\n ? {}\n : {\n useOperationIdAsQueryKey: globalOptions.useOperationIdAsQueryKey,\n }),\n ...(isNullish(queryOptions.useOperationIdAsQueryKey)\n ? {}\n : { useOperationIdAsQueryKey: queryOptions.useOperationIdAsQueryKey }),\n ...(isNullish(globalOptions.signal)\n ? {}\n : {\n signal: globalOptions.signal,\n }),\n ...(isNullish(queryOptions.signal) ? {} : { signal: queryOptions.signal }),\n ...(isNullish(globalOptions.version)\n ? {}\n : {\n version: globalOptions.version,\n }),\n ...(isNullish(queryOptions.version)\n ? {}\n : { version: queryOptions.version }),\n ...(queryOptions.mutationInvalidates\n ? { mutationInvalidates: queryOptions.mutationInvalidates }\n : {}),\n ...(isNullish(globalOptions.runtimeValidation)\n ? {}\n : {\n runtimeValidation: globalOptions.runtimeValidation,\n }),\n ...(isNullish(queryOptions.runtimeValidation)\n ? {}\n : { runtimeValidation: queryOptions.runtimeValidation }),\n };\n}\n\nexport function getDefaultFilesHeader({\n title,\n description,\n version,\n}: {\n title?: string;\n description?: string;\n version?: string;\n} = {}) {\n return [\n `Generated by ${pkg.name} v${pkg.version} 🍺`,\n `Do not edit manually.`,\n ...(title ? [title] : []),\n ...(description ? [description] : []),\n ...(version ? [`OpenAPI spec version: ${version}`] : []),\n ];\n}\n","import { isBoolean, log, logError } from '@orval/core';\n\n/**\n * Start a file watcher and invoke an async callback on file changes.\n *\n * If `watchOptions` is falsy the watcher is not started. Supported shapes:\n * - boolean: when true the `defaultTarget` is watched\n * - string: a single path to watch\n * - string[]: an array of paths to watch\n *\n * @param watchOptions - false to disable watching, or a path/paths to watch\n * @param watchFn - async callback executed on change events\n * @param defaultTarget - path(s) to watch when `watchOptions` is `true` (default: '.')\n * @returns Resolves once the watcher has been started (or immediately if disabled)\n *\n * @example\n * await startWatcher(true, async () => { await buildProject(); }, 'src');\n */\nexport async function startWatcher(\n watchOptions: boolean | string | string[],\n watchFn: () => Promise<void>,\n defaultTarget: string | string[] = '.',\n) {\n if (!watchOptions) return;\n const { watch } = await import('chokidar');\n\n const ignored = ['**/{.git,node_modules}/**'];\n\n const watchPaths = isBoolean(watchOptions) ? defaultTarget : watchOptions;\n\n log(\n `Watching for changes in ${\n Array.isArray(watchPaths)\n ? watchPaths.map((v) => '\"' + v + '\"').join(' | ')\n : '\"' + watchPaths + '\"'\n }`,\n );\n\n const watcher = watch(watchPaths, {\n ignorePermissionErrors: true,\n ignored,\n });\n watcher.on('ready', () => {\n log('Initial scan complete. Watching for changes...');\n watcher.on('all', (type, file) => {\n log(`Change detected: ${type} ${file}`);\n\n watchFn().catch((error: unknown) => {\n logError(error);\n });\n });\n });\n}\n","import path from 'node:path';\n\nimport {\n type ContextSpec,\n conventionName,\n type NamingConvention,\n type NormalizedOutputOptions,\n type OpenApiParameterObject,\n type OpenApiReferenceObject,\n type OpenApiRequestBodyObject,\n type OpenApiSchemaObject,\n pascal,\n type ZodCoerceType,\n} from '@orval/core';\nimport {\n dereference,\n generateFormDataZodSchema,\n generateZodValidationSchemaDefinition,\n isZodVersionV4,\n parseZodValidationSchemaDefinition,\n type ZodValidationSchemaDefinition,\n} from '@orval/zod';\nimport fs from 'fs-extra';\n\ninterface ZodSchemaFileEntry {\n schemaName: string;\n consts: string;\n zodExpression: string;\n}\n\ntype ZodSchemaFileToWrite = ZodSchemaFileEntry & {\n filePath: string;\n};\n\ninterface WriteZodOutputOptions {\n namingConvention: NamingConvention;\n indexFiles: boolean;\n packageJson?: NormalizedOutputOptions['packageJson'];\n override: {\n zod: {\n strict: {\n body: boolean;\n };\n coerce: {\n body: boolean | ZodCoerceType[];\n };\n };\n };\n}\n\ninterface WriteZodSchemasInput {\n spec: ContextSpec['spec'];\n target: string;\n schemas: {\n name: string;\n schema?: OpenApiSchemaObject | OpenApiReferenceObject;\n }[];\n}\n\ninterface WriteZodVerbResponseType {\n value: string;\n isRef?: boolean;\n originalSchema?: OpenApiSchemaObject;\n}\n\ntype WriteZodSchemasFromVerbsInput = Record<\n string,\n {\n operationName: string;\n originalOperation: {\n requestBody?: OpenApiRequestBodyObject | OpenApiReferenceObject;\n parameters?: (OpenApiParameterObject | OpenApiReferenceObject)[];\n };\n response: {\n types: {\n success: WriteZodVerbResponseType[];\n errors: WriteZodVerbResponseType[];\n };\n };\n }\n>;\n\ninterface WriteZodSchemasFromVerbsContext {\n output: {\n override: {\n useDates?: NormalizedOutputOptions['override']['useDates'];\n zod: Pick<\n NormalizedOutputOptions['override']['zod'],\n 'dateTimeOptions' | 'timeOptions'\n >;\n };\n };\n spec: ContextSpec['spec'];\n target: string;\n workspace: string;\n}\n\nfunction generateZodSchemaFileContent(\n header: string,\n schemas: ZodSchemaFileEntry[],\n): string {\n const schemaContent = schemas\n .map(({ schemaName, consts, zodExpression }) => {\n const schemaConsts = consts ? `${consts}\\n` : '';\n\n return `${schemaConsts}export const ${schemaName} = ${zodExpression}\n\nexport type ${schemaName} = zod.input<typeof ${schemaName}>;\nexport type ${schemaName}Output = zod.output<typeof ${schemaName}>;`;\n })\n .join('\\n\\n');\n\n return `${header}import { z as zod } from 'zod';\n\n${schemaContent}\n`;\n}\n\nconst isValidSchemaIdentifier = (name: string) =>\n /^[A-Za-z_][A-Za-z0-9_]*$/.test(name);\n\nconst isPrimitiveSchemaName = (name: string) =>\n ['string', 'number', 'boolean', 'void', 'unknown', 'Blob'].includes(name);\n\nconst dedupeSchemasByName = <T extends { name: string }>(schemas: T[]) => {\n const uniqueSchemas = new Map<string, T>();\n\n for (const schema of schemas) {\n if (!uniqueSchemas.has(schema.name)) {\n uniqueSchemas.set(schema.name, schema);\n }\n }\n\n return [...uniqueSchemas.values()];\n};\n\nconst groupSchemasByFilePath = <T extends { filePath: string }>(\n schemas: T[],\n) => {\n const grouped = new Map<string, T[]>();\n\n for (const schema of schemas) {\n const key = schema.filePath.toLowerCase();\n const existingGroup = grouped.get(key);\n\n if (existingGroup) {\n existingGroup.push(schema);\n } else {\n grouped.set(key, [schema]);\n }\n }\n\n const sortedGroups = [...grouped.values()].map((group) =>\n [...group].toSorted((a, b) => a.filePath.localeCompare(b.filePath)),\n );\n\n return sortedGroups.toSorted((a, b) =>\n a[0].filePath.localeCompare(b[0].filePath),\n );\n};\n\nasync function writeZodSchemaIndex(\n schemasPath: string,\n fileExtension: string,\n header: string,\n schemaNames: string[],\n namingConvention: NamingConvention,\n shouldMergeExisting = false,\n) {\n const importFileExtension = fileExtension.replace(/\\.ts$/, '');\n const indexPath = path.join(schemasPath, `index.ts`);\n\n let existingExports = '';\n if (shouldMergeExisting && (await fs.pathExists(indexPath))) {\n const existingContent = await fs.readFile(indexPath, 'utf8');\n const headerMatch = /^(\\/\\*\\*[\\s\\S]*?\\*\\/\\n)?/.exec(existingContent);\n const headerPart = headerMatch ? headerMatch[0] : '';\n existingExports = existingContent.slice(headerPart.length).trim();\n }\n\n const newExports = schemaNames\n .map((schemaName) => {\n const fileName = conventionName(schemaName, namingConvention);\n return `export * from './${fileName}${importFileExtension}';`;\n })\n .toSorted()\n .join('\\n');\n\n const allExports = existingExports\n ? `${existingExports}\\n${newExports}`\n : newExports;\n\n const uniqueExports = [...new Set(allExports.split('\\n'))]\n .filter((line) => line.trim())\n .toSorted()\n .join('\\n');\n\n await fs.outputFile(indexPath, `${header}\\n${uniqueExports}\\n`);\n}\n\nexport function generateZodSchemasInline(\n builder: WriteZodSchemasInput,\n output: WriteZodOutputOptions,\n): string {\n const schemasWithOpenApiDef = builder.schemas.filter((s) => s.schema);\n\n if (schemasWithOpenApiDef.length === 0) {\n return '';\n }\n\n const isZodV4 = !!output.packageJson && isZodVersionV4(output.packageJson);\n const strict = output.override.zod.strict.body;\n const coerce = output.override.zod.coerce.body;\n const schemas: ZodSchemaFileEntry[] = [];\n\n for (const { name, schema: schemaObject } of schemasWithOpenApiDef) {\n if (!schemaObject) {\n continue;\n }\n\n const context: ContextSpec = {\n spec: builder.spec,\n target: builder.target,\n workspace: '',\n output: output as ContextSpec['output'],\n };\n\n const dereferencedSchema = dereference(schemaObject, context);\n\n const zodDefinition = generateZodValidationSchemaDefinition(\n dereferencedSchema,\n context,\n name,\n strict,\n isZodV4,\n {\n required: true,\n },\n );\n\n const parsedZodDefinition = parseZodValidationSchemaDefinition(\n zodDefinition,\n context,\n coerce,\n strict,\n isZodV4,\n );\n\n schemas.push({\n schemaName: name,\n consts: parsedZodDefinition.consts,\n zodExpression: parsedZodDefinition.zod,\n });\n }\n\n if (schemas.length === 0) {\n return '';\n }\n\n return generateZodSchemaFileContent('', schemas);\n}\n\nexport async function writeZodSchemas(\n builder: WriteZodSchemasInput,\n schemasPath: string,\n fileExtension: string,\n header: string,\n output: WriteZodOutputOptions,\n) {\n const schemasWithOpenApiDef = builder.schemas.filter((s) => s.schema);\n const schemasToWrite: ZodSchemaFileToWrite[] = [];\n const isZodV4 = !!output.packageJson && isZodVersionV4(output.packageJson);\n const strict = output.override.zod.strict.body;\n const coerce = output.override.zod.coerce.body;\n\n for (const generatorSchema of schemasWithOpenApiDef) {\n const { name, schema: schemaObject } = generatorSchema;\n\n if (!schemaObject) {\n continue;\n }\n\n const fileName = conventionName(name, output.namingConvention);\n const filePath = path.join(schemasPath, `${fileName}${fileExtension}`);\n const context: ContextSpec = {\n spec: builder.spec,\n target: builder.target,\n workspace: '',\n output: output as ContextSpec['output'],\n };\n\n // Dereference the schema to resolve $ref\n const dereferencedSchema = dereference(schemaObject, context);\n\n const zodDefinition = generateZodValidationSchemaDefinition(\n dereferencedSchema,\n context,\n name,\n strict,\n isZodV4,\n {\n required: true,\n },\n );\n\n const parsedZodDefinition = parseZodValidationSchemaDefinition(\n zodDefinition,\n context,\n coerce,\n strict,\n isZodV4,\n );\n\n schemasToWrite.push({\n schemaName: name,\n filePath,\n consts: parsedZodDefinition.consts,\n zodExpression: parsedZodDefinition.zod,\n });\n }\n\n const groupedSchemasToWrite = groupSchemasByFilePath(schemasToWrite);\n\n for (const schemaGroup of groupedSchemasToWrite) {\n const fileContent = generateZodSchemaFileContent(header, schemaGroup);\n\n await fs.outputFile(schemaGroup[0].filePath, fileContent);\n }\n\n if (output.indexFiles) {\n const schemaNames = groupedSchemasToWrite.map(\n (schemaGroup) => schemaGroup[0].schemaName,\n );\n await writeZodSchemaIndex(\n schemasPath,\n fileExtension,\n header,\n schemaNames,\n output.namingConvention,\n false,\n );\n }\n}\n\nexport async function writeZodSchemasFromVerbs(\n verbOptions: WriteZodSchemasFromVerbsInput,\n schemasPath: string,\n fileExtension: string,\n header: string,\n output: WriteZodOutputOptions,\n context: WriteZodSchemasFromVerbsContext,\n) {\n const zodContext = context as unknown as ContextSpec;\n const verbOptionsArray = Object.values(verbOptions);\n\n if (verbOptionsArray.length === 0) {\n return;\n }\n\n const isZodV4 = !!output.packageJson && isZodVersionV4(output.packageJson);\n const strict = output.override.zod.strict.body;\n const coerce = output.override.zod.coerce.body;\n\n const generateVerbsSchemas = verbOptionsArray.flatMap((verbOption) => {\n const operation = verbOption.originalOperation;\n\n const requestBody = operation.requestBody;\n const requestBodyContent =\n requestBody && 'content' in requestBody\n ? (requestBody as OpenApiRequestBodyObject).content\n : undefined;\n // Pick the first available body media type. JSON wins; otherwise fall back\n // to form-data / urlencoded so we still generate a `*Body` schema for\n // operations whose only payload is multipart (e.g. file uploads). Without\n // this, endpoints that import `${OperationName}Body` from the zod schemas\n // path resolve to a missing export. (issue #3066)\n const jsonBodyMedia = requestBodyContent?.['application/json'];\n const formDataBodyMedia = requestBodyContent?.['multipart/form-data'];\n const formUrlEncodedBodyMedia =\n requestBodyContent?.['application/x-www-form-urlencoded'];\n const [bodyContentType, bodyMedia] = jsonBodyMedia\n ? (['application/json', jsonBodyMedia] as const)\n : formDataBodyMedia\n ? (['multipart/form-data', formDataBodyMedia] as const)\n : formUrlEncodedBodyMedia\n ? ([\n 'application/x-www-form-urlencoded',\n formUrlEncodedBodyMedia,\n ] as const)\n : [undefined, undefined];\n const bodySchema = bodyMedia?.schema as OpenApiSchemaObject | undefined;\n\n const bodySchemas = bodySchema\n ? [\n {\n name: `${pascal(verbOption.operationName)}Body`,\n schema: dereference(bodySchema, zodContext),\n bodyContentType,\n encoding: bodyMedia?.encoding,\n },\n ]\n : [];\n\n const parameters = operation.parameters;\n\n const queryParams = parameters?.filter(\n (p): p is OpenApiParameterObject => 'in' in p && p.in === 'query',\n );\n\n const queryParamsSchemas =\n queryParams && queryParams.length > 0\n ? [\n {\n name: `${pascal(verbOption.operationName)}Params`,\n schema: {\n type: 'object' as const,\n properties: Object.fromEntries(\n queryParams\n .filter((p) => 'schema' in p && p.schema)\n .map((p) => [\n p.name,\n dereference(p.schema as OpenApiSchemaObject, zodContext),\n ]),\n ) as Record<string, OpenApiSchemaObject>,\n required: queryParams\n .filter((p) => p.required)\n .map((p) => p.name)\n .filter((name): name is string => name !== undefined),\n },\n },\n ]\n : [];\n\n const headerParams = parameters?.filter(\n (p): p is OpenApiParameterObject => 'in' in p && p.in === 'header',\n );\n\n const headerParamsSchemas =\n headerParams && headerParams.length > 0\n ? [\n {\n name: `${pascal(verbOption.operationName)}Headers`,\n schema: {\n type: 'object' as const,\n properties: Object.fromEntries(\n headerParams\n .filter((p) => 'schema' in p && p.schema)\n .map((p) => [\n p.name,\n dereference(p.schema as OpenApiSchemaObject, zodContext),\n ]),\n ) as Record<string, OpenApiSchemaObject>,\n required: headerParams\n .filter((p) => p.required)\n .map((p) => p.name)\n .filter((name): name is string => name !== undefined),\n },\n },\n ]\n : [];\n\n const responseSchemas = [\n ...verbOption.response.types.success,\n ...verbOption.response.types.errors,\n ]\n .filter(\n (\n responseType,\n ): responseType is typeof responseType & {\n originalSchema: OpenApiSchemaObject;\n } =>\n !!responseType.originalSchema &&\n !responseType.isRef &&\n isValidSchemaIdentifier(responseType.value) &&\n !isPrimitiveSchemaName(responseType.value),\n )\n .map((responseType) => ({\n name: responseType.value,\n schema: dereference(responseType.originalSchema, zodContext),\n }));\n\n return dedupeSchemasByName([\n ...bodySchemas,\n ...queryParamsSchemas,\n ...headerParamsSchemas,\n ...responseSchemas,\n ]);\n });\n\n const uniqueVerbsSchemas = dedupeSchemasByName(generateVerbsSchemas);\n const schemasToWrite: ZodSchemaFileToWrite[] = [];\n\n for (const entry of uniqueVerbsSchemas) {\n const { name, schema } = entry;\n const fileName = conventionName(name, output.namingConvention);\n const filePath = path.join(schemasPath, `${fileName}${fileExtension}`);\n\n // multipart/form-data bodies need file-aware overrides so binary fields\n // become `z.instanceof(File)` instead of plain strings.\n const isFormDataBody =\n 'bodyContentType' in entry &&\n entry.bodyContentType === 'multipart/form-data';\n\n const zodDefinition: ZodValidationSchemaDefinition = isFormDataBody\n ? generateFormDataZodSchema(\n schema,\n zodContext,\n name,\n strict,\n isZodV4,\n 'encoding' in entry\n ? (entry.encoding as\n | Record<string, { contentType?: string }>\n | undefined)\n : undefined,\n )\n : generateZodValidationSchemaDefinition(\n schema,\n zodContext,\n name,\n strict,\n isZodV4,\n {\n required: true,\n },\n );\n\n const parsedZodDefinition = parseZodValidationSchemaDefinition(\n zodDefinition,\n zodContext,\n coerce,\n strict,\n isZodV4,\n );\n\n schemasToWrite.push({\n schemaName: name,\n filePath,\n consts: parsedZodDefinition.consts,\n zodExpression: parsedZodDefinition.zod,\n });\n }\n\n const groupedSchemasToWrite = groupSchemasByFilePath(schemasToWrite);\n\n for (const schemaGroup of groupedSchemasToWrite) {\n const fileContent = generateZodSchemaFileContent(header, schemaGroup);\n\n await fs.outputFile(schemaGroup[0].filePath, fileContent);\n }\n\n if (output.indexFiles && uniqueVerbsSchemas.length > 0) {\n const schemaNames = groupedSchemasToWrite.map(\n (schemaGroup) => schemaGroup[0].schemaName,\n );\n await writeZodSchemaIndex(\n schemasPath,\n fileExtension,\n header,\n schemaNames,\n output.namingConvention,\n true,\n );\n }\n}\n","import path from 'node:path';\n\nimport {\n createSuccessMessage,\n fixCrossDirectoryImports,\n fixRegularSchemaImports,\n getFileInfo,\n getMockFileExtensionByTypeName,\n isObject,\n isString,\n jsDoc,\n logWarning,\n type NormalizedOptions,\n type OpenApiInfoObject,\n OutputMode,\n splitSchemasByType,\n SupportedFormatter,\n upath,\n writeSchemas,\n writeSingleMode,\n type WriteSpecBuilder,\n writeSplitMode,\n writeSplitTagsMode,\n writeTagsMode,\n} from '@orval/core';\nimport { execa, ExecaError } from 'execa';\nimport fs from 'fs-extra';\nimport { unique } from 'remeda';\nimport type { TypeDocOptions } from 'typedoc';\n\nimport { formatWithPrettier } from './formatters/prettier';\nimport { executeHook } from './utils';\nimport {\n generateZodSchemasInline,\n writeZodSchemas,\n writeZodSchemasFromVerbs,\n} from './write-zod-specs';\n\nasync function runExternalFormatter(\n bin: string,\n args: string[],\n projectTitle?: string,\n): Promise<void> {\n try {\n await execa(bin, args);\n } catch (error) {\n let message: string;\n if (error instanceof ExecaError) {\n message =\n error.code === 'ENOENT'\n ? `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}${bin} not found`\n : error.message;\n } else if (error instanceof Error) {\n message = error.message;\n } else {\n message = `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}${bin} failed`;\n }\n logWarning(message);\n }\n}\n\nexport async function runFormatter(\n formatter: SupportedFormatter | undefined,\n paths: string[],\n projectTitle?: string,\n): Promise<void> {\n switch (formatter) {\n case SupportedFormatter.PRETTIER: {\n await formatWithPrettier(paths, projectTitle);\n break;\n }\n case SupportedFormatter.BIOME: {\n await runExternalFormatter(\n SupportedFormatter.BIOME,\n ['check', '--write', ...paths],\n projectTitle,\n );\n break;\n }\n case SupportedFormatter.OXFMT: {\n await runExternalFormatter(SupportedFormatter.OXFMT, paths, projectTitle);\n break;\n }\n }\n}\n\nfunction getHeader(\n option: false | ((info: OpenApiInfoObject) => string | string[]),\n info: OpenApiInfoObject,\n): string {\n if (!option) {\n return '';\n }\n\n const header = option(info);\n return Array.isArray(header) ? jsDoc({ description: header }) : header;\n}\n\n/**\n * Add re-export of operation schemas from the main schemas index file.\n * Handles the case where the index file doesn't exist (no regular schemas).\n */\nasync function addOperationSchemasReExport(\n schemaPath: string,\n operationSchemasPath: string,\n header: string,\n): Promise<void> {\n const schemaIndexPath = path.join(schemaPath, `index.ts`);\n const esmImportPath = upath.getRelativeImportPath(\n schemaIndexPath,\n operationSchemasPath,\n );\n const exportLine = `export * from '${esmImportPath}';\\n`;\n\n const indexExists = await fs.pathExists(schemaIndexPath);\n if (indexExists) {\n // Check if export already exists to prevent duplicates on re-runs\n // Use regex to handle both single and double quotes\n const existingContent = await fs.readFile(schemaIndexPath, 'utf8');\n const exportPattern = new RegExp(\n String.raw`export\\s*\\*\\s*from\\s*['\"]${esmImportPath.replaceAll(/[.*+?^${}()|[\\]\\\\]/g, String.raw`\\$&`)}['\"]`,\n );\n if (!exportPattern.test(existingContent)) {\n await fs.appendFile(schemaIndexPath, exportLine);\n }\n } else {\n // Create index with header if file doesn't exist (no regular schemas case)\n const content =\n header && header.trim().length > 0\n ? `${header}\\n${exportLine}`\n : exportLine;\n await fs.outputFile(schemaIndexPath, content);\n }\n}\n\nexport async function writeSpecs(\n builder: WriteSpecBuilder,\n workspace: string,\n options: NormalizedOptions,\n projectName?: string,\n) {\n const { info, schemas, target } = builder;\n const { output } = options;\n const projectTitle = projectName ?? info.title;\n\n const header = getHeader(output.override.header, info);\n\n if (output.schemas) {\n if (isString(output.schemas)) {\n const fileExtension = output.fileExtension || '.ts';\n const schemaPath = output.schemas;\n\n // Split schemas if operationSchemas path is configured\n if (output.operationSchemas) {\n const { regularSchemas, operationSchemas: opSchemas } =\n splitSchemasByType(schemas);\n\n // Fix cross-directory imports before writing (both directions)\n const regularSchemaNames = new Set(regularSchemas.map((s) => s.name));\n const operationSchemaNames = new Set(opSchemas.map((s) => s.name));\n fixCrossDirectoryImports(\n opSchemas,\n regularSchemaNames,\n schemaPath,\n output.operationSchemas,\n output.namingConvention,\n fileExtension,\n );\n fixRegularSchemaImports(\n regularSchemas,\n operationSchemaNames,\n schemaPath,\n output.operationSchemas,\n output.namingConvention,\n fileExtension,\n );\n\n // Write regular schemas to schemas path\n if (regularSchemas.length > 0) {\n await writeSchemas({\n schemaPath,\n schemas: regularSchemas,\n target,\n namingConvention: output.namingConvention,\n fileExtension,\n header,\n indexFiles: output.indexFiles,\n });\n }\n\n // Write operation schemas to operationSchemas path\n if (opSchemas.length > 0) {\n await writeSchemas({\n schemaPath: output.operationSchemas,\n schemas: opSchemas,\n target,\n namingConvention: output.namingConvention,\n fileExtension,\n header,\n indexFiles: output.indexFiles,\n });\n\n // Add re-export from operations in the main schemas index\n if (output.indexFiles) {\n await addOperationSchemasReExport(\n schemaPath,\n output.operationSchemas,\n header,\n );\n }\n }\n } else {\n await writeSchemas({\n schemaPath,\n schemas,\n target,\n namingConvention: output.namingConvention,\n fileExtension,\n header,\n indexFiles: output.indexFiles,\n });\n }\n } else {\n const schemaType = output.schemas.type;\n\n if (schemaType === 'typescript') {\n const fileExtension = output.fileExtension || '.ts';\n\n // Split schemas if operationSchemas path is configured\n if (output.operationSchemas) {\n const { regularSchemas, operationSchemas: opSchemas } =\n splitSchemasByType(schemas);\n\n // Fix cross-directory imports before writing (both directions)\n const regularSchemaNames = new Set(regularSchemas.map((s) => s.name));\n const operationSchemaNames = new Set(opSchemas.map((s) => s.name));\n fixCrossDirectoryImports(\n opSchemas,\n regularSchemaNames,\n output.schemas.path,\n output.operationSchemas,\n output.namingConvention,\n fileExtension,\n );\n fixRegularSchemaImports(\n regularSchemas,\n operationSchemaNames,\n output.schemas.path,\n output.operationSchemas,\n output.namingConvention,\n fileExtension,\n );\n\n if (regularSchemas.length > 0) {\n await writeSchemas({\n schemaPath: output.schemas.path,\n schemas: regularSchemas,\n target,\n namingConvention: output.namingConvention,\n fileExtension,\n header,\n indexFiles: output.indexFiles,\n });\n }\n\n if (opSchemas.length > 0) {\n await writeSchemas({\n schemaPath: output.operationSchemas,\n schemas: opSchemas,\n target,\n namingConvention: output.namingConvention,\n fileExtension,\n header,\n indexFiles: output.indexFiles,\n });\n\n // Add re-export from operations in the main schemas index\n if (output.indexFiles) {\n await addOperationSchemasReExport(\n output.schemas.path,\n output.operationSchemas,\n header,\n );\n }\n }\n } else {\n await writeSchemas({\n schemaPath: output.schemas.path,\n schemas,\n target,\n namingConvention: output.namingConvention,\n fileExtension,\n header,\n indexFiles: output.indexFiles,\n });\n }\n } else {\n // schemaType === 'zod'\n const fileExtension = '.zod.ts';\n\n await writeZodSchemas(\n builder,\n output.schemas.path,\n fileExtension,\n header,\n output,\n );\n\n await writeZodSchemasFromVerbs(\n builder.verbOptions,\n output.schemas.path,\n fileExtension,\n header,\n output,\n {\n spec: builder.spec,\n target: builder.target,\n workspace,\n output,\n },\n );\n }\n }\n }\n\n let implementationPaths: string[] = [];\n\n if (output.target) {\n const writeMode = getWriteMode(output.mode);\n const isZodClient = output.client === 'zod';\n const hasOperations = Object.keys(builder.operations).length > 0;\n const needZodSchemasInline =\n isZodClient && !output.schemas && !hasOperations;\n\n implementationPaths = await writeMode({\n builder,\n workspace,\n output,\n projectName,\n header,\n needSchema: (!output.schemas && !isZodClient) || needZodSchemasInline,\n generateSchemasInline: needZodSchemasInline\n ? () => generateZodSchemasInline(builder, output)\n : undefined,\n });\n }\n\n if (output.workspace) {\n const workspacePath = output.workspace;\n const indexFile = path.join(workspacePath, 'index.ts');\n const imports = implementationPaths\n .filter(\n (p) =>\n !output.mock ||\n !p.endsWith(`.${getMockFileExtensionByTypeName(output.mock)}.ts`),\n )\n .map((p) =>\n upath.getRelativeImportPath(\n indexFile,\n getFileInfo(p).pathWithoutExtension,\n true,\n ),\n );\n\n if (output.schemas) {\n const schemasPath = isString(output.schemas)\n ? output.schemas\n : output.schemas.path;\n imports.push(\n upath.getRelativeImportPath(\n indexFile,\n getFileInfo(schemasPath).dirname,\n ),\n );\n }\n\n if (output.operationSchemas) {\n imports.push(\n upath.getRelativeImportPath(\n indexFile,\n getFileInfo(output.operationSchemas).dirname,\n ),\n );\n }\n\n if (output.indexFiles) {\n if (await fs.pathExists(indexFile)) {\n const data = await fs.readFile(indexFile, 'utf8');\n const importsNotDeclared = imports.filter((imp) => !data.includes(imp));\n await fs.appendFile(\n indexFile,\n unique(importsNotDeclared)\n .map((imp) => `export * from '${imp}';\\n`)\n .join(''),\n );\n } else {\n await fs.outputFile(\n indexFile,\n unique(imports)\n .map((imp) => `export * from '${imp}';`)\n .join('\\n') + '\\n',\n );\n }\n\n implementationPaths = [indexFile, ...implementationPaths];\n }\n }\n\n if (builder.extraFiles.length > 0) {\n await Promise.all(\n builder.extraFiles.map(async (file) =>\n fs.outputFile(file.path, file.content),\n ),\n );\n\n implementationPaths = [\n ...implementationPaths,\n ...builder.extraFiles.map((file) => file.path),\n ];\n }\n\n const paths = [\n ...(output.schemas\n ? [\n getFileInfo(\n isString(output.schemas) ? output.schemas : output.schemas.path,\n ).dirname,\n ]\n : []),\n ...(output.operationSchemas\n ? [getFileInfo(output.operationSchemas).dirname]\n : []),\n ...implementationPaths,\n ];\n\n if (options.hooks.afterAllFilesWrite) {\n await executeHook(\n 'afterAllFilesWrite',\n options.hooks.afterAllFilesWrite,\n paths,\n );\n }\n\n await runFormatter(output.formatter, paths, projectTitle);\n\n if (output.docs) {\n try {\n let config: Partial<TypeDocOptions> = {};\n let configPath: string | undefined;\n if (isObject(output.docs)) {\n ({ configPath, ...config } = output.docs);\n if (configPath) {\n config.options = configPath;\n }\n }\n\n const getTypedocApplication = async () => {\n const { Application } = await import('typedoc');\n return Application;\n };\n\n const Application = await getTypedocApplication();\n const app = await Application.bootstrapWithPlugins({\n entryPoints: paths.map((x) => upath.toUnix(x)),\n theme: 'markdown',\n // Set the custom config location if it has been provided.\n ...config,\n plugin: ['typedoc-plugin-markdown', ...(config.plugin ?? [])],\n });\n // Set defaults if the have not been provided by the external config.\n if (!app.options.isSet('readme')) {\n app.options.setValue('readme', 'none');\n }\n if (!app.options.isSet('logLevel')) {\n app.options.setValue('logLevel', 'None');\n }\n const project = await app.convert();\n if (project) {\n const outputPath = app.options.getValue('out');\n await app.generateDocs(project, outputPath);\n\n await runFormatter(output.formatter, [outputPath], projectTitle);\n } else {\n throw new Error('TypeDoc not initialized');\n }\n } catch (error) {\n const message =\n error instanceof Error\n ? error.message\n : `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}Unable to generate docs`;\n\n logWarning(message);\n }\n }\n\n createSuccessMessage(projectTitle);\n}\n\nfunction getWriteMode(mode: OutputMode) {\n switch (mode) {\n case OutputMode.SPLIT: {\n return writeSplitMode;\n }\n case OutputMode.TAGS: {\n return writeTagsMode;\n }\n case OutputMode.TAGS_SPLIT: {\n return writeSplitTagsMode;\n }\n default: {\n return writeSingleMode;\n }\n }\n}\n","import {\n getFileInfo,\n isString,\n log,\n type NormalizedOptions,\n removeFilesAndEmptyFolders,\n} from '@orval/core';\n\nimport { importSpecs } from './import-specs';\nimport { writeSpecs } from './write-specs';\n\n/**\n * Generate client/spec files for a single Orval project.\n *\n * @param workspace - Absolute or relative workspace path used to resolve imports.\n * @param options - Normalized generation options for this project.\n * @param projectName - Optional project name used in logging output.\n * @returns A promise that resolves once generation (and optional cleaning) completes.\n *\n * @example\n * await generateSpec(process.cwd(), normalizedOptions, 'my-project');\n */\nexport async function generateSpec(\n workspace: string,\n options: NormalizedOptions,\n projectName?: string,\n) {\n if (options.output.clean) {\n const extraPatterns = Array.isArray(options.output.clean)\n ? options.output.clean\n : [];\n\n if (options.output.target) {\n await removeFilesAndEmptyFolders(\n ['**/*', '!**/*.d.ts', ...extraPatterns],\n getFileInfo(options.output.target).dirname,\n );\n }\n if (options.output.schemas) {\n const schemasPath = isString(options.output.schemas)\n ? options.output.schemas\n : options.output.schemas.path;\n await removeFilesAndEmptyFolders(\n ['**/*', '!**/*.d.ts', ...extraPatterns],\n getFileInfo(schemasPath).dirname,\n );\n }\n log(`${projectName} Cleaning output folder`);\n }\n\n const writeSpecBuilder = await importSpecs(workspace, options, projectName);\n await writeSpecs(writeSpecBuilder, workspace, options, projectName);\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { type Config, type ConfigExternal, isFunction } from '@orval/core';\nimport { createJiti } from 'jiti';\n\n/**\n * Resolve the Orval config file path.\n *\n * @param configFilePath - Optional path to the config file (absolute or relative).\n * @returns The absolute path to the resolved config file.\n * @throws If a provided path does not exist or if no config file is found.\n *\n * @example\n * // explicit path\n * const p = findConfigFile('./orval.config.ts');\n *\n * @example\n * // automatic discovery (searches process.cwd())\n * const p = findConfigFile();\n */\nexport function findConfigFile(configFilePath?: string) {\n if (configFilePath) {\n const absolutePath = path.isAbsolute(configFilePath)\n ? configFilePath\n : path.resolve(process.cwd(), configFilePath);\n\n if (!fs.existsSync(absolutePath))\n throw new Error(`Config file ${configFilePath} does not exist`);\n\n return absolutePath;\n }\n\n const root = process.cwd();\n const exts = ['.ts', '.js', '.mjs', '.mts'];\n for (const ext of exts) {\n const fullPath = path.resolve(root, `orval.config${ext}`);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n\n throw new Error(`No config file found in ${root}`);\n}\n\n/**\n * Load an Orval config file\n * @param configFilePath - Path to the config file (absolute or relative).\n * @returns The resolved Orval `Config` object.\n * @throws If the module does not provide a default export or the default export resolves to `undefined`.\n *\n * @example\n * // load a config object\n * const cfg = await loadConfigFile('./orval.config.ts');\n */\nexport async function loadConfigFile(configFilePath: string): Promise<Config> {\n const jiti = createJiti(process.cwd(), {\n interopDefault: true,\n });\n\n const configExternal = await jiti.import<ConfigExternal | undefined>(\n configFilePath,\n {\n default: true,\n },\n );\n\n if (configExternal === undefined) {\n throw new Error(`${configFilePath} doesn't have a default export`);\n }\n\n const config = await (isFunction(configExternal)\n ? configExternal()\n : configExternal);\n\n return config;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACuCA,MAAM,iBAAiB,aAAa;AAEpC,MAAM,sBACJ,cACA,WACG;CACH,MAAM,iBAAiB,SAAS;CAGhC,MAAM,mBAAqC;EACzC,OAAO,MAAM,EAAE,MAAM,SAAS,CAAC,EAAE;EACjC,mBAAmB,MAAM,EAAE,MAAM,mBAAmB,CAAC,EAAE;EACvD,SAAS,eAAe,OAAO,SAAS,QAAQ;EAChD,iBAAiB,MAAM;GAAE;GAAQ,MAAM;GAAiB,CAAC,EAAE;EAC3D,eAAe,MAAM;GAAE;GAAQ,MAAM;GAAe,CAAC,EAAE;EACvD,eAAe,YAAY,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