@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import { Project, StructureModel, fromRef, isNode, isRef, isSymbol, log, nodeBrand, ref, refs } from "@hey-api/codegen-core";
|
|
3
|
+
import { Project, StructureModel, detectInteractiveSession, fromRef, isNode, isRef, isSymbol, loadConfigFile, log, nodeBrand, ref, refs } from "@hey-api/codegen-core";
|
|
4
4
|
import colors from "ansi-colors";
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
@@ -432,6 +432,76 @@ const getInput = (userConfig) => {
|
|
|
432
432
|
return inputs;
|
|
433
433
|
};
|
|
434
434
|
|
|
435
|
+
//#endregion
|
|
436
|
+
//#region src/config/expand.ts
|
|
437
|
+
function expandToJobs(configs) {
|
|
438
|
+
const jobs = [];
|
|
439
|
+
let jobIndex = 0;
|
|
440
|
+
for (const config of configs) {
|
|
441
|
+
const inputs = getInput(config);
|
|
442
|
+
const outputs = config.output instanceof Array ? config.output : [config.output];
|
|
443
|
+
if (outputs.length === 1) jobs.push({
|
|
444
|
+
config: {
|
|
445
|
+
...config,
|
|
446
|
+
input: inputs,
|
|
447
|
+
output: outputs[0]
|
|
448
|
+
},
|
|
449
|
+
index: jobIndex++
|
|
450
|
+
});
|
|
451
|
+
else if (outputs.length > 1 && inputs.length !== outputs.length) {
|
|
452
|
+
console.warn(`⚙️ ${colors.yellow("Warning:")} You provided ${colors.cyan(String(inputs.length))} ${colors.cyan(inputs.length === 1 ? "input" : "inputs")} and ${colors.yellow(String(outputs.length))} ${colors.yellow("outputs")}. This will produce identical output in multiple locations. You likely want to provide a single output or the same number of outputs as inputs.`);
|
|
453
|
+
for (const output of outputs) jobs.push({
|
|
454
|
+
config: {
|
|
455
|
+
...config,
|
|
456
|
+
input: inputs,
|
|
457
|
+
output
|
|
458
|
+
},
|
|
459
|
+
index: jobIndex++
|
|
460
|
+
});
|
|
461
|
+
} else if (outputs.length > 1) outputs.forEach((output, index) => {
|
|
462
|
+
jobs.push({
|
|
463
|
+
config: {
|
|
464
|
+
...config,
|
|
465
|
+
input: inputs[index],
|
|
466
|
+
output
|
|
467
|
+
},
|
|
468
|
+
index: jobIndex++
|
|
469
|
+
});
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
return jobs;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
//#endregion
|
|
476
|
+
//#region src/config/packages.ts
|
|
477
|
+
/**
|
|
478
|
+
* Finds and reads the project's package.json file by searching upwards from the config file location,
|
|
479
|
+
* or from process.cwd() if no config file is provided.
|
|
480
|
+
* This ensures we get the correct dependencies even in monorepo setups.
|
|
481
|
+
*
|
|
482
|
+
* @param configFilePath - The path to the configuration file (e.g., openapi-ts.config.ts)
|
|
483
|
+
* @returns An object containing all project dependencies (dependencies, devDependencies, peerDependencies, optionalDependencies)
|
|
484
|
+
*/
|
|
485
|
+
const getProjectDependencies = (configFilePath) => {
|
|
486
|
+
let currentDir = configFilePath ? path.dirname(configFilePath) : process.cwd();
|
|
487
|
+
while (currentDir !== path.dirname(currentDir)) {
|
|
488
|
+
const packageJsonPath = path.join(currentDir, "package.json");
|
|
489
|
+
if (fs.existsSync(packageJsonPath)) try {
|
|
490
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
491
|
+
return {
|
|
492
|
+
...packageJson.dependencies,
|
|
493
|
+
...packageJson.devDependencies,
|
|
494
|
+
...packageJson.peerDependencies,
|
|
495
|
+
...packageJson.optionalDependencies
|
|
496
|
+
};
|
|
497
|
+
} catch {}
|
|
498
|
+
const parentDir = path.dirname(currentDir);
|
|
499
|
+
if (parentDir === currentDir) break;
|
|
500
|
+
currentDir = parentDir;
|
|
501
|
+
}
|
|
502
|
+
return {};
|
|
503
|
+
};
|
|
504
|
+
|
|
435
505
|
//#endregion
|
|
436
506
|
//#region src/config/logs.ts
|
|
437
507
|
const getLogs = (userConfig) => {
|
|
@@ -448,27 +518,6 @@ const getLogs = (userConfig) => {
|
|
|
448
518
|
return logs;
|
|
449
519
|
};
|
|
450
520
|
|
|
451
|
-
//#endregion
|
|
452
|
-
//#region src/config/merge.ts
|
|
453
|
-
const mergeObjects = (objA, objB) => {
|
|
454
|
-
const a = objA || {};
|
|
455
|
-
const b = objB || {};
|
|
456
|
-
return {
|
|
457
|
-
...a,
|
|
458
|
-
...b
|
|
459
|
-
};
|
|
460
|
-
};
|
|
461
|
-
const mergeConfigs = (configA, configB) => {
|
|
462
|
-
const a = configA || {};
|
|
463
|
-
const b = configB || {};
|
|
464
|
-
const merged = {
|
|
465
|
-
...a,
|
|
466
|
-
...b
|
|
467
|
-
};
|
|
468
|
-
if (typeof merged.logs === "object") merged.logs = mergeObjects(a.logs, b.logs);
|
|
469
|
-
return merged;
|
|
470
|
-
};
|
|
471
|
-
|
|
472
521
|
//#endregion
|
|
473
522
|
//#region src/config/utils/config.ts
|
|
474
523
|
const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && typeof value !== "function";
|
|
@@ -1088,36 +1137,6 @@ function normalizePostProcess(input) {
|
|
|
1088
1137
|
});
|
|
1089
1138
|
}
|
|
1090
1139
|
|
|
1091
|
-
//#endregion
|
|
1092
|
-
//#region src/config/packages.ts
|
|
1093
|
-
/**
|
|
1094
|
-
* Finds and reads the project's package.json file by searching upwards from the config file location,
|
|
1095
|
-
* or from process.cwd() if no config file is provided.
|
|
1096
|
-
* This ensures we get the correct dependencies even in monorepo setups.
|
|
1097
|
-
*
|
|
1098
|
-
* @param configFilePath - The path to the configuration file (e.g., openapi-ts.config.ts)
|
|
1099
|
-
* @returns An object containing all project dependencies (dependencies, devDependencies, peerDependencies, optionalDependencies)
|
|
1100
|
-
*/
|
|
1101
|
-
const getProjectDependencies = (configFilePath) => {
|
|
1102
|
-
let currentDir = configFilePath ? path.dirname(configFilePath) : process.cwd();
|
|
1103
|
-
while (currentDir !== path.dirname(currentDir)) {
|
|
1104
|
-
const packageJsonPath = path.join(currentDir, "package.json");
|
|
1105
|
-
if (fs.existsSync(packageJsonPath)) try {
|
|
1106
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
1107
|
-
return {
|
|
1108
|
-
...packageJson.dependencies,
|
|
1109
|
-
...packageJson.devDependencies,
|
|
1110
|
-
...packageJson.peerDependencies,
|
|
1111
|
-
...packageJson.optionalDependencies
|
|
1112
|
-
};
|
|
1113
|
-
} catch {}
|
|
1114
|
-
const parentDir = path.dirname(currentDir);
|
|
1115
|
-
if (parentDir === currentDir) break;
|
|
1116
|
-
currentDir = parentDir;
|
|
1117
|
-
}
|
|
1118
|
-
return {};
|
|
1119
|
-
};
|
|
1120
|
-
|
|
1121
1140
|
//#endregion
|
|
1122
1141
|
//#region src/config/parser.ts
|
|
1123
1142
|
const defaultPaginationKeywords = [
|
|
@@ -3930,16 +3949,21 @@ const Mixed$25 = DocMixin(TsDsl);
|
|
|
3930
3949
|
var ObjectPropTsDsl = class extends Mixed$25 {
|
|
3931
3950
|
"~dsl" = "ObjectPropTsDsl";
|
|
3932
3951
|
_value;
|
|
3933
|
-
|
|
3952
|
+
_meta;
|
|
3934
3953
|
constructor(meta) {
|
|
3935
3954
|
super();
|
|
3936
|
-
this.
|
|
3955
|
+
this._meta = meta;
|
|
3956
|
+
}
|
|
3957
|
+
get kind() {
|
|
3958
|
+
return this._meta.kind;
|
|
3959
|
+
}
|
|
3960
|
+
get propName() {
|
|
3961
|
+
return this._meta.name;
|
|
3937
3962
|
}
|
|
3938
3963
|
analyze(ctx$1) {
|
|
3939
3964
|
super.analyze(ctx$1);
|
|
3940
3965
|
ctx$1.analyze(this._value);
|
|
3941
3966
|
}
|
|
3942
|
-
/** Returns true when all required builder calls are present. */
|
|
3943
3967
|
get isValid() {
|
|
3944
3968
|
return this.missingRequiredCalls().length === 0;
|
|
3945
3969
|
}
|
|
@@ -3951,33 +3975,33 @@ var ObjectPropTsDsl = class extends Mixed$25 {
|
|
|
3951
3975
|
toAst() {
|
|
3952
3976
|
this.$validate();
|
|
3953
3977
|
const node = this.$node(this._value);
|
|
3954
|
-
if (this.
|
|
3978
|
+
if (this._meta.kind === "spread") {
|
|
3955
3979
|
if (ts.isStatement(node)) throw new Error("Invalid spread: object spread must be an expression, not a statement.");
|
|
3956
3980
|
const result$1 = ts.factory.createSpreadAssignment(node);
|
|
3957
3981
|
return this.$docs(result$1);
|
|
3958
3982
|
}
|
|
3959
|
-
if (this.
|
|
3960
|
-
const getter = new GetterTsDsl(this.
|
|
3983
|
+
if (this._meta.kind === "getter") {
|
|
3984
|
+
const getter = new GetterTsDsl(this._meta.name).do(node);
|
|
3961
3985
|
const result$1 = this.$node(getter);
|
|
3962
3986
|
return this.$docs(result$1);
|
|
3963
3987
|
}
|
|
3964
|
-
if (this.
|
|
3965
|
-
const setter = new SetterTsDsl(this.
|
|
3988
|
+
if (this._meta.kind === "setter") {
|
|
3989
|
+
const setter = new SetterTsDsl(this._meta.name).do(node);
|
|
3966
3990
|
const result$1 = this.$node(setter);
|
|
3967
3991
|
return this.$docs(result$1);
|
|
3968
3992
|
}
|
|
3969
|
-
if (ts.isIdentifier(node) && node.text === this.
|
|
3970
|
-
const result$1 = ts.factory.createShorthandPropertyAssignment(this.
|
|
3993
|
+
if (ts.isIdentifier(node) && node.text === this._meta.name) {
|
|
3994
|
+
const result$1 = ts.factory.createShorthandPropertyAssignment(this._meta.name);
|
|
3971
3995
|
return this.$docs(result$1);
|
|
3972
3996
|
}
|
|
3973
3997
|
if (ts.isStatement(node)) throw new Error("Invalid property: object property value must be an expression, not a statement.");
|
|
3974
|
-
const result = ts.factory.createPropertyAssignment(this.
|
|
3998
|
+
const result = ts.factory.createPropertyAssignment(this._meta.kind === "computed" ? ts.factory.createComputedPropertyName(this.$node(new IdTsDsl(this._meta.name))) : this.$node(safePropName(this._meta.name)), node);
|
|
3975
3999
|
return this.$docs(result);
|
|
3976
4000
|
}
|
|
3977
4001
|
$validate() {
|
|
3978
4002
|
const missing = this.missingRequiredCalls();
|
|
3979
4003
|
if (missing.length === 0) return;
|
|
3980
|
-
throw new Error(`Object property${this.
|
|
4004
|
+
throw new Error(`Object property${this._meta.name ? ` "${this._meta.name}"` : ""} missing ${missing.join(" and ")}`);
|
|
3981
4005
|
}
|
|
3982
4006
|
missingRequiredCalls() {
|
|
3983
4007
|
const missing = [];
|
|
@@ -3991,26 +4015,34 @@ var ObjectPropTsDsl = class extends Mixed$25 {
|
|
|
3991
4015
|
const Mixed$24 = AsMixin(ExprMixin(HintMixin(LayoutMixin(TsDsl))));
|
|
3992
4016
|
var ObjectTsDsl = class extends Mixed$24 {
|
|
3993
4017
|
"~dsl" = "ObjectTsDsl";
|
|
3994
|
-
_props =
|
|
4018
|
+
_props = /* @__PURE__ */ new Map();
|
|
4019
|
+
_spreadCounter = 0;
|
|
3995
4020
|
constructor(...props) {
|
|
3996
4021
|
super();
|
|
3997
4022
|
this.props(...props);
|
|
3998
4023
|
}
|
|
3999
4024
|
analyze(ctx$1) {
|
|
4000
4025
|
super.analyze(ctx$1);
|
|
4001
|
-
for (const prop of this._props) ctx$1.analyze(prop);
|
|
4026
|
+
for (const prop of this._props.values()) ctx$1.analyze(prop);
|
|
4002
4027
|
}
|
|
4003
|
-
/**
|
|
4028
|
+
/** Returns composite key for the property. */
|
|
4029
|
+
_propKey(prop) {
|
|
4030
|
+
if (prop.kind === "spread") return `spread:${this._spreadCounter++}`;
|
|
4031
|
+
return `${prop.kind}:${prop.propName}`;
|
|
4032
|
+
}
|
|
4033
|
+
/** Adds a computed property (e.g. `{ [expr]: value }`), or removes if null. */
|
|
4004
4034
|
computed(name, expr) {
|
|
4005
|
-
this._props.
|
|
4035
|
+
if (expr === null) this._props.delete(`computed:${name}`);
|
|
4036
|
+
else this._props.set(`computed:${name}`, new ObjectPropTsDsl({
|
|
4006
4037
|
kind: "computed",
|
|
4007
4038
|
name
|
|
4008
4039
|
}).value(expr));
|
|
4009
4040
|
return this;
|
|
4010
4041
|
}
|
|
4011
|
-
/** Adds a getter property (e.g. `{ get foo() { ... } }`). */
|
|
4042
|
+
/** Adds a getter property (e.g. `{ get foo() { ... } }`), or removes if null. */
|
|
4012
4043
|
getter(name, stmt) {
|
|
4013
|
-
this._props.
|
|
4044
|
+
if (stmt === null) this._props.delete(`getter:${name}`);
|
|
4045
|
+
else this._props.set(`getter:${name}`, new ObjectPropTsDsl({
|
|
4014
4046
|
kind: "getter",
|
|
4015
4047
|
name
|
|
4016
4048
|
}).value(stmt));
|
|
@@ -4018,15 +4050,16 @@ var ObjectTsDsl = class extends Mixed$24 {
|
|
|
4018
4050
|
}
|
|
4019
4051
|
/** Returns true if object has at least one property or spread. */
|
|
4020
4052
|
hasProps() {
|
|
4021
|
-
return this._props.
|
|
4053
|
+
return this._props.size > 0;
|
|
4022
4054
|
}
|
|
4023
4055
|
/** Returns true if object has no properties or spreads. */
|
|
4024
4056
|
get isEmpty() {
|
|
4025
|
-
return this._props.
|
|
4057
|
+
return this._props.size === 0;
|
|
4026
4058
|
}
|
|
4027
|
-
/** Adds a property assignment. */
|
|
4059
|
+
/** Adds a property assignment, or removes if null. */
|
|
4028
4060
|
prop(name, expr) {
|
|
4029
|
-
this._props.
|
|
4061
|
+
if (expr === null) this._props.delete(`prop:${name}`);
|
|
4062
|
+
else this._props.set(`prop:${name}`, new ObjectPropTsDsl({
|
|
4030
4063
|
kind: "prop",
|
|
4031
4064
|
name
|
|
4032
4065
|
}).value(expr));
|
|
@@ -4034,12 +4067,13 @@ var ObjectTsDsl = class extends Mixed$24 {
|
|
|
4034
4067
|
}
|
|
4035
4068
|
/** Adds multiple properties. */
|
|
4036
4069
|
props(...props) {
|
|
4037
|
-
this._props.
|
|
4070
|
+
for (const prop of props) this._props.set(this._propKey(prop), prop);
|
|
4038
4071
|
return this;
|
|
4039
4072
|
}
|
|
4040
|
-
/** Adds a setter property (e.g. `{ set foo(v) { ... } }`). */
|
|
4073
|
+
/** Adds a setter property (e.g. `{ set foo(v) { ... } }`), or removes if null. */
|
|
4041
4074
|
setter(name, stmt) {
|
|
4042
|
-
this._props.
|
|
4075
|
+
if (stmt === null) this._props.delete(`setter:${name}`);
|
|
4076
|
+
else this._props.set(`setter:${name}`, new ObjectPropTsDsl({
|
|
4043
4077
|
kind: "setter",
|
|
4044
4078
|
name
|
|
4045
4079
|
}).value(stmt));
|
|
@@ -4047,11 +4081,13 @@ var ObjectTsDsl = class extends Mixed$24 {
|
|
|
4047
4081
|
}
|
|
4048
4082
|
/** Adds a spread property (e.g. `{ ...options }`). */
|
|
4049
4083
|
spread(expr) {
|
|
4050
|
-
|
|
4084
|
+
const key = `spread:${this._spreadCounter++}`;
|
|
4085
|
+
this._props.set(key, new ObjectPropTsDsl({ kind: "spread" }).value(expr));
|
|
4051
4086
|
return this;
|
|
4052
4087
|
}
|
|
4053
4088
|
toAst() {
|
|
4054
|
-
const
|
|
4089
|
+
const props = [...this._props.values()];
|
|
4090
|
+
const node = ts.factory.createObjectLiteralExpression(this.$node(props), this.$multiline(props.length));
|
|
4055
4091
|
return this.$hint(node);
|
|
4056
4092
|
}
|
|
4057
4093
|
};
|
|
@@ -4550,6 +4586,14 @@ var TypeIdxSigTsDsl = class extends Mixed$10 {
|
|
|
4550
4586
|
this.name.set(name);
|
|
4551
4587
|
fn?.(this);
|
|
4552
4588
|
}
|
|
4589
|
+
/** Element kind. */
|
|
4590
|
+
get kind() {
|
|
4591
|
+
return "idxSig";
|
|
4592
|
+
}
|
|
4593
|
+
/** Index signature parameter name. */
|
|
4594
|
+
get propName() {
|
|
4595
|
+
return this.name.toString();
|
|
4596
|
+
}
|
|
4553
4597
|
analyze(ctx$1) {
|
|
4554
4598
|
super.analyze(ctx$1);
|
|
4555
4599
|
ctx$1.analyze(this._key);
|
|
@@ -4600,6 +4644,14 @@ var TypePropTsDsl = class extends Mixed$9 {
|
|
|
4600
4644
|
this.name.set(name);
|
|
4601
4645
|
fn(this);
|
|
4602
4646
|
}
|
|
4647
|
+
/** Element kind. */
|
|
4648
|
+
get kind() {
|
|
4649
|
+
return "prop";
|
|
4650
|
+
}
|
|
4651
|
+
/** Property name. */
|
|
4652
|
+
get propName() {
|
|
4653
|
+
return this.name.toString();
|
|
4654
|
+
}
|
|
4603
4655
|
analyze(ctx$1) {
|
|
4604
4656
|
super.analyze(ctx$1);
|
|
4605
4657
|
ctx$1.analyze(this._type);
|
|
@@ -4623,33 +4675,40 @@ const Mixed$8 = TsDsl;
|
|
|
4623
4675
|
var TypeObjectTsDsl = class extends Mixed$8 {
|
|
4624
4676
|
"~dsl" = "TypeObjectTsDsl";
|
|
4625
4677
|
scope = "type";
|
|
4626
|
-
|
|
4678
|
+
_props = /* @__PURE__ */ new Map();
|
|
4627
4679
|
analyze(ctx$1) {
|
|
4628
4680
|
super.analyze(ctx$1);
|
|
4629
|
-
for (const prop of this.
|
|
4681
|
+
for (const prop of this._props.values()) ctx$1.analyze(prop);
|
|
4630
4682
|
}
|
|
4631
|
-
/** Returns true if object has at least one property or
|
|
4683
|
+
/** Returns true if object has at least one property or index signature. */
|
|
4632
4684
|
hasProps() {
|
|
4633
|
-
return this.
|
|
4685
|
+
return this._props.size > 0;
|
|
4634
4686
|
}
|
|
4635
|
-
/** Adds an index signature to the object type. */
|
|
4687
|
+
/** Adds an index signature to the object type, or removes if fn is null. */
|
|
4636
4688
|
idxSig(name, fn) {
|
|
4637
|
-
const
|
|
4638
|
-
this.
|
|
4689
|
+
const key = `idxSig:${name}`;
|
|
4690
|
+
if (fn === null) this._props.delete(key);
|
|
4691
|
+
else this._props.set(key, new TypeIdxSigTsDsl(name, fn));
|
|
4639
4692
|
return this;
|
|
4640
4693
|
}
|
|
4641
|
-
/** Returns true if object has no properties or
|
|
4694
|
+
/** Returns true if object has no properties or index signatures. */
|
|
4642
4695
|
get isEmpty() {
|
|
4643
|
-
return
|
|
4696
|
+
return this._props.size === 0;
|
|
4644
4697
|
}
|
|
4645
|
-
/** Adds a property signature
|
|
4698
|
+
/** Adds a property signature, or removes if fn is null. */
|
|
4646
4699
|
prop(name, fn) {
|
|
4647
|
-
const
|
|
4648
|
-
this.
|
|
4700
|
+
const key = `prop:${name}`;
|
|
4701
|
+
if (fn === null) this._props.delete(key);
|
|
4702
|
+
else this._props.set(key, new TypePropTsDsl(name, fn));
|
|
4703
|
+
return this;
|
|
4704
|
+
}
|
|
4705
|
+
/** Adds multiple properties/index signatures. */
|
|
4706
|
+
props(...members) {
|
|
4707
|
+
for (const member of members) this._props.set(`${member.kind}:${member.propName}`, member);
|
|
4649
4708
|
return this;
|
|
4650
4709
|
}
|
|
4651
4710
|
toAst() {
|
|
4652
|
-
return ts.factory.createTypeLiteralNode(this.$node(this.
|
|
4711
|
+
return ts.factory.createTypeLiteralNode(this.$node([...this._props.values()]));
|
|
4653
4712
|
}
|
|
4654
4713
|
};
|
|
4655
4714
|
|
|
@@ -14980,119 +15039,98 @@ const getPlugins = ({ dependencies, userConfig }) => {
|
|
|
14980
15039
|
});
|
|
14981
15040
|
};
|
|
14982
15041
|
|
|
15042
|
+
//#endregion
|
|
15043
|
+
//#region src/config/resolve.ts
|
|
15044
|
+
const resolveConfig = (validated, dependencies) => {
|
|
15045
|
+
const logs = getLogs(validated.job.config);
|
|
15046
|
+
const input = getInput(validated.job.config);
|
|
15047
|
+
const output = getOutput(validated.job.config);
|
|
15048
|
+
const parser = getParser(validated.job.config);
|
|
15049
|
+
output.path = path.resolve(process.cwd(), output.path);
|
|
15050
|
+
let plugins;
|
|
15051
|
+
try {
|
|
15052
|
+
plugins = getPlugins({
|
|
15053
|
+
dependencies,
|
|
15054
|
+
userConfig: validated.job.config
|
|
15055
|
+
});
|
|
15056
|
+
} catch (error) {
|
|
15057
|
+
validated.errors.push(error);
|
|
15058
|
+
plugins = {
|
|
15059
|
+
pluginOrder: [],
|
|
15060
|
+
plugins: {}
|
|
15061
|
+
};
|
|
15062
|
+
}
|
|
15063
|
+
const config = {
|
|
15064
|
+
configFile: validated.job.config.configFile ?? "",
|
|
15065
|
+
dryRun: validated.job.config.dryRun ?? false,
|
|
15066
|
+
input,
|
|
15067
|
+
interactive: validated.job.config.interactive ?? detectInteractiveSession(),
|
|
15068
|
+
logs,
|
|
15069
|
+
output,
|
|
15070
|
+
parser,
|
|
15071
|
+
pluginOrder: plugins.pluginOrder,
|
|
15072
|
+
plugins: plugins.plugins
|
|
15073
|
+
};
|
|
15074
|
+
if (logs.level === "debug") {
|
|
15075
|
+
const jobPrefix = colors.gray(`[Job ${validated.job.index}] `);
|
|
15076
|
+
console.warn(`${jobPrefix}${colors.cyan("config:")}`, config);
|
|
15077
|
+
}
|
|
15078
|
+
return {
|
|
15079
|
+
config,
|
|
15080
|
+
errors: validated.errors,
|
|
15081
|
+
index: validated.job.index
|
|
15082
|
+
};
|
|
15083
|
+
};
|
|
15084
|
+
|
|
15085
|
+
//#endregion
|
|
15086
|
+
//#region src/config/validate.ts
|
|
15087
|
+
function validateJobs(jobs) {
|
|
15088
|
+
return jobs.map((job) => {
|
|
15089
|
+
const errors = [];
|
|
15090
|
+
const { config } = job;
|
|
15091
|
+
if (!getInput(config).length) errors.push(new ConfigError("missing input - which OpenAPI specification should we use to generate your output?"));
|
|
15092
|
+
if (!getOutput(config).path) errors.push(new ConfigError("missing output - where should we generate your output?"));
|
|
15093
|
+
return {
|
|
15094
|
+
errors,
|
|
15095
|
+
job
|
|
15096
|
+
};
|
|
15097
|
+
});
|
|
15098
|
+
}
|
|
15099
|
+
|
|
14983
15100
|
//#endregion
|
|
14984
15101
|
//#region src/config/init.ts
|
|
14985
15102
|
/**
|
|
14986
|
-
* Detect if the current session is interactive based on TTY status and environment variables.
|
|
14987
|
-
* This is used as a fallback when the user doesn't explicitly set the interactive option.
|
|
14988
15103
|
* @internal
|
|
14989
15104
|
*/
|
|
14990
|
-
|
|
14991
|
-
/**
|
|
14992
|
-
* @internal
|
|
14993
|
-
*/
|
|
14994
|
-
const initConfigs = async ({ logger, userConfigs }) => {
|
|
15105
|
+
async function resolveJobs({ logger, userConfigs }) {
|
|
14995
15106
|
const configs = [];
|
|
14996
15107
|
let dependencies = {};
|
|
14997
15108
|
const eventLoad = logger.timeEvent("load");
|
|
14998
15109
|
for (const userConfig of userConfigs) {
|
|
14999
|
-
let
|
|
15000
|
-
if (userConfig
|
|
15110
|
+
let configFile;
|
|
15111
|
+
if (userConfig.configFile) {
|
|
15001
15112
|
const parts = userConfig.configFile.split(".");
|
|
15002
|
-
|
|
15003
|
-
}
|
|
15004
|
-
const eventC12 = logger.timeEvent("c12");
|
|
15005
|
-
const { loadConfig } = await import("c12");
|
|
15006
|
-
const { config: configFromFile, configFile: loadedConfigFile } = await loadConfig({
|
|
15007
|
-
configFile: configurationFile,
|
|
15008
|
-
name: "openapi-ts"
|
|
15009
|
-
});
|
|
15010
|
-
eventC12.timeEnd();
|
|
15011
|
-
if (!Object.keys(dependencies).length) dependencies = getProjectDependencies(Object.keys(configFromFile).length ? loadedConfigFile : void 0);
|
|
15012
|
-
const mergedConfigs = configFromFile instanceof Array ? configFromFile.map((config) => mergeConfigs(config, userConfig)) : [mergeConfigs(configFromFile, userConfig)];
|
|
15013
|
-
for (const mergedConfig of mergedConfigs) {
|
|
15014
|
-
const input = getInput(mergedConfig);
|
|
15015
|
-
if (mergedConfig.output instanceof Array) {
|
|
15016
|
-
const countInputs = input.length;
|
|
15017
|
-
const countOutputs = mergedConfig.output.length;
|
|
15018
|
-
if (countOutputs > 1) if (countInputs !== countOutputs) {
|
|
15019
|
-
console.warn(`⚙️ ${colors.yellow("Warning:")} You provided ${colors.cyan(String(countInputs))} ${colors.cyan(countInputs === 1 ? "input" : "inputs")} and ${colors.yellow(String(countOutputs))} ${colors.yellow("outputs")}. This is probably not what you want as it will produce identical output in multiple locations. You most likely want to provide a single output or the same number of outputs as inputs.`);
|
|
15020
|
-
for (const output of mergedConfig.output) configs.push({
|
|
15021
|
-
...mergedConfig,
|
|
15022
|
-
input,
|
|
15023
|
-
output
|
|
15024
|
-
});
|
|
15025
|
-
} else mergedConfig.output.forEach((output, index) => {
|
|
15026
|
-
configs.push({
|
|
15027
|
-
...mergedConfig,
|
|
15028
|
-
input: input[index],
|
|
15029
|
-
output
|
|
15030
|
-
});
|
|
15031
|
-
});
|
|
15032
|
-
else configs.push({
|
|
15033
|
-
...mergedConfig,
|
|
15034
|
-
input,
|
|
15035
|
-
output: mergedConfig.output[0] ?? ""
|
|
15036
|
-
});
|
|
15037
|
-
} else configs.push({
|
|
15038
|
-
...mergedConfig,
|
|
15039
|
-
input
|
|
15040
|
-
});
|
|
15113
|
+
configFile = parts.slice(0, parts.length - 1).join(".");
|
|
15041
15114
|
}
|
|
15115
|
+
const loaded = await loadConfigFile({
|
|
15116
|
+
configFile,
|
|
15117
|
+
logger,
|
|
15118
|
+
name: "openapi-ts",
|
|
15119
|
+
userConfig
|
|
15120
|
+
});
|
|
15121
|
+
if (!Object.keys(dependencies).length) dependencies = getProjectDependencies(loaded.foundConfig ? loaded.configFile : void 0);
|
|
15122
|
+
configs.push(...loaded.configs);
|
|
15042
15123
|
}
|
|
15043
15124
|
eventLoad.timeEnd();
|
|
15044
|
-
const results = [];
|
|
15045
15125
|
const eventBuild = logger.timeEvent("build");
|
|
15046
|
-
|
|
15047
|
-
const logs = getLogs(userConfig);
|
|
15048
|
-
const input = getInput(userConfig);
|
|
15049
|
-
const output = getOutput(userConfig);
|
|
15050
|
-
const parser = getParser(userConfig);
|
|
15051
|
-
const errors = [];
|
|
15052
|
-
if (!input.length) errors.push(new ConfigError("missing input - which OpenAPI specification should we use to generate your output?"));
|
|
15053
|
-
if (!output.path) errors.push(new ConfigError("missing output - where should we generate your output?"));
|
|
15054
|
-
output.path = path.resolve(process.cwd(), output.path);
|
|
15055
|
-
let plugins;
|
|
15056
|
-
try {
|
|
15057
|
-
plugins = getPlugins({
|
|
15058
|
-
dependencies,
|
|
15059
|
-
userConfig
|
|
15060
|
-
});
|
|
15061
|
-
} catch (error) {
|
|
15062
|
-
errors.push(error);
|
|
15063
|
-
plugins = {
|
|
15064
|
-
pluginOrder: [],
|
|
15065
|
-
plugins: {}
|
|
15066
|
-
};
|
|
15067
|
-
}
|
|
15068
|
-
const config = {
|
|
15069
|
-
configFile: userConfig.configFile ?? "",
|
|
15070
|
-
dryRun: userConfig.dryRun ?? false,
|
|
15071
|
-
input,
|
|
15072
|
-
interactive: userConfig.interactive ?? detectInteractiveSession(),
|
|
15073
|
-
logs,
|
|
15074
|
-
output,
|
|
15075
|
-
parser,
|
|
15076
|
-
pluginOrder: plugins.pluginOrder,
|
|
15077
|
-
plugins: plugins.plugins
|
|
15078
|
-
};
|
|
15079
|
-
const jobIndex = results.length;
|
|
15080
|
-
if (logs.level === "debug") {
|
|
15081
|
-
const jobPrefix = colors.gray(`[Job ${jobIndex + 1}] `);
|
|
15082
|
-
console.warn(`${jobPrefix}${colors.cyan("config:")}`, config);
|
|
15083
|
-
}
|
|
15084
|
-
results.push({
|
|
15085
|
-
config,
|
|
15086
|
-
errors,
|
|
15087
|
-
jobIndex
|
|
15088
|
-
});
|
|
15089
|
-
}
|
|
15126
|
+
const resolvedJobs = validateJobs(expandToJobs(configs)).map((validated) => resolveConfig(validated, dependencies));
|
|
15090
15127
|
eventBuild.timeEnd();
|
|
15091
15128
|
return {
|
|
15092
15129
|
dependencies,
|
|
15093
|
-
|
|
15130
|
+
jobs: resolvedJobs,
|
|
15131
|
+
results: resolvedJobs
|
|
15094
15132
|
};
|
|
15095
|
-
}
|
|
15133
|
+
}
|
|
15096
15134
|
|
|
15097
15135
|
//#endregion
|
|
15098
15136
|
//#region src/plugins/@hey-api/client-core/bundle/params.ts
|
|
@@ -21732,5 +21770,5 @@ const parseOpenApiSpec = ({ config, dependencies, logger, spec }) => {
|
|
|
21732
21770
|
};
|
|
21733
21771
|
|
|
21734
21772
|
//#endregion
|
|
21735
|
-
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,
|
|
21736
|
-
//# sourceMappingURL=openApi-
|
|
21773
|
+
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, resolveJobs 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 };
|
|
21774
|
+
//# sourceMappingURL=openApi-CE_z8tev.mjs.map
|