orval 8.5.3 → 8.6.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-B7ywe2U9.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { Option, program } from "@commander-js/extra-typings";
|
|
5
5
|
import { ErrorWithTag, OutputClient, OutputMode, isString, log, logError, setVerbose, startMessage } from "@orval/core";
|
|
@@ -20,7 +20,6 @@ import { ExecaError, execa } from "execa";
|
|
|
20
20
|
import fs from "fs-extra";
|
|
21
21
|
import fs$1, { access } from "node:fs/promises";
|
|
22
22
|
import { parseArgsStringToArgv } from "string-argv";
|
|
23
|
-
import { clearTimeout, setTimeout } from "node:timers";
|
|
24
23
|
import { findUp, findUpMultiple } from "find-up";
|
|
25
24
|
import yaml from "js-yaml";
|
|
26
25
|
import { parse } from "tsconfck";
|
|
@@ -30,16 +29,17 @@ import { createJiti } from "jiti";
|
|
|
30
29
|
//#region package.json
|
|
31
30
|
var name = "orval";
|
|
32
31
|
var description = "A swagger client generator for typescript";
|
|
33
|
-
var version = "8.
|
|
32
|
+
var version = "8.6.0";
|
|
34
33
|
|
|
35
34
|
//#endregion
|
|
36
35
|
//#region src/client.ts
|
|
37
36
|
const DEFAULT_CLIENT = OutputClient.AXIOS;
|
|
38
37
|
const getGeneratorClient = (outputClient, output) => {
|
|
38
|
+
const angularBuilder = angular();
|
|
39
39
|
const GENERATOR_CLIENT = {
|
|
40
40
|
axios: axios({ type: "axios" })(),
|
|
41
41
|
"axios-functions": axios({ type: "axios-functions" })(),
|
|
42
|
-
angular: angular
|
|
42
|
+
angular: angularBuilder(output.override.angular),
|
|
43
43
|
"angular-query": query({
|
|
44
44
|
output,
|
|
45
45
|
type: "angular-query"
|
|
@@ -67,7 +67,9 @@ const getGeneratorClient = (outputClient, output) => {
|
|
|
67
67
|
fetch: fetchClient()(),
|
|
68
68
|
mcp: mcp()()
|
|
69
69
|
};
|
|
70
|
-
|
|
70
|
+
const generator = isFunction(outputClient) ? outputClient(GENERATOR_CLIENT) : GENERATOR_CLIENT[outputClient];
|
|
71
|
+
if (!generator) throw new Error(`Unknown output client provided to getGeneratorClient: ${String(outputClient)}`);
|
|
72
|
+
return generator;
|
|
71
73
|
};
|
|
72
74
|
const generateClientImports = ({ client, implementation, imports, projectName, hasSchemaDir, isAllowSyntheticDefaultImports, hasGlobalMutator, hasTagsMutator, hasParamsSerializerOptions, packageJson, output }) => {
|
|
73
75
|
const { dependencies } = getGeneratorClient(client, output);
|
|
@@ -157,8 +159,17 @@ const generateOperations = (outputClient = DEFAULT_CLIENT, verbsOptions, options
|
|
|
157
159
|
const client = await generatorClient(verbOption, options, outputClient, output);
|
|
158
160
|
if (!client.implementation) return acc;
|
|
159
161
|
const generatedMock = generateMock(verbOption, options);
|
|
160
|
-
|
|
161
|
-
|
|
162
|
+
const hasImplementation = client.implementation.trim().length > 0;
|
|
163
|
+
const preferredOperationKey = verbOption.operationName;
|
|
164
|
+
const baseOperationKey = verbOption.operationId ? `${verbOption.operationId}::${verbOption.operationName}` : verbOption.operationName;
|
|
165
|
+
let operationKey = Object.hasOwn(acc, preferredOperationKey) ? baseOperationKey : preferredOperationKey;
|
|
166
|
+
let collisionIndex = 1;
|
|
167
|
+
while (Object.hasOwn(acc, operationKey)) {
|
|
168
|
+
collisionIndex += 1;
|
|
169
|
+
operationKey = `${baseOperationKey}::${collisionIndex}`;
|
|
170
|
+
}
|
|
171
|
+
acc[operationKey] = {
|
|
172
|
+
implementation: hasImplementation ? verbOption.doc + client.implementation : client.implementation,
|
|
162
173
|
imports: client.imports,
|
|
163
174
|
implementationMock: generatedMock.implementation,
|
|
164
175
|
importsMock: generatedMock.imports,
|
|
@@ -184,6 +195,7 @@ const generateExtraFiles = (outputClient = DEFAULT_CLIENT, verbsOptions, output,
|
|
|
184
195
|
//#region src/api.ts
|
|
185
196
|
async function getApiBuilder({ input, output, context }) {
|
|
186
197
|
const api = await asyncReduce(Object.entries(context.spec.paths ?? {}), async (acc, [pathRoute, verbs]) => {
|
|
198
|
+
if (!verbs) return acc;
|
|
187
199
|
const route = getRoute(pathRoute);
|
|
188
200
|
let resolvedVerbs = verbs;
|
|
189
201
|
if (isReference(verbs)) {
|
|
@@ -208,7 +220,7 @@ async function getApiBuilder({ input, output, context }) {
|
|
|
208
220
|
if (headers) schemas.push(headers.schema, ...headers.deps);
|
|
209
221
|
schemas.push(...body.schemas, ...response.schemas);
|
|
210
222
|
}
|
|
211
|
-
const fullRoute = getFullRoute(route,
|
|
223
|
+
const fullRoute = getFullRoute(route, resolvedVerbs.servers ?? context.spec.servers, output.baseUrl);
|
|
212
224
|
if (!output.target) throw new Error("Output does not have a target");
|
|
213
225
|
const pathOperations = await generateOperations(output.client, verbsOptions, {
|
|
214
226
|
route: fullRoute,
|
|
@@ -315,6 +327,7 @@ async function resolveSpec(input, parserOptions) {
|
|
|
315
327
|
],
|
|
316
328
|
treeShake: false
|
|
317
329
|
}));
|
|
330
|
+
validateComponentKeys(dereferencedData);
|
|
318
331
|
const { valid, errors } = await validate(dereferencedData);
|
|
319
332
|
if (!valid) throw new Error("Validation failed", { cause: errors });
|
|
320
333
|
const { specification } = upgrade(dereferencedData);
|
|
@@ -326,11 +339,40 @@ async function importSpecs(workspace, options, projectName) {
|
|
|
326
339
|
spec: await resolveSpec(input.target, input.parserOptions),
|
|
327
340
|
input,
|
|
328
341
|
output,
|
|
329
|
-
target: input.target,
|
|
342
|
+
target: isString(input.target) ? input.target : workspace,
|
|
330
343
|
workspace,
|
|
331
344
|
projectName
|
|
332
345
|
});
|
|
333
346
|
}
|
|
347
|
+
const COMPONENT_KEY_PATTERN = /^[a-zA-Z0-9.\-_]+$/;
|
|
348
|
+
const COMPONENT_SECTIONS = [
|
|
349
|
+
"schemas",
|
|
350
|
+
"responses",
|
|
351
|
+
"parameters",
|
|
352
|
+
"examples",
|
|
353
|
+
"requestBodies",
|
|
354
|
+
"headers",
|
|
355
|
+
"securitySchemes",
|
|
356
|
+
"links",
|
|
357
|
+
"callbacks",
|
|
358
|
+
"pathItems"
|
|
359
|
+
];
|
|
360
|
+
/**
|
|
361
|
+
* Validate that all component keys conform to the OAS regex: ^[a-zA-Z0-9.\-_]+$
|
|
362
|
+
* @see https://spec.openapis.org/oas/v3.0.3.html#fixed-fields-5
|
|
363
|
+
* @see https://spec.openapis.org/oas/v3.1.0#fixed-fields-5
|
|
364
|
+
*/
|
|
365
|
+
function validateComponentKeys(data) {
|
|
366
|
+
const components = data.components;
|
|
367
|
+
if (!isObject(components)) return;
|
|
368
|
+
const invalidKeys = [];
|
|
369
|
+
for (const section of COMPONENT_SECTIONS) {
|
|
370
|
+
const sectionObj = components[section];
|
|
371
|
+
if (!isObject(sectionObj)) continue;
|
|
372
|
+
for (const key of Object.keys(sectionObj)) if (!COMPONENT_KEY_PATTERN.test(key)) invalidKeys.push(`components.${section}.${key}`);
|
|
373
|
+
}
|
|
374
|
+
if (invalidKeys.length > 0) throw new Error(`Invalid component key${invalidKeys.length > 1 ? "s" : ""} found. OpenAPI component keys must match the pattern ${COMPONENT_KEY_PATTERN} (non-ASCII characters are not allowed per the spec).\n See: https://spec.openapis.org/oas/v3.0.3.html#components-object\n Invalid keys:\n` + invalidKeys.map((k) => ` - ${k}`).join("\n"));
|
|
375
|
+
}
|
|
334
376
|
/**
|
|
335
377
|
* The plugins from `@scalar/json-magic` does not dereference $ref.
|
|
336
378
|
* Instead it fetches them and puts them under x-ext, and changes the $ref to point to #x-ext/<name>.
|
|
@@ -466,17 +508,19 @@ function replaceXExtRefs(obj, extensions, schemaNameMappings) {
|
|
|
466
508
|
async function formatWithPrettier(paths, projectTitle) {
|
|
467
509
|
const prettier = await tryImportPrettier();
|
|
468
510
|
if (prettier) {
|
|
469
|
-
const filePaths = await collectFilePaths(paths);
|
|
470
|
-
|
|
511
|
+
const filePaths = [...new Set(await collectFilePaths(paths))];
|
|
512
|
+
if (filePaths.length === 0) return;
|
|
513
|
+
const config = await prettier.resolveConfig(filePaths[0]) ?? {};
|
|
471
514
|
await Promise.all(filePaths.map(async (filePath) => {
|
|
472
|
-
const content = await fs$1.readFile(filePath, "utf8");
|
|
473
515
|
try {
|
|
516
|
+
const content = await fs$1.readFile(filePath, "utf8");
|
|
474
517
|
const formatted = await prettier.format(content, {
|
|
475
518
|
...config,
|
|
476
519
|
filepath: filePath
|
|
477
520
|
});
|
|
478
521
|
await fs$1.writeFile(filePath, formatted);
|
|
479
522
|
} catch (error) {
|
|
523
|
+
if (isMissingFileError(error)) return;
|
|
480
524
|
if (error instanceof Error) if (error.name === "UndefinedParserError") {} else log(styleText("yellow", `⚠️ ${projectTitle ? `${projectTitle} - ` : ""}Failed to format file ${filePath}: ${error.toString()}`));
|
|
481
525
|
else log(styleText("yellow", `⚠️ ${projectTitle ? `${projectTitle} - ` : ""}Failed to format file ${filePath}: unknown error}`));
|
|
482
526
|
}
|
|
@@ -489,6 +533,9 @@ async function formatWithPrettier(paths, projectTitle) {
|
|
|
489
533
|
log(styleText("yellow", `⚠️ ${projectTitle ? `${projectTitle} - ` : ""}prettier not found. Install it as a project dependency or globally.`));
|
|
490
534
|
}
|
|
491
535
|
}
|
|
536
|
+
function isMissingFileError(error) {
|
|
537
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
538
|
+
}
|
|
492
539
|
/**
|
|
493
540
|
* Try to import prettier from the project's dependencies.
|
|
494
541
|
* Returns undefined if prettier is not installed.
|
|
@@ -685,6 +732,7 @@ const loadTsconfig = async (tsconfig, workspace = process.cwd()) => {
|
|
|
685
732
|
|
|
686
733
|
//#endregion
|
|
687
734
|
//#region src/utils/options.ts
|
|
735
|
+
const INPUT_TARGET_FETCH_TIMEOUT_MS = 1e4;
|
|
688
736
|
/**
|
|
689
737
|
* Type helper to make it easier to use orval.config.ts
|
|
690
738
|
* accepts a direct {@link ConfigExternal} object.
|
|
@@ -735,8 +783,8 @@ function normalizeSchemasOption(schemas, workspace) {
|
|
|
735
783
|
}
|
|
736
784
|
async function normalizeOptions(optionsExport, workspace = process.cwd(), globalOptions = {}) {
|
|
737
785
|
const options = await (isFunction(optionsExport) ? optionsExport() : optionsExport);
|
|
738
|
-
if (!options.input) throw new Error(styleText("red", `Config
|
|
739
|
-
if (!options.output) throw new Error(styleText("red", `Config
|
|
786
|
+
if (!options.input) throw new Error(styleText("red", `Config requires an input.`));
|
|
787
|
+
if (!options.output) throw new Error(styleText("red", `Config requires an output.`));
|
|
740
788
|
const inputOptions = isString(options.input) || Array.isArray(options.input) ? { target: options.input } : options.input;
|
|
741
789
|
const outputOptions = isString(options.output) ? { target: options.output } : options.output;
|
|
742
790
|
const outputWorkspace = normalizePath(outputOptions.workspace ?? "", workspace);
|
|
@@ -763,13 +811,9 @@ async function normalizeOptions(optionsExport, workspace = process.cwd(), global
|
|
|
763
811
|
shouldSplitQueryKey: false,
|
|
764
812
|
...normalizeQueryOptions(outputOptions.override?.query, workspace)
|
|
765
813
|
};
|
|
766
|
-
let resolvedInputTarget;
|
|
767
|
-
if (globalOptions.input) resolvedInputTarget = Array.isArray(globalOptions.input) ? await resolveFirstValidTarget(globalOptions.input, process.cwd(), inputOptions.parserOptions) : normalizePathOrUrl(globalOptions.input, process.cwd());
|
|
768
|
-
else if (Array.isArray(inputOptions.target)) resolvedInputTarget = await resolveFirstValidTarget(inputOptions.target, workspace, inputOptions.parserOptions);
|
|
769
|
-
else resolvedInputTarget = normalizePathOrUrl(inputOptions.target, workspace);
|
|
770
814
|
const normalizedOptions = {
|
|
771
815
|
input: {
|
|
772
|
-
target:
|
|
816
|
+
target: globalOptions.input ? Array.isArray(globalOptions.input) ? await resolveFirstValidTarget(globalOptions.input, process.cwd(), inputOptions.parserOptions) : normalizePathOrUrl(globalOptions.input, process.cwd()) : Array.isArray(inputOptions.target) ? await resolveFirstValidTarget(inputOptions.target, workspace, inputOptions.parserOptions) : normalizePathOrUrl(inputOptions.target, workspace),
|
|
773
817
|
override: { transformer: normalizePath(inputOptions.override?.transformer, workspace) },
|
|
774
818
|
filters: inputOptions.filters,
|
|
775
819
|
parserOptions: inputOptions.parserOptions
|
|
@@ -875,7 +919,9 @@ async function normalizeOptions(optionsExport, workspace = process.cwd(), global
|
|
|
875
919
|
},
|
|
876
920
|
angular: {
|
|
877
921
|
provideIn: outputOptions.override?.angular?.provideIn ?? "root",
|
|
878
|
-
|
|
922
|
+
client: outputOptions.override?.angular?.retrievalClient ?? outputOptions.override?.angular?.client ?? "httpClient",
|
|
923
|
+
runtimeValidation: outputOptions.override?.angular?.runtimeValidation ?? false,
|
|
924
|
+
...outputOptions.override?.angular?.httpResource ? { httpResource: outputOptions.override.angular.httpResource } : {}
|
|
879
925
|
},
|
|
880
926
|
fetch: {
|
|
881
927
|
includeHttpResponseReturnType: outputOptions.override?.fetch?.includeHttpResponseReturnType ?? true,
|
|
@@ -888,6 +934,7 @@ async function normalizeOptions(optionsExport, workspace = process.cwd(), global
|
|
|
888
934
|
useDeprecatedOperations: outputOptions.override?.useDeprecatedOperations ?? true,
|
|
889
935
|
enumGenerationType: outputOptions.override?.enumGenerationType ?? "const",
|
|
890
936
|
suppressReadonlyModifier: outputOptions.override?.suppressReadonlyModifier ?? false,
|
|
937
|
+
preserveReadonlyRequestBodies: outputOptions.override?.preserveReadonlyRequestBodies ?? "strip",
|
|
891
938
|
aliasCombinedTypes: outputOptions.override?.aliasCombinedTypes ?? false
|
|
892
939
|
},
|
|
893
940
|
allParamsOptional: outputOptions.allParamsOptional ?? false,
|
|
@@ -897,70 +944,79 @@ async function normalizeOptions(optionsExport, workspace = process.cwd(), global
|
|
|
897
944
|
},
|
|
898
945
|
hooks: options.hooks ? normalizeHooks(options.hooks) : {}
|
|
899
946
|
};
|
|
900
|
-
if (!normalizedOptions.input.target) throw new Error(styleText("red", `Config
|
|
901
|
-
if (!normalizedOptions.output.target && !normalizedOptions.output.schemas) throw new Error(styleText("red", `Config
|
|
947
|
+
if (!normalizedOptions.input.target) throw new Error(styleText("red", `Config requires an input target.`));
|
|
948
|
+
if (!normalizedOptions.output.target && !normalizedOptions.output.schemas) throw new Error(styleText("red", `Config requires an output target or schemas.`));
|
|
902
949
|
return normalizedOptions;
|
|
903
950
|
}
|
|
904
951
|
function normalizeMutator(workspace, mutator) {
|
|
905
952
|
if (isObject(mutator)) {
|
|
906
|
-
|
|
953
|
+
const m = mutator;
|
|
954
|
+
if (!m.path) throw new Error(styleText("red", `Mutator requires a path.`));
|
|
907
955
|
return {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
default:
|
|
956
|
+
path: path.resolve(workspace, m.path),
|
|
957
|
+
name: m.name,
|
|
958
|
+
default: m.default ?? !m.name,
|
|
959
|
+
alias: m.alias,
|
|
960
|
+
external: m.external,
|
|
961
|
+
extension: m.extension
|
|
911
962
|
};
|
|
912
963
|
}
|
|
913
964
|
if (isString(mutator)) return {
|
|
914
965
|
path: path.resolve(workspace, mutator),
|
|
915
966
|
default: true
|
|
916
967
|
};
|
|
917
|
-
return mutator;
|
|
918
968
|
}
|
|
919
|
-
const TARGET_RESOLVE_TIMEOUT_MS = 5e3;
|
|
920
969
|
async function resolveFirstValidTarget(targets, workspace, parserOptions) {
|
|
921
|
-
for (const target of targets)
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
signal: controller.signal
|
|
939
|
-
})).ok) return target;
|
|
970
|
+
for (const target of targets) {
|
|
971
|
+
if (isUrl(target)) {
|
|
972
|
+
try {
|
|
973
|
+
const headers = getHeadersForUrl(target, parserOptions?.headers);
|
|
974
|
+
const headResponse = await fetchWithTimeout(target, {
|
|
975
|
+
method: "HEAD",
|
|
976
|
+
headers
|
|
977
|
+
});
|
|
978
|
+
if (headResponse.ok) return target;
|
|
979
|
+
if (headResponse.status === 405 || headResponse.status === 501) {
|
|
980
|
+
if ((await fetchWithTimeout(target, {
|
|
981
|
+
method: "GET",
|
|
982
|
+
headers
|
|
983
|
+
})).ok) return target;
|
|
984
|
+
}
|
|
985
|
+
} catch {
|
|
986
|
+
continue;
|
|
940
987
|
}
|
|
941
|
-
|
|
942
|
-
clearTimeout(timer);
|
|
988
|
+
continue;
|
|
943
989
|
}
|
|
944
|
-
|
|
945
|
-
continue;
|
|
946
|
-
}
|
|
947
|
-
else {
|
|
948
|
-
const resolved = path.resolve(workspace, target);
|
|
990
|
+
const resolvedTarget = normalizePath(target, workspace);
|
|
949
991
|
try {
|
|
950
|
-
await access(
|
|
951
|
-
return
|
|
992
|
+
await access(resolvedTarget);
|
|
993
|
+
return resolvedTarget;
|
|
952
994
|
} catch {
|
|
953
995
|
continue;
|
|
954
996
|
}
|
|
955
997
|
}
|
|
956
|
-
throw new Error(styleText("red", `None of the input targets could be resolved:\n${targets.map((
|
|
998
|
+
throw new Error(styleText("red", `None of the input targets could be resolved:\n${targets.map((target) => ` - ${target}`).join("\n")}`));
|
|
957
999
|
}
|
|
958
1000
|
function getHeadersForUrl(url, headersConfig) {
|
|
959
1001
|
if (!headersConfig) return {};
|
|
960
1002
|
const { hostname } = new URL(url);
|
|
961
|
-
const
|
|
962
|
-
for (const
|
|
963
|
-
return
|
|
1003
|
+
const matchedHeaders = {};
|
|
1004
|
+
for (const headerEntry of headersConfig) if (headerEntry.domains.some((domain) => hostname === domain || hostname.endsWith(`.${domain}`))) Object.assign(matchedHeaders, headerEntry.headers);
|
|
1005
|
+
return matchedHeaders;
|
|
1006
|
+
}
|
|
1007
|
+
async function fetchWithTimeout(target, init) {
|
|
1008
|
+
const controller = new AbortController();
|
|
1009
|
+
const timeoutId = setTimeout(() => {
|
|
1010
|
+
controller.abort();
|
|
1011
|
+
}, INPUT_TARGET_FETCH_TIMEOUT_MS);
|
|
1012
|
+
try {
|
|
1013
|
+
return await fetch(target, {
|
|
1014
|
+
...init,
|
|
1015
|
+
signal: controller.signal
|
|
1016
|
+
});
|
|
1017
|
+
} finally {
|
|
1018
|
+
clearTimeout(timeoutId);
|
|
1019
|
+
}
|
|
964
1020
|
}
|
|
965
1021
|
function normalizePathOrUrl(path, workspace) {
|
|
966
1022
|
if (isString(path) && !isUrl(path)) return normalizePath(path, workspace);
|
|
@@ -971,9 +1027,15 @@ function normalizePath(path$1, workspace) {
|
|
|
971
1027
|
return path.resolve(workspace, path$1);
|
|
972
1028
|
}
|
|
973
1029
|
function normalizeOperationsAndTags(operationsOrTags, workspace, global) {
|
|
974
|
-
return Object.fromEntries(Object.entries(operationsOrTags).map(([key, { transformer, mutator, formData, formUrlEncoded, paramsSerializer, query, zod, ...rest }]) => {
|
|
1030
|
+
return Object.fromEntries(Object.entries(operationsOrTags).map(([key, { transformer, mutator, formData, formUrlEncoded, paramsSerializer, query, angular, zod, ...rest }]) => {
|
|
975
1031
|
return [key, {
|
|
976
1032
|
...rest,
|
|
1033
|
+
...angular ? { angular: {
|
|
1034
|
+
provideIn: angular.provideIn ?? "root",
|
|
1035
|
+
client: angular.retrievalClient ?? angular.client ?? "httpClient",
|
|
1036
|
+
runtimeValidation: angular.runtimeValidation ?? false,
|
|
1037
|
+
...angular.httpResource ? { httpResource: angular.httpResource } : {}
|
|
1038
|
+
} } : {},
|
|
977
1039
|
...query ? { query: normalizeQueryOptions(query, workspace, global.query) } : {},
|
|
978
1040
|
...zod ? { zod: {
|
|
979
1041
|
strict: {
|
|
@@ -1010,7 +1072,7 @@ function normalizeOperationsAndTags(operationsOrTags, workspace, global) {
|
|
|
1010
1072
|
} } : {},
|
|
1011
1073
|
...transformer ? { transformer: normalizePath(transformer, workspace) } : {},
|
|
1012
1074
|
...mutator ? { mutator: normalizeMutator(workspace, mutator) } : {},
|
|
1013
|
-
...createFormData(workspace, formData),
|
|
1075
|
+
...formData === void 0 ? {} : { formData: createFormData(workspace, formData) },
|
|
1014
1076
|
...formUrlEncoded ? { formUrlEncoded: isBoolean(formUrlEncoded) ? formUrlEncoded : normalizeMutator(workspace, formUrlEncoded) } : {},
|
|
1015
1077
|
...paramsSerializer ? { paramsSerializer: normalizeMutator(workspace, paramsSerializer) } : {}
|
|
1016
1078
|
}];
|
|
@@ -1019,7 +1081,7 @@ function normalizeOperationsAndTags(operationsOrTags, workspace, global) {
|
|
|
1019
1081
|
function normalizeOutputMode(mode) {
|
|
1020
1082
|
if (!mode) return OutputMode.SINGLE;
|
|
1021
1083
|
if (!Object.values(OutputMode).includes(mode)) {
|
|
1022
|
-
createLogger().warn(styleText("yellow", `Unknown
|
|
1084
|
+
createLogger().warn(styleText("yellow", `Unknown provided mode => ${mode}`));
|
|
1023
1085
|
return OutputMode.SINGLE;
|
|
1024
1086
|
}
|
|
1025
1087
|
return mode;
|
|
@@ -1135,7 +1197,8 @@ function generateZodSchemaFileContent(header, schemas) {
|
|
|
1135
1197
|
${schemas.map(({ schemaName, consts, zodExpression }) => {
|
|
1136
1198
|
return `${consts ? `${consts}\n` : ""}export const ${schemaName} = ${zodExpression}
|
|
1137
1199
|
|
|
1138
|
-
export type ${schemaName} = zod.input<typeof ${schemaName}
|
|
1200
|
+
export type ${schemaName} = zod.input<typeof ${schemaName}>;
|
|
1201
|
+
export type ${schemaName}Output = zod.output<typeof ${schemaName}>;`;
|
|
1139
1202
|
}).join("\n\n")}
|
|
1140
1203
|
`;
|
|
1141
1204
|
}
|
|
@@ -1567,4 +1630,4 @@ async function loadConfigFile(configFilePath) {
|
|
|
1567
1630
|
|
|
1568
1631
|
//#endregion
|
|
1569
1632
|
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 };
|
|
1570
|
-
//# sourceMappingURL=config-
|
|
1633
|
+
//# sourceMappingURL=config-B7ywe2U9.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-B7ywe2U9.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 isFunction,\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 console.warn(\n '[WARN] 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 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 ? verbOption.doc + client.implementation\n : client.implementation,\n imports: 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 } = resolveRef<OpenApiPathItemObject>(verbs, context);\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 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';\n\nimport { getApiBuilder } from './api';\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 );\n\n const schemas = getApiSchemas({\n input,\n output,\n target,\n workspace,\n spec: transformedOpenApi,\n });\n\n const api = await getApiBuilder({\n input,\n output,\n context: {\n projectName,\n target,\n workspace,\n spec: transformedOpenApi,\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: transformedOpenApi.info!,\n spec: transformedOpenApi,\n };\n}\n\nasync function applyTransformer(\n openApi: OpenApiDocument,\n transformer: OverrideInput['transformer'],\n workspace: string,\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 const { valid, errors } = await validate(transformedOpenApi);\n if (!valid) {\n throw new Error(`Validation failed`, { cause: errors });\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 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): 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 validateComponentKeys(dereferencedData);\n\n const { valid, errors } = await validateSpec(dereferencedData);\n if (!valid) {\n throw new Error('Validation failed', { cause: errors });\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(input.target, input.parserOptions);\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';\nimport { styleText } from 'node:util';\n\nimport { log } 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 log(\n styleText(\n 'yellow',\n `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}Failed to format file ${filePath}: ${error.toString()}`,\n ),\n );\n }\n } else {\n log(\n styleText(\n 'yellow',\n `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}Failed to format file ${filePath}: unknown error}`,\n ),\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 log(\n styleText(\n 'yellow',\n `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}prettier not found. Install it as a project dependency or globally.`,\n ),\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 log,\n logVerbose,\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 log(\n `⚠️ ${styleText('yellow', '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 log(\n `⚠️ ${styleText('yellow', `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 log(\n `⚠️ ${styleText('yellow', `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 log(\n `⚠️ ${styleText('yellow', `'${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 log(\n `⚠️ ${styleText('yellow', `'${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 createLogger,\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 type Mutator,\n NamingConvention,\n type NormalizedHonoOptions,\n type NormalizedHookOptions,\n type NormalizedJsDocOptions,\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/**\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 | 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, prettier, client, httpClient, mode, biome } = 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 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 prettier: outputOptions.prettier ?? prettier ?? false,\n biome: outputOptions.biome ?? biome ?? false,\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 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 dateTimeOptions: outputOptions.override?.zod?.dateTimeOptions ?? {},\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 ...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 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 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 dateTimeOptions: zod.dateTimeOptions ?? {},\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 createLogger().warn(\n styleText('yellow', `Unknown provided mode => ${mode}`),\n );\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 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 console.warn(\n '[WARN] 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.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('all', (type, file) => {\n log(`Change detected: ${type} ${file}`);\n\n watchFn().catch((error: unknown) => {\n logError(error);\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 generateZodValidationSchemaDefinition,\n isZodVersionV4,\n parseZodValidationSchemaDefinition,\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${fileExtension}`);\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 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 const bodySchema = requestBodyContent?.['application/json']?.schema as\n | OpenApiSchemaObject\n | undefined;\n\n const bodySchemas = bodySchema\n ? [\n {\n name: `${pascal(verbOption.operationName)}Body`,\n schema: dereference(bodySchema, zodContext),\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 { name, schema } of uniqueVerbsSchemas) {\n const fileName = conventionName(name, output.namingConvention);\n const filePath = path.join(schemasPath, `${fileName}${fileExtension}`);\n\n const zodDefinition = 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';\nimport { styleText } from 'node:util';\n\nimport {\n createSuccessMessage,\n fixCrossDirectoryImports,\n fixRegularSchemaImports,\n getFileInfo,\n getMockFileExtensionByTypeName,\n isObject,\n isString,\n jsDoc,\n log,\n type NormalizedOptions,\n type OpenApiInfoObject,\n OutputMode,\n splitSchemasByType,\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 { writeZodSchemas, writeZodSchemasFromVerbs } from './write-zod-specs';\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 fileExtension: string,\n header: string,\n): Promise<void> {\n const schemaIndexPath = path.join(schemaPath, `index${fileExtension}`);\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 fileExtension,\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 fileExtension,\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 implementationPaths = await writeMode({\n builder,\n workspace,\n output,\n projectName,\n header,\n needSchema: !output.schemas && output.client !== 'zod',\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 if (output.prettier) {\n await formatWithPrettier(paths, projectTitle);\n }\n\n if (output.biome) {\n try {\n await execa('biome', ['check', '--write', ...paths]);\n } catch (error) {\n let message = `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}biome not found`;\n if (error instanceof ExecaError && error.exitCode === 1)\n message = error.message;\n\n log(styleText('yellow', message));\n }\n }\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 if (output.prettier) {\n await formatWithPrettier([outputPath], projectTitle);\n }\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 log(styleText('yellow', 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACqCA,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;EACzD,aAAa,MAAM;GAAE;GAAQ,MAAM;GAAa,CAAC,EAAE;EACnD,KAAK,KAAK,EAAE;EACZ,KAAK,KAAK,EAAE;EAC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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-B7ywe2U9.mjs";
|
|
2
2
|
import { isString, logError, setVerbose } from "@orval/core";
|
|
3
3
|
|
|
4
4
|
export * from "@orval/core"
|
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.6.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -12,8 +12,14 @@
|
|
|
12
12
|
"bin": "./dist/bin/orval.mjs",
|
|
13
13
|
"types": "./dist/index.d.mts",
|
|
14
14
|
"exports": {
|
|
15
|
-
".":
|
|
16
|
-
|
|
15
|
+
".": {
|
|
16
|
+
"development": "./src/index.ts",
|
|
17
|
+
"default": "./dist/index.mjs"
|
|
18
|
+
},
|
|
19
|
+
"./bin/orval": {
|
|
20
|
+
"development": "./src/bin/orval.ts",
|
|
21
|
+
"default": "./dist/bin/orval.mjs"
|
|
22
|
+
},
|
|
17
23
|
"./package.json": "./package.json"
|
|
18
24
|
},
|
|
19
25
|
"engines": {
|
|
@@ -56,25 +62,26 @@
|
|
|
56
62
|
"dev": "tsdown --config-loader unrun --watch src",
|
|
57
63
|
"lint": "eslint .",
|
|
58
64
|
"test": "vitest",
|
|
65
|
+
"typecheck": "tsc --noEmit",
|
|
59
66
|
"clean": "rimraf .turbo dist",
|
|
60
67
|
"nuke": "rimraf .turbo dist node_modules"
|
|
61
68
|
},
|
|
62
69
|
"dependencies": {
|
|
63
70
|
"@commander-js/extra-typings": "^14.0.0",
|
|
64
|
-
"@orval/angular": "
|
|
65
|
-
"@orval/axios": "
|
|
66
|
-
"@orval/core": "
|
|
67
|
-
"@orval/fetch": "
|
|
68
|
-
"@orval/hono": "
|
|
69
|
-
"@orval/mcp": "
|
|
70
|
-
"@orval/mock": "
|
|
71
|
-
"@orval/query": "
|
|
72
|
-
"@orval/solid-start": "
|
|
73
|
-
"@orval/swr": "
|
|
74
|
-
"@orval/zod": "
|
|
71
|
+
"@orval/angular": "workspace:*",
|
|
72
|
+
"@orval/axios": "workspace:*",
|
|
73
|
+
"@orval/core": "workspace:*",
|
|
74
|
+
"@orval/fetch": "workspace:*",
|
|
75
|
+
"@orval/hono": "workspace:*",
|
|
76
|
+
"@orval/mcp": "workspace:*",
|
|
77
|
+
"@orval/mock": "workspace:*",
|
|
78
|
+
"@orval/query": "workspace:*",
|
|
79
|
+
"@orval/solid-start": "workspace:*",
|
|
80
|
+
"@orval/swr": "workspace:*",
|
|
81
|
+
"@orval/zod": "workspace:*",
|
|
75
82
|
"@scalar/json-magic": "^0.11.5",
|
|
76
83
|
"@scalar/openapi-parser": "^0.24.13",
|
|
77
|
-
"@scalar/openapi-types": "
|
|
84
|
+
"@scalar/openapi-types": "catalog:",
|
|
78
85
|
"chokidar": "^5.0.0",
|
|
79
86
|
"commander": "^14.0.2",
|
|
80
87
|
"enquirer": "^2.4.1",
|
|
@@ -93,11 +100,11 @@
|
|
|
93
100
|
"devDependencies": {
|
|
94
101
|
"@types/fs-extra": "^11.0.4",
|
|
95
102
|
"@types/js-yaml": "^4.0.9",
|
|
96
|
-
"eslint": "
|
|
97
|
-
"rimraf": "
|
|
98
|
-
"tsdown": "
|
|
99
|
-
"typescript": "
|
|
100
|
-
"vitest": "
|
|
103
|
+
"eslint": "catalog:",
|
|
104
|
+
"rimraf": "catalog:",
|
|
105
|
+
"tsdown": "catalog:",
|
|
106
|
+
"typescript": "catalog:",
|
|
107
|
+
"vitest": "catalog:"
|
|
101
108
|
},
|
|
102
109
|
"peerDependencies": {
|
|
103
110
|
"prettier": ">=3.0.0"
|
|
@@ -106,5 +113,12 @@
|
|
|
106
113
|
"prettier": {
|
|
107
114
|
"optional": true
|
|
108
115
|
}
|
|
116
|
+
},
|
|
117
|
+
"publishConfig": {
|
|
118
|
+
"exports": {
|
|
119
|
+
".": "./dist/index.mjs",
|
|
120
|
+
"./bin/orval": "./dist/bin/orval.mjs",
|
|
121
|
+
"./package.json": "./package.json"
|
|
122
|
+
}
|
|
109
123
|
}
|
|
110
|
-
}
|
|
124
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-Q13xuAhd.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 {\n asyncReduce,\n type ClientFileBuilder,\n type ClientMockBuilder,\n type ClientMockGeneratorBuilder,\n type ContextSpec,\n generateDependencyImports,\n type GeneratorClientFooter,\n type GeneratorClientHeader,\n type GeneratorClientImports,\n type GeneratorClients,\n type GeneratorClientTitle,\n type GeneratorOperations,\n type GeneratorOptions,\n type GeneratorVerbOptions,\n type GeneratorVerbsOptions,\n isFunction,\n type NormalizedOutputOptions,\n OutputClient,\n type OutputClientFunc,\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 GENERATOR_CLIENT: GeneratorClients = {\n axios: axios({ type: 'axios' })(),\n 'axios-functions': axios({ type: 'axios-functions' })(),\n angular: 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 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,\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 = (footer as (operationNames: string[]) => string)(\n operationNames,\n );\n // being here means that the previous call worked\n console.warn(\n '[WARN] 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 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 acc[verbOption.operationId] = {\n implementation: verbOption.doc + client.implementation,\n imports: 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 const route = getRoute(pathRoute);\n\n let resolvedVerbs = verbs;\n\n if (isReference(verbs)) {\n const { schema } = resolveRef<OpenApiPathItemObject>(verbs, context);\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 verbs.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 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';\n\nimport { getApiBuilder } from './api';\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 );\n\n const schemas = getApiSchemas({\n input,\n output,\n target,\n workspace,\n spec: transformedOpenApi,\n });\n\n const api = await getApiBuilder({\n input,\n output,\n context: {\n projectName,\n target,\n workspace,\n spec: transformedOpenApi,\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: transformedOpenApi.info!,\n spec: transformedOpenApi,\n };\n}\n\nasync function applyTransformer(\n openApi: OpenApiDocument,\n transformer: OverrideInput['transformer'],\n workspace: string,\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 const { valid, errors } = await validate(transformedOpenApi);\n if (!valid) {\n throw new Error(`Validation failed`, { cause: errors });\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 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): 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 const { valid, errors } = await validateSpec(dereferencedData);\n if (!valid) {\n throw new Error('Validation failed', { cause: errors });\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(input.target, input.parserOptions);\n\n return importOpenApi({\n spec,\n input,\n output,\n target: input.target,\n workspace,\n projectName,\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 as Record<string, unknown>)\n .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 as Record<string, unknown>).$ref) &&\n (\n (existingSchema as Record<string, unknown>).$ref as string\n ).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 as Record<string, unknown>;\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 as Record<string, unknown>;\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';\nimport { styleText } from 'node:util';\n\nimport { log } 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 = await collectFilePaths(paths);\n const config = await prettier.resolveConfig(filePaths[0]);\n await Promise.all(\n filePaths.map(async (filePath) => {\n const content = await fs.readFile(filePath, 'utf8');\n try {\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 (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 log(\n styleText(\n 'yellow',\n `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}Failed to format file ${filePath}: ${error.toString()}`,\n ),\n );\n }\n } else {\n log(\n styleText(\n 'yellow',\n `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}Failed to format file ${filePath}: unknown error}`,\n ),\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 log(\n styleText(\n 'yellow',\n `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}prettier not found. Install it as a project dependency or globally.`,\n ),\n );\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 log,\n logVerbose,\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 log(\n `⚠️ ${styleText('yellow', '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 log(\n `⚠️ ${styleText('yellow', `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 log(\n `⚠️ ${styleText('yellow', `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 log(\n `⚠️ ${styleText('yellow', `'${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 log(\n `⚠️ ${styleText('yellow', `'${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 { clearTimeout, setTimeout } from 'node:timers';\nimport { styleText } from 'node:util';\n\nimport {\n type ClientMockBuilder,\n type ConfigExternal,\n createLogger,\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 type Mutator,\n NamingConvention,\n type NormalizedHonoOptions,\n type NormalizedHookOptions,\n type NormalizedJsDocOptions,\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\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 | 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 require an input`));\n }\n\n if (!options.output) {\n throw new Error(styleText('red', `Config require 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, prettier, client, httpClient, mode, biome } = 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 let resolvedInputTarget;\n if (globalOptions.input) {\n resolvedInputTarget = Array.isArray(globalOptions.input)\n ? await resolveFirstValidTarget(\n globalOptions.input,\n process.cwd(),\n inputOptions.parserOptions,\n )\n : normalizePathOrUrl(globalOptions.input, process.cwd());\n } else if (Array.isArray(inputOptions.target)) {\n resolvedInputTarget = await resolveFirstValidTarget(\n inputOptions.target,\n workspace,\n inputOptions.parserOptions,\n );\n } else {\n resolvedInputTarget = normalizePathOrUrl(inputOptions.target, workspace);\n }\n\n const normalizedOptions: NormalizedOptions = {\n input: {\n target: resolvedInputTarget,\n override: {\n transformer: normalizePath(\n inputOptions.override?.transformer,\n workspace,\n ),\n },\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 prettier: outputOptions.prettier ?? prettier ?? false,\n biome: outputOptions.biome ?? biome ?? false,\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 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 dateTimeOptions: outputOptions.override?.zod?.dateTimeOptions ?? {},\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 runtimeValidation:\n outputOptions.override?.angular?.runtimeValidation ?? false,\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 ...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 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 require an input target`));\n }\n\n if (!normalizedOptions.output.target && !normalizedOptions.output.schemas) {\n throw new Error(\n styleText('red', `Config require an output target or schemas`),\n );\n }\n\n return normalizedOptions;\n}\n\nfunction normalizeMutator(\n workspace: string,\n mutator?: Mutator,\n): NormalizedMutator | undefined {\n if (isObject(mutator)) {\n if (!mutator.path) {\n throw new Error(styleText('red', `Mutator need a path`));\n }\n\n return {\n ...mutator,\n path: nodePath.resolve(workspace, mutator.path),\n default: mutator.default ?? !mutator.name,\n };\n }\n\n if (isString(mutator)) {\n return {\n path: nodePath.resolve(workspace, mutator),\n default: true,\n };\n }\n\n return mutator;\n}\n\nconst TARGET_RESOLVE_TIMEOUT_MS = 5000;\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 controller = new AbortController();\n const timer = setTimeout(() => {\n controller.abort();\n }, TARGET_RESOLVE_TIMEOUT_MS);\n\n try {\n const response = await fetch(target, {\n method: 'HEAD',\n headers,\n signal: controller.signal,\n });\n\n if (response.ok) return target;\n\n if (response.status === 405 || response.status === 501) {\n const getResponse = await fetch(target, {\n method: 'GET',\n headers,\n signal: controller.signal,\n });\n if (getResponse.ok) return target;\n }\n } finally {\n clearTimeout(timer);\n }\n } catch {\n continue;\n }\n } else {\n const resolved = nodePath.resolve(workspace, target);\n try {\n await access(resolved);\n return resolved;\n } catch {\n continue;\n }\n }\n }\n\n throw new Error(\n styleText(\n 'red',\n `None of the input targets could be resolved:\\n${targets.map((t) => ` - ${t}`).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 matched: Record<string, string> = {};\n\n for (const entry of headersConfig) {\n if (\n entry.domains.some((d) => hostname === d || hostname.endsWith(`.${d}`))\n ) {\n Object.assign(matched, entry.headers);\n }\n }\n\n return matched;\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 zod,\n ...rest\n },\n ]) => {\n return [\n key,\n {\n ...rest,\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 dateTimeOptions: zod.dateTimeOptions ?? {},\n timeOptions: zod.timeOptions ?? {},\n },\n }\n : {}),\n ...(transformer\n ? { transformer: normalizePath(transformer, workspace) }\n : {}),\n ...(mutator\n ? { mutator: normalizeMutator(workspace, mutator) }\n : {}),\n ...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 createLogger().warn(\n styleText('yellow', `Unknown the provided mode => ${mode}`),\n );\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 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 console.warn(\n '[WARN] 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.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('all', (type, file) => {\n log(`Change detected: ${type} ${file}`);\n\n watchFn().catch((error: unknown) => {\n logError(error);\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 generateZodValidationSchemaDefinition,\n isZodVersionV4,\n parseZodValidationSchemaDefinition,\n} from '@orval/zod';\nimport fs from 'fs-extra';\n\ntype ZodSchemaFileEntry = {\n schemaName: string;\n consts: string;\n zodExpression: string;\n};\n\ntype ZodSchemaFileToWrite = ZodSchemaFileEntry & {\n filePath: string;\n};\n\ntype 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\ntype WriteZodSchemasInput = {\n spec: ContextSpec['spec'];\n target: string;\n schemas: {\n name: string;\n schema?: OpenApiSchemaObject | OpenApiReferenceObject;\n }[];\n};\n\ntype 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\ntype WriteZodSchemasFromVerbsContext = {\n output: {\n override: {\n useDates?: boolean;\n zod: {\n dateTimeOptions?: Record<string, unknown>;\n timeOptions?: Record<string, unknown>;\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}>;`;\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${fileExtension}`);\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 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 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 as\n | OpenApiRequestBodyObject\n | OpenApiReferenceObject\n | undefined;\n const requestBodyContent =\n requestBody && 'content' in requestBody\n ? (requestBody as OpenApiRequestBodyObject).content\n : undefined;\n const bodySchema = requestBodyContent?.['application/json']?.schema as\n | OpenApiSchemaObject\n | undefined;\n\n const bodySchemas = bodySchema\n ? [\n {\n name: `${pascal(verbOption.operationName)}Body`,\n schema: dereference(bodySchema, zodContext),\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 { name, schema } of uniqueVerbsSchemas) {\n const fileName = conventionName(name, output.namingConvention);\n const filePath = path.join(schemasPath, `${fileName}${fileExtension}`);\n\n const zodDefinition = 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';\nimport { styleText } from 'node:util';\n\nimport {\n createSuccessMessage,\n fixCrossDirectoryImports,\n fixRegularSchemaImports,\n getFileInfo,\n getMockFileExtensionByTypeName,\n isObject,\n isString,\n jsDoc,\n log,\n type NormalizedOptions,\n type OpenApiInfoObject,\n OutputMode,\n splitSchemasByType,\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 { writeZodSchemas, writeZodSchemasFromVerbs } from './write-zod-specs';\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 fileExtension: string,\n header: string,\n): Promise<void> {\n const schemaIndexPath = path.join(schemaPath, `index${fileExtension}`);\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 fileExtension,\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 fileExtension,\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 implementationPaths = await writeMode({\n builder,\n workspace,\n output,\n projectName,\n header,\n needSchema: !output.schemas && output.client !== 'zod',\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 if (output.prettier) {\n await formatWithPrettier(paths, projectTitle);\n }\n\n if (output.biome) {\n try {\n await execa('biome', ['check', '--write', ...paths]);\n } catch (error) {\n let message = `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}biome not found`;\n if (error instanceof ExecaError && error.exitCode === 1)\n message = error.message;\n\n log(styleText('yellow', message));\n }\n }\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 if (output.prettier) {\n await formatWithPrettier([outputPath], projectTitle);\n }\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 log(styleText('yellow', 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACiCA,MAAM,iBAAiB,aAAa;AAEpC,MAAM,sBACJ,cACA,WACG;CACH,MAAM,mBAAqC;EACzC,OAAO,MAAM,EAAE,MAAM,SAAS,CAAC,EAAE;EACjC,mBAAmB,MAAM,EAAE,MAA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