@voxgig/sdkgen 4.50.0 → 4.52.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/bin/voxgig-sdkgen +1 -1
- package/dist/cmp/ReadmeExplanation.js +5 -2
- package/dist/cmp/ReadmeExplanation.js.map +1 -1
- package/dist/cmp/ReadmeFeatures.js +20 -6
- package/dist/cmp/ReadmeFeatures.js.map +1 -1
- package/dist/helpers/optspec.js +2 -2
- package/dist/helpers/optspec.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/model/sdkgen.aontu +1 -1
- package/package.json +1 -1
- package/project/.sdk/model/feature/audit.aontu +1 -1
- package/project/.sdk/model/feature/cache.aontu +7 -5
- package/project/.sdk/model/feature/clienttrack.aontu +1 -1
- package/project/.sdk/model/feature/cost.aontu +1 -1
- package/project/.sdk/model/feature/debug.aontu +1 -1
- package/project/.sdk/model/feature/idempotency.aontu +1 -1
- package/project/.sdk/model/feature/log.aontu +1 -1
- package/project/.sdk/model/feature/metrics.aontu +3 -1
- package/project/.sdk/model/feature/netsim.aontu +1 -1
- package/project/.sdk/model/feature/paging.aontu +4 -1
- package/project/.sdk/model/feature/proxy.aontu +1 -1
- package/project/.sdk/model/feature/ratelimit.aontu +3 -3
- package/project/.sdk/model/feature/rbac.aontu +1 -1
- package/project/.sdk/model/feature/retry.aontu +1 -1
- package/project/.sdk/model/feature/secrets.aontu +1 -1
- package/project/.sdk/model/feature/streaming.aontu +1 -1
- package/project/.sdk/model/feature/telemetry.aontu +2 -2
- package/project/.sdk/model/feature/test.aontu +1 -1
- package/project/.sdk/model/feature/timeout.aontu +1 -1
- package/project/.sdk/model/feature/validate.aontu +1 -1
- package/project/.sdk/model/target/lua.aontu +6 -0
- package/project/.sdk/src/cmp/c/Config_c.ts +3 -134
- package/project/.sdk/src/cmp/c/TestClean_c.ts +26 -11
- package/project/.sdk/src/cmp/c/fragment/Entity.fragment.c +17 -10
- package/project/.sdk/src/cmp/clojure/TestClean_clojure.ts +10 -5
- package/project/.sdk/src/cmp/clojure/fragment/Entity.fragment.clj +18 -1
- package/project/.sdk/src/cmp/cpp/TestClean_cpp.ts +15 -1
- package/project/.sdk/src/cmp/csharp/TestClean_csharp.ts +9 -0
- package/project/.sdk/src/cmp/csharp/fragment/EntityBase.fragment.cs +30 -2
- package/project/.sdk/src/cmp/csharp/fragment/Main.fragment.cs +31 -12
- package/project/.sdk/src/cmp/elixir/TestClean_elixir.ts +13 -4
- package/project/.sdk/src/cmp/elixir/fragment/Main.fragment.ex +51 -15
- package/project/.sdk/src/cmp/elixir/fragment/Pipeline.fragment.ex +17 -0
- package/project/.sdk/src/cmp/go/TestClean_go.ts +39 -3
- package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +42 -2
- package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +42 -14
- package/project/.sdk/src/cmp/java/TestClean_java.ts +17 -4
- package/project/.sdk/src/cmp/java/fragment/EntityBase.fragment.java +21 -0
- package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +13 -8
- package/project/.sdk/src/cmp/js/TestClean_js.ts +13 -5
- package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +26 -2
- package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +8 -0
- package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +8 -0
- package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +8 -0
- package/project/.sdk/src/cmp/js/fragment/EntityPatchOp.fragment.js +8 -0
- package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +8 -0
- package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +8 -0
- package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +12 -5
- package/project/.sdk/src/cmp/kotlin/TestClean_kotlin.ts +31 -4
- package/project/.sdk/src/cmp/kotlin/fragment/EntityBase.fragment.kt +19 -0
- package/project/.sdk/src/cmp/lua/TestClean_lua.ts +14 -4
- package/project/.sdk/src/cmp/lua/fragment/Entity.fragment.lua +42 -5
- package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +44 -10
- package/project/.sdk/src/cmp/lua/utility_lua.ts +2 -1
- package/project/.sdk/src/cmp/ocaml/TestClean_ocaml.ts +20 -5
- package/project/.sdk/src/cmp/ocaml/fragment/RunOp.fragment.ml +36 -21
- package/project/.sdk/src/cmp/perl/TestClean_perl.ts +13 -4
- package/project/.sdk/src/cmp/perl/fragment/Entity.fragment.pm +21 -0
- package/project/.sdk/src/cmp/perl/fragment/Main.fragment.pm +31 -12
- package/project/.sdk/src/cmp/php/TestClean_php.ts +10 -3
- package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +33 -4
- package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +13 -6
- package/project/.sdk/src/cmp/py/TestClean_py.ts +10 -3
- package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +25 -2
- package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +26 -12
- package/project/.sdk/src/cmp/rb/TestClean_rb.ts +11 -4
- package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +23 -2
- package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +27 -11
- package/project/.sdk/src/cmp/rust/TestClean_rust.ts +24 -17
- package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +22 -2
- package/project/.sdk/src/cmp/scala/TestClean_scala.ts +45 -11
- package/project/.sdk/src/cmp/scala/fragment/EntityBase.fragment.scala +14 -0
- package/project/.sdk/src/cmp/swift/TestClean_swift.ts +31 -21
- package/project/.sdk/src/cmp/swift/fragment/EntityBase.fragment.swift +9 -0
- package/project/.sdk/src/cmp/swift/fragment/Main.fragment.swift +24 -10
- package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +13 -8
- package/project/.sdk/src/cmp/ts/TestClean_ts.ts +13 -5
- package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +26 -2
- package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +8 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +8 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +8 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityPatchOp.fragment.ts +8 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +8 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +8 -0
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +12 -5
- package/project/.sdk/src/cmp/zig/TestClean_zig.ts +23 -11
- package/project/.sdk/src/cmp/zig/fragment/Entity.fragment.zig +17 -10
- package/project/.sdk/src/cmp/zig/fragment/Main.fragment.zig +41 -6
- package/project/.sdk/tm/c/core/context.c +1 -0
- package/project/.sdk/tm/c/core/sdk.h +7 -4
- package/project/.sdk/tm/c/feature/cache.c +243 -13
- package/project/.sdk/tm/c/feature/metrics.c +7 -0
- package/project/.sdk/tm/c/feature/paging.c +231 -2
- package/project/.sdk/tm/c/feature/ratelimit.c +5 -9
- package/project/.sdk/tm/c/feature/retry.c +51 -4
- package/project/.sdk/tm/c/feature/secrets.c +27 -38
- package/project/.sdk/tm/c/feature/streaming.c +2 -1
- package/project/.sdk/tm/c/feature/telemetry.c +19 -18
- package/project/.sdk/tm/c/feature/test.c +78 -54
- package/project/.sdk/tm/c/tests/feature_test.c +288 -0
- package/project/.sdk/tm/c/tests/primary_utility_test.c +2 -0
- package/project/.sdk/tm/c/utility/clean.c +26 -33
- package/project/.sdk/tm/c/utility/make_options.c +89 -17
- package/project/.sdk/tm/clojure/feature/secrets/sdk/feature/secrets.clj +14 -11
- package/project/.sdk/tm/clojure/src/sdk/client.clj +3 -1
- package/project/.sdk/tm/clojure/src/sdk/core.clj +50 -22
- package/project/.sdk/tm/clojure/src/sdk/features.clj +279 -80
- package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +103 -1
- package/project/.sdk/tm/clojure/test/sdk/test/pipeline.clj +1 -0
- package/project/.sdk/tm/cpp/Makefile +5 -0
- package/project/.sdk/tm/cpp/core/types.hpp +148 -72
- package/project/.sdk/tm/cpp/feature/audit.hpp +12 -8
- package/project/.sdk/tm/cpp/feature/cache.hpp +188 -9
- package/project/.sdk/tm/cpp/feature/metrics.hpp +19 -0
- package/project/.sdk/tm/cpp/feature/paging.hpp +160 -2
- package/project/.sdk/tm/cpp/feature/ratelimit.hpp +18 -14
- package/project/.sdk/tm/cpp/feature/retry.hpp +46 -5
- package/project/.sdk/tm/cpp/feature/secrets.hpp +12 -0
- package/project/.sdk/tm/cpp/feature/streaming.hpp +2 -1
- package/project/.sdk/tm/cpp/feature/telemetry.hpp +17 -10
- package/project/.sdk/tm/cpp/feature/test.hpp +63 -53
- package/project/.sdk/tm/cpp/test/feature_test.cpp +236 -0
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +44 -12
- package/project/.sdk/tm/csharp/core/Context.cs +4 -0
- package/project/.sdk/tm/csharp/feature/AuditFeature.cs +8 -1
- package/project/.sdk/tm/csharp/feature/CacheFeature.cs +126 -12
- package/project/.sdk/tm/csharp/feature/MetricsFeature.cs +23 -0
- package/project/.sdk/tm/csharp/feature/PagingFeature.cs +130 -3
- package/project/.sdk/tm/csharp/feature/RatelimitFeature.cs +26 -19
- package/project/.sdk/tm/csharp/feature/RetryFeature.cs +41 -7
- package/project/.sdk/tm/csharp/feature/SecretsFeature.cs +9 -27
- package/project/.sdk/tm/csharp/feature/StreamingFeature.cs +2 -1
- package/project/.sdk/tm/csharp/feature/TelemetryFeature.cs +11 -9
- package/project/.sdk/tm/csharp/feature/TestFeature.cs +55 -67
- package/project/.sdk/tm/csharp/test/FeatureTest.cs +238 -0
- package/project/.sdk/tm/csharp/utility/Clean.cs +5 -10
- package/project/.sdk/tm/csharp/utility/Fetcher.cs +7 -1
- package/project/.sdk/tm/csharp/utility/MakeOptions.cs +94 -24
- package/project/.sdk/tm/elixir/lib/projectname/context.ex +2 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/cache.ex +146 -30
- package/project/.sdk/tm/elixir/lib/projectname/feature/metrics.ex +13 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/paging.ex +110 -5
- package/project/.sdk/tm/elixir/lib/projectname/feature/ratelimit.ex +6 -12
- package/project/.sdk/tm/elixir/lib/projectname/feature/retry.ex +33 -9
- package/project/.sdk/tm/elixir/lib/projectname/feature/secrets.ex +10 -56
- package/project/.sdk/tm/elixir/lib/projectname/feature/streaming.ex +2 -1
- package/project/.sdk/tm/elixir/lib/projectname/feature/telemetry.ex +7 -7
- package/project/.sdk/tm/elixir/lib/projectname/feature/test.ex +52 -48
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +77 -47
- package/project/.sdk/tm/elixir/test/feature_test.exs +198 -0
- package/project/.sdk/tm/go/core/context.go +6 -0
- package/project/.sdk/tm/go/feature/audit_feature.go +1 -3
- package/project/.sdk/tm/go/feature/base_feature.go +11 -0
- package/project/.sdk/tm/go/feature/cache_feature.go +131 -4
- package/project/.sdk/tm/go/feature/metrics_feature.go +14 -0
- package/project/.sdk/tm/go/feature/paging_feature.go +108 -2
- package/project/.sdk/tm/go/feature/ratelimit_feature.go +19 -17
- package/project/.sdk/tm/go/feature/retry_feature.go +81 -9
- package/project/.sdk/tm/go/feature/secrets_feature.go +17 -71
- package/project/.sdk/tm/go/feature/streaming_feature.go +2 -1
- package/project/.sdk/tm/go/feature/telemetry_feature.go +18 -11
- package/project/.sdk/tm/go/feature/test_feature.go +65 -55
- package/project/.sdk/tm/go/test/feature_corpus_test.go +357 -28
- package/project/.sdk/tm/go/test/feature_test.go +93 -0
- package/project/.sdk/tm/go/utility/clean.go +5 -7
- package/project/.sdk/tm/go/utility/fetcher.go +11 -0
- package/project/.sdk/tm/go/utility/make_options.go +116 -13
- package/project/.sdk/tm/java/core/Context.java +9 -0
- package/project/.sdk/tm/java/core/SdkClient.java +43 -14
- package/project/.sdk/tm/java/feature/AuditFeature.java +5 -1
- package/project/.sdk/tm/java/feature/CacheFeature.java +123 -17
- package/project/.sdk/tm/java/feature/MetricsFeature.java +31 -0
- package/project/.sdk/tm/java/feature/PagingFeature.java +156 -2
- package/project/.sdk/tm/java/feature/RatelimitFeature.java +15 -13
- package/project/.sdk/tm/java/feature/RetryFeature.java +33 -6
- package/project/.sdk/tm/java/feature/SecretsFeature.java +9 -92
- package/project/.sdk/tm/java/feature/StreamingFeature.java +2 -1
- package/project/.sdk/tm/java/feature/TelemetryFeature.java +17 -9
- package/project/.sdk/tm/java/feature/TestFeature.java +50 -63
- package/project/.sdk/tm/java/test/FeatureCorpusTest.java +309 -17
- package/project/.sdk/tm/java/test/FeatureTest.java +60 -0
- package/project/.sdk/tm/java/utility/Clean.java +6 -10
- package/project/.sdk/tm/java/utility/Fetcher.java +5 -1
- package/project/.sdk/tm/java/utility/MakeOptions.java +131 -15
- package/project/.sdk/tm/js/src/Context.js +4 -0
- package/project/.sdk/tm/js/src/feature/cache/CacheFeature.js +118 -11
- package/project/.sdk/tm/js/src/feature/cost/CostFeature.js +3 -2
- package/project/.sdk/tm/js/src/feature/metrics/MetricsFeature.js +9 -4
- package/project/.sdk/tm/js/src/feature/paging/PagingFeature.js +103 -5
- package/project/.sdk/tm/js/src/feature/ratelimit/RatelimitFeature.js +5 -9
- package/project/.sdk/tm/js/src/feature/rbac/RbacFeature.js +4 -4
- package/project/.sdk/tm/js/src/feature/retry/RetryFeature.js +25 -3
- package/project/.sdk/tm/js/src/feature/secrets/SecretsFeature.js +16 -6
- package/project/.sdk/tm/js/src/feature/streaming/StreamingFeature.js +2 -1
- package/project/.sdk/tm/js/src/feature/telemetry/TelemetryFeature.js +11 -6
- package/project/.sdk/tm/js/src/feature/test/TestFeature.js +38 -1
- package/project/.sdk/tm/js/src/feature/validate/ValidateFeature.js +2 -1
- package/project/.sdk/tm/js/src/utility/CleanUtility.js +1 -1
- package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +61 -12
- package/project/.sdk/tm/js/test/feature/Corpus.test.js +191 -23
- package/project/.sdk/tm/js/test/feature/harness.js +3 -3
- package/project/.sdk/tm/js/test/feature.test.js +14 -1
- package/project/.sdk/tm/js/test/pipeline.test.js +1 -1
- package/project/.sdk/tm/kotlin/core/Context.kt +3 -0
- package/project/.sdk/tm/kotlin/core/SdkClient.kt +23 -10
- package/project/.sdk/tm/kotlin/feature/AuditFeature.kt +5 -1
- package/project/.sdk/tm/kotlin/feature/CacheFeature.kt +102 -7
- package/project/.sdk/tm/kotlin/feature/MetricsFeature.kt +22 -0
- package/project/.sdk/tm/kotlin/feature/PagingFeature.kt +125 -2
- package/project/.sdk/tm/kotlin/feature/RatelimitFeature.kt +16 -13
- package/project/.sdk/tm/kotlin/feature/RetryFeature.kt +36 -14
- package/project/.sdk/tm/kotlin/feature/SecretsFeature.kt +10 -20
- package/project/.sdk/tm/kotlin/feature/StreamingFeature.kt +4 -0
- package/project/.sdk/tm/kotlin/feature/TelemetryFeature.kt +12 -10
- package/project/.sdk/tm/kotlin/feature/TestFeature.kt +45 -48
- package/project/.sdk/tm/kotlin/test/FeatureTest.kt +173 -0
- package/project/.sdk/tm/kotlin/utility/CoreUtil.kt +5 -5
- package/project/.sdk/tm/kotlin/utility/Fetcher.kt +4 -0
- package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +86 -15
- package/project/.sdk/tm/lua/core/context.lua +6 -0
- package/project/.sdk/tm/lua/feature/cache_feature.lua +212 -15
- package/project/.sdk/tm/lua/feature/debug_feature.lua +2 -3
- package/project/.sdk/tm/lua/feature/metrics_feature.lua +5 -0
- package/project/.sdk/tm/lua/feature/paging_feature.lua +143 -2
- package/project/.sdk/tm/lua/feature/ratelimit_feature.lua +5 -9
- package/project/.sdk/tm/lua/feature/retry_feature.lua +43 -5
- package/project/.sdk/tm/lua/feature/secrets_feature.lua +15 -80
- package/project/.sdk/tm/lua/feature/streaming_feature.lua +2 -1
- package/project/.sdk/tm/lua/feature/telemetry_feature.lua +18 -7
- package/project/.sdk/tm/lua/feature/test_feature.lua +60 -62
- package/project/.sdk/tm/lua/test/feature_test.lua +181 -3
- package/project/.sdk/tm/lua/utility/clean.lua +6 -9
- package/project/.sdk/tm/lua/utility/fetcher.lua +9 -0
- package/project/.sdk/tm/lua/utility/make_options.lua +60 -18
- package/project/.sdk/tm/ocaml/feature/secrets_feature.ml +21 -6
- package/project/.sdk/tm/ocaml/sdk_features.ml +392 -68
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +47 -21
- package/project/.sdk/tm/ocaml/sdk_types.ml +2 -0
- package/project/.sdk/tm/ocaml/test/t_feature.ml +107 -2
- package/project/.sdk/tm/perl/core/context.pm +3 -0
- package/project/.sdk/tm/perl/feature/audit_feature.pm +4 -7
- package/project/.sdk/tm/perl/feature/cache_feature.pm +111 -15
- package/project/.sdk/tm/perl/feature/debug_feature.pm +2 -2
- package/project/.sdk/tm/perl/feature/metrics_feature.pm +5 -0
- package/project/.sdk/tm/perl/feature/paging_feature.pm +139 -2
- package/project/.sdk/tm/perl/feature/ratelimit_feature.pm +5 -11
- package/project/.sdk/tm/perl/feature/retry_feature.pm +22 -4
- package/project/.sdk/tm/perl/feature/secrets_feature.pm +13 -18
- package/project/.sdk/tm/perl/feature/streaming_feature.pm +2 -0
- package/project/.sdk/tm/perl/feature/telemetry_feature.pm +17 -8
- package/project/.sdk/tm/perl/feature/test_feature.pm +45 -50
- package/project/.sdk/tm/perl/t/feature.t +68 -2
- package/project/.sdk/tm/perl/t/feature_corpus.t +204 -25
- package/project/.sdk/tm/perl/utility/clean.pm +6 -8
- package/project/.sdk/tm/perl/utility/fetcher.pm +4 -0
- package/project/.sdk/tm/perl/utility/make_options.pm +38 -15
- package/project/.sdk/tm/php/core/Context.php +4 -0
- package/project/.sdk/tm/php/feature/CacheFeature.php +98 -13
- package/project/.sdk/tm/php/feature/MetricsFeature.php +8 -0
- package/project/.sdk/tm/php/feature/PagingFeature.php +128 -1
- package/project/.sdk/tm/php/feature/RatelimitFeature.php +5 -9
- package/project/.sdk/tm/php/feature/RetryFeature.php +27 -3
- package/project/.sdk/tm/php/feature/SecretsFeature.php +18 -15
- package/project/.sdk/tm/php/feature/StreamingFeature.php +2 -1
- package/project/.sdk/tm/php/feature/TelemetryFeature.php +10 -7
- package/project/.sdk/tm/php/feature/TestFeature.php +55 -47
- package/project/.sdk/tm/php/test/FeatureCorpusTest.php +262 -17
- package/project/.sdk/tm/php/test/FeatureTest.php +68 -0
- package/project/.sdk/tm/php/utility/Clean.php +3 -10
- package/project/.sdk/tm/php/utility/Fetcher.php +8 -3
- package/project/.sdk/tm/php/utility/MakeOptions.php +45 -20
- package/project/.sdk/tm/py/pkg/core/context.py +4 -0
- package/project/.sdk/tm/py/pkg/feature/cache_feature.py +79 -13
- package/project/.sdk/tm/py/pkg/feature/metrics_feature.py +7 -0
- package/project/.sdk/tm/py/pkg/feature/paging_feature.py +86 -1
- package/project/.sdk/tm/py/pkg/feature/ratelimit_feature.py +13 -16
- package/project/.sdk/tm/py/pkg/feature/retry_feature.py +31 -6
- package/project/.sdk/tm/py/pkg/feature/secrets_feature.py +15 -66
- package/project/.sdk/tm/py/pkg/feature/streaming_feature.py +2 -1
- package/project/.sdk/tm/py/pkg/feature/telemetry_feature.py +10 -6
- package/project/.sdk/tm/py/pkg/feature/test_feature.py +56 -53
- package/project/.sdk/tm/py/pkg/utility/clean.py +4 -10
- package/project/.sdk/tm/py/pkg/utility/make_options.py +77 -30
- package/project/.sdk/tm/py/test/feature/secrets/test_secrets.py +23 -9
- package/project/.sdk/tm/py/test/test_feature.py +61 -1
- package/project/.sdk/tm/py/test/test_feature_corpus.py +197 -17
- package/project/.sdk/tm/py-data/pkg/fetch.py +6 -3
- package/project/.sdk/tm/py-data/test/test_fetch.py +7 -4
- package/project/.sdk/tm/rb/core/context.rb +4 -1
- package/project/.sdk/tm/rb/feature/audit_feature.rb +6 -5
- package/project/.sdk/tm/rb/feature/cache_feature.rb +75 -11
- package/project/.sdk/tm/rb/feature/debug_feature.rb +2 -2
- package/project/.sdk/tm/rb/feature/metrics_feature.rb +8 -0
- package/project/.sdk/tm/rb/feature/paging_feature.rb +87 -1
- package/project/.sdk/tm/rb/feature/ratelimit_feature.rb +12 -16
- package/project/.sdk/tm/rb/feature/retry_feature.rb +19 -3
- package/project/.sdk/tm/rb/feature/secrets_feature.rb +9 -64
- package/project/.sdk/tm/rb/feature/streaming_feature.rb +2 -1
- package/project/.sdk/tm/rb/feature/telemetry_feature.rb +11 -6
- package/project/.sdk/tm/rb/feature/test_feature.rb +42 -49
- package/project/.sdk/tm/rb/test/feature_corpus_test.rb +191 -25
- package/project/.sdk/tm/rb/test/feature_test.rb +75 -1
- package/project/.sdk/tm/rb/utility/clean.rb +6 -7
- package/project/.sdk/tm/rb/utility/fetcher.rb +6 -0
- package/project/.sdk/tm/rb/utility/make_options.rb +37 -16
- package/project/.sdk/tm/rust/core/context.rs +8 -0
- package/project/.sdk/tm/rust/feature/audit.rs +2 -2
- package/project/.sdk/tm/rust/feature/cache.rs +120 -3
- package/project/.sdk/tm/rust/feature/metrics.rs +24 -1
- package/project/.sdk/tm/rust/feature/paging.rs +189 -3
- package/project/.sdk/tm/rust/feature/ratelimit.rs +5 -10
- package/project/.sdk/tm/rust/feature/retry.rs +59 -6
- package/project/.sdk/tm/rust/feature/secrets.rs +36 -98
- package/project/.sdk/tm/rust/feature/streaming.rs +3 -2
- package/project/.sdk/tm/rust/feature/support.rs +4 -0
- package/project/.sdk/tm/rust/feature/telemetry.rs +22 -11
- package/project/.sdk/tm/rust/feature/test.rs +63 -57
- package/project/.sdk/tm/rust/tests/feature/secrets/main.rs +3 -3
- package/project/.sdk/tm/rust/tests/feature_test.rs +274 -0
- package/project/.sdk/tm/rust/tests/primary_utility_test.rs +1 -0
- package/project/.sdk/tm/rust/utility/clean.rs +35 -43
- package/project/.sdk/tm/rust/utility/fetcher.rs +6 -0
- package/project/.sdk/tm/rust/utility/make_options.rs +130 -38
- package/project/.sdk/tm/scala/core/Context.scala +4 -0
- package/project/.sdk/tm/scala/core/SdkClient.scala +45 -11
- package/project/.sdk/tm/scala/feature/AuditFeature.scala +6 -1
- package/project/.sdk/tm/scala/feature/CacheFeature.scala +117 -11
- package/project/.sdk/tm/scala/feature/MetricsFeature.scala +31 -1
- package/project/.sdk/tm/scala/feature/PagingFeature.scala +122 -2
- package/project/.sdk/tm/scala/feature/RatelimitFeature.scala +14 -11
- package/project/.sdk/tm/scala/feature/RetryFeature.scala +29 -7
- package/project/.sdk/tm/scala/feature/SecretsFeature.scala +11 -24
- package/project/.sdk/tm/scala/feature/StreamingFeature.scala +2 -1
- package/project/.sdk/tm/scala/feature/TelemetryFeature.scala +12 -10
- package/project/.sdk/tm/scala/feature/TestFeature.scala +44 -44
- package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +69 -0
- package/project/.sdk/tm/scala/utility/Fetcher.scala +5 -0
- package/project/.sdk/tm/scala/utility/Make.scala +99 -14
- package/project/.sdk/tm/scala/utility/Misc.scala +5 -8
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Context.swift +3 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/AuditFeature.swift +3 -2
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/CacheFeature.swift +122 -11
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/MetricsFeature.swift +20 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/PagingFeature.swift +102 -2
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/RatelimitFeature.swift +19 -13
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/RetryFeature.swift +40 -5
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/SecretsFeature.swift +9 -13
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/StreamingFeature.swift +2 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TelemetryFeature.swift +11 -9
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TestFeature.swift +55 -49
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Fetcher.swift +4 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +56 -17
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/ResultUtil.swift +4 -5
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +166 -0
- package/project/.sdk/tm/ts/src/Context.ts +4 -0
- package/project/.sdk/tm/ts/src/feature/cache/CacheFeature.ts +115 -4
- package/project/.sdk/tm/ts/src/feature/cost/CostFeature.ts +3 -2
- package/project/.sdk/tm/ts/src/feature/metrics/MetricsFeature.ts +6 -1
- package/project/.sdk/tm/ts/src/feature/paging/PagingFeature.ts +103 -5
- package/project/.sdk/tm/ts/src/feature/ratelimit/RatelimitFeature.ts +5 -9
- package/project/.sdk/tm/ts/src/feature/rbac/RbacFeature.ts +4 -4
- package/project/.sdk/tm/ts/src/feature/retry/RetryFeature.ts +25 -3
- package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +14 -2
- package/project/.sdk/tm/ts/src/feature/streaming/StreamingFeature.ts +2 -1
- package/project/.sdk/tm/ts/src/feature/telemetry/TelemetryFeature.ts +11 -6
- package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +8 -7
- package/project/.sdk/tm/ts/src/feature/validate/ValidateFeature.ts +2 -1
- package/project/.sdk/tm/ts/src/utility/CleanUtility.ts +1 -1
- package/project/.sdk/tm/ts/src/utility/MakeOptionsUtility.ts +63 -12
- package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +192 -23
- package/project/.sdk/tm/ts/test/feature/harness.ts +3 -3
- package/project/.sdk/tm/ts/test/feature.test.ts +14 -1
- package/project/.sdk/tm/ts/test/pipeline.test.ts +1 -1
- package/project/.sdk/tm/zig/core/context.zig +5 -0
- package/project/.sdk/tm/zig/core/utility.zig +118 -17
- package/project/.sdk/tm/zig/feature/cache.zig +144 -13
- package/project/.sdk/tm/zig/feature/metrics.zig +19 -0
- package/project/.sdk/tm/zig/feature/paging.zig +172 -4
- package/project/.sdk/tm/zig/feature/ratelimit.zig +5 -11
- package/project/.sdk/tm/zig/feature/retry.zig +41 -3
- package/project/.sdk/tm/zig/feature/secrets.zig +6 -1
- package/project/.sdk/tm/zig/feature/streaming.zig +2 -0
- package/project/.sdk/tm/zig/feature/telemetry.zig +15 -9
- package/project/.sdk/tm/zig/feature/test.zig +56 -40
- package/project/.sdk/tm/zig/test/feature_test.zig +174 -0
- package/project/.sdk/tm/zig/test/primary_utility_test.zig +2 -0
- package/project/sdkgen-package.json +1 -1
- package/src/cmp/ReadmeExplanation.ts +5 -2
- package/src/cmp/ReadmeFeatures.ts +21 -6
- package/src/helpers/optspec.ts +2 -2
|
@@ -5,10 +5,13 @@ import (
|
|
|
5
5
|
"encoding/json"
|
|
6
6
|
"errors"
|
|
7
7
|
"fmt"
|
|
8
|
+
"net/url"
|
|
8
9
|
"reflect"
|
|
9
10
|
"sort"
|
|
10
11
|
"strings"
|
|
12
|
+
"sync"
|
|
11
13
|
"testing"
|
|
14
|
+
"time"
|
|
12
15
|
|
|
13
16
|
sdk "GOMODULE"
|
|
14
17
|
)
|
|
@@ -29,14 +32,21 @@ type fcOp struct {
|
|
|
29
32
|
|
|
30
33
|
// fcFetcher builds a scripted transport from a case's `res` list. Responses
|
|
31
34
|
// are consumed in order and the last one repeats, so a case that does not
|
|
32
|
-
// care how many attempts happen need only declare one.
|
|
33
|
-
|
|
35
|
+
// care how many attempts happen need only declare one. Each URL it is sent is
|
|
36
|
+
// kept in sent, with the time it was sent; a `cut` response is one whose body
|
|
37
|
+
// stops before its end.
|
|
38
|
+
func fcFetcher(res []any, sent *fcSent) sdk.FetcherFunc {
|
|
34
39
|
n := -1
|
|
35
40
|
return func(ctx *sdk.Context, fullurl string, fetchdef map[string]any) (any, error) {
|
|
41
|
+
sent.mu.Lock()
|
|
36
42
|
n++
|
|
43
|
+
at := n
|
|
44
|
+
sent.at = append(sent.at, time.Now().UnixMilli())
|
|
45
|
+
sent.url = append(sent.url, fullurl)
|
|
46
|
+
sent.mu.Unlock()
|
|
37
47
|
var spec map[string]any
|
|
38
48
|
if len(res) > 0 {
|
|
39
|
-
i :=
|
|
49
|
+
i := at
|
|
40
50
|
if i >= len(res) {
|
|
41
51
|
i = len(res) - 1
|
|
42
52
|
}
|
|
@@ -78,6 +88,17 @@ func fcFetcher(res []any) sdk.FetcherFunc {
|
|
|
78
88
|
// than a mis-shaped script.
|
|
79
89
|
raw, _ := json.Marshal(body)
|
|
80
90
|
|
|
91
|
+
if cut, _ := spec["cut"].(bool); cut {
|
|
92
|
+
return map[string]any{
|
|
93
|
+
"status": status,
|
|
94
|
+
"statusText": statusText,
|
|
95
|
+
"headers": headers,
|
|
96
|
+
"json": (func() any)(func() any { return nil }),
|
|
97
|
+
"body": string(raw[:len(raw)/2]),
|
|
98
|
+
"unreadable": true,
|
|
99
|
+
}, nil
|
|
100
|
+
}
|
|
101
|
+
|
|
81
102
|
return map[string]any{
|
|
82
103
|
"status": status,
|
|
83
104
|
"statusText": statusText,
|
|
@@ -88,11 +109,39 @@ func fcFetcher(res []any) sdk.FetcherFunc {
|
|
|
88
109
|
}
|
|
89
110
|
}
|
|
90
111
|
|
|
112
|
+
// fcSent records each request the transport saw, and when.
|
|
113
|
+
type fcSent struct {
|
|
114
|
+
mu sync.Mutex
|
|
115
|
+
at []int64
|
|
116
|
+
url []string
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// fcBusiest is the most requests seen in any window of ms.
|
|
120
|
+
func (sent *fcSent) fcBusiest(ms int64) int {
|
|
121
|
+
most := 0
|
|
122
|
+
for _, from := range sent.at {
|
|
123
|
+
n := 0
|
|
124
|
+
for _, t := range sent.at {
|
|
125
|
+
if from <= t && t < from+ms {
|
|
126
|
+
n++
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if n > most {
|
|
130
|
+
most = n
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return most
|
|
134
|
+
}
|
|
135
|
+
|
|
91
136
|
func fcClient(kase map[string]any) *sdk.ProjectNameSDK {
|
|
137
|
+
return fcClientSent(kase, &fcSent{})
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
func fcClientSent(kase map[string]any, sent *fcSent) *sdk.ProjectNameSDK {
|
|
92
141
|
res, _ := kase["res"].([]any)
|
|
93
142
|
opts := map[string]any{
|
|
94
143
|
"test": map[string]any{"active": true},
|
|
95
|
-
"utility": map[string]any{"fetcher": fcFetcher(res)},
|
|
144
|
+
"utility": map[string]any{"fetcher": fcFetcher(res, sent)},
|
|
96
145
|
}
|
|
97
146
|
if f, ok := kase["feature"]; ok {
|
|
98
147
|
opts["feature"] = f
|
|
@@ -185,6 +234,10 @@ func fcCandidates(client *sdk.ProjectNameSDK) []fcOp {
|
|
|
185
234
|
|
|
186
235
|
// fcInvoke performs one operation on a client, by entity name and method.
|
|
187
236
|
func fcInvoke(client *sdk.ProjectNameSDK, op fcOp, ctrl map[string]any) error {
|
|
237
|
+
return fcInvokeArgs(client, op, map[string]any{}, ctrl)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
func fcInvokeArgs(client *sdk.ProjectNameSDK, op fcOp, args map[string]any, ctrl map[string]any) error {
|
|
188
241
|
cv := reflect.ValueOf(client)
|
|
189
242
|
ct := cv.Type()
|
|
190
243
|
mapType := reflect.TypeOf(map[string]any{})
|
|
@@ -208,7 +261,7 @@ func fcInvoke(client *sdk.ProjectNameSDK, op fcOp, ctrl map[string]any) error {
|
|
|
208
261
|
return fmt.Errorf("no method %s on entity %s", op.method, op.accessor)
|
|
209
262
|
}
|
|
210
263
|
rets := om.Call([]reflect.Value{
|
|
211
|
-
reflect.ValueOf(
|
|
264
|
+
reflect.ValueOf(args),
|
|
212
265
|
reflect.ValueOf(ctrl),
|
|
213
266
|
})
|
|
214
267
|
if err, ok := rets[1].Interface().(error); ok && err != nil {
|
|
@@ -239,6 +292,198 @@ func fcUsableOps(want int) []fcOp {
|
|
|
239
292
|
return picked
|
|
240
293
|
}
|
|
241
294
|
|
|
295
|
+
// fcUsablePair finds a read and a write of one entity (#READ, #WRITE), each
|
|
296
|
+
// driven as fcUsableOps drives an op.
|
|
297
|
+
func fcUsablePair() (fcOp, fcOp, bool) {
|
|
298
|
+
reads := map[string]fcOp{}
|
|
299
|
+
writes := map[string]fcOp{}
|
|
300
|
+
for _, cand := range fcCandidates(fcClient(map[string]any{})) {
|
|
301
|
+
role := ""
|
|
302
|
+
switch strings.ToLower(cand.method) {
|
|
303
|
+
case "list", "load":
|
|
304
|
+
role = "read"
|
|
305
|
+
case "create", "update", "patch", "remove":
|
|
306
|
+
role = "write"
|
|
307
|
+
}
|
|
308
|
+
seen := reads
|
|
309
|
+
if role == "write" {
|
|
310
|
+
seen = writes
|
|
311
|
+
}
|
|
312
|
+
if _, done := seen[cand.accessor]; role == "" || done {
|
|
313
|
+
continue
|
|
314
|
+
}
|
|
315
|
+
if err := fcInvoke(fcClient(map[string]any{}), cand, map[string]any{}); err != nil {
|
|
316
|
+
continue
|
|
317
|
+
}
|
|
318
|
+
seen[cand.accessor] = cand
|
|
319
|
+
read, okr := reads[cand.accessor]
|
|
320
|
+
write, okw := writes[cand.accessor]
|
|
321
|
+
if okr && okw {
|
|
322
|
+
return read, write, true
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return fcOp{}, fcOp{}, false
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// fcUsableItem finds a write of one entity (#ITEM) that completes when driven
|
|
329
|
+
// with fcItemArgs.
|
|
330
|
+
func fcUsableItem(entity string) (fcOp, bool) {
|
|
331
|
+
for _, cand := range fcCandidates(fcClient(map[string]any{})) {
|
|
332
|
+
switch strings.ToLower(cand.method) {
|
|
333
|
+
case "update", "patch", "remove":
|
|
334
|
+
default:
|
|
335
|
+
continue
|
|
336
|
+
}
|
|
337
|
+
if cand.accessor != entity {
|
|
338
|
+
continue
|
|
339
|
+
}
|
|
340
|
+
if err := fcInvokeArgs(fcClient(map[string]any{}), cand, fcItemArgs(), map[string]any{}); err == nil {
|
|
341
|
+
return cand, true
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return fcOp{}, false
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
func fcItemArgs() map[string]any {
|
|
348
|
+
return map[string]any{"id": "corpus-item"}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// fcStreamArgs reads one operation through the entity's Stream, and reports
|
|
352
|
+
// how many items it yielded before it ended or failed.
|
|
353
|
+
func fcStreamArgs(client *sdk.ProjectNameSDK, op fcOp, args map[string]any, ctrl map[string]any) (int, error) {
|
|
354
|
+
cv := reflect.ValueOf(client)
|
|
355
|
+
ct := cv.Type()
|
|
356
|
+
mapType := reflect.TypeOf(map[string]any{})
|
|
357
|
+
|
|
358
|
+
for i := 0; i < ct.NumMethod(); i++ {
|
|
359
|
+
mt := ct.Method(i).Type
|
|
360
|
+
if mt.NumIn() != 2 || mt.NumOut() != 1 || mt.In(1) != mapType {
|
|
361
|
+
continue
|
|
362
|
+
}
|
|
363
|
+
ent := cv.Method(i).Call([]reflect.Value{reflect.ValueOf(map[string]any(nil))})[0]
|
|
364
|
+
gn := ent.MethodByName("GetName")
|
|
365
|
+
if !gn.IsValid() || gn.Type().NumIn() != 0 || gn.Type().NumOut() != 1 ||
|
|
366
|
+
gn.Type().Out(0).Kind() != reflect.String {
|
|
367
|
+
continue
|
|
368
|
+
}
|
|
369
|
+
if gn.Call(nil)[0].String() != op.accessor {
|
|
370
|
+
continue
|
|
371
|
+
}
|
|
372
|
+
streamer, ok := ent.Interface().(interface {
|
|
373
|
+
Stream(string, map[string]any, map[string]any) <-chan sdk.StreamItem
|
|
374
|
+
})
|
|
375
|
+
if !ok {
|
|
376
|
+
return 0, fmt.Errorf("no Stream on entity %s", op.accessor)
|
|
377
|
+
}
|
|
378
|
+
items := 0
|
|
379
|
+
for item := range streamer.Stream(strings.ToLower(op.method), args,
|
|
380
|
+
map[string]any{"ctrl": ctrl}) {
|
|
381
|
+
if item.Err != nil {
|
|
382
|
+
return items, item.Err
|
|
383
|
+
}
|
|
384
|
+
items++
|
|
385
|
+
}
|
|
386
|
+
return items, nil
|
|
387
|
+
}
|
|
388
|
+
return 0, fmt.Errorf("no entity accessor for %s", op.accessor)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// fcCheckSent checks each request a case expects, in order: its path, and its
|
|
392
|
+
// whole query. A path is compared without its leading slash, which an SDK
|
|
393
|
+
// with no base omits.
|
|
394
|
+
func fcCheckSent(t *testing.T, sent []string, expect []any, label string) {
|
|
395
|
+
t.Helper()
|
|
396
|
+
if len(sent) != len(expect) {
|
|
397
|
+
t.Errorf("%s: %d request(s) sent, want %d: %s", label, len(sent), len(expect),
|
|
398
|
+
strings.Join(sent, " | "))
|
|
399
|
+
return
|
|
400
|
+
}
|
|
401
|
+
for i, raw := range expect {
|
|
402
|
+
want, _ := raw.(map[string]any)
|
|
403
|
+
u, err := url.Parse(sent[i])
|
|
404
|
+
if err != nil {
|
|
405
|
+
t.Errorf("%s: request %d: %v", label, i, err)
|
|
406
|
+
continue
|
|
407
|
+
}
|
|
408
|
+
if path, ok := want["path"].(string); ok &&
|
|
409
|
+
strings.TrimLeft(u.Path, "/") != strings.TrimLeft(path, "/") {
|
|
410
|
+
t.Errorf("%s: request %d path: got %q, want %q", label, i, u.Path, path)
|
|
411
|
+
}
|
|
412
|
+
if wq, ok := want["query"].(map[string]any); ok {
|
|
413
|
+
got := map[string]any{}
|
|
414
|
+
for k, v := range u.Query() {
|
|
415
|
+
got[k] = v[len(v)-1]
|
|
416
|
+
}
|
|
417
|
+
if fmt.Sprintf("%v", got) != fmt.Sprintf("%v", wq) {
|
|
418
|
+
t.Errorf("%s: request %d query: got %v, want %v", label, i, got, wq)
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// fcStep runs one step: it may wait before its call, may add request headers
|
|
425
|
+
// for its call, and may pass `args` as the operation's first argument. A
|
|
426
|
+
// `stream` step reads the operation through Stream, and `items` is how many it
|
|
427
|
+
// yields.
|
|
428
|
+
func fcStep(client *sdk.ProjectNameSDK, op fcOp, step map[string]any, ctrl map[string]any) error {
|
|
429
|
+
if wait, ok := fcNum(step["wait"]); ok {
|
|
430
|
+
time.Sleep(time.Duration(wait) * time.Millisecond)
|
|
431
|
+
}
|
|
432
|
+
options := client.GetRootCtx().Options
|
|
433
|
+
prior, had := options["headers"]
|
|
434
|
+
if extra, ok := step["headers"].(map[string]any); ok {
|
|
435
|
+
merged := map[string]any{}
|
|
436
|
+
if pm, ok := prior.(map[string]any); ok {
|
|
437
|
+
for k, v := range pm {
|
|
438
|
+
merged[k] = v
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
for k, v := range extra {
|
|
442
|
+
merged[k] = v
|
|
443
|
+
}
|
|
444
|
+
options["headers"] = merged
|
|
445
|
+
defer func() {
|
|
446
|
+
if had {
|
|
447
|
+
options["headers"] = prior
|
|
448
|
+
} else {
|
|
449
|
+
delete(options, "headers")
|
|
450
|
+
}
|
|
451
|
+
}()
|
|
452
|
+
}
|
|
453
|
+
args, _ := step["args"].(map[string]any)
|
|
454
|
+
if args == nil {
|
|
455
|
+
args = map[string]any{}
|
|
456
|
+
}
|
|
457
|
+
if stream, _ := step["stream"].(bool); stream {
|
|
458
|
+
items, err := fcStreamArgs(client, op, args, ctrl)
|
|
459
|
+
if want, ok := fcNum(step["items"]); ok && err == nil && float64(items) != want {
|
|
460
|
+
return fmt.Errorf("%s: streamed %d item(s), want %v", op.key, items, want)
|
|
461
|
+
}
|
|
462
|
+
return err
|
|
463
|
+
}
|
|
464
|
+
return fcInvokeArgs(client, op, args, ctrl)
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// fcCalls runs a step once, or with `together: N` as N overlapping calls,
|
|
468
|
+
// and returns each call's error.
|
|
469
|
+
func fcCalls(client *sdk.ProjectNameSDK, op fcOp, step map[string]any, ctrl map[string]any) []error {
|
|
470
|
+
n := 1
|
|
471
|
+
if together, ok := fcNum(step["together"]); ok {
|
|
472
|
+
n = int(together)
|
|
473
|
+
}
|
|
474
|
+
errs := make([]error, n)
|
|
475
|
+
var wg sync.WaitGroup
|
|
476
|
+
for i := 0; i < n; i++ {
|
|
477
|
+
wg.Add(1)
|
|
478
|
+
go func(i int) {
|
|
479
|
+
defer wg.Done()
|
|
480
|
+
errs[i] = fcStep(client, op, step, ctrl)
|
|
481
|
+
}(i)
|
|
482
|
+
}
|
|
483
|
+
wg.Wait()
|
|
484
|
+
return errs
|
|
485
|
+
}
|
|
486
|
+
|
|
242
487
|
// fcResolve replaces #OPn throughout a case, keys included.
|
|
243
488
|
func fcResolve(node any, tokens map[string]string) any {
|
|
244
489
|
switch v := node.(type) {
|
|
@@ -323,6 +568,18 @@ func fcSubset(t *testing.T, actual any, expect any, path string) {
|
|
|
323
568
|
return
|
|
324
569
|
}
|
|
325
570
|
|
|
571
|
+
if el, ok := expect.([]any); ok {
|
|
572
|
+
av := reflect.ValueOf(actual)
|
|
573
|
+
if actual == nil || (av.Kind() != reflect.Slice && av.Kind() != reflect.Array) || av.Len() != len(el) {
|
|
574
|
+
t.Errorf("%s: want %d item(s), got %v", path, len(el), actual)
|
|
575
|
+
return
|
|
576
|
+
}
|
|
577
|
+
for i, want := range el {
|
|
578
|
+
fcSubset(t, av.Index(i).Interface(), want, fmt.Sprintf("%s[%d]", path, i))
|
|
579
|
+
}
|
|
580
|
+
return
|
|
581
|
+
}
|
|
582
|
+
|
|
326
583
|
if wn, ok := fcNum(expect); ok {
|
|
327
584
|
gn, ok := fcNum(actual)
|
|
328
585
|
if !ok {
|
|
@@ -419,6 +676,16 @@ func fcMissingFeature(kase map[string]any, have map[string]bool) string {
|
|
|
419
676
|
return ""
|
|
420
677
|
}
|
|
421
678
|
|
|
679
|
+
// fcLacking names the first token a case uses that this SDK cannot drive.
|
|
680
|
+
func fcLacking(encoded string, have map[string]bool) string {
|
|
681
|
+
for _, tok := range []string{"#ITEM", "#OTHER"} {
|
|
682
|
+
if !have[tok] && strings.Contains(encoded, tok) {
|
|
683
|
+
return tok
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
return ""
|
|
687
|
+
}
|
|
688
|
+
|
|
422
689
|
func TestFeatureCorpus(t *testing.T) {
|
|
423
690
|
spec := loadTestSpec(t)
|
|
424
691
|
|
|
@@ -429,6 +696,18 @@ func TestFeatureCorpus(t *testing.T) {
|
|
|
429
696
|
|
|
430
697
|
ops := fcUsableOps(2)
|
|
431
698
|
have := map[string]bool{}
|
|
699
|
+
pairRead, pairWrite, paired := fcUsablePair()
|
|
700
|
+
var pairItem, pairOther fcOp
|
|
701
|
+
hasItem, hasOther := false, false
|
|
702
|
+
if paired {
|
|
703
|
+
pairItem, hasItem = fcUsableItem(pairRead.accessor)
|
|
704
|
+
for _, o := range ops {
|
|
705
|
+
if o.accessor != pairRead.accessor {
|
|
706
|
+
pairOther, hasOther = o, true
|
|
707
|
+
break
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}
|
|
432
711
|
|
|
433
712
|
// With every operation needing an argument there is nothing to drive:
|
|
434
713
|
// skip and say so, as the clean test does, rather than fail.
|
|
@@ -483,6 +762,20 @@ func TestFeatureCorpus(t *testing.T) {
|
|
|
483
762
|
continue
|
|
484
763
|
}
|
|
485
764
|
|
|
765
|
+
encoded, _ := json.Marshal(kase)
|
|
766
|
+
wantsPair := strings.Contains(string(encoded), "#READ") || strings.Contains(string(encoded), "#WRITE") ||
|
|
767
|
+
strings.Contains(string(encoded), "#ITEM") || strings.Contains(string(encoded), "#OTHER")
|
|
768
|
+
if wantsPair && !paired {
|
|
769
|
+
t.Logf("skip %q: needs a read and a write of one entity, this SDK offers none",
|
|
770
|
+
kase["name"])
|
|
771
|
+
continue
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
if lacking := fcLacking(string(encoded), map[string]bool{"#ITEM": hasItem, "#OTHER": hasOther}); paired && lacking != "" {
|
|
775
|
+
t.Logf("skip %q: needs %s, which this SDK cannot drive", kase["name"], lacking)
|
|
776
|
+
continue
|
|
777
|
+
}
|
|
778
|
+
|
|
486
779
|
if missing := fcMissingFeature(kase, have); missing != "" {
|
|
487
780
|
t.Logf("skip %q: needs the %s feature, which this SDK does not generate",
|
|
488
781
|
kase["name"], missing)
|
|
@@ -493,16 +786,37 @@ func TestFeatureCorpus(t *testing.T) {
|
|
|
493
786
|
for i := 0; i < need; i++ {
|
|
494
787
|
tokens[fmt.Sprintf("#OP%d", i+1)] = ops[i].key
|
|
495
788
|
}
|
|
789
|
+
if wantsPair {
|
|
790
|
+
tokens["#READ"] = pairRead.key
|
|
791
|
+
tokens["#WRITE"] = pairWrite.key
|
|
792
|
+
if hasItem {
|
|
793
|
+
tokens["#ITEM"] = pairItem.key
|
|
794
|
+
}
|
|
795
|
+
if hasOther {
|
|
796
|
+
tokens["#OTHER"] = pairOther.key
|
|
797
|
+
}
|
|
798
|
+
}
|
|
496
799
|
resolved, _ := fcResolve(kase, tokens).(map[string]any)
|
|
497
800
|
|
|
498
801
|
byKey := map[string]fcOp{}
|
|
499
802
|
for _, o := range ops {
|
|
500
803
|
byKey[o.key] = o
|
|
501
804
|
}
|
|
805
|
+
if paired {
|
|
806
|
+
byKey[pairRead.key] = pairRead
|
|
807
|
+
byKey[pairWrite.key] = pairWrite
|
|
808
|
+
if hasItem {
|
|
809
|
+
byKey[pairItem.key] = pairItem
|
|
810
|
+
}
|
|
811
|
+
}
|
|
502
812
|
|
|
503
|
-
|
|
813
|
+
sent := &fcSent{}
|
|
814
|
+
client := fcClientSent(resolved, sent)
|
|
504
815
|
label, _ := resolved["name"].(string)
|
|
505
816
|
|
|
817
|
+
// A case-level ctrl is one control object every step shares.
|
|
818
|
+
shared, _ := resolved["ctrl"].(map[string]any)
|
|
819
|
+
|
|
506
820
|
steps, _ := resolved["op"].([]any)
|
|
507
821
|
for _, rawstep := range steps {
|
|
508
822
|
step, _ := rawstep.(map[string]any)
|
|
@@ -516,40 +830,55 @@ func TestFeatureCorpus(t *testing.T) {
|
|
|
516
830
|
continue
|
|
517
831
|
}
|
|
518
832
|
ctrl := map[string]any{}
|
|
833
|
+
if shared != nil {
|
|
834
|
+
ctrl = shared
|
|
835
|
+
}
|
|
519
836
|
if c, ok := step["ctrl"].(map[string]any); ok {
|
|
520
837
|
ctrl = c
|
|
521
838
|
}
|
|
522
839
|
|
|
523
|
-
err := fcInvoke(client, op, ctrl)
|
|
524
840
|
wanterr, haserr := step["err"]
|
|
525
841
|
|
|
526
|
-
|
|
527
|
-
if
|
|
528
|
-
|
|
842
|
+
for _, err := range fcCalls(client, op, step, ctrl) {
|
|
843
|
+
if !haserr {
|
|
844
|
+
if err != nil {
|
|
845
|
+
t.Errorf("%s: %s failed unexpectedly: %v", label, opkey, err)
|
|
846
|
+
}
|
|
847
|
+
continue
|
|
529
848
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
t.Errorf("%s: %s was expected to fail, and did not", label, opkey)
|
|
534
|
-
continue
|
|
535
|
-
}
|
|
536
|
-
if code, ok := wanterr.(string); ok {
|
|
537
|
-
// The CODE, not the message. The message is prefixed
|
|
538
|
-
// and humanised by makeError, so matching its text
|
|
539
|
-
// would pass on any error that happened to mention
|
|
540
|
-
// the word.
|
|
541
|
-
got := ""
|
|
542
|
-
var sdkerr *sdk.ProjectNameError
|
|
543
|
-
if errors.As(err, &sdkerr) {
|
|
544
|
-
got = sdkerr.Code
|
|
849
|
+
if err == nil {
|
|
850
|
+
t.Errorf("%s: %s was expected to fail, and did not", label, opkey)
|
|
851
|
+
continue
|
|
545
852
|
}
|
|
546
|
-
if
|
|
547
|
-
|
|
548
|
-
|
|
853
|
+
if code, ok := wanterr.(string); ok {
|
|
854
|
+
// The CODE, not the message. The message is prefixed
|
|
855
|
+
// and humanised by makeError, so matching its text
|
|
856
|
+
// would pass on any error that happened to mention
|
|
857
|
+
// the word.
|
|
858
|
+
got := ""
|
|
859
|
+
var sdkerr *sdk.ProjectNameError
|
|
860
|
+
if errors.As(err, &sdkerr) {
|
|
861
|
+
got = sdkerr.Code
|
|
862
|
+
}
|
|
863
|
+
if got != code {
|
|
864
|
+
t.Errorf("%s: wrong error code: got %q (%v), want %q",
|
|
865
|
+
label, got, err, code)
|
|
866
|
+
}
|
|
549
867
|
}
|
|
550
868
|
}
|
|
551
869
|
}
|
|
552
870
|
|
|
871
|
+
if pace, ok := resolved["pace"].(map[string]any); ok {
|
|
872
|
+
ms, _ := fcNum(pace["ms"])
|
|
873
|
+
max, _ := fcNum(pace["max"])
|
|
874
|
+
if most := sent.fcBusiest(int64(ms)); most > int(max) {
|
|
875
|
+
t.Errorf("%s: %d requests within %v ms, want at most %v", label, most, ms, max)
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
if expect, ok := resolved["sent"].([]any); ok {
|
|
880
|
+
fcCheckSent(t, sent.url, expect, label)
|
|
881
|
+
}
|
|
553
882
|
fcSubset(t, fcRecord(client, name), resolved["out"], label+": _"+name)
|
|
554
883
|
ran++
|
|
555
884
|
}
|
|
@@ -3,6 +3,7 @@ package sdktest
|
|
|
3
3
|
import (
|
|
4
4
|
"encoding/json"
|
|
5
5
|
"errors"
|
|
6
|
+
"fmt"
|
|
6
7
|
"os"
|
|
7
8
|
"reflect"
|
|
8
9
|
"regexp"
|
|
@@ -645,6 +646,67 @@ func TestFeatureCache(t *testing.T) {
|
|
|
645
646
|
}
|
|
646
647
|
})
|
|
647
648
|
|
|
649
|
+
t.Run("keys-on-request-headers", func(t *testing.T) {
|
|
650
|
+
rec := &fhRecorder{}
|
|
651
|
+
h := fhMake(rec.fetch, fhF(feat.NewCacheFeature(), map[string]any{"ttl": 10000}))
|
|
652
|
+
h.op(fhOpSpec{op: "load", path: "/w/1", headers: map[string]any{"x-tenant": "tenant-a"}})
|
|
653
|
+
h.op(fhOpSpec{op: "load", path: "/w/1", headers: map[string]any{"X-Tenant": "tenant-b"}})
|
|
654
|
+
if len(rec.calls) != 2 {
|
|
655
|
+
t.Errorf("a second tenant was served the first tenant's entry: %d calls", len(rec.calls))
|
|
656
|
+
}
|
|
657
|
+
h.op(fhOpSpec{op: "load", path: "/w/1", headers: map[string]any{"x-tenant": "tenant-b"}})
|
|
658
|
+
if len(rec.calls) != 2 {
|
|
659
|
+
t.Errorf("the same headers did not share an entry: %d calls", len(rec.calls))
|
|
660
|
+
}
|
|
661
|
+
})
|
|
662
|
+
|
|
663
|
+
t.Run("a-write-drops-its-collection", func(t *testing.T) {
|
|
664
|
+
rec := &fhRecorder{}
|
|
665
|
+
h := fhMake(rec.fetch, fhF(feat.NewCacheFeature(), map[string]any{"ttl": 10000}))
|
|
666
|
+
paths := []string{"/w/1", "/w", "/w/1/part", "/other/1", "/w/2"}
|
|
667
|
+
for _, p := range paths {
|
|
668
|
+
h.op(fhOpSpec{op: "load", path: p})
|
|
669
|
+
}
|
|
670
|
+
h.op(fhOpSpec{op: "update", method: "PUT", path: "/w/1"})
|
|
671
|
+
for _, p := range paths {
|
|
672
|
+
h.op(fhOpSpec{op: "load", path: p})
|
|
673
|
+
}
|
|
674
|
+
if len(rec.calls) != 9 {
|
|
675
|
+
t.Errorf("expected the collection refetched and /other cached: %d calls", len(rec.calls))
|
|
676
|
+
}
|
|
677
|
+
})
|
|
678
|
+
|
|
679
|
+
t.Run("cache-control-prevents-storing", func(t *testing.T) {
|
|
680
|
+
for _, control := range []string{"no-store", "private", "No-Cache", "max-age=60, private"} {
|
|
681
|
+
rec := &fhRecorder{reply: func(_ int, _ map[string]any) (any, error) {
|
|
682
|
+
return fhResponse(200, map[string]any{"ok": true}, map[string]any{"Cache-Control": control}), nil
|
|
683
|
+
}}
|
|
684
|
+
h := fhMake(rec.fetch, fhF(feat.NewCacheFeature(), map[string]any{"ttl": 10000}))
|
|
685
|
+
h.op(fhOpSpec{op: "load", path: "/w"})
|
|
686
|
+
h.op(fhOpSpec{op: "load", path: "/w"})
|
|
687
|
+
if len(rec.calls) != 2 {
|
|
688
|
+
t.Errorf("%s was stored: %d calls", control, len(rec.calls))
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
})
|
|
692
|
+
|
|
693
|
+
t.Run("max-age-caps-the-ttl", func(t *testing.T) {
|
|
694
|
+
clock := &fhClock{}
|
|
695
|
+
rec := &fhRecorder{reply: func(_ int, _ map[string]any) (any, error) {
|
|
696
|
+
return fhResponse(200, map[string]any{"ok": true}, map[string]any{"cache-control": "max-age=1"}), nil
|
|
697
|
+
}}
|
|
698
|
+
h := fhMake(rec.fetch, fhF(feat.NewCacheFeature(),
|
|
699
|
+
map[string]any{"ttl": 10000, "now": clock.now}))
|
|
700
|
+
h.op(fhOpSpec{op: "load", path: "/w"})
|
|
701
|
+
clock.advance(500)
|
|
702
|
+
h.op(fhOpSpec{op: "load", path: "/w"})
|
|
703
|
+
clock.advance(600)
|
|
704
|
+
h.op(fhOpSpec{op: "load", path: "/w"})
|
|
705
|
+
if len(rec.calls) != 2 {
|
|
706
|
+
t.Errorf("expected max-age=1 to expire the entry before the ttl: %d calls", len(rec.calls))
|
|
707
|
+
}
|
|
708
|
+
})
|
|
709
|
+
|
|
648
710
|
t.Run("inactive-does-not-wrap", func(t *testing.T) {
|
|
649
711
|
rec := &fhRecorder{}
|
|
650
712
|
h := fhMake(rec.fetch, fhF(feat.NewCacheFeature(), map[string]any{"active": false}))
|
|
@@ -818,6 +880,23 @@ func TestFeatureMetrics(t *testing.T) {
|
|
|
818
880
|
}
|
|
819
881
|
})
|
|
820
882
|
|
|
883
|
+
t.Run("sink-gets-counters-once-per-op", func(t *testing.T) {
|
|
884
|
+
var seen []map[string]any
|
|
885
|
+
f := feat.NewMetricsFeature()
|
|
886
|
+
h := fhMake(nil, fhF(f, map[string]any{
|
|
887
|
+
"sink": (func(map[string]any))(func(m map[string]any) { seen = append(seen, m) }),
|
|
888
|
+
}))
|
|
889
|
+
h.op(fhOpSpec{op: "load"})
|
|
890
|
+
h.op(fhOpSpec{op: "list"})
|
|
891
|
+
if len(seen) != 2 {
|
|
892
|
+
t.Fatalf("expected 2 sink calls, got %d", len(seen))
|
|
893
|
+
}
|
|
894
|
+
total, _ := seen[1]["total"].(map[string]any)
|
|
895
|
+
if fmt.Sprint(total["count"]) != "2" {
|
|
896
|
+
t.Errorf("expected count 2 at the second call, got %v", total["count"])
|
|
897
|
+
}
|
|
898
|
+
})
|
|
899
|
+
|
|
821
900
|
t.Run("injected-clock", func(t *testing.T) {
|
|
822
901
|
clock := &fhClock{}
|
|
823
902
|
f := feat.NewMetricsFeature()
|
|
@@ -901,6 +980,20 @@ func TestFeatureTelemetry(t *testing.T) {
|
|
|
901
980
|
}
|
|
902
981
|
})
|
|
903
982
|
|
|
983
|
+
t.Run("default-ids-are-w3c", func(t *testing.T) {
|
|
984
|
+
f := feat.NewTelemetryFeature()
|
|
985
|
+
h := fhMake(nil, fhF(f, nil))
|
|
986
|
+
h.op(fhOpSpec{op: "load"})
|
|
987
|
+
trace, _ := f.Spans[0]["traceId"].(string)
|
|
988
|
+
span, _ := f.Spans[0]["spanId"].(string)
|
|
989
|
+
if !regexp.MustCompile(`^[0-9a-f]{32}$`).MatchString(trace) || strings.Trim(trace, "0") == "" {
|
|
990
|
+
t.Errorf("trace id is not W3C: %q", trace)
|
|
991
|
+
}
|
|
992
|
+
if !regexp.MustCompile(`^[0-9a-f]{16}$`).MatchString(span) || strings.Trim(span, "0") == "" {
|
|
993
|
+
t.Errorf("span id is not W3C: %q", span)
|
|
994
|
+
}
|
|
995
|
+
})
|
|
996
|
+
|
|
904
997
|
t.Run("inactive-records-nothing", func(t *testing.T) {
|
|
905
998
|
f := feat.NewTelemetryFeature()
|
|
906
999
|
h := fhMake(nil, fhF(f, map[string]any{"active": false}))
|
|
@@ -151,15 +151,13 @@ func makeCleanConfig(cleanopts map[string]any) *cleanConfig {
|
|
|
151
151
|
return cfg
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
// The
|
|
155
|
-
//
|
|
154
|
+
// The registry makeOptions builds; a context without one (makeError is
|
|
155
|
+
// reached with a bare one) falls back to the schema defaults, so nothing
|
|
156
156
|
// leaves raw for want of a constructor.
|
|
157
157
|
func cleanConfigOf(ctx *core.Context) *cleanConfig {
|
|
158
|
-
if ctx != nil
|
|
159
|
-
if
|
|
160
|
-
|
|
161
|
-
return cfg
|
|
162
|
-
}
|
|
158
|
+
if ctx != nil {
|
|
159
|
+
if cfg, ok := ctx.CleanCfg.(*cleanConfig); ok {
|
|
160
|
+
return cfg
|
|
163
161
|
}
|
|
164
162
|
}
|
|
165
163
|
spec, _ := core.OPTSPEC["clean"].(map[string]any)
|
|
@@ -13,6 +13,7 @@ import (
|
|
|
13
13
|
"os"
|
|
14
14
|
"strings"
|
|
15
15
|
"sync"
|
|
16
|
+
"time"
|
|
16
17
|
|
|
17
18
|
vs "github.com/voxgig/struct"
|
|
18
19
|
|
|
@@ -49,6 +50,10 @@ func clientFor(ctx *core.Context, fetchdef map[string]any) *http.Client {
|
|
|
49
50
|
// A shallow copy shares the pooled Transport; only CheckRedirect differs.
|
|
50
51
|
policy := *client
|
|
51
52
|
policy.CheckRedirect = followRedirect(ctx)
|
|
53
|
+
// A bound in milliseconds, for a caller beneath the timeout feature.
|
|
54
|
+
if ms := core.ToInt(fetchdef["timeout"]); 0 < ms {
|
|
55
|
+
policy.Timeout = time.Duration(ms) * time.Millisecond
|
|
56
|
+
}
|
|
52
57
|
if redirect, ok := fetchdef["redirect"].(string); ok && redirect == "manual" {
|
|
53
58
|
policy.CheckRedirect = func(req *http.Request, via []*http.Request) error {
|
|
54
59
|
return http.ErrUseLastResponse
|
|
@@ -266,6 +271,12 @@ func decodeBody(body []byte, encoding string) ([]byte, error) {
|
|
|
266
271
|
return out, nil
|
|
267
272
|
}
|
|
268
273
|
|
|
274
|
+
// Fetcher is the SDK's own transport, for a feature that must send beneath
|
|
275
|
+
// the wrappers installed over it.
|
|
276
|
+
func Fetcher(ctx *core.Context, fullurl string, fetchdef map[string]any) (any, error) {
|
|
277
|
+
return fetcherUtil(ctx, fullurl, fetchdef)
|
|
278
|
+
}
|
|
279
|
+
|
|
269
280
|
func fetcherUtil(ctx *core.Context, fullurl string, fetchdef map[string]any) (any, error) {
|
|
270
281
|
if ctx.Client.Mode != "live" {
|
|
271
282
|
return nil, ctx.MakeError("fetch_mode_block",
|