@voxgig/sdkgen 4.51.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 +1 -1
- 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/src/cmp/c/TestClean_c.ts +12 -11
- package/project/.sdk/src/cmp/c/fragment/Entity.fragment.c +17 -10
- package/project/.sdk/src/cmp/clojure/fragment/Entity.fragment.clj +18 -1
- package/project/.sdk/src/cmp/cpp/TestClean_cpp.ts +2 -1
- 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 +2 -1
- 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/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 +9 -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/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 +9 -4
- package/project/.sdk/src/cmp/kotlin/fragment/EntityBase.fragment.kt +19 -0
- package/project/.sdk/src/cmp/lua/TestClean_lua.ts +2 -1
- 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 +2 -1
- package/project/.sdk/src/cmp/ocaml/fragment/RunOp.fragment.ml +36 -21
- package/project/.sdk/src/cmp/perl/TestClean_perl.ts +1 -1
- 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/fragment/Entity.fragment.php +33 -4
- package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +13 -6
- 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 +1 -1
- 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 +14 -17
- package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +22 -2
- package/project/.sdk/src/cmp/scala/TestClean_scala.ts +11 -11
- package/project/.sdk/src/cmp/scala/fragment/EntityBase.fragment.scala +14 -0
- package/project/.sdk/src/cmp/swift/TestClean_swift.ts +11 -11
- 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/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 +11 -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/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/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 +184 -0
- package/project/.sdk/tm/c/tests/primary_utility_test.c +2 -0
- package/project/.sdk/tm/c/utility/make_options.c +80 -9
- package/project/.sdk/tm/clojure/src/sdk/core.clj +31 -11
- package/project/.sdk/tm/clojure/src/sdk/features.clj +198 -70
- package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +70 -1
- package/project/.sdk/tm/cpp/core/types.hpp +137 -68
- package/project/.sdk/tm/cpp/feature/audit.hpp +6 -1
- 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/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 +137 -0
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +35 -5
- package/project/.sdk/tm/csharp/feature/AuditFeature.cs +8 -1
- 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/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 +162 -0
- package/project/.sdk/tm/csharp/utility/MakeOptions.cs +89 -12
- 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/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 +59 -35
- package/project/.sdk/tm/elixir/test/feature_test.exs +137 -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/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/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 +209 -28
- package/project/.sdk/tm/go/test/feature_test.go +32 -0
- package/project/.sdk/tm/go/utility/make_options.go +111 -6
- 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/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/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 +170 -17
- package/project/.sdk/tm/java/utility/MakeOptions.java +128 -14
- package/project/.sdk/tm/js/src/feature/metrics/MetricsFeature.js +8 -3
- package/project/.sdk/tm/js/src/feature/paging/PagingFeature.js +99 -1
- package/project/.sdk/tm/js/src/feature/ratelimit/RatelimitFeature.js +5 -9
- package/project/.sdk/tm/js/src/feature/retry/RetryFeature.js +25 -3
- 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/utility/MakeOptionsUtility.js +55 -6
- package/project/.sdk/tm/js/test/feature/Corpus.test.js +95 -25
- package/project/.sdk/tm/js/test/feature.test.js +14 -1
- 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/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/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 +114 -0
- package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +83 -14
- 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/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 +100 -3
- package/project/.sdk/tm/lua/utility/make_options.lua +55 -13
- package/project/.sdk/tm/ocaml/sdk_features.ml +286 -60
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +34 -11
- package/project/.sdk/tm/ocaml/test/t_feature.ml +72 -1
- 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/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 +2 -2
- package/project/.sdk/tm/perl/t/feature_corpus.t +126 -23
- package/project/.sdk/tm/perl/utility/make_options.pm +33 -10
- 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/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 +151 -16
- package/project/.sdk/tm/php/utility/MakeOptions.php +40 -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/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/make_options.py +68 -20
- package/project/.sdk/tm/py/test/test_feature.py +11 -1
- package/project/.sdk/tm/py/test/test_feature_corpus.py +111 -16
- 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/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/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 +108 -24
- package/project/.sdk/tm/rb/test/feature_test.rb +1 -1
- package/project/.sdk/tm/rb/utility/make_options.rb +32 -11
- package/project/.sdk/tm/rust/feature/audit.rs +2 -2
- 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/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_test.rs +174 -0
- package/project/.sdk/tm/rust/tests/primary_utility_test.rs +1 -0
- package/project/.sdk/tm/rust/utility/make_options.rs +122 -27
- 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/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/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 +41 -0
- package/project/.sdk/tm/scala/utility/Make.scala +96 -13
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/AuditFeature.swift +3 -2
- 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/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/MakeOptions.swift +51 -13
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +111 -0
- package/project/.sdk/tm/ts/src/feature/metrics/MetricsFeature.ts +5 -0
- package/project/.sdk/tm/ts/src/feature/paging/PagingFeature.ts +99 -1
- package/project/.sdk/tm/ts/src/feature/ratelimit/RatelimitFeature.ts +5 -9
- package/project/.sdk/tm/ts/src/feature/retry/RetryFeature.ts +25 -3
- 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/utility/MakeOptionsUtility.ts +57 -6
- package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +95 -25
- package/project/.sdk/tm/ts/test/feature.test.ts +14 -1
- package/project/.sdk/tm/zig/core/utility.zig +107 -8
- 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/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 +109 -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
|
@@ -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)
|
|
@@ -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
|
}
|
|
@@ -116,34 +116,9 @@ public class TestFeature : BaseFeature
|
|
|
116
116
|
var entmap = Helpers.ToMapAny(StructUtils.GetProp(entity, op.Entity))
|
|
117
117
|
?? new Dictionary<string, object?>();
|
|
118
118
|
|
|
119
|
-
// For single-entity ops (load, remove) with an empty explicit
|
|
120
|
-
// match, fall back to the id the entity client already knows from
|
|
121
|
-
// a prior create/load (in ctx.Match / ctx.Data). Mirrors the TS
|
|
122
|
-
// mock where param() resolves the id from that accumulated state.
|
|
123
|
-
Dictionary<string, object?> ResolveMatch(Dictionary<string, object?> explicitMatch)
|
|
124
|
-
{
|
|
125
|
-
if (explicitMatch.Count > 0)
|
|
126
|
-
{
|
|
127
|
-
return explicitMatch;
|
|
128
|
-
}
|
|
129
|
-
foreach (var src in new object?[] { ctx2.Match, ctx2.Data })
|
|
130
|
-
{
|
|
131
|
-
if (src == null)
|
|
132
|
-
{
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
var v = StructUtils.GetProp(src, "id");
|
|
136
|
-
if (v != null && !Equals(v, "__UNDEFINED__"))
|
|
137
|
-
{
|
|
138
|
-
return new Dictionary<string, object?> { ["id"] = v };
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return new Dictionary<string, object?>();
|
|
142
|
-
}
|
|
143
|
-
|
|
144
119
|
if (op.Name == "load")
|
|
145
120
|
{
|
|
146
|
-
var args = BuildArgs(ctx2, op,
|
|
121
|
+
var args = BuildArgs(ctx2, op, ctx2.Reqmatch);
|
|
147
122
|
var found = StructUtils.Select(entmap, args);
|
|
148
123
|
var ent = StructUtils.GetElem(found, 0);
|
|
149
124
|
if (ent == null)
|
|
@@ -177,30 +152,7 @@ public class TestFeature : BaseFeature
|
|
|
177
152
|
}
|
|
178
153
|
else if (op.Name == "update" || op.Name == "patch")
|
|
179
154
|
{
|
|
180
|
-
|
|
181
|
-
// Reqdata also contains the new field values, which would
|
|
182
|
-
// otherwise cause Select to filter out the entity we want to
|
|
183
|
-
// update. When reqdata has no id, fall back to the id the
|
|
184
|
-
// entity client carries from a prior create/load.
|
|
185
|
-
var updateMatch = new Dictionary<string, object?>();
|
|
186
|
-
if (ctx2.Reqdata != null)
|
|
187
|
-
{
|
|
188
|
-
if (ctx2.Reqdata.TryGetValue("id", out var idv))
|
|
189
|
-
{
|
|
190
|
-
updateMatch["id"] = idv;
|
|
191
|
-
}
|
|
192
|
-
if (op.Alias != null &&
|
|
193
|
-
StructUtils.GetProp(op.Alias, "id") is string aliasId &&
|
|
194
|
-
ctx2.Reqdata.TryGetValue(aliasId, out var av))
|
|
195
|
-
{
|
|
196
|
-
updateMatch[aliasId] = av;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
if (updateMatch.Count == 0)
|
|
200
|
-
{
|
|
201
|
-
updateMatch = ResolveMatch(new Dictionary<string, object?>());
|
|
202
|
-
}
|
|
203
|
-
var args = BuildArgs(ctx2, op, updateMatch);
|
|
155
|
+
var args = BuildArgs(ctx2, op, Record(ctx2.Reqdata));
|
|
204
156
|
var found = StructUtils.Select(entmap, args);
|
|
205
157
|
var ent = StructUtils.GetElem(found, 0);
|
|
206
158
|
if (ent == null)
|
|
@@ -221,7 +173,7 @@ public class TestFeature : BaseFeature
|
|
|
221
173
|
}
|
|
222
174
|
else if (op.Name == "remove")
|
|
223
175
|
{
|
|
224
|
-
var args = BuildArgs(ctx2, op,
|
|
176
|
+
var args = BuildArgs(ctx2, op, ctx2.Reqmatch);
|
|
225
177
|
var found = StructUtils.Select(entmap, args);
|
|
226
178
|
var ent = StructUtils.GetElem(found, 0);
|
|
227
179
|
// Remove only the first matched entity. If nothing matches,
|
|
@@ -384,6 +336,12 @@ public class TestFeature : BaseFeature
|
|
|
384
336
|
return m.Success ? m.Groups[1].Value : null;
|
|
385
337
|
}
|
|
386
338
|
|
|
339
|
+
private static bool Held(object? src, string key)
|
|
340
|
+
{
|
|
341
|
+
var v = src == null ? null : StructUtils.GetProp(src, key);
|
|
342
|
+
return v != null && !Equals(v, "__UNDEFINED__");
|
|
343
|
+
}
|
|
344
|
+
|
|
387
345
|
private static object BuildArgs(Context ctx, Operation op, Dictionary<string, object?>? args)
|
|
388
346
|
{
|
|
389
347
|
var opname = op.Name;
|
|
@@ -442,30 +400,60 @@ public class TestFeature : BaseFeature
|
|
|
442
400
|
var qand = new List<object?>();
|
|
443
401
|
var q = new Dictionary<string, object?> { ["`$AND`"] = qand };
|
|
444
402
|
|
|
445
|
-
|
|
403
|
+
var entityName = ctx.Entity!.GetName();
|
|
404
|
+
var idfrom = StructUtils.GetPath(ctx.Config, StructUtils.Jt("entity", entityName, "id", "from"));
|
|
405
|
+
|
|
406
|
+
var names = args == null ? new List<string>() : new List<string>(StructUtils.KeysOf(args));
|
|
407
|
+
|
|
408
|
+
// With no id in the call, the entity's held id (or composite parts) stands in.
|
|
409
|
+
if (args == null || StructUtils.GetProp(args, "id") == null)
|
|
410
|
+
{
|
|
411
|
+
var parts = StructUtils.GetPath(ctx.Config, StructUtils.Jt("entity", entityName, "id", "parts"))
|
|
412
|
+
as List<object?> ?? (opname == "list" ? new List<object?>() : new List<object?> { "id" });
|
|
413
|
+
foreach (var part in parts)
|
|
414
|
+
{
|
|
415
|
+
var pname = Convert.ToString(part) ?? "";
|
|
416
|
+
if (!names.Contains(pname) && (Held(ctx.Match, pname) || Held(ctx.Data, pname)))
|
|
417
|
+
{
|
|
418
|
+
names.Add(pname);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
foreach (var key in names)
|
|
446
424
|
{
|
|
447
|
-
|
|
425
|
+
var isId = key == "id";
|
|
426
|
+
var selected = StructUtils.Select(reqd, key);
|
|
427
|
+
var isReqd = !StructUtils.IsEmpty(selected);
|
|
428
|
+
|
|
429
|
+
if (isId || isReqd)
|
|
448
430
|
{
|
|
449
|
-
var
|
|
450
|
-
var
|
|
451
|
-
var isReqd = !StructUtils.IsEmpty(selected);
|
|
431
|
+
var v = ctx.Utility!.Param(ctx, key);
|
|
432
|
+
var ka = StructUtils.GetProp(op.Alias, key);
|
|
452
433
|
|
|
453
|
-
|
|
434
|
+
var qor = new List<object?>
|
|
435
|
+
{
|
|
436
|
+
new Dictionary<string, object?> { [key] = v },
|
|
437
|
+
};
|
|
438
|
+
if (ka is string kas)
|
|
454
439
|
{
|
|
455
|
-
|
|
456
|
-
|
|
440
|
+
qor.Add(new Dictionary<string, object?> { [kas] = v });
|
|
441
|
+
}
|
|
457
442
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
443
|
+
// An alternative, never a replacement: a seed keeping the
|
|
444
|
+
// parameter flat is still found.
|
|
445
|
+
if (StructUtils.GetProp(idfrom, key) is string kf && kf != key)
|
|
446
|
+
{
|
|
447
|
+
object? nest = v;
|
|
448
|
+
var segs = kf.Split('.');
|
|
449
|
+
for (var i = segs.Length - 1; 0 <= i; i--)
|
|
463
450
|
{
|
|
464
|
-
|
|
451
|
+
nest = new Dictionary<string, object?> { [segs[i]] = nest };
|
|
465
452
|
}
|
|
466
|
-
|
|
467
|
-
qand.Add(new Dictionary<string, object?> { ["`$OR`"] = qor });
|
|
453
|
+
qor.Add(nest);
|
|
468
454
|
}
|
|
455
|
+
|
|
456
|
+
qand.Add(new Dictionary<string, object?> { ["`$OR`"] = qor });
|
|
469
457
|
}
|
|
470
458
|
}
|
|
471
459
|
|
|
@@ -1246,6 +1246,136 @@ public class FeaturePagingTest
|
|
|
1246
1246
|
Assert.Equal(true, res.Result.Paging["hasMore"]);
|
|
1247
1247
|
}
|
|
1248
1248
|
|
|
1249
|
+
// The documented hasMore loop, one request per page.
|
|
1250
|
+
private static List<string> Walk(Func<int, Dictionary<string, object?>> reply,
|
|
1251
|
+
out Dictionary<string, object?> paging, Dictionary<string, object?>? options = null)
|
|
1252
|
+
{
|
|
1253
|
+
var rec = new FhRecorder { Reply = (n, _) => reply(n) };
|
|
1254
|
+
var h = Fh.Make(rec.Fetch, (new PagingFeature(), options));
|
|
1255
|
+
paging = new Dictionary<string, object?>();
|
|
1256
|
+
var ctrl = new Dictionary<string, object?> { ["paging"] = paging };
|
|
1257
|
+
h.Op(new FhOpSpec { Op = "list", Path = "/w", Ctrl = ctrl });
|
|
1258
|
+
while (true.Equals(paging["hasMore"]) && rec.Calls.Count < 4)
|
|
1259
|
+
{
|
|
1260
|
+
h.Op(new FhOpSpec { Op = "list", Path = "/w", Ctrl = ctrl });
|
|
1261
|
+
}
|
|
1262
|
+
return Enumerable.Range(0, rec.Calls.Count).Select(rec.Url).ToList();
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
[Fact]
|
|
1266
|
+
public void BodyNextIsSentAsTheCursor()
|
|
1267
|
+
{
|
|
1268
|
+
if (Fh.SkipWithout("paging")) return;
|
|
1269
|
+
var pages = new object?[] { "c3", "c6", null };
|
|
1270
|
+
var urls = Walk(n => Fh.Response(200, new Dictionary<string, object?>
|
|
1271
|
+
{
|
|
1272
|
+
["next"] = pages[n - 1],
|
|
1273
|
+
}, null), out var paging);
|
|
1274
|
+
Assert.Equal(new List<string>
|
|
1275
|
+
{
|
|
1276
|
+
"http://api.test/w?page=1",
|
|
1277
|
+
"http://api.test/w?cursor=c3",
|
|
1278
|
+
"http://api.test/w?cursor=c6",
|
|
1279
|
+
}, urls);
|
|
1280
|
+
Assert.Equal(false, paging["hasMore"]);
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
[Fact]
|
|
1284
|
+
public void BodyNextUrlIsTheNextRequest()
|
|
1285
|
+
{
|
|
1286
|
+
if (Fh.SkipWithout("paging")) return;
|
|
1287
|
+
var pages = new object?[]
|
|
1288
|
+
{
|
|
1289
|
+
"http://api.test/v2/w?cursor=c%2F3&limit=3", "/v2/w?cursor=c6", null,
|
|
1290
|
+
};
|
|
1291
|
+
var urls = Walk(n => Fh.Response(200, new Dictionary<string, object?>
|
|
1292
|
+
{
|
|
1293
|
+
["next"] = pages[n - 1],
|
|
1294
|
+
}, null), out var paging);
|
|
1295
|
+
Assert.Equal(new List<string>
|
|
1296
|
+
{
|
|
1297
|
+
"http://api.test/w?page=1",
|
|
1298
|
+
"http://api.test/v2/w?cursor=c%2F3&limit=3",
|
|
1299
|
+
"http://api.test/v2/w?cursor=c6",
|
|
1300
|
+
}, urls);
|
|
1301
|
+
Assert.Equal(false, paging["hasMore"]);
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
[Fact]
|
|
1305
|
+
public void LinkNextUrlIsTheNextRequest()
|
|
1306
|
+
{
|
|
1307
|
+
if (Fh.SkipWithout("paging")) return;
|
|
1308
|
+
var links = new[] { "<http://api.test/w?after=b3>; rel=\"next\"", "</w?after=b6>; rel=\"next\"" };
|
|
1309
|
+
var urls = Walk(n => Fh.Response(200, new List<object?>(),
|
|
1310
|
+
n <= links.Length ? new Dictionary<string, object?> { ["link"] = links[n - 1] } : null),
|
|
1311
|
+
out var paging);
|
|
1312
|
+
Assert.Equal(new List<string>
|
|
1313
|
+
{
|
|
1314
|
+
"http://api.test/w?page=1",
|
|
1315
|
+
"http://api.test/w?after=b3",
|
|
1316
|
+
"http://api.test/w?after=b6",
|
|
1317
|
+
}, urls);
|
|
1318
|
+
Assert.Equal(false, paging["hasMore"]);
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
[Fact]
|
|
1322
|
+
public void QueryOnlyLinkKeepsThePath()
|
|
1323
|
+
{
|
|
1324
|
+
if (Fh.SkipWithout("paging")) return;
|
|
1325
|
+
var links = new[] { "</v1/items?page=2>; rel=\"next\"", "<?page=3>; rel=\"next\"" };
|
|
1326
|
+
var urls = Walk(n => Fh.Response(200, new List<object?>(),
|
|
1327
|
+
n <= links.Length ? new Dictionary<string, object?> { ["link"] = links[n - 1] } : null),
|
|
1328
|
+
out _);
|
|
1329
|
+
Assert.Equal(new List<string>
|
|
1330
|
+
{
|
|
1331
|
+
"http://api.test/w?page=1",
|
|
1332
|
+
"http://api.test/v1/items?page=2",
|
|
1333
|
+
"http://api.test/v1/items?page=3",
|
|
1334
|
+
}, urls);
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
[Fact]
|
|
1338
|
+
public void PathRelativeLinkResolvesAgainstTheRequest()
|
|
1339
|
+
{
|
|
1340
|
+
if (Fh.SkipWithout("paging")) return;
|
|
1341
|
+
var links = new[] { "</v1/items?page=2>; rel=\"next\"", "<more?page=3>; rel=\"next\"" };
|
|
1342
|
+
var urls = Walk(n => Fh.Response(200, new List<object?>(),
|
|
1343
|
+
n <= links.Length ? new Dictionary<string, object?> { ["link"] = links[n - 1] } : null),
|
|
1344
|
+
out _);
|
|
1345
|
+
Assert.Equal(new List<string>
|
|
1346
|
+
{
|
|
1347
|
+
"http://api.test/w?page=1",
|
|
1348
|
+
"http://api.test/v1/items?page=2",
|
|
1349
|
+
"http://api.test/v1/more?page=3",
|
|
1350
|
+
}, urls);
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
[Fact]
|
|
1354
|
+
public void ForeignLinkEndsTheWalk()
|
|
1355
|
+
{
|
|
1356
|
+
if (Fh.SkipWithout("paging")) return;
|
|
1357
|
+
var urls = Walk(n => Fh.Response(200, new List<object?>(), new Dictionary<string, object?>
|
|
1358
|
+
{
|
|
1359
|
+
["link"] = "<https://elsewhere.test/w?after=b3>; rel=\"next\"",
|
|
1360
|
+
}), out var paging);
|
|
1361
|
+
Assert.Equal(new List<string> { "http://api.test/w?page=1" }, urls);
|
|
1362
|
+
Assert.Equal(false, paging["hasMore"]);
|
|
1363
|
+
Assert.Equal("https://elsewhere.test/w?after=b3", paging["foreign"]);
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
[Fact]
|
|
1367
|
+
public void CursorModeSendsASlashCursor()
|
|
1368
|
+
{
|
|
1369
|
+
if (Fh.SkipWithout("paging")) return;
|
|
1370
|
+
var pages = new object?[] { "/c3", null };
|
|
1371
|
+
var urls = Walk(n => Fh.Response(200, new Dictionary<string, object?>
|
|
1372
|
+
{
|
|
1373
|
+
["next"] = pages[n - 1],
|
|
1374
|
+
}, null), out var paging, new Dictionary<string, object?> { ["next"] = "cursor" });
|
|
1375
|
+
Assert.Equal(new List<string> { "http://api.test/w?page=1", "http://api.test/w?cursor=%2Fc3" }, urls);
|
|
1376
|
+
Assert.Equal(false, paging["hasMore"]);
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1249
1379
|
[Fact]
|
|
1250
1380
|
public void NonListNotPaged()
|
|
1251
1381
|
{
|
|
@@ -1318,6 +1448,38 @@ public class FeatureStreamingTest
|
|
|
1318
1448
|
"expected chunked batches");
|
|
1319
1449
|
}
|
|
1320
1450
|
|
|
1451
|
+
[Fact]
|
|
1452
|
+
public void FailedResultIsNotStreamed()
|
|
1453
|
+
{
|
|
1454
|
+
if (Fh.SkipWithout("streaming")) return;
|
|
1455
|
+
var rec = new FhRecorder
|
|
1456
|
+
{
|
|
1457
|
+
Reply = (_, _) =>
|
|
1458
|
+
{
|
|
1459
|
+
var res = Fh.Response(200, new List<object?>(), null);
|
|
1460
|
+
res["err"] = new Exception("terminated");
|
|
1461
|
+
return res;
|
|
1462
|
+
},
|
|
1463
|
+
};
|
|
1464
|
+
var f = new StreamingFeature();
|
|
1465
|
+
var h = Fh.Make(rec.Fetch, (f, null));
|
|
1466
|
+
var res = h.Op(new FhOpSpec { Op = "list", Path = "/w" });
|
|
1467
|
+
Assert.False(res.Ok);
|
|
1468
|
+
Assert.False(res.Result!.Streaming || res.Result.Stream != null,
|
|
1469
|
+
"a failed result must keep no stream");
|
|
1470
|
+
Assert.Equal(0, f.Opened);
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
[Fact]
|
|
1474
|
+
public void EmptyListStreamsNothing()
|
|
1475
|
+
{
|
|
1476
|
+
if (Fh.SkipWithout("streaming")) return;
|
|
1477
|
+
var rec = new FhRecorder { Reply = (_, _) => Fh.Response(200, new List<object?>(), null) };
|
|
1478
|
+
var h = Fh.Make(rec.Fetch, (new StreamingFeature(), null));
|
|
1479
|
+
var res = h.Op(new FhOpSpec { Op = "list", Path = "/w" });
|
|
1480
|
+
Assert.Empty(res.Result!.Stream!().ToList());
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1321
1483
|
[Fact]
|
|
1322
1484
|
public void NonListNotStreamed()
|
|
1323
1485
|
{
|
|
@@ -188,6 +188,13 @@ public static partial class SdkUtility
|
|
|
188
188
|
opts["feature"] = fmap;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
+
var fdefaults = FeatureDefaults(StructUtils.GetProp(config, "feature"),
|
|
192
|
+
StructUtils.GetProp(opts, "feature"));
|
|
193
|
+
if (fdefaults != null)
|
|
194
|
+
{
|
|
195
|
+
opts["feature"] = fdefaults;
|
|
196
|
+
}
|
|
197
|
+
|
|
191
198
|
// THE OPTION SPEC IS GENERATED, NOT WRITTEN HERE.
|
|
192
199
|
//
|
|
193
200
|
// Built from the model: `main.kit.optspec` for the standard options,
|
|
@@ -219,6 +226,7 @@ public static partial class SdkUtility
|
|
|
219
226
|
object? validated;
|
|
220
227
|
try
|
|
221
228
|
{
|
|
229
|
+
RefuseStrayKeys(merged, optspec);
|
|
222
230
|
validated = StructUtils.Validate(merged, optspec);
|
|
223
231
|
}
|
|
224
232
|
catch (Exception verr)
|
|
@@ -304,23 +312,23 @@ public static partial class SdkUtility
|
|
|
304
312
|
}
|
|
305
313
|
}
|
|
306
314
|
|
|
307
|
-
// Resolve the feature add-order: an explicit list order (above) wins
|
|
308
|
-
//
|
|
309
|
-
//
|
|
310
|
-
// transport.
|
|
311
|
-
if (featureorder.Count == 0)
|
|
315
|
+
// Resolve the feature add-order: an explicit list order (above) wins, and
|
|
316
|
+
// the names it leaves out follow it test-first, then sorted, so the
|
|
317
|
+
// outcome is deterministic and `test` is the base transport of a map.
|
|
312
318
|
{
|
|
313
319
|
var fmap = Helpers.ToMapAny(StructUtils.GetProp(opts, "feature"))
|
|
314
320
|
?? new Dictionary<string, object?>();
|
|
315
|
-
var names = fmap.Keys.
|
|
321
|
+
var names = fmap.Keys.Where(k => !featureorder.Contains(k))
|
|
322
|
+
.OrderBy(k => k, StringComparer.Ordinal).ToList();
|
|
323
|
+
var rest = new List<object?>();
|
|
316
324
|
if (names.Contains("test"))
|
|
317
325
|
{
|
|
318
|
-
|
|
326
|
+
rest.Add("test");
|
|
319
327
|
foreach (var n in names)
|
|
320
328
|
{
|
|
321
329
|
if (n != "test")
|
|
322
330
|
{
|
|
323
|
-
|
|
331
|
+
rest.Add(n);
|
|
324
332
|
}
|
|
325
333
|
}
|
|
326
334
|
}
|
|
@@ -328,7 +336,7 @@ public static partial class SdkUtility
|
|
|
328
336
|
{
|
|
329
337
|
foreach (var n in names)
|
|
330
338
|
{
|
|
331
|
-
|
|
339
|
+
rest.Add(n);
|
|
332
340
|
}
|
|
333
341
|
}
|
|
334
342
|
|
|
@@ -338,12 +346,13 @@ public static partial class SdkUtility
|
|
|
338
346
|
// test - or first, when no test entry exists. Without this the
|
|
339
347
|
// sorted default would init station last and wrap OUTSIDE the
|
|
340
348
|
// recording features, turning its wire-truth events into fiction.
|
|
341
|
-
var si =
|
|
349
|
+
var si = rest.IndexOf("station");
|
|
342
350
|
if (si >= 0)
|
|
343
351
|
{
|
|
344
|
-
|
|
345
|
-
|
|
352
|
+
rest.RemoveAt(si);
|
|
353
|
+
rest.Insert(rest.IndexOf("test") + 1, "station");
|
|
346
354
|
}
|
|
355
|
+
featureorder.AddRange(rest);
|
|
347
356
|
}
|
|
348
357
|
|
|
349
358
|
opts["__derived__"] = new Dictionary<string, object?> { ["featureorder"] = featureorder };
|
|
@@ -357,10 +366,78 @@ public static partial class SdkUtility
|
|
|
357
366
|
return opts;
|
|
358
367
|
}
|
|
359
368
|
|
|
369
|
+
// Before validate: the struct's own refusal prints the value without its
|
|
370
|
+
// functions, so a misspelled callback key would go unnamed.
|
|
371
|
+
private static void RefuseStrayKeys(object? opts, Dictionary<string, object?> optspec)
|
|
372
|
+
{
|
|
373
|
+
var fspecs = optspec.TryGetValue("feature", out var fs) ? fs as Dictionary<string, object?> : null;
|
|
374
|
+
var feature = (opts as Dictionary<string, object?>)?.GetValueOrDefault("feature") as Dictionary<string, object?>;
|
|
375
|
+
if (fspecs == null || feature == null)
|
|
376
|
+
{
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
foreach (var (name, fopts) in feature)
|
|
380
|
+
{
|
|
381
|
+
var spec = SpecMap(fspecs.GetValueOrDefault(name));
|
|
382
|
+
if (spec == null || spec.ContainsKey("`$OPEN`") || fopts is not Dictionary<string, object?> fm)
|
|
383
|
+
{
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
var stray = fm.Keys.Where(k => !spec.ContainsKey(k)).ToList();
|
|
387
|
+
if (0 < stray.Count)
|
|
388
|
+
{
|
|
389
|
+
throw new Exception("Unexpected keys at field feature." + name + ": " + string.Join(", ", stray));
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
private static Dictionary<string, object?>? SpecMap(object? spec)
|
|
395
|
+
{
|
|
396
|
+
if (spec is List<object?> alts)
|
|
397
|
+
{
|
|
398
|
+
var from = 0 < alts.Count && "`$NOF`".Equals(alts[0]) ? 2 : 0;
|
|
399
|
+
return alts.Skip(from).OfType<Dictionary<string, object?>>().FirstOrDefault();
|
|
400
|
+
}
|
|
401
|
+
return spec as Dictionary<string, object?>;
|
|
402
|
+
}
|
|
403
|
+
|
|
360
404
|
// A feature's name is not a field name: a feature called `secrets` does
|
|
361
405
|
// not make every one of its options a secret. Entity blocks (entity
|
|
362
406
|
// settings, seeded records) hold no credential, and nor do rbac's rules,
|
|
363
407
|
// keyed by entity and operation names.
|
|
408
|
+
// The model's options for a feature sit beneath the caller's, key by key: a
|
|
409
|
+
// key the caller sets replaces the default whole, so a list is never merged.
|
|
410
|
+
private static Dictionary<string, object?>? FeatureDefaults(object? cfgfeature, object? feature)
|
|
411
|
+
{
|
|
412
|
+
if (feature != null && feature is not Dictionary<string, object?>)
|
|
413
|
+
{
|
|
414
|
+
return null;
|
|
415
|
+
}
|
|
416
|
+
var output = feature is Dictionary<string, object?> fm
|
|
417
|
+
? new Dictionary<string, object?>(fm) : new Dictionary<string, object?>();
|
|
418
|
+
foreach (var kv in Helpers.ToMapAny(cfgfeature) ?? new Dictionary<string, object?>())
|
|
419
|
+
{
|
|
420
|
+
var dflt = Helpers.ToMapAny(StructUtils.GetProp(Helpers.ToMapAny(kv.Value), "options"));
|
|
421
|
+
output.TryGetValue(kv.Key, out var given);
|
|
422
|
+
if (dflt == null || (given == null && !true.Equals(StructUtils.GetProp(dflt, "active"))) ||
|
|
423
|
+
(given != null && given is not Dictionary<string, object?>))
|
|
424
|
+
{
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
var merged = new Dictionary<string, object?>(
|
|
428
|
+
Helpers.ToMapAny(StructUtils.Clone(dflt)) ?? new Dictionary<string, object?>());
|
|
429
|
+
if (given is Dictionary<string, object?> gm)
|
|
430
|
+
{
|
|
431
|
+
foreach (var g in gm)
|
|
432
|
+
{
|
|
433
|
+
merged[g.Key] = g.Value;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
output[kv.Key] = merged;
|
|
437
|
+
}
|
|
438
|
+
return output;
|
|
439
|
+
}
|
|
440
|
+
|
|
364
441
|
private static void CleanAddOptions(Context cleanctx, Dictionary<string, object?> opts,
|
|
365
442
|
params string[] omit)
|
|
366
443
|
{
|
|
@@ -104,6 +104,19 @@ defmodule ProjectName.Feature.Metrics do
|
|
|
104
104
|
|
|
105
105
|
bump(S.getprop(metrics, "total"), ok, dur)
|
|
106
106
|
bump(op_bucket, ok, dur)
|
|
107
|
+
|
|
108
|
+
sink = S.getprop(F.opts(f), "sink")
|
|
109
|
+
|
|
110
|
+
if S.isfunc(sink) do
|
|
111
|
+
try do
|
|
112
|
+
sink.(F.clean(ctx, metrics))
|
|
113
|
+
rescue
|
|
114
|
+
_ -> nil
|
|
115
|
+
catch
|
|
116
|
+
_, _ -> nil
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
107
120
|
nil
|
|
108
121
|
end
|
|
109
122
|
end
|