orval 8.4.1 → 8.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { c as name, i as startWatcher, l as version, n as loadConfigFile, o as normalizeOptions, r as generateSpec, s as description, t as findConfigFile } from "../config-glSQmAy7.mjs";
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-By98GXtB.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";
@@ -3,6 +3,7 @@ import { FormDataArrayHandling, GetterPropType, NamingConvention, OutputClient,
3
3
  import { bundle } from "@scalar/json-magic/bundle";
4
4
  import { fetchUrls, parseJson, parseYaml, readFiles } from "@scalar/json-magic/bundle/plugins/node";
5
5
  import { upgrade, validate } from "@scalar/openapi-parser";
6
+ import { isNullish as isNullish$1, unique } from "remeda";
6
7
  import * as mock from "@orval/mock";
7
8
  import { DEFAULT_MOCK_OPTIONS, generateMockImports } from "@orval/mock";
8
9
  import angular from "@orval/angular";
@@ -14,10 +15,9 @@ import query from "@orval/query";
14
15
  import solidStart from "@orval/solid-start";
15
16
  import swr from "@orval/swr";
16
17
  import zod, { dereference, generateZodValidationSchemaDefinition, isZodVersionV4, parseZodValidationSchemaDefinition } from "@orval/zod";
17
- import chalk from "chalk";
18
+ import { styleText } from "node:util";
18
19
  import { ExecaError, execa } from "execa";
19
20
  import fs from "fs-extra";
20
- import { unique } from "remeda";
21
21
  import fs$1 from "node:fs/promises";
22
22
  import { parseArgsStringToArgv } from "string-argv";
23
23
  import { findUp, findUpMultiple } from "find-up";
@@ -29,7 +29,7 @@ import { createJiti } from "jiti";
29
29
  //#region package.json
30
30
  var name = "orval";
31
31
  var description = "A swagger client generator for typescript";
32
- var version = "8.4.1";
32
+ var version = "8.5.0";
33
33
 
34
34
  //#endregion
35
35
  //#region src/client.ts
@@ -174,9 +174,9 @@ const generateOperations = (outputClient = DEFAULT_CLIENT, verbsOptions, options
174
174
  }, {});
175
175
  };
176
176
  const generateExtraFiles = (outputClient = DEFAULT_CLIENT, verbsOptions, output, context) => {
177
- const { extraFiles: generateExtraFiles$1 } = getGeneratorClient(outputClient, output);
178
- if (!generateExtraFiles$1) return Promise.resolve([]);
179
- return generateExtraFiles$1(verbsOptions, output, context);
177
+ const { extraFiles: generateExtraFiles } = getGeneratorClient(outputClient, output);
178
+ if (!generateExtraFiles) return Promise.resolve([]);
179
+ return generateExtraFiles(verbsOptions, output, context);
180
180
  };
181
181
 
182
182
  //#endregion
@@ -312,7 +312,7 @@ async function resolveSpec(input, parserOptions) {
312
312
  parseJson(),
313
313
  parseYaml()
314
314
  ],
315
- treeShake: true
315
+ treeShake: false
316
316
  }));
317
317
  const { valid, errors } = await validate(dereferencedData);
318
318
  if (!valid) throw new Error("Validation failed", { cause: errors });
