@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.
Files changed (307) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +259 -0
  3. package/dist/generate.d.ts +41 -0
  4. package/dist/generate.d.ts.map +1 -0
  5. package/dist/generate.js +64 -0
  6. package/dist/generate.js.map +1 -0
  7. package/dist/index.d.ts +6 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +6 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/ir/constants.d.ts +6 -0
  12. package/dist/ir/constants.d.ts.map +1 -0
  13. package/dist/ir/constants.js +6 -0
  14. package/dist/ir/constants.js.map +1 -0
  15. package/dist/ir/identifiers.d.ts +23 -0
  16. package/dist/ir/identifiers.d.ts.map +1 -0
  17. package/dist/ir/identifiers.js +71 -0
  18. package/dist/ir/identifiers.js.map +1 -0
  19. package/dist/ir/impl/body.d.ts +30 -0
  20. package/dist/ir/impl/body.d.ts.map +1 -0
  21. package/dist/ir/impl/body.js +116 -0
  22. package/dist/ir/impl/body.js.map +1 -0
  23. package/dist/ir/impl/decode.d.ts +14 -0
  24. package/dist/ir/impl/decode.d.ts.map +1 -0
  25. package/dist/ir/impl/decode.js +110 -0
  26. package/dist/ir/impl/decode.js.map +1 -0
  27. package/dist/ir/impl/headers.d.ts +8 -0
  28. package/dist/ir/impl/headers.d.ts.map +1 -0
  29. package/dist/ir/impl/headers.js +22 -0
  30. package/dist/ir/impl/headers.js.map +1 -0
  31. package/dist/ir/impl/index.d.ts +23 -0
  32. package/dist/ir/impl/index.d.ts.map +1 -0
  33. package/dist/ir/impl/index.js +141 -0
  34. package/dist/ir/impl/index.js.map +1 -0
  35. package/dist/ir/impl/request.d.ts +14 -0
  36. package/dist/ir/impl/request.d.ts.map +1 -0
  37. package/dist/ir/impl/request.js +25 -0
  38. package/dist/ir/impl/request.js.map +1 -0
  39. package/dist/ir/impl/serializer.d.ts +20 -0
  40. package/dist/ir/impl/serializer.d.ts.map +1 -0
  41. package/dist/ir/impl/serializer.js +62 -0
  42. package/dist/ir/impl/serializer.js.map +1 -0
  43. package/dist/ir/impl/url.d.ts +16 -0
  44. package/dist/ir/impl/url.d.ts.map +1 -0
  45. package/dist/ir/impl/url.js +77 -0
  46. package/dist/ir/impl/url.js.map +1 -0
  47. package/dist/ir/index.d.ts +4 -0
  48. package/dist/ir/index.d.ts.map +1 -0
  49. package/dist/ir/index.js +3 -0
  50. package/dist/ir/index.js.map +1 -0
  51. package/dist/ir/operation/body.d.ts +18 -0
  52. package/dist/ir/operation/body.d.ts.map +1 -0
  53. package/dist/ir/operation/body.js +51 -0
  54. package/dist/ir/operation/body.js.map +1 -0
  55. package/dist/ir/operation/index.d.ts +7 -0
  56. package/dist/ir/operation/index.d.ts.map +1 -0
  57. package/dist/ir/operation/index.js +5 -0
  58. package/dist/ir/operation/index.js.map +1 -0
  59. package/dist/ir/operation/params.d.ts +16 -0
  60. package/dist/ir/operation/params.d.ts.map +1 -0
  61. package/dist/ir/operation/params.js +28 -0
  62. package/dist/ir/operation/params.js.map +1 -0
  63. package/dist/ir/operation/response.d.ts +26 -0
  64. package/dist/ir/operation/response.d.ts.map +1 -0
  65. package/dist/ir/operation/response.js +58 -0
  66. package/dist/ir/operation/response.js.map +1 -0
  67. package/dist/ir/operation/signature.d.ts +32 -0
  68. package/dist/ir/operation/signature.d.ts.map +1 -0
  69. package/dist/ir/operation/signature.js +53 -0
  70. package/dist/ir/operation/signature.js.map +1 -0
  71. package/dist/ir/operations.d.ts +43 -0
  72. package/dist/ir/operations.d.ts.map +1 -0
  73. package/dist/ir/operations.js +124 -0
  74. package/dist/ir/operations.js.map +1 -0
  75. package/dist/ir/runtime/index.d.ts +3 -0
  76. package/dist/ir/runtime/index.d.ts.map +1 -0
  77. package/dist/ir/runtime/index.js +2 -0
  78. package/dist/ir/runtime/index.js.map +1 -0
  79. package/dist/ir/runtime/templates.d.ts +31 -0
  80. package/dist/ir/runtime/templates.d.ts.map +1 -0
  81. package/dist/ir/runtime/templates.js +431 -0
  82. package/dist/ir/runtime/templates.js.map +1 -0
  83. package/dist/ir/schema.d.ts +11 -0
  84. package/dist/ir/schema.d.ts.map +1 -0
  85. package/dist/ir/schema.js +51 -0
  86. package/dist/ir/schema.js.map +1 -0
  87. package/dist/ir/type/context.d.ts +4 -0
  88. package/dist/ir/type/context.d.ts.map +1 -0
  89. package/dist/ir/type/context.js +2 -0
  90. package/dist/ir/type/context.js.map +1 -0
  91. package/dist/ir/type/index.d.ts +27 -0
  92. package/dist/ir/type/index.d.ts.map +1 -0
  93. package/dist/ir/type/index.js +35 -0
  94. package/dist/ir/type/index.js.map +1 -0
  95. package/dist/ir/type/primitive.d.ts +9 -0
  96. package/dist/ir/type/primitive.d.ts.map +1 -0
  97. package/dist/ir/type/primitive.js +50 -0
  98. package/dist/ir/type/primitive.js.map +1 -0
  99. package/dist/ir/type/property-naming.d.ts +26 -0
  100. package/dist/ir/type/property-naming.d.ts.map +1 -0
  101. package/dist/ir/type/property-naming.js +27 -0
  102. package/dist/ir/type/property-naming.js.map +1 -0
  103. package/dist/ir/type-ops.d.ts +13 -0
  104. package/dist/ir/type-ops.d.ts.map +1 -0
  105. package/dist/ir/type-ops.js +80 -0
  106. package/dist/ir/type-ops.js.map +1 -0
  107. package/dist/kt-compiler/decl/class.d.ts +6 -0
  108. package/dist/kt-compiler/decl/class.d.ts.map +1 -0
  109. package/dist/kt-compiler/decl/class.js +38 -0
  110. package/dist/kt-compiler/decl/class.js.map +1 -0
  111. package/dist/kt-compiler/decl/dataClass.d.ts +3 -0
  112. package/dist/kt-compiler/decl/dataClass.d.ts.map +1 -0
  113. package/dist/kt-compiler/decl/dataClass.js +18 -0
  114. package/dist/kt-compiler/decl/dataClass.js.map +1 -0
  115. package/dist/kt-compiler/decl/enum.d.ts +3 -0
  116. package/dist/kt-compiler/decl/enum.d.ts.map +1 -0
  117. package/dist/kt-compiler/decl/enum.js +32 -0
  118. package/dist/kt-compiler/decl/enum.js.map +1 -0
  119. package/dist/kt-compiler/decl/fun.d.ts +11 -0
  120. package/dist/kt-compiler/decl/fun.d.ts.map +1 -0
  121. package/dist/kt-compiler/decl/fun.js +69 -0
  122. package/dist/kt-compiler/decl/fun.js.map +1 -0
  123. package/dist/kt-compiler/decl/index.d.ts +13 -0
  124. package/dist/kt-compiler/decl/index.d.ts.map +1 -0
  125. package/dist/kt-compiler/decl/index.js +39 -0
  126. package/dist/kt-compiler/decl/index.js.map +1 -0
  127. package/dist/kt-compiler/decl/interface.d.ts +3 -0
  128. package/dist/kt-compiler/decl/interface.d.ts.map +1 -0
  129. package/dist/kt-compiler/decl/interface.js +15 -0
  130. package/dist/kt-compiler/decl/interface.js.map +1 -0
  131. package/dist/kt-compiler/decl/object.d.ts +3 -0
  132. package/dist/kt-compiler/decl/object.d.ts.map +1 -0
  133. package/dist/kt-compiler/decl/object.js +19 -0
  134. package/dist/kt-compiler/decl/object.js.map +1 -0
  135. package/dist/kt-compiler/decl/prop.d.ts +20 -0
  136. package/dist/kt-compiler/decl/prop.d.ts.map +1 -0
  137. package/dist/kt-compiler/decl/prop.js +42 -0
  138. package/dist/kt-compiler/decl/prop.js.map +1 -0
  139. package/dist/kt-compiler/decl/sealedClass.d.ts +3 -0
  140. package/dist/kt-compiler/decl/sealedClass.d.ts.map +1 -0
  141. package/dist/kt-compiler/decl/sealedClass.js +32 -0
  142. package/dist/kt-compiler/decl/sealedClass.js.map +1 -0
  143. package/dist/kt-compiler/decl/topLevel.d.ts +3 -0
  144. package/dist/kt-compiler/decl/topLevel.d.ts.map +1 -0
  145. package/dist/kt-compiler/decl/topLevel.js +5 -0
  146. package/dist/kt-compiler/decl/topLevel.js.map +1 -0
  147. package/dist/kt-compiler/decl/typeAlias.d.ts +3 -0
  148. package/dist/kt-compiler/decl/typeAlias.d.ts.map +1 -0
  149. package/dist/kt-compiler/decl/typeAlias.js +6 -0
  150. package/dist/kt-compiler/decl/typeAlias.js.map +1 -0
  151. package/dist/kt-compiler/expr.d.ts +4 -0
  152. package/dist/kt-compiler/expr.d.ts.map +1 -0
  153. package/dist/kt-compiler/expr.js +123 -0
  154. package/dist/kt-compiler/expr.js.map +1 -0
  155. package/dist/kt-compiler/format.d.ts +20 -0
  156. package/dist/kt-compiler/format.d.ts.map +1 -0
  157. package/dist/kt-compiler/format.js +27 -0
  158. package/dist/kt-compiler/format.js.map +1 -0
  159. package/dist/kt-compiler/index.d.ts +7 -0
  160. package/dist/kt-compiler/index.d.ts.map +1 -0
  161. package/dist/kt-compiler/index.js +24 -0
  162. package/dist/kt-compiler/index.js.map +1 -0
  163. package/dist/kt-compiler/stmt.d.ts +4 -0
  164. package/dist/kt-compiler/stmt.d.ts.map +1 -0
  165. package/dist/kt-compiler/stmt.js +72 -0
  166. package/dist/kt-compiler/stmt.js.map +1 -0
  167. package/dist/kt-compiler/type.d.ts +3 -0
  168. package/dist/kt-compiler/type.d.ts.map +1 -0
  169. package/dist/kt-compiler/type.js +28 -0
  170. package/dist/kt-compiler/type.js.map +1 -0
  171. package/dist/kt-dsl/decl/class.d.ts +50 -0
  172. package/dist/kt-dsl/decl/class.d.ts.map +1 -0
  173. package/dist/kt-dsl/decl/class.js +33 -0
  174. package/dist/kt-dsl/decl/class.js.map +1 -0
  175. package/dist/kt-dsl/decl/dataClass.d.ts +36 -0
  176. package/dist/kt-dsl/decl/dataClass.d.ts.map +1 -0
  177. package/dist/kt-dsl/decl/dataClass.js +25 -0
  178. package/dist/kt-dsl/decl/dataClass.js.map +1 -0
  179. package/dist/kt-dsl/decl/enum.d.ts +60 -0
  180. package/dist/kt-dsl/decl/enum.d.ts.map +1 -0
  181. package/dist/kt-dsl/decl/enum.js +38 -0
  182. package/dist/kt-dsl/decl/enum.js.map +1 -0
  183. package/dist/kt-dsl/decl/index.d.ts +11 -0
  184. package/dist/kt-dsl/decl/index.d.ts.map +1 -0
  185. package/dist/kt-dsl/decl/index.js +11 -0
  186. package/dist/kt-dsl/decl/index.js.map +1 -0
  187. package/dist/kt-dsl/decl/interface.d.ts +33 -0
  188. package/dist/kt-dsl/decl/interface.d.ts.map +1 -0
  189. package/dist/kt-dsl/decl/interface.js +24 -0
  190. package/dist/kt-dsl/decl/interface.js.map +1 -0
  191. package/dist/kt-dsl/decl/object.d.ts +34 -0
  192. package/dist/kt-dsl/decl/object.d.ts.map +1 -0
  193. package/dist/kt-dsl/decl/object.js +24 -0
  194. package/dist/kt-dsl/decl/object.js.map +1 -0
  195. package/dist/kt-dsl/decl/prop.d.ts +47 -0
  196. package/dist/kt-dsl/decl/prop.d.ts.map +1 -0
  197. package/dist/kt-dsl/decl/prop.js +28 -0
  198. package/dist/kt-dsl/decl/prop.js.map +1 -0
  199. package/dist/kt-dsl/decl/sealedClass.d.ts +68 -0
  200. package/dist/kt-dsl/decl/sealedClass.d.ts.map +1 -0
  201. package/dist/kt-dsl/decl/sealedClass.js +52 -0
  202. package/dist/kt-dsl/decl/sealedClass.js.map +1 -0
  203. package/dist/kt-dsl/decl/topLevel.d.ts +19 -0
  204. package/dist/kt-dsl/decl/topLevel.d.ts.map +1 -0
  205. package/dist/kt-dsl/decl/topLevel.js +17 -0
  206. package/dist/kt-dsl/decl/topLevel.js.map +1 -0
  207. package/dist/kt-dsl/decl/typeAlias.d.ts +23 -0
  208. package/dist/kt-dsl/decl/typeAlias.d.ts.map +1 -0
  209. package/dist/kt-dsl/decl/typeAlias.js +18 -0
  210. package/dist/kt-dsl/decl/typeAlias.js.map +1 -0
  211. package/dist/kt-dsl/decl/types.d.ts +10 -0
  212. package/dist/kt-dsl/decl/types.d.ts.map +1 -0
  213. package/dist/kt-dsl/decl/types.js +2 -0
  214. package/dist/kt-dsl/decl/types.js.map +1 -0
  215. package/dist/kt-dsl/expr/access.d.ts +48 -0
  216. package/dist/kt-dsl/expr/access.d.ts.map +1 -0
  217. package/dist/kt-dsl/expr/access.js +59 -0
  218. package/dist/kt-dsl/expr/access.js.map +1 -0
  219. package/dist/kt-dsl/expr/call.d.ts +38 -0
  220. package/dist/kt-dsl/expr/call.d.ts.map +1 -0
  221. package/dist/kt-dsl/expr/call.js +38 -0
  222. package/dist/kt-dsl/expr/call.js.map +1 -0
  223. package/dist/kt-dsl/expr/index.d.ts +7 -0
  224. package/dist/kt-dsl/expr/index.d.ts.map +1 -0
  225. package/dist/kt-dsl/expr/index.js +7 -0
  226. package/dist/kt-dsl/expr/index.js.map +1 -0
  227. package/dist/kt-dsl/expr/literal.d.ts +100 -0
  228. package/dist/kt-dsl/expr/literal.d.ts.map +1 -0
  229. package/dist/kt-dsl/expr/literal.js +108 -0
  230. package/dist/kt-dsl/expr/literal.js.map +1 -0
  231. package/dist/kt-dsl/expr/misc.d.ts +45 -0
  232. package/dist/kt-dsl/expr/misc.d.ts.map +1 -0
  233. package/dist/kt-dsl/expr/misc.js +63 -0
  234. package/dist/kt-dsl/expr/misc.js.map +1 -0
  235. package/dist/kt-dsl/expr/op.d.ts +25 -0
  236. package/dist/kt-dsl/expr/op.d.ts.map +1 -0
  237. package/dist/kt-dsl/expr/op.js +24 -0
  238. package/dist/kt-dsl/expr/op.js.map +1 -0
  239. package/dist/kt-dsl/expr/types.d.ts +93 -0
  240. package/dist/kt-dsl/expr/types.d.ts.map +1 -0
  241. package/dist/kt-dsl/expr/types.js +2 -0
  242. package/dist/kt-dsl/expr/types.js.map +1 -0
  243. package/dist/kt-dsl/file.d.ts +14 -0
  244. package/dist/kt-dsl/file.d.ts.map +1 -0
  245. package/dist/kt-dsl/file.js +9 -0
  246. package/dist/kt-dsl/file.js.map +1 -0
  247. package/dist/kt-dsl/fun.d.ts +73 -0
  248. package/dist/kt-dsl/fun.d.ts.map +1 -0
  249. package/dist/kt-dsl/fun.js +50 -0
  250. package/dist/kt-dsl/fun.js.map +1 -0
  251. package/dist/kt-dsl/index.d.ts +8 -0
  252. package/dist/kt-dsl/index.d.ts.map +1 -0
  253. package/dist/kt-dsl/index.js +8 -0
  254. package/dist/kt-dsl/index.js.map +1 -0
  255. package/dist/kt-dsl/stmt/binding.d.ts +56 -0
  256. package/dist/kt-dsl/stmt/binding.d.ts.map +1 -0
  257. package/dist/kt-dsl/stmt/binding.js +70 -0
  258. package/dist/kt-dsl/stmt/binding.js.map +1 -0
  259. package/dist/kt-dsl/stmt/control.d.ts +80 -0
  260. package/dist/kt-dsl/stmt/control.d.ts.map +1 -0
  261. package/dist/kt-dsl/stmt/control.js +77 -0
  262. package/dist/kt-dsl/stmt/control.js.map +1 -0
  263. package/dist/kt-dsl/stmt/index.d.ts +4 -0
  264. package/dist/kt-dsl/stmt/index.d.ts.map +1 -0
  265. package/dist/kt-dsl/stmt/index.js +4 -0
  266. package/dist/kt-dsl/stmt/index.js.map +1 -0
  267. package/dist/kt-dsl/stmt/types.d.ts +62 -0
  268. package/dist/kt-dsl/stmt/types.d.ts.map +1 -0
  269. package/dist/kt-dsl/stmt/types.js +2 -0
  270. package/dist/kt-dsl/stmt/types.js.map +1 -0
  271. package/dist/kt-dsl/type/builders.d.ts +75 -0
  272. package/dist/kt-dsl/type/builders.d.ts.map +1 -0
  273. package/dist/kt-dsl/type/builders.js +83 -0
  274. package/dist/kt-dsl/type/builders.js.map +1 -0
  275. package/dist/kt-dsl/type/index.d.ts +3 -0
  276. package/dist/kt-dsl/type/index.d.ts.map +1 -0
  277. package/dist/kt-dsl/type/index.js +3 -0
  278. package/dist/kt-dsl/type/index.js.map +1 -0
  279. package/dist/kt-dsl/type/types.d.ts +25 -0
  280. package/dist/kt-dsl/type/types.d.ts.map +1 -0
  281. package/dist/kt-dsl/type/types.js +2 -0
  282. package/dist/kt-dsl/type/types.js.map +1 -0
  283. package/dist/kt-dsl/visibility.d.ts +2 -0
  284. package/dist/kt-dsl/visibility.d.ts.map +1 -0
  285. package/dist/kt-dsl/visibility.js +2 -0
  286. package/dist/kt-dsl/visibility.js.map +1 -0
  287. package/dist/project/build.d.ts +33 -0
  288. package/dist/project/build.d.ts.map +1 -0
  289. package/dist/project/build.js +73 -0
  290. package/dist/project/build.js.map +1 -0
  291. package/dist/project/gradle.d.ts +48 -0
  292. package/dist/project/gradle.d.ts.map +1 -0
  293. package/dist/project/gradle.js +46 -0
  294. package/dist/project/gradle.js.map +1 -0
  295. package/dist/project/imports.d.ts +21 -0
  296. package/dist/project/imports.d.ts.map +1 -0
  297. package/dist/project/imports.js +162 -0
  298. package/dist/project/imports.js.map +1 -0
  299. package/dist/project/index.d.ts +6 -0
  300. package/dist/project/index.d.ts.map +1 -0
  301. package/dist/project/index.js +3 -0
  302. package/dist/project/index.js.map +1 -0
  303. package/dist/project/layout.d.ts +30 -0
  304. package/dist/project/layout.d.ts.map +1 -0
  305. package/dist/project/layout.js +57 -0
  306. package/dist/project/layout.js.map +1 -0
  307. package/package.json +76 -0
