sdkloom 0.0.0-stage → 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 (383) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +239 -2
  3. package/kits/allowed-sources.json +24 -0
  4. package/kits/csharp/kit.json +6 -0
  5. package/kits/csharp/src/Runtime/Client.cs +295 -0
  6. package/kits/csharp/src/Runtime/Context.cs +216 -0
  7. package/kits/csharp/src/Runtime/Errors.cs +121 -0
  8. package/kits/csharp/src/Runtime/Http.cs +218 -0
  9. package/kits/csharp/src/Runtime/Json.cs +650 -0
  10. package/kits/csharp/src/Runtime/Lang.cs +212 -0
  11. package/kits/csharp/src/Runtime/Models.cs +206 -0
  12. package/kits/csharp/src/Runtime/Multipart.cs +108 -0
  13. package/kits/csharp/src/Runtime/Pagination.cs +122 -0
  14. package/kits/csharp/src/Runtime/Sse.cs +197 -0
  15. package/kits/csharp/src/Runtime/Testing.cs +375 -0
  16. package/kits/csharp/src/Runtime/Transport.cs +212 -0
  17. package/kits/csharp/src/Runtime/Wait.cs +57 -0
  18. package/kits/csharp/src/Runtime/Webhooks.cs +148 -0
  19. package/kits/csharp/tests/ClientTests.cs +128 -0
  20. package/kits/csharp/tests/HttpTests.cs +44 -0
  21. package/kits/csharp/tests/JsonTests.cs +132 -0
  22. package/kits/csharp/tests/LangTests.cs +57 -0
  23. package/kits/csharp/tests/MultipartTests.cs +31 -0
  24. package/kits/csharp/tests/PaginationTests.cs +93 -0
  25. package/kits/csharp/tests/SseTests.cs +122 -0
  26. package/kits/csharp/tests/TestRunner.cs +93 -0
  27. package/kits/csharp/tests/TestingTests.cs +80 -0
  28. package/kits/csharp/tests/TransportTests.cs +145 -0
  29. package/kits/csharp/tests/WaitTests.cs +39 -0
  30. package/kits/csharp/tests/WebhooksTests.cs +46 -0
  31. package/kits/csharp/versions.json +12 -0
  32. package/kits/go/kit.json +6 -0
  33. package/kits/go/src/sdkruntime/client.go +322 -0
  34. package/kits/go/src/sdkruntime/context.go +207 -0
  35. package/kits/go/src/sdkruntime/errors.go +74 -0
  36. package/kits/go/src/sdkruntime/http.go +261 -0
  37. package/kits/go/src/sdkruntime/json.go +527 -0
  38. package/kits/go/src/sdkruntime/lang.go +462 -0
  39. package/kits/go/src/sdkruntime/multipart.go +75 -0
  40. package/kits/go/src/sdkruntime/pagination.go +150 -0
  41. package/kits/go/src/sdkruntime/sse.go +267 -0
  42. package/kits/go/src/sdkruntime/testing.go +343 -0
  43. package/kits/go/src/sdkruntime/transport.go +168 -0
  44. package/kits/go/src/sdkruntime/wait.go +49 -0
  45. package/kits/go/src/sdkruntime/webhooks.go +129 -0
  46. package/kits/go/tests/client_test.go +185 -0
  47. package/kits/go/tests/http_test.go +78 -0
  48. package/kits/go/tests/json_test.go +127 -0
  49. package/kits/go/tests/lang_test.go +98 -0
  50. package/kits/go/tests/multipart_test.go +29 -0
  51. package/kits/go/tests/pagination_test.go +69 -0
  52. package/kits/go/tests/sse_test.go +129 -0
  53. package/kits/go/tests/testing_test.go +121 -0
  54. package/kits/go/tests/transport_test.go +133 -0
  55. package/kits/go/tests/wait_test.go +46 -0
  56. package/kits/go/tests/webhooks_test.go +62 -0
  57. package/kits/go/versions.json +12 -0
  58. package/kits/java/kit.json +6 -0
  59. package/kits/java/src/dev/sdkloom/runtime/ApiException.java +63 -0
  60. package/kits/java/src/dev/sdkloom/runtime/ArgumentException.java +24 -0
  61. package/kits/java/src/dev/sdkloom/runtime/Assert.java +72 -0
  62. package/kits/java/src/dev/sdkloom/runtime/ClientRuntime.java +220 -0
  63. package/kits/java/src/dev/sdkloom/runtime/Clock.java +39 -0
  64. package/kits/java/src/dev/sdkloom/runtime/Context.java +79 -0
  65. package/kits/java/src/dev/sdkloom/runtime/Decode.java +200 -0
  66. package/kits/java/src/dev/sdkloom/runtime/DecodeException.java +26 -0
  67. package/kits/java/src/dev/sdkloom/runtime/Decoder.java +16 -0
  68. package/kits/java/src/dev/sdkloom/runtime/Emitter.java +56 -0
  69. package/kits/java/src/dev/sdkloom/runtime/ErrorFactory.java +18 -0
  70. package/kits/java/src/dev/sdkloom/runtime/EventListener.java +20 -0
  71. package/kits/java/src/dev/sdkloom/runtime/EventStream.java +232 -0
  72. package/kits/java/src/dev/sdkloom/runtime/FakeClock.java +37 -0
  73. package/kits/java/src/dev/sdkloom/runtime/Headers.java +42 -0
  74. package/kits/java/src/dev/sdkloom/runtime/HttpRequest.java +88 -0
  75. package/kits/java/src/dev/sdkloom/runtime/HttpResponse.java +69 -0
  76. package/kits/java/src/dev/sdkloom/runtime/JdkTransport.java +97 -0
  77. package/kits/java/src/dev/sdkloom/runtime/Js.java +230 -0
  78. package/kits/java/src/dev/sdkloom/runtime/Json.java +281 -0
  79. package/kits/java/src/dev/sdkloom/runtime/JsonValue.java +15 -0
  80. package/kits/java/src/dev/sdkloom/runtime/Links.java +62 -0
  81. package/kits/java/src/dev/sdkloom/runtime/Middleware.java +16 -0
  82. package/kits/java/src/dev/sdkloom/runtime/MiddlewareEntry.java +43 -0
  83. package/kits/java/src/dev/sdkloom/runtime/MockRoute.java +111 -0
  84. package/kits/java/src/dev/sdkloom/runtime/MockTransport.java +62 -0
  85. package/kits/java/src/dev/sdkloom/runtime/MultipartForm.java +111 -0
  86. package/kits/java/src/dev/sdkloom/runtime/Next.java +16 -0
  87. package/kits/java/src/dev/sdkloom/runtime/OperationInfo.java +35 -0
  88. package/kits/java/src/dev/sdkloom/runtime/OperationMock.java +105 -0
  89. package/kits/java/src/dev/sdkloom/runtime/OperationSpec.java +125 -0
  90. package/kits/java/src/dev/sdkloom/runtime/Pages.java +55 -0
  91. package/kits/java/src/dev/sdkloom/runtime/Pipeline.java +29 -0
  92. package/kits/java/src/dev/sdkloom/runtime/RawResult.java +31 -0
  93. package/kits/java/src/dev/sdkloom/runtime/RecordedEvent.java +36 -0
  94. package/kits/java/src/dev/sdkloom/runtime/SdkInfo.java +38 -0
  95. package/kits/java/src/dev/sdkloom/runtime/SendOptions.java +34 -0
  96. package/kits/java/src/dev/sdkloom/runtime/ServerSentEvent.java +58 -0
  97. package/kits/java/src/dev/sdkloom/runtime/State.java +58 -0
  98. package/kits/java/src/dev/sdkloom/runtime/Test.java +21 -0
  99. package/kits/java/src/dev/sdkloom/runtime/TestRunner.java +63 -0
  100. package/kits/java/src/dev/sdkloom/runtime/Transport.java +16 -0
  101. package/kits/java/src/dev/sdkloom/runtime/TransportException.java +30 -0
  102. package/kits/java/src/dev/sdkloom/runtime/UrlConnectionTransport.java +195 -0
  103. package/kits/java/src/dev/sdkloom/runtime/Urls.java +116 -0
  104. package/kits/java/src/dev/sdkloom/runtime/Waits.java +53 -0
  105. package/kits/java/src/dev/sdkloom/runtime/WebhookSignatureException.java +24 -0
  106. package/kits/java/src/dev/sdkloom/runtime/Webhooks.java +146 -0
  107. package/kits/java/tests/dev/sdkloom/runtime/ClientTest.java +266 -0
  108. package/kits/java/tests/dev/sdkloom/runtime/EventStreamTest.java +131 -0
  109. package/kits/java/tests/dev/sdkloom/runtime/HttpTest.java +95 -0
  110. package/kits/java/tests/dev/sdkloom/runtime/JdkTransportTest.java +12 -0
  111. package/kits/java/tests/dev/sdkloom/runtime/JsTest.java +102 -0
  112. package/kits/java/tests/dev/sdkloom/runtime/JsonTest.java +87 -0
  113. package/kits/java/tests/dev/sdkloom/runtime/LinksTest.java +22 -0
  114. package/kits/java/tests/dev/sdkloom/runtime/MultipartFormTest.java +30 -0
  115. package/kits/java/tests/dev/sdkloom/runtime/PagesTest.java +75 -0
  116. package/kits/java/tests/dev/sdkloom/runtime/TestData.java +53 -0
  117. package/kits/java/tests/dev/sdkloom/runtime/TestingTest.java +156 -0
  118. package/kits/java/tests/dev/sdkloom/runtime/TransportContract.java +201 -0
  119. package/kits/java/tests/dev/sdkloom/runtime/UrlConnectionTransportTest.java +49 -0
  120. package/kits/java/tests/dev/sdkloom/runtime/WaitsTest.java +43 -0
  121. package/kits/java/tests/dev/sdkloom/runtime/WebhooksTest.java +45 -0
  122. package/kits/java/versions.json +41 -0
  123. package/kits/python/kit.json +6 -0
  124. package/kits/python/src/sdkloom_runtime/__init__.py +1 -0
  125. package/kits/python/src/sdkloom_runtime/client.py +232 -0
  126. package/kits/python/src/sdkloom_runtime/compat.py +195 -0
  127. package/kits/python/src/sdkloom_runtime/context.py +134 -0
  128. package/kits/python/src/sdkloom_runtime/errors.py +65 -0
  129. package/kits/python/src/sdkloom_runtime/http.py +192 -0
  130. package/kits/python/src/sdkloom_runtime/lang.py +207 -0
  131. package/kits/python/src/sdkloom_runtime/models.py +221 -0
  132. package/kits/python/src/sdkloom_runtime/multipart.py +69 -0
  133. package/kits/python/src/sdkloom_runtime/pagination.py +61 -0
  134. package/kits/python/src/sdkloom_runtime/pipeline.py +39 -0
  135. package/kits/python/src/sdkloom_runtime/sse.py +121 -0
  136. package/kits/python/src/sdkloom_runtime/testing.py +224 -0
  137. package/kits/python/src/sdkloom_runtime/transport.py +120 -0
  138. package/kits/python/src/sdkloom_runtime/wait.py +44 -0
  139. package/kits/python/src/sdkloom_runtime/webhooks.py +84 -0
  140. package/kits/python/tests/support.py +28 -0
  141. package/kits/python/tests/test_client.py +275 -0
  142. package/kits/python/tests/test_compat.py +87 -0
  143. package/kits/python/tests/test_http.py +94 -0
  144. package/kits/python/tests/test_lang.py +104 -0
  145. package/kits/python/tests/test_models.py +110 -0
  146. package/kits/python/tests/test_multipart.py +37 -0
  147. package/kits/python/tests/test_pagination.py +70 -0
  148. package/kits/python/tests/test_sse.py +61 -0
  149. package/kits/python/tests/test_testing.py +130 -0
  150. package/kits/python/tests/test_transport.py +124 -0
  151. package/kits/python/tests/test_wait.py +46 -0
  152. package/kits/python/tests/test_webhooks.py +57 -0
  153. package/kits/python/versions.json +33 -0
  154. package/kits/rust/kit.json +6 -0
  155. package/kits/rust/src/runtime/client.rs +212 -0
  156. package/kits/rust/src/runtime/context.rs +182 -0
  157. package/kits/rust/src/runtime/crypto.rs +84 -0
  158. package/kits/rust/src/runtime/errors.rs +147 -0
  159. package/kits/rust/src/runtime/http.rs +248 -0
  160. package/kits/rust/src/runtime/json.rs +424 -0
  161. package/kits/rust/src/runtime/lang.rs +296 -0
  162. package/kits/rust/src/runtime/mod.rs +30 -0
  163. package/kits/rust/src/runtime/models.rs +266 -0
  164. package/kits/rust/src/runtime/multipart.rs +81 -0
  165. package/kits/rust/src/runtime/pagination.rs +117 -0
  166. package/kits/rust/src/runtime/sse.rs +195 -0
  167. package/kits/rust/src/runtime/testing.rs +308 -0
  168. package/kits/rust/src/runtime/transport.rs +324 -0
  169. package/kits/rust/src/runtime/wait.rs +29 -0
  170. package/kits/rust/src/runtime/webhooks.rs +142 -0
  171. package/kits/rust/tests/client.rs +152 -0
  172. package/kits/rust/tests/http.rs +44 -0
  173. package/kits/rust/tests/json.rs +82 -0
  174. package/kits/rust/tests/lang.rs +74 -0
  175. package/kits/rust/tests/multipart.rs +21 -0
  176. package/kits/rust/tests/pagination.rs +61 -0
  177. package/kits/rust/tests/sse.rs +77 -0
  178. package/kits/rust/tests/testing.rs +90 -0
  179. package/kits/rust/tests/transport.rs +218 -0
  180. package/kits/rust/tests/wait.rs +32 -0
  181. package/kits/rust/tests/webhooks.rs +73 -0
  182. package/kits/rust/versions.json +6 -0
  183. package/kits/typescript/kit.json +6 -0
  184. package/kits/typescript/src/client.ts +223 -0
  185. package/kits/typescript/src/context.ts +108 -0
  186. package/kits/typescript/src/errors.ts +63 -0
  187. package/kits/typescript/src/helpers.ts +49 -0
  188. package/kits/typescript/src/http.ts +192 -0
  189. package/kits/typescript/src/models.ts +139 -0
  190. package/kits/typescript/src/multipart.ts +66 -0
  191. package/kits/typescript/src/pagination.ts +54 -0
  192. package/kits/typescript/src/pipeline.ts +25 -0
  193. package/kits/typescript/src/sse.ts +102 -0
  194. package/kits/typescript/src/testing.ts +217 -0
  195. package/kits/typescript/src/transport.ts +101 -0
  196. package/kits/typescript/src/wait.ts +36 -0
  197. package/kits/typescript/src/webhooks.ts +168 -0
  198. package/kits/typescript/tests/client.test.ts +269 -0
  199. package/kits/typescript/tests/helpers.test.ts +27 -0
  200. package/kits/typescript/tests/http.test.ts +80 -0
  201. package/kits/typescript/tests/models.test.ts +71 -0
  202. package/kits/typescript/tests/multipart.test.ts +28 -0
  203. package/kits/typescript/tests/pagination.test.ts +76 -0
  204. package/kits/typescript/tests/sse.test.ts +82 -0
  205. package/kits/typescript/tests/testing.test.ts +103 -0
  206. package/kits/typescript/tests/transport.test.ts +127 -0
  207. package/kits/typescript/tests/wait.test.ts +31 -0
  208. package/kits/typescript/tests/webhooks.test.ts +53 -0
  209. package/kits/typescript/versions.json +15 -0
  210. package/package.json +37 -4
  211. package/packages/cli/recipes/apiKeyHeader.ts +16 -0
  212. package/packages/cli/recipes/apiVersionHeader.ts +16 -0
  213. package/packages/cli/recipes/basic.ts +13 -0
  214. package/packages/cli/recipes/bearer.ts +10 -0
  215. package/packages/cli/recipes/hmacSign.ts +23 -0
  216. package/packages/cli/recipes/idempotencyKey.ts +19 -0
  217. package/packages/cli/recipes/oauthClientCredentials.ts +50 -0
  218. package/packages/cli/recipes/retry.ts +42 -0
  219. package/packages/cli/recipes/timing.ts +12 -0
  220. package/packages/cli/recipes/userAgent.ts +8 -0
  221. package/packages/cli/src/build.js +93 -0
  222. package/packages/cli/src/commands/build.js +31 -0
  223. package/packages/cli/src/commands/conformance-check.js +50 -0
  224. package/packages/cli/src/commands/contract.js +181 -0
  225. package/packages/cli/src/commands/diff.js +113 -0
  226. package/packages/cli/src/commands/doctor.js +43 -0
  227. package/packages/cli/src/commands/import-openapi.js +42 -0
  228. package/packages/cli/src/commands/init.js +27 -0
  229. package/packages/cli/src/commands/kit-check.js +145 -0
  230. package/packages/cli/src/commands/publish.js +81 -0
  231. package/packages/cli/src/commands/recipe.js +49 -0
  232. package/packages/cli/src/commands/record.js +181 -0
  233. package/packages/cli/src/commands/serve.js +156 -0
  234. package/packages/cli/src/commands/spec-check.js +57 -0
  235. package/packages/cli/src/commands/test.js +177 -0
  236. package/packages/cli/src/commands/variants.js +32 -0
  237. package/packages/cli/src/commands/verify.js +57 -0
  238. package/packages/cli/src/commands/version.js +63 -0
  239. package/packages/cli/src/containers.js +82 -0
  240. package/packages/cli/src/coverage.js +72 -0
  241. package/packages/cli/src/git.js +25 -0
  242. package/packages/cli/src/io.js +50 -0
  243. package/packages/cli/src/java/ScenarioHarness.java +297 -0
  244. package/packages/cli/src/java/SchemaRoundTrip.java +63 -0
  245. package/packages/cli/src/java.js +70 -0
  246. package/packages/cli/src/js/harness.mjs +120 -0
  247. package/packages/cli/src/kits.js +103 -0
  248. package/packages/cli/src/languages/csharp.js +274 -0
  249. package/packages/cli/src/languages/go.js +185 -0
  250. package/packages/cli/src/languages/index.js +18 -0
  251. package/packages/cli/src/languages/java.js +187 -0
  252. package/packages/cli/src/languages/python.js +120 -0
  253. package/packages/cli/src/languages/rust.js +189 -0
  254. package/packages/cli/src/languages/types.js +93 -0
  255. package/packages/cli/src/languages/typescript.js +112 -0
  256. package/packages/cli/src/main.js +13 -0
  257. package/packages/cli/src/packaging.js +39 -0
  258. package/packages/cli/src/portability.js +45 -0
  259. package/packages/cli/src/profiles.js +55 -0
  260. package/packages/cli/src/project.js +56 -0
  261. package/packages/cli/src/python/scenario_harness.py +162 -0
  262. package/packages/cli/src/python/schema_roundtrip.py +42 -0
  263. package/packages/cli/src/registries.js +214 -0
  264. package/packages/cli/src/resolve-core.js +39 -0
  265. package/packages/cli/src/run.js +133 -0
  266. package/packages/cli/src/runtimes.js +61 -0
  267. package/packages/cli/src/scenarios-java.js +82 -0
  268. package/packages/cli/src/scenarios-javascript.js +54 -0
  269. package/packages/cli/src/scenarios-python.js +90 -0
  270. package/packages/cli/src/scenarios.js +183 -0
  271. package/packages/cli/src/schema.js +84 -0
  272. package/packages/cli/src/templates.js +85 -0
  273. package/packages/cli/src/toolchains.js +68 -0
  274. package/packages/cli/src/transpiled-tests.js +92 -0
  275. package/packages/codegen/src/canonical-json.js +31 -0
  276. package/packages/codegen/src/capabilities.js +50 -0
  277. package/packages/codegen/src/code-writer.js +54 -0
  278. package/packages/codegen/src/file-tree.js +25 -0
  279. package/packages/codegen/src/hash.js +6 -0
  280. package/packages/codegen/src/index.js +16 -0
  281. package/packages/codegen/src/lock.js +106 -0
  282. package/packages/conformance/src/case.js +143 -0
  283. package/packages/conformance/src/checks.js +40 -0
  284. package/packages/conformance/src/index.js +3 -0
  285. package/packages/conformance/src/matrix.js +48 -0
  286. package/packages/conformance/src/suite.js +48 -0
  287. package/packages/differ/src/diff.js +500 -0
  288. package/packages/differ/src/index.js +3 -0
  289. package/packages/differ/src/notes.js +112 -0
  290. package/packages/differ/src/support.js +34 -0
  291. package/packages/gen-csharp/src/emit-client.js +397 -0
  292. package/packages/gen-csharp/src/emit-harness.js +333 -0
  293. package/packages/gen-csharp/src/emit-mock.js +111 -0
  294. package/packages/gen-csharp/src/emit-models.js +119 -0
  295. package/packages/gen-csharp/src/emit-webhooks.js +57 -0
  296. package/packages/gen-csharp/src/generate.js +245 -0
  297. package/packages/gen-csharp/src/index.js +5 -0
  298. package/packages/gen-csharp/src/names.js +284 -0
  299. package/packages/gen-go/src/emit-client.js +405 -0
  300. package/packages/gen-go/src/emit-harness.js +294 -0
  301. package/packages/gen-go/src/emit-mock.js +112 -0
  302. package/packages/gen-go/src/emit-models.js +146 -0
  303. package/packages/gen-go/src/emit-webhooks.js +58 -0
  304. package/packages/gen-go/src/generate.js +205 -0
  305. package/packages/gen-go/src/index.js +5 -0
  306. package/packages/gen-go/src/names.js +197 -0
  307. package/packages/gen-java/src/emit-client.js +441 -0
  308. package/packages/gen-java/src/emit-models.js +342 -0
  309. package/packages/gen-java/src/emit-testing.js +123 -0
  310. package/packages/gen-java/src/emit-webhooks.js +70 -0
  311. package/packages/gen-java/src/generate.js +244 -0
  312. package/packages/gen-java/src/index.js +4 -0
  313. package/packages/gen-java/src/names.js +197 -0
  314. package/packages/gen-python/src/emit-client.js +272 -0
  315. package/packages/gen-python/src/emit-models.js +139 -0
  316. package/packages/gen-python/src/emit-testing.js +93 -0
  317. package/packages/gen-python/src/emit-webhooks.js +48 -0
  318. package/packages/gen-python/src/generate.js +237 -0
  319. package/packages/gen-python/src/index.js +2 -0
  320. package/packages/gen-python/src/names.js +161 -0
  321. package/packages/gen-python/src/style.js +67 -0
  322. package/packages/gen-rust/src/emit-client.js +379 -0
  323. package/packages/gen-rust/src/emit-harness.js +278 -0
  324. package/packages/gen-rust/src/emit-mock.js +121 -0
  325. package/packages/gen-rust/src/emit-models.js +117 -0
  326. package/packages/gen-rust/src/emit-webhooks.js +58 -0
  327. package/packages/gen-rust/src/generate.js +243 -0
  328. package/packages/gen-rust/src/index.js +5 -0
  329. package/packages/gen-rust/src/names.js +223 -0
  330. package/packages/gen-typescript/src/emit-client.js +434 -0
  331. package/packages/gen-typescript/src/emit-models.js +93 -0
  332. package/packages/gen-typescript/src/emit-package.js +90 -0
  333. package/packages/gen-typescript/src/emit-testing.js +138 -0
  334. package/packages/gen-typescript/src/emit-webhooks.js +52 -0
  335. package/packages/gen-typescript/src/generate.js +70 -0
  336. package/packages/gen-typescript/src/index.js +3 -0
  337. package/packages/gen-typescript/src/naming.js +64 -0
  338. package/packages/gen-typescript/src/runtime.js +81 -0
  339. package/packages/gen-typescript/src/types.js +136 -0
  340. package/packages/ir/src/api-surface.js +22 -0
  341. package/packages/ir/src/checks.js +52 -0
  342. package/packages/ir/src/index.js +32 -0
  343. package/packages/ir/src/ir.js +214 -0
  344. package/packages/ir/src/pages.js +18 -0
  345. package/packages/ir/src/validate-ir.js +462 -0
  346. package/packages/ir/src/validate-types.js +140 -0
  347. package/packages/kit/src/block-parser.js +196 -0
  348. package/packages/kit/src/index.js +15 -0
  349. package/packages/kit/src/kit-check.js +203 -0
  350. package/packages/kit/src/sources.js +53 -0
  351. package/packages/kit/src/version-policy.js +133 -0
  352. package/packages/kit/src/version-range.js +132 -0
  353. package/packages/openapi/src/import.js +292 -0
  354. package/packages/openapi/src/index.js +1 -0
  355. package/packages/openapi/src/names.js +50 -0
  356. package/packages/openapi/src/schemas.js +264 -0
  357. package/packages/packager/src/archive.js +106 -0
  358. package/packages/packager/src/crate.js +39 -0
  359. package/packages/packager/src/gomodule.js +11 -0
  360. package/packages/packager/src/index.js +9 -0
  361. package/packages/packager/src/maven.js +85 -0
  362. package/packages/packager/src/metadata.js +34 -0
  363. package/packages/packager/src/npm.js +71 -0
  364. package/packages/packager/src/nuget.js +78 -0
  365. package/packages/packager/src/sbom.js +56 -0
  366. package/packages/packager/src/wheel.js +62 -0
  367. package/packages/spec/src/index.js +11 -0
  368. package/packages/spec/src/requirements.js +139 -0
  369. package/packages/transpile/src/ast.js +51 -0
  370. package/packages/transpile/src/check.js +669 -0
  371. package/packages/transpile/src/emit-csharp.js +469 -0
  372. package/packages/transpile/src/emit-go.js +529 -0
  373. package/packages/transpile/src/emit-java.js +360 -0
  374. package/packages/transpile/src/emit-python.js +320 -0
  375. package/packages/transpile/src/emit-rust.js +499 -0
  376. package/packages/transpile/src/errors.js +15 -0
  377. package/packages/transpile/src/index.js +13 -0
  378. package/packages/transpile/src/lexer.js +161 -0
  379. package/packages/transpile/src/parser.js +543 -0
  380. package/packages/transpile/src/tests/ast.js +46 -0
  381. package/packages/transpile/src/tests/parse.js +376 -0
  382. package/packages/transpile/src/tests/translate.js +849 -0
  383. package/packages/transpile/src/transpile.js +57 -0
