@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
|
@@ -926,6 +926,97 @@ class FeatureTest {
|
|
|
926
926
|
assertEquals(true, res.result!!.paging!!["hasMore"], "expected hasMore")
|
|
927
927
|
}
|
|
928
928
|
|
|
929
|
+
// The documented hasMore loop, one request per page.
|
|
930
|
+
private fun pagingWalk(
|
|
931
|
+
options: MutableMap<String, Any?>? = null,
|
|
932
|
+
reply: (Int) -> Any?,
|
|
933
|
+
): Pair<List<String>, MutableMap<String, Any?>> {
|
|
934
|
+
val rec = FhRecorder()
|
|
935
|
+
rec.reply = { n, _ -> reply(n) }
|
|
936
|
+
val h = fhMake(rec::fetch, fhF(PagingFeature(), options))
|
|
937
|
+
val paging = linkedMapOf<String, Any?>()
|
|
938
|
+
val ctrl = fhMap("paging", paging)
|
|
939
|
+
h.op(fhOp("list").path("/w").ctrl(ctrl))
|
|
940
|
+
while (paging["hasMore"] == true && rec.calls.size < 4) {
|
|
941
|
+
h.op(fhOp("list").path("/w").ctrl(ctrl))
|
|
942
|
+
}
|
|
943
|
+
return Pair(rec.calls.indices.map { rec.url(it) }, paging)
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
@Test
|
|
947
|
+
fun paging_bodyNextIsSentAsTheCursor() {
|
|
948
|
+
assumeFeatures("paging")
|
|
949
|
+
val pages = listOf("c3", "c6", null)
|
|
950
|
+
val (urls, paging) = pagingWalk { n -> fhResponse(200, fhMap("next", pages[n - 1]), null) }
|
|
951
|
+
assertEquals(listOf("http://api.test/w?page=1", "http://api.test/w?cursor=c3",
|
|
952
|
+
"http://api.test/w?cursor=c6"), urls)
|
|
953
|
+
assertEquals(false, paging["hasMore"])
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
@Test
|
|
957
|
+
fun paging_bodyNextUrlIsTheNextRequest() {
|
|
958
|
+
assumeFeatures("paging")
|
|
959
|
+
val pages = listOf("http://api.test/v2/w?cursor=c%2F3&limit=3", "/v2/w?cursor=c6", null)
|
|
960
|
+
val (urls, paging) = pagingWalk { n -> fhResponse(200, fhMap("next", pages[n - 1]), null) }
|
|
961
|
+
assertEquals(listOf("http://api.test/w?page=1", "http://api.test/v2/w?cursor=c%2F3&limit=3",
|
|
962
|
+
"http://api.test/v2/w?cursor=c6"), urls)
|
|
963
|
+
assertEquals(false, paging["hasMore"])
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
@Test
|
|
967
|
+
fun paging_linkNextUrlIsTheNextRequest() {
|
|
968
|
+
assumeFeatures("paging")
|
|
969
|
+
val links = listOf("<http://api.test/w?after=b3>; rel=\"next\"", "</w?after=b6>; rel=\"next\"")
|
|
970
|
+
val (urls, paging) = pagingWalk { n ->
|
|
971
|
+
fhResponse(200, mutableListOf<Any?>(), if (n <= links.size) fhMap("link", links[n - 1]) else null)
|
|
972
|
+
}
|
|
973
|
+
assertEquals(listOf("http://api.test/w?page=1", "http://api.test/w?after=b3",
|
|
974
|
+
"http://api.test/w?after=b6"), urls)
|
|
975
|
+
assertEquals(false, paging["hasMore"])
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
@Test
|
|
979
|
+
fun paging_queryOnlyLinkKeepsThePath() {
|
|
980
|
+
assumeFeatures("paging")
|
|
981
|
+
val links = listOf("</v1/items?page=2>; rel=\"next\"", "<?page=3>; rel=\"next\"")
|
|
982
|
+
val (urls, _) = pagingWalk { n ->
|
|
983
|
+
fhResponse(200, mutableListOf<Any?>(), if (n <= links.size) fhMap("link", links[n - 1]) else null)
|
|
984
|
+
}
|
|
985
|
+
assertEquals(listOf("http://api.test/w?page=1", "http://api.test/v1/items?page=2",
|
|
986
|
+
"http://api.test/v1/items?page=3"), urls)
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
@Test
|
|
990
|
+
fun paging_pathRelativeLinkResolvesAgainstTheRequest() {
|
|
991
|
+
assumeFeatures("paging")
|
|
992
|
+
val links = listOf("</v1/items?page=2>; rel=\"next\"", "<more?page=3>; rel=\"next\"")
|
|
993
|
+
val (urls, _) = pagingWalk { n ->
|
|
994
|
+
fhResponse(200, mutableListOf<Any?>(), if (n <= links.size) fhMap("link", links[n - 1]) else null)
|
|
995
|
+
}
|
|
996
|
+
assertEquals(listOf("http://api.test/w?page=1", "http://api.test/v1/items?page=2",
|
|
997
|
+
"http://api.test/v1/more?page=3"), urls)
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
@Test
|
|
1001
|
+
fun paging_foreignLinkEndsTheWalk() {
|
|
1002
|
+
assumeFeatures("paging")
|
|
1003
|
+
val (urls, paging) = pagingWalk { _ ->
|
|
1004
|
+
fhResponse(200, mutableListOf<Any?>(), fhMap("link", "<https://elsewhere.test/w?after=b3>; rel=\"next\""))
|
|
1005
|
+
}
|
|
1006
|
+
assertEquals(listOf("http://api.test/w?page=1"), urls)
|
|
1007
|
+
assertEquals(false, paging["hasMore"])
|
|
1008
|
+
assertEquals("https://elsewhere.test/w?after=b3", paging["foreign"])
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
@Test
|
|
1012
|
+
fun paging_cursorModeSendsASlashCursor() {
|
|
1013
|
+
assumeFeatures("paging")
|
|
1014
|
+
val pages = listOf("/c3", null)
|
|
1015
|
+
val (urls, paging) = pagingWalk(fhMap("next", "cursor")) { n -> fhResponse(200, fhMap("next", pages[n - 1]), null) }
|
|
1016
|
+
assertEquals(listOf("http://api.test/w?page=1", "http://api.test/w?cursor=%2Fc3"), urls)
|
|
1017
|
+
assertEquals(false, paging["hasMore"])
|
|
1018
|
+
}
|
|
1019
|
+
|
|
929
1020
|
@Test
|
|
930
1021
|
fun paging_nonListNotPaged() {
|
|
931
1022
|
assumeFeatures("paging")
|
|
@@ -979,6 +1070,29 @@ class FeatureTest {
|
|
|
979
1070
|
assertEquals(listOf(listOf(1, 2), listOf(3, 4), listOf(5)), batches, "expected chunked batches")
|
|
980
1071
|
}
|
|
981
1072
|
|
|
1073
|
+
@Test
|
|
1074
|
+
fun streaming_failedResultIsNotStreamed() {
|
|
1075
|
+
assumeFeatures("streaming")
|
|
1076
|
+
val rec = FhRecorder()
|
|
1077
|
+
rec.reply = { _, _ -> fhResponse(503, mutableListOf<Any?>(), null) }
|
|
1078
|
+
val f = StreamingFeature()
|
|
1079
|
+
val h = fhMake(rec::fetch, fhF(f, null))
|
|
1080
|
+
val res = h.op(fhOp("list").path("/w"))
|
|
1081
|
+
assertFalse(res.result!!.streaming, "a failed result must keep no stream")
|
|
1082
|
+
assertNull(res.result!!.stream, "a failed result must keep no stream fn")
|
|
1083
|
+
assertEquals(0, f.opened, "expected no opened streams")
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
@Test
|
|
1087
|
+
fun streaming_emptyListStreamsNothing() {
|
|
1088
|
+
assumeFeatures("streaming")
|
|
1089
|
+
val rec = FhRecorder()
|
|
1090
|
+
rec.reply = { _, _ -> fhResponse(200, mutableListOf<Any?>(), null) }
|
|
1091
|
+
val h = fhMake(rec::fetch, fhF(StreamingFeature(), null))
|
|
1092
|
+
val res = h.op(fhOp("list").path("/w"))
|
|
1093
|
+
assertFalse(res.result!!.stream!!.get().hasNext(), "an empty list streams nothing")
|
|
1094
|
+
}
|
|
1095
|
+
|
|
982
1096
|
@Test
|
|
983
1097
|
fun streaming_nonListNotStreamed() {
|
|
984
1098
|
assumeFeatures("streaming")
|
|
@@ -101,6 +101,8 @@ fun makeOptions(ctx: Context): MutableMap<String, Any?> {
|
|
|
101
101
|
opts["feature"] = fmap
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
featureDefaults(config["feature"], opts["feature"])?.let { opts["feature"] = it }
|
|
105
|
+
|
|
104
106
|
// THE OPTION SPEC IS GENERATED, NOT WRITTEN HERE.
|
|
105
107
|
//
|
|
106
108
|
// Built from the model: `main.kit.optspec` for the standard options, plus
|
|
@@ -129,17 +131,17 @@ fun makeOptions(ctx: Context): MutableMap<String, Any?> {
|
|
|
129
131
|
mergeList.add(Struct.clone(cfgopts))
|
|
130
132
|
mergeList.add(opts)
|
|
131
133
|
val merged = Struct.merge(mergeList)
|
|
134
|
+
val callbacks = holdCallbacks(merged, optspec)
|
|
132
135
|
|
|
133
|
-
val vopts = linkedMapOf<String, Any?>()
|
|
134
|
-
vopts["errs"] = mutableListOf<Any?>()
|
|
135
136
|
val validated = try {
|
|
136
|
-
Struct.validate(merged, optspec
|
|
137
|
+
Struct.validate(merged, optspec)
|
|
137
138
|
} catch (err: RuntimeException) {
|
|
138
139
|
// A rejection quotes the value it rejected.
|
|
139
140
|
throw SdkError("options_invalid",
|
|
140
141
|
cleanWith(cleancfg, err.message ?: err.toString()) as String, ctx)
|
|
141
142
|
}
|
|
142
143
|
opts = validated as MutableMap<String, Any?>
|
|
144
|
+
restoreCallbacks(opts, callbacks)
|
|
143
145
|
|
|
144
146
|
// Restore the suppression the optspec default would otherwise erase.
|
|
145
147
|
if (authSuppressed) {
|
|
@@ -181,21 +183,23 @@ fun makeOptions(ctx: Context): MutableMap<String, Any?> {
|
|
|
181
183
|
}
|
|
182
184
|
}
|
|
183
185
|
|
|
184
|
-
// Resolve the feature add-order: an explicit list order (above) wins
|
|
185
|
-
//
|
|
186
|
-
//
|
|
187
|
-
|
|
186
|
+
// Resolve the feature add-order: an explicit list order (above) wins, and
|
|
187
|
+
// the names it leaves out follow it test-first, then sorted, so the outcome
|
|
188
|
+
// is deterministic and `test` is the base transport of a map.
|
|
189
|
+
run {
|
|
188
190
|
val fmap = Helpers.toMapAny(opts["feature"])
|
|
189
|
-
val names = (fmap?.keys?.
|
|
191
|
+
val names = (fmap?.keys?.filter { !featureorder.contains(it) }?.toMutableList()
|
|
192
|
+
?: mutableListOf()).also { it.sort() }
|
|
193
|
+
val rest = mutableListOf<Any?>()
|
|
190
194
|
if (names.contains("test")) {
|
|
191
|
-
|
|
195
|
+
rest.add("test")
|
|
192
196
|
for (n in names) {
|
|
193
197
|
if ("test" != n) {
|
|
194
|
-
|
|
198
|
+
rest.add(n)
|
|
195
199
|
}
|
|
196
200
|
}
|
|
197
201
|
} else {
|
|
198
|
-
|
|
202
|
+
rest.addAll(names)
|
|
199
203
|
}
|
|
200
204
|
// Station special case, mirroring test's: its transport wrap must
|
|
201
205
|
// sit immediately outside the base transport (inside every other
|
|
@@ -203,11 +207,12 @@ fun makeOptions(ctx: Context): MutableMap<String, Any?> {
|
|
|
203
207
|
// test - or first, when no test entry exists. Without this the
|
|
204
208
|
// sorted default would init station last and wrap OUTSIDE the
|
|
205
209
|
// recording features, turning its wire-truth events into fiction.
|
|
206
|
-
val si =
|
|
210
|
+
val si = rest.indexOf("station")
|
|
207
211
|
if (0 <= si) {
|
|
208
|
-
|
|
209
|
-
|
|
212
|
+
rest.removeAt(si)
|
|
213
|
+
rest.add(rest.indexOf("test") + 1, "station")
|
|
210
214
|
}
|
|
215
|
+
featureorder.addAll(rest)
|
|
211
216
|
}
|
|
212
217
|
|
|
213
218
|
val derived = linkedMapOf<String, Any?>()
|
|
@@ -224,6 +229,70 @@ fun makeOptions(ctx: Context): MutableMap<String, Any?> {
|
|
|
224
229
|
}
|
|
225
230
|
|
|
226
231
|
|
|
232
|
+
// This struct port's `$FUNCTION` admits neither a Consumer nor most other JVM
|
|
233
|
+
// callbacks, so a callback in a slot the spec types as a function is held out
|
|
234
|
+
// of validation and put back; any other key is still validated.
|
|
235
|
+
internal fun holdCallbacks(opts: Any?, optspec: Map<String, Any?>): Map<Pair<String, String>, Any?> {
|
|
236
|
+
val held = linkedMapOf<Pair<String, String>, Any?>()
|
|
237
|
+
val fspecs = Helpers.toMapAny(optspec["feature"]) ?: return held
|
|
238
|
+
for ((name, fopts) in Helpers.toMapAny(Helpers.toMapAny(opts)?.get("feature")) ?: return held) {
|
|
239
|
+
val fm = Helpers.toMapAny(fopts) ?: continue
|
|
240
|
+
val fspec = specMap(fspecs[name]) ?: continue
|
|
241
|
+
for (key in fm.keys.filter { isFunctionSpec(fspec[it]) && isCallback(fm[it]) }) {
|
|
242
|
+
held[name to key] = fm.remove(key)
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return held
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
private fun specMap(spec: Any?): Map<String, Any?>? {
|
|
249
|
+
if (spec is List<*>) {
|
|
250
|
+
val from = if ("`\$NOF`" == spec.firstOrNull()) 2 else 0
|
|
251
|
+
return spec.drop(from).firstOrNull { it is Map<*, *> }?.let { Helpers.toMapAny(it) }
|
|
252
|
+
}
|
|
253
|
+
return Helpers.toMapAny(spec)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
private fun isFunctionSpec(spec: Any?): Boolean =
|
|
257
|
+
"`\$FUNCTION`" == spec || (spec is List<*> && spec.contains("`\$FUNCTION`"))
|
|
258
|
+
|
|
259
|
+
private fun isCallback(v: Any?): Boolean =
|
|
260
|
+
v is Function<*> || (null != v && v.javaClass.interfaces.any {
|
|
261
|
+
it.isAnnotationPresent(FunctionalInterface::class.java) || "java.util.function" == it.`package`?.name
|
|
262
|
+
})
|
|
263
|
+
|
|
264
|
+
internal fun restoreCallbacks(opts: MutableMap<String, Any?>, held: Map<Pair<String, String>, Any?>) {
|
|
265
|
+
val feature = Helpers.toMapAny(opts["feature"]) ?: return
|
|
266
|
+
for ((at, fn) in held) {
|
|
267
|
+
Helpers.toMapAny(feature[at.first])?.put(at.second, fn)
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
// The model's options for a feature sit beneath the caller's, key by key: a
|
|
273
|
+
// key the caller sets replaces the default whole, so a list is never merged.
|
|
274
|
+
@Suppress("UNCHECKED_CAST")
|
|
275
|
+
internal fun featureDefaults(cfgfeature: Any?, feature: Any?): MutableMap<String, Any?>? {
|
|
276
|
+
if (feature != null && feature !is Map<*, *>) {
|
|
277
|
+
return null
|
|
278
|
+
}
|
|
279
|
+
val out = linkedMapOf<String, Any?>()
|
|
280
|
+
(feature as? Map<String, Any?>)?.let { out.putAll(it) }
|
|
281
|
+
for ((name, fdef) in Helpers.toMapAny(cfgfeature) ?: emptyMap<String, Any?>()) {
|
|
282
|
+
val dflt = Helpers.toMapAny(Helpers.toMapAny(fdef)?.get("options")) ?: continue
|
|
283
|
+
val given = out[name]
|
|
284
|
+
if ((given == null && true != dflt["active"]) || (given != null && given !is Map<*, *>)) {
|
|
285
|
+
continue
|
|
286
|
+
}
|
|
287
|
+
val merged = linkedMapOf<String, Any?>()
|
|
288
|
+
merged.putAll(Struct.clone(dflt) as Map<String, Any?>)
|
|
289
|
+
(given as? Map<String, Any?>)?.let { merged.putAll(it) }
|
|
290
|
+
out[name] = merged
|
|
291
|
+
}
|
|
292
|
+
return out
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
|
|
227
296
|
/**
|
|
228
297
|
* Replaces one utility member from `options.utility`, matching the ts
|
|
229
298
|
* reference: a key naming a real member REPLACES it, and any other key is
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
-- status and timing — on `client._debug.entries`. Every entry passes
|
|
6
6
|
-- through the SDK's clean rules (clean.keys and every registered secret);
|
|
7
7
|
-- the `redact` option ADDS header names on top of them. An optional
|
|
8
|
-
-- `
|
|
9
|
-
-- other targets) receives each finished entry. `max` caps the buffer
|
|
8
|
+
-- `onEntry` callback receives each finished entry. `max` caps the buffer
|
|
10
9
|
-- (default 100). The clock is injectable (`now`) for deterministic tests.
|
|
11
10
|
|
|
12
11
|
local BaseFeature = require("feature.base_feature")
|
|
@@ -148,7 +147,7 @@ function DebugFeature:_finish(ctx, ok)
|
|
|
148
147
|
table.remove(buf, 1)
|
|
149
148
|
end
|
|
150
149
|
|
|
151
|
-
local on_entry = self.options["
|
|
150
|
+
local on_entry = self.options["onEntry"]
|
|
152
151
|
if type(on_entry) == "function" then
|
|
153
152
|
pcall(on_entry, entry)
|
|
154
153
|
end
|
|
@@ -106,6 +106,11 @@ function MetricsFeature:_record(ctx, ok)
|
|
|
106
106
|
|
|
107
107
|
self:_bump(m.total, ok, dur)
|
|
108
108
|
self:_bump(op, ok, dur)
|
|
109
|
+
|
|
110
|
+
local sink = self.options["sink"]
|
|
111
|
+
if type(sink) == "function" then
|
|
112
|
+
pcall(sink, ctx.utility.clean(ctx, m))
|
|
113
|
+
end
|
|
109
114
|
end
|
|
110
115
|
|
|
111
116
|
|
|
@@ -36,6 +36,126 @@ local function header_get(headers, name)
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
|
|
39
|
+
-- Under the `next` option's default, a URL or an absolute path is a link and
|
|
40
|
+
-- anything else a cursor; `cursor` and `url` pin the reading.
|
|
41
|
+
local function is_link(nxt, mode)
|
|
42
|
+
if type(nxt) ~= "string" then
|
|
43
|
+
return false
|
|
44
|
+
end
|
|
45
|
+
if mode == "url" then
|
|
46
|
+
return true
|
|
47
|
+
end
|
|
48
|
+
if mode == "cursor" then
|
|
49
|
+
return false
|
|
50
|
+
end
|
|
51
|
+
return string.match(nxt, "^%a[%w+.-]*://") ~= nil or string.sub(nxt, 1, 1) == "/"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
local function origin_of(text)
|
|
56
|
+
if type(text) ~= "string" then
|
|
57
|
+
return ""
|
|
58
|
+
end
|
|
59
|
+
return string.match(text, "^%a[%w+.-]*://[^/?#]*") or ""
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
local function foreign(link, base)
|
|
64
|
+
local origin = string.lower(origin_of(link))
|
|
65
|
+
return origin ~= "" and origin ~= string.lower(origin_of(base))
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
local function unescape(text)
|
|
70
|
+
text = string.gsub(text, "+", " ")
|
|
71
|
+
return (string.gsub(text, "%%(%x%x)", function(h) return string.char(tonumber(h, 16)) end))
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
-- RFC 3986 section 5.2.4.
|
|
76
|
+
local function remove_dots(path)
|
|
77
|
+
local abs = string.sub(path, 1, 1) == "/"
|
|
78
|
+
local segs = {}
|
|
79
|
+
for seg in string.gmatch(path .. "/", "([^/]*)/") do
|
|
80
|
+
table.insert(segs, seg)
|
|
81
|
+
end
|
|
82
|
+
local out = {}
|
|
83
|
+
for i = abs and 2 or 1, #segs do
|
|
84
|
+
local seg = segs[i]
|
|
85
|
+
if seg == "." or seg == ".." then
|
|
86
|
+
if seg == ".." then
|
|
87
|
+
table.remove(out)
|
|
88
|
+
end
|
|
89
|
+
if i == #segs then
|
|
90
|
+
table.insert(out, "")
|
|
91
|
+
end
|
|
92
|
+
else
|
|
93
|
+
table.insert(out, seg)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
return (abs and "/" or "") .. table.concat(out, "/")
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
-- RFC 3986 reference resolution against the URL of the request that returned
|
|
101
|
+
-- the link, by hand: Lua has no resolver. A link on that URL's origin comes
|
|
102
|
+
-- back as its path and query; an absolute link is left as it is.
|
|
103
|
+
local function resolve(link, url)
|
|
104
|
+
if type(url) ~= "string" or url == "" or string.match(link, "^%a[%w+.-]*:") then
|
|
105
|
+
return link
|
|
106
|
+
end
|
|
107
|
+
link = string.match(link, "^[^#]*")
|
|
108
|
+
local origin = origin_of(url)
|
|
109
|
+
if string.sub(link, 1, 2) == "//" then
|
|
110
|
+
return origin == "" and link or (string.match(origin, "^[^:]*:") .. link)
|
|
111
|
+
end
|
|
112
|
+
local from = string.match(string.sub(url, #origin + 1), "^[^#]*")
|
|
113
|
+
local bpath, bquery = string.match(from, "^([^?]*)%??(.*)$")
|
|
114
|
+
if not string.find(from, "?", 1, true) then
|
|
115
|
+
bquery = nil
|
|
116
|
+
end
|
|
117
|
+
local rpath, rquery = string.match(link, "^([^?]*)%??(.*)$")
|
|
118
|
+
if not string.find(link, "?", 1, true) then
|
|
119
|
+
rquery = nil
|
|
120
|
+
end
|
|
121
|
+
local path, query
|
|
122
|
+
if rpath == "" then
|
|
123
|
+
path, query = bpath, rquery or bquery
|
|
124
|
+
elseif string.sub(rpath, 1, 1) == "/" then
|
|
125
|
+
path, query = remove_dots(rpath), rquery
|
|
126
|
+
else
|
|
127
|
+
path, query = remove_dots((string.match(bpath, "^(.*/)") or "") .. rpath), rquery
|
|
128
|
+
end
|
|
129
|
+
if string.sub(path, 1, 1) ~= "/" then
|
|
130
|
+
path = "/" .. path
|
|
131
|
+
end
|
|
132
|
+
return query == nil and path or (path .. "?" .. query)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
-- The request goes to the link's path and query, on the SDK's own origin.
|
|
137
|
+
local function follow(spec, nxt)
|
|
138
|
+
local link = string.sub(nxt, #origin_of(nxt) + 1)
|
|
139
|
+
link = string.match(link, "^[^#]*")
|
|
140
|
+
local path, rawquery = string.match(link, "^([^?]*)%??(.*)$")
|
|
141
|
+
|
|
142
|
+
local query = {}
|
|
143
|
+
for pair in string.gmatch(rawquery or "", "[^&]+") do
|
|
144
|
+
local key, val = string.match(pair, "^([^=]*)=?(.*)$")
|
|
145
|
+
query[unescape(key)] = unescape(val)
|
|
146
|
+
end
|
|
147
|
+
for _, key in ipairs(spec.authquery or {}) do
|
|
148
|
+
query[key] = spec.query[key]
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
spec.base = origin_of(spec.base)
|
|
152
|
+
spec.prefix = ""
|
|
153
|
+
spec.path = path or ""
|
|
154
|
+
spec.suffix = ""
|
|
155
|
+
spec.query = query
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
|
|
39
159
|
function PagingFeature.new()
|
|
40
160
|
local self = setmetatable(BaseFeature.new(), PagingFeature)
|
|
41
161
|
self.version = "0.0.1"
|
|
@@ -95,6 +215,8 @@ function PagingFeature:PreRequest(ctx)
|
|
|
95
215
|
|
|
96
216
|
if paging["cursor"] ~= nil then
|
|
97
217
|
spec.query[cursor_param] = paging["cursor"]
|
|
218
|
+
elseif type(paging["next"]) == "string" and not foreign(paging["next"], spec.base) then
|
|
219
|
+
follow(spec, paging["next"])
|
|
98
220
|
elseif spec.query[page_param] == nil then
|
|
99
221
|
-- A record written back by PreResult holds the page just fetched as
|
|
100
222
|
-- "page" and the one to fetch as "nextPage", so nextPage wins.
|
|
@@ -227,8 +349,13 @@ function PagingFeature:PreResult(ctx)
|
|
|
227
349
|
|
|
228
350
|
-- Body-level signals; snake_case forms are read first so camelCase wins.
|
|
229
351
|
if type(body) == "table" then
|
|
230
|
-
|
|
231
|
-
|
|
352
|
+
local bnext = body["next"]
|
|
353
|
+
if is_link(bnext, self.options["next"] or "auto") then
|
|
354
|
+
if paging.next == nil then
|
|
355
|
+
paging.next = bnext
|
|
356
|
+
end
|
|
357
|
+
elseif type(bnext) == "string" or type(bnext) == "number" then
|
|
358
|
+
paging.cursor = bnext
|
|
232
359
|
end
|
|
233
360
|
if body["next_cursor"] ~= nil then
|
|
234
361
|
paging.cursor = body["next_cursor"]
|
|
@@ -258,6 +385,16 @@ function PagingFeature:PreResult(ctx)
|
|
|
258
385
|
end
|
|
259
386
|
end
|
|
260
387
|
|
|
388
|
+
-- A link to another origin is recorded, never followed, and ends the walk.
|
|
389
|
+
local base = ctx.spec ~= nil and ctx.spec.base or (ctx.options or {})["base"]
|
|
390
|
+
if type(paging.next) == "string" and ctx.spec ~= nil then
|
|
391
|
+
paging.next = resolve(paging.next, ctx.spec.url)
|
|
392
|
+
end
|
|
393
|
+
if paging.next ~= nil and foreign(paging.next, base) then
|
|
394
|
+
paging.foreign = paging.next
|
|
395
|
+
paging.next = nil
|
|
396
|
+
end
|
|
397
|
+
|
|
261
398
|
-- Cursor presence only INFERS another page. When the server stated the
|
|
262
399
|
-- answer outright — relay's `hasNextPage: false`, or a body `hasMore` —
|
|
263
400
|
-- that wins: a final page normally carries both an end cursor and
|
|
@@ -268,6 +405,10 @@ function PagingFeature:PreResult(ctx)
|
|
|
268
405
|
paging.next ~= nil or paging.cursor ~= nil or paging.nextPage ~= nil
|
|
269
406
|
end
|
|
270
407
|
|
|
408
|
+
if paging.foreign ~= nil and paging.cursor == nil and paging.nextPage == nil then
|
|
409
|
+
paging.hasMore = false
|
|
410
|
+
end
|
|
411
|
+
|
|
271
412
|
result.paging = paging
|
|
272
413
|
|
|
273
414
|
if ctx.ctrl ~= nil then
|
|
@@ -62,24 +62,20 @@ function RatelimitFeature:_acquire(ctx)
|
|
|
62
62
|
local rate = self.options["rate"] or 5
|
|
63
63
|
local burst = self.options["burst"] == nil and rate or self.options["burst"]
|
|
64
64
|
|
|
65
|
-
-- Refill
|
|
65
|
+
-- Refill, then reserve this call's token before any wait: a negative
|
|
66
|
+
-- count is the calls already queued, so overlapping calls pace in turn.
|
|
66
67
|
local now = self:_now()
|
|
67
68
|
local elapsed = now - self.last
|
|
68
69
|
self.last = now
|
|
69
|
-
self.tokens = math.min(burst, self.tokens + (elapsed / 1000) * rate)
|
|
70
|
+
self.tokens = math.min(burst, self.tokens + (elapsed / 1000) * rate) - 1
|
|
70
71
|
|
|
71
|
-
if self.tokens >=
|
|
72
|
-
self.tokens = self.tokens - 1
|
|
72
|
+
if self.tokens >= 0 then
|
|
73
73
|
return
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
local needed = 1 - self.tokens
|
|
78
|
-
local wait_ms = math.ceil((needed / rate) * 1000)
|
|
76
|
+
local wait_ms = math.ceil((-self.tokens / rate) * 1000)
|
|
79
77
|
self:_track(ctx, wait_ms)
|
|
80
78
|
self:_sleep(wait_ms)
|
|
81
|
-
self.last = self:_now()
|
|
82
|
-
self.tokens = 0
|
|
83
79
|
end
|
|
84
80
|
|
|
85
81
|
|
|
@@ -106,7 +106,10 @@ function RetryFeature:_retryable(res, err)
|
|
|
106
106
|
if type(status) ~= "number" then
|
|
107
107
|
return false
|
|
108
108
|
end
|
|
109
|
-
local statuses = self.options["statuses"]
|
|
109
|
+
local statuses = self.options["statuses"]
|
|
110
|
+
if statuses == nil then
|
|
111
|
+
statuses = RETRY_STATUSES
|
|
112
|
+
end
|
|
110
113
|
for _, s in ipairs(statuses) do
|
|
111
114
|
if s == status then
|
|
112
115
|
return true
|
|
@@ -117,7 +120,7 @@ end
|
|
|
117
120
|
|
|
118
121
|
|
|
119
122
|
function RetryFeature:_backoff(res, attempt, min_delay, max_delay, factor)
|
|
120
|
-
--
|
|
123
|
+
-- A server-provided Retry-After wins over the computed backoff.
|
|
121
124
|
local ra = self:_retry_after(res)
|
|
122
125
|
if ra ~= nil then
|
|
123
126
|
return math.min(max_delay, ra)
|
|
@@ -139,11 +142,46 @@ function RetryFeature:_retry_after(res)
|
|
|
139
142
|
if v == nil then
|
|
140
143
|
return nil
|
|
141
144
|
end
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
return RetryFeature.retry_after_ms(tostring(v), os.time() * 1000)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
local MONTHS = "JanFebMarAprMayJunJulAugSepOctNovDec"
|
|
150
|
+
local DAYS = " Mon Tue Wed Thu Fri Sat Sun "
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
-- Days from 1970-01-01 to a proleptic Gregorian date.
|
|
154
|
+
local function days_from_civil(y, m, d)
|
|
155
|
+
if m <= 2 then
|
|
156
|
+
y = y - 1
|
|
157
|
+
end
|
|
158
|
+
local era = math.floor(y / 400)
|
|
159
|
+
local yoe = y - era * 400
|
|
160
|
+
local mp = (m + 9) % 12
|
|
161
|
+
local doy = math.floor((153 * mp + 2) / 5) + d - 1
|
|
162
|
+
local doe = yoe * 365 + math.floor(yoe / 4) - math.floor(yoe / 100) + doy
|
|
163
|
+
return era * 146097 + doe - 719468
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
-- RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else nil.
|
|
168
|
+
function RetryFeature.retry_after_ms(value, now)
|
|
169
|
+
local s = value:gsub("^[ \t]+", ""):gsub("[ \t]+$", "")
|
|
170
|
+
if s:match("^%d+$") then
|
|
171
|
+
return tonumber(s) * 1000
|
|
172
|
+
end
|
|
173
|
+
local wd, day, mon, year, hour, min, sec =
|
|
174
|
+
s:match("^(%a%a%a), (%d%d) (%a%a%a) (%d%d%d%d) (%d%d):(%d%d):(%d%d) GMT$")
|
|
175
|
+
if wd == nil or not DAYS:find(" " .. wd .. " ", 1, true) then
|
|
176
|
+
return nil
|
|
177
|
+
end
|
|
178
|
+
local mi = MONTHS:find(mon, 1, true)
|
|
179
|
+
day, year, hour, min, sec = tonumber(day), tonumber(year), tonumber(hour), tonumber(min), tonumber(sec)
|
|
180
|
+
if mi == nil or (mi - 1) % 3 ~= 0 or day < 1 or day > 31 or hour > 23 or min > 59 or sec > 60 then
|
|
144
181
|
return nil
|
|
145
182
|
end
|
|
146
|
-
|
|
183
|
+
local at = (((days_from_civil(year, (mi - 1) / 3 + 1, day) * 24 + hour) * 60 + min) * 60 + sec) * 1000
|
|
184
|
+
return math.max(0, at - now)
|
|
147
185
|
end
|
|
148
186
|
|
|
149
187
|
|
|
@@ -48,8 +48,9 @@ function StreamingFeature:PreResult(ctx)
|
|
|
48
48
|
if not self:_streamable(ctx) then
|
|
49
49
|
return
|
|
50
50
|
end
|
|
51
|
+
-- A failed result keeps no stream, so the entity's stream raises its error.
|
|
51
52
|
local result = ctx.result
|
|
52
|
-
if result == nil then
|
|
53
|
+
if result == nil or result.err ~= nil then
|
|
53
54
|
return
|
|
54
55
|
end
|
|
55
56
|
|
|
@@ -28,7 +28,6 @@ function TelemetryFeature.new()
|
|
|
28
28
|
self.options = nil
|
|
29
29
|
-- Weak keys: an abandoned context must not leak its open span.
|
|
30
30
|
self.spans = setmetatable({}, { __mode = "k" })
|
|
31
|
-
self.seq = 0
|
|
32
31
|
return self
|
|
33
32
|
end
|
|
34
33
|
|
|
@@ -44,7 +43,6 @@ function TelemetryFeature:init(ctx, options)
|
|
|
44
43
|
end
|
|
45
44
|
|
|
46
45
|
self.spans = setmetatable({}, { __mode = "k" })
|
|
47
|
-
self.seq = 0
|
|
48
46
|
|
|
49
47
|
if not self.active then
|
|
50
48
|
return
|
|
@@ -137,16 +135,29 @@ function TelemetryFeature:_close(ctx, ok)
|
|
|
137
135
|
end
|
|
138
136
|
|
|
139
137
|
|
|
138
|
+
-- W3C trace context: lowercase hex from the platform's random source, never all
|
|
139
|
+
-- zeros. Where /dev/urandom cannot be read, math.random stands in.
|
|
140
|
+
local function random_hex(nbytes)
|
|
141
|
+
while true do
|
|
142
|
+
local f = io.open("/dev/urandom", "rb")
|
|
143
|
+
local buf = f and f:read(nbytes) or ""
|
|
144
|
+
if f then f:close() end
|
|
145
|
+
local hex = {}
|
|
146
|
+
for i = 1, nbytes do
|
|
147
|
+
local b = buf:byte(i) or math.random(0, 255)
|
|
148
|
+
hex[i] = string.format("%02x", b)
|
|
149
|
+
end
|
|
150
|
+
local out = table.concat(hex)
|
|
151
|
+
if out:find("[^0]") then return out end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
140
155
|
function TelemetryFeature:_id(kind)
|
|
141
156
|
local idgen = self.options["idgen"]
|
|
142
157
|
if type(idgen) == "function" then
|
|
143
158
|
return idgen(kind)
|
|
144
159
|
end
|
|
145
|
-
|
|
146
|
-
self.seq = self.seq + 1
|
|
147
|
-
local n = string.format("%04x", self.seq)
|
|
148
|
-
local prefix = kind == "trace" and "t" or "s"
|
|
149
|
-
return prefix .. n .. string.rep("0", 12)
|
|
160
|
+
return random_hex(kind == "trace" and 16 or 8)
|
|
150
161
|
end
|
|
151
162
|
|
|
152
163
|
|