orval 7.15.0 → 8.0.0-rc.1

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.
@@ -1,109 +1,62 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
-
23
- //#endregion
24
- let __orval_core = require("@orval/core");
25
- __orval_core = __toESM(__orval_core);
26
- let node_fs = require("node:fs");
27
- node_fs = __toESM(node_fs);
28
- let node_path = require("node:path");
29
- node_path = __toESM(node_path);
30
- let node_process = require("node:process");
31
- node_process = __toESM(node_process);
32
- let node_url = require("node:url");
33
- node_url = __toESM(node_url);
34
- let __apidevtools_swagger_parser = require("@apidevtools/swagger-parser");
35
- __apidevtools_swagger_parser = __toESM(__apidevtools_swagger_parser);
36
- let chalk = require("chalk");
37
- chalk = __toESM(chalk);
38
- let fs_extra = require("fs-extra");
39
- fs_extra = __toESM(fs_extra);
40
- let js_yaml = require("js-yaml");
41
- js_yaml = __toESM(js_yaml);
42
- let __orval_mock = require("@orval/mock");
43
- __orval_mock = __toESM(__orval_mock);
44
- let __orval_angular = require("@orval/angular");
45
- __orval_angular = __toESM(__orval_angular);
46
- let __orval_axios = require("@orval/axios");
47
- __orval_axios = __toESM(__orval_axios);
48
- let __orval_fetch = require("@orval/fetch");
49
- __orval_fetch = __toESM(__orval_fetch);
50
- let __orval_hono = require("@orval/hono");
51
- __orval_hono = __toESM(__orval_hono);
52
- let __orval_mcp = require("@orval/mcp");
53
- __orval_mcp = __toESM(__orval_mcp);
54
- let __orval_query = require("@orval/query");
55
- __orval_query = __toESM(__orval_query);
56
- let __orval_swr = require("@orval/swr");
57
- __orval_swr = __toESM(__orval_swr);
58
- let __orval_zod = require("@orval/zod");
59
- __orval_zod = __toESM(__orval_zod);
60
- let node_https = require("node:https");
61
- node_https = __toESM(node_https);
62
- let enquirer = require("enquirer");
63
- enquirer = __toESM(enquirer);
64
- let find_up = require("find-up");
65
- find_up = __toESM(find_up);
66
- let tsconfck = require("tsconfck");
67
- tsconfck = __toESM(tsconfck);
68
- let execa = require("execa");
69
- execa = __toESM(execa);
70
- let lodash_uniq = require("lodash.uniq");
71
- lodash_uniq = __toESM(lodash_uniq);
72
- let string_argv = require("string-argv");
73
- string_argv = __toESM(string_argv);
1
+ import { ErrorWithTag, FormDataArrayHandling, GetterPropType, NamingConvention, OutputClient, OutputHttpClient, OutputMode, PropertySortOrder, RefComponentSuffix, asyncReduce, createLogger, createSuccessMessage, dynamicImport, generateComponentDefinition, generateDependencyImports, generateParameterDefinition, generateSchemasDefinition, generateVerbsOptions, getFileInfo, getFullRoute, getMockFileExtensionByTypeName, getRoute, ibmOpenapiValidator, isBoolean, isFunction, isObject, isReference, isRootKey, isSchema, isString, isUndefined, isUrl, jsDoc, log, logError, mergeDeep, openApiConverter, pascal, removeFilesAndEmptyFolders, resolveRef, upath, writeSchemas, writeSingleMode, writeSplitMode, writeSplitTagsMode, writeTagsMode } from "@orval/core";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import process$1 from "node:process";
5
+ import { createJiti } from "jiti";
6
+ import SwaggerParser from "@apidevtools/swagger-parser";
7
+ import chalk from "chalk";
8
+ import fs$1 from "fs-extra";
9
+ import yaml from "js-yaml";
10
+ import * as mock from "@orval/mock";
11
+ import { DEFAULT_MOCK_OPTIONS, generateMockImports } from "@orval/mock";
12
+ import angular from "@orval/angular";
13
+ import axios from "@orval/axios";
14
+ import fetchClient from "@orval/fetch";
15
+ import hono from "@orval/hono";
16
+ import mcp from "@orval/mcp";
17
+ import query from "@orval/query";
18
+ import swr from "@orval/swr";
19
+ import zod from "@orval/zod";
20
+ import https from "node:https";
21
+ import enquirer from "enquirer";
22
+ import { findUp } from "find-up";
23
+ import { parse } from "tsconfck";
24
+ import { ExecaError, execa } from "execa";
25
+ import { unique } from "remeda";
26
+ import { parseArgsStringToArgv } from "string-argv";
74
27
 
75
28
  //#region src/client.ts
