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,111 @@
1
+ // sdkloom Java kit: one route of a MockTransport.
2
+ package dev.sdkloom.runtime;
3
+
4
+ import java.nio.charset.StandardCharsets;
5
+ import java.util.AbstractMap;
6
+ import java.util.ArrayList;
7
+ import java.util.Collections;
8
+ import java.util.List;
9
+ import java.util.Map;
10
+ import java.util.function.Predicate;
11
+ import java.util.regex.Pattern;
12
+
13
+ // @block testing.mock_route
14
+ // @summary Answers requests for one method and path template in order, repeating the last answer, and records them.
15
+ // @versions >=8
16
+ // @source [1] https://www.rfc-editor.org/rfc/rfc3986#section-3.3
17
+ // @quote [1] "The path component contains data, usually organized in hierarchical form, that, along with data in the non-hierarchical query component (Section 3.4), serves to identify a resource within the scope of the URI's scheme and naming authority (if any)."
18
+ // @retrieved 2026-12-05
19
+ // @tests tests/dev/sdkloom/runtime/TestingTest.java
20
+ // @requirement SDKL-MOCK-002
21
+ public final class MockRoute {
22
+ private final MockTransport transport;
23
+ private final String method;
24
+ private final String template;
25
+ private final Predicate<HttpRequest> predicate;
26
+ private final Pattern pattern;
27
+ private final List<Object> answers = new ArrayList<>();
28
+ private final List<HttpRequest> calls = new ArrayList<>();
29
+
30
+ MockRoute(MockTransport transport, String method, String template, Predicate<HttpRequest> predicate) {
31
+ this.transport = transport;
32
+ this.method = method;
33
+ this.template = template;
34
+ this.predicate = predicate;
35
+ // {name} matches one segment, {+name} one or more.
36
+ StringBuilder regex = new StringBuilder("^");
37
+ java.util.regex.Matcher placeholder = Pattern.compile("\\{([^{}]+)\\}").matcher(template);
38
+ int last = 0;
39
+ while (placeholder.find()) {
40
+ regex.append(Pattern.quote(template.substring(last, placeholder.start())));
41
+ regex.append(placeholder.group(1).startsWith("+") ? ".+" : "[^/]+");
42
+ last = placeholder.end();
43
+ }
44
+ regex.append(Pattern.quote(template.substring(last)));
45
+ this.pattern = Pattern.compile(regex.append("$").toString());
46
+ }
47
+
48
+ /** Whether the route has an answer yet. */
49
+ synchronized boolean answered() {
50
+ return !answers.isEmpty();
51
+ }
52
+
53
+ boolean matches(HttpRequest request) {
54
+ return request.method().equals(method) && pattern.matcher(MockTransport.pathOf(request.url())).matches() && predicate.test(request);
55
+ }
56
+
57
+ /** Adds a JSON answer; pass null json for an empty body. Answers are used in order; the last one repeats. */
58
+ public synchronized MockRoute replyJson(int status, Object json) {
59
+ if (json == null) {
60
+ answers.add(new HttpResponse(status, Collections.<Map.Entry<String, String>>emptyList(), new byte[0]));
61
+ } else {
62
+ answers.add(new HttpResponse(status, Collections.<Map.Entry<String, String>>singletonList(new AbstractMap.SimpleImmutableEntry<>("content-type", "application/json")), Json.encode(json)));
63
+ }
64
+ return this;
65
+ }
66
+
67
+ public synchronized MockRoute replyBytes(int status, byte[] body) {
68
+ answers.add(new HttpResponse(status, Collections.<Map.Entry<String, String>>emptyList(), body));
69
+ return this;
70
+ }
71
+
72
+ /** Answers with an event stream: text in the event-stream format. */
73
+ public synchronized MockRoute replyEvents(int status, String events) {
74
+ answers.add(new HttpResponse(status, Collections.<Map.Entry<String, String>>singletonList(new AbstractMap.SimpleImmutableEntry<>("content-type", "text/event-stream")), events.getBytes(StandardCharsets.UTF_8)));
75
+ return this;
76
+ }
77
+
78
+ public synchronized MockRoute replyText(int status, String body) {
79
+ return replyBytes(status, body.getBytes(StandardCharsets.UTF_8));
80
+ }
81
+
82
+ public synchronized MockRoute replyError(RuntimeException error) {
83
+ answers.add(error);
84
+ return this;
85
+ }
86
+
87
+ /** A new route for the same operation that only answers requests matching the predicate. */
88
+ public MockRoute narrow(Predicate<HttpRequest> narrower) {
89
+ return transport.route(method, template, narrower);
90
+ }
91
+
92
+ public synchronized List<HttpRequest> calls() {
93
+ return Collections.unmodifiableList(new ArrayList<>(calls));
94
+ }
95
+
96
+ HttpResponse answer(HttpRequest request) {
97
+ Object answer;
98
+ synchronized (this) {
99
+ calls.add(request);
100
+ if (answers.isEmpty()) {
101
+ throw new AssertionError("mock for " + method + " " + template + " has no answer");
102
+ }
103
+ answer = answers.get(Math.min(calls.size(), answers.size()) - 1);
104
+ }
105
+ if (answer instanceof RuntimeException) {
106
+ throw (RuntimeException) answer;
107
+ }
108
+ return (HttpResponse) answer;
109
+ }
110
+ }
111
+ // @end
@@ -0,0 +1,62 @@
1
+ // sdkloom Java kit: a transport for tests.
2
+ package dev.sdkloom.runtime;
3
+
4
+ import java.net.URI;
5
+ import java.util.ArrayList;
6
+ import java.util.Collections;
7
+ import java.util.List;
8
+ import java.util.function.Predicate;
9
+
10
+ // @block testing.mock_transport
11
+ // @summary A transport for tests: answers requests from routes registered by method and path template, records every call and fails requests no route answers.
12
+ // @versions >=8
13
+ // @source [1] https://www.rfc-editor.org/rfc/rfc3986#section-3.3
14
+ // @quote [1] "The path component contains data, usually organized in hierarchical form, that, along with data in the non-hierarchical query component (Section 3.4), serves to identify a resource within the scope of the URI's scheme and naming authority (if any)."
15
+ // @retrieved 2026-12-05
16
+ // @tests tests/dev/sdkloom/runtime/TestingTest.java
17
+ // @requirement SDKL-MOCK-001
18
+ public final class MockTransport implements Transport {
19
+ private final List<MockRoute> routes = new ArrayList<>();
20
+ private final List<HttpRequest> calls = new ArrayList<>();
21
+
22
+ public synchronized MockRoute route(String method, String template) {
23
+ return route(method, template, (request) -> true);
24
+ }
25
+
26
+ public synchronized MockRoute route(String method, String template, Predicate<HttpRequest> predicate) {
27
+ MockRoute route = new MockRoute(this, method, template, predicate);
28
+ routes.add(route);
29
+ return route;
30
+ }
31
+
32
+ public synchronized List<HttpRequest> calls() {
33
+ return Collections.unmodifiableList(new ArrayList<>(calls));
34
+ }
35
+
36
+ static String pathOf(String url) {
37
+ return URI.create(url).getRawPath();
38
+ }
39
+
40
+ /** Routes added later take priority, and a route with answers beats one without. */
41
+ @Override
42
+ public HttpResponse send(HttpRequest request, SendOptions options) {
43
+ MockRoute match = null;
44
+ synchronized (this) {
45
+ calls.add(request);
46
+ MockRoute first = null;
47
+ for (int i = routes.size() - 1; i >= 0 && match == null; i--) {
48
+ MockRoute route = routes.get(i);
49
+ if (route.matches(request)) {
50
+ first = first == null ? route : first;
51
+ match = route.answered() ? route : null;
52
+ }
53
+ }
54
+ match = match == null ? first : match;
55
+ }
56
+ if (match == null) {
57
+ throw new AssertionError("no mock for " + request.method() + " " + pathOf(request.url()));
58
+ }
59
+ return match.answer(request);
60
+ }
61
+ }
62
+ // @end
@@ -0,0 +1,111 @@
1
+ // sdkloom Java kit: multipart/form-data request bodies.
2
+ package dev.sdkloom.runtime;
3
+
4
+ import java.io.ByteArrayOutputStream;
5
+ import java.nio.charset.StandardCharsets;
6
+ import java.util.ArrayList;
7
+ import java.util.Collections;
8
+ import java.util.List;
9
+ import java.util.UUID;
10
+
11
+ // @block http.multipart
12
+ // @summary A multipart/form-data body (RFC 7578) built from text fields and files, immutable; encoded with a random boundary, one part per field with a Content-Disposition naming it (and the file name for files), quotes and line breaks in names percent-encoded.
13
+ // @versions >=8
14
+ // @source [1] https://www.rfc-editor.org/rfc/rfc7578#section-4.2
15
+ // @quote [1] "Each part MUST contain a Content-Disposition header field"
16
+ // @source [2] https://www.rfc-editor.org/rfc/rfc7578#section-4.1
17
+ // @quote [2] "As with other multipart types, the parts are delimited with a boundary delimiter"
18
+ // @retrieved 2026-12-06
19
+ // @tests tests/dev/sdkloom/runtime/MultipartFormTest.java
20
+ // @requirement SDKL-HTTP-005
21
+ public final class MultipartForm {
22
+ /** One part: a text field, or a file when filename is set. */
23
+ public static final class Part {
24
+ private final String name;
25
+ private final byte[] value;
26
+ private final String filename;
27
+ private final String contentType;
28
+
29
+ Part(String name, byte[] value, String filename, String contentType) {
30
+ this.name = name;
31
+ this.value = value.clone();
32
+ this.filename = filename;
33
+ this.contentType = contentType;
34
+ }
35
+
36
+ public String name() {
37
+ return name;
38
+ }
39
+
40
+ public byte[] value() {
41
+ return value.clone();
42
+ }
43
+
44
+ public String filename() {
45
+ return filename;
46
+ }
47
+
48
+ public String contentType() {
49
+ return contentType;
50
+ }
51
+ }
52
+
53
+ private final List<Part> parts;
54
+
55
+ public MultipartForm() {
56
+ this(Collections.<Part>emptyList());
57
+ }
58
+
59
+ private MultipartForm(List<Part> parts) {
60
+ this.parts = Collections.unmodifiableList(parts);
61
+ }
62
+
63
+ public List<Part> parts() {
64
+ return parts;
65
+ }
66
+
67
+ /** A copy with a text field added. */
68
+ public MultipartForm field(String name, String value) {
69
+ return with(new Part(name, value.getBytes(StandardCharsets.UTF_8), null, null));
70
+ }
71
+
72
+ /** A copy with a file added. */
73
+ public MultipartForm file(String name, String filename, String contentType, byte[] data) {
74
+ return with(new Part(name, data, filename, contentType));
75
+ }
76
+
77
+ private MultipartForm with(Part part) {
78
+ List<Part> next = new ArrayList<>(parts);
79
+ next.add(part);
80
+ return new MultipartForm(next);
81
+ }
82
+
83
+ private static String quoted(String text) {
84
+ return "\"" + text.replace("\"", "%22").replace("\r", "%0D").replace("\n", "%0A") + "\"";
85
+ }
86
+
87
+ /** The body bytes for this boundary. */
88
+ public byte[] encode(String boundary) {
89
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
90
+ for (Part part : parts) {
91
+ StringBuilder head = new StringBuilder("--").append(boundary).append("\r\nContent-Disposition: form-data; name=").append(quoted(part.name));
92
+ if (part.filename != null) {
93
+ head.append("; filename=").append(quoted(part.filename)).append("\r\nContent-Type: ").append(part.contentType == null ? "application/octet-stream" : part.contentType);
94
+ }
95
+ byte[] text = head.append("\r\n\r\n").toString().getBytes(StandardCharsets.UTF_8);
96
+ out.write(text, 0, text.length);
97
+ out.write(part.value, 0, part.value.length);
98
+ out.write('\r');
99
+ out.write('\n');
100
+ }
101
+ byte[] end = ("--" + boundary + "--\r\n").getBytes(StandardCharsets.UTF_8);
102
+ out.write(end, 0, end.length);
103
+ return out.toByteArray();
104
+ }
105
+
106
+ /** A random boundary. */
107
+ public static String boundary() {
108
+ return "sdkloom-" + UUID.randomUUID();
109
+ }
110
+ }
111
+ // @end
@@ -0,0 +1,16 @@
1
+ // sdkloom Java kit: the rest of the middleware chain.
2
+ package dev.sdkloom.runtime;
3
+
4
+ // @block pipeline.next
5
+ // @summary Calls the rest of the middleware chain and finally the transport; may be called zero or more times.
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 Next {
14
+ HttpResponse call(HttpRequest request);
15
+ }
16
+ // @end
@@ -0,0 +1,35 @@
1
+ // sdkloom Java kit: which operation a middleware is running for.
2
+ package dev.sdkloom.runtime;
3
+
4
+ // @block context.operation
5
+ // @summary The name, method and path template of the operation being called.
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
+ public final class OperationInfo {
13
+ private final String name;
14
+ private final String method;
15
+ private final String path;
16
+
17
+ public OperationInfo(String name, String method, String path) {
18
+ this.name = name;
19
+ this.method = method;
20
+ this.path = path;
21
+ }
22
+
23
+ public String name() {
24
+ return name;
25
+ }
26
+
27
+ public String method() {
28
+ return method;
29
+ }
30
+
31
+ public String path() {
32
+ return path;
33
+ }
34
+ }
35
+ // @end
@@ -0,0 +1,105 @@
1
+ // sdkloom Java kit: a typed mock for one operation.
2
+ package dev.sdkloom.runtime;
3
+
4
+ import java.util.ArrayList;
5
+ import java.util.List;
6
+ import java.util.function.Function;
7
+ import java.util.function.Predicate;
8
+
9
+ // @block testing.operation_mock
10
+ // @summary A typed mock for one operation: returns() turns values into their wire form and checks them against the response type, fails() and raises() simulate errors, calls() records requests.
11
+ // @versions >=8
12
+ // @source [1] https://www.rfc-editor.org/rfc/rfc3986#section-3.3
13
+ // @quote [1] "The path component contains data, usually organized in hierarchical form, that, along with data in the non-hierarchical query component (Section 3.4), serves to identify a resource within the scope of the URI's scheme and naming authority (if any)."
14
+ // @retrieved 2026-12-05
15
+ // @tests tests/dev/sdkloom/runtime/TestingTest.java
16
+ // @requirement SDKL-MOCK-002
17
+ public final class OperationMock {
18
+ private final String name;
19
+ private final MockRoute route;
20
+ private final Decoder<?> decode;
21
+ private final Function<Object, Object> encode;
22
+ private final boolean events;
23
+
24
+ /** encode turns a value given to returns() into its JSON tree, e.g. adding a union tag; null when no help is needed. */
25
+ public OperationMock(String name, MockRoute route, Decoder<?> decode, Function<Object, Object> encode) {
26
+ this(name, route, decode, encode, false);
27
+ }
28
+
29
+ /** For an event stream (events true), returns() takes a List of ServerSentEvent; decode and encode apply to each data. */
30
+ public OperationMock(String name, MockRoute route, Decoder<?> decode, Function<Object, Object> encode, boolean events) {
31
+ this.name = name;
32
+ this.route = route;
33
+ this.decode = decode;
34
+ this.encode = encode;
35
+ this.events = events;
36
+ }
37
+
38
+ public OperationMock(String name, MockRoute route, Decoder<?> decode) {
39
+ this(name, route, decode, null);
40
+ }
41
+
42
+ public String name() {
43
+ return name;
44
+ }
45
+
46
+ /** Answers with a success; the value is checked against the operation's response type first. */
47
+ public OperationMock returns(Object value) {
48
+ if (events) {
49
+ List<ServerSentEvent<Object>> written = new ArrayList<>();
50
+ for (Object item : (List<?>) value) {
51
+ ServerSentEvent<?> event = (ServerSentEvent<?>) item;
52
+ Object wire = event.data() == null || encode == null ? event.data() : encode.apply(event.data());
53
+ if (decode != null) {
54
+ decode.decode(Json.parse(Json.write(wire)), "$");
55
+ }
56
+ written.add(new ServerSentEvent<>(event.event(), event.id(), wire));
57
+ }
58
+ route.replyEvents(200, EventStream.encode(written));
59
+ return this;
60
+ }
61
+ if (value instanceof byte[]) {
62
+ route.replyBytes(200, (byte[]) value);
63
+ return this;
64
+ }
65
+ Object wire = value == null || encode == null ? value : encode.apply(value);
66
+ if (wire != null && decode != null) {
67
+ decode.decode(Json.parse(Json.write(wire)), "$");
68
+ }
69
+ route.replyJson(200, wire);
70
+ return this;
71
+ }
72
+
73
+ /** Answers with an HTTP error status and no body. */
74
+ public OperationMock fails(int status) {
75
+ route.replyJson(status, null);
76
+ return this;
77
+ }
78
+
79
+ /** Answers with an HTTP error status and a JSON body. */
80
+ public OperationMock fails(int status, Object body) {
81
+ route.replyJson(status, body);
82
+ return this;
83
+ }
84
+
85
+ /** Makes the call fail without a response, e.g. new TransportException("timeout", null). */
86
+ public OperationMock raises(RuntimeException error) {
87
+ route.replyError(error);
88
+ return this;
89
+ }
90
+
91
+ /** Reads naturally between answers: mock.getPayment().fails(503).then().returns(value). */
92
+ public OperationMock then() {
93
+ return this;
94
+ }
95
+
96
+ /** A mock for the same operation that only answers requests matching the predicate. */
97
+ public OperationMock when(Predicate<HttpRequest> predicate) {
98
+ return new OperationMock(name, route.narrow(predicate), decode, encode, events);
99
+ }
100
+
101
+ public List<HttpRequest> calls() {
102
+ return route.calls();
103
+ }
104
+ }
105
+ // @end
@@ -0,0 +1,125 @@
1
+ // sdkloom Java kit: how to call one operation.
2
+ package dev.sdkloom.runtime;
3
+
4
+ import java.util.ArrayList;
5
+ import java.util.Collections;
6
+ import java.util.LinkedHashMap;
7
+ import java.util.List;
8
+ import java.util.Map;
9
+
10
+ // @block client.spec
11
+ // @summary Everything the runtime needs to call one operation: method, path, parameters, body and result kinds, the result decoder, named errors and operation middleware.
12
+ // @versions >=8
13
+ // @source [1] https://www.rfc-editor.org/rfc/rfc9110#section-15.5
14
+ // @quote [1] "The 4xx (Client Error) class of status code indicates that the client seems to have erred."
15
+ // @source [2] https://www.rfc-editor.org/rfc/rfc9110#section-15.6
16
+ // @quote [2] "The 5xx (Server Error) class of status code indicates that the server is aware that it has erred or is incapable of performing the requested method."
17
+ // @retrieved 2026-12-05
18
+ // @tests tests/dev/sdkloom/runtime/ClientTest.java
19
+ // @requirement SDKL-ERR-001
20
+ public final class OperationSpec {
21
+ /** Where a parameter goes: "path", "query" or "header". */
22
+ public static final class Param {
23
+ final String name;
24
+ final String location;
25
+
26
+ Param(String name, String location) {
27
+ this.name = name;
28
+ this.location = location;
29
+ }
30
+ }
31
+
32
+ final String name;
33
+ final String method;
34
+ final String path;
35
+ final List<Param> params;
36
+ /** "json", "bytes", "stream", "multipart" or null. */
37
+ final String body;
38
+ /** "json", "bytes", "stream", "events" (server-sent events; decode reads each event's data, null keeps text) or null. */
39
+ final String result;
40
+ final Decoder<?> decode;
41
+ final Map<Integer, ErrorFactory> errors;
42
+ final List<String> use;
43
+ /** The first API version that has the operation, or null. */
44
+ final String since;
45
+
46
+ private OperationSpec(Builder builder) {
47
+ this.since = builder.since;
48
+ this.name = builder.name;
49
+ this.method = builder.method;
50
+ this.path = builder.path;
51
+ this.params = Collections.unmodifiableList(new ArrayList<>(builder.params));
52
+ this.body = builder.body;
53
+ this.result = builder.result;
54
+ this.decode = builder.decode;
55
+ this.errors = Collections.unmodifiableMap(new LinkedHashMap<>(builder.errors));
56
+ this.use = Collections.unmodifiableList(new ArrayList<>(builder.use));
57
+ }
58
+
59
+ public static Builder builder(String name, String method, String path) {
60
+ return new Builder(name, method, path);
61
+ }
62
+
63
+ public String name() {
64
+ return name;
65
+ }
66
+
67
+ public static final class Builder {
68
+ private final String name;
69
+ private final String method;
70
+ private final String path;
71
+ private final List<Param> params = new ArrayList<>();
72
+ private String body;
73
+ private String result;
74
+ private Decoder<?> decode;
75
+ private final Map<Integer, ErrorFactory> errors = new LinkedHashMap<>();
76
+ private final List<String> use = new ArrayList<>();
77
+ private String since;
78
+
79
+ private Builder(String name, String method, String path) {
80
+ this.name = name;
81
+ this.method = method;
82
+ this.path = path;
83
+ }
84
+
85
+ public Builder param(String paramName, String location) {
86
+ params.add(new Param(paramName, location));
87
+ return this;
88
+ }
89
+
90
+ public Builder body(String kind) {
91
+ this.body = kind;
92
+ return this;
93
+ }
94
+
95
+ public Builder result(String kind) {
96
+ this.result = kind;
97
+ return this;
98
+ }
99
+
100
+ public Builder decode(Decoder<?> decoder) {
101
+ this.decode = decoder;
102
+ return this;
103
+ }
104
+
105
+ public Builder error(int status, ErrorFactory factory) {
106
+ errors.put(status, factory);
107
+ return this;
108
+ }
109
+
110
+ public Builder since(String version) {
111
+ this.since = version;
112
+ return this;
113
+ }
114
+
115
+ public Builder use(String middleware) {
116
+ use.add(middleware);
117
+ return this;
118
+ }
119
+
120
+ public OperationSpec build() {
121
+ return new OperationSpec(this);
122
+ }
123
+ }
124
+ }
125
+ // @end
@@ -0,0 +1,55 @@
1
+ // sdkloom Java kit: iterating over every item of a paginated operation.
2
+ package dev.sdkloom.runtime;
3
+
4
+ import java.util.Collections;
5
+ import java.util.Iterator;
6
+ import java.util.List;
7
+ import java.util.NoSuchElementException;
8
+ import java.util.function.Function;
9
+
10
+ // @block pagination.iterate
11
+ // @summary Walks the pages of a paginated operation lazily: fetches a page, yields its items, asks for the next call's parameters (null ends), so callers write one for-each loop.
12
+ // @versions >=8
13
+ // @source [1] https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html
14
+ // @quote [1] "An iterator over a collection."
15
+ // @retrieved 2026-12-05
16
+ // @tests tests/dev/sdkloom/runtime/PagesTest.java
17
+ // @requirement SDKL-PAGE-001
18
+ public final class Pages {
19
+ private Pages() {
20
+ }
21
+
22
+ /** The parameters of the next call, or null after the last page. */
23
+ @FunctionalInterface
24
+ public interface NextPage<P, R, T> {
25
+ P next(P params, R page, List<T> items);
26
+ }
27
+
28
+ /** Every item of every page, fetched one page at a time as the caller iterates; each iterator starts again. */
29
+ public static <P, R, T> Iterable<T> iterate(P first, Function<P, R> fetch, Function<R, List<T>> items, NextPage<P, R, T> next) {
30
+ return () -> new Iterator<T>() {
31
+ private P params = first;
32
+ private Iterator<T> current = Collections.<T>emptyIterator();
33
+
34
+ @Override
35
+ public boolean hasNext() {
36
+ while (!current.hasNext() && params != null) {
37
+ R page = fetch.apply(params);
38
+ List<T> found = items.apply(page);
39
+ params = next.next(params, page, found);
40
+ current = found.iterator();
41
+ }
42
+ return current.hasNext();
43
+ }
44
+
45
+ @Override
46
+ public T next() {
47
+ if (!hasNext()) {
48
+ throw new NoSuchElementException();
49
+ }
50
+ return current.next();
51
+ }
52
+ };
53
+ }
54
+ }
55
+ // @end
@@ -0,0 +1,29 @@
1
+ // sdkloom Java kit: running middleware in order.
2
+ package dev.sdkloom.runtime;
3
+
4
+ import java.util.List;
5
+
6
+ // @block pipeline.run
7
+ // @summary Runs middleware in order around the transport; each middleware may call next zero or more times.
8
+ // @versions >=8
9
+ // @source [1] https://www.rfc-editor.org/rfc/rfc9110#section-15.5
10
+ // @quote [1] "The 4xx (Client Error) class of status code indicates that the client seems to have erred."
11
+ // @retrieved 2026-12-05
12
+ // @tests tests/dev/sdkloom/runtime/ClientTest.java
13
+ // @requirement SDKL-PIPE-001
14
+ public final class Pipeline {
15
+ private Pipeline() {
16
+ }
17
+
18
+ public static HttpResponse run(List<MiddlewareEntry> entries, Context base, HttpRequest request, Next last) {
19
+ return step(entries, base, 0, last).call(request);
20
+ }
21
+
22
+ private static Next step(List<MiddlewareEntry> entries, Context base, int index, Next last) {
23
+ if (index >= entries.size()) {
24
+ return last;
25
+ }
26
+ return (current) -> entries.get(index).run(current, step(entries, base, index + 1, last), base);
27
+ }
28
+ }
29
+ // @end