@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
|
@@ -104,6 +104,162 @@ impl PagingFeature {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
// The length of a URL's scheme and authority, when it has them.
|
|
108
|
+
fn origin_len(text: &str) -> Option<usize> {
|
|
109
|
+
let bytes = text.as_bytes();
|
|
110
|
+
if bytes.is_empty() || !bytes[0].is_ascii_alphabetic() {
|
|
111
|
+
return None;
|
|
112
|
+
}
|
|
113
|
+
let scheme = bytes
|
|
114
|
+
.iter()
|
|
115
|
+
.position(|b| !(b.is_ascii_alphanumeric() || b"+.-".contains(b)))?;
|
|
116
|
+
if !text[scheme..].starts_with("://") {
|
|
117
|
+
return None;
|
|
118
|
+
}
|
|
119
|
+
let host = scheme + 3;
|
|
120
|
+
Some(text[host..].find(|c| c == '/' || c == '?' || c == '#').map_or(text.len(), |i| host + i))
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Under the `next` option's default, a URL or an absolute path is a link and
|
|
124
|
+
// anything else a cursor; `cursor` and `url` pin the reading.
|
|
125
|
+
fn is_link(next: &Value, mode: &str) -> bool {
|
|
126
|
+
match next.as_str() {
|
|
127
|
+
Some(s) => mode == "url" || (mode != "cursor" && (origin_len(s).is_some() || s.starts_with('/'))),
|
|
128
|
+
None => false,
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
fn origin_of(text: &str) -> String {
|
|
133
|
+
text[..origin_len(text).unwrap_or(0)].to_lowercase()
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
fn foreign(link: &str, base: &str) -> bool {
|
|
137
|
+
let origin = origin_of(link);
|
|
138
|
+
!origin.is_empty() && origin != origin_of(base)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
fn unescape(text: &str) -> String {
|
|
142
|
+
let bytes = text.as_bytes();
|
|
143
|
+
let mut out: Vec<u8> = Vec::with_capacity(bytes.len());
|
|
144
|
+
let mut i = 0;
|
|
145
|
+
while i < bytes.len() {
|
|
146
|
+
match bytes[i] {
|
|
147
|
+
b'+' => out.push(b' '),
|
|
148
|
+
b'%' if i + 2 < bytes.len() => {
|
|
149
|
+
let hex = std::str::from_utf8(&bytes[i + 1..i + 3]).ok()
|
|
150
|
+
.and_then(|h| u8::from_str_radix(h, 16).ok());
|
|
151
|
+
match hex {
|
|
152
|
+
Some(b) => {
|
|
153
|
+
out.push(b);
|
|
154
|
+
i += 2;
|
|
155
|
+
}
|
|
156
|
+
None => out.push(b'%'),
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
b => out.push(b),
|
|
160
|
+
}
|
|
161
|
+
i += 1;
|
|
162
|
+
}
|
|
163
|
+
String::from_utf8(out).unwrap_or_else(|_| text.to_string())
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
fn has_scheme(text: &str) -> bool {
|
|
167
|
+
let b = text.as_bytes();
|
|
168
|
+
!b.is_empty()
|
|
169
|
+
&& b[0].is_ascii_alphabetic()
|
|
170
|
+
&& b.iter().position(|c| !(c.is_ascii_alphanumeric() || b"+.-".contains(c))).map_or(false, |i| b[i] == b':')
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// RFC 3986 reference resolution against the URL of the request that returned
|
|
174
|
+
// the link, by hand: the standard library has no resolver. A link on that URL's
|
|
175
|
+
// origin comes back as its path and query; an absolute link is left as it is.
|
|
176
|
+
fn resolve(link: &str, url: &str) -> String {
|
|
177
|
+
if url.is_empty() || has_scheme(link) {
|
|
178
|
+
return link.to_string();
|
|
179
|
+
}
|
|
180
|
+
let link = link.split('#').next().unwrap_or("");
|
|
181
|
+
let origin = &url[..origin_len(url).unwrap_or(0)];
|
|
182
|
+
if link.starts_with("//") {
|
|
183
|
+
return match origin.split_once(':') {
|
|
184
|
+
Some((scheme, _)) => format!("{}:{}", scheme, link),
|
|
185
|
+
None => link.to_string(),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
let from = url[origin.len()..].split('#').next().unwrap_or("");
|
|
189
|
+
let (bpath, bquery) = match from.split_once('?') {
|
|
190
|
+
Some((p, q)) => (p, Some(q)),
|
|
191
|
+
None => (from, None),
|
|
192
|
+
};
|
|
193
|
+
let (rpath, rquery) = match link.split_once('?') {
|
|
194
|
+
Some((p, q)) => (p, Some(q)),
|
|
195
|
+
None => (link, None),
|
|
196
|
+
};
|
|
197
|
+
let (path, query) = if rpath.is_empty() {
|
|
198
|
+
(bpath.to_string(), rquery.or(bquery))
|
|
199
|
+
} else if rpath.starts_with('/') {
|
|
200
|
+
(remove_dots(rpath), rquery)
|
|
201
|
+
} else {
|
|
202
|
+
let dir = &bpath[..bpath.rfind('/').map_or(0, |k| k + 1)];
|
|
203
|
+
(remove_dots(&format!("{}{}", dir, rpath)), rquery)
|
|
204
|
+
};
|
|
205
|
+
let rooted = if path.starts_with('/') { path } else { format!("/{}", path) };
|
|
206
|
+
match query {
|
|
207
|
+
Some(q) => format!("{}?{}", rooted, q),
|
|
208
|
+
None => rooted,
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// RFC 3986 section 5.2.4.
|
|
213
|
+
fn remove_dots(path: &str) -> String {
|
|
214
|
+
let abs = path.starts_with('/');
|
|
215
|
+
let segs: Vec<&str> = path.split('/').collect();
|
|
216
|
+
let mut out: Vec<&str> = Vec::new();
|
|
217
|
+
let last = segs.len() - 1;
|
|
218
|
+
for (i, seg) in segs.iter().enumerate().skip(if abs { 1 } else { 0 }) {
|
|
219
|
+
if *seg == "." || *seg == ".." {
|
|
220
|
+
if *seg == ".." {
|
|
221
|
+
out.pop();
|
|
222
|
+
}
|
|
223
|
+
if i == last {
|
|
224
|
+
out.push("");
|
|
225
|
+
}
|
|
226
|
+
} else {
|
|
227
|
+
out.push(seg);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
format!("{}{}", if abs { "/" } else { "" }, out.join("/"))
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// The request goes to the link's path and query, on the SDK's own origin.
|
|
234
|
+
fn follow(spec: &Rc<RefCell<Spec>>, next: &str) {
|
|
235
|
+
let rest = &next[origin_len(next).unwrap_or(0)..];
|
|
236
|
+
let rest = rest.split('#').next().unwrap_or("");
|
|
237
|
+
let (path, rawquery) = match rest.find('?') {
|
|
238
|
+
Some(i) => (&rest[..i], &rest[i + 1..]),
|
|
239
|
+
None => (rest, ""),
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
let query = Value::empty_map();
|
|
243
|
+
for pair in rawquery.split('&').filter(|p| !p.is_empty()) {
|
|
244
|
+
let (key, val) = match pair.find('=') {
|
|
245
|
+
Some(i) => (&pair[..i], &pair[i + 1..]),
|
|
246
|
+
None => (pair, ""),
|
|
247
|
+
};
|
|
248
|
+
setp(&query, &unescape(key), Value::str(unescape(val)));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
let mut sp = spec.borrow_mut();
|
|
252
|
+
for key in sp.authquery.clone() {
|
|
253
|
+
setp(&query, &key, getp(&sp.query, &key));
|
|
254
|
+
}
|
|
255
|
+
let base = sp.base.clone();
|
|
256
|
+
sp.base = base[..origin_len(&base).unwrap_or(0)].to_string();
|
|
257
|
+
sp.prefix = String::new();
|
|
258
|
+
sp.path = path.to_string();
|
|
259
|
+
sp.suffix = String::new();
|
|
260
|
+
sp.query = query;
|
|
261
|
+
}
|
|
262
|
+
|
|
107
263
|
// Extract the URL of the `rel="next"` entry from a Link header value.
|
|
108
264
|
fn link_next(link: &str) -> Option<String> {
|
|
109
265
|
for seg in link.split(',') {
|
|
@@ -162,7 +318,7 @@ impl Feature for PagingFeature {
|
|
|
162
318
|
Some(s) => s,
|
|
163
319
|
None => return,
|
|
164
320
|
};
|
|
165
|
-
let query = {
|
|
321
|
+
let mut query = {
|
|
166
322
|
let q = spec.borrow().query.clone();
|
|
167
323
|
if matches!(q, Value::Map(_)) {
|
|
168
324
|
q
|
|
@@ -191,8 +347,12 @@ impl Feature for PagingFeature {
|
|
|
191
347
|
}
|
|
192
348
|
|
|
193
349
|
let cursor = getp(&paging, "cursor");
|
|
350
|
+
let next = getp(&paging, "next");
|
|
194
351
|
if !cursor.is_noval() && !cursor.is_null() {
|
|
195
352
|
setp(&query, &cursor_param, cursor);
|
|
353
|
+
} else if next.as_str().map_or(false, |l| !foreign(l, &spec.borrow().base)) {
|
|
354
|
+
follow(&spec, next.as_str().unwrap_or(""));
|
|
355
|
+
query = spec.borrow().query.clone();
|
|
196
356
|
} else if getp(&query, &page_param).is_noval() {
|
|
197
357
|
// A record written back by pre_result holds the page just fetched
|
|
198
358
|
// as "page" and the one to fetch as "nextPage", so nextPage wins.
|
|
@@ -290,8 +450,12 @@ impl Feature for PagingFeature {
|
|
|
290
450
|
// Body-level signals; snake_case forms are read first so camelCase wins.
|
|
291
451
|
if let Value::Map(_) = body {
|
|
292
452
|
let next = getp(&body, "next");
|
|
293
|
-
if !next.is_noval() && !next.is_null()
|
|
294
|
-
|
|
453
|
+
if !next.is_noval() && !next.is_null() {
|
|
454
|
+
if !is_link(&next, &fopt_str(&self.options, "next", "auto")) {
|
|
455
|
+
setp(&paging, "cursor", next);
|
|
456
|
+
} else if getp(&paging, "next").is_noval() {
|
|
457
|
+
setp(&paging, "next", next);
|
|
458
|
+
}
|
|
295
459
|
}
|
|
296
460
|
let snake_cursor = getp(&body, "next_cursor");
|
|
297
461
|
if !snake_cursor.is_noval() && !snake_cursor.is_null() {
|
|
@@ -324,6 +488,21 @@ impl Feature for PagingFeature {
|
|
|
324
488
|
}
|
|
325
489
|
}
|
|
326
490
|
|
|
491
|
+
// A link to another origin is recorded, never followed, and ends the walk.
|
|
492
|
+
let base = match ctx.spec.borrow().as_ref() {
|
|
493
|
+
Some(sp) => sp.borrow().base.clone(),
|
|
494
|
+
None => getp(&ctx.options.borrow(), "base").as_str().unwrap_or("").to_string(),
|
|
495
|
+
};
|
|
496
|
+
let url = ctx.spec.borrow().as_ref().map(|sp| sp.borrow().url.clone());
|
|
497
|
+
if let (Some(l), Some(u)) = (getp(&paging, "next").as_str(), url) {
|
|
498
|
+
setp(&paging, "next", Value::str(resolve(l, &u)));
|
|
499
|
+
}
|
|
500
|
+
let link = getp(&paging, "next");
|
|
501
|
+
if link.as_str().map_or(false, |l| foreign(l, &base)) {
|
|
502
|
+
setp(&paging, "foreign", link);
|
|
503
|
+
setp(&paging, "next", Value::Noval);
|
|
504
|
+
}
|
|
505
|
+
|
|
327
506
|
// Cursor presence only INFERS another page. When the server stated
|
|
328
507
|
// the answer outright — relay's `hasNextPage: false`, or a body
|
|
329
508
|
// `hasMore` — that wins: a final page normally carries both an end
|
|
@@ -338,6 +517,13 @@ impl Feature for PagingFeature {
|
|
|
338
517
|
setp(&paging, "hasMore", Value::Bool(true));
|
|
339
518
|
}
|
|
340
519
|
|
|
520
|
+
if !getp(&paging, "foreign").is_noval()
|
|
521
|
+
&& getp(&paging, "cursor").is_noval()
|
|
522
|
+
&& getp(&paging, "nextPage").is_noval()
|
|
523
|
+
{
|
|
524
|
+
setp(&paging, "hasMore", Value::Bool(false));
|
|
525
|
+
}
|
|
526
|
+
|
|
341
527
|
result.borrow_mut().paging = paging.clone();
|
|
342
528
|
self.last = paging.clone();
|
|
343
529
|
|
|
@@ -81,30 +81,25 @@ fn acquire(track: &Rc<RefCell<RatelimitTrack>>, options: &Value) {
|
|
|
81
81
|
let burst = fopt_num(options, "burst", rate);
|
|
82
82
|
let now_fn = fopt_now(options);
|
|
83
83
|
|
|
84
|
-
// Refill
|
|
84
|
+
// Refill, then reserve this call's token before any wait: a negative
|
|
85
|
+
// count is the calls already queued, so overlapping calls pace in turn.
|
|
85
86
|
let now = now_fn();
|
|
86
87
|
let wait_ms;
|
|
87
88
|
{
|
|
88
89
|
let mut t = track.borrow_mut();
|
|
89
90
|
let elapsed = now - t.last;
|
|
90
91
|
t.last = now;
|
|
91
|
-
t.tokens = burst.min(t.tokens + (elapsed as f64 / 1000.0) * rate);
|
|
92
|
+
t.tokens = burst.min(t.tokens + (elapsed as f64 / 1000.0) * rate) - 1.0;
|
|
92
93
|
|
|
93
|
-
if t.tokens >=
|
|
94
|
-
t.tokens -= 1.0;
|
|
94
|
+
if t.tokens >= 0.0 {
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
let needed = 1.0 - t.tokens;
|
|
100
|
-
wait_ms = ((needed / rate) * 1000.0).ceil() as i64;
|
|
98
|
+
wait_ms = ((-t.tokens / rate) * 1000.0).ceil() as i64;
|
|
101
99
|
t.throttled += 1;
|
|
102
100
|
t.wait_ms += wait_ms;
|
|
103
101
|
}
|
|
104
102
|
if wait_ms > 0 {
|
|
105
103
|
fopt_sleep(options)(wait_ms);
|
|
106
104
|
}
|
|
107
|
-
let mut t = track.borrow_mut();
|
|
108
|
-
t.last = now_fn();
|
|
109
|
-
t.tokens = 0.0;
|
|
110
105
|
}
|
|
@@ -4,7 +4,7 @@ use std::rc::Rc;
|
|
|
4
4
|
|
|
5
5
|
use crate::core::context::Context;
|
|
6
6
|
use crate::core::error::ProjectNameError;
|
|
7
|
-
use crate::core::helpers::rand_int;
|
|
7
|
+
use crate::core::helpers::{now_ms, rand_int};
|
|
8
8
|
use crate::core::types::{Feature, FetcherFn};
|
|
9
9
|
use crate::feature::support::*;
|
|
10
10
|
use crate::utility::voxgigstruct::Value;
|
|
@@ -133,7 +133,7 @@ fn backoff(
|
|
|
133
133
|
max_delay: i64,
|
|
134
134
|
factor: f64,
|
|
135
135
|
) -> i64 {
|
|
136
|
-
//
|
|
136
|
+
// A server-provided Retry-After wins over the computed backoff.
|
|
137
137
|
if let Ok(res) = out {
|
|
138
138
|
if let Some(ra) = retry_after(res) {
|
|
139
139
|
return ra.min(max_delay);
|
|
@@ -150,12 +150,65 @@ fn backoff(
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
fn retry_after(res: &Value) -> Option<i64> {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
retry_after_ms(&fres_header(res, "retry-after")?, now_ms())
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/// RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else None.
|
|
157
|
+
pub fn retry_after_ms(value: &str, now: i64) -> Option<i64> {
|
|
158
|
+
let s = value.trim_matches(|c| c == ' ' || c == '\t').as_bytes();
|
|
159
|
+
if !s.is_empty() && s.iter().all(u8::is_ascii_digit) {
|
|
160
|
+
let seconds = s.iter().fold(0i64, |n, c| {
|
|
161
|
+
(n * 10 + (c - b'0') as i64).min(i64::MAX / 10_000)
|
|
162
|
+
});
|
|
163
|
+
return Some(seconds * 1000);
|
|
164
|
+
}
|
|
165
|
+
let text = |from: usize, to: usize| std::str::from_utf8(&s[from..to]).unwrap_or("");
|
|
166
|
+
let num = |from: usize, to: usize| -> i64 {
|
|
167
|
+
if s[from..to].iter().all(u8::is_ascii_digit) {
|
|
168
|
+
text(from, to).parse().unwrap_or(-1)
|
|
169
|
+
} else {
|
|
170
|
+
-1
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
if s.len() != 29
|
|
174
|
+
|| text(3, 5) != ", "
|
|
175
|
+
|| s[7] != b' '
|
|
176
|
+
|| s[11] != b' '
|
|
177
|
+
|| s[16] != b' '
|
|
178
|
+
|| s[19] != b':'
|
|
179
|
+
|| s[22] != b':'
|
|
180
|
+
|| text(25, 29) != " GMT"
|
|
181
|
+
|| !["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"].contains(&text(0, 3))
|
|
182
|
+
{
|
|
183
|
+
return None;
|
|
184
|
+
}
|
|
185
|
+
let months = [
|
|
186
|
+
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
|
187
|
+
];
|
|
188
|
+
let m = months.iter().position(|&m| m == text(8, 11))? as i64 + 1;
|
|
189
|
+
let (day, year, hour, min, sec) = (
|
|
190
|
+
num(5, 7),
|
|
191
|
+
num(12, 16),
|
|
192
|
+
num(17, 19),
|
|
193
|
+
num(20, 22),
|
|
194
|
+
num(23, 25),
|
|
195
|
+
);
|
|
196
|
+
if !(1..=31).contains(&day)
|
|
197
|
+
|| year < 0
|
|
198
|
+
|| !(0..=23).contains(&hour)
|
|
199
|
+
|| !(0..=59).contains(&min)
|
|
200
|
+
|| !(0..=60).contains(&sec)
|
|
201
|
+
{
|
|
156
202
|
return None;
|
|
157
203
|
}
|
|
158
|
-
|
|
204
|
+
let y = if m <= 2 { year - 1 } else { year };
|
|
205
|
+
let era = y.div_euclid(400);
|
|
206
|
+
let yoe = y - era * 400;
|
|
207
|
+
let doy = (153 * ((m + 9) % 12) + 2) / 5 + day - 1;
|
|
208
|
+
let doe = yoe * 365 + yoe / 4 - yoe / 100 + doy;
|
|
209
|
+
let days = era * 146097 + doe - 719468;
|
|
210
|
+
let at = (((days * 24 + hour) * 60 + min) * 60 + sec) * 1000;
|
|
211
|
+
Some((at - now).max(0))
|
|
159
212
|
}
|
|
160
213
|
|
|
161
214
|
fn track_attempt(
|
|
@@ -55,9 +55,10 @@ impl Feature for StreamingFeature {
|
|
|
55
55
|
if !self.active || !self.streamable(ctx) {
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
+
// A failed result keeps no stream, so the entity's stream raises its error.
|
|
58
59
|
let result = match ctx.result.borrow().clone() {
|
|
59
|
-
Some(r) => r,
|
|
60
|
-
|
|
60
|
+
Some(r) if r.borrow().err.is_none() => r,
|
|
61
|
+
_ => return,
|
|
61
62
|
};
|
|
62
63
|
|
|
63
64
|
let options = self.options.clone();
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
use crate::core::helpers::{call_vfn, getp, now_ms, sleep_ms, to_int};
|
|
3
3
|
use crate::utility::voxgigstruct::Value;
|
|
4
4
|
|
|
5
|
+
pub fn call_sink(sink: &Value, record: &Value) {
|
|
6
|
+
let _ = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| call_vfn(sink, record)));
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
pub fn fopt_bool(options: &Value, key: &str, def: bool) -> bool {
|
|
6
10
|
match getp(options, key) {
|
|
7
11
|
Value::Bool(b) => b,
|
|
@@ -14,7 +14,6 @@ pub struct TelemetryFeature {
|
|
|
14
14
|
pub active: bool,
|
|
15
15
|
pub add_opts: Option<Value>,
|
|
16
16
|
options: Value,
|
|
17
|
-
seq: i64,
|
|
18
17
|
|
|
19
18
|
// Activity tracking (mirrors the ts client._telemetry record).
|
|
20
19
|
pub spans: Vec<Value>,
|
|
@@ -28,7 +27,6 @@ impl TelemetryFeature {
|
|
|
28
27
|
active: true,
|
|
29
28
|
add_opts: None,
|
|
30
29
|
options: Value::Noval,
|
|
31
|
-
seq: 0,
|
|
32
30
|
spans: Vec::new(),
|
|
33
31
|
active_spans: 0,
|
|
34
32
|
}
|
|
@@ -41,14 +39,7 @@ impl TelemetryFeature {
|
|
|
41
39
|
return s;
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
|
-
|
|
45
|
-
self.seq += 1;
|
|
46
|
-
let mut n = format!("{:04x}", self.seq);
|
|
47
|
-
let prefix = if kind == "trace" { "t" } else { "s" };
|
|
48
|
-
while n.len() < 16 {
|
|
49
|
-
n.push('0');
|
|
50
|
-
}
|
|
51
|
-
format!("{}{}", prefix, n)
|
|
42
|
+
random_hex(if kind == "trace" { 16 } else { 8 })
|
|
52
43
|
}
|
|
53
44
|
|
|
54
45
|
fn close(&mut self, ctx: &Rc<Context>, ok: bool) {
|
|
@@ -92,7 +83,6 @@ impl Feature for TelemetryFeature {
|
|
|
92
83
|
fn init(&mut self, _ctx: &Rc<Context>, options: &Value) {
|
|
93
84
|
self.options = options.clone();
|
|
94
85
|
self.active = fopt_bool(options, "active", false);
|
|
95
|
-
self.seq = 0;
|
|
96
86
|
}
|
|
97
87
|
|
|
98
88
|
fn pre_point(&mut self, ctx: &Rc<Context>) {
|
|
@@ -177,3 +167,24 @@ impl Feature for TelemetryFeature {
|
|
|
177
167
|
self.close(ctx, false);
|
|
178
168
|
}
|
|
179
169
|
}
|
|
170
|
+
|
|
171
|
+
// W3C trace context: lowercase hex from the platform's random source, never all
|
|
172
|
+
// zeros. Without /dev/urandom, the OS-seeded hasher keys stand in.
|
|
173
|
+
fn random_hex(bytes: usize) -> String {
|
|
174
|
+
use std::hash::{BuildHasher, Hasher};
|
|
175
|
+
use std::io::Read;
|
|
176
|
+
loop {
|
|
177
|
+
let mut buf = vec![0u8; bytes];
|
|
178
|
+
let read = std::fs::File::open("/dev/urandom").and_then(|mut f| f.read_exact(&mut buf));
|
|
179
|
+
if read.is_err() {
|
|
180
|
+
for chunk in buf.chunks_mut(8) {
|
|
181
|
+
let mut h = std::collections::hash_map::RandomState::new().build_hasher();
|
|
182
|
+
h.write_usize(chunk.as_ptr() as usize);
|
|
183
|
+
chunk.copy_from_slice(&h.finish().to_le_bytes()[..chunk.len()]);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if buf.iter().any(|b| *b != 0) {
|
|
187
|
+
return buf.iter().map(|b| format!("{:02x}", b)).collect();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -86,21 +86,9 @@ fn respond(ctx: &Rc<Context>, status: i64, data: Value, extra: Vec<(&str, Value)
|
|
|
86
86
|
out
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// id from that accumulated state.
|
|
93
|
-
fn resolve_match(ctx: &Rc<Context>, explicit: &Value) -> Value {
|
|
94
|
-
if vs::size(explicit) > 0 {
|
|
95
|
-
return explicit.clone();
|
|
96
|
-
}
|
|
97
|
-
for src in [ctx.mtch.borrow().clone(), ctx.data.borrow().clone()] {
|
|
98
|
-
let v = getp(&src, "id");
|
|
99
|
-
if !v.is_noval() && !v.is_null() && v != Value::str("__UNDEFINED__") {
|
|
100
|
-
return jo(vec![("id", v)]);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
Value::empty_map()
|
|
89
|
+
fn held(src: &Value, key: &str) -> bool {
|
|
90
|
+
let v = getp(src, key);
|
|
91
|
+
!v.is_noval() && !v.is_null() && v != Value::str("__UNDEFINED__")
|
|
104
92
|
}
|
|
105
93
|
|
|
106
94
|
fn point_terminal(p: &Value) -> bool {
|
|
@@ -180,27 +168,65 @@ fn build_args(ctx: &Rc<Context>, args: &Value) -> Value {
|
|
|
180
168
|
let qand = Value::empty_list();
|
|
181
169
|
let q = jo(vec![("`$AND`", qand.clone())]);
|
|
182
170
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
171
|
+
let config = ctx.config.borrow().clone();
|
|
172
|
+
let idfrom = crate::core::helpers::getpath(&["entity", &entname, "id", "from"], &config);
|
|
173
|
+
|
|
174
|
+
let mut names: Vec<String> = match args {
|
|
175
|
+
Value::Map(_) => vs::keysof_vec(args),
|
|
176
|
+
_ => vec![],
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// With no id in the call, the entity's held id (or composite parts) stands in.
|
|
180
|
+
if !held(args, "id") {
|
|
181
|
+
let parts: Vec<String> = match crate::core::helpers::getpath(&["entity", &entname, "id", "parts"], &config) {
|
|
182
|
+
Value::List(l) => l.borrow().iter().map(|p| match p {
|
|
183
|
+
Value::Str(s) => s.to_string(),
|
|
184
|
+
other => vs::stringify(other, None, false),
|
|
185
|
+
}).collect(),
|
|
186
|
+
_ if opname == "list" => vec![],
|
|
187
|
+
_ => vec!["id".to_string()],
|
|
188
|
+
};
|
|
189
|
+
let mtch = ctx.mtch.borrow().clone();
|
|
190
|
+
let data = ctx.data.borrow().clone();
|
|
191
|
+
for pname in parts {
|
|
192
|
+
if !names.contains(&pname) && (held(&mtch, &pname) || held(&data, &pname)) {
|
|
193
|
+
names.push(pname);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
for key in names {
|
|
199
|
+
let is_id = key == "id";
|
|
200
|
+
let is_reqd = !vs::is_empty(&vs::select(&reqd_params, &Value::str(key.clone())))
|
|
201
|
+
|| !vs::is_empty(&vs::select(&reqd_query, &Value::str(key.clone())));
|
|
189
202
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
203
|
+
if is_id || is_reqd {
|
|
204
|
+
let v = ctx.util().param(ctx, &Value::str(key.clone()));
|
|
205
|
+
let ka = getp(&op.alias, &key);
|
|
193
206
|
|
|
194
|
-
|
|
195
|
-
|
|
207
|
+
let qor = Value::list(vec![jo(vec![(key.as_str(), v.clone())])]);
|
|
208
|
+
if let Value::Str(kas) = &ka {
|
|
209
|
+
if let Value::List(l) = &qor {
|
|
210
|
+
l.borrow_mut().push(jo(vec![(kas.as_str(), v.clone())]));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// An alternative, never a replacement: a seed keeping the
|
|
215
|
+
// parameter flat is still found.
|
|
216
|
+
if let Value::Str(kf) = getp(&idfrom, &key) {
|
|
217
|
+
if kf.as_str() != key.as_str() {
|
|
218
|
+
let mut nest = v.clone();
|
|
219
|
+
for seg in kf.split('.').rev() {
|
|
220
|
+
nest = jo(vec![(seg, nest)]);
|
|
221
|
+
}
|
|
196
222
|
if let Value::List(l) = &qor {
|
|
197
|
-
l.borrow_mut().push(
|
|
223
|
+
l.borrow_mut().push(nest);
|
|
198
224
|
}
|
|
199
225
|
}
|
|
226
|
+
}
|
|
200
227
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
228
|
+
if let Value::List(l) = &qand {
|
|
229
|
+
l.borrow_mut().push(jo(vec![("`$OR`", qor)]));
|
|
204
230
|
}
|
|
205
231
|
}
|
|
206
232
|
}
|
|
@@ -239,8 +265,7 @@ fn test_fetch(
|
|
|
239
265
|
|
|
240
266
|
match op.name.as_str() {
|
|
241
267
|
"load" => {
|
|
242
|
-
let
|
|
243
|
-
let args = build_args(ctx, &m);
|
|
268
|
+
let args = build_args(ctx, &ctx.reqmatch.borrow().clone());
|
|
244
269
|
let found = vs::select(&entmap, &args);
|
|
245
270
|
let ent = vs::get_elem(&found, &Value::Num(0.0), Value::Noval);
|
|
246
271
|
if ent.is_noval() || ent.is_null() {
|
|
@@ -272,25 +297,10 @@ fn test_fetch(
|
|
|
272
297
|
|
|
273
298
|
"update" | "patch" => {
|
|
274
299
|
let reqdata = ctx.reqdata.borrow().clone();
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
setp(&update_match, "id", idv);
|
|
280
|
-
}
|
|
281
|
-
if let Value::Str(alias_id) = getp(&op.alias, "id") {
|
|
282
|
-
let av = getp(&reqdata, &alias_id);
|
|
283
|
-
if !av.is_noval() {
|
|
284
|
-
setp(&update_match, &alias_id, av);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
let update_match = if vs::size(&update_match) == 0 {
|
|
289
|
-
resolve_match(ctx, &Value::empty_map())
|
|
290
|
-
} else {
|
|
291
|
-
update_match
|
|
292
|
-
};
|
|
293
|
-
let args = build_args(ctx, &update_match);
|
|
300
|
+
// `$body` travels on the wire alone; the record is the rest.
|
|
301
|
+
let rec = vs::clone(&reqdata);
|
|
302
|
+
vs::del_prop(rec.clone(), &Value::str("$body"));
|
|
303
|
+
let args = build_args(ctx, &rec);
|
|
294
304
|
let found = vs::select(&entmap, &args);
|
|
295
305
|
let ent = vs::get_elem(&found, &Value::Num(0.0), Value::Noval);
|
|
296
306
|
if ent.is_noval() || ent.is_null() {
|
|
@@ -300,10 +310,7 @@ fn test_fetch(
|
|
|
300
310
|
vec![("statusText", Value::str("Not found"))],
|
|
301
311
|
));
|
|
302
312
|
}
|
|
303
|
-
if let (Value::Map(_), Value::Map(_)) = (&ent, &
|
|
304
|
-
// `$body` travels on the wire alone; the record is the rest.
|
|
305
|
-
let rec = vs::clone(&reqdata);
|
|
306
|
-
vs::del_prop(rec.clone(), &Value::str("$body"));
|
|
313
|
+
if let (Value::Map(_), Value::Map(_)) = (&ent, &rec) {
|
|
307
314
|
vs::merge(&Value::list(vec![ent.clone(), rec]), None);
|
|
308
315
|
}
|
|
309
316
|
vs::del_prop(ent.clone(), &Value::str("$KEY"));
|
|
@@ -311,8 +318,7 @@ fn test_fetch(
|
|
|
311
318
|
}
|
|
312
319
|
|
|
313
320
|
"remove" => {
|
|
314
|
-
let
|
|
315
|
-
let args = build_args(ctx, &m);
|
|
321
|
+
let args = build_args(ctx, &ctx.reqmatch.borrow().clone());
|
|
316
322
|
let found = vs::select(&entmap, &args);
|
|
317
323
|
let ent = vs::get_elem(&found, &Value::Num(0.0), Value::Noval);
|
|
318
324
|
// Remove only the first matched entity. If nothing matches,
|