@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
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
// Response caching for safe (read) requests
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// are snapshotted on capture so both the current caller and later hits can
|
|
8
|
-
// re-read the JSON body repeatedly.
|
|
1
|
+
// Response caching for safe (read) requests, per client: see the features
|
|
2
|
+
// reference for the key, the write invalidation and the Cache-Control rules.
|
|
3
|
+
|
|
4
|
+
using System.Security.Cryptography;
|
|
5
|
+
using System.Text;
|
|
6
|
+
using System.Text.RegularExpressions;
|
|
9
7
|
|
|
10
8
|
using ProjectNameSdk.Util;
|
|
11
9
|
|
|
@@ -19,6 +17,11 @@ public class CacheFeature : BaseFeature
|
|
|
19
17
|
private Dictionary<string, object?>? _options;
|
|
20
18
|
private Dictionary<string, CacheEntry> _store = new();
|
|
21
19
|
private List<string> _order = new();
|
|
20
|
+
private byte[] _secret = Array.Empty<byte>();
|
|
21
|
+
|
|
22
|
+
private static readonly string[] SafeMethods = { "GET", "HEAD" };
|
|
23
|
+
private static readonly string[] Unstored = { "no-store", "private", "no-cache" };
|
|
24
|
+
private static readonly Regex MaxAge = new("^max-age\\s*=\\s*\"?(\\d+)\"?$");
|
|
22
25
|
|
|
23
26
|
// Activity tracking (mirrors the ts client._cache record).
|
|
24
27
|
public int Hit;
|
|
@@ -28,6 +31,7 @@ public class CacheFeature : BaseFeature
|
|
|
28
31
|
private class CacheEntry
|
|
29
32
|
{
|
|
30
33
|
public long Expiry;
|
|
34
|
+
public string Scope = "";
|
|
31
35
|
public CacheSnapshot Snapshot = new();
|
|
32
36
|
}
|
|
33
37
|
|
|
@@ -59,6 +63,7 @@ public class CacheFeature : BaseFeature
|
|
|
59
63
|
|
|
60
64
|
_store = new Dictionary<string, CacheEntry>();
|
|
61
65
|
_order = new List<string>();
|
|
66
|
+
_secret = RandomNumberGenerator.GetBytes(32);
|
|
62
67
|
|
|
63
68
|
var inner = ctx.Utility!.Fetcher;
|
|
64
69
|
|
|
@@ -78,10 +83,22 @@ public class CacheFeature : BaseFeature
|
|
|
78
83
|
var cacheable = methods.Any(x => x.ToUpperInvariant() == method);
|
|
79
84
|
if (!cacheable)
|
|
80
85
|
{
|
|
81
|
-
|
|
86
|
+
if (SafeMethods.Contains(method))
|
|
87
|
+
{
|
|
88
|
+
return inner(ctx, url, fetchdef);
|
|
89
|
+
}
|
|
90
|
+
try
|
|
91
|
+
{
|
|
92
|
+
return inner(ctx, url, fetchdef);
|
|
93
|
+
}
|
|
94
|
+
finally
|
|
95
|
+
{
|
|
96
|
+
Invalidate(url);
|
|
97
|
+
}
|
|
82
98
|
}
|
|
83
99
|
|
|
84
|
-
|
|
100
|
+
fetchdef.TryGetValue("headers", out var headers);
|
|
101
|
+
var key = method + " " + url + " " + Digest(headers);
|
|
85
102
|
var now = FoptNow(_options)();
|
|
86
103
|
|
|
87
104
|
if (_store.TryGetValue(key, out var hit) && hit.Expiry > now)
|
|
@@ -111,9 +128,15 @@ public class CacheFeature : BaseFeature
|
|
|
111
128
|
if (err == null && Storable(res))
|
|
112
129
|
{
|
|
113
130
|
var snapshot = Snapshot(res);
|
|
114
|
-
var ttl = FoptInt(_options, "ttl", 5000);
|
|
131
|
+
var ttl = Lifetime(snapshot.Headers, FoptInt(_options, "ttl", 5000));
|
|
132
|
+
if (ttl <= 0)
|
|
133
|
+
{
|
|
134
|
+
Bypass++;
|
|
135
|
+
return Replay(snapshot);
|
|
136
|
+
}
|
|
137
|
+
Drop(key);
|
|
115
138
|
Evict();
|
|
116
|
-
_store[key] = new CacheEntry { Expiry = now + ttl, Snapshot = snapshot };
|
|
139
|
+
_store[key] = new CacheEntry { Expiry = now + ttl, Scope = UrlScope(url), Snapshot = snapshot };
|
|
117
140
|
_order.Add(key);
|
|
118
141
|
Miss++;
|
|
119
142
|
return Replay(snapshot);
|
|
@@ -127,6 +150,97 @@ public class CacheFeature : BaseFeature
|
|
|
127
150
|
return res;
|
|
128
151
|
}
|
|
129
152
|
|
|
153
|
+
private string Digest(object? headers)
|
|
154
|
+
{
|
|
155
|
+
var pairs = new List<(string Name, string Value)>();
|
|
156
|
+
if (headers is IDictionary<string, object?> hm)
|
|
157
|
+
{
|
|
158
|
+
foreach (var kv in hm)
|
|
159
|
+
{
|
|
160
|
+
if (kv.Value != null)
|
|
161
|
+
{
|
|
162
|
+
pairs.Add((kv.Key.ToLowerInvariant(), Convert.ToString(kv.Value, System.Globalization.CultureInfo.InvariantCulture) ?? ""));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
var text = new StringBuilder();
|
|
167
|
+
foreach (var (name, value) in pairs.OrderBy(p => p.Name, StringComparer.Ordinal).ThenBy(p => p.Value, StringComparer.Ordinal))
|
|
168
|
+
{
|
|
169
|
+
text.Append(name).Append(':').Append(value).Append('\n');
|
|
170
|
+
}
|
|
171
|
+
return Convert.ToHexString(HMACSHA256.HashData(_secret, Encoding.UTF8.GetBytes(text.ToString()))).ToLowerInvariant();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private void Invalidate(string url)
|
|
175
|
+
{
|
|
176
|
+
var path = UrlScope(url);
|
|
177
|
+
var collection = UrlParent(path);
|
|
178
|
+
foreach (var key in _store.Where(kv => Under(kv.Value.Scope, path) || kv.Value.Scope == collection)
|
|
179
|
+
.Select(kv => kv.Key).ToList())
|
|
180
|
+
{
|
|
181
|
+
Drop(key);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
private void Drop(string key)
|
|
186
|
+
{
|
|
187
|
+
if (_store.Remove(key))
|
|
188
|
+
{
|
|
189
|
+
_order.Remove(key);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// The configured ttl capped by the response's Cache-Control; zero when the
|
|
194
|
+
// response may not be stored.
|
|
195
|
+
private static long Lifetime(Dictionary<string, object?> headers, long ttl)
|
|
196
|
+
{
|
|
197
|
+
var control = "";
|
|
198
|
+
foreach (var kv in headers)
|
|
199
|
+
{
|
|
200
|
+
if (kv.Key.ToLowerInvariant() == "cache-control")
|
|
201
|
+
{
|
|
202
|
+
control = (Convert.ToString(kv.Value) ?? "").ToLowerInvariant();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
var life = ttl;
|
|
206
|
+
foreach (var part in control.Split(','))
|
|
207
|
+
{
|
|
208
|
+
var directive = part.Trim();
|
|
209
|
+
if (Unstored.Contains(directive))
|
|
210
|
+
{
|
|
211
|
+
return 0;
|
|
212
|
+
}
|
|
213
|
+
var age = MaxAge.Match(directive);
|
|
214
|
+
if (age.Success && long.TryParse(age.Groups[1].Value, out var secs))
|
|
215
|
+
{
|
|
216
|
+
life = Math.Min(life, secs * 1000);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return life;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
private static string UrlScope(string url)
|
|
223
|
+
{
|
|
224
|
+
var cut = url.IndexOfAny(new[] { '?', '#' });
|
|
225
|
+
return (cut < 0 ? url : url[..cut]).TrimEnd('/');
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private static string UrlParent(string scope)
|
|
229
|
+
{
|
|
230
|
+
var scheme = scope.IndexOf("://", StringComparison.Ordinal);
|
|
231
|
+
var root = scheme < 0 ? 0 : scope.IndexOf('/', scheme + 3);
|
|
232
|
+
if (root < 0)
|
|
233
|
+
{
|
|
234
|
+
return scope;
|
|
235
|
+
}
|
|
236
|
+
return scope[..Math.Max(scope.LastIndexOf('/'), root)];
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
private static bool Under(string scope, string prefix)
|
|
240
|
+
{
|
|
241
|
+
return scope == prefix || scope.StartsWith(prefix + "/", StringComparison.Ordinal);
|
|
242
|
+
}
|
|
243
|
+
|
|
130
244
|
// A body the transport could not read as JSON passes through, for the operation to report.
|
|
131
245
|
private static bool Storable(object? res)
|
|
132
246
|
{
|
|
@@ -16,6 +16,11 @@ public class MetricsBucket
|
|
|
16
16
|
public int Err;
|
|
17
17
|
public long TotalMs;
|
|
18
18
|
public long MaxMs;
|
|
19
|
+
|
|
20
|
+
public Dictionary<string, object?> Record() => new Dictionary<string, object?>
|
|
21
|
+
{
|
|
22
|
+
["count"] = Count, ["ok"] = Ok, ["err"] = Err, ["totalMs"] = TotalMs, ["maxMs"] = MaxMs,
|
|
23
|
+
};
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
public class MetricsFeature : BaseFeature
|
|
@@ -95,6 +100,24 @@ public class MetricsFeature : BaseFeature
|
|
|
95
100
|
|
|
96
101
|
Bump(Total, ok, dur);
|
|
97
102
|
Bump(op, ok, dur);
|
|
103
|
+
|
|
104
|
+
if (Opt(_options, "sink") is Action<Dictionary<string, object?>> sink)
|
|
105
|
+
{
|
|
106
|
+
var ops = new Dictionary<string, object?>();
|
|
107
|
+
foreach (var entry in Ops)
|
|
108
|
+
{
|
|
109
|
+
ops[entry.Key] = entry.Value.Record();
|
|
110
|
+
}
|
|
111
|
+
var counters = Fclean(ctx, new Dictionary<string, object?> { ["total"] = Total.Record(), ["ops"] = ops });
|
|
112
|
+
// A failing sink never changes the operation's outcome.
|
|
113
|
+
try
|
|
114
|
+
{
|
|
115
|
+
sink(counters);
|
|
116
|
+
}
|
|
117
|
+
catch (System.Exception)
|
|
118
|
+
{
|
|
119
|
+
}
|
|
120
|
+
}
|
|
98
121
|
}
|
|
99
122
|
|
|
100
123
|
private static void Bump(MetricsBucket bucket, bool ok, long dur)
|
|
@@ -73,10 +73,16 @@ public class PagingFeature : BaseFeature
|
|
|
73
73
|
|
|
74
74
|
object? cursor = null;
|
|
75
75
|
var hasCursor = paging != null && paging.TryGetValue("cursor", out cursor) && cursor != null;
|
|
76
|
+
object? nextLink = null;
|
|
76
77
|
if (hasCursor)
|
|
77
78
|
{
|
|
78
79
|
spec.Query[cursorParam] = cursor;
|
|
79
80
|
}
|
|
81
|
+
else if (paging != null && paging.TryGetValue("next", out nextLink) && nextLink is string link &&
|
|
82
|
+
!Foreign(link, spec.Base))
|
|
83
|
+
{
|
|
84
|
+
Follow(spec, (string)nextLink!);
|
|
85
|
+
}
|
|
80
86
|
else if (!spec.Query.TryGetValue(pageParam, out var existing) || existing == null)
|
|
81
87
|
{
|
|
82
88
|
// A record written back by PreResult holds the page just fetched
|
|
@@ -231,10 +237,16 @@ public class PagingFeature : BaseFeature
|
|
|
231
237
|
// Body-level signals; snake_case forms are read first so camelCase wins.
|
|
232
238
|
if (body is Dictionary<string, object?> bm)
|
|
233
239
|
{
|
|
234
|
-
if (bm.TryGetValue("next", out var next) && next != null
|
|
235
|
-
(!paging.TryGetValue("next", out var pn) || pn == null))
|
|
240
|
+
if (bm.TryGetValue("next", out var next) && next != null)
|
|
236
241
|
{
|
|
237
|
-
|
|
242
|
+
if (!IsLink(next, FoptStr(_options, "next", "auto")))
|
|
243
|
+
{
|
|
244
|
+
paging["cursor"] = next;
|
|
245
|
+
}
|
|
246
|
+
else if (!paging.TryGetValue("next", out var pn) || pn == null)
|
|
247
|
+
{
|
|
248
|
+
paging["next"] = next;
|
|
249
|
+
}
|
|
238
250
|
}
|
|
239
251
|
if (bm.TryGetValue("next_cursor", out var snakeCursor) && snakeCursor != null)
|
|
240
252
|
{
|
|
@@ -283,6 +295,18 @@ public class PagingFeature : BaseFeature
|
|
|
283
295
|
}
|
|
284
296
|
}
|
|
285
297
|
|
|
298
|
+
// A link to another origin is recorded, never followed, and ends the walk.
|
|
299
|
+
var baseUrl = ctx.Spec?.Base ?? (ctx.Options != null && ctx.Options.TryGetValue("base", out var ob) ? ob as string : null);
|
|
300
|
+
if (paging.TryGetValue("next", out var rl) && rl is string rawNext && ctx.Spec != null)
|
|
301
|
+
{
|
|
302
|
+
paging["next"] = Resolve(rawNext, ctx.Spec.Url);
|
|
303
|
+
}
|
|
304
|
+
if (paging.TryGetValue("next", out var nl) && nl is string nextUrl && Foreign(nextUrl, baseUrl))
|
|
305
|
+
{
|
|
306
|
+
paging["foreign"] = nextUrl;
|
|
307
|
+
paging.Remove("next");
|
|
308
|
+
}
|
|
309
|
+
|
|
286
310
|
// Cursor presence only INFERS another page. When the server stated
|
|
287
311
|
// the answer outright - relay's `hasNextPage: false`, or a body
|
|
288
312
|
// `hasMore` - that wins: a final page normally carries both an end
|
|
@@ -296,6 +320,13 @@ public class PagingFeature : BaseFeature
|
|
|
296
320
|
paging["hasMore"] = true;
|
|
297
321
|
}
|
|
298
322
|
|
|
323
|
+
if (paging.ContainsKey("foreign") &&
|
|
324
|
+
(!paging.TryGetValue("cursor", out var c3) || c3 == null) &&
|
|
325
|
+
(!paging.TryGetValue("nextPage", out var np3) || np3 == null))
|
|
326
|
+
{
|
|
327
|
+
paging["hasMore"] = false;
|
|
328
|
+
}
|
|
329
|
+
|
|
299
330
|
result.Paging = paging;
|
|
300
331
|
Last = paging;
|
|
301
332
|
|
|
@@ -318,6 +349,102 @@ public class PagingFeature : BaseFeature
|
|
|
318
349
|
}
|
|
319
350
|
}
|
|
320
351
|
|
|
352
|
+
private static readonly Regex Origin =
|
|
353
|
+
new(@"^[a-z][a-z0-9+.-]*://[^/?#]*", RegexOptions.IgnoreCase);
|
|
354
|
+
|
|
355
|
+
// Under the `next` option's default, a URL or an absolute path is a link
|
|
356
|
+
// and anything else a cursor; `cursor` and `url` pin the reading.
|
|
357
|
+
internal static bool IsLink(object? next, string mode) =>
|
|
358
|
+
next is string s && (mode == "url" ||
|
|
359
|
+
(mode != "cursor" && (Origin.IsMatch(s) || s.StartsWith("/"))));
|
|
360
|
+
|
|
361
|
+
private static string OriginOf(string? text)
|
|
362
|
+
{
|
|
363
|
+
var m = Origin.Match(text ?? "");
|
|
364
|
+
return m.Success ? m.Value.ToLowerInvariant() : "";
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
internal static bool Foreign(string link, string? baseUrl)
|
|
368
|
+
{
|
|
369
|
+
var origin = OriginOf(link);
|
|
370
|
+
return origin != "" && origin != OriginOf(baseUrl);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
private static readonly Regex Scheme = new Regex("^[a-z][a-z0-9+.-]*:", RegexOptions.IgnoreCase);
|
|
374
|
+
|
|
375
|
+
// RFC 3986 reference resolution against the URL of the request that
|
|
376
|
+
// returned the link. A link on that URL's origin comes back as its path and
|
|
377
|
+
// query; an absolute link is left as the server wrote it.
|
|
378
|
+
internal static string Resolve(string link, string? url)
|
|
379
|
+
{
|
|
380
|
+
if (string.IsNullOrEmpty(url) || Scheme.IsMatch(link))
|
|
381
|
+
{
|
|
382
|
+
return link;
|
|
383
|
+
}
|
|
384
|
+
var bare = !Origin.IsMatch(url);
|
|
385
|
+
var holder = "http://placeholder.invalid" + (url.StartsWith("/") ? "" : "/");
|
|
386
|
+
if (!System.Uri.TryCreate(bare ? holder + url : url, System.UriKind.Absolute, out var from) ||
|
|
387
|
+
!System.Uri.TryCreate(from, link, out var to))
|
|
388
|
+
{
|
|
389
|
+
return link;
|
|
390
|
+
}
|
|
391
|
+
if (to.GetLeftPart(System.UriPartial.Authority) != from.GetLeftPart(System.UriPartial.Authority))
|
|
392
|
+
{
|
|
393
|
+
return to.GetComponents(System.UriComponents.HttpRequestUrl, System.UriFormat.UriEscaped);
|
|
394
|
+
}
|
|
395
|
+
return to.GetComponents(System.UriComponents.PathAndQuery, System.UriFormat.UriEscaped);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// The request goes to the link's path and query, on the SDK's own origin.
|
|
399
|
+
internal static void Follow(Spec spec, string next)
|
|
400
|
+
{
|
|
401
|
+
var rest = Origin.Replace(next, "", 1);
|
|
402
|
+
var hash = rest.IndexOf('#');
|
|
403
|
+
if (hash >= 0)
|
|
404
|
+
{
|
|
405
|
+
rest = rest.Substring(0, hash);
|
|
406
|
+
}
|
|
407
|
+
var mark = rest.IndexOf('?');
|
|
408
|
+
var path = mark < 0 ? rest : rest.Substring(0, mark);
|
|
409
|
+
var rawquery = mark < 0 ? "" : rest.Substring(mark + 1);
|
|
410
|
+
|
|
411
|
+
var query = new Dictionary<string, object?>();
|
|
412
|
+
foreach (var pair in rawquery.Split('&'))
|
|
413
|
+
{
|
|
414
|
+
if (pair.Length == 0)
|
|
415
|
+
{
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
var eq = pair.IndexOf('=');
|
|
419
|
+
var key = eq < 0 ? pair : pair.Substring(0, eq);
|
|
420
|
+
var val = eq < 0 ? "" : pair.Substring(eq + 1);
|
|
421
|
+
query[Unescape(key)] = Unescape(val);
|
|
422
|
+
}
|
|
423
|
+
foreach (var key in spec.AuthQuery)
|
|
424
|
+
{
|
|
425
|
+
query[key] = spec.Query.TryGetValue(key, out var v) ? v : null;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
var origin = Origin.Match(spec.Base ?? "");
|
|
429
|
+
spec.Base = origin.Success ? origin.Value : "";
|
|
430
|
+
spec.Prefix = "";
|
|
431
|
+
spec.Path = path;
|
|
432
|
+
spec.Suffix = "";
|
|
433
|
+
spec.Query = query;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
private static string Unescape(string text)
|
|
437
|
+
{
|
|
438
|
+
try
|
|
439
|
+
{
|
|
440
|
+
return System.Uri.UnescapeDataString(text.Replace('+', ' '));
|
|
441
|
+
}
|
|
442
|
+
catch (System.UriFormatException)
|
|
443
|
+
{
|
|
444
|
+
return text;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
321
448
|
private bool IsList(Context ctx)
|
|
322
449
|
{
|
|
323
450
|
var opname = ctx.Op?.Name ?? "";
|
|
@@ -13,6 +13,7 @@ public class RatelimitFeature : BaseFeature
|
|
|
13
13
|
{
|
|
14
14
|
private ProjectNameSDK? _client;
|
|
15
15
|
private Dictionary<string, object?>? _options;
|
|
16
|
+
private readonly object _lock = new();
|
|
16
17
|
private double _tokens;
|
|
17
18
|
private long _last;
|
|
18
19
|
|
|
@@ -53,32 +54,38 @@ public class RatelimitFeature : BaseFeature
|
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
private void Acquire()
|
|
57
|
+
{
|
|
58
|
+
var waitMs = Reserve();
|
|
59
|
+
if (waitMs > 0)
|
|
60
|
+
{
|
|
61
|
+
FoptSleep(_options)(waitMs);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Refill, then reserve this call's token before any wait, under the lock:
|
|
66
|
+
// a negative count is the calls already queued, so overlapping calls pace
|
|
67
|
+
// in turn.
|
|
68
|
+
private int Reserve()
|
|
56
69
|
{
|
|
57
70
|
var rate = FoptNum(_options, "rate", 5);
|
|
58
71
|
var burst = FoptNum(_options, "burst", rate);
|
|
59
72
|
|
|
60
|
-
|
|
61
|
-
var now = FoptNow(_options)();
|
|
62
|
-
var elapsed = now - _last;
|
|
63
|
-
_last = now;
|
|
64
|
-
_tokens = Math.Min(burst, _tokens + (elapsed / 1000.0) * rate);
|
|
65
|
-
|
|
66
|
-
if (_tokens >= 1)
|
|
73
|
+
lock (_lock)
|
|
67
74
|
{
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
var now = FoptNow(_options)();
|
|
76
|
+
var elapsed = now - _last;
|
|
77
|
+
_last = now;
|
|
78
|
+
_tokens = Math.Min(burst, _tokens + (elapsed / 1000.0) * rate) - 1;
|
|
71
79
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
if (_tokens >= 0)
|
|
81
|
+
{
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
var waitMs = (int)Math.Ceiling((-_tokens / rate) * 1000);
|
|
86
|
+
Track(waitMs);
|
|
87
|
+
return waitMs;
|
|
79
88
|
}
|
|
80
|
-
_last = FoptNow(_options)();
|
|
81
|
-
_tokens = 0;
|
|
82
89
|
}
|
|
83
90
|
|
|
84
91
|
private void Track(int waitMs)
|
|
@@ -97,8 +97,11 @@ public class RetryFeature : BaseFeature
|
|
|
97
97
|
{
|
|
98
98
|
return false;
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
// Only an absent or null option is unset: an empty list retries no status.
|
|
101
|
+
var given = _options != null && _options.TryGetValue("statuses", out var raw) ? raw : null;
|
|
102
|
+
var statuses = given is System.Collections.IEnumerable list && given is not string
|
|
103
|
+
? list
|
|
104
|
+
: new List<object?> { 408, 425, 429, 500, 502, 503, 504 };
|
|
102
105
|
foreach (var s in statuses)
|
|
103
106
|
{
|
|
104
107
|
if (Helpers.ToInt(s) == status)
|
|
@@ -111,7 +114,7 @@ public class RetryFeature : BaseFeature
|
|
|
111
114
|
|
|
112
115
|
private int Backoff(object? res, int attempt, int minDelay, int maxDelay, double factor)
|
|
113
116
|
{
|
|
114
|
-
//
|
|
117
|
+
// A server-provided Retry-After wins over the computed backoff.
|
|
115
118
|
var (ra, has) = RetryAfter(res);
|
|
116
119
|
if (has)
|
|
117
120
|
{
|
|
@@ -134,12 +137,43 @@ public class RetryFeature : BaseFeature
|
|
|
134
137
|
{
|
|
135
138
|
return (0, false);
|
|
136
139
|
}
|
|
137
|
-
var
|
|
138
|
-
|
|
140
|
+
var ms = RetryAfterMs(v, DateTimeOffset.UtcNow.ToUnixTimeMilliseconds());
|
|
141
|
+
return ms < 0 ? (0, false) : (ms, true);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private static readonly System.Text.RegularExpressions.Regex ImfFixdate = new(
|
|
145
|
+
"^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), ([0-9]{2}) ([A-Z][a-z]{2}) ([0-9]{4}) "
|
|
146
|
+
+ "([0-9]{2}):([0-9]{2}):([0-9]{2}) GMT\\z");
|
|
147
|
+
|
|
148
|
+
private const string Months = "JanFebMarAprMayJunJulAugSepOctNovDec";
|
|
149
|
+
|
|
150
|
+
// RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else -1.
|
|
151
|
+
internal static int RetryAfterMs(string value, long now)
|
|
152
|
+
{
|
|
153
|
+
var s = value.Trim(' ', '\t');
|
|
154
|
+
if (s.Length > 0 && s.All(c => c >= '0' && c <= '9'))
|
|
139
155
|
{
|
|
140
|
-
return (
|
|
156
|
+
return s.Length > 6 ? int.MaxValue : int.Parse(s) * 1000;
|
|
157
|
+
}
|
|
158
|
+
var m = ImfFixdate.Match(s);
|
|
159
|
+
var month = m.Success ? Months.IndexOf(m.Groups[2].Value, StringComparison.Ordinal) : -1;
|
|
160
|
+
if (month < 0 || month % 3 != 0)
|
|
161
|
+
{
|
|
162
|
+
return -1;
|
|
163
|
+
}
|
|
164
|
+
var sec = int.Parse(m.Groups[6].Value);
|
|
165
|
+
try
|
|
166
|
+
{
|
|
167
|
+
var at = new DateTimeOffset(int.Parse(m.Groups[3].Value), month / 3 + 1,
|
|
168
|
+
int.Parse(m.Groups[1].Value), int.Parse(m.Groups[4].Value),
|
|
169
|
+
int.Parse(m.Groups[5].Value), Math.Min(sec, 59), TimeSpan.Zero)
|
|
170
|
+
.ToUnixTimeMilliseconds() + (sec > 59 ? 1000 : 0);
|
|
171
|
+
return (int)Math.Min(int.MaxValue, Math.Max(0, at - now));
|
|
172
|
+
}
|
|
173
|
+
catch (ArgumentOutOfRangeException)
|
|
174
|
+
{
|
|
175
|
+
return -1;
|
|
141
176
|
}
|
|
142
|
-
return (seconds * 1000, true);
|
|
143
177
|
}
|
|
144
178
|
|
|
145
179
|
private void SleepMs(int ms)
|
|
@@ -87,6 +87,7 @@ namespace ProjectNameSdk.Feature;
|
|
|
87
87
|
public class SecretsFeature : BaseFeature
|
|
88
88
|
{
|
|
89
89
|
private ProjectNameSDK? _client;
|
|
90
|
+
private Context? _rootctx;
|
|
90
91
|
|
|
91
92
|
// The LIVE options map (root ctx options). READ ONLY: this feature
|
|
92
93
|
// never writes it (see the header).
|
|
@@ -135,6 +136,7 @@ public class SecretsFeature : BaseFeature
|
|
|
135
136
|
public override void Init(Context ctx, Dictionary<string, object?> options)
|
|
136
137
|
{
|
|
137
138
|
_client = ctx.Client;
|
|
139
|
+
_rootctx = ctx;
|
|
138
140
|
_liveopts = ctx.Options;
|
|
139
141
|
Active = FoptBool(options, "active", false);
|
|
140
142
|
|
|
@@ -785,35 +787,15 @@ public class SecretsFeature : BaseFeature
|
|
|
785
787
|
["body"] = body,
|
|
786
788
|
// Never followed by the client: a redirect would carry the refresh token on.
|
|
787
789
|
["redirect"] = "manual",
|
|
790
|
+
// Its own bound, in milliseconds: the timeout feature's wrapper is above it.
|
|
791
|
+
["timeout"] = 30000,
|
|
788
792
|
};
|
|
789
793
|
|
|
790
|
-
//
|
|
791
|
-
// feature
|
|
792
|
-
// would recurse on the first expiry
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
// system.fetch when the caller supplied one, else SdkUtility's own
|
|
796
|
-
// raw HttpClient fetch. The fallback matters: MakeOptions leaves
|
|
797
|
-
// system.fetch unset in the ORDINARY case, and requiring a custom
|
|
798
|
-
// transport there would reject every live token purchase before a
|
|
799
|
-
// request was made. DefaultHttpFetch is `internal` in this
|
|
800
|
-
// assembly, is not the SDK transport (no feature wrapping, no
|
|
801
|
-
// mode/test block) and returns the same { status, json } shape the
|
|
802
|
-
// system.fetch seam promises.
|
|
803
|
-
var sysfetch = StructUtils.GetPath(options, StructUtils.Jt("system", "fetch"));
|
|
804
|
-
|
|
805
|
-
object? Fetch(string at)
|
|
806
|
-
{
|
|
807
|
-
if (sysfetch is Func<string, Dictionary<string, object?>, Dictionary<string, object?>> ff)
|
|
808
|
-
{
|
|
809
|
-
return ff(at, fetchdef);
|
|
810
|
-
}
|
|
811
|
-
if (sysfetch is Func<string, Dictionary<string, object?>, object?> ffa)
|
|
812
|
-
{
|
|
813
|
-
return ffa(at, fetchdef);
|
|
814
|
-
}
|
|
815
|
-
return SdkUtility.DefaultHttpFetch(at, fetchdef);
|
|
816
|
-
}
|
|
794
|
+
// The SDK's own transport, beneath every feature's wrapper: it holds
|
|
795
|
+
// the test feature's block and the GET-only guard, and the wrapped
|
|
796
|
+
// one would recurse on the first expiry.
|
|
797
|
+
var rootctx = _rootctx!;
|
|
798
|
+
object? Fetch(string at) => SdkUtility.FetcherUtil(rootctx, at, fetchdef);
|
|
817
799
|
|
|
818
800
|
var res = Fetch(url);
|
|
819
801
|
|
|
@@ -38,8 +38,9 @@ public class StreamingFeature : BaseFeature
|
|
|
38
38
|
{
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
+
// A failed result keeps no stream, so the entity's Stream raises its error.
|
|
41
42
|
var result = ctx.Result;
|
|
42
|
-
if (result == null)
|
|
43
|
+
if (result == null || result.Err != null)
|
|
43
44
|
{
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
@@ -15,7 +15,6 @@ public class TelemetryFeature : BaseFeature
|
|
|
15
15
|
{
|
|
16
16
|
private ProjectNameSDK? _client;
|
|
17
17
|
private Dictionary<string, object?>? _options;
|
|
18
|
-
private int _seq;
|
|
19
18
|
|
|
20
19
|
// Activity tracking (mirrors the ts client._telemetry record).
|
|
21
20
|
public List<Dictionary<string, object?>> Spans = new();
|
|
@@ -35,7 +34,6 @@ public class TelemetryFeature : BaseFeature
|
|
|
35
34
|
_client = ctx.Client;
|
|
36
35
|
_options = options;
|
|
37
36
|
Active = FoptBool(options, "active", false);
|
|
38
|
-
_seq = 0;
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
public override void PrePoint(Context ctx)
|
|
@@ -135,14 +133,18 @@ public class TelemetryFeature : BaseFeature
|
|
|
135
133
|
{
|
|
136
134
|
return idgen(kind);
|
|
137
135
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
136
|
+
return RandomHex(kind == "trace" ? 16 : 8);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// W3C trace context: lowercase hex from the platform's random source, never all zeros.
|
|
140
|
+
private static string RandomHex(int bytes)
|
|
141
|
+
{
|
|
142
|
+
var buf = new byte[bytes];
|
|
143
|
+
do
|
|
143
144
|
{
|
|
144
|
-
|
|
145
|
+
System.Security.Cryptography.RandomNumberGenerator.Fill(buf);
|
|
145
146
|
}
|
|
146
|
-
|
|
147
|
+
while (Array.TrueForAll(buf, (b) => b == 0));
|
|
148
|
+
return Convert.ToHexString(buf).ToLowerInvariant();
|
|
147
149
|
}
|
|
148
150
|
}
|