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.
- package/LICENSE +202 -0
- package/README.md +239 -2
- package/kits/allowed-sources.json +24 -0
- package/kits/csharp/kit.json +6 -0
- package/kits/csharp/src/Runtime/Client.cs +295 -0
- package/kits/csharp/src/Runtime/Context.cs +216 -0
- package/kits/csharp/src/Runtime/Errors.cs +121 -0
- package/kits/csharp/src/Runtime/Http.cs +218 -0
- package/kits/csharp/src/Runtime/Json.cs +650 -0
- package/kits/csharp/src/Runtime/Lang.cs +212 -0
- package/kits/csharp/src/Runtime/Models.cs +206 -0
- package/kits/csharp/src/Runtime/Multipart.cs +108 -0
- package/kits/csharp/src/Runtime/Pagination.cs +122 -0
- package/kits/csharp/src/Runtime/Sse.cs +197 -0
- package/kits/csharp/src/Runtime/Testing.cs +375 -0
- package/kits/csharp/src/Runtime/Transport.cs +212 -0
- package/kits/csharp/src/Runtime/Wait.cs +57 -0
- package/kits/csharp/src/Runtime/Webhooks.cs +148 -0
- package/kits/csharp/tests/ClientTests.cs +128 -0
- package/kits/csharp/tests/HttpTests.cs +44 -0
- package/kits/csharp/tests/JsonTests.cs +132 -0
- package/kits/csharp/tests/LangTests.cs +57 -0
- package/kits/csharp/tests/MultipartTests.cs +31 -0
- package/kits/csharp/tests/PaginationTests.cs +93 -0
- package/kits/csharp/tests/SseTests.cs +122 -0
- package/kits/csharp/tests/TestRunner.cs +93 -0
- package/kits/csharp/tests/TestingTests.cs +80 -0
- package/kits/csharp/tests/TransportTests.cs +145 -0
- package/kits/csharp/tests/WaitTests.cs +39 -0
- package/kits/csharp/tests/WebhooksTests.cs +46 -0
- package/kits/csharp/versions.json +12 -0
- package/kits/go/kit.json +6 -0
- package/kits/go/src/sdkruntime/client.go +322 -0
- package/kits/go/src/sdkruntime/context.go +207 -0
- package/kits/go/src/sdkruntime/errors.go +74 -0
- package/kits/go/src/sdkruntime/http.go +261 -0
- package/kits/go/src/sdkruntime/json.go +527 -0
- package/kits/go/src/sdkruntime/lang.go +462 -0
- package/kits/go/src/sdkruntime/multipart.go +75 -0
- package/kits/go/src/sdkruntime/pagination.go +150 -0
- package/kits/go/src/sdkruntime/sse.go +267 -0
- package/kits/go/src/sdkruntime/testing.go +343 -0
- package/kits/go/src/sdkruntime/transport.go +168 -0
- package/kits/go/src/sdkruntime/wait.go +49 -0
- package/kits/go/src/sdkruntime/webhooks.go +129 -0
- package/kits/go/tests/client_test.go +185 -0
- package/kits/go/tests/http_test.go +78 -0
- package/kits/go/tests/json_test.go +127 -0
- package/kits/go/tests/lang_test.go +98 -0
- package/kits/go/tests/multipart_test.go +29 -0
- package/kits/go/tests/pagination_test.go +69 -0
- package/kits/go/tests/sse_test.go +129 -0
- package/kits/go/tests/testing_test.go +121 -0
- package/kits/go/tests/transport_test.go +133 -0
- package/kits/go/tests/wait_test.go +46 -0
- package/kits/go/tests/webhooks_test.go +62 -0
- package/kits/go/versions.json +12 -0
- package/kits/java/kit.json +6 -0
- package/kits/java/src/dev/sdkloom/runtime/ApiException.java +63 -0
- package/kits/java/src/dev/sdkloom/runtime/ArgumentException.java +24 -0
- package/kits/java/src/dev/sdkloom/runtime/Assert.java +72 -0
- package/kits/java/src/dev/sdkloom/runtime/ClientRuntime.java +220 -0
- package/kits/java/src/dev/sdkloom/runtime/Clock.java +39 -0
- package/kits/java/src/dev/sdkloom/runtime/Context.java +79 -0
- package/kits/java/src/dev/sdkloom/runtime/Decode.java +200 -0
- package/kits/java/src/dev/sdkloom/runtime/DecodeException.java +26 -0
- package/kits/java/src/dev/sdkloom/runtime/Decoder.java +16 -0
- package/kits/java/src/dev/sdkloom/runtime/Emitter.java +56 -0
- package/kits/java/src/dev/sdkloom/runtime/ErrorFactory.java +18 -0
- package/kits/java/src/dev/sdkloom/runtime/EventListener.java +20 -0
- package/kits/java/src/dev/sdkloom/runtime/EventStream.java +232 -0
- package/kits/java/src/dev/sdkloom/runtime/FakeClock.java +37 -0
- package/kits/java/src/dev/sdkloom/runtime/Headers.java +42 -0
- package/kits/java/src/dev/sdkloom/runtime/HttpRequest.java +88 -0
- package/kits/java/src/dev/sdkloom/runtime/HttpResponse.java +69 -0
- package/kits/java/src/dev/sdkloom/runtime/JdkTransport.java +97 -0
- package/kits/java/src/dev/sdkloom/runtime/Js.java +230 -0
- package/kits/java/src/dev/sdkloom/runtime/Json.java +281 -0
- package/kits/java/src/dev/sdkloom/runtime/JsonValue.java +15 -0
- package/kits/java/src/dev/sdkloom/runtime/Links.java +62 -0
- package/kits/java/src/dev/sdkloom/runtime/Middleware.java +16 -0
- package/kits/java/src/dev/sdkloom/runtime/MiddlewareEntry.java +43 -0
- package/kits/java/src/dev/sdkloom/runtime/MockRoute.java +111 -0
- package/kits/java/src/dev/sdkloom/runtime/MockTransport.java +62 -0
- package/kits/java/src/dev/sdkloom/runtime/MultipartForm.java +111 -0
- package/kits/java/src/dev/sdkloom/runtime/Next.java +16 -0
- package/kits/java/src/dev/sdkloom/runtime/OperationInfo.java +35 -0
- package/kits/java/src/dev/sdkloom/runtime/OperationMock.java +105 -0
- package/kits/java/src/dev/sdkloom/runtime/OperationSpec.java +125 -0
- package/kits/java/src/dev/sdkloom/runtime/Pages.java +55 -0
- package/kits/java/src/dev/sdkloom/runtime/Pipeline.java +29 -0
- package/kits/java/src/dev/sdkloom/runtime/RawResult.java +31 -0
- package/kits/java/src/dev/sdkloom/runtime/RecordedEvent.java +36 -0
- package/kits/java/src/dev/sdkloom/runtime/SdkInfo.java +38 -0
- package/kits/java/src/dev/sdkloom/runtime/SendOptions.java +34 -0
- package/kits/java/src/dev/sdkloom/runtime/ServerSentEvent.java +58 -0
- package/kits/java/src/dev/sdkloom/runtime/State.java +58 -0
- package/kits/java/src/dev/sdkloom/runtime/Test.java +21 -0
- package/kits/java/src/dev/sdkloom/runtime/TestRunner.java +63 -0
- package/kits/java/src/dev/sdkloom/runtime/Transport.java +16 -0
- package/kits/java/src/dev/sdkloom/runtime/TransportException.java +30 -0
- package/kits/java/src/dev/sdkloom/runtime/UrlConnectionTransport.java +195 -0
- package/kits/java/src/dev/sdkloom/runtime/Urls.java +116 -0
- package/kits/java/src/dev/sdkloom/runtime/Waits.java +53 -0
- package/kits/java/src/dev/sdkloom/runtime/WebhookSignatureException.java +24 -0
- package/kits/java/src/dev/sdkloom/runtime/Webhooks.java +146 -0
- package/kits/java/tests/dev/sdkloom/runtime/ClientTest.java +266 -0
- package/kits/java/tests/dev/sdkloom/runtime/EventStreamTest.java +131 -0
- package/kits/java/tests/dev/sdkloom/runtime/HttpTest.java +95 -0
- package/kits/java/tests/dev/sdkloom/runtime/JdkTransportTest.java +12 -0
- package/kits/java/tests/dev/sdkloom/runtime/JsTest.java +102 -0
- package/kits/java/tests/dev/sdkloom/runtime/JsonTest.java +87 -0
- package/kits/java/tests/dev/sdkloom/runtime/LinksTest.java +22 -0
- package/kits/java/tests/dev/sdkloom/runtime/MultipartFormTest.java +30 -0
- package/kits/java/tests/dev/sdkloom/runtime/PagesTest.java +75 -0
- package/kits/java/tests/dev/sdkloom/runtime/TestData.java +53 -0
- package/kits/java/tests/dev/sdkloom/runtime/TestingTest.java +156 -0
- package/kits/java/tests/dev/sdkloom/runtime/TransportContract.java +201 -0
- package/kits/java/tests/dev/sdkloom/runtime/UrlConnectionTransportTest.java +49 -0
- package/kits/java/tests/dev/sdkloom/runtime/WaitsTest.java +43 -0
- package/kits/java/tests/dev/sdkloom/runtime/WebhooksTest.java +45 -0
- package/kits/java/versions.json +41 -0
- package/kits/python/kit.json +6 -0
- package/kits/python/src/sdkloom_runtime/__init__.py +1 -0
- package/kits/python/src/sdkloom_runtime/client.py +232 -0
- package/kits/python/src/sdkloom_runtime/compat.py +195 -0
- package/kits/python/src/sdkloom_runtime/context.py +134 -0
- package/kits/python/src/sdkloom_runtime/errors.py +65 -0
- package/kits/python/src/sdkloom_runtime/http.py +192 -0
- package/kits/python/src/sdkloom_runtime/lang.py +207 -0
- package/kits/python/src/sdkloom_runtime/models.py +221 -0
- package/kits/python/src/sdkloom_runtime/multipart.py +69 -0
- package/kits/python/src/sdkloom_runtime/pagination.py +61 -0
- package/kits/python/src/sdkloom_runtime/pipeline.py +39 -0
- package/kits/python/src/sdkloom_runtime/sse.py +121 -0
- package/kits/python/src/sdkloom_runtime/testing.py +224 -0
- package/kits/python/src/sdkloom_runtime/transport.py +120 -0
- package/kits/python/src/sdkloom_runtime/wait.py +44 -0
- package/kits/python/src/sdkloom_runtime/webhooks.py +84 -0
- package/kits/python/tests/support.py +28 -0
- package/kits/python/tests/test_client.py +275 -0
- package/kits/python/tests/test_compat.py +87 -0
- package/kits/python/tests/test_http.py +94 -0
- package/kits/python/tests/test_lang.py +104 -0
- package/kits/python/tests/test_models.py +110 -0
- package/kits/python/tests/test_multipart.py +37 -0
- package/kits/python/tests/test_pagination.py +70 -0
- package/kits/python/tests/test_sse.py +61 -0
- package/kits/python/tests/test_testing.py +130 -0
- package/kits/python/tests/test_transport.py +124 -0
- package/kits/python/tests/test_wait.py +46 -0
- package/kits/python/tests/test_webhooks.py +57 -0
- package/kits/python/versions.json +33 -0
- package/kits/rust/kit.json +6 -0
- package/kits/rust/src/runtime/client.rs +212 -0
- package/kits/rust/src/runtime/context.rs +182 -0
- package/kits/rust/src/runtime/crypto.rs +84 -0
- package/kits/rust/src/runtime/errors.rs +147 -0
- package/kits/rust/src/runtime/http.rs +248 -0
- package/kits/rust/src/runtime/json.rs +424 -0
- package/kits/rust/src/runtime/lang.rs +296 -0
- package/kits/rust/src/runtime/mod.rs +30 -0
- package/kits/rust/src/runtime/models.rs +266 -0
- package/kits/rust/src/runtime/multipart.rs +81 -0
- package/kits/rust/src/runtime/pagination.rs +117 -0
- package/kits/rust/src/runtime/sse.rs +195 -0
- package/kits/rust/src/runtime/testing.rs +308 -0
- package/kits/rust/src/runtime/transport.rs +324 -0
- package/kits/rust/src/runtime/wait.rs +29 -0
- package/kits/rust/src/runtime/webhooks.rs +142 -0
- package/kits/rust/tests/client.rs +152 -0
- package/kits/rust/tests/http.rs +44 -0
- package/kits/rust/tests/json.rs +82 -0
- package/kits/rust/tests/lang.rs +74 -0
- package/kits/rust/tests/multipart.rs +21 -0
- package/kits/rust/tests/pagination.rs +61 -0
- package/kits/rust/tests/sse.rs +77 -0
- package/kits/rust/tests/testing.rs +90 -0
- package/kits/rust/tests/transport.rs +218 -0
- package/kits/rust/tests/wait.rs +32 -0
- package/kits/rust/tests/webhooks.rs +73 -0
- package/kits/rust/versions.json +6 -0
- package/kits/typescript/kit.json +6 -0
- package/kits/typescript/src/client.ts +223 -0
- package/kits/typescript/src/context.ts +108 -0
- package/kits/typescript/src/errors.ts +63 -0
- package/kits/typescript/src/helpers.ts +49 -0
- package/kits/typescript/src/http.ts +192 -0
- package/kits/typescript/src/models.ts +139 -0
- package/kits/typescript/src/multipart.ts +66 -0
- package/kits/typescript/src/pagination.ts +54 -0
- package/kits/typescript/src/pipeline.ts +25 -0
- package/kits/typescript/src/sse.ts +102 -0
- package/kits/typescript/src/testing.ts +217 -0
- package/kits/typescript/src/transport.ts +101 -0
- package/kits/typescript/src/wait.ts +36 -0
- package/kits/typescript/src/webhooks.ts +168 -0
- package/kits/typescript/tests/client.test.ts +269 -0
- package/kits/typescript/tests/helpers.test.ts +27 -0
- package/kits/typescript/tests/http.test.ts +80 -0
- package/kits/typescript/tests/models.test.ts +71 -0
- package/kits/typescript/tests/multipart.test.ts +28 -0
- package/kits/typescript/tests/pagination.test.ts +76 -0
- package/kits/typescript/tests/sse.test.ts +82 -0
- package/kits/typescript/tests/testing.test.ts +103 -0
- package/kits/typescript/tests/transport.test.ts +127 -0
- package/kits/typescript/tests/wait.test.ts +31 -0
- package/kits/typescript/tests/webhooks.test.ts +53 -0
- package/kits/typescript/versions.json +15 -0
- package/package.json +37 -4
- package/packages/cli/recipes/apiKeyHeader.ts +16 -0
- package/packages/cli/recipes/apiVersionHeader.ts +16 -0
- package/packages/cli/recipes/basic.ts +13 -0
- package/packages/cli/recipes/bearer.ts +10 -0
- package/packages/cli/recipes/hmacSign.ts +23 -0
- package/packages/cli/recipes/idempotencyKey.ts +19 -0
- package/packages/cli/recipes/oauthClientCredentials.ts +50 -0
- package/packages/cli/recipes/retry.ts +42 -0
- package/packages/cli/recipes/timing.ts +12 -0
- package/packages/cli/recipes/userAgent.ts +8 -0
- package/packages/cli/src/build.js +93 -0
- package/packages/cli/src/commands/build.js +31 -0
- package/packages/cli/src/commands/conformance-check.js +50 -0
- package/packages/cli/src/commands/contract.js +181 -0
- package/packages/cli/src/commands/diff.js +113 -0
- package/packages/cli/src/commands/doctor.js +43 -0
- package/packages/cli/src/commands/import-openapi.js +42 -0
- package/packages/cli/src/commands/init.js +27 -0
- package/packages/cli/src/commands/kit-check.js +145 -0
- package/packages/cli/src/commands/publish.js +81 -0
- package/packages/cli/src/commands/recipe.js +49 -0
- package/packages/cli/src/commands/record.js +181 -0
- package/packages/cli/src/commands/serve.js +156 -0
- package/packages/cli/src/commands/spec-check.js +57 -0
- package/packages/cli/src/commands/test.js +177 -0
- package/packages/cli/src/commands/variants.js +32 -0
- package/packages/cli/src/commands/verify.js +57 -0
- package/packages/cli/src/commands/version.js +63 -0
- package/packages/cli/src/containers.js +82 -0
- package/packages/cli/src/coverage.js +72 -0
- package/packages/cli/src/git.js +25 -0
- package/packages/cli/src/io.js +50 -0
- package/packages/cli/src/java/ScenarioHarness.java +297 -0
- package/packages/cli/src/java/SchemaRoundTrip.java +63 -0
- package/packages/cli/src/java.js +70 -0
- package/packages/cli/src/js/harness.mjs +120 -0
- package/packages/cli/src/kits.js +103 -0
- package/packages/cli/src/languages/csharp.js +274 -0
- package/packages/cli/src/languages/go.js +185 -0
- package/packages/cli/src/languages/index.js +18 -0
- package/packages/cli/src/languages/java.js +187 -0
- package/packages/cli/src/languages/python.js +120 -0
- package/packages/cli/src/languages/rust.js +189 -0
- package/packages/cli/src/languages/types.js +93 -0
- package/packages/cli/src/languages/typescript.js +112 -0
- package/packages/cli/src/main.js +13 -0
- package/packages/cli/src/packaging.js +39 -0
- package/packages/cli/src/portability.js +45 -0
- package/packages/cli/src/profiles.js +55 -0
- package/packages/cli/src/project.js +56 -0
- package/packages/cli/src/python/scenario_harness.py +162 -0
- package/packages/cli/src/python/schema_roundtrip.py +42 -0
- package/packages/cli/src/registries.js +214 -0
- package/packages/cli/src/resolve-core.js +39 -0
- package/packages/cli/src/run.js +133 -0
- package/packages/cli/src/runtimes.js +61 -0
- package/packages/cli/src/scenarios-java.js +82 -0
- package/packages/cli/src/scenarios-javascript.js +54 -0
- package/packages/cli/src/scenarios-python.js +90 -0
- package/packages/cli/src/scenarios.js +183 -0
- package/packages/cli/src/schema.js +84 -0
- package/packages/cli/src/templates.js +85 -0
- package/packages/cli/src/toolchains.js +68 -0
- package/packages/cli/src/transpiled-tests.js +92 -0
- package/packages/codegen/src/canonical-json.js +31 -0
- package/packages/codegen/src/capabilities.js +50 -0
- package/packages/codegen/src/code-writer.js +54 -0
- package/packages/codegen/src/file-tree.js +25 -0
- package/packages/codegen/src/hash.js +6 -0
- package/packages/codegen/src/index.js +16 -0
- package/packages/codegen/src/lock.js +106 -0
- package/packages/conformance/src/case.js +143 -0
- package/packages/conformance/src/checks.js +40 -0
- package/packages/conformance/src/index.js +3 -0
- package/packages/conformance/src/matrix.js +48 -0
- package/packages/conformance/src/suite.js +48 -0
- package/packages/differ/src/diff.js +500 -0
- package/packages/differ/src/index.js +3 -0
- package/packages/differ/src/notes.js +112 -0
- package/packages/differ/src/support.js +34 -0
- package/packages/gen-csharp/src/emit-client.js +397 -0
- package/packages/gen-csharp/src/emit-harness.js +333 -0
- package/packages/gen-csharp/src/emit-mock.js +111 -0
- package/packages/gen-csharp/src/emit-models.js +119 -0
- package/packages/gen-csharp/src/emit-webhooks.js +57 -0
- package/packages/gen-csharp/src/generate.js +245 -0
- package/packages/gen-csharp/src/index.js +5 -0
- package/packages/gen-csharp/src/names.js +284 -0
- package/packages/gen-go/src/emit-client.js +405 -0
- package/packages/gen-go/src/emit-harness.js +294 -0
- package/packages/gen-go/src/emit-mock.js +112 -0
- package/packages/gen-go/src/emit-models.js +146 -0
- package/packages/gen-go/src/emit-webhooks.js +58 -0
- package/packages/gen-go/src/generate.js +205 -0
- package/packages/gen-go/src/index.js +5 -0
- package/packages/gen-go/src/names.js +197 -0
- package/packages/gen-java/src/emit-client.js +441 -0
- package/packages/gen-java/src/emit-models.js +342 -0
- package/packages/gen-java/src/emit-testing.js +123 -0
- package/packages/gen-java/src/emit-webhooks.js +70 -0
- package/packages/gen-java/src/generate.js +244 -0
- package/packages/gen-java/src/index.js +4 -0
- package/packages/gen-java/src/names.js +197 -0
- package/packages/gen-python/src/emit-client.js +272 -0
- package/packages/gen-python/src/emit-models.js +139 -0
- package/packages/gen-python/src/emit-testing.js +93 -0
- package/packages/gen-python/src/emit-webhooks.js +48 -0
- package/packages/gen-python/src/generate.js +237 -0
- package/packages/gen-python/src/index.js +2 -0
- package/packages/gen-python/src/names.js +161 -0
- package/packages/gen-python/src/style.js +67 -0
- package/packages/gen-rust/src/emit-client.js +379 -0
- package/packages/gen-rust/src/emit-harness.js +278 -0
- package/packages/gen-rust/src/emit-mock.js +121 -0
- package/packages/gen-rust/src/emit-models.js +117 -0
- package/packages/gen-rust/src/emit-webhooks.js +58 -0
- package/packages/gen-rust/src/generate.js +243 -0
- package/packages/gen-rust/src/index.js +5 -0
- package/packages/gen-rust/src/names.js +223 -0
- package/packages/gen-typescript/src/emit-client.js +434 -0
- package/packages/gen-typescript/src/emit-models.js +93 -0
- package/packages/gen-typescript/src/emit-package.js +90 -0
- package/packages/gen-typescript/src/emit-testing.js +138 -0
- package/packages/gen-typescript/src/emit-webhooks.js +52 -0
- package/packages/gen-typescript/src/generate.js +70 -0
- package/packages/gen-typescript/src/index.js +3 -0
- package/packages/gen-typescript/src/naming.js +64 -0
- package/packages/gen-typescript/src/runtime.js +81 -0
- package/packages/gen-typescript/src/types.js +136 -0
- package/packages/ir/src/api-surface.js +22 -0
- package/packages/ir/src/checks.js +52 -0
- package/packages/ir/src/index.js +32 -0
- package/packages/ir/src/ir.js +214 -0
- package/packages/ir/src/pages.js +18 -0
- package/packages/ir/src/validate-ir.js +462 -0
- package/packages/ir/src/validate-types.js +140 -0
- package/packages/kit/src/block-parser.js +196 -0
- package/packages/kit/src/index.js +15 -0
- package/packages/kit/src/kit-check.js +203 -0
- package/packages/kit/src/sources.js +53 -0
- package/packages/kit/src/version-policy.js +133 -0
- package/packages/kit/src/version-range.js +132 -0
- package/packages/openapi/src/import.js +292 -0
- package/packages/openapi/src/index.js +1 -0
- package/packages/openapi/src/names.js +50 -0
- package/packages/openapi/src/schemas.js +264 -0
- package/packages/packager/src/archive.js +106 -0
- package/packages/packager/src/crate.js +39 -0
- package/packages/packager/src/gomodule.js +11 -0
- package/packages/packager/src/index.js +9 -0
- package/packages/packager/src/maven.js +85 -0
- package/packages/packager/src/metadata.js +34 -0
- package/packages/packager/src/npm.js +71 -0
- package/packages/packager/src/nuget.js +78 -0
- package/packages/packager/src/sbom.js +56 -0
- package/packages/packager/src/wheel.js +62 -0
- package/packages/spec/src/index.js +11 -0
- package/packages/spec/src/requirements.js +139 -0
- package/packages/transpile/src/ast.js +51 -0
- package/packages/transpile/src/check.js +669 -0
- package/packages/transpile/src/emit-csharp.js +469 -0
- package/packages/transpile/src/emit-go.js +529 -0
- package/packages/transpile/src/emit-java.js +360 -0
- package/packages/transpile/src/emit-python.js +320 -0
- package/packages/transpile/src/emit-rust.js +499 -0
- package/packages/transpile/src/errors.js +15 -0
- package/packages/transpile/src/index.js +13 -0
- package/packages/transpile/src/lexer.js +161 -0
- package/packages/transpile/src/parser.js +543 -0
- package/packages/transpile/src/tests/ast.js +46 -0
- package/packages/transpile/src/tests/parse.js +376 -0
- package/packages/transpile/src/tests/translate.js +849 -0
- package/packages/transpile/src/transpile.js +57 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Builds every configured target in memory, writes them, and checks a previous build without writing anything.
|
|
2
|
+
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { canonicalJson, createFileTree, verifyLock, } from "@sdkloom/codegen";
|
|
6
|
+
import { extract } from "@sdkloom/core";
|
|
7
|
+
import { apiSurface, } from "@sdkloom/ir";
|
|
8
|
+
import { listFiles } from "./io.ts";
|
|
9
|
+
import { API_FILE, LOCK_FILE, } from "./kits.ts";
|
|
10
|
+
import { LANGUAGE_MODULES } from "./languages/index.ts";
|
|
11
|
+
import { ProjectError, } from "./project.ts";
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
API_FILE,
|
|
15
|
+
defaultModule,
|
|
16
|
+
JAVA_MIDDLEWARE_FILE,
|
|
17
|
+
KITS_DIR,
|
|
18
|
+
LOCK_FILE,
|
|
19
|
+
profilesOf,
|
|
20
|
+
PYTHON_MIDDLEWARE_FILE,
|
|
21
|
+
SDKLOOM_VERSION,
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
} from "./kits.ts";
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
export function buildInMemory(project ) {
|
|
36
|
+
const configured = LANGUAGE_MODULES.filter((module) => project.config.targets[module.language] !== undefined);
|
|
37
|
+
if (configured.length === 0) {
|
|
38
|
+
throw new ProjectError(`no target configured; add ${LANGUAGE_MODULES.map((module) => `targets.${module.language}`).join(", ")} to sdkloom.config.ts`);
|
|
39
|
+
}
|
|
40
|
+
const { ir, middlewareSources, logicSources } = extract(project.definition);
|
|
41
|
+
const targets = configured.flatMap((module) => module.build({ project, ir, middlewareSources, logicSources }));
|
|
42
|
+
return {
|
|
43
|
+
ir,
|
|
44
|
+
targets,
|
|
45
|
+
lock: canonicalJson({ targets: Object.fromEntries(targets.map((target) => [target.name, target.lockFile])) }),
|
|
46
|
+
api: canonicalJson(apiSurface(ir)),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function write(path , text ) {
|
|
51
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
52
|
+
writeFileSync(path, text);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Replaces every output directory and writes the lock and API surface next to the config. */
|
|
56
|
+
export function writeBuild(root , result ) {
|
|
57
|
+
for (const target of result.targets) {
|
|
58
|
+
const outDir = join(root, target.outDir);
|
|
59
|
+
rmSync(outDir, { recursive: true, force: true });
|
|
60
|
+
target.files.forEach((text, path) => write(join(outDir, path), text));
|
|
61
|
+
}
|
|
62
|
+
write(join(root, LOCK_FILE), result.lock);
|
|
63
|
+
write(join(root, API_FILE), result.api);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Bytecode caches appear whenever Python imports the package; they are not part of the build. */
|
|
67
|
+
const isCache = (path ) => path.split("/").includes("__pycache__");
|
|
68
|
+
|
|
69
|
+
function readTree(dir ) {
|
|
70
|
+
return createFileTree(
|
|
71
|
+
listFiles(dir)
|
|
72
|
+
.filter((path) => !isCache(path))
|
|
73
|
+
.map((path) => [path, readFileSync(join(dir, path), "utf8")]),
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Differences between a fresh in-memory build and what is on disk. Empty means up to date. */
|
|
78
|
+
export function checkBuild(root , result ) {
|
|
79
|
+
const issues = [];
|
|
80
|
+
const compare = (file , expected ) => {
|
|
81
|
+
const path = join(root, file);
|
|
82
|
+
if (!existsSync(path)) issues.push(`${file} is missing; run sdkloom build`);
|
|
83
|
+
else if (readFileSync(path, "utf8") !== expected) issues.push(`${file} is out of date; run sdkloom build`);
|
|
84
|
+
};
|
|
85
|
+
compare(LOCK_FILE, result.lock);
|
|
86
|
+
compare(API_FILE, result.api);
|
|
87
|
+
|
|
88
|
+
for (const target of result.targets) {
|
|
89
|
+
const outDir = join(root, target.outDir);
|
|
90
|
+
if (existsSync(outDir)) verifyLock(target.lockFile, readTree(outDir)).forEach((message) => issues.push(`${target.outDir}: ${message}`));
|
|
91
|
+
}
|
|
92
|
+
return issues;
|
|
93
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// sdkloom build [--check]
|
|
2
|
+
|
|
3
|
+
import { buildInMemory, checkBuild, writeBuild, } from "../build.ts";
|
|
4
|
+
import { plural, } from "../io.ts";
|
|
5
|
+
import { loadProject } from "../project.ts";
|
|
6
|
+
|
|
7
|
+
export function messageOf(error ) {
|
|
8
|
+
return error instanceof Error ? error.message : String(error);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function reportBuilt(result , io ) {
|
|
12
|
+
result.targets.forEach((target) => io.out(`built ${target.outDir} (${plural(target.files.size, "file")})`));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function buildCommand(io , check ) {
|
|
16
|
+
try {
|
|
17
|
+
const result = buildInMemory(await loadProject(io.cwd));
|
|
18
|
+
if (check) {
|
|
19
|
+
const issues = checkBuild(io.cwd, result);
|
|
20
|
+
issues.forEach((line) => io.out(line));
|
|
21
|
+
io.out(issues.length === 0 ? "build is up to date" : `build check failed: ${plural(issues.length, "issue")}`);
|
|
22
|
+
return issues.length === 0 ? 0 : 1;
|
|
23
|
+
}
|
|
24
|
+
writeBuild(io.cwd, result);
|
|
25
|
+
reportBuilt(result, io);
|
|
26
|
+
return 0;
|
|
27
|
+
} catch (error ) {
|
|
28
|
+
io.err(messageOf(error));
|
|
29
|
+
return 1;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// sdkloom conformance check — validates conformance/index.json, every case file and not-applicable.json.
|
|
2
|
+
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { validateCase, validateIndex, validateNotApplicable } from "@sdkloom/conformance";
|
|
6
|
+
import { listFiles, plural, readJson, summary, } from "../io.ts";
|
|
7
|
+
|
|
8
|
+
const DIR = "conformance";
|
|
9
|
+
const INDEX = `${DIR}/index.json`;
|
|
10
|
+
const NOT_APPLICABLE = `${DIR}/not-applicable.json`;
|
|
11
|
+
const CASES_DIR = `${DIR}/cases`;
|
|
12
|
+
|
|
13
|
+
function caseIssues(root , path ) {
|
|
14
|
+
const file = `${CASES_DIR}/${path}`;
|
|
15
|
+
const result = readJson(join(root, file), file);
|
|
16
|
+
if (!result.ok) return [result.message];
|
|
17
|
+
const expectedId = path.replace(/\.json$/, "");
|
|
18
|
+
const value = result.value;
|
|
19
|
+
const id = typeof value === "object" && value !== null ? (value )["id"] : undefined;
|
|
20
|
+
const mismatch = typeof id === "string" && id !== expectedId ? [`id: must match the file name ${expectedId}`] : [];
|
|
21
|
+
return [...validateCase(value), ...mismatch].map((message) => `${file} ${message}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function notApplicableIssues(root , caseIds ) {
|
|
25
|
+
if (!existsSync(join(root, NOT_APPLICABLE))) return [];
|
|
26
|
+
const result = readJson(join(root, NOT_APPLICABLE), NOT_APPLICABLE);
|
|
27
|
+
if (!result.ok) return [result.message];
|
|
28
|
+
return validateNotApplicable(result.value, caseIds).map((message) => `${NOT_APPLICABLE} ${message}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function conformanceCheck(io ) {
|
|
32
|
+
const root = io.cwd;
|
|
33
|
+
const index = readJson(join(root, INDEX), INDEX);
|
|
34
|
+
if (!index.ok) {
|
|
35
|
+
io.err(index.message);
|
|
36
|
+
return 1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const caseFiles = listFiles(join(root, CASES_DIR)).filter((path) => path.endsWith(".json"));
|
|
40
|
+
const caseIds = new Set(caseFiles.map((path) => path.replace(/\.json$/, "")));
|
|
41
|
+
|
|
42
|
+
const lines = [
|
|
43
|
+
...caseFiles.flatMap((path) => caseIssues(root, path)),
|
|
44
|
+
...validateIndex(index.value, caseIds).map((message) => `${INDEX} ${message}`),
|
|
45
|
+
...notApplicableIssues(root, caseIds),
|
|
46
|
+
].sort();
|
|
47
|
+
lines.forEach((line) => io.out(line));
|
|
48
|
+
io.out(summary(plural(caseFiles.length, "case"), lines.length));
|
|
49
|
+
return lines.length === 0 ? 0 : 1;
|
|
50
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// sdkloom contract — checks the definition against a real (staging) API: every read operation (GET) is called through
|
|
2
|
+
// the generated TypeScript SDK, whose decoders are strict, and the answer must decode. Fields the API sends that the
|
|
3
|
+
// definition lacks are listed too: they decode (SDKs ignore unknown fields) but the definition is behind.
|
|
4
|
+
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { pathToFileURL } from "node:url";
|
|
7
|
+
|
|
8
|
+
import { buildInMemory, writeBuild } from "../build.ts";
|
|
9
|
+
|
|
10
|
+
import { loadProject } from "../project.ts";
|
|
11
|
+
import { messageOf } from "./build.ts";
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
/** What one operation's check found. */
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
function jsonObject(text , flag ) {
|
|
33
|
+
if (text === undefined) return {};
|
|
34
|
+
let value ;
|
|
35
|
+
try {
|
|
36
|
+
value = JSON.parse(text);
|
|
37
|
+
} catch {
|
|
38
|
+
// The parser's message quotes the text, which may hold credentials.
|
|
39
|
+
throw new Error(`${flag} is not valid JSON`);
|
|
40
|
+
}
|
|
41
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${flag} must be a JSON object`);
|
|
42
|
+
return value ;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function isRecord(value ) {
|
|
46
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Paths of fields in `value` that the type does not declare, e.g. "$.items[].fee"; each path once. */
|
|
50
|
+
export function unknownFields(ir , type , value , path = "$", found = new Set()) {
|
|
51
|
+
const named = (name ) => ir.types.find((candidate) => candidate.name === name)?.type;
|
|
52
|
+
switch (type.kind) {
|
|
53
|
+
case "ref": {
|
|
54
|
+
const target = named(type.name);
|
|
55
|
+
if (target !== undefined) unknownFields(ir, target, value, path, found);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case "list":
|
|
59
|
+
if (Array.isArray(value)) value.forEach((item) => unknownFields(ir, type.item, item, `${path}[]`, found));
|
|
60
|
+
break;
|
|
61
|
+
case "map":
|
|
62
|
+
if (isRecord(value)) Object.values(value).forEach((item) => unknownFields(ir, type.value, item, `${path}{}`, found));
|
|
63
|
+
break;
|
|
64
|
+
case "object":
|
|
65
|
+
if (!isRecord(value)) break;
|
|
66
|
+
for (const [key, item] of Object.entries(value)) {
|
|
67
|
+
const field = type.fields.find((candidate) => candidate.name === key);
|
|
68
|
+
if (field === undefined) found.add(`${path}.${key}`);
|
|
69
|
+
else unknownFields(ir, field.type, item, `${path}.${key}`, found);
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
case "union": {
|
|
73
|
+
if (!isRecord(value)) break;
|
|
74
|
+
const variant = type.variants.find((candidate) => candidate.tag === value[type.discriminator]);
|
|
75
|
+
const target = variant === undefined ? undefined : named(variant.type);
|
|
76
|
+
if (target?.kind === "object") unknownFields(ir, target, Object.fromEntries(Object.entries(value).filter(([key]) => key !== type.discriminator)), path, found);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
default:
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
return [...found].sort();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Operations that only read: GET and not streamed. */
|
|
86
|
+
function readOperations(ir ) {
|
|
87
|
+
return ir.operations.filter((operation) => operation.method === "GET" && operation.events === undefined);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function missingArgs(operation , args ) {
|
|
91
|
+
return operation.params.filter((param) => !param.optional && args?.[param.name] === undefined).map((param) => param.name);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
async function checkOperation(check , operation , args ) {
|
|
101
|
+
const missing = missingArgs(operation, args);
|
|
102
|
+
if (missing.length > 0) return { operation: operation.name, status: "skipped", message: `needs --args for ${missing.join(", ")}` };
|
|
103
|
+
const before = check.last();
|
|
104
|
+
try {
|
|
105
|
+
await check.call(operation, operation.params.length > 0 ? (args ?? {}) : undefined);
|
|
106
|
+
} catch (error ) {
|
|
107
|
+
const name = error instanceof Error ? error.name : "Error";
|
|
108
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
109
|
+
return name === "DecodeError" ? { operation: operation.name, status: "differs", message } : { operation: operation.name, status: "failed", message: `${name}: ${message}` };
|
|
110
|
+
}
|
|
111
|
+
const exchange = check.last();
|
|
112
|
+
if (operation.returns === undefined || exchange === undefined || exchange === before) return { operation: operation.name, status: "ok", unknownFields: [] };
|
|
113
|
+
const text = new TextDecoder().decode(await exchange.response.bytes());
|
|
114
|
+
try {
|
|
115
|
+
return { operation: operation.name, status: "ok", unknownFields: text === "" ? [] : unknownFields(check.ir, operation.returns, JSON.parse(text)) };
|
|
116
|
+
} catch {
|
|
117
|
+
// Not JSON (bytes or text results): it decoded, and has no fields to compare.
|
|
118
|
+
return { operation: operation.name, status: "ok", unknownFields: [] };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function report(io , results ) {
|
|
123
|
+
for (const result of results) {
|
|
124
|
+
if (result.status === "ok") {
|
|
125
|
+
io.out(`✓ ${result.operation}${result.unknownFields.length === 0 ? "" : `: the API also sends ${result.unknownFields.join(", ")} (not in the definition)`}`);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const detail = result.status === "differs" ? `the answer does not match the definition: ${result.message}` : result.message;
|
|
129
|
+
io.out(`${result.status === "skipped" ? "-" : "✗"} ${result.operation}: ${detail}`);
|
|
130
|
+
}
|
|
131
|
+
const count = (status ) => results.filter((result) => result.status === status).length;
|
|
132
|
+
io.out(`contract: ${count("ok")} match, ${count("differs")} differ, ${count("failed")} failed, ${count("skipped")} skipped`);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export async function contractCommand(io , options ) {
|
|
136
|
+
try {
|
|
137
|
+
if (options.baseUrl === undefined) throw new Error("name the API to check: sdkloom contract --base-url https://staging.example.com/v1");
|
|
138
|
+
const project = await loadProject(io.cwd);
|
|
139
|
+
const result = buildInMemory(project);
|
|
140
|
+
const typescript = result.targets.find((target) => target.language === "typescript");
|
|
141
|
+
if (typescript === undefined) throw new Error("sdkloom contract calls the API through the TypeScript SDK; add targets.typescript");
|
|
142
|
+
const allArgs = jsonObject(options.args, "--args");
|
|
143
|
+
const config = jsonObject(options.config, "--config");
|
|
144
|
+
writeBuild(io.cwd, result);
|
|
145
|
+
|
|
146
|
+
const sdk = (await import(`${pathToFileURL(join(io.cwd, typescript.outDir, "src", "index.ts")).href}?contract=${Date.now()}`)) ;
|
|
147
|
+
const real = (sdk["fetchTransport"] )();
|
|
148
|
+
const exchanges = [];
|
|
149
|
+
const recording = async (request, sendOptions) => {
|
|
150
|
+
const response = await real(request, sendOptions);
|
|
151
|
+
exchanges.push({ response });
|
|
152
|
+
return response;
|
|
153
|
+
};
|
|
154
|
+
const Client = sdk[`${result.ir.name}Client`] ;
|
|
155
|
+
const client = new Client({ ...config, baseUrl: options.baseUrl, transport: recording });
|
|
156
|
+
const check = {
|
|
157
|
+
ir: result.ir,
|
|
158
|
+
call: async (operation, args) => {
|
|
159
|
+
const method = client[operation.name];
|
|
160
|
+
if (typeof method !== "function") throw new Error(`the TypeScript SDK has no method ${operation.name}`);
|
|
161
|
+
return method.call(client, args);
|
|
162
|
+
},
|
|
163
|
+
last: () => exchanges.at(-1),
|
|
164
|
+
};
|
|
165
|
+
const results = [];
|
|
166
|
+
for (const operation of readOperations(result.ir)) {
|
|
167
|
+
const args = allArgs[operation.name];
|
|
168
|
+
results.push(await checkOperation(check, operation, isRecord(args) ? args : undefined));
|
|
169
|
+
}
|
|
170
|
+
report(io, results);
|
|
171
|
+
// Nothing checked is not a pass: every operation was skipped, or there is none to read.
|
|
172
|
+
if (!results.some((entry) => entry.status === "ok")) {
|
|
173
|
+
io.err("no read operation was checked; pass --args for the operations that need them");
|
|
174
|
+
return 1;
|
|
175
|
+
}
|
|
176
|
+
return results.some((entry) => entry.status === "differs" || entry.status === "failed") ? 1 : 0;
|
|
177
|
+
} catch (error ) {
|
|
178
|
+
io.err(messageOf(error));
|
|
179
|
+
return 1;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// sdkloom diff [--against <ref>] — API changes since a release, classified per language, with the version they need.
|
|
2
|
+
|
|
3
|
+
import { bumpOf, diffApi, diffSupport, LANGUAGES, nextVersion, } from "@sdkloom/differ";
|
|
4
|
+
|
|
5
|
+
import { API_FILE, buildInMemory, LOCK_FILE } from "../build.ts";
|
|
6
|
+
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
import { gitHasRef, gitListFiles, gitShow } from "../git.ts";
|
|
9
|
+
|
|
10
|
+
import { loadProject, } from "../project.ts";
|
|
11
|
+
import { messageOf } from "./build.ts";
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
/** The release to compare with: the tag of the current version (v1.2.3) if it exists, else HEAD. */
|
|
24
|
+
export function baselineRef(root , version , against ) {
|
|
25
|
+
if (against !== undefined) return against;
|
|
26
|
+
return gitHasRef(root, `v${version}`) ? `v${version}` : "HEAD";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** language → supported range, from the profiles in a lock ("python@>=3.8"). */
|
|
30
|
+
function supportOf(lockText ) {
|
|
31
|
+
if (lockText === undefined) return {};
|
|
32
|
+
const lock = JSON.parse(lockText) ;
|
|
33
|
+
return Object.fromEntries(
|
|
34
|
+
Object.entries(lock.targets ?? {}).flatMap(([language, target]) => (target.profile === undefined ? [] : [[language, target.profile.slice(target.profile.indexOf("@") + 1)]])),
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function compare(root , against ) {
|
|
39
|
+
const project = await loadProject(root);
|
|
40
|
+
const build = buildInMemory(project);
|
|
41
|
+
const after = build.ir;
|
|
42
|
+
const ref = baselineRef(root, project.config.version, against);
|
|
43
|
+
const text = gitShow(root, ref, API_FILE);
|
|
44
|
+
if (text === undefined) throw new Error(`no ${API_FILE} at ${ref}; build and commit it first, or pass --against <ref>`);
|
|
45
|
+
const before = JSON.parse(text) ;
|
|
46
|
+
const support = diffSupport(supportOf(gitShow(root, ref, LOCK_FILE)), supportOf(build.lock));
|
|
47
|
+
const languages = LANGUAGES.filter((language) => project.config.targets[language] !== undefined);
|
|
48
|
+
return { project, ref, before, after, changes: [...diffApi(before, after), ...support], languages };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function bumps(change , languages ) {
|
|
52
|
+
const values = [...new Set(languages.map((language) => change.bump[language]))];
|
|
53
|
+
if (values.length === 1) return values[0] ?? "patch";
|
|
54
|
+
return languages.map((language) => `${language} ${change.bump[language]}`).join(", ");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function reportChanges(comparison , io ) {
|
|
58
|
+
const { changes, ref, project, languages } = comparison;
|
|
59
|
+
if (changes.length === 0) {
|
|
60
|
+
io.out(`no API changes since ${ref}`);
|
|
61
|
+
} else {
|
|
62
|
+
io.out(`API changes since ${ref}:`);
|
|
63
|
+
changes.forEach((change) => io.out(` ${change.rule.padEnd(24)} ${change.path}: ${change.message} [${bumps(change, languages)}]`));
|
|
64
|
+
}
|
|
65
|
+
const bump = bumpOf(changes, languages);
|
|
66
|
+
const perLanguage = languages.map((language) => `${language} ${bumpOf(changes, language)}`).join(", ");
|
|
67
|
+
io.out(`needs a ${bump} release (${perLanguage}): ${project.config.version} → ${nextVersion(project.config.version, bump)}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Copies a directory as it was at a ref to the project root, so tests importing ../generated/… still resolve. */
|
|
71
|
+
function checkoutDir(root , ref , dir , target ) {
|
|
72
|
+
const files = gitListFiles(root, ref, dir);
|
|
73
|
+
for (const file of files) {
|
|
74
|
+
const text = gitShow(root, ref, `${dir}/${file}`);
|
|
75
|
+
if (text === undefined) continue;
|
|
76
|
+
mkdirSync(dirname(join(root, target, file)), { recursive: true });
|
|
77
|
+
writeFileSync(join(root, target, file), text);
|
|
78
|
+
}
|
|
79
|
+
return files.length;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const OLD_TESTS = ".sdkloom-previous-tests";
|
|
83
|
+
const OLD_SCENARIOS = ".sdkloom-previous-scenarios";
|
|
84
|
+
|
|
85
|
+
/** Runs the scenarios and tests of the earlier release against the SDK built now: a failure is a behavioural break. */
|
|
86
|
+
async function behavior(comparison , io ) {
|
|
87
|
+
const root = io.cwd;
|
|
88
|
+
const { project, ref } = comparison;
|
|
89
|
+
try {
|
|
90
|
+
const tests = checkoutDir(root, ref, project.config.tests ?? "tests", OLD_TESTS);
|
|
91
|
+
const scenarios = checkoutDir(root, ref, project.config.scenarios ?? "scenarios", OLD_SCENARIOS);
|
|
92
|
+
io.out(`running ${scenarios} scenario file${scenarios === 1 ? "" : "s"} and ${tests} test file${tests === 1 ? "" : "s"} from ${ref} against the SDK built now`);
|
|
93
|
+
const { runSuite } = await import("./test.ts");
|
|
94
|
+
const passed = await runSuite(io, { scenariosDir: OLD_SCENARIOS, testsDir: OLD_TESTS, full: false });
|
|
95
|
+
io.out(passed ? `the SDK still passes the scenarios and tests of ${ref}` : `behavioural break: the SDK fails scenarios or tests of ${ref}; that needs a major release`);
|
|
96
|
+
return passed;
|
|
97
|
+
} finally {
|
|
98
|
+
rmSync(join(root, OLD_TESTS), { recursive: true, force: true });
|
|
99
|
+
rmSync(join(root, OLD_SCENARIOS), { recursive: true, force: true });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export async function diffCommand(io , against , checkBehavior = false) {
|
|
104
|
+
try {
|
|
105
|
+
const comparison = await compare(io.cwd, against);
|
|
106
|
+
reportChanges(comparison, io);
|
|
107
|
+
if (checkBehavior && !(await behavior(comparison, io))) return 1;
|
|
108
|
+
return 0;
|
|
109
|
+
} catch (error ) {
|
|
110
|
+
io.err(messageOf(error));
|
|
111
|
+
return 1;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// sdkloom doctor — what each configured package supports, which runtimes are here to test it, and what is known about
|
|
2
|
+
// those versions (end of life, TLS). It informs and never fails: old versions stay supported as long as the author wants.
|
|
3
|
+
|
|
4
|
+
import { buildInMemory, profilesOf, } from "../build.ts";
|
|
5
|
+
|
|
6
|
+
import { portabilityReport } from "../portability.ts";
|
|
7
|
+
import { loadProject } from "../project.ts";
|
|
8
|
+
import { runtimesFor } from "../runtimes.ts";
|
|
9
|
+
import { messageOf } from "./build.ts";
|
|
10
|
+
|
|
11
|
+
function runtimeLine(target , projectRoot ) {
|
|
12
|
+
return runtimesFor(target.language, target.name, target.profile, { container: { projectRoot, pull: false } }).map((runtime) => {
|
|
13
|
+
if (runtime.image !== undefined) return ` ${runtime.label}: not installed; sdkloom test --container runs it in ${runtime.image}`;
|
|
14
|
+
if (runtime.command === undefined) return ` ${runtime.label}: not installed; ${runtime.hint}`;
|
|
15
|
+
return ` ${runtime.label}: ${runtime.command.join(" ")}`;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function notes(target ) {
|
|
20
|
+
const known = profilesOf(target.language).notes;
|
|
21
|
+
return target.profile.test.flatMap((version) => {
|
|
22
|
+
const note = known.get(version);
|
|
23
|
+
return note === undefined ? [] : [` ℹ ${target.language}@${version}: ${note.text} (${note.source})`];
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function doctorCommand(io ) {
|
|
28
|
+
try {
|
|
29
|
+
const project = await loadProject(io.cwd);
|
|
30
|
+
const result = buildInMemory(project);
|
|
31
|
+
for (const target of result.targets) {
|
|
32
|
+
io.out(`${target.name}: ${target.packageName}, ${target.language} ${target.profile.range}`);
|
|
33
|
+
runtimeLine(target, io.cwd).forEach((line) => io.out(line));
|
|
34
|
+
notes(target).forEach((line) => io.out(line));
|
|
35
|
+
if (target.language === "typescript") portabilityReport(target.files).forEach((line) => io.out(` ${line}`));
|
|
36
|
+
}
|
|
37
|
+
io.out("doctor only informs; nothing here fails a build or a test");
|
|
38
|
+
return 0;
|
|
39
|
+
} catch (error ) {
|
|
40
|
+
io.err(messageOf(error));
|
|
41
|
+
return 1;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// sdkloom import openapi <file.json> [--out sdk/index.ts]: an OpenAPI 3.0/3.1 document as an sdkloom definition.
|
|
2
|
+
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
5
|
+
import { importOpenApi, OpenApiError } from "@sdkloom/openapi";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const DEFAULT_OUT = join("sdk", "index.ts");
|
|
9
|
+
|
|
10
|
+
export function importOpenApiCommand(file , out , io ) {
|
|
11
|
+
if (file === undefined) {
|
|
12
|
+
io.err("usage: sdkloom import openapi <file.json> [--out sdk/index.ts]");
|
|
13
|
+
return 2;
|
|
14
|
+
}
|
|
15
|
+
const target = resolve(io.cwd, out ?? DEFAULT_OUT);
|
|
16
|
+
if (existsSync(target)) {
|
|
17
|
+
io.err(`${out ?? DEFAULT_OUT} already exists; not overwriting it (pass --out to write elsewhere)`);
|
|
18
|
+
return 1;
|
|
19
|
+
}
|
|
20
|
+
let document ;
|
|
21
|
+
try {
|
|
22
|
+
document = JSON.parse(readFileSync(resolve(io.cwd, file), "utf8"));
|
|
23
|
+
} catch (error ) {
|
|
24
|
+
io.err(`could not read ${file} as JSON: ${error instanceof Error ? error.message : String(error)}${/\.ya?ml$/i.test(file) ? " (YAML is not supported yet; convert it to JSON)" : ""}`);
|
|
25
|
+
return 1;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const { source, warnings } = importOpenApi(document);
|
|
29
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
30
|
+
writeFileSync(target, source, { flag: "wx" });
|
|
31
|
+
io.out(`wrote ${out ?? DEFAULT_OUT}`);
|
|
32
|
+
warnings.forEach((warning) => io.out(` warning: ${warning}`));
|
|
33
|
+
io.out("Next: review the definition, then sdkloom build.");
|
|
34
|
+
return 0;
|
|
35
|
+
} catch (error ) {
|
|
36
|
+
if (error instanceof OpenApiError) {
|
|
37
|
+
io.err(error.message);
|
|
38
|
+
return 1;
|
|
39
|
+
}
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// sdkloom init — creates a small working SDK project in the current directory.
|
|
2
|
+
|
|
3
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
|
|
6
|
+
import { CONFIG_FILE } from "../project.ts";
|
|
7
|
+
import { TEMPLATE_FILES } from "../templates.ts";
|
|
8
|
+
|
|
9
|
+
export function initCommand(io ) {
|
|
10
|
+
if (existsSync(join(io.cwd, CONFIG_FILE))) {
|
|
11
|
+
io.err(`${io.cwd} already contains ${CONFIG_FILE}`);
|
|
12
|
+
return 1;
|
|
13
|
+
}
|
|
14
|
+
const existing = TEMPLATE_FILES.find(([path]) => existsSync(join(io.cwd, path)));
|
|
15
|
+
if (existing !== undefined) {
|
|
16
|
+
io.err(`${existing[0]} already exists; not overwriting it`);
|
|
17
|
+
return 1;
|
|
18
|
+
}
|
|
19
|
+
for (const [path, text] of TEMPLATE_FILES) {
|
|
20
|
+
mkdirSync(dirname(join(io.cwd, path)), { recursive: true });
|
|
21
|
+
writeFileSync(join(io.cwd, path), text);
|
|
22
|
+
}
|
|
23
|
+
io.out("created a petstore SDK project:");
|
|
24
|
+
TEMPLATE_FILES.forEach(([path]) => io.out(` ${path}`));
|
|
25
|
+
io.out("next: sdkloom build, then sdkloom test");
|
|
26
|
+
return 0;
|
|
27
|
+
}
|