@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
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
import json
|
|
17
17
|
import os
|
|
18
18
|
import re
|
|
19
|
+
import threading
|
|
20
|
+
import time
|
|
21
|
+
from urllib.parse import parse_qsl, urlsplit
|
|
19
22
|
|
|
20
23
|
import pytest
|
|
21
24
|
|
|
@@ -47,19 +50,28 @@ def _load_corpus():
|
|
|
47
50
|
return json.loads(f.read())
|
|
48
51
|
|
|
49
52
|
|
|
50
|
-
def _scripted_fetcher(res):
|
|
53
|
+
def _scripted_fetcher(res, sent=None, at=None):
|
|
51
54
|
"""A scripted transport built from a case's `res` list.
|
|
52
55
|
|
|
53
56
|
Responses are consumed in order and the last one repeats, so a case that
|
|
54
|
-
does not care how many attempts happen need only declare one.
|
|
57
|
+
does not care how many attempts happen need only declare one. Each URL it
|
|
58
|
+
is sent is kept in `sent`, and when it arrived in `at`; a `cut` response
|
|
59
|
+
is one whose body stops before its end.
|
|
55
60
|
"""
|
|
56
61
|
state = {"n": -1}
|
|
62
|
+
lock = threading.Lock()
|
|
63
|
+
sent = [] if sent is None else sent
|
|
64
|
+
at = [] if at is None else at
|
|
57
65
|
|
|
58
66
|
def fetcher(ctx, fullurl, fetchdef):
|
|
59
|
-
|
|
67
|
+
with lock:
|
|
68
|
+
state["n"] += 1
|
|
69
|
+
n = state["n"]
|
|
70
|
+
sent.append(fullurl)
|
|
71
|
+
at.append(time.monotonic() * 1000)
|
|
60
72
|
spec = {}
|
|
61
73
|
if res:
|
|
62
|
-
i =
|
|
74
|
+
i = n
|
|
63
75
|
if i >= len(res):
|
|
64
76
|
i = len(res) - 1
|
|
65
77
|
spec = res[i] or {}
|
|
@@ -77,6 +89,17 @@ def _scripted_fetcher(res):
|
|
|
77
89
|
if spec.get("throw") is True:
|
|
78
90
|
return None, RuntimeError("scripted transport failure")
|
|
79
91
|
|
|
92
|
+
if spec.get("cut") is True:
|
|
93
|
+
raw = json.dumps(body)
|
|
94
|
+
return {
|
|
95
|
+
"status": status,
|
|
96
|
+
"statusText": "OK" if status < 400 else "ERR",
|
|
97
|
+
"headers": dict(spec.get("headers") or {}),
|
|
98
|
+
"json": (lambda: None),
|
|
99
|
+
"body": raw[:len(raw) // 2],
|
|
100
|
+
"unreadable": True,
|
|
101
|
+
}, None
|
|
102
|
+
|
|
80
103
|
return {
|
|
81
104
|
"status": status,
|
|
82
105
|
"statusText": "OK" if status < 400 else "ERR",
|
|
@@ -88,7 +111,7 @@ def _scripted_fetcher(res):
|
|
|
88
111
|
return fetcher
|
|
89
112
|
|
|
90
113
|
|
|
91
|
-
def _client(kase):
|
|
114
|
+
def _client(kase, sent=None, at=None):
|
|
92
115
|
"""Build a client the way a caller would.
|
|
93
116
|
|
|
94
117
|
ProjectNameSDK(...), not ProjectNameSDK.test(...): the `test` feature is
|
|
@@ -103,7 +126,7 @@ def _client(kase):
|
|
|
103
126
|
# would shadow it, which is why this cannot just turn the feature on.
|
|
104
127
|
opts = {
|
|
105
128
|
"test": {"active": True},
|
|
106
|
-
"utility": {"fetcher": _scripted_fetcher(kase.get("res"))},
|
|
129
|
+
"utility": {"fetcher": _scripted_fetcher(kase.get("res"), sent, at)},
|
|
107
130
|
}
|
|
108
131
|
if kase.get("feature") is not None:
|
|
109
132
|
opts["feature"] = kase["feature"]
|
|
@@ -158,9 +181,25 @@ def _candidates(client):
|
|
|
158
181
|
return out
|
|
159
182
|
|
|
160
183
|
|
|
161
|
-
def _invoke(client, op, ctrl):
|
|
184
|
+
def _invoke(client, op, ctrl, args=None):
|
|
162
185
|
ent = getattr(client, op["accessor"])()
|
|
163
|
-
return getattr(ent, op["op"])({}, ctrl)
|
|
186
|
+
return getattr(ent, op["op"])(dict(args or {}), ctrl)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
ITEM_ARGS = {"id": "corpus-item"}
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def _usable_item(accessor):
|
|
193
|
+
"""A write of one entity (#ITEM) that completes when driven with ITEM_ARGS."""
|
|
194
|
+
for cand in _candidates(_client({})):
|
|
195
|
+
if cand["accessor"] != accessor or cand["op"] not in ("update", "patch", "remove"):
|
|
196
|
+
continue
|
|
197
|
+
try:
|
|
198
|
+
_invoke(_client({}), cand, {}, ITEM_ARGS)
|
|
199
|
+
except Exception:
|
|
200
|
+
continue
|
|
201
|
+
return cand
|
|
202
|
+
return None
|
|
164
203
|
|
|
165
204
|
|
|
166
205
|
def _usable_ops(want):
|
|
@@ -183,6 +222,103 @@ def _usable_ops(want):
|
|
|
183
222
|
return picked
|
|
184
223
|
|
|
185
224
|
|
|
225
|
+
READ_OPS = ("list", "load")
|
|
226
|
+
WRITE_OPS = ("create", "update", "patch", "remove")
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def _usable_pair():
|
|
230
|
+
"""A read and a write of one entity (#READ, #WRITE), each driven as
|
|
231
|
+
_usable_ops drives an op."""
|
|
232
|
+
found = {}
|
|
233
|
+
for cand in _candidates(_client({})):
|
|
234
|
+
role = "read" if cand["op"] in READ_OPS else "write" if cand["op"] in WRITE_OPS else None
|
|
235
|
+
seen = found.setdefault(cand["accessor"], {})
|
|
236
|
+
if role is None or role in seen:
|
|
237
|
+
continue
|
|
238
|
+
try:
|
|
239
|
+
_invoke(_client({}), cand, {})
|
|
240
|
+
except Exception:
|
|
241
|
+
continue
|
|
242
|
+
seen[role] = cand
|
|
243
|
+
if "read" in seen and "write" in seen:
|
|
244
|
+
return seen
|
|
245
|
+
return None
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def _stream(client, op, ctrl, args=None):
|
|
249
|
+
"""Read one operation through the entity's stream(); how many it yields."""
|
|
250
|
+
ent = getattr(client, op["accessor"])()
|
|
251
|
+
return sum(1 for _ in ent.stream(op["op"], dict(args or {}), {"ctrl": ctrl}))
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def _check_sent(sent, expect, label):
|
|
255
|
+
"""Each request a case expects, in order: its path, and its whole query.
|
|
256
|
+
A path is compared without its leading slash, which an SDK with no base
|
|
257
|
+
omits."""
|
|
258
|
+
assert len(sent) == len(expect), \
|
|
259
|
+
"{}: {} request(s) sent, want {}: {}".format(label, len(sent), len(expect), " | ".join(sent))
|
|
260
|
+
for i, want in enumerate(expect):
|
|
261
|
+
url = urlsplit(sent[i])
|
|
262
|
+
if want.get("path") is not None:
|
|
263
|
+
assert url.path.lstrip("/") == want["path"].lstrip("/"), \
|
|
264
|
+
"{}: request {} path: got {!r}, want {!r}".format(label, i, url.path, want["path"])
|
|
265
|
+
if want.get("query") is not None:
|
|
266
|
+
query = dict(parse_qsl(url.query, keep_blank_values=True))
|
|
267
|
+
assert query == want["query"], \
|
|
268
|
+
"{}: request {} query: got {!r}, want {!r}".format(label, i, query, want["query"])
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def _step(client, op, step, ctrl):
|
|
272
|
+
"""One step: it may wait before its call, may add request headers for
|
|
273
|
+
its call, and may pass `args` as the operation's first argument. A
|
|
274
|
+
`stream` step reads the operation through stream(), and `items` is how
|
|
275
|
+
many it yields."""
|
|
276
|
+
if step.get("wait") is not None:
|
|
277
|
+
time.sleep(step["wait"] / 1000.0)
|
|
278
|
+
options = client._rootctx.options
|
|
279
|
+
prior = options.get("headers")
|
|
280
|
+
if step.get("headers") is not None:
|
|
281
|
+
options["headers"] = dict(prior or {}, **step["headers"])
|
|
282
|
+
try:
|
|
283
|
+
if step.get("stream") is True:
|
|
284
|
+
items = _stream(client, op, ctrl, step.get("args"))
|
|
285
|
+
if step.get("items") is not None:
|
|
286
|
+
assert items == step["items"], \
|
|
287
|
+
"{}: streamed {} item(s), want {}".format(op["key"], items, step["items"])
|
|
288
|
+
return items
|
|
289
|
+
return _invoke(client, op, ctrl, step.get("args"))
|
|
290
|
+
finally:
|
|
291
|
+
if step.get("headers") is not None:
|
|
292
|
+
if prior is None:
|
|
293
|
+
options.pop("headers", None)
|
|
294
|
+
else:
|
|
295
|
+
options["headers"] = prior
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
def _calls(client, op, step, ctrl):
|
|
299
|
+
"""Run a step once, or with `together: N` as N overlapping calls, and
|
|
300
|
+
return each call's exception or None."""
|
|
301
|
+
errs = [None] * int(step.get("together") or 1)
|
|
302
|
+
|
|
303
|
+
def call(i):
|
|
304
|
+
try:
|
|
305
|
+
_step(client, op, step, ctrl)
|
|
306
|
+
except Exception as err:
|
|
307
|
+
errs[i] = err
|
|
308
|
+
|
|
309
|
+
threads = [threading.Thread(target=call, args=(i,)) for i in range(len(errs))]
|
|
310
|
+
for t in threads:
|
|
311
|
+
t.start()
|
|
312
|
+
for t in threads:
|
|
313
|
+
t.join()
|
|
314
|
+
return errs
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
def _busiest(sent, ms):
|
|
318
|
+
"""The most requests seen in any window of `ms`."""
|
|
319
|
+
return max([len([t for t in sent if start <= t < start + ms]) for start in sent], default=0)
|
|
320
|
+
|
|
321
|
+
|
|
186
322
|
def _resolve(node, tokens):
|
|
187
323
|
"""Replace #OPn throughout a case, keys included."""
|
|
188
324
|
if isinstance(node, str):
|
|
@@ -228,6 +364,13 @@ def _subset(actual, expect, path):
|
|
|
228
364
|
_subset(got, want, "{}.{}".format(path, k))
|
|
229
365
|
return
|
|
230
366
|
|
|
367
|
+
if isinstance(expect, list):
|
|
368
|
+
assert isinstance(actual, list) and len(actual) == len(expect), \
|
|
369
|
+
"{}: want {} item(s), got {!r}".format(path, len(expect), actual)
|
|
370
|
+
for i, want in enumerate(expect):
|
|
371
|
+
_subset(actual[i], want, "{}[{}]".format(path, i))
|
|
372
|
+
return
|
|
373
|
+
|
|
231
374
|
if isinstance(expect, bool) or not isinstance(expect, (int, float)):
|
|
232
375
|
assert actual == expect, "{}: got {!r}, want {!r}".format(path, actual, expect)
|
|
233
376
|
return
|
|
@@ -315,6 +458,14 @@ class TestFeatureCorpus:
|
|
|
315
458
|
|
|
316
459
|
ops = _usable_ops(2)
|
|
317
460
|
by_key = {o["key"]: o for o in ops}
|
|
461
|
+
pair = _usable_pair()
|
|
462
|
+
if pair is not None:
|
|
463
|
+
by_key[pair["read"]["key"]] = pair["read"]
|
|
464
|
+
by_key[pair["write"]["key"]] = pair["write"]
|
|
465
|
+
pair["item"] = _usable_item(pair["read"]["accessor"])
|
|
466
|
+
if pair["item"] is not None:
|
|
467
|
+
by_key[pair["item"]["key"]] = pair["item"]
|
|
468
|
+
pair["other"] = next((o for o in ops if o["accessor"] != pair["read"]["accessor"]), None)
|
|
318
469
|
|
|
319
470
|
ran = 0
|
|
320
471
|
failed = []
|
|
@@ -326,6 +477,18 @@ class TestFeatureCorpus:
|
|
|
326
477
|
raw.get("name"), need, len(ops)))
|
|
327
478
|
continue
|
|
328
479
|
|
|
480
|
+
paired = re.search(r"#(READ|WRITE|ITEM|OTHER)\b", json.dumps(raw)) is not None
|
|
481
|
+
if paired and pair is None:
|
|
482
|
+
print('skip "{}": needs a read and a write of one entity, this SDK offers none'.format(
|
|
483
|
+
raw.get("name")))
|
|
484
|
+
continue
|
|
485
|
+
lacking = next((tok for tok, role in (("#ITEM", "item"), ("#OTHER", "other"))
|
|
486
|
+
if paired and pair[role] is None
|
|
487
|
+
and re.search(tok + r"\b", json.dumps(raw))), None)
|
|
488
|
+
if lacking is not None:
|
|
489
|
+
print('skip "{}": needs {}, which this SDK cannot drive'.format(raw.get("name"), lacking))
|
|
490
|
+
continue
|
|
491
|
+
|
|
329
492
|
missing = _missing_feature(raw, have)
|
|
330
493
|
if missing is not None:
|
|
331
494
|
print('skip "{}": needs the {} feature, which this SDK does not generate'.format(
|
|
@@ -335,27 +498,35 @@ class TestFeatureCorpus:
|
|
|
335
498
|
tokens = {}
|
|
336
499
|
for i in range(need):
|
|
337
500
|
tokens["#OP{}".format(i + 1)] = ops[i]["key"]
|
|
501
|
+
if paired:
|
|
502
|
+
tokens["#READ"] = pair["read"]["key"]
|
|
503
|
+
tokens["#WRITE"] = pair["write"]["key"]
|
|
504
|
+
for tok, role in (("#ITEM", "item"), ("#OTHER", "other")):
|
|
505
|
+
if pair[role] is not None:
|
|
506
|
+
tokens[tok] = pair[role]["key"]
|
|
338
507
|
kase = _resolve(raw, tokens)
|
|
339
508
|
label = kase.get("name")
|
|
340
509
|
ran += 1
|
|
341
510
|
|
|
342
511
|
# Every failing case is reported, not only the first.
|
|
343
512
|
try:
|
|
344
|
-
|
|
513
|
+
sent = []
|
|
514
|
+
at = []
|
|
515
|
+
client = _client(kase, sent, at)
|
|
345
516
|
|
|
517
|
+
# A case-level ctrl is one control object every step shares.
|
|
518
|
+
shared = kase.get("ctrl")
|
|
346
519
|
for step in (kase.get("op") or []):
|
|
347
520
|
op = by_key.get(step["op"])
|
|
348
521
|
assert op is not None, "{}: no operation {}".format(label, step["op"])
|
|
349
|
-
ctrl = step.get("ctrl") or {}
|
|
522
|
+
ctrl = step.get("ctrl") or (shared if shared is not None else {})
|
|
350
523
|
wanterr = step.get("err")
|
|
351
524
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
raise
|
|
358
|
-
except Exception as err:
|
|
525
|
+
for err in _calls(client, op, step, ctrl):
|
|
526
|
+
if err is None:
|
|
527
|
+
assert wanterr is None, \
|
|
528
|
+
"{}: {} was expected to fail, and did not".format(label, step["op"])
|
|
529
|
+
continue
|
|
359
530
|
assert wanterr is not None, \
|
|
360
531
|
"{}: {} failed unexpectedly: {}".format(label, step["op"], err)
|
|
361
532
|
if isinstance(wanterr, str):
|
|
@@ -367,6 +538,15 @@ class TestFeatureCorpus:
|
|
|
367
538
|
"{}: wrong error code: got {!r} ({}), want {!r}".format(
|
|
368
539
|
label, code, err, wanterr)
|
|
369
540
|
|
|
541
|
+
pace = kase.get("pace")
|
|
542
|
+
if pace is not None:
|
|
543
|
+
most = _busiest(at, pace["ms"])
|
|
544
|
+
assert most <= pace["max"], \
|
|
545
|
+
"{}: {} requests within {} ms, want at most {}".format(
|
|
546
|
+
label, most, pace["ms"], pace["max"])
|
|
547
|
+
|
|
548
|
+
if kase.get("sent") is not None:
|
|
549
|
+
_check_sent(sent, kase["sent"], label)
|
|
370
550
|
_subset(_record(client, name), kase.get("out"), "{}: _{}".format(label, name))
|
|
371
551
|
except Exception as err:
|
|
372
552
|
msg = str(err)
|
|
@@ -163,13 +163,16 @@ def _next_ctrl(paging: dict) -> dict | None:
|
|
|
163
163
|
if cursor is not None:
|
|
164
164
|
return {"paging": {"cursor": cursor}}
|
|
165
165
|
|
|
166
|
+
# A next link (a body `next` URL or `Link: rel="next"`): the paging
|
|
167
|
+
# feature builds the next request from it.
|
|
168
|
+
nxt = paging.get("next")
|
|
169
|
+
if nxt is not None:
|
|
170
|
+
return {"paging": {"next": nxt}}
|
|
171
|
+
|
|
166
172
|
next_page = paging.get("nextPage")
|
|
167
173
|
if next_page is not None:
|
|
168
174
|
return {"paging": {"page": next_page}}
|
|
169
175
|
|
|
170
|
-
# A `Link: rel="next"` URL with no cursor/page extracted is not something
|
|
171
|
-
# we can turn into a ctrl — the SDK builds its own request URLs. Rather
|
|
172
|
-
# than guess at query parsing, stop and keep what we have.
|
|
173
176
|
return None
|
|
174
177
|
|
|
175
178
|
|
|
@@ -30,10 +30,10 @@ class FakeClient:
|
|
|
30
30
|
return rows
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
def paging(has_more=False, cursor=None, next_page=None):
|
|
33
|
+
def paging(has_more=False, cursor=None, next_page=None, next_link=None):
|
|
34
34
|
return {
|
|
35
35
|
"page": None, "totalCount": None, "nextPage": next_page,
|
|
36
|
-
"next":
|
|
36
|
+
"next": next_link, "cursor": cursor, "hasMore": has_more,
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
|
|
@@ -125,9 +125,12 @@ class TestDrain:
|
|
|
125
125
|
rows = drain(c.call, c, max_pages=3, quiet=True)
|
|
126
126
|
assert len(rows) == 3
|
|
127
127
|
|
|
128
|
+
def test_a_next_link_is_passed_on(self):
|
|
129
|
+
# The paging feature builds the next request from the link.
|
|
130
|
+
nxt = _next_ctrl(paging(has_more=True, next_link="/w?after=b3", next_page=5))
|
|
131
|
+
assert nxt == {"paging": {"next": "/w?after=b3"}}
|
|
132
|
+
|
|
128
133
|
def test_has_more_without_a_usable_token_stops(self):
|
|
129
|
-
# A Link: rel="next" URL with no cursor/page is not something we can
|
|
130
|
-
# turn into a ctrl; stopping beats guessing at query parsing.
|
|
131
134
|
c = FakeClient([([{"a": 1}], paging(has_more=True))])
|
|
132
135
|
rows = drain(c.call, c, quiet=True)
|
|
133
136
|
assert len(rows) == 1
|
|
@@ -15,7 +15,7 @@ class ProjectNameContext
|
|
|
15
15
|
OPMAP_LOCK = Mutex.new
|
|
16
16
|
|
|
17
17
|
attr_accessor :id, :out, :client, :utility, :ctrl, :meta, :config,
|
|
18
|
-
:entopts, :options, :entity, :shared, :opmap,
|
|
18
|
+
:entopts, :options, :cleancfg, :entity, :shared, :opmap,
|
|
19
19
|
:data, :reqdata, :match, :reqmatch, :point,
|
|
20
20
|
:spec, :result, :response, :op, :unexpected_fired
|
|
21
21
|
|
|
@@ -53,6 +53,9 @@ class ProjectNameContext
|
|
|
53
53
|
o = ProjectNameHelpers.get_ctx_prop(ctxmap, "options")
|
|
54
54
|
@options = o.is_a?(Hash) ? o : basectx&.options
|
|
55
55
|
|
|
56
|
+
# The clean registry, beside the options rather than in them.
|
|
57
|
+
@cleancfg = ProjectNameHelpers.get_ctx_prop(ctxmap, "cleancfg") || basectx&.cleancfg
|
|
58
|
+
|
|
56
59
|
e = ProjectNameHelpers.get_ctx_prop(ctxmap, "entity")
|
|
57
60
|
@entity = e || basectx&.entity
|
|
58
61
|
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
require_relative 'base_feature'
|
|
13
13
|
|
|
14
14
|
class ProjectNameAuditFeature < ProjectNameBaseFeature
|
|
15
|
+
AUDIT_SEEN_KEY = "audit_seen"
|
|
16
|
+
|
|
15
17
|
def initialize
|
|
16
18
|
super
|
|
17
19
|
@version = "0.0.1"
|
|
@@ -21,7 +23,6 @@ class ProjectNameAuditFeature < ProjectNameBaseFeature
|
|
|
21
23
|
@client = nil
|
|
22
24
|
@options = {}
|
|
23
25
|
@seq = 0
|
|
24
|
-
@seen = {}
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
def init(ctx, options)
|
|
@@ -29,7 +30,6 @@ class ProjectNameAuditFeature < ProjectNameBaseFeature
|
|
|
29
30
|
@options = options.is_a?(Hash) ? options : {}
|
|
30
31
|
@active = @options["active"] == true
|
|
31
32
|
@seq = 0
|
|
32
|
-
@seen = {}
|
|
33
33
|
|
|
34
34
|
return unless @active
|
|
35
35
|
|
|
@@ -53,9 +53,10 @@ class ProjectNameAuditFeature < ProjectNameBaseFeature
|
|
|
53
53
|
|
|
54
54
|
def _emit(ctx, outcome)
|
|
55
55
|
# One record per operation (PreDone + a following PreUnexpected on a
|
|
56
|
-
# non-2xx must not double-log).
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
# non-2xx must not double-log). The marker lives on the context, so it
|
|
57
|
+
# goes when the call does.
|
|
58
|
+
return if ctx.out[AUDIT_SEEN_KEY] == true
|
|
59
|
+
ctx.out[AUDIT_SEEN_KEY] = true
|
|
59
60
|
@seq += 1
|
|
60
61
|
|
|
61
62
|
record = ctx.utility.clean.call(ctx, {
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
# ProjectName SDK cache feature
|
|
2
2
|
#
|
|
3
|
-
# Response caching for safe (read) requests
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
# 256, oldest evicted first) and every hit/miss/bypass is counted for
|
|
9
|
-
# inspection. Replayed responses expose a re-readable "json" body.
|
|
3
|
+
# Response caching for safe (read) requests, per client: see the features
|
|
4
|
+
# reference for the key, the write invalidation and the Cache-Control rules.
|
|
5
|
+
|
|
6
|
+
require 'openssl'
|
|
7
|
+
require 'securerandom'
|
|
10
8
|
|
|
11
9
|
require_relative 'base_feature'
|
|
12
10
|
require_relative '../utility/media'
|
|
13
11
|
|
|
14
12
|
class ProjectNameCacheFeature < ProjectNameBaseFeature
|
|
13
|
+
SAFE_METHODS = ["GET", "HEAD"].freeze
|
|
14
|
+
UNSTORED = ["no-store", "private", "no-cache"].freeze
|
|
15
|
+
MAX_AGE = /\Amax-age\s*=\s*"?(\d+)"?\z/
|
|
16
|
+
|
|
15
17
|
def initialize
|
|
16
18
|
super
|
|
17
19
|
@version = "0.0.1"
|
|
@@ -31,6 +33,7 @@ class ProjectNameCacheFeature < ProjectNameBaseFeature
|
|
|
31
33
|
return unless @active
|
|
32
34
|
|
|
33
35
|
@store = {}
|
|
36
|
+
@secret = SecureRandom.random_bytes(32)
|
|
34
37
|
|
|
35
38
|
feature = self
|
|
36
39
|
utility = ctx.utility
|
|
@@ -45,9 +48,17 @@ class ProjectNameCacheFeature < ProjectNameBaseFeature
|
|
|
45
48
|
method = ((fetchdef.is_a?(Hash) && fetchdef["method"]) || "GET").to_s.upcase
|
|
46
49
|
methods = @options["methods"] || ["GET"]
|
|
47
50
|
|
|
48
|
-
|
|
51
|
+
unless methods.include?(method)
|
|
52
|
+
return inner.call(ctx, url, fetchdef) if SAFE_METHODS.include?(method)
|
|
53
|
+
begin
|
|
54
|
+
return inner.call(ctx, url, fetchdef)
|
|
55
|
+
ensure
|
|
56
|
+
_invalidate(url)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
49
59
|
|
|
50
|
-
|
|
60
|
+
headers = fetchdef.is_a?(Hash) ? fetchdef["headers"] : nil
|
|
61
|
+
key = "#{method} #{url} #{_digest(headers)}"
|
|
51
62
|
now = _now
|
|
52
63
|
hit = @store[key]
|
|
53
64
|
|
|
@@ -66,9 +77,14 @@ class ProjectNameCacheFeature < ProjectNameBaseFeature
|
|
|
66
77
|
|
|
67
78
|
if err.nil? && _cacheable(res)
|
|
68
79
|
snapshot = _snapshot(res)
|
|
69
|
-
ttl = @options["ttl"].nil? ? 5000 : @options["ttl"]
|
|
80
|
+
ttl = self.class.lifetime(snapshot["headers"], @options["ttl"].nil? ? 5000 : @options["ttl"])
|
|
81
|
+
if ttl <= 0
|
|
82
|
+
_track("bypass")
|
|
83
|
+
return _replay(snapshot), nil
|
|
84
|
+
end
|
|
85
|
+
@store.delete(key)
|
|
70
86
|
_evict
|
|
71
|
-
@store[key] = { "expiry" => now + ttl, "snapshot" => snapshot }
|
|
87
|
+
@store[key] = { "expiry" => now + ttl, "scope" => self.class.scope(url), "snapshot" => snapshot }
|
|
72
88
|
_track("miss")
|
|
73
89
|
return _replay(snapshot), nil
|
|
74
90
|
end
|
|
@@ -77,6 +93,54 @@ class ProjectNameCacheFeature < ProjectNameBaseFeature
|
|
|
77
93
|
return res, err
|
|
78
94
|
end
|
|
79
95
|
|
|
96
|
+
def _digest(headers)
|
|
97
|
+
pairs = []
|
|
98
|
+
if headers.is_a?(Hash)
|
|
99
|
+
headers.each { |k, v| pairs << [k.to_s.downcase, v.to_s] unless v.nil? }
|
|
100
|
+
end
|
|
101
|
+
text = pairs.sort.map { |k, v| "#{k}:#{v}\n" }.join
|
|
102
|
+
OpenSSL::HMAC.hexdigest("SHA256", @secret, text)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def _invalidate(url)
|
|
106
|
+
path = self.class.scope(url)
|
|
107
|
+
collection = self.class.parent(path)
|
|
108
|
+
@store.delete_if do |_k, e|
|
|
109
|
+
self.class.under(e["scope"], path) || e["scope"] == collection
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# The configured ttl capped by the response's Cache-Control; zero when the
|
|
114
|
+
# response may not be stored.
|
|
115
|
+
def self.lifetime(headers, ttl)
|
|
116
|
+
control = ""
|
|
117
|
+
(headers || {}).each { |k, v| control = v.to_s if k.to_s.downcase == "cache-control" }
|
|
118
|
+
life = ttl
|
|
119
|
+
control.downcase.split(",").each do |part|
|
|
120
|
+
directive = part.strip
|
|
121
|
+
return 0 if UNSTORED.include?(directive)
|
|
122
|
+
age = MAX_AGE.match(directive)
|
|
123
|
+
life = [life, age[1].to_i * 1000].min unless age.nil?
|
|
124
|
+
end
|
|
125
|
+
life
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def self.scope(url)
|
|
129
|
+
url.to_s.split(/[?#]/, 2).first.to_s.sub(%r{/+\z}, "")
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def self.parent(scope)
|
|
133
|
+
scheme = scope.index("://")
|
|
134
|
+
root = scheme.nil? ? 0 : scope.index("/", scheme + 3)
|
|
135
|
+
return scope if root.nil?
|
|
136
|
+
cut = scope.rindex("/") || 0
|
|
137
|
+
scope[0, [cut, root].max]
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def self.under(scope, prefix)
|
|
141
|
+
scope == prefix || scope.start_with?(prefix + "/")
|
|
142
|
+
end
|
|
143
|
+
|
|
80
144
|
# A body the transport could not read as JSON passes through, for the operation to report.
|
|
81
145
|
def _cacheable(res)
|
|
82
146
|
return false unless res.is_a?(Hash)
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# timing. The SDK's own clean rules (clean.keys and every registered secret
|
|
6
6
|
# value) apply to the whole entry, and the "redact" option ADDS header names
|
|
7
7
|
# on top of them. An optional
|
|
8
|
-
# "
|
|
8
|
+
# "onEntry" callback receives each finished entry (e.g. to stream to a
|
|
9
9
|
# console). "max" caps the buffer (default 100). The clock is injectable
|
|
10
10
|
# ("now", ms) for deterministic tests.
|
|
11
11
|
|
|
@@ -113,7 +113,7 @@ class ProjectNameDebugFeature < ProjectNameBaseFeature
|
|
|
113
113
|
max = @options["max"].nil? ? 100 : @options["max"]
|
|
114
114
|
buf.shift while buf.length > max
|
|
115
115
|
|
|
116
|
-
on_entry = @options["
|
|
116
|
+
on_entry = @options["onEntry"]
|
|
117
117
|
if on_entry.is_a?(Proc)
|
|
118
118
|
begin
|
|
119
119
|
on_entry.call(entry)
|
|
@@ -74,6 +74,14 @@ class ProjectNameMetricsFeature < ProjectNameBaseFeature
|
|
|
74
74
|
|
|
75
75
|
_bump(m["total"], ok, dur)
|
|
76
76
|
_bump(op, ok, dur)
|
|
77
|
+
|
|
78
|
+
sink = @options["sink"]
|
|
79
|
+
if sink.is_a?(Proc)
|
|
80
|
+
begin
|
|
81
|
+
sink.call(ctx.utility.clean.call(ctx, m))
|
|
82
|
+
rescue StandardError
|
|
83
|
+
end
|
|
84
|
+
end
|
|
77
85
|
end
|
|
78
86
|
|
|
79
87
|
def _bump(bucket, ok, dur)
|