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,232 @@
1
+ # sdkloom Python kit: calling one operation.
2
+ from __future__ import absolute_import, division, unicode_literals
3
+
4
+ import re
5
+
6
+ from .compat import Record, factory
7
+ from .context import UNKNOWN_SDK, Context, OperationInfo, State, SystemClock, create_emitter
8
+ from .errors import ApiError
9
+ from .http import ArgumentError, HttpRequest, build_url, scalar
10
+ from .models import UNSET, encode_json
11
+ from .multipart import encode_multipart
12
+ from .pipeline import run_pipeline
13
+ from .sse import decode_events, parse_events
14
+ from .transport import SendOptions
15
+
16
+ try: # type names for annotations in generated code and type checkers; Python 2.7 has no typing module
17
+ from typing import Any, Callable, Iterable, Mapping, Optional, Sequence, Tuple # noqa: F401
18
+
19
+ from .context import EventListener, SdkInfo # noqa: F401
20
+ from .errors import ErrorFactory # noqa: F401
21
+ from .http import HttpResponse # noqa: F401
22
+ from .models import Decoder # noqa: F401
23
+ from .pipeline import Handler, Next # noqa: F401
24
+ from .transport import Transport # noqa: F401
25
+ except ImportError: # pragma: no cover
26
+ pass
27
+
28
+ # @block client.call
29
+ # @summary Sends one operation: refuses one newer than the pinned API version, builds URL, headers (with the API version) and body, runs the middleware chain, sends it and turns the response into a result or an error.
30
+ # @versions >=2.7
31
+ # @source [1] https://www.rfc-editor.org/rfc/rfc9110#section-15.5
32
+ # @quote [1] "The 4xx (Client Error) class of status code indicates that the client seems to have erred."
33
+ # @source [2] https://www.rfc-editor.org/rfc/rfc9110#section-15.6
34
+ # @quote [2] "The 5xx (Server Error) class of status code indicates that the server is aware that it has erred or is incapable of performing the requested method."
35
+ # @retrieved 2026-12-05
36
+ # @tests tests/test_client.py
37
+ # @requirement SDKL-ERR-001
38
+ # @requirement SDKL-PIPE-001
39
+ try:
40
+ Middleware = Callable[[HttpRequest, Next, Context], HttpResponse]
41
+ except NameError: # pragma: no cover - Python 2.7
42
+ Middleware = object
43
+ _JSON = "application/json"
44
+ _BYTES = "application/octet-stream"
45
+ _EVENTS = "text/event-stream"
46
+
47
+
48
+ class MiddlewareEntry(Record):
49
+ """name and run(request, call_next, ctx) of one middleware with its configuration bound."""
50
+
51
+ _fields = ("name", "run")
52
+
53
+
54
+ def entry(name, middleware, config):
55
+ # type: (str, Middleware, Any) -> MiddlewareEntry
56
+ """Binds a middleware to its configuration."""
57
+ return MiddlewareEntry(name, lambda request, call_next, base: middleware(request, call_next, base.with_config(config)))
58
+
59
+
60
+ class ParamSpec(Record):
61
+ _fields = ("name", "location")
62
+
63
+
64
+ class OperationSpec(Record):
65
+ """What generated code knows about one operation: name, method, path, params, body and result kinds ("events" for an event stream, with decode_event for its data), decoder, error factories and middleware."""
66
+
67
+ _fields = ("name", "method", "path", "params", "body", "result", "decode", "errors", "use", "decode_event", "since")
68
+ _defaults = {"params": (), "body": None, "result": None, "decode": None, "errors": factory(dict), "use": (), "decode_event": None, "since": None}
69
+
70
+
71
+ class ClientRuntime(Record):
72
+ """Everything a client shares between calls."""
73
+
74
+ _fields = ("base_url", "transport", "clock", "state", "middleware", "registry", "user_middleware", "listeners", "timeout_ms", "sdk", "api_version")
75
+ _defaults = {
76
+ "clock": factory(SystemClock),
77
+ "state": None,
78
+ "middleware": (),
79
+ "registry": factory(dict),
80
+ "user_middleware": (),
81
+ "listeners": (),
82
+ "timeout_ms": None,
83
+ "sdk": UNKNOWN_SDK,
84
+ "api_version": None,
85
+ }
86
+
87
+
88
+ class ApiVersion(Record):
89
+ """The API version a client is pinned to (value), the header that carries it and every version, oldest first."""
90
+
91
+ _fields = ("header", "value", "values")
92
+
93
+
94
+ def check_api_version(version, operation, since):
95
+ # type: (Optional[ApiVersion], str, Optional[str]) -> None
96
+ """Refuses an operation newer than the pinned API version, or a version the SDK does not know."""
97
+ if version is None:
98
+ return
99
+ if version.value not in version.values:
100
+ raise ArgumentError("unknown API version " + version.value + "; this SDK knows " + ", ".join(version.values))
101
+ if since is not None and list(version.values).index(since) > list(version.values).index(version.value):
102
+ raise ArgumentError(operation + " needs API version " + since + " or later; this client uses " + version.value)
103
+
104
+
105
+ class CallOptions(Record):
106
+ """Per-call settings: timeout_ms, extra headers, base_url, and url to call instead of the one built from the path and
107
+ query (the next page a Link header named; resolved against the base URL like resolve_url)."""
108
+
109
+ _fields = ("timeout_ms", "headers", "base_url", "url")
110
+ _defaults = {"timeout_ms": None, "headers": None, "base_url": None, "url": None}
111
+
112
+
113
+ def resolve_url(base, url):
114
+ # type: (str, str) -> str
115
+ """A URL from the API resolved against the base URL: absolute as is, "/path" on the base's origin, else after it."""
116
+ if re.match(r"(?i)^https?://", url):
117
+ return url
118
+ if url.startswith("/"):
119
+ return re.sub(r"(?i)^(https?://[^/]+).*$", r"\1", base) + url
120
+ return base.rstrip("/") + "/" + url
121
+
122
+
123
+ class RawResult(Record):
124
+ """data and the HttpResponse it came from."""
125
+
126
+ _fields = ("data", "response")
127
+
128
+
129
+ def _present(value):
130
+ # type: (Any) -> bool
131
+ return value is not None and value is not UNSET
132
+
133
+
134
+ def _encode_body(kind, value):
135
+ # type: (Optional[str], Any) -> Optional[Tuple[bytes, str]]
136
+ if kind is None or not _present(value):
137
+ return None
138
+ if kind == "json":
139
+ return encode_json(value), _JSON
140
+ if kind == "multipart":
141
+ return encode_multipart(value)
142
+ if isinstance(value, (bytes, bytearray)):
143
+ return bytes(value), _BYTES
144
+ return b"".join(bytes(chunk) for chunk in value), _BYTES
145
+
146
+
147
+ def _build_request(runtime, spec, args, options):
148
+ # type: (ClientRuntime, OperationSpec, Mapping[str, Any], CallOptions) -> HttpRequest
149
+ def params(location):
150
+ # type: (str) -> Sequence[ParamSpec]
151
+ return [param for param in spec.params if param.location == location]
152
+
153
+ path_params = {param.name: args[param.name] for param in params("path") if param.name in args}
154
+ query = [(param.name, args.get(param.name) if _present(args.get(param.name)) else None) for param in params("query")]
155
+ header_params = [(param.name, scalar(args[param.name])) for param in params("header") if _present(args.get(param.name))]
156
+ body = _encode_body(spec.body, args.get("body"))
157
+ accept = _EVENTS if spec.result == "events" else "*/*" if spec.result in ("bytes", "stream") else _JSON
158
+ version = [(runtime.api_version.header, runtime.api_version.value)] if runtime.api_version is not None else []
159
+ headers = [("accept", accept)] + ([("content-type", body[1])] if body else []) + version + header_params + list((options.headers or {}).items())
160
+
161
+ base = options.base_url or runtime.base_url
162
+ url = build_url(base, spec.path, path_params, query) if options.url is None else resolve_url(base, options.url)
163
+ request = HttpRequest(spec.method, url, (), body[0] if body else None)
164
+ for name, value in headers:
165
+ request = request.with_header(name, value)
166
+ return request
167
+
168
+
169
+ def _read_result(spec, response):
170
+ # type: (OperationSpec, HttpResponse) -> Any
171
+ if spec.result == "json":
172
+ value = response.json()
173
+ return value if spec.decode is None else spec.decode(value, "$")
174
+ if spec.result == "bytes":
175
+ return response.body
176
+ if spec.result == "stream":
177
+ return iter([response.body])
178
+ if spec.result == "events":
179
+ return decode_events(parse_events(response.chunks()), spec.decode_event)
180
+ return None
181
+
182
+
183
+ def _error_for(spec, response):
184
+ # type: (OperationSpec, HttpResponse) -> ApiError
185
+ try:
186
+ body = response.json()
187
+ except ValueError:
188
+ body = response.text()
189
+ factory = spec.errors.get(response.status)
190
+ return factory(response.status, body, response) if factory else ApiError(response.status, body, response)
191
+
192
+
193
+ def _lookup(registry, name):
194
+ # type: (Mapping[str, MiddlewareEntry], str) -> MiddlewareEntry
195
+ if name not in registry:
196
+ raise KeyError("unknown middleware " + name)
197
+ return registry[name]
198
+
199
+
200
+ def call_operation(runtime, spec, args, options=None):
201
+ # type: (ClientRuntime, OperationSpec, Mapping[str, Any], Optional[CallOptions]) -> RawResult
202
+ options = options or CallOptions()
203
+ check_api_version(runtime.api_version, spec.name, spec.since)
204
+ request = _build_request(runtime, spec, args, options)
205
+ send_options = SendOptions(timeout_ms=options.timeout_ms if options.timeout_ms is not None else runtime.timeout_ms, stream=spec.result == "events")
206
+
207
+ def send(current):
208
+ # type: (HttpRequest) -> HttpResponse
209
+ return runtime.transport(current, send_options)
210
+
211
+ base = Context(
212
+ config=None,
213
+ operation=OperationInfo(spec.name, spec.method, spec.path),
214
+ clock=runtime.clock,
215
+ state=runtime.state or State(runtime.clock),
216
+ emit=create_emitter(runtime.listeners),
217
+ send=send,
218
+ sdk=runtime.sdk,
219
+ )
220
+ entries = list(runtime.middleware) + [_lookup(runtime.registry, name) for name in spec.use] + list(runtime.user_middleware)
221
+ handlers = [_bind(item, base) for item in entries]
222
+
223
+ response = run_pipeline(handlers, request, send)
224
+ if not 200 <= response.status <= 299:
225
+ raise _error_for(spec, response)
226
+ return RawResult(_read_result(spec, response), response)
227
+
228
+
229
+ def _bind(item, base):
230
+ # type: (MiddlewareEntry, Context) -> Handler
231
+ return lambda request, call_next: item.run(request, call_next, base)
232
+ # @end
@@ -0,0 +1,195 @@
1
+ # sdkloom Python kit: one runtime for Python 2.7 and 3.x.
2
+ # Plain classes and type comments instead of dataclasses and annotations, so the same files run everywhere.
3
+ from __future__ import absolute_import, division, unicode_literals
4
+
5
+ import json
6
+ import sys
7
+ import time
8
+ from collections import OrderedDict
9
+
10
+ # @block compat.py2
11
+ # @summary The few names that differ between Python 2.7 and 3: text and integer types, urllib, a monotonic clock, and immutable records that replace dataclasses.
12
+ # @versions >=2.7
13
+ # @source [1] https://docs.python.org/2.7/library/urllib2.html
14
+ # @quote [1] "The urllib2 module has been split across several modules in Python 3 named urllib.request and urllib.error."
15
+ # @source [2] https://docs.python.org/2.7/library/time.html
16
+ # @quote [2] "Return the time in seconds since the epoch as a floating point number."
17
+ # @retrieved 2026-12-05
18
+ # @tests tests/test_compat.py
19
+ # @requirement SDKL-HTTP-004
20
+ PY2 = sys.version_info[0] == 2
21
+
22
+ if PY2: # pragma: no cover - exercised by the Python 2.7 variant
23
+ text_type = unicode # noqa: F821
24
+ string_types = (str, unicode) # noqa: F821
25
+ integer_types = (int, long) # noqa: F821
26
+ import urllib2 as _request
27
+ from httplib import HTTPException # noqa: F401
28
+ from urllib import quote as _quote, quote_plus as _quote_plus
29
+ from urlparse import urlsplit # noqa: F401
30
+
31
+ HTTPError = _request.HTTPError
32
+ URLError = _request.URLError
33
+
34
+ def to_text(value):
35
+ # type: (object) -> object
36
+ """A native str (bytes on 2.7, written without a u prefix) as text, read as UTF-8; anything else unchanged."""
37
+ return value.decode("utf-8") if isinstance(value, str) else value
38
+
39
+ def quote(text, safe):
40
+ # type: (str, str) -> str
41
+ # "~" is unreserved (RFC 3986); Python 3.7+ leaves it alone and so must 2.7.
42
+ return _quote(to_text(text).encode("utf-8"), safe=(safe + "~").encode("ascii")).decode("ascii")
43
+
44
+ def quote_plus(text, safe):
45
+ # type: (str, str) -> str
46
+ return _quote_plus(to_text(text).encode("utf-8"), safe=safe.encode("ascii")).decode("ascii")
47
+
48
+ def monotonic():
49
+ # type: () -> float
50
+ return time.time()
51
+
52
+ else:
53
+ text_type = str
54
+ string_types = (str,)
55
+ integer_types = (int,)
56
+ import urllib.request as _request
57
+ from http.client import HTTPException # noqa: F401
58
+ from urllib.error import HTTPError, URLError # noqa: F401
59
+ from urllib.parse import quote, quote_plus, urlsplit # noqa: F401
60
+
61
+ def to_text(value):
62
+ # type: (object) -> object
63
+ return value
64
+
65
+ monotonic = time.monotonic
66
+
67
+ request = _request
68
+ # Dicts keep insertion order from Python 3.7 on; on 2.7 field order of JSON objects needs OrderedDict.
69
+ ordered_dict = OrderedDict if PY2 else dict
70
+
71
+
72
+ def _no_constant(name):
73
+ # type: (str) -> object
74
+ raise ValueError("invalid JSON: " + name)
75
+
76
+
77
+ def json_loads(text):
78
+ # type: (str) -> object
79
+ """json.loads that keeps the order of object fields on every version and, like JSON.parse, rejects NaN and Infinity."""
80
+ if PY2:
81
+ return json.loads(text, object_pairs_hook=OrderedDict, parse_constant=_no_constant)
82
+ return json.loads(text, parse_constant=_no_constant)
83
+
84
+
85
+ def message_of(error):
86
+ # type: (BaseException) -> str
87
+ """The text of an exception, also on 2.7 when its message is non-ASCII bytes."""
88
+ try:
89
+ return text_type(error)
90
+ except UnicodeError: # pragma: no cover - Python 2.7
91
+ return str(error).decode("utf-8", "replace")
92
+
93
+
94
+ def is_text(value):
95
+ # type: (object) -> bool
96
+ """A string; on 2.7 both unicode and native str, since callers write "abc" without a u prefix."""
97
+ return isinstance(value, string_types)
98
+
99
+
100
+ def is_integer(value):
101
+ # type: (object) -> bool
102
+ return isinstance(value, integer_types) and not isinstance(value, bool)
103
+
104
+
105
+ def number_text(value):
106
+ # type: (float) -> str
107
+ """repr gives the shortest digits that round-trip in 2.7 and 3; str in 2.7 rounds to 12 digits."""
108
+ return text_type(repr(value))
109
+
110
+
111
+ class Record(object):
112
+ """An immutable value with named fields, equality, hashing and repr; a dataclass(frozen=True) that also runs on 2.7.
113
+
114
+ Subclasses list their fields in _fields and their defaults in _defaults; fields in _hidden are left out of
115
+ equality, hashing and repr, like dataclasses.field(compare=False, repr=False).
116
+ """
117
+
118
+ __slots__ = ()
119
+ _fields = () # type: tuple
120
+ _defaults = {} # type: dict
121
+ _hidden = () # type: tuple
122
+
123
+ def __init__(self, *args, **kwargs):
124
+ if len(args) > len(self._fields):
125
+ raise TypeError(type(self).__name__ + " takes at most " + text_type(len(self._fields)) + " arguments")
126
+ values = dict(zip(self._fields, args))
127
+ for name, value in kwargs.items():
128
+ if name not in self._fields:
129
+ raise TypeError(type(self).__name__ + " got an unexpected argument " + name)
130
+ if name in values:
131
+ raise TypeError(type(self).__name__ + " got two values for " + name)
132
+ values[name] = value
133
+ for name in self._fields:
134
+ if name not in values:
135
+ if name not in self._defaults:
136
+ raise TypeError(type(self).__name__ + " is missing " + name)
137
+ default = self._defaults[name]
138
+ values[name] = default.make() if isinstance(default, _Factory) else default
139
+ object.__setattr__(self, name, values[name])
140
+
141
+ def __setattr__(self, name, value):
142
+ raise AttributeError(type(self).__name__ + " is immutable; use replace()")
143
+
144
+ def __delattr__(self, name):
145
+ raise AttributeError(type(self).__name__ + " is immutable")
146
+
147
+ def _values(self):
148
+ return tuple(getattr(self, name) for name in self._fields)
149
+
150
+ def _compared(self):
151
+ return tuple(getattr(self, name) for name in self._fields if name not in self._hidden)
152
+
153
+ def __eq__(self, other):
154
+ return type(other) is type(self) and other._compared() == self._compared()
155
+
156
+ def __ne__(self, other):
157
+ return not self == other
158
+
159
+ def __hash__(self):
160
+ return hash((type(self).__name__,) + self._compared())
161
+
162
+ def __repr__(self):
163
+ shown = [name for name in self._fields if name not in self._hidden]
164
+ return type(self).__name__ + "(" + ", ".join(name + "=" + repr(getattr(self, name)) for name in shown) + ")"
165
+
166
+
167
+ class _Factory(object):
168
+ __slots__ = ("make",)
169
+
170
+ def __init__(self, make):
171
+ self.make = make
172
+
173
+
174
+ def factory(make):
175
+ """A default built fresh for every instance, like dataclasses.field(default_factory=...)."""
176
+ return _Factory(make)
177
+
178
+
179
+ def replace(value, **changes):
180
+ """dataclasses.replace for Record (and for dataclasses on Python 3)."""
181
+ if isinstance(value, Record):
182
+ values = dict(zip(value._fields, value._values()))
183
+ values.update(changes)
184
+ return type(value)(**values)
185
+ import dataclasses # Python 3 only: generated models of the default package are dataclasses
186
+
187
+ return dataclasses.replace(value, **changes)
188
+
189
+
190
+ def raise_from(error, cause):
191
+ """`raise error from cause`, which is a syntax error on 2.7."""
192
+ error.__cause__ = cause
193
+ error.__suppress_context__ = True
194
+ raise error
195
+ # @end
@@ -0,0 +1,134 @@
1
+ # sdkloom Python kit: the capabilities a middleware receives as ctx.
2
+ from __future__ import absolute_import, division, unicode_literals
3
+
4
+ import threading
5
+ import time
6
+
7
+ from .compat import Record, monotonic, replace, text_type
8
+ from .http import HttpRequest
9
+
10
+ try: # type names for annotations in generated code and type checkers; Python 2.7 has no typing module
11
+ from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple # noqa: F401
12
+
13
+ from .http import HttpResponse # noqa: F401
14
+ except ImportError: # pragma: no cover
15
+ pass
16
+
17
+ # @block context.create
18
+ # @summary The capabilities a middleware gets through ctx: a clock, thread-safe per-client state with expiry, and events whose listeners can never break a call.
19
+ # @versions >=2.7
20
+ # @source [1] https://docs.python.org/3/library/time.html#time.monotonic
21
+ # @quote [1] "Return the value (in fractional seconds) of a monotonic clock, i.e. a clock that cannot go backwards."
22
+ # @source [2] https://docs.python.org/3/library/time.html#time.sleep
23
+ # @quote [2] "Suspend execution of the calling thread for the given number of seconds."
24
+ # @source [3] https://docs.python.org/3/library/threading.html#lock-objects
25
+ # @quote [3] "A primitive lock is a synchronization primitive that is not owned by a particular thread when locked."
26
+ # @source [4] https://docs.python.org/2.7/library/time.html
27
+ # @quote [4] "Return the time in seconds since the epoch as a floating point number."
28
+ # @retrieved 2026-12-05
29
+ # @tests tests/test_client.py
30
+ # @requirement SDKL-PIPE-002
31
+ class SystemClock(object):
32
+ """Milliseconds from a monotonic clock (wall time on Python 2.7, which has none)."""
33
+
34
+ def now(self):
35
+ # type: () -> int
36
+ return int(monotonic() * 1000)
37
+
38
+ def sleep(self, ms):
39
+ # type: (int) -> None
40
+ time.sleep(ms / 1000)
41
+
42
+
43
+ class State(object):
44
+ """Per-client storage shared by all calls, e.g. for a cached token. Thread-safe."""
45
+
46
+ def __init__(self, clock):
47
+ # type: (Any) -> None
48
+ self._clock = clock
49
+ self._lock = threading.Lock()
50
+ self._entries = {} # type: Dict[str, Tuple[Any, Optional[int]]]
51
+
52
+ def get(self, key):
53
+ # type: (str) -> Any
54
+ with self._lock:
55
+ entry = self._entries.get(key)
56
+ if entry is None:
57
+ return None
58
+ value, expires_at = entry
59
+ if expires_at is not None and self._clock.now() >= expires_at:
60
+ del self._entries[key]
61
+ return None
62
+ return value
63
+
64
+ def set(self, key, value, ttl_ms=None):
65
+ # type: (str, Any, Optional[int]) -> None
66
+ with self._lock:
67
+ self._entries[key] = (value, None if ttl_ms is None else self._clock.now() + ttl_ms)
68
+
69
+ def delete(self, key):
70
+ # type: (str) -> None
71
+ with self._lock:
72
+ self._entries.pop(key, None)
73
+
74
+
75
+ try:
76
+ EventFields = Mapping[str, Any]
77
+ EventListener = Callable[[str, EventFields], None]
78
+ except NameError: # pragma: no cover - Python 2.7
79
+ EventFields = EventListener = object
80
+ LISTENER_ERROR = "sdkloom.listener_error"
81
+
82
+
83
+ def create_emitter(listeners):
84
+ # type: (Sequence[EventListener]) -> Callable[[str, EventFields], None]
85
+ """Delivers events to every listener; a listener that raises is reported, never propagated."""
86
+
87
+ def deliver(name, fields, skip):
88
+ # type: (str, EventFields, Optional[EventListener]) -> None
89
+ failures = []
90
+ for listener in listeners:
91
+ if listener is skip:
92
+ continue
93
+ try:
94
+ listener(name, fields)
95
+ except Exception as error: # noqa: BLE001 - listeners must never break a call
96
+ failures.append((listener, error))
97
+ if name == LISTENER_ERROR:
98
+ return
99
+ for listener, error in failures:
100
+ deliver(LISTENER_ERROR, {"event": name, "error": text_type(error)}, listener)
101
+
102
+ return lambda name, fields: deliver(name, fields, None)
103
+
104
+
105
+ class OperationInfo(Record):
106
+ """name, method and path of the operation being called."""
107
+
108
+ _fields = ("name", "method", "path")
109
+
110
+
111
+ class SdkInfo(Record):
112
+ """Which generated SDK a middleware runs in (name, version, language), e.g. for a User-Agent such as "acme-python/1.2.0"."""
113
+
114
+ _fields = ("name", "version", "language")
115
+ _defaults = {"language": "python"}
116
+
117
+
118
+ UNKNOWN_SDK = SdkInfo("", "", "python")
119
+
120
+
121
+ class Context(Record):
122
+ """What a middleware gets as ctx: config, operation, clock, state, emit, send and sdk."""
123
+
124
+ _fields = ("config", "operation", "clock", "state", "emit", "send", "sdk")
125
+ _defaults = {"sdk": UNKNOWN_SDK}
126
+
127
+ def request(self, method, url):
128
+ # type: (str, str) -> HttpRequest
129
+ return HttpRequest(method, url)
130
+
131
+ def with_config(self, config):
132
+ # type: (Any) -> Context
133
+ return replace(self, config=config)
134
+ # @end
@@ -0,0 +1,65 @@
1
+ # sdkloom Python kit: errors.
2
+ from __future__ import absolute_import, division, unicode_literals
3
+
4
+ from .compat import text_type
5
+
6
+ try: # type names for type checkers; Python 2.7 has no typing module
7
+ from typing import Any, Callable, Optional # noqa: F401
8
+
9
+ from .http import HttpResponse # noqa: F401
10
+ except ImportError: # pragma: no cover
11
+ pass
12
+
13
+ # @block errors.api_error
14
+ # @summary The error for a non-2xx response; carries status, decoded body and request id, and marks 429 and 5xx as retryable.
15
+ # @versions >=2.7
16
+ # @source [1] https://www.rfc-editor.org/rfc/rfc9110#section-15.5
17
+ # @quote [1] "The 4xx (Client Error) class of status code indicates that the client seems to have erred."
18
+ # @source [2] https://www.rfc-editor.org/rfc/rfc9110#section-15.6
19
+ # @quote [2] "The 5xx (Server Error) class of status code indicates that the server is aware that it has erred or is incapable of performing the requested method."
20
+ # @retrieved 2026-12-05
21
+ # @tests tests/test_client.py
22
+ # @requirement SDKL-ERR-001
23
+ _TOO_MANY_REQUESTS = 429
24
+ _FIRST_SERVER_ERROR = 500
25
+
26
+
27
+ class ApiError(Exception):
28
+ def __init__(self, status, body, response, name="ApiError"):
29
+ # type: (int, Any, HttpResponse, str) -> None
30
+ super(ApiError, self).__init__(name + ": HTTP " + text_type(status))
31
+ self.name = name
32
+ self.status = status
33
+ self.body = body
34
+ self.response = response
35
+ self.request_id = response.header("x-request-id") # type: Optional[str]
36
+
37
+ @property
38
+ def retryable(self):
39
+ # type: () -> bool
40
+ """True for 429 and 5xx: sending the same request again may succeed."""
41
+ return self.status == _TOO_MANY_REQUESTS or self.status >= _FIRST_SERVER_ERROR
42
+
43
+
44
+ try:
45
+ ErrorFactory = Callable[[int, Any, HttpResponse], ApiError]
46
+ except NameError: # pragma: no cover - Python 2.7
47
+ ErrorFactory = object
48
+ # @end
49
+
50
+ # @block errors.transport_error
51
+ # @summary The error for a request that got no HTTP response: a network failure or a timeout.
52
+ # @versions >=2.7
53
+ # @source [1] https://docs.python.org/3/library/urllib.request.html#urllib.request.urlopen
54
+ # @quote [1] "Open url, which can be either a string containing a valid, properly encoded URL, or a Request object."
55
+ # @retrieved 2026-12-05
56
+ # @tests tests/test_transport.py
57
+ # @requirement SDKL-HTTP-004
58
+ class TransportError(Exception):
59
+ def __init__(self, reason, cause=None):
60
+ # type: (str, Optional[BaseException]) -> None
61
+ super(TransportError, self).__init__("request failed: " + reason)
62
+ self.name = "TransportError"
63
+ self.reason = reason
64
+ self.__cause__ = cause
65
+ # @end