@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
|
@@ -201,28 +201,6 @@ public class TestFeature extends BaseFeature {
|
|
|
201
201
|
return out;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
// For single-entity ops (load, remove) with an empty explicit match,
|
|
205
|
-
// fall back to the id the entity client already knows from a prior
|
|
206
|
-
// create/load (in ctx.match / ctx.data). Mirrors the TS mock where
|
|
207
|
-
// param() resolves the id from that accumulated state.
|
|
208
|
-
private Map<String, Object> resolveMatch(Context ctx, Map<String, Object> explicit) {
|
|
209
|
-
if (explicit != null && !explicit.isEmpty()) {
|
|
210
|
-
return explicit;
|
|
211
|
-
}
|
|
212
|
-
for (Map<String, Object> src : new Map[] { ctx.match, ctx.data }) {
|
|
213
|
-
if (src == null) {
|
|
214
|
-
continue;
|
|
215
|
-
}
|
|
216
|
-
Object v = Struct.getprop(src, "id", null);
|
|
217
|
-
if (v != null && !"__UNDEFINED__".equals(v)) {
|
|
218
|
-
Map<String, Object> out = new LinkedHashMap<>();
|
|
219
|
-
out.put("id", v);
|
|
220
|
-
return out;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
return new LinkedHashMap<>();
|
|
224
|
-
}
|
|
225
|
-
|
|
226
204
|
private Object serve(Context ctx, Map<String, Object> entity) {
|
|
227
205
|
Operation op = ctx.op;
|
|
228
206
|
Map<String, Object> entmap = Helpers.toMapAny(Struct.getprop(entity, op.entity));
|
|
@@ -231,7 +209,7 @@ public class TestFeature extends BaseFeature {
|
|
|
231
209
|
}
|
|
232
210
|
|
|
233
211
|
if ("load".equals(op.name)) {
|
|
234
|
-
Object args = buildArgs(ctx, op,
|
|
212
|
+
Object args = buildArgs(ctx, op, ctx.reqmatch);
|
|
235
213
|
List<Object> found = Struct.select(entmap, args);
|
|
236
214
|
Object ent = Struct.getelem(found, 0, null);
|
|
237
215
|
if (ent == null) {
|
|
@@ -254,32 +232,7 @@ public class TestFeature extends BaseFeature {
|
|
|
254
232
|
return respond(ctx, 200, out, null);
|
|
255
233
|
}
|
|
256
234
|
else if ("update".equals(op.name) || "patch".equals(op.name)) {
|
|
257
|
-
|
|
258
|
-
// also contains the new field values, which would otherwise
|
|
259
|
-
// cause select to filter out the entity we want to update.
|
|
260
|
-
// When reqdata has no id, fall back to the id the entity
|
|
261
|
-
// client carries from a prior create/load (in ctx.match /
|
|
262
|
-
// ctx.data), mirroring the TS mock where param(ctx,'id')
|
|
263
|
-
// resolves from accumulated state.
|
|
264
|
-
Map<String, Object> updateMatch = new LinkedHashMap<>();
|
|
265
|
-
if (ctx.reqdata != null) {
|
|
266
|
-
if (ctx.reqdata.containsKey("id")) {
|
|
267
|
-
updateMatch.put("id", ctx.reqdata.get("id"));
|
|
268
|
-
}
|
|
269
|
-
if (op.alias != null) {
|
|
270
|
-
Object aliasIdRaw = Struct.getprop(op.alias, "id");
|
|
271
|
-
if (aliasIdRaw instanceof String) {
|
|
272
|
-
String aliasId = (String) aliasIdRaw;
|
|
273
|
-
if (ctx.reqdata.containsKey(aliasId)) {
|
|
274
|
-
updateMatch.put(aliasId, ctx.reqdata.get(aliasId));
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
if (updateMatch.isEmpty()) {
|
|
280
|
-
updateMatch = resolveMatch(ctx, new LinkedHashMap<>());
|
|
281
|
-
}
|
|
282
|
-
Object args = buildArgs(ctx, op, updateMatch);
|
|
235
|
+
Object args = buildArgs(ctx, op, record(ctx.reqdata));
|
|
283
236
|
List<Object> found = Struct.select(entmap, args);
|
|
284
237
|
Object ent = Struct.getelem(found, 0, null);
|
|
285
238
|
if (ent == null) {
|
|
@@ -294,7 +247,7 @@ public class TestFeature extends BaseFeature {
|
|
|
294
247
|
return respond(ctx, 200, out, null);
|
|
295
248
|
}
|
|
296
249
|
else if ("remove".equals(op.name)) {
|
|
297
|
-
Object args = buildArgs(ctx, op,
|
|
250
|
+
Object args = buildArgs(ctx, op, ctx.reqmatch);
|
|
298
251
|
List<Object> found = Struct.select(entmap, args);
|
|
299
252
|
Object ent = Struct.getelem(found, 0, null);
|
|
300
253
|
// Remove only the first matched entity. If nothing matches,
|
|
@@ -399,6 +352,11 @@ public class TestFeature extends BaseFeature {
|
|
|
399
352
|
FeatureOptions.foptSleep(net).accept(ms);
|
|
400
353
|
}
|
|
401
354
|
|
|
355
|
+
private static boolean held(Map<String, Object> src, String key) {
|
|
356
|
+
Object v = src == null ? null : Struct.getprop(src, key, null);
|
|
357
|
+
return v != null && !"__UNDEFINED__".equals(v);
|
|
358
|
+
}
|
|
359
|
+
|
|
402
360
|
private Object buildArgs(Context ctx, Operation op, Map<String, Object> args) {
|
|
403
361
|
String opname = op.name;
|
|
404
362
|
|
|
@@ -438,23 +396,52 @@ public class TestFeature extends BaseFeature {
|
|
|
438
396
|
List<Object> qand = Struct.jt();
|
|
439
397
|
Map<String, Object> q = Struct.jm("`$AND`", qand);
|
|
440
398
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
boolean isId = "id".equals(key);
|
|
444
|
-
List<Object> selected = Struct.select(reqd, key);
|
|
445
|
-
boolean isReqd = !Struct.isempty(selected);
|
|
399
|
+
String entityName = ctx.entity == null ? "" : ctx.entity.getName();
|
|
400
|
+
Object idfrom = Struct.getpath(ctx.config, List.of("entity", entityName, "id", "from"));
|
|
446
401
|
|
|
447
|
-
|
|
448
|
-
Object v = ctx.utility.param.apply(ctx, key);
|
|
449
|
-
Object ka = Struct.getprop(op.alias, key);
|
|
402
|
+
List<String> names = new ArrayList<>(args == null ? List.of() : Struct.keysof(args));
|
|
450
403
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
404
|
+
// With no id in the call, the entity's held id (or composite parts) stands in.
|
|
405
|
+
if (args == null || args.get("id") == null) {
|
|
406
|
+
Object parts = Struct.getpath(ctx.config, List.of("entity", entityName, "id", "parts"));
|
|
407
|
+
if (!(parts instanceof List)) {
|
|
408
|
+
parts = "list".equals(opname) ? List.of() : List.of("id");
|
|
409
|
+
}
|
|
410
|
+
for (Object part : (List<Object>) parts) {
|
|
411
|
+
String pname = String.valueOf(part);
|
|
412
|
+
if (!names.contains(pname) && (held(ctx.match, pname) || held(ctx.data, pname))) {
|
|
413
|
+
names.add(pname);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
for (String key : names) {
|
|
419
|
+
boolean isId = "id".equals(key);
|
|
420
|
+
List<Object> selected = Struct.select(reqd, key);
|
|
421
|
+
boolean isReqd = !Struct.isempty(selected);
|
|
455
422
|
|
|
456
|
-
|
|
423
|
+
if (isId || isReqd) {
|
|
424
|
+
Object v = ctx.utility.param.apply(ctx, key);
|
|
425
|
+
Object ka = Struct.getprop(op.alias, key);
|
|
426
|
+
|
|
427
|
+
List<Object> qor = Struct.jt(Struct.jm(key, v));
|
|
428
|
+
if (ka instanceof String) {
|
|
429
|
+
qor.add(Struct.jm((String) ka, v));
|
|
457
430
|
}
|
|
431
|
+
|
|
432
|
+
// An alternative, never a replacement: a seed keeping the parameter
|
|
433
|
+
// flat is still found.
|
|
434
|
+
Object kf = Struct.getprop(idfrom, key);
|
|
435
|
+
if (kf instanceof String && !key.equals(kf)) {
|
|
436
|
+
Object nest = v;
|
|
437
|
+
String[] segs = ((String) kf).split("\\.");
|
|
438
|
+
for (int i = segs.length - 1; 0 <= i; i--) {
|
|
439
|
+
nest = Struct.jm(segs[i], nest);
|
|
440
|
+
}
|
|
441
|
+
qor.add(nest);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
qand.add(Struct.jm("`$OR`", qor));
|
|
458
445
|
}
|
|
459
446
|
}
|
|
460
447
|
|
|
@@ -77,16 +77,23 @@ public class FeatureCorpusTest {
|
|
|
77
77
|
* <p>Returns the shape the real fetcher returns: the parsed body behind a
|
|
78
78
|
* `json` supplier and `body` as the raw string. A script that only set
|
|
79
79
|
* `body` would look like an empty result, which reads as a feature defect
|
|
80
|
-
* rather than a mis-shaped script.
|
|
80
|
+
* rather than a mis-shaped script. Each URL it is sent is kept in `sent`;
|
|
81
|
+
* a `cut` response is one whose body stops before its end.
|
|
81
82
|
*/
|
|
82
|
-
private static Utility.FetcherFn scriptedFetcher(Object resRaw
|
|
83
|
+
private static Utility.FetcherFn scriptedFetcher(Object resRaw, List<String> sent,
|
|
84
|
+
List<Long> sentAt) {
|
|
83
85
|
List<Object> res = resRaw instanceof List ? (List<Object>) resRaw : List.of();
|
|
84
86
|
int[] n = {-1};
|
|
85
87
|
return (ctx, fullurl, fetchdef) -> {
|
|
86
|
-
|
|
88
|
+
int at;
|
|
89
|
+
synchronized (n) {
|
|
90
|
+
at = ++n[0];
|
|
91
|
+
sent.add(fullurl);
|
|
92
|
+
sentAt.add(System.nanoTime() / 1_000_000);
|
|
93
|
+
}
|
|
87
94
|
Map<String, Object> spec = new LinkedHashMap<>();
|
|
88
95
|
if (!res.isEmpty()) {
|
|
89
|
-
int i =
|
|
96
|
+
int i = at >= res.size() ? res.size() - 1 : at;
|
|
90
97
|
Object entry = res.get(i);
|
|
91
98
|
if (entry instanceof Map) {
|
|
92
99
|
spec = (Map<String, Object>) entry;
|
|
@@ -111,6 +118,13 @@ public class FeatureCorpusTest {
|
|
|
111
118
|
out.put("status", status);
|
|
112
119
|
out.put("statusText", status < 400 ? "OK" : "ERR");
|
|
113
120
|
out.put("headers", headers);
|
|
121
|
+
if (Boolean.TRUE.equals(spec.get("cut"))) {
|
|
122
|
+
String raw = RunnerSupport.jsonStr(jsonBody);
|
|
123
|
+
out.put("json", (Supplier<Object>) () -> null);
|
|
124
|
+
out.put("body", raw.substring(0, raw.length() / 2));
|
|
125
|
+
out.put("unreadable", true);
|
|
126
|
+
return out;
|
|
127
|
+
}
|
|
114
128
|
out.put("json", (Supplier<Object>) () -> jsonBody);
|
|
115
129
|
out.put("body", RunnerSupport.jsonStr(jsonBody));
|
|
116
130
|
return out;
|
|
@@ -125,8 +139,13 @@ public class FeatureCorpusTest {
|
|
|
125
139
|
* would shadow the script.
|
|
126
140
|
*/
|
|
127
141
|
private static ProjectNameSDK buildClient(Map<String, Object> kase) {
|
|
142
|
+
return buildClient(kase, new ArrayList<>(), new ArrayList<>());
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private static ProjectNameSDK buildClient(Map<String, Object> kase, List<String> sent,
|
|
146
|
+
List<Long> sentAt) {
|
|
128
147
|
Map<String, Object> utility = new LinkedHashMap<>();
|
|
129
|
-
utility.put("fetcher", scriptedFetcher(kase.get("res")));
|
|
148
|
+
utility.put("fetcher", scriptedFetcher(kase.get("res"), sent, sentAt));
|
|
130
149
|
|
|
131
150
|
// "test" is the OPTION, not the `test` FEATURE: it says "this client is
|
|
132
151
|
// not live", so a REQUIRED OpenAPI server variable resolves to a
|
|
@@ -299,7 +318,67 @@ public class FeatureCorpusTest {
|
|
|
299
318
|
return null;
|
|
300
319
|
}
|
|
301
320
|
|
|
302
|
-
/**
|
|
321
|
+
/** Read one operation through the entity's stream(); how many it yields. */
|
|
322
|
+
private static long streamItems(ProjectNameSDK client, Op op, Map<String, Object> ctrl,
|
|
323
|
+
Map<String, Object> args) throws Exception {
|
|
324
|
+
Object ent = op.accessor.invoke(client, new Object[] {null});
|
|
325
|
+
Method stream = ent.getClass().getMethod("stream", String.class, Map.class, Map.class);
|
|
326
|
+
Map<String, Object> callopts = new LinkedHashMap<>();
|
|
327
|
+
callopts.put("ctrl", ctrl);
|
|
328
|
+
try {
|
|
329
|
+
return ((java.util.stream.Stream<Object>) stream.invoke(ent,
|
|
330
|
+
op.key.substring(op.key.indexOf('.') + 1), new LinkedHashMap<>(args), callopts)).count();
|
|
331
|
+
}
|
|
332
|
+
catch (java.lang.reflect.InvocationTargetException ite) {
|
|
333
|
+
if (ite.getCause() instanceof Exception) {
|
|
334
|
+
throw (Exception) ite.getCause();
|
|
335
|
+
}
|
|
336
|
+
throw ite;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Each request a case expects, in order: its path, and its whole query. A
|
|
342
|
+
* path is compared without its leading slash, which an SDK with no base
|
|
343
|
+
* omits.
|
|
344
|
+
*/
|
|
345
|
+
private static void checkSent(List<String> sent, Object expectRaw, String label) {
|
|
346
|
+
List<Object> expect = (List<Object>) expectRaw;
|
|
347
|
+
assertEquals(expect.size(), sent.size(), label + ": requests sent: " + String.join(" | ", sent));
|
|
348
|
+
for (int i = 0; i < expect.size(); i++) {
|
|
349
|
+
Map<String, Object> want = (Map<String, Object>) expect.get(i);
|
|
350
|
+
String rest = sent.get(i).replaceFirst("(?i)^[a-z][a-z0-9+.-]*://[^/?#]*", "");
|
|
351
|
+
int mark = rest.indexOf('?');
|
|
352
|
+
String path = mark < 0 ? rest : rest.substring(0, mark);
|
|
353
|
+
String rawquery = mark < 0 ? "" : rest.substring(mark + 1);
|
|
354
|
+
if (want.get("path") != null) {
|
|
355
|
+
assertEquals(String.valueOf(want.get("path")).replaceFirst("^/+", ""),
|
|
356
|
+
path.replaceFirst("^/+", ""), label + ": request " + i + " path");
|
|
357
|
+
}
|
|
358
|
+
if (want.get("query") instanceof Map) {
|
|
359
|
+
Map<String, Object> query = new TreeMap<>();
|
|
360
|
+
for (String pair : rawquery.split("&")) {
|
|
361
|
+
if (pair.isEmpty()) {
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
int eq = pair.indexOf('=');
|
|
365
|
+
query.put(
|
|
366
|
+
java.net.URLDecoder.decode(eq < 0 ? pair : pair.substring(0, eq),
|
|
367
|
+
java.nio.charset.StandardCharsets.UTF_8),
|
|
368
|
+
java.net.URLDecoder.decode(eq < 0 ? "" : pair.substring(eq + 1),
|
|
369
|
+
java.nio.charset.StandardCharsets.UTF_8));
|
|
370
|
+
}
|
|
371
|
+
assertEquals(new TreeMap<>((Map<String, Object>) want.get("query")), query,
|
|
372
|
+
label + ": request " + i + " query");
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* One step: it may wait, may add request headers, and may pass `args` as
|
|
379
|
+
* the first argument. A `stream` step reads the operation through
|
|
380
|
+
* stream(), and `items` is how many it yields.
|
|
381
|
+
*/
|
|
303
382
|
private static Object step(ProjectNameSDK client, Op op, Map<String, Object> step,
|
|
304
383
|
Map<String, Object> ctrl) throws Exception {
|
|
305
384
|
if (step.get("wait") instanceof Number) {
|
|
@@ -307,6 +386,13 @@ public class FeatureCorpusTest {
|
|
|
307
386
|
}
|
|
308
387
|
Map<String, Object> args = step.get("args") instanceof Map
|
|
309
388
|
? (Map<String, Object>) step.get("args") : new LinkedHashMap<>();
|
|
389
|
+
if (Boolean.TRUE.equals(step.get("stream"))) {
|
|
390
|
+
long items = streamItems(client, op, ctrl, args);
|
|
391
|
+
if (step.get("items") instanceof Number) {
|
|
392
|
+
assertEquals(((Number) step.get("items")).longValue(), items, op.key + ": items streamed");
|
|
393
|
+
}
|
|
394
|
+
return items;
|
|
395
|
+
}
|
|
310
396
|
if (!(step.get("headers") instanceof Map)) {
|
|
311
397
|
return invoke(client, op, ctrl, args);
|
|
312
398
|
}
|
|
@@ -332,6 +418,49 @@ public class FeatureCorpusTest {
|
|
|
332
418
|
}
|
|
333
419
|
}
|
|
334
420
|
|
|
421
|
+
/**
|
|
422
|
+
* Runs a step once, or with `together: N` as N overlapping calls, and
|
|
423
|
+
* returns each call's exception, or null.
|
|
424
|
+
*/
|
|
425
|
+
private static List<Throwable> calls(ProjectNameSDK client, Op op, Map<String, Object> step,
|
|
426
|
+
Map<String, Object> ctrl) throws InterruptedException {
|
|
427
|
+
int n = step.get("together") instanceof Number ? ((Number) step.get("together")).intValue() : 1;
|
|
428
|
+
Throwable[] errs = new Throwable[n];
|
|
429
|
+
List<Thread> threads = new ArrayList<>();
|
|
430
|
+
for (int i = 0; i < n; i++) {
|
|
431
|
+
final int k = i;
|
|
432
|
+
Thread t = new Thread(() -> {
|
|
433
|
+
try {
|
|
434
|
+
step(client, op, step, ctrl);
|
|
435
|
+
}
|
|
436
|
+
catch (Throwable e) {
|
|
437
|
+
errs[k] = e;
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
threads.add(t);
|
|
441
|
+
t.start();
|
|
442
|
+
}
|
|
443
|
+
for (Thread t : threads) {
|
|
444
|
+
t.join();
|
|
445
|
+
}
|
|
446
|
+
return java.util.Arrays.asList(errs);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/** The most requests seen in any window of `ms`. */
|
|
450
|
+
private static int busiest(List<Long> sent, long ms) {
|
|
451
|
+
int most = 0;
|
|
452
|
+
for (long from : sent) {
|
|
453
|
+
int count = 0;
|
|
454
|
+
for (long t : sent) {
|
|
455
|
+
if (from <= t && t < from + ms) {
|
|
456
|
+
count++;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
most = Math.max(most, count);
|
|
460
|
+
}
|
|
461
|
+
return most;
|
|
462
|
+
}
|
|
463
|
+
|
|
335
464
|
/** Replace #OPn throughout a case, keys included. */
|
|
336
465
|
private static Object resolve(Object node, Map<String, String> tokens) {
|
|
337
466
|
if (node instanceof String) {
|
|
@@ -409,6 +538,16 @@ public class FeatureCorpusTest {
|
|
|
409
538
|
return;
|
|
410
539
|
}
|
|
411
540
|
|
|
541
|
+
if (expect instanceof List) {
|
|
542
|
+
List<Object> want = (List<Object>) expect;
|
|
543
|
+
assertTrue(actual instanceof List && ((List<Object>) actual).size() == want.size(),
|
|
544
|
+
path + ": want " + want.size() + " item(s), got " + actual);
|
|
545
|
+
for (int i = 0; i < want.size(); i++) {
|
|
546
|
+
subset(((List<Object>) actual).get(i), want.get(i), path + "[" + i + "]");
|
|
547
|
+
}
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
|
|
412
551
|
if (expect instanceof Boolean) {
|
|
413
552
|
assertEquals(expect, actual, path);
|
|
414
553
|
return;
|
|
@@ -617,8 +756,13 @@ public class FeatureCorpusTest {
|
|
|
617
756
|
|
|
618
757
|
// Every failing case is reported, not only the first.
|
|
619
758
|
try {
|
|
620
|
-
|
|
759
|
+
List<String> sent = java.util.Collections.synchronizedList(new ArrayList<>());
|
|
760
|
+
List<Long> sentAt = java.util.Collections.synchronizedList(new ArrayList<>());
|
|
761
|
+
ProjectNameSDK client = buildClient(kase, sent, sentAt);
|
|
621
762
|
|
|
763
|
+
// A case-level ctrl is one control object every step shares.
|
|
764
|
+
Map<String, Object> shared = kase.get("ctrl") instanceof Map
|
|
765
|
+
? (Map<String, Object>) kase.get("ctrl") : null;
|
|
622
766
|
List<Object> steps = kase.get("op") instanceof List
|
|
623
767
|
? (List<Object>) kase.get("op") : List.of();
|
|
624
768
|
for (Object stepRaw : steps) {
|
|
@@ -627,19 +771,16 @@ public class FeatureCorpusTest {
|
|
|
627
771
|
assertNotNull(op, label + ": no operation " + step.get("op"));
|
|
628
772
|
Map<String, Object> ctrl = step.get("ctrl") instanceof Map
|
|
629
773
|
? new LinkedHashMap<>((Map<String, Object>) step.get("ctrl"))
|
|
630
|
-
: new LinkedHashMap<>();
|
|
774
|
+
: null != shared ? shared : new LinkedHashMap<>();
|
|
631
775
|
Object wanterr = step.get("err");
|
|
632
776
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
777
|
+
for (Throwable err : calls(client, op, step, ctrl)) {
|
|
778
|
+
if (null == err) {
|
|
779
|
+
if (null != wanterr) {
|
|
780
|
+
fail(label + ": " + step.get("op") + " was expected to fail, and did not");
|
|
781
|
+
}
|
|
782
|
+
continue;
|
|
637
783
|
}
|
|
638
|
-
}
|
|
639
|
-
catch (org.opentest4j.AssertionFailedError e) {
|
|
640
|
-
throw e;
|
|
641
|
-
}
|
|
642
|
-
catch (Exception err) {
|
|
643
784
|
assertNotNull(wanterr,
|
|
644
785
|
label + ": " + step.get("op") + " failed unexpectedly: " + err);
|
|
645
786
|
if (wanterr instanceof String) {
|
|
@@ -652,6 +793,18 @@ public class FeatureCorpusTest {
|
|
|
652
793
|
}
|
|
653
794
|
}
|
|
654
795
|
|
|
796
|
+
if (kase.get("pace") instanceof Map) {
|
|
797
|
+
Map<String, Object> pace = (Map<String, Object>) kase.get("pace");
|
|
798
|
+
long ms = ((Number) pace.get("ms")).longValue();
|
|
799
|
+
int max = ((Number) pace.get("max")).intValue();
|
|
800
|
+
int most = busiest(new ArrayList<>(sentAt), ms);
|
|
801
|
+
assertTrue(most <= max,
|
|
802
|
+
label + ": " + most + " requests within " + ms + " ms, want at most " + max);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
if (kase.get("sent") != null) {
|
|
806
|
+
checkSent(new ArrayList<>(sent), kase.get("sent"), label);
|
|
807
|
+
}
|
|
655
808
|
subset(record(client, name), kase.get("out"), label + ": _" + name);
|
|
656
809
|
}
|
|
657
810
|
catch (AssertionError | Exception e) {
|
|
@@ -118,6 +118,11 @@ final class MakeOptions {
|
|
|
118
118
|
opts.put("feature", fmap);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
Map<String, Object> fdefaults = featureDefaults(config.get("feature"), opts.get("feature"));
|
|
122
|
+
if (fdefaults != null) {
|
|
123
|
+
opts.put("feature", fdefaults);
|
|
124
|
+
}
|
|
125
|
+
|
|
121
126
|
// THE OPTION SPEC IS GENERATED, NOT WRITTEN HERE.
|
|
122
127
|
//
|
|
123
128
|
// Built from the model: `main.kit.optspec` for the standard options,
|
|
@@ -146,12 +151,11 @@ final class MakeOptions {
|
|
|
146
151
|
mergeList.add(Struct.clone(cfgopts));
|
|
147
152
|
mergeList.add(opts);
|
|
148
153
|
Object merged = Struct.merge(mergeList);
|
|
154
|
+
List<Object[]> callbacks = holdCallbacks(merged, optspec);
|
|
149
155
|
|
|
150
|
-
Map<String, Object> vopts = new LinkedHashMap<>();
|
|
151
|
-
vopts.put("errs", new ArrayList<>());
|
|
152
156
|
Object validated;
|
|
153
157
|
try {
|
|
154
|
-
validated = Struct.validate(merged, optspec
|
|
158
|
+
validated = Struct.validate(merged, optspec);
|
|
155
159
|
}
|
|
156
160
|
catch (IllegalArgumentException err) {
|
|
157
161
|
// The message quotes the offending value; a rewrite is the only way to
|
|
@@ -160,6 +164,7 @@ final class MakeOptions {
|
|
|
160
164
|
(String) Clean.cleanWith(cleancfg, String.valueOf(err.getMessage())), err.getCause());
|
|
161
165
|
}
|
|
162
166
|
opts = (Map<String, Object>) validated;
|
|
167
|
+
restoreCallbacks(opts, callbacks);
|
|
163
168
|
|
|
164
169
|
// Restore the suppression the optspec default would otherwise erase.
|
|
165
170
|
if (authSuppressed) {
|
|
@@ -231,26 +236,31 @@ final class MakeOptions {
|
|
|
231
236
|
opts.put("base", resolved.toString());
|
|
232
237
|
}
|
|
233
238
|
|
|
234
|
-
// Resolve the feature add-order: an explicit list order (above) wins
|
|
235
|
-
//
|
|
236
|
-
//
|
|
237
|
-
|
|
239
|
+
// Resolve the feature add-order: an explicit list order (above) wins, and
|
|
240
|
+
// the names it leaves out follow it test-first, then sorted, so the outcome
|
|
241
|
+
// is deterministic and `test` is the base transport of a map.
|
|
242
|
+
{
|
|
238
243
|
Map<String, Object> fmap = Helpers.toMapAny(opts.get("feature"));
|
|
239
244
|
List<String> names = new ArrayList<>();
|
|
240
245
|
if (fmap != null) {
|
|
241
|
-
|
|
246
|
+
for (String n : fmap.keySet()) {
|
|
247
|
+
if (!featureorder.contains(n)) {
|
|
248
|
+
names.add(n);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
242
251
|
}
|
|
243
252
|
names.sort(null);
|
|
253
|
+
List<Object> rest = new ArrayList<>();
|
|
244
254
|
if (names.contains("test")) {
|
|
245
|
-
|
|
255
|
+
rest.add("test");
|
|
246
256
|
for (String n : names) {
|
|
247
257
|
if (!"test".equals(n)) {
|
|
248
|
-
|
|
258
|
+
rest.add(n);
|
|
249
259
|
}
|
|
250
260
|
}
|
|
251
261
|
}
|
|
252
262
|
else {
|
|
253
|
-
|
|
263
|
+
rest.addAll(names);
|
|
254
264
|
}
|
|
255
265
|
// Station special case, mirroring test's: its transport wrap must
|
|
256
266
|
// sit immediately outside the base transport (inside every other
|
|
@@ -258,11 +268,12 @@ final class MakeOptions {
|
|
|
258
268
|
// test - or first, when no test entry exists. Without this the
|
|
259
269
|
// sorted default would init station last and wrap OUTSIDE the
|
|
260
270
|
// recording features, turning its wire-truth events into fiction.
|
|
261
|
-
int si =
|
|
271
|
+
int si = rest.indexOf("station");
|
|
262
272
|
if (0 <= si) {
|
|
263
|
-
|
|
264
|
-
|
|
273
|
+
rest.remove(si);
|
|
274
|
+
rest.add(rest.indexOf("test") + 1, "station");
|
|
265
275
|
}
|
|
276
|
+
featureorder.addAll(rest);
|
|
266
277
|
}
|
|
267
278
|
|
|
268
279
|
Map<String, Object> derived = new LinkedHashMap<>();
|
|
@@ -278,6 +289,109 @@ final class MakeOptions {
|
|
|
278
289
|
return opts;
|
|
279
290
|
}
|
|
280
291
|
|
|
292
|
+
// The model's options for a feature sit beneath the caller's, key by key: a
|
|
293
|
+
// key the caller sets replaces the default whole, so a list is never merged.
|
|
294
|
+
@SuppressWarnings("unchecked")
|
|
295
|
+
private static Map<String, Object> featureDefaults(Object cfgfeature, Object feature) {
|
|
296
|
+
if (feature != null && !(feature instanceof Map)) {
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
Map<String, Object> out = feature == null
|
|
300
|
+
? new LinkedHashMap<>() : new LinkedHashMap<>((Map<String, Object>) feature);
|
|
301
|
+
Map<String, Object> cfg = Helpers.toMapAny(cfgfeature);
|
|
302
|
+
if (cfg == null) {
|
|
303
|
+
return out;
|
|
304
|
+
}
|
|
305
|
+
for (Map.Entry<String, Object> e : cfg.entrySet()) {
|
|
306
|
+
Map<String, Object> fdef = Helpers.toMapAny(e.getValue());
|
|
307
|
+
Map<String, Object> dflt = fdef == null ? null : Helpers.toMapAny(fdef.get("options"));
|
|
308
|
+
Object given = out.get(e.getKey());
|
|
309
|
+
if (dflt == null || (given == null && !Boolean.TRUE.equals(dflt.get("active")))
|
|
310
|
+
|| (given != null && !(given instanceof Map))) {
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
Map<String, Object> merged =
|
|
314
|
+
new LinkedHashMap<>(Helpers.toMapAny(Struct.clone(dflt)));
|
|
315
|
+
if (given != null) {
|
|
316
|
+
merged.putAll((Map<String, Object>) given);
|
|
317
|
+
}
|
|
318
|
+
out.put(e.getKey(), merged);
|
|
319
|
+
}
|
|
320
|
+
return out;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// This struct port's `$FUNCTION` admits only a java.util.function Function or
|
|
324
|
+
// Supplier, so a callback in a slot the spec types as a function is held out
|
|
325
|
+
// of validation and put back; any other key is still validated.
|
|
326
|
+
private static List<Object[]> holdCallbacks(Object opts, Map<String, Object> optspec) {
|
|
327
|
+
List<Object[]> held = new ArrayList<>();
|
|
328
|
+
Map<String, Object> om = Helpers.toMapAny(opts);
|
|
329
|
+
Map<String, Object> feature = om == null ? null : Helpers.toMapAny(om.get("feature"));
|
|
330
|
+
Map<String, Object> fspecs = Helpers.toMapAny(optspec.get("feature"));
|
|
331
|
+
if (feature == null || fspecs == null) {
|
|
332
|
+
return held;
|
|
333
|
+
}
|
|
334
|
+
for (Map.Entry<String, Object> fe : feature.entrySet()) {
|
|
335
|
+
Map<String, Object> fm = Helpers.toMapAny(fe.getValue());
|
|
336
|
+
Map<String, Object> fspec = specMap(fspecs.get(fe.getKey()));
|
|
337
|
+
if (fm == null || fspec == null) {
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
for (String key : new ArrayList<>(fm.keySet())) {
|
|
341
|
+
if (isFunctionSpec(fspec.get(key)) && isCallback(fm.get(key))) {
|
|
342
|
+
held.add(new Object[] {fe.getKey(), key, fm.remove(key)});
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return held;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
private static Map<String, Object> specMap(Object spec) {
|
|
350
|
+
if (spec instanceof List) {
|
|
351
|
+
List<Object> alts = (List<Object>) spec;
|
|
352
|
+
for (int i = "`$NOF`".equals(alts.isEmpty() ? null : alts.get(0)) ? 2 : 0; i < alts.size(); i++) {
|
|
353
|
+
if (alts.get(i) instanceof Map) {
|
|
354
|
+
return (Map<String, Object>) alts.get(i);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
return Helpers.toMapAny(spec);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
private static boolean isFunctionSpec(Object spec) {
|
|
363
|
+
return "`$FUNCTION`".equals(spec)
|
|
364
|
+
|| (spec instanceof List && ((List<Object>) spec).contains("`$FUNCTION`"));
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
private static boolean isCallback(Object v) {
|
|
368
|
+
if (v == null) {
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
for (Class<?> c = v.getClass(); c != null; c = c.getSuperclass()) {
|
|
372
|
+
for (Class<?> i : c.getInterfaces()) {
|
|
373
|
+
if (i.isAnnotationPresent(FunctionalInterface.class)
|
|
374
|
+
|| i.getName().startsWith("java.util.function.")) {
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
private static void restoreCallbacks(Map<String, Object> opts, List<Object[]> held) {
|
|
383
|
+
Map<String, Object> feature = Helpers.toMapAny(opts.get("feature"));
|
|
384
|
+
if (feature == null) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
for (Object[] h : held) {
|
|
388
|
+
Map<String, Object> fm = Helpers.toMapAny(feature.get((String) h[0]));
|
|
389
|
+
if (fm != null) {
|
|
390
|
+
fm.put((String) h[1], h[2]);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
281
395
|
private static Map<String, Object> without(Map<String, Object> map, String... keys) {
|
|
282
396
|
Map<String, Object> out = new LinkedHashMap<>(map);
|
|
283
397
|
for (String key : keys) {
|
|
@@ -6,9 +6,9 @@ const { BaseFeature } = require('../base/BaseFeature')
|
|
|
6
6
|
// Statistics capture. Records per-operation counters and latency for every
|
|
7
7
|
// call: totals plus a breakdown keyed by `<entity>.<op>`. Timing starts at
|
|
8
8
|
// endpoint resolution (PrePoint) and stops when the call returns (PreDone)
|
|
9
|
-
// or throws (PreUnexpected). Aggregates live on `client._metrics
|
|
10
|
-
//
|
|
11
|
-
// (`now`) for deterministic tests.
|
|
9
|
+
// or throws (PreUnexpected). Aggregates live on `client._metrics`; a `sink`
|
|
10
|
+
// callback, when provided, is given a copy of them after each operation. The
|
|
11
|
+
// clock is injectable (`now`) for deterministic tests.
|
|
12
12
|
class MetricsFeature extends BaseFeature {
|
|
13
13
|
version = '0.0.1'
|
|
14
14
|
name = 'metrics'
|
|
@@ -74,6 +74,11 @@ class MetricsFeature extends BaseFeature {
|
|
|
74
74
|
|
|
75
75
|
this._bump(m.total, ok, dur)
|
|
76
76
|
this._bump(op, ok, dur)
|
|
77
|
+
|
|
78
|
+
const sink = this._options.sink
|
|
79
|
+
if ('function' === typeof sink) {
|
|
80
|
+
try { sink(ctx.utility.clean(ctx, m)) } catch (_e) { }
|
|
81
|
+
}
|
|
77
82
|
}
|
|
78
83
|
|
|
79
84
|
|