@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
|
@@ -375,6 +375,9 @@ object MakeOptions {
|
|
|
375
375
|
case _ =>
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
+
val fdefaults = featureDefaults(config.get("feature"), opts.get("feature"))
|
|
379
|
+
if (fdefaults != null) opts.put("feature", fdefaults)
|
|
380
|
+
|
|
378
381
|
// THE OPTION SPEC IS GENERATED, NOT WRITTEN HERE.
|
|
379
382
|
//
|
|
380
383
|
// Built from the model: `main.kit.optspec` for the standard options, plus
|
|
@@ -401,19 +404,18 @@ object MakeOptions {
|
|
|
401
404
|
mergeList.add(Struct.clone(cfgopts))
|
|
402
405
|
mergeList.add(opts)
|
|
403
406
|
val merged = Struct.merge(mergeList)
|
|
407
|
+
val callbacks = holdCallbacks(merged, optspec)
|
|
404
408
|
|
|
405
|
-
//
|
|
406
|
-
val vopts = new LinkedHashMap[String, Object]()
|
|
407
|
-
vopts.put("errs", new ArrayList[Object]())
|
|
409
|
+
// A rejection quotes the value it rejected.
|
|
408
410
|
val validated =
|
|
409
|
-
try Struct.validate(merged, optspec
|
|
411
|
+
try Struct.validate(merged, optspec)
|
|
410
412
|
catch {
|
|
411
|
-
// A rejection quotes the value it rejected.
|
|
412
413
|
case err: RuntimeException =>
|
|
413
414
|
val text = if (err.getMessage == null) String.valueOf(err) else err.getMessage
|
|
414
415
|
throw new SdkError("options_invalid", Clean.cleanWith(cleancfg, text).asInstanceOf[String], ctx)
|
|
415
416
|
}
|
|
416
417
|
opts = validated.asInstanceOf[JMap[String, Object]]
|
|
418
|
+
restoreCallbacks(opts, callbacks)
|
|
417
419
|
|
|
418
420
|
// Restore the suppression the optspec default would otherwise erase.
|
|
419
421
|
if (authSuppressed) opts.put("auth", null)
|
|
@@ -457,34 +459,117 @@ object MakeOptions {
|
|
|
457
459
|
case _ =>
|
|
458
460
|
}
|
|
459
461
|
|
|
460
|
-
// Resolve the feature add-order: an explicit list order (above) wins
|
|
461
|
-
//
|
|
462
|
-
//
|
|
463
|
-
|
|
462
|
+
// Resolve the feature add-order: an explicit list order (above) wins, and
|
|
463
|
+
// the names it leaves out follow it test-first, then sorted, so the outcome
|
|
464
|
+
// is deterministic and `test` is the base transport of a map.
|
|
465
|
+
{
|
|
464
466
|
val fmap = Helpers.toMapAny(opts.get("feature"))
|
|
465
467
|
val names = new ArrayList[String]()
|
|
466
|
-
if (fmap != null)
|
|
468
|
+
if (fmap != null) fmap.keySet().forEach(n => if (!featureorder.contains(n)) names.add(n))
|
|
467
469
|
java.util.Collections.sort(names)
|
|
470
|
+
val rest = new ArrayList[Object]()
|
|
468
471
|
if (names.contains("test")) {
|
|
469
|
-
|
|
472
|
+
rest.add("test")
|
|
470
473
|
val nit = names.iterator()
|
|
471
|
-
while (nit.hasNext) { val n = nit.next(); if ("test" != n)
|
|
474
|
+
while (nit.hasNext) { val n = nit.next(); if ("test" != n) rest.add(n) }
|
|
472
475
|
} else {
|
|
473
|
-
|
|
476
|
+
rest.addAll(names)
|
|
477
|
+
}
|
|
478
|
+
// Station's transport wrap sits just outside the base transport, so a
|
|
479
|
+
// map-form activation hoists it to just after test, or first.
|
|
480
|
+
val si = rest.indexOf("station")
|
|
481
|
+
if (0 <= si) {
|
|
482
|
+
rest.remove(si)
|
|
483
|
+
rest.add(rest.indexOf("test") + 1, "station")
|
|
474
484
|
}
|
|
485
|
+
featureorder.addAll(rest)
|
|
475
486
|
}
|
|
476
487
|
|
|
477
488
|
val derived = new LinkedHashMap[String, Object]()
|
|
478
|
-
derived.put("clean", cleancfg)
|
|
479
489
|
derived.put("featureorder", featureorder)
|
|
480
490
|
opts.put("__derived__", derived)
|
|
481
491
|
|
|
492
|
+
// Beside the options, not in them: optionsMap hands them to callers.
|
|
493
|
+
ctx.cleancfg = cleancfg
|
|
494
|
+
|
|
482
495
|
// Again over the merged result: the config's own defaults can carry one.
|
|
483
496
|
addSensitiveOptions(cleancfg, opts, "clean", "__derived__")
|
|
484
497
|
|
|
485
498
|
opts
|
|
486
499
|
}
|
|
487
500
|
|
|
501
|
+
// This struct port's `$FUNCTION` admits only a java.util.function Function or
|
|
502
|
+
// Supplier, so a callback in a slot the spec types as a function is held out
|
|
503
|
+
// of validation and put back; any other key is still validated.
|
|
504
|
+
private def holdCallbacks(opts: Object, optspec: JMap[String, Object]): java.util.List[Array[Object]] = {
|
|
505
|
+
val held = new ArrayList[Array[Object]]()
|
|
506
|
+
val feature = Helpers.toMapAny(Helpers.toMapAny(opts) match { case null => null; case m => m.get("feature") })
|
|
507
|
+
val fspecs = Helpers.toMapAny(optspec.get("feature"))
|
|
508
|
+
if (feature != null && fspecs != null) feature.forEach((name, fopts) => {
|
|
509
|
+
val fm = Helpers.toMapAny(fopts)
|
|
510
|
+
val fspec = specMap(fspecs.get(name))
|
|
511
|
+
if (fm != null && fspec != null) new ArrayList[String](fm.keySet()).forEach(key => {
|
|
512
|
+
if (isFunctionSpec(fspec.get(key)) && isCallback(fm.get(key)))
|
|
513
|
+
held.add(Array[Object](name, key, fm.remove(key)))
|
|
514
|
+
})
|
|
515
|
+
})
|
|
516
|
+
held
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
private def specMap(spec: Object): JMap[String, Object] = spec match {
|
|
520
|
+
case alts: java.util.List[_] =>
|
|
521
|
+
val from = if (!alts.isEmpty && "`$NOF`" == alts.get(0)) 2 else 0
|
|
522
|
+
var found: JMap[String, Object] = null
|
|
523
|
+
var i = from
|
|
524
|
+
while (found == null && i < alts.size) {
|
|
525
|
+
found = Helpers.toMapAny(alts.get(i))
|
|
526
|
+
i += 1
|
|
527
|
+
}
|
|
528
|
+
found
|
|
529
|
+
case _ => Helpers.toMapAny(spec)
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
private def isFunctionSpec(spec: Object): Boolean =
|
|
533
|
+
"`$FUNCTION`" == spec || (spec match { case l: java.util.List[_] => l.contains("`$FUNCTION`"); case _ => false })
|
|
534
|
+
|
|
535
|
+
private def isCallback(v: Object): Boolean = v match {
|
|
536
|
+
case null => false
|
|
537
|
+
case _: Function0[_] | _: Function1[_, _] | _: Function2[_, _, _] | _: Function3[_, _, _, _] => true
|
|
538
|
+
case _ => v.getClass.getInterfaces.exists(i =>
|
|
539
|
+
i.isAnnotationPresent(classOf[FunctionalInterface]) || i.getName.startsWith("java.util.function."))
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
private def restoreCallbacks(opts: JMap[String, Object], held: java.util.List[Array[Object]]): Unit = {
|
|
543
|
+
val feature = Helpers.toMapAny(opts.get("feature"))
|
|
544
|
+
if (feature != null) held.forEach(h => {
|
|
545
|
+
val fm = Helpers.toMapAny(feature.get(h(0)))
|
|
546
|
+
if (fm != null) fm.put(h(1).asInstanceOf[String], h(2))
|
|
547
|
+
})
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// The model's options for a feature sit beneath the caller's, key by key: a
|
|
551
|
+
// key the caller sets replaces the default whole, so a list is never merged.
|
|
552
|
+
private def featureDefaults(cfgfeature: Object, feature: Object): JMap[String, Object] = {
|
|
553
|
+
if (feature != null && !feature.isInstanceOf[JMap[_, _]]) return null
|
|
554
|
+
val out = new LinkedHashMap[String, Object]()
|
|
555
|
+
if (feature != null) out.putAll(feature.asInstanceOf[JMap[String, Object]])
|
|
556
|
+
val cfg = Helpers.toMapAny(cfgfeature)
|
|
557
|
+
if (cfg != null) cfg.forEach((name, fdef) => {
|
|
558
|
+
val fm = Helpers.toMapAny(fdef)
|
|
559
|
+
val dflt = if (fm == null) null else Helpers.toMapAny(fm.get("options"))
|
|
560
|
+
val supplied = out.get(name)
|
|
561
|
+
val skip = dflt == null ||
|
|
562
|
+
(supplied == null && java.lang.Boolean.TRUE != dflt.get("active")) ||
|
|
563
|
+
(supplied != null && !supplied.isInstanceOf[JMap[_, _]])
|
|
564
|
+
if (!skip) {
|
|
565
|
+
val merged = new LinkedHashMap[String, Object](Helpers.toMapAny(Struct.clone(dflt)))
|
|
566
|
+
if (supplied != null) merged.putAll(supplied.asInstanceOf[JMap[String, Object]])
|
|
567
|
+
out.put(name, merged)
|
|
568
|
+
}
|
|
569
|
+
})
|
|
570
|
+
out
|
|
571
|
+
}
|
|
572
|
+
|
|
488
573
|
// A feature's name is not a field name: a feature called `secrets` does not
|
|
489
574
|
// make every one of its options a secret. Entity blocks (entity settings,
|
|
490
575
|
// seeded records) hold no credential, and nor do rbac's rules, keyed by
|
|
@@ -83,15 +83,12 @@ object Clean {
|
|
|
83
83
|
)
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
// A context without
|
|
87
|
-
// the schema defaults.
|
|
86
|
+
// A context without a registry (makeError accepts a bare one) still masks
|
|
87
|
+
// by the schema defaults.
|
|
88
88
|
private def cleanConfig(ctx: Context): CleanConfig = {
|
|
89
|
-
if (ctx != null
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
case c: CleanConfig => return c
|
|
93
|
-
case _ =>
|
|
94
|
-
}
|
|
89
|
+
if (ctx != null) ctx.cleancfg match {
|
|
90
|
+
case c: CleanConfig => return c
|
|
91
|
+
case _ =>
|
|
95
92
|
}
|
|
96
93
|
makeCleanConfig(Schema.optspec.get("clean"))
|
|
97
94
|
}
|
|
@@ -24,6 +24,8 @@ public final class Context {
|
|
|
24
24
|
public var config: VMap?
|
|
25
25
|
public var entopts: VMap?
|
|
26
26
|
public var options: VMap?
|
|
27
|
+
// The clean registry, beside the options rather than in them.
|
|
28
|
+
public var cleancfg: Utility.CleanConfig?
|
|
27
29
|
public var opmap: [String: Operation] = [:]
|
|
28
30
|
public var response: Response?
|
|
29
31
|
public var result: Result?
|
|
@@ -79,6 +81,7 @@ public final class Context {
|
|
|
79
81
|
// Options
|
|
80
82
|
if let om = ctxProp(ctxmap, "options") as? VMap { options = om }
|
|
81
83
|
if options == nil, let b = basectx { options = b.options }
|
|
84
|
+
cleancfg = (ctxProp(ctxmap, "cleancfg") as? Utility.CleanConfig) ?? basectx?.cleancfg
|
|
82
85
|
|
|
83
86
|
// Entity
|
|
84
87
|
if let ent = ctxProp(ctxmap, "entity") as? Entity { entity = ent }
|
|
@@ -93,8 +93,9 @@ public final class AuditFeature: BaseFeature {
|
|
|
93
93
|
records.removeFirst()
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
// A sink may throw; its failure never changes the operation's outcome.
|
|
97
|
+
if let sink = gp(options, "sink").asNative as? (VMap) throws -> Void {
|
|
98
|
+
try? sink(record)
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
// Response caching for safe (read) requests
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// first) and every hit/miss/bypass is counted. Bodies are snapshotted on
|
|
7
|
-
// capture so both the current caller and later hits can re-read the JSON body
|
|
8
|
-
// 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
|
+
// Foundation on Linux has no HMAC: the seeded Hasher over a random per-client
|
|
4
|
+
// salt separates header sets within one store without holding a header value.
|
|
5
|
+
// It is not a cryptographic commitment.
|
|
9
6
|
|
|
10
7
|
import Foundation
|
|
11
8
|
|
|
@@ -14,6 +11,10 @@ public final class CacheFeature: BaseFeature {
|
|
|
14
11
|
private var options: VMap?
|
|
15
12
|
private var store: [String: CacheEntry] = [:]
|
|
16
13
|
private var order: [String] = []
|
|
14
|
+
private var salt: [UInt8] = []
|
|
15
|
+
|
|
16
|
+
private static let safeMethods: Set<String> = ["GET", "HEAD"]
|
|
17
|
+
private static let unstored: Set<String> = ["no-store", "private", "no-cache"]
|
|
17
18
|
|
|
18
19
|
// Activity tracking (mirrors the ts client._cache record).
|
|
19
20
|
public var hit = 0
|
|
@@ -22,6 +23,7 @@ public final class CacheFeature: BaseFeature {
|
|
|
22
23
|
|
|
23
24
|
private final class CacheEntry {
|
|
24
25
|
var expiry: Int64 = 0
|
|
26
|
+
var scope: String = ""
|
|
25
27
|
var snapshot: CacheSnapshot = CacheSnapshot()
|
|
26
28
|
}
|
|
27
29
|
|
|
@@ -50,6 +52,8 @@ public final class CacheFeature: BaseFeature {
|
|
|
50
52
|
|
|
51
53
|
store = [:]
|
|
52
54
|
order = []
|
|
55
|
+
var rng = SystemRandomNumberGenerator()
|
|
56
|
+
salt = (0..<32).map { _ in UInt8.random(in: 0...255, using: &rng) }
|
|
53
57
|
|
|
54
58
|
let inner = ctx.utility!.fetcher!
|
|
55
59
|
|
|
@@ -68,10 +72,14 @@ public final class CacheFeature: BaseFeature {
|
|
|
68
72
|
let methods = foptStrList(options, "methods") ?? ["GET"]
|
|
69
73
|
let cacheable = methods.contains { $0.uppercased() == method }
|
|
70
74
|
if !cacheable {
|
|
75
|
+
if CacheFeature.safeMethods.contains(method) {
|
|
76
|
+
return try inner(ctx, url, fetchdef)
|
|
77
|
+
}
|
|
78
|
+
defer { invalidate(url) }
|
|
71
79
|
return try inner(ctx, url, fetchdef)
|
|
72
80
|
}
|
|
73
81
|
|
|
74
|
-
let key = method + " " + url
|
|
82
|
+
let key = method + " " + url + " " + digest(fetchdef.entries["headers"])
|
|
75
83
|
let now = foptNow(options)()
|
|
76
84
|
|
|
77
85
|
if let entry = store[key], entry.expiry > now {
|
|
@@ -95,10 +103,16 @@ public final class CacheFeature: BaseFeature {
|
|
|
95
103
|
|
|
96
104
|
if err == nil && CacheFeature.storable(res) {
|
|
97
105
|
let snap = CacheFeature.snapshot(res)
|
|
98
|
-
let ttl = foptInt(options, "ttl", 5000)
|
|
106
|
+
let ttl = CacheFeature.lifetime(snap.headers, Int64(foptInt(options, "ttl", 5000)))
|
|
107
|
+
if ttl <= 0 {
|
|
108
|
+
bypass += 1
|
|
109
|
+
return CacheFeature.replay(snap)
|
|
110
|
+
}
|
|
111
|
+
drop(key)
|
|
99
112
|
evict()
|
|
100
113
|
let entry = CacheEntry()
|
|
101
|
-
entry.expiry = now +
|
|
114
|
+
entry.expiry = now + ttl
|
|
115
|
+
entry.scope = CacheFeature.scope(url)
|
|
102
116
|
entry.snapshot = snap
|
|
103
117
|
store[key] = entry
|
|
104
118
|
order.append(key)
|
|
@@ -113,6 +127,103 @@ public final class CacheFeature: BaseFeature {
|
|
|
113
127
|
return res
|
|
114
128
|
}
|
|
115
129
|
|
|
130
|
+
private func digest(_ headers: Value?) -> String {
|
|
131
|
+
var pairs: [(String, String)] = []
|
|
132
|
+
if let hm = headers?.asMap {
|
|
133
|
+
for (k, v) in hm.entries {
|
|
134
|
+
if let text = CacheFeature.headerText(v) {
|
|
135
|
+
pairs.append((k.lowercased(), text))
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
pairs.sort { $0.0 != $1.0 ? $0.0 < $1.0 : $0.1 < $1.1 }
|
|
140
|
+
var hasher = Hasher()
|
|
141
|
+
hasher.combine(salt)
|
|
142
|
+
for (k, v) in pairs {
|
|
143
|
+
hasher.combine(k + ":" + v + "\n")
|
|
144
|
+
}
|
|
145
|
+
return String(UInt64(bitPattern: Int64(hasher.finalize())), radix: 16)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private static func headerText(_ v: Value) -> String? {
|
|
149
|
+
switch v {
|
|
150
|
+
case .noval, .null: return nil
|
|
151
|
+
case .string(let s): return s
|
|
152
|
+
case .int(let n): return String(n)
|
|
153
|
+
case .bool(let b): return String(b)
|
|
154
|
+
default: return "\(v)"
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
private func invalidate(_ url: String) {
|
|
159
|
+
let path = CacheFeature.scope(url)
|
|
160
|
+
let collection = CacheFeature.parent(path)
|
|
161
|
+
for (key, entry) in store
|
|
162
|
+
where CacheFeature.under(entry.scope, path) || entry.scope == collection {
|
|
163
|
+
drop(key)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private func drop(_ key: String) {
|
|
168
|
+
if store.removeValue(forKey: key) != nil {
|
|
169
|
+
order.removeAll { $0 == key }
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// The configured ttl capped by the response's Cache-Control; zero when the
|
|
174
|
+
// response may not be stored.
|
|
175
|
+
private static func lifetime(_ headers: VMap, _ ttl: Int64) -> Int64 {
|
|
176
|
+
var control = ""
|
|
177
|
+
for (k, v) in headers.entries where k.lowercased() == "cache-control" {
|
|
178
|
+
control = (headerText(v) ?? "").lowercased()
|
|
179
|
+
}
|
|
180
|
+
var life = ttl
|
|
181
|
+
for part in control.split(separator: ",", omittingEmptySubsequences: false) {
|
|
182
|
+
let directive = part.trimmingCharacters(in: .whitespaces)
|
|
183
|
+
if unstored.contains(directive) {
|
|
184
|
+
return 0
|
|
185
|
+
}
|
|
186
|
+
if directive.hasPrefix("max-age") {
|
|
187
|
+
var value = directive.dropFirst("max-age".count).trimmingCharacters(in: .whitespaces)
|
|
188
|
+
if value.hasPrefix("=") {
|
|
189
|
+
value = value.dropFirst().trimmingCharacters(in: .whitespaces)
|
|
190
|
+
.trimmingCharacters(in: CharacterSet(charactersIn: "\""))
|
|
191
|
+
if !value.isEmpty, value.count < 16, value.allSatisfy({ $0.isASCII && $0.isNumber }),
|
|
192
|
+
let secs = Int64(value) {
|
|
193
|
+
life = min(life, secs * 1000)
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return life
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
private static func scope(_ url: String) -> String {
|
|
202
|
+
var out = String(url.split(maxSplits: 1, omittingEmptySubsequences: false) { $0 == "?" || $0 == "#" }[0])
|
|
203
|
+
while out.hasSuffix("/") {
|
|
204
|
+
out.removeLast()
|
|
205
|
+
}
|
|
206
|
+
return out
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
private static func parent(_ scope: String) -> String {
|
|
210
|
+
let chars = Array(scope)
|
|
211
|
+
var root = 0
|
|
212
|
+
if let scheme = scope.range(of: "://") {
|
|
213
|
+
let after = scope.distance(from: scope.startIndex, to: scheme.upperBound)
|
|
214
|
+
guard let slash = chars[after...].firstIndex(of: "/") else {
|
|
215
|
+
return scope
|
|
216
|
+
}
|
|
217
|
+
root = slash
|
|
218
|
+
}
|
|
219
|
+
let cut = chars.lastIndex(of: "/") ?? 0
|
|
220
|
+
return String(chars[0..<Swift.max(cut, root)])
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
private static func under(_ scope: String, _ prefix: String) -> Bool {
|
|
224
|
+
return scope == prefix || scope.hasPrefix(prefix + "/")
|
|
225
|
+
}
|
|
226
|
+
|
|
116
227
|
// A body the transport could not read as JSON passes through, for the operation to report.
|
|
117
228
|
private static func storable(_ res: Value) -> Bool {
|
|
118
229
|
let (status, has) = fresStatus(res)
|
|
@@ -14,6 +14,16 @@ public final class MetricsBucket {
|
|
|
14
14
|
public var totalMs: Int64 = 0
|
|
15
15
|
public var maxMs: Int64 = 0
|
|
16
16
|
public init() {}
|
|
17
|
+
|
|
18
|
+
func record() -> VMap {
|
|
19
|
+
let out = VMap()
|
|
20
|
+
out.entries["count"] = .int(Int64(count))
|
|
21
|
+
out.entries["ok"] = .int(Int64(ok))
|
|
22
|
+
out.entries["err"] = .int(Int64(err))
|
|
23
|
+
out.entries["totalMs"] = .int(totalMs)
|
|
24
|
+
out.entries["maxMs"] = .int(maxMs)
|
|
25
|
+
return out
|
|
26
|
+
}
|
|
17
27
|
}
|
|
18
28
|
|
|
19
29
|
public final class MetricsFeature: BaseFeature {
|
|
@@ -86,6 +96,16 @@ public final class MetricsFeature: BaseFeature {
|
|
|
86
96
|
|
|
87
97
|
bump(total, ok, dur)
|
|
88
98
|
bump(op, ok, dur)
|
|
99
|
+
|
|
100
|
+
// A sink may throw; its failure never changes the operation's outcome.
|
|
101
|
+
if let sink = gp(options, "sink").asNative as? (VMap) throws -> Void {
|
|
102
|
+
let opsOut = VMap()
|
|
103
|
+
for (k, b) in ops { opsOut.entries[k] = .map(b.record()) }
|
|
104
|
+
let raw = VMap()
|
|
105
|
+
raw.entries["total"] = .map(total.record())
|
|
106
|
+
raw.entries["ops"] = .map(opsOut)
|
|
107
|
+
try? sink(fclean(ctx, raw))
|
|
108
|
+
}
|
|
89
109
|
}
|
|
90
110
|
|
|
91
111
|
private func bump(_ bucket: MetricsBucket, _ ok: Bool, _ dur: Int64) {
|
|
@@ -65,6 +65,9 @@ public final class PagingFeature: BaseFeature {
|
|
|
65
65
|
|
|
66
66
|
if hasCursor {
|
|
67
67
|
spec.query.entries[cursorParam] = cursor
|
|
68
|
+
} else if let paging = paging, let link = gp(paging, "next").asString,
|
|
69
|
+
!PagingFeature.foreign(link, spec.base) {
|
|
70
|
+
PagingFeature.follow(spec, link)
|
|
68
71
|
} else if isNil(gp(spec.query, pageParam)) {
|
|
69
72
|
var page: Value? = nil
|
|
70
73
|
if let paging = paging {
|
|
@@ -183,8 +186,12 @@ public final class PagingFeature: BaseFeature {
|
|
|
183
186
|
// Body-level signals; snake_case forms are read first so camelCase wins.
|
|
184
187
|
if let bm = body.asMap {
|
|
185
188
|
let next = gp(bm, "next")
|
|
186
|
-
if !isNil(next)
|
|
187
|
-
|
|
189
|
+
if !isNil(next) {
|
|
190
|
+
if !PagingFeature.isLink(next.asString, foptStr(options, "next", "auto")) {
|
|
191
|
+
paging.entries["cursor"] = next
|
|
192
|
+
} else if isNil(gp(paging, "next")) {
|
|
193
|
+
paging.entries["next"] = next
|
|
194
|
+
}
|
|
188
195
|
}
|
|
189
196
|
let snakeCursor = gp(bm, "next_cursor")
|
|
190
197
|
if !isNil(snakeCursor) {
|
|
@@ -216,6 +223,16 @@ public final class PagingFeature: BaseFeature {
|
|
|
216
223
|
}
|
|
217
224
|
}
|
|
218
225
|
|
|
226
|
+
// A link to another origin is recorded, never followed, and ends the walk.
|
|
227
|
+
let base = ctx.spec?.base ?? gp(ctx.options, "base").asString ?? ""
|
|
228
|
+
if let link = gp(paging, "next").asString, let spec = ctx.spec {
|
|
229
|
+
paging.entries["next"] = .string(PagingFeature.resolve(link, spec.url))
|
|
230
|
+
}
|
|
231
|
+
if let link = gp(paging, "next").asString, PagingFeature.foreign(link, base) {
|
|
232
|
+
paging.entries["foreign"] = .string(link)
|
|
233
|
+
_ = paging.entries.removeValue(forKey: "next")
|
|
234
|
+
}
|
|
235
|
+
|
|
219
236
|
// Cursor presence only INFERS another page. When the server stated the
|
|
220
237
|
// answer outright - relay's `hasNextPage: false`, or a body `hasMore` -
|
|
221
238
|
// that wins: a final page normally carries both an end cursor and
|
|
@@ -227,6 +244,10 @@ public final class PagingFeature: BaseFeature {
|
|
|
227
244
|
paging.entries["hasMore"] = .bool(true)
|
|
228
245
|
}
|
|
229
246
|
|
|
247
|
+
if !isNil(gp(paging, "foreign")) && isNil(gp(paging, "cursor")) && isNil(gp(paging, "nextPage")) {
|
|
248
|
+
paging.entries["hasMore"] = .bool(false)
|
|
249
|
+
}
|
|
250
|
+
|
|
230
251
|
result.paging = paging
|
|
231
252
|
last = paging
|
|
232
253
|
|
|
@@ -239,6 +260,85 @@ public final class PagingFeature: BaseFeature {
|
|
|
239
260
|
}
|
|
240
261
|
}
|
|
241
262
|
|
|
263
|
+
private static let origin = try! NSRegularExpression(
|
|
264
|
+
pattern: "^[a-z][a-z0-9+.-]*://[^/?#]*", options: [.caseInsensitive])
|
|
265
|
+
|
|
266
|
+
private static func originOf(_ text: String) -> String {
|
|
267
|
+
let range = NSRange(text.startIndex..., in: text)
|
|
268
|
+
guard let m = origin.firstMatch(in: text, options: [], range: range),
|
|
269
|
+
let r = Range(m.range, in: text) else {
|
|
270
|
+
return ""
|
|
271
|
+
}
|
|
272
|
+
return String(text[r])
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Under the `next` option's default, a URL or an absolute path is a link and
|
|
276
|
+
// anything else a cursor; `cursor` and `url` pin the reading.
|
|
277
|
+
static func isLink(_ next: String?, _ mode: String) -> Bool {
|
|
278
|
+
guard let next = next else { return false }
|
|
279
|
+
return mode == "url" || (mode != "cursor" && (originOf(next) != "" || next.hasPrefix("/")))
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
static func foreign(_ link: String, _ base: String) -> Bool {
|
|
283
|
+
let origin = originOf(link).lowercased()
|
|
284
|
+
return origin != "" && origin != originOf(base).lowercased()
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
private static let scheme = try! NSRegularExpression(
|
|
288
|
+
pattern: "^[a-z][a-z0-9+.-]*:", options: [.caseInsensitive])
|
|
289
|
+
|
|
290
|
+
// RFC 3986 reference resolution against the URL of the request that
|
|
291
|
+
// returned the link. A link on that URL's origin comes back as its path and
|
|
292
|
+
// query; an absolute link is left as the server wrote it.
|
|
293
|
+
static func resolve(_ link: String, _ url: String) -> String {
|
|
294
|
+
if url.isEmpty || nil != scheme.firstMatch(in: link, options: [], range: NSRange(link.startIndex..., in: link)) {
|
|
295
|
+
return link
|
|
296
|
+
}
|
|
297
|
+
let holder = "http://placeholder.invalid" + (url.hasPrefix("/") ? "" : "/")
|
|
298
|
+
guard let from = URL(string: originOf(url).isEmpty ? holder + url : url),
|
|
299
|
+
let to = URL(string: link, relativeTo: from)?.absoluteURL,
|
|
300
|
+
var parts = URLComponents(url: to, resolvingAgainstBaseURL: false) else {
|
|
301
|
+
return link
|
|
302
|
+
}
|
|
303
|
+
parts.fragment = nil
|
|
304
|
+
if to.scheme != from.scheme || to.host != from.host || to.port != from.port {
|
|
305
|
+
return parts.string ?? link
|
|
306
|
+
}
|
|
307
|
+
return parts.percentEncodedPath + (nil == parts.percentEncodedQuery ? "" : "?" + parts.percentEncodedQuery!)
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// The request goes to the link's path and query, on the SDK's own origin.
|
|
311
|
+
static func follow(_ spec: Spec, _ next: String) {
|
|
312
|
+
var rest = String(next.dropFirst(originOf(next).count))
|
|
313
|
+
if let hash = rest.firstIndex(of: "#") {
|
|
314
|
+
rest = String(rest[..<hash])
|
|
315
|
+
}
|
|
316
|
+
let parts = rest.split(separator: "?", maxSplits: 1, omittingEmptySubsequences: false)
|
|
317
|
+
let path = parts.isEmpty ? "" : String(parts[0])
|
|
318
|
+
let rawquery = parts.count > 1 ? String(parts[1]) : ""
|
|
319
|
+
|
|
320
|
+
let query = VMap()
|
|
321
|
+
for pair in rawquery.split(separator: "&") {
|
|
322
|
+
let kv = pair.split(separator: "=", maxSplits: 1, omittingEmptySubsequences: false)
|
|
323
|
+
let key = unescape(String(kv[0]))
|
|
324
|
+
query.entries[key] = .string(unescape(kv.count > 1 ? String(kv[1]) : ""))
|
|
325
|
+
}
|
|
326
|
+
for key in spec.authquery {
|
|
327
|
+
query.entries[key] = gp(spec.query, key)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
spec.base = originOf(spec.base)
|
|
331
|
+
spec.prefix = ""
|
|
332
|
+
spec.path = path
|
|
333
|
+
spec.suffix = ""
|
|
334
|
+
spec.query = query
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
private static func unescape(_ text: String) -> String {
|
|
338
|
+
let spaced = text.replacingOccurrences(of: "+", with: " ")
|
|
339
|
+
return spaced.removingPercentEncoding ?? spaced
|
|
340
|
+
}
|
|
341
|
+
|
|
242
342
|
private func isList(_ ctx: Context) -> Bool {
|
|
243
343
|
let opname = ctx.op?.name ?? ""
|
|
244
344
|
let ops = foptStrList(options, "ops") ?? ["list"]
|
|
@@ -10,6 +10,7 @@ import Foundation
|
|
|
10
10
|
public final class RatelimitFeature: BaseFeature {
|
|
11
11
|
private var client: ProjectNameSDK?
|
|
12
12
|
private var options: VMap?
|
|
13
|
+
private let lock = NSLock()
|
|
13
14
|
private var tokens: Double = 0
|
|
14
15
|
private var last: Int64 = 0
|
|
15
16
|
|
|
@@ -47,29 +48,34 @@ public final class RatelimitFeature: BaseFeature {
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
private func acquire() {
|
|
51
|
+
let wait = reserve()
|
|
52
|
+
if wait > 0 {
|
|
53
|
+
foptSleep(options)(wait)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Refill, then reserve this call's token before any wait, under the lock:
|
|
58
|
+
// a negative count is the calls already queued, so overlapping calls pace
|
|
59
|
+
// in turn.
|
|
60
|
+
private func reserve() -> Int {
|
|
50
61
|
let rate = foptNum(options, "rate", 5)
|
|
51
62
|
let burst = foptNum(options, "burst", rate)
|
|
52
63
|
|
|
53
|
-
|
|
64
|
+
lock.lock()
|
|
65
|
+
defer { lock.unlock() }
|
|
66
|
+
|
|
54
67
|
let now = foptNow(options)()
|
|
55
68
|
let elapsed = now - last
|
|
56
69
|
last = now
|
|
57
|
-
tokens = min(burst, tokens + (Double(elapsed) / 1000.0) * rate)
|
|
70
|
+
tokens = min(burst, tokens + (Double(elapsed) / 1000.0) * rate) - 1
|
|
58
71
|
|
|
59
|
-
if tokens >=
|
|
60
|
-
|
|
61
|
-
return
|
|
72
|
+
if tokens >= 0 {
|
|
73
|
+
return 0
|
|
62
74
|
}
|
|
63
75
|
|
|
64
|
-
|
|
65
|
-
let needed = 1 - tokens
|
|
66
|
-
let wait = Int(ceil((needed / rate) * 1000))
|
|
76
|
+
let wait = Int(ceil((-tokens / rate) * 1000))
|
|
67
77
|
track(wait)
|
|
68
|
-
|
|
69
|
-
foptSleep(options)(wait)
|
|
70
|
-
}
|
|
71
|
-
last = foptNow(options)()
|
|
72
|
-
tokens = 0
|
|
78
|
+
return wait
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
private func track(_ wait: Int) {
|