@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
|
@@ -113,6 +113,50 @@ let log_feature () : feature =
|
|
|
113
113
|
(* retry *)
|
|
114
114
|
(* ------------------------------------------------------------------ *)
|
|
115
115
|
|
|
116
|
+
(* RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else None. A date
|
|
117
|
+
needs the wall clock, which the stdlib lacks: with no [now] it is None. *)
|
|
118
|
+
let retry_after_ms value (now : float option) =
|
|
119
|
+
let is_ws c = c = ' ' || c = '\t' in
|
|
120
|
+
let n = String.length value in
|
|
121
|
+
let i = ref 0 and j = ref n in
|
|
122
|
+
while !i < n && is_ws value.[!i] do incr i done;
|
|
123
|
+
while !j > !i && is_ws value.[!j - 1] do decr j done;
|
|
124
|
+
let s = String.sub value !i (!j - !i) in
|
|
125
|
+
let len = String.length s in
|
|
126
|
+
let num a b =
|
|
127
|
+
let r = ref 0. in
|
|
128
|
+
(try for k = a to b - 1 do
|
|
129
|
+
match s.[k] with
|
|
130
|
+
| '0' .. '9' as c -> r := !r *. 10. +. float_of_int (Char.code c - 48)
|
|
131
|
+
| _ -> raise Exit
|
|
132
|
+
done; !r
|
|
133
|
+
with Exit -> -1.) in
|
|
134
|
+
let find hay x =
|
|
135
|
+
let rec go k = if k + 3 > String.length hay then -1
|
|
136
|
+
else if String.sub hay k 3 = x then k else go (k + 1) in go 0 in
|
|
137
|
+
if len > 0 && num 0 len >= 0. then Some (num 0 len *. 1000.)
|
|
138
|
+
else if now = None || len <> 29 || String.sub s 3 2 <> ", " || s.[7] <> ' ' || s.[11] <> ' '
|
|
139
|
+
|| s.[16] <> ' ' || s.[19] <> ':' || s.[22] <> ':' || String.sub s 25 4 <> " GMT"
|
|
140
|
+
|| not (List.mem (String.sub s 0 3) ["Mon"; "Tue"; "Wed"; "Thu"; "Fri"; "Sat"; "Sun"])
|
|
141
|
+
then None
|
|
142
|
+
else
|
|
143
|
+
let mi = find "JanFebMarAprMayJunJulAugSepOctNovDec" (String.sub s 8 3) in
|
|
144
|
+
let day = num 5 7 and year = num 12 16 and hour = num 17 19
|
|
145
|
+
and minute = num 20 22 and sec = num 23 25 in
|
|
146
|
+
if mi < 0 || mi mod 3 <> 0 || day < 1. || day > 31. || year < 0. || hour < 0. || hour > 23.
|
|
147
|
+
|| minute < 0. || minute > 59. || sec < 0. || sec > 60. then None
|
|
148
|
+
else begin
|
|
149
|
+
let m = mi / 3 + 1 in
|
|
150
|
+
let y = int_of_float year - (if m <= 2 then 1 else 0) in
|
|
151
|
+
let era = (if y >= 0 then y else y - 399) / 400 in
|
|
152
|
+
let yoe = y - era * 400 in
|
|
153
|
+
let doy = (153 * ((m + 9) mod 12) + 2) / 5 + int_of_float day - 1 in
|
|
154
|
+
let doe = yoe * 365 + yoe / 4 - yoe / 100 + doy in
|
|
155
|
+
let days = float_of_int (era * 146097 + doe - 719468) in
|
|
156
|
+
let at = (((days *. 24. +. hour) *. 60. +. minute) *. 60. +. sec) *. 1000. in
|
|
157
|
+
Some (Float.max 0. (at -. Option.get now))
|
|
158
|
+
end
|
|
159
|
+
|
|
116
160
|
let retry_feature () : feature =
|
|
117
161
|
let options = ref (empty_map ()) in
|
|
118
162
|
let f = { f_name = "retry"; f_version = "0.0.1"; f_active = true; f_options = Noval;
|
|
@@ -123,7 +167,7 @@ let retry_feature () : feature =
|
|
|
123
167
|
(match getp res_v "headers" with
|
|
124
168
|
| Map _ as h -> (match header_ci h "retry-after" with
|
|
125
169
|
| Noval | Null -> None
|
|
126
|
-
| v ->
|
|
170
|
+
| v -> retry_after_ms (vstr_of v) None)
|
|
127
171
|
| _ -> None)
|
|
128
172
|
| _ -> None
|
|
129
173
|
in
|
|
@@ -235,16 +279,14 @@ let ratelimit_feature () : feature =
|
|
|
235
279
|
let r = rate () and b = burst () in
|
|
236
280
|
let now = now_of !options in
|
|
237
281
|
let elapsed = now -. !last in
|
|
282
|
+
(* Refill, then reserve this call's token before any wait: a negative
|
|
283
|
+
count is the calls already queued, so overlapping calls pace in turn. *)
|
|
238
284
|
last := now;
|
|
239
|
-
tokens := Float.min b (!tokens +. (elapsed /. 1000.) *. r)
|
|
240
|
-
if !tokens
|
|
241
|
-
|
|
242
|
-
let needed = 1. -. !tokens in
|
|
243
|
-
let wait_ms = Float.of_int (int_of_float (ceil ((needed /. r) *. 1000.))) in
|
|
285
|
+
tokens := Float.min b (!tokens +. (elapsed /. 1000.) *. r) -. 1.;
|
|
286
|
+
if !tokens < 0. then begin
|
|
287
|
+
let wait_ms = Float.of_int (int_of_float (ceil ((-. !tokens /. r) *. 1000.))) in
|
|
244
288
|
track ctx wait_ms;
|
|
245
|
-
sleep_of !options wait_ms
|
|
246
|
-
last := now_of !options;
|
|
247
|
-
tokens := 0.
|
|
289
|
+
sleep_of !options wait_ms
|
|
248
290
|
end in
|
|
249
291
|
f.f_init <- (fun ctx opts ->
|
|
250
292
|
options := (match to_map opts with Map _ -> opts | _ -> empty_map ());
|
|
@@ -703,7 +745,10 @@ let metrics_feature () : feature =
|
|
|
703
745
|
let ops = getp m "ops" in
|
|
704
746
|
let opb = match getp ops key with Map _ as b -> b
|
|
705
747
|
| _ -> let b = jo [("count", Num 0.); ("ok", Num 0.); ("err", Num 0.); ("totalMs", Num 0.); ("maxMs", Num 0.)] in setp ops key b; b in
|
|
706
|
-
bump (getp m "total") ok dur; bump opb ok dur
|
|
748
|
+
bump (getp m "total") ok dur; bump opb ok dur;
|
|
749
|
+
(match getp !options "sink" with
|
|
750
|
+
| Func _ as fn -> (try ignore (call_vfn fn ((cu ctx).u_clean ctx m)) with _ -> ())
|
|
751
|
+
| _ -> ())
|
|
707
752
|
| _ -> () in
|
|
708
753
|
f.f_init <- (fun ctx opts ->
|
|
709
754
|
options := (match to_map opts with Map _ -> opts | _ -> empty_map ());
|
|
@@ -723,9 +768,29 @@ let metrics_feature () : feature =
|
|
|
723
768
|
(* telemetry *)
|
|
724
769
|
(* ------------------------------------------------------------------ *)
|
|
725
770
|
|
|
771
|
+
(* W3C trace context: lowercase hex from the platform's random source, never all
|
|
772
|
+
zeros. Where /dev/urandom cannot be read, Random stands in. *)
|
|
773
|
+
let telemetry_random_hex nbytes =
|
|
774
|
+
let read () =
|
|
775
|
+
try
|
|
776
|
+
let ic = open_in_bin "/dev/urandom" in
|
|
777
|
+
let s = (try really_input_string ic nbytes with e -> close_in ic; raise e) in
|
|
778
|
+
close_in ic; s
|
|
779
|
+
with _ -> String.init nbytes (fun _ -> Char.chr (Random.int 256)) in
|
|
780
|
+
let rec go () =
|
|
781
|
+
let s = read () in
|
|
782
|
+
let zero = ref true in
|
|
783
|
+
String.iter (fun c -> if c <> '\000' then zero := false) s;
|
|
784
|
+
if !zero then go ()
|
|
785
|
+
else begin
|
|
786
|
+
let b = Buffer.create (2 * nbytes) in
|
|
787
|
+
String.iter (fun c -> Buffer.add_string b (Printf.sprintf "%02x" (Char.code c))) s;
|
|
788
|
+
Buffer.contents b
|
|
789
|
+
end in
|
|
790
|
+
go ()
|
|
791
|
+
|
|
726
792
|
let telemetry_feature () : feature =
|
|
727
793
|
let options = ref (empty_map ()) in
|
|
728
|
-
let seq = ref 0 in
|
|
729
794
|
let f = { f_name = "telemetry"; f_version = "0.0.1"; f_active = true; f_options = Noval;
|
|
730
795
|
f_init = (fun _ _ -> ()); f_hook = (fun _ _ -> ()) } in
|
|
731
796
|
let telemetry ctx = track_bucket (cc ctx) "telemetry"
|
|
@@ -733,11 +798,7 @@ let telemetry_feature () : feature =
|
|
|
733
798
|
let gen_id kind =
|
|
734
799
|
match getp !options "idgen" with
|
|
735
800
|
| Func _ as fn -> vstr_of (call_vfn fn (Str kind))
|
|
736
|
-
| _ ->
|
|
737
|
-
incr seq;
|
|
738
|
-
let n = Printf.sprintf "%04x" !seq in
|
|
739
|
-
let padded = n ^ String.make (max 0 (16 - String.length n)) '0' in
|
|
740
|
-
(if kind = "trace" then "t" else "s") ^ padded in
|
|
801
|
+
| _ -> telemetry_random_hex (if kind = "trace" then 16 else 8) in
|
|
741
802
|
let close ctx ok =
|
|
742
803
|
match scratch_get ctx "telemetry_span" with
|
|
743
804
|
| Some (Map _ as span) ->
|
|
@@ -755,7 +816,6 @@ let telemetry_feature () : feature =
|
|
|
755
816
|
f.f_init <- (fun ctx opts ->
|
|
756
817
|
options := (match to_map opts with Map _ -> opts | _ -> empty_map ());
|
|
757
818
|
f.f_active <- opt_active opts;
|
|
758
|
-
seq := 0;
|
|
759
819
|
ignore (telemetry ctx));
|
|
760
820
|
f.f_hook <- (fun name ctx ->
|
|
761
821
|
if f.f_active then match name with
|
|
@@ -1213,6 +1273,143 @@ let graphql_pre_request (options : value) (spec : spec) (point : value)
|
|
|
1213
1273
|
then setp variables first_var lim)
|
|
1214
1274
|
| _ -> ()
|
|
1215
1275
|
|
|
1276
|
+
(* The length of a URL's scheme and authority, or zero when it has none. *)
|
|
1277
|
+
let paging_origin_len (s : string) : int =
|
|
1278
|
+
let n = String.length s in
|
|
1279
|
+
let is_alpha c = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') in
|
|
1280
|
+
let is_scheme c = is_alpha c || (c >= '0' && c <= '9') || c = '+' || c = '.' || c = '-' in
|
|
1281
|
+
if n = 0 || not (is_alpha s.[0]) then 0
|
|
1282
|
+
else begin
|
|
1283
|
+
let i = ref 1 in
|
|
1284
|
+
while !i < n && is_scheme s.[!i] do incr i done;
|
|
1285
|
+
if !i + 3 <= n && String.sub s !i 3 = "://" then begin
|
|
1286
|
+
let j = ref (!i + 3) in
|
|
1287
|
+
while !j < n && s.[!j] <> '/' && s.[!j] <> '?' && s.[!j] <> '#' do incr j done;
|
|
1288
|
+
!j
|
|
1289
|
+
end else 0
|
|
1290
|
+
end
|
|
1291
|
+
|
|
1292
|
+
(* Under the `next` option's default, a URL or an absolute path is a link and
|
|
1293
|
+
* anything else a cursor; `cursor` and `url` pin the reading. *)
|
|
1294
|
+
let paging_is_link (v : value) (mode : string) : bool = match v with
|
|
1295
|
+
| Str s ->
|
|
1296
|
+
mode = "url" ||
|
|
1297
|
+
(mode <> "cursor" && (paging_origin_len s > 0 || (String.length s > 0 && s.[0] = '/')))
|
|
1298
|
+
| _ -> false
|
|
1299
|
+
|
|
1300
|
+
let paging_origin_of (s : string) : string =
|
|
1301
|
+
String.lowercase_ascii (String.sub s 0 (paging_origin_len s))
|
|
1302
|
+
|
|
1303
|
+
let paging_foreign (link : string) (base : string) : bool =
|
|
1304
|
+
let origin = paging_origin_of link in
|
|
1305
|
+
origin <> "" && origin <> paging_origin_of base
|
|
1306
|
+
|
|
1307
|
+
let paging_unescape (s : string) : string =
|
|
1308
|
+
let n = String.length s in
|
|
1309
|
+
let b = Buffer.create n in
|
|
1310
|
+
let hex c = match c with
|
|
1311
|
+
| '0'..'9' -> Some (Char.code c - 48)
|
|
1312
|
+
| 'a'..'f' -> Some (Char.code c - 87)
|
|
1313
|
+
| 'A'..'F' -> Some (Char.code c - 55)
|
|
1314
|
+
| _ -> None in
|
|
1315
|
+
let i = ref 0 in
|
|
1316
|
+
while !i < n do
|
|
1317
|
+
(match s.[!i] with
|
|
1318
|
+
| '+' -> Buffer.add_char b ' '
|
|
1319
|
+
| '%' when !i + 2 < n ->
|
|
1320
|
+
(match hex s.[!i + 1], hex s.[!i + 2] with
|
|
1321
|
+
| Some h, Some l -> Buffer.add_char b (Char.chr (h * 16 + l)); i := !i + 2
|
|
1322
|
+
| _ -> Buffer.add_char b '%')
|
|
1323
|
+
| c -> Buffer.add_char b c);
|
|
1324
|
+
incr i
|
|
1325
|
+
done;
|
|
1326
|
+
Buffer.contents b
|
|
1327
|
+
|
|
1328
|
+
let paging_has_scheme (s : string) : bool =
|
|
1329
|
+
let n = String.length s in
|
|
1330
|
+
let is_alpha c = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') in
|
|
1331
|
+
let is_scheme c = is_alpha c || (c >= '0' && c <= '9') || c = '+' || c = '.' || c = '-' in
|
|
1332
|
+
if n = 0 || not (is_alpha s.[0]) then false
|
|
1333
|
+
else begin
|
|
1334
|
+
let i = ref 1 in
|
|
1335
|
+
while !i < n && is_scheme s.[!i] do incr i done;
|
|
1336
|
+
!i < n && s.[!i] = ':'
|
|
1337
|
+
end
|
|
1338
|
+
|
|
1339
|
+
let paging_cut (s : string) (c : char) : string * string option =
|
|
1340
|
+
match String.index_opt s c with
|
|
1341
|
+
| Some k -> (String.sub s 0 k, Some (String.sub s (k + 1) (String.length s - k - 1)))
|
|
1342
|
+
| None -> (s, None)
|
|
1343
|
+
|
|
1344
|
+
(* RFC 3986 section 5.2.4. *)
|
|
1345
|
+
let paging_remove_dots (path : string) : string =
|
|
1346
|
+
let abs = String.length path > 0 && path.[0] = '/' in
|
|
1347
|
+
let segs = String.split_on_char '/' path in
|
|
1348
|
+
let segs = if abs then List.tl segs else segs in
|
|
1349
|
+
let n = List.length segs in
|
|
1350
|
+
let step (i, acc) seg =
|
|
1351
|
+
let acc =
|
|
1352
|
+
if seg = "." || seg = ".." then begin
|
|
1353
|
+
let acc = if seg = ".." then (match acc with _ :: tl -> tl | [] -> []) else acc in
|
|
1354
|
+
if i = n - 1 then "" :: acc else acc
|
|
1355
|
+
end else seg :: acc in
|
|
1356
|
+
(i + 1, acc) in
|
|
1357
|
+
let out = List.rev (snd (List.fold_left step (0, []) segs)) in
|
|
1358
|
+
(if abs then "/" else "") ^ String.concat "/" out
|
|
1359
|
+
|
|
1360
|
+
(* RFC 3986 reference resolution against the URL of the request that returned
|
|
1361
|
+
* the link, by hand: the standard library has no resolver. A link on that
|
|
1362
|
+
* URL's origin comes back as its path and query; an absolute link is left as
|
|
1363
|
+
* it is. *)
|
|
1364
|
+
let paging_resolve (link : string) (url : string) : string =
|
|
1365
|
+
if url = "" || paging_has_scheme link then link
|
|
1366
|
+
else begin
|
|
1367
|
+
let link = fst (paging_cut link '#') in
|
|
1368
|
+
let on = paging_origin_len url in
|
|
1369
|
+
if String.length link >= 2 && String.sub link 0 2 = "//" then
|
|
1370
|
+
(if on = 0 then link else fst (paging_cut url ':') ^ ":" ^ link)
|
|
1371
|
+
else begin
|
|
1372
|
+
let from = fst (paging_cut (String.sub url on (String.length url - on)) '#') in
|
|
1373
|
+
let (bpath, bquery) = paging_cut from '?' in
|
|
1374
|
+
let (rpath, rquery) = paging_cut link '?' in
|
|
1375
|
+
let (path, query) =
|
|
1376
|
+
if rpath = "" then (bpath, (match rquery with Some _ -> rquery | None -> bquery))
|
|
1377
|
+
else if rpath.[0] = '/' then (paging_remove_dots rpath, rquery)
|
|
1378
|
+
else begin
|
|
1379
|
+
let dir = match String.rindex_opt bpath '/' with
|
|
1380
|
+
| Some k -> String.sub bpath 0 (k + 1)
|
|
1381
|
+
| None -> "" in
|
|
1382
|
+
(paging_remove_dots (dir ^ rpath), rquery)
|
|
1383
|
+
end in
|
|
1384
|
+
let path = if String.length path > 0 && path.[0] = '/' then path else "/" ^ path in
|
|
1385
|
+
match query with Some q -> path ^ "?" ^ q | None -> path
|
|
1386
|
+
end
|
|
1387
|
+
end
|
|
1388
|
+
|
|
1389
|
+
(* The request goes to the link's path and query, on the SDK's own origin. *)
|
|
1390
|
+
let paging_follow (spec : spec) (next : string) : unit =
|
|
1391
|
+
let skip = paging_origin_len next in
|
|
1392
|
+
let rest = String.sub next skip (String.length next - skip) in
|
|
1393
|
+
let rest = match String.index_opt rest '#' with Some i -> String.sub rest 0 i | None -> rest in
|
|
1394
|
+
let path, rawquery = match String.index_opt rest '?' with
|
|
1395
|
+
| Some i -> String.sub rest 0 i, String.sub rest (i + 1) (String.length rest - i - 1)
|
|
1396
|
+
| None -> rest, "" in
|
|
1397
|
+
let query = empty_map () in
|
|
1398
|
+
List.iter (fun pair ->
|
|
1399
|
+
if pair <> "" then
|
|
1400
|
+
match String.index_opt pair '=' with
|
|
1401
|
+
| Some i ->
|
|
1402
|
+
setp query (paging_unescape (String.sub pair 0 i))
|
|
1403
|
+
(Str (paging_unescape (String.sub pair (i + 1) (String.length pair - i - 1))))
|
|
1404
|
+
| None -> setp query (paging_unescape pair) (Str ""))
|
|
1405
|
+
(String.split_on_char '&' rawquery);
|
|
1406
|
+
List.iter (fun k -> setp query k (getp spec.sp_query k)) spec.sp_authquery;
|
|
1407
|
+
spec.sp_base <- String.sub spec.sp_base 0 (paging_origin_len spec.sp_base);
|
|
1408
|
+
spec.sp_prefix <- "";
|
|
1409
|
+
spec.sp_path <- path;
|
|
1410
|
+
spec.sp_suffix <- "";
|
|
1411
|
+
spec.sp_query <- query
|
|
1412
|
+
|
|
1216
1413
|
let paging_feature () : feature =
|
|
1217
1414
|
let options = ref (empty_map ()) in
|
|
1218
1415
|
let f = { f_name = "paging"; f_version = "0.0.1"; f_active = true; f_options = Noval;
|
|
@@ -1254,6 +1451,10 @@ let paging_feature () : feature =
|
|
|
1254
1451
|
graphql_pre_request !options spec ctx.c_point paging
|
|
1255
1452
|
else begin
|
|
1256
1453
|
(match getp paging "cursor" with
|
|
1454
|
+
| Noval | Null when (match getp paging "next" with
|
|
1455
|
+
| Str l -> not (paging_foreign l spec.sp_base)
|
|
1456
|
+
| _ -> false) ->
|
|
1457
|
+
paging_follow spec (vstr_of (getp paging "next"))
|
|
1257
1458
|
| Noval | Null ->
|
|
1258
1459
|
(match getp q page_param with
|
|
1259
1460
|
| Noval ->
|
|
@@ -1271,7 +1472,10 @@ let paging_feature () : feature =
|
|
|
1271
1472
|
| c -> setp q cursor_param c);
|
|
1272
1473
|
(match getp !options "limit" with
|
|
1273
1474
|
| Noval | Null -> ()
|
|
1274
|
-
| lim ->
|
|
1475
|
+
| lim ->
|
|
1476
|
+
(match getp spec.sp_query limit_param with
|
|
1477
|
+
| Noval -> setp spec.sp_query limit_param lim
|
|
1478
|
+
| _ -> ()))
|
|
1275
1479
|
end)
|
|
1276
1480
|
| "PreResult" ->
|
|
1277
1481
|
(match ctx.c_result with
|
|
@@ -1317,7 +1521,12 @@ let paging_feature () : feature =
|
|
|
1317
1521
|
| _ -> ());
|
|
1318
1522
|
(match body with
|
|
1319
1523
|
| Map _ ->
|
|
1320
|
-
(match getp body "next" with
|
|
1524
|
+
(match getp body "next" with
|
|
1525
|
+
| Noval | Null -> ()
|
|
1526
|
+
| n ->
|
|
1527
|
+
if not (paging_is_link n (opt_str !options "next" ~default:"auto")) then
|
|
1528
|
+
setp paging "cursor" n
|
|
1529
|
+
else if is_nullish (getp paging "next") then setp paging "next" n);
|
|
1321
1530
|
(* Both spellings, camelCase last so it wins when a body
|
|
1322
1531
|
* carries the two. *)
|
|
1323
1532
|
(match getp body "next_cursor" with Noval | Null -> () | c -> setp paging "cursor" c);
|
|
@@ -1333,6 +1542,18 @@ let paging_feature () : feature =
|
|
|
1333
1542
|
| Bool b -> setp paging "hasMore" (Bool b); explicit_more := true
|
|
1334
1543
|
| _ -> ()) ["has_more"; "hasMore"]
|
|
1335
1544
|
| _ -> ());
|
|
1545
|
+
(* A link to another origin is recorded, never followed, and
|
|
1546
|
+
* ends the walk. *)
|
|
1547
|
+
let base = match ctx.c_spec with
|
|
1548
|
+
| Some sp -> sp.sp_base
|
|
1549
|
+
| None -> get_str_d ctx.c_options "base" "" in
|
|
1550
|
+
(match ctx.c_spec, getp paging "next" with
|
|
1551
|
+
| Some sp, Str l -> setp paging "next" (Str (paging_resolve l sp.sp_url))
|
|
1552
|
+
| _ -> ());
|
|
1553
|
+
(match getp paging "next" with
|
|
1554
|
+
| Str l when paging_foreign l base ->
|
|
1555
|
+
setp paging "foreign" (Str l); setp paging "next" Noval
|
|
1556
|
+
| _ -> ());
|
|
1336
1557
|
(* Cursor presence only INFERS another page. When the server
|
|
1337
1558
|
* stated the answer outright — relay's `hasNextPage: false`, or
|
|
1338
1559
|
* a body `hasMore` — that wins: a final page normally carries
|
|
@@ -1346,6 +1567,9 @@ let paging_feature () : feature =
|
|
|
1346
1567
|
|| not (is_nullish (getp paging "nextPage")) in
|
|
1347
1568
|
setp paging "hasMore" (Bool hm)
|
|
1348
1569
|
end;
|
|
1570
|
+
if not (is_nullish (getp paging "foreign")) && is_nullish (getp paging "cursor")
|
|
1571
|
+
&& is_nullish (getp paging "nextPage") then
|
|
1572
|
+
setp paging "hasMore" (Bool false);
|
|
1349
1573
|
result.rt_paging <- paging;
|
|
1350
1574
|
(* The record reached the caller through ctrl in every other typed
|
|
1351
1575
|
* port and through nothing here, so a caller who asked for paging
|
|
@@ -1355,7 +1579,7 @@ let paging_feature () : feature =
|
|
|
1355
1579
|
(* The caller holds this map: refill it in place. Every key of
|
|
1356
1580
|
* the record is written, so no key of an earlier page lives on. *)
|
|
1357
1581
|
List.iter (fun k -> setp held k (getp paging k))
|
|
1358
|
-
["page"; "totalCount"; "nextPage"; "next"; "cursor"; "hasMore"]
|
|
1582
|
+
["page"; "totalCount"; "nextPage"; "next"; "cursor"; "foreign"; "hasMore"]
|
|
1359
1583
|
| _ -> ctx.c_ctrl.ctrl_paging <- paging);
|
|
1360
1584
|
track_set (cc ctx) "paging" (jo [("last", paging)]))
|
|
1361
1585
|
| _ -> ());
|
|
@@ -1388,8 +1612,10 @@ let streaming_feature () : feature =
|
|
|
1388
1612
|
f.f_active <- opt_active opts);
|
|
1389
1613
|
f.f_hook <- (fun name ctx ->
|
|
1390
1614
|
if name = "PreResult" && f.f_active && streamable ctx then
|
|
1615
|
+
(* A failed result keeps no stream, so the entity's stream raises its error. *)
|
|
1391
1616
|
match ctx.c_result with
|
|
1392
1617
|
| None -> ()
|
|
1618
|
+
| Some { rt_err = Some _; _ } -> ()
|
|
1393
1619
|
| Some result ->
|
|
1394
1620
|
result.rt_streaming <- true;
|
|
1395
1621
|
result.rt_stream <- Some (fun () -> iterate result);
|
|
@@ -1660,39 +1886,49 @@ let test_feature () : feature =
|
|
|
1660
1886
|
let reqd_params = reqd_names point "params" in
|
|
1661
1887
|
let reqd_query = reqd_names point "query" in
|
|
1662
1888
|
let qand = ref [] in
|
|
1663
|
-
(
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1889
|
+
let idfrom = getpath_s ctx.c_config ("entity." ^ entname ^ ".id.from") in
|
|
1890
|
+
let held src key = match src with
|
|
1891
|
+
| Map _ -> (match getp src key with Noval | Null | Str "__UNDEFINED__" -> false | _ -> true)
|
|
1892
|
+
| _ -> false in
|
|
1893
|
+
let given = match args with Map _ -> keysof args | _ -> [] in
|
|
1894
|
+
(* With no id in the call, the entity's held id (or composite parts) stands in. *)
|
|
1895
|
+
let names =
|
|
1896
|
+
if held args "id" then given
|
|
1897
|
+
else begin
|
|
1898
|
+
let parts = match getpath_s ctx.c_config ("entity." ^ entname ^ ".id.parts") with
|
|
1899
|
+
| List r -> List.filter_map (function Str s -> Some s | _ -> None) !r
|
|
1900
|
+
| _ -> if opname = "list" then [] else ["id"] in
|
|
1901
|
+
List.fold_left (fun acc p ->
|
|
1902
|
+
if not (List.mem p acc) && (held ctx.c_match p || held ctx.c_data p) then acc @ [p] else acc)
|
|
1903
|
+
given parts
|
|
1904
|
+
end in
|
|
1905
|
+
List.iter (fun key ->
|
|
1906
|
+
let is_id = key = "id" in
|
|
1907
|
+
let is_reqd = not (isempty (select reqd_params (Str key)))
|
|
1908
|
+
|| not (isempty (select reqd_query (Str key))) in
|
|
1909
|
+
if is_id || is_reqd then begin
|
|
1910
|
+
let v = (cu ctx).u_param ctx (Str key) in
|
|
1911
|
+
let ka = (match op.op_alias with Map _ -> (match getp op.op_alias key with Str s -> Some s | _ -> None) | _ -> None) in
|
|
1912
|
+
let qor = ref [jo [(key, v)]] in
|
|
1913
|
+
(match ka with Some k -> qor := !qor @ [jo [(k, v)]] | None -> ());
|
|
1914
|
+
(* An alternative, never a replacement: a seed keeping the parameter
|
|
1915
|
+
flat is still found. *)
|
|
1916
|
+
(match (match idfrom with Map _ -> getp idfrom key | _ -> Noval) with
|
|
1917
|
+
| Str kf when kf <> key ->
|
|
1918
|
+
qor := !qor @ [List.fold_right (fun seg acc -> jo [(seg, acc)]) (String.split_on_char '.' kf) v]
|
|
1919
|
+
| _ -> ());
|
|
1920
|
+
qand := !qand @ [jo [("`$OR`", ja !qor)]]
|
|
1921
|
+
end) names;
|
|
1677
1922
|
let q = jo [("`$AND`", ja !qand)] in
|
|
1678
1923
|
(match ctx.c_ctrl.ctrl_explain with Map _ -> setp ctx.c_ctrl.ctrl_explain "test" (jo [("query", q)]) | _ -> ());
|
|
1679
1924
|
q in
|
|
1680
1925
|
let make_mock entity =
|
|
1681
|
-
let resolve_match fctx explicit =
|
|
1682
|
-
if (match explicit with Map _ -> size explicit > 0 | _ -> false) then explicit
|
|
1683
|
-
else begin
|
|
1684
|
-
let try_src src = match src with
|
|
1685
|
-
| Map _ -> (match getp src "id" with Noval -> None | Str "__UNDEFINED__" -> None | v -> Some v)
|
|
1686
|
-
| _ -> None in
|
|
1687
|
-
match try_src fctx.c_match with Some v -> jo [("id", v)]
|
|
1688
|
-
| None -> (match try_src fctx.c_data with Some v -> jo [("id", v)] | None -> empty_map ())
|
|
1689
|
-
end in
|
|
1690
1926
|
fun fctx _url _fetchdef ->
|
|
1691
1927
|
let op = fctx.c_op in
|
|
1692
1928
|
let entmap = match getp entity op.op_entity with Map _ as m -> m | _ -> empty_map () in
|
|
1693
1929
|
(match op.op_name with
|
|
1694
1930
|
| "load" ->
|
|
1695
|
-
let args = build_args fctx op
|
|
1931
|
+
let args = build_args fctx op fctx.c_reqmatch in
|
|
1696
1932
|
let ent = getelem (select entmap args) (Num 0.0) in
|
|
1697
1933
|
if is_nullish ent then respond fctx 404 Noval (Some (jo [("statusText", Str "Not found")]))
|
|
1698
1934
|
else (ignore (delprop ent (Str "$KEY")); respond fctx 200 (clone ent) None)
|
|
@@ -1705,32 +1941,22 @@ let test_feature () : feature =
|
|
|
1705
1941
|
respond fctx 200 (clone found) None
|
|
1706
1942
|
end
|
|
1707
1943
|
| "update" | "patch" ->
|
|
1708
|
-
|
|
1709
|
-
(match fctx.c_reqdata with
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
(match getp op.op_alias "id" with
|
|
1713
|
-
| Str alias_id -> (match getp fctx.c_reqdata alias_id with Noval -> () | v -> setp update_match alias_id v)
|
|
1714
|
-
| _ -> ())
|
|
1715
|
-
| _ -> ());
|
|
1716
|
-
let update_match = if size update_match > 0 then update_match else resolve_match fctx (empty_map ()) in
|
|
1717
|
-
let args = build_args fctx op update_match in
|
|
1944
|
+
(* `$body` travels on the wire alone; the record is the rest. *)
|
|
1945
|
+
let rest = (match fctx.c_reqdata with Map _ -> clone fctx.c_reqdata | _ -> empty_map ()) in
|
|
1946
|
+
ignore (delprop rest (Str "$body"));
|
|
1947
|
+
let args = build_args fctx op rest in
|
|
1718
1948
|
let ent = getelem (select entmap args) (Num 0.0) in
|
|
1719
1949
|
(* update miss: 404, never another record *)
|
|
1720
1950
|
if is_nullish ent then respond fctx 404 Noval (Some (jo [("statusText", Str "Not found")]))
|
|
1721
1951
|
else begin
|
|
1722
|
-
(* `$body` travels on the wire alone; the record is the rest. *)
|
|
1723
1952
|
(match ent, fctx.c_reqdata with
|
|
1724
|
-
| Map _, Map _ ->
|
|
1725
|
-
let rest = clone fctx.c_reqdata in
|
|
1726
|
-
ignore (delprop rest (Str "$body"));
|
|
1727
|
-
ignore (merge (ja [ent; rest]))
|
|
1953
|
+
| Map _, Map _ -> ignore (merge (ja [ent; rest]))
|
|
1728
1954
|
| _ -> ());
|
|
1729
1955
|
ignore (delprop ent (Str "$KEY"));
|
|
1730
1956
|
respond fctx 200 (clone ent) None
|
|
1731
1957
|
end
|
|
1732
1958
|
| "remove" ->
|
|
1733
|
-
let args = build_args fctx op
|
|
1959
|
+
let args = build_args fctx op fctx.c_reqmatch in
|
|
1734
1960
|
let ent = getelem (select entmap args) (Num 0.0) in
|
|
1735
1961
|
(match ent with Map _ -> ignore (delprop entmap (getp ent "id")) | _ -> ());
|
|
1736
1962
|
respond fctx 200 Noval None
|
|
@@ -1715,6 +1715,30 @@ let secret_scan (opts : value) (names : string list) : value =
|
|
|
1715
1715
|
| _, v -> setp out k v) (keysof opts);
|
|
1716
1716
|
out
|
|
1717
1717
|
|
|
1718
|
+
(* The model's options for a feature sit beneath the caller's, key by key: a
|
|
1719
|
+
key the caller sets replaces the default whole, so a list is never merged. *)
|
|
1720
|
+
let feature_defaults (opts : value) (cfgfeature : value) : unit =
|
|
1721
|
+
let given = getp opts "feature" in
|
|
1722
|
+
let absent v = match v with Noval | Null -> true | _ -> false in
|
|
1723
|
+
match cfgfeature with
|
|
1724
|
+
| Map _ when absent given || (match given with Map _ -> true | _ -> false) ->
|
|
1725
|
+
let out = empty_map () in
|
|
1726
|
+
(match given with Map _ -> List.iter (fun k -> setp out k (getp given k)) (keysof given) | _ -> ());
|
|
1727
|
+
List.iter (fun name ->
|
|
1728
|
+
let dflt = getp (getp cfgfeature name) "options" in
|
|
1729
|
+
let fopts = getp out name in
|
|
1730
|
+
let wanted = match dflt, fopts with
|
|
1731
|
+
| Map _, Map _ -> true
|
|
1732
|
+
| Map _, v when absent v -> (match getp dflt "active" with Bool b -> b | _ -> false)
|
|
1733
|
+
| _ -> false in
|
|
1734
|
+
if wanted then begin
|
|
1735
|
+
let merged = clone dflt in
|
|
1736
|
+
(match fopts with Map _ -> List.iter (fun k -> setp merged k (getp fopts k)) (keysof fopts) | _ -> ());
|
|
1737
|
+
setp out name merged
|
|
1738
|
+
end) (keysof cfgfeature);
|
|
1739
|
+
setp opts "feature" out
|
|
1740
|
+
| _ -> ()
|
|
1741
|
+
|
|
1718
1742
|
let make_options_util (ctx : ctx) : value =
|
|
1719
1743
|
let options = match ctx.c_options with Noval -> empty_map () | v -> v in
|
|
1720
1744
|
(match getp options "utility" with
|
|
@@ -1758,6 +1782,7 @@ let make_options_util (ctx : ctx) : value =
|
|
|
1758
1782
|
| _ -> None in
|
|
1759
1783
|
let config = match ctx.c_config with Map _ as m -> m | _ -> empty_map () in
|
|
1760
1784
|
let cfgopts = match to_map (getp config "options") with Map _ as m -> m | _ -> empty_map () in
|
|
1785
|
+
feature_defaults opts (getp config "feature");
|
|
1761
1786
|
(* THE OPTION SPEC IS GENERATED, NOT WRITTEN HERE.
|
|
1762
1787
|
|
|
1763
1788
|
Built from the model: main.kit.optspec for the standard options, plus one
|
|
@@ -1847,18 +1872,16 @@ let make_options_util (ctx : ctx) : value =
|
|
|
1847
1872
|
match getp opts "system" with
|
|
1848
1873
|
| Map _ as sys -> setp sys "fetch" sys_fetch
|
|
1849
1874
|
| _ -> setp opts "system" (jo [("fetch", sys_fetch)]));
|
|
1850
|
-
(* Resolve the feature add-order: an explicit list order (above) wins
|
|
1851
|
-
|
|
1852
|
-
|
|
1875
|
+
(* Resolve the feature add-order: an explicit list order (above) wins, and
|
|
1876
|
+
the names it leaves out follow it test-first, then sorted, so the outcome
|
|
1877
|
+
is deterministic and `test` is the base transport of a map. *)
|
|
1853
1878
|
let feature_order =
|
|
1854
|
-
match explicit_order with
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
then "test" :: List.filter (fun n -> n <> "test") names
|
|
1861
|
-
else names in
|
|
1879
|
+
let given = match explicit_order with Some ord -> ord | None -> [] in
|
|
1880
|
+
let fmap = match getp opts "feature" with Map _ as m -> m | _ -> empty_map () in
|
|
1881
|
+
let names = List.filter (fun n -> not (List.mem n given)) (keysof fmap) in
|
|
1882
|
+
given @ (if List.mem "test" names
|
|
1883
|
+
then "test" :: List.filter (fun n -> n <> "test") names
|
|
1884
|
+
else names) in
|
|
1862
1885
|
let derived = jo [("featureorder", ja (List.map (fun s -> Str s) feature_order))] in
|
|
1863
1886
|
setp opts "__derived__" derived;
|
|
1864
1887
|
(* Beside the options, not in them: options_map hands them to callers. *)
|
|
@@ -372,7 +372,8 @@ let () =
|
|
|
372
372
|
let h = make_client [("telemetry", empty_map ())] in
|
|
373
373
|
ignore (op h ~op:"load" ());
|
|
374
374
|
let tid = vs_str (getp (getelem (getp (track h "telemetry") "spans") (Num 0.)) "traceId") in
|
|
375
|
-
|
|
375
|
+
let hex = String.for_all (fun c -> (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')) in
|
|
376
|
+
check "w3c trace id" (String.length tid = 32 && hex tid && String.exists (fun c -> c <> '0') tid));
|
|
376
377
|
test "telemetry.inactive" (fun () ->
|
|
377
378
|
let h = make_client [("telemetry", jo [("active", Bool false)])] in
|
|
378
379
|
ignore (op h ~op:"load" ());
|
|
@@ -514,6 +515,62 @@ let () =
|
|
|
514
515
|
let pg = match r.or_result with Some x -> x.rt_paging | None -> Noval in
|
|
515
516
|
check_vstr "cursor" (getp pg "cursor") "abc";
|
|
516
517
|
check "hasMore" (getp pg "hasMore" = Bool true));
|
|
518
|
+
(* The documented hasMore loop, one request per page. *)
|
|
519
|
+
let walk ?(options = empty_map ()) reply =
|
|
520
|
+
let (srv, calls) = recording_server ~reply:(fun n _ -> (reply n, None)) () in
|
|
521
|
+
let h = make_client ~server:srv [("paging", options)] in
|
|
522
|
+
let paging = empty_map () in
|
|
523
|
+
let ctrl = jo [("paging", paging)] in
|
|
524
|
+
ignore (op h ~op:"list" ~path:"/w" ~ctrl ());
|
|
525
|
+
while getp paging "hasMore" = Bool true && List.length !calls < 4 do
|
|
526
|
+
ignore (op h ~op:"list" ~path:"/w" ~ctrl ())
|
|
527
|
+
done;
|
|
528
|
+
(List.map (fun c -> vs_str (getp c "url")) !calls, paging) in
|
|
529
|
+
let nth_or l n d = if n >= 1 && n <= List.length l then List.nth l (n - 1) else d in
|
|
530
|
+
test "paging.body_next_is_the_cursor" (fun () ->
|
|
531
|
+
let (urls, pg) = walk (fun n -> make_response 200 (jo [("next", nth_or [Str "c3"; Str "c6"] n Null)])) in
|
|
532
|
+
check "requests" (urls = ["http://api.test/w?page=1"; "http://api.test/w?cursor=c3";
|
|
533
|
+
"http://api.test/w?cursor=c6"]);
|
|
534
|
+
check "hasMore" (getp pg "hasMore" = Bool false));
|
|
535
|
+
test "paging.body_next_url_is_the_next_request" (fun () ->
|
|
536
|
+
let (urls, pg) = walk (fun n -> make_response 200 (jo [("next", nth_or
|
|
537
|
+
[Str "http://api.test/v2/w?cursor=c%2F3&limit=3"; Str "/v2/w?cursor=c6"] n Null)])) in
|
|
538
|
+
check "requests" (urls = ["http://api.test/w?page=1"; "http://api.test/v2/w?cursor=c%2F3&limit=3";
|
|
539
|
+
"http://api.test/v2/w?cursor=c6"]);
|
|
540
|
+
check "hasMore" (getp pg "hasMore" = Bool false));
|
|
541
|
+
test "paging.link_next_url_is_the_next_request" (fun () ->
|
|
542
|
+
let links = ["<http://api.test/w?after=b3>; rel=\"next\""; "</w?after=b6>; rel=\"next\""] in
|
|
543
|
+
let (urls, pg) = walk (fun n ->
|
|
544
|
+
let headers = if n <= List.length links then [("link", Str (List.nth links (n - 1)))] else [] in
|
|
545
|
+
make_response ~headers 200 (ja [])) in
|
|
546
|
+
check "requests" (urls = ["http://api.test/w?page=1"; "http://api.test/w?after=b3";
|
|
547
|
+
"http://api.test/w?after=b6"]);
|
|
548
|
+
check "hasMore" (getp pg "hasMore" = Bool false));
|
|
549
|
+
test "paging.query_only_link_keeps_the_path" (fun () ->
|
|
550
|
+
let links = ["</v1/items?page=2>; rel=\"next\""; "<?page=3>; rel=\"next\""] in
|
|
551
|
+
let (urls, _) = walk (fun n ->
|
|
552
|
+
let headers = if n <= List.length links then [("link", Str (List.nth links (n - 1)))] else [] in
|
|
553
|
+
make_response ~headers 200 (ja [])) in
|
|
554
|
+
check "requests" (urls = ["http://api.test/w?page=1"; "http://api.test/v1/items?page=2";
|
|
555
|
+
"http://api.test/v1/items?page=3"]));
|
|
556
|
+
test "paging.path_relative_link_resolves_against_the_request" (fun () ->
|
|
557
|
+
let links = ["</v1/items?page=2>; rel=\"next\""; "<more?page=3>; rel=\"next\""] in
|
|
558
|
+
let (urls, _) = walk (fun n ->
|
|
559
|
+
let headers = if n <= List.length links then [("link", Str (List.nth links (n - 1)))] else [] in
|
|
560
|
+
make_response ~headers 200 (ja [])) in
|
|
561
|
+
check "requests" (urls = ["http://api.test/w?page=1"; "http://api.test/v1/items?page=2";
|
|
562
|
+
"http://api.test/v1/more?page=3"]));
|
|
563
|
+
test "paging.foreign_link_ends_the_walk" (fun () ->
|
|
564
|
+
let (urls, pg) = walk (fun _ ->
|
|
565
|
+
make_response ~headers:[("link", Str "<https://elsewhere.test/w?after=b3>; rel=\"next\"")] 200 (ja [])) in
|
|
566
|
+
check "requests" (urls = ["http://api.test/w?page=1"]);
|
|
567
|
+
check "hasMore" (getp pg "hasMore" = Bool false);
|
|
568
|
+
check_vstr "foreign" (getp pg "foreign") "https://elsewhere.test/w?after=b3");
|
|
569
|
+
test "paging.cursor_mode_sends_a_slash_cursor" (fun () ->
|
|
570
|
+
let (urls, pg) = walk ~options:(jo [("next", Str "cursor")])
|
|
571
|
+
(fun n -> make_response 200 (jo [("next", nth_or [Str "/c3"] n Null)])) in
|
|
572
|
+
check "requests" (urls = ["http://api.test/w?page=1"; "http://api.test/w?cursor=%2Fc3"]);
|
|
573
|
+
check "hasMore" (getp pg "hasMore" = Bool false));
|
|
517
574
|
test "paging.non_list_not_paged" (fun () ->
|
|
518
575
|
let (srv, calls) = recording_server () in
|
|
519
576
|
let h = make_client ~server:srv [("paging", empty_map ())] in
|
|
@@ -547,6 +604,20 @@ let () =
|
|
|
547
604
|
check "3 batches" (List.length batches = 3);
|
|
548
605
|
check "b0" (veq (List.nth batches 0) (ja [Num 1.; Num 2.]));
|
|
549
606
|
check "b2" (veq (List.nth batches 2) (ja [Num 5.])));
|
|
607
|
+
test "streaming.failed_result_not_streamed" (fun () ->
|
|
608
|
+
let (srv, _) = recording_server ~reply:(fun _ _ -> (make_response 503 (ja []), None)) () in
|
|
609
|
+
let h = make_client ~server:srv [("streaming", empty_map ())] in
|
|
610
|
+
let r = op h ~op:"list" ~path:"/w" () in
|
|
611
|
+
check "no stream" (match r.or_result with
|
|
612
|
+
| Some x -> not x.rt_streaming && x.rt_stream = None
|
|
613
|
+
| None -> true));
|
|
614
|
+
test "streaming.empty_list_streams_nothing" (fun () ->
|
|
615
|
+
let (srv, _) = recording_server ~reply:(fun _ _ -> (make_response 200 (ja []), None)) () in
|
|
616
|
+
let h = make_client ~server:srv [("streaming", empty_map ())] in
|
|
617
|
+
let r = op h ~op:"list" ~path:"/w" () in
|
|
618
|
+
check "empty" (match r.or_result with
|
|
619
|
+
| Some { rt_stream = Some f; _ } -> f () = []
|
|
620
|
+
| _ -> false));
|
|
550
621
|
test "streaming.non_list_not_streamed" (fun () ->
|
|
551
622
|
let h = make_client [("streaming", empty_map ())] in
|
|
552
623
|
let r = op h ~op:"load" () in
|