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,177 @@
1
+ // sdkloom test — builds, runs every scenario against every target, then runs the author's tests per language.
2
+
3
+ import { mkdtempSync, readFileSync, rmSync } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { join } from "node:path";
6
+ import { renderMatrix, } from "@sdkloom/conformance";
7
+
8
+ import { buildInMemory, writeBuild, } from "../build.ts";
9
+ import { apiCoverage, renderCoverage, } from "../coverage.ts";
10
+ import { listFiles, } from "../io.ts";
11
+ import { LANGUAGE_MODULES, languageModule } from "../languages/index.ts";
12
+
13
+ import { loadProject } from "../project.ts";
14
+ import { judge, loadScenarios, sameJson, } from "../scenarios.ts";
15
+ import { portabilityReport } from "../portability.ts";
16
+ import { installed, runtimesFor, } from "../runtimes.ts";
17
+ import { schemaSamples, } from "../schema.ts";
18
+ import { messageOf, reportBuilt } from "./build.ts";
19
+
20
+ function workspace() {
21
+ const dir = mkdtempSync(join(tmpdir(), "sdkloom-test-"));
22
+ const results = new Map ();
23
+ return {
24
+ path: (name) => join(dir, name),
25
+ once: (key , make ) => {
26
+ if (!results.has(key)) results.set(key, make());
27
+ return results.get(key) ;
28
+ },
29
+ dispose: () => rmSync(dir, { recursive: true, force: true }),
30
+ };
31
+ }
32
+
33
+ /** One matrix column: a target on one runtime version. */
34
+
35
+
36
+
37
+
38
+
39
+ function columnsOf(targets , options ) {
40
+ const runtimes = targets.flatMap((target) => runtimesFor(target.language, target.name, target.profile, options));
41
+ const columns = targets.flatMap((target) => installed(runtimes.filter((runtime) => runtime.target === target.name)).map((runtime) => ({ target, runtime })));
42
+ return { columns, runtimes };
43
+ }
44
+
45
+ function context(root , column , ir , ws , io ) {
46
+ return { root, target: column.target, runtime: column.runtime, ir, ws, io };
47
+ }
48
+
49
+ /** Runs one column, turning a harness that cannot start (an interpreter too old, say) into a problem for that column. */
50
+ function attempt (column , problems , run ) {
51
+ try {
52
+ return run();
53
+ } catch (error ) {
54
+ problems.push(`${column.runtime.label}: ${messageOf(error)}`);
55
+ return new Map();
56
+ }
57
+ }
58
+
59
+ function printMatrix(cases , columns , results , io ) {
60
+ renderMatrix({ cases, languages: columns, results })
61
+ .trimEnd()
62
+ .split("\n")
63
+ .forEach((line) => io.out(line));
64
+ }
65
+
66
+ /** Runs the scenarios on every column; returns whether all passed. */
67
+ function runScenarios(root , loaded , all , columns , ir , io , ws ) {
68
+ if (loaded.length === 0) return true;
69
+ const valid = loaded.flatMap((entry) => (entry.scenario === undefined ? [] : [entry.scenario]));
70
+ const results = new Map ();
71
+ const problems = [];
72
+ for (const entry of loaded.filter((item) => item.issues.length > 0)) {
73
+ entry.issues.forEach((issue) => problems.push(`${entry.id}: ${issue}`));
74
+ columns.forEach((column) => results.set(`${column.runtime.label}:${entry.id}`, "fail"));
75
+ }
76
+ for (const column of columns) {
77
+ const observations = attempt(column, problems, () => languageModule(column.target.language).observe(context(root, column, ir, ws, io), valid));
78
+ for (const scenario of valid) {
79
+ const observation = observations.get(scenario.id);
80
+ const found = observation === undefined ? ["the harness reported nothing"] : judge(scenario, observation);
81
+ found.forEach((problem) => problems.push(`${column.runtime.label} ${scenario.id}: ${problem}`));
82
+ results.set(`${column.runtime.label}:${scenario.id}`, found.length === 0 ? "pass" : "fail");
83
+ }
84
+ }
85
+ problems.forEach((line) => io.out(line));
86
+ printMatrix(loaded, all.map((runtime) => runtime.label), results, io);
87
+ return columns.every((column) => loaded.every((entry) => results.get(`${column.runtime.label}:${entry.id}`) === "pass"));
88
+ }
89
+
90
+ function roundTripProblem(sample , outcome ) {
91
+ if (outcome === undefined) return "the SDK reported nothing";
92
+ if (!outcome.ok) return `${outcome.error}: ${outcome.message}`;
93
+ return sameJson(outcome.value, sample.value) ? undefined : `expected ${JSON.stringify(sample.value)}, got ${JSON.stringify(outcome.value)}`;
94
+ }
95
+
96
+ /** Every model and union sample must decode and re-encode unchanged on every column; returns whether all did. */
97
+ function runSchemaRoundTrip(root , all , columns , ir , io , ws ) {
98
+ const samples = schemaSamples(ir);
99
+ if (samples.length === 0) return true;
100
+ const results = new Map ();
101
+ const problems = [];
102
+ for (const column of columns) {
103
+ const outcomes = attempt(column, problems, () => languageModule(column.target.language).roundTrip(context(root, column, ir, ws, io), samples));
104
+ for (const sample of samples) {
105
+ const problem = roundTripProblem(sample, outcomes.get(sample.id));
106
+ if (problem !== undefined) problems.push(`${column.runtime.label} schema ${sample.id}: ${problem}`);
107
+ results.set(`${column.runtime.label}:${sample.id}`, problem === undefined ? "pass" : "fail");
108
+ }
109
+ }
110
+ problems.forEach((line) => io.out(line));
111
+ io.out("schema round-trip");
112
+ printMatrix(samples.map(({ id }) => ({ id, name: id })), all.map((runtime) => runtime.label), results, io);
113
+ return [...results.values()].every((outcome) => outcome === "pass");
114
+ }
115
+
116
+ /** Every author test file, in any language, for the API coverage report. */
117
+ function testSources(root , dir ) {
118
+ return listFiles(join(root, dir))
119
+ .filter((path) => LANGUAGE_MODULES.some((module) => module.testFile.test(path)))
120
+ .map((path) => ({ file: `${dir}/${path}`, text: readFileSync(join(root, dir, path), "utf8") }));
121
+ }
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+ /** Says which runtime versions run in containers and which are missing; returns whether that is acceptable. */
135
+ function reportMissing(runtimes , strict , io ) {
136
+ runtimes.filter((runtime) => runtime.image !== undefined).forEach((runtime) => io.out(`${runtime.label} runs in ${runtime.image ?? ""}`));
137
+ const missing = runtimes.filter((runtime) => runtime.command === undefined);
138
+ missing.forEach((runtime) => io.out(`${runtime.label} not run: not installed; ${runtime.hint}`));
139
+ return !strict || missing.length === 0;
140
+ }
141
+
142
+ /** Builds and writes the SDK, then runs scenarios and tests from the given directories on every runtime version. */
143
+ export async function runSuite(io , options ) {
144
+ const ws = workspace();
145
+ try {
146
+ const project = await loadProject(io.cwd);
147
+ const result = buildInMemory(project);
148
+ writeBuild(io.cwd, result);
149
+ reportBuilt(result, io);
150
+
151
+ const { columns, runtimes } = columnsOf(result.targets, options.container === true ? { container: { projectRoot: io.cwd } } : {});
152
+ const complete = reportMissing(runtimes, options.strict ?? false, io);
153
+ const scenarios = loadScenarios(io.cwd, options.scenariosDir);
154
+ const scenariosPassed = runScenarios(io.cwd, scenarios, runtimes, columns, result.ir, io, ws);
155
+ const schemaPassed = options.full ? runSchemaRoundTrip(io.cwd, runtimes, columns, result.ir, io, ws) : true;
156
+ // Informational: Node.js-only APIs keep the TypeScript SDK out of browsers and edge workers.
157
+ if (options.full) result.targets.filter((target) => target.language === "typescript").forEach((target) => portabilityReport(target.files).forEach((line) => io.out(line)));
158
+ const testsPassed = result.targets.map((target) =>
159
+ languageModule(target.language).authorTests({ root: io.cwd, dir: options.testsDir, ir: result.ir, target, runtimes: runtimes.filter((runtime) => runtime.target === target.name), ws, io }),
160
+ );
161
+ if (options.full) renderCoverage(apiCoverage(result.ir, scenarios, testSources(io.cwd, options.testsDir))).forEach((line) => io.out(line));
162
+ return complete && scenariosPassed && schemaPassed && testsPassed.every(Boolean);
163
+ } finally {
164
+ ws.dispose();
165
+ }
166
+ }
167
+
168
+ export async function testCommand(io , strict = false, container = false) {
169
+ try {
170
+ const project = await loadProject(io.cwd);
171
+ const passed = await runSuite(io, { scenariosDir: project.config.scenarios ?? "scenarios", testsDir: project.config.tests ?? "tests", full: true, strict, container });
172
+ return passed ? 0 : 1;
173
+ } catch (error ) {
174
+ io.err(messageOf(error));
175
+ return 1;
176
+ }
177
+ }
@@ -0,0 +1,32 @@
1
+ // sdkloom variants <language> — the kit lines a language offers: the default package and the variants below its range.
2
+
3
+ import { profilesOf, } from "../build.ts";
4
+ import { LANGUAGE_MODULES } from "../languages/index.ts";
5
+
6
+
7
+
8
+ const LANGUAGES = LANGUAGE_MODULES.map((module) => module.language);
9
+
10
+ function strategies(profile ) {
11
+ const entries = Object.entries(profile.strategies);
12
+ return entries.length === 0 ? "" : ` ${entries.map(([name, value]) => `${name}=${value}`).join(", ")}`;
13
+ }
14
+
15
+ function describe(label , profile ) {
16
+ const tested = profile.test.length === 0 ? "" : `, tested on ${profile.test.join(", ")}`;
17
+ return ` ${label.padEnd(10)}${profile.range}${tested}${strategies(profile)}`;
18
+ }
19
+
20
+ export function variantsCommand(language , io ) {
21
+ if (language === undefined || !LANGUAGES.includes(language )) {
22
+ io.err(`name a language: ${LANGUAGES.join(", ")}`);
23
+ return 1;
24
+ }
25
+ const { base, variants } = profilesOf(language );
26
+ io.out(`${language}:`);
27
+ io.out(describe("default", base));
28
+ [...variants].forEach(([name, profile]) => io.out(describe(name, profile)));
29
+ if (variants.size === 0) io.out(" no variants");
30
+ else io.out(`Add one to sdkloom.config.ts: targets.${language}.variants: { ${[...variants.keys()][0] ?? ""}: {} }`);
31
+ return 0;
32
+ }
@@ -0,0 +1,57 @@
1
+ // sdkloom verify — every check an SDK author runs before a release, in one command: the build is reproducible, every
2
+ // scenario and test passes in every language, an API change since the released version comes with a new version, and
3
+ // every target packages for its registry.
4
+
5
+ import { gitHasRef } from "../git.ts";
6
+
7
+ import { loadProject } from "../project.ts";
8
+ import { buildCommand, messageOf } from "./build.ts";
9
+ import { compare } from "./diff.ts";
10
+ import { publishCommand } from "./publish.ts";
11
+ import { testCommand } from "./test.ts";
12
+
13
+
14
+
15
+
16
+
17
+
18
+ /** Fails when the API changed since the tag of the current version: that version is already out. */
19
+ async function versionStep(io ) {
20
+ try {
21
+ const project = await loadProject(io.cwd);
22
+ const tag = `v${project.config.version}`;
23
+ if (!gitHasRef(io.cwd, tag)) {
24
+ io.out(`${tag} is not tagged yet; nothing to compare`);
25
+ return 0;
26
+ }
27
+ const { changes } = await compare(io.cwd, tag);
28
+ if (changes.length === 0) {
29
+ io.out(`no API changes since ${tag}`);
30
+ return 0;
31
+ }
32
+ io.err(`the API changed since ${tag} (${changes.length} change${changes.length === 1 ? "" : "s"}); run sdkloom version before releasing`);
33
+ return 1;
34
+ } catch (error ) {
35
+ io.err(messageOf(error));
36
+ return 1;
37
+ }
38
+ }
39
+
40
+ export async function verifyCommand(io ) {
41
+ const steps = [
42
+ { name: "build --check", run: () => buildCommand(io, true) },
43
+ { name: "test", run: () => testCommand(io) },
44
+ { name: "version", run: () => versionStep(io) },
45
+ { name: "publish --dry-run", run: () => publishCommand(io, true, false) },
46
+ ];
47
+ const results = [];
48
+ for (const step of steps) {
49
+ io.out(`▶ ${step.name}`);
50
+ results.push([step.name, (await step.run()) === 0]);
51
+ }
52
+ io.out("");
53
+ results.forEach(([name, passed]) => io.out(`${passed ? "✓" : "✗"} ${name}`));
54
+ const failed = results.filter(([, passed]) => !passed).length;
55
+ io.out(failed === 0 ? "verify passed" : `verify failed: ${failed} of ${results.length} steps`);
56
+ return failed === 0 ? 0 : 1;
57
+ }
@@ -0,0 +1,63 @@
1
+ // sdkloom version [--bump major|minor|patch] [--date YYYY-MM-DD] — sets the next version from the API changes, writes
2
+ // the CHANGELOG entry (and a migration guide for breaking changes) and rebuilds. Committing and tagging stay with you.
3
+
4
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
5
+ import { join } from "node:path";
6
+ import { bumpOf, changelogEntry, migrationGuide, nextVersion, } from "@sdkloom/differ";
7
+ import { buildInMemory, writeBuild } from "../build.ts";
8
+
9
+ import { CONFIG_FILE, loadProject } from "../project.ts";
10
+ import { messageOf, reportBuilt } from "./build.ts";
11
+ import { compare, reportChanges } from "./diff.ts";
12
+
13
+ const RANK = { patch: 0, minor: 1, major: 2 };
14
+ const CHANGELOG = "CHANGELOG.md";
15
+ const MIGRATIONS = "migrations";
16
+
17
+ function today() {
18
+ return new Date().toISOString().slice(0, 10);
19
+ }
20
+
21
+ export async function versionCommand(io , requested , dateArg ) {
22
+ try {
23
+ if (requested !== undefined && !["major", "minor", "patch"].includes(requested)) throw new Error(`--bump must be major, minor or patch, not ${requested}`);
24
+ const date = dateArg ?? today();
25
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) throw new Error(`--date must be YYYY-MM-DD, not ${date}`);
26
+ const comparison = await compare(io.cwd, undefined);
27
+ reportChanges(comparison, io);
28
+ const needed = bumpOf(comparison.changes, comparison.languages);
29
+ const bump = (requested ) ?? needed;
30
+ if (RANK[bump] < RANK[needed]) throw new Error(`the API changes need a ${needed} release; --bump ${bump} would hide them`);
31
+
32
+ const current = comparison.project.config.version;
33
+ const next = nextVersion(current, bump);
34
+ const configPath = join(io.cwd, CONFIG_FILE);
35
+ const config = readFileSync(configPath, "utf8");
36
+ const pattern = new RegExp(`(version:\\s*["'])${current.replaceAll(".", "\\.")}(["'])`);
37
+ if (!pattern.test(config)) throw new Error(`could not find version: "${current}" in ${CONFIG_FILE}`);
38
+ writeFileSync(configPath, config.replace(pattern, `$1${next}$2`));
39
+
40
+ const changelogPath = join(io.cwd, CHANGELOG);
41
+ const existing = existsSync(changelogPath) ? readFileSync(changelogPath, "utf8").replace(/^# Changelog\n+/, "") : "";
42
+ writeFileSync(changelogPath, `# Changelog\n\n${changelogEntry(next, date, comparison.changes, comparison.languages)}\n${existing}`.replace(/\n+$/, "\n"));
43
+ io.out(`wrote ${CHANGELOG}`);
44
+
45
+ if (needed === "major") {
46
+ mkdirSync(join(io.cwd, MIGRATIONS), { recursive: true });
47
+ writeFileSync(join(io.cwd, MIGRATIONS, `${next}.md`), `${migrationGuide(next, comparison.before, comparison.after, comparison.changes, comparison.languages)}\n`.replace(/\n+$/, "\n"));
48
+ io.out(`wrote ${MIGRATIONS}/${next}.md`);
49
+ }
50
+ comparison.changes
51
+ .filter((change) => change.rule === "OPERATION-REMOVED" && change.message.includes("without being deprecated first"))
52
+ .forEach((change) => io.out(`warning: ${change.path} was removed without being deprecated in an earlier release`));
53
+
54
+ const result = buildInMemory(await loadProject(io.cwd));
55
+ writeBuild(io.cwd, result);
56
+ reportBuilt(result, io);
57
+ io.out(`version ${current} → ${next}. Next: commit, then tag v${next}`);
58
+ return 0;
59
+ } catch (error ) {
60
+ io.err(messageOf(error));
61
+ return 1;
62
+ }
63
+ }
@@ -0,0 +1,82 @@
1
+ // Runtimes from official container images, for versions not installed here (`sdkloom test --container`).
2
+ // The images are runtime environments, not libraries: python:2.7-slim, eclipse-temurin:8-jdk, node:18-slim.
3
+
4
+ import { spawnSync } from "node:child_process";
5
+ import { tmpdir } from "node:os";
6
+ import { join } from "node:path";
7
+
8
+ import { languageModule } from "./languages/index.ts";
9
+
10
+ export const DOCKER = process.env["SDKLOOM_DOCKER"] ?? "docker";
11
+
12
+ /** The sdkloom checkout: harness scripts and kits live here. */
13
+ const SDKLOOM_ROOT = join(import.meta.dirname, "..", "..", "..");
14
+
15
+ /**
16
+ * Variables the harnesses, test runners and language modules set (Go, cargo and dotnet stay offline and quiet); forwarded
17
+ * from sdkloom's environment into the container.
18
+ */
19
+ const FORWARDED = [
20
+ "PYTHONPATH",
21
+ "PYTHONDONTWRITEBYTECODE",
22
+ "PYTHONIOENCODING",
23
+ "GOTOOLCHAIN",
24
+ "GOFLAGS",
25
+ "GOPROXY",
26
+ "GOWORK",
27
+ "CARGO_NET_OFFLINE",
28
+ "DOTNET_NOLOGO",
29
+ "DOTNET_CLI_TELEMETRY_OPTOUT",
30
+ "DOTNET_SKIP_FIRST_TIME_EXPERIENCE",
31
+ ];
32
+
33
+ export function containerImage(language , version ) {
34
+ return languageModule(language).toolchain.image(version);
35
+ }
36
+
37
+ let available ;
38
+
39
+ /** Whether a container engine answers; asked once per run. */
40
+ export function containersAvailable() {
41
+ if (available === undefined) {
42
+ const probe = spawnSync(DOCKER, ["version", "--format", "{{.Server.Version}}"], { encoding: "utf8", timeout: 20_000 });
43
+ available = probe.error === undefined && probe.status === 0;
44
+ }
45
+ return available;
46
+ }
47
+
48
+ const PULL_TIMEOUT_MS = 600_000;
49
+ const pulled = new Map ();
50
+
51
+ /**
52
+ * Makes sure the image is here before any test runs in it: a first pull can take minutes, longer than a test run may.
53
+ * Returns false when it cannot be pulled (offline, unknown tag).
54
+ */
55
+ export function ensureImage(image ) {
56
+ const known = pulled.get(image);
57
+ if (known !== undefined) return known;
58
+ const present = spawnSync(DOCKER, ["image", "inspect", "--format", "{{.Id}}", image], { encoding: "utf8", timeout: 20_000 });
59
+ const ok = present.status === 0 || spawnSync(DOCKER, ["pull", "--quiet", image], { encoding: "utf8", timeout: PULL_TIMEOUT_MS }).status === 0;
60
+ pulled.set(image, ok);
61
+ return ok;
62
+ }
63
+
64
+ /**
65
+ * The argv prefix that runs the language's tool in its image. Paths sdkloom passes (the project, sdkloom's own files
66
+ * and temporary directories) are mounted at the same place, so they mean the same inside and outside.
67
+ */
68
+ export function containerCommand(language , version , projectRoot ) {
69
+ const mounts = [...new Set([projectRoot, SDKLOOM_ROOT, tmpdir()])];
70
+ return [
71
+ DOCKER,
72
+ "run",
73
+ "--rm",
74
+ "-i",
75
+ ...mounts.flatMap((path) => ["-v", `${path}:${path}`]),
76
+ "-w",
77
+ projectRoot,
78
+ ...FORWARDED.flatMap((name) => ["-e", name]),
79
+ containerImage(language, version),
80
+ languageModule(language).toolchain.tool,
81
+ ];
82
+ }
@@ -0,0 +1,72 @@
1
+ // API surface coverage: which operations and declared errors no scenario or test exercises.
2
+ // An operation counts when a scenario calls it or a test calls client.<op>(…) / client.raw.<op>(…) in any language's
3
+ // spelling (getOrder, get_order); a declared error counts when a scenario answers with its status, or a test that calls
4
+ // the operation also mocks it with .fails(<status>). Comment lines are ignored.
5
+
6
+
7
+ import { answersOf, } from "./scenarios.ts";
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+ function spellings(name ) {
23
+ const snake = name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase();
24
+ return [...new Set([name, snake])];
25
+ }
26
+
27
+ function escape(text ) {
28
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
29
+ }
30
+
31
+ function withoutComments(text ) {
32
+ return text
33
+ .replace(/\/\*[\s\S]*?\*\//g, "")
34
+ .split("\n")
35
+ .filter((line) => !/^\s*(\/\/|#)/.test(line))
36
+ .join("\n");
37
+ }
38
+
39
+ function calls(text , name ) {
40
+ return spellings(name).some((spelling) => new RegExp(`\\bclient\\s*\\.\\s*(?:raw(?:\\(\\))?\\s*\\.\\s*)?${escape(spelling)}\\s*\\(`).test(text));
41
+ }
42
+
43
+ function mocksFailure(text , name , status ) {
44
+ return spellings(name).some((spelling) => new RegExp(`\\b${escape(spelling)}\\b(?:\\(\\))?(?:[^;\\n]*?)\\.fails\\(\\s*${status}\\b`).test(text));
45
+ }
46
+
47
+ export function apiCoverage(ir , scenarios , sources ) {
48
+ const tests = sources.map((source) => ({ ...source, text: withoutComments(source.text) }));
49
+ const valid = scenarios.flatMap((entry) => (entry.scenario === undefined ? [] : [entry.scenario]));
50
+ const untestedOperations = ir.operations
51
+ .filter((operation) => !valid.some((scenario) => scenario.call.op === operation.name) && !tests.some((source) => calls(source.text, operation.name)))
52
+ .map((operation) => operation.name)
53
+ .sort();
54
+ const errors = ir.operations.flatMap((operation) => operation.errors.map((error) => ({ operation: operation.name, status: error.status, name: error.name })));
55
+ const untestedErrors = errors
56
+ .filter(
57
+ (error) =>
58
+ !valid.some((scenario) => scenario.call.op === error.operation && answersOf(scenario).some((answer) => answer.status === error.status)) &&
59
+ !tests.some((source) => calls(source.text, error.operation) && mocksFailure(source.text, error.operation, error.status)),
60
+ )
61
+ .map((error) => `${error.operation} ${error.status} ${error.name}`)
62
+ .sort();
63
+ return { operations: ir.operations.length, errors: errors.length, untestedOperations, untestedErrors };
64
+ }
65
+
66
+ export function renderCoverage(coverage ) {
67
+ return [
68
+ `API coverage: ${coverage.operations - coverage.untestedOperations.length}/${coverage.operations} operations, ${coverage.errors - coverage.untestedErrors.length}/${coverage.errors} declared errors`,
69
+ ...(coverage.untestedOperations.length === 0 ? [] : [` untested operations: ${coverage.untestedOperations.join(", ")}`]),
70
+ ...(coverage.untestedErrors.length === 0 ? [] : [` untested errors: ${coverage.untestedErrors.join(", ")}`]),
71
+ ];
72
+ }
@@ -0,0 +1,25 @@
1
+ // The few git reads sdkloom needs: an earlier version of a file and whether a tag exists. Git is run as a tool.
2
+
3
+ import { spawnSync } from "node:child_process";
4
+
5
+ export const GIT = process.env["SDKLOOM_GIT"] ?? "git";
6
+
7
+ /** The text of a file (relative to cwd) at a git ref, or undefined when the ref or the file does not exist. */
8
+ export function gitShow(cwd , ref , file ) {
9
+ const result = spawnSync(GIT, ["show", `${ref}:./${file}`], { cwd, encoding: "utf8" });
10
+ return result.status === 0 ? result.stdout : undefined;
11
+ }
12
+
13
+ export function gitHasRef(cwd , ref ) {
14
+ return spawnSync(GIT, ["rev-parse", "-q", "--verify", `${ref}^{commit}`], { cwd, encoding: "utf8" }).status === 0;
15
+ }
16
+
17
+ /** Files under a directory (relative to cwd) at a git ref, relative to that directory. */
18
+ export function gitListFiles(cwd , ref , dir ) {
19
+ const result = spawnSync(GIT, ["ls-tree", "-r", "--name-only", ref, "--", dir], { cwd, encoding: "utf8" });
20
+ if (result.status !== 0) return [];
21
+ return result.stdout
22
+ .split("\n")
23
+ .filter((line) => line !== "")
24
+ .map((line) => line.slice(dir.length + 1));
25
+ }
@@ -0,0 +1,50 @@
1
+ // File-system and output helpers shared by CLI commands.
2
+
3
+ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
4
+ import { join, sep } from "node:path";
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+ /** Turns an OS path into the "/"-separated form used in all CLI output. */
16
+ export function toPosix(path ) {
17
+ return path.split(sep).join("/");
18
+ }
19
+
20
+ export function readJson(path , display ) {
21
+ if (!existsSync(path)) return { ok: false, message: `${display}: file not found` };
22
+ try {
23
+ const value = JSON.parse(readFileSync(path, "utf8"));
24
+ return { ok: true, value };
25
+ } catch (error ) {
26
+ return { ok: false, message: `${display}: invalid JSON (${error instanceof Error ? error.message : String(error)})` };
27
+ }
28
+ }
29
+
30
+ /** Lists files under `dir` recursively as sorted "/"-separated relative paths. Missing dir → []. */
31
+ export function listFiles(dir ) {
32
+ if (!existsSync(dir)) return [];
33
+ return readdirSync(dir, { recursive: true })
34
+ .filter((path) => statSync(join(dir, path)).isFile())
35
+ .map(toPosix)
36
+ .sort();
37
+ }
38
+
39
+ export function plural(count , word ) {
40
+ return `${count} ${word}${count === 1 ? "" : "s"}`;
41
+ }
42
+
43
+ export function summary(subject , issueCount ) {
44
+ return `${subject}, ${issueCount === 0 ? "no issues" : plural(issueCount, "issue")}`;
45
+ }
46
+
47
+ export function compareText(a , b ) {
48
+ if (a === b) return 0;
49
+ return a < b ? -1 : 1;
50
+ }