@voxgig/sdkgen 4.49.1 → 4.51.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/package.json +1 -1
- package/project/.sdk/model/feature/cache.aontu +6 -4
- 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 +14 -0
- package/project/.sdk/src/cmp/clojure/TestClean_clojure.ts +10 -5
- package/project/.sdk/src/cmp/cpp/TestClean_cpp.ts +13 -0
- package/project/.sdk/src/cmp/csharp/TestClean_csharp.ts +9 -0
- package/project/.sdk/src/cmp/elixir/TestClean_elixir.ts +11 -3
- package/project/.sdk/src/cmp/go/TestClean_go.ts +39 -3
- package/project/.sdk/src/cmp/java/TestClean_java.ts +8 -0
- package/project/.sdk/src/cmp/js/TestClean_js.ts +13 -5
- package/project/.sdk/src/cmp/kotlin/TestClean_kotlin.ts +22 -0
- package/project/.sdk/src/cmp/lua/TestClean_lua.ts +12 -3
- package/project/.sdk/src/cmp/ocaml/TestClean_ocaml.ts +18 -4
- package/project/.sdk/src/cmp/perl/TestClean_perl.ts +12 -3
- package/project/.sdk/src/cmp/php/TestClean_php.ts +10 -3
- package/project/.sdk/src/cmp/py/TestClean_py.ts +10 -3
- package/project/.sdk/src/cmp/rb/TestClean_rb.ts +10 -3
- package/project/.sdk/src/cmp/rust/TestClean_rust.ts +10 -0
- package/project/.sdk/src/cmp/scala/TestClean_scala.ts +34 -0
- package/project/.sdk/src/cmp/swift/TestClean_swift.ts +20 -10
- package/project/.sdk/src/cmp/ts/TestClean_ts.ts +13 -5
- package/project/.sdk/src/cmp/zig/TestClean_zig.ts +12 -0
- 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/debug.c +1 -0
- package/project/.sdk/tm/c/feature/secrets.c +27 -38
- package/project/.sdk/tm/c/feature/telemetry.c +1 -0
- package/project/.sdk/tm/c/tests/feature_test.c +142 -0
- package/project/.sdk/tm/c/utility/clean.c +26 -33
- package/project/.sdk/tm/c/utility/make_options.c +9 -8
- 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 +19 -11
- package/project/.sdk/tm/clojure/src/sdk/features.clj +83 -10
- package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +47 -0
- 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 +11 -4
- package/project/.sdk/tm/cpp/feature/audit.hpp +6 -7
- package/project/.sdk/tm/cpp/feature/cache.hpp +188 -9
- package/project/.sdk/tm/cpp/feature/debug.hpp +1 -0
- package/project/.sdk/tm/cpp/feature/secrets.hpp +12 -0
- package/project/.sdk/tm/cpp/feature/telemetry.hpp +1 -0
- package/project/.sdk/tm/cpp/test/feature_test.cpp +128 -0
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +9 -7
- package/project/.sdk/tm/csharp/core/Context.cs +4 -0
- package/project/.sdk/tm/csharp/feature/CacheFeature.cs +126 -12
- package/project/.sdk/tm/csharp/feature/DebugFeature.cs +1 -0
- package/project/.sdk/tm/csharp/feature/SecretsFeature.cs +9 -27
- package/project/.sdk/tm/csharp/feature/TelemetryFeature.cs +1 -0
- package/project/.sdk/tm/csharp/test/FeatureTest.cs +101 -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 +5 -12
- 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/debug.ex +1 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/secrets.ex +10 -56
- package/project/.sdk/tm/elixir/lib/projectname/feature/telemetry.ex +1 -0
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +18 -12
- package/project/.sdk/tm/elixir/test/feature_test.exs +84 -0
- package/project/.sdk/tm/go/core/context.go +6 -0
- package/project/.sdk/tm/go/feature/cache_feature.go +131 -4
- package/project/.sdk/tm/go/feature/debug_feature.go +3 -2
- package/project/.sdk/tm/go/feature/secrets_feature.go +17 -71
- package/project/.sdk/tm/go/feature/telemetry_feature.go +5 -4
- package/project/.sdk/tm/go/test/feature_corpus_test.go +150 -2
- package/project/.sdk/tm/go/test/feature_test.go +101 -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 +5 -7
- package/project/.sdk/tm/java/core/Context.java +9 -0
- package/project/.sdk/tm/java/feature/CacheFeature.java +123 -17
- package/project/.sdk/tm/java/feature/DebugFeature.java +1 -0
- package/project/.sdk/tm/java/feature/SecretsFeature.java +9 -92
- package/project/.sdk/tm/java/feature/TelemetryFeature.java +1 -0
- package/project/.sdk/tm/java/test/FeatureCorpusTest.java +141 -2
- package/project/.sdk/tm/java/test/FeatureTest.java +88 -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 +3 -1
- 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/debug/DebugFeature.js +1 -0
- package/project/.sdk/tm/js/src/feature/metrics/MetricsFeature.js +1 -1
- package/project/.sdk/tm/js/src/feature/paging/PagingFeature.js +4 -4
- package/project/.sdk/tm/js/src/feature/rbac/RbacFeature.js +4 -4
- package/project/.sdk/tm/js/src/feature/secrets/SecretsFeature.js +16 -6
- package/project/.sdk/tm/js/src/feature/telemetry/TelemetryFeature.js +1 -0
- 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 +6 -6
- package/project/.sdk/tm/js/test/feature/Corpus.test.js +100 -2
- package/project/.sdk/tm/js/test/feature/harness.js +3 -3
- package/project/.sdk/tm/js/test/feature.test.js +17 -0
- 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/feature/CacheFeature.kt +102 -7
- package/project/.sdk/tm/kotlin/feature/DebugFeature.kt +1 -0
- package/project/.sdk/tm/kotlin/feature/SecretsFeature.kt +10 -20
- package/project/.sdk/tm/kotlin/feature/TelemetryFeature.kt +1 -0
- package/project/.sdk/tm/kotlin/test/FeatureTest.kt +79 -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 +3 -1
- 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 +1 -0
- package/project/.sdk/tm/lua/feature/secrets_feature.lua +15 -80
- package/project/.sdk/tm/lua/feature/telemetry_feature.lua +1 -0
- package/project/.sdk/tm/lua/test/feature_test.lua +108 -0
- 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 +5 -5
- package/project/.sdk/tm/ocaml/feature/secrets_feature.ml +21 -6
- package/project/.sdk/tm/ocaml/sdk_features.ml +108 -8
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +13 -10
- package/project/.sdk/tm/ocaml/sdk_types.ml +2 -0
- package/project/.sdk/tm/ocaml/test/t_feature.ml +51 -1
- 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 +1 -0
- package/project/.sdk/tm/perl/feature/secrets_feature.pm +13 -18
- package/project/.sdk/tm/perl/feature/telemetry_feature.pm +1 -0
- package/project/.sdk/tm/perl/t/feature.t +86 -0
- package/project/.sdk/tm/perl/t/feature_corpus.t +80 -4
- 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 +5 -5
- 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/DebugFeature.php +1 -0
- package/project/.sdk/tm/php/feature/SecretsFeature.php +18 -15
- package/project/.sdk/tm/php/feature/TelemetryFeature.php +1 -0
- package/project/.sdk/tm/php/test/FeatureCorpusTest.php +113 -3
- package/project/.sdk/tm/php/test/FeatureTest.php +90 -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 +5 -7
- 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/debug_feature.py +1 -0
- package/project/.sdk/tm/py/pkg/feature/secrets_feature.py +15 -66
- package/project/.sdk/tm/py/pkg/feature/telemetry_feature.py +1 -0
- package/project/.sdk/tm/py/pkg/utility/clean.py +4 -10
- package/project/.sdk/tm/py/pkg/utility/make_options.py +8 -9
- package/project/.sdk/tm/py/test/feature/secrets/test_secrets.py +23 -9
- package/project/.sdk/tm/py/test/test_feature.py +73 -0
- package/project/.sdk/tm/py/test/test_feature_corpus.py +88 -3
- 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 +1 -0
- package/project/.sdk/tm/rb/feature/secrets_feature.rb +9 -64
- package/project/.sdk/tm/rb/feature/telemetry_feature.rb +1 -0
- package/project/.sdk/tm/rb/test/feature_corpus_test.rb +85 -3
- package/project/.sdk/tm/rb/test/feature_test.rb +93 -0
- 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 +5 -5
- package/project/.sdk/tm/rust/core/context.rs +8 -0
- package/project/.sdk/tm/rust/feature/cache.rs +120 -3
- package/project/.sdk/tm/rust/feature/debug.rs +1 -0
- package/project/.sdk/tm/rust/feature/secrets.rs +36 -98
- package/project/.sdk/tm/rust/feature/telemetry.rs +1 -0
- package/project/.sdk/tm/rust/tests/feature/secrets/main.rs +3 -3
- package/project/.sdk/tm/rust/tests/feature_test.rs +141 -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 +8 -11
- package/project/.sdk/tm/scala/core/Context.scala +4 -0
- package/project/.sdk/tm/scala/feature/CacheFeature.scala +117 -11
- package/project/.sdk/tm/scala/feature/DebugFeature.scala +1 -0
- package/project/.sdk/tm/scala/feature/SecretsFeature.scala +11 -24
- package/project/.sdk/tm/scala/feature/TelemetryFeature.scala +1 -0
- package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +52 -1
- package/project/.sdk/tm/scala/utility/Fetcher.scala +5 -0
- package/project/.sdk/tm/scala/utility/Make.scala +3 -1
- 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/CacheFeature.swift +122 -11
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/DebugFeature.swift +1 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/SecretsFeature.swift +9 -13
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TelemetryFeature.swift +1 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Fetcher.swift +4 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +5 -4
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/ResultUtil.swift +4 -5
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +79 -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/debug/DebugFeature.ts +1 -0
- package/project/.sdk/tm/ts/src/feature/metrics/MetricsFeature.ts +1 -1
- package/project/.sdk/tm/ts/src/feature/paging/PagingFeature.ts +4 -4
- package/project/.sdk/tm/ts/src/feature/rbac/RbacFeature.ts +4 -4
- package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +14 -2
- package/project/.sdk/tm/ts/src/feature/telemetry/TelemetryFeature.ts +1 -0
- 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 +6 -6
- package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +101 -2
- package/project/.sdk/tm/ts/test/feature/harness.ts +3 -3
- package/project/.sdk/tm/ts/test/feature.test.ts +17 -0
- 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 +11 -9
- package/project/.sdk/tm/zig/feature/cache.zig +144 -13
- package/project/.sdk/tm/zig/feature/debug.zig +1 -0
- package/project/.sdk/tm/zig/feature/secrets.zig +6 -1
- package/project/.sdk/tm/zig/feature/telemetry.zig +1 -0
- package/project/.sdk/tm/zig/test/feature_test.zig +100 -0
- package/project/sdkgen-package.json +1 -1
|
@@ -643,6 +643,51 @@ if (has_feature('cache')) {
|
|
|
643
643
|
$h->op('path' => '/x');
|
|
644
644
|
is(scalar @$calls, 2, 'cache inactive does not wrap');
|
|
645
645
|
}
|
|
646
|
+
|
|
647
|
+
{
|
|
648
|
+
my ($server, $calls) = recording_server();
|
|
649
|
+
my $h = harness([fspec('cache', 'ttl' => 10000)], server => $server);
|
|
650
|
+
$h->op('path' => '/w/1', 'headers' => { 'x-tenant' => 'tenant-a' });
|
|
651
|
+
$h->op('path' => '/w/1', 'headers' => { 'X-Tenant' => 'tenant-b' });
|
|
652
|
+
is(scalar @$calls, 2, 'cache keys on the request headers');
|
|
653
|
+
$h->op('path' => '/w/1', 'headers' => { 'x-tenant' => 'tenant-b' });
|
|
654
|
+
is(scalar @$calls, 2, 'cache shares an entry between the same headers');
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
{
|
|
658
|
+
my ($server, $calls) = recording_server();
|
|
659
|
+
my $h = harness([fspec('cache', 'ttl' => 10000)], server => $server);
|
|
660
|
+
my @paths = ('/w/1', '/w', '/w/1/part', '/other/1', '/w/2');
|
|
661
|
+
$h->op('path' => $_) for @paths;
|
|
662
|
+
$h->op('opname' => 'update', 'method' => 'PUT', 'path' => '/w/1');
|
|
663
|
+
$h->op('path' => $_) for @paths;
|
|
664
|
+
is(scalar @$calls, 9, 'cache write drops its collection');
|
|
665
|
+
is($h->track('_cache')->{hit}, 2, 'cache write keeps another entity');
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
for my $control ('no-store', 'private', 'No-Cache', 'max-age=60, private') {
|
|
669
|
+
my ($server, $calls) = recording_server(sub {
|
|
670
|
+
(make_response(200, { 'ok' => 1 }, { 'Cache-Control' => $control }), undef) });
|
|
671
|
+
my $h = harness([fspec('cache', 'ttl' => 10000)], server => $server);
|
|
672
|
+
$h->op('path' => '/w');
|
|
673
|
+
$h->op('path' => '/w');
|
|
674
|
+
is(scalar @$calls, 2, "cache does not store $control");
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
{
|
|
678
|
+
my $clock = HarnessClock->new;
|
|
679
|
+
my ($server, $calls) = recording_server(sub {
|
|
680
|
+
(make_response(200, { 'ok' => 1 }, { 'cache-control' => 'max-age=1' }), undef) });
|
|
681
|
+
my $h = harness([fspec('cache', 'ttl' => 10000, 'now' => $clock->now)],
|
|
682
|
+
server => $server);
|
|
683
|
+
$h->op('path' => '/w');
|
|
684
|
+
$clock->advance(500);
|
|
685
|
+
$h->op('path' => '/w');
|
|
686
|
+
is(scalar @$calls, 1, 'cache serves inside max-age');
|
|
687
|
+
$clock->advance(600);
|
|
688
|
+
$h->op('path' => '/w');
|
|
689
|
+
is(scalar @$calls, 2, 'cache max-age caps the ttl');
|
|
690
|
+
}
|
|
646
691
|
}
|
|
647
692
|
else { note('feature "cache" not present in this SDK') }
|
|
648
693
|
|
|
@@ -883,6 +928,47 @@ if (has_feature('audit')) {
|
|
|
883
928
|
else { note('feature "audit" not present in this SDK') }
|
|
884
929
|
|
|
885
930
|
|
|
931
|
+
# === per-call state ===
|
|
932
|
+
|
|
933
|
+
{
|
|
934
|
+
my @names = grep { has_feature($_) } qw(audit debug telemetry metrics cost);
|
|
935
|
+
if (has_feature('netsim') && @names) {
|
|
936
|
+
my $h = harness([fspec('netsim', 'failEvery' => 2, 'failStatus' => 500),
|
|
937
|
+
map { fspec($_) } @names]);
|
|
938
|
+
$h->op('path' => "/w/$_") for 1 .. 20;
|
|
939
|
+
for my $name (@names) {
|
|
940
|
+
my $f = $h->feature($name);
|
|
941
|
+
for my $table (qw(seen entries spans starts pending)) {
|
|
942
|
+
next unless ref($f->{$table}) eq 'HASH';
|
|
943
|
+
is(scalar(keys %{ $f->{$table} }), 0,
|
|
944
|
+
"$name $table holds no call after 20 calls");
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
is(scalar @{ $h->track('_audit')->{records} }, 20, 'audit records every one of 20 calls')
|
|
948
|
+
if grep { 'audit' eq $_ } @names;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
# === one call, one id ===
|
|
953
|
+
|
|
954
|
+
if (has_feature('telemetry') && has_feature('debug') && has_feature('audit')) {
|
|
955
|
+
my $h = harness([fspec('telemetry'), fspec('debug'), fspec('audit')]);
|
|
956
|
+
$h->op;
|
|
957
|
+
$h->op('opname' => 'list');
|
|
958
|
+
my $ids = sub { [map { $_->{correlationId} } @{ $_[0] }] };
|
|
959
|
+
my $calls = $ids->($h->track('_audit')->{records});
|
|
960
|
+
is(scalar @$calls, 2, 'telemetry, debug and audit: two calls audited');
|
|
961
|
+
is(scalar(grep { defined $_ && !ref $_ && '' ne $_ } @$calls), 2,
|
|
962
|
+
'telemetry, debug and audit: each call id is a non-empty string');
|
|
963
|
+
isnt($calls->[0], $calls->[1], 'telemetry, debug and audit: each call has its own id');
|
|
964
|
+
is_deeply($ids->($h->track('_telemetry')->{spans}), $calls,
|
|
965
|
+
'telemetry, debug and audit: spans carry the call ids');
|
|
966
|
+
is_deeply($ids->($h->track('_debug')->{entries}), $calls,
|
|
967
|
+
'telemetry, debug and audit: debug entries carry the call ids');
|
|
968
|
+
}
|
|
969
|
+
else { note('feature "telemetry", "debug" or "audit" not present in this SDK') }
|
|
970
|
+
|
|
971
|
+
|
|
886
972
|
# === clienttrack ===
|
|
887
973
|
|
|
888
974
|
if (has_feature('clienttrack')) {
|
|
@@ -20,6 +20,7 @@ use FindBin;
|
|
|
20
20
|
use lib "$FindBin::Bin/../lib";
|
|
21
21
|
use Cwd ();
|
|
22
22
|
use Scalar::Util ();
|
|
23
|
+
use Time::HiRes ();
|
|
23
24
|
|
|
24
25
|
use ProjectNameSDK;
|
|
25
26
|
|
|
@@ -162,11 +163,25 @@ sub candidates {
|
|
|
162
163
|
|
|
163
164
|
|
|
164
165
|
sub invoke {
|
|
165
|
-
my ($client, $op, $ctrl) = @_;
|
|
166
|
+
my ($client, $op, $ctrl, $args) = @_;
|
|
166
167
|
my $acc = $op->{accessor};
|
|
167
168
|
my $fn = $op->{op};
|
|
168
169
|
my $ent = $client->$acc();
|
|
169
|
-
return $ent->$fn({}, $ctrl);
|
|
170
|
+
return $ent->$fn({ %{ $args || {} } }, $ctrl);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
my %ITEM_ARGS = (id => 'corpus-item');
|
|
175
|
+
|
|
176
|
+
# A write of one entity (#ITEM) that completes when driven with %ITEM_ARGS.
|
|
177
|
+
sub usable_item {
|
|
178
|
+
my ($accessor) = @_;
|
|
179
|
+
for my $cand (candidates(build_client({}))) {
|
|
180
|
+
next unless $cand->{accessor} eq $accessor && grep { $_ eq $cand->{op} } qw(update patch remove);
|
|
181
|
+
next unless eval { invoke(build_client({}), $cand, {}, \%ITEM_ARGS); 1 };
|
|
182
|
+
return $cand;
|
|
183
|
+
}
|
|
184
|
+
return undef;
|
|
170
185
|
}
|
|
171
186
|
|
|
172
187
|
|
|
@@ -212,6 +227,43 @@ sub resolve {
|
|
|
212
227
|
}
|
|
213
228
|
|
|
214
229
|
|
|
230
|
+
# A read and a write of one entity (#READ, #WRITE), each driven as usable_ops
|
|
231
|
+
# drives an op.
|
|
232
|
+
sub usable_pair {
|
|
233
|
+
my %found;
|
|
234
|
+
for my $cand (candidates(build_client({}))) {
|
|
235
|
+
my $role = (grep { $_ eq $cand->{op} } qw(list load)) ? 'read'
|
|
236
|
+
: (grep { $_ eq $cand->{op} } qw(create update patch remove)) ? 'write' : undef;
|
|
237
|
+
next unless defined $role;
|
|
238
|
+
my $seen = $found{ $cand->{accessor} } ||= {};
|
|
239
|
+
next if $seen->{$role};
|
|
240
|
+
next unless eval { invoke(build_client({}), $cand, {}); 1 };
|
|
241
|
+
$seen->{$role} = $cand;
|
|
242
|
+
return $seen if $seen->{read} && $seen->{write};
|
|
243
|
+
}
|
|
244
|
+
return undef;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
# One step: it may wait before its call, may add request headers for its
|
|
249
|
+
# call, and may pass `args` as the operation's first argument.
|
|
250
|
+
sub step_call {
|
|
251
|
+
my ($client, $op, $step, $ctrl) = @_;
|
|
252
|
+
Time::HiRes::sleep($step->{wait} / 1000) if defined $step->{wait};
|
|
253
|
+
my $args = Voxgig::Struct::ismap($step->{args}) ? $step->{args} : {};
|
|
254
|
+
return invoke($client, $op, $ctrl, $args) unless Voxgig::Struct::ismap($step->{headers});
|
|
255
|
+
my $options = $client->{options};
|
|
256
|
+
my $had = exists $options->{headers};
|
|
257
|
+
my $prior = $options->{headers};
|
|
258
|
+
$options->{headers} = { %{ $prior || {} }, %{ $step->{headers} } };
|
|
259
|
+
my $ok = eval { invoke($client, $op, $ctrl, $args); 1 };
|
|
260
|
+
my $err = $@;
|
|
261
|
+
if ($had) { $options->{headers} = $prior } else { delete $options->{headers} }
|
|
262
|
+
die $err unless $ok;
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
|
|
215
267
|
# The highest #OPn a case mentions.
|
|
216
268
|
sub tokens_used {
|
|
217
269
|
my ($kase) = @_;
|
|
@@ -304,6 +356,9 @@ sub missing_feature {
|
|
|
304
356
|
|
|
305
357
|
|
|
306
358
|
my @ops = usable_ops(2);
|
|
359
|
+
my $pair = usable_pair();
|
|
360
|
+
my $item = $pair ? usable_item($pair->{read}{accessor}) : undef;
|
|
361
|
+
my ($other) = $pair ? grep { $_->{accessor} ne $pair->{read}{accessor} } @ops : ();
|
|
307
362
|
|
|
308
363
|
# At least one operation, or every case would skip and this file would report
|
|
309
364
|
# green having run nothing.
|
|
@@ -333,7 +388,7 @@ for my $name (sort keys %{ $CORPUS->{feature} || {} }) {
|
|
|
333
388
|
next;
|
|
334
389
|
}
|
|
335
390
|
|
|
336
|
-
my %by_key = map { $_->{key} => $_ } @ops;
|
|
391
|
+
my %by_key = map { $_->{key} => $_ } @ops, ($pair ? values %$pair : ()), ($item ? $item : ());
|
|
337
392
|
|
|
338
393
|
my $ran = 0;
|
|
339
394
|
for my $raw (@$cases) {
|
|
@@ -344,6 +399,21 @@ for my $name (sort keys %{ $CORPUS->{feature} || {} }) {
|
|
|
344
399
|
next;
|
|
345
400
|
}
|
|
346
401
|
|
|
402
|
+
my $paired = Voxgig::Struct::stringify($raw) =~ /#(READ|WRITE|ITEM|OTHER)\b/;
|
|
403
|
+
if ($paired && !$pair) {
|
|
404
|
+
diag(sprintf('skip "%s": needs a read and a write of one entity, this SDK offers none',
|
|
405
|
+
$raw->{name} // ''));
|
|
406
|
+
next;
|
|
407
|
+
}
|
|
408
|
+
my ($lacking) = grep {
|
|
409
|
+
my ($tok, $found) = @$_;
|
|
410
|
+
$paired && !$found && Voxgig::Struct::stringify($raw) =~ /\Q$tok\E\b/
|
|
411
|
+
} (['#ITEM', $item], ['#OTHER', $other]);
|
|
412
|
+
if ($lacking) {
|
|
413
|
+
diag(sprintf('skip "%s": needs %s, which this SDK cannot drive', $raw->{name} // '', $lacking->[0]));
|
|
414
|
+
next;
|
|
415
|
+
}
|
|
416
|
+
|
|
347
417
|
my $missing = missing_feature($raw, \%have);
|
|
348
418
|
if (defined $missing) {
|
|
349
419
|
diag(sprintf('skip "%s": needs the %s feature, which this SDK does not generate',
|
|
@@ -355,6 +425,12 @@ for my $name (sort keys %{ $CORPUS->{feature} || {} }) {
|
|
|
355
425
|
for my $i (0 .. $need - 1) {
|
|
356
426
|
$tokens{ '#OP' . ($i + 1) } = $ops[$i]{key};
|
|
357
427
|
}
|
|
428
|
+
if ($paired) {
|
|
429
|
+
$tokens{'#READ'} = $pair->{read}{key};
|
|
430
|
+
$tokens{'#WRITE'} = $pair->{write}{key};
|
|
431
|
+
$tokens{'#ITEM'} = $item->{key} if $item;
|
|
432
|
+
$tokens{'#OTHER'} = $other->{key} if $other;
|
|
433
|
+
}
|
|
358
434
|
my $kase = resolve($raw, \%tokens);
|
|
359
435
|
my $label = $kase->{name} || '';
|
|
360
436
|
$ran++;
|
|
@@ -369,7 +445,7 @@ for my $name (sort keys %{ $CORPUS->{feature} || {} }) {
|
|
|
369
445
|
my $ctrl = $step->{ctrl} || {};
|
|
370
446
|
my $wanterr = $step->{err};
|
|
371
447
|
|
|
372
|
-
my $ok = eval {
|
|
448
|
+
my $ok = eval { step_call($client, $op, $step, $ctrl); 1 };
|
|
373
449
|
my $err = $@;
|
|
374
450
|
|
|
375
451
|
if (!defined $wanterr) {
|
|
@@ -69,16 +69,14 @@ sub count {
|
|
|
69
69
|
return $n < 0 ? $dflt : $n;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
# The
|
|
73
|
-
#
|
|
74
|
-
#
|
|
75
|
-
#
|
|
72
|
+
# The registry make_options builds; a context without one (make_error is
|
|
73
|
+
# reached with a bare one) falls back to the schema defaults, so nothing
|
|
74
|
+
# leaves raw for want of a constructor. A plain hash stands in for a context
|
|
75
|
+
# before one exists (make_options).
|
|
76
76
|
sub config {
|
|
77
77
|
my ($ctx) = @_;
|
|
78
|
-
my $
|
|
79
|
-
? $ctx->{
|
|
80
|
-
my $derived = Voxgig::Struct::ismap($opts) ? $opts->{__derived__} : undef;
|
|
81
|
-
my $cfg = Voxgig::Struct::ismap($derived) ? $derived->{clean} : undef;
|
|
78
|
+
my $cfg = (defined $ctx && ref $ctx && (Scalar::Util::reftype($ctx) // '') eq 'HASH')
|
|
79
|
+
? $ctx->{cleancfg} : undef;
|
|
82
80
|
return $cfg if Voxgig::Struct::ismap($cfg) && Voxgig::Struct::islist($cfg->{values});
|
|
83
81
|
return make_config(ProjectNameSchema::optspec()->{clean});
|
|
84
82
|
}
|
|
@@ -162,6 +162,10 @@ sub _send_once {
|
|
|
162
162
|
$new_args{http_proxy} = $new_args{https_proxy} = "$fetchdef->{proxy}"
|
|
163
163
|
if defined $fetchdef->{proxy} && !ref $fetchdef->{proxy}
|
|
164
164
|
&& length $fetchdef->{proxy};
|
|
165
|
+
# A bound in milliseconds, for a caller beneath the timeout feature.
|
|
166
|
+
$new_args{timeout} = $fetchdef->{timeout} / 1000
|
|
167
|
+
if defined $fetchdef->{timeout} && !ref $fetchdef->{timeout}
|
|
168
|
+
&& $fetchdef->{timeout} =~ /\A\d+(?:\.\d+)?\z/ && $fetchdef->{timeout} > 0;
|
|
165
169
|
|
|
166
170
|
# A request that got no answer fails the operation.
|
|
167
171
|
my $res = eval { _http_client(%new_args)->request($method, $fullurl, $opts) };
|
|
@@ -102,7 +102,7 @@ $REGISTRY{make_options} = sub {
|
|
|
102
102
|
(Voxgig::Struct::clone(ProjectNameSchema::optspec()->{clean}),
|
|
103
103
|
Voxgig::Struct::clone($cfgopts->{clean}), $opts->{clean}),
|
|
104
104
|
]));
|
|
105
|
-
my $cleanctx = { '
|
|
105
|
+
my $cleanctx = { 'cleancfg' => $cleancfg };
|
|
106
106
|
my %rawscan = %$opts;
|
|
107
107
|
delete $rawscan{clean};
|
|
108
108
|
ProjectNameCleanSupport::add_options($cleanctx, \%rawscan);
|
|
@@ -233,10 +233,10 @@ $REGISTRY{make_options} = sub {
|
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
$opts->{__derived__} = {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
};
|
|
236
|
+
$opts->{__derived__} = { 'featureorder' => \@featureorder };
|
|
237
|
+
|
|
238
|
+
# Beside the options, not in them: options_map hands them to callers.
|
|
239
|
+
$ctx->{cleancfg} = $cleancfg;
|
|
240
240
|
|
|
241
241
|
# Again over the merged result: the config's own defaults can carry one.
|
|
242
242
|
# The extend instances are live objects, not option data.
|
|
@@ -22,6 +22,8 @@ class ProjectNameContext implements \JsonSerializable
|
|
|
22
22
|
public ?array $config;
|
|
23
23
|
public ?array $entopts;
|
|
24
24
|
public ?array $options;
|
|
25
|
+
// The clean registry, beside the options rather than in them.
|
|
26
|
+
public ?\stdClass $cleancfg = null;
|
|
25
27
|
public mixed $entity;
|
|
26
28
|
public ?array $shared;
|
|
27
29
|
public array $opmap;
|
|
@@ -77,6 +79,8 @@ class ProjectNameContext implements \JsonSerializable
|
|
|
77
79
|
|
|
78
80
|
$o = ProjectNameHelpers::get_ctx_prop($ctxmap, 'options');
|
|
79
81
|
$this->options = is_array($o) ? $o : ($basectx ? $basectx->options : null);
|
|
82
|
+
$cc = ProjectNameHelpers::get_ctx_prop($ctxmap, 'cleancfg');
|
|
83
|
+
$this->cleancfg = $cc instanceof \stdClass ? $cc : ($basectx ? $basectx->cleancfg : null);
|
|
80
84
|
|
|
81
85
|
$e = ProjectNameHelpers::get_ctx_prop($ctxmap, 'entity');
|
|
82
86
|
$this->entity = $e ?? ($basectx ? $basectx->entity : null);
|
|
@@ -6,20 +6,18 @@ declare(strict_types=1);
|
|
|
6
6
|
require_once __DIR__ . '/BaseFeature.php';
|
|
7
7
|
require_once __DIR__ . '/../utility/Media.php';
|
|
8
8
|
|
|
9
|
-
// Response caching for safe (read) requests
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
// successful (2xx) responses to cacheable methods (default: GET) are
|
|
13
|
-
// stored, keyed by method+URL. The cache is bounded (`max` entries, default
|
|
14
|
-
// 256, oldest evicted first) and every hit/miss/bypass is recorded on
|
|
15
|
-
// `client->_cache` for inspection. Snapshots replay through a fresh `json`
|
|
16
|
-
// closure so both the current caller and later hits can read the body
|
|
17
|
-
// repeatedly. Mirrors ts/src/feature/cache/CacheFeature.ts.
|
|
9
|
+
// Response caching for safe (read) requests, per client: see the features
|
|
10
|
+
// reference for the key, the write invalidation and the Cache-Control rules.
|
|
11
|
+
// Mirrors ts/src/feature/cache/CacheFeature.ts.
|
|
18
12
|
class ProjectNameCacheFeature extends ProjectNameBaseFeature
|
|
19
13
|
{
|
|
14
|
+
private const SAFE_METHODS = ['GET', 'HEAD'];
|
|
15
|
+
private const UNSTORED = ['no-store', 'private', 'no-cache'];
|
|
16
|
+
|
|
20
17
|
private mixed $client;
|
|
21
18
|
private ?array $options;
|
|
22
19
|
private array $store;
|
|
20
|
+
private string $secret = '';
|
|
23
21
|
|
|
24
22
|
public function __construct()
|
|
25
23
|
{
|
|
@@ -43,6 +41,7 @@ class ProjectNameCacheFeature extends ProjectNameBaseFeature
|
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
$this->store = [];
|
|
44
|
+
$this->secret = random_bytes(32);
|
|
46
45
|
|
|
47
46
|
$utility = $ctx->utility;
|
|
48
47
|
$inner = $utility->fetcher;
|
|
@@ -58,10 +57,17 @@ class ProjectNameCacheFeature extends ProjectNameBaseFeature
|
|
|
58
57
|
$methods = $this->options['methods'] ?? ['GET'];
|
|
59
58
|
|
|
60
59
|
if (!is_array($methods) || !in_array($method, $methods, true)) {
|
|
61
|
-
|
|
60
|
+
if (in_array($method, self::SAFE_METHODS, true)) {
|
|
61
|
+
return $inner($ctx, $url, $fetchdef);
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
return $inner($ctx, $url, $fetchdef);
|
|
65
|
+
} finally {
|
|
66
|
+
$this->_invalidate($url);
|
|
67
|
+
}
|
|
62
68
|
}
|
|
63
69
|
|
|
64
|
-
$key = $method . ' ' . $url;
|
|
70
|
+
$key = $method . ' ' . $url . ' ' . $this->_digest($fetchdef['headers'] ?? null);
|
|
65
71
|
$now = $this->_now();
|
|
66
72
|
$hit = $this->store[$key] ?? null;
|
|
67
73
|
|
|
@@ -80,9 +86,15 @@ class ProjectNameCacheFeature extends ProjectNameBaseFeature
|
|
|
80
86
|
|
|
81
87
|
if ($this->_cacheable($res, $err)) {
|
|
82
88
|
$snapshot = $this->_snapshot($res);
|
|
83
|
-
$ttl =
|
|
89
|
+
$ttl = self::lifetime($snapshot['headers'],
|
|
90
|
+
is_numeric($this->options['ttl'] ?? null) ? (float)$this->options['ttl'] : 5000.0);
|
|
91
|
+
if ($ttl <= 0) {
|
|
92
|
+
$this->_track('bypass');
|
|
93
|
+
return [$this->_replay($snapshot), null];
|
|
94
|
+
}
|
|
95
|
+
unset($this->store[$key]);
|
|
84
96
|
$this->_evict();
|
|
85
|
-
$this->store[$key] = ['expiry' => $now + $ttl, 'snapshot' => $snapshot];
|
|
97
|
+
$this->store[$key] = ['expiry' => $now + $ttl, 'scope' => self::scope($url), 'snapshot' => $snapshot];
|
|
86
98
|
$this->_track('miss');
|
|
87
99
|
return [$this->_replay($snapshot), null];
|
|
88
100
|
}
|
|
@@ -91,6 +103,79 @@ class ProjectNameCacheFeature extends ProjectNameBaseFeature
|
|
|
91
103
|
return [$res, $err];
|
|
92
104
|
}
|
|
93
105
|
|
|
106
|
+
private function _digest(mixed $headers): string
|
|
107
|
+
{
|
|
108
|
+
$pairs = [];
|
|
109
|
+
if (is_array($headers)) {
|
|
110
|
+
foreach ($headers as $name => $val) {
|
|
111
|
+
if ($val !== null) {
|
|
112
|
+
$pairs[] = [strtolower((string)$name), is_scalar($val) ? (string)$val : json_encode($val)];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
usort($pairs, fn($a, $b) => strcmp($a[0], $b[0]) ?: strcmp($a[1], $b[1]));
|
|
117
|
+
$text = '';
|
|
118
|
+
foreach ($pairs as [$name, $val]) {
|
|
119
|
+
$text .= $name . ':' . $val . "\n";
|
|
120
|
+
}
|
|
121
|
+
return hash_hmac('sha256', $text, $this->secret);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private function _invalidate(string $url): void
|
|
125
|
+
{
|
|
126
|
+
$path = self::scope($url);
|
|
127
|
+
$collection = self::parent($path);
|
|
128
|
+
foreach ($this->store as $key => $entry) {
|
|
129
|
+
if (self::under($entry['scope'], $path) || $entry['scope'] === $collection) {
|
|
130
|
+
unset($this->store[$key]);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// The configured ttl capped by the response's Cache-Control; zero when
|
|
136
|
+
// the response may not be stored.
|
|
137
|
+
private static function lifetime(array $headers, float $ttl): float
|
|
138
|
+
{
|
|
139
|
+
$control = '';
|
|
140
|
+
foreach ($headers as $name => $val) {
|
|
141
|
+
if (strtolower((string)$name) === 'cache-control') {
|
|
142
|
+
$control = strtolower((string)$val);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
$life = $ttl;
|
|
146
|
+
foreach (explode(',', $control) as $part) {
|
|
147
|
+
$directive = trim($part);
|
|
148
|
+
if (in_array($directive, self::UNSTORED, true)) {
|
|
149
|
+
return 0.0;
|
|
150
|
+
}
|
|
151
|
+
if (preg_match('/^max-age\s*=\s*"?(\d+)"?$/', $directive, $age)) {
|
|
152
|
+
$life = min($life, (float)$age[1] * 1000.0);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return $life;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
private static function scope(string $url): string
|
|
159
|
+
{
|
|
160
|
+
return rtrim(preg_split('/[?#]/', $url, 2)[0], '/');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
private static function parent(string $scope): string
|
|
164
|
+
{
|
|
165
|
+
$scheme = strpos($scope, '://');
|
|
166
|
+
$root = $scheme === false ? 0 : strpos($scope, '/', $scheme + 3);
|
|
167
|
+
if ($root === false) {
|
|
168
|
+
return $scope;
|
|
169
|
+
}
|
|
170
|
+
$cut = strrpos($scope, '/');
|
|
171
|
+
return substr($scope, 0, max($cut === false ? 0 : $cut, $root));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private static function under(string $scope, string $prefix): bool
|
|
175
|
+
{
|
|
176
|
+
return $scope === $prefix || str_starts_with($scope, $prefix . '/');
|
|
177
|
+
}
|
|
178
|
+
|
|
94
179
|
private function _cacheable(mixed $res, mixed $err): bool
|
|
95
180
|
{
|
|
96
181
|
// A body the transport could not read as JSON passes through, for the operation to report.
|
|
@@ -55,6 +55,7 @@ class ProjectNameDebugFeature extends ProjectNameBaseFeature
|
|
|
55
55
|
$entry = [
|
|
56
56
|
'op' => ($ctx->op->entity !== '' ? $ctx->op->entity : '_')
|
|
57
57
|
. '.' . ($ctx->op->name !== '' ? $ctx->op->name : '_'),
|
|
58
|
+
'correlationId' => $ctx->id,
|
|
58
59
|
'method' => $spec !== null ? $spec->method : null,
|
|
59
60
|
'url' => $spec !== null ? ($spec->url !== '' ? $spec->url : $spec->path) : null,
|
|
60
61
|
'headers' => $this->_redact($ctx, $spec !== null ? $spec->headers : null),
|
|
@@ -313,6 +313,9 @@ class ProjectNameSecretsFeature extends ProjectNameBaseFeature
|
|
|
313
313
|
// gets. A provider ERROR refuses the request with the provider's
|
|
314
314
|
// own message; never an unauthenticated send.
|
|
315
315
|
$err = $this->resolve();
|
|
316
|
+
if ($err instanceof ProjectNameError) {
|
|
317
|
+
return [null, $err];
|
|
318
|
+
}
|
|
316
319
|
if (null !== $err) {
|
|
317
320
|
return [null, $ctx->make_error('secrets_provider', $err->getMessage())];
|
|
318
321
|
}
|
|
@@ -534,17 +537,10 @@ class ProjectNameSecretsFeature extends ProjectNameBaseFeature
|
|
|
534
537
|
$base = is_string($base) ? rtrim($base, '/') : '';
|
|
535
538
|
$url = $base . '/' . ltrim($x['path'], '/');
|
|
536
539
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
// make_options leaves system.fetch unset, so the exchange gets
|
|
542
|
-
// the SDK's own default HTTP path. That static consults neither
|
|
543
|
-
// system.fetch nor the wrapper chain, so there is no recursion,
|
|
544
|
-
// and it already answers the ['status' => .., 'json' => ..]
|
|
545
|
-
// shape read below.
|
|
546
|
-
$fetch = [ProjectNameFetcher::class, 'defaultHttpFetch'];
|
|
547
|
-
}
|
|
540
|
+
// The SDK's own transport, beneath every feature's wrapper: it holds
|
|
541
|
+
// the test feature's block and the GET-only guard.
|
|
542
|
+
$rootctx = $this->rootctx;
|
|
543
|
+
$fetch = static fn (string $at, array $fd): array => ProjectNameFetcher::call($rootctx, $at, $fd);
|
|
548
544
|
|
|
549
545
|
// The body is ENCODED, never concatenated: a refresh token (or a
|
|
550
546
|
// configured request-field name) carrying a quote, backslash or
|
|
@@ -555,16 +551,18 @@ class ProjectNameSecretsFeature extends ProjectNameBaseFeature
|
|
|
555
551
|
'secrets: token exchange request could not be encoded');
|
|
556
552
|
}
|
|
557
553
|
|
|
558
|
-
// Deliberately NOT the
|
|
559
|
-
//
|
|
560
|
-
//
|
|
561
|
-
//
|
|
554
|
+
// Deliberately NOT the wrapped transport: sending the token request
|
|
555
|
+
// back through it would recurse on the first expiry - and would
|
|
556
|
+
// route the exchange through the test mock, which knows nothing
|
|
557
|
+
// about it.
|
|
562
558
|
$fetchdef = [
|
|
563
559
|
'method' => $x['method'],
|
|
564
560
|
'headers' => ['content-type' => 'application/json'],
|
|
565
561
|
'body' => $body,
|
|
566
562
|
// Never followed by the client: a redirect would carry the refresh token on.
|
|
567
563
|
'redirect' => 'manual',
|
|
564
|
+
// Its own bound, in milliseconds: the timeout feature's wrapper is above it.
|
|
565
|
+
'timeout' => 30000,
|
|
568
566
|
];
|
|
569
567
|
|
|
570
568
|
[$res, $err] = $fetch($url, $fetchdef);
|
|
@@ -580,6 +578,11 @@ class ProjectNameSecretsFeature extends ProjectNameBaseFeature
|
|
|
580
578
|
[$res, $err] = $fetch($at, $fetchdef);
|
|
581
579
|
}
|
|
582
580
|
|
|
581
|
+
// The transport's own refusal, the GET-only guard's among them, is
|
|
582
|
+
// the operation's error.
|
|
583
|
+
if ($err instanceof ProjectNameError) {
|
|
584
|
+
throw $err;
|
|
585
|
+
}
|
|
583
586
|
if (null !== $err) {
|
|
584
587
|
throw new \Voxgig\Sekreto\SekretoError(
|
|
585
588
|
'secrets: token exchange failed: ' . self::errtext($err) . ' from ' . $url);
|
|
@@ -58,6 +58,7 @@ class ProjectNameTelemetryFeature extends ProjectNameBaseFeature
|
|
|
58
58
|
$span = [
|
|
59
59
|
'traceId' => $this->_id('trace'),
|
|
60
60
|
'spanId' => $this->_id('span'),
|
|
61
|
+
'correlationId' => $ctx->id,
|
|
61
62
|
'name' => ($ctx->op->entity !== '' ? $ctx->op->entity : '_')
|
|
62
63
|
. '.' . ($ctx->op->name !== '' ? $ctx->op->name : '_'),
|
|
63
64
|
'start' => $this->_now(),
|