@hey-api/openapi-ts 0.90.2 → 0.90.3

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.
@@ -513,66 +513,6 @@ const valueToObject = ({ defaultValue, mappers: mappers$1, value }) => {
513
513
  return result;
514
514
  };
515
515
 
516
- //#endregion
517
- //#region src/config/output/source/config.ts
518
- function resolveSource(config) {
519
- const source$2 = valueToObject({
520
- defaultValue: {
521
- enabled: Boolean(config.source),
522
- extension: "json",
523
- fileName: "source",
524
- serialize: (input) => JSON.stringify(input, null, 2)
525
- },
526
- mappers: { boolean: (enabled) => ({ enabled }) },
527
- value: config.source
528
- });
529
- if (source$2.path === void 0 || source$2.path === true) source$2.path = "";
530
- else if (source$2.path === false) source$2.path = null;
531
- return source$2;
532
- }
533
-
534
- //#endregion
535
- //#region src/config/output/config.ts
536
- function getOutput(userConfig) {
537
- if (userConfig.output instanceof Array) throw new Error("Unexpected array of outputs in user configuration. This should have been expanded already.");
538
- const output = valueToObject({
539
- defaultValue: {
540
- clean: true,
541
- fileName: {
542
- case: "preserve",
543
- name: "{{name}}",
544
- suffix: ".gen"
545
- },
546
- format: null,
547
- header: "// This file is auto-generated by @hey-api/openapi-ts",
548
- indexFile: true,
549
- lint: null,
550
- path: "",
551
- preferExportAll: false
552
- },
553
- mappers: {
554
- object: (fields, defaultValue) => ({
555
- ...fields,
556
- fileName: valueToObject({
557
- defaultValue: { ...defaultValue.fileName },
558
- mappers: {
559
- function: (name) => ({ name }),
560
- string: (name) => ({ name })
561
- },
562
- value: fields.fileName
563
- })
564
- }),
565
- string: (path$4) => ({ path: path$4 })
566
- },
567
- value: userConfig.output
568
- });
569
- output.tsConfig = loadTsConfig(findTsConfigPath(output.tsConfigPath));
570
- if (output.importFileExtension === void 0 && (output.tsConfig?.options.moduleResolution === ts.ModuleResolutionKind.NodeNext || output.tsConfig?.options.moduleResolution === ts.ModuleResolutionKind.Node16)) output.importFileExtension = ".js";
571
- if (output.importFileExtension && !output.importFileExtension.startsWith(".")) output.importFileExtension = `.${output.importFileExtension}`;
572
- output.source = resolveSource(output);
573
- return output;
574
- }
575
-
576
516
  //#endregion
577
517
  //#region ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
578
518
  var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
