@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
|
@@ -58,6 +58,9 @@ class PagingFeature extends BaseFeature {
|
|
|
58
58
|
if (null != paging.cursor) {
|
|
59
59
|
spec.query[cursorParam] = paging.cursor
|
|
60
60
|
}
|
|
61
|
+
else if ('string' === typeof paging.next && !this._foreign(paging.next, spec.base)) {
|
|
62
|
+
this._follow(spec, paging.next)
|
|
63
|
+
}
|
|
61
64
|
else if (null == spec.query[pageParam]) {
|
|
62
65
|
// A record written back by PreResult holds the page just fetched as
|
|
63
66
|
// `page` and the one to fetch as `nextPage`, so nextPage wins.
|
|
@@ -93,6 +96,7 @@ class PagingFeature extends BaseFeature {
|
|
|
93
96
|
nextPage: this._num(this._header(headers, 'x-next-page')),
|
|
94
97
|
next: undefined,
|
|
95
98
|
cursor: undefined,
|
|
99
|
+
foreign: undefined,
|
|
96
100
|
hasMore: false,
|
|
97
101
|
}
|
|
98
102
|
|
|
@@ -130,7 +134,10 @@ class PagingFeature extends BaseFeature {
|
|
|
130
134
|
|
|
131
135
|
// Body-level signals; snake_case forms are read first so camelCase wins.
|
|
132
136
|
if (body && 'object' === typeof body) {
|
|
133
|
-
if (null != body.next) {
|
|
137
|
+
if (null != body.next) {
|
|
138
|
+
if (this._isLink(body.next)) { paging.next = paging.next || body.next }
|
|
139
|
+
else { paging.cursor = body.next }
|
|
140
|
+
}
|
|
134
141
|
if (null != body.next_cursor) { paging.cursor = body.next_cursor }
|
|
135
142
|
if (null != body.cursor) { paging.cursor = body.cursor }
|
|
136
143
|
if (null != body.nextCursor) { paging.cursor = body.nextCursor }
|
|
@@ -148,6 +155,16 @@ class PagingFeature extends BaseFeature {
|
|
|
148
155
|
}
|
|
149
156
|
}
|
|
150
157
|
|
|
158
|
+
// A link to another origin is recorded, never followed, and ends the walk.
|
|
159
|
+
const base = null == ctx.spec ? ctx.options?.base : ctx.spec.base
|
|
160
|
+
if (null != paging.next) {
|
|
161
|
+
paging.next = this._resolve(paging.next, ctx.spec?.url)
|
|
162
|
+
}
|
|
163
|
+
if (null != paging.next && this._foreign(paging.next, base)) {
|
|
164
|
+
paging.foreign = paging.next
|
|
165
|
+
paging.next = undefined
|
|
166
|
+
}
|
|
167
|
+
|
|
151
168
|
// Cursor presence only INFERS another page. When the server stated the
|
|
152
169
|
// answer outright — relay's `hasNextPage: false`, or a body `hasMore` —
|
|
153
170
|
// that wins: a final page normally carries both an end cursor and
|
|
@@ -158,6 +175,10 @@ class PagingFeature extends BaseFeature {
|
|
|
158
175
|
null != paging.next || null != paging.cursor || null != paging.nextPage
|
|
159
176
|
}
|
|
160
177
|
|
|
178
|
+
if (null != paging.foreign && null == paging.cursor && null == paging.nextPage) {
|
|
179
|
+
paging.hasMore = false
|
|
180
|
+
}
|
|
181
|
+
|
|
161
182
|
result.paging = paging
|
|
162
183
|
|
|
163
184
|
// ctx.ctrl is the caller's own object, so the record reaches them.
|
|
@@ -204,6 +225,83 @@ class PagingFeature extends BaseFeature {
|
|
|
204
225
|
}
|
|
205
226
|
}
|
|
206
227
|
|
|
228
|
+
// Under the `next` option's default, a URL or an absolute path is a link and
|
|
229
|
+
// anything else a cursor; `cursor` and `url` pin the reading.
|
|
230
|
+
_isLink(next) {
|
|
231
|
+
if ('string' !== typeof next) { return false }
|
|
232
|
+
const mode = this._options.next || 'auto'
|
|
233
|
+
return 'url' === mode ||
|
|
234
|
+
('cursor' !== mode && ('' !== this._origin(next) || next.startsWith('/')))
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
_origin(text) {
|
|
239
|
+
const m = /^[a-z][a-z0-9+.-]*:\/\/[^/?#]*/i.exec('string' === typeof text ? text : '')
|
|
240
|
+
return null == m ? '' : m[0].toLowerCase()
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
_foreign(link, base) {
|
|
245
|
+
const origin = this._origin(link)
|
|
246
|
+
return '' !== origin && origin !== this._origin(base)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
// RFC 3986 reference resolution against the URL of the request that
|
|
251
|
+
// returned the link. A link on that URL's origin comes back as its path and
|
|
252
|
+
// query; an absolute link is left as the server wrote it.
|
|
253
|
+
_resolve(link, url) {
|
|
254
|
+
if ('string' !== typeof url || '' === url || /^[a-z][a-z0-9+.-]*:/i.test(link)) {
|
|
255
|
+
return link
|
|
256
|
+
}
|
|
257
|
+
const bare = '' === this._origin(url)
|
|
258
|
+
const holder = 'http://placeholder.invalid'
|
|
259
|
+
try {
|
|
260
|
+
const from = new URL(bare ? holder + (url.startsWith('/') ? '' : '/') + url : url)
|
|
261
|
+
const out = new URL(link, from)
|
|
262
|
+
return out.origin === from.origin ? out.pathname + out.search : out.href
|
|
263
|
+
}
|
|
264
|
+
catch (_e) {
|
|
265
|
+
return link
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
// The request goes to the link's path and query, on the SDK's own origin.
|
|
271
|
+
_follow(spec, next) {
|
|
272
|
+
const link = /^(?:[a-z][a-z0-9+.-]*:\/\/[^/?#]*)?([^?#]*)(?:\?([^#]*))?/i.exec(next)
|
|
273
|
+
const origin = /^[a-z][a-z0-9+.-]*:\/\/[^/?#]*/i.exec(String(spec.base || ''))
|
|
274
|
+
|
|
275
|
+
const query = {}
|
|
276
|
+
for (const pair of (link[2] || '').split('&')) {
|
|
277
|
+
if ('' === pair) { continue }
|
|
278
|
+
const at = pair.indexOf('=')
|
|
279
|
+
const key = at < 0 ? pair : pair.slice(0, at)
|
|
280
|
+
const val = at < 0 ? '' : pair.slice(at + 1)
|
|
281
|
+
query[this._unescape(key)] = this._unescape(val)
|
|
282
|
+
}
|
|
283
|
+
for (const key of (spec.authquery || [])) {
|
|
284
|
+
query[key] = spec.query[key]
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
spec.base = null == origin ? '' : origin[0]
|
|
288
|
+
spec.prefix = ''
|
|
289
|
+
spec.path = link[1]
|
|
290
|
+
spec.suffix = ''
|
|
291
|
+
spec.query = query
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
_unescape(text) {
|
|
296
|
+
try {
|
|
297
|
+
return decodeURIComponent(text.replace(/\+/g, ' '))
|
|
298
|
+
}
|
|
299
|
+
catch (err) {
|
|
300
|
+
return text
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
|
|
207
305
|
_isList(ctx) {
|
|
208
306
|
const ops = this._options.ops || ['list']
|
|
209
307
|
return ops.indexOf(ctx.op && ctx.op.name) >= 0
|
|
@@ -48,24 +48,20 @@ class RatelimitFeature extends BaseFeature {
|
|
|
48
48
|
const rate = this._options.rate || 5
|
|
49
49
|
const burst = null == this._options.burst ? rate : this._options.burst
|
|
50
50
|
|
|
51
|
-
// Refill
|
|
51
|
+
// Refill, then reserve this call's token before any wait: a negative
|
|
52
|
+
// count is the calls already queued, so overlapping calls pace in turn.
|
|
52
53
|
const now = this._now()
|
|
53
54
|
const elapsed = now - this._last
|
|
54
55
|
this._last = now
|
|
55
|
-
this._tokens = Math.min(burst, this._tokens + (elapsed / 1000) * rate)
|
|
56
|
+
this._tokens = Math.min(burst, this._tokens + (elapsed / 1000) * rate) - 1
|
|
56
57
|
|
|
57
|
-
if (this._tokens >=
|
|
58
|
-
this._tokens -= 1
|
|
58
|
+
if (this._tokens >= 0) {
|
|
59
59
|
return
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
const needed = 1 - this._tokens
|
|
64
|
-
const waitMs = Math.ceil((needed / rate) * 1000)
|
|
62
|
+
const waitMs = Math.ceil((-this._tokens / rate) * 1000)
|
|
65
63
|
this._track(ctx, waitMs)
|
|
66
64
|
await this._sleep(waitMs, signal)
|
|
67
|
-
this._last = this._now()
|
|
68
|
-
this._tokens = 0
|
|
69
65
|
}
|
|
70
66
|
|
|
71
67
|
|
|
@@ -106,7 +106,7 @@ class RetryFeature extends BaseFeature {
|
|
|
106
106
|
|
|
107
107
|
|
|
108
108
|
_backoff(res, attempt, minDelay, maxDelay, factor) {
|
|
109
|
-
//
|
|
109
|
+
// A server-provided Retry-After wins over the computed backoff.
|
|
110
110
|
const ra = this._retryAfter(res)
|
|
111
111
|
if (null != ra) {
|
|
112
112
|
return Math.min(maxDelay, ra)
|
|
@@ -131,8 +131,7 @@ class RetryFeature extends BaseFeature {
|
|
|
131
131
|
if (null == v) {
|
|
132
132
|
return null
|
|
133
133
|
}
|
|
134
|
-
|
|
135
|
-
return isNaN(n) ? null : n * 1000
|
|
134
|
+
return retryAfterMs(String(v), Date.now())
|
|
136
135
|
}
|
|
137
136
|
|
|
138
137
|
|
|
@@ -166,6 +165,29 @@ class RetryFeature extends BaseFeature {
|
|
|
166
165
|
}
|
|
167
166
|
|
|
168
167
|
|
|
168
|
+
const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
|
169
|
+
|
|
170
|
+
const IMF_FIXDATE =
|
|
171
|
+
/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) ([A-Z][a-z]{2}) (\d{4}) (\d{2}):(\d{2}):(\d{2}) GMT$/
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
// RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else null.
|
|
175
|
+
function retryAfterMs(value, now) {
|
|
176
|
+
const s = value.replace(/^[ \t]+|[ \t]+$/g, '')
|
|
177
|
+
if (/^[0-9]+$/.test(s)) {
|
|
178
|
+
return Number(s) * 1000
|
|
179
|
+
}
|
|
180
|
+
const m = IMF_FIXDATE.exec(s)
|
|
181
|
+
const month = null == m ? -1 : MONTHS.indexOf(m[2])
|
|
182
|
+
if (null == m || month < 0 || +m[1] < 1 || 31 < +m[1] ||
|
|
183
|
+
23 < +m[4] || 59 < +m[5] || 60 < +m[6]) {
|
|
184
|
+
return null
|
|
185
|
+
}
|
|
186
|
+
const at = Date.UTC(+m[3], month, +m[1], +m[4], +m[5], +m[6])
|
|
187
|
+
return Math.max(0, at - now)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
169
191
|
module.exports = {
|
|
170
192
|
RetryFeature
|
|
171
193
|
}
|
|
@@ -30,8 +30,9 @@ class StreamingFeature extends BaseFeature {
|
|
|
30
30
|
if (!this._streamable(ctx)) {
|
|
31
31
|
return
|
|
32
32
|
}
|
|
33
|
+
// A failed result keeps no stream, so the entity's stream() raises its error.
|
|
33
34
|
const result = ctx.result
|
|
34
|
-
if (null == result) {
|
|
35
|
+
if (null == result || null != result.err) {
|
|
35
36
|
return
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
const { BaseFeature } = require('../base/BaseFeature')
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
// W3C trace context: lowercase hex from the platform's random source, never all zeros.
|
|
7
|
+
function randomHex(bytes) {
|
|
8
|
+
const buf = new Uint8Array(bytes)
|
|
9
|
+
do {
|
|
10
|
+
globalThis.crypto.getRandomValues(buf)
|
|
11
|
+
} while (buf.every((b) => 0 === b))
|
|
12
|
+
return Array.from(buf, (b) => b.toString(16).padStart(2, '0')).join('')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
6
16
|
// Distributed-tracing telemetry. Opens a span per operation (PrePoint),
|
|
7
17
|
// propagates trace context to the server as W3C `traceparent` plus
|
|
8
18
|
// `X-Trace-Id` / `X-Span-Id` headers (PreRequest), and closes the span on
|
|
@@ -18,7 +28,6 @@ class TelemetryFeature extends BaseFeature {
|
|
|
18
28
|
_client
|
|
19
29
|
_options = {}
|
|
20
30
|
_spans = new WeakMap()
|
|
21
|
-
_seq = 0
|
|
22
31
|
|
|
23
32
|
|
|
24
33
|
init(ctx, options) {
|
|
@@ -26,7 +35,6 @@ class TelemetryFeature extends BaseFeature {
|
|
|
26
35
|
this._options = options || {}
|
|
27
36
|
this.active = options.active
|
|
28
37
|
this._spans = new WeakMap()
|
|
29
|
-
this._seq = 0
|
|
30
38
|
|
|
31
39
|
const client = this._client
|
|
32
40
|
if (null == client._telemetry) {
|
|
@@ -109,10 +117,7 @@ class TelemetryFeature extends BaseFeature {
|
|
|
109
117
|
if ('function' === typeof idgen) {
|
|
110
118
|
return idgen(kind)
|
|
111
119
|
}
|
|
112
|
-
|
|
113
|
-
this._seq++
|
|
114
|
-
const n = this._seq.toString(16).padStart(4, '0')
|
|
115
|
-
return (kind === 'trace' ? 't' : 's') + n.padEnd(16, '0')
|
|
120
|
+
return randomHex('trace' === kind ? 16 : 8)
|
|
116
121
|
}
|
|
117
122
|
|
|
118
123
|
|
|
@@ -343,7 +343,36 @@ class TestFeature extends BaseFeature {
|
|
|
343
343
|
const qand = []
|
|
344
344
|
const q = { '`$AND`': qand }
|
|
345
345
|
|
|
346
|
-
|
|
346
|
+
const idfrom = getpath(ctx.config, [
|
|
347
|
+
'entity', getprop(ctx.entity, 'name'), 'id', 'from']) || {}
|
|
348
|
+
|
|
349
|
+
const nest = (path, value) => {
|
|
350
|
+
const keys = String(path).split('.')
|
|
351
|
+
let out = value
|
|
352
|
+
for (let i = keys.length - 1; 0 <= i; i--) {
|
|
353
|
+
out = { [keys[i]]: out }
|
|
354
|
+
}
|
|
355
|
+
return out
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const match = ctx.match || {}
|
|
359
|
+
const data = ctx.data || {}
|
|
360
|
+
const names = [...keysof(args)]
|
|
361
|
+
|
|
362
|
+
// With no id in the call, the entity's held id (or composite parts) stands in.
|
|
363
|
+
if (null == getprop(args, 'id')) {
|
|
364
|
+
const parts = getpath(ctx.config, ['entity', getprop(ctx.entity, 'name'), 'id', 'parts']) ||
|
|
365
|
+
('list' === opname ? [] : ['id'])
|
|
366
|
+
for (const part of parts) {
|
|
367
|
+
const pname = String(part)
|
|
368
|
+
if (!names.includes(pname) &&
|
|
369
|
+
(null != getprop(match, pname) || null != getprop(data, pname))) {
|
|
370
|
+
names.push(pname)
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
for (let k of names) {
|
|
347
376
|
if ('id' === k || !isempty(select(reqd, k))) {
|
|
348
377
|
const v = param(ctx, k)
|
|
349
378
|
const ka = getprop(op.alias, k)
|
|
@@ -353,6 +382,14 @@ class TestFeature extends BaseFeature {
|
|
|
353
382
|
qor.push({ [ka]: v })
|
|
354
383
|
}
|
|
355
384
|
|
|
385
|
+
// An ALTERNATIVE, never a replacement: the parameter name still
|
|
386
|
+
// matches a record that happens to carry it flat, so a seed written
|
|
387
|
+
// either way is found. `$OR` is what makes that safe.
|
|
388
|
+
const kf = getprop(idfrom, k)
|
|
389
|
+
if (null != kf && k !== kf) {
|
|
390
|
+
qor.push(nest(kf, v))
|
|
391
|
+
}
|
|
392
|
+
|
|
356
393
|
qor = { '`$OR`': qor }
|
|
357
394
|
|
|
358
395
|
qand.push(qor)
|
|
@@ -68,6 +68,11 @@ function makeOptions(ctx) {
|
|
|
68
68
|
opts = { ...opts, feature: fmap }
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
const fdefaults = featureDefaults(struct, config.feature, opts.feature)
|
|
72
|
+
if (fdefaults !== opts.feature) {
|
|
73
|
+
opts = { ...opts, feature: fdefaults }
|
|
74
|
+
}
|
|
75
|
+
|
|
71
76
|
const customUtils = opts.utility || {}
|
|
72
77
|
for (let [key, val] of items(customUtils)) {
|
|
73
78
|
setprop(utility, key, val)
|
|
@@ -94,6 +99,7 @@ function makeOptions(ctx) {
|
|
|
94
99
|
opts = merge([{}, struct.clone(cfgopts), opts])
|
|
95
100
|
|
|
96
101
|
try {
|
|
102
|
+
refuseStrayKeys(opts, optspec)
|
|
97
103
|
opts = validate(opts, optspec)
|
|
98
104
|
}
|
|
99
105
|
catch (err) {
|
|
@@ -142,11 +148,12 @@ function makeOptions(ctx) {
|
|
|
142
148
|
})
|
|
143
149
|
}
|
|
144
150
|
|
|
145
|
-
// Resolve the feature add-order: an explicit array order (above) wins
|
|
146
|
-
//
|
|
147
|
-
//
|
|
148
|
-
|
|
149
|
-
let names = Object.keys(opts.feature || {})
|
|
151
|
+
// Resolve the feature add-order: an explicit array order (above) wins, and
|
|
152
|
+
// the names it leaves out follow it test-first, then sorted, so the outcome
|
|
153
|
+
// is deterministic and `test` is the base transport of a map.
|
|
154
|
+
{
|
|
155
|
+
let names = Object.keys(opts.feature || {})
|
|
156
|
+
.filter((n) => !featureorder.includes(n)).sort()
|
|
150
157
|
names = names.indexOf('test') < 0
|
|
151
158
|
? names
|
|
152
159
|
: ['test'].concat(names.filter((n) => 'test' !== n))
|
|
@@ -161,7 +168,7 @@ function makeOptions(ctx) {
|
|
|
161
168
|
names.splice(si, 1)
|
|
162
169
|
names.splice(names.indexOf('test') + 1, 0, 'station')
|
|
163
170
|
}
|
|
164
|
-
featureorder = names
|
|
171
|
+
featureorder = featureorder.concat(names)
|
|
165
172
|
}
|
|
166
173
|
|
|
167
174
|
opts.__derived__ = { featureorder }
|
|
@@ -175,6 +182,48 @@ function makeOptions(ctx) {
|
|
|
175
182
|
return opts
|
|
176
183
|
}
|
|
177
184
|
|
|
185
|
+
// Before validate: the struct's own refusal prints the value without its
|
|
186
|
+
// functions, so a misspelled callback key would go unnamed.
|
|
187
|
+
function refuseStrayKeys(opts, optspec) {
|
|
188
|
+
const fspecs = optspec.feature || {}
|
|
189
|
+
for (const [name, fopts] of Object.entries(opts.feature || {})) {
|
|
190
|
+
const spec = specMap(fspecs[name])
|
|
191
|
+
if (null == spec || spec['`$OPEN`'] || null == fopts || 'object' !== typeof fopts) {
|
|
192
|
+
continue
|
|
193
|
+
}
|
|
194
|
+
const stray = Object.keys(fopts)
|
|
195
|
+
.filter((k) => undefined !== fopts[k] && !Object.prototype.hasOwnProperty.call(spec, k))
|
|
196
|
+
if (0 < stray.length) {
|
|
197
|
+
throw new Error('Unexpected keys at field feature.' + name + ': ' + stray.join(', '))
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function specMap(spec) {
|
|
203
|
+
const alts = Array.isArray(spec) ? spec.slice('`$NOF`' === spec[0] ? 2 : 0) : [spec]
|
|
204
|
+
return alts.find((a) => null != a && 'object' === typeof a && !Array.isArray(a))
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// The model's options for a feature sit beneath the caller's, key by key: a
|
|
208
|
+
// key the caller sets replaces the default whole, so a list is never merged.
|
|
209
|
+
function featureDefaults(struct, cfgfeature, feature) {
|
|
210
|
+
const isMap = (b) => null != b && 'object' === typeof b && !Array.isArray(b)
|
|
211
|
+
if (null != feature && !isMap(feature)) {
|
|
212
|
+
return feature
|
|
213
|
+
}
|
|
214
|
+
const out = { ...(feature || {}) }
|
|
215
|
+
for (const name of Object.keys(cfgfeature || {})) {
|
|
216
|
+
const dflt = cfgfeature[name]?.options
|
|
217
|
+
const given = out[name]
|
|
218
|
+
if (!isMap(dflt) || (null == given && true !== dflt.active) ||
|
|
219
|
+
(null != given && !isMap(given))) {
|
|
220
|
+
continue
|
|
221
|
+
}
|
|
222
|
+
out[name] = { ...struct.clone(dflt), ...(given || {}) }
|
|
223
|
+
}
|
|
224
|
+
return null == feature && 0 === Object.keys(out).length ? feature : out
|
|
225
|
+
}
|
|
226
|
+
|
|
178
227
|
// Registration skips entity blocks, and rbac's rules, keyed by entity and op names.
|
|
179
228
|
function settings(opts) {
|
|
180
229
|
const plain = (b, name) => null != b && 'object' === typeof b && !Array.isArray(b)
|
|
@@ -49,11 +49,15 @@ const FEATURES = Object.keys((() => {
|
|
|
49
49
|
|
|
50
50
|
// A scripted transport built from a case's `res` list. Responses are consumed
|
|
51
51
|
// in order and the last one repeats, so a case that does not care how many
|
|
52
|
-
// attempts happen need only declare one.
|
|
53
|
-
|
|
52
|
+
// attempts happen need only declare one. Each URL it is sent is kept in `sent`,
|
|
53
|
+
// and the time it was sent in `at`; a `cut` response is one whose body stops
|
|
54
|
+
// before its end.
|
|
55
|
+
function scriptedFetcher(res, sent = [], at = []) {
|
|
54
56
|
let n = -1
|
|
55
|
-
return async function (_ctx,
|
|
57
|
+
return async function (_ctx, url, _fetchdef) {
|
|
56
58
|
n++
|
|
59
|
+
sent.push(url)
|
|
60
|
+
at.push(Date.now())
|
|
57
61
|
const spec = res[n < res.length ? n : res.length - 1] || {}
|
|
58
62
|
|
|
59
63
|
if (true === spec.throw) {
|
|
@@ -67,7 +71,10 @@ function scriptedFetcher(res) {
|
|
|
67
71
|
status,
|
|
68
72
|
statusText: status < 400 ? 'OK' : 'ERR',
|
|
69
73
|
body: 'not-used',
|
|
70
|
-
json: async () =>
|
|
74
|
+
json: async () => {
|
|
75
|
+
if (true === spec.cut) { throw new TypeError('terminated') }
|
|
76
|
+
return undefined === spec.body ? {} : spec.body
|
|
77
|
+
},
|
|
71
78
|
headers: {
|
|
72
79
|
get(key) {
|
|
73
80
|
const lower = String(key).toLowerCase()
|
|
@@ -83,7 +90,7 @@ function scriptedFetcher(res) {
|
|
|
83
90
|
}
|
|
84
91
|
|
|
85
92
|
|
|
86
|
-
function makeClient(kase) {
|
|
93
|
+
function makeClient(kase, sent = [], at = []) {
|
|
87
94
|
// `test: { active: true }` is the OPTION, not the `test` FEATURE.
|
|
88
95
|
//
|
|
89
96
|
// It says "this client is not live", which is what makes a REQUIRED
|
|
@@ -95,7 +102,7 @@ function makeClient(kase) {
|
|
|
95
102
|
return new SDK({
|
|
96
103
|
test: { active: true },
|
|
97
104
|
feature: kase.feature,
|
|
98
|
-
utility: { fetcher: scriptedFetcher(kase.res || [{ status: 200, body: {} }]) },
|
|
105
|
+
utility: { fetcher: scriptedFetcher(kase.res || [{ status: 200, body: {} }], sent, at) },
|
|
99
106
|
})
|
|
100
107
|
}
|
|
101
108
|
|
|
@@ -198,8 +205,9 @@ async function usableItem(entity) {
|
|
|
198
205
|
|
|
199
206
|
|
|
200
207
|
// A step may wait before its call, may add request headers for its call, and
|
|
201
|
-
// may pass `args` as the operation's first argument.
|
|
202
|
-
|
|
208
|
+
// may pass `args` as the operation's first argument. A `stream` step reads the
|
|
209
|
+
// operation through the entity's stream(), and `items` is how many it yields.
|
|
210
|
+
async function runStep(client, ref, step, ctrl) {
|
|
203
211
|
if (null != step.wait) {
|
|
204
212
|
await new Promise((resolve) => setTimeout(resolve, step.wait))
|
|
205
213
|
}
|
|
@@ -209,13 +217,52 @@ async function runStep(client, ref, step) {
|
|
|
209
217
|
options.headers = { ...(prior || {}), ...step.headers }
|
|
210
218
|
}
|
|
211
219
|
try {
|
|
212
|
-
|
|
220
|
+
if (true === step.stream) {
|
|
221
|
+
let items = 0
|
|
222
|
+
for await (const _item of client[ref.accessor]().stream(ref.op, { ...(step.args || {}) }, { ctrl })) {
|
|
223
|
+
items++
|
|
224
|
+
}
|
|
225
|
+
if (null != step.items) {
|
|
226
|
+
deepStrictEqual(items, step.items, `${ref.key}: items streamed`)
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
await client[ref.accessor]()[ref.op]({ ...(step.args || {}) }, ctrl)
|
|
231
|
+
}
|
|
213
232
|
}
|
|
214
233
|
finally {
|
|
215
234
|
options.headers = prior
|
|
216
235
|
}
|
|
217
236
|
}
|
|
218
237
|
|
|
238
|
+
// A step with `together: N` makes N overlapping calls; each call's error, or
|
|
239
|
+
// undefined, is returned.
|
|
240
|
+
async function runCalls(client, ref, step, ctrl) {
|
|
241
|
+
const calls = Array.from({ length: null == step.together ? 1 : step.together },
|
|
242
|
+
() => runStep(client, ref, step, ctrl).then(() => undefined, (e) => e))
|
|
243
|
+
return Promise.all(calls)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
// Each request a case expects, in order: its path, and its whole query. A
|
|
248
|
+
// path is compared without its leading slash, which an SDK with no base omits.
|
|
249
|
+
function checkSent(sent, expect, label) {
|
|
250
|
+
deepStrictEqual(sent.length, expect.length, `${label}: requests sent: ${sent.join(' | ')}`)
|
|
251
|
+
expect.forEach((want, i) => {
|
|
252
|
+
const url = new URL(sent[i], 'http://corpus.invalid')
|
|
253
|
+
if (null != want.path) {
|
|
254
|
+
deepStrictEqual(url.pathname.replace(/^\/+/, ''), want.path.replace(/^\/+/, ''),
|
|
255
|
+
`${label}: request ${i} path`)
|
|
256
|
+
}
|
|
257
|
+
if (null != want.query) {
|
|
258
|
+
const query = {}
|
|
259
|
+
url.searchParams.forEach((v, k) => { query[k] = v })
|
|
260
|
+
deepStrictEqual(query, want.query, `${label}: request ${i} query`)
|
|
261
|
+
}
|
|
262
|
+
})
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
|
|
219
266
|
// Replace #OP1/#OP2 throughout a case, keys included.
|
|
220
267
|
function resolve(node, tokens) {
|
|
221
268
|
if ('string' === typeof node) {
|
|
@@ -276,10 +323,26 @@ function subset(actual, expect, path) {
|
|
|
276
323
|
}
|
|
277
324
|
return
|
|
278
325
|
}
|
|
326
|
+
if (Array.isArray(expect)) {
|
|
327
|
+
ok(Array.isArray(actual) && actual.length === expect.length,
|
|
328
|
+
`${path}: want ${expect.length} item(s), got ${JSON.stringify(actual)}`)
|
|
329
|
+
expect.forEach((e, i) => subset(actual[i], e, `${path}[${i}]`))
|
|
330
|
+
return
|
|
331
|
+
}
|
|
279
332
|
deepStrictEqual(actual, expect, path)
|
|
280
333
|
}
|
|
281
334
|
|
|
282
335
|
|
|
336
|
+
// The most requests the transport saw in any window of `ms`.
|
|
337
|
+
function busiest(sent, ms) {
|
|
338
|
+
let most = 0
|
|
339
|
+
for (let i = 0; i < sent.length; i++) {
|
|
340
|
+
most = Math.max(most, sent.filter((t) => sent[i] <= t && t < sent[i] + ms).length)
|
|
341
|
+
}
|
|
342
|
+
return most
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
|
|
283
346
|
describe('FeatureCorpus', () => {
|
|
284
347
|
|
|
285
348
|
let corpus
|
|
@@ -396,29 +459,36 @@ describe('FeatureCorpus', () => {
|
|
|
396
459
|
|
|
397
460
|
// Every failing case is reported, not only the first.
|
|
398
461
|
try {
|
|
399
|
-
const
|
|
462
|
+
const sent = []
|
|
463
|
+
const at = []
|
|
464
|
+
const client = makeClient(kase, sent, at)
|
|
400
465
|
|
|
466
|
+
// A case-level ctrl is one control object every step shares.
|
|
401
467
|
for (const step of (kase.op || [])) {
|
|
402
468
|
const ref = byKey[step.op]
|
|
403
469
|
ok(null != ref, `${kase.name}: no operation ${step.op}`)
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
continue
|
|
415
|
-
}
|
|
416
|
-
ok(undefined !== err, `${kase.name}: ${step.op} was expected to fail, and did not`)
|
|
417
|
-
if ('string' === typeof step.err) {
|
|
418
|
-
deepStrictEqual(err.code, step.err, `${kase.name}: wrong error code`)
|
|
470
|
+
for (const err of await runCalls(client, ref, step, step.ctrl || kase.ctrl || {})) {
|
|
471
|
+
if (null == step.err) {
|
|
472
|
+
ok(undefined === err,
|
|
473
|
+
`${kase.name}: ${step.op} failed unexpectedly: ${err?.message}`)
|
|
474
|
+
continue
|
|
475
|
+
}
|
|
476
|
+
ok(undefined !== err, `${kase.name}: ${step.op} was expected to fail, and did not`)
|
|
477
|
+
if ('string' === typeof step.err) {
|
|
478
|
+
deepStrictEqual(err.code, step.err, `${kase.name}: wrong error code`)
|
|
479
|
+
}
|
|
419
480
|
}
|
|
420
481
|
}
|
|
421
482
|
|
|
483
|
+
if (null != kase.pace) {
|
|
484
|
+
const most = busiest(at, kase.pace.ms)
|
|
485
|
+
ok(most <= kase.pace.max, `${kase.name}: ${most} requests within ${kase.pace.ms} ms, ` +
|
|
486
|
+
`want at most ${kase.pace.max}`)
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
if (null != kase.sent) {
|
|
490
|
+
checkSent(sent, kase.sent, kase.name)
|
|
491
|
+
}
|
|
422
492
|
subset(client[`_${name}`], kase.out, `${kase.name}: _${name}`)
|
|
423
493
|
deepStrictEqual(shared(), PRISTINE,
|
|
424
494
|
`${kase.name}: the case wrote onto Object or Object.prototype`)
|
|
@@ -379,6 +379,17 @@ describe('feature', () => {
|
|
|
379
379
|
strictEqual(m.total.err, 1)
|
|
380
380
|
strictEqual(m.ops['widget.load'].count, 2)
|
|
381
381
|
})
|
|
382
|
+
|
|
383
|
+
test('the sink gets the counters once per operation', async () => {
|
|
384
|
+
const seen = []
|
|
385
|
+
const h = makeClient({ features: [
|
|
386
|
+
{ name: 'metrics', options: { sink: (m) => seen.push(m) } },
|
|
387
|
+
] })
|
|
388
|
+
await h.op({ op: 'load' })
|
|
389
|
+
await h.op({ op: 'list' })
|
|
390
|
+
deepStrictEqual(seen.map((m) => m.total.count), [1, 2])
|
|
391
|
+
strictEqual(seen[1].ops['widget.list'].count, 1)
|
|
392
|
+
})
|
|
382
393
|
})
|
|
383
394
|
|
|
384
395
|
|
|
@@ -732,7 +743,9 @@ describe('feature', () => {
|
|
|
732
743
|
test('default id generation and no exporter', async () => {
|
|
733
744
|
const h = makeClient({ features: [{ name: 'telemetry' }] })
|
|
734
745
|
await h.op({ op: 'load' })
|
|
735
|
-
|
|
746
|
+
const span = h.client._telemetry.spans[0]
|
|
747
|
+
ok(/^[0-9a-f]{32}$/.test(span.traceId) && !/^0+$/.test(span.traceId), span.traceId)
|
|
748
|
+
ok(/^[0-9a-f]{16}$/.test(span.spanId) && !/^0+$/.test(span.spanId), span.spanId)
|
|
736
749
|
})
|
|
737
750
|
})
|
|
738
751
|
|