@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
|
@@ -2,6 +2,7 @@ package utility
|
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"encoding/json"
|
|
5
|
+
"errors"
|
|
5
6
|
"regexp"
|
|
6
7
|
"sort"
|
|
7
8
|
"strings"
|
|
@@ -87,9 +88,7 @@ func makeOptionsUtil(ctx *core.Context) (map[string]any, error) {
|
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
cleancfg := makeCleanConfig(cleanraw)
|
|
90
|
-
cleanctx := &core.Context{
|
|
91
|
-
"__derived__": map[string]any{"clean": cleancfg},
|
|
92
|
-
}}
|
|
91
|
+
cleanctx := &core.Context{CleanCfg: cleancfg}
|
|
93
92
|
cleanAddOptions(cleanctx, cleanOmit(opts, "clean"))
|
|
94
93
|
for _, block := range []map[string]any{cfgopts, opts} {
|
|
95
94
|
for _, s := range cleanSplit(vs.GetPath(block, []any{"clean", "values"})) {
|
|
@@ -121,6 +120,10 @@ func makeOptionsUtil(ctx *core.Context) (map[string]any, error) {
|
|
|
121
120
|
opts["feature"] = fmap
|
|
122
121
|
}
|
|
123
122
|
|
|
123
|
+
if fm, ok := featureDefaults(core.ToMapAny(config["feature"]), opts["feature"]); ok {
|
|
124
|
+
opts["feature"] = fm
|
|
125
|
+
}
|
|
126
|
+
|
|
124
127
|
optspec := core.OPTSPEC
|
|
125
128
|
|
|
126
129
|
// Preserve system.fetch before merge/validate.
|
|
@@ -140,7 +143,15 @@ func makeOptionsUtil(ctx *core.Context) (map[string]any, error) {
|
|
|
140
143
|
// UseNumber() are otherwise judged by a rule nothing else applies.
|
|
141
144
|
canonNumbers(merged)
|
|
142
145
|
|
|
143
|
-
|
|
146
|
+
verr := refuseStrayKeys(merged, optspec)
|
|
147
|
+
var validated any
|
|
148
|
+
if verr == nil {
|
|
149
|
+
validated, verr = vs.Validate(merged, optspec)
|
|
150
|
+
}
|
|
151
|
+
if verr != nil {
|
|
152
|
+
return nil, cleanUtil(cleanctx,
|
|
153
|
+
core.NewProjectNameError("options_invalid", verr.Error(), nil)).(*core.ProjectNameError)
|
|
154
|
+
}
|
|
144
155
|
opts = validated.(map[string]any)
|
|
145
156
|
|
|
146
157
|
// Restore the suppression the optspec default would otherwise erase.
|
|
@@ -195,14 +206,20 @@ func makeOptionsUtil(ctx *core.Context) (map[string]any, error) {
|
|
|
195
206
|
}
|
|
196
207
|
}
|
|
197
208
|
|
|
198
|
-
// Resolve the feature add-order: an explicit array order (above) wins
|
|
199
|
-
//
|
|
200
|
-
//
|
|
201
|
-
|
|
209
|
+
// Resolve the feature add-order: an explicit array order (above) wins, and
|
|
210
|
+
// the names it leaves out follow it test-first, then sorted, so the outcome
|
|
211
|
+
// is deterministic and `test` is the base transport of a map.
|
|
212
|
+
{
|
|
213
|
+
given := map[string]bool{}
|
|
214
|
+
for _, n := range featureorder {
|
|
215
|
+
given[n.(string)] = true
|
|
216
|
+
}
|
|
202
217
|
fmap := core.ToMapAny(opts["feature"])
|
|
203
218
|
names := make([]string, 0, len(fmap))
|
|
204
219
|
for k := range fmap {
|
|
205
|
-
|
|
220
|
+
if !given[k] {
|
|
221
|
+
names = append(names, k)
|
|
222
|
+
}
|
|
206
223
|
}
|
|
207
224
|
sort.Strings(names)
|
|
208
225
|
hasTest := false
|
|
@@ -246,10 +263,10 @@ func makeOptionsUtil(ctx *core.Context) (map[string]any, error) {
|
|
|
246
263
|
}
|
|
247
264
|
}
|
|
248
265
|
|
|
249
|
-
opts["__derived__"] = map[string]any{
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
266
|
+
opts["__derived__"] = map[string]any{"featureorder": featureorder}
|
|
267
|
+
|
|
268
|
+
// Beside the options, not in them: OptionsMap hands them to callers.
|
|
269
|
+
ctx.CleanCfg = cleancfg
|
|
253
270
|
|
|
254
271
|
// Again over the merged result: the config's own defaults can carry one.
|
|
255
272
|
cleanAddOptions(cleanctx, cleanOmit(opts, "clean", "__derived__"))
|
|
@@ -257,6 +274,40 @@ func makeOptionsUtil(ctx *core.Context) (map[string]any, error) {
|
|
|
257
274
|
return opts, nil
|
|
258
275
|
}
|
|
259
276
|
|
|
277
|
+
// The model's options for a feature sit beneath the caller's, key by key: a
|
|
278
|
+
// key the caller sets replaces the default whole, so a list is never merged.
|
|
279
|
+
func featureDefaults(cfgfeature map[string]any, feature any) (map[string]any, bool) {
|
|
280
|
+
out := map[string]any{}
|
|
281
|
+
if feature != nil {
|
|
282
|
+
fm, ok := feature.(map[string]any)
|
|
283
|
+
if !ok {
|
|
284
|
+
return nil, false
|
|
285
|
+
}
|
|
286
|
+
for k, v := range fm {
|
|
287
|
+
out[k] = v
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
for name, fdef := range cfgfeature {
|
|
291
|
+
dflt := core.ToMapAny(core.ToMapAny(fdef)["options"])
|
|
292
|
+
given, named := out[name]
|
|
293
|
+
if dflt == nil || (!named && dflt["active"] != true) {
|
|
294
|
+
continue
|
|
295
|
+
}
|
|
296
|
+
gm := map[string]any{}
|
|
297
|
+
if named && given != nil {
|
|
298
|
+
if gm, _ = given.(map[string]any); gm == nil {
|
|
299
|
+
continue
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
merged := vs.Clone(dflt).(map[string]any)
|
|
303
|
+
for k, v := range gm {
|
|
304
|
+
merged[k] = v
|
|
305
|
+
}
|
|
306
|
+
out[name] = merged
|
|
307
|
+
}
|
|
308
|
+
return out, true
|
|
309
|
+
}
|
|
310
|
+
|
|
260
311
|
// A feature's name is not a field name: only the sensitive names inside its
|
|
261
312
|
// settings count, so `secrets` does not make every setting a secret. Entity
|
|
262
313
|
// blocks (per-entity settings, seeded records) hold no credential, and nor do
|
|
@@ -303,3 +354,55 @@ func cleanOmit(m map[string]any, keys ...string) map[string]any {
|
|
|
303
354
|
}
|
|
304
355
|
return out
|
|
305
356
|
}
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
// Before validate: the struct's own refusal prints the value without its
|
|
360
|
+
// functions, so a misspelled callback key would go unnamed.
|
|
361
|
+
func refuseStrayKeys(opts any, optspec map[string]any) error {
|
|
362
|
+
fspecs, _ := optspec["feature"].(map[string]any)
|
|
363
|
+
feature, _ := vs.GetProp(opts, "feature").(map[string]any)
|
|
364
|
+
for _, name := range sortedKeys(feature) {
|
|
365
|
+
fopts, ok := feature[name].(map[string]any)
|
|
366
|
+
spec := specMap(fspecs[name])
|
|
367
|
+
if !ok || spec == nil || spec["`$OPEN`"] != nil {
|
|
368
|
+
continue
|
|
369
|
+
}
|
|
370
|
+
stray := []string{}
|
|
371
|
+
for _, k := range sortedKeys(fopts) {
|
|
372
|
+
if _, has := spec[k]; !has {
|
|
373
|
+
stray = append(stray, k)
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if 0 < len(stray) {
|
|
377
|
+
return errors.New("Unexpected keys at field feature." + name + ": " + strings.Join(stray, ", "))
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return nil
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
func specMap(spec any) map[string]any {
|
|
384
|
+
alts, ok := spec.([]any)
|
|
385
|
+
if !ok {
|
|
386
|
+
m, _ := spec.(map[string]any)
|
|
387
|
+
return m
|
|
388
|
+
}
|
|
389
|
+
from := 0
|
|
390
|
+
if 0 < len(alts) && "`$NOF`" == alts[0] {
|
|
391
|
+
from = 2
|
|
392
|
+
}
|
|
393
|
+
for i := from; i < len(alts); i++ {
|
|
394
|
+
if m, ok := alts[i].(map[string]any); ok {
|
|
395
|
+
return m
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
return nil
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
func sortedKeys(m map[string]any) []string {
|
|
402
|
+
keys := make([]string, 0, len(m))
|
|
403
|
+
for k := range m {
|
|
404
|
+
keys = append(keys, k)
|
|
405
|
+
}
|
|
406
|
+
sort.Strings(keys)
|
|
407
|
+
return keys
|
|
408
|
+
}
|
|
@@ -24,6 +24,8 @@ public class Context {
|
|
|
24
24
|
public Map<String, Object> config;
|
|
25
25
|
public Map<String, Object> entopts;
|
|
26
26
|
public Map<String, Object> options;
|
|
27
|
+
// The clean registry, beside the options rather than in them.
|
|
28
|
+
public Map<String, Object> cleancfg;
|
|
27
29
|
public Map<String, Operation> opmap;
|
|
28
30
|
public Response response;
|
|
29
31
|
public Result result;
|
|
@@ -124,6 +126,13 @@ public class Context {
|
|
|
124
126
|
if (this.options == null && basectx != null) {
|
|
125
127
|
this.options = basectx.options;
|
|
126
128
|
}
|
|
129
|
+
Object cc = Helpers.getCtxProp(ctxmap, "cleancfg");
|
|
130
|
+
if (cc instanceof Map) {
|
|
131
|
+
this.cleancfg = (Map<String, Object>) cc;
|
|
132
|
+
}
|
|
133
|
+
if (this.cleancfg == null && basectx != null) {
|
|
134
|
+
this.cleancfg = basectx.cleancfg;
|
|
135
|
+
}
|
|
127
136
|
|
|
128
137
|
// Entity
|
|
129
138
|
Object e = Helpers.getCtxProp(ctxmap, "entity");
|
|
@@ -61,30 +61,54 @@ public abstract class SdkClient {
|
|
|
61
61
|
if (featureOpts == null) {
|
|
62
62
|
featureOpts = new java.util.LinkedHashMap<>();
|
|
63
63
|
}
|
|
64
|
+
List<Feature> extend = new ArrayList<>();
|
|
65
|
+
Object extendRaw = Struct.getprop(this.options, "extend");
|
|
66
|
+
if (extendRaw instanceof List) {
|
|
67
|
+
for (Object f : (List<Object>) extendRaw) {
|
|
68
|
+
if (f instanceof Feature) {
|
|
69
|
+
extend.add((Feature) f);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
List<Feature> placed = new ArrayList<>();
|
|
64
74
|
Object featureOrderRaw =
|
|
65
75
|
Struct.getpath(this.options, List.of("__derived__", "featureorder"));
|
|
66
76
|
if (featureOrderRaw instanceof List) {
|
|
67
77
|
for (Object fnameObj : (List<Object>) featureOrderRaw) {
|
|
68
78
|
String fname = fnameObj instanceof String ? (String) fnameObj : null;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
if (fname == null || !featureActive(featureOpts, fname)) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
Feature f = Config.makeFeature(fname);
|
|
83
|
+
// An active name with no generated class is legal when an
|
|
84
|
+
// extend-supplied instance carries that name (station's adopt
|
|
85
|
+
// path): the instance takes the slot the order gives its name.
|
|
86
|
+
Feature carried = null;
|
|
87
|
+
if (f == null || !fname.equals(f.getName())) {
|
|
88
|
+
for (Feature ef : extend) {
|
|
89
|
+
if (fname.equals(ef.getName())) {
|
|
90
|
+
carried = ef;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
76
93
|
}
|
|
77
94
|
}
|
|
95
|
+
if (carried != null) {
|
|
96
|
+
placed.add(carried);
|
|
97
|
+
this.utility.featureAdd.apply(this.rootctx, carried);
|
|
98
|
+
}
|
|
99
|
+
else if (f != null) {
|
|
100
|
+
this.utility.featureAdd.apply(this.rootctx, f);
|
|
101
|
+
}
|
|
78
102
|
}
|
|
79
103
|
}
|
|
80
104
|
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
105
|
+
// An extend feature is active by its option, else by its own flag.
|
|
106
|
+
for (Feature f : extend) {
|
|
107
|
+
Map<String, Object> fopts = Helpers.toMapAny(Struct.getprop(featureOpts, f.getName()));
|
|
108
|
+
Object fa = fopts == null ? null : fopts.get("active");
|
|
109
|
+
boolean on = fa instanceof Boolean ? (Boolean) fa : f.getActive();
|
|
110
|
+
if (placed.stream().noneMatch(p -> p == f) && on) {
|
|
111
|
+
this.utility.featureAdd.apply(this.rootctx, f);
|
|
88
112
|
}
|
|
89
113
|
}
|
|
90
114
|
|
|
@@ -96,6 +120,11 @@ public abstract class SdkClient {
|
|
|
96
120
|
this.utility.featureHook.apply(this.rootctx, "PostConstruct");
|
|
97
121
|
}
|
|
98
122
|
|
|
123
|
+
private static boolean featureActive(Map<String, Object> featureOpts, String fname) {
|
|
124
|
+
Map<String, Object> fopts = Helpers.toMapAny(Struct.getprop(featureOpts, fname));
|
|
125
|
+
return fopts != null && Boolean.TRUE.equals(fopts.get("active"));
|
|
126
|
+
}
|
|
127
|
+
|
|
99
128
|
public Map<String, Object> optionsMap() {
|
|
100
129
|
Object out = Struct.clone(this.options);
|
|
101
130
|
if (out instanceof Map) {
|
|
@@ -113,7 +113,11 @@ public class AuditFeature extends BaseFeature {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
if (this.options.get("sink") instanceof Consumer) {
|
|
116
|
-
|
|
116
|
+
// A failing sink never changes the operation's outcome.
|
|
117
|
+
try {
|
|
118
|
+
((Consumer<Map<String, Object>>) this.options.get("sink")).accept(record);
|
|
119
|
+
} catch (RuntimeException e) {
|
|
120
|
+
}
|
|
117
121
|
}
|
|
118
122
|
}
|
|
119
123
|
}
|
|
@@ -1,31 +1,38 @@
|
|
|
1
1
|
package JAVAPACKAGE.feature;
|
|
2
2
|
|
|
3
|
+
import java.nio.charset.StandardCharsets;
|
|
4
|
+
import java.security.GeneralSecurityException;
|
|
5
|
+
import java.security.SecureRandom;
|
|
3
6
|
import java.util.ArrayList;
|
|
7
|
+
import java.util.Iterator;
|
|
4
8
|
import java.util.LinkedHashMap;
|
|
5
9
|
import java.util.List;
|
|
6
10
|
import java.util.Map;
|
|
7
11
|
import java.util.function.Supplier;
|
|
12
|
+
import java.util.regex.Matcher;
|
|
13
|
+
import java.util.regex.Pattern;
|
|
14
|
+
|
|
15
|
+
import javax.crypto.Mac;
|
|
16
|
+
import javax.crypto.spec.SecretKeySpec;
|
|
8
17
|
|
|
9
18
|
import JAVAPACKAGE.core.Context;
|
|
10
19
|
import JAVAPACKAGE.core.SdkClient;
|
|
11
20
|
import JAVAPACKAGE.core.Utility;
|
|
12
21
|
import JAVAPACKAGE.utility.Media;
|
|
13
22
|
|
|
14
|
-
// Response caching for safe (read) requests
|
|
15
|
-
//
|
|
16
|
-
// same method+URL was fetched within `ttl` ms (default: 5000). Only
|
|
17
|
-
// successful (2xx) responses to cacheable methods (default: GET) are
|
|
18
|
-
// stored, keyed by method+URL. The cache is bounded (`max` entries, default
|
|
19
|
-
// 256, oldest evicted first) and every hit/miss/bypass is counted. Bodies
|
|
20
|
-
// are snapshotted on capture so both the current caller and later hits can
|
|
21
|
-
// re-read the JSON body repeatedly.
|
|
23
|
+
// Response caching for safe (read) requests, per client: see the features
|
|
24
|
+
// reference for the key, the write invalidation and the Cache-Control rules.
|
|
22
25
|
@SuppressWarnings({"unchecked"})
|
|
23
26
|
public class CacheFeature extends BaseFeature {
|
|
24
27
|
|
|
25
28
|
private SdkClient client;
|
|
26
29
|
private Map<String, Object> options;
|
|
27
30
|
private Map<String, CacheEntry> store;
|
|
28
|
-
private
|
|
31
|
+
private SecretKeySpec secret;
|
|
32
|
+
|
|
33
|
+
private static final List<String> SAFE_METHODS = List.of("GET", "HEAD");
|
|
34
|
+
private static final List<String> UNSTORED = List.of("no-store", "private", "no-cache");
|
|
35
|
+
private static final Pattern MAX_AGE = Pattern.compile("^max-age\\s*=\\s*\"?(\\d+)\"?$");
|
|
29
36
|
|
|
30
37
|
// Activity tracking (mirrors the ts client._cache record).
|
|
31
38
|
public int hit = 0;
|
|
@@ -34,6 +41,7 @@ public class CacheFeature extends BaseFeature {
|
|
|
34
41
|
|
|
35
42
|
private static final class CacheEntry {
|
|
36
43
|
long expiry;
|
|
44
|
+
String scope;
|
|
37
45
|
CacheSnapshot snapshot;
|
|
38
46
|
}
|
|
39
47
|
|
|
@@ -59,7 +67,9 @@ public class CacheFeature extends BaseFeature {
|
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
this.store = new LinkedHashMap<>();
|
|
62
|
-
|
|
70
|
+
byte[] key = new byte[32];
|
|
71
|
+
new SecureRandom().nextBytes(key);
|
|
72
|
+
this.secret = new SecretKeySpec(key, "HmacSHA256");
|
|
63
73
|
|
|
64
74
|
final Utility.FetcherFn inner = ctx.utility.fetcher;
|
|
65
75
|
|
|
@@ -88,10 +98,18 @@ public class CacheFeature extends BaseFeature {
|
|
|
88
98
|
}
|
|
89
99
|
}
|
|
90
100
|
if (!cacheable) {
|
|
91
|
-
|
|
101
|
+
if (SAFE_METHODS.contains(method)) {
|
|
102
|
+
return inner.fetch(ctx, url, fetchdef);
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
return inner.fetch(ctx, url, fetchdef);
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
invalidate(url);
|
|
109
|
+
}
|
|
92
110
|
}
|
|
93
111
|
|
|
94
|
-
String key = method + " " + url;
|
|
112
|
+
String key = method + " " + url + " " + digest(fetchdef.get("headers"));
|
|
95
113
|
long now = FeatureOptions.foptNow(this.options).getAsLong();
|
|
96
114
|
|
|
97
115
|
CacheEntry hitEntry = this.store.get(key);
|
|
@@ -117,13 +135,18 @@ public class CacheFeature extends BaseFeature {
|
|
|
117
135
|
|
|
118
136
|
if (storable(res)) {
|
|
119
137
|
CacheSnapshot snapshot = snapshot(res);
|
|
120
|
-
|
|
138
|
+
long ttl = lifetime(snapshot.headers, FeatureOptions.foptInt(this.options, "ttl", 5000));
|
|
139
|
+
if (ttl <= 0) {
|
|
140
|
+
this.bypass++;
|
|
141
|
+
return replay(snapshot);
|
|
142
|
+
}
|
|
143
|
+
this.store.remove(key);
|
|
121
144
|
evict();
|
|
122
145
|
CacheEntry entry = new CacheEntry();
|
|
123
146
|
entry.expiry = now + ttl;
|
|
147
|
+
entry.scope = scope(url);
|
|
124
148
|
entry.snapshot = snapshot;
|
|
125
149
|
this.store.put(key, entry);
|
|
126
|
-
this.order.add(key);
|
|
127
150
|
this.miss++;
|
|
128
151
|
return replay(snapshot);
|
|
129
152
|
}
|
|
@@ -132,6 +155,88 @@ public class CacheFeature extends BaseFeature {
|
|
|
132
155
|
return res;
|
|
133
156
|
}
|
|
134
157
|
|
|
158
|
+
private String digest(Object headers) {
|
|
159
|
+
List<String[]> pairs = new ArrayList<>();
|
|
160
|
+
if (headers instanceof Map) {
|
|
161
|
+
for (Map.Entry<?, ?> h : ((Map<?, ?>) headers).entrySet()) {
|
|
162
|
+
if (h.getValue() != null) {
|
|
163
|
+
pairs.add(new String[] {String.valueOf(h.getKey()).toLowerCase(), String.valueOf(h.getValue())});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
pairs.sort((a, b) -> a[0].equals(b[0]) ? a[1].compareTo(b[1]) : a[0].compareTo(b[0]));
|
|
168
|
+
try {
|
|
169
|
+
Mac mac = Mac.getInstance("HmacSHA256");
|
|
170
|
+
mac.init(this.secret);
|
|
171
|
+
for (String[] p : pairs) {
|
|
172
|
+
mac.update((p[0] + ":" + p[1] + "\n").getBytes(StandardCharsets.UTF_8));
|
|
173
|
+
}
|
|
174
|
+
StringBuilder hex = new StringBuilder();
|
|
175
|
+
for (byte b : mac.doFinal()) {
|
|
176
|
+
hex.append(String.format("%02x", b));
|
|
177
|
+
}
|
|
178
|
+
return hex.toString();
|
|
179
|
+
}
|
|
180
|
+
catch (GeneralSecurityException err) {
|
|
181
|
+
throw new IllegalStateException(err);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
private void invalidate(String url) {
|
|
186
|
+
String path = scope(url);
|
|
187
|
+
String collection = parent(path);
|
|
188
|
+
this.store.values().removeIf((e) -> under(e.scope, path) || e.scope.equals(collection));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// The configured ttl capped by the response's Cache-Control; zero when the
|
|
192
|
+
// response may not be stored.
|
|
193
|
+
private static long lifetime(Map<String, Object> headers, long ttl) {
|
|
194
|
+
String control = "";
|
|
195
|
+
for (Map.Entry<String, Object> h : headers.entrySet()) {
|
|
196
|
+
if ("cache-control".equals(h.getKey().toLowerCase())) {
|
|
197
|
+
control = String.valueOf(h.getValue()).toLowerCase();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
long life = ttl;
|
|
201
|
+
for (String part : control.split(",")) {
|
|
202
|
+
String directive = part.trim();
|
|
203
|
+
if (UNSTORED.contains(directive)) {
|
|
204
|
+
return 0;
|
|
205
|
+
}
|
|
206
|
+
Matcher age = MAX_AGE.matcher(directive);
|
|
207
|
+
if (age.matches()) {
|
|
208
|
+
try {
|
|
209
|
+
life = Math.min(life, Long.parseLong(age.group(1)) * 1000);
|
|
210
|
+
}
|
|
211
|
+
catch (NumberFormatException err) {
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return life;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private static String scope(String url) {
|
|
220
|
+
String out = url.split("[?#]", 2)[0];
|
|
221
|
+
while (out.endsWith("/")) {
|
|
222
|
+
out = out.substring(0, out.length() - 1);
|
|
223
|
+
}
|
|
224
|
+
return out;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
private static String parent(String scope) {
|
|
228
|
+
int scheme = scope.indexOf("://");
|
|
229
|
+
int root = scheme < 0 ? 0 : scope.indexOf('/', scheme + 3);
|
|
230
|
+
if (root < 0) {
|
|
231
|
+
return scope;
|
|
232
|
+
}
|
|
233
|
+
return scope.substring(0, Math.max(scope.lastIndexOf('/'), root));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
private static boolean under(String scope, String prefix) {
|
|
237
|
+
return scope.equals(prefix) || scope.startsWith(prefix + "/");
|
|
238
|
+
}
|
|
239
|
+
|
|
135
240
|
// A body the transport could not read as JSON passes through, for the operation to report.
|
|
136
241
|
private boolean storable(Object res) {
|
|
137
242
|
int status = FeatureOptions.fresStatus(res);
|
|
@@ -190,9 +295,10 @@ public class CacheFeature extends BaseFeature {
|
|
|
190
295
|
// evict drops oldest entries (FIFO) until the store is under `max`.
|
|
191
296
|
private void evict() {
|
|
192
297
|
int max = FeatureOptions.foptInt(this.options, "max", 256);
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
298
|
+
Iterator<String> oldest = this.store.keySet().iterator();
|
|
299
|
+
while (this.store.size() >= max && oldest.hasNext()) {
|
|
300
|
+
oldest.next();
|
|
301
|
+
oldest.remove();
|
|
196
302
|
}
|
|
197
303
|
}
|
|
198
304
|
}
|
|
@@ -2,6 +2,7 @@ package JAVAPACKAGE.feature;
|
|
|
2
2
|
|
|
3
3
|
import java.util.LinkedHashMap;
|
|
4
4
|
import java.util.Map;
|
|
5
|
+
import java.util.function.Consumer;
|
|
5
6
|
|
|
6
7
|
import JAVAPACKAGE.core.Context;
|
|
7
8
|
import JAVAPACKAGE.core.Helpers;
|
|
@@ -13,6 +14,7 @@ import JAVAPACKAGE.core.SdkClient;
|
|
|
13
14
|
// or fails (PreUnexpected); each operation is recorded exactly once (the
|
|
14
15
|
// per-context start marker in ctx.out is consumed on record). The clock is
|
|
15
16
|
// injectable (`now`) for deterministic tests.
|
|
17
|
+
@SuppressWarnings({"unchecked"})
|
|
16
18
|
public class MetricsFeature extends BaseFeature {
|
|
17
19
|
|
|
18
20
|
private SdkClient client;
|
|
@@ -28,6 +30,16 @@ public class MetricsFeature extends BaseFeature {
|
|
|
28
30
|
public int err = 0;
|
|
29
31
|
public long totalMs = 0;
|
|
30
32
|
public long maxMs = 0;
|
|
33
|
+
|
|
34
|
+
public Map<String, Object> record() {
|
|
35
|
+
Map<String, Object> out = new LinkedHashMap<>();
|
|
36
|
+
out.put("count", count);
|
|
37
|
+
out.put("ok", ok);
|
|
38
|
+
out.put("err", err);
|
|
39
|
+
out.put("totalMs", totalMs);
|
|
40
|
+
out.put("maxMs", maxMs);
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
31
43
|
}
|
|
32
44
|
|
|
33
45
|
private static final String METRICS_START_KEY = "metrics_start";
|
|
@@ -97,6 +109,25 @@ public class MetricsFeature extends BaseFeature {
|
|
|
97
109
|
|
|
98
110
|
bump(this.total, ok, dur);
|
|
99
111
|
bump(op, ok, dur);
|
|
112
|
+
|
|
113
|
+
if (this.options.get("sink") instanceof Consumer) {
|
|
114
|
+
Map<String, Object> ops = new LinkedHashMap<>();
|
|
115
|
+
for (Map.Entry<String, MetricsBucket> e : this.ops.entrySet()) {
|
|
116
|
+
ops.put(e.getKey(), e.getValue().record());
|
|
117
|
+
}
|
|
118
|
+
Map<String, Object> counters = new LinkedHashMap<>();
|
|
119
|
+
counters.put("total", this.total.record());
|
|
120
|
+
counters.put("ops", ops);
|
|
121
|
+
if (ctx.utility != null && ctx.utility.clean != null) {
|
|
122
|
+
Map<String, Object> cleaned = Helpers.toMapAny(ctx.utility.clean.apply(ctx, counters));
|
|
123
|
+
counters = cleaned == null ? counters : cleaned;
|
|
124
|
+
}
|
|
125
|
+
// A failing sink never changes the operation's outcome.
|
|
126
|
+
try {
|
|
127
|
+
((Consumer<Map<String, Object>>) this.options.get("sink")).accept(counters);
|
|
128
|
+
} catch (RuntimeException e) {
|
|
129
|
+
}
|
|
130
|
+
}
|
|
100
131
|
}
|
|
101
132
|
|
|
102
133
|
private void bump(MetricsBucket bucket, boolean ok, long dur) {
|