@ir-kit/openapi-kotlin 0.1.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/LICENSE.md +21 -0
- package/README.md +259 -0
- package/dist/generate.d.ts +41 -0
- package/dist/generate.d.ts.map +1 -0
- package/dist/generate.js +64 -0
- package/dist/generate.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/ir/constants.d.ts +6 -0
- package/dist/ir/constants.d.ts.map +1 -0
- package/dist/ir/constants.js +6 -0
- package/dist/ir/constants.js.map +1 -0
- package/dist/ir/identifiers.d.ts +23 -0
- package/dist/ir/identifiers.d.ts.map +1 -0
- package/dist/ir/identifiers.js +71 -0
- package/dist/ir/identifiers.js.map +1 -0
- package/dist/ir/impl/body.d.ts +30 -0
- package/dist/ir/impl/body.d.ts.map +1 -0
- package/dist/ir/impl/body.js +116 -0
- package/dist/ir/impl/body.js.map +1 -0
- package/dist/ir/impl/decode.d.ts +14 -0
- package/dist/ir/impl/decode.d.ts.map +1 -0
- package/dist/ir/impl/decode.js +110 -0
- package/dist/ir/impl/decode.js.map +1 -0
- package/dist/ir/impl/headers.d.ts +8 -0
- package/dist/ir/impl/headers.d.ts.map +1 -0
- package/dist/ir/impl/headers.js +22 -0
- package/dist/ir/impl/headers.js.map +1 -0
- package/dist/ir/impl/index.d.ts +23 -0
- package/dist/ir/impl/index.d.ts.map +1 -0
- package/dist/ir/impl/index.js +141 -0
- package/dist/ir/impl/index.js.map +1 -0
- package/dist/ir/impl/request.d.ts +14 -0
- package/dist/ir/impl/request.d.ts.map +1 -0
- package/dist/ir/impl/request.js +25 -0
- package/dist/ir/impl/request.js.map +1 -0
- package/dist/ir/impl/serializer.d.ts +20 -0
- package/dist/ir/impl/serializer.d.ts.map +1 -0
- package/dist/ir/impl/serializer.js +62 -0
- package/dist/ir/impl/serializer.js.map +1 -0
- package/dist/ir/impl/url.d.ts +16 -0
- package/dist/ir/impl/url.d.ts.map +1 -0
- package/dist/ir/impl/url.js +77 -0
- package/dist/ir/impl/url.js.map +1 -0
- package/dist/ir/index.d.ts +4 -0
- package/dist/ir/index.d.ts.map +1 -0
- package/dist/ir/index.js +3 -0
- package/dist/ir/index.js.map +1 -0
- package/dist/ir/operation/body.d.ts +18 -0
- package/dist/ir/operation/body.d.ts.map +1 -0
- package/dist/ir/operation/body.js +51 -0
- package/dist/ir/operation/body.js.map +1 -0
- package/dist/ir/operation/index.d.ts +7 -0
- package/dist/ir/operation/index.d.ts.map +1 -0
- package/dist/ir/operation/index.js +5 -0
- package/dist/ir/operation/index.js.map +1 -0
- package/dist/ir/operation/params.d.ts +16 -0
- package/dist/ir/operation/params.d.ts.map +1 -0
- package/dist/ir/operation/params.js +28 -0
- package/dist/ir/operation/params.js.map +1 -0
- package/dist/ir/operation/response.d.ts +26 -0
- package/dist/ir/operation/response.d.ts.map +1 -0
- package/dist/ir/operation/response.js +58 -0
- package/dist/ir/operation/response.js.map +1 -0
- package/dist/ir/operation/signature.d.ts +32 -0
- package/dist/ir/operation/signature.d.ts.map +1 -0
- package/dist/ir/operation/signature.js +53 -0
- package/dist/ir/operation/signature.js.map +1 -0
- package/dist/ir/operations.d.ts +43 -0
- package/dist/ir/operations.d.ts.map +1 -0
- package/dist/ir/operations.js +124 -0
- package/dist/ir/operations.js.map +1 -0
- package/dist/ir/runtime/index.d.ts +3 -0
- package/dist/ir/runtime/index.d.ts.map +1 -0
- package/dist/ir/runtime/index.js +2 -0
- package/dist/ir/runtime/index.js.map +1 -0
- package/dist/ir/runtime/templates.d.ts +31 -0
- package/dist/ir/runtime/templates.d.ts.map +1 -0
- package/dist/ir/runtime/templates.js +431 -0
- package/dist/ir/runtime/templates.js.map +1 -0
- package/dist/ir/schema.d.ts +11 -0
- package/dist/ir/schema.d.ts.map +1 -0
- package/dist/ir/schema.js +51 -0
- package/dist/ir/schema.js.map +1 -0
- package/dist/ir/type/context.d.ts +4 -0
- package/dist/ir/type/context.d.ts.map +1 -0
- package/dist/ir/type/context.js +2 -0
- package/dist/ir/type/context.js.map +1 -0
- package/dist/ir/type/index.d.ts +27 -0
- package/dist/ir/type/index.d.ts.map +1 -0
- package/dist/ir/type/index.js +35 -0
- package/dist/ir/type/index.js.map +1 -0
- package/dist/ir/type/primitive.d.ts +9 -0
- package/dist/ir/type/primitive.d.ts.map +1 -0
- package/dist/ir/type/primitive.js +50 -0
- package/dist/ir/type/primitive.js.map +1 -0
- package/dist/ir/type/property-naming.d.ts +26 -0
- package/dist/ir/type/property-naming.d.ts.map +1 -0
- package/dist/ir/type/property-naming.js +27 -0
- package/dist/ir/type/property-naming.js.map +1 -0
- package/dist/ir/type-ops.d.ts +13 -0
- package/dist/ir/type-ops.d.ts.map +1 -0
- package/dist/ir/type-ops.js +80 -0
- package/dist/ir/type-ops.js.map +1 -0
- package/dist/kt-compiler/decl/class.d.ts +6 -0
- package/dist/kt-compiler/decl/class.d.ts.map +1 -0
- package/dist/kt-compiler/decl/class.js +38 -0
- package/dist/kt-compiler/decl/class.js.map +1 -0
- package/dist/kt-compiler/decl/dataClass.d.ts +3 -0
- package/dist/kt-compiler/decl/dataClass.d.ts.map +1 -0
- package/dist/kt-compiler/decl/dataClass.js +18 -0
- package/dist/kt-compiler/decl/dataClass.js.map +1 -0
- package/dist/kt-compiler/decl/enum.d.ts +3 -0
- package/dist/kt-compiler/decl/enum.d.ts.map +1 -0
- package/dist/kt-compiler/decl/enum.js +32 -0
- package/dist/kt-compiler/decl/enum.js.map +1 -0
- package/dist/kt-compiler/decl/fun.d.ts +11 -0
- package/dist/kt-compiler/decl/fun.d.ts.map +1 -0
- package/dist/kt-compiler/decl/fun.js +69 -0
- package/dist/kt-compiler/decl/fun.js.map +1 -0
- package/dist/kt-compiler/decl/index.d.ts +13 -0
- package/dist/kt-compiler/decl/index.d.ts.map +1 -0
- package/dist/kt-compiler/decl/index.js +39 -0
- package/dist/kt-compiler/decl/index.js.map +1 -0
- package/dist/kt-compiler/decl/interface.d.ts +3 -0
- package/dist/kt-compiler/decl/interface.d.ts.map +1 -0
- package/dist/kt-compiler/decl/interface.js +15 -0
- package/dist/kt-compiler/decl/interface.js.map +1 -0
- package/dist/kt-compiler/decl/object.d.ts +3 -0
- package/dist/kt-compiler/decl/object.d.ts.map +1 -0
- package/dist/kt-compiler/decl/object.js +19 -0
- package/dist/kt-compiler/decl/object.js.map +1 -0
- package/dist/kt-compiler/decl/prop.d.ts +20 -0
- package/dist/kt-compiler/decl/prop.d.ts.map +1 -0
- package/dist/kt-compiler/decl/prop.js +42 -0
- package/dist/kt-compiler/decl/prop.js.map +1 -0
- package/dist/kt-compiler/decl/sealedClass.d.ts +3 -0
- package/dist/kt-compiler/decl/sealedClass.d.ts.map +1 -0
- package/dist/kt-compiler/decl/sealedClass.js +32 -0
- package/dist/kt-compiler/decl/sealedClass.js.map +1 -0
- package/dist/kt-compiler/decl/topLevel.d.ts +3 -0
- package/dist/kt-compiler/decl/topLevel.d.ts.map +1 -0
- package/dist/kt-compiler/decl/topLevel.js +5 -0
- package/dist/kt-compiler/decl/topLevel.js.map +1 -0
- package/dist/kt-compiler/decl/typeAlias.d.ts +3 -0
- package/dist/kt-compiler/decl/typeAlias.d.ts.map +1 -0
- package/dist/kt-compiler/decl/typeAlias.js +6 -0
- package/dist/kt-compiler/decl/typeAlias.js.map +1 -0
- package/dist/kt-compiler/expr.d.ts +4 -0
- package/dist/kt-compiler/expr.d.ts.map +1 -0
- package/dist/kt-compiler/expr.js +123 -0
- package/dist/kt-compiler/expr.js.map +1 -0
- package/dist/kt-compiler/format.d.ts +20 -0
- package/dist/kt-compiler/format.d.ts.map +1 -0
- package/dist/kt-compiler/format.js +27 -0
- package/dist/kt-compiler/format.js.map +1 -0
- package/dist/kt-compiler/index.d.ts +7 -0
- package/dist/kt-compiler/index.d.ts.map +1 -0
- package/dist/kt-compiler/index.js +24 -0
- package/dist/kt-compiler/index.js.map +1 -0
- package/dist/kt-compiler/stmt.d.ts +4 -0
- package/dist/kt-compiler/stmt.d.ts.map +1 -0
- package/dist/kt-compiler/stmt.js +72 -0
- package/dist/kt-compiler/stmt.js.map +1 -0
- package/dist/kt-compiler/type.d.ts +3 -0
- package/dist/kt-compiler/type.d.ts.map +1 -0
- package/dist/kt-compiler/type.js +28 -0
- package/dist/kt-compiler/type.js.map +1 -0
- package/dist/kt-dsl/decl/class.d.ts +50 -0
- package/dist/kt-dsl/decl/class.d.ts.map +1 -0
- package/dist/kt-dsl/decl/class.js +33 -0
- package/dist/kt-dsl/decl/class.js.map +1 -0
- package/dist/kt-dsl/decl/dataClass.d.ts +36 -0
- package/dist/kt-dsl/decl/dataClass.d.ts.map +1 -0
- package/dist/kt-dsl/decl/dataClass.js +25 -0
- package/dist/kt-dsl/decl/dataClass.js.map +1 -0
- package/dist/kt-dsl/decl/enum.d.ts +60 -0
- package/dist/kt-dsl/decl/enum.d.ts.map +1 -0
- package/dist/kt-dsl/decl/enum.js +38 -0
- package/dist/kt-dsl/decl/enum.js.map +1 -0
- package/dist/kt-dsl/decl/index.d.ts +11 -0
- package/dist/kt-dsl/decl/index.d.ts.map +1 -0
- package/dist/kt-dsl/decl/index.js +11 -0
- package/dist/kt-dsl/decl/index.js.map +1 -0
- package/dist/kt-dsl/decl/interface.d.ts +33 -0
- package/dist/kt-dsl/decl/interface.d.ts.map +1 -0
- package/dist/kt-dsl/decl/interface.js +24 -0
- package/dist/kt-dsl/decl/interface.js.map +1 -0
- package/dist/kt-dsl/decl/object.d.ts +34 -0
- package/dist/kt-dsl/decl/object.d.ts.map +1 -0
- package/dist/kt-dsl/decl/object.js +24 -0
- package/dist/kt-dsl/decl/object.js.map +1 -0
- package/dist/kt-dsl/decl/prop.d.ts +47 -0
- package/dist/kt-dsl/decl/prop.d.ts.map +1 -0
- package/dist/kt-dsl/decl/prop.js +28 -0
- package/dist/kt-dsl/decl/prop.js.map +1 -0
- package/dist/kt-dsl/decl/sealedClass.d.ts +68 -0
- package/dist/kt-dsl/decl/sealedClass.d.ts.map +1 -0
- package/dist/kt-dsl/decl/sealedClass.js +52 -0
- package/dist/kt-dsl/decl/sealedClass.js.map +1 -0
- package/dist/kt-dsl/decl/topLevel.d.ts +19 -0
- package/dist/kt-dsl/decl/topLevel.d.ts.map +1 -0
- package/dist/kt-dsl/decl/topLevel.js +17 -0
- package/dist/kt-dsl/decl/topLevel.js.map +1 -0
- package/dist/kt-dsl/decl/typeAlias.d.ts +23 -0
- package/dist/kt-dsl/decl/typeAlias.d.ts.map +1 -0
- package/dist/kt-dsl/decl/typeAlias.js +18 -0
- package/dist/kt-dsl/decl/typeAlias.js.map +1 -0
- package/dist/kt-dsl/decl/types.d.ts +10 -0
- package/dist/kt-dsl/decl/types.d.ts.map +1 -0
- package/dist/kt-dsl/decl/types.js +2 -0
- package/dist/kt-dsl/decl/types.js.map +1 -0
- package/dist/kt-dsl/expr/access.d.ts +48 -0
- package/dist/kt-dsl/expr/access.d.ts.map +1 -0
- package/dist/kt-dsl/expr/access.js +59 -0
- package/dist/kt-dsl/expr/access.js.map +1 -0
- package/dist/kt-dsl/expr/call.d.ts +38 -0
- package/dist/kt-dsl/expr/call.d.ts.map +1 -0
- package/dist/kt-dsl/expr/call.js +38 -0
- package/dist/kt-dsl/expr/call.js.map +1 -0
- package/dist/kt-dsl/expr/index.d.ts +7 -0
- package/dist/kt-dsl/expr/index.d.ts.map +1 -0
- package/dist/kt-dsl/expr/index.js +7 -0
- package/dist/kt-dsl/expr/index.js.map +1 -0
- package/dist/kt-dsl/expr/literal.d.ts +100 -0
- package/dist/kt-dsl/expr/literal.d.ts.map +1 -0
- package/dist/kt-dsl/expr/literal.js +108 -0
- package/dist/kt-dsl/expr/literal.js.map +1 -0
- package/dist/kt-dsl/expr/misc.d.ts +45 -0
- package/dist/kt-dsl/expr/misc.d.ts.map +1 -0
- package/dist/kt-dsl/expr/misc.js +63 -0
- package/dist/kt-dsl/expr/misc.js.map +1 -0
- package/dist/kt-dsl/expr/op.d.ts +25 -0
- package/dist/kt-dsl/expr/op.d.ts.map +1 -0
- package/dist/kt-dsl/expr/op.js +24 -0
- package/dist/kt-dsl/expr/op.js.map +1 -0
- package/dist/kt-dsl/expr/types.d.ts +93 -0
- package/dist/kt-dsl/expr/types.d.ts.map +1 -0
- package/dist/kt-dsl/expr/types.js +2 -0
- package/dist/kt-dsl/expr/types.js.map +1 -0
- package/dist/kt-dsl/file.d.ts +14 -0
- package/dist/kt-dsl/file.d.ts.map +1 -0
- package/dist/kt-dsl/file.js +9 -0
- package/dist/kt-dsl/file.js.map +1 -0
- package/dist/kt-dsl/fun.d.ts +73 -0
- package/dist/kt-dsl/fun.d.ts.map +1 -0
- package/dist/kt-dsl/fun.js +50 -0
- package/dist/kt-dsl/fun.js.map +1 -0
- package/dist/kt-dsl/index.d.ts +8 -0
- package/dist/kt-dsl/index.d.ts.map +1 -0
- package/dist/kt-dsl/index.js +8 -0
- package/dist/kt-dsl/index.js.map +1 -0
- package/dist/kt-dsl/stmt/binding.d.ts +56 -0
- package/dist/kt-dsl/stmt/binding.d.ts.map +1 -0
- package/dist/kt-dsl/stmt/binding.js +70 -0
- package/dist/kt-dsl/stmt/binding.js.map +1 -0
- package/dist/kt-dsl/stmt/control.d.ts +80 -0
- package/dist/kt-dsl/stmt/control.d.ts.map +1 -0
- package/dist/kt-dsl/stmt/control.js +77 -0
- package/dist/kt-dsl/stmt/control.js.map +1 -0
- package/dist/kt-dsl/stmt/index.d.ts +4 -0
- package/dist/kt-dsl/stmt/index.d.ts.map +1 -0
- package/dist/kt-dsl/stmt/index.js +4 -0
- package/dist/kt-dsl/stmt/index.js.map +1 -0
- package/dist/kt-dsl/stmt/types.d.ts +62 -0
- package/dist/kt-dsl/stmt/types.d.ts.map +1 -0
- package/dist/kt-dsl/stmt/types.js +2 -0
- package/dist/kt-dsl/stmt/types.js.map +1 -0
- package/dist/kt-dsl/type/builders.d.ts +75 -0
- package/dist/kt-dsl/type/builders.d.ts.map +1 -0
- package/dist/kt-dsl/type/builders.js +83 -0
- package/dist/kt-dsl/type/builders.js.map +1 -0
- package/dist/kt-dsl/type/index.d.ts +3 -0
- package/dist/kt-dsl/type/index.d.ts.map +1 -0
- package/dist/kt-dsl/type/index.js +3 -0
- package/dist/kt-dsl/type/index.js.map +1 -0
- package/dist/kt-dsl/type/types.d.ts +25 -0
- package/dist/kt-dsl/type/types.d.ts.map +1 -0
- package/dist/kt-dsl/type/types.js +2 -0
- package/dist/kt-dsl/type/types.js.map +1 -0
- package/dist/kt-dsl/visibility.d.ts +2 -0
- package/dist/kt-dsl/visibility.d.ts.map +1 -0
- package/dist/kt-dsl/visibility.js +2 -0
- package/dist/kt-dsl/visibility.js.map +1 -0
- package/dist/project/build.d.ts +33 -0
- package/dist/project/build.d.ts.map +1 -0
- package/dist/project/build.js +73 -0
- package/dist/project/build.js.map +1 -0
- package/dist/project/gradle.d.ts +48 -0
- package/dist/project/gradle.d.ts.map +1 -0
- package/dist/project/gradle.js +46 -0
- package/dist/project/gradle.js.map +1 -0
- package/dist/project/imports.d.ts +21 -0
- package/dist/project/imports.d.ts.map +1 -0
- package/dist/project/imports.js +162 -0
- package/dist/project/imports.js.map +1 -0
- package/dist/project/index.d.ts +6 -0
- package/dist/project/index.d.ts.map +1 -0
- package/dist/project/index.js +3 -0
- package/dist/project/index.js.map +1 -0
- package/dist/project/layout.d.ts +30 -0
- package/dist/project/layout.d.ts.map +1 -0
- package/dist/project/layout.js +57 -0
- package/dist/project/layout.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type LocatedParam } from "@ir-kit/openapi";
|
|
2
|
+
import { type KtStmt } from "../../kt-dsl/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Statements that build an `HttpUrl` from `baseUrl`, the path template,
|
|
5
|
+
* and query parameters. The result is bound to `url`.
|
|
6
|
+
*
|
|
7
|
+
* - Path-template parameters become `addPathSegment(<expr>.toString())`.
|
|
8
|
+
* - Mixed segments like `users-{id}` interpolate into a single
|
|
9
|
+
* `addPathSegment("users-$id")` call (OkHttp percent-encodes the
|
|
10
|
+
* full segment, so reserved characters in the value stay scoped to
|
|
11
|
+
* that segment).
|
|
12
|
+
* - Query params route through `URLEncoding.addScalar` /
|
|
13
|
+
* `URLEncoding.addArray` so style+explode is uniform.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildUrlStmts(pathStr: string, located: ReadonlyArray<LocatedParam>): ReadonlyArray<KtStmt>;
|
|
16
|
+
//# sourceMappingURL=url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/ir/impl/url.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EAIlB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAGL,KAAK,MAAM,EAWZ,MAAM,uBAAuB,CAAC;AAG/B;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,GACnC,aAAa,CAAC,MAAM,CAAC,CAuBvB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { paramsAt, parseTemplatedSegment, splitPathSegments, } from "@ir-kit/openapi";
|
|
2
|
+
import { ktArg, ktBoolLit, ktCall, ktExprStmt, ktIdent, ktInterp, ktMember, ktStr, ktVal, ktVar, } from "../../kt-dsl/index.js";
|
|
3
|
+
import { paramIdent } from "../identifiers.js";
|
|
4
|
+
/**
|
|
5
|
+
* Statements that build an `HttpUrl` from `baseUrl`, the path template,
|
|
6
|
+
* and query parameters. The result is bound to `url`.
|
|
7
|
+
*
|
|
8
|
+
* - Path-template parameters become `addPathSegment(<expr>.toString())`.
|
|
9
|
+
* - Mixed segments like `users-{id}` interpolate into a single
|
|
10
|
+
* `addPathSegment("users-$id")` call (OkHttp percent-encodes the
|
|
11
|
+
* full segment, so reserved characters in the value stay scoped to
|
|
12
|
+
* that segment).
|
|
13
|
+
* - Query params route through `URLEncoding.addScalar` /
|
|
14
|
+
* `URLEncoding.addArray` so style+explode is uniform.
|
|
15
|
+
*/
|
|
16
|
+
export function buildUrlStmts(pathStr, located) {
|
|
17
|
+
const pathParams = paramsAt(located, "path");
|
|
18
|
+
const queryParams = paramsAt(located, "query");
|
|
19
|
+
const stmts = [
|
|
20
|
+
ktVar("urlBuilder", ktCall(ktMember(ktIdent("baseUrl"), "newBuilder"), [])),
|
|
21
|
+
];
|
|
22
|
+
for (const seg of splitPathSegments(pathStr)) {
|
|
23
|
+
stmts.push(ktExprStmt(ktCall(ktMember(ktIdent("urlBuilder"), "addPathSegment"), [
|
|
24
|
+
ktArg(segmentExpr(seg, pathParams)),
|
|
25
|
+
])));
|
|
26
|
+
}
|
|
27
|
+
for (const p of queryParams) {
|
|
28
|
+
stmts.push(buildQueryStmt(p));
|
|
29
|
+
}
|
|
30
|
+
stmts.push(ktVal("url", ktCall(ktMember(ktIdent("urlBuilder"), "build"), [])));
|
|
31
|
+
return stmts;
|
|
32
|
+
}
|
|
33
|
+
function segmentExpr(seg, pathParams) {
|
|
34
|
+
const parts = parseTemplatedSegment(seg, pathParams).map((p) => p.kind === "literal"
|
|
35
|
+
? p.text
|
|
36
|
+
: {
|
|
37
|
+
expr: ktIdent(paramIdent(p.param ? p.param.name : p.name)),
|
|
38
|
+
isString: p.param?.schema.type === "string",
|
|
39
|
+
});
|
|
40
|
+
if (parts.length === 0)
|
|
41
|
+
return ktStr("");
|
|
42
|
+
if (parts.length === 1 && typeof parts[0] === "string")
|
|
43
|
+
return ktStr(parts[0]);
|
|
44
|
+
if (parts.length === 1) {
|
|
45
|
+
const only = parts[0];
|
|
46
|
+
return only.isString
|
|
47
|
+
? only.expr
|
|
48
|
+
: ktCall(ktMember(only.expr, "toString"), []);
|
|
49
|
+
}
|
|
50
|
+
return ktInterp(parts.map((p) => (typeof p === "string" ? p : p.expr)));
|
|
51
|
+
}
|
|
52
|
+
function buildQueryStmt(p) {
|
|
53
|
+
const id = paramIdent(p.name);
|
|
54
|
+
const isArray = p.schema.type === "array";
|
|
55
|
+
const helper = isArray ? "addArray" : "addScalar";
|
|
56
|
+
const args = [
|
|
57
|
+
ktArg(ktIdent("urlBuilder")),
|
|
58
|
+
ktArg(ktStr(p.name)),
|
|
59
|
+
ktArg(ktIdent(id)),
|
|
60
|
+
];
|
|
61
|
+
if (isArray) {
|
|
62
|
+
args.push(ktArg(ktIdent(`QueryStyle.${queryStyleEntry(p.style)}`), "style"));
|
|
63
|
+
args.push(ktArg(ktBoolLit(p.explode ?? true), "explode"));
|
|
64
|
+
}
|
|
65
|
+
return ktExprStmt(ktCall(ktMember(ktIdent("URLEncoding"), helper), args));
|
|
66
|
+
}
|
|
67
|
+
function queryStyleEntry(style) {
|
|
68
|
+
switch (style) {
|
|
69
|
+
case "spaceDelimited":
|
|
70
|
+
return "SPACE_DELIMITED";
|
|
71
|
+
case "pipeDelimited":
|
|
72
|
+
return "PIPE_DELIMITED";
|
|
73
|
+
default:
|
|
74
|
+
return "FORM";
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../../src/ir/impl/url.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,QAAQ,EACR,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAIL,KAAK,EACL,SAAS,EACT,MAAM,EACN,UAAU,EACV,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,KAAK,EACL,KAAK,GACN,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAC3B,OAAe,EACf,OAAoC;IAEpC,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,EAA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AAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;KACnB,CAAC;IACF,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,CAAC,IAAI,CACP,KAAK,CAAC,OAAO,CAAC,cAAc,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAClE,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,eAAe,CAAC,KAAkC;IACzD,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,gBAAgB;YACnB,OAAO,iBAAiB,CAAC;QAC3B,KAAK,eAAe;YAClB,OAAO,gBAAgB,CAAC;QAC1B;YACE,OAAO,MAAM,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ir/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/ir/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ir/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IR } from "@hey-api/shared";
|
|
2
|
+
import { type KtFunParam } from "../../kt-dsl/index.js";
|
|
3
|
+
import type { TypeCtx } from "../type/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Resolve an `IR.BodyObject` into the function parameters that show up
|
|
6
|
+
* in both the interface signature and the impl method:
|
|
7
|
+
*
|
|
8
|
+
* - `application/json` (and `+json`) → single `body: T`. When the
|
|
9
|
+
* schema collapses to `Any` (e.g. a `oneOf` with no discriminated
|
|
10
|
+
* union codegen), the param falls back to `ByteArray` so the caller
|
|
11
|
+
* pre-encodes JSON — `Any` isn't `@Serializable`, so emitting it
|
|
12
|
+
* would produce code that fails to compile.
|
|
13
|
+
* - `multipart/form-data` + object schema → one param per property; binary fields become `ByteArray`
|
|
14
|
+
* - `application/x-www-form-urlencoded` + object schema → one param per property
|
|
15
|
+
* - empty / octet-stream / image/* / unknown → `body: ByteArray` (caller pre-encodes)
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildBodyParams(body: IR.BodyObject, ctx: TypeCtx): ReadonlyArray<KtFunParam>;
|
|
18
|
+
//# sourceMappingURL=body.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../../src/ir/operation/body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAG1C,OAAO,EACL,KAAK,UAAU,EAIhB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGhD;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,EAAE,CAAC,UAAU,EACnB,GAAG,EAAE,OAAO,GACX,aAAa,CAAC,UAAU,CAAC,CAqB3B"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { classifyBody, iterateObjectProperties } from "@ir-kit/openapi";
|
|
2
|
+
import { ktByteArray, ktFunParam, ktNullable, } from "../../kt-dsl/index.js";
|
|
3
|
+
import { paramIdent } from "../identifiers.js";
|
|
4
|
+
import { schemaToType } from "../type/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Resolve an `IR.BodyObject` into the function parameters that show up
|
|
7
|
+
* in both the interface signature and the impl method:
|
|
8
|
+
*
|
|
9
|
+
* - `application/json` (and `+json`) → single `body: T`. When the
|
|
10
|
+
* schema collapses to `Any` (e.g. a `oneOf` with no discriminated
|
|
11
|
+
* union codegen), the param falls back to `ByteArray` so the caller
|
|
12
|
+
* pre-encodes JSON — `Any` isn't `@Serializable`, so emitting it
|
|
13
|
+
* would produce code that fails to compile.
|
|
14
|
+
* - `multipart/form-data` + object schema → one param per property; binary fields become `ByteArray`
|
|
15
|
+
* - `application/x-www-form-urlencoded` + object schema → one param per property
|
|
16
|
+
* - empty / octet-stream / image/* / unknown → `body: ByteArray` (caller pre-encodes)
|
|
17
|
+
*/
|
|
18
|
+
export function buildBodyParams(body, ctx) {
|
|
19
|
+
const shape = classifyBody(body);
|
|
20
|
+
const schema = body.schema;
|
|
21
|
+
switch (shape.kind) {
|
|
22
|
+
case "json-opaque":
|
|
23
|
+
return [ktFunParam({ name: "body", type: ktByteArray })];
|
|
24
|
+
case "json-typed":
|
|
25
|
+
return [
|
|
26
|
+
ktFunParam({
|
|
27
|
+
name: "body",
|
|
28
|
+
type: schemaToType(schema, { ...ctx, propPath: ["body"] }),
|
|
29
|
+
}),
|
|
30
|
+
];
|
|
31
|
+
case "multipart-object":
|
|
32
|
+
return objectBodyToFlatParams(schema, ctx, /* binaryAsByteArray */ true);
|
|
33
|
+
case "form-urlencoded-object":
|
|
34
|
+
return objectBodyToFlatParams(schema, ctx, /* binaryAsByteArray */ false);
|
|
35
|
+
case "opaque":
|
|
36
|
+
return [ktFunParam({ name: "body", type: ktByteArray })];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function objectBodyToFlatParams(schema, ctx, binaryAsByteArray) {
|
|
40
|
+
return Array.from(iterateObjectProperties(schema)).map(({ jsonKey: propName, schema: propSchema, required, isBinary }) => {
|
|
41
|
+
const t = binaryAsByteArray && isBinary
|
|
42
|
+
? ktByteArray
|
|
43
|
+
: schemaToType(propSchema, { ...ctx, propPath: ["body", propName] });
|
|
44
|
+
return ktFunParam({
|
|
45
|
+
name: paramIdent(propName),
|
|
46
|
+
type: required ? t : ktNullable(t),
|
|
47
|
+
default: required ? undefined : "null",
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body.js","sourceRoot":"","sources":["../../../src/ir/operation/body.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAExE,OAAO,EAEL,WAAW,EACX,UAAU,EACV,UAAU,GACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAmB,EACnB,GAAY;IAEZ,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAE3B,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,aAAa;YAChB,OAAO,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;QAC3D,KAAK,YAAY;YACf,OAAO;gBACL,UAAU,CAAC;oBACT,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,YAAY,CAAC,MAAM,EAAE,EAAE,GAAG,GAAG,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;iBAC3D,CAAC;aACH,CAA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
+
export { buildBodyParams } from "./body.js";
|
|
4
|
+
export { returnTypeFor } from "./response.js";
|
|
5
|
+
export type { OperationSignature, ResponseCase } from "./signature.js";
|
|
6
|
+
export { operationSignature } from "./signature.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ir/operation/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ir/operation/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IR } from "@hey-api/shared";
|
|
2
|
+
import { type LocatedParam } from "@ir-kit/openapi";
|
|
3
|
+
import { type KtFunParam } from "../../kt-dsl/index.js";
|
|
4
|
+
import type { TypeCtx } from "../type/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Produce the function parameters for path/query/header parameters in
|
|
7
|
+
* required-first order (so trailing optional defaults stay tail-only).
|
|
8
|
+
* Cookie params are skipped — OkHttp / kotlinx-serialization have no
|
|
9
|
+
* idiomatic cookie-param mapping and they're rare enough not to warrant
|
|
10
|
+
* codegen support.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildNonBodyParams(op: IR.OperationObject, ctx: TypeCtx): {
|
|
13
|
+
params: KtFunParam[];
|
|
14
|
+
located: LocatedParam[];
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../../src/ir/operation/params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAwB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAE,KAAK,UAAU,EAA0B,MAAM,uBAAuB,CAAC;AAEhF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGhD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,EAAE,CAAC,eAAe,EACtB,GAAG,EAAE,OAAO,GACX;IAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAAC,OAAO,EAAE,YAAY,EAAE,CAAA;CAAE,CAiBnD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { collectLocatedParams } from "@ir-kit/openapi";
|
|
2
|
+
import { ktFunParam, ktNullable } from "../../kt-dsl/index.js";
|
|
3
|
+
import { paramIdent } from "../identifiers.js";
|
|
4
|
+
import { schemaToType } from "../type/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Produce the function parameters for path/query/header parameters in
|
|
7
|
+
* required-first order (so trailing optional defaults stay tail-only).
|
|
8
|
+
* Cookie params are skipped — OkHttp / kotlinx-serialization have no
|
|
9
|
+
* idiomatic cookie-param mapping and they're rare enough not to warrant
|
|
10
|
+
* codegen support.
|
|
11
|
+
*/
|
|
12
|
+
export function buildNonBodyParams(op, ctx) {
|
|
13
|
+
const located = collectLocatedParams(op).filter((l) => l.loc !== "cookie");
|
|
14
|
+
located.sort((a, b) => Number(!a.param.required) - Number(!b.param.required));
|
|
15
|
+
const params = located.map(({ param: p }) => {
|
|
16
|
+
const t = schemaToType(p.schema, {
|
|
17
|
+
...ctx,
|
|
18
|
+
propPath: ["param", p.name],
|
|
19
|
+
});
|
|
20
|
+
return ktFunParam({
|
|
21
|
+
name: paramIdent(p.name),
|
|
22
|
+
type: p.required ? t : ktNullable(t),
|
|
23
|
+
default: p.required ? undefined : "null",
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
return { params, located };
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.js","sourceRoot":"","sources":["../../../src/ir/operation/params.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAqB,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAmB,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAChC,EAAsB,EACtB,GAAY;IAEZ,MAAM,OAAO,GAAG,oBAAoB,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC;IAC3E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE9E,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE;QAC1C,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,MAAM,EAAE;YAC/B,GAAG,GAAG;YACN,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC;SAC5B,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;YAChB,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;YACxB,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;YACpC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM;SACzC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IR } from "@hey-api/shared";
|
|
2
|
+
import { type KtType } from "../../kt-dsl/index.js";
|
|
3
|
+
import type { TypeCtx } from "../type/index.js";
|
|
4
|
+
import type { ResponseCase } from "./signature.js";
|
|
5
|
+
export interface ResolvedReturn {
|
|
6
|
+
type: KtType;
|
|
7
|
+
/**
|
|
8
|
+
* Per-status-code cases when the op has more than one 2xx response.
|
|
9
|
+
* Empty for single-2xx ops — the impl decodes straight into `type`
|
|
10
|
+
* (which is `Unit` or the schema type). Non-empty means `type` is a
|
|
11
|
+
* `ktRef` to an emitted sealed-class hierarchy and the impl must
|
|
12
|
+
* dispatch on `response.code` to pick the matching subclass.
|
|
13
|
+
*/
|
|
14
|
+
cases: ReadonlyArray<ResponseCase>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the success-path return shape for an op.
|
|
18
|
+
*
|
|
19
|
+
* - 0 successful responses → `Unit`
|
|
20
|
+
* - 1 successful response, empty schema → `Unit`
|
|
21
|
+
* - 1 successful response, schema → schema type
|
|
22
|
+
* - 2+ successful responses → emit `<Owner>_Response`
|
|
23
|
+
* sealed-class hierarchy, return a ref + the per-status case info
|
|
24
|
+
*/
|
|
25
|
+
export declare function returnTypeFor(op: IR.OperationObject, ctx: TypeCtx): ResolvedReturn;
|
|
26
|
+
//# sourceMappingURL=response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../src/ir/operation/response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAK1C,OAAO,EACL,KAAK,MAAM,EAMZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,KAAK,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;CACpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,EAAE,CAAC,eAAe,EACtB,GAAG,EAAE,OAAO,GACX,cAAc,CAUhB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { synthName } from "@ir-kit/codegen-core";
|
|
2
|
+
import { classifyReturnShape } from "@ir-kit/openapi";
|
|
3
|
+
import { isMeaningless } from "@ir-kit/openapi-core";
|
|
4
|
+
import { ktProp, ktRef, ktSealedClass, ktSealedSubclass, ktUnit, } from "../../kt-dsl/index.js";
|
|
5
|
+
import { schemaToType } from "../type/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the success-path return shape for an op.
|
|
8
|
+
*
|
|
9
|
+
* - 0 successful responses → `Unit`
|
|
10
|
+
* - 1 successful response, empty schema → `Unit`
|
|
11
|
+
* - 1 successful response, schema → schema type
|
|
12
|
+
* - 2+ successful responses → emit `<Owner>_Response`
|
|
13
|
+
* sealed-class hierarchy, return a ref + the per-status case info
|
|
14
|
+
*/
|
|
15
|
+
export function returnTypeFor(op, ctx) {
|
|
16
|
+
const shape = classifyReturnShape(op);
|
|
17
|
+
switch (shape.kind) {
|
|
18
|
+
case "void":
|
|
19
|
+
return { type: ktUnit, cases: [] };
|
|
20
|
+
case "single":
|
|
21
|
+
return { type: schemaToType(shape.schema, ctx), cases: [] };
|
|
22
|
+
case "multi":
|
|
23
|
+
return emitMultiResponseSealed(shape.cases, ctx);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function emitMultiResponseSealed(responses, ctx) {
|
|
27
|
+
const sealedName = synthName(ctx.ownerName, ["response"]);
|
|
28
|
+
const cases = responses.map(([code, resp]) => {
|
|
29
|
+
const schema = resp?.schema;
|
|
30
|
+
const isVoid = !schema || isMeaningless(schema);
|
|
31
|
+
const caseName = `Status${code}`;
|
|
32
|
+
if (isVoid)
|
|
33
|
+
return { statusCode: code, caseName };
|
|
34
|
+
const payloadType = schemaToType(schema, {
|
|
35
|
+
...ctx,
|
|
36
|
+
propPath: ["response", code],
|
|
37
|
+
});
|
|
38
|
+
return { statusCode: code, caseName, payloadType };
|
|
39
|
+
});
|
|
40
|
+
ctx.emit(ktSealedClass({
|
|
41
|
+
name: sealedName,
|
|
42
|
+
subclasses: cases.map((c) => c.payloadType
|
|
43
|
+
? ktSealedSubclass({
|
|
44
|
+
variant: "class",
|
|
45
|
+
name: c.caseName,
|
|
46
|
+
properties: [
|
|
47
|
+
ktProp({
|
|
48
|
+
name: "value",
|
|
49
|
+
type: c.payloadType,
|
|
50
|
+
inPrimary: true,
|
|
51
|
+
}),
|
|
52
|
+
],
|
|
53
|
+
})
|
|
54
|
+
: ktSealedSubclass({ variant: "object", name: c.caseName })),
|
|
55
|
+
}));
|
|
56
|
+
return { type: ktRef(sealedName), cases };
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=response.js.map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AI,aAAa,CAAC,MAAM,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,SAAS,IAAI,EAAE,CAAC;QACjC,IAAI,MAAM;YAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAClD,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,EAAE;YACvC,GAAG,GAAG;YACN,QAAQ,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC;SAC7B,CAAC,CAAC;QACH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IACrD,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,IAAI,CACN,aAAa,CAAC;QACZ,IAAI,EAAE,UAAU;QAChB,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC1B,CAAC,CAAC,WAAW;YACX,CAAC,CAAC,gBAAgB,CAAC;gBACf,OAAO,EAAE,OAAO;gBAChB,IAAI,EAAE,CAAC,CAAC,QAAQ;gBAChB,UAAU,EAAE;oBACV,MAAM,CAAC;wBACL,IAAI,EAAE,OAAO;wBACb,IAAI,EAAE,CAAC,CAAC,WAAW;wBACnB,SAAS,EAAE,IAAI;qBAChB,CAAC;iBACH;aACF,CAAC;YACJ,CAAC,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAC9D;KACF,CAAC,CACH,CAAC;IACF,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { IR } from "@hey-api/shared";
|
|
2
|
+
import { type ResponseCase as IRResponseCase, type LocatedParam } from "@ir-kit/openapi";
|
|
3
|
+
import type { HttpMethod } from "@ir-kit/openapi-core";
|
|
4
|
+
import { type KtFunParam, type KtType } from "../../kt-dsl/index.js";
|
|
5
|
+
import type { TypeCtx } from "../type/index.js";
|
|
6
|
+
export interface OperationSignature {
|
|
7
|
+
name: string;
|
|
8
|
+
ownerName: string;
|
|
9
|
+
params: ReadonlyArray<KtFunParam>;
|
|
10
|
+
returnType: KtType;
|
|
11
|
+
doc: string;
|
|
12
|
+
locatedParams: ReadonlyArray<LocatedParam>;
|
|
13
|
+
op: IR.OperationObject;
|
|
14
|
+
method: HttpMethod;
|
|
15
|
+
pathStr: string;
|
|
16
|
+
securitySchemeNames: ReadonlyArray<string>;
|
|
17
|
+
responseCases: ReadonlyArray<ResponseCase>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* One arm of a multi-2xx sum-type return. Populated by `returnTypeFor`
|
|
21
|
+
* when an op declares more than one 2xx response code; the impl
|
|
22
|
+
* dispatches on `response.code` to decode the matching payload type
|
|
23
|
+
* into the matching sealed-subclass. `payloadType` is `undefined` for
|
|
24
|
+
* empty bodies (e.g. 204).
|
|
25
|
+
*/
|
|
26
|
+
export type ResponseCase = IRResponseCase<KtType>;
|
|
27
|
+
/**
|
|
28
|
+
* One source of truth for `params + returnType + doc` so the interface
|
|
29
|
+
* declaration and the impl class share the same signature shape.
|
|
30
|
+
*/
|
|
31
|
+
export declare function operationSignature(op: IR.OperationObject, method: HttpMethod, pathStr: string, emit: TypeCtx["emit"], schemeNames?: ReadonlyArray<string>): OperationSignature;
|
|
32
|
+
//# sourceMappingURL=signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../../src/ir/operation/signature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAEL,KAAK,YAAY,IAAI,cAAc,EACnC,KAAK,YAAY,EAElB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,KAAK,UAAU,EACf,KAAK,MAAM,EAGZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAKhD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IAC3C,EAAE,EAAE,EAAE,CAAC,eAAe,CAAC;IACvB,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC3C,aAAa,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;CAC5C;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AAElD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,EAAE,CAAC,eAAe,EACtB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,EACrB,WAAW,GAAE,aAAa,CAAC,MAAM,CAAM,GACtC,kBAAkB,CA0BpB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { camel, pascal } from "@ir-kit/codegen-core";
|
|
2
|
+
import { deriveBaseName, operationDocLine, } from "@ir-kit/openapi";
|
|
3
|
+
import { ktFunParam, ktRef, } from "../../kt-dsl/index.js";
|
|
4
|
+
import { buildBodyParams } from "./body.js";
|
|
5
|
+
import { buildNonBodyParams } from "./params.js";
|
|
6
|
+
import { returnTypeFor } from "./response.js";
|
|
7
|
+
/**
|
|
8
|
+
* One source of truth for `params + returnType + doc` so the interface
|
|
9
|
+
* declaration and the impl class share the same signature shape.
|
|
10
|
+
*/
|
|
11
|
+
export function operationSignature(op, method, pathStr, emit, schemeNames = []) {
|
|
12
|
+
const name = deriveBaseName(op, method, pathStr);
|
|
13
|
+
const ownerName = pascal(name);
|
|
14
|
+
const ctx = { emit, ownerName, propPath: [] };
|
|
15
|
+
const { params: nonBody, located } = buildNonBodyParams(op, ctx);
|
|
16
|
+
const bodyParams = op.body ? buildBodyParams(op.body, ctx) : [];
|
|
17
|
+
const params = [...nonBody, ...bodyParams, optionsParam()];
|
|
18
|
+
const { type: returnType, cases: responseCases } = returnTypeFor(op, {
|
|
19
|
+
...ctx,
|
|
20
|
+
propPath: ["response"],
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
name: camel(name),
|
|
24
|
+
ownerName,
|
|
25
|
+
params,
|
|
26
|
+
returnType,
|
|
27
|
+
doc: operationDocLine(method, pathStr),
|
|
28
|
+
locatedParams: located,
|
|
29
|
+
op,
|
|
30
|
+
method,
|
|
31
|
+
pathStr,
|
|
32
|
+
securitySchemeNames: schemeNames,
|
|
33
|
+
responseCases,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The trailing `options: RequestOptions` param every emitted method
|
|
38
|
+
* takes. Mirrors hey-api's TS SDK per-call options pattern — caller
|
|
39
|
+
* can override `client`, `baseUrl`, `headers`, or pass extra
|
|
40
|
+
* `requestInterceptors` for one call.
|
|
41
|
+
*
|
|
42
|
+
* No default value: Kotlin forbids defaults on `override` methods, so
|
|
43
|
+
* the impl class can't carry one. Callers who don't need overrides
|
|
44
|
+
* reach for the no-options convenience overload emitted alongside as a
|
|
45
|
+
* top-level extension fun.
|
|
46
|
+
*/
|
|
47
|
+
function optionsParam() {
|
|
48
|
+
return ktFunParam({
|
|
49
|
+
name: "options",
|
|
50
|
+
type: ktRef("RequestOptions"),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=signature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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C,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC;QACjB,SAAS;QACT,MAAM;QACN,UAAU;QACV,GAAG,EAAE,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC;QACtC,aAAa,EAAE,OAAO;QACtB,EAAE;QACF,MAAM;QACN,OAAO;QACP,mBAAmB,EAAE,WAAW;QAChC,aAAa;KACd,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,YAAY;IACnB,OAAO,UAAU,CAAC;QAChB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,KAAK,CAAC,gBAAgB,CAAC;KAC9B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { IR } from "@hey-api/shared";
|
|
2
|
+
import { type KtDecl } from "../kt-dsl/index.js";
|
|
3
|
+
export interface OperationsOptions {
|
|
4
|
+
/** Default: `"Default"`. */
|
|
5
|
+
defaultTag?: string;
|
|
6
|
+
/** Default: `(tag) => `${PascalCase(tag)}Api``. */
|
|
7
|
+
interfaceName?: (tag: string) => string;
|
|
8
|
+
/** Default: `(interfaceName) => `OkHttp${interfaceName}``. */
|
|
9
|
+
clientClassName?: (interfaceName: string) => string;
|
|
10
|
+
/** Skip emitting the OkHttp impl class. Default: `false`. */
|
|
11
|
+
interfaceOnly?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Emit the impl class as `open` instead of `final` so consumers can
|
|
14
|
+
* subclass and override individual methods. Default: `false`.
|
|
15
|
+
*/
|
|
16
|
+
openImpl?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Per-operation security-scheme names, keyed by `${pathStr}|${method}`.
|
|
19
|
+
* The IR drops scheme names from `op.security`, so the caller (usually
|
|
20
|
+
* `generate()`) resolves them from the raw spec and threads the map
|
|
21
|
+
* here. Empty / missing entries → no auto-auth wiring for that op.
|
|
22
|
+
*/
|
|
23
|
+
securitySchemeNames?: ReadonlyMap<string, ReadonlyArray<string>>;
|
|
24
|
+
}
|
|
25
|
+
export interface OperationsResult {
|
|
26
|
+
decls: KtDecl[];
|
|
27
|
+
/** True when at least one impl class needs the `MultipartFormBody`
|
|
28
|
+
* helper. The orchestrator uses this to decide whether to emit the
|
|
29
|
+
* runtime file. */
|
|
30
|
+
needsMultipart: boolean;
|
|
31
|
+
/** True when at least one op declares `security` requirements. The
|
|
32
|
+
* orchestrator uses this to decide whether to emit `Auth.kt` /
|
|
33
|
+
* `APIKeyLocation.kt` and the `auth` field on `APIClient`. */
|
|
34
|
+
needsAuth: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Translate `IR.Model.paths` into Kotlin interfaces (one per tag) and
|
|
38
|
+
* matching OkHttp + kotlinx-serialization impl classes. Inline body /
|
|
39
|
+
* response / param schemas are promoted to synthetic top-level decls
|
|
40
|
+
* in the same output array.
|
|
41
|
+
*/
|
|
42
|
+
export declare function operationsToDecls(paths: IR.PathsObject | undefined, opts?: OperationsOptions): OperationsResult;
|
|
43
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/ir/operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAI1C,OAAO,EACL,KAAK,MAAM,EAaZ,MAAM,oBAAoB,CAAC;AAO5B,MAAM,WAAW,iBAAiB;IAChC,4BAA4B;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACxC,8DAA8D;IAC9D,eAAe,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,MAAM,CAAC;IACpD,6DAA6D;IAC7D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;CAClE;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;wBAEoB;IACpB,cAAc,EAAE,OAAO,CAAC;IACxB;;mEAE+D;IAC/D,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,EAAE,CAAC,WAAW,GAAG,SAAS,EACjC,IAAI,GAAE,iBAAsB,GAC3B,gBAAgB,CAqDlB"}
|