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,120 @@
1
+ // Python: one runtime kit for 2.7 and 3, the default package for 3.8+ and the py27 variant; tested with each interpreter.
2
+
3
+ import { spawnSync } from "node:child_process";
4
+ import { existsSync, readFileSync } from "node:fs";
5
+ import { join } from "node:path";
6
+ import { generatePython, pep440, } from "@sdkloom/gen-python";
7
+ import { purl, pythonWheel } from "@sdkloom/packager";
8
+ import { listFiles } from "../io.ts";
9
+ import { defaultModule, loadKit, lockOf, profilesOf, PYTHON_MIDDLEWARE_FILE, PYTHON_RUNTIME, SDKLOOM_VERSION, variantProfile, withVariants, } from "../kits.ts";
10
+ import { printOutput } from "../packaging.ts";
11
+
12
+ import { pypiUpload } from "../registries.ts";
13
+ import { installed, spawnCommand, } from "../runtimes.ts";
14
+ import { observePython, PYTHON, pythonEnv, roundTripPython } from "../scenarios-python.ts";
15
+ import { runTranspiledPython } from "../transpiled-tests.ts";
16
+
17
+
18
+ /** Native Python tests live in <tests>/python/. */
19
+ const PYTHON_TESTS = "python";
20
+
21
+ export function loadPythonKit(profile = profilesOf("python").base) {
22
+ return { ...loadKit("python", PYTHON_RUNTIME, ".py", profile), syntax: profile.strategies["syntax"] === "py27" ? "py27" : "py3" };
23
+ }
24
+
25
+ function nativeTests(suite , runtimes ) {
26
+ const { root, dir, target, io } = suite;
27
+ const testDir = join(dir, PYTHON_TESTS);
28
+ if (!existsSync(join(root, testDir)) || !listFiles(join(root, testDir)).some((path) => /(^|\/)test_[^/]*\.py$/.test(path))) {
29
+ io.out(`no Python tests in ${testDir}/`);
30
+ return true;
31
+ }
32
+ return runtimes
33
+ .map((runtime) => {
34
+ io.out(`Python tests on ${runtime.label}`);
35
+ const result = spawnCommand(runtime.command, ["-m", "unittest", "discover", "-s", testDir, "-t", testDir], {
36
+ cwd: root,
37
+ env: pythonEnv({ PYTHONPATH: join(root, target.outDir) }),
38
+ });
39
+ if (result.error !== undefined) {
40
+ io.out(`could not run the Python tests with ${runtime.command.join(" ")}: ${result.error.message}`);
41
+ return false;
42
+ }
43
+ printOutput(`${result.stdout}${result.stderr}`, io.out);
44
+ return result.status === 0;
45
+ })
46
+ .every(Boolean);
47
+ }
48
+
49
+ export const python = {
50
+ language: "python",
51
+ toolchain: {
52
+ variable: "SDKLOOM_PYTHON",
53
+ versionArgs: ["--version"],
54
+ parseVersion: (output) => /Python (\d+\.\d+(?:\.\d+)?)/.exec(output)?.[1],
55
+ candidates: (version) => {
56
+ const uv = spawnSync("uv", ["python", "find", version], { encoding: "utf8", timeout: 20_000 });
57
+ return [`python${version}`, ...(uv.status === 0 ? [uv.stdout.trim()] : []), "python3"];
58
+ },
59
+ executable: (candidate) => candidate,
60
+ fallback: PYTHON,
61
+ image: (version) => `python:${version}-slim`,
62
+ tool: "python",
63
+ },
64
+
65
+ build: ({ project, ir, middlewareSources, logicSources }) => {
66
+ const target = project.config.targets.python;
67
+ if (target === undefined) return [];
68
+ const middlewarePath = join(project.root, PYTHON_MIDDLEWARE_FILE);
69
+ const middleware = existsSync(middlewarePath) ? readFileSync(middlewarePath, "utf8") : undefined;
70
+ return withVariants(target.variants, (variant) => {
71
+ const profile = variant === undefined ? profilesOf("python").base : variantProfile("python", variant);
72
+ const kit = loadPythonKit(profile);
73
+ const settings = variant === undefined ? undefined : target.variants?.[variant];
74
+ const packageName = variant === undefined ? target.package : (settings?.package ?? `${target.package}-${variant}`);
75
+ const module = target.module ?? defaultModule(target.package);
76
+ const output = generatePython({
77
+ ir,
78
+ middlewareSources,
79
+ logicSources,
80
+ kit,
81
+ packageName,
82
+ module,
83
+ version: project.config.version,
84
+ sdkloomVersion: SDKLOOM_VERSION,
85
+ source: project.config.source,
86
+ ...(middleware === undefined ? {} : { middleware }),
87
+ });
88
+ const outDir = target.outDir ?? "generated/python";
89
+ return {
90
+ language: "python",
91
+ name: variant === undefined ? "python" : `python-${variant}`,
92
+ profile,
93
+ packageName,
94
+ outDir: variant === undefined ? outDir : (settings?.outDir ?? `${outDir}-${variant}`),
95
+ files: output.files,
96
+ lockFile: lockOf("python", ir, kit, output),
97
+ module,
98
+ };
99
+ });
100
+ },
101
+
102
+ observe: ({ root, target, runtime, ir }, scenarios) => observePython(runtime.command, root, target.outDir, target.module ?? "", ir, scenarios),
103
+ roundTrip: ({ root, target, runtime }, samples) => roundTripPython(runtime.command, root, target.outDir, target.module ?? "", samples),
104
+
105
+ /** A variant runs the transpiled tests too (its generated code differs); native tests are written for the default package. */
106
+ authorTests: (suite) => {
107
+ const native = suite.target.name === "python" ? nativeTests(suite, installed(suite.runtimes)) : true;
108
+ return runTranspiledPython(suite.root, suite.dir, suite.ir, suite.target, suite.ws.path(suite.target.name), suite.runtimes, suite.io) && native;
109
+ },
110
+ testFile: /(^|\/)test_[^/]*\.py$/,
111
+
112
+ pack: (project, target, metadata) => {
113
+ const version = project.config.version;
114
+ const supports = pep440(target.lockFile.profile.slice(target.lockFile.profile.indexOf("@") + 1));
115
+ const pythonTag = target.profile.strategies["syntax"] === "py27" ? "py2" : "py3";
116
+ const name = target.packageName;
117
+ const artifact = pythonWheel(new Map(target.files), { name, module: target.module ?? "", version, requiresPython: supports, generator: `sdkloom ${SDKLOOM_VERSION}`, pythonTag }, metadata);
118
+ return { target, artifact, upload: pypiUpload(artifact, name, version, pythonTag), name, purl: purl("python", name, version) };
119
+ },
120
+ };
@@ -0,0 +1,189 @@
1
+ // Rust: one crate with the vendored kit as its runtime module and typed mocks; tested with each Rust toolchain by a
2
+ // harness program generated for the SDK. Toolchains come from rustup (~/.rustup/toolchains/<version>-<host>).
3
+
4
+ import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
5
+ import { homedir } from "node:os";
6
+ import { basename, dirname, isAbsolute, join } from "node:path";
7
+ import { emitHarness, generateRust, libraryName, } from "@sdkloom/gen-rust";
8
+ import { purl, rustCrate } from "@sdkloom/packager";
9
+ import { listFiles, toPosix } from "../io.ts";
10
+ import { loadKit, lockOf, profilesOf, RUST_MIDDLEWARE_FILE, SDKLOOM_VERSION, } from "../kits.ts";
11
+ import { printOutput } from "../packaging.ts";
12
+ import { cratesUpload } from "../registries.ts";
13
+ import { installed, spawnCommand, } from "../runtimes.ts";
14
+ import { harnessCase, } from "../scenarios.ts";
15
+
16
+
17
+ /** Native Rust tests live in <tests>/rust/ and run as the integration tests of a crate that uses the SDK. */
18
+ const RUST_TESTS = "rust";
19
+ const RUN_TIMEOUT_MS = 600_000;
20
+
21
+ export function loadRustKit() {
22
+ return loadKit("rust", join("src", "runtime"), ".rs", profilesOf("rust").base);
23
+ }
24
+
25
+ /**
26
+ * Cargo must not touch the network (the SDK has no dependencies), and a cargo taken from a rustup toolchain directory
27
+ * must use that toolchain's rustc rather than the rustup proxy on PATH.
28
+ */
29
+ export function cargoEnv(command ) {
30
+ const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => key !== "NODE_TEST_CONTEXT" && key !== "RUSTUP_TOOLCHAIN"));
31
+ const cargo = command[0] ?? "";
32
+ const rustc = join(dirname(cargo), "rustc");
33
+ return { ...env, CARGO_NET_OFFLINE: "true", ...(command.length === 1 && isAbsolute(cargo) && basename(cargo) === "cargo" && existsSync(rustc) ? { RUSTC: rustc } : {}) };
34
+ }
35
+
36
+ /** A crate that uses the generated SDK from its output directory. */
37
+ function consumer(dir , name , root , target , main ) {
38
+ mkdirSync(join(dir, "src"), { recursive: true });
39
+ const manifest = join(dir, "Cargo.toml");
40
+ writeFileSync(manifest, `[package]\nname = "${name}"\nversion = "0.0.0"\nedition = "2021"\npublish = false\n\n[dependencies]\n${target.packageName} = { path = ${JSON.stringify(toPosix(join(root, target.outDir)))} }\n\n[workspace]\n`);
41
+ writeFileSync(join(dir, "src", main === undefined ? "lib.rs" : "main.rs"), main ?? "");
42
+ return manifest;
43
+ }
44
+
45
+ function cargo(runtime , args , manifest , input ) {
46
+ const targetDir = join(dirname(manifest), "target");
47
+ return spawnCommand(runtime.command, [...args, "--offline", "--quiet", "--manifest-path", manifest, "--target-dir", targetDir], {
48
+ env: cargoEnv(runtime.command),
49
+ timeout: RUN_TIMEOUT_MS,
50
+ ...(input === undefined ? {} : { input }),
51
+ });
52
+ }
53
+
54
+ /** The harness crate for one runtime, built once per run; building it checks the SDK compiles on that version. */
55
+ function harness(column ) {
56
+ const { root, target, runtime, ir, ws } = column;
57
+ return ws.once(`rust:${runtime.label}`, () => {
58
+ const manifest = consumer(ws.path(`rust-harness-${runtime.label}`), "sdkloom-harness", root, target, emitHarness(ir, libraryName(target.packageName)));
59
+ const built = cargo(runtime, ["build"], manifest);
60
+ if (built.status !== 0) throw new Error(`the generated Rust SDK does not build with ${runtime.label}:\n${`${built.stdout}${built.stderr}`.trim()}`);
61
+ return manifest;
62
+ });
63
+ }
64
+
65
+ function runHarness(column , plan ) {
66
+ const result = cargo(column.runtime, ["run"], harness(column), JSON.stringify(plan));
67
+ if (result.status !== 0) throw new Error(`the Rust harness failed: ${`${result.stderr}`.trim().split("\n").at(-1) ?? ""}`);
68
+ return JSON.parse(result.stdout) ;
69
+ }
70
+
71
+ function nativeTests(suite , runtimes ) {
72
+ const { root, dir, target, ws, io } = suite;
73
+ const testDir = join(root, dir, RUST_TESTS);
74
+ const tests = listFiles(testDir).filter((path) => path.endsWith(".rs"));
75
+ if (tests.length === 0) {
76
+ io.out(`no Rust tests in ${toPosix(join(dir, RUST_TESTS))}/`);
77
+ return true;
78
+ }
79
+ const crate = ws.path("rust-tests");
80
+ const manifest = consumer(crate, "sdkloom-tests", root, target);
81
+ tests.forEach((path) => {
82
+ mkdirSync(join(crate, "tests", path, ".."), { recursive: true });
83
+ writeFileSync(join(crate, "tests", path), readFileSync(join(testDir, path)));
84
+ });
85
+ return runtimes
86
+ .map((runtime) => {
87
+ io.out(`Rust tests on ${runtime.label}`);
88
+ const run = cargo(runtime, ["test"], manifest);
89
+ printOutput(`${run.stdout}${run.stderr}`, io.out);
90
+ return run.status === 0;
91
+ })
92
+ .every(Boolean);
93
+ }
94
+
95
+ /** rustup toolchain directories for a version: "1.70" matches 1.70-<host> and 1.70.0-<host>; stable matches any. */
96
+ function toolchainDirs(version ) {
97
+ const dir = join(process.env["RUSTUP_HOME"] ?? join(homedir(), ".rustup"), "toolchains");
98
+ if (!existsSync(dir)) return [];
99
+ return readdirSync(dir)
100
+ .filter((name) => name.startsWith(`${version}-`) || name.startsWith(`${version}.`) || name.startsWith("stable-"))
101
+ .sort()
102
+ .map((name) => join(dir, name));
103
+ }
104
+
105
+ export const rustLanguage = {
106
+ language: "rust",
107
+ toolchain: {
108
+ variable: "SDKLOOM_CARGO",
109
+ versionArgs: ["--version"],
110
+ parseVersion: (output) => /cargo (\d+\.\d+\.\d+)/.exec(output)?.[1],
111
+ candidates: (version) => [...toolchainDirs(version), "cargo"],
112
+ executable: (candidate) => (existsSync(join(candidate, "bin", "cargo")) ? join(candidate, "bin", "cargo") : candidate),
113
+ fallback: "cargo",
114
+ image: (version) => `rust:${version}`,
115
+ tool: "cargo",
116
+ },
117
+
118
+ build: ({ project, ir, middlewareSources, logicSources }) => {
119
+ const target = project.config.targets.rust;
120
+ if (target === undefined) return [];
121
+ const kit = loadRustKit();
122
+ const middlewarePath = join(project.root, RUST_MIDDLEWARE_FILE);
123
+ const output = generateRust({
124
+ ir,
125
+ middlewareSources,
126
+ logicSources,
127
+ kit,
128
+ crateName: target.crate,
129
+ version: project.config.version,
130
+ sdkloomVersion: SDKLOOM_VERSION,
131
+ source: project.config.source,
132
+ ...(project.config.publish?.license === undefined ? {} : { license: project.config.publish.license }),
133
+ ...(existsSync(middlewarePath) ? { middleware: readFileSync(middlewarePath, "utf8") } : {}),
134
+ });
135
+ const built = {
136
+ language: "rust",
137
+ name: "rust",
138
+ profile: profilesOf("rust").base,
139
+ packageName: target.crate,
140
+ outDir: target.outDir ?? "generated/rust",
141
+ files: output.files,
142
+ lockFile: lockOf("rust", ir, kit, output),
143
+ module: libraryName(target.crate),
144
+ };
145
+ return [built];
146
+ },
147
+
148
+ observe: (column, scenarios) => {
149
+ const cases = scenarios.map(harnessCase);
150
+ const reported = runHarness(column, { mode: "scenarios", cases }) ;
151
+ return new Map(reported.map(({ id, ...observation }) => [id, observation]));
152
+ },
153
+ roundTrip: (column, samples) => {
154
+ const reported = runHarness(column, { mode: "roundtrip", cases: samples.map(({ id, type, value }) => ({ id, type, value })) }) ;
155
+ return new Map(reported.map((entry) => [entry.id, entry.outcome]));
156
+ },
157
+
158
+ authorTests: (suite) => {
159
+ const native = nativeTests(suite, installed(suite.runtimes));
160
+ if (listFiles(join(suite.root, suite.dir)).some((path) => path.endsWith(".test.ts") && !path.includes("/"))) {
161
+ suite.io.out(`${suite.dir}/*.test.ts → rust: not transpiled yet; Rust runs the scenarios, schema round-trips and ${toPosix(join(suite.dir, RUST_TESTS))}/`);
162
+ }
163
+ return native;
164
+ },
165
+ testFile: /\/rust\/.*\.rs$|^rust\/.*\.rs$/,
166
+
167
+ pack: (project, target, metadata) => {
168
+ const version = project.config.version;
169
+ const artifact = rustCrate(new Map(target.files), target.packageName, version, metadata);
170
+ const rustVersion = /^rust-version = "([^"]+)"$/m.exec(target.files.get("Cargo.toml") ?? "")?.[1];
171
+ return {
172
+ target,
173
+ artifact,
174
+ name: target.packageName,
175
+ purl: purl("rust", target.packageName, version),
176
+ upload: cratesUpload(artifact, {
177
+ name: target.packageName,
178
+ vers: version,
179
+ ...(metadata.description === undefined ? {} : { description: metadata.description }),
180
+ ...(metadata.license === undefined ? {} : { license: metadata.license }),
181
+ ...(metadata.homepage === undefined ? {} : { homepage: metadata.homepage }),
182
+ ...(metadata.repository === undefined ? {} : { repository: metadata.repository }),
183
+ ...(metadata.authors === undefined ? {} : { authors: metadata.authors }),
184
+ ...(rustVersion === undefined ? {} : { rust_version: rustVersion }),
185
+ readme: target.files.get("README.md") ?? "",
186
+ }),
187
+ };
188
+ },
189
+ };
@@ -0,0 +1,93 @@
1
+ // What sdkloom needs to know about one target language. Everything language-specific lives in a module implementing
2
+ // this interface (languages/<language>.ts); build, test, doctor and publish only go through it.
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+ /** How to find, recognise and containerise the language's tool (python, java, node, go, cargo, dotnet). */
15
+
16
+  
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+ /** Temporary directories of one `sdkloom test` run, with results computed once (a compiled SDK, say). */
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+ /** One matrix column: a target on one installed runtime version. */
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+ /** The author's tests of one target, on every runtime version of that target. */
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
@@ -0,0 +1,112 @@
1
+ // TypeScript: the SDK as source for TypeScript users and as stripped JavaScript on npm, tested on every Node.js version.
2
+
3
+ import { spawnSync } from "node:child_process";
4
+ import { readdirSync } from "node:fs";
5
+ import { homedir } from "node:os";
6
+ import { extname, join } from "node:path";
7
+ import { pathToFileURL } from "node:url";
8
+ import { generateTypeScript, } from "@sdkloom/gen-typescript";
9
+ import { npmPackage, purl } from "@sdkloom/packager";
10
+ import { listFiles } from "../io.ts";
11
+ import { loadKit, lockOf, profilesOf, SDKLOOM_VERSION, } from "../kits.ts";
12
+ import { printOutput } from "../packaging.ts";
13
+ import { npmUpload } from "../registries.ts";
14
+ import { observeJavaScript, roundTripJavaScript, writeJavaScript } from "../scenarios-javascript.ts";
15
+
16
+
17
+ /** Loaded into the test process so tests outside this repository can import @sdkloom/core. */
18
+ // .ts in the repository, .js in the published package.
19
+ const RESOLVE_CORE = pathToFileURL(join(import.meta.dirname, "..", `resolve-core${extname(import.meta.filename)}`)).href;
20
+
21
+ export function loadTypeScriptKit() {
22
+ return loadKit("typescript", "src", ".ts", profilesOf("typescript").base);
23
+ }
24
+
25
+ function installed(dir , suffix ) {
26
+ try {
27
+ return readdirSync(dir).map((name) => join(dir, name, ...suffix));
28
+ } catch {
29
+ return [];
30
+ }
31
+ }
32
+
33
+ /** The JavaScript form of the SDK, written once per run. */
34
+ function javaScript(column ) {
35
+ return column.ws.once(`js:${column.target.name}`, () => writeJavaScript(column.target, column.ws.path(`${column.target.name}-js`)));
36
+ }
37
+
38
+ function authorTests(root , dir , out ) {
39
+ const files = listFiles(join(root, dir))
40
+ .filter((path) => path.endsWith(".test.ts"))
41
+ .map((path) => join(dir, path));
42
+ if (files.length === 0) {
43
+ out(`no TypeScript tests in ${dir}/`);
44
+ return true;
45
+ }
46
+ // A test runner started from inside another test run must not report to the outer one.
47
+ const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => key !== "NODE_TEST_CONTEXT"));
48
+ const result = spawnSync(process.execPath, ["--import", RESOLVE_CORE, "--test", "--test-reporter=tap", ...files], { cwd: root, encoding: "utf8", env });
49
+ printOutput(`${result.stdout}${result.stderr}`, out);
50
+ return result.status === 0;
51
+ }
52
+
53
+ export const typescript = {
54
+ language: "typescript",
55
+ toolchain: {
56
+ variable: "SDKLOOM_NODE",
57
+ versionArgs: ["--version"],
58
+ parseVersion: (output) => /v(\d+\.\d+\.\d+)/.exec(output)?.[1],
59
+ candidates: () => {
60
+ const home = homedir();
61
+ return [
62
+ process.execPath,
63
+ ...installed(join(home, ".local", "share", "fnm", "node-versions"), ["installation", "bin", "node"]),
64
+ ...installed(join(home, "Library", "Application Support", "fnm", "node-versions"), ["installation", "bin", "node"]),
65
+ ...installed(join(home, ".nvm", "versions", "node"), ["bin", "node"]),
66
+ "node",
67
+ ];
68
+ },
69
+ executable: (candidate) => candidate,
70
+ fallback: process.execPath,
71
+ image: (version) => `node:${version}-slim`,
72
+ tool: "node",
73
+ },
74
+
75
+ build: ({ project, ir, middlewareSources, logicSources }) => {
76
+ const target = project.config.targets.typescript;
77
+ if (target === undefined) return [];
78
+ const kit = loadTypeScriptKit();
79
+ const output = generateTypeScript({
80
+ ir,
81
+ middlewareSources,
82
+ logicSources,
83
+ kit,
84
+ packageName: target.package,
85
+ version: project.config.version,
86
+ sdkloomVersion: SDKLOOM_VERSION,
87
+ source: project.config.source,
88
+ });
89
+ const built = {
90
+ language: "typescript",
91
+ name: "typescript",
92
+ profile: profilesOf("typescript").base,
93
+ packageName: target.package,
94
+ outDir: target.outDir ?? "generated/typescript",
95
+ files: output.files,
96
+ lockFile: lockOf("typescript", ir, kit, output),
97
+ };
98
+ return [built];
99
+ },
100
+
101
+ observe: (column, scenarios) => observeJavaScript(column.runtime.command, javaScript(column), column.ir, scenarios),
102
+ roundTrip: (column, samples) => roundTripJavaScript(column.runtime.command, javaScript(column), samples),
103
+ // TypeScript tests run on the current Node.js, which strips types; other versions run the scenarios.
104
+ authorTests: (suite) => authorTests(suite.root, suite.dir, suite.io.out),
105
+ testFile: /\.test\.ts$/,
106
+
107
+ pack: (project, target, metadata) => {
108
+ const artifact = npmPackage(new Map(target.files), metadata);
109
+ const manifest = artifact.manifest ;
110
+ return { target, artifact, upload: npmUpload(artifact, manifest), name: manifest.name, purl: purl("typescript", manifest.name, project.config.version) };
111
+ },
112
+ };
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ // The `sdkloom` executable. All logic lives in run.ts, loaded after the resolve hooks are registered: static imports
3
+ // are resolved before any module runs, so run.ts is imported dynamically.
4
+
5
+ import "./resolve-core.js";
6
+
7
+ const { run } = await import("./run.js");
8
+
9
+ process.exitCode = await run(process.argv.slice(2), {
10
+ cwd: process.cwd(),
11
+ out: (line) => console.log(line),
12
+ err: (line) => console.error(line),
13
+ });
@@ -0,0 +1,39 @@
1
+ // Helpers language modules share when packaging: reading compiled trees and gpg signatures.
2
+
3
+ import { spawnSync } from "node:child_process";
4
+ import { readdirSync, readFileSync, writeFileSync } from "node:fs";
5
+ import { join } from "node:path";
6
+
7
+ const GPG = process.env["SDKLOOM_GPG"] ?? "gpg";
8
+
9
+ /** Every file under dir that keep() accepts, by path relative to dir. */
10
+ export function readTree(dir , keep ) {
11
+ return new Map(
12
+ readdirSync(dir, { recursive: true })
13
+ .filter(keep)
14
+ .map((path) => [path, readFileSync(join(dir, path))]),
15
+ );
16
+ }
17
+
18
+ /** Detached ASCII-armoured gpg signatures, or undefined when no signing key is configured. */
19
+ export function sign(files , workspace ) {
20
+ const key = process.env["SDKLOOM_GPG_KEY"];
21
+ if (key === undefined) return undefined;
22
+ const signatures = new Map ();
23
+ for (const [name, bytes] of files) {
24
+ const path = join(workspace, name);
25
+ writeFileSync(path, bytes);
26
+ const result = spawnSync(GPG, ["--batch", "--yes", "--armor", "--detach-sign", "--local-user", key, "--output", `${path}.asc`, path], { encoding: "utf8" });
27
+ if (result.status !== 0) throw new Error(`gpg could not sign ${name}: ${result.error?.message ?? result.stderr.trim()}`);
28
+ signatures.set(name, readFileSync(`${path}.asc`, "utf8"));
29
+ }
30
+ return signatures;
31
+ }
32
+
33
+ /** Prints a tool's output line by line, without blank lines. */
34
+ export function printOutput(text , out ) {
35
+ text
36
+ .split("\n")
37
+ .filter((line) => line !== "")
38
+ .forEach((line) => out(line));
39
+ }
@@ -0,0 +1,45 @@
1
+ // Whether the generated TypeScript SDK sticks to web-standard APIs (fetch, URL, TextEncoder, AbortController, timers),
2
+ // so it runs on Node.js, Deno, Bun, browsers and edge workers alike. A static scan: these runtimes are not started.
3
+
4
+ /** Node.js-only names that break the SDK elsewhere, and what each looks like in code. */
5
+ const NODE_ONLY = [
6
+ { name: "a node: import", pattern: /\bfrom\s+["']node:|\bimport\(\s*["']node:/ },
7
+ { name: "require()", pattern: /\brequire\s*\(/ },
8
+ { name: "process", pattern: /\bprocess\s*\./ },
9
+ { name: "Buffer", pattern: /\bBuffer\b/ },
10
+ { name: "__dirname or __filename", pattern: /\b__(dirname|filename)\b/ },
11
+ { name: "global.", pattern: /(^|[^.\w])global\./ },
12
+ ];
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+ /** Comment lines are skipped: the kit cites Node.js documentation in its block comments. */
21
+ function isComment(line ) {
22
+ const trimmed = line.trim();
23
+ return trimmed.startsWith("//") || trimmed.startsWith("*") || trimmed.startsWith("/*");
24
+ }
25
+
26
+ /** Every use of a Node.js-only API in the SDK's TypeScript files (paths ending in .ts). */
27
+ export function portabilityIssues(files ) {
28
+ return [...files].flatMap(([file, text]) =>
29
+ file.endsWith(".ts")
30
+ ? text.split("\n").flatMap((line, index) =>
31
+ isComment(line) ? [] : NODE_ONLY.filter((rule) => rule.pattern.test(line)).map((rule) => ({ file, line: index + 1, name: rule.name })),
32
+ )
33
+ : [],
34
+ );
35
+ }
36
+
37
+ /** One summary line, then one line per issue. */
38
+ export function portabilityReport(files ) {
39
+ const issues = portabilityIssues(files);
40
+ if (issues.length === 0) return ["typescript: web-standard APIs only; runs on Node.js, Deno, Bun, browsers and edge workers"];
41
+ return [
42
+ `typescript: ${issues.length} Node.js-only API use(s); the SDK will not run in browsers or edge workers:`,
43
+ ...issues.map((issue) => ` ${issue.file}:${issue.line} ${issue.name}`),
44
+ ];
45
+ }
@@ -0,0 +1,55 @@
1
+ // A kit's version lines from kits/<lang>/versions.json: the default package and the variants below its range.
2
+ // Each line names the versions it is tested on, the strategies the generator uses and the kit files it leaves out.
3
+
4
+ import { existsSync, readFileSync } from "node:fs";
5
+ import { join } from "node:path";
6
+ import { checkVersionPolicy, } from "@sdkloom/kit";
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+ export const DEFAULT_PROFILE = "default";
19
+
20
+ function profile(name , line ) {
21
+ return { name, range: line.range, test: line.test, strategies: line.strategies ?? {}, exclude: line.exclude ?? [] };
22
+ }
23
+
24
+ /** The default line and the variants of the kit in kitDir; a kit without versions.json has a default line only. */
25
+
26
+
27
+
28
+  
29
+
30
+
31
+
32
+ export function kitProfiles(kitDir , supports ) {
33
+ const path = join(kitDir, "versions.json");
34
+ if (!existsSync(path)) return { base: { name: DEFAULT_PROFILE, range: supports, test: [], strategies: {}, exclude: [] }, variants: new Map(), notes: new Map() };
35
+ const value = JSON.parse(readFileSync(path, "utf8"));
36
+ const issues = checkVersionPolicy(value);
37
+ if (issues.length > 0) throw new Error(`${path} is invalid: ${issues.join("; ")}`);
38
+ const policy = value ;
39
+ return {
40
+ base: profile(DEFAULT_PROFILE, policy.default),
41
+ variants: new Map(Object.entries(policy.variants ?? {}).map(([name, line]) => [name, profile(name, line)])),
42
+ notes: new Map(Object.entries(policy.notes ?? {})),
43
+ };
44
+ }
45
+
46
+ /** Whether a kit file (or its test, "<Name>Test.java" / "test_<name>.py") belongs to the profile; paths may be absolute. */
47
+ export function included(profile , path ) {
48
+ const posix = path.split("\\").join("/");
49
+ const base = posix.slice(posix.lastIndexOf("/") + 1);
50
+ return !profile.exclude.some((excluded) => {
51
+ const name = excluded.slice(excluded.lastIndexOf("/") + 1);
52
+ const stem = name.replace(/\.[^.]+$/, "");
53
+ return posix === excluded || posix.endsWith(`/${excluded}`) || base === `${stem}Test.java` || base === `test_${stem}.py`;
54
+ });
55
+ }