@hey-api/openapi-ts 0.90.7 → 0.90.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -8
- package/dist/index.cjs +9 -3
- package/dist/index.d.cts +5 -4
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +2 -2
- package/dist/internal.cjs +2 -2
- package/dist/internal.d.cts +16 -9
- package/dist/internal.d.mts +16 -9
- package/dist/internal.mjs +2 -2
- package/dist/{openApi-BZ7m5ia5.cjs → openApi-BaGlRfMs.cjs} +249 -211
- package/dist/openApi-BaGlRfMs.cjs.map +1 -0
- package/dist/{openApi-B6J9qPwL.mjs → openApi-CE_z8tev.mjs} +227 -189
- package/dist/openApi-CE_z8tev.mjs.map +1 -0
- package/dist/run.cjs +40 -48
- package/dist/run.cjs.map +1 -1
- package/dist/run.mjs +41 -49
- package/dist/run.mjs.map +1 -1
- package/dist/{src-BkOFTEi8.cjs → src-CO2t0IHm.cjs} +32 -172
- package/dist/src-CO2t0IHm.cjs.map +1 -0
- package/dist/{src-BehyjtZ7.mjs → src-DqFHTOrs.mjs} +34 -168
- package/dist/src-DqFHTOrs.mjs.map +1 -0
- package/dist/{config-CU3acGju.d.mts → types-CQTciSfa.d.mts} +4495 -4498
- package/dist/{config-BF7XAWuG.d.cts → types-WLqvV8HC.d.cts} +4495 -4498
- package/package.json +3 -4
- package/dist/openApi-B6J9qPwL.mjs.map +0 -1
- package/dist/openApi-BZ7m5ia5.cjs.map +0 -1
- package/dist/src-BehyjtZ7.mjs.map +0 -1
- package/dist/src-BkOFTEi8.cjs.map +0 -1
package/dist/run.cjs
CHANGED
|
@@ -1,65 +1,57 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
const require_openApi = require('./openApi-
|
|
5
|
-
const require_src = require('./src-
|
|
4
|
+
const require_openApi = require('./openApi-BaGlRfMs.cjs');
|
|
5
|
+
const require_src = require('./src-CO2t0IHm.cjs');
|
|
6
6
|
let commander = require("commander");
|
|
7
7
|
|
|
8
8
|
//#region package.json
|
|
9
|
-
var version = "0.90.
|
|
9
|
+
var version = "0.90.9";
|
|
10
10
|
var bin = { "openapi-ts": "./bin/run.js" };
|
|
11
11
|
|
|
12
12
|
//#endregion
|
|
13
|
-
//#region src/cli.ts
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
13
|
+
//#region src/cli/adapter.ts
|
|
14
|
+
const cliToConfig = (cli) => {
|
|
15
|
+
const config = {};
|
|
16
|
+
if (cli.input) config.input = cli.input;
|
|
17
|
+
if (cli.output) config.output = cli.output;
|
|
18
|
+
if (cli.file) config.configFile = cli.file;
|
|
19
|
+
if (cli.dryRun !== void 0) config.dryRun = cli.dryRun;
|
|
20
|
+
const plugins = [];
|
|
21
|
+
if (cli.plugins instanceof Array && cli.plugins.length > 0) plugins.push(...cli.plugins);
|
|
22
|
+
if (cli.client) plugins.push(cli.client);
|
|
23
|
+
if (plugins.length > 0) config.plugins = plugins;
|
|
24
|
+
if (cli.debug || cli.silent || cli.logs || cli.logFile !== void 0) config.logs = {
|
|
25
|
+
...cli.logs && { path: cli.logs },
|
|
26
|
+
...cli.debug && { level: "debug" },
|
|
27
|
+
...cli.silent && { level: "silent" },
|
|
28
|
+
...cli.logFile !== void 0 && { file: cli.logFile }
|
|
29
|
+
};
|
|
30
|
+
if (cli.watch !== void 0) if (typeof cli.watch === "string") config.watch = Number.parseInt(cli.watch, 10);
|
|
31
|
+
else config.watch = cli.watch;
|
|
32
|
+
return config;
|
|
18
33
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return obj;
|
|
29
|
-
};
|
|
30
|
-
const runCli = async () => {
|
|
31
|
-
const params = new commander.Command().name(Object.keys(bin)[0]).usage("[options]").version(version).option("-c, --client <value>", "HTTP client to generate").option("-d, --debug", "Set log level to debug").option("--dry-run [value]", "Skip writing files to disk?").option("-f, --file [value]", "Path to the config file").option("-i, --input <value>", "OpenAPI specification (path, url, or string content)").option("-l, --logs [value]", "Logs folder").option("-o, --output <value>", "Output folder").option("-p, --plugins [value...]", "List of plugins you'd like to use").option("-s, --silent", "Set log level to silent").option("--no-log-file", "Disable writing a log file. Works like --silent but without suppressing console output").option("-w, --watch [value]", "Regenerate the client when the input file changes?").parse(process.argv).opts();
|
|
32
|
-
let userConfig;
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/cli/index.ts
|
|
37
|
+
const binName = Object.keys(bin)[0];
|
|
38
|
+
const program = new commander.Command().name(binName).description("Generate TypeScript code from OpenAPI specifications").version(version);
|
|
39
|
+
program.option("-i, --input <path...>", "OpenAPI specification (path, URL, or string)").option("-o, --output <path...>", "Output folder(s)").option("-c, --client <name>", "HTTP client to generate").option("-p, --plugins [names...]", "Plugins to use").option("-f, --file <path>", "Path to config file").option("-d, --debug", "Enable debug logging").option("-s, --silent", "Suppress all output").option("-l, --logs <path>", "Logs folder path").option("--no-log-file", "Disable log file output").option("--dry-run", "Skip writing files").option("-w, --watch [interval]", "Watch for changes").action(async (options) => {
|
|
40
|
+
if (!(await require_src.createClient(cliToConfig(options)))[0]?.config.input.some((input) => input.watch?.enabled)) process.exit(0);
|
|
41
|
+
});
|
|
42
|
+
async function runCli() {
|
|
33
43
|
try {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
else if (params.plugins) userConfig.plugins = params.plugins;
|
|
41
|
-
else if (userConfig.client) userConfig.plugins = ["@hey-api/typescript", "@hey-api/sdk"];
|
|
42
|
-
if (userConfig.client) {
|
|
43
|
-
userConfig.plugins.push(userConfig.client);
|
|
44
|
-
delete userConfig.client;
|
|
44
|
+
await program.parseAsync(process.argv);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (error instanceof commander.CommanderError && "code" in error) {
|
|
47
|
+
if (error.code === "commander.optionMissingArgument") console.error(`\nMissing required argument. Run '${binName} --help' for usage.\n`);
|
|
48
|
+
else if (error.code === "commander.unknownOption") console.error(`\nUnknown option. Run '${binName} --help' for available options.\n`);
|
|
49
|
+
process.exit(error.exitCode);
|
|
45
50
|
}
|
|
46
|
-
|
|
47
|
-
if (userConfig.debug) {
|
|
48
|
-
userConfig.logs.level = "debug";
|
|
49
|
-
delete userConfig.debug;
|
|
50
|
-
} else if (userConfig.silent) {
|
|
51
|
-
userConfig.logs.level = "silent";
|
|
52
|
-
delete userConfig.silent;
|
|
53
|
-
}
|
|
54
|
-
userConfig.logs.file = userConfig.logFile;
|
|
55
|
-
delete userConfig.logFile;
|
|
56
|
-
if (typeof params.watch === "string") userConfig.watch = Number.parseInt(params.watch, 10);
|
|
57
|
-
if (!Object.keys(userConfig.logs).length) delete userConfig.logs;
|
|
58
|
-
if (!(await require_src.createClient(userConfig))[0]?.config.input.some((input) => input.watch && input.watch.enabled)) process.exit(0);
|
|
59
|
-
} catch {
|
|
51
|
+
console.error("Unexpected error:", error);
|
|
60
52
|
process.exit(1);
|
|
61
53
|
}
|
|
62
|
-
}
|
|
54
|
+
}
|
|
63
55
|
|
|
64
56
|
//#endregion
|
|
65
57
|
//#region src/run.ts
|
package/dist/run.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.cjs","names":["
|
|
1
|
+
{"version":3,"file":"run.cjs","names":["config: Partial<UserConfig>","plugins: ToArray<UserConfig['plugins']>","pkg.bin","Command","pkg.version","createClient","CommanderError"],"sources":["../package.json","../src/cli/adapter.ts","../src/cli/index.ts","../src/run.ts"],"sourcesContent":["","import type { ToArray } from '@hey-api/types';\n\nimport type { UserConfig } from '~/config/types';\n\nimport type { CliOptions } from './schema';\n\nexport const cliToConfig = (cli: CliOptions): Partial<UserConfig> => {\n const config: Partial<UserConfig> = {};\n\n if (cli.input) config.input = cli.input;\n if (cli.output) config.output = cli.output;\n if (cli.file) config.configFile = cli.file;\n if (cli.dryRun !== undefined) config.dryRun = cli.dryRun;\n\n const plugins: ToArray<UserConfig['plugins']> = [];\n if (cli.plugins instanceof Array && cli.plugins.length > 0) {\n plugins.push(...cli.plugins);\n }\n if (cli.client) plugins.push(cli.client);\n if (plugins.length > 0) config.plugins = plugins;\n\n if (cli.debug || cli.silent || cli.logs || cli.logFile !== undefined) {\n config.logs = {\n ...(cli.logs && { path: cli.logs }),\n ...(cli.debug && { level: 'debug' as const }),\n ...(cli.silent && { level: 'silent' as const }),\n ...(cli.logFile !== undefined && { file: cli.logFile }),\n };\n }\n\n if (cli.watch !== undefined) {\n if (typeof cli.watch === 'string') {\n config.watch = Number.parseInt(cli.watch, 10);\n } else {\n config.watch = cli.watch;\n }\n }\n\n return config;\n};\n","import { Command, CommanderError } from 'commander';\n\nimport { createClient } from '~/index';\n\nimport pkg from '../../package.json' assert { type: 'json' };\nimport { cliToConfig } from './adapter';\n\nconst binName = Object.keys(pkg.bin)[0]!;\n\nconst program = new Command()\n .name(binName)\n .description('Generate TypeScript code from OpenAPI specifications')\n .version(pkg.version);\n\nprogram\n .option(\n '-i, --input <path...>',\n 'OpenAPI specification (path, URL, or string)',\n )\n .option('-o, --output <path...>', 'Output folder(s)')\n .option('-c, --client <name>', 'HTTP client to generate')\n .option('-p, --plugins [names...]', 'Plugins to use')\n .option('-f, --file <path>', 'Path to config file')\n .option('-d, --debug', 'Enable debug logging')\n .option('-s, --silent', 'Suppress all output')\n .option('-l, --logs <path>', 'Logs folder path')\n .option('--no-log-file', 'Disable log file output')\n .option('--dry-run', 'Skip writing files')\n .option('-w, --watch [interval]', 'Watch for changes')\n .action(async (options) => {\n const config = cliToConfig(options);\n\n const context = await createClient(\n config as Parameters<typeof createClient>[0],\n );\n\n const hasActiveWatch = context[0]?.config.input.some(\n (input) => input.watch?.enabled,\n );\n\n if (!hasActiveWatch) {\n process.exit(0);\n }\n });\n\nexport async function runCli(): Promise<void> {\n try {\n await program.parseAsync(process.argv);\n } catch (error) {\n if (error instanceof CommanderError && 'code' in error) {\n if (error.code === 'commander.optionMissingArgument') {\n console.error(\n `\\nMissing required argument. Run '${binName} --help' for usage.\\n`,\n );\n } else if (error.code === 'commander.unknownOption') {\n console.error(\n `\\nUnknown option. Run '${binName} --help' for available options.\\n`,\n );\n }\n\n process.exit(error.exitCode);\n }\n\n console.error('Unexpected error:', error);\n process.exit(1);\n }\n}\n","#!/usr/bin/env node\n\nimport { runCli } from '~/cli';\n\nrunCli();\n"],"mappings":";;;;;;;;;;;;;;ACMA,MAAa,eAAe,QAAyC;CACnE,MAAMA,SAA8B,EAAE;AAEtC,KAAI,IAAI,MAAO,QAAO,QAAQ,IAAI;AAClC,KAAI,IAAI,OAAQ,QAAO,SAAS,IAAI;AACpC,KAAI,IAAI,KAAM,QAAO,aAAa,IAAI;AACtC,KAAI,IAAI,WAAW,OAAW,QAAO,SAAS,IAAI;CAElD,MAAMC,UAA0C,EAAE;AAClD,KAAI,IAAI,mBAAmB,SAAS,IAAI,QAAQ,SAAS,EACvD,SAAQ,KAAK,GAAG,IAAI,QAAQ;AAE9B,KAAI,IAAI,OAAQ,SAAQ,KAAK,IAAI,OAAO;AACxC,KAAI,QAAQ,SAAS,EAAG,QAAO,UAAU;AAEzC,KAAI,IAAI,SAAS,IAAI,UAAU,IAAI,QAAQ,IAAI,YAAY,OACzD,QAAO,OAAO;EACZ,GAAI,IAAI,QAAQ,EAAE,MAAM,IAAI,MAAM;EAClC,GAAI,IAAI,SAAS,EAAE,OAAO,SAAkB;EAC5C,GAAI,IAAI,UAAU,EAAE,OAAO,UAAmB;EAC9C,GAAI,IAAI,YAAY,UAAa,EAAE,MAAM,IAAI,SAAS;EACvD;AAGH,KAAI,IAAI,UAAU,OAChB,KAAI,OAAO,IAAI,UAAU,SACvB,QAAO,QAAQ,OAAO,SAAS,IAAI,OAAO,GAAG;KAE7C,QAAO,QAAQ,IAAI;AAIvB,QAAO;;;;;AC/BT,MAAM,UAAU,OAAO,KAAKC,IAAQ,CAAC;AAErC,MAAM,UAAU,IAAIC,mBAAS,CAC1B,KAAK,QAAQ,CACb,YAAY,uDAAuD,CACnE,QAAQC,QAAY;AAEvB,QACG,OACC,yBACA,+CACD,CACA,OAAO,0BAA0B,mBAAmB,CACpD,OAAO,uBAAuB,0BAA0B,CACxD,OAAO,4BAA4B,iBAAiB,CACpD,OAAO,qBAAqB,sBAAsB,CAClD,OAAO,eAAe,uBAAuB,CAC7C,OAAO,gBAAgB,sBAAsB,CAC7C,OAAO,qBAAqB,mBAAmB,CAC/C,OAAO,iBAAiB,0BAA0B,CAClD,OAAO,aAAa,qBAAqB,CACzC,OAAO,0BAA0B,oBAAoB,CACrD,OAAO,OAAO,YAAY;AAWzB,KAAI,EARY,MAAMC,yBAFP,YAAY,QAAQ,CAIlC,EAE8B,IAAI,OAAO,MAAM,MAC7C,UAAU,MAAM,OAAO,QACzB,CAGC,SAAQ,KAAK,EAAE;EAEjB;AAEJ,eAAsB,SAAwB;AAC5C,KAAI;AACF,QAAM,QAAQ,WAAW,QAAQ,KAAK;UAC/B,OAAO;AACd,MAAI,iBAAiBC,4BAAkB,UAAU,OAAO;AACtD,OAAI,MAAM,SAAS,kCACjB,SAAQ,MACN,qCAAqC,QAAQ,uBAC9C;YACQ,MAAM,SAAS,0BACxB,SAAQ,MACN,0BAA0B,QAAQ,mCACnC;AAGH,WAAQ,KAAK,MAAM,SAAS;;AAG9B,UAAQ,MAAM,qBAAqB,MAAM;AACzC,UAAQ,KAAK,EAAE;;;;;;AC5DnB,QAAQ"}
|
package/dist/run.mjs
CHANGED
|
@@ -1,65 +1,57 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
import "./openApi-
|
|
5
|
-
import {
|
|
6
|
-
import { Command } from "commander";
|
|
4
|
+
import "./openApi-CE_z8tev.mjs";
|
|
5
|
+
import { i as createClient } from "./src-DqFHTOrs.mjs";
|
|
6
|
+
import { Command, CommanderError } from "commander";
|
|
7
7
|
|
|
8
8
|
//#region package.json
|
|
9
|
-
var version = "0.90.
|
|
9
|
+
var version = "0.90.9";
|
|
10
10
|
var bin = { "openapi-ts": "./bin/run.js" };
|
|
11
11
|
|
|
12
12
|
//#endregion
|
|
13
|
-
//#region src/cli.ts
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
13
|
+
//#region src/cli/adapter.ts
|
|
14
|
+
const cliToConfig = (cli) => {
|
|
15
|
+
const config = {};
|
|
16
|
+
if (cli.input) config.input = cli.input;
|
|
17
|
+
if (cli.output) config.output = cli.output;
|
|
18
|
+
if (cli.file) config.configFile = cli.file;
|
|
19
|
+
if (cli.dryRun !== void 0) config.dryRun = cli.dryRun;
|
|
20
|
+
const plugins = [];
|
|
21
|
+
if (cli.plugins instanceof Array && cli.plugins.length > 0) plugins.push(...cli.plugins);
|
|
22
|
+
if (cli.client) plugins.push(cli.client);
|
|
23
|
+
if (plugins.length > 0) config.plugins = plugins;
|
|
24
|
+
if (cli.debug || cli.silent || cli.logs || cli.logFile !== void 0) config.logs = {
|
|
25
|
+
...cli.logs && { path: cli.logs },
|
|
26
|
+
...cli.debug && { level: "debug" },
|
|
27
|
+
...cli.silent && { level: "silent" },
|
|
28
|
+
...cli.logFile !== void 0 && { file: cli.logFile }
|
|
29
|
+
};
|
|
30
|
+
if (cli.watch !== void 0) if (typeof cli.watch === "string") config.watch = Number.parseInt(cli.watch, 10);
|
|
31
|
+
else config.watch = cli.watch;
|
|
32
|
+
return config;
|
|
18
33
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return obj;
|
|
29
|
-
};
|
|
30
|
-
const runCli = async () => {
|
|
31
|
-
const params = new Command().name(Object.keys(bin)[0]).usage("[options]").version(version).option("-c, --client <value>", "HTTP client to generate").option("-d, --debug", "Set log level to debug").option("--dry-run [value]", "Skip writing files to disk?").option("-f, --file [value]", "Path to the config file").option("-i, --input <value>", "OpenAPI specification (path, url, or string content)").option("-l, --logs [value]", "Logs folder").option("-o, --output <value>", "Output folder").option("-p, --plugins [value...]", "List of plugins you'd like to use").option("-s, --silent", "Set log level to silent").option("--no-log-file", "Disable writing a log file. Works like --silent but without suppressing console output").option("-w, --watch [value]", "Regenerate the client when the input file changes?").parse(process.argv).opts();
|
|
32
|
-
let userConfig;
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/cli/index.ts
|
|
37
|
+
const binName = Object.keys(bin)[0];
|
|
38
|
+
const program = new Command().name(binName).description("Generate TypeScript code from OpenAPI specifications").version(version);
|
|
39
|
+
program.option("-i, --input <path...>", "OpenAPI specification (path, URL, or string)").option("-o, --output <path...>", "Output folder(s)").option("-c, --client <name>", "HTTP client to generate").option("-p, --plugins [names...]", "Plugins to use").option("-f, --file <path>", "Path to config file").option("-d, --debug", "Enable debug logging").option("-s, --silent", "Suppress all output").option("-l, --logs <path>", "Logs folder path").option("--no-log-file", "Disable log file output").option("--dry-run", "Skip writing files").option("-w, --watch [interval]", "Watch for changes").action(async (options) => {
|
|
40
|
+
if (!(await createClient(cliToConfig(options)))[0]?.config.input.some((input) => input.watch?.enabled)) process.exit(0);
|
|
41
|
+
});
|
|
42
|
+
async function runCli() {
|
|
33
43
|
try {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
else if (params.plugins) userConfig.plugins = params.plugins;
|
|
41
|
-
else if (userConfig.client) userConfig.plugins = ["@hey-api/typescript", "@hey-api/sdk"];
|
|
42
|
-
if (userConfig.client) {
|
|
43
|
-
userConfig.plugins.push(userConfig.client);
|
|
44
|
-
delete userConfig.client;
|
|
44
|
+
await program.parseAsync(process.argv);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (error instanceof CommanderError && "code" in error) {
|
|
47
|
+
if (error.code === "commander.optionMissingArgument") console.error(`\nMissing required argument. Run '${binName} --help' for usage.\n`);
|
|
48
|
+
else if (error.code === "commander.unknownOption") console.error(`\nUnknown option. Run '${binName} --help' for available options.\n`);
|
|
49
|
+
process.exit(error.exitCode);
|
|
45
50
|
}
|
|
46
|
-
|
|
47
|
-
if (userConfig.debug) {
|
|
48
|
-
userConfig.logs.level = "debug";
|
|
49
|
-
delete userConfig.debug;
|
|
50
|
-
} else if (userConfig.silent) {
|
|
51
|
-
userConfig.logs.level = "silent";
|
|
52
|
-
delete userConfig.silent;
|
|
53
|
-
}
|
|
54
|
-
userConfig.logs.file = userConfig.logFile;
|
|
55
|
-
delete userConfig.logFile;
|
|
56
|
-
if (typeof params.watch === "string") userConfig.watch = Number.parseInt(params.watch, 10);
|
|
57
|
-
if (!Object.keys(userConfig.logs).length) delete userConfig.logs;
|
|
58
|
-
if (!(await createClient(userConfig))[0]?.config.input.some((input) => input.watch && input.watch.enabled)) process.exit(0);
|
|
59
|
-
} catch {
|
|
51
|
+
console.error("Unexpected error:", error);
|
|
60
52
|
process.exit(1);
|
|
61
53
|
}
|
|
62
|
-
}
|
|
54
|
+
}
|
|
63
55
|
|
|
64
56
|
//#endregion
|
|
65
57
|
//#region src/run.ts
|
package/dist/run.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.mjs","names":["pkg.bin","pkg.version"
|
|
1
|
+
{"version":3,"file":"run.mjs","names":["config: Partial<UserConfig>","plugins: ToArray<UserConfig['plugins']>","pkg.bin","pkg.version"],"sources":["../package.json","../src/cli/adapter.ts","../src/cli/index.ts","../src/run.ts"],"sourcesContent":["","import type { ToArray } from '@hey-api/types';\n\nimport type { UserConfig } from '~/config/types';\n\nimport type { CliOptions } from './schema';\n\nexport const cliToConfig = (cli: CliOptions): Partial<UserConfig> => {\n const config: Partial<UserConfig> = {};\n\n if (cli.input) config.input = cli.input;\n if (cli.output) config.output = cli.output;\n if (cli.file) config.configFile = cli.file;\n if (cli.dryRun !== undefined) config.dryRun = cli.dryRun;\n\n const plugins: ToArray<UserConfig['plugins']> = [];\n if (cli.plugins instanceof Array && cli.plugins.length > 0) {\n plugins.push(...cli.plugins);\n }\n if (cli.client) plugins.push(cli.client);\n if (plugins.length > 0) config.plugins = plugins;\n\n if (cli.debug || cli.silent || cli.logs || cli.logFile !== undefined) {\n config.logs = {\n ...(cli.logs && { path: cli.logs }),\n ...(cli.debug && { level: 'debug' as const }),\n ...(cli.silent && { level: 'silent' as const }),\n ...(cli.logFile !== undefined && { file: cli.logFile }),\n };\n }\n\n if (cli.watch !== undefined) {\n if (typeof cli.watch === 'string') {\n config.watch = Number.parseInt(cli.watch, 10);\n } else {\n config.watch = cli.watch;\n }\n }\n\n return config;\n};\n","import { Command, CommanderError } from 'commander';\n\nimport { createClient } from '~/index';\n\nimport pkg from '../../package.json' assert { type: 'json' };\nimport { cliToConfig } from './adapter';\n\nconst binName = Object.keys(pkg.bin)[0]!;\n\nconst program = new Command()\n .name(binName)\n .description('Generate TypeScript code from OpenAPI specifications')\n .version(pkg.version);\n\nprogram\n .option(\n '-i, --input <path...>',\n 'OpenAPI specification (path, URL, or string)',\n )\n .option('-o, --output <path...>', 'Output folder(s)')\n .option('-c, --client <name>', 'HTTP client to generate')\n .option('-p, --plugins [names...]', 'Plugins to use')\n .option('-f, --file <path>', 'Path to config file')\n .option('-d, --debug', 'Enable debug logging')\n .option('-s, --silent', 'Suppress all output')\n .option('-l, --logs <path>', 'Logs folder path')\n .option('--no-log-file', 'Disable log file output')\n .option('--dry-run', 'Skip writing files')\n .option('-w, --watch [interval]', 'Watch for changes')\n .action(async (options) => {\n const config = cliToConfig(options);\n\n const context = await createClient(\n config as Parameters<typeof createClient>[0],\n );\n\n const hasActiveWatch = context[0]?.config.input.some(\n (input) => input.watch?.enabled,\n );\n\n if (!hasActiveWatch) {\n process.exit(0);\n }\n });\n\nexport async function runCli(): Promise<void> {\n try {\n await program.parseAsync(process.argv);\n } catch (error) {\n if (error instanceof CommanderError && 'code' in error) {\n if (error.code === 'commander.optionMissingArgument') {\n console.error(\n `\\nMissing required argument. Run '${binName} --help' for usage.\\n`,\n );\n } else if (error.code === 'commander.unknownOption') {\n console.error(\n `\\nUnknown option. Run '${binName} --help' for available options.\\n`,\n );\n }\n\n process.exit(error.exitCode);\n }\n\n console.error('Unexpected error:', error);\n process.exit(1);\n }\n}\n","#!/usr/bin/env node\n\nimport { runCli } from '~/cli';\n\nrunCli();\n"],"mappings":";;;;;;;;;;;;;;ACMA,MAAa,eAAe,QAAyC;CACnE,MAAMA,SAA8B,EAAE;AAEtC,KAAI,IAAI,MAAO,QAAO,QAAQ,IAAI;AAClC,KAAI,IAAI,OAAQ,QAAO,SAAS,IAAI;AACpC,KAAI,IAAI,KAAM,QAAO,aAAa,IAAI;AACtC,KAAI,IAAI,WAAW,OAAW,QAAO,SAAS,IAAI;CAElD,MAAMC,UAA0C,EAAE;AAClD,KAAI,IAAI,mBAAmB,SAAS,IAAI,QAAQ,SAAS,EACvD,SAAQ,KAAK,GAAG,IAAI,QAAQ;AAE9B,KAAI,IAAI,OAAQ,SAAQ,KAAK,IAAI,OAAO;AACxC,KAAI,QAAQ,SAAS,EAAG,QAAO,UAAU;AAEzC,KAAI,IAAI,SAAS,IAAI,UAAU,IAAI,QAAQ,IAAI,YAAY,OACzD,QAAO,OAAO;EACZ,GAAI,IAAI,QAAQ,EAAE,MAAM,IAAI,MAAM;EAClC,GAAI,IAAI,SAAS,EAAE,OAAO,SAAkB;EAC5C,GAAI,IAAI,UAAU,EAAE,OAAO,UAAmB;EAC9C,GAAI,IAAI,YAAY,UAAa,EAAE,MAAM,IAAI,SAAS;EACvD;AAGH,KAAI,IAAI,UAAU,OAChB,KAAI,OAAO,IAAI,UAAU,SACvB,QAAO,QAAQ,OAAO,SAAS,IAAI,OAAO,GAAG;KAE7C,QAAO,QAAQ,IAAI;AAIvB,QAAO;;;;;AC/BT,MAAM,UAAU,OAAO,KAAKC,IAAQ,CAAC;AAErC,MAAM,UAAU,IAAI,SAAS,CAC1B,KAAK,QAAQ,CACb,YAAY,uDAAuD,CACnE,QAAQC,QAAY;AAEvB,QACG,OACC,yBACA,+CACD,CACA,OAAO,0BAA0B,mBAAmB,CACpD,OAAO,uBAAuB,0BAA0B,CACxD,OAAO,4BAA4B,iBAAiB,CACpD,OAAO,qBAAqB,sBAAsB,CAClD,OAAO,eAAe,uBAAuB,CAC7C,OAAO,gBAAgB,sBAAsB,CAC7C,OAAO,qBAAqB,mBAAmB,CAC/C,OAAO,iBAAiB,0BAA0B,CAClD,OAAO,aAAa,qBAAqB,CACzC,OAAO,0BAA0B,oBAAoB,CACrD,OAAO,OAAO,YAAY;AAWzB,KAAI,EARY,MAAM,aAFP,YAAY,QAAQ,CAIlC,EAE8B,IAAI,OAAO,MAAM,MAC7C,UAAU,MAAM,OAAO,QACzB,CAGC,SAAQ,KAAK,EAAE;EAEjB;AAEJ,eAAsB,SAAwB;AAC5C,KAAI;AACF,QAAM,QAAQ,WAAW,QAAQ,KAAK;UAC/B,OAAO;AACd,MAAI,iBAAiB,kBAAkB,UAAU,OAAO;AACtD,OAAI,MAAM,SAAS,kCACjB,SAAQ,MACN,qCAAqC,QAAQ,uBAC9C;YACQ,MAAM,SAAS,0BACxB,SAAQ,MACN,0BAA0B,QAAQ,mCACnC;AAGH,WAAQ,KAAK,MAAM,SAAS;;AAG9B,UAAQ,MAAM,qBAAqB,MAAM;AACzC,UAAQ,KAAK,EAAE;;;;;;AC5DnB,QAAQ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
const require_openApi = require('./openApi-
|
|
2
|
+
const require_openApi = require('./openApi-BaGlRfMs.cjs');
|
|
3
3
|
let _hey_api_codegen_core = require("@hey-api/codegen-core");
|
|
4
4
|
let ansi_colors = require("ansi-colors");
|
|
5
5
|
ansi_colors = require_openApi.__toESM(ansi_colors);
|
|
@@ -356,152 +356,16 @@ const asciiToLines = (ascii, options) => {
|
|
|
356
356
|
maxLineLength
|
|
357
357
|
};
|
|
358
358
|
};
|
|
359
|
-
function printCliIntro() {
|
|
359
|
+
function printCliIntro(showLogo = false) {
|
|
360
360
|
const packageJson = require_openApi.loadPackageJson();
|
|
361
|
-
|
|
362
|
-
|
|
361
|
+
if (showLogo) {
|
|
362
|
+
const text = asciiToLines(textAscii, { padding: 1 });
|
|
363
|
+
for (const line of text.lines) console.log(ansi_colors.default.cyan(line));
|
|
364
|
+
}
|
|
363
365
|
console.log(ansi_colors.default.gray(`${packageJson.name} v${packageJson.version}`));
|
|
364
366
|
console.log("");
|
|
365
367
|
}
|
|
366
368
|
|
|
367
|
-
//#endregion
|
|
368
|
-
//#region src/utils/logger.ts
|
|
369
|
-
let loggerCounter = 0;
|
|
370
|
-
const nameToId = (name) => `${name}-${loggerCounter++}`;
|
|
371
|
-
const idEnd = (id) => `${id}-end`;
|
|
372
|
-
const idLength = (id) => `${id}-length`;
|
|
373
|
-
const idStart = (id) => `${id}-start`;
|
|
374
|
-
const getSeverity = (duration, percentage) => {
|
|
375
|
-
if (duration > 200) return {
|
|
376
|
-
color: ansi_colors.default.red,
|
|
377
|
-
type: "duration"
|
|
378
|
-
};
|
|
379
|
-
if (percentage > 30) return {
|
|
380
|
-
color: ansi_colors.default.red,
|
|
381
|
-
type: "percentage"
|
|
382
|
-
};
|
|
383
|
-
if (duration > 50) return {
|
|
384
|
-
color: ansi_colors.default.yellow,
|
|
385
|
-
type: "duration"
|
|
386
|
-
};
|
|
387
|
-
if (percentage > 10) return {
|
|
388
|
-
color: ansi_colors.default.yellow,
|
|
389
|
-
type: "percentage"
|
|
390
|
-
};
|
|
391
|
-
};
|
|
392
|
-
var Logger = class {
|
|
393
|
-
events = [];
|
|
394
|
-
end(result) {
|
|
395
|
-
let event;
|
|
396
|
-
let events = this.events;
|
|
397
|
-
for (const index of result.position) {
|
|
398
|
-
event = events[index];
|
|
399
|
-
if (event?.events) events = event.events;
|
|
400
|
-
}
|
|
401
|
-
if (event && !event.end) event.end = performance.mark(idEnd(event.id));
|
|
402
|
-
}
|
|
403
|
-
/**
|
|
404
|
-
* Recursively end all unended events in the event tree.
|
|
405
|
-
* This ensures all events have end marks before measuring.
|
|
406
|
-
*/
|
|
407
|
-
endAllEvents(events) {
|
|
408
|
-
for (const event of events) {
|
|
409
|
-
if (!event.end) event.end = performance.mark(idEnd(event.id));
|
|
410
|
-
if (event.events.length > 0) this.endAllEvents(event.events);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
report(print = true) {
|
|
414
|
-
const firstEvent = this.events[0];
|
|
415
|
-
if (!firstEvent) return;
|
|
416
|
-
this.endAllEvents(this.events);
|
|
417
|
-
const lastEvent = this.events[this.events.length - 1];
|
|
418
|
-
const name = "root";
|
|
419
|
-
const id = nameToId(name);
|
|
420
|
-
try {
|
|
421
|
-
const measure = performance.measure(idLength(id), idStart(firstEvent.id), idEnd(lastEvent.id));
|
|
422
|
-
if (print) this.reportEvent({
|
|
423
|
-
end: lastEvent.end,
|
|
424
|
-
events: this.events,
|
|
425
|
-
id,
|
|
426
|
-
indent: 0,
|
|
427
|
-
measure,
|
|
428
|
-
name,
|
|
429
|
-
start: firstEvent.start
|
|
430
|
-
});
|
|
431
|
-
return measure;
|
|
432
|
-
} catch {
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
reportEvent({ indent, ...parent }) {
|
|
437
|
-
const color = !indent ? ansi_colors.default.cyan : ansi_colors.default.gray;
|
|
438
|
-
const lastIndex = parent.events.length - 1;
|
|
439
|
-
parent.events.forEach((event, index) => {
|
|
440
|
-
try {
|
|
441
|
-
const measure = performance.measure(idLength(event.id), idStart(event.id), idEnd(event.id));
|
|
442
|
-
const duration = Math.ceil(measure.duration * 100) / 100;
|
|
443
|
-
const percentage = Math.ceil(measure.duration / parent.measure.duration * 100 * 100) / 100;
|
|
444
|
-
const severity = indent ? getSeverity(duration, percentage) : void 0;
|
|
445
|
-
let durationLabel = `${duration.toFixed(2).padStart(8)}ms`;
|
|
446
|
-
if (severity?.type === "duration") durationLabel = severity.color(durationLabel);
|
|
447
|
-
const branch = index === lastIndex ? "└─ " : "├─ ";
|
|
448
|
-
const prefix = !indent ? "" : "│ ".repeat(indent - 1) + branch;
|
|
449
|
-
const maxLength = 38 - prefix.length;
|
|
450
|
-
const percentageBranch = !indent ? "" : "↳ ";
|
|
451
|
-
let percentageLabel = `${indent ? " ".repeat(indent - 1) + percentageBranch : ""}${percentage.toFixed(2)}%`;
|
|
452
|
-
if (severity?.type === "percentage") percentageLabel = severity.color(percentageLabel);
|
|
453
|
-
const jobPrefix = ansi_colors.default.gray("[root] ");
|
|
454
|
-
console.log(`${jobPrefix}${ansi_colors.default.gray(prefix)}${color(`${event.name.padEnd(maxLength)} ${durationLabel} (${percentageLabel})`)}`);
|
|
455
|
-
this.reportEvent({
|
|
456
|
-
...event,
|
|
457
|
-
indent: indent + 1,
|
|
458
|
-
measure
|
|
459
|
-
});
|
|
460
|
-
} catch {}
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
start(id) {
|
|
464
|
-
return performance.mark(idStart(id));
|
|
465
|
-
}
|
|
466
|
-
storeEvent({ result, ...event }) {
|
|
467
|
-
const lastEventIndex = event.events.length - 1;
|
|
468
|
-
const lastEvent = event.events[lastEventIndex];
|
|
469
|
-
if (lastEvent && !lastEvent.end) {
|
|
470
|
-
result.position = [...result.position, lastEventIndex];
|
|
471
|
-
this.storeEvent({
|
|
472
|
-
...event,
|
|
473
|
-
events: lastEvent.events,
|
|
474
|
-
result
|
|
475
|
-
});
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
const length = event.events.push({
|
|
479
|
-
...event,
|
|
480
|
-
events: []
|
|
481
|
-
});
|
|
482
|
-
result.position = [...result.position, length - 1];
|
|
483
|
-
}
|
|
484
|
-
timeEvent(name) {
|
|
485
|
-
const id = nameToId(name);
|
|
486
|
-
const start = this.start(id);
|
|
487
|
-
const event = {
|
|
488
|
-
events: this.events,
|
|
489
|
-
id,
|
|
490
|
-
name,
|
|
491
|
-
start
|
|
492
|
-
};
|
|
493
|
-
const result = { position: [] };
|
|
494
|
-
this.storeEvent({
|
|
495
|
-
...event,
|
|
496
|
-
result
|
|
497
|
-
});
|
|
498
|
-
return {
|
|
499
|
-
mark: start,
|
|
500
|
-
timeEnd: () => this.end(result)
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
|
|
505
369
|
//#endregion
|
|
506
370
|
//#region src/generate.ts
|
|
507
371
|
/**
|
|
@@ -509,50 +373,50 @@ var Logger = class {
|
|
|
509
373
|
*
|
|
510
374
|
* @param userConfig User provided {@link UserConfig} configuration(s).
|
|
511
375
|
*/
|
|
512
|
-
|
|
376
|
+
async function createClient(userConfig, logger = new _hey_api_codegen_core.Logger()) {
|
|
513
377
|
const resolvedConfig = typeof userConfig === "function" ? await userConfig() : userConfig;
|
|
514
378
|
const userConfigs = resolvedConfig ? resolvedConfig instanceof Array ? resolvedConfig : [resolvedConfig] : [];
|
|
515
379
|
let rawLogs = userConfigs.find((config) => require_openApi.getLogs(config).level !== "silent")?.logs;
|
|
516
380
|
if (typeof rawLogs === "string") rawLogs = require_openApi.getLogs({ logs: rawLogs });
|
|
517
|
-
let
|
|
381
|
+
let jobs = [];
|
|
518
382
|
try {
|
|
519
383
|
checkNodeVersion();
|
|
520
384
|
const eventCreateClient = logger.timeEvent("createClient");
|
|
521
385
|
const eventConfig = logger.timeEvent("config");
|
|
522
|
-
|
|
386
|
+
const resolved = await require_openApi.resolveJobs({
|
|
523
387
|
logger,
|
|
524
388
|
userConfigs
|
|
525
389
|
});
|
|
526
|
-
|
|
390
|
+
const dependencies = resolved.dependencies;
|
|
391
|
+
jobs = resolved.jobs;
|
|
392
|
+
if (jobs.some((job) => job.config.logs.level !== "silent")) printCliIntro();
|
|
527
393
|
eventConfig.timeEnd();
|
|
528
|
-
const
|
|
394
|
+
const configErrors = jobs.flatMap((job) => job.errors.map((error) => ({
|
|
529
395
|
error,
|
|
530
|
-
jobIndex:
|
|
396
|
+
jobIndex: job.index
|
|
531
397
|
})));
|
|
532
|
-
if (
|
|
533
|
-
const
|
|
398
|
+
if (configErrors.length > 0) throw new require_openApi.ConfigValidationError(configErrors);
|
|
399
|
+
const contexts = (await Promise.all(jobs.map(async (job) => {
|
|
534
400
|
try {
|
|
535
401
|
return await createClient$1({
|
|
536
|
-
config:
|
|
537
|
-
dependencies
|
|
538
|
-
jobIndex:
|
|
402
|
+
config: job.config,
|
|
403
|
+
dependencies,
|
|
404
|
+
jobIndex: job.index,
|
|
539
405
|
logger
|
|
540
406
|
});
|
|
541
407
|
} catch (error) {
|
|
542
408
|
throw new require_openApi.JobError("", {
|
|
543
409
|
error,
|
|
544
|
-
jobIndex:
|
|
410
|
+
jobIndex: job.index
|
|
545
411
|
});
|
|
546
412
|
}
|
|
547
|
-
}))).filter((
|
|
413
|
+
}))).filter((ctx) => ctx !== void 0);
|
|
548
414
|
eventCreateClient.timeEnd();
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
return result;
|
|
415
|
+
logger.report(jobs.some((job) => job.config.logs.level === "debug"));
|
|
416
|
+
return contexts;
|
|
552
417
|
} catch (error) {
|
|
553
|
-
const
|
|
554
|
-
const
|
|
555
|
-
const dryRun = results.some((result) => result.config.dryRun) ?? userConfigs.some((config) => config.dryRun) ?? false;
|
|
418
|
+
const logs = jobs.find((job) => job.config.logs.level !== "silent")?.config.logs ?? jobs[0]?.config.logs ?? rawLogs;
|
|
419
|
+
const dryRun = jobs.some((job) => job.config.dryRun) ?? userConfigs.some((config) => config.dryRun) ?? false;
|
|
556
420
|
const logPath = logs?.file && !dryRun ? require_openApi.logCrashReport(error, logs.path ?? "") : void 0;
|
|
557
421
|
if (!logs || logs.level !== "silent") {
|
|
558
422
|
require_openApi.printCrashReport({
|
|
@@ -561,12 +425,12 @@ const createClient = async (userConfig, logger = new Logger()) => {
|
|
|
561
425
|
});
|
|
562
426
|
if (await require_openApi.shouldReportCrash({
|
|
563
427
|
error,
|
|
564
|
-
isInteractive:
|
|
428
|
+
isInteractive: jobs.some((job) => job.config.interactive) ?? userConfigs.some((config) => config.interactive) ?? false
|
|
565
429
|
})) await require_openApi.openGitHubIssueWithCrashReport(error);
|
|
566
430
|
}
|
|
567
431
|
throw error;
|
|
568
432
|
}
|
|
569
|
-
}
|
|
433
|
+
}
|
|
570
434
|
|
|
571
435
|
//#endregion
|
|
572
436
|
//#region src/utils/exports.ts
|
|
@@ -584,17 +448,13 @@ const utils = {
|
|
|
584
448
|
//#region src/index.ts
|
|
585
449
|
ansi_colors.default.enabled = (0, color_support.default)().hasBasic;
|
|
586
450
|
/**
|
|
587
|
-
* Type helper for
|
|
451
|
+
* Type helper for configuration object, returns {@link MaybeArray<UserConfig>} object(s)
|
|
588
452
|
*/
|
|
589
|
-
|
|
453
|
+
async function defineConfig(config) {
|
|
454
|
+
return typeof config === "function" ? await config() : config;
|
|
455
|
+
}
|
|
590
456
|
|
|
591
457
|
//#endregion
|
|
592
|
-
Object.defineProperty(exports, 'Logger', {
|
|
593
|
-
enumerable: true,
|
|
594
|
-
get: function () {
|
|
595
|
-
return Logger;
|
|
596
|
-
}
|
|
597
|
-
});
|
|
598
458
|
Object.defineProperty(exports, 'createClient', {
|
|
599
459
|
enumerable: true,
|
|
600
460
|
get: function () {
|
|
@@ -613,4 +473,4 @@ Object.defineProperty(exports, 'utils', {
|
|
|
613
473
|
return utils;
|
|
614
474
|
}
|
|
615
475
|
});
|
|
616
|
-
//# sourceMappingURL=src-
|
|
476
|
+
//# sourceMappingURL=src-CO2t0IHm.cjs.map
|