@voxgig/sdkgen 4.32.1 → 4.34.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/action/copies.d.ts +21 -0
- package/dist/action/copies.js +146 -0
- package/dist/action/copies.js.map +1 -0
- package/dist/action/doctor.d.ts +15 -2
- package/dist/action/doctor.js +169 -23
- package/dist/action/doctor.js.map +1 -1
- package/dist/action/edition.js +6 -2
- package/dist/action/edition.js.map +1 -1
- package/dist/action/feature.js +6 -2
- package/dist/action/feature.js.map +1 -1
- package/dist/action/package.js +28 -10
- package/dist/action/package.js.map +1 -1
- package/dist/action/remove.js +2 -0
- package/dist/action/remove.js.map +1 -1
- package/dist/action/resolve.d.ts +1 -0
- package/dist/action/resolve.js +10 -2
- package/dist/action/resolve.js.map +1 -1
- package/dist/action/target.js +6 -2
- package/dist/action/target.js.map +1 -1
- package/dist/helpers/naming.js +1 -1
- package/dist/helpers/naming.js.map +1 -1
- package/dist/sdkgen.d.ts +2 -1
- package/dist/sdkgen.js +36 -3
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/model/sdkgen.aontu +7 -1
- package/package.json +1 -1
- package/project/.sdk/model/feature/debug.aontu +3 -1
- package/project/.sdk/src/cmp/c/PrepareAuth_c.ts +8 -28
- package/project/.sdk/src/cmp/c/TestClean_c.ts +774 -0
- package/project/.sdk/src/cmp/c/Test_c.ts +3 -0
- package/project/.sdk/src/cmp/c/fragment/Entity.fragment.c +16 -5
- package/project/.sdk/src/cmp/c/fragment/Main.fragment.c +1 -1
- package/project/.sdk/src/cmp/clojure/PrepareAuth_clojure.ts +3 -0
- package/project/.sdk/src/cmp/clojure/TestClean_clojure.ts +473 -0
- package/project/.sdk/src/cmp/clojure/Test_clojure.ts +6 -0
- package/project/.sdk/src/cmp/clojure/fragment/Entity.fragment.clj +18 -8
- package/project/.sdk/src/cmp/cpp/PrepareAuth_cpp.ts +3 -0
- package/project/.sdk/src/cmp/cpp/TestClean_cpp.ts +782 -0
- package/project/.sdk/src/cmp/cpp/TestEntity_cpp.ts +1 -1
- package/project/.sdk/src/cmp/cpp/Test_cpp.ts +2 -0
- package/project/.sdk/src/cmp/csharp/PrepareAuth_csharp.ts +3 -0
- package/project/.sdk/src/cmp/csharp/TestClean_csharp.ts +887 -0
- package/project/.sdk/src/cmp/csharp/Test_csharp.ts +2 -0
- package/project/.sdk/src/cmp/csharp/fragment/EntityBase.fragment.cs +68 -4
- package/project/.sdk/src/cmp/csharp/fragment/Main.fragment.cs +8 -2
- package/project/.sdk/src/cmp/csharp/fragment/SdkError.fragment.cs +49 -0
- package/project/.sdk/src/cmp/elixir/PrepareAuth_elixir.ts +3 -0
- package/project/.sdk/src/cmp/elixir/Schema_elixir.ts +20 -10
- package/project/.sdk/src/cmp/elixir/TestClean_elixir.ts +666 -0
- package/project/.sdk/src/cmp/elixir/Test_elixir.ts +4 -0
- package/project/.sdk/src/cmp/elixir/fragment/Main.fragment.ex +1 -1
- package/project/.sdk/src/cmp/elixir/fragment/Pipeline.fragment.ex +14 -2
- package/project/.sdk/src/cmp/go/PrepareAuth_go.ts +3 -0
- package/project/.sdk/src/cmp/go/TestClean_go.ts +804 -0
- package/project/.sdk/src/cmp/go/Test_go.ts +3 -0
- package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +54 -4
- package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +27 -2
- package/project/.sdk/src/cmp/java/PrepareAuth_java.ts +3 -0
- package/project/.sdk/src/cmp/java/TestClean_java.ts +884 -0
- package/project/.sdk/src/cmp/java/Test_java.ts +2 -0
- package/project/.sdk/src/cmp/java/fragment/EntityBase.fragment.java +56 -11
- package/project/.sdk/src/cmp/java/fragment/SdkError.fragment.java +36 -3
- package/project/.sdk/src/cmp/js/PrepareAuth_js.ts +3 -0
- package/project/.sdk/src/cmp/js/TestClean_js.ts +458 -0
- package/project/.sdk/src/cmp/js/Test_js.ts +2 -0
- package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +5 -4
- package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +7 -1
- package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +7 -1
- package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +7 -1
- package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +7 -1
- package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +7 -1
- package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +11 -2
- package/project/.sdk/src/cmp/js/fragment/SdkError.fragment.js +17 -1
- package/project/.sdk/src/cmp/kotlin/Package_kotlin.ts +5 -0
- package/project/.sdk/src/cmp/kotlin/PrepareAuth_kotlin.ts +3 -0
- package/project/.sdk/src/cmp/kotlin/TestClean_kotlin.ts +654 -0
- package/project/.sdk/src/cmp/kotlin/Test_kotlin.ts +3 -0
- package/project/.sdk/src/cmp/kotlin/fragment/EntityBase.fragment.kt +44 -11
- package/project/.sdk/src/cmp/kotlin/fragment/SdkError.fragment.kt +31 -0
- package/project/.sdk/src/cmp/lua/PrepareAuth_lua.ts +3 -0
- package/project/.sdk/src/cmp/lua/TestClean_lua.ts +769 -0
- package/project/.sdk/src/cmp/lua/Test_lua.ts +3 -0
- package/project/.sdk/src/cmp/lua/fragment/Entity.fragment.lua +77 -1
- package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +49 -2
- package/project/.sdk/src/cmp/ocaml/Entity_ocaml.ts +3 -2
- package/project/.sdk/src/cmp/ocaml/PrepareAuth_ocaml.ts +4 -25
- package/project/.sdk/src/cmp/ocaml/TestClean_ocaml.ts +538 -0
- package/project/.sdk/src/cmp/ocaml/Test_ocaml.ts +5 -0
- package/project/.sdk/src/cmp/ocaml/fragment/RunOp.fragment.ml +16 -4
- package/project/.sdk/src/cmp/perl/PrepareAuth_perl.ts +3 -0
- package/project/.sdk/src/cmp/perl/TestClean_perl.ts +619 -0
- package/project/.sdk/src/cmp/perl/Test_perl.ts +3 -0
- package/project/.sdk/src/cmp/perl/fragment/Entity.fragment.pm +67 -5
- package/project/.sdk/src/cmp/perl/fragment/Main.fragment.pm +13 -1
- package/project/.sdk/src/cmp/php/PrepareAuth_php.ts +3 -0
- package/project/.sdk/src/cmp/php/TestClean_php.ts +809 -0
- package/project/.sdk/src/cmp/php/Test_php.ts +2 -0
- package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +96 -55
- package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +15 -2
- package/project/.sdk/src/cmp/py/PrepareAuth_py.ts +3 -0
- package/project/.sdk/src/cmp/py/TestClean_py.ts +549 -0
- package/project/.sdk/src/cmp/py/Test_py.ts +3 -0
- package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +83 -55
- package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +19 -3
- package/project/.sdk/src/cmp/rb/PrepareAuth_rb.ts +3 -0
- package/project/.sdk/src/cmp/rb/TestClean_rb.ts +535 -0
- package/project/.sdk/src/cmp/rb/Test_rb.ts +3 -0
- package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +108 -46
- package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +12 -1
- package/project/.sdk/src/cmp/rust/PrepareAuth_rust.ts +9 -45
- package/project/.sdk/src/cmp/rust/TestClean_rust.ts +881 -0
- package/project/.sdk/src/cmp/rust/Test_rust.ts +3 -0
- package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +14 -6
- package/project/.sdk/src/cmp/rust/fragment/Main.fragment.rs +17 -1
- package/project/.sdk/src/cmp/rust/fragment/SdkError.fragment.rs +34 -2
- package/project/.sdk/src/cmp/scala/PrepareAuth_scala.ts +3 -0
- package/project/.sdk/src/cmp/scala/TestClean_scala.ts +608 -0
- package/project/.sdk/src/cmp/scala/Test_scala.ts +3 -0
- package/project/.sdk/src/cmp/scala/fragment/EntityBase.fragment.scala +58 -6
- package/project/.sdk/src/cmp/swift/PrepareAuth_swift.ts +3 -0
- package/project/.sdk/src/cmp/swift/TestClean_swift.ts +671 -0
- package/project/.sdk/src/cmp/swift/Test_swift.ts +3 -0
- package/project/.sdk/src/cmp/swift/fragment/EntityBase.fragment.swift +10 -0
- package/project/.sdk/src/cmp/swift/fragment/Main.fragment.swift +16 -2
- package/project/.sdk/src/cmp/swift/fragment/SdkError.fragment.swift +47 -3
- package/project/.sdk/src/cmp/ts/PrepareAuth_ts.ts +3 -0
- package/project/.sdk/src/cmp/ts/TestClean_ts.ts +465 -0
- package/project/.sdk/src/cmp/ts/Test_ts.ts +2 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +5 -4
- package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +7 -1
- package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +7 -1
- package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +7 -1
- package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +7 -1
- package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +7 -1
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +8 -2
- package/project/.sdk/src/cmp/ts/fragment/SdkError.fragment.ts +20 -2
- package/project/.sdk/src/cmp/zig/PrepareAuth_zig.ts +3 -0
- package/project/.sdk/src/cmp/zig/TestClean_zig.ts +791 -0
- package/project/.sdk/src/cmp/zig/Test_zig.ts +5 -0
- package/project/.sdk/src/cmp/zig/fragment/Build.fragment.zig +19 -0
- package/project/.sdk/src/cmp/zig/fragment/Entity.fragment.zig +14 -5
- package/project/.sdk/src/cmp/zig/fragment/Main.fragment.zig +1 -1
- package/project/.sdk/tm/c/core/context.c +25 -0
- package/project/.sdk/tm/c/core/error.c +16 -0
- package/project/.sdk/tm/c/core/sdk.h +22 -0
- package/project/.sdk/tm/c/feature/audit.c +2 -0
- package/project/.sdk/tm/c/feature/cost.c +1 -0
- package/project/.sdk/tm/c/feature/debug.c +19 -29
- package/project/.sdk/tm/c/feature/log.c +21 -2
- package/project/.sdk/tm/c/feature/proxy.c +55 -3
- package/project/.sdk/tm/c/feature/secrets.c +7 -0
- package/project/.sdk/tm/c/feature/telemetry.c +2 -0
- package/project/.sdk/tm/c/tests/feature_test.c +2 -2
- package/project/.sdk/tm/c/utility/clean.c +530 -8
- package/project/.sdk/tm/c/utility/done.c +28 -12
- package/project/.sdk/tm/c/utility/make_error.c +4 -3
- package/project/.sdk/tm/c/utility/make_options.c +71 -45
- package/project/.sdk/tm/clojure/feature/secrets/sdk/feature/secrets.clj +15 -0
- package/project/.sdk/tm/clojure/src/sdk/client.clj +20 -4
- package/project/.sdk/tm/clojure/src/sdk/core.clj +319 -35
- package/project/.sdk/tm/clojure/src/sdk/features.clj +68 -30
- package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +4 -2
- package/project/.sdk/tm/clojure/test/sdk/test/pipeline.clj +47 -20
- package/project/.sdk/tm/clojure/test/sdk/test_runner.clj +4 -0
- package/project/.sdk/tm/cpp/core/types.hpp +93 -3
- package/project/.sdk/tm/cpp/feature/audit.hpp +1 -0
- package/project/.sdk/tm/cpp/feature/cost.hpp +1 -0
- package/project/.sdk/tm/cpp/feature/debug.hpp +20 -12
- package/project/.sdk/tm/cpp/feature/log.hpp +31 -9
- package/project/.sdk/tm/cpp/feature/proxy.hpp +52 -6
- package/project/.sdk/tm/cpp/feature/secrets.hpp +13 -0
- package/project/.sdk/tm/cpp/feature/telemetry.hpp +4 -2
- package/project/.sdk/tm/cpp/test/feature_test.cpp +2 -2
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +426 -51
- package/project/.sdk/tm/csharp/core/Context.cs +32 -0
- package/project/.sdk/tm/csharp/core/Utility.cs +2 -0
- package/project/.sdk/tm/csharp/feature/AuditFeature.cs +1 -0
- package/project/.sdk/tm/csharp/feature/CostFeature.cs +7 -5
- package/project/.sdk/tm/csharp/feature/DebugFeature.cs +19 -16
- package/project/.sdk/tm/csharp/feature/FeatureOptions.cs +16 -0
- package/project/.sdk/tm/csharp/feature/LogFeature.cs +4 -1
- package/project/.sdk/tm/csharp/feature/ProxyFeature.cs +26 -5
- package/project/.sdk/tm/csharp/feature/SecretsFeature.cs +16 -0
- package/project/.sdk/tm/csharp/feature/TelemetryFeature.cs +4 -2
- package/project/.sdk/tm/csharp/test/FeatureTest.cs +2 -2
- package/project/.sdk/tm/csharp/utility/Clean.cs +440 -2
- package/project/.sdk/tm/csharp/utility/Done.cs +27 -11
- package/project/.sdk/tm/csharp/utility/MakeError.cs +19 -8
- package/project/.sdk/tm/csharp/utility/MakeOptions.cs +119 -29
- package/project/.sdk/tm/csharp/utility/MakeResponse.cs +21 -11
- package/project/.sdk/tm/csharp/utility/Register.cs +1 -0
- package/project/.sdk/tm/elixir/lib/projectname/context.ex +19 -0
- package/project/.sdk/tm/elixir/lib/projectname/entity_base.ex +22 -1
- package/project/.sdk/tm/elixir/lib/projectname/error.ex +24 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/audit.ex +2 -2
- package/project/.sdk/tm/elixir/lib/projectname/feature/cost.ex +2 -2
- package/project/.sdk/tm/elixir/lib/projectname/feature/debug.ex +13 -13
- package/project/.sdk/tm/elixir/lib/projectname/feature/log.ex +18 -5
- package/project/.sdk/tm/elixir/lib/projectname/feature/proxy.ex +19 -1
- package/project/.sdk/tm/elixir/lib/projectname/feature/secrets.ex +15 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/telemetry.ex +4 -2
- package/project/.sdk/tm/elixir/lib/projectname/feature.ex +22 -0
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +464 -41
- package/project/.sdk/tm/elixir/test/feature_test.exs +3 -2
- package/project/.sdk/tm/go/core/context.go +42 -0
- package/project/.sdk/tm/go/core/error.go +30 -10
- package/project/.sdk/tm/go/core/utility_type.go +2 -0
- package/project/.sdk/tm/go/feature/audit_feature.go +1 -0
- package/project/.sdk/tm/go/feature/base_feature.go +12 -0
- package/project/.sdk/tm/go/feature/cost_feature.go +2 -2
- package/project/.sdk/tm/go/feature/debug_feature.go +14 -12
- package/project/.sdk/tm/go/feature/log_feature.go +13 -8
- package/project/.sdk/tm/go/feature/proxy_feature.go +26 -6
- package/project/.sdk/tm/go/feature/secrets_feature.go +19 -0
- package/project/.sdk/tm/go/feature/telemetry_feature.go +4 -2
- package/project/.sdk/tm/go/test/feature_test.go +2 -2
- package/project/.sdk/tm/go/utility/clean.go +585 -2
- package/project/.sdk/tm/go/utility/done.go +29 -9
- package/project/.sdk/tm/go/utility/make_error.go +51 -16
- package/project/.sdk/tm/go/utility/make_options.go +77 -36
- package/project/.sdk/tm/go/utility/register.go +12 -0
- package/project/.sdk/tm/java/core/Context.java +29 -0
- package/project/.sdk/tm/java/core/SdkClient.java +4 -2
- package/project/.sdk/tm/java/core/Utility.java +7 -0
- package/project/.sdk/tm/java/feature/AuditFeature.java +6 -0
- package/project/.sdk/tm/java/feature/CostFeature.java +5 -0
- package/project/.sdk/tm/java/feature/DebugFeature.java +25 -14
- package/project/.sdk/tm/java/feature/LogFeature.java +11 -4
- package/project/.sdk/tm/java/feature/ProxyFeature.java +41 -6
- package/project/.sdk/tm/java/feature/SecretsFeature.java +18 -0
- package/project/.sdk/tm/java/feature/TelemetryFeature.java +8 -2
- package/project/.sdk/tm/java/test/FeatureTest.java +2 -2
- package/project/.sdk/tm/java/utility/Clean.java +519 -1
- package/project/.sdk/tm/java/utility/Done.java +1 -1
- package/project/.sdk/tm/java/utility/MakeError.java +5 -1
- package/project/.sdk/tm/java/utility/MakeOptions.java +55 -31
- package/project/.sdk/tm/java/utility/Register.java +4 -0
- package/project/.sdk/tm/js/src/Context.js +5 -1
- package/project/.sdk/tm/js/src/feature/audit/AuditFeature.js +2 -2
- package/project/.sdk/tm/js/src/feature/cost/CostFeature.js +2 -2
- package/project/.sdk/tm/js/src/feature/debug/DebugFeature.js +13 -7
- package/project/.sdk/tm/js/src/feature/log/LogFeature.js +9 -5
- package/project/.sdk/tm/js/src/feature/proxy/ProxyFeature.js +19 -1
- package/project/.sdk/tm/js/src/feature/secrets/SecretsFeature.js +14 -0
- package/project/.sdk/tm/js/src/feature/telemetry/TelemetryFeature.js +4 -2
- package/project/.sdk/tm/js/src/utility/CleanUtility.js +294 -21
- package/project/.sdk/tm/js/src/utility/DoneUtility.js +17 -5
- package/project/.sdk/tm/js/src/utility/MakeErrorUtility.js +18 -2
- package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +39 -15
- package/project/.sdk/tm/js/src/utility/Utility.js +4 -2
- package/project/.sdk/tm/js/test/feature/harness.js +11 -1
- package/project/.sdk/tm/js/test/feature.test.js +9 -2
- package/project/.sdk/tm/kotlin/core/Context.kt +19 -0
- package/project/.sdk/tm/kotlin/core/SdkClient.kt +9 -2
- package/project/.sdk/tm/kotlin/core/Utility.kt +2 -0
- package/project/.sdk/tm/kotlin/feature/AuditFeature.kt +11 -9
- package/project/.sdk/tm/kotlin/feature/CostFeature.kt +8 -5
- package/project/.sdk/tm/kotlin/feature/DebugFeature.kt +15 -22
- package/project/.sdk/tm/kotlin/feature/LogFeature.kt +8 -4
- package/project/.sdk/tm/kotlin/feature/ProxyFeature.kt +26 -2
- package/project/.sdk/tm/kotlin/feature/SecretsFeature.kt +11 -0
- package/project/.sdk/tm/kotlin/feature/TelemetryFeature.kt +4 -2
- package/project/.sdk/tm/kotlin/test/FeatureTest.kt +2 -2
- package/project/.sdk/tm/kotlin/utility/CoreUtil.kt +447 -11
- package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +38 -31
- package/project/.sdk/tm/kotlin/utility/Register.kt +1 -0
- package/project/.sdk/tm/lua/core/context.lua +43 -0
- package/project/.sdk/tm/lua/core/error.lua +36 -1
- package/project/.sdk/tm/lua/core/utility_type.lua +4 -0
- package/project/.sdk/tm/lua/feature/audit_feature.lua +2 -2
- package/project/.sdk/tm/lua/feature/cost_feature.lua +2 -2
- package/project/.sdk/tm/lua/feature/debug_feature.lua +21 -17
- package/project/.sdk/tm/lua/feature/log_feature.lua +2 -1
- package/project/.sdk/tm/lua/feature/proxy_feature.lua +23 -1
- package/project/.sdk/tm/lua/feature/secrets_feature.lua +18 -0
- package/project/.sdk/tm/lua/feature/telemetry_feature.lua +4 -2
- package/project/.sdk/tm/lua/test/feature/secrets/secrets_feature_test.lua +3 -2
- package/project/.sdk/tm/lua/test/feature_test.lua +10 -3
- package/project/.sdk/tm/lua/utility/clean.lua +426 -2
- package/project/.sdk/tm/lua/utility/clean_explain.lua +34 -0
- package/project/.sdk/tm/lua/utility/done.lua +1 -7
- package/project/.sdk/tm/lua/utility/make_error.lua +3 -1
- package/project/.sdk/tm/lua/utility/make_options.lua +76 -30
- package/project/.sdk/tm/lua/utility/register.lua +4 -1
- package/project/.sdk/tm/ocaml/Makefile +5 -1
- package/project/.sdk/tm/ocaml/feature/secrets_feature.ml +12 -1
- package/project/.sdk/tm/ocaml/sdk_features.ml +78 -18
- package/project/.sdk/tm/ocaml/sdk_helpers.ml +27 -0
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +304 -26
- package/project/.sdk/tm/ocaml/sdk_types.ml +1 -0
- package/project/.sdk/tm/ocaml/test/feature/secrets/t_secrets.ml +3 -1
- package/project/.sdk/tm/ocaml/test/t_feature.ml +2 -2
- package/project/.sdk/tm/perl/core/context.pm +27 -0
- package/project/.sdk/tm/perl/core/error.pm +52 -5
- package/project/.sdk/tm/perl/feature/audit_feature.pm +2 -2
- package/project/.sdk/tm/perl/feature/cost_feature.pm +2 -2
- package/project/.sdk/tm/perl/feature/debug_feature.pm +17 -13
- package/project/.sdk/tm/perl/feature/log_feature.pm +3 -1
- package/project/.sdk/tm/perl/feature/proxy_feature.pm +21 -1
- package/project/.sdk/tm/perl/feature/secrets_feature.pm +20 -1
- package/project/.sdk/tm/perl/feature/telemetry_feature.pm +4 -2
- package/project/.sdk/tm/perl/t/feature.t +4 -2
- package/project/.sdk/tm/perl/utility/clean.pm +345 -1
- package/project/.sdk/tm/perl/utility/done.pm +24 -6
- package/project/.sdk/tm/perl/utility/make_error.pm +17 -4
- package/project/.sdk/tm/perl/utility/make_options.pm +33 -14
- package/project/.sdk/tm/php/core/Context.php +24 -1
- package/project/.sdk/tm/php/core/Error.php +34 -3
- package/project/.sdk/tm/php/core/UtilityType.php +4 -0
- package/project/.sdk/tm/php/feature/AuditFeature.php +2 -2
- package/project/.sdk/tm/php/feature/CostFeature.php +2 -2
- package/project/.sdk/tm/php/feature/DebugFeature.php +18 -9
- package/project/.sdk/tm/php/feature/LogFeature.php +5 -2
- package/project/.sdk/tm/php/feature/ProxyFeature.php +20 -1
- package/project/.sdk/tm/php/feature/SecretsFeature.php +18 -0
- package/project/.sdk/tm/php/feature/TelemetryFeature.php +4 -2
- package/project/.sdk/tm/php/test/FeatureTest.php +2 -2
- package/project/.sdk/tm/php/utility/Clean.php +438 -2
- package/project/.sdk/tm/php/utility/Done.php +14 -7
- package/project/.sdk/tm/php/utility/MakeError.php +9 -7
- package/project/.sdk/tm/php/utility/MakeOptions.php +62 -38
- package/project/.sdk/tm/php/utility/Register.php +2 -0
- package/project/.sdk/tm/py/pkg/core/context.py +17 -0
- package/project/.sdk/tm/py/pkg/core/error.py +42 -1
- package/project/.sdk/tm/py/pkg/core/utility_type.py +4 -0
- package/project/.sdk/tm/py/pkg/feature/audit_feature.py +2 -2
- package/project/.sdk/tm/py/pkg/feature/cost_feature.py +2 -2
- package/project/.sdk/tm/py/pkg/feature/debug_feature.py +17 -12
- package/project/.sdk/tm/py/pkg/feature/log_feature.py +2 -1
- package/project/.sdk/tm/py/pkg/feature/proxy_feature.py +18 -1
- package/project/.sdk/tm/py/pkg/feature/secrets_feature.py +12 -0
- package/project/.sdk/tm/py/pkg/feature/telemetry_feature.py +4 -2
- package/project/.sdk/tm/py/pkg/utility/clean.py +311 -1
- package/project/.sdk/tm/py/pkg/utility/done.py +18 -5
- package/project/.sdk/tm/py/pkg/utility/make_error.py +9 -6
- package/project/.sdk/tm/py/pkg/utility/make_options.py +64 -25
- package/project/.sdk/tm/py/pkg/utility/make_response.py +19 -13
- package/project/.sdk/tm/py/pkg/utility/register.py +4 -2
- package/project/.sdk/tm/py/test/feature_harness.py +4 -0
- package/project/.sdk/tm/py/test/test_feature.py +2 -2
- package/project/.sdk/tm/py/test/test_primary_utility.py +1 -0
- package/project/.sdk/tm/rb/core/context.rb +28 -0
- package/project/.sdk/tm/rb/core/error.rb +30 -0
- package/project/.sdk/tm/rb/core/utility_type.rb +1 -1
- package/project/.sdk/tm/rb/feature/audit_feature.rb +2 -2
- package/project/.sdk/tm/rb/feature/cost_feature.rb +2 -2
- package/project/.sdk/tm/rb/feature/debug_feature.rb +15 -12
- package/project/.sdk/tm/rb/feature/log_feature.rb +3 -1
- package/project/.sdk/tm/rb/feature/proxy_feature.rb +25 -1
- package/project/.sdk/tm/rb/feature/secrets_feature.rb +17 -0
- package/project/.sdk/tm/rb/feature/telemetry_feature.rb +4 -2
- package/project/.sdk/tm/rb/test/feature_test.rb +4 -2
- package/project/.sdk/tm/rb/utility/clean.rb +312 -1
- package/project/.sdk/tm/rb/utility/done.rb +15 -5
- package/project/.sdk/tm/rb/utility/make_error.rb +13 -4
- package/project/.sdk/tm/rb/utility/make_options.rb +31 -12
- package/project/.sdk/tm/rb/utility/register.rb +2 -0
- package/project/.sdk/tm/rust/core/context.rs +55 -0
- package/project/.sdk/tm/rust/core/utility_type.rs +17 -0
- package/project/.sdk/tm/rust/feature/audit.rs +2 -0
- package/project/.sdk/tm/rust/feature/cost.rs +3 -2
- package/project/.sdk/tm/rust/feature/debug.rs +16 -16
- package/project/.sdk/tm/rust/feature/log.rs +42 -7
- package/project/.sdk/tm/rust/feature/proxy.rs +48 -2
- package/project/.sdk/tm/rust/feature/secrets.rs +12 -0
- package/project/.sdk/tm/rust/feature/telemetry.rs +2 -0
- package/project/.sdk/tm/rust/tests/feature_test.rs +2 -2
- package/project/.sdk/tm/rust/utility/clean.rs +446 -5
- package/project/.sdk/tm/rust/utility/done.rs +22 -12
- package/project/.sdk/tm/rust/utility/make_error.rs +4 -1
- package/project/.sdk/tm/rust/utility/make_options.rs +73 -19
- package/project/.sdk/tm/scala/Makefile +3 -1
- package/project/.sdk/tm/scala/core/Context.scala +16 -0
- package/project/.sdk/tm/scala/core/SdkClient.scala +14 -4
- package/project/.sdk/tm/scala/core/SdkError.scala +28 -0
- package/project/.sdk/tm/scala/core/Types.scala +3 -0
- package/project/.sdk/tm/scala/core/Utility.scala +2 -0
- package/project/.sdk/tm/scala/feature/AuditFeature.scala +16 -10
- package/project/.sdk/tm/scala/feature/CostFeature.scala +10 -5
- package/project/.sdk/tm/scala/feature/DebugFeature.scala +24 -21
- package/project/.sdk/tm/scala/feature/LogFeature.scala +9 -4
- package/project/.sdk/tm/scala/feature/ProxyFeature.scala +23 -2
- package/project/.sdk/tm/scala/feature/SecretsFeature.scala +14 -0
- package/project/.sdk/tm/scala/feature/TelemetryFeature.scala +9 -2
- package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +2 -2
- package/project/.sdk/tm/scala/utility/Make.scala +63 -20
- package/project/.sdk/tm/scala/utility/Misc.scala +358 -5
- package/project/.sdk/tm/scala/utility/Register.scala +1 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Context.swift +29 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Utility.swift +2 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/AuditFeature.swift +10 -9
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/CostFeature.swift +7 -5
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/DebugFeature.swift +19 -15
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/FeatureOptions.swift +16 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/LogFeature.swift +4 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/ProxyFeature.swift +20 -5
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/SecretsFeature.swift +13 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TelemetryFeature.swift +4 -2
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeError.swift +15 -5
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +58 -19
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Register.swift +1 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/ResultUtil.swift +391 -4
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +2 -2
- package/project/.sdk/tm/ts/src/Context.ts +5 -1
- package/project/.sdk/tm/ts/src/feature/audit/AuditFeature.ts +2 -2
- package/project/.sdk/tm/ts/src/feature/cost/CostFeature.ts +2 -2
- package/project/.sdk/tm/ts/src/feature/debug/DebugFeature.ts +13 -7
- package/project/.sdk/tm/ts/src/feature/log/LogFeature.ts +9 -5
- package/project/.sdk/tm/ts/src/feature/proxy/ProxyFeature.ts +19 -1
- package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +12 -0
- package/project/.sdk/tm/ts/src/feature/telemetry/TelemetryFeature.ts +4 -2
- package/project/.sdk/tm/ts/src/utility/CleanUtility.ts +287 -9
- package/project/.sdk/tm/ts/src/utility/DoneUtility.ts +18 -5
- package/project/.sdk/tm/ts/src/utility/MakeErrorUtility.ts +18 -8
- package/project/.sdk/tm/ts/src/utility/MakeOptionsUtility.ts +38 -16
- package/project/.sdk/tm/ts/src/utility/Utility.ts +4 -2
- package/project/.sdk/tm/ts/test/feature/harness.ts +11 -1
- package/project/.sdk/tm/ts/test/feature.test.ts +9 -2
- package/project/.sdk/tm/zig/core/context.zig +34 -0
- package/project/.sdk/tm/zig/core/error.zig +22 -1
- package/project/.sdk/tm/zig/core/utility.zig +403 -39
- package/project/.sdk/tm/zig/feature/audit.zig +4 -2
- package/project/.sdk/tm/zig/feature/cost.zig +3 -2
- package/project/.sdk/tm/zig/feature/debug.zig +20 -25
- package/project/.sdk/tm/zig/feature/log.zig +3 -1
- package/project/.sdk/tm/zig/feature/proxy.zig +47 -6
- package/project/.sdk/tm/zig/feature/secrets.zig +7 -0
- package/project/.sdk/tm/zig/feature/telemetry.zig +4 -2
- package/project/.sdk/tm/zig/test/feature_test.zig +2 -2
- package/project/sdkgen-package.json +1 -1
- package/src/action/copies.ts +219 -0
- package/src/action/doctor.ts +247 -21
- package/src/action/edition.ts +10 -2
- package/src/action/feature.ts +11 -2
- package/src/action/package.ts +31 -10
- package/src/action/remove.ts +4 -0
- package/src/action/resolve.ts +16 -3
- package/src/action/target.ts +10 -2
- package/src/helpers/naming.ts +1 -1
- package/src/sdkgen.ts +45 -5
|
@@ -1,26 +1,461 @@
|
|
|
1
1
|
package KOTLINPACKAGE.utility
|
|
2
2
|
|
|
3
|
+
import java.io.PrintWriter
|
|
4
|
+
import java.io.StringWriter
|
|
5
|
+
import java.nio.charset.StandardCharsets
|
|
6
|
+
import java.util.Base64
|
|
7
|
+
|
|
3
8
|
import KOTLINPACKAGE.core.Context
|
|
9
|
+
import KOTLINPACKAGE.core.Entity
|
|
4
10
|
import KOTLINPACKAGE.core.Helpers
|
|
11
|
+
import KOTLINPACKAGE.core.Operation
|
|
12
|
+
import KOTLINPACKAGE.core.Response
|
|
5
13
|
import KOTLINPACKAGE.core.Result
|
|
14
|
+
import KOTLINPACKAGE.core.Schema
|
|
6
15
|
import KOTLINPACKAGE.core.SdkError
|
|
7
16
|
import KOTLINPACKAGE.core.Spec
|
|
17
|
+
import KOTLINPACKAGE.utility.struct.Struct
|
|
8
18
|
|
|
9
19
|
fun makeContext(ctxmap: MutableMap<String, Any?>?, basectx: Context?): Context {
|
|
10
20
|
return Context(ctxmap, basectx)
|
|
11
21
|
}
|
|
12
22
|
|
|
13
|
-
|
|
14
|
-
|
|
23
|
+
// Everything that leaves the pipeline passes through clean; inside it data
|
|
24
|
+
// stays raw, so a hook can still read the header it must add to. See
|
|
25
|
+
// docs/explanation/secret-redaction.md.
|
|
26
|
+
|
|
27
|
+
private const val MAXDEPTH = 32
|
|
28
|
+
private const val CIRCULAR = "[circular]"
|
|
29
|
+
|
|
30
|
+
// The derived clean block: built by makeOptions from the raw input, grown by
|
|
31
|
+
// cleanAdd for as long as the client lives (features register later).
|
|
32
|
+
class CleanConfig(
|
|
33
|
+
val active: Boolean,
|
|
34
|
+
val keys: List<String>,
|
|
35
|
+
val values: MutableList<String>,
|
|
36
|
+
val mask: String,
|
|
37
|
+
val hint: Int,
|
|
38
|
+
val min: Int,
|
|
39
|
+
) {
|
|
40
|
+
// The options map this sits in can itself be printed; the registry never is.
|
|
41
|
+
override fun toString(): String = "CleanConfig(active=$active)"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private fun normkey(key: Any?): String {
|
|
45
|
+
return key.toString().lowercase().replace("-", "").replace("_", "")
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private val SPLIT_RE = Regex("\\s*,\\s*")
|
|
49
|
+
|
|
50
|
+
private fun splitkeys(keys: Any?): List<String> {
|
|
51
|
+
return (keys?.toString() ?: "").split(SPLIT_RE).map { normkey(it) }.filter { "" != it }
|
|
15
52
|
}
|
|
16
53
|
|
|
54
|
+
fun splitvalues(values: Any?): List<String> {
|
|
55
|
+
if (values is List<*>) {
|
|
56
|
+
return values.filterIsInstance<String>()
|
|
57
|
+
}
|
|
58
|
+
return (values?.toString() ?: "").split(SPLIT_RE).filter { "" != it }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private fun count(v: Any?, dflt: Int): Int {
|
|
62
|
+
val n: Double = when (v) {
|
|
63
|
+
is Number -> v.toDouble()
|
|
64
|
+
is String -> v.trim().toDoubleOrNull() ?: return dflt
|
|
65
|
+
else -> return dflt
|
|
66
|
+
}
|
|
67
|
+
if (n.isNaN() || n.isInfinite() || n < 0) {
|
|
68
|
+
return dflt
|
|
69
|
+
}
|
|
70
|
+
return Math.floor(n).toInt()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
fun makeCleanConfig(cleanopts: Any?): CleanConfig {
|
|
74
|
+
val opts = Helpers.toMapAny(cleanopts) ?: linkedMapOf()
|
|
75
|
+
return CleanConfig(
|
|
76
|
+
active = false != opts["active"],
|
|
77
|
+
keys = splitkeys(opts["keys"]),
|
|
78
|
+
values = mutableListOf(),
|
|
79
|
+
mask = (opts["mask"] as? String) ?: "[redacted]",
|
|
80
|
+
hint = count(opts["hint"], 0),
|
|
81
|
+
min = Math.max(1, count(opts["min"], 4)),
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// A context without options (makeError accepts a bare one) still masks by
|
|
86
|
+
// the schema defaults.
|
|
87
|
+
private fun cleanConfig(ctx: Context?): CleanConfig {
|
|
88
|
+
val derived = Helpers.toMapAny(ctx?.options?.get("__derived__"))?.get("clean")
|
|
89
|
+
if (derived is CleanConfig) {
|
|
90
|
+
return derived
|
|
91
|
+
}
|
|
92
|
+
return makeCleanConfig(Schema.optspec["clean"])
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// encodeURIComponent, byte for byte: URLEncoder differs on space and `~!'()*`.
|
|
96
|
+
private fun percentEncode(value: String): String {
|
|
97
|
+
val out = StringBuilder()
|
|
98
|
+
for (b in value.toByteArray(StandardCharsets.UTF_8)) {
|
|
99
|
+
val c = b.toInt() and 0xff
|
|
100
|
+
val ch = c.toChar()
|
|
101
|
+
if ((ch in 'A'..'Z') || (ch in 'a'..'z') || (ch in '0'..'9') || "-_.!~*'()".indexOf(ch) >= 0) {
|
|
102
|
+
out.append(ch)
|
|
103
|
+
} else {
|
|
104
|
+
out.append('%').append(String.format("%02X", c))
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return out.toString()
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// The encoded forms a value travels in.
|
|
111
|
+
private fun forms(value: String): List<String> {
|
|
112
|
+
val out = mutableListOf(value)
|
|
113
|
+
fun add(s: String) {
|
|
114
|
+
if ("" != s && !out.contains(s)) {
|
|
115
|
+
out.add(s)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
add(Base64.getEncoder().encodeToString(value.toByteArray(StandardCharsets.UTF_8)))
|
|
120
|
+
} catch (e: RuntimeException) {
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
add(percentEncode(value))
|
|
124
|
+
} catch (e: RuntimeException) {
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
val json = Struct.jsonify(value)
|
|
128
|
+
if (json.length >= 2) {
|
|
129
|
+
add(json.substring(1, json.length - 1))
|
|
130
|
+
}
|
|
131
|
+
} catch (e: RuntimeException) {
|
|
132
|
+
}
|
|
133
|
+
return out
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
internal fun registerValue(cfg: CleanConfig, value: Any?) {
|
|
137
|
+
if (value !is String || value.length < cfg.min) {
|
|
138
|
+
return
|
|
139
|
+
}
|
|
140
|
+
synchronized(cfg) {
|
|
141
|
+
var changed = false
|
|
142
|
+
for (form in forms(value)) {
|
|
143
|
+
if (form.length >= cfg.min && !cfg.values.contains(form)) {
|
|
144
|
+
cfg.values.add(form)
|
|
145
|
+
changed = true
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (changed) {
|
|
149
|
+
cfg.values.sortByDescending { it.length }
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
fun cleanAdd(ctx: Context, value: Any?) {
|
|
155
|
+
registerValue(cleanConfig(ctx), value)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Every scalar under a sensitive name in the options, at any depth and of any
|
|
159
|
+
// shape: a credential mistyped as a map or a number is still one, and a
|
|
160
|
+
// message can quote it. A key under `feature` names a feature, not a field,
|
|
161
|
+
// so a feature called secrets does not make its settings secret.
|
|
162
|
+
// Entity blocks (entity settings, seeded records) hold no credential.
|
|
163
|
+
internal fun registerSensitive(cfg: CleanConfig, opts: Map<String, Any?>) {
|
|
164
|
+
val seen = mutableListOf<Any>()
|
|
165
|
+
for ((k, v) in opts) {
|
|
166
|
+
if ("entity" == k) {
|
|
167
|
+
continue
|
|
168
|
+
}
|
|
169
|
+
val under = sensitiveKey(cfg, k)
|
|
170
|
+
when {
|
|
171
|
+
"feature" == k && v is Map<*, *> -> for (fopts in v.values) {
|
|
172
|
+
addSensitive(cfg, noEntity(fopts), under, 2, seen)
|
|
173
|
+
}
|
|
174
|
+
"feature" == k && v is List<*> -> for (fopts in v) {
|
|
175
|
+
addSensitive(cfg, noEntity(fopts), under, 2, seen)
|
|
176
|
+
}
|
|
177
|
+
else -> addSensitive(cfg, if ("test" == k) noEntity(v) else v, under, 1, seen)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
private fun noEntity(block: Any?): Any? =
|
|
183
|
+
if (block is Map<*, *>) block.filterKeys { it != "entity" } else block
|
|
184
|
+
|
|
185
|
+
private fun addSensitive(cfg: CleanConfig, v: Any?, under: Boolean, depth: Int, seen: MutableList<Any>) {
|
|
186
|
+
if (v == null || MAXDEPTH <= depth) {
|
|
187
|
+
return
|
|
188
|
+
}
|
|
189
|
+
if (v is String || v is Number) {
|
|
190
|
+
if (under) {
|
|
191
|
+
registerValue(cfg, v.toString())
|
|
192
|
+
registerValue(cfg, Struct.stringify(v))
|
|
193
|
+
}
|
|
194
|
+
return
|
|
195
|
+
}
|
|
196
|
+
if (seen.any { it === v }) {
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
seen.add(v)
|
|
200
|
+
when (v) {
|
|
201
|
+
is Map<*, *> -> for ((k, item) in v) {
|
|
202
|
+
addSensitive(cfg, item, under || sensitiveKey(cfg, k), depth + 1, seen)
|
|
203
|
+
}
|
|
204
|
+
is Collection<*> -> for (item in v) {
|
|
205
|
+
addSensitive(cfg, item, under, depth + 1, seen)
|
|
206
|
+
}
|
|
207
|
+
is Array<*> -> for (item in v) {
|
|
208
|
+
addSensitive(cfg, item, under, depth + 1, seen)
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
private fun maskValue(cfg: CleanConfig, value: String): String {
|
|
214
|
+
if (0 < cfg.hint && value.length > 2 * cfg.hint) {
|
|
215
|
+
return cfg.mask + value.substring(value.length - cfg.hint)
|
|
216
|
+
}
|
|
217
|
+
return cfg.mask
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
private fun cleanString(cfg: CleanConfig, text: String): String {
|
|
221
|
+
val values = synchronized(cfg) { cfg.values.toList() }
|
|
222
|
+
var out = text
|
|
223
|
+
for (value in values) {
|
|
224
|
+
if (out.contains(value)) {
|
|
225
|
+
out = out.replace(value, maskValue(cfg, value))
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return out
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
private fun sensitiveKey(cfg: CleanConfig, key: Any?): Boolean {
|
|
232
|
+
if (key == null || key is Number) {
|
|
233
|
+
return false
|
|
234
|
+
}
|
|
235
|
+
val nk = normkey(key)
|
|
236
|
+
for (k in cfg.keys) {
|
|
237
|
+
if (nk.contains(k)) {
|
|
238
|
+
return true
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return false
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
private val DROP = Any()
|
|
245
|
+
|
|
246
|
+
private fun isfunc(v: Any): Boolean {
|
|
247
|
+
if (v is Function<*>) {
|
|
248
|
+
return true
|
|
249
|
+
}
|
|
250
|
+
val cls = v.javaClass
|
|
251
|
+
return cls.isSynthetic || cls.interfaces.any { it.name.startsWith("java.util.function.") }
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
private fun stackOf(err: Throwable): String {
|
|
255
|
+
val sw = StringWriter()
|
|
256
|
+
err.printStackTrace(PrintWriter(sw))
|
|
257
|
+
return sw.toString()
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// The SDK's own objects have no serialisation hook, so this is the record
|
|
261
|
+
// each one leaves as. The context stays raw on the error and is not here.
|
|
262
|
+
private fun record(v: Any): MutableMap<String, Any?> {
|
|
263
|
+
val out = linkedMapOf<String, Any?>()
|
|
264
|
+
when (v) {
|
|
265
|
+
is Throwable -> {
|
|
266
|
+
out["message"] = v.message ?: ""
|
|
267
|
+
out["stack"] = stackOf(v)
|
|
268
|
+
if (v is SdkError) {
|
|
269
|
+
out["sdk"] = v.sdk
|
|
270
|
+
out["code"] = v.code
|
|
271
|
+
out["status"] = v.status
|
|
272
|
+
out["result"] = v.result
|
|
273
|
+
out["spec"] = v.spec
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
is Spec -> {
|
|
277
|
+
out["method"] = v.method
|
|
278
|
+
out["base"] = v.base
|
|
279
|
+
out["prefix"] = v.prefix
|
|
280
|
+
out["suffix"] = v.suffix
|
|
281
|
+
out["path"] = v.path
|
|
282
|
+
out["url"] = v.url
|
|
283
|
+
out["params"] = v.params
|
|
284
|
+
out["query"] = v.query
|
|
285
|
+
out["headers"] = v.headers
|
|
286
|
+
out["body"] = v.body
|
|
287
|
+
out["step"] = v.step
|
|
288
|
+
}
|
|
289
|
+
is Result -> {
|
|
290
|
+
out["ok"] = v.ok
|
|
291
|
+
out["status"] = v.status
|
|
292
|
+
out["statusText"] = v.statusText
|
|
293
|
+
out["headers"] = v.headers
|
|
294
|
+
out["body"] = v.body
|
|
295
|
+
out["resdata"] = v.resdata
|
|
296
|
+
out["resmatch"] = v.resmatch
|
|
297
|
+
out["err"] = v.err
|
|
298
|
+
out["paging"] = v.paging
|
|
299
|
+
}
|
|
300
|
+
is Response -> {
|
|
301
|
+
out["status"] = v.status
|
|
302
|
+
out["statusText"] = v.statusText
|
|
303
|
+
out["headers"] = v.headers
|
|
304
|
+
out["body"] = v.body
|
|
305
|
+
out["err"] = v.err
|
|
306
|
+
}
|
|
307
|
+
is Operation -> {
|
|
308
|
+
out["entity"] = v.entity
|
|
309
|
+
out["name"] = v.name
|
|
310
|
+
out["input"] = v.input
|
|
311
|
+
}
|
|
312
|
+
is Context -> {
|
|
313
|
+
out["id"] = v.id
|
|
314
|
+
out["op"] = v.op
|
|
315
|
+
out["spec"] = v.spec
|
|
316
|
+
out["entity"] = v.entity
|
|
317
|
+
out["result"] = v.result
|
|
318
|
+
out["response"] = v.response
|
|
319
|
+
out["meta"] = v.meta
|
|
320
|
+
}
|
|
321
|
+
is Entity -> {
|
|
322
|
+
out["name"] = v.name
|
|
323
|
+
out["data"] = try { v.data() } catch (e: RuntimeException) { null }
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return out
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// A masked plain-data copy: functions dropped, cycles cut, and nothing
|
|
330
|
+
// shared with the live value, whose spec must stay raw.
|
|
17
331
|
@Suppress("UNCHECKED_CAST")
|
|
332
|
+
private fun snapshot(cfg: CleanConfig, v: Any?, key: Any?, depth: Int, seen: MutableList<Any>): Any? {
|
|
333
|
+
if (v == null || v === Struct.UNDEF) {
|
|
334
|
+
return v
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (v is String) {
|
|
338
|
+
return if (sensitiveKey(cfg, key)) maskValue(cfg, v) else cleanString(cfg, v)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (isfunc(v)) {
|
|
342
|
+
return DROP
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (v is Number || v is Boolean || v is Char) {
|
|
346
|
+
return if (sensitiveKey(cfg, key)) cfg.mask else v
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (MAXDEPTH <= depth || seen.any { it === v }) {
|
|
350
|
+
return CIRCULAR
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (sensitiveKey(cfg, key)) {
|
|
354
|
+
return cfg.mask
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
seen.add(v)
|
|
358
|
+
try {
|
|
359
|
+
return when (v) {
|
|
360
|
+
is List<*> -> {
|
|
361
|
+
val out = mutableListOf<Any?>()
|
|
362
|
+
v.forEachIndexed { i, item ->
|
|
363
|
+
val s = snapshot(cfg, item, i, depth + 1, seen)
|
|
364
|
+
if (s !== DROP) {
|
|
365
|
+
out.add(s)
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
out
|
|
369
|
+
}
|
|
370
|
+
is Map<*, *> -> plain(cfg, v, depth, seen)
|
|
371
|
+
is Throwable, is Spec, is Result, is Response, is Operation, is Context, is Entity ->
|
|
372
|
+
plain(cfg, record(v), depth, seen)
|
|
373
|
+
else -> cleanString(cfg, v.toString())
|
|
374
|
+
}
|
|
375
|
+
} finally {
|
|
376
|
+
seen.removeAt(seen.size - 1)
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
private fun plain(cfg: CleanConfig, v: Map<*, *>, depth: Int, seen: MutableList<Any>): MutableMap<String, Any?> {
|
|
381
|
+
val out = linkedMapOf<String, Any?>()
|
|
382
|
+
for ((k, item) in v) {
|
|
383
|
+
val s = snapshot(cfg, item, k, depth + 1, seen)
|
|
384
|
+
if (s !== DROP) {
|
|
385
|
+
out[cleanName(cfg, out, k.toString())] = s
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return out
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// A registered value used as a property name is masked like any other
|
|
392
|
+
// string; names that mask alike take a counter, so none is lost.
|
|
393
|
+
private fun cleanName(cfg: CleanConfig, out: Map<String, Any?>, key: String): String {
|
|
394
|
+
val name = cleanString(cfg, key)
|
|
395
|
+
if (name == key || !out.containsKey(name)) {
|
|
396
|
+
return name
|
|
397
|
+
}
|
|
398
|
+
var i = 1
|
|
399
|
+
while (out.containsKey(name + "#" + i)) {
|
|
400
|
+
i++
|
|
401
|
+
}
|
|
402
|
+
return name + "#" + i
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
internal fun cleanWith(cfg: CleanConfig, value: Any?): Any? {
|
|
406
|
+
if (!cfg.active) {
|
|
407
|
+
return value
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (value is String) {
|
|
411
|
+
return cleanString(cfg, value)
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// An SdkError is cleaned in place, since it is about to be thrown.
|
|
415
|
+
if (value is SdkError) {
|
|
416
|
+
value.msg = cleanString(cfg, value.msg)
|
|
417
|
+
value.code = cleanString(cfg, value.code)
|
|
418
|
+
value.result = snapshot(cfg, value.result, "result", 1, mutableListOf())
|
|
419
|
+
value.spec = snapshot(cfg, value.spec, "spec", 1, mutableListOf())
|
|
420
|
+
return value
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// A foreign exception's message cannot be rewritten, so it is replaced by
|
|
424
|
+
// an SdkError with the cleaned message and the original frames; the
|
|
425
|
+
// original is not attached, as a printed stack trace would show it.
|
|
426
|
+
if (value is Throwable) {
|
|
427
|
+
val out = SdkError("", cleanString(cfg, value.message ?: value.toString()), null)
|
|
428
|
+
out.stackTrace = value.stackTrace
|
|
429
|
+
return out
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
val out = snapshot(cfg, value, null, 0, mutableListOf())
|
|
433
|
+
return if (out === DROP) null else out
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
fun clean(ctx: Context, value: Any?): Any? {
|
|
437
|
+
return cleanWith(cleanConfig(ctx), value)
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
fun cleanKey(ctx: Context, key: Any?): Boolean {
|
|
441
|
+
return sensitiveKey(cleanConfig(ctx), key)
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// The caller holds the explain map, so the cleaned copy is written back into
|
|
445
|
+
// it rather than swapped for it.
|
|
446
|
+
private fun cleanExplain(ctx: Context) {
|
|
447
|
+
val explain = ctx.ctrl.explain ?: return
|
|
448
|
+
val cleaned = Helpers.toMapAny(clean(ctx, explain))
|
|
449
|
+
if (cleaned != null && cleaned !== explain) {
|
|
450
|
+
explain.clear()
|
|
451
|
+
explain.putAll(cleaned)
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
18
455
|
fun done(ctx: Context): Any? {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
val
|
|
22
|
-
ctx.ctrl.explain = cleaned
|
|
23
|
-
val rm = Helpers.toMapAny(cleaned["result"])
|
|
456
|
+
if (ctx.ctrl.explain != null) {
|
|
457
|
+
cleanExplain(ctx)
|
|
458
|
+
val rm = Helpers.toMapAny(ctx.ctrl.explain!!["result"])
|
|
24
459
|
rm?.remove("err")
|
|
25
460
|
}
|
|
26
461
|
|
|
@@ -64,21 +499,22 @@ fun makeError(ctx: Context, errIn: RuntimeException?): Any? {
|
|
|
64
499
|
|
|
65
500
|
val spec = ctx.spec
|
|
66
501
|
|
|
67
|
-
|
|
68
|
-
|
|
502
|
+
if (ctx.ctrl.explain != null) {
|
|
503
|
+
cleanExplain(ctx)
|
|
69
504
|
val errRecord = linkedMapOf<String, Any?>()
|
|
70
505
|
errRecord["message"] = msg
|
|
71
|
-
explain["err"] = errRecord
|
|
506
|
+
ctx.ctrl.explain!!["err"] = errRecord
|
|
72
507
|
}
|
|
73
508
|
|
|
74
509
|
var code = ""
|
|
75
510
|
if (err is SdkError) {
|
|
76
|
-
code = err.code
|
|
511
|
+
code = clean(ctx, err.code) as String
|
|
77
512
|
}
|
|
78
513
|
|
|
79
514
|
val sdkErr = SdkError(code, msg, ctx)
|
|
80
515
|
sdkErr.result = clean(ctx, result)
|
|
81
516
|
sdkErr.spec = clean(ctx, spec)
|
|
517
|
+
sdkErr.status = result.status
|
|
82
518
|
|
|
83
519
|
ctx.ctrl.err = sdkErr
|
|
84
520
|
|
|
@@ -3,6 +3,7 @@ package KOTLINPACKAGE.utility
|
|
|
3
3
|
import KOTLINPACKAGE.core.Context
|
|
4
4
|
import KOTLINPACKAGE.core.Helpers
|
|
5
5
|
import KOTLINPACKAGE.core.Schema
|
|
6
|
+
import KOTLINPACKAGE.core.SdkError
|
|
6
7
|
import KOTLINPACKAGE.core.Utility
|
|
7
8
|
import KOTLINPACKAGE.utility.struct.Struct
|
|
8
9
|
|
|
@@ -41,6 +42,32 @@ fun makeOptions(ctx: Context): MutableMap<String, Any?> {
|
|
|
41
42
|
// check on the value, which cannot distinguish them.
|
|
42
43
|
val authSuppressed = options.containsKey("auth") && null == options["auth"]
|
|
43
44
|
|
|
45
|
+
var config = ctx.config
|
|
46
|
+
if (config == null) {
|
|
47
|
+
config = linkedMapOf()
|
|
48
|
+
}
|
|
49
|
+
var cfgopts = Helpers.toMapAny(config["options"])
|
|
50
|
+
if (cfgopts == null) {
|
|
51
|
+
cfgopts = linkedMapOf()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// The secret registry exists BEFORE validation, fed from the raw input, so
|
|
55
|
+
// the constructor's own rejection of a mistyped credential is clean too.
|
|
56
|
+
// Both clean blocks are cloned for the reason the options merge below is,
|
|
57
|
+
// and an absent one is left out: merge lets a null replace everything.
|
|
58
|
+
val cleanblocks = listOf(Helpers.toMapAny(cfgopts["clean"]), Helpers.toMapAny(options["clean"]))
|
|
59
|
+
val cleanmerge = mutableListOf<Any?>(linkedMapOf<String, Any?>(), Struct.clone(Schema.optspec["clean"]))
|
|
60
|
+
for (block in cleanblocks.filterNotNull()) {
|
|
61
|
+
cleanmerge.add(Struct.clone(block))
|
|
62
|
+
}
|
|
63
|
+
val cleancfg = makeCleanConfig(Struct.merge(cleanmerge))
|
|
64
|
+
registerSensitive(cleancfg, options - "clean")
|
|
65
|
+
for (block in cleanblocks) {
|
|
66
|
+
for (raw in splitvalues(block?.get("values"))) {
|
|
67
|
+
registerValue(cleancfg, raw)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
44
71
|
var opts = Struct.clone(options) as MutableMap<String, Any?>
|
|
45
72
|
|
|
46
73
|
if (authSuppressed) {
|
|
@@ -71,15 +98,6 @@ fun makeOptions(ctx: Context): MutableMap<String, Any?> {
|
|
|
71
98
|
opts["feature"] = fmap
|
|
72
99
|
}
|
|
73
100
|
|
|
74
|
-
var config = ctx.config
|
|
75
|
-
if (config == null) {
|
|
76
|
-
config = linkedMapOf()
|
|
77
|
-
}
|
|
78
|
-
var cfgopts = Helpers.toMapAny(config["options"])
|
|
79
|
-
if (cfgopts == null) {
|
|
80
|
-
cfgopts = linkedMapOf()
|
|
81
|
-
}
|
|
82
|
-
|
|
83
101
|
// THE OPTION SPEC IS GENERATED, NOT WRITTEN HERE.
|
|
84
102
|
//
|
|
85
103
|
// Built from the model: `main.kit.optspec` for the standard options, plus
|
|
@@ -111,7 +129,13 @@ fun makeOptions(ctx: Context): MutableMap<String, Any?> {
|
|
|
111
129
|
|
|
112
130
|
val vopts = linkedMapOf<String, Any?>()
|
|
113
131
|
vopts["errs"] = mutableListOf<Any?>()
|
|
114
|
-
val validated =
|
|
132
|
+
val validated = try {
|
|
133
|
+
Struct.validate(merged, optspec, vopts)
|
|
134
|
+
} catch (err: RuntimeException) {
|
|
135
|
+
// A rejection quotes the value it rejected.
|
|
136
|
+
throw SdkError("options_invalid",
|
|
137
|
+
cleanWith(cleancfg, err.message ?: err.toString()) as String, ctx)
|
|
138
|
+
}
|
|
115
139
|
opts = validated as MutableMap<String, Any?>
|
|
116
140
|
|
|
117
141
|
// Restore the suppression the optspec default would otherwise erase.
|
|
@@ -131,22 +155,6 @@ fun makeOptions(ctx: Context): MutableMap<String, Any?> {
|
|
|
131
155
|
}
|
|
132
156
|
}
|
|
133
157
|
|
|
134
|
-
// Derived clean config.
|
|
135
|
-
var cleanKeys = "key,token,id"
|
|
136
|
-
val ck = Struct.getpath(opts, listOf("clean", "keys"))
|
|
137
|
-
if (ck is String) {
|
|
138
|
-
cleanKeys = ck
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
val filtered = mutableListOf<String>()
|
|
142
|
-
for (pRaw in cleanKeys.split(",")) {
|
|
143
|
-
val p = pRaw.trim()
|
|
144
|
-
if ("" != p) {
|
|
145
|
-
filtered.add(Struct.escre(p))
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
val keyre = filtered.joinToString("|")
|
|
149
|
-
|
|
150
158
|
// Resolve the feature add-order: an explicit list order (above) wins;
|
|
151
159
|
// otherwise order the map test-first, then the remaining names sorted, so
|
|
152
160
|
// the outcome is deterministic and `test` is always the base transport.
|
|
@@ -177,14 +185,13 @@ fun makeOptions(ctx: Context): MutableMap<String, Any?> {
|
|
|
177
185
|
}
|
|
178
186
|
|
|
179
187
|
val derived = linkedMapOf<String, Any?>()
|
|
180
|
-
|
|
181
|
-
if ("" != keyre) {
|
|
182
|
-
derivedClean["keyre"] = keyre
|
|
183
|
-
}
|
|
184
|
-
derived["clean"] = derivedClean
|
|
188
|
+
derived["clean"] = cleancfg
|
|
185
189
|
derived["featureorder"] = featureorder
|
|
186
190
|
opts["__derived__"] = derived
|
|
187
191
|
|
|
192
|
+
// Again over the merged result: the config's own defaults can carry one.
|
|
193
|
+
registerSensitive(cleancfg, opts - "clean" - "__derived__")
|
|
194
|
+
|
|
188
195
|
return opts
|
|
189
196
|
}
|
|
190
197
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
-- ProjectName SDK context
|
|
2
2
|
|
|
3
|
+
local json = require("dkjson")
|
|
3
4
|
local vs = require("utility.struct.struct")
|
|
4
5
|
local Control = require("core.control")
|
|
5
6
|
local Operation = require("core.operation")
|
|
@@ -217,4 +218,46 @@ function Context:make_error(code, msg)
|
|
|
217
218
|
end
|
|
218
219
|
|
|
219
220
|
|
|
221
|
+
-- The record a logger or an error dump sees; the live fields stay raw for
|
|
222
|
+
-- the pipeline's own use. Raw here, so clean's snapshot can take it.
|
|
223
|
+
function Context:to_record()
|
|
224
|
+
return {
|
|
225
|
+
id = self.id,
|
|
226
|
+
op = self.op,
|
|
227
|
+
spec = self.spec,
|
|
228
|
+
entity = self.entity,
|
|
229
|
+
result = self.result,
|
|
230
|
+
response = self.response,
|
|
231
|
+
meta = self.meta,
|
|
232
|
+
}
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
-- The serialised context leaves the pipeline, so it is cleaned.
|
|
237
|
+
function Context:to_json()
|
|
238
|
+
local record = self:to_record()
|
|
239
|
+
local clean = self.utility ~= nil and self.utility.clean or nil
|
|
240
|
+
if type(clean) == "function" then
|
|
241
|
+
record = clean(self, record)
|
|
242
|
+
end
|
|
243
|
+
local ok, text = pcall(json.encode, record, {
|
|
244
|
+
exception = function() return "null" end,
|
|
245
|
+
})
|
|
246
|
+
if ok and type(text) == "string" then
|
|
247
|
+
return text
|
|
248
|
+
end
|
|
249
|
+
return json.encode({ id = self.id })
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
function Context:__tostring()
|
|
254
|
+
return "Context " .. self:to_json()
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
function Context.__tojson(self)
|
|
259
|
+
return self:to_json()
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
|
|
220
263
|
return Context
|