@voxgig/sdkgen 1.3.8 → 1.3.10
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/audit.aontu +22 -0
- package/project/.sdk/model/feature/cache.aontu +23 -0
- package/project/.sdk/model/feature/clienttrack.aontu +20 -0
- package/project/.sdk/model/feature/debug.aontu +25 -0
- package/project/.sdk/model/feature/feature-index.aontu +20 -1
- package/project/.sdk/model/feature/idempotency.aontu +21 -0
- package/project/.sdk/model/feature/metrics.aontu +20 -0
- package/project/.sdk/model/feature/netsim.aontu +36 -0
- package/project/.sdk/model/feature/paging.aontu +23 -0
- package/project/.sdk/model/feature/proxy.aontu +23 -0
- package/project/.sdk/model/feature/ratelimit.aontu +21 -0
- package/project/.sdk/model/feature/rbac.aontu +24 -0
- package/project/.sdk/model/feature/retry.aontu +23 -0
- package/project/.sdk/model/feature/streaming.aontu +22 -0
- package/project/.sdk/model/feature/telemetry.aontu +21 -0
- package/project/.sdk/model/feature/timeout.aontu +18 -0
- package/project/.sdk/model/target/c.aontu +37 -0
- package/project/.sdk/model/target/clojure.aontu +36 -0
- package/project/.sdk/model/target/cpp.aontu +35 -0
- package/project/.sdk/model/target/csharp.aontu +35 -0
- package/project/.sdk/model/target/dart.aontu +34 -0
- package/project/.sdk/model/target/elixir.aontu +33 -0
- package/project/.sdk/model/target/haskell.aontu +47 -0
- package/project/.sdk/model/target/java.aontu +37 -0
- package/project/.sdk/model/target/kotlin.aontu +37 -0
- package/project/.sdk/model/target/ocaml.aontu +36 -0
- package/project/.sdk/model/target/perl.aontu +37 -0
- package/project/.sdk/model/target/rust.aontu +37 -0
- package/project/.sdk/model/target/scala.aontu +37 -0
- package/project/.sdk/model/target/swift.aontu +35 -0
- package/project/.sdk/model/target/zig.aontu +27 -0
- package/project/.sdk/src/cmp/c/Config_c.ts +109 -0
- package/project/.sdk/src/cmp/c/EntityBase_c.ts +61 -0
- package/project/.sdk/src/cmp/c/EntityOperation_c.ts +41 -0
- package/project/.sdk/src/cmp/c/Entity_c.ts +85 -0
- package/project/.sdk/src/cmp/c/Gitignore_c.ts +29 -0
- package/project/.sdk/src/cmp/c/MainEntity_c.ts +31 -0
- package/project/.sdk/src/cmp/c/Main_c.ts +83 -0
- package/project/.sdk/src/cmp/c/Package_c.ts +17 -0
- package/project/.sdk/src/cmp/c/TestDirect_c.ts +227 -0
- package/project/.sdk/src/cmp/c/TestEntity_c.ts +82 -0
- package/project/.sdk/src/cmp/c/Test_c.ts +51 -0
- package/project/.sdk/src/cmp/c/fragment/Entity.fragment.c +265 -0
- package/project/.sdk/src/cmp/c/fragment/EntityCreateOp.fragment.c +27 -0
- package/project/.sdk/src/cmp/c/fragment/EntityListOp.fragment.c +24 -0
- package/project/.sdk/src/cmp/c/fragment/EntityLoadOp.fragment.c +29 -0
- package/project/.sdk/src/cmp/c/fragment/EntityRemoveOp.fragment.c +29 -0
- package/project/.sdk/src/cmp/c/fragment/EntityUpdateOp.fragment.c +29 -0
- package/project/.sdk/src/cmp/c/fragment/Main.fragment.c +220 -0
- package/project/.sdk/src/cmp/c/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/c/utility_c.ts +102 -0
- package/project/.sdk/src/cmp/clojure/Config_clojure.ts +94 -0
- package/project/.sdk/src/cmp/clojure/EntityOperation_clojure.ts +35 -0
- package/project/.sdk/src/cmp/clojure/Entity_clojure.ts +77 -0
- package/project/.sdk/src/cmp/clojure/Gitignore_clojure.ts +28 -0
- package/project/.sdk/src/cmp/clojure/MainEntity_clojure.ts +21 -0
- package/project/.sdk/src/cmp/clojure/Main_clojure.ts +88 -0
- package/project/.sdk/src/cmp/clojure/Package_clojure.ts +41 -0
- package/project/.sdk/src/cmp/clojure/Test_clojure.ts +120 -0
- package/project/.sdk/src/cmp/clojure/fragment/Entity.fragment.clj +158 -0
- package/project/.sdk/src/cmp/clojure/fragment/EntityCreateOp.fragment.clj +14 -0
- package/project/.sdk/src/cmp/clojure/fragment/EntityListOp.fragment.clj +17 -0
- package/project/.sdk/src/cmp/clojure/fragment/EntityLoadOp.fragment.clj +15 -0
- package/project/.sdk/src/cmp/clojure/fragment/EntityRemoveOp.fragment.clj +15 -0
- package/project/.sdk/src/cmp/clojure/fragment/EntityUpdateOp.fragment.clj +15 -0
- package/project/.sdk/src/cmp/clojure/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/clojure/utility_clojure.ts +82 -0
- package/project/.sdk/src/cmp/cpp/Config_cpp.ts +136 -0
- package/project/.sdk/src/cmp/cpp/EntityBase_cpp.ts +51 -0
- package/project/.sdk/src/cmp/cpp/EntityOperation_cpp.ts +37 -0
- package/project/.sdk/src/cmp/cpp/Entity_cpp.ts +78 -0
- package/project/.sdk/src/cmp/cpp/Gitignore_cpp.ts +27 -0
- package/project/.sdk/src/cmp/cpp/MainEntity_cpp.ts +35 -0
- package/project/.sdk/src/cmp/cpp/Main_cpp.ts +84 -0
- package/project/.sdk/src/cmp/cpp/Package_cpp.ts +17 -0
- package/project/.sdk/src/cmp/cpp/TestDirect_cpp.ts +258 -0
- package/project/.sdk/src/cmp/cpp/TestEntity_cpp.ts +454 -0
- package/project/.sdk/src/cmp/cpp/Test_cpp.ts +36 -0
- package/project/.sdk/src/cmp/cpp/fragment/Entity.fragment.cpp +40 -0
- package/project/.sdk/src/cmp/cpp/fragment/EntityCreateOp.fragment.cpp +22 -0
- package/project/.sdk/src/cmp/cpp/fragment/EntityListOp.fragment.cpp +21 -0
- package/project/.sdk/src/cmp/cpp/fragment/EntityLoadOp.fragment.cpp +25 -0
- package/project/.sdk/src/cmp/cpp/fragment/EntityRemoveOp.fragment.cpp +21 -0
- package/project/.sdk/src/cmp/cpp/fragment/EntityUpdateOp.fragment.cpp +22 -0
- package/project/.sdk/src/cmp/cpp/fragment/Main.fragment.cpp +43 -0
- package/project/.sdk/src/cmp/cpp/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/cpp/utility_cpp.ts +83 -0
- package/project/.sdk/src/cmp/csharp/Config_csharp.ts +134 -0
- package/project/.sdk/src/cmp/csharp/EntityBase_csharp.ts +39 -0
- package/project/.sdk/src/cmp/csharp/EntityOperation_csharp.ts +41 -0
- package/project/.sdk/src/cmp/csharp/Entity_csharp.ts +85 -0
- package/project/.sdk/src/cmp/csharp/Gitignore_csharp.ts +38 -0
- package/project/.sdk/src/cmp/csharp/MainEntity_csharp.ts +36 -0
- package/project/.sdk/src/cmp/csharp/Main_csharp.ts +91 -0
- package/project/.sdk/src/cmp/csharp/Package_csharp.ts +101 -0
- package/project/.sdk/src/cmp/csharp/SdkError_csharp.ts +42 -0
- package/project/.sdk/src/cmp/csharp/TestDirect_csharp.ts +560 -0
- package/project/.sdk/src/cmp/csharp/TestEntity_csharp.ts +618 -0
- package/project/.sdk/src/cmp/csharp/Test_csharp.ts +38 -0
- package/project/.sdk/src/cmp/csharp/fragment/Entity.fragment.cs +28 -0
- package/project/.sdk/src/cmp/csharp/fragment/EntityBase.fragment.cs +268 -0
- package/project/.sdk/src/cmp/csharp/fragment/EntityCreateOp.fragment.cs +37 -0
- package/project/.sdk/src/cmp/csharp/fragment/EntityListOp.fragment.cs +35 -0
- package/project/.sdk/src/cmp/csharp/fragment/EntityLoadOp.fragment.cs +41 -0
- package/project/.sdk/src/cmp/csharp/fragment/EntityRemoveOp.fragment.cs +41 -0
- package/project/.sdk/src/cmp/csharp/fragment/EntityUpdateOp.fragment.cs +41 -0
- package/project/.sdk/src/cmp/csharp/fragment/Main.fragment.cs +278 -0
- package/project/.sdk/src/cmp/csharp/fragment/SdkError.fragment.cs +21 -0
- package/project/.sdk/src/cmp/csharp/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/csharp/utility_csharp.ts +143 -0
- package/project/.sdk/src/cmp/dart/Config_dart.ts +99 -0
- package/project/.sdk/src/cmp/dart/EntityBase_dart.ts +34 -0
- package/project/.sdk/src/cmp/dart/EntityOperation_dart.ts +43 -0
- package/project/.sdk/src/cmp/dart/EntityTypes_dart.ts +190 -0
- package/project/.sdk/src/cmp/dart/Entity_dart.ts +79 -0
- package/project/.sdk/src/cmp/dart/Gitignore_dart.ts +34 -0
- package/project/.sdk/src/cmp/dart/MainEntity_dart.ts +33 -0
- package/project/.sdk/src/cmp/dart/Main_dart.ts +105 -0
- package/project/.sdk/src/cmp/dart/Package_dart.ts +81 -0
- package/project/.sdk/src/cmp/dart/SdkError_dart.ts +42 -0
- package/project/.sdk/src/cmp/dart/TestDirect_dart.ts +498 -0
- package/project/.sdk/src/cmp/dart/TestEntity_dart.ts +552 -0
- package/project/.sdk/src/cmp/dart/Test_dart.ts +105 -0
- package/project/.sdk/src/cmp/dart/fragment/Config.fragment.dart +48 -0
- package/project/.sdk/src/cmp/dart/fragment/Direct.test.fragment.dart +25 -0
- package/project/.sdk/src/cmp/dart/fragment/Entity.fragment.dart +31 -0
- package/project/.sdk/src/cmp/dart/fragment/Entity.test.fragment.dart +67 -0
- package/project/.sdk/src/cmp/dart/fragment/EntityBase.fragment.dart +285 -0
- package/project/.sdk/src/cmp/dart/fragment/EntityCreateOp.fragment.dart +90 -0
- package/project/.sdk/src/cmp/dart/fragment/EntityListOp.fragment.dart +90 -0
- package/project/.sdk/src/cmp/dart/fragment/EntityLoadOp.fragment.dart +94 -0
- package/project/.sdk/src/cmp/dart/fragment/EntityRemoveOp.fragment.dart +94 -0
- package/project/.sdk/src/cmp/dart/fragment/EntityUpdateOp.fragment.dart +94 -0
- package/project/.sdk/src/cmp/dart/fragment/Main.fragment.dart +240 -0
- package/project/.sdk/src/cmp/dart/fragment/SdkError.fragment.dart +18 -0
- package/project/.sdk/src/cmp/dart/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/dart/utility_dart.ts +86 -0
- package/project/.sdk/src/cmp/elixir/Config_elixir.ts +101 -0
- package/project/.sdk/src/cmp/elixir/EntityOperation_elixir.ts +27 -0
- package/project/.sdk/src/cmp/elixir/Entity_elixir.ts +54 -0
- package/project/.sdk/src/cmp/elixir/Gitignore_elixir.ts +28 -0
- package/project/.sdk/src/cmp/elixir/MainEntity_elixir.ts +26 -0
- package/project/.sdk/src/cmp/elixir/Main_elixir.ts +124 -0
- package/project/.sdk/src/cmp/elixir/Package_elixir.ts +64 -0
- package/project/.sdk/src/cmp/elixir/TestDirect_elixir.ts +95 -0
- package/project/.sdk/src/cmp/elixir/TestEntity_elixir.ts +115 -0
- package/project/.sdk/src/cmp/elixir/Test_elixir.ts +47 -0
- package/project/.sdk/src/cmp/elixir/fragment/Entity.fragment.ex +37 -0
- package/project/.sdk/src/cmp/elixir/fragment/EntityCreateOp.fragment.ex +28 -0
- package/project/.sdk/src/cmp/elixir/fragment/EntityListOp.fragment.ex +30 -0
- package/project/.sdk/src/cmp/elixir/fragment/EntityLoadOp.fragment.ex +32 -0
- package/project/.sdk/src/cmp/elixir/fragment/EntityRemoveOp.fragment.ex +32 -0
- package/project/.sdk/src/cmp/elixir/fragment/EntityUpdateOp.fragment.ex +30 -0
- package/project/.sdk/src/cmp/elixir/fragment/Main.fragment.ex +218 -0
- package/project/.sdk/src/cmp/elixir/fragment/Pipeline.fragment.ex +62 -0
- package/project/.sdk/src/cmp/elixir/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/elixir/utility_elixir.ts +85 -0
- package/project/.sdk/src/cmp/go/TestEntity_go.ts +62 -0
- package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +133 -0
- package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +14 -8
- package/project/.sdk/src/cmp/haskell/Config_haskell.ts +115 -0
- package/project/.sdk/src/cmp/haskell/Entity_haskell.ts +13 -0
- package/project/.sdk/src/cmp/haskell/Gitignore_haskell.ts +27 -0
- package/project/.sdk/src/cmp/haskell/Main_haskell.ts +123 -0
- package/project/.sdk/src/cmp/haskell/Package_haskell.ts +58 -0
- package/project/.sdk/src/cmp/haskell/Test_haskell.ts +263 -0
- package/project/.sdk/src/cmp/haskell/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/haskell/utility_haskell.ts +105 -0
- package/project/.sdk/src/cmp/java/Config_java.ts +138 -0
- package/project/.sdk/src/cmp/java/EntityBase_java.ts +50 -0
- package/project/.sdk/src/cmp/java/EntityOperation_java.ts +48 -0
- package/project/.sdk/src/cmp/java/Entity_java.ts +95 -0
- package/project/.sdk/src/cmp/java/Gitignore_java.ts +37 -0
- package/project/.sdk/src/cmp/java/MainEntity_java.ts +41 -0
- package/project/.sdk/src/cmp/java/Main_java.ts +100 -0
- package/project/.sdk/src/cmp/java/Package_java.ts +126 -0
- package/project/.sdk/src/cmp/java/SdkError_java.ts +49 -0
- package/project/.sdk/src/cmp/java/TestDirect_java.ts +509 -0
- package/project/.sdk/src/cmp/java/TestEntity_java.ts +599 -0
- package/project/.sdk/src/cmp/java/Test_java.ts +42 -0
- package/project/.sdk/src/cmp/java/fragment/Entity.fragment.java +35 -0
- package/project/.sdk/src/cmp/java/fragment/EntityBase.fragment.java +235 -0
- package/project/.sdk/src/cmp/java/fragment/EntityCreateOp.fragment.java +42 -0
- package/project/.sdk/src/cmp/java/fragment/EntityListOp.fragment.java +39 -0
- package/project/.sdk/src/cmp/java/fragment/EntityLoadOp.fragment.java +45 -0
- package/project/.sdk/src/cmp/java/fragment/EntityRemoveOp.fragment.java +45 -0
- package/project/.sdk/src/cmp/java/fragment/EntityUpdateOp.fragment.java +45 -0
- package/project/.sdk/src/cmp/java/fragment/Main.fragment.java +34 -0
- package/project/.sdk/src/cmp/java/fragment/SdkError.fragment.java +27 -0
- package/project/.sdk/src/cmp/java/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/java/utility_java.ts +102 -0
- package/project/.sdk/src/cmp/js/Config_js.ts +4 -2
- package/project/.sdk/src/cmp/js/TestEntity_js.ts +1 -0
- package/project/.sdk/src/cmp/js/fragment/Entity.test.fragment.js +32 -1
- package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +81 -0
- package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +10 -5
- package/project/.sdk/src/cmp/kotlin/Config_kotlin.ts +128 -0
- package/project/.sdk/src/cmp/kotlin/EntityBase_kotlin.ts +50 -0
- package/project/.sdk/src/cmp/kotlin/EntityOperation_kotlin.ts +48 -0
- package/project/.sdk/src/cmp/kotlin/Entity_kotlin.ts +93 -0
- package/project/.sdk/src/cmp/kotlin/Gitignore_kotlin.ts +41 -0
- package/project/.sdk/src/cmp/kotlin/MainEntity_kotlin.ts +40 -0
- package/project/.sdk/src/cmp/kotlin/Main_kotlin.ts +94 -0
- package/project/.sdk/src/cmp/kotlin/Package_kotlin.ts +110 -0
- package/project/.sdk/src/cmp/kotlin/SdkError_kotlin.ts +48 -0
- package/project/.sdk/src/cmp/kotlin/TestDirect_kotlin.ts +479 -0
- package/project/.sdk/src/cmp/kotlin/TestEntity_kotlin.ts +567 -0
- package/project/.sdk/src/cmp/kotlin/Test_kotlin.ts +42 -0
- package/project/.sdk/src/cmp/kotlin/fragment/Entity.fragment.kt +28 -0
- package/project/.sdk/src/cmp/kotlin/fragment/EntityBase.fragment.kt +195 -0
- package/project/.sdk/src/cmp/kotlin/fragment/EntityCreateOp.fragment.kt +37 -0
- package/project/.sdk/src/cmp/kotlin/fragment/EntityListOp.fragment.kt +34 -0
- package/project/.sdk/src/cmp/kotlin/fragment/EntityLoadOp.fragment.kt +40 -0
- package/project/.sdk/src/cmp/kotlin/fragment/EntityRemoveOp.fragment.kt +40 -0
- package/project/.sdk/src/cmp/kotlin/fragment/EntityUpdateOp.fragment.kt +40 -0
- package/project/.sdk/src/cmp/kotlin/fragment/Main.fragment.kt +28 -0
- package/project/.sdk/src/cmp/kotlin/fragment/SdkError.fragment.kt +24 -0
- package/project/.sdk/src/cmp/kotlin/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/kotlin/utility_kotlin.ts +101 -0
- package/project/.sdk/src/cmp/lua/Entity_lua.ts +7 -9
- package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +55 -0
- package/project/.sdk/src/cmp/lua/fragment/Entity.fragment.lua +137 -0
- package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +9 -6
- package/project/.sdk/src/cmp/ocaml/Config_ocaml.ts +114 -0
- package/project/.sdk/src/cmp/ocaml/EntityOperation_ocaml.ts +63 -0
- package/project/.sdk/src/cmp/ocaml/Entity_ocaml.ts +152 -0
- package/project/.sdk/src/cmp/ocaml/Gitignore_ocaml.ts +37 -0
- package/project/.sdk/src/cmp/ocaml/MainEntity_ocaml.ts +28 -0
- package/project/.sdk/src/cmp/ocaml/Main_ocaml.ts +111 -0
- package/project/.sdk/src/cmp/ocaml/Package_ocaml.ts +47 -0
- package/project/.sdk/src/cmp/ocaml/SdkError_ocaml.ts +42 -0
- package/project/.sdk/src/cmp/ocaml/TestDirect_ocaml.ts +47 -0
- package/project/.sdk/src/cmp/ocaml/TestEntity_ocaml.ts +130 -0
- package/project/.sdk/src/cmp/ocaml/Test_ocaml.ts +35 -0
- package/project/.sdk/src/cmp/ocaml/fragment/RunOp.fragment.ml +32 -0
- package/project/.sdk/src/cmp/ocaml/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/ocaml/utility_ocaml.ts +129 -0
- package/project/.sdk/src/cmp/perl/Config_perl.ts +127 -0
- package/project/.sdk/src/cmp/perl/EntityOperation_perl.ts +42 -0
- package/project/.sdk/src/cmp/perl/Entity_perl.ts +84 -0
- package/project/.sdk/src/cmp/perl/Gitignore_perl.ts +32 -0
- package/project/.sdk/src/cmp/perl/MainEntity_perl.ts +34 -0
- package/project/.sdk/src/cmp/perl/Main_perl.ts +140 -0
- package/project/.sdk/src/cmp/perl/Package_perl.ts +63 -0
- package/project/.sdk/src/cmp/perl/TestDirect_perl.ts +433 -0
- package/project/.sdk/src/cmp/perl/TestEntity_perl.ts +515 -0
- package/project/.sdk/src/cmp/perl/Test_perl.ts +54 -0
- package/project/.sdk/src/cmp/perl/fragment/Entity.fragment.pm +235 -0
- package/project/.sdk/src/cmp/perl/fragment/EntityCreateOp.fragment.pm +31 -0
- package/project/.sdk/src/cmp/perl/fragment/EntityListOp.fragment.pm +43 -0
- package/project/.sdk/src/cmp/perl/fragment/EntityLoadOp.fragment.pm +34 -0
- package/project/.sdk/src/cmp/perl/fragment/EntityRemoveOp.fragment.pm +32 -0
- package/project/.sdk/src/cmp/perl/fragment/EntityUpdateOp.fragment.pm +32 -0
- package/project/.sdk/src/cmp/perl/fragment/Main.fragment.pm +263 -0
- package/project/.sdk/src/cmp/perl/fragment/SdkError.fragment.pm +27 -0
- package/project/.sdk/src/cmp/perl/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/perl/utility_perl.ts +30 -0
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +53 -0
- package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +124 -0
- package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +13 -6
- package/project/.sdk/src/cmp/py/Entity_py.ts +8 -9
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +48 -0
- package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +135 -28
- package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +9 -6
- package/project/.sdk/src/cmp/rb/Entity_rb.ts +8 -9
- package/project/.sdk/src/cmp/rb/ReadmeExamplesTest_rb.ts +4 -1
- package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +50 -0
- package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +122 -23
- package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +9 -6
- package/project/.sdk/src/cmp/rust/Config_rust.ts +118 -0
- package/project/.sdk/src/cmp/rust/EntityBase_rust.ts +59 -0
- package/project/.sdk/src/cmp/rust/EntityOperation_rust.ts +44 -0
- package/project/.sdk/src/cmp/rust/Entity_rust.ts +94 -0
- package/project/.sdk/src/cmp/rust/Gitignore_rust.ts +29 -0
- package/project/.sdk/src/cmp/rust/MainEntity_rust.ts +37 -0
- package/project/.sdk/src/cmp/rust/Main_rust.ts +146 -0
- package/project/.sdk/src/cmp/rust/Package_rust.ts +80 -0
- package/project/.sdk/src/cmp/rust/SdkError_rust.ts +42 -0
- package/project/.sdk/src/cmp/rust/TestDirect_rust.ts +448 -0
- package/project/.sdk/src/cmp/rust/TestEntity_rust.ts +635 -0
- package/project/.sdk/src/cmp/rust/Test_rust.ts +51 -0
- package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +288 -0
- package/project/.sdk/src/cmp/rust/fragment/EntityCreateOp.fragment.rs +29 -0
- package/project/.sdk/src/cmp/rust/fragment/EntityListOp.fragment.rs +26 -0
- package/project/.sdk/src/cmp/rust/fragment/EntityLoadOp.fragment.rs +35 -0
- package/project/.sdk/src/cmp/rust/fragment/EntityRemoveOp.fragment.rs +35 -0
- package/project/.sdk/src/cmp/rust/fragment/EntityUpdateOp.fragment.rs +35 -0
- package/project/.sdk/src/cmp/rust/fragment/Main.fragment.rs +296 -0
- package/project/.sdk/src/cmp/rust/fragment/SdkError.fragment.rs +34 -0
- package/project/.sdk/src/cmp/rust/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/rust/utility_rust.ts +104 -0
- package/project/.sdk/src/cmp/scala/Config_scala.ts +126 -0
- package/project/.sdk/src/cmp/scala/EntityBase_scala.ts +50 -0
- package/project/.sdk/src/cmp/scala/EntityOperation_scala.ts +46 -0
- package/project/.sdk/src/cmp/scala/Entity_scala.ts +87 -0
- package/project/.sdk/src/cmp/scala/Gitignore_scala.ts +31 -0
- package/project/.sdk/src/cmp/scala/MainEntity_scala.ts +40 -0
- package/project/.sdk/src/cmp/scala/Main_scala.ts +93 -0
- package/project/.sdk/src/cmp/scala/Package_scala.ts +22 -0
- package/project/.sdk/src/cmp/scala/TestDirect_scala.ts +233 -0
- package/project/.sdk/src/cmp/scala/TestEntity_scala.ts +397 -0
- package/project/.sdk/src/cmp/scala/Test_scala.ts +93 -0
- package/project/.sdk/src/cmp/scala/fragment/Entity.fragment.scala +24 -0
- package/project/.sdk/src/cmp/scala/fragment/EntityBase.fragment.scala +169 -0
- package/project/.sdk/src/cmp/scala/fragment/EntityCreateOp.fragment.scala +32 -0
- package/project/.sdk/src/cmp/scala/fragment/EntityListOp.fragment.scala +28 -0
- package/project/.sdk/src/cmp/scala/fragment/EntityLoadOp.fragment.scala +33 -0
- package/project/.sdk/src/cmp/scala/fragment/EntityRemoveOp.fragment.scala +33 -0
- package/project/.sdk/src/cmp/scala/fragment/EntityUpdateOp.fragment.scala +33 -0
- package/project/.sdk/src/cmp/scala/fragment/Main.fragment.scala +27 -0
- package/project/.sdk/src/cmp/scala/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/scala/utility_scala.ts +99 -0
- package/project/.sdk/src/cmp/swift/Config_swift.ts +127 -0
- package/project/.sdk/src/cmp/swift/EntityBase_swift.ts +38 -0
- package/project/.sdk/src/cmp/swift/EntityOperation_swift.ts +39 -0
- package/project/.sdk/src/cmp/swift/Entity_swift.ts +86 -0
- package/project/.sdk/src/cmp/swift/Gitignore_swift.ts +32 -0
- package/project/.sdk/src/cmp/swift/MainEntity_swift.ts +35 -0
- package/project/.sdk/src/cmp/swift/Main_swift.ts +94 -0
- package/project/.sdk/src/cmp/swift/Package_swift.ts +66 -0
- package/project/.sdk/src/cmp/swift/SdkError_swift.ts +41 -0
- package/project/.sdk/src/cmp/swift/TestDirect_swift.ts +84 -0
- package/project/.sdk/src/cmp/swift/TestEntity_swift.ts +84 -0
- package/project/.sdk/src/cmp/swift/Test_swift.ts +39 -0
- package/project/.sdk/src/cmp/swift/fragment/Entity.fragment.swift +23 -0
- package/project/.sdk/src/cmp/swift/fragment/EntityBase.fragment.swift +202 -0
- package/project/.sdk/src/cmp/swift/fragment/EntityCreateOp.fragment.swift +23 -0
- package/project/.sdk/src/cmp/swift/fragment/EntityListOp.fragment.swift +21 -0
- package/project/.sdk/src/cmp/swift/fragment/EntityLoadOp.fragment.swift +24 -0
- package/project/.sdk/src/cmp/swift/fragment/EntityRemoveOp.fragment.swift +24 -0
- package/project/.sdk/src/cmp/swift/fragment/EntityUpdateOp.fragment.swift +24 -0
- package/project/.sdk/src/cmp/swift/fragment/Main.fragment.swift +211 -0
- package/project/.sdk/src/cmp/swift/fragment/SdkError.fragment.swift +22 -0
- package/project/.sdk/src/cmp/swift/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/swift/utility_swift.ts +76 -0
- package/project/.sdk/src/cmp/ts/Config_ts.ts +4 -2
- package/project/.sdk/src/cmp/ts/Package_ts.ts +12 -0
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +8 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +81 -0
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +10 -5
- package/project/.sdk/src/cmp/zig/Config_zig.ts +113 -0
- package/project/.sdk/src/cmp/zig/EntityOperation_zig.ts +39 -0
- package/project/.sdk/src/cmp/zig/Entity_zig.ts +89 -0
- package/project/.sdk/src/cmp/zig/Gitignore_zig.ts +27 -0
- package/project/.sdk/src/cmp/zig/MainEntity_zig.ts +38 -0
- package/project/.sdk/src/cmp/zig/Main_zig.ts +78 -0
- package/project/.sdk/src/cmp/zig/Test_zig.ts +114 -0
- package/project/.sdk/src/cmp/zig/fragment/Entity.fragment.zig +278 -0
- package/project/.sdk/src/cmp/zig/fragment/EntityCreateOp.fragment.zig +24 -0
- package/project/.sdk/src/cmp/zig/fragment/EntityListOp.fragment.zig +21 -0
- package/project/.sdk/src/cmp/zig/fragment/EntityLoadOp.fragment.zig +26 -0
- package/project/.sdk/src/cmp/zig/fragment/EntityRemoveOp.fragment.zig +26 -0
- package/project/.sdk/src/cmp/zig/fragment/EntityUpdateOp.fragment.zig +26 -0
- package/project/.sdk/src/cmp/zig/fragment/Main.fragment.zig +258 -0
- package/project/.sdk/src/cmp/zig/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/zig/utility_zig.ts +95 -0
- package/project/.sdk/tm/c/LICENSE +22 -0
- package/project/.sdk/tm/c/Makefile +50 -0
- package/project/.sdk/tm/c/VERSION +1 -0
- package/project/.sdk/tm/c/core/context.c +145 -0
- package/project/.sdk/tm/c/core/control.c +19 -0
- package/project/.sdk/tm/c/core/error.c +24 -0
- package/project/.sdk/tm/c/core/helpers.c +228 -0
- package/project/.sdk/tm/c/core/operation.c +34 -0
- package/project/.sdk/tm/c/core/point.c +49 -0
- package/project/.sdk/tm/c/core/response.c +29 -0
- package/project/.sdk/tm/c/core/result.c +60 -0
- package/project/.sdk/tm/c/core/sdk.h +514 -0
- package/project/.sdk/tm/c/core/spec.c +94 -0
- package/project/.sdk/tm/c/core/utility.c +74 -0
- package/project/.sdk/tm/c/feature/audit.c +134 -0
- package/project/.sdk/tm/c/feature/base.c +40 -0
- package/project/.sdk/tm/c/feature/cache.c +262 -0
- package/project/.sdk/tm/c/feature/clienttrack.c +144 -0
- package/project/.sdk/tm/c/feature/debug.c +230 -0
- package/project/.sdk/tm/c/feature/idempotency.c +164 -0
- package/project/.sdk/tm/c/feature/log.c +79 -0
- package/project/.sdk/tm/c/feature/metrics.c +177 -0
- package/project/.sdk/tm/c/feature/netsim.c +211 -0
- package/project/.sdk/tm/c/feature/paging.c +223 -0
- package/project/.sdk/tm/c/feature/proxy.c +249 -0
- package/project/.sdk/tm/c/feature/ratelimit.c +124 -0
- package/project/.sdk/tm/c/feature/rbac.c +167 -0
- package/project/.sdk/tm/c/feature/retry.c +164 -0
- package/project/.sdk/tm/c/feature/streaming.c +147 -0
- package/project/.sdk/tm/c/feature/support.c +115 -0
- package/project/.sdk/tm/c/feature/telemetry.c +205 -0
- package/project/.sdk/tm/c/feature/test.c +385 -0
- package/project/.sdk/tm/c/feature/timeout.c +106 -0
- package/project/.sdk/tm/c/src/feature/README.md +1 -0
- package/project/.sdk/tm/c/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/c/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/c/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/c/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/c/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/c/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/c/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/c/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/c/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/c/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/c/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/c/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/c/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/c/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/c/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/c/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/c/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/c/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/c/tests/ctest.h +58 -0
- package/project/.sdk/tm/c/tests/feature_harness.h +441 -0
- package/project/.sdk/tm/c/tests/feature_test.c +1210 -0
- package/project/.sdk/tm/c/tests/pipeline_test.c +561 -0
- package/project/.sdk/tm/c/tests/primary_utility_test.c +573 -0
- package/project/.sdk/tm/c/tests/runner.h +274 -0
- package/project/.sdk/tm/c/tests/sdk_pipeline_test.c +89 -0
- package/project/.sdk/tm/c/tests/struct_corpus_test.c +939 -0
- package/project/.sdk/tm/c/utility/clean.c +20 -0
- package/project/.sdk/tm/c/utility/done.c +26 -0
- package/project/.sdk/tm/c/utility/feature_add.c +42 -0
- package/project/.sdk/tm/c/utility/feature_hook.c +22 -0
- package/project/.sdk/tm/c/utility/feature_init.c +22 -0
- package/project/.sdk/tm/c/utility/fetcher.c +78 -0
- package/project/.sdk/tm/c/utility/jsonparse.c +11 -0
- package/project/.sdk/tm/c/utility/make_context.c +7 -0
- package/project/.sdk/tm/c/utility/make_error.c +66 -0
- package/project/.sdk/tm/c/utility/make_fetch_def.c +43 -0
- package/project/.sdk/tm/c/utility/make_options.c +179 -0
- package/project/.sdk/tm/c/utility/make_point.c +109 -0
- package/project/.sdk/tm/c/utility/make_request.c +62 -0
- package/project/.sdk/tm/c/utility/make_response.c +45 -0
- package/project/.sdk/tm/c/utility/make_result.c +61 -0
- package/project/.sdk/tm/c/utility/make_spec.c +60 -0
- package/project/.sdk/tm/c/utility/make_url.c +88 -0
- package/project/.sdk/tm/c/utility/param.c +58 -0
- package/project/.sdk/tm/c/utility/prepare_auth.c +65 -0
- package/project/.sdk/tm/c/utility/prepare_body.c +12 -0
- package/project/.sdk/tm/c/utility/prepare_headers.c +13 -0
- package/project/.sdk/tm/c/utility/prepare_method.c +16 -0
- package/project/.sdk/tm/c/utility/prepare_params.c +30 -0
- package/project/.sdk/tm/c/utility/prepare_path.c +17 -0
- package/project/.sdk/tm/c/utility/prepare_query.c +37 -0
- package/project/.sdk/tm/c/utility/result_basic.c +43 -0
- package/project/.sdk/tm/c/utility/result_body.c +17 -0
- package/project/.sdk/tm/c/utility/result_headers.c +17 -0
- package/project/.sdk/tm/c/utility/struct/inject.c +703 -0
- package/project/.sdk/tm/c/utility/struct/re_util.c +221 -0
- package/project/.sdk/tm/c/utility/struct/regex.c +1103 -0
- package/project/.sdk/tm/c/utility/struct/regex.h +84 -0
- package/project/.sdk/tm/c/utility/struct/transform.c +2224 -0
- package/project/.sdk/tm/c/utility/struct/utility.c +1971 -0
- package/project/.sdk/tm/c/utility/struct/value.c +640 -0
- package/project/.sdk/tm/c/utility/struct/value.h +273 -0
- package/project/.sdk/tm/c/utility/struct/value_io.c +366 -0
- package/project/.sdk/tm/c/utility/struct/value_io.h +31 -0
- package/project/.sdk/tm/c/utility/struct/voxgig_struct.h +216 -0
- package/project/.sdk/tm/c/utility/transform_request.c +21 -0
- package/project/.sdk/tm/c/utility/transform_response.c +36 -0
- package/project/.sdk/tm/clojure/LICENSE +22 -0
- package/project/.sdk/tm/clojure/Makefile +15 -0
- package/project/.sdk/tm/clojure/VERSION +1 -0
- package/project/.sdk/tm/clojure/src/feature/README.md +1 -0
- package/project/.sdk/tm/clojure/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/clojure/src/sdk/client.clj +119 -0
- package/project/.sdk/tm/clojure/src/sdk/core.clj +901 -0
- package/project/.sdk/tm/clojure/src/sdk/features.clj +1027 -0
- package/project/.sdk/tm/clojure/src/voxgig/struct.clj +1734 -0
- package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +596 -0
- package/project/.sdk/tm/clojure/test/sdk/test/netsim.clj +42 -0
- package/project/.sdk/tm/clojure/test/sdk/test/pipeline.clj +314 -0
- package/project/.sdk/tm/clojure/test/sdk/test/primary.clj +52 -0
- package/project/.sdk/tm/clojure/test/sdk/test/struct_corpus.clj +337 -0
- package/project/.sdk/tm/clojure/test/sdk/test_runner.clj +39 -0
- package/project/.sdk/tm/clojure/test/sdk/testutil.clj +35 -0
- package/project/.sdk/tm/cpp/LICENSE +22 -0
- package/project/.sdk/tm/cpp/Makefile +36 -0
- package/project/.sdk/tm/cpp/VERSION +1 -0
- package/project/.sdk/tm/cpp/core/sdk.hpp +16 -0
- package/project/.sdk/tm/cpp/core/struct.hpp +225 -0
- package/project/.sdk/tm/cpp/core/types.hpp +1105 -0
- package/project/.sdk/tm/cpp/feature/audit.hpp +107 -0
- package/project/.sdk/tm/cpp/feature/base.hpp +34 -0
- package/project/.sdk/tm/cpp/feature/cache.hpp +189 -0
- package/project/.sdk/tm/cpp/feature/clienttrack.hpp +105 -0
- package/project/.sdk/tm/cpp/feature/debug.hpp +157 -0
- package/project/.sdk/tm/cpp/feature/idempotency.hpp +119 -0
- package/project/.sdk/tm/cpp/feature/log.hpp +90 -0
- package/project/.sdk/tm/cpp/feature/metrics.hpp +103 -0
- package/project/.sdk/tm/cpp/feature/netsim.hpp +152 -0
- package/project/.sdk/tm/cpp/feature/options.hpp +156 -0
- package/project/.sdk/tm/cpp/feature/paging.hpp +156 -0
- package/project/.sdk/tm/cpp/feature/proxy.hpp +145 -0
- package/project/.sdk/tm/cpp/feature/ratelimit.hpp +87 -0
- package/project/.sdk/tm/cpp/feature/rbac.hpp +108 -0
- package/project/.sdk/tm/cpp/feature/retry.hpp +130 -0
- package/project/.sdk/tm/cpp/feature/streaming.hpp +98 -0
- package/project/.sdk/tm/cpp/feature/telemetry.hpp +139 -0
- package/project/.sdk/tm/cpp/feature/test.hpp +289 -0
- package/project/.sdk/tm/cpp/feature/timeout.hpp +88 -0
- package/project/.sdk/tm/cpp/src/feature/README.md +1 -0
- package/project/.sdk/tm/cpp/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/test/custom_utility_test.cpp +57 -0
- package/project/.sdk/tm/cpp/test/exists_test.cpp +16 -0
- package/project/.sdk/tm/cpp/test/feature_test.cpp +911 -0
- package/project/.sdk/tm/cpp/test/harness.hpp +344 -0
- package/project/.sdk/tm/cpp/test/netsim_test.cpp +48 -0
- package/project/.sdk/tm/cpp/test/pipeline_test.cpp +526 -0
- package/project/.sdk/tm/cpp/test/primary_utility_test.cpp +841 -0
- package/project/.sdk/tm/cpp/test/runner_support.hpp +437 -0
- package/project/.sdk/tm/cpp/test/sdk-test-control.json +19 -0
- package/project/.sdk/tm/cpp/test/struct_corpus_test.cpp +494 -0
- package/project/.sdk/tm/cpp/test/struct_runner.hpp +314 -0
- package/project/.sdk/tm/cpp/test/testlib.hpp +82 -0
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +1054 -0
- package/project/.sdk/tm/cpp/utility/voxgigstruct/value.hpp +525 -0
- package/project/.sdk/tm/cpp/utility/voxgigstruct/value_io.hpp +315 -0
- package/project/.sdk/tm/cpp/utility/voxgigstruct/voxgig_struct.hpp +3379 -0
- package/project/.sdk/tm/csharp/LICENSE +22 -0
- package/project/.sdk/tm/csharp/Makefile +43 -0
- package/project/.sdk/tm/csharp/VERSION +1 -0
- package/project/.sdk/tm/csharp/core/Context.cs +257 -0
- package/project/.sdk/tm/csharp/core/Control.cs +17 -0
- package/project/.sdk/tm/csharp/core/Helpers.cs +61 -0
- package/project/.sdk/tm/csharp/core/Operation.cs +51 -0
- package/project/.sdk/tm/csharp/core/Point.cs +68 -0
- package/project/.sdk/tm/csharp/core/Response.cs +45 -0
- package/project/.sdk/tm/csharp/core/Result.cs +63 -0
- package/project/.sdk/tm/csharp/core/Spec.cs +81 -0
- package/project/.sdk/tm/csharp/core/Types.cs +21 -0
- package/project/.sdk/tm/csharp/core/Utility.cs +88 -0
- package/project/.sdk/tm/csharp/feature/AuditFeature.cs +116 -0
- package/project/.sdk/tm/csharp/feature/BaseFeature.cs +39 -0
- package/project/.sdk/tm/csharp/feature/CacheFeature.cs +186 -0
- package/project/.sdk/tm/csharp/feature/ClienttrackFeature.cs +103 -0
- package/project/.sdk/tm/csharp/feature/DebugFeature.cs +157 -0
- package/project/.sdk/tm/csharp/feature/FeatureOptions.cs +197 -0
- package/project/.sdk/tm/csharp/feature/IdempotencyFeature.cs +97 -0
- package/project/.sdk/tm/csharp/feature/LogFeature.cs +109 -0
- package/project/.sdk/tm/csharp/feature/MetricsFeature.cs +117 -0
- package/project/.sdk/tm/csharp/feature/NetsimFeature.cs +200 -0
- package/project/.sdk/tm/csharp/feature/PagingFeature.cs +187 -0
- package/project/.sdk/tm/csharp/feature/ProxyFeature.cs +138 -0
- package/project/.sdk/tm/csharp/feature/RatelimitFeature.cs +89 -0
- package/project/.sdk/tm/csharp/feature/RbacFeature.cs +124 -0
- package/project/.sdk/tm/csharp/feature/RetryFeature.cs +174 -0
- package/project/.sdk/tm/csharp/feature/StreamingFeature.cs +93 -0
- package/project/.sdk/tm/csharp/feature/TelemetryFeature.cs +145 -0
- package/project/.sdk/tm/csharp/feature/TestFeature.cs +368 -0
- package/project/.sdk/tm/csharp/feature/TimeoutFeature.cs +69 -0
- package/project/.sdk/tm/csharp/src/feature/README.md +1 -0
- package/project/.sdk/tm/csharp/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/csharp/test/CustomUtilityTest.cs +51 -0
- package/project/.sdk/tm/csharp/test/ExistsTest.cs +17 -0
- package/project/.sdk/tm/csharp/test/FeatureTest.cs +1653 -0
- package/project/.sdk/tm/csharp/test/NetsimTest.cs +67 -0
- package/project/.sdk/tm/csharp/test/PipelineTest.cs +605 -0
- package/project/.sdk/tm/csharp/test/PrimaryUtilityTest.cs +957 -0
- package/project/.sdk/tm/csharp/test/Runner.cs +626 -0
- package/project/.sdk/tm/csharp/test/StructRunner.cs +276 -0
- package/project/.sdk/tm/csharp/test/StructUtilityTest.cs +1273 -0
- package/project/.sdk/tm/csharp/test/sdk-test-control.json +19 -0
- package/project/.sdk/tm/csharp/utility/Clean.cs +11 -0
- package/project/.sdk/tm/csharp/utility/Done.cs +28 -0
- package/project/.sdk/tm/csharp/utility/FeatureAdd.cs +54 -0
- package/project/.sdk/tm/csharp/utility/FeatureHook.cs +35 -0
- package/project/.sdk/tm/csharp/utility/FeatureInit.cs +28 -0
- package/project/.sdk/tm/csharp/utility/Fetcher.cs +181 -0
- package/project/.sdk/tm/csharp/utility/MakeContext.cs +11 -0
- package/project/.sdk/tm/csharp/utility/MakeError.cs +69 -0
- package/project/.sdk/tm/csharp/utility/MakeFetchDef.cs +38 -0
- package/project/.sdk/tm/csharp/utility/MakeOptions.cs +203 -0
- package/project/.sdk/tm/csharp/utility/MakePoint.cs +127 -0
- package/project/.sdk/tm/csharp/utility/MakeRequest.cs +87 -0
- package/project/.sdk/tm/csharp/utility/MakeResponse.cs +55 -0
- package/project/.sdk/tm/csharp/utility/MakeResult.cs +64 -0
- package/project/.sdk/tm/csharp/utility/MakeSpec.cs +64 -0
- package/project/.sdk/tm/csharp/utility/MakeUrl.cs +54 -0
- package/project/.sdk/tm/csharp/utility/Param.cs +67 -0
- package/project/.sdk/tm/csharp/utility/PrepareAuth.cs +54 -0
- package/project/.sdk/tm/csharp/utility/PrepareBody.cs +19 -0
- package/project/.sdk/tm/csharp/utility/PrepareHeaders.cs +22 -0
- package/project/.sdk/tm/csharp/utility/PrepareMethod.cs +22 -0
- package/project/.sdk/tm/csharp/utility/PrepareParams.cs +38 -0
- package/project/.sdk/tm/csharp/utility/PreparePath.cs +18 -0
- package/project/.sdk/tm/csharp/utility/PrepareQuery.cs +40 -0
- package/project/.sdk/tm/csharp/utility/Register.cs +41 -0
- package/project/.sdk/tm/csharp/utility/ResultBasic.cs +39 -0
- package/project/.sdk/tm/csharp/utility/ResultBody.cs +22 -0
- package/project/.sdk/tm/csharp/utility/ResultHeaders.cs +26 -0
- package/project/.sdk/tm/csharp/utility/TransformRequest.cs +39 -0
- package/project/.sdk/tm/csharp/utility/TransformResponse.cs +53 -0
- package/project/.sdk/tm/csharp/utility/struct/Struct.cs +3582 -0
- package/project/.sdk/tm/dart/LICENSE +22 -0
- package/project/.sdk/tm/dart/Makefile +50 -0
- package/project/.sdk/tm/dart/lib/Context.dart +150 -0
- package/project/.sdk/tm/dart/lib/Control.dart +15 -0
- package/project/.sdk/tm/dart/lib/Operation.dart +31 -0
- package/project/.sdk/tm/dart/lib/Point.dart +43 -0
- package/project/.sdk/tm/dart/lib/Response.dart +32 -0
- package/project/.sdk/tm/dart/lib/Result.dart +39 -0
- package/project/.sdk/tm/dart/lib/Spec.dart +49 -0
- package/project/.sdk/tm/dart/lib/feature/audit/AuditFeature.dart +103 -0
- package/project/.sdk/tm/dart/lib/feature/base/BaseFeature.dart +76 -0
- package/project/.sdk/tm/dart/lib/feature/cache/CacheFeature.dart +152 -0
- package/project/.sdk/tm/dart/lib/feature/clienttrack/ClienttrackFeature.dart +104 -0
- package/project/.sdk/tm/dart/lib/feature/debug/DebugFeature.dart +153 -0
- package/project/.sdk/tm/dart/lib/feature/idempotency/IdempotencyFeature.dart +92 -0
- package/project/.sdk/tm/dart/lib/feature/log/LogFeature.dart +85 -0
- package/project/.sdk/tm/dart/lib/feature/metrics/MetricsFeature.dart +103 -0
- package/project/.sdk/tm/dart/lib/feature/netsim/NetsimFeature.dart +186 -0
- package/project/.sdk/tm/dart/lib/feature/paging/PagingFeature.dart +145 -0
- package/project/.sdk/tm/dart/lib/feature/proxy/ProxyFeature.dart +118 -0
- package/project/.sdk/tm/dart/lib/feature/ratelimit/RatelimitFeature.dart +103 -0
- package/project/.sdk/tm/dart/lib/feature/rbac/RbacFeature.dart +121 -0
- package/project/.sdk/tm/dart/lib/feature/retry/RetryFeature.dart +155 -0
- package/project/.sdk/tm/dart/lib/feature/streaming/StreamingFeature.dart +97 -0
- package/project/.sdk/tm/dart/lib/feature/telemetry/TelemetryFeature.dart +136 -0
- package/project/.sdk/tm/dart/lib/feature/test/TestFeature.dart +270 -0
- package/project/.sdk/tm/dart/lib/feature/timeout/TimeoutFeature.dart +104 -0
- package/project/.sdk/tm/dart/lib/utility/CleanUtility.dart +12 -0
- package/project/.sdk/tm/dart/lib/utility/DoneUtility.dart +18 -0
- package/project/.sdk/tm/dart/lib/utility/ErrUtility.dart +46 -0
- package/project/.sdk/tm/dart/lib/utility/FeatureAddUtility.dart +35 -0
- package/project/.sdk/tm/dart/lib/utility/FeatureHookUtility.dart +20 -0
- package/project/.sdk/tm/dart/lib/utility/FeatureInitUtility.dart +9 -0
- package/project/.sdk/tm/dart/lib/utility/FetcherUtility.dart +95 -0
- package/project/.sdk/tm/dart/lib/utility/MakeContextUtility.dart +6 -0
- package/project/.sdk/tm/dart/lib/utility/MakeErrorUtility.dart +67 -0
- package/project/.sdk/tm/dart/lib/utility/MakeFetchDefUtility.dart +42 -0
- package/project/.sdk/tm/dart/lib/utility/MakeOptionsUtility.dart +147 -0
- package/project/.sdk/tm/dart/lib/utility/MakePointUtility.dart +84 -0
- package/project/.sdk/tm/dart/lib/utility/MakeRequestUtility.dart +63 -0
- package/project/.sdk/tm/dart/lib/utility/MakeResponseUtility.dart +54 -0
- package/project/.sdk/tm/dart/lib/utility/MakeResultUtility.dart +49 -0
- package/project/.sdk/tm/dart/lib/utility/MakeSpecUtility.dart +61 -0
- package/project/.sdk/tm/dart/lib/utility/MakeUrlUtility.dart +51 -0
- package/project/.sdk/tm/dart/lib/utility/ParamUtility.dart +56 -0
- package/project/.sdk/tm/dart/lib/utility/PrepareAuthUtility.dart +46 -0
- package/project/.sdk/tm/dart/lib/utility/PrepareBodyUtility.dart +19 -0
- package/project/.sdk/tm/dart/lib/utility/PrepareHeadersUtility.dart +11 -0
- package/project/.sdk/tm/dart/lib/utility/PrepareMethodUtility.dart +15 -0
- package/project/.sdk/tm/dart/lib/utility/PrepareParamsUtility.dart +23 -0
- package/project/.sdk/tm/dart/lib/utility/PreparePathUtility.dart +9 -0
- package/project/.sdk/tm/dart/lib/utility/PrepareQueryUtility.dart +18 -0
- package/project/.sdk/tm/dart/lib/utility/ResultBasicUtility.dart +29 -0
- package/project/.sdk/tm/dart/lib/utility/ResultBodyUtility.dart +15 -0
- package/project/.sdk/tm/dart/lib/utility/ResultHeadersUtility.dart +18 -0
- package/project/.sdk/tm/dart/lib/utility/StructUtility.dart +127 -0
- package/project/.sdk/tm/dart/lib/utility/TransformRequestUtility.dart +28 -0
- package/project/.sdk/tm/dart/lib/utility/TransformResponseUtility.dart +44 -0
- package/project/.sdk/tm/dart/lib/utility/Utility.dart +230 -0
- package/project/.sdk/tm/dart/lib/utility/voxgig_struct.dart +2456 -0
- package/project/.sdk/tm/dart/src/feature/README.md +3 -0
- package/project/.sdk/tm/dart/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/dart/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/dart/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/dart/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/dart/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/dart/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/dart/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/dart/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/dart/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/dart/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/dart/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/dart/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/dart/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/dart/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/dart/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/dart/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/dart/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/dart/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/dart/test/custom_test.dart +65 -0
- package/project/.sdk/tm/dart/test/exists_test.dart +12 -0
- package/project/.sdk/tm/dart/test/feature/harness.dart +329 -0
- package/project/.sdk/tm/dart/test/feature_test.dart +1139 -0
- package/project/.sdk/tm/dart/test/harness.dart +153 -0
- package/project/.sdk/tm/dart/test/netsim_test.dart +48 -0
- package/project/.sdk/tm/dart/test/pipeline_test.dart +608 -0
- package/project/.sdk/tm/dart/test/primary_test.dart +411 -0
- package/project/.sdk/tm/dart/test/runner.dart +406 -0
- package/project/.sdk/tm/dart/test/sdk-test-control.json +19 -0
- package/project/.sdk/tm/dart/test/struct_corpus.dart +531 -0
- package/project/.sdk/tm/dart/test/struct_test.dart +41 -0
- package/project/.sdk/tm/dart/test/utility.dart +159 -0
- package/project/.sdk/tm/elixir/LICENSE +21 -0
- package/project/.sdk/tm/elixir/Makefile +15 -0
- package/project/.sdk/tm/elixir/VERSION +1 -0
- package/project/.sdk/tm/elixir/lib/projectname/context.ex +138 -0
- package/project/.sdk/tm/elixir/lib/projectname/core.ex +125 -0
- package/project/.sdk/tm/elixir/lib/projectname/entity_base.ex +155 -0
- package/project/.sdk/tm/elixir/lib/projectname/error.ex +16 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/audit.ex +125 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/cache.ex +170 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/clienttrack.ex +136 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/debug.ex +232 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/idempotency.ex +107 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/log.ex +62 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/metrics.ex +130 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/netsim.ex +213 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/paging.ex +191 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/proxy.ex +142 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/ratelimit.ex +81 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/rbac.ex +139 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/retry.ex +150 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/streaming.ex +107 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/telemetry.ex +172 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/test.ex +285 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/timeout.ex +64 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature.ex +90 -0
- package/project/.sdk/tm/elixir/lib/projectname/helpers.ex +66 -0
- package/project/.sdk/tm/elixir/lib/projectname/json.ex +115 -0
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +1257 -0
- package/project/.sdk/tm/elixir/lib/utility/struct/voxgig_struct.ex +2615 -0
- package/project/.sdk/tm/elixir/src/feature/README.md +3 -0
- package/project/.sdk/tm/elixir/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/elixir/test/feature_test.exs +879 -0
- package/project/.sdk/tm/elixir/test/netsim_test.exs +58 -0
- package/project/.sdk/tm/elixir/test/pipeline_test.exs +558 -0
- package/project/.sdk/tm/elixir/test/primary_utility_test.exs +133 -0
- package/project/.sdk/tm/elixir/test/stream_test.exs +119 -0
- package/project/.sdk/tm/elixir/test/struct_corpus_test.exs +18 -0
- package/project/.sdk/tm/elixir/test/support/feature_harness.ex +346 -0
- package/project/.sdk/tm/elixir/test/support/struct_corpus.ex +677 -0
- package/project/.sdk/tm/elixir/test/test_helper.exs +1 -0
- package/project/.sdk/tm/go/core/context.go +10 -0
- package/project/.sdk/tm/go/core/control.go +2 -0
- package/project/.sdk/tm/go/core/result.go +6 -0
- package/project/.sdk/tm/go/core/types.go +1 -0
- package/project/.sdk/tm/go/feature/audit_feature.go +110 -0
- package/project/.sdk/tm/go/feature/base_feature.go +8 -0
- package/project/.sdk/tm/go/feature/cache_feature.go +171 -0
- package/project/.sdk/tm/go/feature/clienttrack_feature.go +100 -0
- package/project/.sdk/tm/go/feature/debug_feature.go +159 -0
- package/project/.sdk/tm/go/feature/feature_options.go +204 -0
- package/project/.sdk/tm/go/feature/idempotency_feature.go +115 -0
- package/project/.sdk/tm/go/feature/metrics_feature.go +112 -0
- package/project/.sdk/tm/go/feature/netsim_feature.go +184 -0
- package/project/.sdk/tm/go/feature/paging_feature.go +173 -0
- package/project/.sdk/tm/go/feature/proxy_feature.go +121 -0
- package/project/.sdk/tm/go/feature/ratelimit_feature.go +88 -0
- package/project/.sdk/tm/go/feature/rbac_feature.go +126 -0
- package/project/.sdk/tm/go/feature/retry_feature.go +165 -0
- package/project/.sdk/tm/go/feature/streaming_feature.go +119 -0
- package/project/.sdk/tm/go/feature/telemetry_feature.go +142 -0
- package/project/.sdk/tm/go/feature/test_feature.go +78 -3
- package/project/.sdk/tm/go/feature/timeout_feature.go +88 -0
- package/project/.sdk/tm/go/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/go/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/go/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/go/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/go/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/go/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/go/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/go/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/go/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/go/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/go/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/go/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/go/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/go/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/go/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/go/test/feature_test.go +1465 -0
- package/project/.sdk/tm/go/test/netsim_test.go +70 -0
- package/project/.sdk/tm/go/test/pipeline_test.go +571 -0
- package/project/.sdk/tm/go/utility/feature_add.go +38 -0
- package/project/.sdk/tm/go/utility/fetcher.go +13 -1
- package/project/.sdk/tm/go/utility/make_error.go +8 -0
- package/project/.sdk/tm/go/utility/make_options.go +62 -0
- package/project/.sdk/tm/go/utility/make_point.go +6 -0
- package/project/.sdk/tm/go-cli/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/LICENSE +21 -0
- package/project/.sdk/tm/haskell/Makefile +22 -0
- package/project/.sdk/tm/haskell/VERSION +1 -0
- package/project/.sdk/tm/haskell/src/SdkFeatures.hs +1278 -0
- package/project/.sdk/tm/haskell/src/SdkHelpers.hs +337 -0
- package/project/.sdk/tm/haskell/src/SdkRuntime.hs +1007 -0
- package/project/.sdk/tm/haskell/src/SdkTypes.hs +186 -0
- package/project/.sdk/tm/haskell/src/VoxgigStruct.hs +2299 -0
- package/project/.sdk/tm/haskell/src/Vregex.hs +237 -0
- package/project/.sdk/tm/haskell/src/feature/README.md +5 -0
- package/project/.sdk/tm/haskell/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/haskell/test/Harness.hs +276 -0
- package/project/.sdk/tm/haskell/test/Runner.hs +47 -0
- package/project/.sdk/tm/haskell/test/StructCorpus.hs +449 -0
- package/project/.sdk/tm/haskell/test/TCustomUtility.hs +38 -0
- package/project/.sdk/tm/haskell/test/TFeature.hs +794 -0
- package/project/.sdk/tm/haskell/test/TNetsim.hs +50 -0
- package/project/.sdk/tm/haskell/test/TPipeline.hs +334 -0
- package/project/.sdk/tm/haskell/test/TPrimaryUtility.hs +386 -0
- package/project/.sdk/tm/haskell/test/TestJson.hs +107 -0
- package/project/.sdk/tm/haskell/test/Testutil.hs +59 -0
- package/project/.sdk/tm/java/LICENSE +22 -0
- package/project/.sdk/tm/java/Makefile +44 -0
- package/project/.sdk/tm/java/VERSION +1 -0
- package/project/.sdk/tm/java/core/Context.java +269 -0
- package/project/.sdk/tm/java/core/Control.java +23 -0
- package/project/.sdk/tm/java/core/Entity.java +13 -0
- package/project/.sdk/tm/java/core/Feature.java +45 -0
- package/project/.sdk/tm/java/core/FeaturePlacement.java +13 -0
- package/project/.sdk/tm/java/core/Helpers.java +50 -0
- package/project/.sdk/tm/java/core/Operation.java +47 -0
- package/project/.sdk/tm/java/core/Point.java +90 -0
- package/project/.sdk/tm/java/core/Response.java +48 -0
- package/project/.sdk/tm/java/core/Result.java +64 -0
- package/project/.sdk/tm/java/core/SdkClient.java +280 -0
- package/project/.sdk/tm/java/core/SdkEntity.java +28 -0
- package/project/.sdk/tm/java/core/Spec.java +84 -0
- package/project/.sdk/tm/java/core/Utility.java +128 -0
- package/project/.sdk/tm/java/feature/AuditFeature.java +113 -0
- package/project/.sdk/tm/java/feature/BaseFeature.java +91 -0
- package/project/.sdk/tm/java/feature/CacheFeature.java +184 -0
- package/project/.sdk/tm/java/feature/ClienttrackFeature.java +103 -0
- package/project/.sdk/tm/java/feature/DebugFeature.java +163 -0
- package/project/.sdk/tm/java/feature/FeatureOptions.java +204 -0
- package/project/.sdk/tm/java/feature/IdempotencyFeature.java +115 -0
- package/project/.sdk/tm/java/feature/LogFeature.java +143 -0
- package/project/.sdk/tm/java/feature/MetricsFeature.java +115 -0
- package/project/.sdk/tm/java/feature/NetsimFeature.java +181 -0
- package/project/.sdk/tm/java/feature/PagingFeature.java +178 -0
- package/project/.sdk/tm/java/feature/ProxyFeature.java +122 -0
- package/project/.sdk/tm/java/feature/RatelimitFeature.java +83 -0
- package/project/.sdk/tm/java/feature/RbacFeature.java +132 -0
- package/project/.sdk/tm/java/feature/RetryFeature.java +156 -0
- package/project/.sdk/tm/java/feature/StreamingFeature.java +110 -0
- package/project/.sdk/tm/java/feature/TelemetryFeature.java +146 -0
- package/project/.sdk/tm/java/feature/TestFeature.java +333 -0
- package/project/.sdk/tm/java/feature/TimeoutFeature.java +89 -0
- package/project/.sdk/tm/java/src/feature/README.md +1 -0
- package/project/.sdk/tm/java/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/java/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/java/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/java/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/java/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/java/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/java/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/java/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/java/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/java/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/java/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/java/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/java/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/java/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/java/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/java/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/java/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/java/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/java/test/CustomUtilityTest.java +59 -0
- package/project/.sdk/tm/java/test/ExistsTest.java +16 -0
- package/project/.sdk/tm/java/test/FeatureHarness.java +448 -0
- package/project/.sdk/tm/java/test/FeatureTest.java +1018 -0
- package/project/.sdk/tm/java/test/NetsimTest.java +59 -0
- package/project/.sdk/tm/java/test/PipelineTest.java +618 -0
- package/project/.sdk/tm/java/test/PrimaryUtilityTest.java +864 -0
- package/project/.sdk/tm/java/test/RunnerSupport.java +545 -0
- package/project/.sdk/tm/java/test/StructCorpusTest.java +351 -0
- package/project/.sdk/tm/java/test/StructRunner.java +281 -0
- package/project/.sdk/tm/java/test/sdk-test-control.json +19 -0
- package/project/.sdk/tm/java/utility/Clean.java +12 -0
- package/project/.sdk/tm/java/utility/Done.java +29 -0
- package/project/.sdk/tm/java/utility/FeatureAdd.java +59 -0
- package/project/.sdk/tm/java/utility/FeatureHookUtil.java +72 -0
- package/project/.sdk/tm/java/utility/FeatureInit.java +35 -0
- package/project/.sdk/tm/java/utility/Fetcher.java +170 -0
- package/project/.sdk/tm/java/utility/Json.java +268 -0
- package/project/.sdk/tm/java/utility/MakeContext.java +14 -0
- package/project/.sdk/tm/java/utility/MakeError.java +81 -0
- package/project/.sdk/tm/java/utility/MakeFetchDef.java +48 -0
- package/project/.sdk/tm/java/utility/MakeOptions.java +168 -0
- package/project/.sdk/tm/java/utility/MakePoint.java +118 -0
- package/project/.sdk/tm/java/utility/MakeRequest.java +83 -0
- package/project/.sdk/tm/java/utility/MakeResponse.java +54 -0
- package/project/.sdk/tm/java/utility/MakeResult.java +68 -0
- package/project/.sdk/tm/java/utility/MakeSpec.java +69 -0
- package/project/.sdk/tm/java/utility/MakeUrl.java +67 -0
- package/project/.sdk/tm/java/utility/Param.java +74 -0
- package/project/.sdk/tm/java/utility/PrepareAuth.java +66 -0
- package/project/.sdk/tm/java/utility/PrepareBody.java +16 -0
- package/project/.sdk/tm/java/utility/PrepareHeaders.java +28 -0
- package/project/.sdk/tm/java/utility/PrepareMethod.java +28 -0
- package/project/.sdk/tm/java/utility/PrepareParams.java +50 -0
- package/project/.sdk/tm/java/utility/PreparePath.java +26 -0
- package/project/.sdk/tm/java/utility/PrepareQuery.java +54 -0
- package/project/.sdk/tm/java/utility/Register.java +41 -0
- package/project/.sdk/tm/java/utility/ResultBasic.java +36 -0
- package/project/.sdk/tm/java/utility/ResultBody.java +23 -0
- package/project/.sdk/tm/java/utility/ResultHeaders.java +36 -0
- package/project/.sdk/tm/java/utility/TransformRequest.java +35 -0
- package/project/.sdk/tm/java/utility/TransformResponse.java +52 -0
- package/project/.sdk/tm/java/utility/struct/Struct.java +3550 -0
- package/project/.sdk/tm/js/src/feature/audit/AuditFeature.js +96 -0
- package/project/.sdk/tm/js/src/feature/cache/CacheFeature.js +150 -0
- package/project/.sdk/tm/js/src/feature/clienttrack/ClienttrackFeature.js +104 -0
- package/project/.sdk/tm/js/src/feature/debug/DebugFeature.js +132 -0
- package/project/.sdk/tm/js/src/feature/idempotency/IdempotencyFeature.js +95 -0
- package/project/.sdk/tm/js/src/feature/metrics/MetricsFeature.js +102 -0
- package/project/.sdk/tm/js/src/feature/netsim/NetsimFeature.js +187 -0
- package/project/.sdk/tm/js/src/feature/paging/PagingFeature.js +139 -0
- package/project/.sdk/tm/js/src/feature/proxy/ProxyFeature.js +110 -0
- package/project/.sdk/tm/js/src/feature/ratelimit/RatelimitFeature.js +106 -0
- package/project/.sdk/tm/js/src/feature/rbac/RbacFeature.js +102 -0
- package/project/.sdk/tm/js/src/feature/retry/RetryFeature.js +158 -0
- package/project/.sdk/tm/js/src/feature/streaming/StreamingFeature.js +96 -0
- package/project/.sdk/tm/js/src/feature/telemetry/TelemetryFeature.js +128 -0
- package/project/.sdk/tm/js/src/feature/test/TestFeature.js +58 -1
- package/project/.sdk/tm/js/src/feature/timeout/TimeoutFeature.js +101 -0
- package/project/.sdk/tm/js/src/utility/FeatureHookUtility.js +4 -1
- package/project/.sdk/tm/js/src/utility/MakeErrorUtility.js +9 -0
- package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +31 -1
- package/project/.sdk/tm/js/test/feature/harness.js +275 -0
- package/project/.sdk/tm/js/test/feature.test.js +772 -0
- package/project/.sdk/tm/js/test/netsim.test.js +43 -0
- package/project/.sdk/tm/js/test/pipeline.test.js +382 -0
- package/project/.sdk/tm/kotlin/LICENSE +22 -0
- package/project/.sdk/tm/kotlin/Makefile +43 -0
- package/project/.sdk/tm/kotlin/VERSION +1 -0
- package/project/.sdk/tm/kotlin/core/Context.kt +247 -0
- package/project/.sdk/tm/kotlin/core/Control.kt +21 -0
- package/project/.sdk/tm/kotlin/core/Helpers.kt +49 -0
- package/project/.sdk/tm/kotlin/core/Interfaces.kt +88 -0
- package/project/.sdk/tm/kotlin/core/Operation.kt +43 -0
- package/project/.sdk/tm/kotlin/core/Point.kt +83 -0
- package/project/.sdk/tm/kotlin/core/Response.kt +43 -0
- package/project/.sdk/tm/kotlin/core/Result.kt +61 -0
- package/project/.sdk/tm/kotlin/core/SdkClient.kt +266 -0
- package/project/.sdk/tm/kotlin/core/Spec.kt +76 -0
- package/project/.sdk/tm/kotlin/core/Utility.kt +93 -0
- package/project/.sdk/tm/kotlin/feature/AuditFeature.kt +96 -0
- package/project/.sdk/tm/kotlin/feature/BaseFeature.kt +57 -0
- package/project/.sdk/tm/kotlin/feature/CacheFeature.kt +167 -0
- package/project/.sdk/tm/kotlin/feature/ClienttrackFeature.kt +84 -0
- package/project/.sdk/tm/kotlin/feature/DebugFeature.kt +141 -0
- package/project/.sdk/tm/kotlin/feature/FeatureOptions.kt +191 -0
- package/project/.sdk/tm/kotlin/feature/IdempotencyFeature.kt +98 -0
- package/project/.sdk/tm/kotlin/feature/LogFeature.kt +92 -0
- package/project/.sdk/tm/kotlin/feature/MetricsFeature.kt +96 -0
- package/project/.sdk/tm/kotlin/feature/NetsimFeature.kt +162 -0
- package/project/.sdk/tm/kotlin/feature/PagingFeature.kt +143 -0
- package/project/.sdk/tm/kotlin/feature/ProxyFeature.kt +109 -0
- package/project/.sdk/tm/kotlin/feature/RatelimitFeature.kt +77 -0
- package/project/.sdk/tm/kotlin/feature/RbacFeature.kt +100 -0
- package/project/.sdk/tm/kotlin/feature/RetryFeature.kt +140 -0
- package/project/.sdk/tm/kotlin/feature/StreamingFeature.kt +90 -0
- package/project/.sdk/tm/kotlin/feature/TelemetryFeature.kt +118 -0
- package/project/.sdk/tm/kotlin/feature/TestFeature.kt +306 -0
- package/project/.sdk/tm/kotlin/feature/TimeoutFeature.kt +74 -0
- package/project/.sdk/tm/kotlin/src/feature/README.md +1 -0
- package/project/.sdk/tm/kotlin/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/kotlin/test/CustomUtilityTest.kt +51 -0
- package/project/.sdk/tm/kotlin/test/ExistsTest.kt +15 -0
- package/project/.sdk/tm/kotlin/test/FeatureHarness.kt +380 -0
- package/project/.sdk/tm/kotlin/test/FeatureTest.kt +924 -0
- package/project/.sdk/tm/kotlin/test/NetsimTest.kt +50 -0
- package/project/.sdk/tm/kotlin/test/PipelineTest.kt +556 -0
- package/project/.sdk/tm/kotlin/test/PrimaryUtilityTest.kt +829 -0
- package/project/.sdk/tm/kotlin/test/RunnerSupport.kt +477 -0
- package/project/.sdk/tm/kotlin/test/StructCorpusTest.kt +297 -0
- package/project/.sdk/tm/kotlin/test/StructRunner.kt +177 -0
- package/project/.sdk/tm/kotlin/test/sdk-test-control.json +19 -0
- package/project/.sdk/tm/kotlin/utility/CoreUtil.kt +96 -0
- package/project/.sdk/tm/kotlin/utility/FeatureUtil.kt +121 -0
- package/project/.sdk/tm/kotlin/utility/Fetcher.kt +156 -0
- package/project/.sdk/tm/kotlin/utility/Json.kt +237 -0
- package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +152 -0
- package/project/.sdk/tm/kotlin/utility/MakePoint.kt +108 -0
- package/project/.sdk/tm/kotlin/utility/MakeReqRes.kt +152 -0
- package/project/.sdk/tm/kotlin/utility/MakeSpecUrl.kt +142 -0
- package/project/.sdk/tm/kotlin/utility/Prepare.kt +236 -0
- package/project/.sdk/tm/kotlin/utility/Register.kt +39 -0
- package/project/.sdk/tm/kotlin/utility/ResultTransform.kt +109 -0
- package/project/.sdk/tm/kotlin/utility/struct/Struct.kt +2697 -0
- package/project/.sdk/tm/lua/feature/audit_feature.lua +132 -0
- package/project/.sdk/tm/lua/feature/cache_feature.lua +188 -0
- package/project/.sdk/tm/lua/feature/clienttrack_feature.lua +127 -0
- package/project/.sdk/tm/lua/feature/debug_feature.lua +194 -0
- package/project/.sdk/tm/lua/feature/idempotency_feature.lua +127 -0
- package/project/.sdk/tm/lua/feature/metrics_feature.lua +135 -0
- package/project/.sdk/tm/lua/feature/netsim_feature.lua +205 -0
- package/project/.sdk/tm/lua/feature/paging_feature.lua +180 -0
- package/project/.sdk/tm/lua/feature/proxy_feature.lua +147 -0
- package/project/.sdk/tm/lua/feature/ratelimit_feature.lua +120 -0
- package/project/.sdk/tm/lua/feature/rbac_feature.lua +141 -0
- package/project/.sdk/tm/lua/feature/retry_feature.lua +188 -0
- package/project/.sdk/tm/lua/feature/streaming_feature.lua +143 -0
- package/project/.sdk/tm/lua/feature/telemetry_feature.lua +159 -0
- package/project/.sdk/tm/lua/feature/test_feature.lua +85 -1
- package/project/.sdk/tm/lua/feature/timeout_feature.lua +94 -0
- package/project/.sdk/tm/lua/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/lua/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/lua/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/lua/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/lua/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/lua/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/lua/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/lua/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/lua/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/lua/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/lua/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/lua/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/lua/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/lua/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/lua/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/lua/test/feature_test.lua +1244 -0
- package/project/.sdk/tm/lua/test/netsim_test.lua +61 -0
- package/project/.sdk/tm/lua/test/pipeline_test.lua +613 -0
- package/project/.sdk/tm/lua/utility/feature_add.lua +28 -1
- package/project/.sdk/tm/lua/utility/make_error.lua +9 -0
- package/project/.sdk/tm/lua/utility/make_options.lua +58 -0
- package/project/.sdk/tm/lua/utility/make_point.lua +8 -1
- package/project/.sdk/tm/ocaml/LICENSE +21 -0
- package/project/.sdk/tm/ocaml/Makefile +58 -0
- package/project/.sdk/tm/ocaml/VERSION +1 -0
- package/project/.sdk/tm/ocaml/sdk_features.ml +1127 -0
- package/project/.sdk/tm/ocaml/sdk_helpers.ml +110 -0
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +942 -0
- package/project/.sdk/tm/ocaml/sdk_types.ml +259 -0
- package/project/.sdk/tm/ocaml/src/feature/README.md +1 -0
- package/project/.sdk/tm/ocaml/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/test/custom_utility.ml +30 -0
- package/project/.sdk/tm/ocaml/test/harness.ml +198 -0
- package/project/.sdk/tm/ocaml/test/struct_corpus.ml +487 -0
- package/project/.sdk/tm/ocaml/test/t_feature.ml +533 -0
- package/project/.sdk/tm/ocaml/test/t_main.ml +5 -0
- package/project/.sdk/tm/ocaml/test/t_pipeline.ml +354 -0
- package/project/.sdk/tm/ocaml/test/testutil.ml +57 -0
- package/project/.sdk/tm/ocaml/utility/voxgig_struct.ml +1858 -0
- package/project/.sdk/tm/ocaml/utility/vregex.ml +254 -0
- package/project/.sdk/tm/perl/LICENSE +22 -0
- package/project/.sdk/tm/perl/Makefile +57 -0
- package/project/.sdk/tm/perl/core/context.pm +138 -0
- package/project/.sdk/tm/perl/core/control.pm +22 -0
- package/project/.sdk/tm/perl/core/error.pm +30 -0
- package/project/.sdk/tm/perl/core/helpers.pm +142 -0
- package/project/.sdk/tm/perl/core/operation.pm +47 -0
- package/project/.sdk/tm/perl/core/response.pm +40 -0
- package/project/.sdk/tm/perl/core/result.pm +45 -0
- package/project/.sdk/tm/perl/core/spec.pm +33 -0
- package/project/.sdk/tm/perl/core/utility_type.pm +32 -0
- package/project/.sdk/tm/perl/feature/audit_feature.pm +128 -0
- package/project/.sdk/tm/perl/feature/base_feature.pm +41 -0
- package/project/.sdk/tm/perl/feature/cache_feature.pm +168 -0
- package/project/.sdk/tm/perl/feature/clienttrack_feature.pm +126 -0
- package/project/.sdk/tm/perl/feature/debug_feature.pm +168 -0
- package/project/.sdk/tm/perl/feature/idempotency_feature.pm +104 -0
- package/project/.sdk/tm/perl/feature/log_feature.pm +77 -0
- package/project/.sdk/tm/perl/feature/metrics_feature.pm +124 -0
- package/project/.sdk/tm/perl/feature/netsim_feature.pm +215 -0
- package/project/.sdk/tm/perl/feature/paging_feature.pm +158 -0
- package/project/.sdk/tm/perl/feature/proxy_feature.pm +128 -0
- package/project/.sdk/tm/perl/feature/ratelimit_feature.pm +126 -0
- package/project/.sdk/tm/perl/feature/rbac_feature.pm +124 -0
- package/project/.sdk/tm/perl/feature/retry_feature.pm +153 -0
- package/project/.sdk/tm/perl/feature/streaming_feature.pm +112 -0
- package/project/.sdk/tm/perl/feature/telemetry_feature.pm +155 -0
- package/project/.sdk/tm/perl/feature/test_feature.pm +314 -0
- package/project/.sdk/tm/perl/feature/timeout_feature.pm +110 -0
- package/project/.sdk/tm/perl/lib/Voxgig/Struct.pm +2897 -0
- package/project/.sdk/tm/perl/src/feature/README.md +3 -0
- package/project/.sdk/tm/perl/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/perl/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/perl/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/perl/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/perl/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/perl/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/perl/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/perl/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/perl/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/perl/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/perl/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/perl/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/perl/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/perl/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/perl/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/perl/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/perl/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/perl/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/perl/t/feature.t +1054 -0
- package/project/.sdk/tm/perl/t/netsim.t +55 -0
- package/project/.sdk/tm/perl/t/pipeline.t +632 -0
- package/project/.sdk/tm/perl/t/primary_utility.t +1023 -0
- package/project/.sdk/tm/perl/t/runner.pm +140 -0
- package/project/.sdk/tm/perl/t/sdk-test-control.json +19 -0
- package/project/.sdk/tm/perl/t/stream.t +132 -0
- package/project/.sdk/tm/perl/t/struct_runner.pm +275 -0
- package/project/.sdk/tm/perl/t/struct_utility.t +438 -0
- package/project/.sdk/tm/perl/utility/clean.pm +15 -0
- package/project/.sdk/tm/perl/utility/done.pm +34 -0
- package/project/.sdk/tm/perl/utility/feature_add.pm +47 -0
- package/project/.sdk/tm/perl/utility/feature_hook.pm +25 -0
- package/project/.sdk/tm/perl/utility/feature_init.pm +33 -0
- package/project/.sdk/tm/perl/utility/fetcher.pm +112 -0
- package/project/.sdk/tm/perl/utility/make_context.pm +22 -0
- package/project/.sdk/tm/perl/utility/make_error.pm +74 -0
- package/project/.sdk/tm/perl/utility/make_fetch_def.pm +46 -0
- package/project/.sdk/tm/perl/utility/make_options.pm +123 -0
- package/project/.sdk/tm/perl/utility/make_point.pm +104 -0
- package/project/.sdk/tm/perl/utility/make_request.pm +66 -0
- package/project/.sdk/tm/perl/utility/make_response.pm +38 -0
- package/project/.sdk/tm/perl/utility/make_result.pm +53 -0
- package/project/.sdk/tm/perl/utility/make_spec.pm +71 -0
- package/project/.sdk/tm/perl/utility/make_url.pm +63 -0
- package/project/.sdk/tm/perl/utility/param.pm +65 -0
- package/project/.sdk/tm/perl/utility/prepare_auth.pm +56 -0
- package/project/.sdk/tm/perl/utility/prepare_body.pm +17 -0
- package/project/.sdk/tm/perl/utility/prepare_headers.pm +27 -0
- package/project/.sdk/tm/perl/utility/prepare_method.pm +25 -0
- package/project/.sdk/tm/perl/utility/prepare_params.pm +41 -0
- package/project/.sdk/tm/perl/utility/prepare_path.pm +29 -0
- package/project/.sdk/tm/perl/utility/prepare_query.pm +40 -0
- package/project/.sdk/tm/perl/utility/register.pm +53 -0
- package/project/.sdk/tm/perl/utility/result_basic.pm +38 -0
- package/project/.sdk/tm/perl/utility/result_body.pm +28 -0
- package/project/.sdk/tm/perl/utility/result_headers.pm +32 -0
- package/project/.sdk/tm/perl/utility/transform_request.pm +30 -0
- package/project/.sdk/tm/perl/utility/transform_response.pm +43 -0
- package/project/.sdk/tm/php/core/Result.php +10 -0
- package/project/.sdk/tm/php/feature/AuditFeature.php +125 -0
- package/project/.sdk/tm/php/feature/BaseFeature.php +6 -0
- package/project/.sdk/tm/php/feature/CacheFeature.php +158 -0
- package/project/.sdk/tm/php/feature/ClienttrackFeature.php +126 -0
- package/project/.sdk/tm/php/feature/DebugFeature.php +167 -0
- package/project/.sdk/tm/php/feature/IdempotencyFeature.php +102 -0
- package/project/.sdk/tm/php/feature/MetricsFeature.php +122 -0
- package/project/.sdk/tm/php/feature/NetsimFeature.php +190 -0
- package/project/.sdk/tm/php/feature/PagingFeature.php +153 -0
- package/project/.sdk/tm/php/feature/ProxyFeature.php +136 -0
- package/project/.sdk/tm/php/feature/RatelimitFeature.php +116 -0
- package/project/.sdk/tm/php/feature/RbacFeature.php +133 -0
- package/project/.sdk/tm/php/feature/RetryFeature.php +159 -0
- package/project/.sdk/tm/php/feature/StreamingFeature.php +107 -0
- package/project/.sdk/tm/php/feature/TelemetryFeature.php +156 -0
- package/project/.sdk/tm/php/feature/TestFeature.php +80 -1
- package/project/.sdk/tm/php/feature/TimeoutFeature.php +95 -0
- package/project/.sdk/tm/php/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/php/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/php/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/php/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/php/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/php/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/php/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/php/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/php/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/php/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/php/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/php/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/php/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/php/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/php/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/php/test/FeatureTest.php +1259 -0
- package/project/.sdk/tm/php/test/NetsimTest.php +53 -0
- package/project/.sdk/tm/php/test/PipelineTest.php +674 -0
- package/project/.sdk/tm/php/utility/FeatureAdd.php +32 -1
- package/project/.sdk/tm/php/utility/MakeError.php +9 -0
- package/project/.sdk/tm/php/utility/MakeOptions.php +46 -0
- package/project/.sdk/tm/php/utility/MakePoint.php +7 -0
- package/project/.sdk/tm/py/core/context.py +4 -0
- package/project/.sdk/tm/py/core/control.py +3 -0
- package/project/.sdk/tm/py/feature/audit_feature.py +98 -0
- package/project/.sdk/tm/py/feature/cache_feature.py +138 -0
- package/project/.sdk/tm/py/feature/clienttrack_feature.py +97 -0
- package/project/.sdk/tm/py/feature/debug_feature.py +134 -0
- package/project/.sdk/tm/py/feature/idempotency_feature.py +89 -0
- package/project/.sdk/tm/py/feature/metrics_feature.py +93 -0
- package/project/.sdk/tm/py/feature/netsim_feature.py +170 -0
- package/project/.sdk/tm/py/feature/paging_feature.py +134 -0
- package/project/.sdk/tm/py/feature/proxy_feature.py +104 -0
- package/project/.sdk/tm/py/feature/ratelimit_feature.py +98 -0
- package/project/.sdk/tm/py/feature/rbac_feature.py +102 -0
- package/project/.sdk/tm/py/feature/retry_feature.py +142 -0
- package/project/.sdk/tm/py/feature/streaming_feature.py +84 -0
- package/project/.sdk/tm/py/feature/telemetry_feature.py +128 -0
- package/project/.sdk/tm/py/feature/test_feature.py +70 -1
- package/project/.sdk/tm/py/feature/timeout_feature.py +78 -0
- package/project/.sdk/tm/py/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/py/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/py/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/py/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/py/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/py/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/py/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/py/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/py/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/py/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/py/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/py/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/py/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/py/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/py/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/py/test/feature_harness.py +336 -0
- package/project/.sdk/tm/py/test/test_feature.py +807 -0
- package/project/.sdk/tm/py/test/test_netsim.py +52 -0
- package/project/.sdk/tm/py/test/test_pipeline.py +606 -0
- package/project/.sdk/tm/py/utility/feature_add.py +25 -1
- package/project/.sdk/tm/py/utility/make_error.py +8 -0
- package/project/.sdk/tm/py/utility/make_options.py +32 -0
- package/project/.sdk/tm/py/utility/make_point.py +8 -2
- package/project/.sdk/tm/py/utility/make_request.py +6 -2
- package/project/.sdk/tm/py/utility/make_response.py +6 -2
- package/project/.sdk/tm/py/utility/make_result.py +6 -2
- package/project/.sdk/tm/py/utility/make_spec.py +6 -2
- package/project/.sdk/tm/rb/core/context.rb +2 -0
- package/project/.sdk/tm/rb/core/control.rb +5 -1
- package/project/.sdk/tm/rb/core/result.rb +2 -1
- package/project/.sdk/tm/rb/feature/audit_feature.rb +103 -0
- package/project/.sdk/tm/rb/feature/base_feature.rb +5 -0
- package/project/.sdk/tm/rb/feature/cache_feature.rb +133 -0
- package/project/.sdk/tm/rb/feature/clienttrack_feature.rb +91 -0
- package/project/.sdk/tm/rb/feature/debug_feature.rb +138 -0
- package/project/.sdk/tm/rb/feature/idempotency_feature.rb +78 -0
- package/project/.sdk/tm/rb/feature/metrics_feature.rb +91 -0
- package/project/.sdk/tm/rb/feature/netsim_feature.rb +167 -0
- package/project/.sdk/tm/rb/feature/paging_feature.rb +120 -0
- package/project/.sdk/tm/rb/feature/proxy_feature.rb +93 -0
- package/project/.sdk/tm/rb/feature/ratelimit_feature.rb +95 -0
- package/project/.sdk/tm/rb/feature/rbac_feature.rb +96 -0
- package/project/.sdk/tm/rb/feature/retry_feature.rb +116 -0
- package/project/.sdk/tm/rb/feature/streaming_feature.rb +85 -0
- package/project/.sdk/tm/rb/feature/telemetry_feature.rb +122 -0
- package/project/.sdk/tm/rb/feature/test_feature.rb +65 -1
- package/project/.sdk/tm/rb/feature/timeout_feature.rb +74 -0
- package/project/.sdk/tm/rb/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/rb/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/rb/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/rb/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/rb/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/rb/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/rb/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/rb/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/rb/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/rb/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/rb/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/rb/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/rb/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/rb/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/rb/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/rb/test/feature_test.rb +1031 -0
- package/project/.sdk/tm/rb/test/netsim_test.rb +48 -0
- package/project/.sdk/tm/rb/test/pipeline_test.rb +584 -0
- package/project/.sdk/tm/rb/utility/feature_add.rb +28 -1
- package/project/.sdk/tm/rb/utility/make_error.rb +8 -0
- package/project/.sdk/tm/rb/utility/make_options.rb +35 -0
- package/project/.sdk/tm/rb/utility/make_point.rb +7 -1
- package/project/.sdk/tm/rust/LICENSE +22 -0
- package/project/.sdk/tm/rust/Makefile +41 -0
- package/project/.sdk/tm/rust/VERSION +1 -0
- package/project/.sdk/tm/rust/core/context.rs +320 -0
- package/project/.sdk/tm/rust/core/control.rs +37 -0
- package/project/.sdk/tm/rust/core/helpers.rs +168 -0
- package/project/.sdk/tm/rust/core/mod.rs +18 -0
- package/project/.sdk/tm/rust/core/operation.rs +35 -0
- package/project/.sdk/tm/rust/core/point.rs +68 -0
- package/project/.sdk/tm/rust/core/response.rs +38 -0
- package/project/.sdk/tm/rust/core/result.rs +90 -0
- package/project/.sdk/tm/rust/core/spec.rs +109 -0
- package/project/.sdk/tm/rust/core/types.rs +105 -0
- package/project/.sdk/tm/rust/core/utility_type.rs +184 -0
- package/project/.sdk/tm/rust/feature/audit.rs +138 -0
- package/project/.sdk/tm/rust/feature/base.rs +49 -0
- package/project/.sdk/tm/rust/feature/cache.rs +198 -0
- package/project/.sdk/tm/rust/feature/clienttrack.rs +154 -0
- package/project/.sdk/tm/rust/feature/debug.rs +188 -0
- package/project/.sdk/tm/rust/feature/idempotency.rs +139 -0
- package/project/.sdk/tm/rust/feature/log.rs +114 -0
- package/project/.sdk/tm/rust/feature/metrics.rs +136 -0
- package/project/.sdk/tm/rust/feature/mod.rs +24 -0
- package/project/.sdk/tm/rust/feature/netsim.rs +233 -0
- package/project/.sdk/tm/rust/feature/paging.rs +209 -0
- package/project/.sdk/tm/rust/feature/proxy.rs +165 -0
- package/project/.sdk/tm/rust/feature/ratelimit.rs +116 -0
- package/project/.sdk/tm/rust/feature/rbac.rs +152 -0
- package/project/.sdk/tm/rust/feature/retry.rs +190 -0
- package/project/.sdk/tm/rust/feature/streaming.rs +124 -0
- package/project/.sdk/tm/rust/feature/support.rs +145 -0
- package/project/.sdk/tm/rust/feature/telemetry.rs +185 -0
- package/project/.sdk/tm/rust/feature/test.rs +397 -0
- package/project/.sdk/tm/rust/feature/timeout.rs +103 -0
- package/project/.sdk/tm/rust/src/feature/README.md +1 -0
- package/project/.sdk/tm/rust/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/rust/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/rust/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/rust/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/rust/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/rust/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/rust/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/rust/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/rust/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/rust/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/rust/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/rust/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/rust/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/rust/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/rust/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/rust/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/rust/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/rust/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/rust/tests/common/mod.rs +969 -0
- package/project/.sdk/tm/rust/tests/custom_utility_test.rs +69 -0
- package/project/.sdk/tm/rust/tests/feature_test.rs +1864 -0
- package/project/.sdk/tm/rust/tests/netsim_test.rs +78 -0
- package/project/.sdk/tm/rust/tests/pipeline_test.rs +699 -0
- package/project/.sdk/tm/rust/tests/primary_utility_test.rs +999 -0
- package/project/.sdk/tm/rust/tests/sdk-test-control.json +19 -0
- package/project/.sdk/tm/rust/tests/struct_runner/mod.rs +424 -0
- package/project/.sdk/tm/rust/tests/struct_utility_test.rs +733 -0
- package/project/.sdk/tm/rust/utility/clean.rs +13 -0
- package/project/.sdk/tm/rust/utility/done.rs +31 -0
- package/project/.sdk/tm/rust/utility/feature_add.rs +46 -0
- package/project/.sdk/tm/rust/utility/feature_hook.rs +18 -0
- package/project/.sdk/tm/rust/utility/feature_init.rs +26 -0
- package/project/.sdk/tm/rust/utility/fetcher.rs +142 -0
- package/project/.sdk/tm/rust/utility/jsonparse.rs +211 -0
- package/project/.sdk/tm/rust/utility/make_context.rs +7 -0
- package/project/.sdk/tm/rust/utility/make_error.rs +79 -0
- package/project/.sdk/tm/rust/utility/make_fetch_def.rs +42 -0
- package/project/.sdk/tm/rust/utility/make_options.rs +175 -0
- package/project/.sdk/tm/rust/utility/make_point.rs +116 -0
- package/project/.sdk/tm/rust/utility/make_request.rs +73 -0
- package/project/.sdk/tm/rust/utility/make_response.rs +56 -0
- package/project/.sdk/tm/rust/utility/make_result.rs +64 -0
- package/project/.sdk/tm/rust/utility/make_spec.rs +70 -0
- package/project/.sdk/tm/rust/utility/make_url.rs +83 -0
- package/project/.sdk/tm/rust/utility/mod.rs +36 -0
- package/project/.sdk/tm/rust/utility/param.rs +67 -0
- package/project/.sdk/tm/rust/utility/prepare_auth.rs +65 -0
- package/project/.sdk/tm/rust/utility/prepare_body.rs +14 -0
- package/project/.sdk/tm/rust/utility/prepare_headers.rs +23 -0
- package/project/.sdk/tm/rust/utility/prepare_method.rs +18 -0
- package/project/.sdk/tm/rust/utility/prepare_params.rs +33 -0
- package/project/.sdk/tm/rust/utility/prepare_path.rs +17 -0
- package/project/.sdk/tm/rust/utility/prepare_query.rs +47 -0
- package/project/.sdk/tm/rust/utility/result_basic.rs +35 -0
- package/project/.sdk/tm/rust/utility/result_body.rs +26 -0
- package/project/.sdk/tm/rust/utility/result_headers.rs +24 -0
- package/project/.sdk/tm/rust/utility/transform_request.rs +31 -0
- package/project/.sdk/tm/rust/utility/transform_response.rs +55 -0
- package/project/.sdk/tm/rust/utility/voxgigstruct/consts.rs +122 -0
- package/project/.sdk/tm/rust/utility/voxgigstruct/major.rs +2688 -0
- package/project/.sdk/tm/rust/utility/voxgigstruct/mini.rs +1081 -0
- package/project/.sdk/tm/rust/utility/voxgigstruct/mod.rs +70 -0
- package/project/.sdk/tm/rust/utility/voxgigstruct/ordered_map.rs +159 -0
- package/project/.sdk/tm/rust/utility/voxgigstruct/re.rs +1229 -0
- package/project/.sdk/tm/rust/utility/voxgigstruct/value.rs +372 -0
- package/project/.sdk/tm/scala/LICENSE +22 -0
- package/project/.sdk/tm/scala/Makefile +24 -0
- package/project/.sdk/tm/scala/VERSION +1 -0
- package/project/.sdk/tm/scala/core/Context.scala +160 -0
- package/project/.sdk/tm/scala/core/Contracts.scala +76 -0
- package/project/.sdk/tm/scala/core/Control.scala +23 -0
- package/project/.sdk/tm/scala/core/Helpers.scala +38 -0
- package/project/.sdk/tm/scala/core/Operation.scala +37 -0
- package/project/.sdk/tm/scala/core/Point.scala +44 -0
- package/project/.sdk/tm/scala/core/Response.scala +37 -0
- package/project/.sdk/tm/scala/core/Result.scala +42 -0
- package/project/.sdk/tm/scala/core/SdkClient.scala +220 -0
- package/project/.sdk/tm/scala/core/SdkError.scala +15 -0
- package/project/.sdk/tm/scala/core/Spec.scala +39 -0
- package/project/.sdk/tm/scala/core/Types.scala +31 -0
- package/project/.sdk/tm/scala/core/Utility.scala +85 -0
- package/project/.sdk/tm/scala/feature/AuditFeature.scala +101 -0
- package/project/.sdk/tm/scala/feature/BaseFeature.scala +21 -0
- package/project/.sdk/tm/scala/feature/CacheFeature.scala +181 -0
- package/project/.sdk/tm/scala/feature/ClienttrackFeature.scala +93 -0
- package/project/.sdk/tm/scala/feature/DebugFeature.scala +149 -0
- package/project/.sdk/tm/scala/feature/FeatureOptions.scala +111 -0
- package/project/.sdk/tm/scala/feature/IdempotencyFeature.scala +106 -0
- package/project/.sdk/tm/scala/feature/LogFeature.scala +64 -0
- package/project/.sdk/tm/scala/feature/MetricsFeature.scala +105 -0
- package/project/.sdk/tm/scala/feature/NetsimFeature.scala +134 -0
- package/project/.sdk/tm/scala/feature/PagingFeature.scala +170 -0
- package/project/.sdk/tm/scala/feature/ProxyFeature.scala +113 -0
- package/project/.sdk/tm/scala/feature/RatelimitFeature.scala +58 -0
- package/project/.sdk/tm/scala/feature/RbacFeature.scala +90 -0
- package/project/.sdk/tm/scala/feature/RetryFeature.scala +104 -0
- package/project/.sdk/tm/scala/feature/StreamingFeature.scala +98 -0
- package/project/.sdk/tm/scala/feature/TelemetryFeature.scala +129 -0
- package/project/.sdk/tm/scala/feature/TestFeature.scala +253 -0
- package/project/.sdk/tm/scala/feature/TimeoutFeature.scala +57 -0
- package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +766 -0
- package/project/.sdk/tm/scala/sdktest/SdkTestSupport.scala +93 -0
- package/project/.sdk/tm/scala/sdktest/StructCorpus.scala +0 -0
- package/project/.sdk/tm/scala/sdktest/sdk-test-control.json +19 -0
- package/project/.sdk/tm/scala/src/feature/README.md +1 -0
- package/project/.sdk/tm/scala/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/scala/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/scala/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/scala/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/scala/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/scala/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/scala/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/scala/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/scala/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/scala/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/scala/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/scala/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/scala/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/scala/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/scala/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/scala/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/scala/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/scala/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/scala/utility/FeatureUtils.scala +68 -0
- package/project/.sdk/tm/scala/utility/Fetcher.scala +129 -0
- package/project/.sdk/tm/scala/utility/Json.java +268 -0
- package/project/.sdk/tm/scala/utility/Make.scala +463 -0
- package/project/.sdk/tm/scala/utility/MakeSpec.scala +49 -0
- package/project/.sdk/tm/scala/utility/Misc.scala +68 -0
- package/project/.sdk/tm/scala/utility/Prepare.scala +142 -0
- package/project/.sdk/tm/scala/utility/Register.scala +38 -0
- package/project/.sdk/tm/scala/utility/Results.scala +63 -0
- package/project/.sdk/tm/scala/utility/StructUtility.scala +29 -0
- package/project/.sdk/tm/scala/utility/Transform.scala +52 -0
- package/project/.sdk/tm/scala/utility/struct/Struct.java +3550 -0
- package/project/.sdk/tm/scala/utility/struct/voxgig_struct.scala +1833 -0
- package/project/.sdk/tm/swift/LICENSE +22 -0
- package/project/.sdk/tm/swift/Makefile +41 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Constants.swift +113 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Inject.swift +260 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Injection.swift +111 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/JSON.swift +327 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Merge.swift +55 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Minor.swift +601 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/OrderedDictionary.swift +79 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Path.swift +157 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Select.swift +259 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Transform.swift +462 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Validate.swift +378 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Value.swift +184 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Walk.swift +44 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Context.swift +161 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Control.swift +20 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Operation.swift +27 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Point.swift +37 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Response.swift +29 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Result.swift +41 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Spec.swift +36 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Support.swift +98 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Types.swift +25 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Utility.swift +81 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/AuditFeature.swift +99 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/BaseFeature.swift +60 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/CacheFeature.swift +164 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/ClienttrackFeature.swift +95 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/DebugFeature.swift +126 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/FeatureOptions.swift +96 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/IdempotencyFeature.swift +80 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/LogFeature.swift +69 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/MetricsFeature.swift +103 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/NetsimFeature.swift +177 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/PagingFeature.swift +154 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/ProxyFeature.swift +122 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/RatelimitFeature.swift +79 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/RbacFeature.swift +103 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/RetryFeature.swift +150 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/StreamingFeature.swift +82 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TelemetryFeature.swift +119 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TestFeature.swift +257 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TimeoutFeature.swift +83 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Feature.swift +56 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Fetcher.swift +107 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Make.swift +321 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeError.swift +56 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +151 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Prepare.swift +157 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Register.swift +40 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/ResultUtil.swift +107 -0
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/CustomUtilityTest.swift +44 -0
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/ExistsTest.swift +12 -0
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +1049 -0
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/NetsimTest.swift +50 -0
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/PipelineTest.swift +398 -0
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/PrimaryUtilityTest.swift +750 -0
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/Runner.swift +237 -0
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/StructUtilityTest.swift +523 -0
- package/project/.sdk/tm/swift/VERSION +1 -0
- package/project/.sdk/tm/swift/src/feature/README.md +6 -0
- package/project/.sdk/tm/swift/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/swift/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/swift/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/swift/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/swift/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/swift/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/swift/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/swift/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/swift/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/swift/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/swift/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/swift/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/swift/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/swift/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/swift/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/swift/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/swift/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/swift/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/ts/Makefile +6 -1
- package/project/.sdk/tm/ts/src/feature/audit/AuditFeature.ts +98 -0
- package/project/.sdk/tm/ts/src/feature/cache/CacheFeature.ts +152 -0
- package/project/.sdk/tm/ts/src/feature/clienttrack/ClienttrackFeature.ts +106 -0
- package/project/.sdk/tm/ts/src/feature/debug/DebugFeature.ts +134 -0
- package/project/.sdk/tm/ts/src/feature/idempotency/IdempotencyFeature.ts +97 -0
- package/project/.sdk/tm/ts/src/feature/metrics/MetricsFeature.ts +104 -0
- package/project/.sdk/tm/ts/src/feature/netsim/NetsimFeature.ts +189 -0
- package/project/.sdk/tm/ts/src/feature/paging/PagingFeature.ts +141 -0
- package/project/.sdk/tm/ts/src/feature/proxy/ProxyFeature.ts +112 -0
- package/project/.sdk/tm/ts/src/feature/ratelimit/RatelimitFeature.ts +108 -0
- package/project/.sdk/tm/ts/src/feature/rbac/RbacFeature.ts +104 -0
- package/project/.sdk/tm/ts/src/feature/retry/RetryFeature.ts +160 -0
- package/project/.sdk/tm/ts/src/feature/streaming/StreamingFeature.ts +98 -0
- package/project/.sdk/tm/ts/src/feature/telemetry/TelemetryFeature.ts +130 -0
- package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +58 -1
- package/project/.sdk/tm/ts/src/feature/timeout/TimeoutFeature.ts +103 -0
- package/project/.sdk/tm/ts/src/utility/FeatureHookUtility.ts +4 -1
- package/project/.sdk/tm/ts/src/utility/MakeErrorUtility.ts +9 -0
- package/project/.sdk/tm/ts/src/utility/MakeOptionsUtility.ts +31 -1
- package/project/.sdk/tm/ts/test/feature/harness.ts +293 -0
- package/project/.sdk/tm/ts/test/feature.test.ts +772 -0
- package/project/.sdk/tm/ts/test/netsim.test.ts +43 -0
- package/project/.sdk/tm/ts/test/pipeline.test.ts +382 -0
- package/project/.sdk/tm/zig/LICENSE +21 -0
- package/project/.sdk/tm/zig/Makefile +31 -0
- package/project/.sdk/tm/zig/VERSION +1 -0
- package/project/.sdk/tm/zig/build.zig +58 -0
- package/project/.sdk/tm/zig/build.zig.zon +11 -0
- package/project/.sdk/tm/zig/core/context.zig +258 -0
- package/project/.sdk/tm/zig/core/control.zig +26 -0
- package/project/.sdk/tm/zig/core/error.zig +28 -0
- package/project/.sdk/tm/zig/core/helpers.zig +326 -0
- package/project/.sdk/tm/zig/core/mem.zig +20 -0
- package/project/.sdk/tm/zig/core/operation.zig +34 -0
- package/project/.sdk/tm/zig/core/point.zig +63 -0
- package/project/.sdk/tm/zig/core/response.zig +32 -0
- package/project/.sdk/tm/zig/core/result.zig +73 -0
- package/project/.sdk/tm/zig/core/spec.zig +68 -0
- package/project/.sdk/tm/zig/core/types.zig +101 -0
- package/project/.sdk/tm/zig/core/utility.zig +1115 -0
- package/project/.sdk/tm/zig/feature/audit.zig +131 -0
- package/project/.sdk/tm/zig/feature/base.zig +52 -0
- package/project/.sdk/tm/zig/feature/cache.zig +216 -0
- package/project/.sdk/tm/zig/feature/clienttrack.zig +129 -0
- package/project/.sdk/tm/zig/feature/debug.zig +191 -0
- package/project/.sdk/tm/zig/feature/idempotency.zig +121 -0
- package/project/.sdk/tm/zig/feature/log.zig +93 -0
- package/project/.sdk/tm/zig/feature/metrics.zig +145 -0
- package/project/.sdk/tm/zig/feature/netsim.zig +186 -0
- package/project/.sdk/tm/zig/feature/paging.zig +201 -0
- package/project/.sdk/tm/zig/feature/proxy.zig +180 -0
- package/project/.sdk/tm/zig/feature/ratelimit.zig +123 -0
- package/project/.sdk/tm/zig/feature/rbac.zig +126 -0
- package/project/.sdk/tm/zig/feature/retry.zig +167 -0
- package/project/.sdk/tm/zig/feature/streaming.zig +127 -0
- package/project/.sdk/tm/zig/feature/support.zig +128 -0
- package/project/.sdk/tm/zig/feature/telemetry.zig +165 -0
- package/project/.sdk/tm/zig/feature/test.zig +315 -0
- package/project/.sdk/tm/zig/feature/timeout.zig +105 -0
- package/project/.sdk/tm/zig/root.zig +74 -0
- package/project/.sdk/tm/zig/src/feature/README.md +1 -0
- package/project/.sdk/tm/zig/src/feature/audit/.gitkeep +0 -0
- package/project/.sdk/tm/zig/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/zig/src/feature/cache/.gitkeep +0 -0
- package/project/.sdk/tm/zig/src/feature/clienttrack/.gitkeep +0 -0
- package/project/.sdk/tm/zig/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/zig/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/zig/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/zig/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/zig/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/zig/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/zig/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/zig/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/zig/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/zig/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/zig/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/zig/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/zig/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/zig/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/zig/test/feature_test.zig +1045 -0
- package/project/.sdk/tm/zig/test/fh.zig +531 -0
- package/project/.sdk/tm/zig/test/gotcha_test.zig +230 -0
- package/project/.sdk/tm/zig/test/pipeline_test.zig +493 -0
- package/project/.sdk/tm/zig/test/primary_utility_test.zig +346 -0
- package/project/.sdk/tm/zig/test/struct_corpus.zig +1145 -0
- package/project/.sdk/tm/zig/test/struct_runner.zig +226 -0
- package/project/.sdk/tm/zig/utility/jsonparse.zig +13 -0
- package/project/.sdk/tm/zig/utility/voxgigstruct/regex.zig +779 -0
- package/project/.sdk/tm/zig/utility/voxgigstruct/struct.zig +4400 -0
|
@@ -0,0 +1,3379 @@
|
|
|
1
|
+
// Copyright (c) 2025-2026 Voxgig Ltd. MIT LICENSE.
|
|
2
|
+
//
|
|
3
|
+
// Voxgig Struct — main API.
|
|
4
|
+
//
|
|
5
|
+
// Header-only port of the canonical TypeScript implementation. Everything
|
|
6
|
+
// public lives in namespace voxgig::structlib. Mirrors the Java port at
|
|
7
|
+
// java/src/Struct.java which itself mirrors ts/src/StructUtility.ts.
|
|
8
|
+
|
|
9
|
+
#ifndef VOXGIG_STRUCT_HPP
|
|
10
|
+
#define VOXGIG_STRUCT_HPP
|
|
11
|
+
|
|
12
|
+
#include <algorithm>
|
|
13
|
+
#include <cctype>
|
|
14
|
+
#include <cmath>
|
|
15
|
+
#include <cstdint>
|
|
16
|
+
#include <iomanip>
|
|
17
|
+
#include <regex>
|
|
18
|
+
#include <sstream>
|
|
19
|
+
#include <stdexcept>
|
|
20
|
+
#include <string>
|
|
21
|
+
#include <unordered_map>
|
|
22
|
+
#include <utility>
|
|
23
|
+
#include <vector>
|
|
24
|
+
|
|
25
|
+
#include "value.hpp"
|
|
26
|
+
|
|
27
|
+
namespace voxgig {
|
|
28
|
+
namespace structlib {
|
|
29
|
+
|
|
30
|
+
// ===========================================================================
|
|
31
|
+
// String / regex constants
|
|
32
|
+
// ===========================================================================
|
|
33
|
+
|
|
34
|
+
inline const std::string& S_MT() {
|
|
35
|
+
static const std::string s = "";
|
|
36
|
+
return s;
|
|
37
|
+
}
|
|
38
|
+
inline const std::string& S_DT() {
|
|
39
|
+
static const std::string s = ".";
|
|
40
|
+
return s;
|
|
41
|
+
}
|
|
42
|
+
inline const std::string& S_DTOP() {
|
|
43
|
+
static const std::string s = "$TOP";
|
|
44
|
+
return s;
|
|
45
|
+
}
|
|
46
|
+
inline const std::string& S_DSPEC() {
|
|
47
|
+
static const std::string s = "$SPEC";
|
|
48
|
+
return s;
|
|
49
|
+
}
|
|
50
|
+
inline const std::string& S_DKEY() {
|
|
51
|
+
static const std::string s = "$KEY";
|
|
52
|
+
return s;
|
|
53
|
+
}
|
|
54
|
+
inline const std::string& S_DERRS() {
|
|
55
|
+
static const std::string s = "$ERRS";
|
|
56
|
+
return s;
|
|
57
|
+
}
|
|
58
|
+
inline const std::string& S_BKEY() {
|
|
59
|
+
static const std::string s = "`$KEY`";
|
|
60
|
+
return s;
|
|
61
|
+
}
|
|
62
|
+
inline const std::string& S_BANNO() {
|
|
63
|
+
static const std::string s = "`$ANNO`";
|
|
64
|
+
return s;
|
|
65
|
+
}
|
|
66
|
+
inline const std::string& S_BVAL() {
|
|
67
|
+
static const std::string s = "`$VAL`";
|
|
68
|
+
return s;
|
|
69
|
+
}
|
|
70
|
+
inline const std::string& S_BEXACT() {
|
|
71
|
+
static const std::string s = "`$EXACT`";
|
|
72
|
+
return s;
|
|
73
|
+
}
|
|
74
|
+
inline const std::string& S_BOPEN() {
|
|
75
|
+
static const std::string s = "`$OPEN`";
|
|
76
|
+
return s;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
inline const std::regex& R_INTEGER_KEY() {
|
|
80
|
+
static const std::regex r("^[-0-9]+$");
|
|
81
|
+
return r;
|
|
82
|
+
}
|
|
83
|
+
inline const std::regex& R_META_PATH() {
|
|
84
|
+
static const std::regex r("^([^$]+)\\$([=~])(.+)$");
|
|
85
|
+
return r;
|
|
86
|
+
}
|
|
87
|
+
inline const std::regex& R_INJECTION_FULL() {
|
|
88
|
+
static const std::regex r("^`(\\$[A-Z]+|[^`]*)[0-9]*`$");
|
|
89
|
+
return r;
|
|
90
|
+
}
|
|
91
|
+
inline const std::regex& R_INJECTION_PARTIAL() {
|
|
92
|
+
static const std::regex r("`([^`]+)`");
|
|
93
|
+
return r;
|
|
94
|
+
}
|
|
95
|
+
inline const std::regex& R_DOUBLE_DOLLAR() {
|
|
96
|
+
static const std::regex r("\\$\\$");
|
|
97
|
+
return r;
|
|
98
|
+
}
|
|
99
|
+
inline const std::regex& R_TRANSFORM_NAME() {
|
|
100
|
+
static const std::regex r("`\\$([A-Z]+)`");
|
|
101
|
+
return r;
|
|
102
|
+
}
|
|
103
|
+
inline const std::regex& R_BT_ESCAPE() {
|
|
104
|
+
static const std::regex r("\\$BT");
|
|
105
|
+
return r;
|
|
106
|
+
}
|
|
107
|
+
inline const std::regex& R_DS_ESCAPE() {
|
|
108
|
+
static const std::regex r("\\$DS");
|
|
109
|
+
return r;
|
|
110
|
+
}
|
|
111
|
+
inline const std::regex& R_ESCAPE_REGEXP() {
|
|
112
|
+
static const std::regex r(R"([.*+?^${}()|\[\]\\])");
|
|
113
|
+
return r;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// ===========================================================================
|
|
117
|
+
// Predicates (most also exposed via Value methods)
|
|
118
|
+
// ===========================================================================
|
|
119
|
+
|
|
120
|
+
inline bool isnode(const Value& v) {
|
|
121
|
+
return v.is_node() || v.is_sentinel();
|
|
122
|
+
}
|
|
123
|
+
inline bool ismap(const Value& v) {
|
|
124
|
+
return v.is_map() || v.is_sentinel();
|
|
125
|
+
}
|
|
126
|
+
inline bool islist(const Value& v) {
|
|
127
|
+
return v.is_list();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
inline bool iskey(const Value& v) {
|
|
131
|
+
if (v.is_string())
|
|
132
|
+
return !v.as_string().empty();
|
|
133
|
+
if (v.is_int())
|
|
134
|
+
return true;
|
|
135
|
+
if (v.is_double())
|
|
136
|
+
return true;
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
inline bool isempty(const Value& v) {
|
|
141
|
+
if (v.is_undef() || v.is_null())
|
|
142
|
+
return true;
|
|
143
|
+
if (v.is_string())
|
|
144
|
+
return v.as_string().empty();
|
|
145
|
+
if (v.is_list())
|
|
146
|
+
return v.as_list()->empty();
|
|
147
|
+
if (v.is_map())
|
|
148
|
+
return v.as_map()->empty();
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
inline bool isfunc(const Value& v) {
|
|
153
|
+
return v.is_func();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
inline Value getdef(const Value& v, const Value& alt) {
|
|
157
|
+
if (v.is_undef())
|
|
158
|
+
return alt;
|
|
159
|
+
return v;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
inline int64_t size(const Value& v) {
|
|
163
|
+
return size_of(v);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// ===========================================================================
|
|
167
|
+
// Type helpers re-exported (defined in value.hpp)
|
|
168
|
+
// ===========================================================================
|
|
169
|
+
// typify(const Value&) -> int
|
|
170
|
+
// typename_str(int) -> std::string
|
|
171
|
+
// typename_str(const Value&) -> std::string
|
|
172
|
+
|
|
173
|
+
// ===========================================================================
|
|
174
|
+
// Forward declarations
|
|
175
|
+
// ===========================================================================
|
|
176
|
+
|
|
177
|
+
class Injection;
|
|
178
|
+
|
|
179
|
+
inline std::string strkey(const Value& key);
|
|
180
|
+
inline Value getprop(const Value& val, const Value& key, const Value& alt = Value::undef());
|
|
181
|
+
inline Value getelem(const Value& val, const Value& key, const Value& alt = Value::undef());
|
|
182
|
+
inline Value lookup_v(const Value& val, const Value& key);
|
|
183
|
+
inline Value setprop(Value parent, const Value& key, const Value& val);
|
|
184
|
+
inline Value delprop(Value parent, const Value& key);
|
|
185
|
+
inline std::vector<std::string> keysof(const Value& v);
|
|
186
|
+
inline bool haskey(const Value& v, const Value& key);
|
|
187
|
+
inline std::vector<Value> items(const Value& v);
|
|
188
|
+
inline std::string stringify(const Value& v, int maxlen = -1);
|
|
189
|
+
inline std::string pathify(const Value& v, int startin = 0, int endin = 0);
|
|
190
|
+
inline Value slice(const Value& v, const Value& start = Value::undef(),
|
|
191
|
+
const Value& end = Value::undef());
|
|
192
|
+
inline Value walk_v(
|
|
193
|
+
const Value& val,
|
|
194
|
+
std::function<Value(const Value&, const Value&, const Value&, const std::vector<std::string>&)>
|
|
195
|
+
before,
|
|
196
|
+
std::function<Value(const Value&, const Value&, const Value&, const std::vector<std::string>&)>
|
|
197
|
+
after,
|
|
198
|
+
int maxdepth = MAXDEPTH);
|
|
199
|
+
inline Value merge_v(const Value& list, int maxdepth = MAXDEPTH);
|
|
200
|
+
inline Value getpath_v(const Value& store, const Value& path, Injection* inj = nullptr);
|
|
201
|
+
inline Value setpath_v(const Value& store, const Value& path, const Value& val);
|
|
202
|
+
inline Value inject(const Value& val, const Value& store, Injection* injdef = nullptr);
|
|
203
|
+
inline Value transform(const Value& data, const Value& spec, const Value& options = Value::undef());
|
|
204
|
+
inline Value validate(const Value& data, const Value& spec, const Value& options = Value::undef());
|
|
205
|
+
inline std::vector<Value> select(const Value& children, const Value& query);
|
|
206
|
+
|
|
207
|
+
// ===========================================================================
|
|
208
|
+
// strkey / getprop / setprop / delprop / getelem
|
|
209
|
+
// ===========================================================================
|
|
210
|
+
|
|
211
|
+
inline std::string strkey(const Value& key) {
|
|
212
|
+
if (key.is_undef())
|
|
213
|
+
return S_MT();
|
|
214
|
+
if (key.is_string())
|
|
215
|
+
return key.as_string();
|
|
216
|
+
if (key.is_bool())
|
|
217
|
+
return S_MT();
|
|
218
|
+
if (key.is_int())
|
|
219
|
+
return std::to_string(key.as_int());
|
|
220
|
+
if (key.is_double()) {
|
|
221
|
+
double d = key.as_double();
|
|
222
|
+
if (std::floor(d) == d)
|
|
223
|
+
return std::to_string(static_cast<int64_t>(d));
|
|
224
|
+
return std::to_string(static_cast<int64_t>(std::floor(d)));
|
|
225
|
+
}
|
|
226
|
+
return S_MT();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
inline Value getprop(const Value& val, const Value& key, const Value& alt) {
|
|
230
|
+
if (val.is_undef() || key.is_undef())
|
|
231
|
+
return alt;
|
|
232
|
+
if (val.is_map()) {
|
|
233
|
+
auto m = val.as_map();
|
|
234
|
+
if (!m)
|
|
235
|
+
return alt;
|
|
236
|
+
std::string sk = strkey(key);
|
|
237
|
+
Value* found = m->find(sk);
|
|
238
|
+
if (!found)
|
|
239
|
+
return alt;
|
|
240
|
+
// Group A: a stored JSON null counts as "no value" (canonical `null == out`
|
|
241
|
+
// is true for both undefined and null), so the alt is substituted.
|
|
242
|
+
if (found->is_undef() || found->is_null())
|
|
243
|
+
return alt;
|
|
244
|
+
return *found;
|
|
245
|
+
}
|
|
246
|
+
if (val.is_list()) {
|
|
247
|
+
auto l = val.as_list();
|
|
248
|
+
if (!l)
|
|
249
|
+
return alt;
|
|
250
|
+
int idx;
|
|
251
|
+
if (key.is_int()) {
|
|
252
|
+
idx = static_cast<int>(key.as_int());
|
|
253
|
+
} else if (key.is_string()) {
|
|
254
|
+
// Match TS: only accept strings that match /^[-0-9]+$/ entirely.
|
|
255
|
+
if (!std::regex_match(key.as_string(), R_INTEGER_KEY()))
|
|
256
|
+
return alt;
|
|
257
|
+
try {
|
|
258
|
+
idx = std::stoi(key.as_string());
|
|
259
|
+
} catch (...) {
|
|
260
|
+
return alt;
|
|
261
|
+
}
|
|
262
|
+
} else if (key.is_double()) {
|
|
263
|
+
idx = static_cast<int>(key.as_double());
|
|
264
|
+
} else {
|
|
265
|
+
return alt;
|
|
266
|
+
}
|
|
267
|
+
if (idx < 0 || idx >= static_cast<int>(l->size()))
|
|
268
|
+
return alt;
|
|
269
|
+
Value v = (*l)[idx];
|
|
270
|
+
// Group A: a stored JSON null counts as "no value" — substitute the alt.
|
|
271
|
+
if (v.is_undef() || v.is_null())
|
|
272
|
+
return alt;
|
|
273
|
+
return v;
|
|
274
|
+
}
|
|
275
|
+
return alt;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Match TS regex /^[-0-9]+$/ check.
|
|
279
|
+
inline bool is_integer_key_string(const Value& key) {
|
|
280
|
+
if (key.is_int() || key.is_double())
|
|
281
|
+
return true;
|
|
282
|
+
if (key.is_string()) {
|
|
283
|
+
return std::regex_match(key.as_string(), R_INTEGER_KEY());
|
|
284
|
+
}
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
inline Value getelem(const Value& val, const Value& key, const Value& alt) {
|
|
289
|
+
Value out = Value::undef();
|
|
290
|
+
if (val.is_undef() || key.is_undef()) {
|
|
291
|
+
if (alt.is_func() && alt.is_injector())
|
|
292
|
+
return alt;
|
|
293
|
+
return alt;
|
|
294
|
+
}
|
|
295
|
+
if (val.is_list()) {
|
|
296
|
+
auto l = val.as_list();
|
|
297
|
+
int nkey;
|
|
298
|
+
if (key.is_int()) {
|
|
299
|
+
nkey = static_cast<int>(key.as_int());
|
|
300
|
+
} else if (key.is_string()) {
|
|
301
|
+
if (!is_integer_key_string(key))
|
|
302
|
+
return alt;
|
|
303
|
+
try {
|
|
304
|
+
nkey = std::stoi(key.as_string());
|
|
305
|
+
} catch (...) {
|
|
306
|
+
return alt;
|
|
307
|
+
}
|
|
308
|
+
} else if (key.is_double()) {
|
|
309
|
+
nkey = static_cast<int>(key.as_double());
|
|
310
|
+
} else {
|
|
311
|
+
return alt;
|
|
312
|
+
}
|
|
313
|
+
if (nkey < 0)
|
|
314
|
+
nkey = static_cast<int>(l->size()) + nkey;
|
|
315
|
+
if (nkey < 0 || nkey >= static_cast<int>(l->size()))
|
|
316
|
+
return alt;
|
|
317
|
+
out = (*l)[nkey];
|
|
318
|
+
}
|
|
319
|
+
// Group A: a stored JSON null at the slot counts as "no value" (canonical
|
|
320
|
+
// `null == out` is true for both undefined and null) — substitute the alt.
|
|
321
|
+
if (out.is_undef() || out.is_null())
|
|
322
|
+
return alt;
|
|
323
|
+
return out;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Internal Group B lookup: read the raw stored value at a slot, preserving a
|
|
327
|
+
// stored JSON null. Mirrors canonical `_lookup` (StructUtility.ts). The public
|
|
328
|
+
// getprop / getelem / haskey treat a stored null as absent (Group A); the
|
|
329
|
+
// validate / transform / inject internals that need the literal value (e.g. to
|
|
330
|
+
// validate against $NULL or echo a null back through an injector) use this.
|
|
331
|
+
inline Value lookup_v(const Value& val, const Value& key) {
|
|
332
|
+
if (val.is_undef() || key.is_undef())
|
|
333
|
+
return Value::undef();
|
|
334
|
+
if (val.is_list()) {
|
|
335
|
+
auto l = val.as_list();
|
|
336
|
+
if (!l)
|
|
337
|
+
return Value::undef();
|
|
338
|
+
int idx;
|
|
339
|
+
if (key.is_int()) {
|
|
340
|
+
idx = static_cast<int>(key.as_int());
|
|
341
|
+
} else if (key.is_double()) {
|
|
342
|
+
idx = static_cast<int>(key.as_double());
|
|
343
|
+
} else if (key.is_string()) {
|
|
344
|
+
if (!std::regex_match(key.as_string(), R_INTEGER_KEY()))
|
|
345
|
+
return Value::undef();
|
|
346
|
+
try {
|
|
347
|
+
idx = std::stoi(key.as_string());
|
|
348
|
+
} catch (...) {
|
|
349
|
+
return Value::undef();
|
|
350
|
+
}
|
|
351
|
+
} else {
|
|
352
|
+
return Value::undef();
|
|
353
|
+
}
|
|
354
|
+
if (idx < 0)
|
|
355
|
+
idx = static_cast<int>(l->size()) + idx;
|
|
356
|
+
if (idx < 0 || idx >= static_cast<int>(l->size()))
|
|
357
|
+
return Value::undef();
|
|
358
|
+
Value v = (*l)[idx];
|
|
359
|
+
return v.is_undef() ? Value::undef() : v;
|
|
360
|
+
}
|
|
361
|
+
if (val.is_map()) {
|
|
362
|
+
auto m = val.as_map();
|
|
363
|
+
if (!m)
|
|
364
|
+
return Value::undef();
|
|
365
|
+
std::string sk = strkey(key);
|
|
366
|
+
if (sk.empty())
|
|
367
|
+
return Value::undef();
|
|
368
|
+
Value* found = m->find(sk);
|
|
369
|
+
if (!found)
|
|
370
|
+
return Value::undef();
|
|
371
|
+
return *found;
|
|
372
|
+
}
|
|
373
|
+
return Value::undef();
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
inline Value setprop(Value parent, const Value& key, const Value& val) {
|
|
377
|
+
if (!iskey(key))
|
|
378
|
+
return parent;
|
|
379
|
+
if (parent.is_map()) {
|
|
380
|
+
auto m = parent.as_map();
|
|
381
|
+
std::string sk = strkey(key);
|
|
382
|
+
m->set(sk, val);
|
|
383
|
+
return parent;
|
|
384
|
+
}
|
|
385
|
+
if (parent.is_list()) {
|
|
386
|
+
auto l = parent.as_list();
|
|
387
|
+
int idx;
|
|
388
|
+
if (key.is_int())
|
|
389
|
+
idx = static_cast<int>(key.as_int());
|
|
390
|
+
else if (key.is_string()) {
|
|
391
|
+
try {
|
|
392
|
+
idx = std::stoi(key.as_string());
|
|
393
|
+
} catch (...) {
|
|
394
|
+
return parent;
|
|
395
|
+
}
|
|
396
|
+
} else if (key.is_double())
|
|
397
|
+
idx = static_cast<int>(key.as_double());
|
|
398
|
+
else
|
|
399
|
+
return parent;
|
|
400
|
+
|
|
401
|
+
if (idx >= 0) {
|
|
402
|
+
if (idx >= static_cast<int>(l->size())) {
|
|
403
|
+
l->push_back(val);
|
|
404
|
+
} else {
|
|
405
|
+
(*l)[idx] = val;
|
|
406
|
+
}
|
|
407
|
+
} else {
|
|
408
|
+
l->insert(l->begin(), val);
|
|
409
|
+
}
|
|
410
|
+
return parent;
|
|
411
|
+
}
|
|
412
|
+
return parent;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
inline Value delprop(Value parent, const Value& key) {
|
|
416
|
+
if (!iskey(key))
|
|
417
|
+
return parent;
|
|
418
|
+
if (parent.is_map()) {
|
|
419
|
+
parent.as_map()->erase(strkey(key));
|
|
420
|
+
return parent;
|
|
421
|
+
}
|
|
422
|
+
if (parent.is_list()) {
|
|
423
|
+
auto l = parent.as_list();
|
|
424
|
+
int idx;
|
|
425
|
+
if (key.is_int())
|
|
426
|
+
idx = static_cast<int>(key.as_int());
|
|
427
|
+
else if (key.is_string()) {
|
|
428
|
+
try {
|
|
429
|
+
idx = std::stoi(key.as_string());
|
|
430
|
+
} catch (...) {
|
|
431
|
+
return parent;
|
|
432
|
+
}
|
|
433
|
+
} else if (key.is_double())
|
|
434
|
+
idx = static_cast<int>(key.as_double());
|
|
435
|
+
else
|
|
436
|
+
return parent;
|
|
437
|
+
if (idx >= 0 && idx < static_cast<int>(l->size())) {
|
|
438
|
+
l->erase(l->begin() + idx);
|
|
439
|
+
}
|
|
440
|
+
return parent;
|
|
441
|
+
}
|
|
442
|
+
return parent;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// ===========================================================================
|
|
446
|
+
// keysof / haskey / items
|
|
447
|
+
// ===========================================================================
|
|
448
|
+
|
|
449
|
+
inline std::vector<std::string> keysof(const Value& v) {
|
|
450
|
+
std::vector<std::string> out;
|
|
451
|
+
if (!v.is_node())
|
|
452
|
+
return out;
|
|
453
|
+
if (v.is_map()) {
|
|
454
|
+
for (const auto& [k, _] : *v.as_map())
|
|
455
|
+
out.push_back(k);
|
|
456
|
+
// Matches TS canonical Object.keys(val).sort() — keysof returns
|
|
457
|
+
// alphabetically sorted keys regardless of insertion order.
|
|
458
|
+
std::sort(out.begin(), out.end());
|
|
459
|
+
} else {
|
|
460
|
+
auto l = v.as_list();
|
|
461
|
+
out.reserve(l->size());
|
|
462
|
+
for (size_t i = 0; i < l->size(); i++)
|
|
463
|
+
out.push_back(std::to_string(i));
|
|
464
|
+
}
|
|
465
|
+
return out;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
inline bool haskey(const Value& v, const Value& key) {
|
|
469
|
+
// Canonical: `null != getprop(val, key)`. A present-but-null key is false
|
|
470
|
+
// (getprop already substitutes its undef default for a stored null).
|
|
471
|
+
Value r = getprop(v, key);
|
|
472
|
+
return !r.is_undef() && !r.is_null();
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// items returns list of [key, value] pairs as Value-list-of-Value-lists.
|
|
476
|
+
inline Value items_v(const Value& v) {
|
|
477
|
+
auto out = std::make_shared<List>();
|
|
478
|
+
if (!v.is_node())
|
|
479
|
+
return Value(out);
|
|
480
|
+
for (const auto& key : keysof(v)) {
|
|
481
|
+
auto pair = std::make_shared<List>();
|
|
482
|
+
pair->push_back(Value(key));
|
|
483
|
+
pair->push_back(getprop(v, Value(key)));
|
|
484
|
+
out->push_back(Value(std::move(pair)));
|
|
485
|
+
}
|
|
486
|
+
return Value(out);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
inline std::vector<Value> items(const Value& v) {
|
|
490
|
+
std::vector<Value> out;
|
|
491
|
+
if (!v.is_node())
|
|
492
|
+
return out;
|
|
493
|
+
for (const auto& key : keysof(v)) {
|
|
494
|
+
auto pair = std::make_shared<List>();
|
|
495
|
+
pair->push_back(Value(key));
|
|
496
|
+
pair->push_back(getprop(v, Value(key)));
|
|
497
|
+
out.push_back(Value(std::move(pair)));
|
|
498
|
+
}
|
|
499
|
+
return out;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// ===========================================================================
|
|
503
|
+
// flatten / filter
|
|
504
|
+
// ===========================================================================
|
|
505
|
+
|
|
506
|
+
inline Value flatten(const Value& list, int depth = 1) {
|
|
507
|
+
if (!list.is_list())
|
|
508
|
+
return list;
|
|
509
|
+
auto out = std::make_shared<List>();
|
|
510
|
+
std::function<void(const std::shared_ptr<List>&, int)> rec = [&](const std::shared_ptr<List>& src,
|
|
511
|
+
int d) {
|
|
512
|
+
for (const auto& e : *src) {
|
|
513
|
+
if (d > 0 && e.is_list())
|
|
514
|
+
rec(e.as_list(), d - 1);
|
|
515
|
+
else
|
|
516
|
+
out->push_back(e);
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
rec(list.as_list(), depth);
|
|
520
|
+
return Value(std::move(out));
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
using ItemCheck = std::function<bool(const Value& pair)>;
|
|
524
|
+
|
|
525
|
+
inline Value filter(const Value& v, const ItemCheck& check) {
|
|
526
|
+
auto out = std::make_shared<List>();
|
|
527
|
+
for (const auto& pair : items(v)) {
|
|
528
|
+
if (check(pair)) {
|
|
529
|
+
out->push_back(getprop(pair, Value(static_cast<int64_t>(1))));
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
return Value(std::move(out));
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// ===========================================================================
|
|
536
|
+
// slice / pad
|
|
537
|
+
// ===========================================================================
|
|
538
|
+
//
|
|
539
|
+
// slice mirrors TS lines 314–383. Negative indices count from end. For
|
|
540
|
+
// numbers, performs min/max bounding (start inclusive, end exclusive).
|
|
541
|
+
|
|
542
|
+
inline Value slice(const Value& val, const Value& start_v, const Value& end_v) {
|
|
543
|
+
// Number case: bound between start and end-1.
|
|
544
|
+
if (val.is_number()) {
|
|
545
|
+
double n = val.as_double();
|
|
546
|
+
int64_t lo = std::numeric_limits<int64_t>::min();
|
|
547
|
+
int64_t hi = std::numeric_limits<int64_t>::max();
|
|
548
|
+
if (start_v.is_number())
|
|
549
|
+
lo = start_v.as_int();
|
|
550
|
+
if (end_v.is_number())
|
|
551
|
+
hi = end_v.as_int() - 1;
|
|
552
|
+
if (n < lo)
|
|
553
|
+
n = lo;
|
|
554
|
+
if (n > hi)
|
|
555
|
+
n = hi;
|
|
556
|
+
if (val.is_int())
|
|
557
|
+
return Value(static_cast<int64_t>(n));
|
|
558
|
+
return Value(n);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
int vlen = static_cast<int>(size(val));
|
|
562
|
+
bool has_start = !start_v.is_undef();
|
|
563
|
+
bool has_end = !end_v.is_undef();
|
|
564
|
+
int start = has_start ? static_cast<int>(start_v.as_int()) : 0;
|
|
565
|
+
int end = has_end ? static_cast<int>(end_v.as_int()) : vlen;
|
|
566
|
+
|
|
567
|
+
if (has_end && !has_start) {
|
|
568
|
+
start = 0;
|
|
569
|
+
has_start = true; // proceed into slice block even if only end was given
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
if (has_start) {
|
|
573
|
+
if (start < 0) {
|
|
574
|
+
end = vlen + start;
|
|
575
|
+
if (end < 0)
|
|
576
|
+
end = 0;
|
|
577
|
+
start = 0;
|
|
578
|
+
} else if (has_end) {
|
|
579
|
+
if (end < 0) {
|
|
580
|
+
end = vlen + end;
|
|
581
|
+
if (end < 0)
|
|
582
|
+
end = 0;
|
|
583
|
+
} else if (vlen < end) {
|
|
584
|
+
end = vlen;
|
|
585
|
+
}
|
|
586
|
+
} else {
|
|
587
|
+
end = vlen;
|
|
588
|
+
}
|
|
589
|
+
if (vlen < start)
|
|
590
|
+
start = vlen;
|
|
591
|
+
|
|
592
|
+
if (start >= 0 && start <= end && end <= vlen) {
|
|
593
|
+
if (val.is_list()) {
|
|
594
|
+
auto src = val.as_list();
|
|
595
|
+
auto out = std::make_shared<List>(src->begin() + start, src->begin() + end);
|
|
596
|
+
return Value(std::move(out));
|
|
597
|
+
}
|
|
598
|
+
if (val.is_string()) {
|
|
599
|
+
return Value(val.as_string().substr(start, end - start));
|
|
600
|
+
}
|
|
601
|
+
} else {
|
|
602
|
+
if (val.is_list())
|
|
603
|
+
return Value(std::make_shared<List>());
|
|
604
|
+
if (val.is_string())
|
|
605
|
+
return Value(std::string(""));
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return val;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
inline std::string pad(const Value& v, int padding = 44, const std::string& padchar = " ") {
|
|
612
|
+
std::string s = v.is_string() ? v.as_string() : stringify(v);
|
|
613
|
+
std::string pc = padchar.empty() ? std::string(" ") : padchar.substr(0, 1);
|
|
614
|
+
if (padding >= 0) {
|
|
615
|
+
if (static_cast<int>(s.size()) < padding) {
|
|
616
|
+
s.append(padding - s.size(), pc[0]);
|
|
617
|
+
}
|
|
618
|
+
return s;
|
|
619
|
+
}
|
|
620
|
+
int need = -padding - static_cast<int>(s.size());
|
|
621
|
+
if (need > 0) {
|
|
622
|
+
return std::string(need, pc[0]) + s;
|
|
623
|
+
}
|
|
624
|
+
return s;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// Convenience overload: pad with default args using Value parameters.
|
|
628
|
+
inline std::string pad(const Value& v, const Value& padding_v,
|
|
629
|
+
const Value& padchar_v = Value::undef()) {
|
|
630
|
+
int p = padding_v.is_number() ? static_cast<int>(padding_v.as_int()) : 44;
|
|
631
|
+
std::string pc = padchar_v.is_string() ? padchar_v.as_string() : " ";
|
|
632
|
+
return pad(v, p, pc);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// ===========================================================================
|
|
636
|
+
// escre / escurl / replace / join
|
|
637
|
+
// ===========================================================================
|
|
638
|
+
|
|
639
|
+
inline std::string escre(const Value& v) {
|
|
640
|
+
std::string s = v.is_string() ? v.as_string() : (v.is_undef() ? "" : stringify(v));
|
|
641
|
+
return std::regex_replace(s, R_ESCAPE_REGEXP(), "\\$&");
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
// ----------------------------------------------------------------------------
|
|
645
|
+
// Regex utility — uniform re_* API (see /REGEX_API.md). C++'s <regex>
|
|
646
|
+
// (ECMAScript dialect by default) is a strict superset of RE2.
|
|
647
|
+
// ----------------------------------------------------------------------------
|
|
648
|
+
|
|
649
|
+
inline std::regex re_compile(const std::string& pattern) {
|
|
650
|
+
return std::regex(pattern);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
inline bool re_test(const std::string& pattern, const std::string& input) {
|
|
654
|
+
return std::regex_search(input, std::regex(pattern));
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
inline std::vector<std::string> re_find(const std::string& pattern, const std::string& input) {
|
|
658
|
+
std::smatch m;
|
|
659
|
+
if (!std::regex_search(input, m, std::regex(pattern)))
|
|
660
|
+
return {};
|
|
661
|
+
std::vector<std::string> out;
|
|
662
|
+
for (size_t i = 0; i < m.size(); i++)
|
|
663
|
+
out.push_back(m[i].str());
|
|
664
|
+
return out;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
inline std::vector<std::vector<std::string>> re_find_all(const std::string& pattern,
|
|
668
|
+
const std::string& input) {
|
|
669
|
+
std::vector<std::vector<std::string>> out;
|
|
670
|
+
std::regex rx(pattern);
|
|
671
|
+
auto begin = std::sregex_iterator(input.begin(), input.end(), rx);
|
|
672
|
+
auto end = std::sregex_iterator();
|
|
673
|
+
for (auto it = begin; it != end; ++it) {
|
|
674
|
+
std::vector<std::string> row;
|
|
675
|
+
for (size_t i = 0; i < it->size(); i++)
|
|
676
|
+
row.push_back((*it)[i].str());
|
|
677
|
+
out.push_back(std::move(row));
|
|
678
|
+
}
|
|
679
|
+
return out;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
inline std::string re_replace(const std::string& pattern, const std::string& input,
|
|
683
|
+
const std::string& replacement) {
|
|
684
|
+
return std::regex_replace(input, std::regex(pattern), replacement);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
inline std::string re_escape(const std::string& s) {
|
|
688
|
+
return std::regex_replace(s, R_ESCAPE_REGEXP(), "\\$&");
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
inline std::string escurl(const Value& v) {
|
|
692
|
+
if (v.is_undef())
|
|
693
|
+
return "";
|
|
694
|
+
std::string s = v.is_string() ? v.as_string() : stringify(v);
|
|
695
|
+
std::ostringstream out;
|
|
696
|
+
out.fill('0');
|
|
697
|
+
out << std::hex;
|
|
698
|
+
for (unsigned char c : s) {
|
|
699
|
+
if (std::isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') {
|
|
700
|
+
out << c;
|
|
701
|
+
} else {
|
|
702
|
+
out << '%' << std::uppercase << std::setw(2) << static_cast<int>(c);
|
|
703
|
+
out << std::nouppercase;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return out.str();
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// JS-style scalar -> string: integer-valued doubles render without ".0".
|
|
710
|
+
inline std::string js_string(const Value& v) {
|
|
711
|
+
if (v.is_undef() || v.is_null())
|
|
712
|
+
return "null";
|
|
713
|
+
if (v.is_bool())
|
|
714
|
+
return v.as_bool() ? "true" : "false";
|
|
715
|
+
if (v.is_int())
|
|
716
|
+
return std::to_string(v.as_int());
|
|
717
|
+
if (v.is_double()) {
|
|
718
|
+
double d = v.as_double();
|
|
719
|
+
if (std::isfinite(d) && std::floor(d) == d) {
|
|
720
|
+
return std::to_string(static_cast<int64_t>(d));
|
|
721
|
+
}
|
|
722
|
+
std::ostringstream oss;
|
|
723
|
+
oss << d;
|
|
724
|
+
return oss.str();
|
|
725
|
+
}
|
|
726
|
+
if (v.is_string())
|
|
727
|
+
return v.as_string();
|
|
728
|
+
return stringify(v);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
inline std::string join(const Value& arr, const std::string& sep = ",", bool url = false) {
|
|
732
|
+
if (!arr.is_list())
|
|
733
|
+
return "";
|
|
734
|
+
// Filter to non-empty strings.
|
|
735
|
+
std::vector<std::string> parts;
|
|
736
|
+
auto src = arr.as_list();
|
|
737
|
+
for (size_t i = 0; i < src->size(); i++) {
|
|
738
|
+
const Value& v = (*src)[i];
|
|
739
|
+
if (!v.is_string() || v.as_string().empty())
|
|
740
|
+
continue;
|
|
741
|
+
parts.push_back(v.as_string());
|
|
742
|
+
}
|
|
743
|
+
size_t sarr = parts.size();
|
|
744
|
+
std::string sepre = sep.size() == 1 ? std::regex_replace(sep, R_ESCAPE_REGEXP(), "\\$&") : "";
|
|
745
|
+
|
|
746
|
+
std::vector<std::string> cleaned;
|
|
747
|
+
for (size_t i = 0; i < parts.size(); i++) {
|
|
748
|
+
std::string s = parts[i];
|
|
749
|
+
if (!sepre.empty()) {
|
|
750
|
+
if (url && i == 0) {
|
|
751
|
+
s = std::regex_replace(s, std::regex(sepre + "+$"), "");
|
|
752
|
+
} else {
|
|
753
|
+
if (i > 0)
|
|
754
|
+
s = std::regex_replace(s, std::regex("^" + sepre + "+"), "");
|
|
755
|
+
if (i < sarr - 1 || !url) {
|
|
756
|
+
s = std::regex_replace(s, std::regex(sepre + "+$"), "");
|
|
757
|
+
}
|
|
758
|
+
s = std::regex_replace(s, std::regex("([^" + sepre + "])" + sepre + "+([^" + sepre + "])"),
|
|
759
|
+
std::string("$1") + sep + "$2");
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
if (!s.empty())
|
|
763
|
+
cleaned.push_back(s);
|
|
764
|
+
}
|
|
765
|
+
std::string out;
|
|
766
|
+
for (size_t i = 0; i < cleaned.size(); i++) {
|
|
767
|
+
if (i > 0)
|
|
768
|
+
out += sep;
|
|
769
|
+
out += cleaned[i];
|
|
770
|
+
}
|
|
771
|
+
return out;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
inline std::string join(const Value& arr, const Value& sep_v, const Value& url_v = Value::undef()) {
|
|
775
|
+
std::string sep = sep_v.is_string() ? sep_v.as_string() : ",";
|
|
776
|
+
bool url = url_v.is_bool() ? url_v.as_bool() : false;
|
|
777
|
+
return join(arr, sep, url);
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
// ===========================================================================
|
|
781
|
+
// jsonify / stringify / pathify
|
|
782
|
+
// ===========================================================================
|
|
783
|
+
|
|
784
|
+
// Pure-C++ JSON emitter — mirrors c/src/utility.c::jsonify_inner. Map keys
|
|
785
|
+
// are emitted in INSERTION order (matching TS canonical's JSON.stringify
|
|
786
|
+
// behaviour), not alphabetically. Used by jsonify / stringify / partial
|
|
787
|
+
// inject so the library proper does not depend on nlohmann::json for
|
|
788
|
+
// output (nlohmann is still used by the test harness for corpus loading).
|
|
789
|
+
inline void _json_escape(const std::string& s, std::string& out) {
|
|
790
|
+
for (char c : s) {
|
|
791
|
+
switch (c) {
|
|
792
|
+
case '"':
|
|
793
|
+
out += "\\\"";
|
|
794
|
+
break;
|
|
795
|
+
case '\\':
|
|
796
|
+
out += "\\\\";
|
|
797
|
+
break;
|
|
798
|
+
case '\b':
|
|
799
|
+
out += "\\b";
|
|
800
|
+
break;
|
|
801
|
+
case '\f':
|
|
802
|
+
out += "\\f";
|
|
803
|
+
break;
|
|
804
|
+
case '\n':
|
|
805
|
+
out += "\\n";
|
|
806
|
+
break;
|
|
807
|
+
case '\r':
|
|
808
|
+
out += "\\r";
|
|
809
|
+
break;
|
|
810
|
+
case '\t':
|
|
811
|
+
out += "\\t";
|
|
812
|
+
break;
|
|
813
|
+
default:
|
|
814
|
+
if (static_cast<unsigned char>(c) < 0x20) {
|
|
815
|
+
char buf[8];
|
|
816
|
+
std::snprintf(buf, sizeof(buf), "\\u%04x", static_cast<unsigned char>(c));
|
|
817
|
+
out += buf;
|
|
818
|
+
} else {
|
|
819
|
+
out += c;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
inline void _jsonify_inner(const Value& v, std::string& out, int indent, int depth,
|
|
826
|
+
bool sort_keys = false) {
|
|
827
|
+
if (v.is_undef() || v.is_null()) {
|
|
828
|
+
out += "null";
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
if (v.is_bool()) {
|
|
832
|
+
out += v.as_bool() ? "true" : "false";
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
if (v.is_int()) {
|
|
836
|
+
char buf[32];
|
|
837
|
+
std::snprintf(buf, sizeof(buf), "%lld", static_cast<long long>(v.as_int()));
|
|
838
|
+
out += buf;
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
if (v.is_double()) {
|
|
842
|
+
double d = v.as_double();
|
|
843
|
+
if (!std::isfinite(d)) {
|
|
844
|
+
out += "null";
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
char buf[48];
|
|
848
|
+
if (std::floor(d) == d && std::abs(d) < 1e15) {
|
|
849
|
+
std::snprintf(buf, sizeof(buf), "%lld", static_cast<long long>(d));
|
|
850
|
+
} else {
|
|
851
|
+
// Use %g (shortest round-trip-ish form) — matches C's doublestr and
|
|
852
|
+
// closely tracks JS JSON.stringify for typical fractional values.
|
|
853
|
+
std::snprintf(buf, sizeof(buf), "%g", d);
|
|
854
|
+
}
|
|
855
|
+
out += buf;
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
if (v.is_string()) {
|
|
859
|
+
out += '"';
|
|
860
|
+
_json_escape(v.as_string(), out);
|
|
861
|
+
out += '"';
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
if (v.is_list()) {
|
|
865
|
+
const auto& l = *v.as_list();
|
|
866
|
+
if (l.empty()) {
|
|
867
|
+
out += "[]";
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
out += '[';
|
|
871
|
+
bool first = true;
|
|
872
|
+
for (const auto& e : l) {
|
|
873
|
+
if (!first)
|
|
874
|
+
out += ',';
|
|
875
|
+
first = false;
|
|
876
|
+
if (indent > 0) {
|
|
877
|
+
out += '\n';
|
|
878
|
+
out.append(static_cast<size_t>((depth + 1) * indent), ' ');
|
|
879
|
+
}
|
|
880
|
+
_jsonify_inner(e, out, indent, depth + 1, sort_keys);
|
|
881
|
+
}
|
|
882
|
+
if (indent > 0) {
|
|
883
|
+
out += '\n';
|
|
884
|
+
out.append(static_cast<size_t>(depth * indent), ' ');
|
|
885
|
+
}
|
|
886
|
+
out += ']';
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
if (v.is_map()) {
|
|
890
|
+
const auto& m = *v.as_map();
|
|
891
|
+
if (m.empty()) {
|
|
892
|
+
out += "{}";
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
out += '{';
|
|
896
|
+
|
|
897
|
+
// Optionally walk in sorted key order (stringify behaviour, matching
|
|
898
|
+
// TS canonical's stringify replacer). jsonify keeps insertion order.
|
|
899
|
+
std::vector<std::string> order;
|
|
900
|
+
order.reserve(m.size());
|
|
901
|
+
for (const auto& [k, _e] : m)
|
|
902
|
+
order.push_back(k);
|
|
903
|
+
if (sort_keys)
|
|
904
|
+
std::sort(order.begin(), order.end());
|
|
905
|
+
|
|
906
|
+
bool first = true;
|
|
907
|
+
for (const auto& k : order) {
|
|
908
|
+
const Value* ep = m.find(k);
|
|
909
|
+
if (!ep)
|
|
910
|
+
continue;
|
|
911
|
+
const auto& e = *ep;
|
|
912
|
+
if (!first)
|
|
913
|
+
out += ',';
|
|
914
|
+
first = false;
|
|
915
|
+
if (indent > 0) {
|
|
916
|
+
out += '\n';
|
|
917
|
+
out.append(static_cast<size_t>((depth + 1) * indent), ' ');
|
|
918
|
+
}
|
|
919
|
+
out += '"';
|
|
920
|
+
_json_escape(k, out);
|
|
921
|
+
out += indent > 0 ? "\": " : "\":";
|
|
922
|
+
_jsonify_inner(e, out, indent, depth + 1, sort_keys);
|
|
923
|
+
}
|
|
924
|
+
if (indent > 0) {
|
|
925
|
+
out += '\n';
|
|
926
|
+
out.append(static_cast<size_t>(depth * indent), ' ');
|
|
927
|
+
}
|
|
928
|
+
out += '}';
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
// function / sentinel / unknown -> null
|
|
932
|
+
out += "null";
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
inline std::string jsonify(const Value& v, int indent = 2) {
|
|
936
|
+
if (v.is_undef() || v.is_null())
|
|
937
|
+
return "null";
|
|
938
|
+
std::string out;
|
|
939
|
+
_jsonify_inner(v, out, indent, 0);
|
|
940
|
+
return out;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
inline std::string jsonify(const Value& v, const Value& flags) {
|
|
944
|
+
int indent = 2;
|
|
945
|
+
int offset = 0;
|
|
946
|
+
if (flags.is_map()) {
|
|
947
|
+
Value iv = getprop(flags, Value("indent"));
|
|
948
|
+
Value ov = getprop(flags, Value("offset"));
|
|
949
|
+
if (iv.is_int())
|
|
950
|
+
indent = static_cast<int>(iv.as_int());
|
|
951
|
+
if (ov.is_int())
|
|
952
|
+
offset = static_cast<int>(ov.as_int());
|
|
953
|
+
}
|
|
954
|
+
std::string out = jsonify(v, indent);
|
|
955
|
+
if (offset > 0 && out.find('\n') != std::string::npos) {
|
|
956
|
+
std::string pad_str(offset, ' ');
|
|
957
|
+
std::string padded;
|
|
958
|
+
bool first = true;
|
|
959
|
+
size_t pos = 0;
|
|
960
|
+
while (pos < out.size()) {
|
|
961
|
+
size_t nl = out.find('\n', pos);
|
|
962
|
+
std::string line = (nl == std::string::npos) ? out.substr(pos) : out.substr(pos, nl - pos);
|
|
963
|
+
if (first) {
|
|
964
|
+
padded += line;
|
|
965
|
+
first = false;
|
|
966
|
+
} else
|
|
967
|
+
padded += "\n" + pad_str + line;
|
|
968
|
+
if (nl == std::string::npos)
|
|
969
|
+
break;
|
|
970
|
+
pos = nl + 1;
|
|
971
|
+
}
|
|
972
|
+
out = padded;
|
|
973
|
+
}
|
|
974
|
+
return out;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
// stringify renders a Value in a JSON-ish form, but with no quotes around
|
|
978
|
+
// strings (mirrors TS stringify which strips quotes for human friendliness).
|
|
979
|
+
inline std::string stringify(const Value& v, int maxlen) {
|
|
980
|
+
std::string valstr;
|
|
981
|
+
if (v.is_undef())
|
|
982
|
+
return "";
|
|
983
|
+
if (v.is_string()) {
|
|
984
|
+
valstr = v.as_string();
|
|
985
|
+
} else {
|
|
986
|
+
// Use the in-tree printer (no third-party dep) with compact output
|
|
987
|
+
// AND sorted keys (matches TS canonical's stringify replacer); then
|
|
988
|
+
// strip double-quotes (TS regex /"/g).
|
|
989
|
+
std::string raw;
|
|
990
|
+
_jsonify_inner(v, raw, 0, 0, true);
|
|
991
|
+
valstr.reserve(raw.size());
|
|
992
|
+
for (char c : raw)
|
|
993
|
+
if (c != '"')
|
|
994
|
+
valstr.push_back(c);
|
|
995
|
+
}
|
|
996
|
+
if (maxlen > 0 && static_cast<int>(valstr.size()) > maxlen) {
|
|
997
|
+
if (maxlen >= 3) {
|
|
998
|
+
return valstr.substr(0, maxlen - 3) + "...";
|
|
999
|
+
}
|
|
1000
|
+
return valstr.substr(0, maxlen);
|
|
1001
|
+
}
|
|
1002
|
+
return valstr;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
inline std::string pathify(const Value& v, int startin, int endin) {
|
|
1006
|
+
std::vector<std::string> parts;
|
|
1007
|
+
bool valid = false;
|
|
1008
|
+
if (v.is_list()) {
|
|
1009
|
+
valid = true;
|
|
1010
|
+
for (const auto& e : *v.as_list()) {
|
|
1011
|
+
if (iskey(e)) {
|
|
1012
|
+
if (e.is_int())
|
|
1013
|
+
parts.push_back(std::to_string(e.as_int()));
|
|
1014
|
+
else if (e.is_double())
|
|
1015
|
+
parts.push_back(std::to_string(static_cast<int64_t>(std::floor(e.as_double()))));
|
|
1016
|
+
else {
|
|
1017
|
+
std::string s = e.as_string();
|
|
1018
|
+
// Strip dots — TS regex /\./g.
|
|
1019
|
+
std::string filtered;
|
|
1020
|
+
for (char c : s)
|
|
1021
|
+
if (c != '.')
|
|
1022
|
+
filtered += c;
|
|
1023
|
+
parts.push_back(filtered);
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
} else if (v.is_string()) {
|
|
1028
|
+
valid = true;
|
|
1029
|
+
parts.push_back(v.as_string());
|
|
1030
|
+
} else if (v.is_number()) {
|
|
1031
|
+
valid = true;
|
|
1032
|
+
parts.push_back(v.is_int() ? std::to_string(v.as_int())
|
|
1033
|
+
: std::to_string(static_cast<int64_t>(std::floor(v.as_double()))));
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
int start = std::max(0, startin);
|
|
1037
|
+
int end = std::max(0, endin);
|
|
1038
|
+
if (valid) {
|
|
1039
|
+
int total = static_cast<int>(parts.size());
|
|
1040
|
+
int new_end = total - end;
|
|
1041
|
+
if (new_end < start)
|
|
1042
|
+
new_end = start;
|
|
1043
|
+
if (new_end > total)
|
|
1044
|
+
new_end = total;
|
|
1045
|
+
std::vector<std::string> sliced(parts.begin() + std::min(start, total),
|
|
1046
|
+
parts.begin() + new_end);
|
|
1047
|
+
if (sliced.empty())
|
|
1048
|
+
return "<root>";
|
|
1049
|
+
std::string out;
|
|
1050
|
+
for (size_t i = 0; i < sliced.size(); i++) {
|
|
1051
|
+
if (i > 0)
|
|
1052
|
+
out += ".";
|
|
1053
|
+
out += sliced[i];
|
|
1054
|
+
}
|
|
1055
|
+
return out;
|
|
1056
|
+
}
|
|
1057
|
+
std::string s = "<unknown-path";
|
|
1058
|
+
if (!v.is_undef()) {
|
|
1059
|
+
s += ":" + stringify(v, 47);
|
|
1060
|
+
}
|
|
1061
|
+
s += ">";
|
|
1062
|
+
return s;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
// ===========================================================================
|
|
1066
|
+
// jm / jt builders
|
|
1067
|
+
// ===========================================================================
|
|
1068
|
+
|
|
1069
|
+
inline Value jm(std::initializer_list<Value> kv) {
|
|
1070
|
+
auto m = std::shared_ptr<Map>(new Map());
|
|
1071
|
+
auto it = kv.begin();
|
|
1072
|
+
size_t i = 0;
|
|
1073
|
+
while (it != kv.end()) {
|
|
1074
|
+
std::string k = it->is_string() ? it->as_string() : stringify(*it);
|
|
1075
|
+
if (k.empty())
|
|
1076
|
+
k = "$KEY" + std::to_string(i);
|
|
1077
|
+
++it;
|
|
1078
|
+
i++;
|
|
1079
|
+
Value v = (it != kv.end()) ? *it : Value(nullptr);
|
|
1080
|
+
if (it != kv.end()) {
|
|
1081
|
+
++it;
|
|
1082
|
+
i++;
|
|
1083
|
+
}
|
|
1084
|
+
m->set(k, v);
|
|
1085
|
+
}
|
|
1086
|
+
return Value(std::move(m));
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
inline Value jt(std::initializer_list<Value> v) {
|
|
1090
|
+
auto l = std::make_shared<List>(v.begin(), v.end());
|
|
1091
|
+
return Value(std::move(l));
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
// ===========================================================================
|
|
1095
|
+
// walk
|
|
1096
|
+
// ===========================================================================
|
|
1097
|
+
//
|
|
1098
|
+
// Depth-first walk, applying optional `before` (on descend) and `after`
|
|
1099
|
+
// (on ascend) callbacks. Mirrors TS walk lines 915–975.
|
|
1100
|
+
|
|
1101
|
+
using WalkApply = std::function<Value(const Value& key, const Value& val, const Value& parent,
|
|
1102
|
+
const std::vector<std::string>& path)>;
|
|
1103
|
+
|
|
1104
|
+
namespace detail {
|
|
1105
|
+
|
|
1106
|
+
inline Value walk_descend(Value val, const WalkApply& before, const WalkApply& after, int maxdepth,
|
|
1107
|
+
const Value& key, const Value& parent, std::vector<std::string>& path) {
|
|
1108
|
+
Value out = before ? before(key, val, parent, path) : val;
|
|
1109
|
+
int depth = static_cast<int>(path.size());
|
|
1110
|
+
if (maxdepth == 0 || (maxdepth > 0 && maxdepth <= depth)) {
|
|
1111
|
+
// Match TS walk: do NOT fire `after` on the maxdepth early-return.
|
|
1112
|
+
return out;
|
|
1113
|
+
}
|
|
1114
|
+
if (isnode(out)) {
|
|
1115
|
+
auto entries = items(out);
|
|
1116
|
+
for (auto& pair : entries) {
|
|
1117
|
+
auto pl = pair.as_list();
|
|
1118
|
+
Value ckey = (*pl)[0];
|
|
1119
|
+
Value child = (*pl)[1];
|
|
1120
|
+
path.push_back(strkey(ckey));
|
|
1121
|
+
Value newchild = walk_descend(child, before, after, maxdepth, ckey, out, path);
|
|
1122
|
+
out = setprop(out, ckey, newchild);
|
|
1123
|
+
path.pop_back();
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
if (after)
|
|
1127
|
+
out = after(key, out, parent, path);
|
|
1128
|
+
return out;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
} // namespace detail
|
|
1132
|
+
|
|
1133
|
+
inline Value walk_v(const Value& val, WalkApply before, WalkApply after, int maxdepth) {
|
|
1134
|
+
std::vector<std::string> path;
|
|
1135
|
+
return detail::walk_descend(val, before, after, maxdepth, Value::undef(), Value::undef(), path);
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
inline Value walk_v(const Value& val, WalkApply before) {
|
|
1139
|
+
return walk_v(val, before, nullptr, MAXDEPTH);
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
// ===========================================================================
|
|
1143
|
+
// merge
|
|
1144
|
+
// ===========================================================================
|
|
1145
|
+
//
|
|
1146
|
+
// Deep merge a list of values; later values win, nodes override scalars,
|
|
1147
|
+
// node kinds (list vs map) do not merge. The first element is modified.
|
|
1148
|
+
// Mirrors TS lines 982–1098.
|
|
1149
|
+
|
|
1150
|
+
inline Value merge_v(const Value& list, int maxdepth) {
|
|
1151
|
+
int md = std::max(0, std::min(maxdepth, MAXDEPTH));
|
|
1152
|
+
if (!list.is_list())
|
|
1153
|
+
return list;
|
|
1154
|
+
auto src = list.as_list();
|
|
1155
|
+
if (src->empty())
|
|
1156
|
+
return Value(nullptr);
|
|
1157
|
+
if (src->size() == 1)
|
|
1158
|
+
return (*src)[0];
|
|
1159
|
+
|
|
1160
|
+
Value out = (*src)[0];
|
|
1161
|
+
if (out.is_undef()) {
|
|
1162
|
+
out = Value(std::shared_ptr<Map>(new Map()));
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
for (size_t oI = 1; oI < src->size(); oI++) {
|
|
1166
|
+
Value obj = (*src)[oI];
|
|
1167
|
+
if (!isnode(obj)) {
|
|
1168
|
+
out = obj;
|
|
1169
|
+
continue;
|
|
1170
|
+
}
|
|
1171
|
+
// Scratch arrays of cur/dst per depth (TS uses pI to index).
|
|
1172
|
+
std::vector<Value> cur(MAXDEPTH + 2, Value::undef());
|
|
1173
|
+
std::vector<Value> dst(MAXDEPTH + 2, Value::undef());
|
|
1174
|
+
cur[0] = out;
|
|
1175
|
+
dst[0] = out;
|
|
1176
|
+
|
|
1177
|
+
WalkApply before = [&](const Value& key, const Value& val, const Value& parent,
|
|
1178
|
+
const std::vector<std::string>& path) -> Value {
|
|
1179
|
+
int pI = static_cast<int>(path.size());
|
|
1180
|
+
if (md <= pI) {
|
|
1181
|
+
if (!key.is_undef()) {
|
|
1182
|
+
cur[pI - 1] = setprop(cur[pI - 1], key, val);
|
|
1183
|
+
}
|
|
1184
|
+
return val;
|
|
1185
|
+
}
|
|
1186
|
+
if (!isnode(val)) {
|
|
1187
|
+
cur[pI] = val;
|
|
1188
|
+
return val;
|
|
1189
|
+
}
|
|
1190
|
+
// Descending into a node.
|
|
1191
|
+
if (pI > 0 && !key.is_undef()) {
|
|
1192
|
+
dst[pI] = getprop(dst[pI - 1], key);
|
|
1193
|
+
if (dst[pI].is_undef())
|
|
1194
|
+
dst[pI] = Value::undef();
|
|
1195
|
+
}
|
|
1196
|
+
Value tval = dst[pI];
|
|
1197
|
+
if (tval.is_undef() && (typify(val) & T_instance) == 0) {
|
|
1198
|
+
cur[pI] = val.is_list() ? Value(std::make_shared<List>())
|
|
1199
|
+
: Value(std::shared_ptr<Map>(new Map()));
|
|
1200
|
+
} else if (typify(val) == typify(tval)) {
|
|
1201
|
+
cur[pI] = tval;
|
|
1202
|
+
} else {
|
|
1203
|
+
cur[pI] = val;
|
|
1204
|
+
return Value::undef(); // skip descent
|
|
1205
|
+
}
|
|
1206
|
+
return val;
|
|
1207
|
+
};
|
|
1208
|
+
|
|
1209
|
+
WalkApply after = [&](const Value& key, const Value& val_unused, const Value& parent,
|
|
1210
|
+
const std::vector<std::string>& path) -> Value {
|
|
1211
|
+
int cI = static_cast<int>(path.size());
|
|
1212
|
+
if (key.is_undef() || cI <= 0) {
|
|
1213
|
+
return cur[0];
|
|
1214
|
+
}
|
|
1215
|
+
Value value = cur[cI];
|
|
1216
|
+
cur[cI - 1] = setprop(cur[cI - 1], key, value);
|
|
1217
|
+
return value;
|
|
1218
|
+
};
|
|
1219
|
+
|
|
1220
|
+
walk_v(obj, before, after, md);
|
|
1221
|
+
out = cur[0];
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
if (md == 0) {
|
|
1225
|
+
Value last = src->back();
|
|
1226
|
+
if (last.is_list())
|
|
1227
|
+
out = Value(std::make_shared<List>());
|
|
1228
|
+
else if (last.is_map())
|
|
1229
|
+
out = Value(std::shared_ptr<Map>(new Map()));
|
|
1230
|
+
else
|
|
1231
|
+
out = last;
|
|
1232
|
+
}
|
|
1233
|
+
return out;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
// ===========================================================================
|
|
1237
|
+
// pathParts — shared helper for getpath / setpath
|
|
1238
|
+
// ===========================================================================
|
|
1239
|
+
|
|
1240
|
+
namespace detail {
|
|
1241
|
+
inline std::vector<std::string> path_parts(const Value& path) {
|
|
1242
|
+
std::vector<std::string> out;
|
|
1243
|
+
if (path.is_string()) {
|
|
1244
|
+
const std::string& s = path.as_string();
|
|
1245
|
+
if (s.empty()) {
|
|
1246
|
+
out.push_back("");
|
|
1247
|
+
return out;
|
|
1248
|
+
}
|
|
1249
|
+
size_t pos = 0;
|
|
1250
|
+
while (pos <= s.size()) {
|
|
1251
|
+
size_t dot = s.find('.', pos);
|
|
1252
|
+
if (dot == std::string::npos) {
|
|
1253
|
+
out.push_back(s.substr(pos));
|
|
1254
|
+
break;
|
|
1255
|
+
}
|
|
1256
|
+
out.push_back(s.substr(pos, dot - pos));
|
|
1257
|
+
pos = dot + 1;
|
|
1258
|
+
}
|
|
1259
|
+
return out;
|
|
1260
|
+
}
|
|
1261
|
+
if (path.is_list()) {
|
|
1262
|
+
auto l = path.as_list();
|
|
1263
|
+
for (const auto& e : *l) {
|
|
1264
|
+
if (e.is_string())
|
|
1265
|
+
out.push_back(e.as_string());
|
|
1266
|
+
else if (e.is_number())
|
|
1267
|
+
out.push_back(strkey(e));
|
|
1268
|
+
else
|
|
1269
|
+
out.push_back(strkey(e));
|
|
1270
|
+
}
|
|
1271
|
+
return out;
|
|
1272
|
+
}
|
|
1273
|
+
if (path.is_number()) {
|
|
1274
|
+
out.push_back(strkey(path));
|
|
1275
|
+
return out;
|
|
1276
|
+
}
|
|
1277
|
+
return {};
|
|
1278
|
+
}
|
|
1279
|
+
} // namespace detail
|
|
1280
|
+
|
|
1281
|
+
// ===========================================================================
|
|
1282
|
+
// setpath
|
|
1283
|
+
// ===========================================================================
|
|
1284
|
+
|
|
1285
|
+
inline Value setpath_v(const Value& store, const Value& path, const Value& val) {
|
|
1286
|
+
std::vector<std::string> parts;
|
|
1287
|
+
bool path_is_list = path.is_list();
|
|
1288
|
+
if (path.is_undef() || path.is_null())
|
|
1289
|
+
return Value::undef();
|
|
1290
|
+
if (path.is_string())
|
|
1291
|
+
parts = detail::path_parts(path);
|
|
1292
|
+
else if (path.is_list())
|
|
1293
|
+
parts = detail::path_parts(path);
|
|
1294
|
+
else if (path.is_number())
|
|
1295
|
+
parts.push_back(strkey(path));
|
|
1296
|
+
else
|
|
1297
|
+
return Value::undef();
|
|
1298
|
+
if (parts.empty())
|
|
1299
|
+
return Value::undef();
|
|
1300
|
+
|
|
1301
|
+
// String paths only create maps (TS: "Use a string list to create list parts").
|
|
1302
|
+
// For list paths, decide list-vs-map by whether the next part is integer.
|
|
1303
|
+
Value parent = store;
|
|
1304
|
+
for (size_t i = 0; i + 1 < parts.size(); i++) {
|
|
1305
|
+
Value next = getprop(parent, Value(parts[i]));
|
|
1306
|
+
if (!isnode(next)) {
|
|
1307
|
+
bool make_list = false;
|
|
1308
|
+
if (path_is_list) {
|
|
1309
|
+
// Check the original list for whether parts[i+1] came from a number.
|
|
1310
|
+
Value el = getprop(path, Value(static_cast<int64_t>(i + 1)));
|
|
1311
|
+
if (el.is_number())
|
|
1312
|
+
make_list = true;
|
|
1313
|
+
}
|
|
1314
|
+
next = make_list ? Value(std::make_shared<List>()) : Value(std::shared_ptr<Map>(new Map()));
|
|
1315
|
+
setprop(parent, Value(parts[i]), next);
|
|
1316
|
+
}
|
|
1317
|
+
parent = next;
|
|
1318
|
+
}
|
|
1319
|
+
Value last_key(parts.back());
|
|
1320
|
+
if (is_delete(val)) {
|
|
1321
|
+
delprop(parent, last_key);
|
|
1322
|
+
} else {
|
|
1323
|
+
setprop(parent, last_key, val);
|
|
1324
|
+
}
|
|
1325
|
+
return parent;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
// ===========================================================================
|
|
1329
|
+
// Injection
|
|
1330
|
+
// ===========================================================================
|
|
1331
|
+
|
|
1332
|
+
class Injection {
|
|
1333
|
+
public:
|
|
1334
|
+
int mode = M_VAL;
|
|
1335
|
+
bool full = false;
|
|
1336
|
+
int keyI = 0;
|
|
1337
|
+
std::shared_ptr<std::vector<std::string>> keys; // shared with prior
|
|
1338
|
+
std::string key;
|
|
1339
|
+
Value val;
|
|
1340
|
+
Value parent;
|
|
1341
|
+
std::vector<std::string> path;
|
|
1342
|
+
std::shared_ptr<std::vector<Value>> nodes;
|
|
1343
|
+
Injector handler;
|
|
1344
|
+
std::shared_ptr<std::vector<Value>> errs;
|
|
1345
|
+
std::shared_ptr<Map> meta;
|
|
1346
|
+
Value dparent;
|
|
1347
|
+
std::vector<std::string> dpath;
|
|
1348
|
+
std::string base;
|
|
1349
|
+
Modify modify;
|
|
1350
|
+
Injection* prior = nullptr;
|
|
1351
|
+
Value extra;
|
|
1352
|
+
|
|
1353
|
+
Injection(const Value& val_in, const Value& parent_in) : val(val_in), parent(parent_in) {
|
|
1354
|
+
keys = std::make_shared<std::vector<std::string>>();
|
|
1355
|
+
keys->push_back(S_DTOP());
|
|
1356
|
+
key = S_DTOP();
|
|
1357
|
+
path.push_back(S_DTOP());
|
|
1358
|
+
nodes = std::make_shared<std::vector<Value>>();
|
|
1359
|
+
nodes->push_back(parent_in);
|
|
1360
|
+
dparent = Value::undef();
|
|
1361
|
+
dpath.push_back(S_DTOP());
|
|
1362
|
+
errs = std::make_shared<std::vector<Value>>();
|
|
1363
|
+
meta = std::shared_ptr<Map>(new Map());
|
|
1364
|
+
base = S_DTOP();
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
Value descend() {
|
|
1368
|
+
int64_t d = 0;
|
|
1369
|
+
if (auto* m = meta.get()) {
|
|
1370
|
+
Value* dv = m->find("__d");
|
|
1371
|
+
if (dv && dv->is_int())
|
|
1372
|
+
d = dv->as_int();
|
|
1373
|
+
m->set("__d", Value(d + 1));
|
|
1374
|
+
}
|
|
1375
|
+
if (path.size() < 2)
|
|
1376
|
+
return dparent;
|
|
1377
|
+
const std::string& parentkey = path[path.size() - 2];
|
|
1378
|
+
|
|
1379
|
+
if (dparent.is_undef()) {
|
|
1380
|
+
if (dpath.size() > 1) {
|
|
1381
|
+
dpath.push_back(parentkey);
|
|
1382
|
+
}
|
|
1383
|
+
} else {
|
|
1384
|
+
dparent = getprop(dparent, Value(parentkey));
|
|
1385
|
+
std::string lastpart = dpath.empty() ? "" : dpath.back();
|
|
1386
|
+
std::string marker = "$:" + parentkey;
|
|
1387
|
+
if (marker == lastpart) {
|
|
1388
|
+
if (!dpath.empty())
|
|
1389
|
+
dpath.pop_back();
|
|
1390
|
+
} else {
|
|
1391
|
+
dpath.push_back(parentkey);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
return dparent;
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
std::unique_ptr<Injection> child(int keyI_in,
|
|
1398
|
+
const std::shared_ptr<std::vector<std::string>>& keys_in) {
|
|
1399
|
+
std::string ck = strkey(Value((*keys_in)[keyI_in]));
|
|
1400
|
+
Value child_val = getprop(val, Value(ck));
|
|
1401
|
+
auto cinj = std::unique_ptr<Injection>(new Injection(child_val, val));
|
|
1402
|
+
cinj->keyI = keyI_in;
|
|
1403
|
+
cinj->keys = keys_in; // shared reference
|
|
1404
|
+
cinj->key = ck;
|
|
1405
|
+
cinj->path = path; // copy
|
|
1406
|
+
cinj->path.push_back(ck);
|
|
1407
|
+
cinj->nodes = std::make_shared<std::vector<Value>>(*nodes);
|
|
1408
|
+
cinj->nodes->push_back(val);
|
|
1409
|
+
cinj->mode = mode;
|
|
1410
|
+
cinj->handler = handler;
|
|
1411
|
+
cinj->modify = modify;
|
|
1412
|
+
cinj->base = base;
|
|
1413
|
+
cinj->meta = meta; // shared reference
|
|
1414
|
+
cinj->errs = errs; // shared reference
|
|
1415
|
+
cinj->prior = this;
|
|
1416
|
+
cinj->dpath = dpath; // copy
|
|
1417
|
+
cinj->dparent = dparent;
|
|
1418
|
+
return cinj;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
Value setval(const Value& v) { return setval(v, 0); }
|
|
1422
|
+
|
|
1423
|
+
Value setval(const Value& v, int ancestor) {
|
|
1424
|
+
Value pp;
|
|
1425
|
+
if (ancestor < 2) {
|
|
1426
|
+
if (v.is_undef()) {
|
|
1427
|
+
pp = delprop(parent, Value(key));
|
|
1428
|
+
parent = pp;
|
|
1429
|
+
} else {
|
|
1430
|
+
pp = setprop(parent, Value(key), v);
|
|
1431
|
+
}
|
|
1432
|
+
} else {
|
|
1433
|
+
// Use nodes[-ancestor] and path[-ancestor]
|
|
1434
|
+
int idx_n = static_cast<int>(nodes->size()) - ancestor;
|
|
1435
|
+
int idx_p = static_cast<int>(path.size()) - ancestor;
|
|
1436
|
+
if (idx_n < 0 || idx_p < 0)
|
|
1437
|
+
return Value::undef();
|
|
1438
|
+
Value aval = (*nodes)[idx_n];
|
|
1439
|
+
Value akey(path[idx_p]);
|
|
1440
|
+
if (v.is_undef()) {
|
|
1441
|
+
pp = delprop(aval, akey);
|
|
1442
|
+
} else {
|
|
1443
|
+
pp = setprop(aval, akey, v);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
return pp;
|
|
1447
|
+
}
|
|
1448
|
+
};
|
|
1449
|
+
|
|
1450
|
+
// ===========================================================================
|
|
1451
|
+
// getpath
|
|
1452
|
+
// ===========================================================================
|
|
1453
|
+
|
|
1454
|
+
namespace detail {
|
|
1455
|
+
|
|
1456
|
+
inline Value getpath_inner(const Value& store, const Value& path, std::vector<std::string>& parts,
|
|
1457
|
+
Injection* inj);
|
|
1458
|
+
|
|
1459
|
+
} // namespace detail
|
|
1460
|
+
|
|
1461
|
+
inline Value getpath_v(const Value& store, const Value& path, Injection* inj) {
|
|
1462
|
+
std::vector<std::string> parts;
|
|
1463
|
+
bool valid_path = false;
|
|
1464
|
+
if (path.is_string()) {
|
|
1465
|
+
parts = detail::path_parts(path);
|
|
1466
|
+
valid_path = true;
|
|
1467
|
+
} else if (path.is_list()) {
|
|
1468
|
+
parts = detail::path_parts(path);
|
|
1469
|
+
valid_path = true;
|
|
1470
|
+
} else if (path.is_number()) {
|
|
1471
|
+
parts.push_back(strkey(path));
|
|
1472
|
+
valid_path = true;
|
|
1473
|
+
}
|
|
1474
|
+
// Note: undef / null / bool / map paths are invalid (matches TS lines 1147-1153).
|
|
1475
|
+
if (!valid_path)
|
|
1476
|
+
return Value::undef();
|
|
1477
|
+
Value val = detail::getpath_inner(store, path, parts, inj);
|
|
1478
|
+
if (inj && inj->handler) {
|
|
1479
|
+
std::string ref = path.is_undef() ? "" : pathify(path);
|
|
1480
|
+
val = inj->handler(*inj, val, ref, store);
|
|
1481
|
+
}
|
|
1482
|
+
return val;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
namespace detail {
|
|
1486
|
+
|
|
1487
|
+
inline Value getpath_inner(const Value& store, const Value& path, std::vector<std::string>& parts,
|
|
1488
|
+
Injection* inj) {
|
|
1489
|
+
if (path.is_undef() || path.is_null()) {
|
|
1490
|
+
return store;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
Value base_v = inj ? Value(inj->base) : Value::undef();
|
|
1494
|
+
Value src = getprop(store, base_v, store);
|
|
1495
|
+
Value dparent = inj ? inj->dparent : Value::undef();
|
|
1496
|
+
std::vector<std::string>* dpath = inj ? &inj->dpath : nullptr;
|
|
1497
|
+
|
|
1498
|
+
int numparts = static_cast<int>(parts.size());
|
|
1499
|
+
Value val = store;
|
|
1500
|
+
|
|
1501
|
+
if (numparts == 0 || (numparts == 1 && parts[0].empty())) {
|
|
1502
|
+
return src;
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
// Function shortcut: if only one part and it directly resolves to a function
|
|
1506
|
+
// in store, return it.
|
|
1507
|
+
if (numparts == 1) {
|
|
1508
|
+
val = getprop(store, Value(parts[0]));
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
if (!isfunc(val)) {
|
|
1512
|
+
val = src;
|
|
1513
|
+
|
|
1514
|
+
// Meta path syntax `<root>$=value` / `<root>$~spec`.
|
|
1515
|
+
{
|
|
1516
|
+
std::smatch m;
|
|
1517
|
+
if (inj && inj->meta && std::regex_match(parts[0], m, R_META_PATH())) {
|
|
1518
|
+
val = getprop(Value(inj->meta), Value(m[1].str()));
|
|
1519
|
+
parts[0] = m[3].str();
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
for (int pI = 0; !val.is_undef() && !val.is_null() && pI < numparts; pI++) {
|
|
1524
|
+
std::string part = parts[pI];
|
|
1525
|
+
|
|
1526
|
+
if (inj && part == S_DKEY()) {
|
|
1527
|
+
part = inj->key;
|
|
1528
|
+
} else if (inj && part.size() > 5 && part.substr(0, 5) == "$GET:") {
|
|
1529
|
+
std::string subpath = part.substr(5, part.size() - 6);
|
|
1530
|
+
Value res = getpath_v(src, Value(subpath));
|
|
1531
|
+
part = stringify(res);
|
|
1532
|
+
} else if (inj && part.size() > 5 && part.substr(0, 5) == "$REF:") {
|
|
1533
|
+
std::string subpath = part.substr(5, part.size() - 6);
|
|
1534
|
+
Value spec = getprop(store, Value(S_DSPEC()));
|
|
1535
|
+
if (spec.is_injector()) {
|
|
1536
|
+
// Supplier-like: call the injector with a synthetic Injection.
|
|
1537
|
+
// (TS uses () => origspec; emulated here as Injector taking an inj.)
|
|
1538
|
+
Injection synth(Value::undef(), Value::undef());
|
|
1539
|
+
spec = spec.as_injector()(synth, Value::undef(), "$SPEC", store);
|
|
1540
|
+
}
|
|
1541
|
+
if (!spec.is_undef()) {
|
|
1542
|
+
Value res = getpath_v(spec, Value(subpath));
|
|
1543
|
+
part = stringify(res);
|
|
1544
|
+
}
|
|
1545
|
+
} else if (inj && part.size() > 6 && part.substr(0, 6) == "$META:") {
|
|
1546
|
+
std::string subpath = part.substr(6, part.size() - 7);
|
|
1547
|
+
Value res = getpath_v(Value(inj->meta), Value(subpath));
|
|
1548
|
+
part = stringify(res);
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
// $$ -> $
|
|
1552
|
+
part = std::regex_replace(part, R_DOUBLE_DOLLAR(), "$");
|
|
1553
|
+
|
|
1554
|
+
if (part.empty()) {
|
|
1555
|
+
int ascends = 0;
|
|
1556
|
+
while (1 + pI < numparts && parts[1 + pI].empty()) {
|
|
1557
|
+
ascends++;
|
|
1558
|
+
pI++;
|
|
1559
|
+
}
|
|
1560
|
+
if (inj && ascends > 0) {
|
|
1561
|
+
if (pI == numparts - 1)
|
|
1562
|
+
ascends--;
|
|
1563
|
+
if (ascends == 0) {
|
|
1564
|
+
val = dparent;
|
|
1565
|
+
} else if (dpath) {
|
|
1566
|
+
int dlen = static_cast<int>(dpath->size());
|
|
1567
|
+
int cut = dlen - ascends;
|
|
1568
|
+
if (cut < 0)
|
|
1569
|
+
cut = 0;
|
|
1570
|
+
std::vector<std::string> fullpath(dpath->begin(), dpath->begin() + cut);
|
|
1571
|
+
for (int j = pI + 1; j < numparts; j++) {
|
|
1572
|
+
fullpath.push_back(parts[j]);
|
|
1573
|
+
}
|
|
1574
|
+
if (ascends <= dlen) {
|
|
1575
|
+
auto fp = std::make_shared<List>();
|
|
1576
|
+
for (auto& p : fullpath)
|
|
1577
|
+
fp->push_back(Value(p));
|
|
1578
|
+
val = getpath_v(store, Value(std::move(fp)));
|
|
1579
|
+
} else {
|
|
1580
|
+
val = Value::undef();
|
|
1581
|
+
}
|
|
1582
|
+
break;
|
|
1583
|
+
}
|
|
1584
|
+
} else {
|
|
1585
|
+
val = dparent;
|
|
1586
|
+
}
|
|
1587
|
+
} else {
|
|
1588
|
+
val = getprop(val, Value(part));
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
return val;
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
} // namespace detail
|
|
1596
|
+
|
|
1597
|
+
// ===========================================================================
|
|
1598
|
+
// _invalidTypeMsg / _injectstr / _injecthandler
|
|
1599
|
+
// ===========================================================================
|
|
1600
|
+
|
|
1601
|
+
inline std::string invalid_type_msg(const std::vector<std::string>& path,
|
|
1602
|
+
const std::string& need_type, int vt, const Value& v,
|
|
1603
|
+
const std::string& whence = "") {
|
|
1604
|
+
(void) whence;
|
|
1605
|
+
std::string vs = (v.is_undef() || v.is_null()) ? "no value" : stringify(v);
|
|
1606
|
+
std::string out = "Expected ";
|
|
1607
|
+
if (path.size() > 1) {
|
|
1608
|
+
auto pl = std::make_shared<List>();
|
|
1609
|
+
for (auto& p : path)
|
|
1610
|
+
pl->push_back(Value(p));
|
|
1611
|
+
out += "field " + pathify(Value(pl), 1, 0) + " to be ";
|
|
1612
|
+
}
|
|
1613
|
+
out += need_type + ", but found ";
|
|
1614
|
+
if (!v.is_undef() && !v.is_null()) {
|
|
1615
|
+
out += typename_str(vt) + ": ";
|
|
1616
|
+
}
|
|
1617
|
+
out += vs + ".";
|
|
1618
|
+
return out;
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
inline std::string invalid_type_msg(const Value& path_v, const std::string& need_type, int vt,
|
|
1622
|
+
const Value& v, const std::string& whence = "") {
|
|
1623
|
+
std::vector<std::string> p;
|
|
1624
|
+
if (path_v.is_list()) {
|
|
1625
|
+
for (const auto& e : *path_v.as_list())
|
|
1626
|
+
p.push_back(strkey(e));
|
|
1627
|
+
} else if (path_v.is_string()) {
|
|
1628
|
+
p.push_back(path_v.as_string());
|
|
1629
|
+
}
|
|
1630
|
+
return invalid_type_msg(p, need_type, vt, v, whence);
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
// MODENAME / PLACEMENT helpers.
|
|
1634
|
+
inline std::string modename(int mode) {
|
|
1635
|
+
switch (mode) {
|
|
1636
|
+
case M_VAL:
|
|
1637
|
+
return "val";
|
|
1638
|
+
case M_KEYPRE:
|
|
1639
|
+
return "key:pre";
|
|
1640
|
+
case M_KEYPOST:
|
|
1641
|
+
return "key:post";
|
|
1642
|
+
default:
|
|
1643
|
+
return "";
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
inline std::string placement(int mode) {
|
|
1647
|
+
switch (mode) {
|
|
1648
|
+
case M_VAL:
|
|
1649
|
+
return "value";
|
|
1650
|
+
case M_KEYPRE:
|
|
1651
|
+
case M_KEYPOST:
|
|
1652
|
+
return "key";
|
|
1653
|
+
default:
|
|
1654
|
+
return "";
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
// _injecthandler: forward declared, defined below after Injection helpers.
|
|
1659
|
+
inline Value injecthandler(Injection& inj, const Value& val, const std::string& ref,
|
|
1660
|
+
const Value& store);
|
|
1661
|
+
|
|
1662
|
+
inline Value injectstr(const std::string& val, const Value& store, Injection* inj) {
|
|
1663
|
+
if (val.empty())
|
|
1664
|
+
return Value(std::string(""));
|
|
1665
|
+
|
|
1666
|
+
std::smatch m;
|
|
1667
|
+
if (std::regex_match(val, m, R_INJECTION_FULL())) {
|
|
1668
|
+
if (inj)
|
|
1669
|
+
inj->full = true;
|
|
1670
|
+
std::string pathref = m[1].str();
|
|
1671
|
+
if (pathref.size() > 3) {
|
|
1672
|
+
pathref = std::regex_replace(pathref, R_BT_ESCAPE(), "`");
|
|
1673
|
+
pathref = std::regex_replace(pathref, R_DS_ESCAPE(), "$");
|
|
1674
|
+
}
|
|
1675
|
+
return getpath_v(store, Value(pathref), inj);
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
// Partial replacement.
|
|
1679
|
+
auto begin = std::sregex_iterator(val.begin(), val.end(), R_INJECTION_PARTIAL());
|
|
1680
|
+
auto end = std::sregex_iterator();
|
|
1681
|
+
std::string out;
|
|
1682
|
+
size_t cursor = 0;
|
|
1683
|
+
for (auto it = begin; it != end; ++it) {
|
|
1684
|
+
auto pos = static_cast<size_t>(it->position(0));
|
|
1685
|
+
out.append(val, cursor, pos - cursor);
|
|
1686
|
+
std::string ref = (*it)[1].str();
|
|
1687
|
+
if (ref.size() > 3) {
|
|
1688
|
+
ref = std::regex_replace(ref, R_BT_ESCAPE(), "`");
|
|
1689
|
+
ref = std::regex_replace(ref, R_DS_ESCAPE(), "$");
|
|
1690
|
+
}
|
|
1691
|
+
if (inj)
|
|
1692
|
+
inj->full = false;
|
|
1693
|
+
Value found = getpath_v(store, Value(ref), inj);
|
|
1694
|
+
if (found.is_undef()) {
|
|
1695
|
+
// append nothing
|
|
1696
|
+
} else if (found.is_null()) {
|
|
1697
|
+
out += "null";
|
|
1698
|
+
} else if (found.is_string()) {
|
|
1699
|
+
out += found.as_string();
|
|
1700
|
+
} else {
|
|
1701
|
+
// Compact JSON for non-string injection — no third-party dep.
|
|
1702
|
+
_jsonify_inner(found, out, 0, 0);
|
|
1703
|
+
}
|
|
1704
|
+
cursor = pos + it->length(0);
|
|
1705
|
+
}
|
|
1706
|
+
out.append(val, cursor, val.size() - cursor);
|
|
1707
|
+
|
|
1708
|
+
Value out_val(out);
|
|
1709
|
+
if (inj && inj->handler) {
|
|
1710
|
+
inj->full = true;
|
|
1711
|
+
out_val = inj->handler(*inj, out_val, val, store);
|
|
1712
|
+
}
|
|
1713
|
+
return out_val;
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
inline Value injecthandler(Injection& inj, const Value& val, const std::string& ref,
|
|
1717
|
+
const Value& store) {
|
|
1718
|
+
Value out = val;
|
|
1719
|
+
bool iscmd = isfunc(val) && (ref.empty() || ref[0] == '$');
|
|
1720
|
+
if (iscmd) {
|
|
1721
|
+
if (val.is_injector()) {
|
|
1722
|
+
out = val.as_injector()(inj, val, ref, store);
|
|
1723
|
+
}
|
|
1724
|
+
} else if (inj.mode == M_VAL && inj.full) {
|
|
1725
|
+
inj.setval(val);
|
|
1726
|
+
}
|
|
1727
|
+
return out;
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
// ===========================================================================
|
|
1731
|
+
// checkPlacement / injectorArgs / injectChild
|
|
1732
|
+
// ===========================================================================
|
|
1733
|
+
|
|
1734
|
+
inline bool checkPlacement(int modes, const std::string& ijname, int parent_types, Injection& inj) {
|
|
1735
|
+
if ((modes & inj.mode) == 0) {
|
|
1736
|
+
std::string allowed;
|
|
1737
|
+
int first = 1;
|
|
1738
|
+
for (int m : {M_KEYPRE, M_KEYPOST, M_VAL}) {
|
|
1739
|
+
if (modes & m) {
|
|
1740
|
+
if (!first)
|
|
1741
|
+
allowed += ",";
|
|
1742
|
+
allowed += placement(m);
|
|
1743
|
+
first = 0;
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
inj.errs->push_back(Value("$" + ijname + ": invalid placement as " + placement(inj.mode) +
|
|
1747
|
+
", expected: " + allowed + "."));
|
|
1748
|
+
return false;
|
|
1749
|
+
}
|
|
1750
|
+
if (parent_types != 0) {
|
|
1751
|
+
int ptype = typify(inj.parent);
|
|
1752
|
+
if ((parent_types & ptype) == 0) {
|
|
1753
|
+
inj.errs->push_back(Value("$" + ijname + ": invalid placement in parent " +
|
|
1754
|
+
typename_str(ptype) + ", expected: " + typename_str(parent_types) +
|
|
1755
|
+
"."));
|
|
1756
|
+
return false;
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
return true;
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
// Returns a vector of size argTypes.size() + 1.
|
|
1763
|
+
// [0] is error message (empty string if ok), [1..] are args.
|
|
1764
|
+
inline std::vector<Value> injectorArgs(const std::vector<int>& arg_types,
|
|
1765
|
+
const std::vector<Value>& args) {
|
|
1766
|
+
std::vector<Value> out(arg_types.size() + 1);
|
|
1767
|
+
out[0] = Value::undef();
|
|
1768
|
+
for (size_t i = 0; i < arg_types.size(); i++) {
|
|
1769
|
+
Value arg = i < args.size() ? args[i] : Value::undef();
|
|
1770
|
+
int argType = typify(arg);
|
|
1771
|
+
if ((arg_types[i] & argType) == 0) {
|
|
1772
|
+
out[0] = Value("invalid argument: " + stringify(arg, 22) + " (" + typename_str(argType) +
|
|
1773
|
+
" at position " + std::to_string(1 + i) +
|
|
1774
|
+
") is not of type: " + typename_str(arg_types[i]) + ".");
|
|
1775
|
+
return out;
|
|
1776
|
+
}
|
|
1777
|
+
out[i + 1] = arg;
|
|
1778
|
+
}
|
|
1779
|
+
return out;
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
// Forward decl: inject is defined below.
|
|
1783
|
+
inline std::unique_ptr<Injection> injectChild_helper(const Value& child, const Value& store,
|
|
1784
|
+
Injection& inj);
|
|
1785
|
+
|
|
1786
|
+
inline Injection& injectChild(const Value& child, const Value& store,
|
|
1787
|
+
Injection& inj); // signature only; inline below
|
|
1788
|
+
|
|
1789
|
+
// ===========================================================================
|
|
1790
|
+
// inject
|
|
1791
|
+
// ===========================================================================
|
|
1792
|
+
|
|
1793
|
+
inline Value inject(const Value& val, const Value& store, Injection* injdef) {
|
|
1794
|
+
std::unique_ptr<Injection> inj_owner;
|
|
1795
|
+
Injection* inj = nullptr;
|
|
1796
|
+
bool isInitial = (injdef == nullptr || injdef->prior == nullptr);
|
|
1797
|
+
|
|
1798
|
+
if (isInitial) {
|
|
1799
|
+
auto wrap = std::shared_ptr<Map>(new Map());
|
|
1800
|
+
wrap->set(S_DTOP(), val);
|
|
1801
|
+
inj_owner.reset(new Injection(val, Value(wrap)));
|
|
1802
|
+
inj_owner->dparent = store;
|
|
1803
|
+
Value errs_v = getprop(store, Value(S_DERRS()));
|
|
1804
|
+
if (errs_v.is_list()) {
|
|
1805
|
+
// Replace shared errs with the store's list (by transferring pointers).
|
|
1806
|
+
// We can't directly assign vector<Value>; convert.
|
|
1807
|
+
// Store list-of-values share semantics: keep using inj's errs; but we
|
|
1808
|
+
// need the same list as the store's $ERRS so the test runner sees them.
|
|
1809
|
+
// Quickly: inj->errs = a fresh vec, then push references via the
|
|
1810
|
+
// `Value(list)` storage. For simplicity, swap our shared_ptr for the
|
|
1811
|
+
// List behind store.$ERRS. We store via shared_ptr<vector<Value>>,
|
|
1812
|
+
// not shared_ptr<List>; bridge by reusing the underlying vector.
|
|
1813
|
+
// Simplest: mirror — use the store's list directly when possible.
|
|
1814
|
+
auto sl = errs_v.as_list();
|
|
1815
|
+
// Replace inj_owner->errs with a fresh vec backed by sl's elements;
|
|
1816
|
+
// append back to sl when an error is added. To keep semantics simple,
|
|
1817
|
+
// the errs list is kept as an alias: every push to inj_owner->errs is
|
|
1818
|
+
// also pushed to sl. We achieve this by sharing via a wrapper:
|
|
1819
|
+
// assign inj_owner->errs to a new vec that mirrors sl. For now,
|
|
1820
|
+
// use sl's vector as the source of truth.
|
|
1821
|
+
//
|
|
1822
|
+
// Simpler approach: don't share; copy on initial setup, push back at
|
|
1823
|
+
// end. The corpus tests pass errs externally via the options map, so
|
|
1824
|
+
// this is wired in transform()/validate() instead.
|
|
1825
|
+
(void) sl;
|
|
1826
|
+
}
|
|
1827
|
+
inj_owner->meta->set("__d", Value(int64_t(0)));
|
|
1828
|
+
|
|
1829
|
+
if (injdef) {
|
|
1830
|
+
if (injdef->modify)
|
|
1831
|
+
inj_owner->modify = injdef->modify;
|
|
1832
|
+
if (!injdef->extra.is_undef())
|
|
1833
|
+
inj_owner->extra = injdef->extra;
|
|
1834
|
+
if (injdef->meta)
|
|
1835
|
+
inj_owner->meta = injdef->meta;
|
|
1836
|
+
if (injdef->handler)
|
|
1837
|
+
inj_owner->handler = injdef->handler;
|
|
1838
|
+
if (!injdef->base.empty())
|
|
1839
|
+
inj_owner->base = injdef->base;
|
|
1840
|
+
if (!injdef->dparent.is_undef())
|
|
1841
|
+
inj_owner->dparent = injdef->dparent;
|
|
1842
|
+
if (injdef->errs && !injdef->errs->empty())
|
|
1843
|
+
inj_owner->errs = injdef->errs;
|
|
1844
|
+
// Always honor an external errs list pointer if one is supplied.
|
|
1845
|
+
if (injdef->errs)
|
|
1846
|
+
inj_owner->errs = injdef->errs;
|
|
1847
|
+
}
|
|
1848
|
+
if (!inj_owner->handler) {
|
|
1849
|
+
inj_owner->handler = injecthandler;
|
|
1850
|
+
}
|
|
1851
|
+
// Top-level wrapper participates in nodes stack.
|
|
1852
|
+
inj_owner->nodes->clear();
|
|
1853
|
+
inj_owner->nodes->push_back(Value(wrap));
|
|
1854
|
+
inj = inj_owner.get();
|
|
1855
|
+
} else {
|
|
1856
|
+
inj = injdef;
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
inj->descend();
|
|
1860
|
+
|
|
1861
|
+
Value cur = val;
|
|
1862
|
+
|
|
1863
|
+
if (isnode(cur) && !cur.is_sentinel()) {
|
|
1864
|
+
auto node_keys_vec = keysof(cur);
|
|
1865
|
+
auto nodekeys = std::make_shared<std::vector<std::string>>();
|
|
1866
|
+
|
|
1867
|
+
if (cur.is_map()) {
|
|
1868
|
+
// $-suffix ordering: non-$ first, then $.
|
|
1869
|
+
for (const auto& k : node_keys_vec) {
|
|
1870
|
+
if (k.find('$') == std::string::npos)
|
|
1871
|
+
nodekeys->push_back(k);
|
|
1872
|
+
}
|
|
1873
|
+
for (const auto& k : node_keys_vec) {
|
|
1874
|
+
if (k.find('$') != std::string::npos)
|
|
1875
|
+
nodekeys->push_back(k);
|
|
1876
|
+
}
|
|
1877
|
+
} else {
|
|
1878
|
+
*nodekeys = node_keys_vec;
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
inj->val = cur;
|
|
1882
|
+
|
|
1883
|
+
for (size_t nkI = 0; nkI < nodekeys->size(); nkI++) {
|
|
1884
|
+
auto cinj_owner = inj->child(static_cast<int>(nkI), nodekeys);
|
|
1885
|
+
Injection* cinj = cinj_owner.get();
|
|
1886
|
+
std::string nodekey = cinj->key;
|
|
1887
|
+
cinj->mode = M_KEYPRE;
|
|
1888
|
+
|
|
1889
|
+
Value prekey = injectstr(nodekey, store, cinj);
|
|
1890
|
+
nkI = cinj->keyI;
|
|
1891
|
+
nodekeys = cinj->keys;
|
|
1892
|
+
|
|
1893
|
+
if (!prekey.is_undef()) {
|
|
1894
|
+
cinj->val = getprop(cur, prekey);
|
|
1895
|
+
cinj->mode = M_VAL;
|
|
1896
|
+
inject(cinj->val, store, cinj);
|
|
1897
|
+
|
|
1898
|
+
cinj->mode = M_KEYPOST;
|
|
1899
|
+
injectstr(nodekey, store, cinj);
|
|
1900
|
+
|
|
1901
|
+
nkI = cinj->keyI;
|
|
1902
|
+
nodekeys = cinj->keys;
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
} else if (cur.is_string()) {
|
|
1906
|
+
inj->mode = M_VAL;
|
|
1907
|
+
Value newVal = injectstr(cur.as_string(), store, inj);
|
|
1908
|
+
if (!is_skip(newVal)) {
|
|
1909
|
+
inj->setval(newVal);
|
|
1910
|
+
}
|
|
1911
|
+
cur = newVal;
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
if (inj->modify && !is_skip(cur)) {
|
|
1915
|
+
Value mkey(inj->key);
|
|
1916
|
+
Value mparent = inj->parent;
|
|
1917
|
+
Value mval = getprop(mparent, mkey);
|
|
1918
|
+
inj->modify(mval, mkey, mparent, *inj, store);
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
inj->val = cur;
|
|
1922
|
+
return lookup_v(inj->parent, Value(S_DTOP()));
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
// injectChild definition (after inject is declared).
|
|
1926
|
+
inline Injection& injectChild(const Value& child, const Value& store, Injection& inj) {
|
|
1927
|
+
static thread_local std::unique_ptr<Injection> hold;
|
|
1928
|
+
Injection* cinj = &inj;
|
|
1929
|
+
std::unique_ptr<Injection> owner;
|
|
1930
|
+
if (inj.prior) {
|
|
1931
|
+
if (inj.prior->prior) {
|
|
1932
|
+
owner = inj.prior->prior->child(inj.prior->keyI, inj.prior->keys);
|
|
1933
|
+
owner->val = child;
|
|
1934
|
+
setprop(owner->parent, Value(inj.prior->key), child);
|
|
1935
|
+
} else {
|
|
1936
|
+
owner = inj.prior->child(inj.keyI, inj.keys);
|
|
1937
|
+
owner->val = child;
|
|
1938
|
+
setprop(owner->parent, Value(inj.key), child);
|
|
1939
|
+
}
|
|
1940
|
+
cinj = owner.get();
|
|
1941
|
+
}
|
|
1942
|
+
inject(child, store, cinj);
|
|
1943
|
+
if (owner) {
|
|
1944
|
+
hold = std::move(owner);
|
|
1945
|
+
}
|
|
1946
|
+
return *cinj;
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
// ===========================================================================
|
|
1950
|
+
// Transform injectors
|
|
1951
|
+
// ===========================================================================
|
|
1952
|
+
|
|
1953
|
+
namespace transforms {
|
|
1954
|
+
|
|
1955
|
+
inline Value DELETE_FN(Injection& inj, const Value& val, const std::string& ref,
|
|
1956
|
+
const Value& store) {
|
|
1957
|
+
inj.setval(Value::undef());
|
|
1958
|
+
return Value::undef();
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
inline Value COPY_FN(Injection& inj, const Value& val, const std::string& ref, const Value& store) {
|
|
1962
|
+
if (!checkPlacement(M_VAL, "COPY", T_any, inj))
|
|
1963
|
+
return Value::undef();
|
|
1964
|
+
Value out = lookup_v(inj.dparent, Value(inj.key));
|
|
1965
|
+
inj.setval(out);
|
|
1966
|
+
return out;
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
inline Value KEY_FN(Injection& inj, const Value& val, const std::string& ref, const Value& store) {
|
|
1970
|
+
if (inj.mode != M_VAL)
|
|
1971
|
+
return Value::undef();
|
|
1972
|
+
Value keyspec = lookup_v(inj.parent, Value(S_BKEY()));
|
|
1973
|
+
if (!keyspec.is_undef()) {
|
|
1974
|
+
delprop(inj.parent, Value(S_BKEY()));
|
|
1975
|
+
return getprop(inj.dparent, keyspec);
|
|
1976
|
+
}
|
|
1977
|
+
Value anno = lookup_v(inj.parent, Value(S_BANNO()));
|
|
1978
|
+
Value alt = inj.path.size() >= 2 ? Value(inj.path[inj.path.size() - 2]) : Value::undef();
|
|
1979
|
+
// Canonical: `_lookup(anno, S_KEY) ?? getelem(path, -2)` — null/undef -> alt.
|
|
1980
|
+
Value k = lookup_v(anno, Value("KEY"));
|
|
1981
|
+
if (k.is_undef() || k.is_null())
|
|
1982
|
+
return alt;
|
|
1983
|
+
return k;
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
inline Value ANNO_FN(Injection& inj, const Value& val, const std::string& ref, const Value& store) {
|
|
1987
|
+
delprop(inj.parent, Value(S_BANNO()));
|
|
1988
|
+
return Value::undef();
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
inline Value MERGE_FN(Injection& inj, const Value& val, const std::string& ref,
|
|
1992
|
+
const Value& store) {
|
|
1993
|
+
if (inj.mode == M_KEYPRE)
|
|
1994
|
+
return Value(inj.key);
|
|
1995
|
+
if (inj.mode != M_KEYPOST)
|
|
1996
|
+
return Value::undef();
|
|
1997
|
+
|
|
1998
|
+
Value args = getprop(inj.parent, Value(inj.key));
|
|
1999
|
+
auto arg_list = std::make_shared<List>();
|
|
2000
|
+
if (args.is_list()) {
|
|
2001
|
+
for (const auto& e : *args.as_list())
|
|
2002
|
+
arg_list->push_back(e);
|
|
2003
|
+
} else {
|
|
2004
|
+
arg_list->push_back(args);
|
|
2005
|
+
}
|
|
2006
|
+
inj.setval(Value::undef());
|
|
2007
|
+
|
|
2008
|
+
auto merge_args = std::make_shared<List>();
|
|
2009
|
+
merge_args->push_back(inj.parent);
|
|
2010
|
+
for (const auto& a : *arg_list)
|
|
2011
|
+
merge_args->push_back(a);
|
|
2012
|
+
merge_args->push_back(clone(inj.parent));
|
|
2013
|
+
merge_v(Value(merge_args));
|
|
2014
|
+
return Value(inj.key);
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
// FORMATTER map (named formatters for $FORMAT).
|
|
2018
|
+
inline std::unordered_map<std::string, std::function<Value(const Value&)>>& formatters() {
|
|
2019
|
+
static std::unordered_map<std::string, std::function<Value(const Value&)>> F;
|
|
2020
|
+
if (F.empty()) {
|
|
2021
|
+
auto deep_apply = [](const Value& v, std::function<Value(const Value&)> f) -> Value {
|
|
2022
|
+
std::function<Value(const Value&)> rec = [&](const Value& x) -> Value {
|
|
2023
|
+
if (x.is_list()) {
|
|
2024
|
+
auto out = std::make_shared<List>();
|
|
2025
|
+
for (const auto& e : *x.as_list())
|
|
2026
|
+
out->push_back(rec(e));
|
|
2027
|
+
return Value(out);
|
|
2028
|
+
}
|
|
2029
|
+
if (x.is_map()) {
|
|
2030
|
+
auto out = std::shared_ptr<Map>(new Map());
|
|
2031
|
+
for (const auto& [k, e] : *x.as_map())
|
|
2032
|
+
out->set(k, rec(e));
|
|
2033
|
+
return Value(out);
|
|
2034
|
+
}
|
|
2035
|
+
return f(x);
|
|
2036
|
+
};
|
|
2037
|
+
return rec(v);
|
|
2038
|
+
};
|
|
2039
|
+
F["identity"] = [](const Value& v) { return v; };
|
|
2040
|
+
F["upper"] = [deep_apply](const Value& v) {
|
|
2041
|
+
return deep_apply(v, [](const Value& x) -> Value {
|
|
2042
|
+
if (isnode(x))
|
|
2043
|
+
return x;
|
|
2044
|
+
std::string s = js_string(x);
|
|
2045
|
+
for (auto& c : s)
|
|
2046
|
+
c = static_cast<char>(std::toupper(static_cast<unsigned char>(c)));
|
|
2047
|
+
return Value(s);
|
|
2048
|
+
});
|
|
2049
|
+
};
|
|
2050
|
+
F["lower"] = [deep_apply](const Value& v) {
|
|
2051
|
+
return deep_apply(v, [](const Value& x) -> Value {
|
|
2052
|
+
if (isnode(x))
|
|
2053
|
+
return x;
|
|
2054
|
+
std::string s = js_string(x);
|
|
2055
|
+
for (auto& c : s)
|
|
2056
|
+
c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
|
2057
|
+
return Value(s);
|
|
2058
|
+
});
|
|
2059
|
+
};
|
|
2060
|
+
F["string"] = [deep_apply](const Value& v) {
|
|
2061
|
+
return deep_apply(v, [](const Value& x) -> Value {
|
|
2062
|
+
if (isnode(x))
|
|
2063
|
+
return x;
|
|
2064
|
+
return Value(js_string(x));
|
|
2065
|
+
});
|
|
2066
|
+
};
|
|
2067
|
+
F["number"] = [deep_apply](const Value& v) {
|
|
2068
|
+
return deep_apply(v, [](const Value& x) -> Value {
|
|
2069
|
+
if (isnode(x))
|
|
2070
|
+
return x;
|
|
2071
|
+
if (x.is_number())
|
|
2072
|
+
return x;
|
|
2073
|
+
try {
|
|
2074
|
+
double d = std::stod(js_string(x));
|
|
2075
|
+
if (std::isnan(d))
|
|
2076
|
+
return Value(int64_t(0));
|
|
2077
|
+
if (std::floor(d) == d)
|
|
2078
|
+
return Value(static_cast<int64_t>(d));
|
|
2079
|
+
return Value(d);
|
|
2080
|
+
} catch (...) {
|
|
2081
|
+
return Value(int64_t(0));
|
|
2082
|
+
}
|
|
2083
|
+
});
|
|
2084
|
+
};
|
|
2085
|
+
F["integer"] = [deep_apply](const Value& v) {
|
|
2086
|
+
return deep_apply(v, [](const Value& x) -> Value {
|
|
2087
|
+
if (isnode(x))
|
|
2088
|
+
return x;
|
|
2089
|
+
try {
|
|
2090
|
+
return Value(static_cast<int64_t>(std::stod(js_string(x))));
|
|
2091
|
+
} catch (...) {
|
|
2092
|
+
return Value(int64_t(0));
|
|
2093
|
+
}
|
|
2094
|
+
});
|
|
2095
|
+
};
|
|
2096
|
+
F["concat"] = [](const Value& v) -> Value {
|
|
2097
|
+
if (!v.is_list())
|
|
2098
|
+
return v;
|
|
2099
|
+
std::string out;
|
|
2100
|
+
for (const auto& e : *v.as_list()) {
|
|
2101
|
+
if (!isnode(e))
|
|
2102
|
+
out += js_string(e);
|
|
2103
|
+
}
|
|
2104
|
+
return Value(out);
|
|
2105
|
+
};
|
|
2106
|
+
}
|
|
2107
|
+
return F;
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
inline Value FORMAT_FN(Injection& inj, const Value& val, const std::string& ref,
|
|
2111
|
+
const Value& store) {
|
|
2112
|
+
// Truncate keys to single element.
|
|
2113
|
+
if (inj.keys && inj.keys->size() > 1) {
|
|
2114
|
+
inj.keys->resize(1);
|
|
2115
|
+
}
|
|
2116
|
+
if (inj.mode != M_VAL)
|
|
2117
|
+
return Value::undef();
|
|
2118
|
+
|
|
2119
|
+
Value name = lookup_v(inj.parent, Value(int64_t(1)));
|
|
2120
|
+
Value child = lookup_v(inj.parent, Value(int64_t(2)));
|
|
2121
|
+
|
|
2122
|
+
Value tkey = inj.path.size() >= 2 ? Value(inj.path[inj.path.size() - 2]) : Value::undef();
|
|
2123
|
+
Value target;
|
|
2124
|
+
if (inj.nodes && inj.nodes->size() >= 2) {
|
|
2125
|
+
target = (*inj.nodes)[inj.nodes->size() - 2];
|
|
2126
|
+
} else if (inj.nodes && !inj.nodes->empty()) {
|
|
2127
|
+
target = inj.nodes->back();
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
Injection& cinj = injectChild(child, store, inj);
|
|
2131
|
+
Value resolved = cinj.val;
|
|
2132
|
+
|
|
2133
|
+
auto& F = formatters();
|
|
2134
|
+
std::string fname = name.is_string() ? name.as_string() : "";
|
|
2135
|
+
auto it = F.find(fname);
|
|
2136
|
+
if (it == F.end()) {
|
|
2137
|
+
inj.errs->push_back(Value("$FORMAT: unknown format: " + fname + "."));
|
|
2138
|
+
return Value::undef();
|
|
2139
|
+
}
|
|
2140
|
+
Value out = it->second(resolved);
|
|
2141
|
+
setprop(target, tkey, out);
|
|
2142
|
+
return out;
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
inline Value APPLY_FN(Injection& inj, const Value& val, const std::string& ref,
|
|
2146
|
+
const Value& store) {
|
|
2147
|
+
if (!checkPlacement(M_VAL, "APPLY", T_list, inj))
|
|
2148
|
+
return Value::undef();
|
|
2149
|
+
std::vector<Value> args;
|
|
2150
|
+
if (inj.parent.is_list()) {
|
|
2151
|
+
auto pl = inj.parent.as_list();
|
|
2152
|
+
for (size_t i = 1; i < pl->size(); i++)
|
|
2153
|
+
args.push_back((*pl)[i]);
|
|
2154
|
+
}
|
|
2155
|
+
auto checked = injectorArgs({T_function, T_any}, args);
|
|
2156
|
+
if (!checked[0].is_undef()) {
|
|
2157
|
+
inj.errs->push_back(Value("$APPLY: " + checked[0].as_string()));
|
|
2158
|
+
return Value::undef();
|
|
2159
|
+
}
|
|
2160
|
+
Value apply = checked[1];
|
|
2161
|
+
Value child = checked[2];
|
|
2162
|
+
|
|
2163
|
+
Value tkey = inj.path.size() >= 2 ? Value(inj.path[inj.path.size() - 2]) : Value::undef();
|
|
2164
|
+
Value target;
|
|
2165
|
+
if (inj.nodes && inj.nodes->size() >= 2) {
|
|
2166
|
+
target = (*inj.nodes)[inj.nodes->size() - 2];
|
|
2167
|
+
} else if (inj.nodes && !inj.nodes->empty()) {
|
|
2168
|
+
target = inj.nodes->back();
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
Injection& cinj = injectChild(child, store, inj);
|
|
2172
|
+
Value resolved = cinj.val;
|
|
2173
|
+
|
|
2174
|
+
Value out;
|
|
2175
|
+
if (apply.is_injector()) {
|
|
2176
|
+
out = apply.as_injector()(inj, resolved, ref, store);
|
|
2177
|
+
} else {
|
|
2178
|
+
out = Value::undef();
|
|
2179
|
+
}
|
|
2180
|
+
setprop(target, tkey, out);
|
|
2181
|
+
return out;
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
inline Value EACH_FN(Injection& inj, const Value& val, const std::string& ref, const Value& store) {
|
|
2185
|
+
if (!checkPlacement(M_VAL, "EACH", T_list, inj))
|
|
2186
|
+
return Value::undef();
|
|
2187
|
+
if (inj.keys && inj.keys->size() > 1) {
|
|
2188
|
+
inj.keys->resize(1);
|
|
2189
|
+
}
|
|
2190
|
+
std::vector<Value> args;
|
|
2191
|
+
if (inj.parent.is_list()) {
|
|
2192
|
+
auto pl = inj.parent.as_list();
|
|
2193
|
+
for (size_t i = 1; i < pl->size(); i++)
|
|
2194
|
+
args.push_back((*pl)[i]);
|
|
2195
|
+
}
|
|
2196
|
+
auto checked = injectorArgs({T_string, T_any}, args);
|
|
2197
|
+
if (!checked[0].is_undef()) {
|
|
2198
|
+
inj.errs->push_back(Value("$EACH: " + checked[0].as_string()));
|
|
2199
|
+
return Value::undef();
|
|
2200
|
+
}
|
|
2201
|
+
std::string srcpath = checked[1].as_string();
|
|
2202
|
+
Value child = checked[2];
|
|
2203
|
+
|
|
2204
|
+
Value srcstore = getprop(store, Value(inj.base), store);
|
|
2205
|
+
Value src = getpath_v(srcstore, Value(srcpath), &inj);
|
|
2206
|
+
int srctype = typify(src);
|
|
2207
|
+
|
|
2208
|
+
Value tkey = inj.path.size() >= 2 ? Value(inj.path[inj.path.size() - 2]) : Value::undef();
|
|
2209
|
+
Value target;
|
|
2210
|
+
if (inj.nodes && inj.nodes->size() >= 2) {
|
|
2211
|
+
target = (*inj.nodes)[inj.nodes->size() - 2];
|
|
2212
|
+
} else if (inj.nodes && !inj.nodes->empty()) {
|
|
2213
|
+
target = inj.nodes->back();
|
|
2214
|
+
}
|
|
2215
|
+
|
|
2216
|
+
auto tval = std::make_shared<List>();
|
|
2217
|
+
if ((T_list & srctype) && src.is_list()) {
|
|
2218
|
+
auto sl = src.as_list();
|
|
2219
|
+
for (size_t i = 0; i < sl->size(); i++)
|
|
2220
|
+
tval->push_back(clone(child));
|
|
2221
|
+
} else if ((T_map & srctype) && src.is_map()) {
|
|
2222
|
+
auto sm = src.as_map();
|
|
2223
|
+
for (const auto& [k, v] : *sm) {
|
|
2224
|
+
Value cl = clone(child);
|
|
2225
|
+
auto anno = std::shared_ptr<Map>(new Map());
|
|
2226
|
+
auto keymap = std::shared_ptr<Map>(new Map());
|
|
2227
|
+
keymap->set("KEY", Value(k));
|
|
2228
|
+
anno->set(S_BANNO(), Value(keymap));
|
|
2229
|
+
auto args_l = std::make_shared<List>();
|
|
2230
|
+
args_l->push_back(cl);
|
|
2231
|
+
args_l->push_back(Value(anno));
|
|
2232
|
+
Value merged = merge_v(Value(args_l), 1);
|
|
2233
|
+
tval->push_back(merged);
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
Value rval(std::make_shared<List>());
|
|
2238
|
+
|
|
2239
|
+
if (!tval->empty()) {
|
|
2240
|
+
Value tcur;
|
|
2241
|
+
if (src.is_list()) {
|
|
2242
|
+
auto tcur_list = std::make_shared<List>();
|
|
2243
|
+
for (const auto& e : *src.as_list())
|
|
2244
|
+
tcur_list->push_back(e);
|
|
2245
|
+
tcur = Value(tcur_list);
|
|
2246
|
+
} else if (src.is_map()) {
|
|
2247
|
+
auto tcur_list = std::make_shared<List>();
|
|
2248
|
+
for (const auto& [_, e] : *src.as_map())
|
|
2249
|
+
tcur_list->push_back(e);
|
|
2250
|
+
tcur = Value(tcur_list);
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
std::string ckey = inj.path.size() >= 2 ? inj.path[inj.path.size() - 2] : "";
|
|
2254
|
+
|
|
2255
|
+
std::vector<std::string> tpath(inj.path.begin(), inj.path.end() - 1);
|
|
2256
|
+
std::vector<std::string> dpath;
|
|
2257
|
+
dpath.push_back(S_DTOP());
|
|
2258
|
+
if (!srcpath.empty()) {
|
|
2259
|
+
// split srcpath on '.'
|
|
2260
|
+
size_t pos = 0;
|
|
2261
|
+
while (pos <= srcpath.size()) {
|
|
2262
|
+
size_t dot = srcpath.find('.', pos);
|
|
2263
|
+
if (dot == std::string::npos) {
|
|
2264
|
+
dpath.push_back(srcpath.substr(pos));
|
|
2265
|
+
break;
|
|
2266
|
+
}
|
|
2267
|
+
dpath.push_back(srcpath.substr(pos, dot - pos));
|
|
2268
|
+
pos = dot + 1;
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
dpath.push_back("$:" + ckey);
|
|
2272
|
+
|
|
2273
|
+
auto tcur_map = std::shared_ptr<Map>(new Map());
|
|
2274
|
+
tcur_map->set(ckey, tcur);
|
|
2275
|
+
Value tcur_out(tcur_map);
|
|
2276
|
+
if (tpath.size() > 1) {
|
|
2277
|
+
std::string pkey = inj.path.size() >= 3 ? inj.path[inj.path.size() - 3] : S_DTOP();
|
|
2278
|
+
auto wrap = std::shared_ptr<Map>(new Map());
|
|
2279
|
+
wrap->set(pkey, tcur_out);
|
|
2280
|
+
tcur_out = Value(wrap);
|
|
2281
|
+
dpath.push_back("$:" + pkey);
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2284
|
+
auto single_keys = std::make_shared<std::vector<std::string>>();
|
|
2285
|
+
single_keys->push_back(ckey);
|
|
2286
|
+
auto tinj_owner = inj.child(0, single_keys);
|
|
2287
|
+
Injection* tinj = tinj_owner.get();
|
|
2288
|
+
tinj->path = tpath;
|
|
2289
|
+
tinj->nodes = std::make_shared<std::vector<Value>>(inj.nodes->begin(), inj.nodes->end() - 1);
|
|
2290
|
+
tinj->parent = tinj->nodes->empty() ? Value::undef() : tinj->nodes->back();
|
|
2291
|
+
setprop(tinj->parent, Value(ckey), Value(tval));
|
|
2292
|
+
tinj->val = Value(tval);
|
|
2293
|
+
tinj->dpath = dpath;
|
|
2294
|
+
tinj->dparent = tcur_out;
|
|
2295
|
+
|
|
2296
|
+
inject(Value(tval), store, tinj);
|
|
2297
|
+
rval = tinj->val;
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
setprop(target, tkey, rval);
|
|
2301
|
+
if (rval.is_list() && !rval.as_list()->empty()) {
|
|
2302
|
+
return (*rval.as_list())[0];
|
|
2303
|
+
}
|
|
2304
|
+
return Value::undef();
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
inline Value PACK_FN(Injection& inj, const Value& val, const std::string& ref, const Value& store) {
|
|
2308
|
+
if (!checkPlacement(M_KEYPRE, "PACK", T_map, inj))
|
|
2309
|
+
return Value::undef();
|
|
2310
|
+
|
|
2311
|
+
Value args = getprop(inj.parent, Value(inj.key));
|
|
2312
|
+
std::vector<Value> arg_list;
|
|
2313
|
+
if (args.is_list()) {
|
|
2314
|
+
for (const auto& e : *args.as_list())
|
|
2315
|
+
arg_list.push_back(e);
|
|
2316
|
+
}
|
|
2317
|
+
auto checked = injectorArgs({T_string, T_any}, arg_list);
|
|
2318
|
+
if (!checked[0].is_undef()) {
|
|
2319
|
+
inj.errs->push_back(Value("$PACK: " + checked[0].as_string()));
|
|
2320
|
+
return Value::undef();
|
|
2321
|
+
}
|
|
2322
|
+
std::string srcpath = checked[1].as_string();
|
|
2323
|
+
Value origchildspec = checked[2];
|
|
2324
|
+
|
|
2325
|
+
Value tkey = inj.path.size() >= 2 ? Value(inj.path[inj.path.size() - 2]) : Value::undef();
|
|
2326
|
+
int pathsize = static_cast<int>(inj.path.size());
|
|
2327
|
+
Value target;
|
|
2328
|
+
if (inj.nodes && static_cast<int>(inj.nodes->size()) >= pathsize) {
|
|
2329
|
+
target = (*inj.nodes)[pathsize - 2];
|
|
2330
|
+
}
|
|
2331
|
+
if (target.is_undef() && inj.nodes && !inj.nodes->empty()) {
|
|
2332
|
+
target = inj.nodes->back();
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2335
|
+
Value srcstore = getprop(store, Value(inj.base), store);
|
|
2336
|
+
Value src = getpath_v(srcstore, Value(srcpath), &inj);
|
|
2337
|
+
|
|
2338
|
+
std::vector<Value> srcList;
|
|
2339
|
+
if (src.is_list()) {
|
|
2340
|
+
for (const auto& e : *src.as_list())
|
|
2341
|
+
srcList.push_back(e);
|
|
2342
|
+
} else if (src.is_map()) {
|
|
2343
|
+
for (const auto& [k, e] : *src.as_map()) {
|
|
2344
|
+
if (isnode(e)) {
|
|
2345
|
+
auto annoMap = std::shared_ptr<Map>(new Map());
|
|
2346
|
+
annoMap->set("KEY", Value(k));
|
|
2347
|
+
setprop(e, Value(S_BANNO()), Value(annoMap));
|
|
2348
|
+
srcList.push_back(e);
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
} else {
|
|
2352
|
+
return Value::undef();
|
|
2353
|
+
}
|
|
2354
|
+
|
|
2355
|
+
// Extract `$KEY` and `$VAL` from origchildspec.
|
|
2356
|
+
Value keypath = Value::undef();
|
|
2357
|
+
Value child = origchildspec;
|
|
2358
|
+
if (origchildspec.is_map()) {
|
|
2359
|
+
keypath = getprop(origchildspec, Value(S_BKEY()));
|
|
2360
|
+
delprop(origchildspec, Value(S_BKEY()));
|
|
2361
|
+
Value vspec = getprop(origchildspec, Value(S_BVAL()));
|
|
2362
|
+
child = vspec.is_undef() ? origchildspec : vspec;
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
auto tval = std::shared_ptr<Map>(new Map());
|
|
2366
|
+
|
|
2367
|
+
for (size_t i = 0; i < srcList.size(); i++) {
|
|
2368
|
+
const Value& item = srcList[i];
|
|
2369
|
+
std::string outKey;
|
|
2370
|
+
if (keypath.is_undef()) {
|
|
2371
|
+
Value dk = getprop(item, Value(S_DKEY()));
|
|
2372
|
+
outKey = dk.is_undef() ? std::to_string(i) : strkey(dk);
|
|
2373
|
+
} else if (keypath.is_string() && !keypath.as_string().empty() &&
|
|
2374
|
+
keypath.as_string()[0] == '`') {
|
|
2375
|
+
// Inject keypath against {$TOP: srcnode} merged into store.
|
|
2376
|
+
auto mergeList = std::make_shared<List>();
|
|
2377
|
+
mergeList->push_back(Value(std::shared_ptr<Map>(new Map())));
|
|
2378
|
+
mergeList->push_back(store);
|
|
2379
|
+
auto topMap = std::shared_ptr<Map>(new Map());
|
|
2380
|
+
topMap->set(S_DTOP(), item);
|
|
2381
|
+
mergeList->push_back(Value(topMap));
|
|
2382
|
+
Value merged = merge_v(Value(mergeList), 1);
|
|
2383
|
+
Value injected = inject(keypath, merged);
|
|
2384
|
+
outKey = injected.is_string() ? injected.as_string() : stringify(injected);
|
|
2385
|
+
} else {
|
|
2386
|
+
Value kv = getpath_v(item, keypath, &inj);
|
|
2387
|
+
outKey = kv.is_string() ? kv.as_string() : strkey(kv);
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
Value tchild = clone(child);
|
|
2391
|
+
tval->set(outKey, tchild);
|
|
2392
|
+
Value anno = getprop(item, Value(S_BANNO()));
|
|
2393
|
+
if (anno.is_undef()) {
|
|
2394
|
+
delprop(tchild, Value(S_BANNO()));
|
|
2395
|
+
} else {
|
|
2396
|
+
setprop(tchild, Value(S_BANNO()), anno);
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
Value rval(std::shared_ptr<Map>(new Map()));
|
|
2401
|
+
|
|
2402
|
+
if (!tval->empty()) {
|
|
2403
|
+
auto tsrc = std::shared_ptr<Map>(new Map());
|
|
2404
|
+
for (size_t i = 0; i < srcList.size(); i++) {
|
|
2405
|
+
const Value& item = srcList[i];
|
|
2406
|
+
std::string kn;
|
|
2407
|
+
if (keypath.is_undef()) {
|
|
2408
|
+
kn = std::to_string(i);
|
|
2409
|
+
} else if (keypath.is_string() && !keypath.as_string().empty() &&
|
|
2410
|
+
keypath.as_string()[0] == '`') {
|
|
2411
|
+
auto mergeList = std::make_shared<List>();
|
|
2412
|
+
mergeList->push_back(Value(std::shared_ptr<Map>(new Map())));
|
|
2413
|
+
mergeList->push_back(store);
|
|
2414
|
+
auto topMap = std::shared_ptr<Map>(new Map());
|
|
2415
|
+
topMap->set(S_DTOP(), item);
|
|
2416
|
+
mergeList->push_back(Value(topMap));
|
|
2417
|
+
Value merged = merge_v(Value(mergeList), 1);
|
|
2418
|
+
Value injected = inject(keypath, merged);
|
|
2419
|
+
kn = injected.is_string() ? injected.as_string() : stringify(injected);
|
|
2420
|
+
} else {
|
|
2421
|
+
Value kv = getpath_v(item, keypath, &inj);
|
|
2422
|
+
kn = kv.is_string() ? kv.as_string() : strkey(kv);
|
|
2423
|
+
}
|
|
2424
|
+
tsrc->set(kn, item);
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
std::vector<std::string> tpath(inj.path.begin(), inj.path.end() - 1);
|
|
2428
|
+
std::string ckey = inj.path.size() >= 2 ? inj.path[inj.path.size() - 2] : "";
|
|
2429
|
+
|
|
2430
|
+
std::vector<std::string> dpath;
|
|
2431
|
+
dpath.push_back(S_DTOP());
|
|
2432
|
+
if (!srcpath.empty()) {
|
|
2433
|
+
size_t pos = 0;
|
|
2434
|
+
while (pos <= srcpath.size()) {
|
|
2435
|
+
size_t dot = srcpath.find('.', pos);
|
|
2436
|
+
if (dot == std::string::npos) {
|
|
2437
|
+
dpath.push_back(srcpath.substr(pos));
|
|
2438
|
+
break;
|
|
2439
|
+
}
|
|
2440
|
+
dpath.push_back(srcpath.substr(pos, dot - pos));
|
|
2441
|
+
pos = dot + 1;
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
dpath.push_back("$:" + ckey);
|
|
2445
|
+
|
|
2446
|
+
auto tcur = std::shared_ptr<Map>(new Map());
|
|
2447
|
+
tcur->set(ckey, Value(tsrc));
|
|
2448
|
+
Value tcur_out(tcur);
|
|
2449
|
+
if (tpath.size() > 1) {
|
|
2450
|
+
std::string pkey = inj.path.size() >= 3 ? inj.path[inj.path.size() - 3] : S_DTOP();
|
|
2451
|
+
auto wrap = std::shared_ptr<Map>(new Map());
|
|
2452
|
+
wrap->set(pkey, tcur_out);
|
|
2453
|
+
tcur_out = Value(wrap);
|
|
2454
|
+
dpath.push_back("$:" + pkey);
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
auto single_keys = std::make_shared<std::vector<std::string>>();
|
|
2458
|
+
single_keys->push_back(ckey);
|
|
2459
|
+
auto tinj_owner = inj.child(0, single_keys);
|
|
2460
|
+
Injection* tinj = tinj_owner.get();
|
|
2461
|
+
tinj->path = tpath;
|
|
2462
|
+
tinj->nodes = std::make_shared<std::vector<Value>>(inj.nodes->begin(), inj.nodes->end() - 1);
|
|
2463
|
+
tinj->parent = tinj->nodes->empty() ? Value::undef() : tinj->nodes->back();
|
|
2464
|
+
tinj->val = Value(tval);
|
|
2465
|
+
tinj->dpath = dpath;
|
|
2466
|
+
tinj->dparent = tcur_out;
|
|
2467
|
+
|
|
2468
|
+
inject(Value(tval), store, tinj);
|
|
2469
|
+
if (tinj->val.is_map())
|
|
2470
|
+
rval = tinj->val;
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
setprop(target, tkey, rval);
|
|
2474
|
+
return Value::undef();
|
|
2475
|
+
}
|
|
2476
|
+
|
|
2477
|
+
inline Value REF_FN(Injection& inj, const Value& val, const std::string& ref, const Value& store) {
|
|
2478
|
+
if (inj.mode != M_VAL)
|
|
2479
|
+
return Value::undef();
|
|
2480
|
+
Value refpath = lookup_v(inj.parent, Value(int64_t(1)));
|
|
2481
|
+
inj.keyI = static_cast<int>(inj.keys ? inj.keys->size() : 0);
|
|
2482
|
+
|
|
2483
|
+
Value spec_holder = getprop(store, Value(S_DSPEC()));
|
|
2484
|
+
Value spec = spec_holder;
|
|
2485
|
+
if (spec_holder.is_injector()) {
|
|
2486
|
+
Injection synth(Value::undef(), Value::undef());
|
|
2487
|
+
spec = spec_holder.as_injector()(synth, Value::undef(), "$SPEC", store);
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
std::vector<std::string> dpath_slice(inj.path.begin() + 1, inj.path.end());
|
|
2491
|
+
Injection refInj(Value::undef(), Value::undef());
|
|
2492
|
+
refInj.dpath = dpath_slice;
|
|
2493
|
+
auto fp = std::make_shared<List>();
|
|
2494
|
+
for (auto& p : dpath_slice)
|
|
2495
|
+
fp->push_back(Value(p));
|
|
2496
|
+
refInj.dparent = getpath_v(spec, Value(fp));
|
|
2497
|
+
refInj.handler = injecthandler;
|
|
2498
|
+
Value refResolved = getpath_v(spec, refpath, &refInj);
|
|
2499
|
+
|
|
2500
|
+
Value tref = clone(refResolved);
|
|
2501
|
+
bool hasSubRef = false;
|
|
2502
|
+
if (isnode(tref)) {
|
|
2503
|
+
walk_v(
|
|
2504
|
+
tref,
|
|
2505
|
+
[&](const Value&, const Value& v, const Value&, const std::vector<std::string>&) -> Value {
|
|
2506
|
+
if (v.is_string() && v.as_string() == "`$REF`")
|
|
2507
|
+
hasSubRef = true;
|
|
2508
|
+
return v;
|
|
2509
|
+
});
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2512
|
+
std::vector<std::string> cpath_v;
|
|
2513
|
+
if (inj.path.size() >= 3) {
|
|
2514
|
+
cpath_v = std::vector<std::string>(inj.path.begin(), inj.path.begin() + (inj.path.size() - 3));
|
|
2515
|
+
}
|
|
2516
|
+
std::vector<std::string> tpath_v;
|
|
2517
|
+
if (!inj.path.empty()) {
|
|
2518
|
+
tpath_v = std::vector<std::string>(inj.path.begin(), inj.path.end() - 1);
|
|
2519
|
+
}
|
|
2520
|
+
auto cpath_list = std::make_shared<List>();
|
|
2521
|
+
for (auto& p : cpath_v)
|
|
2522
|
+
cpath_list->push_back(Value(p));
|
|
2523
|
+
auto tpath_list = std::make_shared<List>();
|
|
2524
|
+
for (auto& p : tpath_v)
|
|
2525
|
+
tpath_list->push_back(Value(p));
|
|
2526
|
+
|
|
2527
|
+
Value tval_at = getpath_v(store, Value(tpath_list));
|
|
2528
|
+
Value rval = Value::undef();
|
|
2529
|
+
|
|
2530
|
+
if (!hasSubRef || !tval_at.is_undef()) {
|
|
2531
|
+
std::string lastkey = tpath_v.empty() ? "" : tpath_v.back();
|
|
2532
|
+
auto single_keys = std::make_shared<std::vector<std::string>>();
|
|
2533
|
+
single_keys->push_back(lastkey);
|
|
2534
|
+
auto tinj_owner = inj.child(0, single_keys);
|
|
2535
|
+
Injection* tinj = tinj_owner.get();
|
|
2536
|
+
tinj->path = tpath_v;
|
|
2537
|
+
if (inj.nodes && inj.nodes->size() >= 1) {
|
|
2538
|
+
tinj->nodes = std::make_shared<std::vector<Value>>(inj.nodes->begin(), inj.nodes->end() - 1);
|
|
2539
|
+
}
|
|
2540
|
+
if (inj.nodes && inj.nodes->size() >= 2) {
|
|
2541
|
+
tinj->parent = (*inj.nodes)[inj.nodes->size() - 2];
|
|
2542
|
+
}
|
|
2543
|
+
tinj->val = tref;
|
|
2544
|
+
tinj->dpath = cpath_v;
|
|
2545
|
+
tinj->dparent = getpath_v(store, Value(cpath_list));
|
|
2546
|
+
|
|
2547
|
+
inject(tref, store, tinj);
|
|
2548
|
+
rval = tinj->val;
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
Value grandparent = inj.setval(rval, 2);
|
|
2552
|
+
if (grandparent.is_list() && inj.prior) {
|
|
2553
|
+
inj.prior->keyI--;
|
|
2554
|
+
}
|
|
2555
|
+
return val;
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
} // namespace transforms
|
|
2559
|
+
|
|
2560
|
+
// ===========================================================================
|
|
2561
|
+
// transform()
|
|
2562
|
+
// ===========================================================================
|
|
2563
|
+
|
|
2564
|
+
inline Value transform(const Value& data, const Value& spec, const Value& options) {
|
|
2565
|
+
Value origspec = spec;
|
|
2566
|
+
Value workspec = clone(origspec);
|
|
2567
|
+
|
|
2568
|
+
Value extra = options.is_map() ? getprop(options, Value("extra")) : Value::undef();
|
|
2569
|
+
Value modifyRaw = options.is_map() ? getprop(options, Value("modify")) : Value::undef();
|
|
2570
|
+
Value handlerRaw = options.is_map() ? getprop(options, Value("handler")) : Value::undef();
|
|
2571
|
+
Value metaRaw = options.is_map() ? getprop(options, Value("meta")) : Value::undef();
|
|
2572
|
+
Value errsRaw = options.is_map() ? getprop(options, Value("errs")) : Value::undef();
|
|
2573
|
+
|
|
2574
|
+
bool collect = errsRaw.is_list();
|
|
2575
|
+
std::shared_ptr<std::vector<Value>> errs;
|
|
2576
|
+
if (collect) {
|
|
2577
|
+
errs = std::make_shared<std::vector<Value>>();
|
|
2578
|
+
for (const auto& e : *errsRaw.as_list())
|
|
2579
|
+
errs->push_back(e);
|
|
2580
|
+
} else {
|
|
2581
|
+
errs = std::make_shared<std::vector<Value>>();
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
// Split extra into commands ($-keyed) and data.
|
|
2585
|
+
auto extraTransforms = std::shared_ptr<Map>(new Map());
|
|
2586
|
+
auto extraData = std::shared_ptr<Map>(new Map());
|
|
2587
|
+
if (extra.is_map()) {
|
|
2588
|
+
for (const auto& [k, v] : *extra.as_map()) {
|
|
2589
|
+
if (!k.empty() && k[0] == '$')
|
|
2590
|
+
extraTransforms->set(k, v);
|
|
2591
|
+
else
|
|
2592
|
+
extraData->set(k, v);
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
auto dataMergeList = std::make_shared<List>();
|
|
2597
|
+
if (!extraData->empty())
|
|
2598
|
+
dataMergeList->push_back(Value(extraData));
|
|
2599
|
+
dataMergeList->push_back(clone(data));
|
|
2600
|
+
Value dataClone = merge_v(Value(dataMergeList));
|
|
2601
|
+
|
|
2602
|
+
auto baseStore = std::shared_ptr<Map>(new Map());
|
|
2603
|
+
baseStore->set(S_DTOP(), dataClone);
|
|
2604
|
+
// $SPEC as Injector that returns origspec.
|
|
2605
|
+
Injector spec_supplier = [origspec](Injection&, const Value&, const std::string&,
|
|
2606
|
+
const Value&) -> Value { return origspec; };
|
|
2607
|
+
baseStore->set(S_DSPEC(), Value(spec_supplier));
|
|
2608
|
+
// $BT, $DS, $WHEN as Injectors (called via _injecthandler when matched).
|
|
2609
|
+
baseStore->set("$BT", Value(Injector([](Injection&, const Value&, const std::string&,
|
|
2610
|
+
const Value&) -> Value { return Value("`"); })));
|
|
2611
|
+
baseStore->set("$DS", Value(Injector([](Injection&, const Value&, const std::string&,
|
|
2612
|
+
const Value&) -> Value { return Value("$"); })));
|
|
2613
|
+
baseStore->set("$WHEN", Value(Injector([](Injection&, const Value&, const std::string&,
|
|
2614
|
+
const Value&) -> Value {
|
|
2615
|
+
// ISO timestamp.
|
|
2616
|
+
auto t = std::time(nullptr);
|
|
2617
|
+
auto* tm = std::gmtime(&t);
|
|
2618
|
+
char buf[40];
|
|
2619
|
+
std::strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S.000Z", tm);
|
|
2620
|
+
return Value(std::string(buf));
|
|
2621
|
+
})));
|
|
2622
|
+
baseStore->set("$DELETE", Value(Injector(transforms::DELETE_FN)));
|
|
2623
|
+
baseStore->set("$COPY", Value(Injector(transforms::COPY_FN)));
|
|
2624
|
+
baseStore->set("$KEY", Value(Injector(transforms::KEY_FN)));
|
|
2625
|
+
baseStore->set("$ANNO", Value(Injector(transforms::ANNO_FN)));
|
|
2626
|
+
baseStore->set("$MERGE", Value(Injector(transforms::MERGE_FN)));
|
|
2627
|
+
baseStore->set("$EACH", Value(Injector(transforms::EACH_FN)));
|
|
2628
|
+
baseStore->set("$PACK", Value(Injector(transforms::PACK_FN)));
|
|
2629
|
+
baseStore->set("$REF", Value(Injector(transforms::REF_FN)));
|
|
2630
|
+
baseStore->set("$FORMAT", Value(Injector(transforms::FORMAT_FN)));
|
|
2631
|
+
baseStore->set("$APPLY", Value(Injector(transforms::APPLY_FN)));
|
|
2632
|
+
|
|
2633
|
+
auto storeMergeList = std::make_shared<List>();
|
|
2634
|
+
storeMergeList->push_back(Value(baseStore));
|
|
2635
|
+
if (!extraTransforms->empty()) {
|
|
2636
|
+
storeMergeList->push_back(Value(extraTransforms));
|
|
2637
|
+
}
|
|
2638
|
+
// $ERRS holder list.
|
|
2639
|
+
auto errsListPtr = std::make_shared<List>();
|
|
2640
|
+
// Note: errs is std::vector<Value>; convert below as needed.
|
|
2641
|
+
auto errsHolder = std::shared_ptr<Map>(new Map());
|
|
2642
|
+
errsHolder->set(S_DERRS(), Value(errsListPtr));
|
|
2643
|
+
storeMergeList->push_back(Value(errsHolder));
|
|
2644
|
+
Value store = merge_v(Value(storeMergeList), 1);
|
|
2645
|
+
|
|
2646
|
+
Injection injdef(workspec, Value::undef());
|
|
2647
|
+
injdef.prior = nullptr;
|
|
2648
|
+
if (modifyRaw.is_modify())
|
|
2649
|
+
injdef.modify = modifyRaw.as_modify();
|
|
2650
|
+
if (handlerRaw.is_injector())
|
|
2651
|
+
injdef.handler = handlerRaw.as_injector();
|
|
2652
|
+
if (metaRaw.is_map())
|
|
2653
|
+
injdef.meta = metaRaw.as_map();
|
|
2654
|
+
injdef.errs = errs;
|
|
2655
|
+
|
|
2656
|
+
Value out = inject(workspec, store, &injdef);
|
|
2657
|
+
|
|
2658
|
+
// Sync $ERRS list back to errs.
|
|
2659
|
+
for (const auto& e : *errsListPtr)
|
|
2660
|
+
errs->push_back(e);
|
|
2661
|
+
|
|
2662
|
+
if (!errs->empty() && !collect) {
|
|
2663
|
+
std::string msg;
|
|
2664
|
+
for (size_t i = 0; i < errs->size(); i++) {
|
|
2665
|
+
if (i > 0)
|
|
2666
|
+
msg += " | ";
|
|
2667
|
+
msg += stringify((*errs)[i]);
|
|
2668
|
+
}
|
|
2669
|
+
throw std::runtime_error(msg);
|
|
2670
|
+
}
|
|
2671
|
+
// Update options.errs if the caller passed a list (back-compat).
|
|
2672
|
+
if (collect && errsRaw.is_list()) {
|
|
2673
|
+
auto rawList = errsRaw.as_list();
|
|
2674
|
+
rawList->clear();
|
|
2675
|
+
for (const auto& e : *errs)
|
|
2676
|
+
rawList->push_back(e);
|
|
2677
|
+
}
|
|
2678
|
+
return out;
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2681
|
+
// ===========================================================================
|
|
2682
|
+
// Validate injectors
|
|
2683
|
+
// ===========================================================================
|
|
2684
|
+
|
|
2685
|
+
namespace validators {
|
|
2686
|
+
|
|
2687
|
+
inline Value STRING_FN(Injection& inj, const Value& val, const std::string& ref,
|
|
2688
|
+
const Value& store) {
|
|
2689
|
+
Value out = lookup_v(inj.dparent, Value(inj.key));
|
|
2690
|
+
int t = typify(out);
|
|
2691
|
+
if ((T_string & t) == 0) {
|
|
2692
|
+
inj.errs->push_back(Value(invalid_type_msg(inj.path, "string", t, out, "V1010")));
|
|
2693
|
+
return Value::undef();
|
|
2694
|
+
}
|
|
2695
|
+
if (out.as_string().empty()) {
|
|
2696
|
+
auto pl = std::make_shared<List>();
|
|
2697
|
+
for (auto& p : inj.path)
|
|
2698
|
+
pl->push_back(Value(p));
|
|
2699
|
+
inj.errs->push_back(Value("Empty string at " + pathify(Value(pl), 1, 0)));
|
|
2700
|
+
return Value::undef();
|
|
2701
|
+
}
|
|
2702
|
+
return out;
|
|
2703
|
+
}
|
|
2704
|
+
|
|
2705
|
+
inline Value TYPE_FN(Injection& inj, const Value& val, const std::string& ref, const Value& store) {
|
|
2706
|
+
std::string tname = ref.size() >= 2 ? ref.substr(1) : "";
|
|
2707
|
+
for (auto& c : tname)
|
|
2708
|
+
c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
|
2709
|
+
int idx = -1;
|
|
2710
|
+
for (int i = 0; i < 26; i++) {
|
|
2711
|
+
if (typename_table(i) == tname) {
|
|
2712
|
+
idx = i;
|
|
2713
|
+
break;
|
|
2714
|
+
}
|
|
2715
|
+
}
|
|
2716
|
+
if (idx < 0)
|
|
2717
|
+
return Value::undef();
|
|
2718
|
+
int typev = 1 << (31 - idx);
|
|
2719
|
+
Value out = lookup_v(inj.dparent, Value(inj.key));
|
|
2720
|
+
int t = typify(out);
|
|
2721
|
+
if ((t & typev) == 0) {
|
|
2722
|
+
inj.errs->push_back(Value(invalid_type_msg(inj.path, tname, t, out, "V1001")));
|
|
2723
|
+
return Value::undef();
|
|
2724
|
+
}
|
|
2725
|
+
return out;
|
|
2726
|
+
}
|
|
2727
|
+
|
|
2728
|
+
inline Value ANY_FN(Injection& inj, const Value& val, const std::string& ref, const Value& store) {
|
|
2729
|
+
return lookup_v(inj.dparent, Value(inj.key));
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2732
|
+
inline Value CHILD_FN(Injection& inj, const Value& val, const std::string& ref,
|
|
2733
|
+
const Value& store) {
|
|
2734
|
+
if (inj.mode == M_KEYPRE) {
|
|
2735
|
+
Value childtm = getprop(inj.parent, Value(inj.key));
|
|
2736
|
+
Value pkey = inj.path.size() >= 2 ? Value(inj.path[inj.path.size() - 2]) : Value::undef();
|
|
2737
|
+
Value tval = getprop(inj.dparent, pkey);
|
|
2738
|
+
|
|
2739
|
+
if (tval.is_undef() || tval.is_null()) {
|
|
2740
|
+
tval = Value(std::shared_ptr<Map>(new Map()));
|
|
2741
|
+
} else if (!ismap(tval)) {
|
|
2742
|
+
auto pl = std::make_shared<List>();
|
|
2743
|
+
for (size_t i = 0; i + 1 < inj.path.size(); i++)
|
|
2744
|
+
pl->push_back(Value(inj.path[i]));
|
|
2745
|
+
inj.errs->push_back(
|
|
2746
|
+
Value(invalid_type_msg(Value(pl), "object", typify(tval), tval, "V0220")));
|
|
2747
|
+
return Value::undef();
|
|
2748
|
+
}
|
|
2749
|
+
auto ckeys = keysof(tval);
|
|
2750
|
+
for (const auto& ck : ckeys) {
|
|
2751
|
+
setprop(inj.parent, Value(ck), clone(childtm));
|
|
2752
|
+
if (inj.keys)
|
|
2753
|
+
inj.keys->push_back(ck);
|
|
2754
|
+
}
|
|
2755
|
+
inj.setval(Value::undef());
|
|
2756
|
+
return Value::undef();
|
|
2757
|
+
}
|
|
2758
|
+
if (inj.mode == M_VAL) {
|
|
2759
|
+
if (!inj.parent.is_list()) {
|
|
2760
|
+
inj.errs->push_back(Value("Invalid $CHILD as value"));
|
|
2761
|
+
return Value::undef();
|
|
2762
|
+
}
|
|
2763
|
+
Value childtm = lookup_v(inj.parent, Value(int64_t(1)));
|
|
2764
|
+
if (inj.dparent.is_undef() || inj.dparent.is_null()) {
|
|
2765
|
+
inj.parent.as_list()->clear();
|
|
2766
|
+
return Value::undef();
|
|
2767
|
+
}
|
|
2768
|
+
if (!inj.dparent.is_list()) {
|
|
2769
|
+
auto pl = std::make_shared<List>();
|
|
2770
|
+
for (size_t i = 0; i + 1 < inj.path.size(); i++)
|
|
2771
|
+
pl->push_back(Value(inj.path[i]));
|
|
2772
|
+
inj.errs->push_back(
|
|
2773
|
+
Value(invalid_type_msg(Value(pl), "list", typify(inj.dparent), inj.dparent, "V0230")));
|
|
2774
|
+
inj.keyI = static_cast<int>(size(inj.parent));
|
|
2775
|
+
return inj.dparent;
|
|
2776
|
+
}
|
|
2777
|
+
auto dpl = inj.dparent.as_list();
|
|
2778
|
+
auto pl = inj.parent.as_list();
|
|
2779
|
+
for (size_t i = 0; i < dpl->size(); i++) {
|
|
2780
|
+
setprop(inj.parent, Value(static_cast<int64_t>(i)), clone(childtm));
|
|
2781
|
+
}
|
|
2782
|
+
while (pl->size() > dpl->size())
|
|
2783
|
+
pl->pop_back();
|
|
2784
|
+
inj.keyI = 0;
|
|
2785
|
+
return getprop(inj.dparent, Value(int64_t(0)));
|
|
2786
|
+
}
|
|
2787
|
+
return Value::undef();
|
|
2788
|
+
}
|
|
2789
|
+
|
|
2790
|
+
inline Value ONE_FN(Injection& inj, const Value& val, const std::string& ref, const Value& store) {
|
|
2791
|
+
if (inj.mode != M_VAL)
|
|
2792
|
+
return Value::undef();
|
|
2793
|
+
if (!inj.parent.is_list() || inj.keyI != 0) {
|
|
2794
|
+
auto pl = std::make_shared<List>();
|
|
2795
|
+
for (auto& p : inj.path)
|
|
2796
|
+
pl->push_back(Value(p));
|
|
2797
|
+
inj.errs->push_back(Value("The $ONE validator at field " + pathify(Value(pl), 1, 1) +
|
|
2798
|
+
" must be the first element of an array."));
|
|
2799
|
+
return Value::undef();
|
|
2800
|
+
}
|
|
2801
|
+
inj.keyI = static_cast<int>(inj.keys ? inj.keys->size() : 0);
|
|
2802
|
+
inj.setval(inj.dparent, 2);
|
|
2803
|
+
if (!inj.path.empty())
|
|
2804
|
+
inj.path.pop_back();
|
|
2805
|
+
inj.key = inj.path.empty() ? "" : inj.path.back();
|
|
2806
|
+
|
|
2807
|
+
std::vector<Value> tvals;
|
|
2808
|
+
if (inj.parent.is_list()) {
|
|
2809
|
+
auto pl = inj.parent.as_list();
|
|
2810
|
+
for (size_t i = 1; i < pl->size(); i++)
|
|
2811
|
+
tvals.push_back((*pl)[i]);
|
|
2812
|
+
}
|
|
2813
|
+
if (tvals.empty()) {
|
|
2814
|
+
auto pl = std::make_shared<List>();
|
|
2815
|
+
for (auto& p : inj.path)
|
|
2816
|
+
pl->push_back(Value(p));
|
|
2817
|
+
inj.errs->push_back(Value("The $ONE validator at field " + pathify(Value(pl), 1, 1) +
|
|
2818
|
+
" must have at least one argument."));
|
|
2819
|
+
return Value::undef();
|
|
2820
|
+
}
|
|
2821
|
+
for (const auto& tval : tvals) {
|
|
2822
|
+
auto terrs = std::make_shared<std::vector<Value>>();
|
|
2823
|
+
auto vstore = std::shared_ptr<Map>(new Map());
|
|
2824
|
+
if (store.is_map()) {
|
|
2825
|
+
for (const auto& [k, v] : *store.as_map())
|
|
2826
|
+
vstore->set(k, v);
|
|
2827
|
+
}
|
|
2828
|
+
vstore->set(S_DTOP(), inj.dparent);
|
|
2829
|
+
auto opts = std::shared_ptr<Map>(new Map());
|
|
2830
|
+
auto terrs_list = std::make_shared<List>();
|
|
2831
|
+
opts->set("extra", Value(vstore));
|
|
2832
|
+
opts->set("errs", Value(terrs_list));
|
|
2833
|
+
if (inj.meta)
|
|
2834
|
+
opts->set("meta", Value(inj.meta));
|
|
2835
|
+
Value vcurrent;
|
|
2836
|
+
try {
|
|
2837
|
+
vcurrent = validate(inj.dparent, tval, Value(opts));
|
|
2838
|
+
} catch (const std::exception& e) {
|
|
2839
|
+
terrs_list->push_back(Value(std::string(e.what())));
|
|
2840
|
+
vcurrent = inj.dparent;
|
|
2841
|
+
}
|
|
2842
|
+
inj.setval(vcurrent, -2);
|
|
2843
|
+
if (terrs_list->empty())
|
|
2844
|
+
return Value::undef();
|
|
2845
|
+
}
|
|
2846
|
+
// No match.
|
|
2847
|
+
std::string valdesc;
|
|
2848
|
+
for (size_t i = 0; i < tvals.size(); i++) {
|
|
2849
|
+
if (i > 0)
|
|
2850
|
+
valdesc += ", ";
|
|
2851
|
+
if (tvals[i].is_string()) {
|
|
2852
|
+
std::smatch m;
|
|
2853
|
+
const std::string& s = tvals[i].as_string();
|
|
2854
|
+
if (std::regex_match(s, m, R_TRANSFORM_NAME())) {
|
|
2855
|
+
std::string lower = m[1].str();
|
|
2856
|
+
for (auto& c : lower)
|
|
2857
|
+
c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
|
2858
|
+
valdesc += lower;
|
|
2859
|
+
continue;
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
valdesc += stringify(tvals[i]);
|
|
2863
|
+
}
|
|
2864
|
+
inj.errs->push_back(
|
|
2865
|
+
Value(invalid_type_msg(inj.path, (tvals.size() > 1 ? "one of " : "") + valdesc,
|
|
2866
|
+
typify(inj.dparent), inj.dparent, "V0210")));
|
|
2867
|
+
return Value::undef();
|
|
2868
|
+
}
|
|
2869
|
+
|
|
2870
|
+
inline Value EXACT_FN(Injection& inj, const Value& val, const std::string& ref,
|
|
2871
|
+
const Value& store) {
|
|
2872
|
+
if (inj.mode == M_VAL) {
|
|
2873
|
+
if (!inj.parent.is_list() || inj.keyI != 0) {
|
|
2874
|
+
auto pl = std::make_shared<List>();
|
|
2875
|
+
for (auto& p : inj.path)
|
|
2876
|
+
pl->push_back(Value(p));
|
|
2877
|
+
inj.errs->push_back(Value("The $EXACT validator at field " + pathify(Value(pl), 1, 1) +
|
|
2878
|
+
" must be the first element of an array."));
|
|
2879
|
+
return Value::undef();
|
|
2880
|
+
}
|
|
2881
|
+
inj.keyI = static_cast<int>(inj.keys ? inj.keys->size() : 0);
|
|
2882
|
+
inj.setval(inj.dparent, 2);
|
|
2883
|
+
if (!inj.path.empty())
|
|
2884
|
+
inj.path.pop_back();
|
|
2885
|
+
inj.key = inj.path.empty() ? "" : inj.path.back();
|
|
2886
|
+
|
|
2887
|
+
std::vector<Value> tvals;
|
|
2888
|
+
if (inj.parent.is_list()) {
|
|
2889
|
+
auto pl = inj.parent.as_list();
|
|
2890
|
+
for (size_t i = 1; i < pl->size(); i++)
|
|
2891
|
+
tvals.push_back((*pl)[i]);
|
|
2892
|
+
}
|
|
2893
|
+
if (tvals.empty()) {
|
|
2894
|
+
auto pl = std::make_shared<List>();
|
|
2895
|
+
for (auto& p : inj.path)
|
|
2896
|
+
pl->push_back(Value(p));
|
|
2897
|
+
inj.errs->push_back(Value("The $EXACT validator at field " + pathify(Value(pl), 1, 1) +
|
|
2898
|
+
" must have at least one argument."));
|
|
2899
|
+
return Value::undef();
|
|
2900
|
+
}
|
|
2901
|
+
std::string currentstr;
|
|
2902
|
+
bool currentstr_set = false;
|
|
2903
|
+
for (const auto& tval : tvals) {
|
|
2904
|
+
bool exactmatch = (tval == inj.dparent);
|
|
2905
|
+
if (!exactmatch && isnode(tval)) {
|
|
2906
|
+
if (!currentstr_set) {
|
|
2907
|
+
currentstr = stringify(inj.dparent);
|
|
2908
|
+
currentstr_set = true;
|
|
2909
|
+
}
|
|
2910
|
+
std::string ts = stringify(tval);
|
|
2911
|
+
exactmatch = (ts == currentstr);
|
|
2912
|
+
}
|
|
2913
|
+
if (exactmatch)
|
|
2914
|
+
return Value::undef();
|
|
2915
|
+
}
|
|
2916
|
+
std::string valdesc;
|
|
2917
|
+
for (size_t i = 0; i < tvals.size(); i++) {
|
|
2918
|
+
if (i > 0)
|
|
2919
|
+
valdesc += ", ";
|
|
2920
|
+
if (tvals[i].is_string()) {
|
|
2921
|
+
std::smatch m;
|
|
2922
|
+
const std::string& s = tvals[i].as_string();
|
|
2923
|
+
if (std::regex_match(s, m, R_TRANSFORM_NAME())) {
|
|
2924
|
+
std::string lower = m[1].str();
|
|
2925
|
+
for (auto& c : lower)
|
|
2926
|
+
c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
|
2927
|
+
valdesc += lower;
|
|
2928
|
+
continue;
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
valdesc += stringify(tvals[i]);
|
|
2932
|
+
}
|
|
2933
|
+
inj.errs->push_back(Value(invalid_type_msg(inj.path,
|
|
2934
|
+
std::string(inj.path.size() > 1 ? "" : "value ") +
|
|
2935
|
+
"exactly equal to " +
|
|
2936
|
+
(tvals.size() == 1 ? "" : "one of ") + valdesc,
|
|
2937
|
+
typify(inj.dparent), inj.dparent, "V0110")));
|
|
2938
|
+
return Value::undef();
|
|
2939
|
+
} else {
|
|
2940
|
+
delprop(inj.parent, Value(inj.key));
|
|
2941
|
+
return Value::undef();
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
|
|
2945
|
+
} // namespace validators
|
|
2946
|
+
|
|
2947
|
+
// ===========================================================================
|
|
2948
|
+
// _validation Modify
|
|
2949
|
+
// ===========================================================================
|
|
2950
|
+
|
|
2951
|
+
inline void _validation(const Value& pval, const Value& key, const Value& parent, Injection& inj,
|
|
2952
|
+
const Value& store) {
|
|
2953
|
+
if (is_skip(pval))
|
|
2954
|
+
return;
|
|
2955
|
+
bool exact = false;
|
|
2956
|
+
if (inj.meta) {
|
|
2957
|
+
Value* e = inj.meta->find(S_BEXACT());
|
|
2958
|
+
if (e && e->is_bool())
|
|
2959
|
+
exact = e->as_bool();
|
|
2960
|
+
}
|
|
2961
|
+
Value cval = getprop(inj.dparent, key);
|
|
2962
|
+
if (!exact && (cval.is_undef() || cval.is_null()))
|
|
2963
|
+
return;
|
|
2964
|
+
|
|
2965
|
+
int ptype = typify(pval);
|
|
2966
|
+
if ((T_string & ptype) && pval.is_string() && pval.as_string().find('$') != std::string::npos) {
|
|
2967
|
+
return;
|
|
2968
|
+
}
|
|
2969
|
+
int ctype = typify(cval);
|
|
2970
|
+
if (ptype != ctype && !pval.is_undef()) {
|
|
2971
|
+
inj.errs->push_back(
|
|
2972
|
+
Value(invalid_type_msg(inj.path, typename_str(ptype), ctype, cval, "V0010")));
|
|
2973
|
+
return;
|
|
2974
|
+
}
|
|
2975
|
+
|
|
2976
|
+
if (ismap(cval)) {
|
|
2977
|
+
if (!ismap(pval)) {
|
|
2978
|
+
inj.errs->push_back(
|
|
2979
|
+
Value(invalid_type_msg(inj.path, typename_str(ptype), ctype, cval, "V0020")));
|
|
2980
|
+
return;
|
|
2981
|
+
}
|
|
2982
|
+
auto ckeys = keysof(cval);
|
|
2983
|
+
auto pkeys = keysof(pval);
|
|
2984
|
+
Value open_v = getprop(pval, Value(S_BOPEN()));
|
|
2985
|
+
bool is_open = open_v.is_bool() && open_v.as_bool();
|
|
2986
|
+
if (!pkeys.empty() && !is_open) {
|
|
2987
|
+
std::vector<std::string> badkeys;
|
|
2988
|
+
for (auto& ck : ckeys) {
|
|
2989
|
+
// Canonical uses `NONE === _lookup(pval, ckey)`: the shape's literal
|
|
2990
|
+
// presence, so a key whose validator stored null still counts as
|
|
2991
|
+
// declared (Group A haskey would miss a null-valued slot).
|
|
2992
|
+
if (lookup_v(pval, Value(ck)).is_undef())
|
|
2993
|
+
badkeys.push_back(ck);
|
|
2994
|
+
}
|
|
2995
|
+
if (!badkeys.empty()) {
|
|
2996
|
+
auto pl = std::make_shared<List>();
|
|
2997
|
+
for (auto& p : inj.path)
|
|
2998
|
+
pl->push_back(Value(p));
|
|
2999
|
+
std::string joined;
|
|
3000
|
+
for (size_t i = 0; i < badkeys.size(); i++) {
|
|
3001
|
+
if (i > 0)
|
|
3002
|
+
joined += ", ";
|
|
3003
|
+
joined += badkeys[i];
|
|
3004
|
+
}
|
|
3005
|
+
inj.errs->push_back(
|
|
3006
|
+
Value("Unexpected keys at field " + pathify(Value(pl), 1, 0) + ": " + joined));
|
|
3007
|
+
}
|
|
3008
|
+
} else {
|
|
3009
|
+
auto args_l = std::make_shared<List>();
|
|
3010
|
+
args_l->push_back(pval);
|
|
3011
|
+
args_l->push_back(cval);
|
|
3012
|
+
merge_v(Value(args_l));
|
|
3013
|
+
if (isnode(pval))
|
|
3014
|
+
delprop(pval, Value(S_BOPEN()));
|
|
3015
|
+
}
|
|
3016
|
+
} else if (islist(cval)) {
|
|
3017
|
+
if (!islist(pval)) {
|
|
3018
|
+
inj.errs->push_back(
|
|
3019
|
+
Value(invalid_type_msg(inj.path, typename_str(ptype), ctype, cval, "V0030")));
|
|
3020
|
+
}
|
|
3021
|
+
} else if (exact) {
|
|
3022
|
+
if (cval != pval) {
|
|
3023
|
+
auto pl = std::make_shared<List>();
|
|
3024
|
+
for (auto& p : inj.path)
|
|
3025
|
+
pl->push_back(Value(p));
|
|
3026
|
+
std::string pathmsg =
|
|
3027
|
+
inj.path.size() > 1 ? "at field " + pathify(Value(pl), 1, 0) + ": " : "";
|
|
3028
|
+
inj.errs->push_back(
|
|
3029
|
+
Value("Value " + pathmsg + js_string(cval) + " should equal " + js_string(pval) + "."));
|
|
3030
|
+
}
|
|
3031
|
+
} else {
|
|
3032
|
+
setprop(parent, key, cval);
|
|
3033
|
+
}
|
|
3034
|
+
}
|
|
3035
|
+
|
|
3036
|
+
inline Value _validatehandler(Injection& inj, const Value& val, const std::string& ref,
|
|
3037
|
+
const Value& store) {
|
|
3038
|
+
if (!ref.empty()) {
|
|
3039
|
+
std::smatch m;
|
|
3040
|
+
if (std::regex_match(ref, m, R_META_PATH())) {
|
|
3041
|
+
std::string op = m[2].str();
|
|
3042
|
+
if (op == "=") {
|
|
3043
|
+
auto wrap = std::make_shared<List>();
|
|
3044
|
+
wrap->push_back(Value(S_BEXACT()));
|
|
3045
|
+
wrap->push_back(val);
|
|
3046
|
+
inj.setval(Value(wrap));
|
|
3047
|
+
} else {
|
|
3048
|
+
inj.setval(val);
|
|
3049
|
+
}
|
|
3050
|
+
inj.keyI = -1;
|
|
3051
|
+
return SKIP();
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
return injecthandler(inj, val, ref, store);
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
// ===========================================================================
|
|
3058
|
+
// validate()
|
|
3059
|
+
// ===========================================================================
|
|
3060
|
+
|
|
3061
|
+
inline Value validate(const Value& data, const Value& spec, const Value& options) {
|
|
3062
|
+
Value extraRaw = options.is_map() ? getprop(options, Value("extra")) : Value::undef();
|
|
3063
|
+
Value errsRaw = options.is_map() ? getprop(options, Value("errs")) : Value::undef();
|
|
3064
|
+
Value metaRaw = options.is_map() ? getprop(options, Value("meta")) : Value::undef();
|
|
3065
|
+
|
|
3066
|
+
bool collect = errsRaw.is_list();
|
|
3067
|
+
std::shared_ptr<std::vector<Value>> errs = std::make_shared<std::vector<Value>>();
|
|
3068
|
+
if (collect) {
|
|
3069
|
+
for (const auto& e : *errsRaw.as_list())
|
|
3070
|
+
errs->push_back(e);
|
|
3071
|
+
}
|
|
3072
|
+
|
|
3073
|
+
auto baseStore = std::shared_ptr<Map>(new Map());
|
|
3074
|
+
baseStore->set("$DELETE", Value(nullptr));
|
|
3075
|
+
baseStore->set("$COPY", Value(nullptr));
|
|
3076
|
+
baseStore->set("$KEY", Value(nullptr));
|
|
3077
|
+
baseStore->set("$META", Value(nullptr));
|
|
3078
|
+
baseStore->set("$MERGE", Value(nullptr));
|
|
3079
|
+
baseStore->set("$EACH", Value(nullptr));
|
|
3080
|
+
baseStore->set("$PACK", Value(nullptr));
|
|
3081
|
+
|
|
3082
|
+
baseStore->set("$STRING", Value(Injector(validators::STRING_FN)));
|
|
3083
|
+
baseStore->set("$NUMBER", Value(Injector(validators::TYPE_FN)));
|
|
3084
|
+
baseStore->set("$INTEGER", Value(Injector(validators::TYPE_FN)));
|
|
3085
|
+
baseStore->set("$DECIMAL", Value(Injector(validators::TYPE_FN)));
|
|
3086
|
+
baseStore->set("$BOOLEAN", Value(Injector(validators::TYPE_FN)));
|
|
3087
|
+
baseStore->set("$NULL", Value(Injector(validators::TYPE_FN)));
|
|
3088
|
+
baseStore->set("$NIL", Value(Injector(validators::TYPE_FN)));
|
|
3089
|
+
baseStore->set("$MAP", Value(Injector(validators::TYPE_FN)));
|
|
3090
|
+
baseStore->set("$LIST", Value(Injector(validators::TYPE_FN)));
|
|
3091
|
+
baseStore->set("$FUNCTION", Value(Injector(validators::TYPE_FN)));
|
|
3092
|
+
baseStore->set("$INSTANCE", Value(Injector(validators::TYPE_FN)));
|
|
3093
|
+
baseStore->set("$ANY", Value(Injector(validators::ANY_FN)));
|
|
3094
|
+
baseStore->set("$CHILD", Value(Injector(validators::CHILD_FN)));
|
|
3095
|
+
baseStore->set("$ONE", Value(Injector(validators::ONE_FN)));
|
|
3096
|
+
baseStore->set("$EXACT", Value(Injector(validators::EXACT_FN)));
|
|
3097
|
+
|
|
3098
|
+
auto mergeList = std::make_shared<List>();
|
|
3099
|
+
mergeList->push_back(Value(baseStore));
|
|
3100
|
+
if (extraRaw.is_map())
|
|
3101
|
+
mergeList->push_back(extraRaw);
|
|
3102
|
+
auto errsListPtr = std::make_shared<List>();
|
|
3103
|
+
auto errsHolder = std::shared_ptr<Map>(new Map());
|
|
3104
|
+
errsHolder->set(S_DERRS(), Value(errsListPtr));
|
|
3105
|
+
mergeList->push_back(Value(errsHolder));
|
|
3106
|
+
Value store = merge_v(Value(mergeList), 1);
|
|
3107
|
+
|
|
3108
|
+
std::shared_ptr<Map> meta;
|
|
3109
|
+
if (metaRaw.is_map()) {
|
|
3110
|
+
meta = std::shared_ptr<Map>(new Map());
|
|
3111
|
+
for (const auto& [k, v] : *metaRaw.as_map())
|
|
3112
|
+
meta->set(k, v);
|
|
3113
|
+
} else {
|
|
3114
|
+
meta = std::shared_ptr<Map>(new Map());
|
|
3115
|
+
}
|
|
3116
|
+
if (!meta->find(S_BEXACT()))
|
|
3117
|
+
meta->set(S_BEXACT(), Value(false));
|
|
3118
|
+
|
|
3119
|
+
auto opts = std::shared_ptr<Map>(new Map());
|
|
3120
|
+
opts->set("meta", Value(meta));
|
|
3121
|
+
opts->set("extra", store);
|
|
3122
|
+
opts->set("modify", Value(Modify(_validation)));
|
|
3123
|
+
opts->set("handler", Value(Injector(_validatehandler)));
|
|
3124
|
+
auto opt_errs_list = std::make_shared<List>();
|
|
3125
|
+
for (const auto& e : *errs)
|
|
3126
|
+
opt_errs_list->push_back(e);
|
|
3127
|
+
opts->set("errs", Value(opt_errs_list));
|
|
3128
|
+
|
|
3129
|
+
Value out = transform(data, spec, Value(opts));
|
|
3130
|
+
|
|
3131
|
+
// Sync opt_errs_list back to errs.
|
|
3132
|
+
errs->clear();
|
|
3133
|
+
for (const auto& e : *opt_errs_list)
|
|
3134
|
+
errs->push_back(e);
|
|
3135
|
+
|
|
3136
|
+
if (!errs->empty() && !collect) {
|
|
3137
|
+
std::string msg;
|
|
3138
|
+
for (size_t i = 0; i < errs->size(); i++) {
|
|
3139
|
+
if (i > 0)
|
|
3140
|
+
msg += " | ";
|
|
3141
|
+
msg += stringify((*errs)[i]);
|
|
3142
|
+
}
|
|
3143
|
+
throw std::runtime_error(msg);
|
|
3144
|
+
}
|
|
3145
|
+
if (collect && errsRaw.is_list()) {
|
|
3146
|
+
auto rl = errsRaw.as_list();
|
|
3147
|
+
rl->clear();
|
|
3148
|
+
for (const auto& e : *errs)
|
|
3149
|
+
rl->push_back(e);
|
|
3150
|
+
}
|
|
3151
|
+
return out;
|
|
3152
|
+
}
|
|
3153
|
+
|
|
3154
|
+
// ===========================================================================
|
|
3155
|
+
// Select injectors + select()
|
|
3156
|
+
// ===========================================================================
|
|
3157
|
+
|
|
3158
|
+
namespace selectors {
|
|
3159
|
+
|
|
3160
|
+
inline std::shared_ptr<Map> recOpts(const Value& store, const Value& point,
|
|
3161
|
+
std::shared_ptr<Map> meta, std::shared_ptr<List> errs_list) {
|
|
3162
|
+
auto vstore = std::shared_ptr<Map>(new Map());
|
|
3163
|
+
if (store.is_map()) {
|
|
3164
|
+
for (const auto& [k, v] : *store.as_map())
|
|
3165
|
+
vstore->set(k, v);
|
|
3166
|
+
}
|
|
3167
|
+
vstore->set(S_DTOP(), point);
|
|
3168
|
+
auto opts = std::shared_ptr<Map>(new Map());
|
|
3169
|
+
opts->set("errs", Value(errs_list));
|
|
3170
|
+
opts->set("meta", Value(meta));
|
|
3171
|
+
opts->set("extra", Value(vstore));
|
|
3172
|
+
return opts;
|
|
3173
|
+
}
|
|
3174
|
+
|
|
3175
|
+
inline Value AND_FN(Injection& inj, const Value& val, const std::string& ref, const Value& store) {
|
|
3176
|
+
if (inj.mode != M_KEYPRE)
|
|
3177
|
+
return Value::undef();
|
|
3178
|
+
Value terms = lookup_v(inj.parent, Value(inj.key));
|
|
3179
|
+
if (!terms.is_list())
|
|
3180
|
+
return Value::undef();
|
|
3181
|
+
|
|
3182
|
+
auto ppath = std::make_shared<List>();
|
|
3183
|
+
for (size_t i = 0; i + 1 < inj.path.size(); i++)
|
|
3184
|
+
ppath->push_back(Value(inj.path[i]));
|
|
3185
|
+
Value point = getpath_v(store, Value(ppath));
|
|
3186
|
+
|
|
3187
|
+
for (const auto& term : *terms.as_list()) {
|
|
3188
|
+
auto terrs = std::make_shared<List>();
|
|
3189
|
+
auto opts = recOpts(store, point, inj.meta, terrs);
|
|
3190
|
+
try {
|
|
3191
|
+
validate(point, term, Value(opts));
|
|
3192
|
+
} catch (const std::exception& e) {
|
|
3193
|
+
terrs->push_back(Value(std::string(e.what())));
|
|
3194
|
+
}
|
|
3195
|
+
if (!terrs->empty()) {
|
|
3196
|
+
inj.errs->push_back(Value("AND:" + pathify(Value(ppath)) + ": " + stringify(point) +
|
|
3197
|
+
" fail:" + stringify(terms)));
|
|
3198
|
+
}
|
|
3199
|
+
}
|
|
3200
|
+
Value gkey = inj.path.size() >= 2 ? Value(inj.path[inj.path.size() - 2]) : Value::undef();
|
|
3201
|
+
Value gp;
|
|
3202
|
+
if (inj.nodes && inj.nodes->size() >= 2)
|
|
3203
|
+
gp = (*inj.nodes)[inj.nodes->size() - 2];
|
|
3204
|
+
setprop(gp, gkey, point);
|
|
3205
|
+
return Value::undef();
|
|
3206
|
+
}
|
|
3207
|
+
|
|
3208
|
+
inline Value OR_FN(Injection& inj, const Value& val, const std::string& ref, const Value& store) {
|
|
3209
|
+
if (inj.mode != M_KEYPRE)
|
|
3210
|
+
return Value::undef();
|
|
3211
|
+
Value terms = lookup_v(inj.parent, Value(inj.key));
|
|
3212
|
+
if (!terms.is_list())
|
|
3213
|
+
return Value::undef();
|
|
3214
|
+
|
|
3215
|
+
auto ppath = std::make_shared<List>();
|
|
3216
|
+
for (size_t i = 0; i + 1 < inj.path.size(); i++)
|
|
3217
|
+
ppath->push_back(Value(inj.path[i]));
|
|
3218
|
+
Value point = getpath_v(store, Value(ppath));
|
|
3219
|
+
|
|
3220
|
+
for (const auto& term : *terms.as_list()) {
|
|
3221
|
+
auto terrs = std::make_shared<List>();
|
|
3222
|
+
auto opts = recOpts(store, point, inj.meta, terrs);
|
|
3223
|
+
try {
|
|
3224
|
+
validate(point, term, Value(opts));
|
|
3225
|
+
} catch (const std::exception& e) {
|
|
3226
|
+
terrs->push_back(Value(std::string(e.what())));
|
|
3227
|
+
}
|
|
3228
|
+
if (terrs->empty()) {
|
|
3229
|
+
Value gkey = inj.path.size() >= 2 ? Value(inj.path[inj.path.size() - 2]) : Value::undef();
|
|
3230
|
+
Value gp;
|
|
3231
|
+
if (inj.nodes && inj.nodes->size() >= 2)
|
|
3232
|
+
gp = (*inj.nodes)[inj.nodes->size() - 2];
|
|
3233
|
+
setprop(gp, gkey, point);
|
|
3234
|
+
return Value::undef();
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
inj.errs->push_back(
|
|
3238
|
+
Value("OR:" + pathify(Value(ppath)) + ": " + stringify(point) + " fail:" + stringify(terms)));
|
|
3239
|
+
return Value::undef();
|
|
3240
|
+
}
|
|
3241
|
+
|
|
3242
|
+
inline Value NOT_FN(Injection& inj, const Value& val, const std::string& ref, const Value& store) {
|
|
3243
|
+
if (inj.mode != M_KEYPRE)
|
|
3244
|
+
return Value::undef();
|
|
3245
|
+
Value term = lookup_v(inj.parent, Value(inj.key));
|
|
3246
|
+
auto ppath = std::make_shared<List>();
|
|
3247
|
+
for (size_t i = 0; i + 1 < inj.path.size(); i++)
|
|
3248
|
+
ppath->push_back(Value(inj.path[i]));
|
|
3249
|
+
Value point = getpath_v(store, Value(ppath));
|
|
3250
|
+
auto terrs = std::make_shared<List>();
|
|
3251
|
+
auto opts = recOpts(store, point, inj.meta, terrs);
|
|
3252
|
+
try {
|
|
3253
|
+
validate(point, term, Value(opts));
|
|
3254
|
+
} catch (const std::exception& e) {
|
|
3255
|
+
terrs->push_back(Value(std::string(e.what())));
|
|
3256
|
+
}
|
|
3257
|
+
if (terrs->empty()) {
|
|
3258
|
+
inj.errs->push_back(Value("NOT:" + pathify(Value(ppath)) + ": " + stringify(point) +
|
|
3259
|
+
" fail:" + stringify(term)));
|
|
3260
|
+
}
|
|
3261
|
+
Value gkey = inj.path.size() >= 2 ? Value(inj.path[inj.path.size() - 2]) : Value::undef();
|
|
3262
|
+
Value gp;
|
|
3263
|
+
if (inj.nodes && inj.nodes->size() >= 2)
|
|
3264
|
+
gp = (*inj.nodes)[inj.nodes->size() - 2];
|
|
3265
|
+
setprop(gp, gkey, point);
|
|
3266
|
+
return Value::undef();
|
|
3267
|
+
}
|
|
3268
|
+
|
|
3269
|
+
inline Value CMP_FN(Injection& inj, const Value& val, const std::string& ref, const Value& store) {
|
|
3270
|
+
if (inj.mode != M_KEYPRE)
|
|
3271
|
+
return Value::undef();
|
|
3272
|
+
Value term = lookup_v(inj.parent, Value(inj.key));
|
|
3273
|
+
Value gkey = inj.path.size() >= 2 ? Value(inj.path[inj.path.size() - 2]) : Value::undef();
|
|
3274
|
+
auto ppath = std::make_shared<List>();
|
|
3275
|
+
for (size_t i = 0; i + 1 < inj.path.size(); i++)
|
|
3276
|
+
ppath->push_back(Value(inj.path[i]));
|
|
3277
|
+
Value point = getpath_v(store, Value(ppath));
|
|
3278
|
+
bool pass = false;
|
|
3279
|
+
if (point.is_number() && term.is_number()) {
|
|
3280
|
+
double a = point.as_double();
|
|
3281
|
+
double b = term.as_double();
|
|
3282
|
+
if (ref == "$GT")
|
|
3283
|
+
pass = a > b;
|
|
3284
|
+
else if (ref == "$LT")
|
|
3285
|
+
pass = a < b;
|
|
3286
|
+
else if (ref == "$GTE")
|
|
3287
|
+
pass = a >= b;
|
|
3288
|
+
else if (ref == "$LTE")
|
|
3289
|
+
pass = a <= b;
|
|
3290
|
+
} else if (ref == "$LIKE" && term.is_string()) {
|
|
3291
|
+
try {
|
|
3292
|
+
std::regex pat(term.as_string());
|
|
3293
|
+
pass = std::regex_search(stringify(point), pat);
|
|
3294
|
+
} catch (...) {
|
|
3295
|
+
pass = false;
|
|
3296
|
+
}
|
|
3297
|
+
}
|
|
3298
|
+
if (pass) {
|
|
3299
|
+
Value gp;
|
|
3300
|
+
if (inj.nodes && inj.nodes->size() >= 2)
|
|
3301
|
+
gp = (*inj.nodes)[inj.nodes->size() - 2];
|
|
3302
|
+
setprop(gp, gkey, point);
|
|
3303
|
+
} else {
|
|
3304
|
+
inj.errs->push_back(Value("CMP: " + pathify(Value(ppath)) + ": " + stringify(point) +
|
|
3305
|
+
" fail:" + ref + " " + stringify(term)));
|
|
3306
|
+
}
|
|
3307
|
+
return Value::undef();
|
|
3308
|
+
}
|
|
3309
|
+
|
|
3310
|
+
} // namespace selectors
|
|
3311
|
+
|
|
3312
|
+
inline std::vector<Value> select(const Value& children, const Value& query) {
|
|
3313
|
+
if (!isnode(children))
|
|
3314
|
+
return {};
|
|
3315
|
+
|
|
3316
|
+
std::vector<Value> childList;
|
|
3317
|
+
if (ismap(children)) {
|
|
3318
|
+
for (const auto& [k, v] : *children.as_map()) {
|
|
3319
|
+
if (isnode(v)) {
|
|
3320
|
+
setprop(v, Value(S_DKEY()), Value(k));
|
|
3321
|
+
}
|
|
3322
|
+
childList.push_back(v);
|
|
3323
|
+
}
|
|
3324
|
+
} else {
|
|
3325
|
+
auto cl = children.as_list();
|
|
3326
|
+
for (size_t i = 0; i < cl->size(); i++) {
|
|
3327
|
+
const Value& node = (*cl)[i];
|
|
3328
|
+
if (isnode(node)) {
|
|
3329
|
+
setprop(node, Value(S_DKEY()), Value(static_cast<int64_t>(i)));
|
|
3330
|
+
}
|
|
3331
|
+
childList.push_back(node);
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3335
|
+
auto meta = std::shared_ptr<Map>(new Map());
|
|
3336
|
+
meta->set(S_BEXACT(), Value(true));
|
|
3337
|
+
|
|
3338
|
+
auto extra = std::shared_ptr<Map>(new Map());
|
|
3339
|
+
extra->set("$AND", Value(Injector(selectors::AND_FN)));
|
|
3340
|
+
extra->set("$OR", Value(Injector(selectors::OR_FN)));
|
|
3341
|
+
extra->set("$NOT", Value(Injector(selectors::NOT_FN)));
|
|
3342
|
+
extra->set("$GT", Value(Injector(selectors::CMP_FN)));
|
|
3343
|
+
extra->set("$LT", Value(Injector(selectors::CMP_FN)));
|
|
3344
|
+
extra->set("$GTE", Value(Injector(selectors::CMP_FN)));
|
|
3345
|
+
extra->set("$LTE", Value(Injector(selectors::CMP_FN)));
|
|
3346
|
+
extra->set("$LIKE", Value(Injector(selectors::CMP_FN)));
|
|
3347
|
+
|
|
3348
|
+
Value q = clone(query);
|
|
3349
|
+
walk_v(q,
|
|
3350
|
+
[](const Value&, const Value& v, const Value&, const std::vector<std::string>&) -> Value {
|
|
3351
|
+
if (ismap(v)) {
|
|
3352
|
+
Value cur = getprop(v, Value(S_BOPEN()));
|
|
3353
|
+
setprop(v, Value(S_BOPEN()), cur.is_undef() ? Value(true) : cur);
|
|
3354
|
+
}
|
|
3355
|
+
return v;
|
|
3356
|
+
});
|
|
3357
|
+
|
|
3358
|
+
std::vector<Value> results;
|
|
3359
|
+
for (const auto& child : childList) {
|
|
3360
|
+
auto errs_list = std::make_shared<List>();
|
|
3361
|
+
auto opts = std::shared_ptr<Map>(new Map());
|
|
3362
|
+
opts->set("errs", Value(errs_list));
|
|
3363
|
+
opts->set("meta", Value(meta));
|
|
3364
|
+
opts->set("extra", Value(extra));
|
|
3365
|
+
try {
|
|
3366
|
+
validate(child, clone(q), Value(opts));
|
|
3367
|
+
} catch (const std::exception& e) {
|
|
3368
|
+
errs_list->push_back(Value(std::string(e.what())));
|
|
3369
|
+
}
|
|
3370
|
+
if (errs_list->empty())
|
|
3371
|
+
results.push_back(child);
|
|
3372
|
+
}
|
|
3373
|
+
return results;
|
|
3374
|
+
}
|
|
3375
|
+
|
|
3376
|
+
} // namespace structlib
|
|
3377
|
+
} // namespace voxgig
|
|
3378
|
+
|
|
3379
|
+
#endif // VOXGIG_STRUCT_HPP
|