76
- const DEFAULT_CLIENT = __orval_core.OutputClient.AXIOS;
29
+ const DEFAULT_CLIENT = OutputClient.AXIOS;
77
30
  const getGeneratorClient = (outputClient, output) => {
78
31
  const GENERATOR_CLIENT = {
79
- axios: (0, __orval_axios.default)({ type: "axios" })(),
80
- "axios-functions": (0, __orval_axios.default)({ type: "axios-functions" })(),
81
- angular: (0, __orval_angular.default)()(),
82
- "react-query": (0, __orval_query.default)({
32
+ axios: axios({ type: "axios" })(),
33
+ "axios-functions": axios({ type: "axios-functions" })(),
34
+ angular: angular()(),
35
+ "react-query": query({
83
36
  output,
84
37
  type: "react-query"
85
38
  })(),
86
- "svelte-query": (0, __orval_query.default)({
39
+ "svelte-query": query({
87
40
  output,
88
41
  type: "svelte-query"
89
42
  })(),
90
- "vue-query": (0, __orval_query.default)({
43
+ "vue-query": query({
91
44
  output,
92
45
  type: "vue-query"
93
46
  })(),
94
- swr: (0, __orval_swr.default)()(),
95
- zod: (0, __orval_zod.default)()(),
96
- hono: (0, __orval_hono.default)()(),
97
- fetch: (0, __orval_fetch.default)()(),
98
- mcp: (0, __orval_mcp.default)()()
47
+ swr: swr()(),
48
+ zod: zod()(),
49
+ hono: hono()(),
50
+ fetch: fetchClient()(),
51
+ mcp: mcp()()
99
52
  };
100
- const generator = (0, __orval_core.isFunction)(outputClient) ? outputClient(GENERATOR_CLIENT) : GENERATOR_CLIENT[outputClient];
53
+ const generator = isFunction(outputClient) ? outputClient(GENERATOR_CLIENT) : GENERATOR_CLIENT[outputClient];
101
54
  if (!generator) throw new Error(`Oups... 🍻. Client not found: ${outputClient}`);
102
55
  return generator;
103
56
  };
104
57
  const generateClientImports = ({ client = DEFAULT_CLIENT, implementation, imports, specsName, hasSchemaDir, isAllowSyntheticDefaultImports, hasGlobalMutator, hasTagsMutator, hasParamsSerializerOptions, packageJson, output }) => {
105
- const { dependencies: dependencies$1 } = getGeneratorClient(client, output);
106
- return (0, __orval_core.generateDependencyImports)(implementation, dependencies$1 ? [...dependencies$1(hasGlobalMutator, hasParamsSerializerOptions, packageJson, output.httpClient, hasTagsMutator, output.override), ...imports] : imports, specsName, hasSchemaDir, isAllowSyntheticDefaultImports);
58
+ const { dependencies } = getGeneratorClient(client, output);
59
+ return generateDependencyImports(implementation, dependencies ? [...dependencies(hasGlobalMutator, hasParamsSerializerOptions, packageJson, output.httpClient, hasTagsMutator, output.override), ...imports] : imports, specsName, hasSchemaDir, isAllowSyntheticDefaultImports);
107
60
  };
108
61
  const generateClientHeader = ({ outputClient = DEFAULT_CLIENT, isRequestOptions, isGlobalMutator, isMutator, provideIn, hasAwaitedType, titles, output, verbOptions, tag, clientImplementation }) => {
109
62
  const { header } = getGeneratorClient(outputClient, output);
@@ -131,7 +84,7 @@ const generateClientFooter = ({ outputClient = DEFAULT_CLIENT, operationNames, h
131
84
  };
132
85
  let implementation;
133
86
  try {
134
- if ((0, __orval_core.isFunction)(outputClient)) {
87
+ if (isFunction(outputClient)) {
135
88
  implementation = footer(operationNames);
136
89
  console.warn("[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[] }.");
137
90
  } else implementation = footer({
@@ -157,18 +110,18 @@ const generateClientTitle = ({ outputClient = DEFAULT_CLIENT, title, customTitle
157
110
  const { title: generatorTitle } = getGeneratorClient(outputClient, output);
158
111
  if (!generatorTitle) return {
159
112
  implementation: "",
160
- implementationMock: `get${(0, __orval_core.pascal)(title)}Mock`
113
+ implementationMock: `get${pascal(title)}Mock`
161
114
  };
162
115
  if (customTitleFunc) {
163
116
  const customTitle = customTitleFunc(title);
164
117
  return {
165
118
  implementation: generatorTitle(customTitle),
166
- implementationMock: `get${(0, __orval_core.pascal)(customTitle)}Mock`
119
+ implementationMock: `get${pascal(customTitle)}Mock`
167
120
  };
168
121
  }
169
122
  return {
170
123
  implementation: generatorTitle(title),
171
- implementationMock: `get${(0, __orval_core.pascal)(title)}Mock`
124
+ implementationMock: `get${pascal(title)}Mock`
172
125
  };
173
126
  };
174
127
  const generateMock = (verbOption, options) => {
@@ -180,11 +133,11 @@ const generateMock = (verbOption, options) => {
180
133
  },
181
134
  imports: []
182
135
  };
183
- if ((0, __orval_core.isFunction)(options.mock)) return options.mock(verbOption, options);
184
- return __orval_mock.generateMock(verbOption, options);
136
+ if (isFunction(options.mock)) return options.mock(verbOption, options);
137
+ return mock.generateMock(verbOption, options);
185
138
  };
186
139
  const generateOperations = (outputClient = DEFAULT_CLIENT, verbsOptions, options, output) => {
187
- return (0, __orval_core.asyncReduce)(verbsOptions, async (acc, verbOption) => {
140
+ return asyncReduce(verbsOptions, async (acc, verbOption) => {
188
141
  const { client: generatorClient } = getGeneratorClient(outputClient, output);
189
142
  const client = await generatorClient(verbOption, options, outputClient);
190
143
  if (!client.implementation) return acc;
@@ -215,19 +168,19 @@ const generateExtraFiles = (outputClient = DEFAULT_CLIENT, verbsOptions, output,
215
168
  //#endregion
216
169
  //#region src/api.ts
217
170
  const getApiBuilder = async ({ input, output, context }) => {
218
- const api = await (0, __orval_core.asyncReduce)(Object.entries(context.specs[context.specKey].paths ?? {}), async (acc, [pathRoute, verbs]) => {
219
- const route = (0, __orval_core.getRoute)(pathRoute);
171
+ const api = await asyncReduce(Object.entries(context.specs[context.specKey].paths ?? {}), async (acc, [pathRoute, verbs]) => {
172
+ const route = getRoute(pathRoute);
220
173
  let resolvedVerbs = verbs;
221
174
  let resolvedContext = context;
222
- if ((0, __orval_core.isReference)(verbs)) {
223
- const { schema, imports } = (0, __orval_core.resolveRef)(verbs, context);
175
+ if (isReference(verbs)) {
176
+ const { schema, imports } = resolveRef(verbs, context);
224
177
  resolvedVerbs = schema;
225
178
  resolvedContext = {
226
179
  ...context,
227
180
  ...imports.length > 0 ? { specKey: imports[0].specKey } : {}
228
181
  };
229
182
  }
230
- let verbsOptions = await (0, __orval_core.generateVerbsOptions)({
183
+ let verbsOptions = await generateVerbsOptions({
231
184
  verbs: resolvedVerbs,
232
185
  input,
233
186
  output,
@@ -239,13 +192,13 @@ const getApiBuilder = async ({ input, output, context }) => {
239
192
  return !verb.deprecated;
240
193
  });
241
194
  const schemas = verbsOptions.reduce((acc$1, { queryParams, headers, body, response, props }) => {
242
- if (props) acc$1.push(...props.flatMap((param) => param.type === __orval_core.GetterPropType.NAMED_PATH_PARAMS ? param.schema : []));
195
+ if (props) acc$1.push(...props.flatMap((param) => param.type === GetterPropType.NAMED_PATH_PARAMS ? param.schema : []));
243
196
  if (queryParams) acc$1.push(queryParams.schema, ...queryParams.deps);
244
197
  if (headers) acc$1.push(headers.schema, ...headers.deps);
245
198
  acc$1.push(...body.schemas, ...response.schemas);
246
199
  return acc$1;
247
200
  }, []);
248
- const fullRoute = (0, __orval_core.getFullRoute)(route, verbs.servers ?? context.specs[context.specKey].servers, output.baseUrl);
201
+ const fullRoute = getFullRoute(route, verbs.servers ?? context.specs[context.specKey].servers, output.baseUrl);
249
202
  if (!output.target) throw new Error("Output does not have a target");
250
203
  const pathOperations = await generateOperations(output.client, verbsOptions, {
251
204
  route: fullRoute,
@@ -276,7 +229,7 @@ const getApiBuilder = async ({ input, output, context }) => {
276
229
  header: generateClientHeader,
277
230
  footer: generateClientFooter,
278
231
  imports: generateClientImports,
279
- importsMock: __orval_mock.generateMockImports,
232
+ importsMock: generateMockImports,
280
233
  extraFiles
281
234
  };
282
235
  };
@@ -318,11 +271,11 @@ const importOpenApi = async ({ data, input, output, target, workspace }) => {
318
271
  };
319
272
  };
320
273
  const generateInputSpecs = async ({ specs, input, workspace }) => {
321
- const transformerFn = input.override?.transformer ? await (0, __orval_core.dynamicImport)(input.override.transformer, workspace) : void 0;
322
- return (0, __orval_core.asyncReduce)(Object.entries(specs), async (acc, [specKey, value]) => {
323
- const schema = await (0, __orval_core.openApiConverter)(value, input.converterOptions, specKey);
274
+ const transformerFn = input.override?.transformer ? await dynamicImport(input.override.transformer, workspace) : void 0;
275
+ return asyncReduce(Object.entries(specs), async (acc, [specKey, value]) => {
276
+ const schema = await openApiConverter(value, input.converterOptions, specKey);
324
277
  const transfomedSchema = transformerFn ? transformerFn(schema) : schema;
325
- if (input.validation) await (0, __orval_core.ibmOpenapiValidator)(transfomedSchema, input.validation);
278
+ if (input.validation) await ibmOpenapiValidator(transfomedSchema, input.validation);
326
279
  acc[specKey] = transfomedSchema;
327
280
  return acc;
328
281
  }, {});
@@ -336,11 +289,10 @@ const getApiSchemas = ({ input, output, target, workspace, specs }) => {
336
289
  specs,
337
290
  output
338
291
  };
339
- const parsedSchemas = spec.openapi ? spec.components?.schemas : getAllSchemas(spec, specKey);
340
- const schemaDefinition = (0, __orval_core.generateSchemasDefinition)(parsedSchemas, context, output.override.components.schemas.suffix, input.filters);
341
- const responseDefinition = (0, __orval_core.generateComponentDefinition)(spec.components?.responses, context, output.override.components.responses.suffix);
342
- const bodyDefinition = (0, __orval_core.generateComponentDefinition)(spec.components?.requestBodies, context, output.override.components.requestBodies.suffix);
343
- const parameters = (0, __orval_core.generateParameterDefinition)(spec.components?.parameters, context, output.override.components.parameters.suffix);
292
+ const schemaDefinition = generateSchemasDefinition(spec.openapi ? spec.components?.schemas : getAllSchemas(spec, specKey), context, output.override.components.schemas.suffix, input.filters);
293
+ const responseDefinition = generateComponentDefinition(spec.components?.responses, context, output.override.components.responses.suffix);
294
+ const bodyDefinition = generateComponentDefinition(spec.components?.requestBodies, context, output.override.components.requestBodies.suffix);
295
+ const parameters = generateParameterDefinition(spec.components?.parameters, context, output.override.components.parameters.suffix);
344
296
  const schemas = [
345
297
  ...schemaDefinition,
346
298
  ...responseDefinition,
@@ -364,8 +316,8 @@ const getAllSchemas = (spec, specKey) => {
364
316
  "externalDocs"
365
317
  ]);
366
318
  const cleanedSpec = Object.fromEntries(Object.entries(spec).filter(([key]) => !keysToOmit.has(key)));
367
- if (specKey && (0, __orval_core.isSchema)(cleanedSpec)) {
368
- const name$1 = __orval_core.upath.getSchemaFileName(specKey);
319
+ if (specKey && isSchema(cleanedSpec)) {
320
+ const name$1 = upath.getSchemaFileName(specKey);
369
321
  const additionalKeysToOmit = new Set([
370
322
  "type",
371
323
  "properties",
@@ -381,8 +333,8 @@ const getAllSchemas = (spec, specKey) => {
381
333
  }
382
334
  return {
383
335
  ...Object.entries(cleanedSpec).reduce((acc, [key, value]) => {
384
- if (!(0, __orval_core.isObject)(value)) return acc;
385
- if (!(0, __orval_core.isSchema)(value) && !(0, __orval_core.isReference)(value)) return {
336
+ if (!isObject(value)) return acc;
337
+ if (!isSchema(value) && !isReference(value)) return {
386
338
  ...acc,
387
339
  ...getAllSchemas(value)
388
340
  };
@@ -398,32 +350,31 @@ const getAllSchemas = (spec, specKey) => {
398
350
  const resolveSpecs = async (path$1, { validate,...options }, _isUrl, isOnlySchema) => {
399
351
  try {
400
352
  if (validate) try {
401
- await __apidevtools_swagger_parser.default.validate(path$1, options);
353
+ await SwaggerParser.validate(path$1, options);
402
354
  } catch (error) {
403
355
  if (error instanceof Error && error.name === "ParserError") throw error;
404
- if (!isOnlySchema) (0, __orval_core.log)(`⚠️ ${chalk.default.yellow(error)}`);
356
+ if (!isOnlySchema) log(`⚠️ ${chalk.yellow(error)}`);
405
357
  }
406
- const data = (await __apidevtools_swagger_parser.default.resolve(path$1, options)).values();
358
+ const data = (await SwaggerParser.resolve(path$1, options)).values();
407
359
  if (_isUrl) return data;
408
- return Object.fromEntries(Object.entries(data).sort().map(([key, value]) => [(0, __orval_core.isUrl)(key) ? key : __orval_core.upath.resolve(key), value]));
360
+ return Object.fromEntries(Object.entries(data).sort().map(([key, value]) => [isUrl(key) ? key : upath.resolve(key), value]));
409
361
  } catch {
410
- const file = await fs_extra.default.readFile(path$1, "utf8");
411
- return { [path$1]: js_yaml.default.load(file) };
362
+ const file = await fs$1.readFile(path$1, "utf8");
363
+ return { [path$1]: yaml.load(file) };
412
364
  }
413
365
  };
414
366
  const importSpecs = async (workspace, options) => {
415
367
  const { input, output } = options;
416
- if (!(0, __orval_core.isString)(input.target)) return importOpenApi({
368
+ if (!isString(input.target)) return importOpenApi({
417
369
  data: { [workspace]: input.target },
418
370
  input,
419
371
  output,
420
372
  target: workspace,
421
373
  workspace
422
374
  });
423
- const isPathUrl = (0, __orval_core.isUrl)(input.target);
424
- const data = await resolveSpecs(input.target, input.parserOptions, isPathUrl, !output.target);
375
+ const isPathUrl = isUrl(input.target);
425
376
  return importOpenApi({
426
- data,
377
+ data: await resolveSpecs(input.target, input.parserOptions, isPathUrl, !output.target),
427
378
  input,
428
379
  output,
429
380
  target: input.target,
@@ -435,120 +386,13 @@ const importSpecs = async (workspace, options) => {
435
386
  //#region package.json
436
387
  var name = "orval";
437
388
  var description = "A swagger client generator for typescript";
438
- var version = "7.15.0";
439
- var license = "MIT";
440
- var files = ["dist", "!dist/**/*.d.ts.map"];
441
- var bin = "./dist/bin/orval.js";
442
- var type = "commonjs";
443
- var exports$1 = { ".": {
444
- "types": "./dist/index.d.ts",
445
- "default": "./dist/index.js"
446
- } };
447
- var engines = { "node": ">=22.18.0" };
448
- var keywords = [
449
- "rest",
450
- "client",
451
- "swagger",
452
- "open-api",
453
- "fetch",
454
- "data fetching",
455
- "code-generation",
456
- "angular",
457
- "react",
458
- "react-query",
459
- "svelte",
460
- "svelte-query",
461
- "vue",
462
- "vue-query",
463
- "msw",
464
- "mock",
465
- "axios",
466
- "vue-query",
467
- "vue",
468
- "swr",
469
- "zod",
470
- "hono"
471
- ];
472
- var author = {
473
- "name": "Victor Bury",
474
- "email": "victor@anymaniax.com"
475
- };
476
- var repository = {
477
- "type": "git",
478
- "url": "git+https://github.com/orval-labs/orval.git"
479
- };
480
- var scripts = {
481
- "build": "tsdown --config-loader unconfig",
482
- "dev": "tsdown --config-loader unconfig --watch src --onSuccess 'yarn generate-api'",
483
- "lint": "eslint .",
484
- "generate-api": "orval --config ../../samples/react-query/basic/orval.config.ts",
485
- "test": "tsc --noEmit && vitest",
486
- "clean": "rimraf .turbo dist",
487
- "nuke": "rimraf .turbo dist node_modules"
488
- };
489
- var devDependencies = {
490
- "@types/fs-extra": "^11.0.4",
491
- "@types/js-yaml": "^4.0.9",
492
- "@types/lodash.uniq": "^4.5.9",
493
- "eslint": "^9.38.0",
494
- "openapi-types": "^12.1.3",
495
- "rimraf": "^6.0.1",
496
- "tsdown": "^0.15.8",
497
- "typescript": "^5.9.3",
498
- "vitest": "^3.2.4"
499
- };
500
- var dependencies = {
501
- "@apidevtools/swagger-parser": "^12.1.0",
502
- "@commander-js/extra-typings": "^14.0.0",
503
- "@orval/angular": "workspace:*",
504
- "@orval/axios": "workspace:*",
505
- "@orval/core": "workspace:*",
506
- "@orval/fetch": "workspace:*",
507
- "@orval/hono": "workspace:*",
508
- "@orval/mcp": "workspace:*",
509
- "@orval/mock": "workspace:*",
510
- "@orval/query": "workspace:*",
511
- "@orval/swr": "workspace:*",
512
- "@orval/zod": "workspace:*",
513
- "chalk": "^4.1.2",
514
- "chokidar": "^4.0.3",
515
- "commander": "^14.0.1",
516
- "enquirer": "^2.4.1",
517
- "execa": "^5.1.1",
518
- "find-up": "5.0.0",
519
- "fs-extra": "^11.3.2",
520
- "js-yaml": "4.1.0",
521
- "lodash.uniq": "^4.5.0",
522
- "openapi3-ts": "4.5.0",
523
- "string-argv": "^0.3.2",
524
- "tsconfck": "^2.1.2",
525
- "typedoc": "^0.28.14",
526
- "typedoc-plugin-coverage": "^4.0.2",
527
- "typedoc-plugin-markdown": "^4.9.0"
528
- };
529
- var package_default = {
530
- name,
531
- description,
532
- version,
533
- license,
534
- files,
535
- bin,
536
- type,
537
- exports: exports$1,
538
- engines,
539
- keywords,
540
- author,
541
- repository,
542
- scripts,
543
- devDependencies,
544
- dependencies
545
- };
389
+ var version = "8.0.0-rc.1";
546
390
 
547
391
  //#endregion
548
392
  //#region src/utils/request.ts
549
393
  const request = (urlOptions, data) => {
550
394
  return new Promise((resolve, reject) => {
551
- const req = node_https.default.request(urlOptions, (res) => {
395
+ const req = https.request(urlOptions, (res) => {
552
396
  let body = "";
553
397
  res.on("data", (chunk) => body += chunk.toString());
554
398
  res.on("error", reject);
@@ -595,9 +439,9 @@ const getGithubSpecReq = ({ accessToken, repo, owner, branch, path: path$1 }) =>
595
439
  let githubToken = null;
596
440
  const getGithubAcessToken = async (githubTokenPath) => {
597
441
  if (githubToken) return githubToken;
598
- if (await fs_extra.default.pathExists(githubTokenPath)) return fs_extra.default.readFile(githubTokenPath, "utf8");
442
+ if (await fs$1.pathExists(githubTokenPath)) return fs$1.readFile(githubTokenPath, "utf8");
599
443
  else {
600
- const answers = await (0, enquirer.prompt)([{
444
+ const answers = await enquirer.prompt([{
601
445
  type: "input",
602
446
  name: "githubToken",
603
447
  message: "Please provide a GitHub token with `repo` rules checked (https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/)"
@@ -607,14 +451,14 @@ const getGithubAcessToken = async (githubTokenPath) => {
607
451
  message: "Would you like to store your token for the next time? (stored in your node_modules)"
608
452
  }]);
609
453
  githubToken = answers.githubToken;
610
- if (answers.saveToken) await fs_extra.default.outputFile(githubTokenPath, answers.githubToken);
454
+ if (answers.saveToken) await fs$1.outputFile(githubTokenPath, answers.githubToken);
611
455
  return answers.githubToken;
612
456
  }
613
457
  };
614
- const getGithubOpenApi = async (url$1) => {
615
- const githubTokenPath = __orval_core.upath.join(__dirname, ".githubToken");
458
+ const getGithubOpenApi = async (url) => {
459
+ const githubTokenPath = upath.join(import.meta.dirname, ".githubToken");
616
460
  const accessToken = await getGithubAcessToken(githubTokenPath);
617
- const [info] = url$1.split("github.com/").slice(-1);
461
+ const [info] = url.split("github.com/").slice(-1);
618
462
  const [owner, repo, , branch, ...paths] = info.split("/");
619
463
  const path$1 = paths.join("/");
620
464
  try {
@@ -627,22 +471,22 @@ const getGithubOpenApi = async (url$1) => {
627
471
  }));
628
472
  if (body.errors?.length) {
629
473
  if (body.errors?.some((error) => error?.type === "NOT_FOUND")) {
630
- if ((await (0, enquirer.prompt)([{
474
+ if ((await enquirer.prompt([{
631
475
  type: "confirm",
632
476
  name: "removeToken",
633
477
  message: "Your token doesn't have the correct permissions, should we remove it?"
634
- }])).removeToken) await fs_extra.default.unlink(githubTokenPath);
478
+ }])).removeToken) await fs$1.unlink(githubTokenPath);
635
479
  }
636
480
  }
637
481
  return body.data?.repository?.object.text;
638
482
  } catch (error) {
639
483
  if (!error.body) throw new Error(`Oups... 🍻. ${error}`);
640
484
  if (error.body.message === "Bad credentials") {
641
- if ((await (0, enquirer.prompt)([{
485
+ if ((await enquirer.prompt([{
642
486
  type: "confirm",
643
487
  name: "removeToken",
644
488
  message: "Your token doesn't have the correct permissions, should we remove it?"
645
- }])).removeToken) await fs_extra.default.unlink(githubTokenPath);
489
+ }])).removeToken) await fs$1.unlink(githubTokenPath);
646
490
  }
647
491
  throw new Error(error.body.message || `Oups... 🍻. ${error}`);
648
492
  }
@@ -657,21 +501,25 @@ const githubResolver = {
657
501
  }
658
502
  };
659
503
 
504
+ //#endregion
505
+ //#region src/utils/http-resolver.ts
506
+ const httpResolver = { safeUrlResolver: false };
507
+
660
508
  //#endregion
661
509
  //#region src/utils/package-json.ts
662
510
  const loadPackageJson = async (packageJson, workspace = process.cwd()) => {
663
511
  if (!packageJson) {
664
- const pkgPath = await (0, find_up.default)(["package.json"], { cwd: workspace });
512
+ const pkgPath = await findUp(["package.json"], { cwd: workspace });
665
513
  if (pkgPath) {
666
- const pkg = await (0, __orval_core.dynamicImport)(pkgPath, workspace);
514
+ const pkg = await dynamicImport(pkgPath, workspace);
667
515
  if (isPackageJson(pkg)) return await maybeReplaceCatalog(pkg, workspace);
668
516
  else throw new Error("Invalid package.json file");
669
517
  }
670
518
  return;
671
519
  }
672
520
  const normalizedPath = normalizePath(packageJson, workspace);
673
- if (fs_extra.default.existsSync(normalizedPath)) {
674
- const pkg = await (0, __orval_core.dynamicImport)(normalizedPath);
521
+ if (fs$1.existsSync(normalizedPath)) {
522
+ const pkg = await dynamicImport(normalizedPath);
675
523
  if (isPackageJson(pkg)) return await maybeReplaceCatalog(pkg, workspace);
676
524
  else throw new Error(`Invalid package.json file: ${normalizedPath}`);
677
525
  }
@@ -682,71 +530,67 @@ const maybeReplaceCatalog = async (pkg, workspace) => {
682
530
  ...Object.entries(pkg.dependencies ?? {}),
683
531
  ...Object.entries(pkg.devDependencies ?? {}),
684
532
  ...Object.entries(pkg.peerDependencies ?? {})
685
- ].some(([, value]) => (0, __orval_core.isString)(value) && value.startsWith("catalog:"))) return pkg;
686
- const filePath = await (0, find_up.default)("pnpm-workspace.yaml", { cwd: workspace });
533
+ ].some(([, value]) => isString(value) && value.startsWith("catalog:"))) return pkg;
534
+ const filePath = await findUp("pnpm-workspace.yaml", { cwd: workspace });
687
535
  if (!filePath) {
688
- (0, __orval_core.log)(`⚠️ ${chalk.default.yellow("package.json contains pnpm catalog: in dependencies, but no pnpm-workspace.yaml was found.")}`);
536
+ log(`⚠️ ${chalk.yellow("package.json contains pnpm catalog: in dependencies, but no pnpm-workspace.yaml was found.")}`);
689
537
  return pkg;
690
538
  }
691
- const file = await fs_extra.default.readFile(filePath, "utf8");
692
- const pnpmWorkspaceFile = js_yaml.default.load(file);
539
+ const file = await fs$1.readFile(filePath, "utf8");
540
+ const pnpmWorkspaceFile = yaml.load(file);
693
541
  performSubstitution(pkg.dependencies, pnpmWorkspaceFile);
694
542
  performSubstitution(pkg.devDependencies, pnpmWorkspaceFile);
695
543
  performSubstitution(pkg.peerDependencies, pnpmWorkspaceFile);
696
544
  return pkg;
697
545
  };
698
- const performSubstitution = (dependencies$1, pnpmWorkspaceFile) => {
699
- if (!dependencies$1) return;
700
- for (const [packageName, version$1] of Object.entries(dependencies$1)) if (version$1 === "catalog:" || version$1 === "catalog:default") {
546
+ const performSubstitution = (dependencies, pnpmWorkspaceFile) => {
547
+ if (!dependencies) return;
548
+ for (const [packageName, version$1] of Object.entries(dependencies)) if (version$1 === "catalog:" || version$1 === "catalog:default") {
701
549
  if (!pnpmWorkspaceFile.catalog) {
702
- (0, __orval_core.log)(`⚠️ ${chalk.default.yellow(`when reading from pnpm-workspace.yaml, catalog: substitution for the package '${packageName}' failed as there were no default catalog.`)}`);
550
+ log(`⚠️ ${chalk.yellow(`when reading from pnpm-workspace.yaml, catalog: substitution for the package '${packageName}' failed as there were no default catalog.`)}`);
703
551
  continue;
704
552
  }
705
553
  const sub = pnpmWorkspaceFile.catalog[packageName];
706
554
  if (!sub) {
707
- (0, __orval_core.log)(`⚠️ ${chalk.default.yellow(`when reading from pnpm-workspace.yaml, catalog: substitution for the package '${packageName}' failed as there were no matching package in the default catalog.`)}`);
555
+ log(`⚠️ ${chalk.yellow(`when reading from pnpm-workspace.yaml, catalog: substitution for the package '${packageName}' failed as there were no matching package in the default catalog.`)}`);
708
556
  continue;
709
557
  }
710
- dependencies$1[packageName] = sub;
558
+ dependencies[packageName] = sub;
711
559
  } else if (version$1.startsWith("catalog:")) {
712
560
  const catalogName = version$1.slice(8);
713
561
  const catalog = pnpmWorkspaceFile.catalogs?.[catalogName];
714
562
  if (!catalog) {
715
- (0, __orval_core.log)(`⚠️ ${chalk.default.yellow(`when reading from pnpm-workspace.yaml, '${version$1}' substitution for the package '${packageName}' failed as there were no matching catalog named '${catalogName}'. (available named catalogs are: ${Object.keys(pnpmWorkspaceFile.catalogs ?? {}).join(", ")})`)}`);
563
+ log(`⚠️ ${chalk.yellow(`when reading from pnpm-workspace.yaml, '${version$1}' substitution for the package '${packageName}' failed as there were no matching catalog named '${catalogName}'. (available named catalogs are: ${Object.keys(pnpmWorkspaceFile.catalogs ?? {}).join(", ")})`)}`);
716
564
  continue;
717
565
  }
718
566
  const sub = catalog[packageName];
719
567
  if (!sub) {
720
- (0, __orval_core.log)(`⚠️ ${chalk.default.yellow(`when reading from pnpm-workspace.yaml, '${version$1}' substitution for the package '${packageName}' failed as there were no package in the catalog named '${catalogName}'. (packages in the catalog are: ${Object.keys(catalog).join(", ")})`)}`);
568
+ log(`⚠️ ${chalk.yellow(`when reading from pnpm-workspace.yaml, '${version$1}' substitution for the package '${packageName}' failed as there were no package in the catalog named '${catalogName}'. (packages in the catalog are: ${Object.keys(catalog).join(", ")})`)}`);
721
569
  continue;
722
570
  }
723
- dependencies$1[packageName] = sub;
571
+ dependencies[packageName] = sub;
724
572
  }
725
573
  };
726
574
 
727
575
  //#endregion
728
576
  //#region src/utils/tsconfig.ts
729
577
  const loadTsconfig = async (tsconfig, workspace = process.cwd()) => {
730
- if ((0, __orval_core.isUndefined)(tsconfig)) {
731
- const configPath = await (0, find_up.default)(["tsconfig.json", "jsconfig.json"], { cwd: workspace });
732
- if (configPath) return (await (0, tsconfck.parse)(configPath)).tsconfig;
578
+ if (isUndefined(tsconfig)) {
579
+ const configPath = await findUp(["tsconfig.json", "jsconfig.json"], { cwd: workspace });
580
+ if (configPath) return (await parse(configPath)).tsconfig;
733
581
  return;
734
582
  }
735
- if ((0, __orval_core.isString)(tsconfig)) {
583
+ if (isString(tsconfig)) {
736
584
  const normalizedPath = normalizePath(tsconfig, workspace);
737
- if (fs_extra.default.existsSync(normalizedPath)) {
738
- const config = await (0, tsconfck.parse)(normalizedPath);
585
+ if (fs$1.existsSync(normalizedPath)) {
586
+ const config = await parse(normalizedPath);
739
587
  return config.referenced?.find(({ tsconfigFile }) => tsconfigFile === normalizedPath)?.tsconfig || config.tsconfig;
740
588
  }
741
589
  return;
742
590
  }
743
- if ((0, __orval_core.isObject)(tsconfig)) return tsconfig;
591
+ if (isObject(tsconfig)) return tsconfig;
744
592
  };
745
593
 
746
- //#endregion
747
- //#region src/utils/http-resolver.ts
748
- const httpResolver = { safeUrlResolver: false };
749
-
750
594
  //#endregion
751
595
  //#region src/utils/options.ts
752
596
  /**
@@ -757,16 +601,16 @@ function defineConfig(options) {
757
601
  return options;
758
602
  }
759
603
  const createFormData = (workspace, formData) => {
760
- const defaultArrayHandling = __orval_core.FormDataArrayHandling.SERIALIZE;
604
+ const defaultArrayHandling = FormDataArrayHandling.SERIALIZE;
761
605
  if (formData === void 0) return {
762
606
  disabled: false,
763
607
  arrayHandling: defaultArrayHandling
764
608
  };
765
- if ((0, __orval_core.isBoolean)(formData)) return {
609
+ if (isBoolean(formData)) return {
766
610
  disabled: !formData,
767
611
  arrayHandling: defaultArrayHandling
768
612
  };
769
- if ((0, __orval_core.isString)(formData)) return {
613
+ if (isString(formData)) return {
770
614
  disabled: false,
771
615
  mutator: normalizeMutator(workspace, formData),
772
616
  arrayHandling: defaultArrayHandling
@@ -783,24 +627,24 @@ const createFormData = (workspace, formData) => {
783
627
  };
784
628
  };
785
629
  const normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOptions = {}) => {
786
- const options = await ((0, __orval_core.isFunction)(optionsExport) ? optionsExport() : optionsExport);
787
- if (!options.input) throw new Error(chalk.default.red(`Config require an input`));
788
- if (!options.output) throw new Error(chalk.default.red(`Config require an output`));
789
- const inputOptions = (0, __orval_core.isString)(options.input) ? { target: options.input } : options.input;
790
- const outputOptions = (0, __orval_core.isString)(options.output) ? { target: options.output } : options.output;
630
+ const options = await (isFunction(optionsExport) ? optionsExport() : optionsExport);
631
+ if (!options.input) throw new Error(chalk.red(`Config require an input`));
632
+ if (!options.output) throw new Error(chalk.red(`Config require an output`));
633
+ const inputOptions = isString(options.input) ? { target: options.input } : options.input;
634
+ const outputOptions = isString(options.output) ? { target: options.output } : options.output;
791
635
  const outputWorkspace = normalizePath(outputOptions.workspace || "", workspace);
792
636
  const { clean, prettier, client, httpClient, mode, biome } = globalOptions;
793
637
  const tsconfig = await loadTsconfig(outputOptions.tsconfig || globalOptions.tsconfig, workspace);
794
638
  const packageJson = await loadPackageJson(outputOptions.packageJson || globalOptions.packageJson, workspace);
795
639
  const mockOption = outputOptions.mock ?? globalOptions.mock;
796
- let mock;
797
- if (typeof mockOption === "boolean" && mockOption) mock = __orval_mock.DEFAULT_MOCK_OPTIONS;
798
- else if ((0, __orval_core.isFunction)(mockOption)) mock = mockOption;
799
- else if (mockOption) mock = {
800
- ...__orval_mock.DEFAULT_MOCK_OPTIONS,
640
+ let mock$1;
641
+ if (typeof mockOption === "boolean" && mockOption) mock$1 = DEFAULT_MOCK_OPTIONS;
642
+ else if (isFunction(mockOption)) mock$1 = mockOption;
643
+ else if (mockOption) mock$1 = {
644
+ ...DEFAULT_MOCK_OPTIONS,
801
645
  ...mockOption
802
646
  };
803
- else mock = void 0;
647
+ else mock$1 = void 0;
804
648
  const defaultFileExtension = ".ts";
805
649
  const globalQueryOptions = {
806
650
  useQuery: true,
@@ -818,19 +662,19 @@ const normalizeOptions = async (optionsExport, workspace = process.cwd(), global
818
662
  validation: inputOptions.validation || false,
819
663
  override: { transformer: normalizePath(inputOptions.override?.transformer, workspace) },
820
664
  converterOptions: inputOptions.converterOptions ?? {},
821
- parserOptions: (0, __orval_core.mergeDeep)(parserDefaultOptions, inputOptions.parserOptions ?? {}),
665
+ parserOptions: mergeDeep(parserDefaultOptions, inputOptions.parserOptions ?? {}),
822
666
  filters: inputOptions.filters
823
667
  },
824
668
  output: {
825
669
  target: globalOptions.output ? normalizePath(globalOptions.output, process.cwd()) : normalizePath(outputOptions.target, outputWorkspace),
826
670
  schemas: normalizePath(outputOptions.schemas, outputWorkspace),
827
- namingConvention: outputOptions.namingConvention || __orval_core.NamingConvention.CAMEL_CASE,
671
+ namingConvention: outputOptions.namingConvention || NamingConvention.CAMEL_CASE,
828
672
  fileExtension: outputOptions.fileExtension || defaultFileExtension,
829
673
  workspace: outputOptions.workspace ? outputWorkspace : void 0,
830
- client: outputOptions.client ?? client ?? __orval_core.OutputClient.AXIOS_FUNCTIONS,
831
- httpClient: outputOptions.httpClient ?? httpClient ?? __orval_core.OutputHttpClient.AXIOS,
674
+ client: outputOptions.client ?? client ?? OutputClient.AXIOS_FUNCTIONS,
675
+ httpClient: outputOptions.httpClient ?? httpClient ?? OutputHttpClient.FETCH,
832
676
  mode: normalizeOutputMode(outputOptions.mode ?? mode),
833
- mock,
677
+ mock: mock$1,
834
678
  clean: outputOptions.clean ?? clean ?? false,
835
679
  docs: outputOptions.docs ?? false,
836
680
  prettier: outputOptions.prettier ?? prettier ?? false,
@@ -855,27 +699,27 @@ const normalizeOptions = async (optionsExport, workspace = process.cwd(), global
855
699
  tags: normalizeOperationsAndTags(outputOptions.override?.tags ?? {}, outputWorkspace, { query: globalQueryOptions }),
856
700
  mutator: normalizeMutator(outputWorkspace, outputOptions.override?.mutator),
857
701
  formData: createFormData(outputWorkspace, outputOptions.override?.formData),
858
- formUrlEncoded: ((0, __orval_core.isBoolean)(outputOptions.override?.formUrlEncoded) ? outputOptions.override?.formUrlEncoded : normalizeMutator(outputWorkspace, outputOptions.override?.formUrlEncoded)) ?? true,
702
+ formUrlEncoded: (isBoolean(outputOptions.override?.formUrlEncoded) ? outputOptions.override?.formUrlEncoded : normalizeMutator(outputWorkspace, outputOptions.override?.formUrlEncoded)) ?? true,
859
703
  paramsSerializer: normalizeMutator(outputWorkspace, outputOptions.override?.paramsSerializer),
860
- header: outputOptions.override?.header === false ? false : (0, __orval_core.isFunction)(outputOptions.override?.header) ? outputOptions.override?.header : getDefaultFilesHeader,
704
+ header: outputOptions.override?.header === false ? false : isFunction(outputOptions.override?.header) ? outputOptions.override?.header : getDefaultFilesHeader,
861
705
  requestOptions: outputOptions.override?.requestOptions ?? true,
862
706
  namingConvention: outputOptions.override?.namingConvention ?? {},
863
707
  components: {
864
708
  schemas: {
865
- suffix: __orval_core.RefComponentSuffix.schemas,
709
+ suffix: RefComponentSuffix.schemas,
866
710
  itemSuffix: outputOptions.override?.components?.schemas?.itemSuffix ?? "Item",
867
711
  ...outputOptions.override?.components?.schemas
868
712
  },
869
713
  responses: {
870
- suffix: __orval_core.RefComponentSuffix.responses,
714
+ suffix: RefComponentSuffix.responses,
871
715
  ...outputOptions.override?.components?.responses
872
716
  },
873
717
  parameters: {
874
- suffix: __orval_core.RefComponentSuffix.parameters,
718
+ suffix: RefComponentSuffix.parameters,
875
719
  ...outputOptions.override?.components?.parameters
876
720
  },
877
721
  requestBodies: {
878
- suffix: __orval_core.RefComponentSuffix.requestBodies,
722
+ suffix: RefComponentSuffix.requestBodies,
879
723
  ...outputOptions.override?.components?.requestBodies
880
724
  }
881
725
  },
@@ -920,23 +764,22 @@ const normalizeOptions = async (optionsExport, workspace = process.cwd(), global
920
764
  fetch: {
921
765
  includeHttpResponseReturnType: outputOptions.override?.fetch?.includeHttpResponseReturnType ?? true,
922
766
  forceSuccessResponse: outputOptions.override?.fetch?.forceSuccessResponse ?? false,
923
- explode: outputOptions.override?.fetch?.explode ?? true,
924
767
  ...outputOptions.override?.fetch
925
768
  },
926
769
  useDates: outputOptions.override?.useDates || false,
927
770
  useDeprecatedOperations: outputOptions.override?.useDeprecatedOperations ?? true,
928
- enumGenerationType: outputOptions.override?.useNativeEnums ?? false ? "enum" : outputOptions.override?.enumGenerationType ?? "const",
771
+ enumGenerationType: outputOptions.override?.enumGenerationType ?? "const",
929
772
  suppressReadonlyModifier: outputOptions.override?.suppressReadonlyModifier || false
930
773
  },
931
774
  allParamsOptional: outputOptions.allParamsOptional ?? false,
932
775
  urlEncodeParameters: outputOptions.urlEncodeParameters ?? false,
933
776
  optionsParamRequired: outputOptions.optionsParamRequired ?? false,
934
- propertySortOrder: outputOptions.propertySortOrder ?? __orval_core.PropertySortOrder.SPECIFICATION
777
+ propertySortOrder: outputOptions.propertySortOrder ?? PropertySortOrder.SPECIFICATION
935
778
  },
936
779
  hooks: options.hooks ? normalizeHooks(options.hooks) : {}
937
780
  };
938
- if (!normalizedOptions.input.target) throw new Error(chalk.default.red(`Config require an input target`));
939
- if (!normalizedOptions.output.target && !normalizedOptions.output.schemas) throw new Error(chalk.default.red(`Config require an output target or schemas`));
781
+ if (!normalizedOptions.input.target) throw new Error(chalk.red(`Config require an input target`));
782
+ if (!normalizedOptions.output.target && !normalizedOptions.output.schemas) throw new Error(chalk.red(`Config require an output target or schemas`));
940
783
  return normalizedOptions;
941
784
  };
942
785
  const parserDefaultOptions = {
@@ -947,27 +790,27 @@ const parserDefaultOptions = {
947
790
  }
948
791
  };
949
792
  const normalizeMutator = (workspace, mutator) => {
950
- if ((0, __orval_core.isObject)(mutator)) {
951
- if (!mutator.path) throw new Error(chalk.default.red(`Mutator need a path`));
793
+ if (isObject(mutator)) {
794
+ if (!mutator.path) throw new Error(chalk.red(`Mutator need a path`));
952
795
  return {
953
796
  ...mutator,
954
- path: __orval_core.upath.resolve(workspace, mutator.path),
797
+ path: upath.resolve(workspace, mutator.path),
955
798
  default: (mutator.default || !mutator.name) ?? false
956
799
  };
957
800
  }
958
- if ((0, __orval_core.isString)(mutator)) return {
959
- path: __orval_core.upath.resolve(workspace, mutator),
801
+ if (isString(mutator)) return {
802
+ path: upath.resolve(workspace, mutator),
960
803
  default: true
961
804
  };
962
805
  return mutator;
963
806
  };
964
807
  const normalizePathOrUrl = (path$1, workspace) => {
965
- if ((0, __orval_core.isString)(path$1) && !(0, __orval_core.isUrl)(path$1)) return normalizePath(path$1, workspace);
808
+ if (isString(path$1) && !isUrl(path$1)) return normalizePath(path$1, workspace);
966
809
  return path$1;
967
810
  };
968
811
  const normalizePath = (path$1, workspace) => {
969
- if (!(0, __orval_core.isString)(path$1)) return path$1;
970
- return __orval_core.upath.resolve(workspace, path$1);
812
+ if (!isString(path$1)) return path$1;
813
+ return upath.resolve(workspace, path$1);
971
814
  };
972
815
  const normalizeOperationsAndTags = (operationsOrTags, workspace, global) => {
973
816
  return Object.fromEntries(Object.entries(operationsOrTags).map(([key, { transformer, mutator, formData, formUrlEncoded, paramsSerializer, query: query$1, zod: zod$1,...rest }]) => {
@@ -1010,22 +853,22 @@ const normalizeOperationsAndTags = (operationsOrTags, workspace, global) => {
1010
853
  ...transformer ? { transformer: normalizePath(transformer, workspace) } : {},
1011
854
  ...mutator ? { mutator: normalizeMutator(workspace, mutator) } : {},
1012
855
  ...createFormData(workspace, formData),
1013
- ...formUrlEncoded ? { formUrlEncoded: (0, __orval_core.isBoolean)(formUrlEncoded) ? formUrlEncoded : normalizeMutator(workspace, formUrlEncoded) } : {},
856
+ ...formUrlEncoded ? { formUrlEncoded: isBoolean(formUrlEncoded) ? formUrlEncoded : normalizeMutator(workspace, formUrlEncoded) } : {},
1014
857
  ...paramsSerializer ? { paramsSerializer: normalizeMutator(workspace, paramsSerializer) } : {}
1015
858
  }];
1016
859
  }));
1017
860
  };
1018
861
  const normalizeOutputMode = (mode) => {
1019
- if (!mode) return __orval_core.OutputMode.SINGLE;
1020
- if (!Object.values(__orval_core.OutputMode).includes(mode)) {
1021
- (0, __orval_core.createLogger)().warn(chalk.default.yellow(`Unknown the provided mode => ${mode}`));
1022
- return __orval_core.OutputMode.SINGLE;
862
+ if (!mode) return OutputMode.SINGLE;
863
+ if (!Object.values(OutputMode).includes(mode)) {
864
+ createLogger().warn(chalk.yellow(`Unknown the provided mode => ${mode}`));
865
+ return OutputMode.SINGLE;
1023
866
  }
1024
867
  return mode;
1025
868
  };
1026
869
  const normalizeHooks = (hooks) => {
1027
870
  return Object.keys(hooks).reduce((acc, key) => {
1028
- if ((0, __orval_core.isString)(hooks[key])) return {
871
+ if (isString(hooks[key])) return {
1029
872
  ...acc,
1030
873
  [key]: [hooks[key]]
1031
874
  };
@@ -1033,11 +876,11 @@ const normalizeHooks = (hooks) => {
1033
876
  ...acc,
1034
877
  [key]: hooks[key]
1035
878
  };
1036
- else if ((0, __orval_core.isFunction)(hooks[key])) return {
879
+ else if (isFunction(hooks[key])) return {
1037
880
  ...acc,
1038
881
  [key]: [hooks[key]]
1039
882
  };
1040
- else if ((0, __orval_core.isObject)(hooks[key])) return {
883
+ else if (isObject(hooks[key])) return {
1041
884
  ...acc,
1042
885
  [key]: [hooks[key]]
1043
886
  };
@@ -1046,10 +889,10 @@ const normalizeHooks = (hooks) => {
1046
889
  };
1047
890
  const normalizeHonoOptions = (hono$1 = {}, workspace) => {
1048
891
  return {
1049
- ...hono$1.handlers ? { handlers: __orval_core.upath.resolve(workspace, hono$1.handlers) } : {},
892
+ ...hono$1.handlers ? { handlers: upath.resolve(workspace, hono$1.handlers) } : {},
1050
893
  compositeRoute: hono$1.compositeRoute ?? "",
1051
894
  validator: hono$1.validator ?? true,
1052
- validatorOutputPath: hono$1.validatorOutputPath ? __orval_core.upath.resolve(workspace, hono$1.validatorOutputPath) : ""
895
+ validatorOutputPath: hono$1.validatorOutputPath ? upath.resolve(workspace, hono$1.validatorOutputPath) : ""
1053
896
  };
1054
897
  };
1055
898
  const normalizeJSDocOptions = (jsdoc = {}) => {
@@ -1058,13 +901,13 @@ const normalizeJSDocOptions = (jsdoc = {}) => {
1058
901
  const normalizeQueryOptions = (queryOptions = {}, outputWorkspace, globalOptions = {}) => {
1059
902
  if (queryOptions.options) console.warn("[WARN] Using query options is deprecated and will be removed in a future major release. Please use queryOptions or mutationOptions instead.");
1060
903
  return {
1061
- ...(0, __orval_core.isUndefined)(queryOptions.usePrefetch) ? {} : { usePrefetch: queryOptions.usePrefetch },
1062
- ...(0, __orval_core.isUndefined)(queryOptions.useInvalidate) ? {} : { useInvalidate: queryOptions.useInvalidate },
1063
- ...(0, __orval_core.isUndefined)(queryOptions.useQuery) ? {} : { useQuery: queryOptions.useQuery },
1064
- ...(0, __orval_core.isUndefined)(queryOptions.useSuspenseQuery) ? {} : { useSuspenseQuery: queryOptions.useSuspenseQuery },
1065
- ...(0, __orval_core.isUndefined)(queryOptions.useMutation) ? {} : { useMutation: queryOptions.useMutation },
1066
- ...(0, __orval_core.isUndefined)(queryOptions.useInfinite) ? {} : { useInfinite: queryOptions.useInfinite },
1067
- ...(0, __orval_core.isUndefined)(queryOptions.useSuspenseInfiniteQuery) ? {} : { useSuspenseInfiniteQuery: queryOptions.useSuspenseInfiniteQuery },
904
+ ...isUndefined(queryOptions.usePrefetch) ? {} : { usePrefetch: queryOptions.usePrefetch },
905
+ ...isUndefined(queryOptions.useInvalidate) ? {} : { useInvalidate: queryOptions.useInvalidate },
906
+ ...isUndefined(queryOptions.useQuery) ? {} : { useQuery: queryOptions.useQuery },
907
+ ...isUndefined(queryOptions.useSuspenseQuery) ? {} : { useSuspenseQuery: queryOptions.useSuspenseQuery },
908
+ ...isUndefined(queryOptions.useMutation) ? {} : { useMutation: queryOptions.useMutation },
909
+ ...isUndefined(queryOptions.useInfinite) ? {} : { useInfinite: queryOptions.useInfinite },
910
+ ...isUndefined(queryOptions.useSuspenseInfiniteQuery) ? {} : { useSuspenseInfiniteQuery: queryOptions.useSuspenseInfiniteQuery },
1068
911
  ...queryOptions.useInfiniteQueryParam ? { useInfiniteQueryParam: queryOptions.useInfiniteQueryParam } : {},
1069
912
  ...queryOptions.options ? { options: queryOptions.options } : {},
1070
913
  ...globalOptions.queryKey ? { queryKey: globalOptions.queryKey } : {},
@@ -1073,25 +916,25 @@ const normalizeQueryOptions = (queryOptions = {}, outputWorkspace, globalOptions
1073
916
  ...queryOptions?.queryOptions ? { queryOptions: normalizeMutator(outputWorkspace, queryOptions?.queryOptions) } : {},
1074
917
  ...globalOptions.mutationOptions ? { mutationOptions: globalOptions.mutationOptions } : {},
1075
918
  ...queryOptions?.mutationOptions ? { mutationOptions: normalizeMutator(outputWorkspace, queryOptions?.mutationOptions) } : {},
1076
- ...(0, __orval_core.isUndefined)(globalOptions.shouldExportQueryKey) ? {} : { shouldExportQueryKey: globalOptions.shouldExportQueryKey },
1077
- ...(0, __orval_core.isUndefined)(queryOptions.shouldExportQueryKey) ? {} : { shouldExportQueryKey: queryOptions.shouldExportQueryKey },
1078
- ...(0, __orval_core.isUndefined)(globalOptions.shouldExportHttpClient) ? {} : { shouldExportHttpClient: globalOptions.shouldExportHttpClient },
1079
- ...(0, __orval_core.isUndefined)(queryOptions.shouldExportHttpClient) ? {} : { shouldExportHttpClient: queryOptions.shouldExportHttpClient },
1080
- ...(0, __orval_core.isUndefined)(globalOptions.shouldExportMutatorHooks) ? {} : { shouldExportMutatorHooks: globalOptions.shouldExportMutatorHooks },
1081
- ...(0, __orval_core.isUndefined)(queryOptions.shouldExportMutatorHooks) ? {} : { shouldExportMutatorHooks: queryOptions.shouldExportMutatorHooks },
1082
- ...(0, __orval_core.isUndefined)(globalOptions.shouldSplitQueryKey) ? {} : { shouldSplitQueryKey: globalOptions.shouldSplitQueryKey },
1083
- ...(0, __orval_core.isUndefined)(queryOptions.shouldSplitQueryKey) ? {} : { shouldSplitQueryKey: queryOptions.shouldSplitQueryKey },
1084
- ...(0, __orval_core.isUndefined)(globalOptions.signal) ? {} : { signal: globalOptions.signal },
1085
- ...(0, __orval_core.isUndefined)(globalOptions.useOperationIdAsQueryKey) ? {} : { useOperationIdAsQueryKey: globalOptions.useOperationIdAsQueryKey },
1086
- ...(0, __orval_core.isUndefined)(queryOptions.useOperationIdAsQueryKey) ? {} : { useOperationIdAsQueryKey: queryOptions.useOperationIdAsQueryKey },
1087
- ...(0, __orval_core.isUndefined)(globalOptions.signal) ? {} : { signal: globalOptions.signal },
1088
- ...(0, __orval_core.isUndefined)(queryOptions.signal) ? {} : { signal: queryOptions.signal },
1089
- ...(0, __orval_core.isUndefined)(globalOptions.version) ? {} : { version: globalOptions.version },
1090
- ...(0, __orval_core.isUndefined)(queryOptions.version) ? {} : { version: queryOptions.version }
919
+ ...isUndefined(globalOptions.shouldExportQueryKey) ? {} : { shouldExportQueryKey: globalOptions.shouldExportQueryKey },
920
+ ...isUndefined(queryOptions.shouldExportQueryKey) ? {} : { shouldExportQueryKey: queryOptions.shouldExportQueryKey },
921
+ ...isUndefined(globalOptions.shouldExportHttpClient) ? {} : { shouldExportHttpClient: globalOptions.shouldExportHttpClient },
922
+ ...isUndefined(queryOptions.shouldExportHttpClient) ? {} : { shouldExportHttpClient: queryOptions.shouldExportHttpClient },
923
+ ...isUndefined(globalOptions.shouldExportMutatorHooks) ? {} : { shouldExportMutatorHooks: globalOptions.shouldExportMutatorHooks },
924
+ ...isUndefined(queryOptions.shouldExportMutatorHooks) ? {} : { shouldExportMutatorHooks: queryOptions.shouldExportMutatorHooks },
925
+ ...isUndefined(globalOptions.shouldSplitQueryKey) ? {} : { shouldSplitQueryKey: globalOptions.shouldSplitQueryKey },
926
+ ...isUndefined(queryOptions.shouldSplitQueryKey) ? {} : { shouldSplitQueryKey: queryOptions.shouldSplitQueryKey },
927
+ ...isUndefined(globalOptions.signal) ? {} : { signal: globalOptions.signal },
928
+ ...isUndefined(globalOptions.useOperationIdAsQueryKey) ? {} : { useOperationIdAsQueryKey: globalOptions.useOperationIdAsQueryKey },
929
+ ...isUndefined(queryOptions.useOperationIdAsQueryKey) ? {} : { useOperationIdAsQueryKey: queryOptions.useOperationIdAsQueryKey },
930
+ ...isUndefined(globalOptions.signal) ? {} : { signal: globalOptions.signal },
931
+ ...isUndefined(queryOptions.signal) ? {} : { signal: queryOptions.signal },
932
+ ...isUndefined(globalOptions.version) ? {} : { version: globalOptions.version },
933
+ ...isUndefined(queryOptions.version) ? {} : { version: queryOptions.version }
1091
934
  };
1092
935
  };
1093
936
  const getDefaultFilesHeader = ({ title, description: description$1, version: version$1 } = {}) => [
1094
- `Generated by ${package_default.name} v${package_default.version} 🍺`,
937
+ `Generated by ${name} v${version} 🍺`,
1095
938
  `Do not edit manually.`,
1096
939
  ...title ? [title] : [],
1097
940
  ...description$1 ? [description$1] : [],
@@ -1105,16 +948,16 @@ const startWatcher = async (watchOptions, watchFn, defaultTarget = ".") => {
1105
948
  const { watch } = await import("chokidar");
1106
949
  const ignored = ["**/{.git,node_modules}/**"];
1107
950
  const watchPaths = typeof watchOptions === "boolean" ? defaultTarget : Array.isArray(watchOptions) ? watchOptions.filter((path$1) => typeof path$1 === "string") : watchOptions;
1108
- (0, __orval_core.log)(`Watching for changes in ${Array.isArray(watchPaths) ? watchPaths.map((v) => "\"" + v + "\"").join(" | ") : "\"" + watchPaths + "\""}`);
951
+ log(`Watching for changes in ${Array.isArray(watchPaths) ? watchPaths.map((v) => "\"" + v + "\"").join(" | ") : "\"" + watchPaths + "\""}`);
1109
952
  watch(watchPaths, {
1110
953
  ignorePermissionErrors: true,
1111
954
  ignored
1112
- }).on("all", async (type$1, file) => {
1113
- (0, __orval_core.log)(`Change detected: ${type$1} ${file}`);
955
+ }).on("all", async (type, file) => {
956
+ log(`Change detected: ${type} ${file}`);
1114
957
  try {
1115
958
  await watchFn();
1116
959
  } catch (error) {
1117
- (0, __orval_core.logError)(error);
960
+ logError(error);
1118
961
  }
1119
962
  });
1120
963
  };
@@ -1122,23 +965,23 @@ const startWatcher = async (watchOptions, watchFn, defaultTarget = ".") => {
1122
965
  //#endregion
1123
966
  //#region src/utils/execute-hook.ts
1124
967
  const executeHook = async (name$1, commands = [], args = []) => {
1125
- (0, __orval_core.log)(chalk.default.white(`Running ${name$1} hook...`));
968
+ log(chalk.white(`Running ${name$1} hook...`));
1126
969
  for (const command of commands) try {
1127
- if ((0, __orval_core.isString)(command)) await executeCommand(command, args);
1128
- else if ((0, __orval_core.isFunction)(command)) await command(args);
1129
- else if ((0, __orval_core.isObject)(command)) await executeObjectCommand(command, args);
970
+ if (isString(command)) await executeCommand(command, args);
971
+ else if (isFunction(command)) await command(args);
972
+ else if (isObject(command)) await executeObjectCommand(command, args);
1130
973
  } catch (error) {
1131
- (0, __orval_core.logError)(error, `Failed to run ${name$1} hook`);
974
+ logError(error, `Failed to run ${name$1} hook`);
1132
975
  }
1133
976
  };
1134
977
  async function executeCommand(command, args) {
1135
- const [cmd, ..._args] = [...(0, string_argv.parseArgsStringToArgv)(command), ...args];
1136
- await (0, execa.default)(cmd, _args);
978
+ const [cmd, ..._args] = [...parseArgsStringToArgv(command), ...args];
979
+ await execa(cmd, _args);
1137
980
  }
1138
981
  async function executeObjectCommand(command, args) {
1139
982
  if (command.injectGeneratedDirsAndFiles === false) args = [];
1140
- if ((0, __orval_core.isString)(command.command)) await executeCommand(command.command, args);
1141
- else if ((0, __orval_core.isFunction)(command.command)) await command.command();
983
+ if (isString(command.command)) await executeCommand(command.command, args);
984
+ else if (isFunction(command.command)) await command.command();
1142
985
  }
1143
986
 
1144
987
  //#endregion
@@ -1146,7 +989,7 @@ async function executeObjectCommand(command, args) {
1146
989
  const getHeader = (option, info) => {
1147
990
  if (!option) return "";
1148
991
  const header = option(info);
1149
- return Array.isArray(header) ? (0, __orval_core.jsDoc)({ description: header }) : header;
992
+ return Array.isArray(header) ? jsDoc({ description: header }) : header;
1150
993
  };
1151
994
  const writeSpecs = async (builder, workspace, options, projectName) => {
1152
995
  const { info = {
@@ -1154,9 +997,9 @@ const writeSpecs = async (builder, workspace, options, projectName) => {
1154
997
  version: 0
1155
998
  }, schemas, target } = builder;
1156
999
  const { output } = options;
1157
- const projectTitle = projectName || info.title;
1000
+ const projectTitle = projectName ?? info.title;
1158
1001
  const specsName = Object.keys(schemas).reduce((acc, specKey) => {
1159
- acc[specKey] = __orval_core.upath.getSpecName(specKey, target).slice(1).split("/").join("-");
1002
+ acc[specKey] = upath.getSpecName(specKey, target).slice(1).split("/").join("-");
1160
1003
  return acc;
1161
1004
  }, {});
1162
1005
  const header = getHeader(output.override.header, info);
@@ -1168,16 +1011,15 @@ const writeSpecs = async (builder, workspace, options, projectName) => {
1168
1011
  "split"
1169
1012
  ].includes(output.mode) ? ".ts" : output.fileExtension ?? ".ts";
1170
1013
  await Promise.all(Object.entries(schemas).map(([specKey, schemas$1]) => {
1171
- const schemaPath = (0, __orval_core.isRootKey)(specKey, target) ? rootSchemaPath : __orval_core.upath.join(rootSchemaPath, specsName[specKey]);
1172
- return (0, __orval_core.writeSchemas)({
1173
- schemaPath,
1014
+ return writeSchemas({
1015
+ schemaPath: isRootKey(specKey, target) ? rootSchemaPath : upath.join(rootSchemaPath, specsName[specKey]),
1174
1016
  schemas: schemas$1,
1175
1017
  target,
1176
1018
  namingConvention: output.namingConvention,
1177
1019
  fileExtension,
1178
1020
  specsName,
1179
1021
  specKey,
1180
- isRootKey: (0, __orval_core.isRootKey)(specKey, target),
1022
+ isRootKey: isRootKey(specKey, target),
1181
1023
  header,
1182
1024
  indexFiles: output.indexFiles
1183
1025
  });
@@ -1194,39 +1036,39 @@ const writeSpecs = async (builder, workspace, options, projectName) => {
1194
1036
  });
1195
1037
  if (output.workspace) {
1196
1038
  const workspacePath = output.workspace;
1197
- const imports = implementationPaths.filter((path$1) => !output.mock || !path$1.endsWith(`.${(0, __orval_core.getMockFileExtensionByTypeName)(output.mock)}.ts`)).map((path$1) => __orval_core.upath.relativeSafe(workspacePath, (0, __orval_core.getFileInfo)(path$1).pathWithoutExtension));
1198
- if (output.schemas) imports.push(__orval_core.upath.relativeSafe(workspacePath, (0, __orval_core.getFileInfo)(output.schemas).dirname));
1039
+ const imports = implementationPaths.filter((path$1) => !output.mock || !path$1.endsWith(`.${getMockFileExtensionByTypeName(output.mock)}.ts`)).map((path$1) => upath.relativeSafe(workspacePath, getFileInfo(path$1).pathWithoutExtension));
1040
+ if (output.schemas) imports.push(upath.relativeSafe(workspacePath, getFileInfo(output.schemas).dirname));
1199
1041
  if (output.indexFiles) {
1200
- const indexFile = __orval_core.upath.join(workspacePath, "/index.ts");
1201
- if (await fs_extra.default.pathExists(indexFile)) {
1202
- const data = await fs_extra.default.readFile(indexFile, "utf8");
1042
+ const indexFile = upath.join(workspacePath, "/index.ts");
1043
+ if (await fs$1.pathExists(indexFile)) {
1044
+ const data = await fs$1.readFile(indexFile, "utf8");
1203
1045
  const importsNotDeclared = imports.filter((imp) => !data.includes(imp));
1204
- await fs_extra.default.appendFile(indexFile, (0, lodash_uniq.default)(importsNotDeclared).map((imp) => `export * from '${imp}';\n`).join(""));
1205
- } else await fs_extra.default.outputFile(indexFile, (0, lodash_uniq.default)(imports).map((imp) => `export * from '${imp}';`).join("\n") + "\n");
1046
+ await fs$1.appendFile(indexFile, unique(importsNotDeclared).map((imp) => `export * from '${imp}';\n`).join(""));
1047
+ } else await fs$1.outputFile(indexFile, unique(imports).map((imp) => `export * from '${imp}';`).join("\n") + "\n");
1206
1048
  implementationPaths = [indexFile, ...implementationPaths];
1207
1049
  }
1208
1050
  }
1209
1051
  if (builder.extraFiles.length > 0) {
1210
- await Promise.all(builder.extraFiles.map(async (file) => fs_extra.default.outputFile(file.path, file.content)));
1052
+ await Promise.all(builder.extraFiles.map(async (file) => fs$1.outputFile(file.path, file.content)));
1211
1053
  implementationPaths = [...implementationPaths, ...builder.extraFiles.map((file) => file.path)];
1212
1054
  }
1213
- const paths = [...output.schemas ? [(0, __orval_core.getFileInfo)(output.schemas).dirname] : [], ...implementationPaths];
1055
+ const paths = [...output.schemas ? [getFileInfo(output.schemas).dirname] : [], ...implementationPaths];
1214
1056
  if (options.hooks.afterAllFilesWrite) await executeHook("afterAllFilesWrite", options.hooks.afterAllFilesWrite, paths);
1215
1057
  if (output.prettier) try {
1216
- await (0, execa.default)("prettier", ["--write", ...paths]);
1058
+ await execa("prettier", ["--write", ...paths]);
1217
1059
  } catch {
1218
- (0, __orval_core.log)(chalk.default.yellow(`⚠️ ${projectTitle ? `${projectTitle} - ` : ""}Globally installed prettier not found`));
1060
+ log(chalk.yellow(`⚠️ ${projectTitle ? `${projectTitle} - ` : ""}Globally installed prettier not found`));
1219
1061
  }
1220
1062
  if (output.biome) try {
1221
- await (0, execa.default)("biome", [
1063
+ await execa("biome", [
1222
1064
  "check",
1223
1065
  "--write",
1224
1066
  ...paths
1225
1067
  ]);
1226
1068
  } catch (error) {
1227
- const errorExeca = error;
1228
- const message = errorExeca.exitCode === 1 ? errorExeca.stdout + errorExeca.stderr : `⚠️ ${projectTitle ? `${projectTitle} - ` : ""}biome not found`;
1229
- (0, __orval_core.log)(chalk.default.yellow(message));
1069
+ let message = `⚠️ ${projectTitle ? `${projectTitle} - ` : ""}biome not found`;
1070
+ if (error instanceof ExecaError && error.exitCode === 1) message = error.message;
1071
+ log(chalk.yellow(message));
1230
1072
  }
1231
1073
  if (output.docs) try {
1232
1074
  let config = {};
@@ -1252,17 +1094,17 @@ const writeSpecs = async (builder, workspace, options, projectName) => {
1252
1094
  else throw new Error("TypeDoc not initialized");
1253
1095
  } catch (error) {
1254
1096
  const message = error instanceof Error ? error.message : `⚠️ ${projectTitle ? `${projectTitle} - ` : ""}Unable to generate docs`;
1255
- (0, __orval_core.log)(chalk.default.yellow(message));
1097
+ log(chalk.yellow(message));
1256
1098
  }
1257
- (0, __orval_core.createSuccessMessage)(projectTitle);
1099
+ createSuccessMessage(projectTitle);
1258
1100
  };
1259
1101
  const getWriteMode = (mode) => {
1260
1102
  switch (mode) {
1261
- case __orval_core.OutputMode.SPLIT: return __orval_core.writeSplitMode;
1262
- case __orval_core.OutputMode.TAGS: return __orval_core.writeTagsMode;
1263
- case __orval_core.OutputMode.TAGS_SPLIT: return __orval_core.writeSplitTagsMode;
1264
- case __orval_core.OutputMode.SINGLE:
1265
- default: return __orval_core.writeSingleMode;
1103
+ case OutputMode.SPLIT: return writeSplitMode;
1104
+ case OutputMode.TAGS: return writeTagsMode;
1105
+ case OutputMode.TAGS_SPLIT: return writeSplitTagsMode;
1106
+ case OutputMode.SINGLE:
1107
+ default: return writeSingleMode;
1266
1108
  }
1267
1109
  };
1268
1110
 
@@ -1271,20 +1113,19 @@ const getWriteMode = (mode) => {
1271
1113
  const generateSpec = async (workspace, options, projectName) => {
1272
1114
  if (options.output.clean) {
1273
1115
  const extraPatterns = Array.isArray(options.output.clean) ? options.output.clean : [];
1274
- if (options.output.target) await (0, __orval_core.removeFilesAndEmptyFolders)([
1116
+ if (options.output.target) await removeFilesAndEmptyFolders([
1275
1117
  "**/*",
1276
1118
  "!**/*.d.ts",
1277
1119
  ...extraPatterns
1278
- ], (0, __orval_core.getFileInfo)(options.output.target).dirname);
1279
- if (options.output.schemas) await (0, __orval_core.removeFilesAndEmptyFolders)([
1120
+ ], getFileInfo(options.output.target).dirname);
1121
+ if (options.output.schemas) await removeFilesAndEmptyFolders([
1280
1122
  "**/*",
1281
1123
  "!**/*.d.ts",
1282
1124
  ...extraPatterns
1283
- ], (0, __orval_core.getFileInfo)(options.output.schemas).dirname);
1284
- (0, __orval_core.log)(`${projectName ? `${projectName}: ` : ""}Cleaning output folder`);
1125
+ ], getFileInfo(options.output.schemas).dirname);
1126
+ log(`${projectName ? `${projectName}: ` : ""}Cleaning output folder`);
1285
1127
  }
1286
- const writeSpecBuilder = await importSpecs(workspace, options);
1287
- await writeSpecs(writeSpecBuilder, workspace, options, projectName);
1128
+ await writeSpecs(await importSpecs(workspace, options), workspace, options, projectName);
1288
1129
  };
1289
1130
  const generateSpecs = async (config, workspace, projectName) => {
1290
1131
  if (projectName) {
@@ -1292,8 +1133,7 @@ const generateSpecs = async (config, workspace, projectName) => {
1292
1133
  if (options) try {
1293
1134
  await generateSpec(workspace, options, projectName);
1294
1135
  } catch (error) {
1295
- const errorMsg = error instanceof Error ? error.message : "unknown error";
1296
- throw new __orval_core.ErrorWithTag(errorMsg, projectName, { cause: error });
1136
+ throw new ErrorWithTag(error instanceof Error ? error.message : "unknown error", projectName, { cause: error });
1297
1137
  }
1298
1138
  else throw new Error("Project not found");
1299
1139
  return;
@@ -1302,97 +1142,60 @@ const generateSpecs = async (config, workspace, projectName) => {
1302
1142
  for (const [projectName$1, options] of Object.entries(config)) {
1303
1143
  if (!options) {
1304
1144
  hasErrors = true;
1305
- (0, __orval_core.logError)("No options found", projectName$1);
1145
+ logError("No options found", projectName$1);
1306
1146
  continue;
1307
1147
  }
1308
1148
  try {
1309
1149
  await generateSpec(workspace, options, projectName$1);
1310
1150
  } catch (error) {
1311
1151
  hasErrors = true;
1312
- (0, __orval_core.logError)(error, projectName$1);
1152
+ logError(error, projectName$1);
1313
1153
  }
1314
1154
  }
1315
1155
  if (hasErrors) throw new Error("One or more project failed, see above for details");
1316
1156
  };
1317
1157
  function findConfigFile(configFilePath) {
1318
1158
  if (configFilePath) {
1319
- if (!node_fs.default.existsSync(configFilePath)) throw new Error(`Config file ${configFilePath} does not exist`);
1320
- return configFilePath;
1159
+ const absolutePath = path.isAbsolute(configFilePath) ? configFilePath : path.resolve(process$1.cwd(), configFilePath);
1160
+ if (!fs.existsSync(absolutePath)) throw new Error(`Config file ${configFilePath} does not exist`);
1161
+ return absolutePath;
1321
1162
  }
1322
- const root = node_process.default.cwd();
1163
+ const root = process$1.cwd();
1323
1164
  for (const ext of [
1324
1165
  ".ts",
1325
1166
  ".js",
1326
1167
  ".mjs",
1327
- ".cjs"
1168
+ ".mts"
1328
1169
  ]) {
1329
- const fullPath = node_path.default.resolve(root, `orval.config${ext}`);
1330
- if (node_fs.default.existsSync(fullPath)) return fullPath;
1170
+ const fullPath = path.resolve(root, `orval.config${ext}`);
1171
+ if (fs.existsSync(fullPath)) return fullPath;
1331
1172
  }
1332
1173
  throw new Error(`No config file found in ${root}`);
1333
1174
  }
1175
+ async function loadConfigFile(configFilePath) {
1176
+ const module = await createJiti(import.meta.url, { interopDefault: true }).import(configFilePath, { default: true });
1177
+ if (module === void 0) throw new Error(`${configFilePath} doesn't have a default export`);
1178
+ return await Promise.resolve(module);
1179
+ }
1334
1180
  const generateConfig = async (configFile, options) => {
1335
1181
  const configFilePath = findConfigFile(configFile);
1336
1182
  let configExternal;
1337
1183
  try {
1338
- const importedModule = await import(node_url.default.pathToFileURL(configFilePath).href);
1339
- if (importedModule.default === void 0) throw new Error(`${configFilePath} doesn't have a default export`);
1340
- configExternal = importedModule.default;
1184
+ configExternal = await loadConfigFile(configFilePath);
1341
1185
  } catch (error) {
1342
1186
  const errorMsg = error instanceof Error ? error.message : "unknown error";
1343
1187
  throw new Error(`failed to load from ${configFilePath} => ${errorMsg}`);
1344
1188
  }
1345
- const workspace = node_path.default.dirname(configFilePath);
1346
- const config = await ((0, __orval_core.isFunction)(configExternal) ? configExternal() : configExternal);
1347
- const normalizedConfig = await (0, __orval_core.asyncReduce)(Object.entries(config), async (acc, [key, value]) => {
1189
+ const workspace = path.dirname(configFilePath);
1190
+ const config = await (isFunction(configExternal) ? configExternal() : configExternal);
1191
+ const normalizedConfig = await asyncReduce(Object.entries(config), async (acc, [key, value]) => {
1348
1192
  acc[key] = await normalizeOptions(value, workspace, options);
1349
1193
  return acc;
1350
1194
  }, {});
1351
- const fileToWatch = Object.entries(normalizedConfig).filter(([project]) => options?.projectName === void 0 || project === options.projectName).map(([, options$1]) => options$1?.input.target).filter((target) => (0, __orval_core.isString)(target));
1195
+ const fileToWatch = Object.entries(normalizedConfig).filter(([project]) => options?.projectName === void 0 || project === options.projectName).map(([, options$1]) => options$1?.input.target).filter((target) => isString(target));
1352
1196
  await (options?.watch && fileToWatch.length > 0 ? startWatcher(options.watch, () => generateSpecs(normalizedConfig, workspace, options.projectName), fileToWatch) : generateSpecs(normalizedConfig, workspace, options?.projectName));
1353
1197
  };
1354
1198
 
1355
1199
  //#endregion
1356
- Object.defineProperty(exports, '__toESM', {
1357
- enumerable: true,
1358
- get: function () {
1359
- return __toESM;
1360
- }
1361
- });
1362
- Object.defineProperty(exports, 'defineConfig', {
1363
- enumerable: true,
1364
- get: function () {
1365
- return defineConfig;
1366
- }
1367
- });
1368
- Object.defineProperty(exports, 'generateConfig', {
1369
- enumerable: true,
1370
- get: function () {
1371
- return generateConfig;
1372
- }
1373
- });
1374
- Object.defineProperty(exports, 'generateSpec', {
1375
- enumerable: true,
1376
- get: function () {
1377
- return generateSpec;
1378
- }
1379
- });
1380
- Object.defineProperty(exports, 'normalizeOptions', {
1381
- enumerable: true,
1382
- get: function () {
1383
- return normalizeOptions;
1384
- }
1385
- });
1386
- Object.defineProperty(exports, 'package_default', {
1387
- enumerable: true,
1388
- get: function () {
1389
- return package_default;
1390
- }
1391
- });
1392
- Object.defineProperty(exports, 'startWatcher', {
1393
- enumerable: true,
1394
- get: function () {
1395
- return startWatcher;
1396
- }
1397
- });
1398
- //# sourceMappingURL=generate-BRYifonC.js.map
1200
+ export { normalizeOptions as a, version as c, defineConfig as i, generateSpec as n, description as o, startWatcher as r, name as s, generateConfig as t };
1201
+ //# sourceMappingURL=generate-6oT76j_W.js.map