@@ -0,0 +1,51 @@
1
+ import { refName } from "@ir-kit/openapi-core";
2
+ import { ktAny, ktMap, ktRef, ktString, ktTypeAlias, } from "../kt-dsl/index.js";
3
+ import { buildEnumFromIR, buildStruct, schemaToType } from "./type/index.js";
4
+ /**
5
+ * Translate `IR.Model.components.schemas` into Kotlin decls. Object schemas
6
+ * with properties become `@Serializable` data classes; `enum` schemas
7
+ * become `String`-raw `@Serializable` enums; primitives/arrays/unions
8
+ * become typealiases. Inline nested objects/enums are promoted to
9
+ * top-level synthetic decls (`Owner_PropertyName`).
10
+ */
11
+ export function schemasToDecls(schemas) {
12
+ const decls = [];
13
+ const emit = (d) => decls.push(d);
14
+ for (const [name, schema] of Object.entries(schemas)) {
15
+ if (schema.$ref) {
16
+ decls.push(ktTypeAlias({ name, type: ktRef(refName(schema.$ref)) }));
17
+ continue;
18
+ }
19
+ if (schema.type === "enum") {
20
+ buildEnumFromIR(name, schema, emit);
21
+ continue;
22
+ }
23
+ if (schema.type === "object" && schema.properties) {
24
+ decls.push(buildStruct(name, schema, { emit }));
25
+ continue;
26
+ }
27
+ if (schema.type === "object") {
28
+ const ap = schema.additionalProperties;
29
+ const sealed = ap === false ||
30
+ (typeof ap === "object" &&
31
+ (ap.type === "void" ||
32
+ ap.type === "never" ||
33
+ ap.type === "undefined"));
34
+ if (sealed) {
35
+ decls.push(buildStruct(name, schema, { emit }));
36
+ continue;
37
+ }
38
+ const valueType = ap && typeof ap === "object"
39
+ ? schemaToType(ap, { emit, ownerName: name, propPath: [] })
40
+ : ktAny;
41
+ decls.push(ktTypeAlias({ name, type: ktMap(ktString, valueType) }));
42
+ continue;
43
+ }
44
+ decls.push(ktTypeAlias({
45
+ name,
46
+ type: schemaToType(schema, { emit, ownerName: name, propPath: [] }),
47
+ }));
48
+ }
49
+ return decls;
50
+ }
51
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/ir/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAEL,KAAK,EACL,KAAK,EACL,KAAK,EACL,QAAQ,EACR,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE7E;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAwC;IAExC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE1C,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACrD,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAChB,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACrE,SAAS;QACX,CAAC;QACD,IAAI,MAAM,CA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,YAAY,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;SACpE,CAAC,CACH,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { TypeCtx as IRTypeCtx } from "@ir-kit/openapi";
2
+ import type { KtDecl } from "../../kt-dsl/decl/types.js";
3
+ export type TypeCtx = IRTypeCtx<KtDecl>;
4
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/ir/type/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,MAAM,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/ir/type/context.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import type { IR } from "@hey-api/shared";
2
+ import type { KtDecl } from "../../kt-dsl/decl/types.js";
3
+ import type { KtType } from "../../kt-dsl/index.js";
4
+ import type { TypeCtx } from "./context.js";
5
+ export type { TypeCtx } from "./context.js";
6
+ /**
7
+ * Top-level dispatch from `IR.SchemaObject` to a `KtType`. Side-effects:
8
+ * inline objects/enums get promoted to top-level decls via `ctx.emit`.
9
+ * Thin wrapper over the shared `@ir-kit/openapi.schemaToType` with the
10
+ * Kotlin ops record bound.
11
+ */
12
+ export declare function schemaToType(schema: IR.SchemaObject, ctx: TypeCtx): KtType;
13
+ /**
14
+ * Build a top-level Kotlin data class from an object-shaped IR schema
15
+ * — used by `schemasToDecls` for `components.schemas` entries where
16
+ * the name is given. Returns the decl; caller decides whether to emit.
17
+ */
18
+ export declare function buildStruct(name: string, schema: IR.SchemaObject, ctx: {
19
+ emit: (d: KtDecl) => void;
20
+ }): KtDecl;
21
+ /**
22
+ * Build a top-level Kotlin enum (`enum class(val raw: String)`) or
23
+ * integer-degrade typealias from an enum-typed IR schema. Decls are
24
+ * pushed via `emit`; a ref to the named type is returned.
25
+ */
26
+ export declare function buildEnumFromIR(name: string, schema: IR.SchemaObject, emit: (d: KtDecl) => void): KtType;
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ir/type/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAQ1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAE1E;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,EAAE,CAAC,YAAY,EACvB,GAAG,EAAE;IAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,GACjC,MAAM,CAUR;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,EAAE,CAAC,YAAY,EACvB,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,GACxB,MAAM,CAMR"}
@@ -0,0 +1,35 @@
1
+ import { classifyEnumLiterals, iterateObjectProperties, schemaToType as sharedSchemaToType, } from "@ir-kit/openapi";
2
+ import { getEnumLiterals } from "@ir-kit/openapi-tools";
3
+ import { ktOps } from "../type-ops.js";
4
+ /**
5
+ * Top-level dispatch from `IR.SchemaObject` to a `KtType`. Side-effects:
6
+ * inline objects/enums get promoted to top-level decls via `ctx.emit`.
7
+ * Thin wrapper over the shared `@ir-kit/openapi.schemaToType` with the
8
+ * Kotlin ops record bound.
9
+ */
10
+ export function schemaToType(schema, ctx) {
11
+ return sharedSchemaToType(schema, ctx, ktOps);
12
+ }
13
+ /**
14
+ * Build a top-level Kotlin data class from an object-shaped IR schema
15
+ * — used by `schemasToDecls` for `components.schemas` entries where
16
+ * the name is given. Returns the decl; caller decides whether to emit.
17
+ */
18
+ export function buildStruct(name, schema, ctx) {
19
+ const properties = Array.from(iterateObjectProperties(schema));
20
+ const dispatch = (s, c) => sharedSchemaToType(s, c, ktOps);
21
+ return ktOps.buildStructDecl(name, properties, { emit: ctx.emit, ownerName: name, propPath: [] }, dispatch);
22
+ }
23
+ /**
24
+ * Build a top-level Kotlin enum (`enum class(val raw: String)`) or
25
+ * integer-degrade typealias from an enum-typed IR schema. Decls are
26
+ * pushed via `emit`; a ref to the named type is returned.
27
+ */
28
+ export function buildEnumFromIR(name, schema, emit) {
29
+ const rawValues = getEnumLiterals(schema);
30
+ const kind = classifyEnumLiterals(rawValues, name);
31
+ if (kind === "integer")
32
+ return ktOps.emitIntegerEnum(name, rawValues, emit);
33
+ return ktOps.emitStringEnum(name, rawValues, emit);
34
+ }
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ir/type/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,YAAY,IAAI,kBAAkB,GACnC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAKvC;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAuB,EAAE,GAAY;IAChE,OAAO,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,IAAY,EACZ,MAAuB,EACvB,GAAkC;IAElC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/D,MAAM,QAAQ,GAAG,CAAC,CAAkB,EAAE,CAAU,EAAU,EAAE,CAC1D,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,eAAe,CAC1B,IAAI,EACJ,UAAU,EACV,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,EACjD,QAAQ,CACT,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAY,EACZ,MAAuB,EACvB,IAAyB;IAEzB,MAAM,SAAS,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,oBAAoB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACnD,IAAI,IAAI,KAAK,SAAS;QACpB,OAAO,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE,SAAqB,EAAE,IAAI,CAAC,CAAC;IAClE,OAAO,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,SAAqB,EAAE,IAAI,CAAC,CAAC;AACjE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { IR } from "@hey-api/shared";
2
+ import { type KtType } from "../../kt-dsl/index.js";
3
+ /**
4
+ * Map a primitive `IR.SchemaObject.type` (with optional `format`) to the
5
+ * matching Kotlin type. Returns `undefined` for non-primitive types so
6
+ * the dispatcher can fall through.
7
+ */
8
+ export declare function typeForPrimitive(s: IR.SchemaObject): KtType | undefined;
9
+ //# sourceMappingURL=primitive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitive.d.ts","sourceRoot":"","sources":["../../../src/ir/type/primitive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EACL,KAAK,MAAM,EASZ,MAAM,uBAAuB,CAAC;AA8B/B;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,GAAG,MAAM,GAAG,SAAS,CAcvE"}
@@ -0,0 +1,50 @@
1
+ import { ktBoolean, ktByteArray, ktDouble, ktFloat, ktInt, ktLong, ktRef, ktString, } from "../../kt-dsl/index.js";
2
+ /**
3
+ * OpenAPI string `format` → Kotlin / kotlinx-datetime / `String` type.
4
+ * Unknown formats fall back to `String`.
5
+ *
6
+ * - `date-time` → `Instant` (kotlinx-datetime; built-in
7
+ * `@Serializable` serializer).
8
+ * - `date` → `LocalDate` (kotlinx-datetime, same).
9
+ * - `uuid` / `uri` / `url` → `String`. kotlinx-serialization has no
10
+ * built-in `UUID` / `URL` serializers, so wire
11
+ * compat wins over type safety. Consumers who
12
+ * want `java.util.UUID` can layer a custom
13
+ * `@Contextual` serializer on top of the field.
14
+ * - `binary` / `byte` → `ByteArray` (matches multipart field handling).
15
+ */
16
+ function typeForStringFormat(format) {
17
+ switch (format) {
18
+ case "date-time":
19
+ return ktRef("Instant");
20
+ case "date":
21
+ return ktRef("LocalDate");
22
+ case "binary":
23
+ case "byte":
24
+ return ktByteArray;
25
+ default:
26
+ return ktString;
27
+ }
28
+ }
29
+ /**
30
+ * Map a primitive `IR.SchemaObject.type` (with optional `format`) to the
31
+ * matching Kotlin type. Returns `undefined` for non-primitive types so
32
+ * the dispatcher can fall through.
33
+ */
34
+ export function typeForPrimitive(s) {
35
+ switch (s.type) {
36
+ case "string":
37
+ return typeForStringFormat(s.format);
38
+ case "integer":
39
+ if (s.format === "int64")
40
+ return ktLong;
41
+ return ktInt;
42
+ case "number":
43
+ return s.format === "float" ? ktFloat : ktDouble;
44
+ case "boolean":
45
+ return ktBoolean;
46
+ default:
47
+ return undefined;
48
+ }
49
+ }
50
+ //# sourceMappingURL=primitive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitive.js","sourceRoot":"","sources":["../../../src/ir/type/primitive.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,SAAS,EACT,WAAW,EACX,QAAQ,EACR,OAAO,EACP,KAAK,EACL,MAAM,EACN,KAAK,EACL,QAAQ,GACT,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;;GAaG;AACH,SAAS,mBAAmB,CAAC,MAA0B;IACrD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,WAAW;YACd,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC;QAC1B,KAAK,MAAM;YACT,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC;QAC5B,KAAK,QAAQ,CAAC;QACd,KAAK,MAAM;YACT,OAAO,WAAW,CAAC;QACrB;YACE,OAAO,QAAQ,CAAC;IACpB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IACjD,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACvC,KAAK,SAAS;YACZ,IAAI,CAAC,CAAC,MAAM,KAAK,OAAO;gBAAE,OAAO,MAAM,CAAC;YACxC,OAAO,KAAK,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,CAAC,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;QACnD,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
@@ -0,0 +1,26 @@
1
+ export interface PropertyName {
2
+ /** The original key as it appears in the OpenAPI schema / JSON wire format. */
3
+ jsonKey: string;
4
+ /** The idiomatic Kotlin identifier the generated data class uses (already
5
+ * backtick-escaped if it would collide with a reserved keyword). */
6
+ kotlinName: string;
7
+ /** True when the kotlin name differs from the JSON key — emit
8
+ * `@SerialName(jsonKey)` on the property. */
9
+ renamed: boolean;
10
+ }
11
+ /**
12
+ * Translate an OpenAPI property name into a Kotlin identifier following
13
+ * lower-camelCase conventions. When the result differs from the JSON
14
+ * key the caller is responsible for emitting a `@SerialName` annotation
15
+ * to preserve wire compatibility.
16
+ *
17
+ * first_name → firstName (renamed)
18
+ * first-name → firstName (renamed)
19
+ * firstName → firstName (no rename)
20
+ * id → id (no rename)
21
+ * class → `class` (no rename, but escaped — caller still
22
+ * emits `@SerialName("class")` to avoid
23
+ * the backticks being part of the wire)
24
+ */
25
+ export declare function propertyName(jsonKey: string): PropertyName;
26
+ //# sourceMappingURL=property-naming.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property-naming.d.ts","sourceRoot":"","sources":["../../../src/ir/type/property-naming.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC;IAChB;yEACqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB;kDAC8C;IAC9C,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAS1D"}
@@ -0,0 +1,27 @@
1
+ import { camel } from "@ir-kit/codegen-core";
2
+ import { paramIdent } from "../identifiers.js";
3
+ /**
4
+ * Translate an OpenAPI property name into a Kotlin identifier following
5
+ * lower-camelCase conventions. When the result differs from the JSON
6
+ * key the caller is responsible for emitting a `@SerialName` annotation
7
+ * to preserve wire compatibility.
8
+ *
9
+ * first_name → firstName (renamed)
10
+ * first-name → firstName (renamed)
11
+ * firstName → firstName (no rename)
12
+ * id → id (no rename)
13
+ * class → `class` (no rename, but escaped — caller still
14
+ * emits `@SerialName("class")` to avoid
15
+ * the backticks being part of the wire)
16
+ */
17
+ export function propertyName(jsonKey) {
18
+ const camelName = camel(jsonKey);
19
+ const kotlinName = paramIdent(jsonKey);
20
+ // Backtick-escaping for reserved keywords doesn't constitute a rename
21
+ // for serialization purposes (the wire still uses the bare name), but
22
+ // we still emit `@SerialName` because kotlinx-serialization sees the
23
+ // backticked form as a distinct identifier.
24
+ const renamed = camelName !== jsonKey;
25
+ return { jsonKey, kotlinName, renamed };
26
+ }
27
+ //# sourceMappingURL=property-naming.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property-naming.js","sourceRoot":"","sources":["../../../src/ir/type/property-naming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAa/C;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACvC,sEAAsE;IACtE,sEAAsE;IACtE,qEAAqE;IACrE,4CAA4C;IAC5C,MAAM,OAAO,GAAG,SAAS,KAAK,OAAO,CAAC;IACtC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type SchemaToTypeOps } from "@ir-kit/openapi";
2
+ import type { KtDecl } from "../kt-dsl/decl/types.js";
3
+ import { type KtType } from "../kt-dsl/index.js";
4
+ /**
5
+ * Kotlin's plug into the shared `schemaToType` dispatcher. Per-target
6
+ * choices: `kotlinx-serialization` `@Serializable` annotations and
7
+ * `@SerialName` rewrites for renamed JSON keys; `Map<String, V>` for
8
+ * additionalProperties; `enum class(val raw: String)` for string
9
+ * enums and `typealias = Int` for integer enums (kotlinx's enum
10
+ * support only round-trips strings).
11
+ */
12
+ export declare const ktOps: SchemaToTypeOps<KtType, KtDecl>;
13
+ //# sourceMappingURL=type-ops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-ops.d.ts","sourceRoot":"","sources":["../../src/ir/type-ops.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EACL,KAAK,MAAM,EAeZ,MAAM,oBAAoB,CAAC;AAK5B;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAAE,eAAe,CAAC,MAAM,EAAE,MAAM,CAuEjD,CAAC"}
@@ -0,0 +1,80 @@
1
+ import { synthName } from "@ir-kit/codegen-core";
2
+ import { assertNoEnumCollisions } from "@ir-kit/openapi";
3
+ import { ktAnnotation, ktAny, ktDataClass, ktEnum, ktEnumEntry, ktInt, ktList, ktMap, ktNullable, ktProp, ktRef, ktString, ktTypeAlias, ktUnit, } from "../kt-dsl/index.js";
4
+ import { enumEntryIdent } from "./identifiers.js";
5
+ import { typeForPrimitive } from "./type/primitive.js";
6
+ import { propertyName } from "./type/property-naming.js";
7
+ /**
8
+ * Kotlin's plug into the shared `schemaToType` dispatcher. Per-target
9
+ * choices: `kotlinx-serialization` `@Serializable` annotations and
10
+ * `@SerialName` rewrites for renamed JSON keys; `Map<String, V>` for
11
+ * additionalProperties; `enum class(val raw: String)` for string
12
+ * enums and `typealias = Int` for integer enums (kotlinx's enum
13
+ * support only round-trips strings).
14
+ */
15
+ export const ktOps = {
16
+ refType: ktRef,
17
+ arrayType: ktList,
18
+ mapType: (value) => ktMap(ktString, value),
19
+ voidType: () => ktUnit,
20
+ anyType: () => ktAny,
21
+ // `null`-typed primitive → `Any?`.
22
+ nullableAnyType: () => ktNullable(ktAny),
23
+ // Single non-null + nullable → wrap in nullable iff not already.
24
+ wrapForUnionSingle: (inner, nullable) => nullable && inner.kind !== "nullable" ? ktNullable(inner) : inner,
25
+ unionFallback: (nullable) => (nullable ? ktNullable(ktAny) : ktAny),
26
+ primitiveType: typeForPrimitive,
27
+ // kotlinx convention: `Owner_Property` (underscore joiner).
28
+ synthName,
29
+ buildStructDecl: (name, properties, ctx, dispatch) => {
30
+ const props = properties.map(({ jsonKey, schema: propSchema, required, propPathSegment }) => {
31
+ const naming = propertyName(jsonKey);
32
+ const t = dispatch(propSchema, {
33
+ emit: ctx.emit,
34
+ ownerName: name,
35
+ propPath: [propPathSegment],
36
+ });
37
+ const optional = !required;
38
+ const finalType = optional && t.kind !== "nullable" ? ktNullable(t) : t;
39
+ return ktProp({
40
+ name: naming.kotlinName,
41
+ type: finalType,
42
+ inPrimary: true,
43
+ default: optional ? "null" : undefined,
44
+ annotations: naming.renamed
45
+ ? [ktAnnotation("SerialName", JSON.stringify(naming.jsonKey))]
46
+ : [],
47
+ });
48
+ });
49
+ return ktDataClass({
50
+ name,
51
+ annotations: [ktAnnotation("Serializable")],
52
+ properties: props,
53
+ });
54
+ },
55
+ emitStringEnum: (name, rawValues, emit) => {
56
+ const idents = rawValues.map((raw) => ({
57
+ identifier: enumEntryIdent(raw),
58
+ raw,
59
+ }));
60
+ assertNoEnumCollisions(name, idents);
61
+ const entries = idents.map(({ identifier, raw }) => ktEnumEntry(identifier, JSON.stringify(raw), [
62
+ ktAnnotation("SerialName", JSON.stringify(raw)),
63
+ ]));
64
+ emit(ktEnum({
65
+ name,
66
+ annotations: [ktAnnotation("Serializable")],
67
+ properties: [ktProp({ name: "raw", type: ktString, inPrimary: true })],
68
+ entries,
69
+ }));
70
+ return ktRef(name);
71
+ },
72
+ // kotlinx-serialization can't round-trip integer enums via
73
+ // `@SerialName`; degrade to a typealias that preserves the wire
74
+ // shape but loses enum-value constraint at the type level.
75
+ emitIntegerEnum: (name, _rawValues, emit) => {
76
+ emit(ktTypeAlias({ name, type: ktInt }));
77
+ return ktRef(name);
78
+ },
79
+ };
80
+ //# sourceMappingURL=type-ops.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-ops.js","sourceRoot":"","sources":["../../src/ir/type-ops.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAwB,MAAM,iBAAiB,CAAC;AAG/E,OAAO,EAEL,YAAY,EACZ,KAAK,EACL,WAAW,EACX,MAAM,EACN,WAAW,EACX,KAAK,EACL,MAAM,EACN,KAAK,EACL,UAAU,EACV,MAAM,EACN,KAAK,EACL,QAAQ,EACR,WAAW,EACX,MAAM,GACP,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAoC;IACpD,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,MAAM;IACjB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC;IAC1C,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM;IACtB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK;IACpB,mCAAmC;IACnC,eAAe,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;IACxC,iEAAiE;IACjE,kBAAkB,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CACtC,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK;IACnE,aAAa,EAAE,CAAC,QAA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
+ import type { KtClass } from "../../kt-dsl/decl/class.js";
2
+ import { printType } from "../type.js";
3
+ export declare function printClass(d: KtClass): string;
4
+ /** Used by sealed-subclass lowering. */
5
+ export { printType };
6
+ //# sourceMappingURL=class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../../src/kt-compiler/decl/class.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAG1D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAiC7C;AAED,wCAAwC;AACxC,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { INDENT, superTypeTail, visibilityPrefix } from "../format.js";
2
+ import { printStmt } from "../stmt.js";
3
+ import { printType } from "../type.js";
4
+ import { printFun, printFunParam } from "./fun.js";
5
+ import { printAnnotations, printPrimaryProp, printProp } from "./prop.js";
6
+ export function printClass(d) {
7
+ const annLines = printAnnotations(d.annotations, "");
8
+ const vis = visibilityPrefix(d.visibility);
9
+ const modifiers = d.modifiers.length > 0 ? `${d.modifiers.join(" ")} ` : "";
10
+ const primaryProps = d.properties.filter((p) => p.inPrimary);
11
+ const bodyProps = d.properties.filter((p) => !p.inPrimary);
12
+ const ctorEntries = [];
13
+ for (const p of primaryProps)
14
+ ctorEntries.push(printPrimaryProp(p, INDENT));
15
+ for (const p of d.ctorParams)
16
+ ctorEntries.push(`${INDENT}${printFunParam(p)}`);
17
+ const ctor = ctorEntries.length === 0 ? "" : `(\n${ctorEntries.join(",\n")},\n)`;
18
+ const head = `${annLines}${vis}${modifiers}class ${d.name}${ctor}${superTypeTail(d.superTypes)}`;
19
+ const sections = [];
20
+ if (bodyProps.length > 0) {
21
+ sections.push(bodyProps.map((p) => printProp(p, INDENT)).join("\n"));
22
+ }
23
+ if (d.initBlock && d.initBlock.length > 0) {
24
+ const inner = d.initBlock
25
+ .map((s) => printStmt(s, INDENT + INDENT))
26
+ .join("\n");
27
+ sections.push(`${INDENT}init {\n${inner}\n${INDENT}}`);
28
+ }
29
+ if (d.funs.length > 0) {
30
+ sections.push(d.funs.map((f) => printFun(f, INDENT)).join("\n\n"));
31
+ }
32
+ if (sections.length === 0)
33
+ return head;
34
+ return `${head} {\n${sections.join("\n\n")}\n}`;
35
+ }
36
+ /** Used by sealed-subclass lowering. */
37
+ export { printType };
38
+ //# sourceMappingURL=class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../../src/kt-compiler/decl/class.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE1E,MAAM,UAAU,UAAU,CAAC,CAAU;IACnC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACrD,MAAM,GAAG,GAAG,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAE5E,MAAM,YAAY,GAAG,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC7D,MAAM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I,CAAC,IAAI,CAAC,CAAC;QACd,QAAQ,CAAC,IAAI,CAAC,GAAG,MAAM,WAAW,KAAK,KAAK,MAAM,GAAG,CAAC,CAAC;IACzD,CAAC;IACD,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,OAAO,GAAG,IAAI,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;AAClD,CAAC;AAED,wCAAwC;AACxC,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { KtDataClass } from "../../kt-dsl/decl/dataClass.js";
2
+ export declare function printDataClass(d: KtDataClass): string;
3
+ //# sourceMappingURL=dataClass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataClass.d.ts","sourceRoot":"","sources":["../../../src/kt-compiler/decl/dataClass.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAKlE,wBAAgB,cAAc,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CAarD"}
@@ -0,0 +1,18 @@
1
+ import { INDENT, superTypeTail, visibilityPrefix } from "../format.js";
2
+ import { printFun } from "./fun.js";
3
+ import { printAnnotations, printPrimaryProp } from "./prop.js";
4
+ export function printDataClass(d) {
5
+ const annLines = printAnnotations(d.annotations, "");
6
+ const vis = visibilityPrefix(d.visibility);
7
+ // Data classes carry all properties in the primary constructor.
8
+ const primaryProps = d.properties
9
+ .map((p) => printPrimaryProp({ ...p, inPrimary: true }, INDENT))
10
+ .join(",\n");
11
+ const ctor = d.properties.length === 0 ? "()" : `(\n${primaryProps},\n)`;
12
+ const head = `${annLines}${vis}data class ${d.name}${ctor}${superTypeTail(d.superTypes)}`;
13
+ if (d.funs.length === 0)
14
+ return head;
15
+ const funs = d.funs.map((f) => printFun(f, INDENT)).join("\n\n");
16
+ return `${head} {\n${funs}\n}`;
17
+ }
18
+ //# sourceMappingURL=dataClass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataClass.js","sourceRoot":"","sources":["../../../src/kt-compiler/decl/dataClass.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE/D,MAAM,UAAU,cAAc,CAAC,CAAc;IAC3C,MAAM,QAAQ,GAAG,gBAAgB,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACrD,MAAM,GAAG,GAAG,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IAC3C,gEAAgE;IAChE,MAAM,YAAY,GAAG,CAAC,CAAC,UAAU;SAC9B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;SAC/D,IAAI,CAAC,KAAK,CAAC,CAAC;IACf,MAAM,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,YAAY,MAAM,CAAC;IACzE,MAAM,IAAI,GAAG,GAAG,QAAQ,GAAG,GAAG,cAAc,CAAC,CAAC,IAAI,GAAG,IAAI,GAAG,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC;IAE1F,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACrC,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjE,OAAO,GAAG,IAAI,OAAO,IAAI,KAAK,CAAC;AACjC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { KtEnum } from "../../kt-dsl/decl/enum.js";
2
+ export declare function printEnum(d: KtEnum): string;
3
+ //# sourceMappingURL=enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../../src/kt-compiler/decl/enum.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAKxD,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAiC3C"}
@@ -0,0 +1,32 @@
1
+ import { INDENT, superTypeTail, visibilityPrefix } from "../format.js";
2
+ import { printFun } from "./fun.js";
3
+ import { printAnnotation, printAnnotations, printPrimaryProp } from "./prop.js";
4
+ export function printEnum(d) {
5
+ const annLines = printAnnotations(d.annotations, "");
6
+ const vis = visibilityPrefix(d.visibility);
7
+ const ctor = d.properties.length === 0
8
+ ? ""
9
+ : `(\n${d.properties.map((p) => printPrimaryProp({ ...p, inPrimary: true }, INDENT)).join(",\n")},\n)`;
10
+ const head = `${annLines}${vis}enum class ${d.name}${ctor}${superTypeTail(d.superTypes)}`;
11
+ if (d.entries.length === 0 && d.funs.length === 0) {
12
+ return `${head} {}`;
13
+ }
14
+ const entryLines = d.entries.map((e) => {
15
+ const annPrefix = e.annotations && e.annotations.length > 0
16
+ ? `${e.annotations.map(printAnnotation).join(" ")} `
17
+ : "";
18
+ const args = e.args === undefined ? "" : `(${e.args})`;
19
+ return `${INDENT}${annPrefix}${e.name}${args}`;
20
+ });
21
+ // Trailing semicolon is required by Kotlin when the enum class has
22
+ // additional members (funs/companion) below the entry list.
23
+ const entriesBlock = d.funs.length > 0
24
+ ? `${entryLines.join(",\n")};`
25
+ : `${entryLines.join(",\n")},`;
26
+ const sections = [entriesBlock];
27
+ if (d.funs.length > 0) {
28
+ sections.push(d.funs.map((f) => printFun(f, INDENT)).join("\n\n"));
29
+ }
30
+ return `${head} {\n${sections.join("\n\n")}\n}`;
31
+ }
32
+ //# sourceMappingURL=enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../src/kt-compiler/decl/enum.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAEhF,MAAM,UAAU,SAAS,CAAC,CAAS;IACjC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACrD,MAAM,GAAG,GAAG,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,IAAI,GACR,CAAC,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;QACvB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3G,MAAM,IAAI,GAAG,GAAG,QAAQ,GAAG,GAAG,cAAc,CAAC,CAAC,IAAI,GAA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CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,GAAG,IAAI,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;AAClD,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { KtFun, KtFunParam } from "../../kt-dsl/fun.js";
2
+ export declare function printFunParam(p: KtFunParam, includeDefault?: boolean): string;
3
+ export declare function printParamsBlock(params: ReadonlyArray<KtFunParam>, indent: string, includeDefault?: boolean): string;
4
+ export declare function printFun(fn: KtFun, indent?: string,
5
+ /**
6
+ * Suppress the visibility modifier — required when the function lives
7
+ * inside an interface (members inherit the interface's visibility),
8
+ * or as part of an enum entry's member list.
9
+ */
10
+ suppressVisibility?: boolean): string;
11
+ //# sourceMappingURL=fun.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fun.d.ts","sourceRoot":"","sources":["../../../src/kt-compiler/decl/fun.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAe,MAAM,qBAAqB,CAAC;AAgB1E,wBAAgB,aAAa,CAC3B,CAAC,EAAE,UAAU,EACb,cAAc,GAAE,OAAc,GAC7B,MAAM,CAIR;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,EACjC,MAAM,EAAE,MAAM,EACd,cAAc,GAAE,OAAc,GAC7B,MAAM,CAKR;AAED,wBAAgB,QAAQ,CACtB,EAAE,EAAE,KAAK,EACT,MAAM,GAAE,MAAW;AACnB;;;;GAIG;AACH,kBAAkB,GAAE,OAAe,GAClC,MAAM,CAqCR"}
@@ -0,0 +1,69 @@
1
+ import { printExpr } from "../expr.js";
2
+ import { INDENT, visibilityPrefix } from "../format.js";
3
+ import { printStmt } from "../stmt.js";
4
+ import { printType } from "../type.js";
5
+ function printTypeParams(typeParams) {
6
+ if (typeParams.length === 0)
7
+ return "";
8
+ return `<${typeParams
9
+ .map((t) => {
10
+ if (!t.bounds || t.bounds.length === 0)
11
+ return t.name;
12
+ return `${t.name} : ${t.bounds.join(" & ")}`;
13
+ })
14
+ .join(", ")}>`;
15
+ }
16
+ export function printFunParam(p, includeDefault = true) {
17
+ const def = includeDefault && p.default !== undefined ? ` = ${p.default}` : "";
18
+ return `${p.name}: ${printType(p.type)}${def}`;
19
+ }
20
+ export function printParamsBlock(params, indent, includeDefault = true) {
21
+ if (params.length === 0)
22
+ return "()";
23
+ return `(\n${params
24
+ .map((p) => `${indent}${INDENT}${printFunParam(p, includeDefault)}`)
25
+ .join(",\n")}\n${indent})`;
26
+ }
27
+ export function printFun(fn, indent = "",
28
+ /**
29
+ * Suppress the visibility modifier — required when the function lives
30
+ * inside an interface (members inherit the interface's visibility),
31
+ * or as part of an enum entry's member list.
32
+ */
33
+ suppressVisibility = false) {
34
+ const lines = [];
35
+ if (fn.doc) {
36
+ for (const line of fn.doc.split("\n"))
37
+ lines.push(`${indent}/** ${line} */`);
38
+ }
39
+ const vis = suppressVisibility ? "" : visibilityPrefix(fn.visibility);
40
+ const isAbstract = fn.body === undefined;
41
+ // `abstract`/`override`/`open` are mutually exclusive with `final`; the
42
+ // DSL doesn't model `final` since Kotlin's default is final and we
43
+ // don't need the keyword.
44
+ const modifiers = fn.modifiers.length > 0 ? `${fn.modifiers.join(" ")} ` : "";
45
+ const typeParams = printTypeParams(fn.typeParams);
46
+ const params = printParamsBlock(fn.params, indent, !isAbstract);
47
+ const isUnit = fn.returnType.kind === "primitive" && fn.returnType.name === "Unit";
48
+ const ret = isUnit ? "" : `: ${printType(fn.returnType)}`;
49
+ const receiver = fn.receiver ? `${printType(fn.receiver)}.` : "";
50
+ const tp = typeParams ? `${typeParams} ` : "";
51
+ const head = `${indent}${vis}${modifiers}fun ${tp}${receiver}${fn.name}${params}${ret}`;
52
+ if (fn.body === undefined) {
53
+ lines.push(head);
54
+ return lines.join("\n");
55
+ }
56
+ if (fn.body.length === 0) {
57
+ lines.push(`${head} {}`);
58
+ return lines.join("\n");
59
+ }
60
+ // Single-expression body shorthand: `fun foo(): T = expr`.
61
+ if (fn.body.length === 1 && fn.body[0].kind === "returnExpr") {
62
+ lines.push(`${head} = ${printExpr(fn.body[0].expr)}`);
63
+ return lines.join("\n");
64
+ }
65
+ const body = fn.body.map((s) => printStmt(s, indent + INDENT)).join("\n");
66
+ lines.push(`${head} {\n${body}\n${indent}}`);
67
+ return lines.join("\n");
68
+ }
69
+ //# sourceMappingURL=fun.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fun.js","sourceRoot":"","sources":["../../../src/kt-compiler/decl/fun.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,SAAS,eAAe,CAAC,UAAsC;IAC7D,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACvC,OAAO,IAAI,UAAU;SAClB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC,IAAI,CAAC;QACtD,OAAO,GAAG,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;IAC/C,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,CAAa,EACb,iBAA0B,IAAI;IAE9B,MAAM,GAAG,GACP,cAAc,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,MA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