@hey-api/openapi-ts 0.91.0 → 0.92.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/clients/angular/client.ts +23 -49
- package/dist/clients/angular/types.ts +11 -34
- package/dist/clients/angular/utils.ts +6 -22
- package/dist/clients/axios/client.ts +16 -27
- package/dist/clients/axios/types.ts +17 -54
- package/dist/clients/axios/utils.ts +3 -8
- package/dist/clients/core/auth.ts +1 -2
- package/dist/clients/core/bodySerializer.ts +5 -21
- package/dist/clients/core/params.ts +3 -10
- package/dist/clients/core/pathSerializer.ts +4 -14
- package/dist/clients/core/queryKeySerializer.ts +6 -25
- package/dist/clients/core/serverSentEvents.ts +8 -31
- package/dist/clients/core/types.ts +4 -18
- package/dist/clients/core/utils.ts +1 -4
- package/dist/clients/fetch/client.ts +25 -48
- package/dist/clients/fetch/types.ts +12 -40
- package/dist/clients/fetch/utils.ts +6 -22
- package/dist/clients/ky/client.ts +27 -58
- package/dist/clients/ky/types.ts +14 -45
- package/dist/clients/ky/utils.ts +6 -22
- package/dist/clients/next/client.ts +30 -47
- package/dist/clients/next/types.ts +13 -47
- package/dist/clients/next/utils.ts +8 -31
- package/dist/clients/nuxt/client.ts +18 -37
- package/dist/clients/nuxt/types.ts +12 -31
- package/dist/clients/nuxt/utils.ts +5 -17
- package/dist/clients/ofetch/client.ts +34 -60
- package/dist/clients/ofetch/types.ts +13 -44
- package/dist/clients/ofetch/utils.ts +20 -58
- package/dist/index.d.mts +289 -452
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{init-kvO44gnv.mjs → init-DlaW5Djq.mjs} +355 -86
- package/dist/init-DlaW5Djq.mjs.map +1 -0
- package/dist/internal.mjs +1 -1
- package/dist/run.mjs +3 -3
- package/dist/run.mjs.map +1 -1
- package/dist/{src-Dmlg6WRV.mjs → src-BYA2YioO.mjs} +5 -8
- package/dist/src-BYA2YioO.mjs.map +1 -0
- package/dist/types-Ba27ofyy.d.mts.map +1 -1
- package/package.json +36 -37
- package/dist/init-kvO44gnv.mjs.map +0 -1
- package/dist/src-Dmlg6WRV.mjs.map +0 -1
|
@@ -140,6 +140,7 @@ function getOutput(userConfig) {
|
|
|
140
140
|
const output = valueToObject({
|
|
141
141
|
defaultValue: {
|
|
142
142
|
clean: true,
|
|
143
|
+
entryFile: true,
|
|
143
144
|
fileName: {
|
|
144
145
|
case: "preserve",
|
|
145
146
|
name: "{{name}}",
|
|
@@ -147,7 +148,6 @@ function getOutput(userConfig) {
|
|
|
147
148
|
},
|
|
148
149
|
format: null,
|
|
149
150
|
header: "// This file is auto-generated by @hey-api/openapi-ts",
|
|
150
|
-
indexFile: true,
|
|
151
151
|
lint: null,
|
|
152
152
|
path: "",
|
|
153
153
|
postProcess: [],
|
|
@@ -395,12 +395,12 @@ function getTypedConfig(plugin) {
|
|
|
395
395
|
|
|
396
396
|
//#endregion
|
|
397
397
|
//#region src/plugins/@hey-api/client-core/utils.ts
|
|
398
|
-
|
|
398
|
+
function getClientBaseUrlKey(config) {
|
|
399
399
|
const client = getClientPlugin(config);
|
|
400
400
|
if (client.name === "@hey-api/client-axios" || client.name === "@hey-api/client-nuxt") return "baseURL";
|
|
401
401
|
return "baseUrl";
|
|
402
|
-
}
|
|
403
|
-
|
|
402
|
+
}
|
|
403
|
+
function getClientPlugin(config) {
|
|
404
404
|
for (const name of config.pluginOrder) {
|
|
405
405
|
const plugin = config.plugins[name];
|
|
406
406
|
if (plugin?.tags?.includes("client")) return plugin;
|
|
@@ -409,7 +409,7 @@ const getClientPlugin = (config) => {
|
|
|
409
409
|
config: { name: "" },
|
|
410
410
|
name: ""
|
|
411
411
|
};
|
|
412
|
-
}
|
|
412
|
+
}
|
|
413
413
|
|
|
414
414
|
//#endregion
|
|
415
415
|
//#region src/ts-dsl/base.ts
|
|
@@ -587,6 +587,10 @@ var PrefixTsDsl = class extends Mixed$51 {
|
|
|
587
587
|
super.analyze(ctx$1);
|
|
588
588
|
ctx$1.analyze(this._expr);
|
|
589
589
|
}
|
|
590
|
+
/** Returns true when all required builder calls are present. */
|
|
591
|
+
get isValid() {
|
|
592
|
+
return this.missingRequiredCalls().length === 0;
|
|
593
|
+
}
|
|
590
594
|
/** Sets the operand (the expression being prefixed). */
|
|
591
595
|
expr(expr) {
|
|
592
596
|
this._expr = expr;
|
|
@@ -608,10 +612,20 @@ var PrefixTsDsl = class extends Mixed$51 {
|
|
|
608
612
|
return this;
|
|
609
613
|
}
|
|
610
614
|
toAst() {
|
|
611
|
-
|
|
612
|
-
if (!this._op) throw new Error("Missing operator for prefix unary expression");
|
|
615
|
+
this.$validate();
|
|
613
616
|
return ts.factory.createPrefixUnaryExpression(this._op, this.$node(this._expr));
|
|
614
617
|
}
|
|
618
|
+
$validate() {
|
|
619
|
+
const missing = this.missingRequiredCalls();
|
|
620
|
+
if (missing.length === 0) return;
|
|
621
|
+
throw new Error(`Prefix unary expression missing ${missing.join(" and ")}`);
|
|
622
|
+
}
|
|
623
|
+
missingRequiredCalls() {
|
|
624
|
+
const missing = [];
|
|
625
|
+
if (!this._expr) missing.push(".expr()");
|
|
626
|
+
if (!this._op) missing.push("operator (e.g., .not(), .neg())");
|
|
627
|
+
return missing;
|
|
628
|
+
}
|
|
615
629
|
};
|
|
616
630
|
|
|
617
631
|
//#endregion
|
|
@@ -876,7 +890,7 @@ const safePropName = (name) => {
|
|
|
876
890
|
const safeName = (name, reserved$1) => {
|
|
877
891
|
let sanitized = "";
|
|
878
892
|
let index;
|
|
879
|
-
const first = name[0];
|
|
893
|
+
const first = name[0] ?? "";
|
|
880
894
|
regexp.illegalStartCharacters.lastIndex = 0;
|
|
881
895
|
if (regexp.illegalStartCharacters.test(first)) {
|
|
882
896
|
sanitized += "_";
|
|
@@ -886,7 +900,7 @@ const safeName = (name, reserved$1) => {
|
|
|
886
900
|
index = 1;
|
|
887
901
|
}
|
|
888
902
|
while (index < name.length) {
|
|
889
|
-
const char = name[index];
|
|
903
|
+
const char = name[index] ?? "";
|
|
890
904
|
sanitized += /^[\u200c\u200d\p{ID_Continue}]$/u.test(char) ? char : "_";
|
|
891
905
|
index += 1;
|
|
892
906
|
}
|
|
@@ -1451,9 +1465,23 @@ var TokenTsDsl = class extends TsDsl {
|
|
|
1451
1465
|
return this.kind(ts.SyntaxKind.DotDotDotToken);
|
|
1452
1466
|
}
|
|
1453
1467
|
toAst() {
|
|
1454
|
-
|
|
1468
|
+
this.$validate();
|
|
1455
1469
|
return ts.factory.createToken(this._kind);
|
|
1456
1470
|
}
|
|
1471
|
+
$validate() {
|
|
1472
|
+
const missing = this.missingRequiredCalls();
|
|
1473
|
+
if (missing.length === 0) return;
|
|
1474
|
+
throw new Error(`Token missing ${missing.join(" and ")}`);
|
|
1475
|
+
}
|
|
1476
|
+
missingRequiredCalls() {
|
|
1477
|
+
const missing = [];
|
|
1478
|
+
if (!this._kind) missing.push(".kind()");
|
|
1479
|
+
return missing;
|
|
1480
|
+
}
|
|
1481
|
+
/** Returns true when all required builder calls are present. */
|
|
1482
|
+
get isValid() {
|
|
1483
|
+
return this.missingRequiredCalls().length === 0;
|
|
1484
|
+
}
|
|
1457
1485
|
};
|
|
1458
1486
|
|
|
1459
1487
|
//#endregion
|
|
@@ -1535,6 +1563,10 @@ var TypeAttrTsDsl = class extends Mixed$47 {
|
|
|
1535
1563
|
ctx$1.analyze(this._base);
|
|
1536
1564
|
ctx$1.analyze(this._right);
|
|
1537
1565
|
}
|
|
1566
|
+
/** Returns true when all required builder calls are present. */
|
|
1567
|
+
get isValid() {
|
|
1568
|
+
return this.missingRequiredCalls().length === 0;
|
|
1569
|
+
}
|
|
1538
1570
|
base(base) {
|
|
1539
1571
|
if (isRef(base)) this._base = base;
|
|
1540
1572
|
else this._base = base ? ref(base) : void 0;
|
|
@@ -1545,11 +1577,22 @@ var TypeAttrTsDsl = class extends Mixed$47 {
|
|
|
1545
1577
|
return this;
|
|
1546
1578
|
}
|
|
1547
1579
|
toAst() {
|
|
1548
|
-
|
|
1580
|
+
this.$validate();
|
|
1549
1581
|
const left = this.$node(this._base);
|
|
1550
1582
|
if (!ts.isEntityName(left)) throw new Error("TypeAttrTsDsl: base must be an EntityName");
|
|
1551
1583
|
return ts.factory.createQualifiedName(left, this.$node(this._right));
|
|
1552
1584
|
}
|
|
1585
|
+
$validate() {
|
|
1586
|
+
const missing = this.missingRequiredCalls();
|
|
1587
|
+
if (missing.length === 0) return;
|
|
1588
|
+
throw new Error(`Type attribute missing ${missing.join(" and ")}`);
|
|
1589
|
+
}
|
|
1590
|
+
missingRequiredCalls() {
|
|
1591
|
+
const missing = [];
|
|
1592
|
+
if (!this._base) missing.push(".base()");
|
|
1593
|
+
if (!this._right) missing.push(".right()");
|
|
1594
|
+
return missing;
|
|
1595
|
+
}
|
|
1553
1596
|
};
|
|
1554
1597
|
|
|
1555
1598
|
//#endregion
|
|
@@ -1571,15 +1614,29 @@ var TypeExprTsDsl = class extends Mixed$46 {
|
|
|
1571
1614
|
super.analyze(ctx$1);
|
|
1572
1615
|
ctx$1.analyze(this._exprInput);
|
|
1573
1616
|
}
|
|
1617
|
+
/** Returns true when all required builder calls are present. */
|
|
1618
|
+
get isValid() {
|
|
1619
|
+
return this.missingRequiredCalls().length === 0;
|
|
1620
|
+
}
|
|
1574
1621
|
/** Accesses a nested type (e.g. `Foo.Bar`). */
|
|
1575
1622
|
attr(right) {
|
|
1576
1623
|
this._exprInput = isNode(right) ? ref(right.base(this._exprInput)) : ref(new TypeAttrTsDsl(this._exprInput, right));
|
|
1577
1624
|
return this;
|
|
1578
1625
|
}
|
|
1579
1626
|
toAst() {
|
|
1580
|
-
|
|
1627
|
+
this.$validate();
|
|
1581
1628
|
return ts.factory.createTypeReferenceNode(this.$type(this._exprInput), this.$generics());
|
|
1582
1629
|
}
|
|
1630
|
+
$validate() {
|
|
1631
|
+
const missing = this.missingRequiredCalls();
|
|
1632
|
+
if (missing.length === 0) return;
|
|
1633
|
+
throw new Error(`Type expression missing ${missing.join(" and ")}`);
|
|
1634
|
+
}
|
|
1635
|
+
missingRequiredCalls() {
|
|
1636
|
+
const missing = [];
|
|
1637
|
+
if (!this._exprInput) missing.push("name or .attr()");
|
|
1638
|
+
return missing;
|
|
1639
|
+
}
|
|
1583
1640
|
};
|
|
1584
1641
|
f.type.expr.set((...args) => new TypeExprTsDsl(...args));
|
|
1585
1642
|
|
|
@@ -1672,6 +1729,10 @@ var PatternTsDsl = class extends Mixed$43 {
|
|
|
1672
1729
|
analyze(ctx$1) {
|
|
1673
1730
|
super.analyze(ctx$1);
|
|
1674
1731
|
}
|
|
1732
|
+
/** Returns true when all required builder calls are present. */
|
|
1733
|
+
get isValid() {
|
|
1734
|
+
return this.missingRequiredCalls().length === 0;
|
|
1735
|
+
}
|
|
1675
1736
|
/** Defines an array pattern (e.g. `[a, b, c]`). */
|
|
1676
1737
|
array(...props) {
|
|
1677
1738
|
this.pattern = {
|
|
@@ -1698,7 +1759,7 @@ var PatternTsDsl = class extends Mixed$43 {
|
|
|
1698
1759
|
return this;
|
|
1699
1760
|
}
|
|
1700
1761
|
toAst() {
|
|
1701
|
-
|
|
1762
|
+
this.$validate();
|
|
1702
1763
|
if (this.pattern.kind === "object") {
|
|
1703
1764
|
const elements = Object.entries(this.pattern.values).map(([key, alias]) => key === alias ? ts.factory.createBindingElement(void 0, void 0, key, void 0) : ts.factory.createBindingElement(void 0, key, alias, void 0));
|
|
1704
1765
|
const spread = this.createSpread();
|
|
@@ -1713,6 +1774,16 @@ var PatternTsDsl = class extends Mixed$43 {
|
|
|
1713
1774
|
}
|
|
1714
1775
|
throw new Error("PatternTsDsl requires object() or array() pattern");
|
|
1715
1776
|
}
|
|
1777
|
+
$validate() {
|
|
1778
|
+
const missing = this.missingRequiredCalls();
|
|
1779
|
+
if (missing.length === 0) return;
|
|
1780
|
+
throw new Error(`Binding pattern missing ${missing.join(" and ")}`);
|
|
1781
|
+
}
|
|
1782
|
+
missingRequiredCalls() {
|
|
1783
|
+
const missing = [];
|
|
1784
|
+
if (!this.pattern) missing.push(".array() or .object()");
|
|
1785
|
+
return missing;
|
|
1786
|
+
}
|
|
1716
1787
|
createSpread() {
|
|
1717
1788
|
return this._spread ? ts.factory.createBindingElement(this.$node(new TokenTsDsl().spread()), void 0, this.$node(new IdTsDsl(this._spread))) : void 0;
|
|
1718
1789
|
}
|
|
@@ -1771,15 +1842,28 @@ var ParamTsDsl = class extends Mixed$42 {
|
|
|
1771
1842
|
ctx$1.analyze(this.name);
|
|
1772
1843
|
ctx$1.analyze(this._type);
|
|
1773
1844
|
}
|
|
1845
|
+
/** Returns true when all required builder calls are present. */
|
|
1846
|
+
get isValid() {
|
|
1847
|
+
return this.missingRequiredCalls().length === 0;
|
|
1848
|
+
}
|
|
1774
1849
|
/** Sets the parameter type. */
|
|
1775
1850
|
type(type) {
|
|
1776
1851
|
this._type = type instanceof TypeTsDsl ? type : new TypeExprTsDsl(type);
|
|
1777
1852
|
return this;
|
|
1778
1853
|
}
|
|
1779
1854
|
toAst() {
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1855
|
+
this.$validate();
|
|
1856
|
+
return ts.factory.createParameterDeclaration(this.$decorators(), void 0, this.$pattern() ?? this.name.toString(), this._optional ? this.$node(new TokenTsDsl().optional()) : void 0, this.$type(this._type), this.$value());
|
|
1857
|
+
}
|
|
1858
|
+
$validate() {
|
|
1859
|
+
const missing = this.missingRequiredCalls();
|
|
1860
|
+
if (missing.length === 0) return;
|
|
1861
|
+
throw new Error(`Parameter missing ${missing.join(" and ")}`);
|
|
1862
|
+
}
|
|
1863
|
+
missingRequiredCalls() {
|
|
1864
|
+
const missing = [];
|
|
1865
|
+
if (!this.$pattern() && !this.name.toString()) missing.push("name or pattern (.array()/.object())");
|
|
1866
|
+
return missing;
|
|
1783
1867
|
}
|
|
1784
1868
|
};
|
|
1785
1869
|
|
|
@@ -2094,6 +2178,10 @@ var ImplFuncTsDsl = class extends Mixed$35 {
|
|
|
2094
2178
|
ctx$1.popScope();
|
|
2095
2179
|
}
|
|
2096
2180
|
}
|
|
2181
|
+
/** Returns true when all required builder calls are present. */
|
|
2182
|
+
get isValid() {
|
|
2183
|
+
return this.missingRequiredCalls().length === 0;
|
|
2184
|
+
}
|
|
2097
2185
|
/** Switches the function to an arrow function form. */
|
|
2098
2186
|
arrow() {
|
|
2099
2187
|
this.mode = "arrow";
|
|
@@ -2110,9 +2198,9 @@ var ImplFuncTsDsl = class extends Mixed$35 {
|
|
|
2110
2198
|
return this;
|
|
2111
2199
|
}
|
|
2112
2200
|
toAst() {
|
|
2201
|
+
this.$validate();
|
|
2113
2202
|
const body = this.$node(new BlockTsDsl(...this._do).pretty());
|
|
2114
2203
|
if (this.mode === "decl") {
|
|
2115
|
-
if (!this.name.toString()) throw new Error("Function declaration requires a name");
|
|
2116
2204
|
const node$1 = ts.factory.createFunctionDeclaration([...this.$decorators(), ...this.modifiers], void 0, this.$node(this.name), this.$generics(), this.$params(), this.$returns(), body);
|
|
2117
2205
|
return this.$docs(node$1);
|
|
2118
2206
|
}
|
|
@@ -2123,6 +2211,16 @@ var ImplFuncTsDsl = class extends Mixed$35 {
|
|
|
2123
2211
|
const node = ts.factory.createArrowFunction(this.modifiers, this.$generics(), this.$params(), this.$returns(), void 0, body.statements.length === 1 && ts.isReturnStatement(body.statements[0]) && body.statements[0].expression ? body.statements[0].expression : body);
|
|
2124
2212
|
return this.$docs(node);
|
|
2125
2213
|
}
|
|
2214
|
+
$validate() {
|
|
2215
|
+
const missing = this.missingRequiredCalls();
|
|
2216
|
+
if (missing.length === 0) return;
|
|
2217
|
+
throw new Error(`Function ${this.mode} missing ${missing.join(" and ")}`);
|
|
2218
|
+
}
|
|
2219
|
+
missingRequiredCalls() {
|
|
2220
|
+
const missing = [];
|
|
2221
|
+
if (this.mode === "decl" && !this.name.toString()) missing.push("name");
|
|
2222
|
+
return missing;
|
|
2223
|
+
}
|
|
2126
2224
|
};
|
|
2127
2225
|
const FuncTsDsl = ImplFuncTsDsl;
|
|
2128
2226
|
|
|
@@ -2288,6 +2386,10 @@ var BinaryTsDsl = class extends Mixed$30 {
|
|
|
2288
2386
|
ctx$1.analyze(this._base);
|
|
2289
2387
|
ctx$1.analyze(this._expr);
|
|
2290
2388
|
}
|
|
2389
|
+
/** Returns true when all required builder calls are present. */
|
|
2390
|
+
get isValid() {
|
|
2391
|
+
return this.missingRequiredCalls().length === 0;
|
|
2392
|
+
}
|
|
2291
2393
|
/** Logical AND — `this && expr` */
|
|
2292
2394
|
and(expr) {
|
|
2293
2395
|
return this.opAndExpr("&&", expr);
|
|
@@ -2357,12 +2459,21 @@ var BinaryTsDsl = class extends Mixed$30 {
|
|
|
2357
2459
|
return this.opAndExpr("*", expr);
|
|
2358
2460
|
}
|
|
2359
2461
|
toAst() {
|
|
2360
|
-
|
|
2361
|
-
const expr = this.$node(this._expr);
|
|
2362
|
-
if (!expr) throw new Error("BinaryTsDsl: missing right-hand expression");
|
|
2462
|
+
this.$validate();
|
|
2363
2463
|
const base = this.$node(this._base);
|
|
2364
2464
|
const operator = typeof this._op === "string" ? this.opToToken(this._op) : this._op;
|
|
2365
|
-
return ts.factory.createBinaryExpression(base, operator,
|
|
2465
|
+
return ts.factory.createBinaryExpression(base, operator, this.$node(this._expr));
|
|
2466
|
+
}
|
|
2467
|
+
$validate() {
|
|
2468
|
+
const missing = this.missingRequiredCalls();
|
|
2469
|
+
if (missing.length === 0) return;
|
|
2470
|
+
throw new Error(`Binary expression missing ${missing.join(" and ")}`);
|
|
2471
|
+
}
|
|
2472
|
+
missingRequiredCalls() {
|
|
2473
|
+
const missing = [];
|
|
2474
|
+
if (!this._op) missing.push("operator (e.g., .eq(), .plus())");
|
|
2475
|
+
if (!this._expr) missing.push("right-hand expression");
|
|
2476
|
+
return missing;
|
|
2366
2477
|
}
|
|
2367
2478
|
/** Sets the binary operator and right-hand operand for this expression. */
|
|
2368
2479
|
opAndExpr(op, expr) {
|
|
@@ -2886,6 +2997,10 @@ var TernaryTsDsl = class extends Mixed$20 {
|
|
|
2886
2997
|
ctx$1.analyze(this._then);
|
|
2887
2998
|
ctx$1.analyze(this._else);
|
|
2888
2999
|
}
|
|
3000
|
+
/** Returns true when all required builder calls are present. */
|
|
3001
|
+
get isValid() {
|
|
3002
|
+
return this.missingRequiredCalls().length === 0;
|
|
3003
|
+
}
|
|
2889
3004
|
condition(condition) {
|
|
2890
3005
|
this._condition = condition;
|
|
2891
3006
|
return this;
|
|
@@ -2899,11 +3014,21 @@ var TernaryTsDsl = class extends Mixed$20 {
|
|
|
2899
3014
|
return this;
|
|
2900
3015
|
}
|
|
2901
3016
|
toAst() {
|
|
2902
|
-
|
|
2903
|
-
if (!this._then) throw new Error("Missing then expression in ternary");
|
|
2904
|
-
if (!this._else) throw new Error("Missing else expression in ternary");
|
|
3017
|
+
this.$validate();
|
|
2905
3018
|
return ts.factory.createConditionalExpression(this.$node(this._condition), void 0, this.$node(this._then), void 0, this.$node(this._else));
|
|
2906
3019
|
}
|
|
3020
|
+
$validate() {
|
|
3021
|
+
const missing = this.missingRequiredCalls();
|
|
3022
|
+
if (missing.length === 0) return;
|
|
3023
|
+
throw new Error(`Ternary expression missing ${missing.join(" and ")}`);
|
|
3024
|
+
}
|
|
3025
|
+
missingRequiredCalls() {
|
|
3026
|
+
const missing = [];
|
|
3027
|
+
if (!this._condition) missing.push(".condition()");
|
|
3028
|
+
if (!this._then) missing.push(".do()");
|
|
3029
|
+
if (!this._else) missing.push(".otherwise()");
|
|
3030
|
+
return missing;
|
|
3031
|
+
}
|
|
2907
3032
|
};
|
|
2908
3033
|
|
|
2909
3034
|
//#endregion
|
|
@@ -2981,6 +3106,10 @@ var IfTsDsl = class extends Mixed$18 {
|
|
|
2981
3106
|
}
|
|
2982
3107
|
}
|
|
2983
3108
|
}
|
|
3109
|
+
/** Returns true when all required builder calls are present. */
|
|
3110
|
+
get isValid() {
|
|
3111
|
+
return this.missingRequiredCalls().length === 0;
|
|
3112
|
+
}
|
|
2984
3113
|
condition(condition) {
|
|
2985
3114
|
this._condition = condition;
|
|
2986
3115
|
return this;
|
|
@@ -2990,10 +3119,20 @@ var IfTsDsl = class extends Mixed$18 {
|
|
|
2990
3119
|
return this;
|
|
2991
3120
|
}
|
|
2992
3121
|
toAst() {
|
|
2993
|
-
|
|
2994
|
-
if (!this._do) throw new Error("Missing then block in if");
|
|
3122
|
+
this.$validate();
|
|
2995
3123
|
return ts.factory.createIfStatement(this.$node(this._condition), this.$node(new BlockTsDsl(...this._do).pretty()), this._else ? this.$node(new BlockTsDsl(...this._else).pretty()) : void 0);
|
|
2996
3124
|
}
|
|
3125
|
+
$validate() {
|
|
3126
|
+
const missing = this.missingRequiredCalls();
|
|
3127
|
+
if (missing.length === 0) return;
|
|
3128
|
+
throw new Error(`If statement missing ${missing.join(" and ")}`);
|
|
3129
|
+
}
|
|
3130
|
+
missingRequiredCalls() {
|
|
3131
|
+
const missing = [];
|
|
3132
|
+
if (!this._condition) missing.push(".condition()");
|
|
3133
|
+
if (this._do.length === 0) missing.push(".do()");
|
|
3134
|
+
return missing;
|
|
3135
|
+
}
|
|
2997
3136
|
};
|
|
2998
3137
|
|
|
2999
3138
|
//#endregion
|
|
@@ -3088,6 +3227,10 @@ var TryTsDsl = class extends Mixed$15 {
|
|
|
3088
3227
|
}
|
|
3089
3228
|
}
|
|
3090
3229
|
}
|
|
3230
|
+
/** Returns true when all required builder calls are present. */
|
|
3231
|
+
get isValid() {
|
|
3232
|
+
return this.missingRequiredCalls().length === 0;
|
|
3233
|
+
}
|
|
3091
3234
|
catch(...items) {
|
|
3092
3235
|
this._catch = items;
|
|
3093
3236
|
return this;
|
|
@@ -3105,10 +3248,20 @@ var TryTsDsl = class extends Mixed$15 {
|
|
|
3105
3248
|
return this;
|
|
3106
3249
|
}
|
|
3107
3250
|
toAst() {
|
|
3108
|
-
|
|
3251
|
+
this.$validate();
|
|
3109
3252
|
const catchParam = this._catchArg ? this.$node(this._catchArg) : void 0;
|
|
3110
3253
|
return ts.factory.createTryStatement(this.$node(new BlockTsDsl(...this._try).pretty()), ts.factory.createCatchClause(catchParam ? ts.factory.createVariableDeclaration(catchParam) : void 0, this.$node(new BlockTsDsl(...this._catch ?? []).pretty())), this._finally ? this.$node(new BlockTsDsl(...this._finally).pretty()) : void 0);
|
|
3111
3254
|
}
|
|
3255
|
+
$validate() {
|
|
3256
|
+
const missing = this.missingRequiredCalls();
|
|
3257
|
+
if (missing.length === 0) return;
|
|
3258
|
+
throw new Error(`Try statement missing ${missing.join(" and ")}`);
|
|
3259
|
+
}
|
|
3260
|
+
missingRequiredCalls() {
|
|
3261
|
+
const missing = [];
|
|
3262
|
+
if (!this._try || this._try.length === 0) missing.push(".try()");
|
|
3263
|
+
return missing;
|
|
3264
|
+
}
|
|
3112
3265
|
};
|
|
3113
3266
|
|
|
3114
3267
|
//#endregion
|
|
@@ -3129,6 +3282,10 @@ var VarTsDsl = class extends Mixed$14 {
|
|
|
3129
3282
|
ctx$1.analyze(this.name);
|
|
3130
3283
|
ctx$1.analyze(this._type);
|
|
3131
3284
|
}
|
|
3285
|
+
/** Returns true when all required builder calls are present. */
|
|
3286
|
+
get isValid() {
|
|
3287
|
+
return this.missingRequiredCalls().length === 0;
|
|
3288
|
+
}
|
|
3132
3289
|
const() {
|
|
3133
3290
|
this.kind = ts.NodeFlags.Const;
|
|
3134
3291
|
return this;
|
|
@@ -3147,11 +3304,20 @@ var VarTsDsl = class extends Mixed$14 {
|
|
|
3147
3304
|
return this;
|
|
3148
3305
|
}
|
|
3149
3306
|
toAst() {
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
const node = ts.factory.createVariableStatement(this.modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, void 0, this.$type(this._type), this.$value())], this.kind));
|
|
3307
|
+
this.$validate();
|
|
3308
|
+
const node = ts.factory.createVariableStatement(this.modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(this.$pattern() ?? this.$node(this.name), void 0, this.$type(this._type), this.$value())], this.kind));
|
|
3153
3309
|
return this.$docs(this.$hint(node));
|
|
3154
3310
|
}
|
|
3311
|
+
$validate() {
|
|
3312
|
+
const missing = this.missingRequiredCalls();
|
|
3313
|
+
if (missing.length === 0) return;
|
|
3314
|
+
throw new Error(`Variable declaration missing ${missing.join(" and ")}`);
|
|
3315
|
+
}
|
|
3316
|
+
missingRequiredCalls() {
|
|
3317
|
+
const missing = [];
|
|
3318
|
+
if (!this.$pattern() && !this.name.toString()) missing.push("name or pattern (.array()/.object())");
|
|
3319
|
+
return missing;
|
|
3320
|
+
}
|
|
3155
3321
|
};
|
|
3156
3322
|
|
|
3157
3323
|
//#endregion
|
|
@@ -3173,16 +3339,31 @@ var TypeAliasTsDsl = class extends Mixed$13 {
|
|
|
3173
3339
|
ctx$1.analyze(this.name);
|
|
3174
3340
|
ctx$1.analyze(this.value);
|
|
3175
3341
|
}
|
|
3342
|
+
/** Returns true when all required builder calls are present. */
|
|
3343
|
+
get isValid() {
|
|
3344
|
+
return this.missingRequiredCalls().length === 0;
|
|
3345
|
+
}
|
|
3176
3346
|
/** Sets the type expression on the right-hand side of `= ...`. */
|
|
3177
3347
|
type(node) {
|
|
3178
3348
|
this.value = node;
|
|
3179
3349
|
return this;
|
|
3180
3350
|
}
|
|
3181
3351
|
toAst() {
|
|
3182
|
-
|
|
3352
|
+
this.$validate();
|
|
3183
3353
|
const node = ts.factory.createTypeAliasDeclaration(this.modifiers, this.$node(this.name), this.$generics(), this.$type(this.value));
|
|
3184
3354
|
return this.$docs(node);
|
|
3185
3355
|
}
|
|
3356
|
+
$validate() {
|
|
3357
|
+
const missing = this.missingRequiredCalls();
|
|
3358
|
+
if (missing.length === 0) return;
|
|
3359
|
+
const name = this.name.toString();
|
|
3360
|
+
throw new Error(`Type alias${name ? ` "${name}"` : ""} missing ${missing.join(" and ")}`);
|
|
3361
|
+
}
|
|
3362
|
+
missingRequiredCalls() {
|
|
3363
|
+
const missing = [];
|
|
3364
|
+
if (!this.value) missing.push(".type()");
|
|
3365
|
+
return missing;
|
|
3366
|
+
}
|
|
3186
3367
|
};
|
|
3187
3368
|
|
|
3188
3369
|
//#endregion
|
|
@@ -3317,17 +3498,32 @@ var TypePropTsDsl = class extends Mixed$9 {
|
|
|
3317
3498
|
super.analyze(ctx$1);
|
|
3318
3499
|
ctx$1.analyze(this._type);
|
|
3319
3500
|
}
|
|
3501
|
+
/** Returns true when all required builder calls are present. */
|
|
3502
|
+
get isValid() {
|
|
3503
|
+
return this.missingRequiredCalls().length === 0;
|
|
3504
|
+
}
|
|
3320
3505
|
/** Sets the property type. */
|
|
3321
3506
|
type(type) {
|
|
3322
3507
|
this._type = ref(type);
|
|
3323
3508
|
return this;
|
|
3324
3509
|
}
|
|
3325
3510
|
toAst() {
|
|
3511
|
+
this.$validate();
|
|
3326
3512
|
const name = this.name.toString();
|
|
3327
|
-
if (!this._type || !name) throw new Error(`Type not specified for property '${name}'`);
|
|
3328
3513
|
const node = ts.factory.createPropertySignature(this.modifiers, this.$node(safePropName(name)), this._optional ? this.$node(new TokenTsDsl().optional()) : void 0, this.$type(this._type));
|
|
3329
3514
|
return this.$docs(node);
|
|
3330
3515
|
}
|
|
3516
|
+
$validate() {
|
|
3517
|
+
const missing = this.missingRequiredCalls();
|
|
3518
|
+
if (missing.length === 0) return;
|
|
3519
|
+
const name = this.name.toString();
|
|
3520
|
+
throw new Error(`Type property${name ? ` "${name}"` : ""} missing ${missing.join(" and ")}`);
|
|
3521
|
+
}
|
|
3522
|
+
missingRequiredCalls() {
|
|
3523
|
+
const missing = [];
|
|
3524
|
+
if (!this._type) missing.push(".type()");
|
|
3525
|
+
return missing;
|
|
3526
|
+
}
|
|
3331
3527
|
};
|
|
3332
3528
|
|
|
3333
3529
|
//#endregion
|
|
@@ -3424,12 +3620,25 @@ var TypeFuncTsDsl = class extends Mixed$6 {
|
|
|
3424
3620
|
analyze(ctx$1) {
|
|
3425
3621
|
super.analyze(ctx$1);
|
|
3426
3622
|
}
|
|
3623
|
+
/** Returns true when all required builder calls are present. */
|
|
3624
|
+
get isValid() {
|
|
3625
|
+
return this.missingRequiredCalls().length === 0;
|
|
3626
|
+
}
|
|
3427
3627
|
toAst() {
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
const node = ts.factory.createFunctionTypeNode(this.$generics(), this.$params(), returns);
|
|
3628
|
+
this.$validate();
|
|
3629
|
+
const node = ts.factory.createFunctionTypeNode(this.$generics(), this.$params(), this.$returns());
|
|
3431
3630
|
return this.$docs(node);
|
|
3432
3631
|
}
|
|
3632
|
+
$validate() {
|
|
3633
|
+
const missing = this.missingRequiredCalls();
|
|
3634
|
+
if (missing.length === 0) return;
|
|
3635
|
+
throw new Error(`Function type missing ${missing.join(" and ")}`);
|
|
3636
|
+
}
|
|
3637
|
+
missingRequiredCalls() {
|
|
3638
|
+
const missing = [];
|
|
3639
|
+
if (this.$returns() === void 0) missing.push(".returns()");
|
|
3640
|
+
return missing;
|
|
3641
|
+
}
|
|
3433
3642
|
};
|
|
3434
3643
|
|
|
3435
3644
|
//#endregion
|
|
@@ -3450,6 +3659,10 @@ var TypeIdxTsDsl = class extends Mixed$5 {
|
|
|
3450
3659
|
ctx$1.analyze(this._base);
|
|
3451
3660
|
ctx$1.analyze(this._index);
|
|
3452
3661
|
}
|
|
3662
|
+
/** Returns true when all required builder calls are present. */
|
|
3663
|
+
get isValid() {
|
|
3664
|
+
return this.missingRequiredCalls().length === 0;
|
|
3665
|
+
}
|
|
3453
3666
|
base(base) {
|
|
3454
3667
|
this._base = base;
|
|
3455
3668
|
return this;
|
|
@@ -3459,8 +3672,20 @@ var TypeIdxTsDsl = class extends Mixed$5 {
|
|
|
3459
3672
|
return this;
|
|
3460
3673
|
}
|
|
3461
3674
|
toAst() {
|
|
3675
|
+
this.$validate();
|
|
3462
3676
|
return ts.factory.createIndexedAccessTypeNode(this.$type(this._base), this.$type(this._index));
|
|
3463
3677
|
}
|
|
3678
|
+
$validate() {
|
|
3679
|
+
const missing = this.missingRequiredCalls();
|
|
3680
|
+
if (missing.length === 0) return;
|
|
3681
|
+
throw new Error(`Indexed access type missing ${missing.join(" and ")}`);
|
|
3682
|
+
}
|
|
3683
|
+
missingRequiredCalls() {
|
|
3684
|
+
const missing = [];
|
|
3685
|
+
if (this._base === void 0) missing.push(".base()");
|
|
3686
|
+
if (this._index === void 0) missing.push(".index()");
|
|
3687
|
+
return missing;
|
|
3688
|
+
}
|
|
3464
3689
|
};
|
|
3465
3690
|
f.type.idx.set((...args) => new TypeIdxTsDsl(...args));
|
|
3466
3691
|
|
|
@@ -3751,7 +3976,7 @@ function astToString(node) {
|
|
|
3751
3976
|
return result;
|
|
3752
3977
|
}
|
|
3753
3978
|
}
|
|
3754
|
-
|
|
3979
|
+
function moduleSortKey({ file, fromFile, preferFileExtension, root }) {
|
|
3755
3980
|
const filePath = file.finalPath.split(path.sep).join("/");
|
|
3756
3981
|
let modulePath = fromFile.finalPath.split(path.sep).join("/");
|
|
3757
3982
|
if (fromFile.external && !path.isAbsolute(modulePath)) return [
|
|
@@ -3781,7 +4006,7 @@ const moduleSortKey = ({ file, fromFile, preferFileExtension, root }) => {
|
|
|
3781
4006
|
parentCount,
|
|
3782
4007
|
modulePath
|
|
3783
4008
|
];
|
|
3784
|
-
}
|
|
4009
|
+
}
|
|
3785
4010
|
|
|
3786
4011
|
//#endregion
|
|
3787
4012
|
//#region src/ts-dsl/utils/render.ts
|
|
@@ -4472,8 +4697,8 @@ function isInstance(plugin) {
|
|
|
4472
4697
|
return config.container === "class" && config.methods === "instance" && config.strategy !== "flat";
|
|
4473
4698
|
}
|
|
4474
4699
|
function attachComment$1(args) {
|
|
4475
|
-
const { node, operation } = args;
|
|
4476
|
-
return node.$if(createOperationComment(operation), (n, v) => n.doc(v));
|
|
4700
|
+
const { node, operation, plugin } = args;
|
|
4701
|
+
return node.$if(plugin.config.comments && createOperationComment(operation), (n, v) => n.doc(v));
|
|
4477
4702
|
}
|
|
4478
4703
|
function createShellMeta(node) {
|
|
4479
4704
|
return {
|
|
@@ -4614,7 +4839,8 @@ function toNode(model, plugin) {
|
|
|
4614
4839
|
}));
|
|
4615
4840
|
node$1 = attachComment$1({
|
|
4616
4841
|
node: node$1,
|
|
4617
|
-
operation
|
|
4842
|
+
operation,
|
|
4843
|
+
plugin
|
|
4618
4844
|
});
|
|
4619
4845
|
nodes$1.push(node$1);
|
|
4620
4846
|
exampleIntent(node$1, operation, plugin);
|
|
@@ -4634,7 +4860,8 @@ function toNode(model, plugin) {
|
|
|
4634
4860
|
const method = implementFn({
|
|
4635
4861
|
node: $.method(createFnSymbol(plugin, item), (m) => attachComment$1({
|
|
4636
4862
|
node: m,
|
|
4637
|
-
operation
|
|
4863
|
+
operation,
|
|
4864
|
+
plugin
|
|
4638
4865
|
}).public().static(!isAngularClient && !isInstance(plugin))),
|
|
4639
4866
|
operation,
|
|
4640
4867
|
plugin
|
|
@@ -4694,8 +4921,8 @@ function hasOperationSse({ operation }) {
|
|
|
4694
4921
|
//#region src/plugins/@angular/common/shared/node.ts
|
|
4695
4922
|
const source = globalThis.Symbol("@angular/common");
|
|
4696
4923
|
function attachComment(args) {
|
|
4697
|
-
const { node, operation } = args;
|
|
4698
|
-
return node.$if(createOperationComment(operation), (n, v) => n.doc(v));
|
|
4924
|
+
const { node, operation, plugin } = args;
|
|
4925
|
+
return node.$if(plugin.config.comments && createOperationComment(operation), (n, v) => n.doc(v));
|
|
4699
4926
|
}
|
|
4700
4927
|
function createHttpRequestFnMeta(operation) {
|
|
4701
4928
|
return {
|
|
@@ -4841,7 +5068,8 @@ function toHttpRequestNode(model, plugin) {
|
|
|
4841
5068
|
}));
|
|
4842
5069
|
node$1 = attachComment({
|
|
4843
5070
|
node: node$1,
|
|
4844
|
-
operation
|
|
5071
|
+
operation,
|
|
5072
|
+
plugin
|
|
4845
5073
|
});
|
|
4846
5074
|
nodes$1.push(node$1);
|
|
4847
5075
|
}
|
|
@@ -4858,7 +5086,8 @@ function toHttpRequestNode(model, plugin) {
|
|
|
4858
5086
|
node.do(implementHttpRequestFn({
|
|
4859
5087
|
node: $.method(createHttpRequestFnSymbol(plugin, item), (m) => attachComment({
|
|
4860
5088
|
node: m,
|
|
4861
|
-
operation
|
|
5089
|
+
operation,
|
|
5090
|
+
plugin
|
|
4862
5091
|
}).public()),
|
|
4863
5092
|
operation,
|
|
4864
5093
|
plugin
|
|
@@ -4887,7 +5116,8 @@ function toHttpResourceNode(model, plugin) {
|
|
|
4887
5116
|
}));
|
|
4888
5117
|
node$1 = attachComment({
|
|
4889
5118
|
node: node$1,
|
|
4890
|
-
operation
|
|
5119
|
+
operation,
|
|
5120
|
+
plugin
|
|
4891
5121
|
});
|
|
4892
5122
|
nodes$1.push(node$1);
|
|
4893
5123
|
}
|
|
@@ -4904,7 +5134,8 @@ function toHttpResourceNode(model, plugin) {
|
|
|
4904
5134
|
node.do(implementHttpResourceFn({
|
|
4905
5135
|
node: $.method(createHttpResourceFnSymbol(plugin, item), (m) => attachComment({
|
|
4906
5136
|
node: m,
|
|
4907
|
-
operation
|
|
5137
|
+
operation,
|
|
5138
|
+
plugin
|
|
4908
5139
|
}).public()),
|
|
4909
5140
|
operation,
|
|
4910
5141
|
plugin
|
|
@@ -5005,7 +5236,10 @@ const handler$11 = ({ plugin }) => {
|
|
|
5005
5236
|
//#endregion
|
|
5006
5237
|
//#region src/plugins/@angular/common/config.ts
|
|
5007
5238
|
const defaultConfig$23 = {
|
|
5008
|
-
config: {
|
|
5239
|
+
config: {
|
|
5240
|
+
comments: true,
|
|
5241
|
+
includeInEntry: false
|
|
5242
|
+
},
|
|
5009
5243
|
dependencies: ["@hey-api/client-angular", "@hey-api/sdk"],
|
|
5010
5244
|
handler: handler$11,
|
|
5011
5245
|
name: "@angular/common",
|
|
@@ -5032,7 +5266,7 @@ const defaultConfig$22 = {
|
|
|
5032
5266
|
api: new Api$4(),
|
|
5033
5267
|
config: {
|
|
5034
5268
|
case: "camelCase",
|
|
5035
|
-
|
|
5269
|
+
includeInEntry: false
|
|
5036
5270
|
},
|
|
5037
5271
|
handler: () => {},
|
|
5038
5272
|
name: "@faker-js/faker",
|
|
@@ -5063,7 +5297,7 @@ const defineConfig$22 = definePluginConfig(defaultConfig$22);
|
|
|
5063
5297
|
const clientDefaultConfig = {
|
|
5064
5298
|
baseUrl: true,
|
|
5065
5299
|
bundle: true,
|
|
5066
|
-
|
|
5300
|
+
includeInEntry: false
|
|
5067
5301
|
};
|
|
5068
5302
|
const clientDefaultMeta = {
|
|
5069
5303
|
dependencies: ["@hey-api/typescript"],
|
|
@@ -5075,22 +5309,48 @@ const clientDefaultMeta = {
|
|
|
5075
5309
|
const __filename = fileURLToPath(import.meta.url);
|
|
5076
5310
|
const __dirname = path.dirname(__filename);
|
|
5077
5311
|
/**
|
|
5312
|
+
* Dev mode: 'src' appears after 'dist' (or dist doesn't exist), and 'generate' follows 'src'
|
|
5313
|
+
*/
|
|
5314
|
+
function isDevMode() {
|
|
5315
|
+
const normalized = __dirname.split(path.sep);
|
|
5316
|
+
const srcIndex = normalized.lastIndexOf("src");
|
|
5317
|
+
const distIndex = normalized.lastIndexOf("dist");
|
|
5318
|
+
return srcIndex !== -1 && srcIndex > distIndex && srcIndex === normalized.length - 2 && normalized[srcIndex + 1] === "generate";
|
|
5319
|
+
}
|
|
5320
|
+
/**
|
|
5321
|
+
* Returns paths to client bundle files based on execution context
|
|
5322
|
+
*/
|
|
5323
|
+
function getClientBundlePaths(pluginName) {
|
|
5324
|
+
const clientName = pluginName.slice(16);
|
|
5325
|
+
if (isDevMode()) {
|
|
5326
|
+
const pluginsDir = path.resolve(__dirname, "..", "plugins", "@hey-api");
|
|
5327
|
+
return {
|
|
5328
|
+
clientPath: path.resolve(pluginsDir, `client-${clientName}`, "bundle"),
|
|
5329
|
+
corePath: path.resolve(pluginsDir, "client-core", "bundle")
|
|
5330
|
+
};
|
|
5331
|
+
}
|
|
5332
|
+
return {
|
|
5333
|
+
clientPath: path.resolve(__dirname, "clients", clientName),
|
|
5334
|
+
corePath: path.resolve(__dirname, "clients", "core")
|
|
5335
|
+
};
|
|
5336
|
+
}
|
|
5337
|
+
/**
|
|
5078
5338
|
* Returns absolute path to the client folder. This is hard-coded for now.
|
|
5079
5339
|
*/
|
|
5080
|
-
|
|
5340
|
+
function clientFolderAbsolutePath(config) {
|
|
5081
5341
|
const client = getClientPlugin(config);
|
|
5082
5342
|
if ("bundle" in client.config && client.config.bundle) {
|
|
5083
5343
|
const renamed = config._FRAGILE_CLIENT_BUNDLE_RENAMED;
|
|
5084
5344
|
return path.resolve(config.output.path, "client", `${renamed?.get("index") ?? "index"}.ts`);
|
|
5085
5345
|
}
|
|
5086
5346
|
return client.name;
|
|
5087
|
-
}
|
|
5347
|
+
}
|
|
5088
5348
|
/**
|
|
5089
5349
|
* Recursively copies files and directories.
|
|
5090
5350
|
* This is a PnP-compatible alternative to fs.cpSync that works with Yarn PnP's
|
|
5091
5351
|
* virtualized filesystem.
|
|
5092
5352
|
*/
|
|
5093
|
-
|
|
5353
|
+
function copyRecursivePnP(src, dest) {
|
|
5094
5354
|
if (fs.statSync(src).isDirectory()) {
|
|
5095
5355
|
if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
|
|
5096
5356
|
const files = fs.readdirSync(src);
|
|
@@ -5099,8 +5359,8 @@ const copyRecursivePnP = (src, dest) => {
|
|
|
5099
5359
|
const content = fs.readFileSync(src);
|
|
5100
5360
|
fs.writeFileSync(dest, content);
|
|
5101
5361
|
}
|
|
5102
|
-
}
|
|
5103
|
-
|
|
5362
|
+
}
|
|
5363
|
+
function renameFile({ filePath, project, renamed }) {
|
|
5104
5364
|
const extension = path.extname(filePath);
|
|
5105
5365
|
const name = path.basename(filePath, extension);
|
|
5106
5366
|
const renamedName = project.fileName?.(name) || name;
|
|
@@ -5109,9 +5369,13 @@ const renameFile = ({ filePath, project, renamed }) => {
|
|
|
5109
5369
|
fs.renameSync(filePath, path.resolve(outputPath, `${renamedName}${extension}`));
|
|
5110
5370
|
renamed.set(name, renamedName);
|
|
5111
5371
|
}
|
|
5112
|
-
}
|
|
5113
|
-
|
|
5372
|
+
}
|
|
5373
|
+
function replaceImports({ filePath, isDevMode: isDevMode$1, meta, renamed }) {
|
|
5114
5374
|
let content = fs.readFileSync(filePath, "utf8");
|
|
5375
|
+
if (isDevMode$1) {
|
|
5376
|
+
content = content.replace(/from\s+['"]\.\.\/\.\.\/client-core\/bundle\//g, "from '../core/");
|
|
5377
|
+
content = content.replace(/from\s+['"]\.\.\/\.\.\/client-core\/bundle['"]/g, "from '../core'");
|
|
5378
|
+
}
|
|
5115
5379
|
content = content.replace(/from\s+['"](\.\.?\/[^'"]*?)['"]/g, (match, importPath) => {
|
|
5116
5380
|
const importIndex = match.indexOf(importPath);
|
|
5117
5381
|
const extension = path.extname(importPath);
|
|
@@ -5124,20 +5388,21 @@ const replaceImports = ({ filePath, meta, renamed }) => {
|
|
|
5124
5388
|
|
|
5125
5389
|
${content}`;
|
|
5126
5390
|
fs.writeFileSync(filePath, content, "utf8");
|
|
5127
|
-
}
|
|
5391
|
+
}
|
|
5128
5392
|
/**
|
|
5129
5393
|
* Creates a `client` folder containing the same modules as the client package.
|
|
5130
5394
|
*/
|
|
5131
|
-
|
|
5395
|
+
function generateClientBundle({ meta, outputPath, plugin, project }) {
|
|
5132
5396
|
const renamed = /* @__PURE__ */ new Map();
|
|
5397
|
+
const devMode = isDevMode();
|
|
5133
5398
|
if (plugin.name.startsWith("@hey-api/client-")) {
|
|
5399
|
+
const { clientPath, corePath } = getClientBundlePaths(plugin.name);
|
|
5134
5400
|
const coreOutputPath = path.resolve(outputPath, "core");
|
|
5135
5401
|
ensureDirSync(coreOutputPath);
|
|
5136
|
-
copyRecursivePnP(
|
|
5402
|
+
copyRecursivePnP(corePath, coreOutputPath);
|
|
5137
5403
|
const clientOutputPath = path.resolve(outputPath, "client");
|
|
5138
5404
|
ensureDirSync(clientOutputPath);
|
|
5139
|
-
|
|
5140
|
-
copyRecursivePnP(path.resolve(__dirname, "clients", clientDistFolderName), clientOutputPath);
|
|
5405
|
+
copyRecursivePnP(clientPath, clientOutputPath);
|
|
5141
5406
|
if (project) {
|
|
5142
5407
|
const copiedCoreFiles = fs.readdirSync(coreOutputPath);
|
|
5143
5408
|
for (const file of copiedCoreFiles) renameFile({
|
|
@@ -5155,12 +5420,14 @@ const generateClientBundle = ({ meta, outputPath, plugin, project }) => {
|
|
|
5155
5420
|
const coreFiles = fs.readdirSync(coreOutputPath);
|
|
5156
5421
|
for (const file of coreFiles) replaceImports({
|
|
5157
5422
|
filePath: path.resolve(coreOutputPath, file),
|
|
5423
|
+
isDevMode: devMode,
|
|
5158
5424
|
meta,
|
|
5159
5425
|
renamed
|
|
5160
5426
|
});
|
|
5161
5427
|
const clientFiles = fs.readdirSync(clientOutputPath);
|
|
5162
5428
|
for (const file of clientFiles) replaceImports({
|
|
5163
5429
|
filePath: path.resolve(clientOutputPath, file),
|
|
5430
|
+
isDevMode: devMode,
|
|
5164
5431
|
meta,
|
|
5165
5432
|
renamed
|
|
5166
5433
|
});
|
|
@@ -5183,7 +5450,7 @@ const generateClientBundle = ({ meta, outputPath, plugin, project }) => {
|
|
|
5183
5450
|
const dirPath = path.resolve(outputPath, "client");
|
|
5184
5451
|
ensureDirSync(dirPath);
|
|
5185
5452
|
for (const file of distFiles) fs.copyFileSync(path.resolve(clientDistPath, file), path.resolve(dirPath, file));
|
|
5186
|
-
}
|
|
5453
|
+
}
|
|
5187
5454
|
|
|
5188
5455
|
//#endregion
|
|
5189
5456
|
//#region src/plugins/@hey-api/client-core/client.ts
|
|
@@ -5626,7 +5893,7 @@ const handler$10 = ({ plugin }) => {
|
|
|
5626
5893
|
//#region src/plugins/@hey-api/schemas/config.ts
|
|
5627
5894
|
const defaultConfig$14 = {
|
|
5628
5895
|
config: {
|
|
5629
|
-
|
|
5896
|
+
includeInEntry: false,
|
|
5630
5897
|
nameBuilder: (name) => `${name}Schema`,
|
|
5631
5898
|
type: "json"
|
|
5632
5899
|
},
|
|
@@ -5936,7 +6203,8 @@ const defaultConfig$13 = {
|
|
|
5936
6203
|
config: {
|
|
5937
6204
|
auth: true,
|
|
5938
6205
|
client: true,
|
|
5939
|
-
|
|
6206
|
+
comments: true,
|
|
6207
|
+
includeInEntry: true,
|
|
5940
6208
|
paramsStructure: "grouped",
|
|
5941
6209
|
responseStyle: "fields",
|
|
5942
6210
|
transformer: false,
|
|
@@ -6156,7 +6424,7 @@ const defaultConfig$12 = {
|
|
|
6156
6424
|
config: {
|
|
6157
6425
|
bigInt: true,
|
|
6158
6426
|
dates: true,
|
|
6159
|
-
|
|
6427
|
+
includeInEntry: false,
|
|
6160
6428
|
transformers: [],
|
|
6161
6429
|
typeTransformers: []
|
|
6162
6430
|
},
|
|
@@ -6257,10 +6525,10 @@ const exportType = ({ plugin, schema, state, type }) => {
|
|
|
6257
6525
|
tags: fromRef(state.tags),
|
|
6258
6526
|
tool: "typescript"
|
|
6259
6527
|
} });
|
|
6260
|
-
const objectNode = $.const(symbolObject).export().$if(createSchemaComment(schema), (c, v) => c.doc(v)).assign($.object(...enumObject.obj.map((item) => $.prop({
|
|
6528
|
+
const objectNode = $.const(symbolObject).export().$if(plugin.config.comments && createSchemaComment(schema), (c, v) => c.doc(v)).assign($.object(...enumObject.obj.map((item) => $.prop({
|
|
6261
6529
|
kind: "prop",
|
|
6262
6530
|
name: item.key
|
|
6263
|
-
}).$if(createSchemaComment(item.schema), (p, v) => p.doc(v)).value($.fromValue(item.schema.const)))).as("const"));
|
|
6531
|
+
}).$if(plugin.config.comments && createSchemaComment(item.schema), (p, v) => p.doc(v)).value($.fromValue(item.schema.const)))).as("const"));
|
|
6264
6532
|
plugin.node(objectNode);
|
|
6265
6533
|
const symbol$1 = plugin.symbol(applyNaming(refToName($ref), plugin.config.definitions), { meta: {
|
|
6266
6534
|
category: "type",
|
|
@@ -6270,7 +6538,7 @@ const exportType = ({ plugin, schema, state, type }) => {
|
|
|
6270
6538
|
tags: fromRef(state.tags),
|
|
6271
6539
|
tool: "typescript"
|
|
6272
6540
|
} });
|
|
6273
|
-
const node$1 = $.type.alias(symbol$1).export().$if(createSchemaComment(schema), (t, v) => t.doc(v)).type($.type(symbol$1).idx($.type(symbol$1).typeofType().keyof()).typeofType());
|
|
6541
|
+
const node$1 = $.type.alias(symbol$1).export().$if(plugin.config.comments && createSchemaComment(schema), (t, v) => t.doc(v)).type($.type(symbol$1).idx($.type(symbol$1).typeofType().keyof()).typeofType());
|
|
6274
6542
|
plugin.node(node$1);
|
|
6275
6543
|
return;
|
|
6276
6544
|
} else if (plugin.config.enums.mode === "typescript" || plugin.config.enums.mode === "typescript-const") {
|
|
@@ -6283,7 +6551,7 @@ const exportType = ({ plugin, schema, state, type }) => {
|
|
|
6283
6551
|
tags: fromRef(state.tags),
|
|
6284
6552
|
tool: "typescript"
|
|
6285
6553
|
} });
|
|
6286
|
-
const enumNode = $.enum(symbol$1).export().$if(createSchemaComment(schema), (e, v) => e.doc(v)).const(plugin.config.enums.mode === "typescript-const").members(...enumObject.obj.map((item) => $.member(item.key).$if(createSchemaComment(item.schema), (m, v) => m.doc(v)).value($.fromValue(item.schema.const))));
|
|
6554
|
+
const enumNode = $.enum(symbol$1).export().$if(plugin.config.comments && createSchemaComment(schema), (e, v) => e.doc(v)).const(plugin.config.enums.mode === "typescript-const").members(...enumObject.obj.map((item) => $.member(item.key).$if(plugin.config.comments && createSchemaComment(item.schema), (m, v) => m.doc(v)).value($.fromValue(item.schema.const))));
|
|
6287
6555
|
plugin.node(enumNode);
|
|
6288
6556
|
return;
|
|
6289
6557
|
}
|
|
@@ -6297,7 +6565,7 @@ const exportType = ({ plugin, schema, state, type }) => {
|
|
|
6297
6565
|
tags: fromRef(state.tags),
|
|
6298
6566
|
tool: "typescript"
|
|
6299
6567
|
} });
|
|
6300
|
-
const node = $.type.alias(symbol).export().$if(createSchemaComment(schema), (t, v) => t.doc(v)).type(type);
|
|
6568
|
+
const node = $.type.alias(symbol).export().$if(plugin.config.comments && createSchemaComment(schema), (t, v) => t.doc(v)).type(type);
|
|
6301
6569
|
plugin.node(node);
|
|
6302
6570
|
};
|
|
6303
6571
|
|
|
@@ -6457,7 +6725,7 @@ const operationToDataType = ({ operation, plugin, state }) => {
|
|
|
6457
6725
|
tags: fromRef(state.tags),
|
|
6458
6726
|
tool: "typescript"
|
|
6459
6727
|
} });
|
|
6460
|
-
const node$1 = $.type.alias(symbolWebhookPayload).export().$if(createSchemaComment(operation.body.schema), (t, v) => t.doc(v)).type(irSchemaToAst$5({
|
|
6728
|
+
const node$1 = $.type.alias(symbolWebhookPayload).export().$if(plugin.config.comments && createSchemaComment(operation.body.schema), (t, v) => t.doc(v)).type(irSchemaToAst$5({
|
|
6461
6729
|
plugin,
|
|
6462
6730
|
schema: operation.body.schema,
|
|
6463
6731
|
state
|
|
@@ -6591,7 +6859,7 @@ const objectToAst$5 = ({ plugin, schema, state }) => {
|
|
|
6591
6859
|
}
|
|
6592
6860
|
});
|
|
6593
6861
|
const isRequired = required.includes(name);
|
|
6594
|
-
shape.prop(name, (p) => p.$if(createSchemaComment(property), (p$1, v) => p$1.doc(v)).readonly(property.accessScope === "read").required(isRequired).type(propertyType));
|
|
6862
|
+
shape.prop(name, (p) => p.$if(plugin.config.comments && createSchemaComment(property), (p$1, v) => p$1.doc(v)).readonly(property.accessScope === "read").required(isRequired).type(propertyType));
|
|
6595
6863
|
indexSchemas.push(property);
|
|
6596
6864
|
if (!isRequired) hasOptionalProperties = true;
|
|
6597
6865
|
}
|
|
@@ -6926,7 +7194,8 @@ const defaultConfig$11 = {
|
|
|
6926
7194
|
api: new Api$3(),
|
|
6927
7195
|
config: {
|
|
6928
7196
|
case: "PascalCase",
|
|
6929
|
-
|
|
7197
|
+
comments: true,
|
|
7198
|
+
includeInEntry: true,
|
|
6930
7199
|
topType: "unknown"
|
|
6931
7200
|
},
|
|
6932
7201
|
handler: handler$7,
|
|
@@ -7298,7 +7567,7 @@ const defaultConfig$10 = {
|
|
|
7298
7567
|
config: {
|
|
7299
7568
|
case: "camelCase",
|
|
7300
7569
|
comments: true,
|
|
7301
|
-
|
|
7570
|
+
includeInEntry: false
|
|
7302
7571
|
},
|
|
7303
7572
|
dependencies: ["@hey-api/typescript", "@hey-api/sdk"],
|
|
7304
7573
|
handler: handler$6,
|
|
@@ -7752,7 +8021,7 @@ const defaultConfig$9 = {
|
|
|
7752
8021
|
config: {
|
|
7753
8022
|
case: "camelCase",
|
|
7754
8023
|
comments: true,
|
|
7755
|
-
|
|
8024
|
+
includeInEntry: false
|
|
7756
8025
|
},
|
|
7757
8026
|
dependencies: ["@hey-api/sdk", "@hey-api/typescript"],
|
|
7758
8027
|
handler: handler$5,
|
|
@@ -7839,7 +8108,7 @@ const defaultConfig$8 = {
|
|
|
7839
8108
|
config: {
|
|
7840
8109
|
case: "camelCase",
|
|
7841
8110
|
comments: true,
|
|
7842
|
-
|
|
8111
|
+
includeInEntry: false
|
|
7843
8112
|
},
|
|
7844
8113
|
dependencies: ["@hey-api/sdk", "@hey-api/typescript"],
|
|
7845
8114
|
handler: handler$5,
|
|
@@ -7955,7 +8224,7 @@ const defaultConfig$7 = {
|
|
|
7955
8224
|
config: {
|
|
7956
8225
|
case: "camelCase",
|
|
7957
8226
|
comments: true,
|
|
7958
|
-
|
|
8227
|
+
includeInEntry: false
|
|
7959
8228
|
},
|
|
7960
8229
|
dependencies: ["@hey-api/sdk", "@hey-api/typescript"],
|
|
7961
8230
|
handler: handler$5,
|
|
@@ -8042,7 +8311,7 @@ const defaultConfig$6 = {
|
|
|
8042
8311
|
config: {
|
|
8043
8312
|
case: "camelCase",
|
|
8044
8313
|
comments: true,
|
|
8045
|
-
|
|
8314
|
+
includeInEntry: false
|
|
8046
8315
|
},
|
|
8047
8316
|
dependencies: ["@hey-api/sdk", "@hey-api/typescript"],
|
|
8048
8317
|
handler: handler$5,
|
|
@@ -8129,7 +8398,7 @@ const defaultConfig$5 = {
|
|
|
8129
8398
|
config: {
|
|
8130
8399
|
case: "camelCase",
|
|
8131
8400
|
comments: true,
|
|
8132
|
-
|
|
8401
|
+
includeInEntry: false
|
|
8133
8402
|
},
|
|
8134
8403
|
dependencies: ["@hey-api/sdk", "@hey-api/typescript"],
|
|
8135
8404
|
handler: handler$5,
|
|
@@ -8621,7 +8890,7 @@ const defaultConfig$4 = {
|
|
|
8621
8890
|
config: {
|
|
8622
8891
|
case: "PascalCase",
|
|
8623
8892
|
comments: true,
|
|
8624
|
-
|
|
8893
|
+
includeInEntry: false,
|
|
8625
8894
|
metadata: false
|
|
8626
8895
|
},
|
|
8627
8896
|
handler: handler$4,
|
|
@@ -8884,7 +9153,7 @@ const handler$3 = ({ plugin }) => {
|
|
|
8884
9153
|
//#endregion
|
|
8885
9154
|
//#region src/plugins/fastify/config.ts
|
|
8886
9155
|
const defaultConfig$3 = {
|
|
8887
|
-
config: {
|
|
9156
|
+
config: { includeInEntry: false },
|
|
8888
9157
|
dependencies: ["@hey-api/typescript"],
|
|
8889
9158
|
handler: handler$3,
|
|
8890
9159
|
name: "fastify"
|
|
@@ -8944,7 +9213,7 @@ const defaultConfig$2 = {
|
|
|
8944
9213
|
config: {
|
|
8945
9214
|
case: "camelCase",
|
|
8946
9215
|
comments: true,
|
|
8947
|
-
|
|
9216
|
+
includeInEntry: false
|
|
8948
9217
|
},
|
|
8949
9218
|
dependencies: ["@hey-api/sdk", "@hey-api/typescript"],
|
|
8950
9219
|
handler: handler$2,
|
|
@@ -10364,7 +10633,7 @@ const defaultConfig$1 = {
|
|
|
10364
10633
|
config: {
|
|
10365
10634
|
case: "camelCase",
|
|
10366
10635
|
comments: true,
|
|
10367
|
-
|
|
10636
|
+
includeInEntry: false,
|
|
10368
10637
|
metadata: false
|
|
10369
10638
|
},
|
|
10370
10639
|
handler: handler$1,
|
|
@@ -13150,7 +13419,7 @@ const defaultConfig = {
|
|
|
13150
13419
|
config: {
|
|
13151
13420
|
case: "camelCase",
|
|
13152
13421
|
comments: true,
|
|
13153
|
-
|
|
13422
|
+
includeInEntry: false,
|
|
13154
13423
|
metadata: false
|
|
13155
13424
|
},
|
|
13156
13425
|
handler,
|
|
@@ -13560,4 +13829,4 @@ async function resolveJobs({ logger, userConfigs }) {
|
|
|
13560
13829
|
|
|
13561
13830
|
//#endregion
|
|
13562
13831
|
export { postProcessors as _, clientDefaultConfig as a, TypeScriptRenderer as c, reserved as d, keywords as f, getTypedConfig as g, getClientPlugin as h, generateClientBundle as i, TsDslContext as l, TsDsl as m, defaultPlugins as n, clientDefaultMeta as o, regexp as p, clientPluginHandler as r, $ as s, resolveJobs as t, ctx as u };
|
|
13563
|
-
//# sourceMappingURL=init-
|
|
13832
|
+
//# sourceMappingURL=init-DlaW5Djq.mjs.map
|