@hey-api/openapi-ts 0.90.8 → 0.90.10
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 +2 -2
- package/dist/index.d.cts +5 -5
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +2 -2
- package/dist/internal.cjs +2 -2
- package/dist/internal.d.cts +15 -9
- package/dist/internal.d.mts +15 -9
- package/dist/internal.mjs +2 -2
- package/dist/{openApi-BZ7m5ia5.cjs → openApi-Dy5wknYZ.cjs} +288 -222
- package/dist/openApi-Dy5wknYZ.cjs.map +1 -0
- package/dist/{openApi-B6J9qPwL.mjs → openApi-Gs-XGatv.mjs} +266 -200
- package/dist/openApi-Gs-XGatv.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-Dbxz7RgS.cjs → src-DMQOp4DI.cjs} +27 -25
- package/dist/src-DMQOp4DI.cjs.map +1 -0
- package/dist/{src-C9rj3EgV.mjs → src-YIQMkx2V.mjs} +27 -25
- package/dist/src-YIQMkx2V.mjs.map +1 -0
- package/dist/{types-DzR_aHdx.d.cts → types-BcLsQaJ_.d.cts} +184 -167
- package/dist/{types-ByDiVB9E.d.mts → types-CLcjoomL.d.mts} +184 -167
- package/package.json +3 -4
- package/dist/openApi-B6J9qPwL.mjs.map +0 -1
- package/dist/openApi-BZ7m5ia5.cjs.map +0 -1
- package/dist/src-C9rj3EgV.mjs.map +0 -1
- package/dist/src-Dbxz7RgS.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);
|
|
4027
|
+
}
|
|
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}`;
|
|
4002
4032
|
}
|
|
4003
|
-
/** Adds a computed property (e.g. `{ [expr]: value }`). */
|
|
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
|
|
|
@@ -5575,6 +5634,25 @@ const pathToJsonPointer = (path$4) => {
|
|
|
5575
5634
|
const segments = path$4.map(encodeJsonPointerSegment).join("/");
|
|
5576
5635
|
return "#" + (segments ? `/${segments}` : "");
|
|
5577
5636
|
};
|
|
5637
|
+
/**
|
|
5638
|
+
* Checks if a $ref points to a top-level component (not a deep path reference).
|
|
5639
|
+
*
|
|
5640
|
+
* Top-level component references:
|
|
5641
|
+
* - OpenAPI 3.x: #/components/{type}/{name} (3 segments)
|
|
5642
|
+
* - OpenAPI 2.0: #/definitions/{name} (2 segments)
|
|
5643
|
+
*
|
|
5644
|
+
* Deep path references (4+ segments for 3.x, 3+ for 2.0) should be inlined
|
|
5645
|
+
* because they don't have corresponding registered symbols.
|
|
5646
|
+
*
|
|
5647
|
+
* @param $ref - The $ref string to check
|
|
5648
|
+
* @returns true if the ref points to a top-level component, false otherwise
|
|
5649
|
+
*/
|
|
5650
|
+
const isTopLevelComponentRef = ($ref) => {
|
|
5651
|
+
const path$4 = jsonPointerToPath($ref);
|
|
5652
|
+
if (path$4[0] === "components") return path$4.length === 3;
|
|
5653
|
+
if (path$4[0] === "definitions") return path$4.length === 2;
|
|
5654
|
+
return false;
|
|
5655
|
+
};
|
|
5578
5656
|
const resolveRef = ({ $ref, spec }) => {
|
|
5579
5657
|
const path$4 = jsonPointerToPath(decodeURI($ref));
|
|
5580
5658
|
let current = spec;
|
|
@@ -5593,7 +5671,7 @@ const resolveRef = ({ $ref, spec }) => {
|
|
|
5593
5671
|
* - Prefixes all conflicting names with their location (e.g. path_foo, query_foo)
|
|
5594
5672
|
* - Returns a flat map of resolved parameter names to their metadata
|
|
5595
5673
|
*/
|
|
5596
|
-
|
|
5674
|
+
function getSignatureParameters({ operation }) {
|
|
5597
5675
|
const locations = [
|
|
5598
5676
|
"header",
|
|
5599
5677
|
"path",
|
|
@@ -5680,7 +5758,10 @@ const getSignatureParameters = ({ operation }) => {
|
|
|
5680
5758
|
name: "body",
|
|
5681
5759
|
schema: operation.body.schema
|
|
5682
5760
|
};
|
|
5683
|
-
fields.push({
|
|
5761
|
+
fields.push({
|
|
5762
|
+
key: "body",
|
|
5763
|
+
map: "body"
|
|
5764
|
+
});
|
|
5684
5765
|
}
|
|
5685
5766
|
}
|
|
5686
5767
|
if (!Object.keys(signatureParameters).length) return;
|
|
@@ -5688,7 +5769,7 @@ const getSignatureParameters = ({ operation }) => {
|
|
|
5688
5769
|
fields,
|
|
5689
5770
|
parameters: signatureParameters
|
|
5690
5771
|
};
|
|
5691
|
-
}
|
|
5772
|
+
}
|
|
5692
5773
|
|
|
5693
5774
|
//#endregion
|
|
5694
5775
|
//#region src/plugins/@hey-api/sdk/shared/validator.ts
|
|
@@ -5740,7 +5821,7 @@ const operationOptionsType = ({ isDataAllowed = true, operation, plugin, throwOn
|
|
|
5740
5821
|
if (throwOnError) return $.type(symbolOptions).generic(isDataAllowed ? symbolDataType ?? "unknown" : "never").generic(throwOnError);
|
|
5741
5822
|
return $.type(symbolOptions).$if(!isDataAllowed || symbolDataType, (t) => t.generic(isDataAllowed ? symbolDataType : "never"));
|
|
5742
5823
|
};
|
|
5743
|
-
|
|
5824
|
+
function operationParameters({ isRequiredOptions, operation, plugin }) {
|
|
5744
5825
|
const result = {
|
|
5745
5826
|
argNames: [],
|
|
5746
5827
|
fields: [],
|
|
@@ -5777,7 +5858,7 @@ const operationParameters = ({ isRequiredOptions, operation, plugin }) => {
|
|
|
5777
5858
|
throwOnError: isNuxtClient ? void 0 : "ThrowOnError"
|
|
5778
5859
|
}))));
|
|
5779
5860
|
return result;
|
|
5780
|
-
}
|
|
5861
|
+
}
|
|
5781
5862
|
/**
|
|
5782
5863
|
* Infers `responseType` value from provided response content type. This is
|
|
5783
5864
|
* an adapted version of `getParseAs()` from the Fetch API client.
|
|
@@ -5800,7 +5881,7 @@ const getResponseType = (contentType) => {
|
|
|
5800
5881
|
].some((type) => cleanContent.startsWith(type))) return "blob";
|
|
5801
5882
|
if (cleanContent.startsWith("text/")) return "text";
|
|
5802
5883
|
};
|
|
5803
|
-
|
|
5884
|
+
function operationStatements({ isRequiredOptions, opParameters, operation, plugin }) {
|
|
5804
5885
|
const client = getClientPlugin(plugin.context.config);
|
|
5805
5886
|
const isNuxtClient = client.name === "@hey-api/client-nuxt";
|
|
5806
5887
|
const symbolResponseType = plugin.querySymbol({
|
|
@@ -5931,7 +6012,7 @@ const operationStatements = ({ isRequiredOptions, opParameters, operation, plugi
|
|
|
5931
6012
|
functionName = functionName.attr(operation.method);
|
|
5932
6013
|
statements.push($.return(functionName.call(reqOptions).$if(isNuxtClient, (f$1) => f$1.generic(nuxtTypeComposable).generic($.type.or(symbolResponseType ?? "unknown", nuxtTypeDefault)).generic(symbolErrorType ?? "unknown").generic(nuxtTypeDefault), (f$1) => f$1.generic(symbolResponseType ?? "unknown").generic(symbolErrorType ?? "unknown").generic("ThrowOnError")).$if(plugin.config.responseStyle === "data", (f$1) => f$1.generic($.type.literal(plugin.config.responseStyle)))));
|
|
5933
6014
|
return statements;
|
|
5934
|
-
}
|
|
6015
|
+
}
|
|
5935
6016
|
|
|
5936
6017
|
//#endregion
|
|
5937
6018
|
//#region src/plugins/@hey-api/sdk/v1/node.ts
|
|
@@ -9088,7 +9169,13 @@ const createMutationOptions = ({ operation, plugin }) => {
|
|
|
9088
9169
|
if (plugin.getPluginOrThrow("@hey-api/sdk").config.responseStyle === "data") statements.push($.return(awaitSdkFn));
|
|
9089
9170
|
else statements.push($.const().object("data").assign(awaitSdkFn), $.return("data"));
|
|
9090
9171
|
const mutationOptionsFn = "mutationOptions";
|
|
9091
|
-
const symbolMutationOptions = plugin.symbol(applyNaming(operation.id, plugin.config.mutationOptions)
|
|
9172
|
+
const symbolMutationOptions = plugin.symbol(applyNaming(operation.id, plugin.config.mutationOptions), { meta: {
|
|
9173
|
+
category: "hook",
|
|
9174
|
+
resource: "operation",
|
|
9175
|
+
resourceId: operation.id,
|
|
9176
|
+
role: "mutationOptions",
|
|
9177
|
+
tool: plugin.name
|
|
9178
|
+
} });
|
|
9092
9179
|
const statement = $.const(symbolMutationOptions).export().$if(plugin.config.comments && createOperationComment(operation), (c, v) => c.doc(v)).assign($.func().param("options", (p) => p.optional().type($.type("Partial").generic(typeData))).returns(mutationType).do($.const(mutationOptionsFn).type(mutationType).assign($.object().pretty().prop("mutationFn", $.func().async().param(fnOptions$1).do(...statements)).$if(handleMeta(plugin, operation, "mutationOptions"), (c, v) => c.prop("meta", v))), $(mutationOptionsFn).return()));
|
|
9093
9180
|
plugin.node(statement);
|
|
9094
9181
|
};
|
|
@@ -14980,119 +15067,98 @@ const getPlugins = ({ dependencies, userConfig }) => {
|
|
|
14980
15067
|
});
|
|
14981
15068
|
};
|
|
14982
15069
|
|
|
15070
|
+
//#endregion
|
|
15071
|
+
//#region src/config/resolve.ts
|
|
15072
|
+
const resolveConfig = (validated, dependencies) => {
|
|
15073
|
+
const logs = getLogs(validated.job.config);
|
|
15074
|
+
const input = getInput(validated.job.config);
|
|
15075
|
+
const output = getOutput(validated.job.config);
|
|
15076
|
+
const parser = getParser(validated.job.config);
|
|
15077
|
+
output.path = path.resolve(process.cwd(), output.path);
|
|
15078
|
+
let plugins;
|
|
15079
|
+
try {
|
|
15080
|
+
plugins = getPlugins({
|
|
15081
|
+
dependencies,
|
|
15082
|
+
userConfig: validated.job.config
|
|
15083
|
+
});
|
|
15084
|
+
} catch (error) {
|
|
15085
|
+
validated.errors.push(error);
|
|
15086
|
+
plugins = {
|
|
15087
|
+
pluginOrder: [],
|
|
15088
|
+
plugins: {}
|
|
15089
|
+
};
|
|
15090
|
+
}
|
|
15091
|
+
const config = {
|
|
15092
|
+
configFile: validated.job.config.configFile ?? "",
|
|
15093
|
+
dryRun: validated.job.config.dryRun ?? false,
|
|
15094
|
+
input,
|
|
15095
|
+
interactive: validated.job.config.interactive ?? detectInteractiveSession(),
|
|
15096
|
+
logs,
|
|
15097
|
+
output,
|
|
15098
|
+
parser,
|
|
15099
|
+
pluginOrder: plugins.pluginOrder,
|
|
15100
|
+
plugins: plugins.plugins
|
|
15101
|
+
};
|
|
15102
|
+
if (logs.level === "debug") {
|
|
15103
|
+
const jobPrefix = colors.gray(`[Job ${validated.job.index}] `);
|
|
15104
|
+
console.warn(`${jobPrefix}${colors.cyan("config:")}`, config);
|
|
15105
|
+
}
|
|
15106
|
+
return {
|
|
15107
|
+
config,
|
|
15108
|
+
errors: validated.errors,
|
|
15109
|
+
index: validated.job.index
|
|
15110
|
+
};
|
|
15111
|
+
};
|
|
15112
|
+
|
|
15113
|
+
//#endregion
|
|
15114
|
+
//#region src/config/validate.ts
|
|
15115
|
+
function validateJobs(jobs) {
|
|
15116
|
+
return jobs.map((job) => {
|
|
15117
|
+
const errors = [];
|
|
15118
|
+
const { config } = job;
|
|
15119
|
+
if (!getInput(config).length) errors.push(new ConfigError("missing input - which OpenAPI specification should we use to generate your output?"));
|
|
15120
|
+
if (!getOutput(config).path) errors.push(new ConfigError("missing output - where should we generate your output?"));
|
|
15121
|
+
return {
|
|
15122
|
+
errors,
|
|
15123
|
+
job
|
|
15124
|
+
};
|
|
15125
|
+
});
|
|
15126
|
+
}
|
|
15127
|
+
|
|
14983
15128
|
//#endregion
|
|
14984
15129
|
//#region src/config/init.ts
|
|
14985
15130
|
/**
|
|
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
15131
|
* @internal
|
|
14989
15132
|
*/
|
|
14990
|
-
|
|
14991
|
-
/**
|
|
14992
|
-
* @internal
|
|
14993
|
-
*/
|
|
14994
|
-
const initConfigs = async ({ logger, userConfigs }) => {
|
|
15133
|
+
async function resolveJobs({ logger, userConfigs }) {
|
|
14995
15134
|
const configs = [];
|
|
14996
15135
|
let dependencies = {};
|
|
14997
15136
|
const eventLoad = logger.timeEvent("load");
|
|
14998
15137
|
for (const userConfig of userConfigs) {
|
|
14999
|
-
let
|
|
15000
|
-
if (userConfig
|
|
15138
|
+
let configFile;
|
|
15139
|
+
if (userConfig.configFile) {
|
|
15001
15140
|
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
|
-
});
|
|
15141
|
+
configFile = parts.slice(0, parts.length - 1).join(".");
|
|
15041
15142
|
}
|
|
15143
|
+
const loaded = await loadConfigFile({
|
|
15144
|
+
configFile,
|
|
15145
|
+
logger,
|
|
15146
|
+
name: "openapi-ts",
|
|
15147
|
+
userConfig
|
|
15148
|
+
});
|
|
15149
|
+
if (!Object.keys(dependencies).length) dependencies = getProjectDependencies(loaded.foundConfig ? loaded.configFile : void 0);
|
|
15150
|
+
configs.push(...loaded.configs);
|
|
15042
15151
|
}
|
|
15043
15152
|
eventLoad.timeEnd();
|
|
15044
|
-
const results = [];
|
|
15045
15153
|
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
|
-
}
|
|
15154
|
+
const resolvedJobs = validateJobs(expandToJobs(configs)).map((validated) => resolveConfig(validated, dependencies));
|
|
15090
15155
|
eventBuild.timeEnd();
|
|
15091
15156
|
return {
|
|
15092
15157
|
dependencies,
|
|
15093
|
-
|
|
15158
|
+
jobs: resolvedJobs,
|
|
15159
|
+
results: resolvedJobs
|
|
15094
15160
|
};
|
|
15095
|
-
}
|
|
15161
|
+
}
|
|
15096
15162
|
|
|
15097
15163
|
//#endregion
|
|
15098
15164
|
//#region src/plugins/@hey-api/client-core/bundle/params.ts
|
|
@@ -18085,7 +18151,7 @@ const parseEnum$2 = ({ context, schema, state }) => {
|
|
|
18085
18151
|
};
|
|
18086
18152
|
const parseRef$2 = ({ context, schema, state }) => {
|
|
18087
18153
|
const irSchema = {};
|
|
18088
|
-
if (!schema.$ref
|
|
18154
|
+
if (!isTopLevelComponentRef(schema.$ref)) {
|
|
18089
18155
|
if (!state.circularReferenceTracker.has(schema.$ref)) {
|
|
18090
18156
|
const refSchema = context.resolveRef(schema.$ref);
|
|
18091
18157
|
const originalRef = state.$ref;
|
|
@@ -19385,7 +19451,7 @@ const parseOneOf$1 = ({ context, schema, state }) => {
|
|
|
19385
19451
|
return irSchema;
|
|
19386
19452
|
};
|
|
19387
19453
|
const parseRef$1 = ({ context, schema, state }) => {
|
|
19388
|
-
if (!schema.$ref
|
|
19454
|
+
if (!isTopLevelComponentRef(schema.$ref)) {
|
|
19389
19455
|
if (!state.circularReferenceTracker.has(schema.$ref)) {
|
|
19390
19456
|
const refSchema = context.resolveRef(schema.$ref);
|
|
19391
19457
|
const originalRef = state.$ref;
|
|
@@ -20733,7 +20799,7 @@ const parseOneOf = ({ context, schema, state }) => {
|
|
|
20733
20799
|
return irSchema;
|
|
20734
20800
|
};
|
|
20735
20801
|
const parseRef = ({ context, schema, state }) => {
|
|
20736
|
-
if (!schema.$ref
|
|
20802
|
+
if (!isTopLevelComponentRef(schema.$ref)) {
|
|
20737
20803
|
if (!state.circularReferenceTracker.has(schema.$ref)) {
|
|
20738
20804
|
const refSchema = context.resolveRef(schema.$ref);
|
|
20739
20805
|
const originalRef = state.$ref;
|
|
@@ -21732,5 +21798,5 @@ const parseOpenApiSpec = ({ config, dependencies, logger, spec }) => {
|
|
|
21732
21798
|
};
|
|
21733
21799
|
|
|
21734
21800
|
//#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-
|
|
21801
|
+
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 };
|
|
21802
|
+
//# sourceMappingURL=openApi-Gs-XGatv.mjs.map
|