@hey-api/openapi-ts 0.94.5 → 0.95.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 +0 -20
- package/dist/clients/angular/client.ts +8 -2
- package/dist/clients/angular/types.ts +1 -1
- package/dist/clients/axios/client.ts +7 -2
- package/dist/clients/axios/types.ts +6 -3
- package/dist/clients/fetch/client.ts +12 -4
- package/dist/clients/fetch/types.ts +1 -1
- package/dist/clients/ky/client.ts +12 -4
- package/dist/clients/ky/types.ts +1 -1
- package/dist/clients/next/client.ts +10 -4
- package/dist/clients/next/types.ts +1 -1
- package/dist/clients/ofetch/types.ts +1 -1
- package/dist/index.d.mts +1036 -476
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{init-DXg2DSyt.mjs → init-C3GzFcQR.mjs} +1333 -538
- package/dist/init-C3GzFcQR.mjs.map +1 -0
- package/dist/internal.mjs +1 -1
- package/dist/run.mjs +3 -3
- package/dist/{src-onOyaUFS.mjs → src-BzTu1krN.mjs} +2 -2
- package/dist/{src-onOyaUFS.mjs.map → src-BzTu1krN.mjs.map} +1 -1
- package/package.json +5 -5
- package/dist/init-DXg2DSyt.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { StructureModel, detectInteractiveSession, fromRef, isNode, isRef, isSymbol, loadConfigFile, log, nodeBrand, ref, refs } from "@hey-api/codegen-core";
|
|
3
|
-
import { ConfigError, OperationPath, OperationStrategy, applyNaming, buildSymbolIn, childContext, createOperationKey, createSchemaProcessor, createSchemaWalker, deduplicateSchema, definePluginConfig, dependencyFactory, ensureDirSync, escapeComment, findTsConfigPath, getInput, getLogs, getParser, hasOperationDataRequired, hasParameterGroupObjectRequired, isEnvironment, mappers, operationPagination, operationResponsesMap, outputHeaderToPrefix, parseUrl, pathToJsonPointer, pathToName, refToName, resolveSource, satisfies, statusCodeToGroup, toCase, valueToObject } from "@hey-api/shared";
|
|
3
|
+
import { ConfigError, OperationPath, OperationStrategy, applyNaming, buildSymbolIn, childContext, createOperationKey, createSchemaProcessor, createSchemaWalker, deduplicateSchema, definePluginConfig, dependencyFactory, ensureDirSync, escapeComment, findTsConfigPath, getInput, getLogs, getParser, hasOperationDataRequired, hasParameterGroupObjectRequired, isEnvironment, mappers, operationPagination, operationResponsesMap, outputHeaderToPrefix, parseUrl, pathToJsonPointer, pathToName, refToName, requestValidatorLayers, resolveSource, resolveValidatorLayer, satisfies, statusCodeToGroup, toCase, valueToObject } from "@hey-api/shared";
|
|
4
4
|
import colors from "ansi-colors";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
@@ -538,8 +538,8 @@ var TypeTsDsl = class extends TsDsl {};
|
|
|
538
538
|
|
|
539
539
|
//#endregion
|
|
540
540
|
//#region src/ts-dsl/expr/id.ts
|
|
541
|
-
const Mixed$
|
|
542
|
-
var IdTsDsl = class extends Mixed$
|
|
541
|
+
const Mixed$56 = TsDsl;
|
|
542
|
+
var IdTsDsl = class extends Mixed$56 {
|
|
543
543
|
"~dsl" = "IdTsDsl";
|
|
544
544
|
constructor(name) {
|
|
545
545
|
super();
|
|
@@ -594,8 +594,8 @@ function ArgsMixin(Base) {
|
|
|
594
594
|
|
|
595
595
|
//#endregion
|
|
596
596
|
//#region src/ts-dsl/expr/prefix.ts
|
|
597
|
-
const Mixed$
|
|
598
|
-
var PrefixTsDsl = class extends Mixed$
|
|
597
|
+
const Mixed$55 = TsDsl;
|
|
598
|
+
var PrefixTsDsl = class extends Mixed$55 {
|
|
599
599
|
"~dsl" = "PrefixTsDsl";
|
|
600
600
|
_expr;
|
|
601
601
|
_op;
|
|
@@ -667,13 +667,16 @@ const f = {
|
|
|
667
667
|
attr: createFactory("attr"),
|
|
668
668
|
await: createFactory("await"),
|
|
669
669
|
call: createFactory("call"),
|
|
670
|
+
method: createFactory("method"),
|
|
670
671
|
new: createFactory("new"),
|
|
671
672
|
return: createFactory("return"),
|
|
673
|
+
spread: createFactory("spread"),
|
|
672
674
|
type: {
|
|
673
675
|
expr: createFactory("type.expr"),
|
|
674
676
|
idx: createFactory("type.idx"),
|
|
675
677
|
operator: createFactory("type.operator"),
|
|
676
|
-
query: createFactory("type.query")
|
|
678
|
+
query: createFactory("type.query"),
|
|
679
|
+
tupleMember: createFactory("type.tupleMember")
|
|
677
680
|
},
|
|
678
681
|
typeofExpr: createFactory("typeofExpr")
|
|
679
682
|
};
|
|
@@ -694,8 +697,8 @@ function AsMixin(Base) {
|
|
|
694
697
|
|
|
695
698
|
//#endregion
|
|
696
699
|
//#region src/ts-dsl/expr/literal.ts
|
|
697
|
-
const Mixed$
|
|
698
|
-
var LiteralTsDsl = class extends Mixed$
|
|
700
|
+
const Mixed$54 = AsMixin(TsDsl);
|
|
701
|
+
var LiteralTsDsl = class extends Mixed$54 {
|
|
699
702
|
"~dsl" = "LiteralTsDsl";
|
|
700
703
|
value;
|
|
701
704
|
constructor(value) {
|
|
@@ -984,8 +987,8 @@ const safeTypeName = (name) => safeName(name, reserved.type);
|
|
|
984
987
|
|
|
985
988
|
//#endregion
|
|
986
989
|
//#region src/ts-dsl/decl/decorator.ts
|
|
987
|
-
const Mixed$
|
|
988
|
-
var DecoratorTsDsl = class extends Mixed$
|
|
990
|
+
const Mixed$53 = ArgsMixin(TsDsl);
|
|
991
|
+
var DecoratorTsDsl = class extends Mixed$53 {
|
|
989
992
|
"~dsl" = "DecoratorTsDsl";
|
|
990
993
|
nameSanitizer = safeRuntimeName;
|
|
991
994
|
constructor(name, ...args) {
|
|
@@ -1403,8 +1406,8 @@ function StaticMixin(Base) {
|
|
|
1403
1406
|
|
|
1404
1407
|
//#endregion
|
|
1405
1408
|
//#region src/ts-dsl/type/param.ts
|
|
1406
|
-
const Mixed$
|
|
1407
|
-
var TypeParamTsDsl = class extends Mixed$
|
|
1409
|
+
const Mixed$52 = TsDsl;
|
|
1410
|
+
var TypeParamTsDsl = class extends Mixed$52 {
|
|
1408
1411
|
"~dsl" = "TypeParamTsDsl";
|
|
1409
1412
|
scope = "type";
|
|
1410
1413
|
constraint;
|
|
@@ -1615,8 +1618,8 @@ function TypeExprMixin(Base) {
|
|
|
1615
1618
|
|
|
1616
1619
|
//#endregion
|
|
1617
1620
|
//#region src/ts-dsl/type/attr.ts
|
|
1618
|
-
const Mixed$
|
|
1619
|
-
var TypeAttrTsDsl = class extends Mixed$
|
|
1621
|
+
const Mixed$51 = TypeExprMixin(TsDsl);
|
|
1622
|
+
var TypeAttrTsDsl = class extends Mixed$51 {
|
|
1620
1623
|
"~dsl" = "TypeAttrTsDsl";
|
|
1621
1624
|
scope = "type";
|
|
1622
1625
|
_base;
|
|
@@ -1670,8 +1673,8 @@ var TypeAttrTsDsl = class extends Mixed$49 {
|
|
|
1670
1673
|
|
|
1671
1674
|
//#endregion
|
|
1672
1675
|
//#region src/ts-dsl/type/expr.ts
|
|
1673
|
-
const Mixed$
|
|
1674
|
-
var TypeExprTsDsl = class extends Mixed$
|
|
1676
|
+
const Mixed$50 = TypeArgsMixin(TypeExprMixin(TsDsl));
|
|
1677
|
+
var TypeExprTsDsl = class extends Mixed$50 {
|
|
1675
1678
|
"~dsl" = "TypeExprTsDsl";
|
|
1676
1679
|
scope = "type";
|
|
1677
1680
|
_exprInput;
|
|
@@ -1715,8 +1718,8 @@ f.type.expr.set((...args) => new TypeExprTsDsl(...args));
|
|
|
1715
1718
|
|
|
1716
1719
|
//#endregion
|
|
1717
1720
|
//#region src/ts-dsl/decl/field.ts
|
|
1718
|
-
const Mixed$
|
|
1719
|
-
var FieldTsDsl = class extends Mixed$
|
|
1721
|
+
const Mixed$49 = DecoratorMixin(DocMixin(OptionalMixin(PrivateMixin(ProtectedMixin(PublicMixin(ReadonlyMixin(StaticMixin(ValueMixin(TsDsl)))))))));
|
|
1722
|
+
var FieldTsDsl = class extends Mixed$49 {
|
|
1720
1723
|
"~dsl" = "FieldTsDsl";
|
|
1721
1724
|
nameSanitizer = safeAccessorName;
|
|
1722
1725
|
_type;
|
|
@@ -1743,8 +1746,8 @@ var FieldTsDsl = class extends Mixed$47 {
|
|
|
1743
1746
|
|
|
1744
1747
|
//#endregion
|
|
1745
1748
|
//#region src/ts-dsl/stmt/stmt.ts
|
|
1746
|
-
const Mixed$
|
|
1747
|
-
var StmtTsDsl = class extends Mixed$
|
|
1749
|
+
const Mixed$48 = TsDsl;
|
|
1750
|
+
var StmtTsDsl = class extends Mixed$48 {
|
|
1748
1751
|
"~dsl" = "StmtTsDsl";
|
|
1749
1752
|
_inner;
|
|
1750
1753
|
constructor(inner) {
|
|
@@ -1791,11 +1794,11 @@ function DoMixin(Base) {
|
|
|
1791
1794
|
|
|
1792
1795
|
//#endregion
|
|
1793
1796
|
//#region src/ts-dsl/decl/pattern.ts
|
|
1794
|
-
const Mixed$
|
|
1797
|
+
const Mixed$47 = TsDsl;
|
|
1795
1798
|
/**
|
|
1796
1799
|
* Builds binding patterns (e.g., `{ foo, bar }`, `[a, b, ...rest]`).
|
|
1797
1800
|
*/
|
|
1798
|
-
var PatternTsDsl = class extends Mixed$
|
|
1801
|
+
var PatternTsDsl = class extends Mixed$47 {
|
|
1799
1802
|
"~dsl" = "PatternTsDsl";
|
|
1800
1803
|
pattern;
|
|
1801
1804
|
_spread;
|
|
@@ -1898,8 +1901,8 @@ function PatternMixin(Base) {
|
|
|
1898
1901
|
|
|
1899
1902
|
//#endregion
|
|
1900
1903
|
//#region src/ts-dsl/decl/param.ts
|
|
1901
|
-
const Mixed$
|
|
1902
|
-
var ParamTsDsl = class extends Mixed$
|
|
1904
|
+
const Mixed$46 = DecoratorMixin(OptionalMixin(PatternMixin(ValueMixin(TsDsl))));
|
|
1905
|
+
var ParamTsDsl = class extends Mixed$46 {
|
|
1903
1906
|
"~dsl" = "ParamTsDsl";
|
|
1904
1907
|
_type;
|
|
1905
1908
|
constructor(name, fn) {
|
|
@@ -1920,8 +1923,8 @@ var ParamTsDsl = class extends Mixed$44 {
|
|
|
1920
1923
|
return !this.missingRequiredCalls().length;
|
|
1921
1924
|
}
|
|
1922
1925
|
/** Sets the parameter type. */
|
|
1923
|
-
type(
|
|
1924
|
-
this._type =
|
|
1926
|
+
type(node) {
|
|
1927
|
+
this._type = node instanceof TypeTsDsl ? node : new TypeExprTsDsl(node);
|
|
1925
1928
|
return this;
|
|
1926
1929
|
}
|
|
1927
1930
|
toAst() {
|
|
@@ -1997,8 +2000,8 @@ function LayoutMixin(Base) {
|
|
|
1997
2000
|
|
|
1998
2001
|
//#endregion
|
|
1999
2002
|
//#region src/ts-dsl/stmt/block.ts
|
|
2000
|
-
const Mixed$
|
|
2001
|
-
var BlockTsDsl = class extends Mixed$
|
|
2003
|
+
const Mixed$45 = DoMixin(LayoutMixin(TsDsl));
|
|
2004
|
+
var BlockTsDsl = class extends Mixed$45 {
|
|
2002
2005
|
"~dsl" = "BlockTsDsl";
|
|
2003
2006
|
constructor(...items) {
|
|
2004
2007
|
super();
|
|
@@ -2015,8 +2018,8 @@ var BlockTsDsl = class extends Mixed$43 {
|
|
|
2015
2018
|
|
|
2016
2019
|
//#endregion
|
|
2017
2020
|
//#region src/ts-dsl/decl/init.ts
|
|
2018
|
-
const Mixed$
|
|
2019
|
-
var InitTsDsl = class extends Mixed$
|
|
2021
|
+
const Mixed$44 = DecoratorMixin(DoMixin(DocMixin(ParamMixin(PrivateMixin(ProtectedMixin(PublicMixin(TsDsl)))))));
|
|
2022
|
+
var InitTsDsl = class extends Mixed$44 {
|
|
2020
2023
|
"~dsl" = "InitTsDsl";
|
|
2021
2024
|
constructor(fn) {
|
|
2022
2025
|
super();
|
|
@@ -2058,8 +2061,8 @@ function TypeReturnsMixin(Base) {
|
|
|
2058
2061
|
|
|
2059
2062
|
//#endregion
|
|
2060
2063
|
//#region src/ts-dsl/decl/method.ts
|
|
2061
|
-
const Mixed$
|
|
2062
|
-
var MethodTsDsl = class extends Mixed$
|
|
2064
|
+
const Mixed$43 = AbstractMixin(AsyncMixin(DecoratorMixin(DoMixin(DocMixin(OptionalMixin(ParamMixin(PrivateMixin(ProtectedMixin(PublicMixin(StaticMixin(TypeParamsMixin(TypeReturnsMixin(TsDsl)))))))))))));
|
|
2065
|
+
var MethodTsDsl = class extends Mixed$43 {
|
|
2063
2066
|
"~dsl" = "MethodTsDsl";
|
|
2064
2067
|
nameSanitizer = safeAccessorName;
|
|
2065
2068
|
constructor(name, fn) {
|
|
@@ -2081,11 +2084,12 @@ var MethodTsDsl = class extends Mixed$41 {
|
|
|
2081
2084
|
return this.$docs(node);
|
|
2082
2085
|
}
|
|
2083
2086
|
};
|
|
2087
|
+
f.method.set((...args) => new MethodTsDsl(...args));
|
|
2084
2088
|
|
|
2085
2089
|
//#endregion
|
|
2086
2090
|
//#region src/ts-dsl/decl/class.ts
|
|
2087
|
-
const Mixed$
|
|
2088
|
-
var ClassTsDsl = class extends Mixed$
|
|
2091
|
+
const Mixed$42 = AbstractMixin(DecoratorMixin(DefaultMixin(DocMixin(ExportMixin(TypeParamsMixin(TsDsl))))));
|
|
2092
|
+
var ClassTsDsl = class extends Mixed$42 {
|
|
2089
2093
|
"~dsl" = "ClassTsDsl";
|
|
2090
2094
|
nameSanitizer = safeRuntimeName;
|
|
2091
2095
|
baseClass;
|
|
@@ -2158,8 +2162,8 @@ var ClassTsDsl = class extends Mixed$40 {
|
|
|
2158
2162
|
|
|
2159
2163
|
//#endregion
|
|
2160
2164
|
//#region src/ts-dsl/decl/member.ts
|
|
2161
|
-
const Mixed$
|
|
2162
|
-
var EnumMemberTsDsl = class extends Mixed$
|
|
2165
|
+
const Mixed$41 = DocMixin(TsDsl);
|
|
2166
|
+
var EnumMemberTsDsl = class extends Mixed$41 {
|
|
2163
2167
|
"~dsl" = "EnumMemberTsDsl";
|
|
2164
2168
|
_value;
|
|
2165
2169
|
constructor(name, value) {
|
|
@@ -2185,8 +2189,8 @@ var EnumMemberTsDsl = class extends Mixed$39 {
|
|
|
2185
2189
|
|
|
2186
2190
|
//#endregion
|
|
2187
2191
|
//#region src/ts-dsl/decl/enum.ts
|
|
2188
|
-
const Mixed$
|
|
2189
|
-
var EnumTsDsl = class extends Mixed$
|
|
2192
|
+
const Mixed$40 = ConstMixin(DocMixin(ExportMixin(TsDsl)));
|
|
2193
|
+
var EnumTsDsl = class extends Mixed$40 {
|
|
2190
2194
|
"~dsl" = "EnumTsDsl";
|
|
2191
2195
|
nameSanitizer = safeRuntimeName;
|
|
2192
2196
|
_members = [];
|
|
@@ -2225,8 +2229,8 @@ var EnumTsDsl = class extends Mixed$38 {
|
|
|
2225
2229
|
|
|
2226
2230
|
//#endregion
|
|
2227
2231
|
//#region src/ts-dsl/decl/func.ts
|
|
2228
|
-
const Mixed$
|
|
2229
|
-
var ImplFuncTsDsl = class extends Mixed$
|
|
2232
|
+
const Mixed$39 = AbstractMixin(AsMixin(AsyncMixin(DecoratorMixin(DoMixin(DocMixin(ExportMixin(ParamMixin(PrivateMixin(ProtectedMixin(PublicMixin(StaticMixin(TypeParamsMixin(TypeReturnsMixin(TsDsl))))))))))))));
|
|
2233
|
+
var ImplFuncTsDsl = class extends Mixed$39 {
|
|
2230
2234
|
"~dsl" = "FuncTsDsl";
|
|
2231
2235
|
nameSanitizer = safeRuntimeName;
|
|
2232
2236
|
mode;
|
|
@@ -2299,8 +2303,8 @@ const FuncTsDsl = ImplFuncTsDsl;
|
|
|
2299
2303
|
|
|
2300
2304
|
//#endregion
|
|
2301
2305
|
//#region src/ts-dsl/decl/getter.ts
|
|
2302
|
-
const Mixed$
|
|
2303
|
-
var GetterTsDsl = class extends Mixed$
|
|
2306
|
+
const Mixed$38 = AbstractMixin(AsyncMixin(DecoratorMixin(DoMixin(DocMixin(ParamMixin(PrivateMixin(ProtectedMixin(PublicMixin(StaticMixin(TypeReturnsMixin(TsDsl)))))))))));
|
|
2307
|
+
var GetterTsDsl = class extends Mixed$38 {
|
|
2304
2308
|
"~dsl" = "GetterTsDsl";
|
|
2305
2309
|
nameSanitizer = safeAccessorName;
|
|
2306
2310
|
constructor(name, fn) {
|
|
@@ -2325,8 +2329,8 @@ var GetterTsDsl = class extends Mixed$36 {
|
|
|
2325
2329
|
|
|
2326
2330
|
//#endregion
|
|
2327
2331
|
//#region src/ts-dsl/decl/setter.ts
|
|
2328
|
-
const Mixed$
|
|
2329
|
-
var SetterTsDsl = class extends Mixed$
|
|
2332
|
+
const Mixed$37 = AbstractMixin(AsyncMixin(DecoratorMixin(DoMixin(DocMixin(ParamMixin(PrivateMixin(ProtectedMixin(PublicMixin(StaticMixin(TsDsl))))))))));
|
|
2333
|
+
var SetterTsDsl = class extends Mixed$37 {
|
|
2330
2334
|
"~dsl" = "SetterTsDsl";
|
|
2331
2335
|
nameSanitizer = safeAccessorName;
|
|
2332
2336
|
constructor(name, fn) {
|
|
@@ -2372,10 +2376,24 @@ function ExprMixin(Base) {
|
|
|
2372
2376
|
return Expr;
|
|
2373
2377
|
}
|
|
2374
2378
|
|
|
2379
|
+
//#endregion
|
|
2380
|
+
//#region src/ts-dsl/mixins/spread.ts
|
|
2381
|
+
function SpreadMixin(Base) {
|
|
2382
|
+
class Spread extends Base {
|
|
2383
|
+
analyze(ctx) {
|
|
2384
|
+
super.analyze(ctx);
|
|
2385
|
+
}
|
|
2386
|
+
spread() {
|
|
2387
|
+
return f.spread(this);
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
return Spread;
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2375
2393
|
//#endregion
|
|
2376
2394
|
//#region src/ts-dsl/expr/array.ts
|
|
2377
|
-
const Mixed$
|
|
2378
|
-
var ArrayTsDsl = class extends Mixed$
|
|
2395
|
+
const Mixed$36 = AsMixin(ExprMixin(LayoutMixin(SpreadMixin(TsDsl))));
|
|
2396
|
+
var ArrayTsDsl = class extends Mixed$36 {
|
|
2379
2397
|
"~dsl" = "ArrayTsDsl";
|
|
2380
2398
|
_elements = [];
|
|
2381
2399
|
constructor(...exprs) {
|
|
@@ -2384,15 +2402,12 @@ var ArrayTsDsl = class extends Mixed$34 {
|
|
|
2384
2402
|
}
|
|
2385
2403
|
analyze(ctx) {
|
|
2386
2404
|
super.analyze(ctx);
|
|
2387
|
-
for (const item of this._elements) ctx.analyze(item
|
|
2405
|
+
for (const item of this._elements) ctx.analyze(item);
|
|
2388
2406
|
}
|
|
2389
2407
|
/** Adds a single array element. */
|
|
2390
2408
|
element(expr) {
|
|
2391
2409
|
const node = typeof expr === "string" || typeof expr === "number" || typeof expr === "boolean" ? new LiteralTsDsl(expr) : expr;
|
|
2392
|
-
this._elements.push(
|
|
2393
|
-
expr: node,
|
|
2394
|
-
kind: "element"
|
|
2395
|
-
});
|
|
2410
|
+
this._elements.push(node);
|
|
2396
2411
|
return this;
|
|
2397
2412
|
}
|
|
2398
2413
|
/** Adds multiple array elements. */
|
|
@@ -2400,27 +2415,15 @@ var ArrayTsDsl = class extends Mixed$34 {
|
|
|
2400
2415
|
for (const expr of exprs) this.element(expr);
|
|
2401
2416
|
return this;
|
|
2402
2417
|
}
|
|
2403
|
-
/** Adds a spread element (`...expr`). */
|
|
2404
|
-
spread(expr) {
|
|
2405
|
-
this._elements.push({
|
|
2406
|
-
expr,
|
|
2407
|
-
kind: "spread"
|
|
2408
|
-
});
|
|
2409
|
-
return this;
|
|
2410
|
-
}
|
|
2411
2418
|
toAst() {
|
|
2412
|
-
|
|
2413
|
-
const node = this.$node(item.expr);
|
|
2414
|
-
return item.kind === "spread" ? ts.factory.createSpreadElement(node) : node;
|
|
2415
|
-
});
|
|
2416
|
-
return ts.factory.createArrayLiteralExpression(elements, this.$multiline(this._elements.length));
|
|
2419
|
+
return ts.factory.createArrayLiteralExpression(this._elements.map((item) => this.$node(item)), this.$multiline(this._elements.length));
|
|
2417
2420
|
}
|
|
2418
2421
|
};
|
|
2419
2422
|
|
|
2420
2423
|
//#endregion
|
|
2421
2424
|
//#region src/ts-dsl/expr/as.ts
|
|
2422
|
-
const Mixed$
|
|
2423
|
-
var AsTsDsl = class extends Mixed$
|
|
2425
|
+
const Mixed$35 = AsMixin(ExprMixin(TsDsl));
|
|
2426
|
+
var AsTsDsl = class extends Mixed$35 {
|
|
2424
2427
|
"~dsl" = "AsTsDsl";
|
|
2425
2428
|
expr;
|
|
2426
2429
|
type;
|
|
@@ -2442,8 +2445,8 @@ f.as.set((...args) => new AsTsDsl(...args));
|
|
|
2442
2445
|
|
|
2443
2446
|
//#endregion
|
|
2444
2447
|
//#region src/ts-dsl/expr/binary.ts
|
|
2445
|
-
const Mixed$
|
|
2446
|
-
var BinaryTsDsl = class extends Mixed$
|
|
2448
|
+
const Mixed$34 = AsMixin(ExprMixin(TsDsl));
|
|
2449
|
+
var BinaryTsDsl = class extends Mixed$34 {
|
|
2447
2450
|
"~dsl" = "BinaryTsDsl";
|
|
2448
2451
|
_base;
|
|
2449
2452
|
_expr;
|
|
@@ -2643,8 +2646,8 @@ function OperatorMixin(Base) {
|
|
|
2643
2646
|
|
|
2644
2647
|
//#endregion
|
|
2645
2648
|
//#region src/ts-dsl/expr/attr.ts
|
|
2646
|
-
const Mixed$
|
|
2647
|
-
var AttrTsDsl = class extends Mixed$
|
|
2649
|
+
const Mixed$33 = AsMixin(ExprMixin(OperatorMixin(OptionalMixin(SpreadMixin(TsDsl)))));
|
|
2650
|
+
var AttrTsDsl = class extends Mixed$33 {
|
|
2648
2651
|
"~dsl" = "AttrTsDsl";
|
|
2649
2652
|
_computed = false;
|
|
2650
2653
|
_left;
|
|
@@ -2683,8 +2686,8 @@ f.attr.set((...args) => new AttrTsDsl(...args));
|
|
|
2683
2686
|
|
|
2684
2687
|
//#endregion
|
|
2685
2688
|
//#region src/ts-dsl/expr/await.ts
|
|
2686
|
-
const Mixed$
|
|
2687
|
-
var AwaitTsDsl = class extends Mixed$
|
|
2689
|
+
const Mixed$32 = ExprMixin(TsDsl);
|
|
2690
|
+
var AwaitTsDsl = class extends Mixed$32 {
|
|
2688
2691
|
"~dsl" = "AwaitTsDsl";
|
|
2689
2692
|
_awaitExpr;
|
|
2690
2693
|
constructor(expr) {
|
|
@@ -2703,8 +2706,8 @@ f.await.set((...args) => new AwaitTsDsl(...args));
|
|
|
2703
2706
|
|
|
2704
2707
|
//#endregion
|
|
2705
2708
|
//#region src/ts-dsl/expr/call.ts
|
|
2706
|
-
const Mixed$
|
|
2707
|
-
var CallTsDsl = class extends Mixed$
|
|
2709
|
+
const Mixed$31 = ArgsMixin(AsMixin(ExprMixin(SpreadMixin(TypeArgsMixin(TsDsl)))));
|
|
2710
|
+
var CallTsDsl = class extends Mixed$31 {
|
|
2708
2711
|
"~dsl" = "CallTsDsl";
|
|
2709
2712
|
_callee;
|
|
2710
2713
|
constructor(callee, ...args) {
|
|
@@ -2724,8 +2727,8 @@ f.call.set((...args) => new CallTsDsl(...args));
|
|
|
2724
2727
|
|
|
2725
2728
|
//#endregion
|
|
2726
2729
|
//#region src/ts-dsl/expr/expr.ts
|
|
2727
|
-
const Mixed$
|
|
2728
|
-
var ExprTsDsl = class extends Mixed$
|
|
2730
|
+
const Mixed$30 = AsMixin(ExprMixin(OperatorMixin(SpreadMixin(TypeExprMixin(TsDsl)))));
|
|
2731
|
+
var ExprTsDsl = class extends Mixed$30 {
|
|
2729
2732
|
"~dsl" = "ExprTsDsl";
|
|
2730
2733
|
_exprInput;
|
|
2731
2734
|
constructor(id) {
|
|
@@ -2796,8 +2799,8 @@ function HintMixin(Base) {
|
|
|
2796
2799
|
|
|
2797
2800
|
//#endregion
|
|
2798
2801
|
//#region src/ts-dsl/expr/prop.ts
|
|
2799
|
-
const Mixed$
|
|
2800
|
-
var ObjectPropTsDsl = class extends Mixed$
|
|
2802
|
+
const Mixed$29 = DocMixin(TsDsl);
|
|
2803
|
+
var ObjectPropTsDsl = class extends Mixed$29 {
|
|
2801
2804
|
"~dsl" = "ObjectPropTsDsl";
|
|
2802
2805
|
_value;
|
|
2803
2806
|
_meta;
|
|
@@ -2805,12 +2808,6 @@ var ObjectPropTsDsl = class extends Mixed$27 {
|
|
|
2805
2808
|
super();
|
|
2806
2809
|
this._meta = meta;
|
|
2807
2810
|
}
|
|
2808
|
-
get kind() {
|
|
2809
|
-
return this._meta.kind;
|
|
2810
|
-
}
|
|
2811
|
-
get propName() {
|
|
2812
|
-
return this._meta.name;
|
|
2813
|
-
}
|
|
2814
2811
|
analyze(ctx) {
|
|
2815
2812
|
super.analyze(ctx);
|
|
2816
2813
|
ctx.analyze(this._value);
|
|
@@ -2818,9 +2815,14 @@ var ObjectPropTsDsl = class extends Mixed$27 {
|
|
|
2818
2815
|
get isValid() {
|
|
2819
2816
|
return !this.missingRequiredCalls().length;
|
|
2820
2817
|
}
|
|
2818
|
+
get kind() {
|
|
2819
|
+
return this._meta.kind;
|
|
2820
|
+
}
|
|
2821
|
+
get propName() {
|
|
2822
|
+
return this._meta.name;
|
|
2823
|
+
}
|
|
2821
2824
|
value(value) {
|
|
2822
|
-
|
|
2823
|
-
else this._value = ref(value);
|
|
2825
|
+
this._value = ref(value);
|
|
2824
2826
|
return this;
|
|
2825
2827
|
}
|
|
2826
2828
|
toAst() {
|
|
@@ -2841,6 +2843,7 @@ var ObjectPropTsDsl = class extends Mixed$27 {
|
|
|
2841
2843
|
const result = this.$node(setter);
|
|
2842
2844
|
return this.$docs(result);
|
|
2843
2845
|
}
|
|
2846
|
+
if (this._meta.kind === "method") return this.$docs(node);
|
|
2844
2847
|
if (ts.isIdentifier(node) && node.text === this._meta.name) {
|
|
2845
2848
|
const result = ts.factory.createShorthandPropertyAssignment(this._meta.name);
|
|
2846
2849
|
return this.$docs(result);
|
|
@@ -2863,14 +2866,15 @@ var ObjectPropTsDsl = class extends Mixed$27 {
|
|
|
2863
2866
|
|
|
2864
2867
|
//#endregion
|
|
2865
2868
|
//#region src/ts-dsl/expr/object.ts
|
|
2866
|
-
const Mixed$
|
|
2867
|
-
var ObjectTsDsl = class extends Mixed$
|
|
2869
|
+
const Mixed$28 = AsMixin(ExprMixin(HintMixin(LayoutMixin(TsDsl))));
|
|
2870
|
+
var ObjectTsDsl = class extends Mixed$28 {
|
|
2868
2871
|
"~dsl" = "ObjectTsDsl";
|
|
2869
2872
|
_props = /* @__PURE__ */ new Map();
|
|
2870
2873
|
_spreadCounter = 0;
|
|
2871
2874
|
constructor(...props) {
|
|
2872
2875
|
super();
|
|
2873
|
-
|
|
2876
|
+
if (props.length === 1 && typeof props[0] === "function") props[0](this);
|
|
2877
|
+
else this.props(...props);
|
|
2874
2878
|
}
|
|
2875
2879
|
analyze(ctx) {
|
|
2876
2880
|
super.analyze(ctx);
|
|
@@ -2907,6 +2911,15 @@ var ObjectTsDsl = class extends Mixed$26 {
|
|
|
2907
2911
|
get isEmpty() {
|
|
2908
2912
|
return this._props.size === 0;
|
|
2909
2913
|
}
|
|
2914
|
+
/** Adds a method property (e.g., `{ foo() { ... } }`), or removes if null. */
|
|
2915
|
+
method(name, fn) {
|
|
2916
|
+
if (fn === null) this._props.delete(`method:${name}`);
|
|
2917
|
+
else this._props.set(`method:${name}`, new ObjectPropTsDsl({
|
|
2918
|
+
kind: "method",
|
|
2919
|
+
name
|
|
2920
|
+
}).value(f.method(name, fn)));
|
|
2921
|
+
return this;
|
|
2922
|
+
}
|
|
2910
2923
|
/** Adds a property assignment, or removes if null. */
|
|
2911
2924
|
prop(name, expr) {
|
|
2912
2925
|
if (expr === null) this._props.delete(`prop:${name}`);
|
|
@@ -2944,7 +2957,7 @@ var ObjectTsDsl = class extends Mixed$26 {
|
|
|
2944
2957
|
};
|
|
2945
2958
|
|
|
2946
2959
|
//#endregion
|
|
2947
|
-
//#region src/ts-dsl/expr/
|
|
2960
|
+
//#region src/ts-dsl/expr/from-value.ts
|
|
2948
2961
|
const fromValue$1 = (input, options) => {
|
|
2949
2962
|
if (isNode(input)) return input;
|
|
2950
2963
|
if (input === null || typeof input === "number" || typeof input === "boolean" || typeof input === "string" || typeof input === "bigint") return new LiteralTsDsl(input);
|
|
@@ -2967,8 +2980,8 @@ const fromValue$1 = (input, options) => {
|
|
|
2967
2980
|
|
|
2968
2981
|
//#endregion
|
|
2969
2982
|
//#region src/ts-dsl/expr/new.ts
|
|
2970
|
-
const Mixed$
|
|
2971
|
-
var NewTsDsl = class extends Mixed$
|
|
2983
|
+
const Mixed$27 = ArgsMixin(AsMixin(ExprMixin(SpreadMixin(TypeArgsMixin(TsDsl)))));
|
|
2984
|
+
var NewTsDsl = class extends Mixed$27 {
|
|
2972
2985
|
"~dsl" = "NewTsDsl";
|
|
2973
2986
|
_newExpr;
|
|
2974
2987
|
constructor(expr, ...args) {
|
|
@@ -2988,8 +3001,8 @@ f.new.set((...args) => new NewTsDsl(...args));
|
|
|
2988
3001
|
|
|
2989
3002
|
//#endregion
|
|
2990
3003
|
//#region src/ts-dsl/expr/postfix.ts
|
|
2991
|
-
const Mixed$
|
|
2992
|
-
var PostfixTsDsl = class extends Mixed$
|
|
3004
|
+
const Mixed$26 = TsDsl;
|
|
3005
|
+
var PostfixTsDsl = class extends Mixed$26 {
|
|
2993
3006
|
"~dsl" = "PostfixTsDsl";
|
|
2994
3007
|
_expr;
|
|
2995
3008
|
_op;
|
|
@@ -3045,8 +3058,8 @@ var PostfixTsDsl = class extends Mixed$24 {
|
|
|
3045
3058
|
|
|
3046
3059
|
//#endregion
|
|
3047
3060
|
//#region src/ts-dsl/expr/regexp.ts
|
|
3048
|
-
const Mixed$
|
|
3049
|
-
var RegExpTsDsl = class extends Mixed$
|
|
3061
|
+
const Mixed$25 = TsDsl;
|
|
3062
|
+
var RegExpTsDsl = class extends Mixed$25 {
|
|
3050
3063
|
"~dsl" = "RegExpTsDsl";
|
|
3051
3064
|
pattern;
|
|
3052
3065
|
flags;
|
|
@@ -3064,10 +3077,30 @@ var RegExpTsDsl = class extends Mixed$23 {
|
|
|
3064
3077
|
}
|
|
3065
3078
|
};
|
|
3066
3079
|
|
|
3080
|
+
//#endregion
|
|
3081
|
+
//#region src/ts-dsl/expr/spread.ts
|
|
3082
|
+
const Mixed$24 = TsDsl;
|
|
3083
|
+
var SpreadTsDsl = class extends Mixed$24 {
|
|
3084
|
+
"~dsl" = "SpreadTsDsl";
|
|
3085
|
+
_expr;
|
|
3086
|
+
constructor(expr) {
|
|
3087
|
+
super();
|
|
3088
|
+
this._expr = ref(expr);
|
|
3089
|
+
}
|
|
3090
|
+
analyze(ctx) {
|
|
3091
|
+
super.analyze(ctx);
|
|
3092
|
+
ctx.analyze(this._expr);
|
|
3093
|
+
}
|
|
3094
|
+
toAst() {
|
|
3095
|
+
return ts.factory.createSpreadElement(this.$node(this._expr));
|
|
3096
|
+
}
|
|
3097
|
+
};
|
|
3098
|
+
f.spread.set((...args) => new SpreadTsDsl(...args));
|
|
3099
|
+
|
|
3067
3100
|
//#endregion
|
|
3068
3101
|
//#region src/ts-dsl/expr/template.ts
|
|
3069
|
-
const Mixed$
|
|
3070
|
-
var TemplateTsDsl = class extends Mixed$
|
|
3102
|
+
const Mixed$23 = TsDsl;
|
|
3103
|
+
var TemplateTsDsl = class extends Mixed$23 {
|
|
3071
3104
|
"~dsl" = "TemplateTsDsl";
|
|
3072
3105
|
parts = [];
|
|
3073
3106
|
constructor(value) {
|
|
@@ -3117,8 +3150,8 @@ var TemplateTsDsl = class extends Mixed$22 {
|
|
|
3117
3150
|
|
|
3118
3151
|
//#endregion
|
|
3119
3152
|
//#region src/ts-dsl/expr/ternary.ts
|
|
3120
|
-
const Mixed$
|
|
3121
|
-
var TernaryTsDsl = class extends Mixed$
|
|
3153
|
+
const Mixed$22 = TsDsl;
|
|
3154
|
+
var TernaryTsDsl = class extends Mixed$22 {
|
|
3122
3155
|
"~dsl" = "TernaryTsDsl";
|
|
3123
3156
|
_condition;
|
|
3124
3157
|
_then;
|
|
@@ -3169,8 +3202,8 @@ var TernaryTsDsl = class extends Mixed$21 {
|
|
|
3169
3202
|
|
|
3170
3203
|
//#endregion
|
|
3171
3204
|
//#region src/ts-dsl/expr/typeof.ts
|
|
3172
|
-
const Mixed$
|
|
3173
|
-
var TypeOfExprTsDsl = class extends Mixed$
|
|
3205
|
+
const Mixed$21 = OperatorMixin(TsDsl);
|
|
3206
|
+
var TypeOfExprTsDsl = class extends Mixed$21 {
|
|
3174
3207
|
"~dsl" = "TypeOfExprTsDsl";
|
|
3175
3208
|
_expr;
|
|
3176
3209
|
constructor(expr) {
|
|
@@ -3221,8 +3254,8 @@ var NoteTsDsl = class extends TsDsl {
|
|
|
3221
3254
|
|
|
3222
3255
|
//#endregion
|
|
3223
3256
|
//#region src/ts-dsl/stmt/for.ts
|
|
3224
|
-
const Mixed$
|
|
3225
|
-
var ImplForTsDsl = class extends Mixed$
|
|
3257
|
+
const Mixed$20 = DoMixin(LayoutMixin(TsDsl));
|
|
3258
|
+
var ImplForTsDsl = class extends Mixed$20 {
|
|
3226
3259
|
"~dsl" = "ForTsDsl";
|
|
3227
3260
|
_await;
|
|
3228
3261
|
_condition;
|
|
@@ -3320,8 +3353,8 @@ const ForTsDsl = ImplForTsDsl;
|
|
|
3320
3353
|
|
|
3321
3354
|
//#endregion
|
|
3322
3355
|
//#region src/ts-dsl/stmt/if.ts
|
|
3323
|
-
const Mixed$
|
|
3324
|
-
var IfTsDsl = class extends Mixed$
|
|
3356
|
+
const Mixed$19 = DoMixin(TsDsl);
|
|
3357
|
+
var IfTsDsl = class extends Mixed$19 {
|
|
3325
3358
|
"~dsl" = "IfTsDsl";
|
|
3326
3359
|
_condition;
|
|
3327
3360
|
_else;
|
|
@@ -3372,8 +3405,8 @@ var IfTsDsl = class extends Mixed$18 {
|
|
|
3372
3405
|
|
|
3373
3406
|
//#endregion
|
|
3374
3407
|
//#region src/ts-dsl/stmt/return.ts
|
|
3375
|
-
const Mixed$
|
|
3376
|
-
var ReturnTsDsl = class extends Mixed$
|
|
3408
|
+
const Mixed$18 = TsDsl;
|
|
3409
|
+
var ReturnTsDsl = class extends Mixed$18 {
|
|
3377
3410
|
"~dsl" = "ReturnTsDsl";
|
|
3378
3411
|
_returnExpr;
|
|
3379
3412
|
constructor(expr) {
|
|
@@ -3392,8 +3425,8 @@ f.return.set((...args) => new ReturnTsDsl(...args));
|
|
|
3392
3425
|
|
|
3393
3426
|
//#endregion
|
|
3394
3427
|
//#region src/ts-dsl/stmt/throw.ts
|
|
3395
|
-
const Mixed$
|
|
3396
|
-
var ThrowTsDsl = class extends Mixed$
|
|
3428
|
+
const Mixed$17 = TsDsl;
|
|
3429
|
+
var ThrowTsDsl = class extends Mixed$17 {
|
|
3397
3430
|
"~dsl" = "ThrowTsDsl";
|
|
3398
3431
|
error;
|
|
3399
3432
|
msg;
|
|
@@ -3423,8 +3456,8 @@ var ThrowTsDsl = class extends Mixed$16 {
|
|
|
3423
3456
|
|
|
3424
3457
|
//#endregion
|
|
3425
3458
|
//#region src/ts-dsl/stmt/try.ts
|
|
3426
|
-
const Mixed$
|
|
3427
|
-
var TryTsDsl = class extends Mixed$
|
|
3459
|
+
const Mixed$16 = TsDsl;
|
|
3460
|
+
var TryTsDsl = class extends Mixed$16 {
|
|
3428
3461
|
"~dsl" = "TryTsDsl";
|
|
3429
3462
|
_catch;
|
|
3430
3463
|
_catchArg;
|
|
@@ -3501,8 +3534,8 @@ var TryTsDsl = class extends Mixed$15 {
|
|
|
3501
3534
|
|
|
3502
3535
|
//#endregion
|
|
3503
3536
|
//#region src/ts-dsl/stmt/var.ts
|
|
3504
|
-
const Mixed$
|
|
3505
|
-
var VarTsDsl = class extends Mixed$
|
|
3537
|
+
const Mixed$15 = DefaultMixin(DocMixin(ExportMixin(HintMixin(PatternMixin(ValueMixin(TsDsl))))));
|
|
3538
|
+
var VarTsDsl = class extends Mixed$15 {
|
|
3506
3539
|
"~dsl" = "VarTsDsl";
|
|
3507
3540
|
nameSanitizer = safeRuntimeName;
|
|
3508
3541
|
kind = ts.NodeFlags.None;
|
|
@@ -3530,8 +3563,8 @@ var VarTsDsl = class extends Mixed$14 {
|
|
|
3530
3563
|
return this;
|
|
3531
3564
|
}
|
|
3532
3565
|
/** Sets the variable type. */
|
|
3533
|
-
type(
|
|
3534
|
-
this._type =
|
|
3566
|
+
type(node) {
|
|
3567
|
+
this._type = node instanceof TypeTsDsl ? node : new TypeExprTsDsl(node);
|
|
3535
3568
|
return this;
|
|
3536
3569
|
}
|
|
3537
3570
|
var() {
|
|
@@ -3557,8 +3590,8 @@ var VarTsDsl = class extends Mixed$14 {
|
|
|
3557
3590
|
|
|
3558
3591
|
//#endregion
|
|
3559
3592
|
//#region src/ts-dsl/type/alias.ts
|
|
3560
|
-
const Mixed$
|
|
3561
|
-
var TypeAliasTsDsl = class extends Mixed$
|
|
3593
|
+
const Mixed$14 = DocMixin(ExportMixin(TypeParamsMixin(TsDsl)));
|
|
3594
|
+
var TypeAliasTsDsl = class extends Mixed$14 {
|
|
3562
3595
|
"~dsl" = "TypeAliasTsDsl";
|
|
3563
3596
|
nameSanitizer = safeTypeName;
|
|
3564
3597
|
scope = "type";
|
|
@@ -3603,8 +3636,8 @@ var TypeAliasTsDsl = class extends Mixed$13 {
|
|
|
3603
3636
|
|
|
3604
3637
|
//#endregion
|
|
3605
3638
|
//#region src/ts-dsl/type/and.ts
|
|
3606
|
-
const Mixed$
|
|
3607
|
-
var TypeAndTsDsl = class extends Mixed$
|
|
3639
|
+
const Mixed$13 = TsDsl;
|
|
3640
|
+
var TypeAndTsDsl = class extends Mixed$13 {
|
|
3608
3641
|
"~dsl" = "TypeAndTsDsl";
|
|
3609
3642
|
scope = "type";
|
|
3610
3643
|
_types = [];
|
|
@@ -3633,8 +3666,8 @@ var TypeAndTsDsl = class extends Mixed$12 {
|
|
|
3633
3666
|
|
|
3634
3667
|
//#endregion
|
|
3635
3668
|
//#region src/ts-dsl/type/literal.ts
|
|
3636
|
-
const Mixed$
|
|
3637
|
-
var TypeLiteralTsDsl = class extends Mixed$
|
|
3669
|
+
const Mixed$12 = TsDsl;
|
|
3670
|
+
var TypeLiteralTsDsl = class extends Mixed$12 {
|
|
3638
3671
|
"~dsl" = "TypeLiteralTsDsl";
|
|
3639
3672
|
scope = "type";
|
|
3640
3673
|
value;
|
|
@@ -3652,8 +3685,8 @@ var TypeLiteralTsDsl = class extends Mixed$11 {
|
|
|
3652
3685
|
|
|
3653
3686
|
//#endregion
|
|
3654
3687
|
//#region src/ts-dsl/type/idx-sig.ts
|
|
3655
|
-
const Mixed$
|
|
3656
|
-
var TypeIdxSigTsDsl = class extends Mixed$
|
|
3688
|
+
const Mixed$11 = DocMixin(ReadonlyMixin(TsDsl));
|
|
3689
|
+
var TypeIdxSigTsDsl = class extends Mixed$11 {
|
|
3657
3690
|
"~dsl" = "TypeIdxSigTsDsl";
|
|
3658
3691
|
scope = "type";
|
|
3659
3692
|
_key;
|
|
@@ -3711,8 +3744,8 @@ var TypeIdxSigTsDsl = class extends Mixed$10 {
|
|
|
3711
3744
|
|
|
3712
3745
|
//#endregion
|
|
3713
3746
|
//#region src/ts-dsl/type/prop.ts
|
|
3714
|
-
const Mixed$
|
|
3715
|
-
var TypePropTsDsl = class extends Mixed$
|
|
3747
|
+
const Mixed$10 = DocMixin(OptionalMixin(ReadonlyMixin(TsDsl)));
|
|
3748
|
+
var TypePropTsDsl = class extends Mixed$10 {
|
|
3716
3749
|
"~dsl" = "TypePropTsDsl";
|
|
3717
3750
|
scope = "type";
|
|
3718
3751
|
_type;
|
|
@@ -3763,8 +3796,8 @@ var TypePropTsDsl = class extends Mixed$9 {
|
|
|
3763
3796
|
|
|
3764
3797
|
//#endregion
|
|
3765
3798
|
//#region src/ts-dsl/type/object.ts
|
|
3766
|
-
const Mixed$
|
|
3767
|
-
var TypeObjectTsDsl = class extends Mixed$
|
|
3799
|
+
const Mixed$9 = TsDsl;
|
|
3800
|
+
var TypeObjectTsDsl = class extends Mixed$9 {
|
|
3768
3801
|
"~dsl" = "TypeObjectTsDsl";
|
|
3769
3802
|
scope = "type";
|
|
3770
3803
|
_props = /* @__PURE__ */ new Map();
|
|
@@ -3806,8 +3839,8 @@ var TypeObjectTsDsl = class extends Mixed$8 {
|
|
|
3806
3839
|
|
|
3807
3840
|
//#endregion
|
|
3808
3841
|
//#region src/ts-dsl/type/tuple.ts
|
|
3809
|
-
const Mixed$
|
|
3810
|
-
var TypeTupleTsDsl = class extends Mixed$
|
|
3842
|
+
const Mixed$8 = TsDsl;
|
|
3843
|
+
var TypeTupleTsDsl = class extends Mixed$8 {
|
|
3811
3844
|
"~dsl" = "TypeTupleTsDsl";
|
|
3812
3845
|
scope = "type";
|
|
3813
3846
|
_elements = [];
|
|
@@ -3829,7 +3862,7 @@ var TypeTupleTsDsl = class extends Mixed$7 {
|
|
|
3829
3862
|
};
|
|
3830
3863
|
|
|
3831
3864
|
//#endregion
|
|
3832
|
-
//#region src/ts-dsl/type/
|
|
3865
|
+
//#region src/ts-dsl/type/from-value.ts
|
|
3833
3866
|
const fromValue = (input) => {
|
|
3834
3867
|
if (isNode(input)) return input;
|
|
3835
3868
|
if (input === null) return new TypeLiteralTsDsl(input);
|
|
@@ -3848,8 +3881,8 @@ const fromValue = (input) => {
|
|
|
3848
3881
|
|
|
3849
3882
|
//#endregion
|
|
3850
3883
|
//#region src/ts-dsl/type/func.ts
|
|
3851
|
-
const Mixed$
|
|
3852
|
-
var TypeFuncTsDsl = class extends Mixed$
|
|
3884
|
+
const Mixed$7 = DocMixin(ParamMixin(TypeParamsMixin(TypeReturnsMixin(TsDsl))));
|
|
3885
|
+
var TypeFuncTsDsl = class extends Mixed$7 {
|
|
3853
3886
|
"~dsl" = "TypeFuncTsDsl";
|
|
3854
3887
|
scope = "type";
|
|
3855
3888
|
analyze(ctx) {
|
|
@@ -3878,8 +3911,8 @@ var TypeFuncTsDsl = class extends Mixed$6 {
|
|
|
3878
3911
|
|
|
3879
3912
|
//#endregion
|
|
3880
3913
|
//#region src/ts-dsl/type/idx.ts
|
|
3881
|
-
const Mixed$
|
|
3882
|
-
var TypeIdxTsDsl = class extends Mixed$
|
|
3914
|
+
const Mixed$6 = TypeExprMixin(TsDsl);
|
|
3915
|
+
var TypeIdxTsDsl = class extends Mixed$6 {
|
|
3883
3916
|
"~dsl" = "TypeIdxTsDsl";
|
|
3884
3917
|
scope = "type";
|
|
3885
3918
|
_base;
|
|
@@ -3926,8 +3959,8 @@ f.type.idx.set((...args) => new TypeIdxTsDsl(...args));
|
|
|
3926
3959
|
|
|
3927
3960
|
//#endregion
|
|
3928
3961
|
//#region src/ts-dsl/type/mapped.ts
|
|
3929
|
-
const Mixed$
|
|
3930
|
-
var TypeMappedTsDsl = class extends Mixed$
|
|
3962
|
+
const Mixed$5 = TsDsl;
|
|
3963
|
+
var TypeMappedTsDsl = class extends Mixed$5 {
|
|
3931
3964
|
"~dsl" = "TypeMappedTsDsl";
|
|
3932
3965
|
scope = "type";
|
|
3933
3966
|
questionToken;
|
|
@@ -3999,7 +4032,7 @@ var TypeMappedTsDsl = class extends Mixed$4 {
|
|
|
3999
4032
|
|
|
4000
4033
|
//#endregion
|
|
4001
4034
|
//#region src/ts-dsl/type/operator.ts
|
|
4002
|
-
const Mixed$
|
|
4035
|
+
const Mixed$4 = TsDsl;
|
|
4003
4036
|
/**
|
|
4004
4037
|
* Builds a TypeScript `TypeOperatorNode`, such as:
|
|
4005
4038
|
*
|
|
@@ -4012,7 +4045,7 @@ const Mixed$3 = TsDsl;
|
|
|
4012
4045
|
*
|
|
4013
4046
|
* The node will throw during render if required fields are missing.
|
|
4014
4047
|
*/
|
|
4015
|
-
var TypeOperatorTsDsl = class extends Mixed$
|
|
4048
|
+
var TypeOperatorTsDsl = class extends Mixed$4 {
|
|
4016
4049
|
"~dsl" = "TypeOperatorTsDsl";
|
|
4017
4050
|
scope = "type";
|
|
4018
4051
|
_op;
|
|
@@ -4070,8 +4103,8 @@ f.type.operator.set((...args) => new TypeOperatorTsDsl(...args));
|
|
|
4070
4103
|
|
|
4071
4104
|
//#endregion
|
|
4072
4105
|
//#region src/ts-dsl/type/or.ts
|
|
4073
|
-
const Mixed$
|
|
4074
|
-
var TypeOrTsDsl = class extends Mixed$
|
|
4106
|
+
const Mixed$3 = TsDsl;
|
|
4107
|
+
var TypeOrTsDsl = class extends Mixed$3 {
|
|
4075
4108
|
"~dsl" = "TypeOrTsDsl";
|
|
4076
4109
|
scope = "type";
|
|
4077
4110
|
_types = [];
|
|
@@ -4100,8 +4133,8 @@ var TypeOrTsDsl = class extends Mixed$2 {
|
|
|
4100
4133
|
|
|
4101
4134
|
//#endregion
|
|
4102
4135
|
//#region src/ts-dsl/type/query.ts
|
|
4103
|
-
const Mixed$
|
|
4104
|
-
var TypeQueryTsDsl = class extends Mixed$
|
|
4136
|
+
const Mixed$2 = TypeExprMixin(TsDsl);
|
|
4137
|
+
var TypeQueryTsDsl = class extends Mixed$2 {
|
|
4105
4138
|
"~dsl" = "TypeQueryTsDsl";
|
|
4106
4139
|
scope = "type";
|
|
4107
4140
|
_expr;
|
|
@@ -4122,8 +4155,8 @@ f.type.query.set((...args) => new TypeQueryTsDsl(...args));
|
|
|
4122
4155
|
|
|
4123
4156
|
//#endregion
|
|
4124
4157
|
//#region src/ts-dsl/type/template.ts
|
|
4125
|
-
const Mixed = TsDsl;
|
|
4126
|
-
var TypeTemplateTsDsl = class extends Mixed {
|
|
4158
|
+
const Mixed$1 = TsDsl;
|
|
4159
|
+
var TypeTemplateTsDsl = class extends Mixed$1 {
|
|
4127
4160
|
"~dsl" = "TypeTemplateTsDsl";
|
|
4128
4161
|
scope = "type";
|
|
4129
4162
|
parts = [];
|
|
@@ -4169,6 +4202,47 @@ var TypeTemplateTsDsl = class extends Mixed {
|
|
|
4169
4202
|
}
|
|
4170
4203
|
};
|
|
4171
4204
|
|
|
4205
|
+
//#endregion
|
|
4206
|
+
//#region src/ts-dsl/type/tuple-member.ts
|
|
4207
|
+
const Mixed = OptionalMixin(TsDsl);
|
|
4208
|
+
var TypeTupleMemberTsDsl = class extends Mixed {
|
|
4209
|
+
"~dsl" = "TypeTupleMemberTsDsl";
|
|
4210
|
+
scope = "type";
|
|
4211
|
+
_type;
|
|
4212
|
+
constructor(name) {
|
|
4213
|
+
super();
|
|
4214
|
+
this.name.set(name);
|
|
4215
|
+
}
|
|
4216
|
+
analyze(ctx) {
|
|
4217
|
+
super.analyze(ctx);
|
|
4218
|
+
ctx.analyze(this.name);
|
|
4219
|
+
ctx.analyze(this._type);
|
|
4220
|
+
}
|
|
4221
|
+
/** Returns true when all required builder calls are present. */
|
|
4222
|
+
get isValid() {
|
|
4223
|
+
return !this.missingRequiredCalls().length;
|
|
4224
|
+
}
|
|
4225
|
+
type(node) {
|
|
4226
|
+
this._type = ref(node);
|
|
4227
|
+
return this;
|
|
4228
|
+
}
|
|
4229
|
+
toAst() {
|
|
4230
|
+
this.$validate();
|
|
4231
|
+
return ts.factory.createNamedTupleMember(void 0, this.$node(this.name), this._optional ? ts.factory.createToken(ts.SyntaxKind.QuestionToken) : void 0, this.$type(this._type));
|
|
4232
|
+
}
|
|
4233
|
+
$validate() {
|
|
4234
|
+
const missing = this.missingRequiredCalls();
|
|
4235
|
+
if (!missing.length) return;
|
|
4236
|
+
throw new Error(`Tuple member missing ${missing.join(" and ")}`);
|
|
4237
|
+
}
|
|
4238
|
+
missingRequiredCalls() {
|
|
4239
|
+
const missing = [];
|
|
4240
|
+
if (!this._type) missing.push(".type()");
|
|
4241
|
+
return missing;
|
|
4242
|
+
}
|
|
4243
|
+
};
|
|
4244
|
+
f.type.tupleMember.set((name) => new TypeTupleMemberTsDsl(name));
|
|
4245
|
+
|
|
4172
4246
|
//#endregion
|
|
4173
4247
|
//#region src/ts-dsl/utils/lazy.ts
|
|
4174
4248
|
var LazyTsDsl = class extends TsDsl {
|
|
@@ -4474,6 +4548,7 @@ const tsDsl = {
|
|
|
4474
4548
|
regexp: (...args) => new RegExpTsDsl(...args),
|
|
4475
4549
|
return: (...args) => new ReturnTsDsl(...args),
|
|
4476
4550
|
setter: (...args) => new SetterTsDsl(...args),
|
|
4551
|
+
spread: (...args) => new SpreadTsDsl(...args),
|
|
4477
4552
|
stmt: (...args) => new StmtTsDsl(...args),
|
|
4478
4553
|
template: (...args) => new TemplateTsDsl(...args),
|
|
4479
4554
|
ternary: (...args) => new TernaryTsDsl(...args),
|
|
@@ -4496,7 +4571,8 @@ const tsDsl = {
|
|
|
4496
4571
|
param: (...args) => new TypeParamTsDsl(...args),
|
|
4497
4572
|
query: (...args) => new TypeQueryTsDsl(...args),
|
|
4498
4573
|
template: (...args) => new TypeTemplateTsDsl(...args),
|
|
4499
|
-
tuple: (...args) => new TypeTupleTsDsl(...args)
|
|
4574
|
+
tuple: (...args) => new TypeTupleTsDsl(...args),
|
|
4575
|
+
tupleMember: (...args) => new TypeTupleMemberTsDsl(...args)
|
|
4500
4576
|
}),
|
|
4501
4577
|
typeofExpr: (...args) => new TypeOfExprTsDsl(...args),
|
|
4502
4578
|
var: (...args) => new VarTsDsl(...args)
|
|
@@ -4511,7 +4587,7 @@ const createRegistryClass = ({ plugin, sdkSymbol, symbol }) => {
|
|
|
4511
4587
|
return $.class(symbol).generic("T").field(symbolDefaultKey, (f) => f.private().readonly().assign($.literal("default"))).newline().field(symbolInstances, (f) => f.private().readonly().type($.type("Map").generics("string", "T")).assign($.new("Map"))).newline().method("get", (m) => m.returns("T").param("key", (p) => p.type("string").optional()).do($.const("instance").assign($("this").attr(symbolInstances).attr("get").call($("key").coalesce($("this").attr(symbolDefaultKey)))), $.if($.not("instance")).do($.throw("Error").message($.template("No SDK client found. Create one with \"new ").add(sdkSymbol).add("()\" to fix this error."))), $.return("instance"))).newline().method("set", (m) => m.returns("void").param("value", (p) => p.type("T")).param("key", (p) => p.type("string").optional()).do($("this").attr(symbolInstances).attr("set").call($("key").coalesce($("this").attr(symbolDefaultKey)), "value")));
|
|
4512
4588
|
};
|
|
4513
4589
|
const createClientClass = ({ plugin, symbol }) => {
|
|
4514
|
-
const symClient = plugin.
|
|
4590
|
+
const symClient = plugin.querySymbol({ category: "client" });
|
|
4515
4591
|
const optionalClient = Boolean(plugin.config.client && symClient);
|
|
4516
4592
|
const symbolClient = plugin.external("client.Client");
|
|
4517
4593
|
return $.class(symbol).field("client", (f) => f.protected().type(symbolClient)).newline().init((i) => i.param("args", (p) => p.optional(optionalClient).type($.type.object().prop("client", (p) => p.optional(optionalClient).type(symbolClient)))).do($("this").attr("client").assign($("args").attr("client").optional(optionalClient).$if(optionalClient, (a) => a.coalesce(symClient)))));
|
|
@@ -4678,16 +4754,16 @@ function getSignatureParameters({ operation }) {
|
|
|
4678
4754
|
|
|
4679
4755
|
//#endregion
|
|
4680
4756
|
//#region src/plugins/@hey-api/sdk/shared/validator.ts
|
|
4681
|
-
|
|
4757
|
+
function createRequestValidator({ plugin, ...args }) {
|
|
4682
4758
|
if (!plugin.config.validator.request) return;
|
|
4683
4759
|
const validator = plugin.getPluginOrThrow(plugin.config.validator.request);
|
|
4684
4760
|
if (!validator.api.createRequestValidator) return;
|
|
4685
4761
|
return validator.api.createRequestValidator({
|
|
4686
|
-
|
|
4762
|
+
...args,
|
|
4687
4763
|
plugin: validator
|
|
4688
4764
|
});
|
|
4689
|
-
}
|
|
4690
|
-
|
|
4765
|
+
}
|
|
4766
|
+
function createResponseValidator({ operation, plugin }) {
|
|
4691
4767
|
if (!plugin.config.validator.response) return;
|
|
4692
4768
|
const validator = plugin.getPluginOrThrow(plugin.config.validator.response);
|
|
4693
4769
|
if (!validator.api.createResponseValidator) return;
|
|
@@ -4695,7 +4771,7 @@ const createResponseValidator = ({ operation, plugin }) => {
|
|
|
4695
4771
|
operation,
|
|
4696
4772
|
plugin: validator
|
|
4697
4773
|
});
|
|
4698
|
-
}
|
|
4774
|
+
}
|
|
4699
4775
|
|
|
4700
4776
|
//#endregion
|
|
4701
4777
|
//#region src/plugins/@hey-api/sdk/shared/operation.ts
|
|
@@ -4723,6 +4799,15 @@ const operationOptionsType = ({ isDataAllowed = true, operation, plugin, throwOn
|
|
|
4723
4799
|
});
|
|
4724
4800
|
return $.type(symbolOptions).generic(nuxtTypeComposable).generic(isDataAllowed ? symbolDataType ?? "unknown" : "never").generic(symbolResponseType ?? "unknown").generic(nuxtTypeDefault);
|
|
4725
4801
|
}
|
|
4802
|
+
if (hasOperationSse({ operation })) {
|
|
4803
|
+
const symbolResponseType = plugin.querySymbol({
|
|
4804
|
+
category: "type",
|
|
4805
|
+
resource: "operation",
|
|
4806
|
+
resourceId: operation.id,
|
|
4807
|
+
role: "response"
|
|
4808
|
+
});
|
|
4809
|
+
return $.type(symbolOptions).generic(isDataAllowed ? symbolDataType ?? "unknown" : "never").generic(throwOnError !== void 0 ? throwOnError : "boolean").generic(symbolResponseType ?? "unknown");
|
|
4810
|
+
}
|
|
4726
4811
|
if (throwOnError) return $.type(symbolOptions).generic(isDataAllowed ? symbolDataType ?? "unknown" : "never").generic(throwOnError);
|
|
4727
4812
|
return $.type(symbolOptions).$if(!isDataAllowed || symbolDataType, (t) => t.generic(isDataAllowed ? symbolDataType : "never"));
|
|
4728
4813
|
};
|
|
@@ -4903,7 +4988,7 @@ function operationStatements({ isRequiredOptions, opParameters, operation, plugi
|
|
|
4903
4988
|
reqOptions.prop("headers", headers);
|
|
4904
4989
|
}
|
|
4905
4990
|
}
|
|
4906
|
-
const symbolClient = plugin.config.client ? plugin.
|
|
4991
|
+
const symbolClient = plugin.config.client ? plugin.querySymbol({ category: "client" }) : void 0;
|
|
4907
4992
|
let clientExpression;
|
|
4908
4993
|
const optionsClient = $("options").attr("client").required(isRequiredOptions);
|
|
4909
4994
|
if (isInstance(plugin)) clientExpression = optionsClient.coalesce($("this").attr("client"));
|
|
@@ -5003,7 +5088,7 @@ function enrichRootClass(args) {
|
|
|
5003
5088
|
sdkSymbol: symbol,
|
|
5004
5089
|
symbol: symbolRegistry
|
|
5005
5090
|
}));
|
|
5006
|
-
const isClientRequired = !plugin.config.client || !plugin.
|
|
5091
|
+
const isClientRequired = !plugin.config.client || !plugin.querySymbol({ category: "client" });
|
|
5007
5092
|
const registry = plugin.symbol("__registry");
|
|
5008
5093
|
node.toAccessNode = (node, options) => {
|
|
5009
5094
|
if (options.context) return;
|
|
@@ -5239,7 +5324,7 @@ function implementHttpRequestFn(args) {
|
|
|
5239
5324
|
operation
|
|
5240
5325
|
});
|
|
5241
5326
|
const symbolHttpRequest = plugin.external("@angular/common/http.HttpRequest");
|
|
5242
|
-
const symbolClient = plugin.
|
|
5327
|
+
const symbolClient = plugin.querySymbol({ category: "client" });
|
|
5243
5328
|
const symbolOptions = plugin.referenceSymbol({
|
|
5244
5329
|
category: "type",
|
|
5245
5330
|
resource: "client-options",
|
|
@@ -6305,7 +6390,7 @@ const createTypeOptions = ({ plugin }) => {
|
|
|
6305
6390
|
resource: "client-options",
|
|
6306
6391
|
tool: "sdk"
|
|
6307
6392
|
} });
|
|
6308
|
-
const typeOptions = $.type.alias(symbolOptions).export().$if(isNuxtClient, (t) => t.generic("TComposable", (g) => g.extends(plugin.external("client.Composable")).default($.type.literal("$fetch"))).generic("TData", (g) => g.extends(symbolTDataShape).default(symbolTDataShape)).generic(nuxtTypeResponse, (g) => g.default("unknown")).generic(nuxtTypeDefault, (g) => g.default("undefined")), (t) => t.generic("TData", (g) => g.extends(symbolTDataShape).default(symbolTDataShape)).generic("ThrowOnError", (g) => g.extends("boolean").default("boolean"))).type($.type.and($.type(symbolClientOptions).$if(isNuxtClient, (t) => t.generic("TComposable").generic("TData").generic(nuxtTypeResponse).generic(nuxtTypeDefault), (t) => t.generic("TData").generic("ThrowOnError")), $.type.object().prop("client", (p) => p.doc([
|
|
6393
|
+
const typeOptions = $.type.alias(symbolOptions).export().$if(isNuxtClient, (t) => t.generic("TComposable", (g) => g.extends(plugin.external("client.Composable")).default($.type.literal("$fetch"))).generic("TData", (g) => g.extends(symbolTDataShape).default(symbolTDataShape)).generic(nuxtTypeResponse, (g) => g.default("unknown")).generic(nuxtTypeDefault, (g) => g.default("undefined")), (t) => t.generic("TData", (g) => g.extends(symbolTDataShape).default(symbolTDataShape)).generic("ThrowOnError", (g) => g.extends("boolean").default("boolean")).generic("TResponse", (g) => g.default("unknown"))).type($.type.and($.type(symbolClientOptions).$if(isNuxtClient, (t) => t.generic("TComposable").generic("TData").generic(nuxtTypeResponse).generic(nuxtTypeDefault), (t) => t.generic("TData").generic("ThrowOnError").generic("TResponse")), $.type.object().prop("client", (p) => p.doc([
|
|
6309
6394
|
"You can provide a client instance returned by `createClient()` instead of",
|
|
6310
6395
|
"individual options. This might be also useful if you want to implement a",
|
|
6311
6396
|
"custom client."
|
|
@@ -6491,7 +6576,7 @@ function processSchemaType({ dataExpression, plugin, schema }) {
|
|
|
6491
6576
|
resource: "definition",
|
|
6492
6577
|
resourceId: schema.$ref
|
|
6493
6578
|
};
|
|
6494
|
-
const symbol = plugin.
|
|
6579
|
+
const symbol = plugin.querySymbol(query) ?? plugin.symbol(applyNaming(refToName(schema.$ref), {
|
|
6495
6580
|
case: "camelCase",
|
|
6496
6581
|
name: "{{name}}SchemaResponseTransformer"
|
|
6497
6582
|
}), { meta: query });
|
|
@@ -7180,14 +7265,14 @@ function formatNode$4(ctx) {
|
|
|
7180
7265
|
resourceId: typeidBase,
|
|
7181
7266
|
tool: "typescript"
|
|
7182
7267
|
};
|
|
7183
|
-
if (!plugin.
|
|
7268
|
+
if (!plugin.querySymbol(typeidQuery)) {
|
|
7184
7269
|
const containerQuery = {
|
|
7185
7270
|
category: "type",
|
|
7186
7271
|
resource: "type-id",
|
|
7187
7272
|
tool: "typescript",
|
|
7188
7273
|
variant: "container"
|
|
7189
7274
|
};
|
|
7190
|
-
if (!plugin.
|
|
7275
|
+
if (!plugin.querySymbol(containerQuery)) {
|
|
7191
7276
|
const symbolTypeId = plugin.symbol("TypeID", { meta: containerQuery });
|
|
7192
7277
|
const nodeTypeId = $.type.alias(symbolTypeId).export().generic("T", (g) => g.extends("string")).type($.type.template().add($.type("T")).add("_").add($.type("string")));
|
|
7193
7278
|
plugin.node(nodeTypeId);
|
|
@@ -7350,7 +7435,7 @@ function voidToAst$3({ plugin, schema }) {
|
|
|
7350
7435
|
|
|
7351
7436
|
//#endregion
|
|
7352
7437
|
//#region src/plugins/@hey-api/typescript/v1/walker.ts
|
|
7353
|
-
function createVisitor$4(config) {
|
|
7438
|
+
function createVisitor$4(config = {}) {
|
|
7354
7439
|
const { schemaExtractor } = config;
|
|
7355
7440
|
return {
|
|
7356
7441
|
applyModifiers(result) {
|
|
@@ -7578,7 +7663,7 @@ function createProcessor$4(plugin) {
|
|
|
7578
7663
|
const extractorHooks = [plugin.config["~hooks"]?.schemas?.shouldExtract, plugin.context.config.parser.hooks.schemas?.shouldExtract];
|
|
7579
7664
|
function extractor(ctx) {
|
|
7580
7665
|
if (processor.hasEmitted(ctx.path)) return ctx.schema;
|
|
7581
|
-
for (const hook of extractorHooks) if (hook?.(ctx)) {
|
|
7666
|
+
for (const hook of extractorHooks) if (typeof hook === "boolean" ? hook : hook?.(ctx) ?? false) {
|
|
7582
7667
|
process({
|
|
7583
7668
|
namingAnchor: processor.context.anchor,
|
|
7584
7669
|
tags: processor.context.tags,
|
|
@@ -8210,7 +8295,7 @@ const createQueryKeyFunction$1 = ({ plugin }) => {
|
|
|
8210
8295
|
resource: "client-options",
|
|
8211
8296
|
tool: "sdk"
|
|
8212
8297
|
});
|
|
8213
|
-
const symbolClient = plugin.
|
|
8298
|
+
const symbolClient = plugin.querySymbol({ category: "client" });
|
|
8214
8299
|
const clientModule = clientFolderAbsolutePath(getTypedConfig(plugin));
|
|
8215
8300
|
const symbolSerializeQueryValue = plugin.symbol("serializeQueryKeyValue", { external: clientModule });
|
|
8216
8301
|
const fn = $.const(symbolCreateQueryKey).assign($.func().param("id", (p) => p.type("string")).param("options", (p) => p.optional().type(TOptionsType$1)).param("tags", (p) => p.optional().type("ReadonlyArray<string>")).returns($.type.tuple(returnType)).generic(TOptionsType$1, (g) => g.extends(symbolOptions)).do($.const("params").type(returnType).assign($.object().prop("_id", "id").prop(baseUrlKey, $("options").attr(baseUrlKey).optional().or($("options").attr("client").optional().$if(symbolClient, (a, v) => a.coalesce(v)).attr("getConfig").call().attr(baseUrlKey))).as(returnType)), $.if("tags").do($("params").attr("tags").assign($("tags").as("unknown").as(symbolJsonValue))), $.if($("options").attr("body").optional().neq($.id("undefined"))).do($.const("normalizedBody").assign($(symbolSerializeQueryValue).call($("options").attr("body"))), $.if($("normalizedBody").neq($.id("undefined"))).do($("params").attr("body").assign("normalizedBody"))), $.if($("options").attr("path").optional()).do($("params").attr("path").assign($("options").attr("path"))), $.if($("options").attr("query").optional().neq($.id("undefined"))).do($.const("normalizedQuery").assign($(symbolSerializeQueryValue).call($("options").attr("query"))), $.if($("normalizedQuery").neq($.id("undefined"))).do($("params").attr("query").assign("normalizedQuery"))), $.return($.array($("params")))));
|
|
@@ -8264,7 +8349,7 @@ const createQueryOptions$1 = ({ operation, plugin }) => {
|
|
|
8264
8349
|
context: plugin.context,
|
|
8265
8350
|
operation
|
|
8266
8351
|
});
|
|
8267
|
-
if (!plugin.
|
|
8352
|
+
if (!plugin.querySymbol({
|
|
8268
8353
|
category: "utility",
|
|
8269
8354
|
resource: "createQueryKey",
|
|
8270
8355
|
tool: plugin.name
|
|
@@ -8458,7 +8543,7 @@ const createQueryKeyFunction = ({ plugin }) => {
|
|
|
8458
8543
|
tool: plugin.name
|
|
8459
8544
|
});
|
|
8460
8545
|
const baseUrlKey = getClientBaseUrlKey(getTypedConfig(plugin));
|
|
8461
|
-
const symbolClient = plugin.
|
|
8546
|
+
const symbolClient = plugin.querySymbol({ category: "client" });
|
|
8462
8547
|
const symbolOptions = plugin.referenceSymbol({
|
|
8463
8548
|
category: "type",
|
|
8464
8549
|
resource: "client-options",
|
|
@@ -8536,7 +8621,7 @@ const createInfiniteQueryOptions = ({ operation, plugin }) => {
|
|
|
8536
8621
|
context: plugin.context,
|
|
8537
8622
|
operation
|
|
8538
8623
|
});
|
|
8539
|
-
if (!plugin.
|
|
8624
|
+
if (!plugin.querySymbol({
|
|
8540
8625
|
category: "utility",
|
|
8541
8626
|
resource: "createQueryKey",
|
|
8542
8627
|
tool: plugin.name
|
|
@@ -8544,7 +8629,7 @@ const createInfiniteQueryOptions = ({ operation, plugin }) => {
|
|
|
8544
8629
|
createQueryKeyType({ plugin });
|
|
8545
8630
|
createQueryKeyFunction({ plugin });
|
|
8546
8631
|
}
|
|
8547
|
-
if (!plugin.
|
|
8632
|
+
if (!plugin.querySymbol({
|
|
8548
8633
|
category: "utility",
|
|
8549
8634
|
resource: "createInfiniteParams",
|
|
8550
8635
|
tool: plugin.name
|
|
@@ -8644,7 +8729,7 @@ const createQueryOptions = ({ operation, plugin }) => {
|
|
|
8644
8729
|
context: plugin.context,
|
|
8645
8730
|
operation
|
|
8646
8731
|
});
|
|
8647
|
-
if (!plugin.
|
|
8732
|
+
if (!plugin.querySymbol({
|
|
8648
8733
|
category: "utility",
|
|
8649
8734
|
resource: "createQueryKey",
|
|
8650
8735
|
tool: plugin.name
|
|
@@ -9333,8 +9418,8 @@ const defineConfig$7 = definePluginConfig(defaultConfig$7);
|
|
|
9333
9418
|
|
|
9334
9419
|
//#endregion
|
|
9335
9420
|
//#region src/plugins/arktype/v2/api.ts
|
|
9336
|
-
|
|
9337
|
-
const symbol = plugin.
|
|
9421
|
+
function createRequestValidatorV2({ operation, plugin }) {
|
|
9422
|
+
const symbol = plugin.querySymbol({
|
|
9338
9423
|
category: "schema",
|
|
9339
9424
|
resource: "operation",
|
|
9340
9425
|
resourceId: operation.id,
|
|
@@ -9344,9 +9429,9 @@ const createRequestValidatorV2 = ({ operation, plugin }) => {
|
|
|
9344
9429
|
if (!symbol) return;
|
|
9345
9430
|
const dataParameterName = "data";
|
|
9346
9431
|
return $.func().async().param(dataParameterName).do($(symbol).attr("parseAsync").call(dataParameterName).await().return());
|
|
9347
|
-
}
|
|
9348
|
-
|
|
9349
|
-
const symbol = plugin.
|
|
9432
|
+
}
|
|
9433
|
+
function createResponseValidatorV2({ operation, plugin }) {
|
|
9434
|
+
const symbol = plugin.querySymbol({
|
|
9350
9435
|
category: "schema",
|
|
9351
9436
|
resource: "operation",
|
|
9352
9437
|
resourceId: operation.id,
|
|
@@ -9356,7 +9441,7 @@ const createResponseValidatorV2 = ({ operation, plugin }) => {
|
|
|
9356
9441
|
if (!symbol) return;
|
|
9357
9442
|
const dataParameterName = "data";
|
|
9358
9443
|
return $.func().async().param(dataParameterName).do($(symbol).attr("parseAsync").call(dataParameterName).await().return());
|
|
9359
|
-
}
|
|
9444
|
+
}
|
|
9360
9445
|
|
|
9361
9446
|
//#endregion
|
|
9362
9447
|
//#region src/plugins/arktype/api.ts
|
|
@@ -10208,13 +10293,25 @@ function createContractExpression(plugin, operation) {
|
|
|
10208
10293
|
const successResponse = getSuccessResponse(operation);
|
|
10209
10294
|
const tags = getTags(operation, plugin.config.contracts.strategyDefaultTag);
|
|
10210
10295
|
let expression = $(plugin.external("@orpc/contract.oc")).attr("route").call($.object().$if(operation.deprecated, (o, v) => o.prop("deprecated", $.literal(v))).$if(operation.description, (o, v) => o.prop("description", $.literal(v))).prop("inputStructure", $.literal("detailed")).prop("method", $.literal(operation.method.toUpperCase())).$if(operation.operationId, (o, v) => o.prop("operationId", $.literal(v))).prop("path", $.literal(operation.path)).$if(successResponse.hasOutput && successResponse.statusCode !== 200 && successResponse.statusCode, (o, v) => o.prop("successStatus", $.literal(v))).$if(operation.summary, (o, v) => o.prop("summary", $.literal(v))).$if(Boolean(tags.length) && tags, (o, v) => o.prop("tags", $.fromValue(v))));
|
|
10211
|
-
if (hasInput(operation) && plugin.config.validator.input)
|
|
10212
|
-
|
|
10213
|
-
|
|
10214
|
-
|
|
10215
|
-
|
|
10216
|
-
|
|
10217
|
-
|
|
10296
|
+
if (hasInput(operation) && plugin.config.validator.input) {
|
|
10297
|
+
const validator = plugin.getPluginOrThrow(plugin.config.validator.input);
|
|
10298
|
+
if ("createRequestSchema" in validator.api) {
|
|
10299
|
+
const requestSchema = validator.api.createRequestSchema({
|
|
10300
|
+
layers: {
|
|
10301
|
+
body: { whenEmpty: "omit" },
|
|
10302
|
+
headers: { whenEmpty: "omit" },
|
|
10303
|
+
path: {
|
|
10304
|
+
as: "params",
|
|
10305
|
+
whenEmpty: "omit"
|
|
10306
|
+
},
|
|
10307
|
+
query: { whenEmpty: "omit" }
|
|
10308
|
+
},
|
|
10309
|
+
operation,
|
|
10310
|
+
plugin: validator
|
|
10311
|
+
});
|
|
10312
|
+
if (requestSchema) expression = expression.attr("input").call(requestSchema);
|
|
10313
|
+
}
|
|
10314
|
+
}
|
|
10218
10315
|
if (successResponse.hasOutput && plugin.config.validator.output) expression = expression.attr("output").call(plugin.referenceSymbol({
|
|
10219
10316
|
category: "schema",
|
|
10220
10317
|
resource: "operation",
|
|
@@ -10801,82 +10898,27 @@ function pipesToNode(pipes, plugin) {
|
|
|
10801
10898
|
}
|
|
10802
10899
|
|
|
10803
10900
|
//#endregion
|
|
10804
|
-
//#region src/plugins/valibot/
|
|
10805
|
-
|
|
10806
|
-
const
|
|
10807
|
-
|
|
10808
|
-
|
|
10809
|
-
|
|
10810
|
-
|
|
10811
|
-
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
tool: "valibot"
|
|
10816
|
-
});
|
|
10817
|
-
if (!symbol) return;
|
|
10818
|
-
const ctx = {
|
|
10819
|
-
$,
|
|
10820
|
-
operation,
|
|
10821
|
-
pipes: {
|
|
10822
|
-
...pipes,
|
|
10823
|
-
current: []
|
|
10824
|
-
},
|
|
10825
|
-
plugin,
|
|
10826
|
-
symbols: {
|
|
10827
|
-
schema: symbol,
|
|
10828
|
-
v: plugin.external("valibot.v")
|
|
10829
|
-
}
|
|
10830
|
-
};
|
|
10831
|
-
const validator = plugin.config["~resolvers"]?.validator;
|
|
10832
|
-
const candidates = [typeof validator === "function" ? validator : validator?.request, validatorResolver$3];
|
|
10833
|
-
for (const candidate of candidates) {
|
|
10834
|
-
const statements = candidate?.(ctx);
|
|
10835
|
-
if (statements === null) return;
|
|
10836
|
-
if (statements !== void 0) return $.func().async().param("data").do(...statements instanceof Array ? statements : [statements]);
|
|
10837
|
-
}
|
|
10838
|
-
};
|
|
10839
|
-
const createResponseValidatorV1 = ({ operation, plugin }) => {
|
|
10840
|
-
const symbol = plugin.getSymbol({
|
|
10841
|
-
category: "schema",
|
|
10842
|
-
resource: "operation",
|
|
10843
|
-
resourceId: operation.id,
|
|
10844
|
-
role: "responses",
|
|
10845
|
-
tool: "valibot"
|
|
10846
|
-
});
|
|
10847
|
-
if (!symbol) return;
|
|
10848
|
-
const ctx = {
|
|
10849
|
-
$,
|
|
10850
|
-
operation,
|
|
10851
|
-
pipes: {
|
|
10852
|
-
...pipes,
|
|
10853
|
-
current: []
|
|
10901
|
+
//#region src/plugins/valibot/shared/export.ts
|
|
10902
|
+
function exportAst$1({ final, meta, naming, namingAnchor, path, plugin, schema, tags }) {
|
|
10903
|
+
const v = plugin.external("valibot.v");
|
|
10904
|
+
const name = pathToName(path, { anchor: namingAnchor });
|
|
10905
|
+
const symbol = plugin.registerSymbol(buildSymbolIn({
|
|
10906
|
+
meta: {
|
|
10907
|
+
category: "schema",
|
|
10908
|
+
path,
|
|
10909
|
+
tags,
|
|
10910
|
+
tool: "valibot",
|
|
10911
|
+
...meta
|
|
10854
10912
|
},
|
|
10913
|
+
name,
|
|
10914
|
+
naming,
|
|
10855
10915
|
plugin,
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
|
|
10861
|
-
|
|
10862
|
-
const candidates = [typeof validator === "function" ? validator : validator?.response, validatorResolver$3];
|
|
10863
|
-
for (const candidate of candidates) {
|
|
10864
|
-
const statements = candidate?.(ctx);
|
|
10865
|
-
if (statements === null) return;
|
|
10866
|
-
if (statements !== void 0) return $.func().async().param("data").do(...statements instanceof Array ? statements : [statements]);
|
|
10867
|
-
}
|
|
10868
|
-
};
|
|
10869
|
-
|
|
10870
|
-
//#endregion
|
|
10871
|
-
//#region src/plugins/valibot/api.ts
|
|
10872
|
-
var Api$1 = class {
|
|
10873
|
-
createRequestValidator(args) {
|
|
10874
|
-
return createRequestValidatorV1(args);
|
|
10875
|
-
}
|
|
10876
|
-
createResponseValidator(args) {
|
|
10877
|
-
return createResponseValidatorV1(args);
|
|
10878
|
-
}
|
|
10879
|
-
};
|
|
10916
|
+
schema
|
|
10917
|
+
}));
|
|
10918
|
+
const statement = $.const(symbol).export().$if(plugin.config.comments && createSchemaComment(schema), (c, v) => c.doc(v)).$if(final.typeName, (c) => c.type($.type(v).attr(final.typeName))).assign(pipesToNode(final.pipes, plugin));
|
|
10919
|
+
plugin.node(statement);
|
|
10920
|
+
return symbol;
|
|
10921
|
+
}
|
|
10880
10922
|
|
|
10881
10923
|
//#endregion
|
|
10882
10924
|
//#region src/plugins/valibot/shared/operation-schema.ts
|
|
@@ -10926,51 +10968,288 @@ function buildOperationSchema$1(operation) {
|
|
|
10926
10968
|
}
|
|
10927
10969
|
|
|
10928
10970
|
//#endregion
|
|
10929
|
-
//#region src/plugins/valibot/shared/
|
|
10930
|
-
function
|
|
10931
|
-
|
|
10932
|
-
|
|
10933
|
-
|
|
10934
|
-
|
|
10935
|
-
|
|
10936
|
-
|
|
10937
|
-
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
|
|
10941
|
-
|
|
10942
|
-
|
|
10943
|
-
|
|
10944
|
-
|
|
10945
|
-
|
|
10946
|
-
|
|
10947
|
-
|
|
10948
|
-
|
|
10949
|
-
|
|
10950
|
-
|
|
10951
|
-
|
|
10952
|
-
resource: "operation",
|
|
10953
|
-
resourceId: operation.id,
|
|
10954
|
-
role: "responses"
|
|
10955
|
-
},
|
|
10956
|
-
naming: plugin.config.responses,
|
|
10957
|
-
namingAnchor: operation.id,
|
|
10958
|
-
path: [...path, "responses"],
|
|
10959
|
-
plugin,
|
|
10960
|
-
schema: response,
|
|
10961
|
-
tags
|
|
10962
|
-
});
|
|
10971
|
+
//#region src/plugins/valibot/shared/validator.ts
|
|
10972
|
+
function getDefaultRequestValidatorLayers$1(operation) {
|
|
10973
|
+
const { schema } = buildOperationSchema$1(operation);
|
|
10974
|
+
return {
|
|
10975
|
+
body: {
|
|
10976
|
+
as: "body",
|
|
10977
|
+
optional: !schema.required?.includes("body"),
|
|
10978
|
+
whenEmpty: "strict"
|
|
10979
|
+
},
|
|
10980
|
+
headers: {
|
|
10981
|
+
as: "headers",
|
|
10982
|
+
optional: !schema.required?.includes("headers"),
|
|
10983
|
+
whenEmpty: "omit"
|
|
10984
|
+
},
|
|
10985
|
+
path: {
|
|
10986
|
+
as: "path",
|
|
10987
|
+
optional: !schema.required?.includes("path"),
|
|
10988
|
+
whenEmpty: "strict"
|
|
10989
|
+
},
|
|
10990
|
+
query: {
|
|
10991
|
+
as: "query",
|
|
10992
|
+
optional: !schema.required?.includes("query"),
|
|
10993
|
+
whenEmpty: "strict"
|
|
10963
10994
|
}
|
|
10964
|
-
}
|
|
10995
|
+
};
|
|
10965
10996
|
}
|
|
10966
10997
|
|
|
10967
10998
|
//#endregion
|
|
10968
|
-
//#region src/plugins/valibot/
|
|
10969
|
-
function
|
|
10970
|
-
|
|
10971
|
-
|
|
10972
|
-
|
|
10973
|
-
|
|
10999
|
+
//#region src/plugins/valibot/v1/api.ts
|
|
11000
|
+
function emptyNode$3(ctx) {
|
|
11001
|
+
const { v } = ctx.symbols;
|
|
11002
|
+
if (ctx.layer.whenEmpty === "omit") throw new Error(`Cannot create empty schema for layer "${ctx.layer.as}" with whenEmpty: 'omit'`);
|
|
11003
|
+
if (ctx.layer.whenEmpty === "strict") return $(v).attr(identifiers$1.schemas.never).call();
|
|
11004
|
+
return $(v).attr(identifiers$1.schemas.object).call($.object());
|
|
11005
|
+
}
|
|
11006
|
+
function optionalNode$3(ctx) {
|
|
11007
|
+
if (!ctx.layer.optional) return ctx.schema;
|
|
11008
|
+
const v = ctx.symbols.v;
|
|
11009
|
+
return $(v).attr(identifiers$1.schemas.optional).call(ctx.schema);
|
|
11010
|
+
}
|
|
11011
|
+
function compositeNode$3(ctx) {
|
|
11012
|
+
const { v } = ctx.symbols;
|
|
11013
|
+
const obj = $.object();
|
|
11014
|
+
const defaultValues = getDefaultRequestValidatorLayers$1(ctx.operation);
|
|
11015
|
+
for (const key of requestValidatorLayers) {
|
|
11016
|
+
const layer = resolveValidatorLayer(ctx.layers, key, defaultValues);
|
|
11017
|
+
const layerSchema = ctx.plugin.querySymbol({
|
|
11018
|
+
category: "schema",
|
|
11019
|
+
resource: "operation",
|
|
11020
|
+
resourceId: ctx.operation.id,
|
|
11021
|
+
role: `request-${key}`,
|
|
11022
|
+
tool: "valibot"
|
|
11023
|
+
});
|
|
11024
|
+
if (layerSchema) {
|
|
11025
|
+
obj.prop(layer.as, ctx.nodes.optional({
|
|
11026
|
+
...ctx,
|
|
11027
|
+
layer,
|
|
11028
|
+
schema: $(layerSchema)
|
|
11029
|
+
}));
|
|
11030
|
+
continue;
|
|
11031
|
+
}
|
|
11032
|
+
if (layer.whenEmpty === "omit") continue;
|
|
11033
|
+
const empty = ctx.nodes.empty({
|
|
11034
|
+
...ctx,
|
|
11035
|
+
layer
|
|
11036
|
+
});
|
|
11037
|
+
obj.prop(layer.as, ctx.nodes.optional({
|
|
11038
|
+
...ctx,
|
|
11039
|
+
layer,
|
|
11040
|
+
schema: empty
|
|
11041
|
+
}));
|
|
11042
|
+
}
|
|
11043
|
+
if (obj.isEmpty) return;
|
|
11044
|
+
return $(v).attr(identifiers$1.schemas.object).call(obj);
|
|
11045
|
+
}
|
|
11046
|
+
function requestValidatorResolver$3(ctx) {
|
|
11047
|
+
const { schema, v } = ctx.symbols;
|
|
11048
|
+
return $(v).attr(identifiers$1.async.parseAsync).call(schema, "data").await().return();
|
|
11049
|
+
}
|
|
11050
|
+
function responseValidatorResolver$3(ctx) {
|
|
11051
|
+
const { schema, v } = ctx.symbols;
|
|
11052
|
+
return $(v).attr(identifiers$1.async.parseAsync).call(schema, "data").await().return();
|
|
11053
|
+
}
|
|
11054
|
+
function runRequestResolver$3(ctx) {
|
|
11055
|
+
const validator = ctx.plugin.config["~resolvers"]?.validator;
|
|
11056
|
+
const candidates = [typeof validator === "function" ? validator : validator?.request, requestValidatorResolver$3];
|
|
11057
|
+
for (const candidate of candidates) {
|
|
11058
|
+
const statements = candidate?.(ctx);
|
|
11059
|
+
if (statements === null) return;
|
|
11060
|
+
if (statements !== void 0) return $.func().async().param("data").do(...statements instanceof Array ? statements : [statements]);
|
|
11061
|
+
}
|
|
11062
|
+
}
|
|
11063
|
+
function runResponseResolver$3(ctx) {
|
|
11064
|
+
const validator = ctx.plugin.config["~resolvers"]?.validator;
|
|
11065
|
+
const candidates = [typeof validator === "function" ? validator : validator?.response, responseValidatorResolver$3];
|
|
11066
|
+
for (const candidate of candidates) {
|
|
11067
|
+
const statements = candidate?.(ctx);
|
|
11068
|
+
if (statements === null) return;
|
|
11069
|
+
if (statements !== void 0) return $.func().async().param("data").do(...statements instanceof Array ? statements : [statements]);
|
|
11070
|
+
}
|
|
11071
|
+
}
|
|
11072
|
+
function createRequestSchemaContext$3(ctx) {
|
|
11073
|
+
const { plugin } = ctx;
|
|
11074
|
+
const v = plugin.external("valibot.v");
|
|
11075
|
+
return {
|
|
11076
|
+
...ctx,
|
|
11077
|
+
$,
|
|
11078
|
+
nodes: {
|
|
11079
|
+
composite: compositeNode$3,
|
|
11080
|
+
empty: emptyNode$3,
|
|
11081
|
+
optional: optionalNode$3
|
|
11082
|
+
},
|
|
11083
|
+
pipes: {
|
|
11084
|
+
...pipes,
|
|
11085
|
+
current: []
|
|
11086
|
+
},
|
|
11087
|
+
symbols: {
|
|
11088
|
+
schema: $(""),
|
|
11089
|
+
v
|
|
11090
|
+
}
|
|
11091
|
+
};
|
|
11092
|
+
}
|
|
11093
|
+
function createRequestSchemaV1(ctx) {
|
|
11094
|
+
const { operation, plugin } = ctx;
|
|
11095
|
+
const baseCtx = createRequestSchemaContext$3(ctx);
|
|
11096
|
+
const schema = baseCtx.nodes.composite(baseCtx);
|
|
11097
|
+
if (!schema) return;
|
|
11098
|
+
if (!plugin.config.requests.shouldExtract({ operation })) return schema;
|
|
11099
|
+
return exportAst$1({
|
|
11100
|
+
final: { pipes: [schema] },
|
|
11101
|
+
meta: {
|
|
11102
|
+
resource: "operation",
|
|
11103
|
+
resourceId: operation.id,
|
|
11104
|
+
role: "data"
|
|
11105
|
+
},
|
|
11106
|
+
naming: plugin.config.requests,
|
|
11107
|
+
namingAnchor: operation.id,
|
|
11108
|
+
path: [],
|
|
11109
|
+
plugin,
|
|
11110
|
+
schema: {}
|
|
11111
|
+
});
|
|
11112
|
+
}
|
|
11113
|
+
function createRequestValidatorV1(ctx) {
|
|
11114
|
+
const symbolOrSchema = createRequestSchemaV1(ctx);
|
|
11115
|
+
if (!symbolOrSchema) return;
|
|
11116
|
+
const baseCtx = createRequestSchemaContext$3(ctx);
|
|
11117
|
+
return runRequestResolver$3({
|
|
11118
|
+
...baseCtx,
|
|
11119
|
+
symbols: {
|
|
11120
|
+
...baseCtx.symbols,
|
|
11121
|
+
schema: symbolOrSchema
|
|
11122
|
+
}
|
|
11123
|
+
});
|
|
11124
|
+
}
|
|
11125
|
+
function createResponseValidatorV1({ operation, plugin }) {
|
|
11126
|
+
const symbol = plugin.querySymbol({
|
|
11127
|
+
category: "schema",
|
|
11128
|
+
resource: "operation",
|
|
11129
|
+
resourceId: operation.id,
|
|
11130
|
+
role: "responses",
|
|
11131
|
+
tool: "valibot"
|
|
11132
|
+
});
|
|
11133
|
+
if (!symbol) return;
|
|
11134
|
+
const v = plugin.external("valibot.v");
|
|
11135
|
+
return runResponseResolver$3({
|
|
11136
|
+
$,
|
|
11137
|
+
operation,
|
|
11138
|
+
pipes: {
|
|
11139
|
+
...pipes,
|
|
11140
|
+
current: []
|
|
11141
|
+
},
|
|
11142
|
+
plugin,
|
|
11143
|
+
symbols: {
|
|
11144
|
+
schema: symbol,
|
|
11145
|
+
v
|
|
11146
|
+
}
|
|
11147
|
+
});
|
|
11148
|
+
}
|
|
11149
|
+
|
|
11150
|
+
//#endregion
|
|
11151
|
+
//#region src/plugins/valibot/api.ts
|
|
11152
|
+
var Api$1 = class {
|
|
11153
|
+
createRequestSchema(ctx) {
|
|
11154
|
+
const { plugin } = ctx;
|
|
11155
|
+
if (!plugin.config.requests.enabled) return;
|
|
11156
|
+
return createRequestSchemaV1(ctx);
|
|
11157
|
+
}
|
|
11158
|
+
createRequestValidator(args) {
|
|
11159
|
+
const { plugin } = args;
|
|
11160
|
+
if (!plugin.config.requests.enabled) return;
|
|
11161
|
+
return createRequestValidatorV1(args);
|
|
11162
|
+
}
|
|
11163
|
+
createResponseValidator(args) {
|
|
11164
|
+
return createResponseValidatorV1(args);
|
|
11165
|
+
}
|
|
11166
|
+
};
|
|
11167
|
+
|
|
11168
|
+
//#endregion
|
|
11169
|
+
//#region src/plugins/valibot/shared/operation.ts
|
|
11170
|
+
function irOperationToAst$1({ operation, path, plugin, processor, tags }) {
|
|
11171
|
+
if (plugin.config.requests.enabled) {
|
|
11172
|
+
const { schema } = buildOperationSchema$1(operation);
|
|
11173
|
+
if (schema.properties?.body && schema.properties.body.type !== "never") processor.process({
|
|
11174
|
+
meta: {
|
|
11175
|
+
resource: "operation",
|
|
11176
|
+
resourceId: operation.id,
|
|
11177
|
+
role: "request-body"
|
|
11178
|
+
},
|
|
11179
|
+
naming: plugin.config.requests.body,
|
|
11180
|
+
namingAnchor: operation.id,
|
|
11181
|
+
path: [...path, "body"],
|
|
11182
|
+
plugin,
|
|
11183
|
+
schema: schema.properties.body,
|
|
11184
|
+
tags
|
|
11185
|
+
});
|
|
11186
|
+
if (schema.properties?.headers && schema.properties.headers.type === "object") processor.process({
|
|
11187
|
+
meta: {
|
|
11188
|
+
resource: "operation",
|
|
11189
|
+
resourceId: operation.id,
|
|
11190
|
+
role: "request-headers"
|
|
11191
|
+
},
|
|
11192
|
+
naming: plugin.config.requests.headers,
|
|
11193
|
+
namingAnchor: operation.id,
|
|
11194
|
+
path: [...path, "headers"],
|
|
11195
|
+
plugin,
|
|
11196
|
+
schema: schema.properties.headers,
|
|
11197
|
+
tags
|
|
11198
|
+
});
|
|
11199
|
+
if (schema.properties?.path && schema.properties.path.type === "object") processor.process({
|
|
11200
|
+
meta: {
|
|
11201
|
+
resource: "operation",
|
|
11202
|
+
resourceId: operation.id,
|
|
11203
|
+
role: "request-path"
|
|
11204
|
+
},
|
|
11205
|
+
naming: plugin.config.requests.path,
|
|
11206
|
+
namingAnchor: operation.id,
|
|
11207
|
+
path: [...path, "path"],
|
|
11208
|
+
plugin,
|
|
11209
|
+
schema: schema.properties.path,
|
|
11210
|
+
tags
|
|
11211
|
+
});
|
|
11212
|
+
if (schema.properties?.query && schema.properties.query.type === "object") processor.process({
|
|
11213
|
+
meta: {
|
|
11214
|
+
resource: "operation",
|
|
11215
|
+
resourceId: operation.id,
|
|
11216
|
+
role: "request-query"
|
|
11217
|
+
},
|
|
11218
|
+
naming: plugin.config.requests.query,
|
|
11219
|
+
namingAnchor: operation.id,
|
|
11220
|
+
path: [...path, "query"],
|
|
11221
|
+
plugin,
|
|
11222
|
+
schema: schema.properties.query,
|
|
11223
|
+
tags
|
|
11224
|
+
});
|
|
11225
|
+
}
|
|
11226
|
+
if (plugin.config.responses.enabled) {
|
|
11227
|
+
if (operation.responses) {
|
|
11228
|
+
const { response } = operationResponsesMap(operation);
|
|
11229
|
+
if (response) processor.process({
|
|
11230
|
+
meta: {
|
|
11231
|
+
resource: "operation",
|
|
11232
|
+
resourceId: operation.id,
|
|
11233
|
+
role: "responses"
|
|
11234
|
+
},
|
|
11235
|
+
naming: plugin.config.responses,
|
|
11236
|
+
namingAnchor: operation.id,
|
|
11237
|
+
path: [...path, "responses"],
|
|
11238
|
+
plugin,
|
|
11239
|
+
schema: response,
|
|
11240
|
+
tags
|
|
11241
|
+
});
|
|
11242
|
+
}
|
|
11243
|
+
}
|
|
11244
|
+
}
|
|
11245
|
+
|
|
11246
|
+
//#endregion
|
|
11247
|
+
//#region src/plugins/valibot/shared/webhook.ts
|
|
11248
|
+
function irWebhookToAst$1({ operation, path, plugin, processor, tags }) {
|
|
11249
|
+
if (plugin.config.webhooks.enabled) {
|
|
11250
|
+
const { schema } = buildOperationSchema$1(operation);
|
|
11251
|
+
processor.process({
|
|
11252
|
+
meta: {
|
|
10974
11253
|
resource: "webhook",
|
|
10975
11254
|
resourceId: operation.id,
|
|
10976
11255
|
role: "data"
|
|
@@ -10985,28 +11264,6 @@ function irWebhookToAst$1({ operation, path, plugin, processor, tags }) {
|
|
|
10985
11264
|
}
|
|
10986
11265
|
}
|
|
10987
11266
|
|
|
10988
|
-
//#endregion
|
|
10989
|
-
//#region src/plugins/valibot/shared/export.ts
|
|
10990
|
-
function exportAst$1({ final, meta, naming, namingAnchor, path, plugin, schema, tags }) {
|
|
10991
|
-
const v = plugin.external("valibot.v");
|
|
10992
|
-
const name = pathToName(path, { anchor: namingAnchor });
|
|
10993
|
-
const symbol = plugin.registerSymbol(buildSymbolIn({
|
|
10994
|
-
meta: {
|
|
10995
|
-
category: "schema",
|
|
10996
|
-
path,
|
|
10997
|
-
tags,
|
|
10998
|
-
tool: "valibot",
|
|
10999
|
-
...meta
|
|
11000
|
-
},
|
|
11001
|
-
name,
|
|
11002
|
-
naming,
|
|
11003
|
-
plugin,
|
|
11004
|
-
schema
|
|
11005
|
-
}));
|
|
11006
|
-
const statement = $.const(symbol).export().$if(plugin.config.comments && createSchemaComment(schema), (c, v) => c.doc(v)).$if(final.typeName, (c) => c.type($.type(v).attr(final.typeName))).assign(pipesToNode(final.pipes, plugin));
|
|
11007
|
-
plugin.node(statement);
|
|
11008
|
-
}
|
|
11009
|
-
|
|
11010
11267
|
//#endregion
|
|
11011
11268
|
//#region src/plugins/shared/utils/coerce.ts
|
|
11012
11269
|
const shouldCoerceToBigInt = (format) => format === "int64" || format === "uint64";
|
|
@@ -11826,7 +12083,7 @@ function voidToPipes({ plugin, schema }) {
|
|
|
11826
12083
|
function getDefaultValue(meta) {
|
|
11827
12084
|
return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
|
|
11828
12085
|
}
|
|
11829
|
-
function createVisitor$3(config) {
|
|
12086
|
+
function createVisitor$3(config = {}) {
|
|
11830
12087
|
const { schemaExtractor } = config;
|
|
11831
12088
|
return {
|
|
11832
12089
|
applyModifiers(result, ctx, options = {}) {
|
|
@@ -11911,6 +12168,10 @@ function createVisitor$3(config) {
|
|
|
11911
12168
|
});
|
|
11912
12169
|
if (extracted !== schema) return walk(extracted, ctx);
|
|
11913
12170
|
}
|
|
12171
|
+
if (schema.symbolRef) return {
|
|
12172
|
+
meta: defaultMeta$1(schema),
|
|
12173
|
+
pipes: [$(schema.symbolRef)]
|
|
12174
|
+
};
|
|
11914
12175
|
},
|
|
11915
12176
|
intersection(items, schemas, parentSchema, ctx) {
|
|
11916
12177
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
@@ -12106,7 +12367,7 @@ function createProcessor$3(plugin) {
|
|
|
12106
12367
|
const extractorHooks = [plugin.config["~hooks"]?.schemas?.shouldExtract, plugin.context.config.parser.hooks.schemas?.shouldExtract];
|
|
12107
12368
|
function extractor(ctx) {
|
|
12108
12369
|
if (processor.hasEmitted(ctx.path)) return ctx.schema;
|
|
12109
|
-
for (const hook of extractorHooks) if (hook?.(ctx)) {
|
|
12370
|
+
for (const hook of extractorHooks) if (typeof hook === "boolean" ? hook : hook?.(ctx) ?? false) {
|
|
12110
12371
|
process({
|
|
12111
12372
|
namingAnchor: processor.context.anchor,
|
|
12112
12373
|
tags: processor.context.tags,
|
|
@@ -12245,11 +12506,58 @@ const defaultConfig$1 = {
|
|
|
12245
12506
|
});
|
|
12246
12507
|
plugin.config.requests = context.valueToObject({
|
|
12247
12508
|
defaultValue: {
|
|
12509
|
+
body: {
|
|
12510
|
+
case: plugin.config.case ?? "camelCase",
|
|
12511
|
+
enabled: true,
|
|
12512
|
+
name: "v{{name}}Body"
|
|
12513
|
+
},
|
|
12248
12514
|
case: plugin.config.case ?? "camelCase",
|
|
12249
12515
|
enabled: true,
|
|
12250
|
-
|
|
12516
|
+
headers: {
|
|
12517
|
+
case: plugin.config.case ?? "camelCase",
|
|
12518
|
+
enabled: true,
|
|
12519
|
+
name: "v{{name}}Headers"
|
|
12520
|
+
},
|
|
12521
|
+
name: "v{{name}}Data",
|
|
12522
|
+
path: {
|
|
12523
|
+
case: plugin.config.case ?? "camelCase",
|
|
12524
|
+
enabled: true,
|
|
12525
|
+
name: "v{{name}}Path"
|
|
12526
|
+
},
|
|
12527
|
+
query: {
|
|
12528
|
+
case: plugin.config.case ?? "camelCase",
|
|
12529
|
+
enabled: true,
|
|
12530
|
+
name: "v{{name}}Query"
|
|
12531
|
+
},
|
|
12532
|
+
shouldExtract: () => false
|
|
12533
|
+
},
|
|
12534
|
+
mappers: {
|
|
12535
|
+
...mappers,
|
|
12536
|
+
object: (fields, defaultValue) => ({
|
|
12537
|
+
...fields,
|
|
12538
|
+
body: context.valueToObject({
|
|
12539
|
+
defaultValue: defaultValue.body,
|
|
12540
|
+
mappers,
|
|
12541
|
+
value: fields.body
|
|
12542
|
+
}),
|
|
12543
|
+
headers: context.valueToObject({
|
|
12544
|
+
defaultValue: defaultValue.headers,
|
|
12545
|
+
mappers,
|
|
12546
|
+
value: fields.headers
|
|
12547
|
+
}),
|
|
12548
|
+
path: context.valueToObject({
|
|
12549
|
+
defaultValue: defaultValue.path,
|
|
12550
|
+
mappers,
|
|
12551
|
+
value: fields.path
|
|
12552
|
+
}),
|
|
12553
|
+
query: context.valueToObject({
|
|
12554
|
+
defaultValue: defaultValue.query,
|
|
12555
|
+
mappers,
|
|
12556
|
+
value: fields.query
|
|
12557
|
+
}),
|
|
12558
|
+
shouldExtract: fields.shouldExtract !== void 0 ? typeof fields.shouldExtract === "function" ? fields.shouldExtract : () => Boolean(fields.shouldExtract) : defaultValue.shouldExtract
|
|
12559
|
+
})
|
|
12251
12560
|
},
|
|
12252
|
-
mappers,
|
|
12253
12561
|
value: plugin.config.requests
|
|
12254
12562
|
});
|
|
12255
12563
|
plugin.config.responses = context.valueToObject({
|
|
@@ -12343,42 +12651,248 @@ const identifiers = {
|
|
|
12343
12651
|
void: "void"
|
|
12344
12652
|
};
|
|
12345
12653
|
|
|
12654
|
+
//#endregion
|
|
12655
|
+
//#region src/plugins/zod/shared/export.ts
|
|
12656
|
+
function exportAst({ final, meta, naming, namingAnchor, path, plugin, schema, tags }) {
|
|
12657
|
+
const z = plugin.external("zod.z");
|
|
12658
|
+
const name = pathToName(path, { anchor: namingAnchor });
|
|
12659
|
+
const symbol = plugin.registerSymbol(buildSymbolIn({
|
|
12660
|
+
meta: {
|
|
12661
|
+
category: "schema",
|
|
12662
|
+
path,
|
|
12663
|
+
tags,
|
|
12664
|
+
tool: "zod",
|
|
12665
|
+
...meta
|
|
12666
|
+
},
|
|
12667
|
+
name,
|
|
12668
|
+
naming,
|
|
12669
|
+
plugin,
|
|
12670
|
+
schema
|
|
12671
|
+
}));
|
|
12672
|
+
const typeInferSymbol = naming.types.infer.enabled ? plugin.registerSymbol(buildSymbolIn({
|
|
12673
|
+
meta: {
|
|
12674
|
+
category: "type",
|
|
12675
|
+
path,
|
|
12676
|
+
tags,
|
|
12677
|
+
tool: "zod",
|
|
12678
|
+
variant: "infer",
|
|
12679
|
+
...meta
|
|
12680
|
+
},
|
|
12681
|
+
name,
|
|
12682
|
+
naming: naming.types.infer,
|
|
12683
|
+
plugin,
|
|
12684
|
+
schema
|
|
12685
|
+
})) : void 0;
|
|
12686
|
+
const statement = $.const(symbol).export().$if(plugin.config.comments && createSchemaComment(schema), (c, v) => c.doc(v)).$if(final.typeName, (c) => c.type($.type(z).attr(final.typeName))).assign(final.expression);
|
|
12687
|
+
plugin.node(statement);
|
|
12688
|
+
if (typeInferSymbol) {
|
|
12689
|
+
const inferType = $.type.alias(typeInferSymbol).export().type($.type(z).attr(identifiers.infer).generic($(symbol).typeofType()));
|
|
12690
|
+
plugin.node(inferType);
|
|
12691
|
+
}
|
|
12692
|
+
return symbol;
|
|
12693
|
+
}
|
|
12694
|
+
|
|
12695
|
+
//#endregion
|
|
12696
|
+
//#region src/plugins/zod/shared/operation-schema.ts
|
|
12697
|
+
function buildOperationSchema(operation) {
|
|
12698
|
+
const requiredProperties = /* @__PURE__ */ new Set();
|
|
12699
|
+
const schema = {
|
|
12700
|
+
properties: {
|
|
12701
|
+
body: { type: "never" },
|
|
12702
|
+
path: { type: "never" },
|
|
12703
|
+
query: { type: "never" }
|
|
12704
|
+
},
|
|
12705
|
+
type: "object"
|
|
12706
|
+
};
|
|
12707
|
+
if (operation.parameters) for (const location of [
|
|
12708
|
+
"header",
|
|
12709
|
+
"path",
|
|
12710
|
+
"query"
|
|
12711
|
+
]) {
|
|
12712
|
+
const params = operation.parameters[location];
|
|
12713
|
+
if (!params) continue;
|
|
12714
|
+
const properties = {};
|
|
12715
|
+
const required = [];
|
|
12716
|
+
const propKey = location === "header" ? "headers" : location;
|
|
12717
|
+
for (const key in params) {
|
|
12718
|
+
const parameter = params[key];
|
|
12719
|
+
properties[parameter.name] = parameter.schema;
|
|
12720
|
+
if (parameter.required) {
|
|
12721
|
+
required.push(parameter.name);
|
|
12722
|
+
requiredProperties.add(propKey);
|
|
12723
|
+
}
|
|
12724
|
+
}
|
|
12725
|
+
if (Object.keys(properties).length) schema.properties[propKey] = {
|
|
12726
|
+
properties,
|
|
12727
|
+
required,
|
|
12728
|
+
type: "object"
|
|
12729
|
+
};
|
|
12730
|
+
}
|
|
12731
|
+
if (operation.body) {
|
|
12732
|
+
schema.properties.body = operation.body.schema;
|
|
12733
|
+
if (operation.body.required) requiredProperties.add("body");
|
|
12734
|
+
}
|
|
12735
|
+
schema.required = [...requiredProperties];
|
|
12736
|
+
return {
|
|
12737
|
+
required: schema.required,
|
|
12738
|
+
schema
|
|
12739
|
+
};
|
|
12740
|
+
}
|
|
12741
|
+
|
|
12742
|
+
//#endregion
|
|
12743
|
+
//#region src/plugins/zod/shared/validator.ts
|
|
12744
|
+
function getDefaultRequestValidatorLayers(operation) {
|
|
12745
|
+
const { schema } = buildOperationSchema(operation);
|
|
12746
|
+
return {
|
|
12747
|
+
body: {
|
|
12748
|
+
as: "body",
|
|
12749
|
+
optional: !schema.required?.includes("body"),
|
|
12750
|
+
whenEmpty: "strict"
|
|
12751
|
+
},
|
|
12752
|
+
headers: {
|
|
12753
|
+
as: "headers",
|
|
12754
|
+
optional: !schema.required?.includes("headers"),
|
|
12755
|
+
whenEmpty: "omit"
|
|
12756
|
+
},
|
|
12757
|
+
path: {
|
|
12758
|
+
as: "path",
|
|
12759
|
+
optional: !schema.required?.includes("path"),
|
|
12760
|
+
whenEmpty: "strict"
|
|
12761
|
+
},
|
|
12762
|
+
query: {
|
|
12763
|
+
as: "query",
|
|
12764
|
+
optional: !schema.required?.includes("query"),
|
|
12765
|
+
whenEmpty: "strict"
|
|
12766
|
+
}
|
|
12767
|
+
};
|
|
12768
|
+
}
|
|
12769
|
+
|
|
12346
12770
|
//#endregion
|
|
12347
12771
|
//#region src/plugins/zod/mini/api.ts
|
|
12348
|
-
|
|
12772
|
+
function emptyNode$2(ctx) {
|
|
12773
|
+
const { z } = ctx.symbols;
|
|
12774
|
+
if (ctx.layer.whenEmpty === "omit") throw new Error(`Cannot create empty schema for layer "${ctx.layer.as}" with whenEmpty: 'omit'`);
|
|
12775
|
+
if (ctx.layer.whenEmpty === "strict") return $(z).attr(identifiers.never).call();
|
|
12776
|
+
return $(z).attr(identifiers.object).call($.object());
|
|
12777
|
+
}
|
|
12778
|
+
function optionalNode$2(ctx) {
|
|
12779
|
+
if (!ctx.layer.optional) return ctx.schema;
|
|
12780
|
+
const { z } = ctx.symbols;
|
|
12781
|
+
return $(z).attr(identifiers.optional).call(ctx.schema);
|
|
12782
|
+
}
|
|
12783
|
+
function compositeNode$2(ctx) {
|
|
12784
|
+
const { z } = ctx.symbols;
|
|
12785
|
+
const obj = $.object();
|
|
12786
|
+
const defaultValues = getDefaultRequestValidatorLayers(ctx.operation);
|
|
12787
|
+
for (const key of requestValidatorLayers) {
|
|
12788
|
+
const layer = resolveValidatorLayer(ctx.layers, key, defaultValues);
|
|
12789
|
+
const layerSchema = ctx.plugin.querySymbol({
|
|
12790
|
+
category: "schema",
|
|
12791
|
+
resource: "operation",
|
|
12792
|
+
resourceId: ctx.operation.id,
|
|
12793
|
+
role: `request-${key}`,
|
|
12794
|
+
tool: "zod"
|
|
12795
|
+
});
|
|
12796
|
+
if (layerSchema) {
|
|
12797
|
+
obj.prop(layer.as, ctx.nodes.optional({
|
|
12798
|
+
...ctx,
|
|
12799
|
+
layer,
|
|
12800
|
+
schema: $(layerSchema)
|
|
12801
|
+
}));
|
|
12802
|
+
continue;
|
|
12803
|
+
}
|
|
12804
|
+
if (layer.whenEmpty === "omit") continue;
|
|
12805
|
+
const empty = ctx.nodes.empty({
|
|
12806
|
+
...ctx,
|
|
12807
|
+
layer
|
|
12808
|
+
});
|
|
12809
|
+
obj.prop(layer.as, ctx.nodes.optional({
|
|
12810
|
+
...ctx,
|
|
12811
|
+
layer,
|
|
12812
|
+
schema: empty
|
|
12813
|
+
}));
|
|
12814
|
+
}
|
|
12815
|
+
if (obj.isEmpty) return;
|
|
12816
|
+
return $(z).attr(identifiers.object).call(obj);
|
|
12817
|
+
}
|
|
12818
|
+
function requestValidatorResolver$2(ctx) {
|
|
12349
12819
|
const { schema } = ctx.symbols;
|
|
12350
12820
|
return $(schema).attr(identifiers.parseAsync).call("data").await().return();
|
|
12351
|
-
}
|
|
12352
|
-
|
|
12353
|
-
const
|
|
12354
|
-
|
|
12355
|
-
|
|
12356
|
-
|
|
12357
|
-
|
|
12358
|
-
|
|
12359
|
-
|
|
12360
|
-
|
|
12821
|
+
}
|
|
12822
|
+
function responseValidatorResolver$2(ctx) {
|
|
12823
|
+
const { schema } = ctx.symbols;
|
|
12824
|
+
return $(schema).attr(identifiers.parseAsync).call("data").await().return();
|
|
12825
|
+
}
|
|
12826
|
+
function runRequestResolver$2(ctx) {
|
|
12827
|
+
const validator = ctx.plugin.config["~resolvers"]?.validator;
|
|
12828
|
+
const candidates = [typeof validator === "function" ? validator : validator?.request, requestValidatorResolver$2];
|
|
12829
|
+
for (const candidate of candidates) {
|
|
12830
|
+
const statements = candidate?.(ctx);
|
|
12831
|
+
if (statements === null) return;
|
|
12832
|
+
if (statements !== void 0) return $.func().async().param("data").do(...statements instanceof Array ? statements : [statements]);
|
|
12833
|
+
}
|
|
12834
|
+
}
|
|
12835
|
+
function runResponseResolver$2(ctx) {
|
|
12836
|
+
const validator = ctx.plugin.config["~resolvers"]?.validator;
|
|
12837
|
+
const candidates = [typeof validator === "function" ? validator : validator?.response, responseValidatorResolver$2];
|
|
12838
|
+
for (const candidate of candidates) {
|
|
12839
|
+
const statements = candidate?.(ctx);
|
|
12840
|
+
if (statements === null) return;
|
|
12841
|
+
if (statements !== void 0) return $.func().async().param("data").do(...statements instanceof Array ? statements : [statements]);
|
|
12842
|
+
}
|
|
12843
|
+
}
|
|
12844
|
+
function createRequestSchemaContext$2(ctx) {
|
|
12845
|
+
const { plugin } = ctx;
|
|
12361
12846
|
const z = plugin.external("zod.z");
|
|
12362
|
-
|
|
12847
|
+
return {
|
|
12848
|
+
...ctx,
|
|
12363
12849
|
$,
|
|
12364
12850
|
chain: { current: $(z) },
|
|
12365
|
-
|
|
12366
|
-
|
|
12851
|
+
nodes: {
|
|
12852
|
+
composite: compositeNode$2,
|
|
12853
|
+
empty: emptyNode$2,
|
|
12854
|
+
optional: optionalNode$2
|
|
12855
|
+
},
|
|
12367
12856
|
symbols: {
|
|
12368
|
-
schema:
|
|
12857
|
+
schema: $(""),
|
|
12369
12858
|
z
|
|
12370
12859
|
}
|
|
12371
12860
|
};
|
|
12372
|
-
|
|
12373
|
-
|
|
12374
|
-
|
|
12375
|
-
|
|
12376
|
-
|
|
12377
|
-
|
|
12378
|
-
}
|
|
12379
|
-
|
|
12380
|
-
|
|
12381
|
-
|
|
12861
|
+
}
|
|
12862
|
+
function createRequestSchemaMini(ctx) {
|
|
12863
|
+
const { operation, plugin } = ctx;
|
|
12864
|
+
const baseCtx = createRequestSchemaContext$2(ctx);
|
|
12865
|
+
const schema = baseCtx.nodes.composite(baseCtx);
|
|
12866
|
+
if (!schema) return;
|
|
12867
|
+
if (!plugin.config.requests.shouldExtract({ operation })) return schema;
|
|
12868
|
+
return exportAst({
|
|
12869
|
+
final: { expression: schema },
|
|
12870
|
+
meta: {
|
|
12871
|
+
resource: "operation",
|
|
12872
|
+
resourceId: operation.id,
|
|
12873
|
+
role: "data"
|
|
12874
|
+
},
|
|
12875
|
+
naming: plugin.config.requests,
|
|
12876
|
+
namingAnchor: operation.id,
|
|
12877
|
+
path: [],
|
|
12878
|
+
plugin,
|
|
12879
|
+
schema: {}
|
|
12880
|
+
});
|
|
12881
|
+
}
|
|
12882
|
+
function createRequestValidatorMini(ctx) {
|
|
12883
|
+
const symbolOrSchema = createRequestSchemaMini(ctx);
|
|
12884
|
+
if (!symbolOrSchema) return;
|
|
12885
|
+
const baseCtx = createRequestSchemaContext$2(ctx);
|
|
12886
|
+
return runRequestResolver$2({
|
|
12887
|
+
...baseCtx,
|
|
12888
|
+
symbols: {
|
|
12889
|
+
...baseCtx.symbols,
|
|
12890
|
+
schema: symbolOrSchema
|
|
12891
|
+
}
|
|
12892
|
+
});
|
|
12893
|
+
}
|
|
12894
|
+
function createResponseValidatorMini({ operation, plugin }) {
|
|
12895
|
+
const symbol = plugin.querySymbol({
|
|
12382
12896
|
category: "schema",
|
|
12383
12897
|
resource: "operation",
|
|
12384
12898
|
resourceId: operation.id,
|
|
@@ -12387,7 +12901,7 @@ const createResponseValidatorMini = ({ operation, plugin }) => {
|
|
|
12387
12901
|
});
|
|
12388
12902
|
if (!symbol) return;
|
|
12389
12903
|
const z = plugin.external("zod.z");
|
|
12390
|
-
|
|
12904
|
+
return runResponseResolver$2({
|
|
12391
12905
|
$,
|
|
12392
12906
|
chain: { current: $(z) },
|
|
12393
12907
|
operation,
|
|
@@ -12396,52 +12910,134 @@ const createResponseValidatorMini = ({ operation, plugin }) => {
|
|
|
12396
12910
|
schema: symbol,
|
|
12397
12911
|
z
|
|
12398
12912
|
}
|
|
12399
|
-
};
|
|
12400
|
-
|
|
12401
|
-
const candidates = [typeof validator === "function" ? validator : validator?.response, validatorResolver$2];
|
|
12402
|
-
for (const candidate of candidates) {
|
|
12403
|
-
const statements = candidate?.(ctx);
|
|
12404
|
-
if (statements === null) return;
|
|
12405
|
-
if (statements !== void 0) return $.func().async().param("data").do(...statements instanceof Array ? statements : [statements]);
|
|
12406
|
-
}
|
|
12407
|
-
};
|
|
12913
|
+
});
|
|
12914
|
+
}
|
|
12408
12915
|
|
|
12409
12916
|
//#endregion
|
|
12410
12917
|
//#region src/plugins/zod/v3/api.ts
|
|
12411
|
-
|
|
12918
|
+
function emptyNode$1(ctx) {
|
|
12919
|
+
const { z } = ctx.symbols;
|
|
12920
|
+
if (ctx.layer.whenEmpty === "omit") throw new Error(`Cannot create empty schema for layer "${ctx.layer.as}" with whenEmpty: 'omit'`);
|
|
12921
|
+
if (ctx.layer.whenEmpty === "strict") return $(z).attr(identifiers.never).call();
|
|
12922
|
+
return $(z).attr(identifiers.object).call($.object());
|
|
12923
|
+
}
|
|
12924
|
+
function optionalNode$1(ctx) {
|
|
12925
|
+
if (!ctx.layer.optional) return ctx.schema;
|
|
12926
|
+
return $(ctx.schema).attr(identifiers.optional).call();
|
|
12927
|
+
}
|
|
12928
|
+
function compositeNode$1(ctx) {
|
|
12929
|
+
const { z } = ctx.symbols;
|
|
12930
|
+
const obj = $.object();
|
|
12931
|
+
const defaultValues = getDefaultRequestValidatorLayers(ctx.operation);
|
|
12932
|
+
for (const key of requestValidatorLayers) {
|
|
12933
|
+
const layer = resolveValidatorLayer(ctx.layers, key, defaultValues);
|
|
12934
|
+
const layerSchema = ctx.plugin.querySymbol({
|
|
12935
|
+
category: "schema",
|
|
12936
|
+
resource: "operation",
|
|
12937
|
+
resourceId: ctx.operation.id,
|
|
12938
|
+
role: `request-${key}`,
|
|
12939
|
+
tool: "zod"
|
|
12940
|
+
});
|
|
12941
|
+
if (layerSchema) {
|
|
12942
|
+
obj.prop(layer.as, ctx.nodes.optional({
|
|
12943
|
+
...ctx,
|
|
12944
|
+
layer,
|
|
12945
|
+
schema: $(layerSchema)
|
|
12946
|
+
}));
|
|
12947
|
+
continue;
|
|
12948
|
+
}
|
|
12949
|
+
if (layer.whenEmpty === "omit") continue;
|
|
12950
|
+
const empty = ctx.nodes.empty({
|
|
12951
|
+
...ctx,
|
|
12952
|
+
layer
|
|
12953
|
+
});
|
|
12954
|
+
obj.prop(layer.as, ctx.nodes.optional({
|
|
12955
|
+
...ctx,
|
|
12956
|
+
layer,
|
|
12957
|
+
schema: empty
|
|
12958
|
+
}));
|
|
12959
|
+
}
|
|
12960
|
+
if (obj.isEmpty) return;
|
|
12961
|
+
return $(z).attr(identifiers.object).call(obj);
|
|
12962
|
+
}
|
|
12963
|
+
function requestValidatorResolver$1(ctx) {
|
|
12412
12964
|
const { schema } = ctx.symbols;
|
|
12413
12965
|
return $(schema).attr(identifiers.parseAsync).call("data").await().return();
|
|
12414
|
-
}
|
|
12415
|
-
|
|
12416
|
-
const
|
|
12417
|
-
|
|
12418
|
-
|
|
12419
|
-
|
|
12420
|
-
|
|
12421
|
-
|
|
12422
|
-
|
|
12423
|
-
|
|
12966
|
+
}
|
|
12967
|
+
function responseValidatorResolver$1(ctx) {
|
|
12968
|
+
const { schema } = ctx.symbols;
|
|
12969
|
+
return $(schema).attr(identifiers.parseAsync).call("data").await().return();
|
|
12970
|
+
}
|
|
12971
|
+
function runRequestResolver$1(ctx) {
|
|
12972
|
+
const validator = ctx.plugin.config["~resolvers"]?.validator;
|
|
12973
|
+
const candidates = [typeof validator === "function" ? validator : validator?.request, requestValidatorResolver$1];
|
|
12974
|
+
for (const candidate of candidates) {
|
|
12975
|
+
const statements = candidate?.(ctx);
|
|
12976
|
+
if (statements === null) return;
|
|
12977
|
+
if (statements !== void 0) return $.func().async().param("data").do(...statements instanceof Array ? statements : [statements]);
|
|
12978
|
+
}
|
|
12979
|
+
}
|
|
12980
|
+
function runResponseResolver$1(ctx) {
|
|
12981
|
+
const validator = ctx.plugin.config["~resolvers"]?.validator;
|
|
12982
|
+
const candidates = [typeof validator === "function" ? validator : validator?.response, responseValidatorResolver$1];
|
|
12983
|
+
for (const candidate of candidates) {
|
|
12984
|
+
const statements = candidate?.(ctx);
|
|
12985
|
+
if (statements === null) return;
|
|
12986
|
+
if (statements !== void 0) return $.func().async().param("data").do(...statements instanceof Array ? statements : [statements]);
|
|
12987
|
+
}
|
|
12988
|
+
}
|
|
12989
|
+
function createRequestSchemaContext$1(ctx) {
|
|
12990
|
+
const { plugin } = ctx;
|
|
12424
12991
|
const z = plugin.external("zod.z");
|
|
12425
|
-
|
|
12992
|
+
return {
|
|
12993
|
+
...ctx,
|
|
12426
12994
|
$,
|
|
12427
12995
|
chain: { current: $(z) },
|
|
12428
|
-
|
|
12429
|
-
|
|
12996
|
+
nodes: {
|
|
12997
|
+
composite: compositeNode$1,
|
|
12998
|
+
empty: emptyNode$1,
|
|
12999
|
+
optional: optionalNode$1
|
|
13000
|
+
},
|
|
12430
13001
|
symbols: {
|
|
12431
|
-
schema:
|
|
13002
|
+
schema: $(""),
|
|
12432
13003
|
z
|
|
12433
13004
|
}
|
|
12434
13005
|
};
|
|
12435
|
-
|
|
12436
|
-
|
|
12437
|
-
|
|
12438
|
-
|
|
12439
|
-
|
|
12440
|
-
|
|
12441
|
-
}
|
|
12442
|
-
|
|
12443
|
-
|
|
12444
|
-
|
|
13006
|
+
}
|
|
13007
|
+
function createRequestSchemaV3(ctx) {
|
|
13008
|
+
const { operation, plugin } = ctx;
|
|
13009
|
+
const baseCtx = createRequestSchemaContext$1(ctx);
|
|
13010
|
+
const schema = baseCtx.nodes.composite(baseCtx);
|
|
13011
|
+
if (!schema) return;
|
|
13012
|
+
if (!plugin.config.requests.shouldExtract({ operation })) return schema;
|
|
13013
|
+
return exportAst({
|
|
13014
|
+
final: { expression: schema },
|
|
13015
|
+
meta: {
|
|
13016
|
+
resource: "operation",
|
|
13017
|
+
resourceId: operation.id,
|
|
13018
|
+
role: "data"
|
|
13019
|
+
},
|
|
13020
|
+
naming: plugin.config.requests,
|
|
13021
|
+
namingAnchor: operation.id,
|
|
13022
|
+
path: [],
|
|
13023
|
+
plugin,
|
|
13024
|
+
schema: {}
|
|
13025
|
+
});
|
|
13026
|
+
}
|
|
13027
|
+
function createRequestValidatorV3(ctx) {
|
|
13028
|
+
const symbolOrSchema = createRequestSchemaV3(ctx);
|
|
13029
|
+
if (!symbolOrSchema) return;
|
|
13030
|
+
const baseCtx = createRequestSchemaContext$1(ctx);
|
|
13031
|
+
return runRequestResolver$1({
|
|
13032
|
+
...baseCtx,
|
|
13033
|
+
symbols: {
|
|
13034
|
+
...baseCtx.symbols,
|
|
13035
|
+
schema: symbolOrSchema
|
|
13036
|
+
}
|
|
13037
|
+
});
|
|
13038
|
+
}
|
|
13039
|
+
function createResponseValidatorV3({ operation, plugin }) {
|
|
13040
|
+
const symbol = plugin.querySymbol({
|
|
12445
13041
|
category: "schema",
|
|
12446
13042
|
resource: "operation",
|
|
12447
13043
|
resourceId: operation.id,
|
|
@@ -12450,7 +13046,7 @@ const createResponseValidatorV3 = ({ operation, plugin }) => {
|
|
|
12450
13046
|
});
|
|
12451
13047
|
if (!symbol) return;
|
|
12452
13048
|
const z = plugin.external("zod.z");
|
|
12453
|
-
|
|
13049
|
+
return runResponseResolver$1({
|
|
12454
13050
|
$,
|
|
12455
13051
|
chain: { current: $(z) },
|
|
12456
13052
|
operation,
|
|
@@ -12459,52 +13055,134 @@ const createResponseValidatorV3 = ({ operation, plugin }) => {
|
|
|
12459
13055
|
schema: symbol,
|
|
12460
13056
|
z
|
|
12461
13057
|
}
|
|
12462
|
-
};
|
|
12463
|
-
|
|
12464
|
-
const candidates = [typeof validator === "function" ? validator : validator?.response, validatorResolver$1];
|
|
12465
|
-
for (const candidate of candidates) {
|
|
12466
|
-
const statements = candidate?.(ctx);
|
|
12467
|
-
if (statements === null) return;
|
|
12468
|
-
if (statements !== void 0) return $.func().async().param("data").do(...statements instanceof Array ? statements : [statements]);
|
|
12469
|
-
}
|
|
12470
|
-
};
|
|
13058
|
+
});
|
|
13059
|
+
}
|
|
12471
13060
|
|
|
12472
13061
|
//#endregion
|
|
12473
13062
|
//#region src/plugins/zod/v4/api.ts
|
|
12474
|
-
|
|
13063
|
+
function emptyNode(ctx) {
|
|
13064
|
+
const { z } = ctx.symbols;
|
|
13065
|
+
if (ctx.layer.whenEmpty === "omit") throw new Error(`Cannot create empty schema for layer "${ctx.layer.as}" with whenEmpty: 'omit'`);
|
|
13066
|
+
if (ctx.layer.whenEmpty === "strict") return $(z).attr(identifiers.never).call();
|
|
13067
|
+
return $(z).attr(identifiers.object).call($.object());
|
|
13068
|
+
}
|
|
13069
|
+
function optionalNode(ctx) {
|
|
13070
|
+
if (!ctx.layer.optional) return ctx.schema;
|
|
13071
|
+
return $(ctx.schema).attr(identifiers.optional).call();
|
|
13072
|
+
}
|
|
13073
|
+
function compositeNode(ctx) {
|
|
13074
|
+
const { z } = ctx.symbols;
|
|
13075
|
+
const obj = $.object();
|
|
13076
|
+
const defaultValues = getDefaultRequestValidatorLayers(ctx.operation);
|
|
13077
|
+
for (const key of requestValidatorLayers) {
|
|
13078
|
+
const layer = resolveValidatorLayer(ctx.layers, key, defaultValues);
|
|
13079
|
+
const layerSchema = ctx.plugin.querySymbol({
|
|
13080
|
+
category: "schema",
|
|
13081
|
+
resource: "operation",
|
|
13082
|
+
resourceId: ctx.operation.id,
|
|
13083
|
+
role: `request-${key}`,
|
|
13084
|
+
tool: "zod"
|
|
13085
|
+
});
|
|
13086
|
+
if (layerSchema) {
|
|
13087
|
+
obj.prop(layer.as, ctx.nodes.optional({
|
|
13088
|
+
...ctx,
|
|
13089
|
+
layer,
|
|
13090
|
+
schema: $(layerSchema)
|
|
13091
|
+
}));
|
|
13092
|
+
continue;
|
|
13093
|
+
}
|
|
13094
|
+
if (layer.whenEmpty === "omit") continue;
|
|
13095
|
+
const empty = ctx.nodes.empty({
|
|
13096
|
+
...ctx,
|
|
13097
|
+
layer
|
|
13098
|
+
});
|
|
13099
|
+
obj.prop(layer.as, ctx.nodes.optional({
|
|
13100
|
+
...ctx,
|
|
13101
|
+
layer,
|
|
13102
|
+
schema: empty
|
|
13103
|
+
}));
|
|
13104
|
+
}
|
|
13105
|
+
if (obj.isEmpty) return;
|
|
13106
|
+
return $(z).attr(identifiers.object).call(obj);
|
|
13107
|
+
}
|
|
13108
|
+
function requestValidatorResolver(ctx) {
|
|
12475
13109
|
const { schema } = ctx.symbols;
|
|
12476
13110
|
return $(schema).attr(identifiers.parseAsync).call("data").await().return();
|
|
12477
|
-
}
|
|
12478
|
-
|
|
12479
|
-
const
|
|
12480
|
-
|
|
12481
|
-
|
|
12482
|
-
|
|
12483
|
-
|
|
12484
|
-
|
|
12485
|
-
|
|
12486
|
-
|
|
13111
|
+
}
|
|
13112
|
+
function responseValidatorResolver(ctx) {
|
|
13113
|
+
const { schema } = ctx.symbols;
|
|
13114
|
+
return $(schema).attr(identifiers.parseAsync).call("data").await().return();
|
|
13115
|
+
}
|
|
13116
|
+
function runRequestResolver(ctx) {
|
|
13117
|
+
const validator = ctx.plugin.config["~resolvers"]?.validator;
|
|
13118
|
+
const candidates = [typeof validator === "function" ? validator : validator?.request, requestValidatorResolver];
|
|
13119
|
+
for (const candidate of candidates) {
|
|
13120
|
+
const statements = candidate?.(ctx);
|
|
13121
|
+
if (statements === null) return;
|
|
13122
|
+
if (statements !== void 0) return $.func().async().param("data").do(...statements instanceof Array ? statements : [statements]);
|
|
13123
|
+
}
|
|
13124
|
+
}
|
|
13125
|
+
function runResponseResolver(ctx) {
|
|
13126
|
+
const validator = ctx.plugin.config["~resolvers"]?.validator;
|
|
13127
|
+
const candidates = [typeof validator === "function" ? validator : validator?.response, responseValidatorResolver];
|
|
13128
|
+
for (const candidate of candidates) {
|
|
13129
|
+
const statements = candidate?.(ctx);
|
|
13130
|
+
if (statements === null) return;
|
|
13131
|
+
if (statements !== void 0) return $.func().async().param("data").do(...statements instanceof Array ? statements : [statements]);
|
|
13132
|
+
}
|
|
13133
|
+
}
|
|
13134
|
+
function createRequestSchemaContext(ctx) {
|
|
13135
|
+
const { plugin } = ctx;
|
|
12487
13136
|
const z = plugin.external("zod.z");
|
|
12488
|
-
|
|
13137
|
+
return {
|
|
13138
|
+
...ctx,
|
|
12489
13139
|
$,
|
|
12490
13140
|
chain: { current: $(z) },
|
|
12491
|
-
|
|
12492
|
-
|
|
13141
|
+
nodes: {
|
|
13142
|
+
composite: compositeNode,
|
|
13143
|
+
empty: emptyNode,
|
|
13144
|
+
optional: optionalNode
|
|
13145
|
+
},
|
|
12493
13146
|
symbols: {
|
|
12494
|
-
schema:
|
|
13147
|
+
schema: $(""),
|
|
12495
13148
|
z
|
|
12496
13149
|
}
|
|
12497
13150
|
};
|
|
12498
|
-
|
|
12499
|
-
|
|
12500
|
-
|
|
12501
|
-
|
|
12502
|
-
|
|
12503
|
-
|
|
12504
|
-
}
|
|
12505
|
-
|
|
12506
|
-
|
|
12507
|
-
|
|
13151
|
+
}
|
|
13152
|
+
function createRequestSchemaV4(ctx) {
|
|
13153
|
+
const { operation, plugin } = ctx;
|
|
13154
|
+
const baseCtx = createRequestSchemaContext(ctx);
|
|
13155
|
+
const schema = baseCtx.nodes.composite(baseCtx);
|
|
13156
|
+
if (!schema) return;
|
|
13157
|
+
if (!plugin.config.requests.shouldExtract({ operation })) return schema;
|
|
13158
|
+
return exportAst({
|
|
13159
|
+
final: { expression: schema },
|
|
13160
|
+
meta: {
|
|
13161
|
+
resource: "operation",
|
|
13162
|
+
resourceId: operation.id,
|
|
13163
|
+
role: "data"
|
|
13164
|
+
},
|
|
13165
|
+
naming: plugin.config.requests,
|
|
13166
|
+
namingAnchor: operation.id,
|
|
13167
|
+
path: [],
|
|
13168
|
+
plugin,
|
|
13169
|
+
schema: {}
|
|
13170
|
+
});
|
|
13171
|
+
}
|
|
13172
|
+
function createRequestValidatorV4(ctx) {
|
|
13173
|
+
const symbolOrSchema = createRequestSchemaV4(ctx);
|
|
13174
|
+
if (!symbolOrSchema) return;
|
|
13175
|
+
const baseCtx = createRequestSchemaContext(ctx);
|
|
13176
|
+
return runRequestResolver({
|
|
13177
|
+
...baseCtx,
|
|
13178
|
+
symbols: {
|
|
13179
|
+
...baseCtx.symbols,
|
|
13180
|
+
schema: symbolOrSchema
|
|
13181
|
+
}
|
|
13182
|
+
});
|
|
13183
|
+
}
|
|
13184
|
+
function createResponseValidatorV4({ operation, plugin }) {
|
|
13185
|
+
const symbol = plugin.querySymbol({
|
|
12508
13186
|
category: "schema",
|
|
12509
13187
|
resource: "operation",
|
|
12510
13188
|
resourceId: operation.id,
|
|
@@ -12513,7 +13191,7 @@ const createResponseValidatorV4 = ({ operation, plugin }) => {
|
|
|
12513
13191
|
});
|
|
12514
13192
|
if (!symbol) return;
|
|
12515
13193
|
const z = plugin.external("zod.z");
|
|
12516
|
-
|
|
13194
|
+
return runResponseResolver({
|
|
12517
13195
|
$,
|
|
12518
13196
|
chain: { current: $(z) },
|
|
12519
13197
|
operation,
|
|
@@ -12522,33 +13200,36 @@ const createResponseValidatorV4 = ({ operation, plugin }) => {
|
|
|
12522
13200
|
schema: symbol,
|
|
12523
13201
|
z
|
|
12524
13202
|
}
|
|
12525
|
-
};
|
|
12526
|
-
|
|
12527
|
-
const candidates = [typeof validator === "function" ? validator : validator?.response, validatorResolver];
|
|
12528
|
-
for (const candidate of candidates) {
|
|
12529
|
-
const statements = candidate?.(ctx);
|
|
12530
|
-
if (statements === null) return;
|
|
12531
|
-
if (statements !== void 0) return $.func().async().param("data").do(...statements instanceof Array ? statements : [statements]);
|
|
12532
|
-
}
|
|
12533
|
-
};
|
|
13203
|
+
});
|
|
13204
|
+
}
|
|
12534
13205
|
|
|
12535
13206
|
//#endregion
|
|
12536
13207
|
//#region src/plugins/zod/api.ts
|
|
12537
13208
|
var Api = class {
|
|
12538
|
-
|
|
12539
|
-
const { plugin } =
|
|
13209
|
+
createRequestSchema(ctx) {
|
|
13210
|
+
const { plugin } = ctx;
|
|
13211
|
+
if (!plugin.config.requests.enabled) return;
|
|
12540
13212
|
switch (plugin.config.compatibilityVersion) {
|
|
12541
|
-
case 3: return
|
|
12542
|
-
case "mini": return
|
|
12543
|
-
default: return
|
|
13213
|
+
case 3: return createRequestSchemaV3(ctx);
|
|
13214
|
+
case "mini": return createRequestSchemaMini(ctx);
|
|
13215
|
+
default: return createRequestSchemaV4(ctx);
|
|
12544
13216
|
}
|
|
12545
13217
|
}
|
|
12546
|
-
|
|
12547
|
-
const { plugin } =
|
|
13218
|
+
createRequestValidator(ctx) {
|
|
13219
|
+
const { plugin } = ctx;
|
|
13220
|
+
if (!plugin.config.requests.enabled) return;
|
|
13221
|
+
switch (plugin.config.compatibilityVersion) {
|
|
13222
|
+
case 3: return createRequestValidatorV3(ctx);
|
|
13223
|
+
case "mini": return createRequestValidatorMini(ctx);
|
|
13224
|
+
default: return createRequestValidatorV4(ctx);
|
|
13225
|
+
}
|
|
13226
|
+
}
|
|
13227
|
+
createResponseValidator(ctx) {
|
|
13228
|
+
const { plugin } = ctx;
|
|
12548
13229
|
switch (plugin.config.compatibilityVersion) {
|
|
12549
|
-
case 3: return createResponseValidatorV3(
|
|
12550
|
-
case "mini": return createResponseValidatorMini(
|
|
12551
|
-
default: return createResponseValidatorV4(
|
|
13230
|
+
case 3: return createResponseValidatorV3(ctx);
|
|
13231
|
+
case "mini": return createResponseValidatorMini(ctx);
|
|
13232
|
+
default: return createResponseValidatorV4(ctx);
|
|
12552
13233
|
}
|
|
12553
13234
|
}
|
|
12554
13235
|
};
|
|
@@ -12573,69 +13254,61 @@ function getZodModule({ plugin }) {
|
|
|
12573
13254
|
}
|
|
12574
13255
|
}
|
|
12575
13256
|
|
|
12576
|
-
//#endregion
|
|
12577
|
-
//#region src/plugins/zod/shared/operation-schema.ts
|
|
12578
|
-
function buildOperationSchema(operation) {
|
|
12579
|
-
const requiredProperties = /* @__PURE__ */ new Set();
|
|
12580
|
-
const schema = {
|
|
12581
|
-
properties: {
|
|
12582
|
-
body: { type: "never" },
|
|
12583
|
-
path: { type: "never" },
|
|
12584
|
-
query: { type: "never" }
|
|
12585
|
-
},
|
|
12586
|
-
type: "object"
|
|
12587
|
-
};
|
|
12588
|
-
if (operation.parameters) for (const location of [
|
|
12589
|
-
"header",
|
|
12590
|
-
"path",
|
|
12591
|
-
"query"
|
|
12592
|
-
]) {
|
|
12593
|
-
const params = operation.parameters[location];
|
|
12594
|
-
if (!params) continue;
|
|
12595
|
-
const properties = {};
|
|
12596
|
-
const required = [];
|
|
12597
|
-
const propKey = location === "header" ? "headers" : location;
|
|
12598
|
-
for (const key in params) {
|
|
12599
|
-
const parameter = params[key];
|
|
12600
|
-
properties[parameter.name] = parameter.schema;
|
|
12601
|
-
if (parameter.required) {
|
|
12602
|
-
required.push(parameter.name);
|
|
12603
|
-
requiredProperties.add(propKey);
|
|
12604
|
-
}
|
|
12605
|
-
}
|
|
12606
|
-
if (Object.keys(properties).length) schema.properties[propKey] = {
|
|
12607
|
-
properties,
|
|
12608
|
-
required,
|
|
12609
|
-
type: "object"
|
|
12610
|
-
};
|
|
12611
|
-
}
|
|
12612
|
-
if (operation.body) {
|
|
12613
|
-
schema.properties.body = operation.body.schema;
|
|
12614
|
-
if (operation.body.required) requiredProperties.add("body");
|
|
12615
|
-
}
|
|
12616
|
-
schema.required = [...requiredProperties];
|
|
12617
|
-
return {
|
|
12618
|
-
required: schema.required,
|
|
12619
|
-
schema
|
|
12620
|
-
};
|
|
12621
|
-
}
|
|
12622
|
-
|
|
12623
13257
|
//#endregion
|
|
12624
13258
|
//#region src/plugins/zod/shared/operation.ts
|
|
12625
13259
|
function irOperationToAst({ operation, path, plugin, processor, tags }) {
|
|
12626
13260
|
if (plugin.config.requests.enabled) {
|
|
12627
13261
|
const { schema } = buildOperationSchema(operation);
|
|
12628
|
-
processor.process({
|
|
13262
|
+
if (schema.properties?.body && schema.properties.body.type !== "never") processor.process({
|
|
12629
13263
|
meta: {
|
|
12630
13264
|
resource: "operation",
|
|
12631
13265
|
resourceId: operation.id,
|
|
12632
|
-
role: "
|
|
13266
|
+
role: "request-body"
|
|
12633
13267
|
},
|
|
12634
|
-
naming: plugin.config.requests,
|
|
13268
|
+
naming: plugin.config.requests.body,
|
|
12635
13269
|
namingAnchor: operation.id,
|
|
12636
|
-
path,
|
|
13270
|
+
path: [...path, "body"],
|
|
12637
13271
|
plugin,
|
|
12638
|
-
schema,
|
|
13272
|
+
schema: schema.properties.body,
|
|
13273
|
+
tags
|
|
13274
|
+
});
|
|
13275
|
+
if (schema.properties?.headers && schema.properties.headers.type === "object") processor.process({
|
|
13276
|
+
meta: {
|
|
13277
|
+
resource: "operation",
|
|
13278
|
+
resourceId: operation.id,
|
|
13279
|
+
role: "request-headers"
|
|
13280
|
+
},
|
|
13281
|
+
naming: plugin.config.requests.headers,
|
|
13282
|
+
namingAnchor: operation.id,
|
|
13283
|
+
path: [...path, "headers"],
|
|
13284
|
+
plugin,
|
|
13285
|
+
schema: schema.properties.headers,
|
|
13286
|
+
tags
|
|
13287
|
+
});
|
|
13288
|
+
if (schema.properties?.path && schema.properties.path.type === "object") processor.process({
|
|
13289
|
+
meta: {
|
|
13290
|
+
resource: "operation",
|
|
13291
|
+
resourceId: operation.id,
|
|
13292
|
+
role: "request-path"
|
|
13293
|
+
},
|
|
13294
|
+
naming: plugin.config.requests.path,
|
|
13295
|
+
namingAnchor: operation.id,
|
|
13296
|
+
path: [...path, "path"],
|
|
13297
|
+
plugin,
|
|
13298
|
+
schema: schema.properties.path,
|
|
13299
|
+
tags
|
|
13300
|
+
});
|
|
13301
|
+
if (schema.properties?.query && schema.properties.query.type === "object") processor.process({
|
|
13302
|
+
meta: {
|
|
13303
|
+
resource: "operation",
|
|
13304
|
+
resourceId: operation.id,
|
|
13305
|
+
role: "request-query"
|
|
13306
|
+
},
|
|
13307
|
+
naming: plugin.config.requests.query,
|
|
13308
|
+
namingAnchor: operation.id,
|
|
13309
|
+
path: [...path, "query"],
|
|
13310
|
+
plugin,
|
|
13311
|
+
schema: schema.properties.query,
|
|
12639
13312
|
tags
|
|
12640
13313
|
});
|
|
12641
13314
|
}
|
|
@@ -12680,46 +13353,6 @@ function irWebhookToAst({ operation, path, plugin, processor, tags }) {
|
|
|
12680
13353
|
}
|
|
12681
13354
|
}
|
|
12682
13355
|
|
|
12683
|
-
//#endregion
|
|
12684
|
-
//#region src/plugins/zod/shared/export.ts
|
|
12685
|
-
function exportAst({ final, meta, naming, namingAnchor, path, plugin, schema, tags }) {
|
|
12686
|
-
const z = plugin.external("zod.z");
|
|
12687
|
-
const name = pathToName(path, { anchor: namingAnchor });
|
|
12688
|
-
const symbol = plugin.registerSymbol(buildSymbolIn({
|
|
12689
|
-
meta: {
|
|
12690
|
-
category: "schema",
|
|
12691
|
-
path,
|
|
12692
|
-
tags,
|
|
12693
|
-
tool: "zod",
|
|
12694
|
-
...meta
|
|
12695
|
-
},
|
|
12696
|
-
name,
|
|
12697
|
-
naming,
|
|
12698
|
-
plugin,
|
|
12699
|
-
schema
|
|
12700
|
-
}));
|
|
12701
|
-
const typeInferSymbol = naming.types.infer.enabled ? plugin.registerSymbol(buildSymbolIn({
|
|
12702
|
-
meta: {
|
|
12703
|
-
category: "type",
|
|
12704
|
-
path,
|
|
12705
|
-
tags,
|
|
12706
|
-
tool: "zod",
|
|
12707
|
-
variant: "infer",
|
|
12708
|
-
...meta
|
|
12709
|
-
},
|
|
12710
|
-
name,
|
|
12711
|
-
naming: naming.types.infer,
|
|
12712
|
-
plugin,
|
|
12713
|
-
schema
|
|
12714
|
-
})) : void 0;
|
|
12715
|
-
const statement = $.const(symbol).export().$if(plugin.config.comments && createSchemaComment(schema), (c, v) => c.doc(v)).$if(final.typeName, (c) => c.type($.type(z).attr(final.typeName))).assign(final.expression);
|
|
12716
|
-
plugin.node(statement);
|
|
12717
|
-
if (typeInferSymbol) {
|
|
12718
|
-
const inferType = $.type.alias(typeInferSymbol).export().type($.type(z).attr(identifiers.infer).generic($(symbol).typeofType()));
|
|
12719
|
-
plugin.node(inferType);
|
|
12720
|
-
}
|
|
12721
|
-
}
|
|
12722
|
-
|
|
12723
13356
|
//#endregion
|
|
12724
13357
|
//#region src/plugins/zod/shared/meta.ts
|
|
12725
13358
|
/**
|
|
@@ -13386,7 +14019,7 @@ function voidToAst$2({ plugin, schema }) {
|
|
|
13386
14019
|
|
|
13387
14020
|
//#endregion
|
|
13388
14021
|
//#region src/plugins/zod/mini/walker.ts
|
|
13389
|
-
function createVisitor$2(config) {
|
|
14022
|
+
function createVisitor$2(config = {}) {
|
|
13390
14023
|
const { schemaExtractor } = config;
|
|
13391
14024
|
return {
|
|
13392
14025
|
applyModifiers(result, ctx, options = {}) {
|
|
@@ -13465,6 +14098,10 @@ function createVisitor$2(config) {
|
|
|
13465
14098
|
});
|
|
13466
14099
|
if (extracted !== schema) return walk(extracted, ctx);
|
|
13467
14100
|
}
|
|
14101
|
+
if (schema.symbolRef) return {
|
|
14102
|
+
expression: $(schema.symbolRef),
|
|
14103
|
+
meta: defaultMeta(schema)
|
|
14104
|
+
};
|
|
13468
14105
|
},
|
|
13469
14106
|
intersection(items, schemas, parentSchema, ctx) {
|
|
13470
14107
|
const z = ctx.plugin.external("zod.z");
|
|
@@ -13682,10 +14319,10 @@ function createVisitor$2(config) {
|
|
|
13682
14319
|
//#region src/plugins/zod/mini/processor.ts
|
|
13683
14320
|
function createProcessor$2(plugin) {
|
|
13684
14321
|
const processor = createSchemaProcessor();
|
|
13685
|
-
const
|
|
14322
|
+
const extractorHooks = [plugin.config["~hooks"]?.schemas?.shouldExtract, plugin.context.config.parser.hooks.schemas?.shouldExtract];
|
|
13686
14323
|
function extractor(ctx) {
|
|
13687
14324
|
if (processor.hasEmitted(ctx.path)) return ctx.schema;
|
|
13688
|
-
for (const hook of
|
|
14325
|
+
for (const hook of extractorHooks) if (typeof hook === "boolean" ? hook : hook?.(ctx) ?? false) {
|
|
13689
14326
|
process({
|
|
13690
14327
|
namingAnchor: processor.context.anchor,
|
|
13691
14328
|
tags: processor.context.tags,
|
|
@@ -14403,7 +15040,7 @@ function voidToAst$1({ plugin, schema }) {
|
|
|
14403
15040
|
|
|
14404
15041
|
//#endregion
|
|
14405
15042
|
//#region src/plugins/zod/v3/walker.ts
|
|
14406
|
-
function createVisitor$1(config) {
|
|
15043
|
+
function createVisitor$1(config = {}) {
|
|
14407
15044
|
const { schemaExtractor } = config;
|
|
14408
15045
|
return {
|
|
14409
15046
|
applyModifiers(result, ctx, options = {}) {
|
|
@@ -14484,6 +15121,10 @@ function createVisitor$1(config) {
|
|
|
14484
15121
|
});
|
|
14485
15122
|
if (extracted !== schema) return walk(extracted, ctx);
|
|
14486
15123
|
}
|
|
15124
|
+
if (schema.symbolRef) return {
|
|
15125
|
+
expression: $(schema.symbolRef),
|
|
15126
|
+
meta: defaultMeta(schema)
|
|
15127
|
+
};
|
|
14487
15128
|
},
|
|
14488
15129
|
intersection(items, schemas, parentSchema, ctx) {
|
|
14489
15130
|
const z = ctx.plugin.external("zod.z");
|
|
@@ -14697,10 +15338,10 @@ function createVisitor$1(config) {
|
|
|
14697
15338
|
//#region src/plugins/zod/v3/processor.ts
|
|
14698
15339
|
function createProcessor$1(plugin) {
|
|
14699
15340
|
const processor = createSchemaProcessor();
|
|
14700
|
-
const
|
|
15341
|
+
const extractorHooks = [plugin.config["~hooks"]?.schemas?.shouldExtract, plugin.context.config.parser.hooks.schemas?.shouldExtract];
|
|
14701
15342
|
function extractor(ctx) {
|
|
14702
15343
|
if (processor.hasEmitted(ctx.path)) return ctx.schema;
|
|
14703
|
-
for (const hook of
|
|
15344
|
+
for (const hook of extractorHooks) if (typeof hook === "boolean" ? hook : hook?.(ctx) ?? false) {
|
|
14704
15345
|
process({
|
|
14705
15346
|
namingAnchor: processor.context.anchor,
|
|
14706
15347
|
tags: processor.context.tags,
|
|
@@ -15424,7 +16065,7 @@ function voidToAst({ plugin, schema }) {
|
|
|
15424
16065
|
|
|
15425
16066
|
//#endregion
|
|
15426
16067
|
//#region src/plugins/zod/v4/walker.ts
|
|
15427
|
-
function createVisitor(config) {
|
|
16068
|
+
function createVisitor(config = {}) {
|
|
15428
16069
|
const { schemaExtractor } = config;
|
|
15429
16070
|
return {
|
|
15430
16071
|
applyModifiers(result, ctx, options = {}) {
|
|
@@ -15502,6 +16143,10 @@ function createVisitor(config) {
|
|
|
15502
16143
|
});
|
|
15503
16144
|
if (extracted !== schema) return walk(extracted, ctx);
|
|
15504
16145
|
}
|
|
16146
|
+
if (schema.symbolRef) return {
|
|
16147
|
+
expression: $(schema.symbolRef),
|
|
16148
|
+
meta: defaultMeta(schema)
|
|
16149
|
+
};
|
|
15505
16150
|
},
|
|
15506
16151
|
intersection(items, schemas, parentSchema, ctx) {
|
|
15507
16152
|
const z = ctx.plugin.external("zod.z");
|
|
@@ -15724,10 +16369,10 @@ function createVisitor(config) {
|
|
|
15724
16369
|
//#region src/plugins/zod/v4/processor.ts
|
|
15725
16370
|
function createProcessor(plugin) {
|
|
15726
16371
|
const processor = createSchemaProcessor();
|
|
15727
|
-
const
|
|
16372
|
+
const extractorHooks = [plugin.config["~hooks"]?.schemas?.shouldExtract, plugin.context.config.parser.hooks.schemas?.shouldExtract];
|
|
15728
16373
|
function extractor(ctx) {
|
|
15729
16374
|
if (processor.hasEmitted(ctx.path)) return ctx.schema;
|
|
15730
|
-
for (const hook of
|
|
16375
|
+
for (const hook of extractorHooks) if (typeof hook === "boolean" ? hook : hook?.(ctx) ?? false) {
|
|
15731
16376
|
process({
|
|
15732
16377
|
namingAnchor: processor.context.anchor,
|
|
15733
16378
|
tags: processor.context.tags,
|
|
@@ -15945,9 +16590,58 @@ const defaultConfig = {
|
|
|
15945
16590
|
});
|
|
15946
16591
|
plugin.config.requests = context.valueToObject({
|
|
15947
16592
|
defaultValue: {
|
|
16593
|
+
body: {
|
|
16594
|
+
case: plugin.config.case ?? "camelCase",
|
|
16595
|
+
enabled: true,
|
|
16596
|
+
name: "z{{name}}Body",
|
|
16597
|
+
types: {
|
|
16598
|
+
...plugin.config.types,
|
|
16599
|
+
infer: {
|
|
16600
|
+
...plugin.config.types.infer,
|
|
16601
|
+
name: "{{name}}BodyZodType"
|
|
16602
|
+
}
|
|
16603
|
+
}
|
|
16604
|
+
},
|
|
15948
16605
|
case: plugin.config.case ?? "camelCase",
|
|
15949
16606
|
enabled: true,
|
|
16607
|
+
headers: {
|
|
16608
|
+
case: plugin.config.case ?? "camelCase",
|
|
16609
|
+
enabled: true,
|
|
16610
|
+
name: "z{{name}}Headers",
|
|
16611
|
+
types: {
|
|
16612
|
+
...plugin.config.types,
|
|
16613
|
+
infer: {
|
|
16614
|
+
...plugin.config.types.infer,
|
|
16615
|
+
name: "{{name}}HeadersZodType"
|
|
16616
|
+
}
|
|
16617
|
+
}
|
|
16618
|
+
},
|
|
15950
16619
|
name: "z{{name}}Data",
|
|
16620
|
+
path: {
|
|
16621
|
+
case: plugin.config.case ?? "camelCase",
|
|
16622
|
+
enabled: true,
|
|
16623
|
+
name: "z{{name}}Path",
|
|
16624
|
+
types: {
|
|
16625
|
+
...plugin.config.types,
|
|
16626
|
+
infer: {
|
|
16627
|
+
...plugin.config.types.infer,
|
|
16628
|
+
name: "{{name}}PathZodType"
|
|
16629
|
+
}
|
|
16630
|
+
}
|
|
16631
|
+
},
|
|
16632
|
+
query: {
|
|
16633
|
+
case: plugin.config.case ?? "camelCase",
|
|
16634
|
+
enabled: true,
|
|
16635
|
+
name: "z{{name}}Query",
|
|
16636
|
+
types: {
|
|
16637
|
+
...plugin.config.types,
|
|
16638
|
+
infer: {
|
|
16639
|
+
...plugin.config.types.infer,
|
|
16640
|
+
name: "{{name}}QueryZodType"
|
|
16641
|
+
}
|
|
16642
|
+
}
|
|
16643
|
+
},
|
|
16644
|
+
shouldExtract: () => false,
|
|
15951
16645
|
types: {
|
|
15952
16646
|
...plugin.config.types,
|
|
15953
16647
|
infer: {
|
|
@@ -15960,6 +16654,107 @@ const defaultConfig = {
|
|
|
15960
16654
|
...mappers,
|
|
15961
16655
|
object: (fields, defaultValue) => ({
|
|
15962
16656
|
...fields,
|
|
16657
|
+
body: context.valueToObject({
|
|
16658
|
+
defaultValue: defaultValue.body,
|
|
16659
|
+
mappers: {
|
|
16660
|
+
...mappers,
|
|
16661
|
+
object: (fields, defaultValue) => ({
|
|
16662
|
+
...fields,
|
|
16663
|
+
types: context.valueToObject({
|
|
16664
|
+
defaultValue: defaultValue.types,
|
|
16665
|
+
mappers: { object: (fields, defaultValue) => ({
|
|
16666
|
+
...fields,
|
|
16667
|
+
infer: context.valueToObject({
|
|
16668
|
+
defaultValue: {
|
|
16669
|
+
...defaultValue.infer,
|
|
16670
|
+
enabled: fields.infer !== void 0 ? Boolean(fields.infer) : defaultValue.infer.enabled
|
|
16671
|
+
},
|
|
16672
|
+
mappers,
|
|
16673
|
+
value: fields.infer
|
|
16674
|
+
})
|
|
16675
|
+
}) },
|
|
16676
|
+
value: fields.types
|
|
16677
|
+
})
|
|
16678
|
+
})
|
|
16679
|
+
},
|
|
16680
|
+
value: fields.body
|
|
16681
|
+
}),
|
|
16682
|
+
headers: context.valueToObject({
|
|
16683
|
+
defaultValue: defaultValue.headers,
|
|
16684
|
+
mappers: {
|
|
16685
|
+
...mappers,
|
|
16686
|
+
object: (fields, defaultValue) => ({
|
|
16687
|
+
...fields,
|
|
16688
|
+
types: context.valueToObject({
|
|
16689
|
+
defaultValue: defaultValue.types,
|
|
16690
|
+
mappers: { object: (fields, defaultValue) => ({
|
|
16691
|
+
...fields,
|
|
16692
|
+
infer: context.valueToObject({
|
|
16693
|
+
defaultValue: {
|
|
16694
|
+
...defaultValue.infer,
|
|
16695
|
+
enabled: fields.infer !== void 0 ? Boolean(fields.infer) : defaultValue.infer.enabled
|
|
16696
|
+
},
|
|
16697
|
+
mappers,
|
|
16698
|
+
value: fields.infer
|
|
16699
|
+
})
|
|
16700
|
+
}) },
|
|
16701
|
+
value: fields.types
|
|
16702
|
+
})
|
|
16703
|
+
})
|
|
16704
|
+
},
|
|
16705
|
+
value: fields.headers
|
|
16706
|
+
}),
|
|
16707
|
+
path: context.valueToObject({
|
|
16708
|
+
defaultValue: defaultValue.path,
|
|
16709
|
+
mappers: {
|
|
16710
|
+
...mappers,
|
|
16711
|
+
object: (fields, defaultValue) => ({
|
|
16712
|
+
...fields,
|
|
16713
|
+
types: context.valueToObject({
|
|
16714
|
+
defaultValue: defaultValue.types,
|
|
16715
|
+
mappers: { object: (fields, defaultValue) => ({
|
|
16716
|
+
...fields,
|
|
16717
|
+
infer: context.valueToObject({
|
|
16718
|
+
defaultValue: {
|
|
16719
|
+
...defaultValue.infer,
|
|
16720
|
+
enabled: fields.infer !== void 0 ? Boolean(fields.infer) : defaultValue.infer.enabled
|
|
16721
|
+
},
|
|
16722
|
+
mappers,
|
|
16723
|
+
value: fields.infer
|
|
16724
|
+
})
|
|
16725
|
+
}) },
|
|
16726
|
+
value: fields.types
|
|
16727
|
+
})
|
|
16728
|
+
})
|
|
16729
|
+
},
|
|
16730
|
+
value: fields.path
|
|
16731
|
+
}),
|
|
16732
|
+
query: context.valueToObject({
|
|
16733
|
+
defaultValue: defaultValue.query,
|
|
16734
|
+
mappers: {
|
|
16735
|
+
...mappers,
|
|
16736
|
+
object: (fields, defaultValue) => ({
|
|
16737
|
+
...fields,
|
|
16738
|
+
types: context.valueToObject({
|
|
16739
|
+
defaultValue: defaultValue.types,
|
|
16740
|
+
mappers: { object: (fields, defaultValue) => ({
|
|
16741
|
+
...fields,
|
|
16742
|
+
infer: context.valueToObject({
|
|
16743
|
+
defaultValue: {
|
|
16744
|
+
...defaultValue.infer,
|
|
16745
|
+
enabled: fields.infer !== void 0 ? Boolean(fields.infer) : defaultValue.infer.enabled
|
|
16746
|
+
},
|
|
16747
|
+
mappers,
|
|
16748
|
+
value: fields.infer
|
|
16749
|
+
})
|
|
16750
|
+
}) },
|
|
16751
|
+
value: fields.types
|
|
16752
|
+
})
|
|
16753
|
+
})
|
|
16754
|
+
},
|
|
16755
|
+
value: fields.query
|
|
16756
|
+
}),
|
|
16757
|
+
shouldExtract: fields.shouldExtract !== void 0 ? typeof fields.shouldExtract === "function" ? fields.shouldExtract : () => Boolean(fields.shouldExtract) : defaultValue.shouldExtract,
|
|
15963
16758
|
types: context.valueToObject({
|
|
15964
16759
|
defaultValue: defaultValue.types,
|
|
15965
16760
|
mappers: { object: (fields, defaultValue) => ({
|
|
@@ -16270,4 +17065,4 @@ async function resolveJobs({ logger, userConfigs }) {
|
|
|
16270
17065
|
|
|
16271
17066
|
//#endregion
|
|
16272
17067
|
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 };
|
|
16273
|
-
//# sourceMappingURL=init-
|
|
17068
|
+
//# sourceMappingURL=init-C3GzFcQR.mjs.map
|