@@ -985,68 +925,169 @@ var require_cross_spawn = /* @__PURE__ */ __commonJSMin(((exports, module) => {
985
925
  //#endregion
986
926
  //#region src/config/output/postprocess.ts
987
927
  var import_cross_spawn = require_cross_spawn();
988
- /**
989
- * Map of supported formatters
990
- */
991
- const formatters = {
992
- biome: {
993
- args: (path$4) => [
928
+ const postProcessors = {
929
+ "biome:format": {
930
+ args: [
994
931
  "format",
995
932
  "--write",
996
- path$4
933
+ "{{path}}"
997
934
  ],
998
935
  command: "biome",
999
936
  name: "Biome (Format)"
1000
937
  },
1001
- prettier: {
1002
- args: (path$4) => [
1003
- "--ignore-unknown",
1004
- path$4,
1005
- "--write",
1006
- "--ignore-path",
1007
- "./.prettierignore"
1008
- ],
1009
- command: "prettier",
1010
- name: "Prettier"
1011
- }
1012
- };
1013
- /**
1014
- * Map of supported linters
1015
- */
1016
- const linters = {
1017
- biome: {
1018
- args: (path$4) => [
938
+ "biome:lint": {
939
+ args: [
1019
940
  "lint",
1020
941
  "--apply",
1021
- path$4
942
+ "{{path}}"
1022
943
  ],
1023
944
  command: "biome",
1024
945
  name: "Biome (Lint)"
1025
946
  },
1026
947
  eslint: {
1027
- args: (path$4) => [path$4, "--fix"],
948
+ args: ["{{path}}", "--fix"],
1028
949
  command: "eslint",
1029
950
  name: "ESLint"
1030
951
  },
952
+ oxfmt: {
953
+ args: ["{{path}}"],
954
+ command: "oxfmt",
955
+ name: "Oxfmt"
956
+ },
1031
957
  oxlint: {
1032
- args: (path$4) => ["--fix", path$4],
958
+ args: ["--fix", "{{path}}"],
1033
959
  command: "oxlint",
1034
- name: "oxlint"
960
+ name: "Oxlint"
961
+ },
962
+ prettier: {
963
+ args: [
964
+ "--ignore-unknown",
965
+ "{{path}}",
966
+ "--write",
967
+ "--ignore-path",
968
+ "./.prettierignore"
969
+ ],
970
+ command: "prettier",
971
+ name: "Prettier"
1035
972
  }
1036
973
  };
1037
- const postprocessOutput = (config) => {
1038
- if (config.lint) {
1039
- const module$1 = linters[config.lint];
1040
- console.log(`✨ Running ${module$1.name}`);
1041
- (0, import_cross_spawn.sync)(module$1.command, module$1.args(config.path));
1042
- }
1043
- if (config.format) {
1044
- const module$1 = formatters[config.format];
1045
- console.log(`✨ Running ${module$1.name}`);
1046
- (0, import_cross_spawn.sync)(module$1.command, module$1.args(config.path));
974
+ const postprocessOutput = (config, jobPrefix) => {
975
+ for (const processor of config.postProcess) {
976
+ const resolved = typeof processor === "string" ? postProcessors[processor] : processor;
977
+ const name = resolved.name ?? resolved.command;
978
+ const args = resolved.args.map((arg) => arg.replace("{{path}}", config.path));
979
+ console.log(`${jobPrefix}🧹 Running ${colors.cyanBright(name)}`);
980
+ (0, import_cross_spawn.sync)(resolved.command, args);
1047
981
  }
1048
982
  };
1049
983
 
984
+ //#endregion
985
+ //#region src/config/output/source/config.ts
986
+ function resolveSource(config) {
987
+ const source$2 = valueToObject({
988
+ defaultValue: {
989
+ enabled: Boolean(config.source),
990
+ extension: "json",
991
+ fileName: "source",
992
+ serialize: (input) => JSON.stringify(input, null, 2)
993
+ },
994
+ mappers: { boolean: (enabled) => ({ enabled }) },
995
+ value: config.source
996
+ });
997
+ if (source$2.path === void 0 || source$2.path === true) source$2.path = "";
998
+ else if (source$2.path === false) source$2.path = null;
999
+ return source$2;
1000
+ }
1001
+
1002
+ //#endregion
1003
+ //#region src/config/output/config.ts
1004
+ function getOutput(userConfig) {
1005
+ if (userConfig.output instanceof Array) throw new Error("Unexpected array of outputs in user configuration. This should have been expanded already.");
1006
+ const userOutput = typeof userConfig.output === "string" ? { path: userConfig.output } : userConfig.output ?? {};
1007
+ const legacyPostProcess = resolveLegacyPostProcess(userOutput);
1008
+ const output = valueToObject({
1009
+ defaultValue: {
1010
+ clean: true,
1011
+ fileName: {
1012
+ case: "preserve",
1013
+ name: "{{name}}",
1014
+ suffix: ".gen"
1015
+ },
1016
+ format: null,
1017
+ header: "// This file is auto-generated by @hey-api/openapi-ts",
1018
+ indexFile: true,
1019
+ lint: null,
1020
+ path: "",
1021
+ postProcess: [],
1022
+ preferExportAll: false
1023
+ },
1024
+ mappers: { object: (fields, defaultValue) => ({
1025
+ ...fields,
1026
+ fileName: valueToObject({
1027
+ defaultValue: { ...defaultValue.fileName },
1028
+ mappers: {
1029
+ function: (name) => ({ name }),
1030
+ string: (name) => ({ name })
1031
+ },
1032
+ value: fields.fileName
1033
+ })
1034
+ }) },
1035
+ value: userOutput
1036
+ });
1037
+ output.tsConfig = loadTsConfig(findTsConfigPath(output.tsConfigPath));
1038
+ if (output.importFileExtension === void 0 && (output.tsConfig?.options.moduleResolution === ts.ModuleResolutionKind.NodeNext || output.tsConfig?.options.moduleResolution === ts.ModuleResolutionKind.Node16)) output.importFileExtension = ".js";
1039
+ if (output.importFileExtension && !output.importFileExtension.startsWith(".")) output.importFileExtension = `.${output.importFileExtension}`;
1040
+ output.postProcess = normalizePostProcess(userOutput.postProcess ?? legacyPostProcess);
1041
+ output.source = resolveSource(output);
1042
+ return output;
1043
+ }
1044
+ function resolveLegacyPostProcess(config) {
1045
+ const result = [];
1046
+ if (config.lint !== void 0) {
1047
+ let processor;
1048
+ let preset;
1049
+ if (config.lint) {
1050
+ preset = config.lint === "biome" ? "biome:lint" : config.lint;
1051
+ processor = postProcessors[preset];
1052
+ if (processor) result.push(processor);
1053
+ }
1054
+ log.warnDeprecated({
1055
+ context: "output",
1056
+ field: "lint",
1057
+ replacement: `postProcess: [${processor && preset ? `'${preset}'` : ""}]`
1058
+ });
1059
+ }
1060
+ if (config.format !== void 0) {
1061
+ let processor;
1062
+ let preset;
1063
+ if (config.format) {
1064
+ preset = config.format === "biome" ? "biome:format" : config.format;
1065
+ processor = postProcessors[preset];
1066
+ if (processor) result.push(processor);
1067
+ }
1068
+ log.warnDeprecated({
1069
+ context: "output",
1070
+ field: "format",
1071
+ replacement: `postProcess: [${processor && preset ? `'${preset}'` : ""}]`
1072
+ });
1073
+ }
1074
+ return result;
1075
+ }
1076
+ function normalizePostProcess(input) {
1077
+ if (!input) return [];
1078
+ return input.map((item) => {
1079
+ if (typeof item === "string") {
1080
+ const preset = postProcessors[item];
1081
+ if (!preset) throw new Error(`Unknown post-processor preset: "${item}"`);
1082
+ return preset;
1083
+ }
1084
+ return {
1085
+ name: item.name ?? item.command,
1086
+ ...item
1087
+ };
1088
+ });
1089
+ }
1090
+
1050
1091
  //#endregion
1051
1092
  //#region src/config/packages.ts
1052
1093
  /**
@@ -21445,4 +21486,4 @@ const parseOpenApiSpec = ({ config, dependencies, logger, spec }) => {
21445
21486
 
21446
21487
  //#endregion
21447
21488
  export { openGitHubIssueWithCrashReport as A, defaultPaginationKeywords as C, ConfigValidationError as D, ConfigError as E, shouldReportCrash as M, loadPackageJson as N, JobError as O, definePluginConfig as S, getLogs as T, regexp as _, defaultPlugins as a, OperationPath as b, clientDefaultConfig as c, $ as d, TypeScriptRenderer as f, keywords as g, reserved as h, initConfigs as i, printCrashReport as j, logCrashReport as k, clientDefaultMeta as l, ctx as m, buildGraph as n, clientPluginHandler as o, TsDslContext as p, getSpec as r, generateClientBundle as s, parseOpenApiSpec as t, toCase as u, TsDsl as v, postprocessOutput as w, OperationStrategy as x, getClientPlugin as y };
21448
- //# sourceMappingURL=openApi-PX3rDrOF.mjs.map
21489
+ //# sourceMappingURL=openApi-Ci-wjGgv.mjs.map