@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,7 @@
|
|
|
1
1
|
# ProjectName SDK cache feature
|
|
2
2
|
#
|
|
3
|
-
# Response caching for safe (read) requests
|
|
4
|
-
#
|
|
5
|
-
# method+URL was fetched within `ttl` ms (default 5000). Only successful (2xx)
|
|
6
|
-
# responses to cacheable methods (default: GET) are stored, keyed by
|
|
7
|
-
# method+URL. The cache is bounded (`max` entries, default 256, oldest evicted
|
|
8
|
-
# first) and every hit/miss is recorded on `client._cache` for inspection.
|
|
9
|
-
# Response bodies are snapshotted on capture so both the current caller and
|
|
10
|
-
# later hits can read the JSON body 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 rules.
|
|
11
5
|
|
|
12
6
|
defmodule ProjectName.Feature.Cache do
|
|
13
7
|
alias Voxgig.Struct, as: S
|
|
@@ -25,6 +19,7 @@ defmodule ProjectName.Feature.Cache do
|
|
|
25
19
|
|
|
26
20
|
if active do
|
|
27
21
|
S.setprop(f, "store", S.jm([]))
|
|
22
|
+
S.setprop(f, "secret", :crypto.strong_rand_bytes(32))
|
|
28
23
|
|
|
29
24
|
utility = S.getprop(ctx, "utility")
|
|
30
25
|
inner = S.getprop(utility, "fetcher")
|
|
@@ -47,41 +42,162 @@ defmodule ProjectName.Feature.Cache do
|
|
|
47
42
|
|
|
48
43
|
methods = opt_list(S.getprop(opts, "methods"), ["GET"])
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
cond do
|
|
46
|
+
method in methods ->
|
|
47
|
+
lookup(f, opts, store, method, ctx, url, fetchdef, inner)
|
|
48
|
+
|
|
49
|
+
method in ["GET", "HEAD"] ->
|
|
50
|
+
inner.(ctx, url, fetchdef)
|
|
51
|
+
|
|
52
|
+
true ->
|
|
53
|
+
try do
|
|
54
|
+
inner.(ctx, url, fetchdef)
|
|
55
|
+
after
|
|
56
|
+
invalidate(f, url)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
defp lookup(f, opts, store, method, ctx, url, fetchdef, inner) do
|
|
62
|
+
headers = if S.ismap(fetchdef), do: S.getprop(fetchdef, "headers"), else: nil
|
|
63
|
+
key = method <> " " <> url <> " " <> digest(S.getprop(f, "secret"), headers)
|
|
64
|
+
now = F.now(f)
|
|
65
|
+
hit = S.getprop(store, key)
|
|
66
|
+
|
|
67
|
+
if hit != nil and S.getprop(hit, "expiry") > now do
|
|
68
|
+
track(f, "hit")
|
|
69
|
+
{replay(S.getprop(hit, "snapshot")), nil}
|
|
52
70
|
else
|
|
53
|
-
|
|
54
|
-
now = F.now(f)
|
|
55
|
-
hit = S.getprop(store, key)
|
|
71
|
+
{res, err} = inner.(ctx, url, fetchdef)
|
|
56
72
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
cond do
|
|
74
|
+
# A body that declares another type than JSON passes by, unread.
|
|
75
|
+
err == nil and cacheable(res) and not json?(res) ->
|
|
76
|
+
track(f, "bypass")
|
|
77
|
+
{res, err}
|
|
62
78
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
track(f, "bypass")
|
|
67
|
-
{res, err}
|
|
79
|
+
err == nil and cacheable(res) ->
|
|
80
|
+
snap = snapshot(res)
|
|
81
|
+
ttl = lifetime(S.getprop(snap, "headers"), case S.getprop(opts, "ttl") do nil -> 5000; v -> v end)
|
|
68
82
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
83
|
+
if ttl <= 0 do
|
|
84
|
+
track(f, "bypass")
|
|
85
|
+
{replay(snap), nil}
|
|
86
|
+
else
|
|
87
|
+
S.delprop(store, key)
|
|
72
88
|
evict(f)
|
|
73
|
-
S.setprop(store, key, S.jm(["expiry", now + ttl, "snapshot", snap]))
|
|
89
|
+
S.setprop(store, key, S.jm(["expiry", now + ttl, "scope", scope(url), "snapshot", snap]))
|
|
74
90
|
track(f, "miss")
|
|
75
91
|
{replay(snap), nil}
|
|
92
|
+
end
|
|
76
93
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
94
|
+
true ->
|
|
95
|
+
track(f, "bypass")
|
|
96
|
+
{res, err}
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
defp header_text(nil), do: nil
|
|
102
|
+
defp header_text(v) when is_binary(v), do: v
|
|
103
|
+
defp header_text(v) when is_float(v) and v == trunc(v), do: Integer.to_string(trunc(v))
|
|
104
|
+
defp header_text(v), do: to_string(v)
|
|
105
|
+
|
|
106
|
+
defp digest(secret, headers) do
|
|
107
|
+
pairs =
|
|
108
|
+
if S.ismap(headers) do
|
|
109
|
+
H.entries(headers)
|
|
110
|
+
|> Enum.flat_map(fn {k, v} ->
|
|
111
|
+
case header_text(v) do
|
|
112
|
+
nil -> []
|
|
113
|
+
text -> [{String.downcase(to_string(k)), text}]
|
|
114
|
+
end
|
|
115
|
+
end)
|
|
116
|
+
|> Enum.sort()
|
|
117
|
+
else
|
|
118
|
+
[]
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
text = Enum.map_join(pairs, "", fn {k, v} -> k <> ":" <> v <> "\n" end)
|
|
122
|
+
Base.encode16(:crypto.mac(:hmac, :sha256, secret, text), case: :lower)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
defp invalidate(f, url) do
|
|
126
|
+
store = S.getprop(f, "store")
|
|
127
|
+
path = scope(url)
|
|
128
|
+
collection = parent(path)
|
|
129
|
+
|
|
130
|
+
H.entries(store)
|
|
131
|
+
|> Enum.filter(fn {_k, e} ->
|
|
132
|
+
entry = S.getprop(e, "scope")
|
|
133
|
+
under?(entry, path) or entry == collection
|
|
134
|
+
end)
|
|
135
|
+
|> Enum.each(fn {k, _e} -> S.delprop(store, k) end)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# The configured ttl capped by the response's Cache-Control; zero when the
|
|
139
|
+
# response may not be stored.
|
|
140
|
+
defp lifetime(headers, ttl) do
|
|
141
|
+
control =
|
|
142
|
+
if S.ismap(headers) do
|
|
143
|
+
Enum.find_value(H.entries(headers), "", fn {k, v} ->
|
|
144
|
+
if String.downcase(to_string(k)) == "cache-control", do: String.downcase(header_text(v) || "")
|
|
145
|
+
end)
|
|
146
|
+
else
|
|
147
|
+
""
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
directives = control |> String.split(",") |> Enum.map(&String.trim/1)
|
|
151
|
+
|
|
152
|
+
if Enum.any?(directives, &(&1 in ["no-store", "private", "no-cache"])) do
|
|
153
|
+
0
|
|
154
|
+
else
|
|
155
|
+
Enum.reduce(directives, ttl, fn d, life ->
|
|
156
|
+
case Regex.run(~r/^max-age\s*=\s*"?(\d+)"?$/, d) do
|
|
157
|
+
[_, secs] -> min(life, String.to_integer(secs) * 1000)
|
|
158
|
+
_ -> life
|
|
80
159
|
end
|
|
160
|
+
end)
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
defp scope(url) do
|
|
165
|
+
[base | _] = String.split(to_string(url), ["?", "#"], parts: 2)
|
|
166
|
+
String.replace(base, ~r{/+$}, "")
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
defp parent(scope) do
|
|
170
|
+
root =
|
|
171
|
+
case :binary.match(scope, "://") do
|
|
172
|
+
:nomatch ->
|
|
173
|
+
0
|
|
174
|
+
|
|
175
|
+
{at, 3} ->
|
|
176
|
+
case :binary.match(scope, "/", scope: {at + 3, byte_size(scope) - at - 3}) do
|
|
177
|
+
:nomatch -> nil
|
|
178
|
+
{slash, 1} -> slash
|
|
179
|
+
end
|
|
81
180
|
end
|
|
181
|
+
|
|
182
|
+
case root do
|
|
183
|
+
nil ->
|
|
184
|
+
scope
|
|
185
|
+
|
|
186
|
+
root ->
|
|
187
|
+
cut =
|
|
188
|
+
case :binary.matches(scope, "/") do
|
|
189
|
+
[] -> 0
|
|
190
|
+
found -> found |> List.last() |> elem(0)
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
binary_part(scope, 0, max(cut, root))
|
|
82
194
|
end
|
|
83
195
|
end
|
|
84
196
|
|
|
197
|
+
defp under?(scope, prefix) do
|
|
198
|
+
scope == prefix or String.starts_with?(scope, prefix <> "/")
|
|
199
|
+
end
|
|
200
|
+
|
|
85
201
|
# A body the transport could not read as JSON passes through, for the operation to report.
|
|
86
202
|
defp cacheable(res) do
|
|
87
203
|
if not S.ismap(res) or S.getprop(res, "unreadable") == true do
|
|
@@ -104,6 +104,19 @@ defmodule ProjectName.Feature.Metrics do
|
|
|
104
104
|
|
|
105
105
|
bump(S.getprop(metrics, "total"), ok, dur)
|
|
106
106
|
bump(op_bucket, ok, dur)
|
|
107
|
+
|
|
108
|
+
sink = S.getprop(F.opts(f), "sink")
|
|
109
|
+
|
|
110
|
+
if S.isfunc(sink) do
|
|
111
|
+
try do
|
|
112
|
+
sink.(F.clean(ctx, metrics))
|
|
113
|
+
rescue
|
|
114
|
+
_ -> nil
|
|
115
|
+
catch
|
|
116
|
+
_, _ -> nil
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
107
120
|
nil
|
|
108
121
|
end
|
|
109
122
|
end
|
|
@@ -16,6 +16,8 @@ defmodule ProjectName.Feature.Paging do
|
|
|
16
16
|
|
|
17
17
|
@next_re ~r/<([^>]+)>\s*;\s*rel="?next"?/i
|
|
18
18
|
|
|
19
|
+
@origin_re ~r/^[a-z][a-z0-9+.-]*:\/\/[^\/?#]*/i
|
|
20
|
+
|
|
19
21
|
def new do
|
|
20
22
|
f = F.base("paging")
|
|
21
23
|
F.install(f, "init", fn ctx, opts -> init(f, ctx, opts) end)
|
|
@@ -66,6 +68,10 @@ defmodule ProjectName.Feature.Paging do
|
|
|
66
68
|
S.getprop(paging, "cursor") != nil ->
|
|
67
69
|
S.setprop(query, cursor_param, S.getprop(paging, "cursor"))
|
|
68
70
|
|
|
71
|
+
is_binary(S.getprop(paging, "next")) and
|
|
72
|
+
not foreign?(S.getprop(paging, "next"), S.getprop(spec, "base")) ->
|
|
73
|
+
follow(spec, S.getprop(paging, "next"))
|
|
74
|
+
|
|
69
75
|
S.getprop(query, page_param) == nil ->
|
|
70
76
|
# A record written back by pre_result holds the page just fetched
|
|
71
77
|
# as "page" and the one to fetch as "nextPage", so nextPage wins.
|
|
@@ -79,6 +85,7 @@ defmodule ProjectName.Feature.Paging do
|
|
|
79
85
|
end
|
|
80
86
|
|
|
81
87
|
limit = S.getprop(opts, "limit")
|
|
88
|
+
query = S.getprop(spec, "query")
|
|
82
89
|
|
|
83
90
|
if limit != nil and S.getprop(query, limit_param) == nil do
|
|
84
91
|
S.setprop(query, limit_param, limit)
|
|
@@ -177,13 +184,12 @@ defmodule ProjectName.Feature.Paging do
|
|
|
177
184
|
nil
|
|
178
185
|
end
|
|
179
186
|
|
|
187
|
+
mode = por(S.getprop(F.opts(f), "next"), "auto")
|
|
188
|
+
|
|
180
189
|
{next_val, cursor_val, has_more} =
|
|
181
190
|
if S.ismap(body) do
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
nil -> next_from_link
|
|
185
|
-
bnext -> por(next_from_link, bnext)
|
|
186
|
-
end
|
|
191
|
+
bnext = S.getprop(body, "next")
|
|
192
|
+
n = if link?(bnext, mode), do: por(next_from_link, bnext), else: next_from_link
|
|
187
193
|
|
|
188
194
|
# snake_case forms rank below the camelCase ones.
|
|
189
195
|
c =
|
|
@@ -191,6 +197,7 @@ defmodule ProjectName.Feature.Paging do
|
|
|
191
197
|
S.getprop(body, "nextCursor") != nil -> S.getprop(body, "nextCursor")
|
|
192
198
|
S.getprop(body, "cursor") != nil -> S.getprop(body, "cursor")
|
|
193
199
|
S.getprop(body, "next_cursor") != nil -> S.getprop(body, "next_cursor")
|
|
200
|
+
bnext != nil and not link?(bnext, mode) -> bnext
|
|
194
201
|
true -> nil
|
|
195
202
|
end
|
|
196
203
|
|
|
@@ -255,6 +262,20 @@ defmodule ProjectName.Feature.Paging do
|
|
|
255
262
|
next_page
|
|
256
263
|
end
|
|
257
264
|
|
|
265
|
+
# A link to another origin is recorded, never followed, and ends the walk.
|
|
266
|
+
spec = S.getprop(ctx, "spec")
|
|
267
|
+
base = if spec != nil, do: S.getprop(spec, "base"), else: S.getprop(S.getprop(ctx, "options"), "base")
|
|
268
|
+
|
|
269
|
+
next_val =
|
|
270
|
+
if is_binary(next_val) and spec != nil,
|
|
271
|
+
do: resolve(next_val, S.getprop(spec, "url")),
|
|
272
|
+
else: next_val
|
|
273
|
+
|
|
274
|
+
{next_val, foreign_val} =
|
|
275
|
+
if is_binary(next_val) and foreign?(next_val, base),
|
|
276
|
+
do: {nil, next_val},
|
|
277
|
+
else: {next_val, nil}
|
|
278
|
+
|
|
258
279
|
# Cursor presence only INFERS another page. When the server stated the
|
|
259
280
|
# answer outright — relay's `hasNextPage: false`, or a body `hasMore`
|
|
260
281
|
# — that wins: a final page normally carries both an end cursor and
|
|
@@ -267,6 +288,8 @@ defmodule ProjectName.Feature.Paging do
|
|
|
267
288
|
has_more or next_val != nil or cursor_val != nil or next_page != nil
|
|
268
289
|
end
|
|
269
290
|
|
|
291
|
+
has_more = if foreign_val != nil and cursor_val == nil and next_page == nil, do: false, else: has_more
|
|
292
|
+
|
|
270
293
|
paging =
|
|
271
294
|
S.jm([
|
|
272
295
|
"page", page,
|
|
@@ -274,6 +297,7 @@ defmodule ProjectName.Feature.Paging do
|
|
|
274
297
|
"nextPage", next_page,
|
|
275
298
|
"next", next_val,
|
|
276
299
|
"cursor", cursor_val,
|
|
300
|
+
"foreign", foreign_val,
|
|
277
301
|
"hasMore", has_more
|
|
278
302
|
])
|
|
279
303
|
|
|
@@ -317,6 +341,87 @@ defmodule ProjectName.Feature.Paging do
|
|
|
317
341
|
end
|
|
318
342
|
end
|
|
319
343
|
|
|
344
|
+
# Under the `next` option's default, a URL or an absolute path is a link and
|
|
345
|
+
# anything else a cursor; `cursor` and `url` pin the reading.
|
|
346
|
+
defp link?(next, "url") when is_binary(next), do: true
|
|
347
|
+
defp link?(next, "cursor") when is_binary(next), do: false
|
|
348
|
+
|
|
349
|
+
defp link?(next, _) when is_binary(next),
|
|
350
|
+
do: Regex.match?(@origin_re, next) or String.starts_with?(next, "/")
|
|
351
|
+
|
|
352
|
+
defp link?(_, _), do: false
|
|
353
|
+
|
|
354
|
+
defp foreign?(link, base) do
|
|
355
|
+
origin = String.downcase(origin_of(link))
|
|
356
|
+
origin != "" and origin != String.downcase(origin_of(base))
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
defp origin_of(text) when is_binary(text) do
|
|
360
|
+
case Regex.run(@origin_re, text) do
|
|
361
|
+
[origin] -> origin
|
|
362
|
+
_ -> ""
|
|
363
|
+
end
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
defp origin_of(_), do: ""
|
|
367
|
+
|
|
368
|
+
@holder "http://placeholder.invalid"
|
|
369
|
+
|
|
370
|
+
# RFC 3986 reference resolution against the URL of the request that
|
|
371
|
+
# returned the link. A link on that URL's origin comes back as its path and
|
|
372
|
+
# query; an absolute link is left as the server wrote it.
|
|
373
|
+
defp resolve(link, url) when is_binary(url) and url != "" do
|
|
374
|
+
if Regex.match?(~r/^[a-z][a-z0-9+.-]*:/i, link) do
|
|
375
|
+
link
|
|
376
|
+
else
|
|
377
|
+
from = if origin_of(url) == "", do: @holder <> if(String.starts_with?(url, "/"), do: "", else: "/") <> url, else: url
|
|
378
|
+
base = URI.parse(from)
|
|
379
|
+
out = %{URI.merge(base, link) | fragment: nil}
|
|
380
|
+
|
|
381
|
+
if {out.scheme, out.host, out.port} == {base.scheme, base.host, base.port},
|
|
382
|
+
do: (out.path || "/") <> if(out.query == nil, do: "", else: "?" <> out.query),
|
|
383
|
+
else: URI.to_string(out)
|
|
384
|
+
end
|
|
385
|
+
rescue
|
|
386
|
+
_ -> link
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
defp resolve(link, _), do: link
|
|
390
|
+
|
|
391
|
+
# The request goes to the link's path and query, on the SDK's own origin.
|
|
392
|
+
defp follow(spec, next) do
|
|
393
|
+
origin = origin_of(next)
|
|
394
|
+
link = next |> String.slice(String.length(origin)..-1//1) |> String.split("#", parts: 2) |> hd()
|
|
395
|
+
[path | rest] = String.split(link, "?", parts: 2)
|
|
396
|
+
rawquery = List.first(rest) || ""
|
|
397
|
+
|
|
398
|
+
query = S.jm([])
|
|
399
|
+
|
|
400
|
+
for pair <- String.split(rawquery, "&"), pair != "" do
|
|
401
|
+
[key | val] = String.split(pair, "=", parts: 2)
|
|
402
|
+
S.setprop(query, unescape(key), unescape(List.first(val) || ""))
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
old = S.getprop(spec, "query")
|
|
406
|
+
|
|
407
|
+
for {_, key} <- ProjectName.Helpers.entries(S.getprop(spec, "authquery")) do
|
|
408
|
+
S.setprop(query, key, S.getprop(old, key))
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
S.setprop(spec, "base", origin_of(S.getprop(spec, "base")))
|
|
412
|
+
S.setprop(spec, "prefix", "")
|
|
413
|
+
S.setprop(spec, "path", path)
|
|
414
|
+
S.setprop(spec, "suffix", "")
|
|
415
|
+
S.setprop(spec, "query", query)
|
|
416
|
+
nil
|
|
417
|
+
end
|
|
418
|
+
|
|
419
|
+
defp unescape(text) do
|
|
420
|
+
URI.decode_www_form(text)
|
|
421
|
+
rescue
|
|
422
|
+
ArgumentError -> text
|
|
423
|
+
end
|
|
424
|
+
|
|
320
425
|
defp is_list_op(f, ctx) do
|
|
321
426
|
ops = opt_list(S.getprop(F.opts(f), "ops"), ["list"])
|
|
322
427
|
op = S.getprop(ctx, "op")
|
|
@@ -44,24 +44,18 @@ defmodule ProjectName.Feature.Ratelimit do
|
|
|
44
44
|
rate = por(S.getprop(opts, "rate"), 5)
|
|
45
45
|
burst = case S.getprop(opts, "burst") do nil -> rate; v -> v end
|
|
46
46
|
|
|
47
|
-
# Refill
|
|
47
|
+
# Refill, then reserve this call's token before any wait: a negative
|
|
48
|
+
# count is the calls already queued, so overlapping calls pace in turn.
|
|
48
49
|
now = F.now(f)
|
|
49
50
|
elapsed = now - S.getprop(f, "last")
|
|
50
51
|
S.setprop(f, "last", now)
|
|
51
|
-
|
|
52
|
+
tokens = min(burst, S.getprop(f, "tokens") + elapsed / 1000 * rate) - 1
|
|
53
|
+
S.setprop(f, "tokens", tokens)
|
|
52
54
|
|
|
53
|
-
tokens
|
|
54
|
-
|
|
55
|
-
if tokens >= 1 do
|
|
56
|
-
S.setprop(f, "tokens", tokens - 1)
|
|
57
|
-
else
|
|
58
|
-
# Not enough tokens: wait for one to accrue, then consume it.
|
|
59
|
-
needed = 1 - tokens
|
|
60
|
-
wait_ms = ceil((needed / rate) * 1000)
|
|
55
|
+
if tokens < 0 do
|
|
56
|
+
wait_ms = ceil(-tokens / rate * 1000)
|
|
61
57
|
track(f, wait_ms)
|
|
62
58
|
F.sleep(f, wait_ms)
|
|
63
|
-
S.setprop(f, "last", F.now(f))
|
|
64
|
-
S.setprop(f, "tokens", 0)
|
|
65
59
|
end
|
|
66
60
|
|
|
67
61
|
nil
|
|
@@ -69,7 +69,12 @@ defmodule ProjectName.Feature.Retry do
|
|
|
69
69
|
if not is_number(status) or is_boolean(status) do
|
|
70
70
|
false
|
|
71
71
|
else
|
|
72
|
-
statuses =
|
|
72
|
+
statuses =
|
|
73
|
+
case S.getprop(opts, "statuses") do
|
|
74
|
+
nil -> S.jt(@statuses)
|
|
75
|
+
given -> given
|
|
76
|
+
end
|
|
77
|
+
|
|
73
78
|
Enum.member?(struct_list(statuses), trunc(status))
|
|
74
79
|
end
|
|
75
80
|
end
|
|
@@ -107,18 +112,37 @@ defmodule ProjectName.Feature.Retry do
|
|
|
107
112
|
else
|
|
108
113
|
val = F.header_get(headers, "retry-after")
|
|
109
114
|
|
|
110
|
-
|
|
111
|
-
val == nil -> nil
|
|
112
|
-
true ->
|
|
113
|
-
case Float.parse(to_string(val)) do
|
|
114
|
-
{n, _} -> n * 1000
|
|
115
|
-
:error -> nil
|
|
116
|
-
end
|
|
117
|
-
end
|
|
115
|
+
if val == nil, do: nil, else: retry_after_ms(to_string(val), System.system_time(:millisecond))
|
|
118
116
|
end
|
|
119
117
|
end
|
|
120
118
|
end
|
|
121
119
|
|
|
120
|
+
@months ~w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
|
|
121
|
+
|
|
122
|
+
@imf_fixdate ~r/\A(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) ([A-Z][a-z]{2}) (\d{4}) (\d{2}):(\d{2}):(\d{2}) GMT\z/
|
|
123
|
+
|
|
124
|
+
# RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else nil.
|
|
125
|
+
def retry_after_ms(value, now) do
|
|
126
|
+
s = String.replace(value, ~r/\A[ \t]+|[ \t]+\z/, "")
|
|
127
|
+
|
|
128
|
+
cond do
|
|
129
|
+
s =~ ~r/\A[0-9]+\z/ ->
|
|
130
|
+
String.to_integer(s) * 1000
|
|
131
|
+
|
|
132
|
+
true ->
|
|
133
|
+
with [_, day, mon, year, hour, minute, sec] <- Regex.run(@imf_fixdate, s),
|
|
134
|
+
mi when mi != nil <- Enum.find_index(@months, &(&1 == mon)),
|
|
135
|
+
[d, y, hh, mm, ss] = Enum.map([day, year, hour, minute, sec], &String.to_integer/1),
|
|
136
|
+
true <- d >= 1 and d <= 31 and hh <= 23 and mm <= 59 and ss <= 60,
|
|
137
|
+
{:ok, date} <- Date.new(y, mi + 1, d) do
|
|
138
|
+
at = (Date.diff(date, ~D[1970-01-01]) * 86_400 + hh * 3600 + mm * 60 + ss) * 1000
|
|
139
|
+
max(0, at - now)
|
|
140
|
+
else
|
|
141
|
+
_ -> nil
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
122
146
|
defp track(f, _ctx, attempt, res, err, raised, wait) do
|
|
123
147
|
client = S.getprop(f, "client")
|
|
124
148
|
track = F.track_node(client, "_retry", S.jm(["attempts", 0, "retries", S.jt([])]))
|
|
@@ -714,21 +714,20 @@ defmodule ProjectName.Feature.Secrets do
|
|
|
714
714
|
"headers", S.jm(["content-type", "application/json"]),
|
|
715
715
|
"body", S.jsonify(S.jm([x.request, refresh]), S.jm(["indent", 0])),
|
|
716
716
|
# Never followed by the client: a redirect would carry the refresh token on.
|
|
717
|
-
"redirect", "manual"
|
|
717
|
+
"redirect", "manual",
|
|
718
|
+
# Its own bound, in milliseconds: the timeout feature's wrapper is above it.
|
|
719
|
+
"timeout", 30000
|
|
718
720
|
])
|
|
719
721
|
|
|
720
|
-
|
|
722
|
+
# The SDK's own transport, beneath every feature's wrapper: it holds
|
|
723
|
+
# the test feature's block and the GET-only guard, and the wrapped one
|
|
724
|
+
# would recurse on the first expiry.
|
|
725
|
+
client = S.getprop(f, "client")
|
|
726
|
+
rootctx = if client != nil, do: S.getprop(client, "_rootctx"), else: nil
|
|
721
727
|
|
|
722
|
-
# Deliberately NOT the SDK transport. The transport is what this
|
|
723
|
-
# feature wraps, and sending the token request back through it would
|
|
724
|
-
# recurse on the first expiry - and would route the exchange through
|
|
725
|
-
# the test mock, which knows nothing about it. `options.system.fetch`
|
|
726
|
-
# is preferred when set, so a test can intercept the purchase.
|
|
727
728
|
ask = fn at ->
|
|
728
729
|
try do
|
|
729
|
-
|
|
730
|
-
do: sysfetch.(at, fetchdef),
|
|
731
|
-
else: raw_exchange_fetch(at, fetchdef)
|
|
730
|
+
ProjectName.Utility.fetcher_impl(rootctx, at, fetchdef)
|
|
732
731
|
rescue
|
|
733
732
|
e -> {nil, fail(e)}
|
|
734
733
|
end
|
|
@@ -813,52 +812,6 @@ defmodule ProjectName.Feature.Secrets do
|
|
|
813
812
|
if S.ismap(body), do: S.getprop(body, name), else: nil
|
|
814
813
|
end
|
|
815
814
|
|
|
816
|
-
# The token-exchange transport of last resort: plain :httpc, same result
|
|
817
|
-
# shape the system.fetch seam promises. It exists so an exchange works
|
|
818
|
-
# with ordinary SDK options - requiring a custom transport for the COMMON
|
|
819
|
-
# case would reject every live token purchase before a request was made.
|
|
820
|
-
defp raw_exchange_fetch(url, fetchdef) do
|
|
821
|
-
Application.ensure_all_started(:inets)
|
|
822
|
-
Application.ensure_all_started(:ssl)
|
|
823
|
-
|
|
824
|
-
method =
|
|
825
|
-
H.or_(S.getprop(fetchdef, "method"), "POST") |> to_string() |> String.downcase() |> String.to_atom()
|
|
826
|
-
|
|
827
|
-
body = tostr(S.getprop(fetchdef, "body"))
|
|
828
|
-
|
|
829
|
-
hlist =
|
|
830
|
-
Enum.map(H.entries(H.or_(S.getprop(fetchdef, "headers"), S.jm([]))), fn {k, v} ->
|
|
831
|
-
{String.to_charlist(to_string(k)), String.to_charlist(to_string(v))}
|
|
832
|
-
end)
|
|
833
|
-
|
|
834
|
-
request =
|
|
835
|
-
if method in [:post, :put, :patch, :delete] do
|
|
836
|
-
{String.to_charlist(url), hlist, ~c"application/json", body}
|
|
837
|
-
else
|
|
838
|
-
{String.to_charlist(url), hlist}
|
|
839
|
-
end
|
|
840
|
-
|
|
841
|
-
case :httpc.request(method, request, [autoredirect: false], body_format: :binary) do
|
|
842
|
-
{:ok, {{_v, status, _reason}, rh, resbody}} ->
|
|
843
|
-
text = if is_binary(resbody), do: resbody, else: to_string(resbody)
|
|
844
|
-
|
|
845
|
-
parsed =
|
|
846
|
-
try do
|
|
847
|
-
ProjectName.Json.parse(text)
|
|
848
|
-
rescue
|
|
849
|
-
_ -> nil
|
|
850
|
-
end
|
|
851
|
-
|
|
852
|
-
headers =
|
|
853
|
-
S.jm(Enum.flat_map(rh, fn {k, v} -> [String.downcase(to_string(k)), to_string(v)] end))
|
|
854
|
-
|
|
855
|
-
{S.jm(["status", status, "headers", headers, "json", fn -> parsed end, "body", text]), nil}
|
|
856
|
-
|
|
857
|
-
{:error, reason} ->
|
|
858
|
-
{nil, err("secrets_exchange_failed", "secrets: token exchange transport: " <> inspect(reason))}
|
|
859
|
-
end
|
|
860
|
-
end
|
|
861
|
-
|
|
862
815
|
# ---- small helpers -------------------------------------------------------
|
|
863
816
|
|
|
864
817
|
defp statuses(v) do
|
|
@@ -908,6 +861,7 @@ defmodule ProjectName.Feature.Secrets do
|
|
|
908
861
|
# an exception, or a plain string from the default HTTP path.
|
|
909
862
|
defp aserr(e, code) do
|
|
910
863
|
cond do
|
|
864
|
+
match?(%ProjectName.Error{}, e) -> e
|
|
911
865
|
is_exception(e) -> fail(e)
|
|
912
866
|
is_binary(e) -> err(code, e)
|
|
913
867
|
true -> err(code, inspect(e))
|
|
@@ -38,9 +38,10 @@ defmodule ProjectName.Feature.Streaming do
|
|
|
38
38
|
if not streamable?(f, ctx) do
|
|
39
39
|
nil
|
|
40
40
|
else
|
|
41
|
+
# A failed result keeps no stream, so the entity's stream raises its error.
|
|
41
42
|
result = S.getprop(ctx, "result")
|
|
42
43
|
|
|
43
|
-
if result == nil do
|
|
44
|
+
if result == nil or S.getprop(result, "err") != nil do
|
|
44
45
|
nil
|
|
45
46
|
else
|
|
46
47
|
S.setprop(result, "streaming", true)
|
|
@@ -25,7 +25,6 @@ defmodule ProjectName.Feature.Telemetry do
|
|
|
25
25
|
|
|
26
26
|
def init(f, ctx, options) do
|
|
27
27
|
F.init_common(f, ctx, options)
|
|
28
|
-
S.setprop(f, "seq", 0)
|
|
29
28
|
|
|
30
29
|
client = S.getprop(f, "client")
|
|
31
30
|
|
|
@@ -159,15 +158,16 @@ defmodule ProjectName.Feature.Telemetry do
|
|
|
159
158
|
if S.isfunc(idgen) do
|
|
160
159
|
idgen.(kind)
|
|
161
160
|
else
|
|
162
|
-
|
|
163
|
-
seq = S.getprop(f, "seq") + 1
|
|
164
|
-
S.setprop(f, "seq", seq)
|
|
165
|
-
n = seq |> Integer.to_string(16) |> String.downcase() |> String.pad_leading(4, "0")
|
|
166
|
-
prefix = if kind == "trace", do: "t", else: "s"
|
|
167
|
-
prefix <> String.pad_trailing(n, 16, "0")
|
|
161
|
+
random_hex(if kind == "trace", do: 16, else: 8)
|
|
168
162
|
end
|
|
169
163
|
end
|
|
170
164
|
|
|
165
|
+
# W3C trace context: lowercase hex from the platform's random source, never all zeros.
|
|
166
|
+
defp random_hex(nbytes) do
|
|
167
|
+
hex = :crypto.strong_rand_bytes(nbytes) |> Base.encode16(case: :lower)
|
|
168
|
+
if String.trim(hex, "0") == "", do: random_hex(nbytes), else: hex
|
|
169
|
+
end
|
|
170
|
+
|
|
171
171
|
# Python `v or default`: falsy = nil, false, "".
|
|
172
172
|
defp por(v, d) do
|
|
173
173
|
if v == nil or v == false or v == "", do: d, else: v
|