@@ -0,0 +1,230 @@
1
+ // sdkloom Java kit: JavaScript semantics that transpiled middleware relies on.
2
+ package dev.sdkloom.runtime;
3
+
4
+ import java.math.BigDecimal;
5
+ import java.math.MathContext;
6
+ import java.math.RoundingMode;
7
+ import java.nio.charset.StandardCharsets;
8
+ import java.util.ArrayList;
9
+ import java.util.Arrays;
10
+ import java.util.Base64;
11
+ import java.util.LinkedHashMap;
12
+ import java.util.List;
13
+ import java.util.Map;
14
+ import java.util.Objects;
15
+ import java.util.regex.Pattern;
16
+
17
+ // @block lang.js
18
+ // @summary String(value), Number(text), btoa(text), encodeURIComponent(text), randomUUID(), hmacSha256Hex and hmacSha256Base64 (UTF-8 key and text), strict equality, JSON field reads and literal maps and arrays with JavaScript's results, so transpiled middleware behaves like its TypeScript source.
19
+ // @versions >=8
20
+ // @source [1] https://tc39.es/ecma262/multipage/abstract-operations.html#sec-tostring
21
+ // @quote [1] "The abstract operation ToString takes argument arg (an ECMAScript language value) and returns either a normal completion containing a String or a throw completion."
22
+ // @source [2] https://tc39.es/ecma262/multipage/ecmascript-data-types-and-values.html#sec-numeric-types-number-tostring
23
+ // @quote [2] "The abstract operation Number::toString takes arguments x (a Number) and radix (an integer in the inclusive interval from 2 to 36) and returns a String."
24
+ // @source [3] https://tc39.es/ecma262/multipage/abstract-operations.html#sec-stringtonumber
25
+ // @quote [3] "The abstract operation StringToNumber specifies how to convert a String value to a Number value, using the following grammar."
26
+ // @source [4] https://developer.mozilla.org/en-US/docs/Web/API/Window/btoa
27
+ // @quote [4] "The string contained a character that did not fit in a single byte."
28
+ // @source [5] https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Base64.html
29
+ // @quote [5] "This class consists exclusively of static methods for obtaining encoders and decoders for the Base64 encoding scheme."
30
+ // @source [6] https://docs.oracle.com/javase/8/docs/api/java/util/UUID.html#randomUUID--
31
+ // @quote [6] "The UUID is generated using a cryptographically strong pseudo random number generator."
32
+ // @retrieved 2026-12-05
33
+ // @tests tests/dev/sdkloom/runtime/JsTest.java
34
+ // @requirement SDKL-XPILE-001
35
+ public final class Js {
36
+ private static final double MAX_PLAIN = 1e21;
37
+ private static final double MIN_PLAIN = 1e-6;
38
+ private static final Pattern DECIMAL = Pattern.compile("[+-]?(\\d+\\.?\\d*|\\.\\d+)([eE][+-]?\\d+)?");
39
+ /** 17 significant digits always identify a double. */
40
+ private static final int MAX_DIGITS = 17;
41
+ private static final Pattern HEX = Pattern.compile("0[xX][0-9a-fA-F]+");
42
+ /** What String.prototype.trim removes: white space and line terminators, including no-break and BOM. */
43
+ private static final Pattern EDGE_SPACE = Pattern.compile("^[\\s\\u00A0\\uFEFF\\p{Zs}\\u2028\\u2029]+|[\\s\\u00A0\\uFEFF\\p{Zs}\\u2028\\u2029]+$");
44
+
45
+ private Js() {
46
+ }
47
+
48
+ /**
49
+ * The shortest decimal that reads back as the same double, as JavaScript and Python print numbers. Double.toString
50
+ * gives the same only from JDK 19 on (1e23 is 9.999999999999999E22 on JDK 8 and 11).
51
+ */
52
+ static BigDecimal shortest(double value) {
53
+ BigDecimal exact = new BigDecimal(value);
54
+ for (int precision = 1; precision < MAX_DIGITS; precision++) {
55
+ // The nearest decimal of this length may miss while its neighbour still reads back (2^-44 needs ...802, not ...801).
56
+ BigDecimal best = null;
57
+ for (RoundingMode mode : new RoundingMode[] {RoundingMode.HALF_EVEN, RoundingMode.FLOOR, RoundingMode.CEILING}) {
58
+ BigDecimal candidate = exact.round(new MathContext(precision, mode));
59
+ boolean closer = best == null || candidate.subtract(exact).abs().compareTo(best.subtract(exact).abs()) < 0;
60
+ if (Double.parseDouble(candidate.toString()) == value && closer) {
61
+ best = candidate;
62
+ }
63
+ }
64
+ if (best != null) {
65
+ return best.stripTrailingZeros();
66
+ }
67
+ }
68
+ return exact.round(new MathContext(MAX_DIGITS, RoundingMode.HALF_EVEN)).stripTrailingZeros();
69
+ }
70
+
71
+ static String number(double value) {
72
+ if (Double.isNaN(value)) {
73
+ return "NaN";
74
+ }
75
+ if (Double.isInfinite(value)) {
76
+ return value > 0 ? "Infinity" : "-Infinity";
77
+ }
78
+ if (value == 0) {
79
+ return "0";
80
+ }
81
+ // Integers above 2^53 too: JavaScript prints the shortest digits and pads with zeros (87003261217788850).
82
+ BigDecimal digits = shortest(value);
83
+ if (Math.abs(value) >= MAX_PLAIN || Math.abs(value) < MIN_PLAIN) {
84
+ String unscaled = digits.unscaledValue().abs().toString();
85
+ int exponent = unscaled.length() - 1 - digits.scale();
86
+ String mantissa = unscaled.length() == 1 ? unscaled : unscaled.charAt(0) + "." + unscaled.substring(1);
87
+ return (value < 0 ? "-" : "") + mantissa + "e" + (exponent < 0 ? "-" : "+") + Math.abs(exponent);
88
+ }
89
+ return digits.toPlainString();
90
+ }
91
+
92
+ /** String(value) as JavaScript writes it. Absent values (null) become "null". */
93
+ public static String str(Object value) {
94
+ if (value == null) {
95
+ return "null";
96
+ }
97
+ if (value instanceof String) {
98
+ return (String) value;
99
+ }
100
+ if (value instanceof Double || value instanceof Float || value instanceof BigDecimal) {
101
+ return number(((Number) value).doubleValue());
102
+ }
103
+ if (value instanceof Number || value instanceof Boolean) {
104
+ return value.toString();
105
+ }
106
+ if (value instanceof List) {
107
+ List<String> parts = new ArrayList<>();
108
+ for (Object item : (List<?>) value) {
109
+ parts.add(item == null ? "" : str(item));
110
+ }
111
+ return String.join(",", parts);
112
+ }
113
+ return "[object Object]";
114
+ }
115
+
116
+ /** Number(text) as JavaScript parses it: trimmed, "" is 0, hex is allowed, anything else is NaN. */
117
+ public static double number(Object text) {
118
+ String trimmed = EDGE_SPACE.matcher(str(text)).replaceAll("");
119
+ if (trimmed.isEmpty()) {
120
+ return 0;
121
+ }
122
+ if (HEX.matcher(trimmed).matches()) {
123
+ return Long.parseLong(trimmed.substring(2), 16);
124
+ }
125
+ if (trimmed.equals("Infinity") || trimmed.equals("+Infinity")) {
126
+ return Double.POSITIVE_INFINITY;
127
+ }
128
+ if (trimmed.equals("-Infinity")) {
129
+ return Double.NEGATIVE_INFINITY;
130
+ }
131
+ return DECIMAL.matcher(trimmed).matches() ? Double.parseDouble(trimmed) : Double.NaN;
132
+ }
133
+
134
+ /** btoa(text): Base64 of a string whose characters each fit in one byte, like JavaScript. */
135
+ public static String btoa(String text) {
136
+ for (int i = 0; i < text.length(); i++) {
137
+ if (text.charAt(i) > 0xFF) {
138
+ throw new IllegalStateException("InvalidCharacterError: the string contains a character that does not fit in a single byte");
139
+ }
140
+ }
141
+ return Base64.getEncoder().encodeToString(text.getBytes(StandardCharsets.ISO_8859_1));
142
+ }
143
+
144
+ /** encodeURIComponent(text): letters, digits and - _ . ! ~ * ' ( ) stay; everything else is UTF-8 percent-encoded. */
145
+ public static String encodeURIComponent(String text) {
146
+ return Urls.pathSegment(text);
147
+ }
148
+
149
+ /** Text as UTF-8 bytes, e.g. for a request body. */
150
+ public static byte[] utf8(String text) {
151
+ return text.getBytes(StandardCharsets.UTF_8);
152
+ }
153
+
154
+ /** a === b in the subset: numbers compare by value, null equals null, nothing is coerced. */
155
+ public static boolean same(Object left, Object right) {
156
+ if (left instanceof Number && right instanceof Number) {
157
+ return ((Number) left).doubleValue() == ((Number) right).doubleValue();
158
+ }
159
+ return Objects.equals(left, right);
160
+ }
161
+
162
+ /** value.name for a JSON value: a missing field is null; reading from null fails like JavaScript. */
163
+ public static Object get(Object value, String name) {
164
+ if (value == null) {
165
+ throw new IllegalStateException("Cannot read properties of null (reading '" + name + "')");
166
+ }
167
+ return value instanceof Map ? ((Map<?, ?>) value).get(name) : null;
168
+ }
169
+
170
+ /** An object literal: keys and values in pairs, order kept, null values allowed. */
171
+ public static Map<String, Object> map(Object... pairs) {
172
+ Map<String, Object> result = new LinkedHashMap<>();
173
+ for (int i = 0; i < pairs.length; i += 2) {
174
+ result.put((String) pairs[i], pairs[i + 1]);
175
+ }
176
+ return result;
177
+ }
178
+
179
+ /** An array literal; null items allowed. */
180
+ public static List<Object> list(Object... items) {
181
+ return new ArrayList<>(Arrays.asList(items));
182
+ }
183
+
184
+ /** The items of a JSON array for `for … of`. */
185
+ public static List<?> iterate(Object value) {
186
+ if (!(value instanceof List)) {
187
+ throw new IllegalStateException(str(value) + " is not iterable");
188
+ }
189
+ return (List<?>) value;
190
+ }
191
+
192
+ /** randomUUID(): a random version 4 UUID in lower case. */
193
+ public static String randomUUID() {
194
+ return java.util.UUID.randomUUID().toString();
195
+ }
196
+
197
+ private static byte[] hmacSha256(String key, String text) {
198
+ try {
199
+ javax.crypto.Mac mac = javax.crypto.Mac.getInstance("HmacSHA256");
200
+ mac.init(new javax.crypto.spec.SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
201
+ return mac.doFinal(text.getBytes(StandardCharsets.UTF_8));
202
+ } catch (java.security.GeneralSecurityException impossible) {
203
+ throw new IllegalStateException("HmacSHA256 is not available", impossible);
204
+ }
205
+ }
206
+
207
+ /** hmacSha256Hex(key, text): HMAC-SHA256 of UTF-8 text with a UTF-8 key, in lower-case hex. */
208
+ public static String hmacSha256Hex(String key, String text) {
209
+ StringBuilder out = new StringBuilder();
210
+ for (byte value : hmacSha256(key, text)) {
211
+ out.append(Character.forDigit((value >> 4) & 0xf, 16)).append(Character.forDigit(value & 0xf, 16));
212
+ }
213
+ return out.toString();
214
+ }
215
+
216
+ /** hmacSha256Base64(key, text): HMAC-SHA256 of UTF-8 text with a UTF-8 key, in Base64. */
217
+ public static String hmacSha256Base64(String key, String text) {
218
+ return Base64.getEncoder().encodeToString(hmacSha256(key, text));
219
+ }
220
+
221
+ /** A JSON object used as event fields. */
222
+ @SuppressWarnings("unchecked")
223
+ public static Map<String, Object> asMap(Object value) {
224
+ if (!(value instanceof Map)) {
225
+ throw new IllegalStateException(str(value) + " is not an object");
226
+ }
227
+ return (Map<String, Object>) value;
228
+ }
229
+ }
230
+ // @end
@@ -0,0 +1,281 @@
1
+ // sdkloom Java kit: a small, strict JSON reader and writer.
2
+ package dev.sdkloom.runtime;
3
+
4
+ import java.math.BigDecimal;
5
+ import java.nio.charset.StandardCharsets;
6
+ import java.util.ArrayList;
7
+ import java.util.Collections;
8
+ import java.util.LinkedHashMap;
9
+ import java.util.List;
10
+ import java.util.Map;
11
+
12
+ // @block json.codec
13
+ // @summary Parses JSON into maps (keeping key order), lists, strings, BigDecimal numbers, booleans and null, and writes such trees back as compact UTF-8 JSON.
14
+ // @versions >=8
15
+ // @source [1] https://www.rfc-editor.org/rfc/rfc8259#section-7
16
+ // @quote [1] "All Unicode characters may be placed within the quotation marks, except for the characters that MUST be escaped: quotation mark, reverse solidus, and the control characters (U+0000 through U+001F)."
17
+ // @source [2] https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html
18
+ // @quote [2] "Immutable, arbitrary-precision signed decimal numbers."
19
+ // @retrieved 2026-12-05
20
+ // @tests tests/dev/sdkloom/runtime/JsonTest.java
21
+ // @requirement SDKL-JSON-004
22
+ public final class Json {
23
+ private final String text;
24
+ private int index;
25
+
26
+ private Json(String text) {
27
+ this.text = text;
28
+ }
29
+
30
+ /** Parses one JSON text. Numbers become BigDecimal so no digit is lost. */
31
+ public static Object parse(String text) {
32
+ Json reader = new Json(text);
33
+ reader.skipSpace();
34
+ Object value = reader.value();
35
+ reader.skipSpace();
36
+ if (reader.index != text.length()) {
37
+ throw reader.fail("unexpected text after the JSON value");
38
+ }
39
+ return value;
40
+ }
41
+
42
+ /** Writes compact JSON. Accepts maps, lists, strings, numbers, booleans, null and JsonValue. */
43
+ public static String write(Object value) {
44
+ StringBuilder out = new StringBuilder();
45
+ writeTo(out, value);
46
+ return out.toString();
47
+ }
48
+
49
+ public static byte[] encode(Object value) {
50
+ return write(value).getBytes(StandardCharsets.UTF_8);
51
+ }
52
+
53
+ private DecodeException fail(String message) {
54
+ return new DecodeException("$", "invalid JSON at offset " + index + ": " + message);
55
+ }
56
+
57
+ private void skipSpace() {
58
+ while (index < text.length() && " \t\n\r".indexOf(text.charAt(index)) >= 0) {
59
+ index++;
60
+ }
61
+ }
62
+
63
+ private boolean consume(String word) {
64
+ if (text.startsWith(word, index)) {
65
+ index += word.length();
66
+ return true;
67
+ }
68
+ return false;
69
+ }
70
+
71
+ private Object value() {
72
+ if (index >= text.length()) {
73
+ throw fail("unexpected end");
74
+ }
75
+ char next = text.charAt(index);
76
+ if (next == '{') {
77
+ return object();
78
+ }
79
+ if (next == '[') {
80
+ return array();
81
+ }
82
+ if (next == '"') {
83
+ return string();
84
+ }
85
+ if (consume("true")) {
86
+ return Boolean.TRUE;
87
+ }
88
+ if (consume("false")) {
89
+ return Boolean.FALSE;
90
+ }
91
+ if (consume("null")) {
92
+ return null;
93
+ }
94
+ return number();
95
+ }
96
+
97
+ private Map<String, Object> object() {
98
+ Map<String, Object> result = new LinkedHashMap<>();
99
+ index++;
100
+ skipSpace();
101
+ if (consume("}")) {
102
+ return result;
103
+ }
104
+ while (true) {
105
+ skipSpace();
106
+ if (index >= text.length() || text.charAt(index) != '"') {
107
+ throw fail("expected a string key");
108
+ }
109
+ String key = string();
110
+ skipSpace();
111
+ if (!consume(":")) {
112
+ throw fail("expected ':'");
113
+ }
114
+ skipSpace();
115
+ result.put(key, value());
116
+ skipSpace();
117
+ if (consume("}")) {
118
+ return result;
119
+ }
120
+ if (!consume(",")) {
121
+ throw fail("expected ',' or '}'");
122
+ }
123
+ }
124
+ }
125
+
126
+ private List<Object> array() {
127
+ List<Object> result = new ArrayList<>();
128
+ index++;
129
+ skipSpace();
130
+ if (consume("]")) {
131
+ return result;
132
+ }
133
+ while (true) {
134
+ skipSpace();
135
+ result.add(value());
136
+ skipSpace();
137
+ if (consume("]")) {
138
+ return result;
139
+ }
140
+ if (!consume(",")) {
141
+ throw fail("expected ',' or ']'");
142
+ }
143
+ }
144
+ }
145
+
146
+ private String string() {
147
+ StringBuilder out = new StringBuilder();
148
+ index++;
149
+ while (index < text.length()) {
150
+ char c = text.charAt(index++);
151
+ if (c == '"') {
152
+ return out.toString();
153
+ }
154
+ if (c < 0x20) {
155
+ throw fail("control character in string");
156
+ }
157
+ if (c != '\\') {
158
+ out.append(c);
159
+ continue;
160
+ }
161
+ if (index >= text.length()) {
162
+ break;
163
+ }
164
+ char escape = text.charAt(index++);
165
+ switch (escape) {
166
+ case '"': out.append('"'); break;
167
+ case '\\': out.append('\\'); break;
168
+ case '/': out.append('/'); break;
169
+ case 'b': out.append('\b'); break;
170
+ case 'f': out.append('\f'); break;
171
+ case 'n': out.append('\n'); break;
172
+ case 'r': out.append('\r'); break;
173
+ case 't': out.append('\t'); break;
174
+ case 'u':
175
+ if (index + 4 > text.length()) {
176
+ throw fail("short unicode escape");
177
+ }
178
+ try {
179
+ out.append((char) Integer.parseInt(text.substring(index, index + 4), 16));
180
+ } catch (NumberFormatException error) {
181
+ throw fail("invalid unicode escape");
182
+ }
183
+ index += 4;
184
+ break;
185
+ default:
186
+ throw fail("invalid escape \\" + escape);
187
+ }
188
+ }
189
+ throw fail("unterminated string");
190
+ }
191
+
192
+ private BigDecimal number() {
193
+ int start = index;
194
+ while (index < text.length() && "+-0123456789.eE".indexOf(text.charAt(index)) >= 0) {
195
+ index++;
196
+ }
197
+ String token = text.substring(start, index);
198
+ if (!token.matches("-?(0|[1-9][0-9]*)(\\.[0-9]+)?([eE][+-]?[0-9]+)?")) {
199
+ index = start;
200
+ throw fail("unexpected character '" + (start < text.length() ? text.charAt(start) : ' ') + "'");
201
+ }
202
+ return new BigDecimal(token);
203
+ }
204
+
205
+ private static void writeTo(StringBuilder out, Object value) {
206
+ if (value == null) {
207
+ out.append("null");
208
+ } else if (value instanceof JsonValue) {
209
+ writeTo(out, ((JsonValue) value).toJson());
210
+ } else if (value instanceof String) {
211
+ writeString(out, (String) value);
212
+ } else if (value instanceof Boolean) {
213
+ out.append(value.toString());
214
+ } else if (value instanceof BigDecimal) {
215
+ out.append(((BigDecimal) value).toString());
216
+ } else if (value instanceof Double || value instanceof Float) {
217
+ double number = ((Number) value).doubleValue();
218
+ if (Double.isNaN(number) || Double.isInfinite(number)) {
219
+ throw new IllegalArgumentException("JSON has no representation for " + number);
220
+ }
221
+ out.append(Urls.scalar(value));
222
+ } else if (value instanceof Number) {
223
+ out.append(value.toString());
224
+ } else if (value instanceof Map) {
225
+ out.append('{');
226
+ boolean first = true;
227
+ for (Map.Entry<?, ?> entry : ((Map<?, ?>) value).entrySet()) {
228
+ if (!first) {
229
+ out.append(',');
230
+ }
231
+ first = false;
232
+ writeString(out, String.valueOf(entry.getKey()));
233
+ out.append(':');
234
+ writeTo(out, entry.getValue());
235
+ }
236
+ out.append('}');
237
+ } else if (value instanceof List) {
238
+ out.append('[');
239
+ boolean first = true;
240
+ for (Object item : (List<?>) value) {
241
+ if (!first) {
242
+ out.append(',');
243
+ }
244
+ first = false;
245
+ writeTo(out, item);
246
+ }
247
+ out.append(']');
248
+ } else {
249
+ throw new IllegalArgumentException("cannot write " + value.getClass().getName() + " as JSON");
250
+ }
251
+ }
252
+
253
+ private static void writeString(StringBuilder out, String value) {
254
+ out.append('"');
255
+ for (int i = 0; i < value.length(); i++) {
256
+ char c = value.charAt(i);
257
+ if (c == '"') {
258
+ out.append("\\\"");
259
+ } else if (c == '\\') {
260
+ out.append("\\\\");
261
+ } else if (c == '\n') {
262
+ out.append("\\n");
263
+ } else if (c == '\r') {
264
+ out.append("\\r");
265
+ } else if (c == '\t') {
266
+ out.append("\\t");
267
+ } else if (c < 0x20) {
268
+ out.append(String.format("\\u%04x", (int) c));
269
+ } else {
270
+ out.append(c);
271
+ }
272
+ }
273
+ out.append('"');
274
+ }
275
+
276
+ /** An unmodifiable copy of a JSON object, keeping key order. */
277
+ public static Map<String, Object> copy(Map<String, Object> value) {
278
+ return Collections.unmodifiableMap(new LinkedHashMap<>(value));
279
+ }
280
+ }
281
+ // @end
@@ -0,0 +1,15 @@
1
+ // sdkloom Java kit: values that know their JSON form.
2
+ package dev.sdkloom.runtime;
3
+
4
+ // @block json.value
5
+ // @summary Implemented by generated models: toJson() returns the plain JSON tree (maps, lists, strings, numbers, booleans, null).
6
+ // @versions >=8
7
+ // @source [1] https://www.rfc-editor.org/rfc/rfc8259#section-2
8
+ // @quote [1] "A JSON text is a sequence of tokens."
9
+ // @retrieved 2026-12-05
10
+ // @tests tests/dev/sdkloom/runtime/JsonTest.java
11
+ // @requirement SDKL-JSON-001
12
+ public interface JsonValue {
13
+ Object toJson();
14
+ }
15
+ // @end
@@ -0,0 +1,62 @@
1
+ // sdkloom Java kit: following Link headers to the next page.
2
+ package dev.sdkloom.runtime;
3
+
4
+ import java.util.Locale;
5
+ import java.util.regex.Matcher;
6
+ import java.util.regex.Pattern;
7
+
8
+ // @block pagination.link
9
+ // @summary Finds the next page's URL in a Link header (RFC 8288): splits link-values at commas outside <...>, reads the rel parameter (quoted or not, several relation types allowed, compared case-insensitively) and returns the target of rel="next"; resolves it against the base URL.
10
+ // @versions >=8
11
+ // @source [1] https://www.rfc-editor.org/rfc/rfc8288#section-3
12
+ // @quote [1] "The Link header field provides a means for serialising one or more links into HTTP headers."
13
+ // @quote [1] "The rel parameter can, however, contain multiple link relation types."
14
+ // @quote [1] "MUST be compared character by character in a case-insensitive fashion."
15
+ // @retrieved 2026-12-06
16
+ // @tests tests/dev/sdkloom/runtime/LinksTest.java
17
+ // @requirement SDKL-PAGE-001
18
+ public final class Links {
19
+ private static final Pattern LINK_VALUE = Pattern.compile("<([^>]*)>([^,]*)");
20
+ private static final Pattern ABSOLUTE = Pattern.compile("(?i)^https?://.*");
21
+ private static final Pattern ORIGIN = Pattern.compile("(?i)^(https?://[^/]+).*$");
22
+
23
+ private Links() {
24
+ }
25
+
26
+ /** The URL of the link with relation type "next" in a Link header, or null. */
27
+ public static String next(String header) {
28
+ if (header == null) {
29
+ return null;
30
+ }
31
+ Matcher matcher = LINK_VALUE.matcher(header);
32
+ while (matcher.find()) {
33
+ for (String param : matcher.group(2).split(";")) {
34
+ int equals = param.indexOf('=');
35
+ if (equals < 0 || !param.substring(0, equals).trim().equalsIgnoreCase("rel")) {
36
+ continue;
37
+ }
38
+ String types = param.substring(equals + 1).trim().replaceAll("^\"|\"$", "").toLowerCase(Locale.ROOT);
39
+ for (String type : types.split("\\s+")) {
40
+ if (type.equals("next")) {
41
+ return matcher.group(1);
42
+ }
43
+ }
44
+ break;
45
+ }
46
+ }
47
+ return null;
48
+ }
49
+
50
+ /** A URL from the API resolved against the base URL: absolute as is, "/path" on the base's origin, else after it. */
51
+ public static String resolve(String base, String url) {
52
+ if (ABSOLUTE.matcher(url).matches()) {
53
+ return url;
54
+ }
55
+ if (url.startsWith("/")) {
56
+ Matcher origin = ORIGIN.matcher(base);
57
+ return (origin.matches() ? origin.group(1) : base) + url;
58
+ }
59
+ return base.replaceAll("/+$", "") + "/" + url;
60
+ }
61
+ }
62
+ // @end
@@ -0,0 +1,16 @@
1
+ // sdkloom Java kit: a middleware function.
2
+ package dev.sdkloom.runtime;
3
+
4
+ // @block pipeline.middleware
5
+ // @summary A middleware: (request, next, ctx) -> response. It may change the request, call next zero or more times, or answer itself.
6
+ // @versions >=8
7
+ // @source [1] https://www.rfc-editor.org/rfc/rfc9110#section-15.5
8
+ // @quote [1] "The 4xx (Client Error) class of status code indicates that the client seems to have erred."
9
+ // @retrieved 2026-12-05
10
+ // @tests tests/dev/sdkloom/runtime/ClientTest.java
11
+ // @requirement SDKL-PIPE-001
12
+ @FunctionalInterface
13
+ public interface Middleware {
14
+ HttpResponse handle(HttpRequest request, Next next, Context ctx);
15
+ }
16
+ // @end
@@ -0,0 +1,43 @@
1
+ // sdkloom Java kit: a middleware bound to its configuration.
2
+ package dev.sdkloom.runtime;
3
+
4
+ import java.util.Collections;
5
+ import java.util.LinkedHashMap;
6
+ import java.util.Map;
7
+
8
+ // @block pipeline.entry
9
+ // @summary A named middleware bound to its configuration, ready to run for any operation.
10
+ // @versions >=8
11
+ // @source [1] https://www.rfc-editor.org/rfc/rfc9110#section-15.5
12
+ // @quote [1] "The 4xx (Client Error) class of status code indicates that the client seems to have erred."
13
+ // @retrieved 2026-12-05
14
+ // @tests tests/dev/sdkloom/runtime/ClientTest.java
15
+ // @requirement SDKL-PIPE-001
16
+ public final class MiddlewareEntry {
17
+ private final String name;
18
+ private final Middleware middleware;
19
+ private final Map<String, Object> config;
20
+
21
+ private MiddlewareEntry(String name, Middleware middleware, Map<String, Object> config) {
22
+ this.name = name;
23
+ this.middleware = middleware;
24
+ this.config = config;
25
+ }
26
+
27
+ public static MiddlewareEntry of(String name, Middleware middleware, Map<String, Object> config) {
28
+ return new MiddlewareEntry(name, middleware, Collections.unmodifiableMap(new LinkedHashMap<>(config)));
29
+ }
30
+
31
+ public static MiddlewareEntry of(String name, Middleware middleware) {
32
+ return of(name, middleware, Collections.<String, Object>emptyMap());
33
+ }
34
+
35
+ public String name() {
36
+ return name;
37
+ }
38
+
39
+ HttpResponse run(HttpRequest request, Next next, Context base) {
40
+ return middleware.handle(request, next, base.withConfig(config));
41
+ }
42
+ }
43
+ // @end