@voxgig/sdkgen 4.50.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 +7 -5
- 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/model/target/lua.aontu +6 -0
- package/project/.sdk/src/cmp/c/Config_c.ts +3 -134
- package/project/.sdk/src/cmp/c/TestClean_c.ts +26 -11
- package/project/.sdk/src/cmp/c/fragment/Entity.fragment.c +17 -10
- package/project/.sdk/src/cmp/clojure/TestClean_clojure.ts +10 -5
- package/project/.sdk/src/cmp/clojure/fragment/Entity.fragment.clj +18 -1
- package/project/.sdk/src/cmp/cpp/TestClean_cpp.ts +15 -1
- package/project/.sdk/src/cmp/csharp/TestClean_csharp.ts +9 -0
- 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 +13 -4
- 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/TestClean_go.ts +39 -3
- 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 +17 -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/TestClean_js.ts +13 -5
- 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 +31 -4
- package/project/.sdk/src/cmp/kotlin/fragment/EntityBase.fragment.kt +19 -0
- package/project/.sdk/src/cmp/lua/TestClean_lua.ts +14 -4
- 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 +20 -5
- package/project/.sdk/src/cmp/ocaml/fragment/RunOp.fragment.ml +36 -21
- package/project/.sdk/src/cmp/perl/TestClean_perl.ts +13 -4
- 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/TestClean_php.ts +10 -3
- 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/TestClean_py.ts +10 -3
- 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 +11 -4
- 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 +24 -17
- package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +22 -2
- package/project/.sdk/src/cmp/scala/TestClean_scala.ts +45 -11
- package/project/.sdk/src/cmp/scala/fragment/EntityBase.fragment.scala +14 -0
- package/project/.sdk/src/cmp/swift/TestClean_swift.ts +31 -21
- 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/TestClean_ts.ts +13 -5
- 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 +23 -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/core/context.c +1 -0
- package/project/.sdk/tm/c/core/sdk.h +7 -4
- package/project/.sdk/tm/c/feature/cache.c +243 -13
- 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/secrets.c +27 -38
- 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 +288 -0
- package/project/.sdk/tm/c/tests/primary_utility_test.c +2 -0
- package/project/.sdk/tm/c/utility/clean.c +26 -33
- package/project/.sdk/tm/c/utility/make_options.c +89 -17
- package/project/.sdk/tm/clojure/feature/secrets/sdk/feature/secrets.clj +14 -11
- package/project/.sdk/tm/clojure/src/sdk/client.clj +3 -1
- package/project/.sdk/tm/clojure/src/sdk/core.clj +50 -22
- package/project/.sdk/tm/clojure/src/sdk/features.clj +279 -80
- package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +103 -1
- package/project/.sdk/tm/clojure/test/sdk/test/pipeline.clj +1 -0
- package/project/.sdk/tm/cpp/Makefile +5 -0
- package/project/.sdk/tm/cpp/core/types.hpp +148 -72
- package/project/.sdk/tm/cpp/feature/audit.hpp +12 -8
- package/project/.sdk/tm/cpp/feature/cache.hpp +188 -9
- 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/secrets.hpp +12 -0
- 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 +236 -0
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +44 -12
- package/project/.sdk/tm/csharp/core/Context.cs +4 -0
- package/project/.sdk/tm/csharp/feature/AuditFeature.cs +8 -1
- package/project/.sdk/tm/csharp/feature/CacheFeature.cs +126 -12
- 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/SecretsFeature.cs +9 -27
- 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 +238 -0
- package/project/.sdk/tm/csharp/utility/Clean.cs +5 -10
- package/project/.sdk/tm/csharp/utility/Fetcher.cs +7 -1
- package/project/.sdk/tm/csharp/utility/MakeOptions.cs +94 -24
- package/project/.sdk/tm/elixir/lib/projectname/context.ex +2 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/cache.ex +146 -30
- 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/secrets.ex +10 -56
- 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 +77 -47
- package/project/.sdk/tm/elixir/test/feature_test.exs +198 -0
- package/project/.sdk/tm/go/core/context.go +6 -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/cache_feature.go +131 -4
- 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/secrets_feature.go +17 -71
- 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 +357 -28
- package/project/.sdk/tm/go/test/feature_test.go +93 -0
- package/project/.sdk/tm/go/utility/clean.go +5 -7
- package/project/.sdk/tm/go/utility/fetcher.go +11 -0
- package/project/.sdk/tm/go/utility/make_options.go +116 -13
- package/project/.sdk/tm/java/core/Context.java +9 -0
- 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/CacheFeature.java +123 -17
- 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/SecretsFeature.java +9 -92
- 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 +309 -17
- package/project/.sdk/tm/java/test/FeatureTest.java +60 -0
- package/project/.sdk/tm/java/utility/Clean.java +6 -10
- package/project/.sdk/tm/java/utility/Fetcher.java +5 -1
- package/project/.sdk/tm/java/utility/MakeOptions.java +131 -15
- package/project/.sdk/tm/js/src/Context.js +4 -0
- package/project/.sdk/tm/js/src/feature/cache/CacheFeature.js +118 -11
- package/project/.sdk/tm/js/src/feature/cost/CostFeature.js +3 -2
- package/project/.sdk/tm/js/src/feature/metrics/MetricsFeature.js +9 -4
- package/project/.sdk/tm/js/src/feature/paging/PagingFeature.js +103 -5
- package/project/.sdk/tm/js/src/feature/ratelimit/RatelimitFeature.js +5 -9
- package/project/.sdk/tm/js/src/feature/rbac/RbacFeature.js +4 -4
- package/project/.sdk/tm/js/src/feature/retry/RetryFeature.js +25 -3
- package/project/.sdk/tm/js/src/feature/secrets/SecretsFeature.js +16 -6
- 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/feature/validate/ValidateFeature.js +2 -1
- package/project/.sdk/tm/js/src/utility/CleanUtility.js +1 -1
- package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +61 -12
- package/project/.sdk/tm/js/test/feature/Corpus.test.js +191 -23
- package/project/.sdk/tm/js/test/feature/harness.js +3 -3
- package/project/.sdk/tm/js/test/feature.test.js +14 -1
- package/project/.sdk/tm/js/test/pipeline.test.js +1 -1
- package/project/.sdk/tm/kotlin/core/Context.kt +3 -0
- 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/CacheFeature.kt +102 -7
- 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/SecretsFeature.kt +10 -20
- 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 +173 -0
- package/project/.sdk/tm/kotlin/utility/CoreUtil.kt +5 -5
- package/project/.sdk/tm/kotlin/utility/Fetcher.kt +4 -0
- package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +86 -15
- package/project/.sdk/tm/lua/core/context.lua +6 -0
- package/project/.sdk/tm/lua/feature/cache_feature.lua +212 -15
- 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/secrets_feature.lua +15 -80
- 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 +181 -3
- package/project/.sdk/tm/lua/utility/clean.lua +6 -9
- package/project/.sdk/tm/lua/utility/fetcher.lua +9 -0
- package/project/.sdk/tm/lua/utility/make_options.lua +60 -18
- package/project/.sdk/tm/ocaml/feature/secrets_feature.ml +21 -6
- package/project/.sdk/tm/ocaml/sdk_features.ml +392 -68
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +47 -21
- package/project/.sdk/tm/ocaml/sdk_types.ml +2 -0
- package/project/.sdk/tm/ocaml/test/t_feature.ml +107 -2
- package/project/.sdk/tm/perl/core/context.pm +3 -0
- package/project/.sdk/tm/perl/feature/audit_feature.pm +4 -7
- package/project/.sdk/tm/perl/feature/cache_feature.pm +111 -15
- 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/secrets_feature.pm +13 -18
- 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 +68 -2
- package/project/.sdk/tm/perl/t/feature_corpus.t +204 -25
- package/project/.sdk/tm/perl/utility/clean.pm +6 -8
- package/project/.sdk/tm/perl/utility/fetcher.pm +4 -0
- package/project/.sdk/tm/perl/utility/make_options.pm +38 -15
- package/project/.sdk/tm/php/core/Context.php +4 -0
- package/project/.sdk/tm/php/feature/CacheFeature.php +98 -13
- 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/SecretsFeature.php +18 -15
- 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 +262 -17
- package/project/.sdk/tm/php/test/FeatureTest.php +68 -0
- package/project/.sdk/tm/php/utility/Clean.php +3 -10
- package/project/.sdk/tm/php/utility/Fetcher.php +8 -3
- package/project/.sdk/tm/php/utility/MakeOptions.php +45 -20
- package/project/.sdk/tm/py/pkg/core/context.py +4 -0
- package/project/.sdk/tm/py/pkg/feature/cache_feature.py +79 -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/secrets_feature.py +15 -66
- 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/clean.py +4 -10
- package/project/.sdk/tm/py/pkg/utility/make_options.py +77 -30
- package/project/.sdk/tm/py/test/feature/secrets/test_secrets.py +23 -9
- package/project/.sdk/tm/py/test/test_feature.py +61 -1
- package/project/.sdk/tm/py/test/test_feature_corpus.py +197 -17
- 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/core/context.rb +4 -1
- package/project/.sdk/tm/rb/feature/audit_feature.rb +6 -5
- package/project/.sdk/tm/rb/feature/cache_feature.rb +75 -11
- 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/secrets_feature.rb +9 -64
- 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 +191 -25
- package/project/.sdk/tm/rb/test/feature_test.rb +75 -1
- package/project/.sdk/tm/rb/utility/clean.rb +6 -7
- package/project/.sdk/tm/rb/utility/fetcher.rb +6 -0
- package/project/.sdk/tm/rb/utility/make_options.rb +37 -16
- package/project/.sdk/tm/rust/core/context.rs +8 -0
- package/project/.sdk/tm/rust/feature/audit.rs +2 -2
- package/project/.sdk/tm/rust/feature/cache.rs +120 -3
- 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/secrets.rs +36 -98
- 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/secrets/main.rs +3 -3
- package/project/.sdk/tm/rust/tests/feature_test.rs +274 -0
- package/project/.sdk/tm/rust/tests/primary_utility_test.rs +1 -0
- package/project/.sdk/tm/rust/utility/clean.rs +35 -43
- package/project/.sdk/tm/rust/utility/fetcher.rs +6 -0
- package/project/.sdk/tm/rust/utility/make_options.rs +130 -38
- package/project/.sdk/tm/scala/core/Context.scala +4 -0
- 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/CacheFeature.scala +117 -11
- 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/SecretsFeature.scala +11 -24
- 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 +69 -0
- package/project/.sdk/tm/scala/utility/Fetcher.scala +5 -0
- package/project/.sdk/tm/scala/utility/Make.scala +99 -14
- package/project/.sdk/tm/scala/utility/Misc.scala +5 -8
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Context.swift +3 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/AuditFeature.swift +3 -2
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/CacheFeature.swift +122 -11
- 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/SecretsFeature.swift +9 -13
- 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/Fetcher.swift +4 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +56 -17
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/ResultUtil.swift +4 -5
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +166 -0
- package/project/.sdk/tm/ts/src/Context.ts +4 -0
- package/project/.sdk/tm/ts/src/feature/cache/CacheFeature.ts +115 -4
- package/project/.sdk/tm/ts/src/feature/cost/CostFeature.ts +3 -2
- package/project/.sdk/tm/ts/src/feature/metrics/MetricsFeature.ts +6 -1
- package/project/.sdk/tm/ts/src/feature/paging/PagingFeature.ts +103 -5
- package/project/.sdk/tm/ts/src/feature/ratelimit/RatelimitFeature.ts +5 -9
- package/project/.sdk/tm/ts/src/feature/rbac/RbacFeature.ts +4 -4
- package/project/.sdk/tm/ts/src/feature/retry/RetryFeature.ts +25 -3
- package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +14 -2
- 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/feature/validate/ValidateFeature.ts +2 -1
- package/project/.sdk/tm/ts/src/utility/CleanUtility.ts +1 -1
- package/project/.sdk/tm/ts/src/utility/MakeOptionsUtility.ts +63 -12
- package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +192 -23
- package/project/.sdk/tm/ts/test/feature/harness.ts +3 -3
- package/project/.sdk/tm/ts/test/feature.test.ts +14 -1
- package/project/.sdk/tm/ts/test/pipeline.test.ts +1 -1
- package/project/.sdk/tm/zig/core/context.zig +5 -0
- package/project/.sdk/tm/zig/core/utility.zig +118 -17
- package/project/.sdk/tm/zig/feature/cache.zig +144 -13
- 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/secrets.zig +6 -1
- 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 +174 -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
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
-- ProjectName SDK cache feature
|
|
2
2
|
--
|
|
3
|
-
-- Response caching for safe (read) requests
|
|
4
|
-
--
|
|
5
|
-
--
|
|
6
|
-
|
|
7
|
-
--
|
|
8
|
-
--
|
|
9
|
-
--
|
|
10
|
-
-- body so both the original caller and later hits can parse repeatedly.
|
|
3
|
+
-- Response caching for safe (read) requests, per client: see the features
|
|
4
|
+
-- reference for the key, the write invalidation and the Cache-Control
|
|
5
|
+
-- rules.
|
|
6
|
+
|
|
7
|
+
-- Lua has no HMAC: SipHash-2-4 under a random per-client key separates
|
|
8
|
+
-- header sets within one store without holding a header value. It is not a
|
|
9
|
+
-- cryptographic commitment.
|
|
11
10
|
|
|
12
11
|
local BaseFeature = require("feature.base_feature")
|
|
13
12
|
local media = require("utility.media")
|
|
@@ -16,6 +15,138 @@ local CacheFeature = {}
|
|
|
16
15
|
CacheFeature.__index = CacheFeature
|
|
17
16
|
setmetatable(CacheFeature, { __index = BaseFeature })
|
|
18
17
|
|
|
18
|
+
local UNSTORED = { ["no-store"] = true, ["private"] = true, ["no-cache"] = true }
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
local function rotl(x, b)
|
|
22
|
+
return (x << b) | (x >> (64 - b))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
local function sipround(v0, v1, v2, v3)
|
|
27
|
+
v0 = v0 + v1; v1 = rotl(v1, 13); v1 = v1 ~ v0; v0 = rotl(v0, 32)
|
|
28
|
+
v2 = v2 + v3; v3 = rotl(v3, 16); v3 = v3 ~ v2
|
|
29
|
+
v0 = v0 + v3; v3 = rotl(v3, 21); v3 = v3 ~ v0
|
|
30
|
+
v2 = v2 + v1; v1 = rotl(v1, 17); v1 = v1 ~ v2; v2 = rotl(v2, 32)
|
|
31
|
+
return v0, v1, v2, v3
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
local function siphash24(key, data)
|
|
36
|
+
local k0, k1 = string.unpack("<i8<i8", key)
|
|
37
|
+
local v0 = 0x736f6d6570736575 ~ k0
|
|
38
|
+
local v1 = 0x646f72616e646f6d ~ k1
|
|
39
|
+
local v2 = 0x6c7967656e657261 ~ k0
|
|
40
|
+
local v3 = 0x7465646279746573 ~ k1
|
|
41
|
+
local len = #data
|
|
42
|
+
local full = len - (len % 8)
|
|
43
|
+
for i = 1, full, 8 do
|
|
44
|
+
local m = string.unpack("<i8", data, i)
|
|
45
|
+
v3 = v3 ~ m
|
|
46
|
+
v0, v1, v2, v3 = sipround(v0, v1, v2, v3)
|
|
47
|
+
v0, v1, v2, v3 = sipround(v0, v1, v2, v3)
|
|
48
|
+
v0 = v0 ~ m
|
|
49
|
+
end
|
|
50
|
+
local b = len << 56
|
|
51
|
+
for i = 0, (len % 8) - 1 do
|
|
52
|
+
b = b | (string.byte(data, full + i + 1) << (8 * i))
|
|
53
|
+
end
|
|
54
|
+
v3 = v3 ~ b
|
|
55
|
+
v0, v1, v2, v3 = sipround(v0, v1, v2, v3)
|
|
56
|
+
v0, v1, v2, v3 = sipround(v0, v1, v2, v3)
|
|
57
|
+
v0 = v0 ~ b
|
|
58
|
+
v2 = v2 ~ 0xff
|
|
59
|
+
for _ = 1, 4 do
|
|
60
|
+
v0, v1, v2, v3 = sipround(v0, v1, v2, v3)
|
|
61
|
+
end
|
|
62
|
+
return v0 ~ v1 ~ v2 ~ v3
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
-- The system's random source where it has one; otherwise math.random, which
|
|
67
|
+
-- is not a cryptographic generator.
|
|
68
|
+
CacheFeature._siphash24 = siphash24
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
local function cache_secret()
|
|
72
|
+
local f = io.open("/dev/urandom", "rb")
|
|
73
|
+
local bytes = f and f:read(16) or ""
|
|
74
|
+
if f then
|
|
75
|
+
f:close()
|
|
76
|
+
end
|
|
77
|
+
while #bytes < 16 do
|
|
78
|
+
bytes = bytes .. string.char(math.random(0, 255))
|
|
79
|
+
end
|
|
80
|
+
return bytes
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
local function header_text(v)
|
|
85
|
+
if v == nil then
|
|
86
|
+
return nil
|
|
87
|
+
end
|
|
88
|
+
if math.type(v) == "float" and v == math.floor(v) then
|
|
89
|
+
return string.format("%d", math.tointeger(v))
|
|
90
|
+
end
|
|
91
|
+
return tostring(v)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
-- The configured ttl capped by the response's Cache-Control; zero when the
|
|
96
|
+
-- response may not be stored.
|
|
97
|
+
local function cache_lifetime(headers, ttl)
|
|
98
|
+
local control = ""
|
|
99
|
+
for k, v in pairs(headers or {}) do
|
|
100
|
+
if type(k) == "string" and string.lower(k) == "cache-control" then
|
|
101
|
+
control = string.lower(header_text(v) or "")
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
local life = ttl
|
|
105
|
+
for part in string.gmatch(control .. ",", "([^,]*),") do
|
|
106
|
+
local directive = string.match(part, "^%s*(.-)%s*$")
|
|
107
|
+
if UNSTORED[directive] then
|
|
108
|
+
return 0
|
|
109
|
+
end
|
|
110
|
+
local secs = string.match(directive, '^max%-age%s*=%s*"?(%d+)"?$')
|
|
111
|
+
if secs ~= nil then
|
|
112
|
+
life = math.min(life, tonumber(secs) * 1000)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
return life
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
local function url_scope(url)
|
|
120
|
+
local base = string.match(url, "^[^?#]*")
|
|
121
|
+
return (string.gsub(base, "/+$", ""))
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
local function url_parent(scope)
|
|
126
|
+
local root = 0
|
|
127
|
+
local scheme = string.find(scope, "://", 1, true)
|
|
128
|
+
if scheme ~= nil then
|
|
129
|
+
root = string.find(scope, "/", scheme + 3, true)
|
|
130
|
+
if root == nil then
|
|
131
|
+
return scope
|
|
132
|
+
end
|
|
133
|
+
root = root - 1
|
|
134
|
+
end
|
|
135
|
+
local cut = 0
|
|
136
|
+
for i = #scope, 1, -1 do
|
|
137
|
+
if string.sub(scope, i, i) == "/" then
|
|
138
|
+
cut = i - 1
|
|
139
|
+
break
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
return string.sub(scope, 1, math.max(cut, root))
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
local function scope_under(scope, prefix)
|
|
147
|
+
return scope == prefix or string.sub(scope, 1, #prefix + 1) == prefix .. "/"
|
|
148
|
+
end
|
|
149
|
+
|
|
19
150
|
|
|
20
151
|
function CacheFeature.new()
|
|
21
152
|
local self = setmetatable(BaseFeature.new(), CacheFeature)
|
|
@@ -46,6 +177,7 @@ function CacheFeature:init(ctx, options)
|
|
|
46
177
|
|
|
47
178
|
self.store = {}
|
|
48
179
|
self.order = {}
|
|
180
|
+
self.secret = cache_secret()
|
|
49
181
|
|
|
50
182
|
local cache_self = self
|
|
51
183
|
local utility = ctx.utility
|
|
@@ -72,10 +204,19 @@ function CacheFeature:_through(ctx, fullurl, fetchdef, inner)
|
|
|
72
204
|
end
|
|
73
205
|
end
|
|
74
206
|
if not cacheable_method then
|
|
75
|
-
|
|
207
|
+
if method == "GET" or method == "HEAD" then
|
|
208
|
+
return inner(ctx, fullurl, fetchdef)
|
|
209
|
+
end
|
|
210
|
+
local out = table.pack(pcall(inner, ctx, fullurl, fetchdef))
|
|
211
|
+
self:_invalidate(fullurl)
|
|
212
|
+
if not out[1] then
|
|
213
|
+
error(out[2], 0)
|
|
214
|
+
end
|
|
215
|
+
return table.unpack(out, 2, out.n)
|
|
76
216
|
end
|
|
77
217
|
|
|
78
|
-
local
|
|
218
|
+
local headers = fetchdef ~= nil and fetchdef["headers"] or nil
|
|
219
|
+
local key = method .. " " .. fullurl .. " " .. self:_digest(headers)
|
|
79
220
|
local now = self:_now()
|
|
80
221
|
local hit = self.store[key]
|
|
81
222
|
|
|
@@ -94,12 +235,16 @@ function CacheFeature:_through(ctx, fullurl, fetchdef, inner)
|
|
|
94
235
|
|
|
95
236
|
if self:_cacheable(res, err) then
|
|
96
237
|
local snapshot = self:_snapshot(res)
|
|
97
|
-
local ttl =
|
|
98
|
-
|
|
99
|
-
if
|
|
100
|
-
|
|
238
|
+
local ttl = cache_lifetime(snapshot.headers,
|
|
239
|
+
self.options["ttl"] == nil and 5000 or self.options["ttl"])
|
|
240
|
+
if ttl <= 0 then
|
|
241
|
+
self:_track("bypass")
|
|
242
|
+
return self:_replay(snapshot), nil
|
|
101
243
|
end
|
|
102
|
-
self
|
|
244
|
+
self:_drop(key)
|
|
245
|
+
self:_evict()
|
|
246
|
+
table.insert(self.order, key)
|
|
247
|
+
self.store[key] = { expiry = now + ttl, scope = url_scope(fullurl), snapshot = snapshot }
|
|
103
248
|
self:_track("miss")
|
|
104
249
|
return self:_replay(snapshot), nil
|
|
105
250
|
end
|
|
@@ -109,6 +254,58 @@ function CacheFeature:_through(ctx, fullurl, fetchdef, inner)
|
|
|
109
254
|
end
|
|
110
255
|
|
|
111
256
|
|
|
257
|
+
function CacheFeature:_digest(headers)
|
|
258
|
+
local pairs_ = {}
|
|
259
|
+
if type(headers) == "table" then
|
|
260
|
+
for k, v in pairs(headers) do
|
|
261
|
+
local text = type(k) == "string" and header_text(v) or nil
|
|
262
|
+
if text ~= nil then
|
|
263
|
+
table.insert(pairs_, { string.lower(k), text })
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
table.sort(pairs_, function(a, b)
|
|
268
|
+
if a[1] ~= b[1] then
|
|
269
|
+
return a[1] < b[1]
|
|
270
|
+
end
|
|
271
|
+
return a[2] < b[2]
|
|
272
|
+
end)
|
|
273
|
+
local parts = {}
|
|
274
|
+
for _, p in ipairs(pairs_) do
|
|
275
|
+
table.insert(parts, p[1] .. ":" .. p[2] .. "\n")
|
|
276
|
+
end
|
|
277
|
+
return string.format("%016x", siphash24(self.secret, table.concat(parts)))
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
function CacheFeature:_invalidate(url)
|
|
282
|
+
local path = url_scope(url)
|
|
283
|
+
local collection = url_parent(path)
|
|
284
|
+
local dropped = {}
|
|
285
|
+
for key, entry in pairs(self.store) do
|
|
286
|
+
if scope_under(entry.scope, path) or entry.scope == collection then
|
|
287
|
+
table.insert(dropped, key)
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
for _, key in ipairs(dropped) do
|
|
291
|
+
self:_drop(key)
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
function CacheFeature:_drop(key)
|
|
297
|
+
if self.store[key] == nil then
|
|
298
|
+
return
|
|
299
|
+
end
|
|
300
|
+
self.store[key] = nil
|
|
301
|
+
for i = #self.order, 1, -1 do
|
|
302
|
+
if self.order[i] == key then
|
|
303
|
+
table.remove(self.order, i)
|
|
304
|
+
end
|
|
305
|
+
end
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
|
|
112
309
|
function CacheFeature:_cacheable(res, err)
|
|
113
310
|
-- A body the transport could not read as JSON passes through, for the operation to report.
|
|
114
311
|
if err ~= nil or res == nil or res["unreadable"] == true then
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
-- status and timing — on `client._debug.entries`. Every entry passes
|
|
6
6
|
-- through the SDK's clean rules (clean.keys and every registered secret);
|
|
7
7
|
-- the `redact` option ADDS header names on top of them. An optional
|
|
8
|
-
-- `
|
|
9
|
-
-- other targets) receives each finished entry. `max` caps the buffer
|
|
8
|
+
-- `onEntry` callback receives each finished entry. `max` caps the buffer
|
|
10
9
|
-- (default 100). The clock is injectable (`now`) for deterministic tests.
|
|
11
10
|
|
|
12
11
|
local BaseFeature = require("feature.base_feature")
|
|
@@ -148,7 +147,7 @@ function DebugFeature:_finish(ctx, ok)
|
|
|
148
147
|
table.remove(buf, 1)
|
|
149
148
|
end
|
|
150
149
|
|
|
151
|
-
local on_entry = self.options["
|
|
150
|
+
local on_entry = self.options["onEntry"]
|
|
152
151
|
if type(on_entry) == "function" then
|
|
153
152
|
pcall(on_entry, entry)
|
|
154
153
|
end
|
|
@@ -106,6 +106,11 @@ function MetricsFeature:_record(ctx, ok)
|
|
|
106
106
|
|
|
107
107
|
self:_bump(m.total, ok, dur)
|
|
108
108
|
self:_bump(op, ok, dur)
|
|
109
|
+
|
|
110
|
+
local sink = self.options["sink"]
|
|
111
|
+
if type(sink) == "function" then
|
|
112
|
+
pcall(sink, ctx.utility.clean(ctx, m))
|
|
113
|
+
end
|
|
109
114
|
end
|
|
110
115
|
|
|
111
116
|
|
|
@@ -36,6 +36,126 @@ local function header_get(headers, name)
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
|
|
39
|
+
-- Under the `next` option's default, a URL or an absolute path is a link and
|
|
40
|
+
-- anything else a cursor; `cursor` and `url` pin the reading.
|
|
41
|
+
local function is_link(nxt, mode)
|
|
42
|
+
if type(nxt) ~= "string" then
|
|
43
|
+
return false
|
|
44
|
+
end
|
|
45
|
+
if mode == "url" then
|
|
46
|
+
return true
|
|
47
|
+
end
|
|
48
|
+
if mode == "cursor" then
|
|
49
|
+
return false
|
|
50
|
+
end
|
|
51
|
+
return string.match(nxt, "^%a[%w+.-]*://") ~= nil or string.sub(nxt, 1, 1) == "/"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
local function origin_of(text)
|
|
56
|
+
if type(text) ~= "string" then
|
|
57
|
+
return ""
|
|
58
|
+
end
|
|
59
|
+
return string.match(text, "^%a[%w+.-]*://[^/?#]*") or ""
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
local function foreign(link, base)
|
|
64
|
+
local origin = string.lower(origin_of(link))
|
|
65
|
+
return origin ~= "" and origin ~= string.lower(origin_of(base))
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
local function unescape(text)
|
|
70
|
+
text = string.gsub(text, "+", " ")
|
|
71
|
+
return (string.gsub(text, "%%(%x%x)", function(h) return string.char(tonumber(h, 16)) end))
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
-- RFC 3986 section 5.2.4.
|
|
76
|
+
local function remove_dots(path)
|
|
77
|
+
local abs = string.sub(path, 1, 1) == "/"
|
|
78
|
+
local segs = {}
|
|
79
|
+
for seg in string.gmatch(path .. "/", "([^/]*)/") do
|
|
80
|
+
table.insert(segs, seg)
|
|
81
|
+
end
|
|
82
|
+
local out = {}
|
|
83
|
+
for i = abs and 2 or 1, #segs do
|
|
84
|
+
local seg = segs[i]
|
|
85
|
+
if seg == "." or seg == ".." then
|
|
86
|
+
if seg == ".." then
|
|
87
|
+
table.remove(out)
|
|
88
|
+
end
|
|
89
|
+
if i == #segs then
|
|
90
|
+
table.insert(out, "")
|
|
91
|
+
end
|
|
92
|
+
else
|
|
93
|
+
table.insert(out, seg)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
return (abs and "/" or "") .. table.concat(out, "/")
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
-- RFC 3986 reference resolution against the URL of the request that returned
|
|
101
|
+
-- the link, by hand: Lua has no resolver. A link on that URL's origin comes
|
|
102
|
+
-- back as its path and query; an absolute link is left as it is.
|
|
103
|
+
local function resolve(link, url)
|
|
104
|
+
if type(url) ~= "string" or url == "" or string.match(link, "^%a[%w+.-]*:") then
|
|
105
|
+
return link
|
|
106
|
+
end
|
|
107
|
+
link = string.match(link, "^[^#]*")
|
|
108
|
+
local origin = origin_of(url)
|
|
109
|
+
if string.sub(link, 1, 2) == "//" then
|
|
110
|
+
return origin == "" and link or (string.match(origin, "^[^:]*:") .. link)
|
|
111
|
+
end
|
|
112
|
+
local from = string.match(string.sub(url, #origin + 1), "^[^#]*")
|
|
113
|
+
local bpath, bquery = string.match(from, "^([^?]*)%??(.*)$")
|
|
114
|
+
if not string.find(from, "?", 1, true) then
|
|
115
|
+
bquery = nil
|
|
116
|
+
end
|
|
117
|
+
local rpath, rquery = string.match(link, "^([^?]*)%??(.*)$")
|
|
118
|
+
if not string.find(link, "?", 1, true) then
|
|
119
|
+
rquery = nil
|
|
120
|
+
end
|
|
121
|
+
local path, query
|
|
122
|
+
if rpath == "" then
|
|
123
|
+
path, query = bpath, rquery or bquery
|
|
124
|
+
elseif string.sub(rpath, 1, 1) == "/" then
|
|
125
|
+
path, query = remove_dots(rpath), rquery
|
|
126
|
+
else
|
|
127
|
+
path, query = remove_dots((string.match(bpath, "^(.*/)") or "") .. rpath), rquery
|
|
128
|
+
end
|
|
129
|
+
if string.sub(path, 1, 1) ~= "/" then
|
|
130
|
+
path = "/" .. path
|
|
131
|
+
end
|
|
132
|
+
return query == nil and path or (path .. "?" .. query)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
-- The request goes to the link's path and query, on the SDK's own origin.
|
|
137
|
+
local function follow(spec, nxt)
|
|
138
|
+
local link = string.sub(nxt, #origin_of(nxt) + 1)
|
|
139
|
+
link = string.match(link, "^[^#]*")
|
|
140
|
+
local path, rawquery = string.match(link, "^([^?]*)%??(.*)$")
|
|
141
|
+
|
|
142
|
+
local query = {}
|
|
143
|
+
for pair in string.gmatch(rawquery or "", "[^&]+") do
|
|
144
|
+
local key, val = string.match(pair, "^([^=]*)=?(.*)$")
|
|
145
|
+
query[unescape(key)] = unescape(val)
|
|
146
|
+
end
|
|
147
|
+
for _, key in ipairs(spec.authquery or {}) do
|
|
148
|
+
query[key] = spec.query[key]
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
spec.base = origin_of(spec.base)
|
|
152
|
+
spec.prefix = ""
|
|
153
|
+
spec.path = path or ""
|
|
154
|
+
spec.suffix = ""
|
|
155
|
+
spec.query = query
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
|
|
39
159
|
function PagingFeature.new()
|
|
40
160
|
local self = setmetatable(BaseFeature.new(), PagingFeature)
|
|
41
161
|
self.version = "0.0.1"
|
|
@@ -95,6 +215,8 @@ function PagingFeature:PreRequest(ctx)
|
|
|
95
215
|
|
|
96
216
|
if paging["cursor"] ~= nil then
|
|
97
217
|
spec.query[cursor_param] = paging["cursor"]
|
|
218
|
+
elseif type(paging["next"]) == "string" and not foreign(paging["next"], spec.base) then
|
|
219
|
+
follow(spec, paging["next"])
|
|
98
220
|
elseif spec.query[page_param] == nil then
|
|
99
221
|
-- A record written back by PreResult holds the page just fetched as
|
|
100
222
|
-- "page" and the one to fetch as "nextPage", so nextPage wins.
|
|
@@ -227,8 +349,13 @@ function PagingFeature:PreResult(ctx)
|
|
|
227
349
|
|
|
228
350
|
-- Body-level signals; snake_case forms are read first so camelCase wins.
|
|
229
351
|
if type(body) == "table" then
|
|
230
|
-
|
|
231
|
-
|
|
352
|
+
local bnext = body["next"]
|
|
353
|
+
if is_link(bnext, self.options["next"] or "auto") then
|
|
354
|
+
if paging.next == nil then
|
|
355
|
+
paging.next = bnext
|
|
356
|
+
end
|
|
357
|
+
elseif type(bnext) == "string" or type(bnext) == "number" then
|
|
358
|
+
paging.cursor = bnext
|
|
232
359
|
end
|
|
233
360
|
if body["next_cursor"] ~= nil then
|
|
234
361
|
paging.cursor = body["next_cursor"]
|
|
@@ -258,6 +385,16 @@ function PagingFeature:PreResult(ctx)
|
|
|
258
385
|
end
|
|
259
386
|
end
|
|
260
387
|
|
|
388
|
+
-- A link to another origin is recorded, never followed, and ends the walk.
|
|
389
|
+
local base = ctx.spec ~= nil and ctx.spec.base or (ctx.options or {})["base"]
|
|
390
|
+
if type(paging.next) == "string" and ctx.spec ~= nil then
|
|
391
|
+
paging.next = resolve(paging.next, ctx.spec.url)
|
|
392
|
+
end
|
|
393
|
+
if paging.next ~= nil and foreign(paging.next, base) then
|
|
394
|
+
paging.foreign = paging.next
|
|
395
|
+
paging.next = nil
|
|
396
|
+
end
|
|
397
|
+
|
|
261
398
|
-- Cursor presence only INFERS another page. When the server stated the
|
|
262
399
|
-- answer outright — relay's `hasNextPage: false`, or a body `hasMore` —
|
|
263
400
|
-- that wins: a final page normally carries both an end cursor and
|
|
@@ -268,6 +405,10 @@ function PagingFeature:PreResult(ctx)
|
|
|
268
405
|
paging.next ~= nil or paging.cursor ~= nil or paging.nextPage ~= nil
|
|
269
406
|
end
|
|
270
407
|
|
|
408
|
+
if paging.foreign ~= nil and paging.cursor == nil and paging.nextPage == nil then
|
|
409
|
+
paging.hasMore = false
|
|
410
|
+
end
|
|
411
|
+
|
|
271
412
|
result.paging = paging
|
|
272
413
|
|
|
273
414
|
if ctx.ctrl ~= nil then
|
|
@@ -62,24 +62,20 @@ function RatelimitFeature:_acquire(ctx)
|
|
|
62
62
|
local rate = self.options["rate"] or 5
|
|
63
63
|
local burst = self.options["burst"] == nil and rate or self.options["burst"]
|
|
64
64
|
|
|
65
|
-
-- Refill
|
|
65
|
+
-- Refill, then reserve this call's token before any wait: a negative
|
|
66
|
+
-- count is the calls already queued, so overlapping calls pace in turn.
|
|
66
67
|
local now = self:_now()
|
|
67
68
|
local elapsed = now - self.last
|
|
68
69
|
self.last = now
|
|
69
|
-
self.tokens = math.min(burst, self.tokens + (elapsed / 1000) * rate)
|
|
70
|
+
self.tokens = math.min(burst, self.tokens + (elapsed / 1000) * rate) - 1
|
|
70
71
|
|
|
71
|
-
if self.tokens >=
|
|
72
|
-
self.tokens = self.tokens - 1
|
|
72
|
+
if self.tokens >= 0 then
|
|
73
73
|
return
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
local needed = 1 - self.tokens
|
|
78
|
-
local wait_ms = math.ceil((needed / rate) * 1000)
|
|
76
|
+
local wait_ms = math.ceil((-self.tokens / rate) * 1000)
|
|
79
77
|
self:_track(ctx, wait_ms)
|
|
80
78
|
self:_sleep(wait_ms)
|
|
81
|
-
self.last = self:_now()
|
|
82
|
-
self.tokens = 0
|
|
83
79
|
end
|
|
84
80
|
|
|
85
81
|
|
|
@@ -106,7 +106,10 @@ function RetryFeature:_retryable(res, err)
|
|
|
106
106
|
if type(status) ~= "number" then
|
|
107
107
|
return false
|
|
108
108
|
end
|
|
109
|
-
local statuses = self.options["statuses"]
|
|
109
|
+
local statuses = self.options["statuses"]
|
|
110
|
+
if statuses == nil then
|
|
111
|
+
statuses = RETRY_STATUSES
|
|
112
|
+
end
|
|
110
113
|
for _, s in ipairs(statuses) do
|
|
111
114
|
if s == status then
|
|
112
115
|
return true
|
|
@@ -117,7 +120,7 @@ end
|
|
|
117
120
|
|
|
118
121
|
|
|
119
122
|
function RetryFeature:_backoff(res, attempt, min_delay, max_delay, factor)
|
|
120
|
-
--
|
|
123
|
+
-- A server-provided Retry-After wins over the computed backoff.
|
|
121
124
|
local ra = self:_retry_after(res)
|
|
122
125
|
if ra ~= nil then
|
|
123
126
|
return math.min(max_delay, ra)
|
|
@@ -139,11 +142,46 @@ function RetryFeature:_retry_after(res)
|
|
|
139
142
|
if v == nil then
|
|
140
143
|
return nil
|
|
141
144
|
end
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
return RetryFeature.retry_after_ms(tostring(v), os.time() * 1000)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
local MONTHS = "JanFebMarAprMayJunJulAugSepOctNovDec"
|
|
150
|
+
local DAYS = " Mon Tue Wed Thu Fri Sat Sun "
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
-- Days from 1970-01-01 to a proleptic Gregorian date.
|
|
154
|
+
local function days_from_civil(y, m, d)
|
|
155
|
+
if m <= 2 then
|
|
156
|
+
y = y - 1
|
|
157
|
+
end
|
|
158
|
+
local era = math.floor(y / 400)
|
|
159
|
+
local yoe = y - era * 400
|
|
160
|
+
local mp = (m + 9) % 12
|
|
161
|
+
local doy = math.floor((153 * mp + 2) / 5) + d - 1
|
|
162
|
+
local doe = yoe * 365 + math.floor(yoe / 4) - math.floor(yoe / 100) + doy
|
|
163
|
+
return era * 146097 + doe - 719468
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
-- RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else nil.
|
|
168
|
+
function RetryFeature.retry_after_ms(value, now)
|
|
169
|
+
local s = value:gsub("^[ \t]+", ""):gsub("[ \t]+$", "")
|
|
170
|
+
if s:match("^%d+$") then
|
|
171
|
+
return tonumber(s) * 1000
|
|
172
|
+
end
|
|
173
|
+
local wd, day, mon, year, hour, min, sec =
|
|
174
|
+
s:match("^(%a%a%a), (%d%d) (%a%a%a) (%d%d%d%d) (%d%d):(%d%d):(%d%d) GMT$")
|
|
175
|
+
if wd == nil or not DAYS:find(" " .. wd .. " ", 1, true) then
|
|
176
|
+
return nil
|
|
177
|
+
end
|
|
178
|
+
local mi = MONTHS:find(mon, 1, true)
|
|
179
|
+
day, year, hour, min, sec = tonumber(day), tonumber(year), tonumber(hour), tonumber(min), tonumber(sec)
|
|
180
|
+
if mi == nil or (mi - 1) % 3 ~= 0 or day < 1 or day > 31 or hour > 23 or min > 59 or sec > 60 then
|
|
144
181
|
return nil
|
|
145
182
|
end
|
|
146
|
-
|
|
183
|
+
local at = (((days_from_civil(year, (mi - 1) / 3 + 1, day) * 24 + hour) * 60 + min) * 60 + sec) * 1000
|
|
184
|
+
return math.max(0, at - now)
|
|
147
185
|
end
|
|
148
186
|
|
|
149
187
|
|