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,196 @@
|
|
|
1
|
+
// Parses sdkloom kit blocks out of a source file. Block format: docs/07-language-kits.md.
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
const SINGLE_TAGS = {
|
|
50
|
+
summary: "summary",
|
|
51
|
+
versions: "versions",
|
|
52
|
+
strategy: "strategy",
|
|
53
|
+
retrieved: "retrieved",
|
|
54
|
+
security: "security",
|
|
55
|
+
"since-kit": "sinceKit",
|
|
56
|
+
deprecated: "deprecated",
|
|
57
|
+
} ;
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
// The URL itself is validated by kit-check (KIT012); the parser only splits index and value.
|
|
63
|
+
const SOURCE_VALUE = /^\[(\d+)\]\s+(.+)$/;
|
|
64
|
+
const QUOTE_VALUE = /^\[(\d+)\]\s+"(.*)"$/;
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
function escapeForRegExp(text ) {
|
|
84
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function isSingleTag(tag ) {
|
|
88
|
+
return Object.hasOwn(SINGLE_TAGS, tag);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function newDraft(id , line ) {
|
|
92
|
+
return { id, line, singles: new Map(), sources: [], quotes: [], tests: [], requirements: [], code: [], inCode: false };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function toBlock(draft , file ) {
|
|
96
|
+
const singles = Object.fromEntries(draft.singles) ;
|
|
97
|
+
return {
|
|
98
|
+
id: draft.id,
|
|
99
|
+
file,
|
|
100
|
+
line: draft.line,
|
|
101
|
+
...singles,
|
|
102
|
+
sources: [...draft.sources],
|
|
103
|
+
quotes: [...draft.quotes],
|
|
104
|
+
tests: [...draft.tests],
|
|
105
|
+
requirements: [...draft.requirements],
|
|
106
|
+
code: draft.code.join("\n"),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Applies one metadata tag to the draft; returns an error message or null. */
|
|
111
|
+
function applyTag(draft , { tag, value } ) {
|
|
112
|
+
if (value === "") return `@${tag} needs a value`;
|
|
113
|
+
|
|
114
|
+
if (isSingleTag(tag)) {
|
|
115
|
+
const field = SINGLE_TAGS[tag];
|
|
116
|
+
if (draft.singles.has(field)) return `@${tag} appears more than once in block ${draft.id}`;
|
|
117
|
+
draft.singles.set(field, value);
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
switch (tag) {
|
|
122
|
+
case "source": {
|
|
123
|
+
const match = SOURCE_VALUE.exec(value);
|
|
124
|
+
if (!match) return `@source must look like: [n] https://…`;
|
|
125
|
+
draft.sources.push({ index: Number(match[1]), url: match[2] ?? "" });
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
case "quote": {
|
|
129
|
+
const match = QUOTE_VALUE.exec(value);
|
|
130
|
+
if (!match) return `@quote must look like: [n] "verbatim text"`;
|
|
131
|
+
draft.quotes.push({ index: Number(match[1]), text: match[2] ?? "" });
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
case "tests":
|
|
135
|
+
draft.tests.push(value);
|
|
136
|
+
return null;
|
|
137
|
+
case "requirement":
|
|
138
|
+
draft.requirements.push(value);
|
|
139
|
+
return null;
|
|
140
|
+
default:
|
|
141
|
+
return `unknown tag @${tag}`;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function parseBlocks(text , options ) {
|
|
146
|
+
const tagPattern = new RegExp(`^\\s*${escapeForRegExp(options.commentPrefix)}\\s*@([a-z][a-z-]*)(?:\\s+(.*))?$`);
|
|
147
|
+
const readTag = (line ) => {
|
|
148
|
+
const match = tagPattern.exec(line);
|
|
149
|
+
return match ? { tag: match[1] ?? "", value: (match[2] ?? "").trim() } : null;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const blocks = [];
|
|
153
|
+
const errors = [];
|
|
154
|
+
const fail = (line , message ) => {
|
|
155
|
+
errors.push({ file: options.file, line, message });
|
|
156
|
+
};
|
|
157
|
+
let draft = null;
|
|
158
|
+
|
|
159
|
+
text.split("\n").forEach((rawLine, index) => {
|
|
160
|
+
const lineNumber = index + 1;
|
|
161
|
+
const tagLine = readTag(rawLine);
|
|
162
|
+
|
|
163
|
+
if (draft === null) {
|
|
164
|
+
if (tagLine?.tag === "block") {
|
|
165
|
+
if (tagLine.value === "") fail(lineNumber, "@block needs a value");
|
|
166
|
+
else draft = newDraft(tagLine.value, lineNumber);
|
|
167
|
+
} else if (tagLine?.tag === "end") {
|
|
168
|
+
fail(lineNumber, "@end without an open block");
|
|
169
|
+
}
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (tagLine?.tag === "block") {
|
|
174
|
+
fail(lineNumber, `nested @block inside block ${draft.id}`);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (tagLine?.tag === "end") {
|
|
178
|
+
if (draft.code.length === 0) fail(draft.line, `block ${draft.id} has no code`);
|
|
179
|
+
else blocks.push(toBlock(draft, options.file));
|
|
180
|
+
draft = null;
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (!draft.inCode && tagLine !== null) {
|
|
184
|
+
const message = applyTag(draft, tagLine);
|
|
185
|
+
if (message !== null) fail(lineNumber, message);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
draft.inCode = true;
|
|
189
|
+
draft.code.push(rawLine);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const unclosed = draft ;
|
|
193
|
+
if (unclosed !== null) fail(unclosed.line, `block ${unclosed.id} is not closed with @end`);
|
|
194
|
+
|
|
195
|
+
return { blocks, errors };
|
|
196
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { parseBlocks, } from "./block-parser.ts";
|
|
2
|
+
export { checkVersionPolicy, } from "./version-policy.ts";
|
|
3
|
+
export { checkKit, } from "./kit-check.ts";
|
|
4
|
+
export {
|
|
5
|
+
compareVersions,
|
|
6
|
+
findGaps,
|
|
7
|
+
formatInterval,
|
|
8
|
+
formatVersion,
|
|
9
|
+
parseRange,
|
|
10
|
+
parseVersion,
|
|
11
|
+
rangesOverlap,
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
} from "./version-range.ts";
|
|
15
|
+
export { pageText, verifySources, } from "./sources.ts";
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// Validates parsed kit blocks against the rules in docs/07-language-kits.md.
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { findGaps, formatInterval, parseRange, rangesOverlap, } from "./version-range.ts";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// invalid supported range in the manifest
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
const DEFAULT_MANIFEST_FILE = "kit.json";
|
|
48
|
+
const ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
function isRealDate(text ) {
|
|
53
|
+
const match = ISO_DATE.exec(text);
|
|
54
|
+
if (!match) return false;
|
|
55
|
+
const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
56
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
57
|
+
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function isAllowedSource(url , allowed ) {
|
|
61
|
+
return allowed.some((entry) => {
|
|
62
|
+
const slash = entry.indexOf("/");
|
|
63
|
+
const host = slash === -1 ? entry : entry.slice(0, slash);
|
|
64
|
+
const pathPrefix = slash === -1 ? "" : entry.slice(slash);
|
|
65
|
+
const hostMatches = url.hostname === host || url.hostname.endsWith(`.${host}`);
|
|
66
|
+
const pathMatches = pathPrefix === "" || url.pathname === pathPrefix || url.pathname.startsWith(`${pathPrefix}/`);
|
|
67
|
+
return hostMatches && pathMatches;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function checkRequiredFields(block , report ) {
|
|
72
|
+
const missing = [
|
|
73
|
+
...(block.summary === undefined ? ["@summary"] : []),
|
|
74
|
+
...(block.versions === undefined ? ["@versions"] : []),
|
|
75
|
+
...(block.sources.length === 0 ? ["@source"] : []),
|
|
76
|
+
...(block.retrieved === undefined ? ["@retrieved"] : []),
|
|
77
|
+
...(block.tests.length === 0 ? ["@tests"] : []),
|
|
78
|
+
...(block.requirements.length === 0 ? ["@requirement"] : []),
|
|
79
|
+
];
|
|
80
|
+
missing.forEach((field) => report("KIT001", `missing ${field}`));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function checkSources(block , options , report ) {
|
|
84
|
+
const seen = new Set ();
|
|
85
|
+
for (const source of block.sources) {
|
|
86
|
+
if (seen.has(source.index)) report("KIT011", `source [${source.index}] is defined more than once`);
|
|
87
|
+
seen.add(source.index);
|
|
88
|
+
|
|
89
|
+
if (!URL.canParse(source.url) || new URL(source.url).protocol !== "https:") {
|
|
90
|
+
report("KIT012", `source [${source.index}] must be an https URL: ${source.url}`);
|
|
91
|
+
} else if (!isAllowedSource(new URL(source.url), options.allowedSources)) {
|
|
92
|
+
report("KIT003", `source [${source.index}] is not an allowed primary source: ${source.url}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const quoted = new Set(block.quotes.map((quote) => quote.index));
|
|
97
|
+
[...seen].filter((index) => !quoted.has(index)).forEach((index) => report("KIT004", `source [${index}] has no @quote`));
|
|
98
|
+
block.quotes
|
|
99
|
+
.filter((quote) => !seen.has(quote.index))
|
|
100
|
+
.forEach((quote) => report("KIT005", `quote [${quote.index}] points to no @source`));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function checkBlock(block , options , report ) {
|
|
104
|
+
checkRequiredFields(block, report);
|
|
105
|
+
checkSources(block, options, report);
|
|
106
|
+
|
|
107
|
+
if (block.retrieved !== undefined && !isRealDate(block.retrieved)) {
|
|
108
|
+
report("KIT006", `@retrieved must be a real date in YYYY-MM-DD form: ${block.retrieved}`);
|
|
109
|
+
}
|
|
110
|
+
block.tests
|
|
111
|
+
.filter((ref) => !options.testExists(ref))
|
|
112
|
+
.forEach((ref) => report("KIT007", `test not found: ${ref}`));
|
|
113
|
+
|
|
114
|
+
if (block.versions === undefined) return null;
|
|
115
|
+
try {
|
|
116
|
+
return parseRange(block.versions);
|
|
117
|
+
} catch (error ) {
|
|
118
|
+
report("KIT002", `invalid @versions "${block.versions}": ${error instanceof Error ? error.message : String(error)}`);
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
function groupById(entries ) {
|
|
129
|
+
const groups = new Map ();
|
|
130
|
+
for (const entry of entries) {
|
|
131
|
+
groups.set(entry.block.id, [...(groups.get(entry.block.id) ?? []), entry]);
|
|
132
|
+
}
|
|
133
|
+
return groups;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function checkCoverage(id , group , supported , push ) {
|
|
137
|
+
const ranged = group.filter((entry) => entry.range !== null);
|
|
138
|
+
|
|
139
|
+
ranged.forEach((later, laterIndex) => {
|
|
140
|
+
ranged.slice(0, laterIndex).forEach((earlier) => {
|
|
141
|
+
if (rangesOverlap(earlier.range, later.range)) {
|
|
142
|
+
push({
|
|
143
|
+
code: "KIT008",
|
|
144
|
+
file: later.block.file,
|
|
145
|
+
line: later.block.line,
|
|
146
|
+
message: `${id}: ${earlier.block.versions ?? ""} overlaps ${later.block.versions ?? ""}`,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const first = group[0];
|
|
153
|
+
if (first === undefined) return;
|
|
154
|
+
findGaps(
|
|
155
|
+
ranged.map((entry) => entry.range),
|
|
156
|
+
supported,
|
|
157
|
+
).forEach((gap) => {
|
|
158
|
+
push({ code: "KIT009", file: first.block.file, line: first.block.line, message: `${id}: no block covers ${formatInterval(gap)}` });
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function byLocation(a , b ) {
|
|
163
|
+
if (a.file !== b.file) return a.file < b.file ? -1 : 1;
|
|
164
|
+
if (a.line !== b.line) return a.line - b.line;
|
|
165
|
+
if (a.code !== b.code) return a.code < b.code ? -1 : 1;
|
|
166
|
+
return 0;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Validates a kit's blocks. Issues come back sorted by file, line and code. */
|
|
170
|
+
export function checkKit(manifest , blocks , options ) {
|
|
171
|
+
const manifestFile = options.manifestFile ?? DEFAULT_MANIFEST_FILE;
|
|
172
|
+
const issues = [];
|
|
173
|
+
const push = (issue ) => {
|
|
174
|
+
issues.push(issue);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const ranged = blocks.map((block) => ({
|
|
178
|
+
block,
|
|
179
|
+
range: checkBlock(block, options, (code, message) =>
|
|
180
|
+
push({ code, file: block.file, line: block.line, message: `${block.id}: ${message}` }),
|
|
181
|
+
),
|
|
182
|
+
}));
|
|
183
|
+
|
|
184
|
+
let supported = null;
|
|
185
|
+
try {
|
|
186
|
+
supported = parseRange(manifest.supports);
|
|
187
|
+
} catch (error ) {
|
|
188
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
189
|
+
push({ code: "KIT013", file: manifestFile, line: 1, message: `invalid "supports" range "${manifest.supports}": ${reason}` });
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const groups = groupById(ranged);
|
|
193
|
+
if (supported !== null) {
|
|
194
|
+
const range = supported;
|
|
195
|
+
groups.forEach((group, id) => checkCoverage(id, group, range, push));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
(options.requiredIds ?? [])
|
|
199
|
+
.filter((id) => !groups.has(id))
|
|
200
|
+
.forEach((id) => push({ code: "KIT010", file: manifestFile, line: 1, message: `required block ${id} is missing` }));
|
|
201
|
+
|
|
202
|
+
return [...issues].sort(byLocation);
|
|
203
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Checks that every @quote still appears, word for word, on its @source page. Pages change; this keeps the citations in
|
|
2
|
+
// kits honest. It reaches the network, so it is a command you run by hand, not part of the deterministic build.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const ENTITIES = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: " " };
|
|
17
|
+
|
|
18
|
+
/** The readable text of an HTML (or plain text) page, with whitespace collapsed the way quotes are written. */
|
|
19
|
+
export function pageText(html ) {
|
|
20
|
+
return html
|
|
21
|
+
.replace(/<(script|style)\b[\s\S]*?<\/\1>/gi, " ")
|
|
22
|
+
.replace(/<[^>]+>/g, "")
|
|
23
|
+
.replace(/&#x([0-9a-f]+);/gi, (_, hex ) => String.fromCodePoint(Number.parseInt(hex, 16)))
|
|
24
|
+
.replace(/&#(\d+);/g, (_, code ) => String.fromCodePoint(Number(code)))
|
|
25
|
+
.replace(/&([a-z]+);/gi, (entity, name ) => ENTITIES[name.toLowerCase()] ?? entity)
|
|
26
|
+
.replace(/[\s ]+/g, " ")
|
|
27
|
+
.trim();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const normalize = (text ) => text.replace(/[\s ]+/g, " ").trim();
|
|
31
|
+
|
|
32
|
+
/** Looks every quote up on its source page (fragment removed); each page is fetched once. */
|
|
33
|
+
export async function verifySources(blocks , fetcher ) {
|
|
34
|
+
const pages = new Map ();
|
|
35
|
+
const results = [];
|
|
36
|
+
for (const block of blocks) {
|
|
37
|
+
for (const source of block.sources) {
|
|
38
|
+
const page = source.url.split("#")[0] ?? source.url;
|
|
39
|
+
if (!pages.has(page)) pages.set(page, fetcher(page).then(pageText));
|
|
40
|
+
let text ;
|
|
41
|
+
try {
|
|
42
|
+
text = await (pages.get(page) ?? Promise.resolve(""));
|
|
43
|
+
} catch (error ) {
|
|
44
|
+
results.push({ block: block.id, index: source.index, url: source.url, status: "unreachable", detail: error instanceof Error ? error.message : String(error) });
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
for (const quote of block.quotes.filter((candidate) => candidate.index === source.index)) {
|
|
48
|
+
results.push({ block: block.id, index: source.index, url: source.url, status: text.includes(normalize(quote.text)) ? "found" : "missing" });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return results;
|
|
53
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Validates a kit's versions.json (docs/06-language-versions.md §8).
|
|
2
|
+
|
|
3
|
+
import { compareVersions, parseRange, parseVersion, rangesOverlap, } from "./version-range.ts";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/** What `sdkloom doctor` says about one version, e.g. its end of life; informational, it never blocks. */
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const EOL_LEVELS = new Set(["info"]);
|
|
28
|
+
|
|
29
|
+
function isRecord(value ) {
|
|
30
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function messageOf(error ) {
|
|
34
|
+
return error instanceof Error ? error.message : String(error);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function contains(interval , version ) {
|
|
38
|
+
const parsed = parseVersion(version);
|
|
39
|
+
const aboveMin = interval.min === null || compareVersions(parsed, interval.min) >= 0;
|
|
40
|
+
const belowMax = interval.max === null || compareVersions(parsed, interval.max) < 0;
|
|
41
|
+
return aboveMin && belowMax;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function checkLine(value , path , issues ) {
|
|
45
|
+
if (!isRecord(value) || typeof value["range"] !== "string" || !Array.isArray(value["test"])) {
|
|
46
|
+
issues.push(`${path}: must be an object with range and test`);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const range = value["range"];
|
|
50
|
+
const tests = value["test"];
|
|
51
|
+
const strategies = value["strategies"];
|
|
52
|
+
if (strategies !== undefined && (!isRecord(strategies) || !Object.values(strategies).every((item) => typeof item === "string"))) {
|
|
53
|
+
issues.push(`${path}.strategies: must map names to strings`);
|
|
54
|
+
}
|
|
55
|
+
const exclude = value["exclude"];
|
|
56
|
+
if (exclude !== undefined && (!Array.isArray(exclude) || !exclude.every((item) => typeof item === "string"))) {
|
|
57
|
+
issues.push(`${path}.exclude: must list file paths`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let interval ;
|
|
61
|
+
try {
|
|
62
|
+
interval = parseRange(range);
|
|
63
|
+
} catch (error ) {
|
|
64
|
+
issues.push(`${path}.range: ${messageOf(error)}`);
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (tests.length === 0 || !tests.every((version) => typeof version === "string")) {
|
|
69
|
+
issues.push(`${path}.test: must list at least one version`);
|
|
70
|
+
return interval;
|
|
71
|
+
}
|
|
72
|
+
for (const version of tests) {
|
|
73
|
+
try {
|
|
74
|
+
if (!contains(interval, version)) issues.push(`${path}.test: ${version} is outside ${range}`);
|
|
75
|
+
} catch (error ) {
|
|
76
|
+
issues.push(`${path}.test: ${messageOf(error)}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return interval;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function checkVariants(value , defaultRange , issues ) {
|
|
83
|
+
if (value === undefined) return;
|
|
84
|
+
if (!isRecord(value)) {
|
|
85
|
+
issues.push("variants: must be an object");
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const seen = [];
|
|
89
|
+
for (const [name, line] of Object.entries(value)) {
|
|
90
|
+
const path = `variants.${name}`;
|
|
91
|
+
const interval = checkLine(line, path, issues);
|
|
92
|
+
if (interval === null) continue;
|
|
93
|
+
if (defaultRange !== null && rangesOverlap(interval, defaultRange)) issues.push(`${path}: overlaps default`);
|
|
94
|
+
seen
|
|
95
|
+
.filter((other) => rangesOverlap(interval, other.interval))
|
|
96
|
+
.forEach((other) => issues.push(`${path}: overlaps variants.${other.name}`));
|
|
97
|
+
seen.push({ name, interval });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function checkEol(value , issues ) {
|
|
102
|
+
if (value === undefined) return;
|
|
103
|
+
if (!isRecord(value)) {
|
|
104
|
+
issues.push("eol: must be an object");
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
Object.entries(value)
|
|
108
|
+
.filter(([, level]) => typeof level !== "string" || !EOL_LEVELS.has(level))
|
|
109
|
+
.forEach(([version]) => issues.push(`eol.${version}: must be "info"`));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function checkNotes(value , issues ) {
|
|
113
|
+
if (value === undefined) return;
|
|
114
|
+
if (!isRecord(value)) {
|
|
115
|
+
issues.push("notes: must be an object");
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
for (const [version, note] of Object.entries(value)) {
|
|
119
|
+
const valid = isRecord(note) && typeof note["text"] === "string" && note["text"] !== "" && typeof note["source"] === "string" && note["source"].startsWith("https://");
|
|
120
|
+
if (!valid) issues.push(`notes.${version}: must have text and an https source`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Returns one message per problem; an empty list means the policy is valid. */
|
|
125
|
+
export function checkVersionPolicy(value ) {
|
|
126
|
+
if (!isRecord(value)) return ["policy must be an object"];
|
|
127
|
+
const issues = [];
|
|
128
|
+
const defaultRange = checkLine(value["default"], "default", issues);
|
|
129
|
+
checkVariants(value["variants"], defaultRange, issues);
|
|
130
|
+
checkEol(value["eol"], issues);
|
|
131
|
+
checkNotes(value["notes"], issues);
|
|
132
|
+
return issues;
|
|
133
|
+
}
|