@@ -333,55 +333,125 @@ async function importSpecs(workspace, options, projectName) {
333
333
  /**
334
334
  * The plugins from `@scalar/json-magic` does not dereference $ref.
335
335
  * Instead it fetches them and puts them under x-ext, and changes the $ref to point to #x-ext/<name>.
336
- * This function dereferences those x-ext $ref's.
336
+ * This function:
337
+ * 1. Merges external schemas into main spec's components.schemas (with collision handling)
338
+ * 2. Replaces x-ext refs with standard component refs or inlined content
337
339
  */
338
340
  function dereferenceExternalRef(data) {
339
341
  const extensions = data["x-ext"] ?? {};
342
+ const schemaNameMappings = mergeExternalSchemas(data, extensions);
343
+ const result = {};
344
+ for (const [key, value] of Object.entries(data)) if (key !== "x-ext") result[key] = replaceXExtRefs(value, extensions, schemaNameMappings);
345
+ return result;
346
+ }
347
+ /**
348
+ * Merge external document schemas into main spec's components.schemas
349
+ * Returns mapping of original schema names to final names (with suffixes for collisions)
350
+ */
351
+ function mergeExternalSchemas(data, extensions) {
352
+ const schemaNameMappings = {};
353
+ data.components ??= {};
354
+ const mainComponents = data.components;
355
+ mainComponents.schemas ??= {};
356
+ const mainSchemas = mainComponents.schemas;
357
+ for (const [extKey, extDoc] of Object.entries(extensions)) {
358
+ schemaNameMappings[extKey] = {};
359
+ if (isObject(extDoc) && "components" in extDoc) {
360
+ const extComponents = extDoc.components;
361
+ if (isObject(extComponents) && "schemas" in extComponents) {
362
+ const extSchemas = extComponents.schemas;
363
+ for (const [schemaName, schema] of Object.entries(extSchemas)) {
364
+ const existingSchema = mainSchemas[schemaName];
365
+ const isXExtRef = isObject(existingSchema) && "$ref" in existingSchema && isString(existingSchema.$ref) && existingSchema.$ref.startsWith("#/x-ext/");
366
+ let finalSchemaName = schemaName;
367
+ if (schemaName in mainSchemas && !isXExtRef) {
368
+ finalSchemaName = `${schemaName}_${extKey.replaceAll(/[^a-zA-Z0-9]/g, "_")}`;
369
+ schemaNameMappings[extKey][schemaName] = finalSchemaName;
370
+ } else schemaNameMappings[extKey][schemaName] = schemaName;
371
+ mainSchemas[finalSchemaName] = scrubUnwantedKeys(schema);
372
+ }
373
+ }
374
+ }
375
+ }
376
+ for (const [extKey, mapping] of Object.entries(schemaNameMappings)) for (const [, finalName] of Object.entries(mapping)) {
377
+ const schema = mainSchemas[finalName];
378
+ if (schema) mainSchemas[finalName] = updateInternalRefs(schema, extKey, schemaNameMappings);
379
+ }
380
+ return schemaNameMappings;
381
+ }
382
+ /**
383
+ * Remove unwanted keys like $schema and $id from objects
384
+ */
385
+ function scrubUnwantedKeys(obj) {
340
386
  const UNWANTED_KEYS = new Set(["$schema", "$id"]);
341
- function scrub(obj) {
342
- if (obj === null || obj === void 0) return obj;
343
- if (Array.isArray(obj)) return obj.map((x) => scrub(x));
344
- if (isObject(obj)) {
345
- const rec = obj;
346
- const out = {};
347
- for (const [k, v] of Object.entries(rec)) {
348
- if (UNWANTED_KEYS.has(k)) continue;
349
- out[k] = scrub(v);
387
+ if (obj === null || obj === void 0) return obj;
388
+ if (Array.isArray(obj)) return obj.map((x) => scrubUnwantedKeys(x));
389
+ if (isObject(obj)) {
390
+ const rec = obj;
391
+ const out = {};
392
+ for (const [k, v] of Object.entries(rec)) {
393
+ if (UNWANTED_KEYS.has(k)) continue;
394
+ out[k] = scrubUnwantedKeys(v);
395
+ }
396
+ return out;
397
+ }
398
+ return obj;
399
+ }
400
+ /**
401
+ * Update internal refs within an external schema to use suffixed names
402
+ */
403
+ function updateInternalRefs(obj, extKey, schemaNameMappings) {
404
+ if (obj === null || obj === void 0) return obj;
405
+ if (Array.isArray(obj)) return obj.map((element) => updateInternalRefs(element, extKey, schemaNameMappings));
406
+ if (isObject(obj)) {
407
+ const record = obj;
408
+ if ("$ref" in record && isString(record.$ref)) {
409
+ const refValue = record.$ref;
410
+ if (refValue.startsWith("#/components/schemas/")) {
411
+ const schemaName = refValue.replace("#/components/schemas/", "");
412
+ const mappedName = schemaNameMappings[extKey][schemaName];
413
+ if (mappedName) return { $ref: `#/components/schemas/${mappedName}` };
350
414
  }
351
- return out;
352
415
  }
353
- return obj;
416
+ const result = {};
417
+ for (const [key, value] of Object.entries(record)) result[key] = updateInternalRefs(value, extKey, schemaNameMappings);
418
+ return result;
354
419
  }
355
- function replaceRefs(obj) {
356
- if (obj === null || obj === void 0) return obj;
357
- if (Array.isArray(obj)) return obj.map((element) => replaceRefs(element));
358
- if (isObject(obj)) {
359
- const record = obj;
360
- if ("$ref" in record && isString(record.$ref)) {
361
- const refValue = record.$ref;
362
- if (refValue.startsWith("#/x-ext/")) {
363
- const parts = refValue.replace("#/x-ext/", "").split("/");
364
- const extKey = parts.shift();
365
- if (extKey) {
366
- let refObj = extensions[extKey];
367
- for (const p of parts) if (refObj && (isObject(refObj) || Array.isArray(refObj)) && p in refObj) refObj = refObj[p];
368
- else {
369
- refObj = void 0;
370
- break;
371
- }
372
- if (refObj) return replaceRefs(scrub(refObj));
420
+ return obj;
421
+ }
422
+ /**
423
+ * Replace x-ext refs with either standard component refs or inlined content
424
+ */
425
+ function replaceXExtRefs(obj, extensions, schemaNameMappings) {
426
+ if (isNullish$1(obj)) return obj;
427
+ if (Array.isArray(obj)) return obj.map((element) => replaceXExtRefs(element, extensions, schemaNameMappings));
428
+ if (isObject(obj)) {
429
+ const record = obj;
430
+ if ("$ref" in record && isString(record.$ref)) {
431
+ const refValue = record.$ref;
432
+ if (refValue.startsWith("#/x-ext/")) {
433
+ const parts = refValue.replace("#/x-ext/", "").split("/");
434
+ const extKey = parts.shift();
435
+ if (extKey) {
436
+ if (parts.length >= 3 && parts[0] === "components" && parts[1] === "schemas") {
437
+ const schemaName = parts.slice(2).join("/");
438
+ return { $ref: `#/components/schemas/${schemaNameMappings[extKey][schemaName] || schemaName}` };
373
439
  }
440
+ let refObj = extensions[extKey];
441
+ for (const p of parts) if (refObj && (isObject(refObj) || Array.isArray(refObj)) && p in refObj) refObj = refObj[p];
442
+ else {
443
+ refObj = void 0;
444
+ break;
445
+ }
446
+ if (refObj) return replaceXExtRefs(scrubUnwantedKeys(refObj), extensions, schemaNameMappings);
374
447
  }
375
448
  }
376
- const result$1 = {};
377
- for (const [key, value] of Object.entries(record)) result$1[key] = replaceRefs(value);
378
- return result$1;
379
449
  }
380
- return obj;
450
+ const result = {};
451
+ for (const [key, value] of Object.entries(record)) result[key] = replaceXExtRefs(value, extensions, schemaNameMappings);
452
+ return result;
381
453
  }
382
- const result = {};
383
- for (const [key, value] of Object.entries(data)) if (key !== "x-ext") result[key] = replaceRefs(value);
384
- return result;
454
+ return obj;
385
455
  }
386
456
 
387
457
  //#endregion
@@ -405,8 +475,8 @@ async function formatWithPrettier(paths, projectTitle) {
405
475
  });
406
476
  await fs$1.writeFile(filePath, formatted);
407
477
  } catch (error) {
408
- if (error instanceof Error) if (error.name === "UndefinedParserError") {} else log(chalk.yellow(`⚠️ ${projectTitle ? `${projectTitle} - ` : ""}Failed to format file ${filePath}: ${error.toString()}`));
409
- else log(chalk.yellow(`⚠️ ${projectTitle ? `${projectTitle} - ` : ""}Failed to format file ${filePath}: unknown error}`));
478
+ if (error instanceof Error) if (error.name === "UndefinedParserError") {} else log(styleText("yellow", `⚠️ ${projectTitle ? `${projectTitle} - ` : ""}Failed to format file ${filePath}: ${error.toString()}`));
479
+ else log(styleText("yellow", `⚠️ ${projectTitle ? `${projectTitle} - ` : ""}Failed to format file ${filePath}: unknown error}`));
410
480
  }
411
481
  }));
412
482
  return;
@@ -414,7 +484,7 @@ async function formatWithPrettier(paths, projectTitle) {
414
484
  try {
415
485
  await execa("prettier", ["--write", ...paths]);
416
486
  } catch {
417
- log(chalk.yellow(`⚠️ ${projectTitle ? `${projectTitle} - ` : ""}prettier not found. Install it as a project dependency or globally.`));
487
+ log(styleText("yellow", `⚠️ ${projectTitle ? `${projectTitle} - ` : ""}prettier not found. Install it as a project dependency or globally.`));
418
488
  }
419
489
  }
420
490
  /**
@@ -449,14 +519,14 @@ async function collectFilePaths(paths) {
449
519
 
450
520
  //#endregion
451
521
  //#region src/utils/execute-hook.ts
452
- const executeHook = async (name$1, commands = [], args = []) => {
453
- log(chalk.white(`Running ${name$1} hook...`));
522
+ const executeHook = async (name, commands = [], args = []) => {
523
+ log(styleText("white", `Running ${name} hook...`));
454
524
  for (const command of commands) try {
455
525
  if (isString(command)) await executeCommand(command, args);
456
526
  else if (isFunction(command)) await command(args);
457
527
  else if (isObject(command)) await executeObjectCommand(command, args);
458
528
  } catch (error) {
459
- logError(error, `Failed to run ${name$1} hook`);
529
+ logError(error, `Failed to run ${name} hook`);
460
530
  }
461
531
  };
462
532
  async function executeCommand(command, args) {
@@ -500,7 +570,7 @@ const resolveAndAttachVersions = (pkg, workspace, cacheKey) => {
500
570
  if (Object.keys(resolved).length > 0) {
501
571
  pkg.resolvedVersions = resolved;
502
572
  resolvedCache.set(cacheKey, resolved);
503
- for (const [name$1, version$1] of Object.entries(resolved)) logVerbose(chalk.dim(`Detected ${chalk.white(name$1)} v${chalk.white(version$1)}`));
573
+ for (const [name, version] of Object.entries(resolved)) logVerbose(styleText("dim", `Detected ${styleText("white", name)} v${styleText("white", version)}`));
504
574
  }
505
575
  return pkg;
506
576
  };
@@ -555,7 +625,7 @@ const maybeReplaceCatalog = async (pkg, workspace) => {
555
625
  if (!hasCatalogReferences(pkg)) return pkg;
556
626
  const catalogData = await loadPnpmWorkspaceCatalog(workspace) ?? await loadPackageJsonCatalog(workspace) ?? await loadYarnrcCatalog(workspace);
557
627
  if (!catalogData) {
558
- log(`⚠️ ${chalk.yellow("package.json contains catalog: references, but no catalog source was found (checked: pnpm-workspace.yaml, package.json, .yarnrc.yml).")}`);
628
+ log(`⚠️ ${styleText("yellow", "package.json contains catalog: references, but no catalog source was found (checked: pnpm-workspace.yaml, package.json, .yarnrc.yml).")}`);
559
629
  return pkg;
560
630
  }
561
631
  performSubstitution(pkg.dependencies, catalogData);
@@ -565,27 +635,27 @@ const maybeReplaceCatalog = async (pkg, workspace) => {
565
635
  };
566
636
  const performSubstitution = (dependencies, catalogData) => {
567
637
  if (!dependencies) return;
568
- for (const [packageName, version$1] of Object.entries(dependencies)) if (version$1 === "catalog:" || version$1 === "catalog:default") {
638
+ for (const [packageName, version] of Object.entries(dependencies)) if (version === "catalog:" || version === "catalog:default") {
569
639
  if (!catalogData.catalog) {
570
- log(`⚠️ ${chalk.yellow(`catalog: substitution for the package '${packageName}' failed as there is no default catalog.`)}`);
640
+ log(`⚠️ ${styleText("yellow", `catalog: substitution for the package '${packageName}' failed as there is no default catalog.`)}`);
571
641
  continue;
572
642
  }
573
643
  const sub = catalogData.catalog[packageName];
574
644
  if (!sub) {
575
- log(`⚠️ ${chalk.yellow(`catalog: substitution for the package '${packageName}' failed as there is no matching package in the default catalog.`)}`);
645
+ log(`⚠️ ${styleText("yellow", `catalog: substitution for the package '${packageName}' failed as there is no matching package in the default catalog.`)}`);
576
646
  continue;
577
647
  }
578
648
  dependencies[packageName] = sub;
579
- } else if (version$1.startsWith("catalog:")) {
580
- const catalogName = version$1.slice(8);
649
+ } else if (version.startsWith("catalog:")) {
650
+ const catalogName = version.slice(8);
581
651
  const catalog = catalogData.catalogs?.[catalogName];
582
652
  if (!catalog) {
583
- log(`⚠️ ${chalk.yellow(`'${version$1}' substitution for the package '${packageName}' failed as there is no matching catalog named '${catalogName}'. (available named catalogs are: ${Object.keys(catalogData.catalogs ?? {}).join(", ")})`)}`);
653
+ log(`⚠️ ${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(", ")})`)}`);
584
654
  continue;
585
655
  }
586
656
  const sub = catalog[packageName];
587
657
  if (!sub) {
588
- log(`⚠️ ${chalk.yellow(`'${version$1}' 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(", ")})`)}`);
658
+ log(`⚠️ ${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(", ")})`)}`);
589
659
  continue;
590
660
  }
591
661
  dependencies[packageName] = sub;
@@ -620,6 +690,13 @@ const loadTsconfig = async (tsconfig, workspace = process.cwd()) => {
620
690
  function defineConfig(options) {
621
691
  return options;
622
692
  }
693
+ /**
694
+ * Type helper to make it easier to write input transformers.
695
+ * accepts a direct {@link InputTransformerFn} function.
696
+ */
697
+ function defineTransformer(transformer) {
698
+ return transformer;
699
+ }
623
700
  function createFormData(workspace, formData) {
624
701
  const defaultArrayHandling = FormDataArrayHandling.SERIALIZE;
625
702
  if (formData === void 0) return {
@@ -656,8 +733,8 @@ function normalizeSchemasOption(schemas, workspace) {
656
733
  }
657
734
  async function normalizeOptions(optionsExport, workspace = process.cwd(), globalOptions = {}) {
658
735
  const options = await (isFunction(optionsExport) ? optionsExport() : optionsExport);
659
- if (!options.input) throw new Error(chalk.red(`Config require an input`));
660
- if (!options.output) throw new Error(chalk.red(`Config require an output`));
736
+ if (!options.input) throw new Error(styleText("red", `Config require an input`));
737
+ if (!options.output) throw new Error(styleText("red", `Config require an output`));
661
738
  const inputOptions = isString(options.input) ? { target: options.input } : options.input;
662
739
  const outputOptions = isString(options.output) ? { target: options.output } : options.output;
663
740
  const outputWorkspace = normalizePath(outputOptions.workspace ?? "", workspace);
@@ -665,14 +742,14 @@ async function normalizeOptions(optionsExport, workspace = process.cwd(), global
665
742
  const tsconfig = await loadTsconfig(outputOptions.tsconfig ?? globalOptions.tsconfig, workspace);
666
743
  const packageJson = await loadPackageJson(outputOptions.packageJson ?? globalOptions.packageJson, workspace);
667
744
  const mockOption = outputOptions.mock ?? globalOptions.mock;
668
- let mock$1;
669
- if (isBoolean(mockOption) && mockOption) mock$1 = DEFAULT_MOCK_OPTIONS;
670
- else if (isFunction(mockOption)) mock$1 = mockOption;
671
- else if (mockOption) mock$1 = {
745
+ let mock;
746
+ if (isBoolean(mockOption) && mockOption) mock = DEFAULT_MOCK_OPTIONS;
747
+ else if (isFunction(mockOption)) mock = mockOption;
748
+ else if (mockOption) mock = {
672
749
  ...DEFAULT_MOCK_OPTIONS,
673
750
  ...mockOption
674
751
  };
675
- else mock$1 = void 0;
752
+ else mock = void 0;
676
753
  const defaultFileExtension = ".ts";
677
754
  const globalQueryOptions = {
678
755
  useQuery: true,
@@ -701,7 +778,7 @@ async function normalizeOptions(optionsExport, workspace = process.cwd(), global
701
778
  client: outputOptions.client ?? client ?? OutputClient.AXIOS_FUNCTIONS,
702
779
  httpClient: outputOptions.httpClient ?? httpClient ?? ((outputOptions.client ?? client) === OutputClient.ANGULAR_QUERY ? OutputHttpClient.ANGULAR : OutputHttpClient.FETCH),
703
780
  mode: normalizeOutputMode(outputOptions.mode ?? mode),
704
- mock: mock$1,
781
+ mock,
705
782
  clean: outputOptions.clean ?? clean ?? false,
706
783
  docs: outputOptions.docs ?? false,
707
784
  prettier: outputOptions.prettier ?? prettier ?? false,
@@ -813,13 +890,13 @@ async function normalizeOptions(optionsExport, workspace = process.cwd(), global
813
890
  },
814
891
  hooks: options.hooks ? normalizeHooks(options.hooks) : {}
815
892
  };
816
- if (!normalizedOptions.input.target) throw new Error(chalk.red(`Config require an input target`));
817
- if (!normalizedOptions.output.target && !normalizedOptions.output.schemas) throw new Error(chalk.red(`Config require an output target or schemas`));
893
+ if (!normalizedOptions.input.target) throw new Error(styleText("red", `Config require an input target`));
894
+ if (!normalizedOptions.output.target && !normalizedOptions.output.schemas) throw new Error(styleText("red", `Config require an output target or schemas`));
818
895
  return normalizedOptions;
819
896
  }
820
897
  function normalizeMutator(workspace, mutator) {
821
898
  if (isObject(mutator)) {
822
- if (!mutator.path) throw new Error(chalk.red(`Mutator need a path`));
899
+ if (!mutator.path) throw new Error(styleText("red", `Mutator need a path`));
823
900
  return {
824
901
  ...mutator,
825
902
  path: upath.resolve(workspace, mutator.path),
@@ -832,51 +909,51 @@ function normalizeMutator(workspace, mutator) {
832
909
  };
833
910
  return mutator;
834
911
  }
835
- function normalizePathOrUrl(path$1, workspace) {
836
- if (isString(path$1) && !isUrl(path$1)) return normalizePath(path$1, workspace);
837
- return path$1;
912
+ function normalizePathOrUrl(path, workspace) {
913
+ if (isString(path) && !isUrl(path)) return normalizePath(path, workspace);
914
+ return path;
838
915
  }
839
- function normalizePath(path$1, workspace) {
840
- if (!isString(path$1)) return path$1;
841
- return upath.resolve(workspace, path$1);
916
+ function normalizePath(path, workspace) {
917
+ if (!isString(path)) return path;
918
+ return upath.resolve(workspace, path);
842
919
  }
843
920
  function normalizeOperationsAndTags(operationsOrTags, workspace, global) {
844
- return Object.fromEntries(Object.entries(operationsOrTags).map(([key, { transformer, mutator, formData, formUrlEncoded, paramsSerializer, query: query$1, zod: zod$1, ...rest }]) => {
921
+ return Object.fromEntries(Object.entries(operationsOrTags).map(([key, { transformer, mutator, formData, formUrlEncoded, paramsSerializer, query, zod, ...rest }]) => {
845
922
  return [key, {
846
923
  ...rest,
847
- ...query$1 ? { query: normalizeQueryOptions(query$1, workspace, global.query) } : {},
848
- ...zod$1 ? { zod: {
924
+ ...query ? { query: normalizeQueryOptions(query, workspace, global.query) } : {},
925
+ ...zod ? { zod: {
849
926
  strict: {
850
- param: zod$1.strict?.param ?? false,
851
- query: zod$1.strict?.query ?? false,
852
- header: zod$1.strict?.header ?? false,
853
- body: zod$1.strict?.body ?? false,
854
- response: zod$1.strict?.response ?? false
927
+ param: zod.strict?.param ?? false,
928
+ query: zod.strict?.query ?? false,
929
+ header: zod.strict?.header ?? false,
930
+ body: zod.strict?.body ?? false,
931
+ response: zod.strict?.response ?? false
855
932
  },
856
933
  generate: {
857
- param: zod$1.generate?.param ?? true,
858
- query: zod$1.generate?.query ?? true,
859
- header: zod$1.generate?.header ?? true,
860
- body: zod$1.generate?.body ?? true,
861
- response: zod$1.generate?.response ?? true
934
+ param: zod.generate?.param ?? true,
935
+ query: zod.generate?.query ?? true,
936
+ header: zod.generate?.header ?? true,
937
+ body: zod.generate?.body ?? true,
938
+ response: zod.generate?.response ?? true
862
939
  },
863
940
  coerce: {
864
- param: zod$1.coerce?.param ?? false,
865
- query: zod$1.coerce?.query ?? false,
866
- header: zod$1.coerce?.header ?? false,
867
- body: zod$1.coerce?.body ?? false,
868
- response: zod$1.coerce?.response ?? false
941
+ param: zod.coerce?.param ?? false,
942
+ query: zod.coerce?.query ?? false,
943
+ header: zod.coerce?.header ?? false,
944
+ body: zod.coerce?.body ?? false,
945
+ response: zod.coerce?.response ?? false
869
946
  },
870
947
  preprocess: {
871
- ...zod$1.preprocess?.param ? { param: normalizeMutator(workspace, zod$1.preprocess.param) } : {},
872
- ...zod$1.preprocess?.query ? { query: normalizeMutator(workspace, zod$1.preprocess.query) } : {},
873
- ...zod$1.preprocess?.header ? { header: normalizeMutator(workspace, zod$1.preprocess.header) } : {},
874
- ...zod$1.preprocess?.body ? { body: normalizeMutator(workspace, zod$1.preprocess.body) } : {},
875
- ...zod$1.preprocess?.response ? { response: normalizeMutator(workspace, zod$1.preprocess.response) } : {}
948
+ ...zod.preprocess?.param ? { param: normalizeMutator(workspace, zod.preprocess.param) } : {},
949
+ ...zod.preprocess?.query ? { query: normalizeMutator(workspace, zod.preprocess.query) } : {},
950
+ ...zod.preprocess?.header ? { header: normalizeMutator(workspace, zod.preprocess.header) } : {},
951
+ ...zod.preprocess?.body ? { body: normalizeMutator(workspace, zod.preprocess.body) } : {},
952
+ ...zod.preprocess?.response ? { response: normalizeMutator(workspace, zod.preprocess.response) } : {}
876
953
  },
877
- generateEachHttpStatus: zod$1.generateEachHttpStatus ?? false,
878
- dateTimeOptions: zod$1.dateTimeOptions ?? {},
879
- timeOptions: zod$1.timeOptions ?? {}
954
+ generateEachHttpStatus: zod.generateEachHttpStatus ?? false,
955
+ dateTimeOptions: zod.dateTimeOptions ?? {},
956
+ timeOptions: zod.timeOptions ?? {}
880
957
  } } : {},
881
958
  ...transformer ? { transformer: normalizePath(transformer, workspace) } : {},
882
959
  ...mutator ? { mutator: normalizeMutator(workspace, mutator) } : {},
@@ -889,7 +966,7 @@ function normalizeOperationsAndTags(operationsOrTags, workspace, global) {
889
966
  function normalizeOutputMode(mode) {
890
967
  if (!mode) return OutputMode.SINGLE;
891
968
  if (!Object.values(OutputMode).includes(mode)) {
892
- createLogger().warn(chalk.yellow(`Unknown the provided mode => ${mode}`));
969
+ createLogger().warn(styleText("yellow", `Unknown the provided mode => ${mode}`));
893
970
  return OutputMode.SINGLE;
894
971
  }
895
972
  return mode;
@@ -903,12 +980,12 @@ function normalizeHooks(hooks) {
903
980
  else if (isObject(hooks[key])) result[key] = [hooks[key]];
904
981
  return result;
905
982
  }
906
- function normalizeHonoOptions(hono$1 = {}, workspace) {
983
+ function normalizeHonoOptions(hono = {}, workspace) {
907
984
  return {
908
- ...hono$1.handlers ? { handlers: upath.resolve(workspace, hono$1.handlers) } : {},
909
- compositeRoute: hono$1.compositeRoute ?? "",
910
- validator: hono$1.validator ?? true,
911
- validatorOutputPath: hono$1.validatorOutputPath ? upath.resolve(workspace, hono$1.validatorOutputPath) : ""
985
+ ...hono.handlers ? { handlers: upath.resolve(workspace, hono.handlers) } : {},
986
+ compositeRoute: hono.compositeRoute ?? "",
987
+ validator: hono.validator ?? true,
988
+ validatorOutputPath: hono.validatorOutputPath ? upath.resolve(workspace, hono.validatorOutputPath) : ""
912
989
  };
913
990
  }
914
991
  function normalizeJSDocOptions(jsdoc = {}) {
@@ -952,12 +1029,12 @@ function normalizeQueryOptions(queryOptions = {}, outputWorkspace, globalOptions
952
1029
  ...isNullish(queryOptions.runtimeValidation) ? {} : { runtimeValidation: queryOptions.runtimeValidation }
953
1030
  };
954
1031
  }
955
- function getDefaultFilesHeader({ title, description: description$1, version: version$1 } = {}) {
1032
+ function getDefaultFilesHeader({ title, description, version: version$1 } = {}) {
956
1033
  return [
957
1034
  `Generated by ${name} v${version} 🍺`,
958
1035
  `Do not edit manually.`,
959
1036
  ...title ? [title] : [],
960
- ...description$1 ? [description$1] : [],
1037
+ ...description ? [description] : [],
961
1038
  ...version$1 ? [`OpenAPI spec version: ${version$1}`] : []
962
1039
  ];
963
1040
  }
@@ -1009,15 +1086,15 @@ export type ${schemaName} = zod.input<typeof ${schemaName}>;`;
1009
1086
  }).join("\n\n")}
1010
1087
  `;
1011
1088
  }
1012
- const isValidSchemaIdentifier = (name$1) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(name$1);
1013
- const isPrimitiveSchemaName = (name$1) => [
1089
+ const isValidSchemaIdentifier = (name) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(name);
1090
+ const isPrimitiveSchemaName = (name) => [
1014
1091
  "string",
1015
1092
  "number",
1016
1093
  "boolean",
1017
1094
  "void",
1018
1095
  "unknown",
1019
1096
  "Blob"
1020
- ].includes(name$1);
1097
+ ].includes(name);
1021
1098
  const dedupeSchemasByName = (schemas) => {
1022
1099
  const uniqueSchemas = /* @__PURE__ */ new Map();
1023
1100
  for (const schema of schemas) if (!uniqueSchemas.has(schema.name)) uniqueSchemas.set(schema.name, schema);
@@ -1057,9 +1134,9 @@ async function writeZodSchemas(builder, schemasPath, fileExtension, header, outp
1057
1134
  const strict = output.override.zod.strict.body;
1058
1135
  const coerce = output.override.zod.coerce.body;
1059
1136
  for (const generatorSchema of schemasWithOpenApiDef) {
1060
- const { name: name$1, schema: schemaObject } = generatorSchema;
1137
+ const { name, schema: schemaObject } = generatorSchema;
1061
1138
  if (!schemaObject) continue;
1062
- const fileName = conventionName(name$1, output.namingConvention);
1139
+ const fileName = conventionName(name, output.namingConvention);
1063
1140
  const filePath = upath.join(schemasPath, `${fileName}${fileExtension}`);
1064
1141
  const context = {
1065
1142
  spec: builder.spec,
@@ -1067,9 +1144,9 @@ async function writeZodSchemas(builder, schemasPath, fileExtension, header, outp
1067
1144
  workspace: "",
1068
1145
  output
1069
1146
  };
1070
- const parsedZodDefinition = parseZodValidationSchemaDefinition(generateZodValidationSchemaDefinition(dereference(schemaObject, context), context, name$1, strict, isZodV4, { required: true }), context, coerce, strict, isZodV4);
1147
+ const parsedZodDefinition = parseZodValidationSchemaDefinition(generateZodValidationSchemaDefinition(dereference(schemaObject, context), context, name, strict, isZodV4, { required: true }), context, coerce, strict, isZodV4);
1071
1148
  schemasToWrite.push({
1072
- schemaName: name$1,
1149
+ schemaName: name,
1073
1150
  filePath,
1074
1151
  consts: parsedZodDefinition.consts,
1075
1152
  zodExpression: parsedZodDefinition.zod
@@ -1104,7 +1181,7 @@ async function writeZodSchemasFromVerbs(verbOptions, schemasPath, fileExtension,
1104
1181
  schema: {
1105
1182
  type: "object",
1106
1183
  properties: Object.fromEntries(queryParams.filter((p) => "schema" in p && p.schema).map((p) => [p.name, dereference(p.schema, zodContext)])),
1107
- required: queryParams.filter((p) => p.required).map((p) => p.name).filter((name$1) => name$1 !== void 0)
1184
+ required: queryParams.filter((p) => p.required).map((p) => p.name).filter((name) => name !== void 0)
1108
1185
  }
1109
1186
  }] : [];
1110
1187
  const headerParams = parameters?.filter((p) => "in" in p && p.in === "header");
@@ -1113,7 +1190,7 @@ async function writeZodSchemasFromVerbs(verbOptions, schemasPath, fileExtension,
1113
1190
  schema: {
1114
1191
  type: "object",
1115
1192
  properties: Object.fromEntries(headerParams.filter((p) => "schema" in p && p.schema).map((p) => [p.name, dereference(p.schema, zodContext)])),
1116
- required: headerParams.filter((p) => p.required).map((p) => p.name).filter((name$1) => name$1 !== void 0)
1193
+ required: headerParams.filter((p) => p.required).map((p) => p.name).filter((name) => name !== void 0)
1117
1194
  }
1118
1195
  }] : [];
1119
1196
  const responseSchemas = [...verbOption.response.types.success, ...verbOption.response.types.errors].filter((responseType) => !!responseType.originalSchema && !responseType.isRef && isValidSchemaIdentifier(responseType.value) && !isPrimitiveSchemaName(responseType.value)).map((responseType) => ({
@@ -1128,12 +1205,12 @@ async function writeZodSchemasFromVerbs(verbOptions, schemasPath, fileExtension,
1128
1205
  ]);
1129
1206
  }));
1130
1207
  const schemasToWrite = [];
1131
- for (const { name: name$1, schema } of uniqueVerbsSchemas) {
1132
- const fileName = conventionName(name$1, output.namingConvention);
1208
+ for (const { name, schema } of uniqueVerbsSchemas) {
1209
+ const fileName = conventionName(name, output.namingConvention);
1133
1210
  const filePath = upath.join(schemasPath, `${fileName}${fileExtension}`);
1134
- const parsedZodDefinition = parseZodValidationSchemaDefinition(generateZodValidationSchemaDefinition(schema, zodContext, name$1, strict, isZodV4, { required: true }), zodContext, coerce, strict, isZodV4);
1211
+ const parsedZodDefinition = parseZodValidationSchemaDefinition(generateZodValidationSchemaDefinition(schema, zodContext, name, strict, isZodV4, { required: true }), zodContext, coerce, strict, isZodV4);
1135
1212
  schemasToWrite.push({
1136
- schemaName: name$1,
1213
+ schemaName: name,
1137
1214
  filePath,
1138
1215
  consts: parsedZodDefinition.consts,
1139
1216
  zodExpression: parsedZodDefinition.zod
@@ -1273,7 +1350,7 @@ async function writeSpecs(builder, workspace, options, projectName) {
1273
1350
  });
1274
1351
  if (output.workspace) {
1275
1352
  const workspacePath = output.workspace;
1276
- 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));
1353
+ const imports = implementationPaths.filter((path) => !output.mock || !path.endsWith(`.${getMockFileExtensionByTypeName(output.mock)}.ts`)).map((path) => upath.relativeSafe(workspacePath, getFileInfo(path).pathWithoutExtension));
1277
1354
  if (output.schemas) {
1278
1355
  const schemasPath = isString(output.schemas) ? output.schemas : output.schemas.path;
1279
1356
  imports.push(upath.relativeSafe(workspacePath, getFileInfo(schemasPath).dirname));
@@ -1309,7 +1386,7 @@ async function writeSpecs(builder, workspace, options, projectName) {
1309
1386
  } catch (error) {
1310
1387
  let message = `⚠️ ${projectTitle ? `${projectTitle} - ` : ""}biome not found`;
1311
1388
  if (error instanceof ExecaError && error.exitCode === 1) message = error.message;
1312
- log(chalk.yellow(message));
1389
+ log(styleText("yellow", message));
1313
1390
  }
1314
1391
  if (output.docs) try {
1315
1392
  let config = {};
@@ -1337,8 +1414,7 @@ async function writeSpecs(builder, workspace, options, projectName) {
1337
1414
  if (output.prettier) await formatWithPrettier([outputPath], projectTitle);
1338
1415
  } else throw new Error("TypeDoc not initialized");
1339
1416
  } catch (error) {
1340
- const message = error instanceof Error ? error.message : `⚠️ ${projectTitle ? `${projectTitle} - ` : ""}Unable to generate docs`;
1341
- log(chalk.yellow(message));
1417
+ log(styleText("yellow", error instanceof Error ? error.message : `⚠️ ${projectTitle ? `${projectTitle} - ` : ""}Unable to generate docs`));
1342
1418
  }
1343
1419
  createSuccessMessage(projectTitle);
1344
1420
  }
@@ -1437,5 +1513,5 @@ async function loadConfigFile(configFilePath) {
1437
1513
  }
1438
1514
 
1439
1515
  //#endregion
1440
- export { defineConfig as a, name as c, startWatcher as i, version as l, loadConfigFile as n, normalizeOptions as o, generateSpec as r, description as s, findConfigFile as t };
1441
- //# sourceMappingURL=config-glSQmAy7.mjs.map
1516
+ 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 };
1517
+ //# sourceMappingURL=config-By98GXtB.mjs.map