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,68 @@
1
+ // Finds the interpreters, JDKs and compilers for the versions a kit tests (kits/<lang>/versions.json): an explicit
2
+ // variable first (SDKLOOM_PYTHON_3_8, SDKLOOM_JAVA_HOME_11, …), then the places the language module lists.
3
+ // Nothing is downloaded here.
4
+
5
+ import { spawnSync } from "node:child_process";
6
+
7
+ import { languageModule } from "./languages/index.ts";
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+ /** "3.8.20" from `python --version`, "8.0.512" from java's "1.8.0_512", "18.20.8" from `node --version`. */
21
+ export function parseVersionOutput(language , output ) {
22
+ return languageModule(language).toolchain.parseVersion(output);
23
+ }
24
+
25
+ export function matchesVersion(found , wanted ) {
26
+ const have = found.split(".");
27
+ return wanted.split(".").every((part, index) => have[index] === part);
28
+ }
29
+
30
+ /** SDKLOOM_PYTHON_3_8 for ("SDKLOOM_PYTHON", "3.8"). */
31
+ export function toolchainVariable(spec , version ) {
32
+ return `${spec.variable}_${version.replaceAll(".", "_")}`;
33
+ }
34
+
35
+ /** Every version the candidate offers; one for most tools, several for dotnet. */
36
+ function probe(spec , candidate ) {
37
+ // A child of `node --test` must not think it is a test reporter, or `node --version` prints nothing.
38
+ const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => key !== "NODE_TEST_CONTEXT"));
39
+ const result = spawnSync(spec.executable(candidate), spec.versionArgs, { encoding: "utf8", timeout: 20_000, env });
40
+ if (result.error !== undefined || result.status !== 0) return [];
41
+ const output = `${result.stdout}${result.stderr}`;
42
+ if (spec.parseVersions !== undefined) return spec.parseVersions(output);
43
+ const found = spec.parseVersion(output);
44
+ return found === undefined ? [] : [found];
45
+ }
46
+
47
+ const cache = new Map ();
48
+
49
+ /** The first installed toolchain whose version starts with `version`, or undefined. */
50
+ export function resolveToolchain(language , version ) {
51
+ const spec = languageModule(language).toolchain;
52
+ const explicit = process.env[toolchainVariable(spec, version)];
53
+ const key = `${language}@${version}@${explicit ?? ""}`;
54
+ if (cache.has(key)) return cache.get(key);
55
+ let result ;
56
+ for (const candidate of [...(explicit === undefined ? [] : [explicit]), ...spec.candidates(version)]) {
57
+ if (candidate === "") continue;
58
+ const offered = probe(spec, candidate);
59
+ // An explicit SDKLOOM_* variable is the user's choice and wins as long as the tool runs.
60
+ const found = candidate === explicit ? (offered.find((item) => matchesVersion(item, version)) ?? offered[0]) : offered.find((item) => matchesVersion(item, version));
61
+ if (found !== undefined) {
62
+ result = { language, version, found, command: candidate };
63
+ break;
64
+ }
65
+ }
66
+ cache.set(key, result);
67
+ return result;
68
+ }
@@ -0,0 +1,92 @@
1
+ // TypeScript tests transpiled to Python and Java (spec/subset.md, "Tests") and run next to the author's native tests.
2
+
3
+ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
4
+ import { dirname, join } from "node:path";
5
+
6
+ import { parseTestFile, translateTests, TranspileError, } from "@sdkloom/transpile";
7
+
8
+ import { listFiles, } from "./io.ts";
9
+ import { compileJava, javaSources, runJava } from "./java.ts";
10
+ import { installed, spawnCommand, } from "./runtimes.ts";
11
+ import { pythonEnv } from "./scenarios-python.ts";
12
+
13
+
14
+
15
+
16
+
17
+
18
+ function print(text , io ) {
19
+ text
20
+ .split("\n")
21
+ .filter((line) => line !== "")
22
+ .forEach((line) => io.out(line));
23
+ }
24
+
25
+ /** Translates every tests/*.test.ts for one language and reports what was transpiled and what was skipped. */
26
+ function translateAll(root , dir , ir , target , io ) {
27
+ const files = listFiles(join(root, dir)).filter((path) => path.endsWith(".test.ts") && !path.includes("/"));
28
+ const results = [];
29
+ for (const path of files) {
30
+ const file = `${dir}/${path}`;
31
+ try {
32
+ const parsed = parseTestFile(file, readFileSync(join(root, dir, path), "utf8"));
33
+ const result = translateTests(ir, parsed, target.language === "python" ? { language: "python", module: target.module ?? "" } : { language: "java", javaPackage: target.module ?? "" });
34
+ io.out(`${file} → ${target.language}: ${result.translated.length} of ${result.translated.length + result.skipped.length} tests transpiled`);
35
+ result.skipped.forEach((item) => io.out(` skipped "${item.name}": ${item.reason}`));
36
+ if (result.translated.length > 0) results.push(result);
37
+ } catch (error ) {
38
+ if (!(error instanceof TranspileError)) throw error;
39
+ io.out(`${file} → ${target.language}: not transpiled: ${error.message}`);
40
+ }
41
+ }
42
+ return results;
43
+ }
44
+
45
+ function write(base , results ) {
46
+ results.forEach((result) => {
47
+ mkdirSync(dirname(join(base, result.path)), { recursive: true });
48
+ writeFileSync(join(base, result.path), result.code);
49
+ });
50
+ }
51
+
52
+ export function runTranspiledPython(root , dir , ir , target , workspace , runtimes , io ) {
53
+ const results = translateAll(root, dir, ir, target, io);
54
+ if (results.length === 0) return true;
55
+ const out = join(workspace, "python-transpiled");
56
+ write(out, results);
57
+ return installed(runtimes)
58
+ .map((runtime) => {
59
+ io.out(`transpiled tests on ${runtime.label}`);
60
+ const run = spawnCommand(runtime.command, ["-m", "unittest", "discover", "-s", out, "-t", out], { cwd: root, env: pythonEnv({ PYTHONPATH: join(root, target.outDir) }) });
61
+ if (run.error !== undefined) {
62
+ io.out(`could not run the transpiled Python tests with ${runtime.command.join(" ")}: ${run.error.message}`);
63
+ return false;
64
+ }
65
+ print(`${run.stdout}${run.stderr}`, io);
66
+ return run.status === 0;
67
+ })
68
+ .every(Boolean);
69
+ }
70
+
71
+ export function runTranspiledJava(root , dir , ir , target , java , workspace , runtimes , io ) {
72
+ const results = translateAll(root, dir, ir, target, io);
73
+ if (results.length === 0) return true;
74
+ if (!java.compile()) return false;
75
+ const sources = join(workspace, "java-transpiled-src");
76
+ const classes = join(workspace, "java-transpiled");
77
+ write(sources, results);
78
+ const compiled = compileJava(javaSources(sources), classes, [java.sdk]);
79
+ if (!compiled.ok) {
80
+ print(compiled.output, io);
81
+ return false;
82
+ }
83
+ const tests = results.flatMap((result) => (result.className === undefined ? [] : [result.className]));
84
+ return installed(runtimes)
85
+ .map((runtime) => {
86
+ io.out(`transpiled tests on ${runtime.label}`);
87
+ const run = runJava([java.sdk, classes], `${target.module ?? ""}.runtime.TestRunner`, tests, undefined, runtime.command);
88
+ print(run.output, io);
89
+ return run.ok;
90
+ })
91
+ .every(Boolean);
92
+ }
@@ -0,0 +1,31 @@
1
+ // Canonical JSON: object keys sorted at every level, 2-space indentation, trailing newline.
2
+ // Rejects anything JSON cannot represent exactly, so the same value always gives the same bytes.
3
+
4
+ function isPlainObject(value ) {
5
+ const prototype = Object.getPrototypeOf(value);
6
+ return prototype === Object.prototype || prototype === null;
7
+ }
8
+
9
+ function normalize(value , path ) {
10
+ if (value === null || typeof value === "string" || typeof value === "boolean") return value;
11
+ if (typeof value === "number") {
12
+ if (!Number.isFinite(value)) throw new Error(`${path}: numbers must be finite`);
13
+ return value;
14
+ }
15
+ if (value === undefined) throw new Error(`${path}: undefined cannot be represented in JSON`);
16
+ if (typeof value === "function") throw new Error(`${path}: a function cannot be represented in JSON`);
17
+ if (Array.isArray(value)) return value.map((item , index) => normalize(item, `${path}[${index}]`));
18
+ if (typeof value === "object" && isPlainObject(value)) {
19
+ const record = value ;
20
+ return Object.fromEntries(
21
+ Object.keys(record)
22
+ .sort()
23
+ .map((key) => [key, normalize(record[key], `${path}.${key}`)]),
24
+ );
25
+ }
26
+ throw new Error(`${path}: ${typeof value} values cannot be represented in JSON`);
27
+ }
28
+
29
+ export function canonicalJson(value ) {
30
+ return `${JSON.stringify(normalize(value, "$"), null, 2)}\n`;
31
+ }
@@ -0,0 +1,50 @@
1
+ // Capability tables and strategy selection (docs/06-language-versions.md §1–2).
2
+ // Generators never compare language versions directly; they ask for capabilities.
3
+
4
+ import { compareVersions, parseVersion } from "@sdkloom/kit";
5
+
6
+ /** Capability name → first language version that has it, e.g. { records: "16" }. */
7
+
8
+
9
+ /** One way to implement a concern, usable when every required capability is present. */
10
+
11
+
12
+
13
+
14
+
15
+
16
+ export function capabilitiesFor(table , version ) {
17
+ const target = parseVersion(version);
18
+ const available = Object.entries(table)
19
+ .filter(([, since]) => compareVersions(target, parseVersion(since)) >= 0)
20
+ .map(([name]) => name)
21
+ .sort();
22
+ return new Set(available);
23
+ }
24
+
25
+ /**
26
+ * Picks, for every concern, the first rule whose required capabilities are all available.
27
+ * Pass `known` (the capability table's names) to catch misspelled capability names.
28
+ */
29
+ export function selectStrategies(
30
+ rules ,
31
+ available ,
32
+ known ,
33
+ ) {
34
+ if (known !== undefined) {
35
+ const knownNames = new Set(known);
36
+ for (const rule of rules) {
37
+ const unknown = rule.requires.find((name) => !knownNames.has(name));
38
+ if (unknown !== undefined) throw new Error(`unknown capability "${unknown}" in strategy ${rule.strategy}`);
39
+ }
40
+ }
41
+
42
+ const concerns = [...new Set(rules.map((rule) => rule.concern))];
43
+ return Object.fromEntries(
44
+ concerns.map((concern) => {
45
+ const rule = rules.find((candidate) => candidate.concern === concern && candidate.requires.every((name) => available.has(name)));
46
+ if (rule === undefined) throw new Error(`no strategy for "${concern}" with capabilities [${[...available].join(", ")}]`);
47
+ return [concern, rule.strategy];
48
+ }),
49
+ );
50
+ }
@@ -0,0 +1,54 @@
1
+ // A small, deterministic code writer: LF line endings, no trailing whitespace,
2
+ // at most one blank line in a row, and exactly one trailing newline.
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+ const DEFAULT_INDENT = " ";
18
+ const LINE_BREAK = /[\r\n]/;
19
+
20
+ function render(lines ) {
21
+ const kept = lines.filter((line, index) => line !== "" || (index > 0 && lines[index - 1] !== ""));
22
+ const start = kept.findIndex((line) => line !== "");
23
+ if (start === -1) return "";
24
+ const end = kept.findLastIndex((line) => line !== "");
25
+ return `${kept.slice(start, end + 1).join("\n")}\n`;
26
+ }
27
+
28
+ export function createCodeWriter(options = {}) {
29
+ const unit = options.indent ?? DEFAULT_INDENT;
30
+ const lines = [];
31
+
32
+ const writerAt = (depth ) => {
33
+ const writer = {
34
+ line(text = "") {
35
+ if (LINE_BREAK.test(text)) {
36
+ throw new Error(`code writer lines must not contain line breaks: ${JSON.stringify(text)}`);
37
+ }
38
+ const trimmed = text.trimEnd();
39
+ lines.push(trimmed === "" ? "" : `${unit.repeat(depth)}${trimmed}`);
40
+ return writer;
41
+ },
42
+ indent(body) {
43
+ body(writerAt(depth + 1));
44
+ return writer;
45
+ },
46
+ toString() {
47
+ return render(lines);
48
+ },
49
+ };
50
+ return writer;
51
+ };
52
+
53
+ return writerAt(0);
54
+ }
@@ -0,0 +1,25 @@
1
+ // An in-memory set of generated files. Generators return a FileTree; writing to disk is a separate step.
2
+
3
+ /** Relative POSIX path → file content, always sorted by path. */
4
+
5
+
6
+ function isRelativePosixPath(path ) {
7
+ if (path === "" || path.startsWith("/") || path.includes("\\")) return false;
8
+ return path.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
9
+ }
10
+
11
+ function byPath(a , b ) {
12
+ if (a[0] === b[0]) return 0;
13
+ return a[0] < b[0] ? -1 : 1;
14
+ }
15
+
16
+ export function createFileTree(entries ) {
17
+ const files = new Map ();
18
+ for (const [path, content] of entries) {
19
+ if (!isRelativePosixPath(path)) throw new Error(`invalid path "${path}": use a relative POSIX path`);
20
+ if (content.includes("\r")) throw new Error(`${path} contains CR characters; generated files must use LF`);
21
+ if (files.has(path)) throw new Error(`duplicate path ${path}`);
22
+ files.set(path, content);
23
+ }
24
+ return new Map([...files.entries()].sort(byPath));
25
+ }
@@ -0,0 +1,6 @@
1
+ import { createHash } from "node:crypto";
2
+
3
+ /** SHA-256 of the UTF-8 encoding of `text`, as lowercase hex. */
4
+ export function sha256(text ) {
5
+ return createHash("sha256").update(text, "utf8").digest("hex");
6
+ }
@@ -0,0 +1,16 @@
1
+ export { canonicalJson } from "./canonical-json.ts";
2
+ export { capabilitiesFor, selectStrategies, } from "./capabilities.ts";
3
+ export { createCodeWriter, } from "./code-writer.ts";
4
+ export { createFileTree, } from "./file-tree.ts";
5
+ export { sha256 } from "./hash.ts";
6
+ export {
7
+ createLock,
8
+ verifyLock,
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+ } from "./lock.ts";
@@ -0,0 +1,106 @@
1
+ // sdkloom.lock.json: records exactly what a build used and produced (docs/07-language-kits.md §4).
2
+
3
+ import { canonicalJson } from "./canonical-json.ts";
4
+
5
+ import { sha256 } from "./hash.ts";
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+  
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+ function compareText(a , b ) {
61
+ if (a === b) return 0;
62
+ return a < b ? -1 : 1;
63
+ }
64
+
65
+ export function createLock(input ) {
66
+ const kits = input.kits
67
+ .map((kit) => ({ name: kit.name, version: kit.version, sha256: sha256(kit.content) }))
68
+ .sort((a, b) => compareText(a.name, b.name));
69
+
70
+ const blocks = input.blocks
71
+ .map((block) => ({
72
+ id: block.id,
73
+ ...(block.strategy === undefined ? {} : { strategy: block.strategy }),
74
+ versions: block.versions,
75
+ sha256: sha256(block.code),
76
+ }))
77
+ .sort((a, b) => compareText(a.id, b.id) || compareText(a.versions, b.versions));
78
+
79
+ const files = [...input.files.entries()].map(([path, content]) => ({
80
+ path,
81
+ sha256: sha256(content),
82
+ from: [...new Set(input.trace.get(path) ?? [])].sort(compareText),
83
+ }));
84
+
85
+ return {
86
+ sdkloom: input.sdkloom,
87
+ profile: input.profile,
88
+ ir: { sha256: sha256(canonicalJson(input.ir)) },
89
+ kits,
90
+ blocks,
91
+ files,
92
+ output: { sha256: sha256(canonicalJson(files)) },
93
+ };
94
+ }
95
+
96
+ /** Compares generated files with a lock. Returns one message per difference, sorted. */
97
+ export function verifyLock(lock , files ) {
98
+ const locked = new Set(lock.files.map((file) => file.path));
99
+ const differences = lock.files.flatMap((file) => {
100
+ const content = files.get(file.path);
101
+ if (content === undefined) return [`missing: ${file.path}`];
102
+ return sha256(content) === file.sha256 ? [] : [`modified: ${file.path}`];
103
+ });
104
+ const unexpected = [...files.keys()].filter((path) => !locked.has(path)).map((path) => `unexpected: ${path}`);
105
+ return [...differences, ...unexpected];
106
+ }
@@ -0,0 +1,143 @@
1
+ // Validates one conformance case file (docs/05-testing.md, part C).
2
+
3
+ import { checkOneOf, checkStringMap, collect, IDENTIFIER, isNonEmptyString, isRecord, LEVELS, METHODS, } from "./checks.ts";
4
+
5
+ const CASE_ID = /^\d{4}-[a-z0-9]+(?:-[a-z0-9]+)*$/;
6
+ const MIN_STATUS = 100;
7
+ const MAX_STATUS = 599;
8
+
9
+ function checkRequirements(value , report ) {
10
+ if (!Array.isArray(value) || value.length === 0) {
11
+ report("requirements", "must list at least one requirement");
12
+ return;
13
+ }
14
+ value.forEach((entry , index) => {
15
+ if (!isNonEmptyString(entry)) report(`requirements[${index}]`, "must be a non-empty string");
16
+ });
17
+ }
18
+
19
+ function checkCall(value , report ) {
20
+ if (!isRecord(value)) {
21
+ report("call", "must be an object");
22
+ return;
23
+ }
24
+ if (typeof value["op"] !== "string" || !IDENTIFIER.test(value["op"])) report("call.op", "must be an identifier");
25
+ if (!isRecord(value["args"])) report("call.args", "must be an object");
26
+ if ("all" in value && typeof value["all"] !== "boolean") report("call.all", "must be a boolean");
27
+ if ("wait" in value && typeof value["wait"] !== "boolean") report("call.wait", "must be a boolean");
28
+ }
29
+
30
+ function checkExpectedRequest(value , report , at = "expectRequest") {
31
+ if (!isRecord(value)) {
32
+ report(at, "must be an object");
33
+ return;
34
+ }
35
+ checkOneOf(value["method"], METHODS, `${at}.method`, report);
36
+ const path = value["path"];
37
+ if (typeof path !== "string" || !path.startsWith("/")) report(`${at}.path`, "must start with /");
38
+ checkStringMap(value, "query", at, report);
39
+ checkStringMap(value, "headers", at, report);
40
+ if ("multipart" in value) {
41
+ const parts = value["multipart"];
42
+ if (!Array.isArray(parts)) report(`${at}.multipart`, "must list the form's parts");
43
+ else {
44
+ parts.forEach((part , index) => {
45
+ const ok = isRecord(part) && typeof part["name"] === "string" && typeof part["value"] === "string" && ["filename", "contentType"].every((key) => !(key in part) || typeof part[key] === "string");
46
+ if (!ok) report(`${at}.multipart[${index}]`, "must have a string name and value, and optionally a string filename and contentType");
47
+ });
48
+ }
49
+ }
50
+ }
51
+
52
+ /** Every request, in order: for calls that send more than one (pagination, retries). */
53
+ function checkExpectedRequests(value , report ) {
54
+ if (!Array.isArray(value) || value.length === 0) {
55
+ report("expectRequests", "must list at least one request");
56
+ return;
57
+ }
58
+ value.forEach((entry , index) => checkExpectedRequest(entry, report, `expectRequests[${index}]`));
59
+ }
60
+
61
+ function checkOneResponse(value , report , at ) {
62
+ if (!isRecord(value)) {
63
+ report(at, "must be an object");
64
+ return;
65
+ }
66
+ const status = value["status"];
67
+ if (typeof status !== "number" || !Number.isInteger(status) || status < MIN_STATUS || status > MAX_STATUS) {
68
+ report(`${at}.status`, `must be an integer from ${MIN_STATUS} to ${MAX_STATUS}`);
69
+ }
70
+ checkStringMap(value, "headers", at, report);
71
+ if ("text" in value && typeof value["text"] !== "string") report(`${at}.text`, "must be a string");
72
+ if ("text" in value && "json" in value) report(at, "has either json or text, not both");
73
+ }
74
+
75
+ /** One response, or a list answered in order (the last one repeats). */
76
+ function checkResponse(value , report ) {
77
+ if (!Array.isArray(value)) {
78
+ checkOneResponse(value, report, "respond");
79
+ return;
80
+ }
81
+ if (value.length === 0) report("respond", "must list at least one response");
82
+ value.forEach((entry , index) => checkOneResponse(entry, report, `respond[${index}]`));
83
+ }
84
+
85
+ /** A logic case: the SDK's logic function `name` is called with `args` (its inputs by name); no request is made. */
86
+ function checkLogicCall(value , report ) {
87
+ if (!isRecord(value)) {
88
+ report("logic", "must be an object");
89
+ return;
90
+ }
91
+ if (typeof value["name"] !== "string" || !IDENTIFIER.test(value["name"])) report("logic.name", "must be an identifier");
92
+ if (!isRecord(value["args"])) report("logic.args", "must be an object");
93
+ }
94
+
95
+ /** A webhook case: the SDK verifies and reads a request the API sent, instead of calling an operation. */
96
+ function checkWebhook(value , report ) {
97
+ if (!isRecord(value)) {
98
+ report("webhook", "must be an object");
99
+ return;
100
+ }
101
+ if (typeof value["name"] !== "string" || !IDENTIFIER.test(value["name"])) report("webhook.name", "must be an identifier");
102
+ if (typeof value["secret"] !== "string") report("webhook.secret", "must be a string");
103
+ if (typeof value["body"] !== "string") report("webhook.body", "must be a string");
104
+ checkStringMap(value, "headers", "webhook", report);
105
+ const now = value["now"];
106
+ if (typeof now !== "number" || !Number.isInteger(now)) report("webhook.now", "must be the current time in whole seconds since 1970");
107
+ }
108
+
109
+ function checkExpectation(value , report ) {
110
+ if (!isRecord(value)) {
111
+ report("expect", "must be an object");
112
+ return;
113
+ }
114
+ const hasEquals = "equals" in value;
115
+ const hasError = "error" in value;
116
+ if (hasEquals === hasError) {
117
+ report("expect", "must have exactly one of equals or error");
118
+ } else if (hasError && !isNonEmptyString(value["error"])) {
119
+ report("expect.error", "must be a non-empty string");
120
+ }
121
+ }
122
+
123
+ /** Returns sorted "<path>: <message>" issues; empty means the case is valid. */
124
+ export function validateCase(value ) {
125
+ if (!isRecord(value)) return ["$: must be an object"];
126
+ return collect((report) => {
127
+ if (typeof value["id"] !== "string" || !CASE_ID.test(value["id"])) report("id", "must look like 0001-short-name");
128
+ if (!isNonEmptyString(value["name"])) report("name", "must be a non-empty string");
129
+ checkOneOf(value["level"], LEVELS, "level", report);
130
+ checkRequirements(value["requirements"], report);
131
+ if ("webhook" in value) {
132
+ checkWebhook(value["webhook"], report);
133
+ } else if ("logic" in value) {
134
+ checkLogicCall(value["logic"], report);
135
+ } else {
136
+ checkCall(value["call"], report);
137
+ if ("expectRequest" in value) checkExpectedRequest(value["expectRequest"], report);
138
+ if ("expectRequests" in value) checkExpectedRequests(value["expectRequests"], report);
139
+ checkResponse(value["respond"], report);
140
+ }
141
+ checkExpectation(value["expect"], report);
142
+ });
143
+ }
@@ -0,0 +1,40 @@
1
+ // Shared helpers for conformance validators. Each check reports "<path>: <message>".
2
+
3
+
4
+
5
+ export const IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
6
+ export const METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"] ;
7
+ export const LEVELS = ["MUST", "SHOULD", "MAY"] ;
8
+
9
+ export function isRecord(value ) {
10
+ return typeof value === "object" && value !== null && !Array.isArray(value);
11
+ }
12
+
13
+ export function isNonEmptyString(value ) {
14
+ return typeof value === "string" && value !== "";
15
+ }
16
+
17
+ export function checkOneOf(value , allowed , path , report ) {
18
+ if (typeof value !== "string" || !allowed.includes(value)) report(path, `must be one of ${allowed.join(", ")}`);
19
+ }
20
+
21
+ /** Checks an optional { name: string } map such as headers or query parameters. */
22
+ export function checkStringMap(record , key , path , report ) {
23
+ if (!(key in record)) return;
24
+ const value = record[key];
25
+ if (!isRecord(value)) {
26
+ report(`${path}.${key}`, "must be an object");
27
+ return;
28
+ }
29
+ Object.entries(value)
30
+ .filter(([, entry]) => typeof entry !== "string")
31
+ .forEach(([name]) => report(`${path}.${key}.${name}`, "must be a string"));
32
+ }
33
+
34
+ export function collect(check ) {
35
+ const issues = [];
36
+ check((path, message) => {
37
+ issues.push(`${path}: ${message}`);
38
+ });
39
+ return issues.sort();
40
+ }
@@ -0,0 +1,3 @@
1
+ export { validateCase } from "./case.ts";
2
+ export { renderMatrix, } from "./matrix.ts";
3
+ export { validateIndex, validateNotApplicable } from "./suite.ts";