@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,2299 @@
|
|
|
1
|
+
-- Copyright (c) 2025-2026 Voxgig Ltd. MIT LICENSE.
|
|
2
|
+
|
|
3
|
+
{-# LANGUAGE LambdaCase #-}
|
|
4
|
+
|
|
5
|
+
-- |
|
|
6
|
+
-- Module : VoxgigStruct
|
|
7
|
+
-- Copyright : (c) 2025-2026 Voxgig Ltd.
|
|
8
|
+
-- License : MIT
|
|
9
|
+
-- Maintainer : richard.rodger\@voxgig.com
|
|
10
|
+
-- Stability : experimental
|
|
11
|
+
--
|
|
12
|
+
-- Utilities for walking, merging, transforming, injecting into and validating
|
|
13
|
+
-- JSON-like data structures — the Haskell port of the canonical
|
|
14
|
+
-- @voxgig\/struct@ library (TypeScript @typescript\/src\/StructUtility.ts@).
|
|
15
|
+
--
|
|
16
|
+
-- Values are modelled by the 'Value' type. Like the canonical TypeScript (and
|
|
17
|
+
-- the OCaml \/ Rust ports) this port keeps @undefined@ ('VNoval') and JSON
|
|
18
|
+
-- @null@ ('VNull') distinct, so it mirrors the canonical logic directly.
|
|
19
|
+
--
|
|
20
|
+
-- The canonical algorithm mutates nodes in place and relies on
|
|
21
|
+
-- reference-stable nodes (shared references observed by 'walk', 'merge' and
|
|
22
|
+
-- 'inject'). Haskell has no mutable native collection, so a node carries an
|
|
23
|
+
-- 'Data.IORef.IORef' to its contents — lists are @'IORef' ['Value']@, maps an
|
|
24
|
+
-- @'IORef'@ of ordered key\/value pairs, the analog of OCaml's @ref@ or Rust's
|
|
25
|
+
-- @Rc\<RefCell\>@. A consequence is that __the whole API runs in 'IO'__: every
|
|
26
|
+
-- reader and mutator returns @IO@. Build nodes with 'jm' \/ 'jt', or by running
|
|
27
|
+
-- the 'transform' \/ 'inject' engines.
|
|
28
|
+
--
|
|
29
|
+
-- There are zero third-party runtime dependencies; the regex helper is the
|
|
30
|
+
-- in-tree @Vregex@ engine (an RE2 subset).
|
|
31
|
+
--
|
|
32
|
+
-- == Example
|
|
33
|
+
--
|
|
34
|
+
-- @
|
|
35
|
+
-- import VoxgigStruct
|
|
36
|
+
--
|
|
37
|
+
-- demo :: IO ()
|
|
38
|
+
-- demo = do
|
|
39
|
+
-- a <- 'jm' ['VStr' \"a\", 'VNum' 1]; b <- 'jm' ['VStr' \"b\", 'VNum' 2]; xs <- 'jt' [a, b]
|
|
40
|
+
-- putStrLn =<< 'stringify' =<< 'merge' xs -- {a:1,b:2}
|
|
41
|
+
-- @
|
|
42
|
+
module VoxgigStruct where
|
|
43
|
+
|
|
44
|
+
import Control.Exception (Exception, throwIO)
|
|
45
|
+
import Control.Monad (filterM, foldM, forM_, when)
|
|
46
|
+
import Data.Bits (shiftL, (.&.), (.|.))
|
|
47
|
+
import Data.Char (toLower, toUpper)
|
|
48
|
+
import Data.IORef
|
|
49
|
+
import Data.List (findIndex, intercalate, isPrefixOf, sort)
|
|
50
|
+
import qualified Data.List as L
|
|
51
|
+
import Data.Maybe (fromMaybe)
|
|
52
|
+
import Numeric (showHex)
|
|
53
|
+
import System.IO.Unsafe (unsafePerformIO)
|
|
54
|
+
import Text.Printf (printf)
|
|
55
|
+
import Text.Read (readMaybe)
|
|
56
|
+
import qualified Vregex
|
|
57
|
+
|
|
58
|
+
import Prelude hiding (filter)
|
|
59
|
+
|
|
60
|
+
-- ---------------------------------------------------------------------------
|
|
61
|
+
-- Value model
|
|
62
|
+
-- ---------------------------------------------------------------------------
|
|
63
|
+
|
|
64
|
+
-- | The universal JSON-like value: scalars, mutable 'IORef'-backed nodes, functions and sentinels.
|
|
65
|
+
data Value
|
|
66
|
+
= VNoval -- ^ canonical @undefined@ — property absent
|
|
67
|
+
| VNull -- ^ JSON @null@
|
|
68
|
+
| VBool !Bool -- ^ boolean
|
|
69
|
+
| VNum !Double -- ^ number (integers are whole 'Double's)
|
|
70
|
+
| VStr !String -- ^ string
|
|
71
|
+
| VList !(IORef [Value]) -- ^ list \/ array node (mutable, reference-stable)
|
|
72
|
+
| VMap !(IORef [(String, Value)]) -- ^ map \/ object node (ordered, mutable, reference-stable)
|
|
73
|
+
| VFunc Injector -- ^ function (a custom injector)
|
|
74
|
+
| VSentinel !String -- ^ SKIP \/ DELETE marker, compared by tag
|
|
75
|
+
|
|
76
|
+
-- | A custom @$@-directive handler: injection state, value, key and parent to a result.
|
|
77
|
+
type Injector = Inj -> Value -> String -> Value -> IO Value
|
|
78
|
+
-- | A post-injection mutation hook (used by validation).
|
|
79
|
+
type ModifyFn = Value -> Value -> Value -> Inj -> IO ()
|
|
80
|
+
|
|
81
|
+
-- | Mutable injection state threaded through the inject\/transform\/validate engines.
|
|
82
|
+
data Inj = Inj
|
|
83
|
+
{ iMode :: IORef Int -- ^ current pass (key-pre \/ key-post \/ value)
|
|
84
|
+
, iFull :: IORef Bool -- ^ whether the string is a whole-value injection
|
|
85
|
+
, iKeyi :: IORef Int -- ^ index of the current key among its siblings
|
|
86
|
+
, iKeys :: IORef Value -- ^ the sibling keys being iterated
|
|
87
|
+
, iKey :: IORef Value -- ^ the current key
|
|
88
|
+
, iIval :: IORef Value -- ^ the current (injected) value
|
|
89
|
+
, iParent :: IORef Value -- ^ the parent node of the current value
|
|
90
|
+
, iPath :: IORef Value -- ^ path from the root to the current value
|
|
91
|
+
, iNodes :: IORef Value -- ^ ancestor nodes along the current path
|
|
92
|
+
, iHandler :: IORef Injector -- ^ the active @$@-directive handler
|
|
93
|
+
, iErrs :: IORef Value -- ^ accumulated validation errors
|
|
94
|
+
, iMeta :: IORef Value -- ^ caller metadata bag
|
|
95
|
+
, iDparent :: IORef Value -- ^ parent within the data store
|
|
96
|
+
, iDpath :: IORef Value -- ^ path within the data store
|
|
97
|
+
, iBase :: IORef Value -- ^ base name for @$@ lookups
|
|
98
|
+
, iModify :: IORef (Maybe ModifyFn) -- ^ post-injection mutation hook
|
|
99
|
+
, iPrior :: IORef (Maybe Inj) -- ^ the enclosing injection state, if any
|
|
100
|
+
, iExtra :: IORef Value -- ^ extra store merged into lookups
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
-- | The loose @Partial<Injection>@ record the public API accepts.
|
|
104
|
+
data InjDef = InjDef
|
|
105
|
+
{ dMeta :: Value -- ^ caller metadata bag
|
|
106
|
+
, dExtra :: Value -- ^ extra store merged into lookups
|
|
107
|
+
, dErrs :: Value -- ^ collector for validation errors
|
|
108
|
+
, dModify :: Maybe ModifyFn -- ^ post-injection mutation hook
|
|
109
|
+
, dHandler :: Maybe Injector -- ^ custom @$@-directive handler
|
|
110
|
+
, dBase :: Value -- ^ base name for @$@ lookups
|
|
111
|
+
, dDparent :: Value -- ^ parent within the data store
|
|
112
|
+
, dDpath :: Value -- ^ path within the data store
|
|
113
|
+
, dKey :: Value -- ^ the current key
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
-- | How callers pass injection state: 'INone', a caller 'InjDef', or a live 'Inj'.
|
|
117
|
+
data InjArg = IInj Inj | IDef InjDef | INone
|
|
118
|
+
|
|
119
|
+
-- | The exception thrown on an unrecoverable structure error.
|
|
120
|
+
newtype StructError = StructError String
|
|
121
|
+
instance Show StructError where show (StructError m) = m
|
|
122
|
+
instance Exception StructError
|
|
123
|
+
|
|
124
|
+
-- ---------------------------------------------------------------------------
|
|
125
|
+
-- Constants
|
|
126
|
+
-- ---------------------------------------------------------------------------
|
|
127
|
+
|
|
128
|
+
-- | Injection-mode bitmask flags: the key-prefix, key-postfix and value passes.
|
|
129
|
+
m_keypre, m_keypost, m_val :: Int
|
|
130
|
+
m_keypre = 1
|
|
131
|
+
m_keypost = 2
|
|
132
|
+
m_val = 4
|
|
133
|
+
|
|
134
|
+
-- | Dollar-directive name constants (@$KEY@, @$TOP@, @$ERRS@, @$SPEC@ ...) the engines recognise.
|
|
135
|
+
s_dkey, s_banno, s_dtop, s_derrs, s_dspec, s_bexact, s_bval, s_bkey, s_bopen :: String
|
|
136
|
+
s_dkey = "$KEY"
|
|
137
|
+
s_banno = "`$ANNO`"
|
|
138
|
+
s_dtop = "$TOP"
|
|
139
|
+
s_derrs = "$ERRS"
|
|
140
|
+
s_dspec = "$SPEC"
|
|
141
|
+
s_bexact = "`$EXACT`"
|
|
142
|
+
s_bval = "`$VAL`"
|
|
143
|
+
s_bkey = "`$KEY`"
|
|
144
|
+
s_bopen = "`$OPEN`"
|
|
145
|
+
|
|
146
|
+
-- | Single-token syntax constants: empty, backtick, @$@, dot, colon, slash, the literal @"KEY"@ and the @": "@ path separator.
|
|
147
|
+
s_mt, s_bt, s_ds, s_dt, s_cn, s_fs, s_key, s_viz :: String
|
|
148
|
+
s_mt = ""
|
|
149
|
+
s_bt = "`"
|
|
150
|
+
s_ds = "$"
|
|
151
|
+
s_dt = "."
|
|
152
|
+
s_cn = ":"
|
|
153
|
+
s_fs = "/"
|
|
154
|
+
s_key = "KEY"
|
|
155
|
+
s_viz = ": "
|
|
156
|
+
|
|
157
|
+
-- | Canonical type-name string constants (@"string"@, @"object"@, @"list"@, @"map"@, @"nil"@, @"null"@).
|
|
158
|
+
s_string, s_object, s_list, s_map, s_nil, s_null :: String
|
|
159
|
+
s_string = "string"
|
|
160
|
+
s_object = "object"
|
|
161
|
+
s_list = "list"
|
|
162
|
+
s_map = "map"
|
|
163
|
+
s_nil = "nil"
|
|
164
|
+
s_null = "null"
|
|
165
|
+
|
|
166
|
+
-- | The U+2A2F cross mark used in 'select' error messages.
|
|
167
|
+
cross :: String
|
|
168
|
+
cross = "\10799" -- U+2A2F vector cross product (select error messages)
|
|
169
|
+
|
|
170
|
+
-- | Type-tag bitmask constants (part 1): the wildcard and scalar leaf types.
|
|
171
|
+
t_any, t_noval, t_boolean, t_decimal, t_integer, t_number, t_string :: Int
|
|
172
|
+
-- | Type-tag bitmask constants (part 2): function, null and the composite @list@/@map@/@node@/@scalar@ groups.
|
|
173
|
+
t_function, t_null, t_list, t_map, t_instance, t_scalar, t_node :: Int
|
|
174
|
+
t_any = 0x7FFFFFFF
|
|
175
|
+
t_noval = 0x40000000
|
|
176
|
+
t_boolean = 0x20000000
|
|
177
|
+
t_decimal = 0x10000000
|
|
178
|
+
t_integer = 0x08000000
|
|
179
|
+
t_number = 0x04000000
|
|
180
|
+
t_string = 0x02000000
|
|
181
|
+
t_function = 0x01000000
|
|
182
|
+
t_null = 0x00400000
|
|
183
|
+
t_list = 0x00004000
|
|
184
|
+
t_map = 0x00002000
|
|
185
|
+
t_instance = 0x00001000
|
|
186
|
+
t_scalar = 0x00000080
|
|
187
|
+
t_node = 0x00000040
|
|
188
|
+
|
|
189
|
+
-- | Ordered table mapping type-tag indices to their canonical type names.
|
|
190
|
+
typenameTbl :: [String]
|
|
191
|
+
typenameTbl =
|
|
192
|
+
[ "any", "nil", "boolean", "decimal", "integer", "number", "string", "function"
|
|
193
|
+
, "symbol", "null", "", "", "", "", "", "", "", "list", "map", "instance"
|
|
194
|
+
, "", "", "", "", "scalar", "node" ]
|
|
195
|
+
|
|
196
|
+
-- | The SKIP and DELETE sentinel values (compared by tag via 'is_skip' \/ 'is_delete').
|
|
197
|
+
skip, delete :: Value
|
|
198
|
+
skip = VSentinel "skip"
|
|
199
|
+
delete = VSentinel "delete"
|
|
200
|
+
|
|
201
|
+
-- | Maximum recursion depth for 'walk' and the engines (32).
|
|
202
|
+
maxdepth :: Int
|
|
203
|
+
maxdepth = 32
|
|
204
|
+
|
|
205
|
+
-- ---------------------------------------------------------------------------
|
|
206
|
+
-- Small helpers
|
|
207
|
+
-- ---------------------------------------------------------------------------
|
|
208
|
+
|
|
209
|
+
-- | Build a fresh list node from the given elements.
|
|
210
|
+
mkList :: [Value] -> IO Value
|
|
211
|
+
mkList xs = VList <$> newIORef xs
|
|
212
|
+
|
|
213
|
+
-- | Build a fresh map node from the given key\/value pairs (insertion order preserved).
|
|
214
|
+
mkMap :: [(String, Value)] -> IO Value
|
|
215
|
+
mkMap es = VMap <$> newIORef es
|
|
216
|
+
|
|
217
|
+
-- | A fresh empty list node.
|
|
218
|
+
emptyList :: IO Value
|
|
219
|
+
emptyList = mkList []
|
|
220
|
+
|
|
221
|
+
-- | A fresh empty map node.
|
|
222
|
+
emptyMap :: IO Value
|
|
223
|
+
emptyMap = mkMap []
|
|
224
|
+
|
|
225
|
+
-- | Wrap an 'Int' as a numeric 'Value'.
|
|
226
|
+
vint :: Int -> Value
|
|
227
|
+
vint i = VNum (fromIntegral i)
|
|
228
|
+
|
|
229
|
+
-- | Read the elements of a list node (@[]@ for non-lists).
|
|
230
|
+
listItems :: Value -> IO [Value]
|
|
231
|
+
listItems (VList r) = readIORef r
|
|
232
|
+
listItems _ = return []
|
|
233
|
+
|
|
234
|
+
-- | Read the key\/value entries of a map node (@[]@ for non-maps).
|
|
235
|
+
mapEntries :: Value -> IO [(String, Value)]
|
|
236
|
+
mapEntries (VMap m) = readIORef m
|
|
237
|
+
mapEntries _ = return []
|
|
238
|
+
|
|
239
|
+
-- | True for 'VNoval' (canonical @undefined@).
|
|
240
|
+
isNoval :: Value -> Bool
|
|
241
|
+
isNoval VNoval = True
|
|
242
|
+
isNoval _ = False
|
|
243
|
+
|
|
244
|
+
-- | True for 'VNoval' or 'VNull' — the "no value" test shared by the readers.
|
|
245
|
+
isNullish :: Value -> Bool
|
|
246
|
+
isNullish VNoval = True
|
|
247
|
+
isNullish VNull = True
|
|
248
|
+
isNullish _ = False
|
|
249
|
+
|
|
250
|
+
-- | True for the SKIP sentinel.
|
|
251
|
+
is_skip :: Value -> Bool
|
|
252
|
+
is_skip (VSentinel "skip") = True
|
|
253
|
+
is_skip _ = False
|
|
254
|
+
|
|
255
|
+
-- | True for the DELETE sentinel.
|
|
256
|
+
is_delete :: Value -> Bool
|
|
257
|
+
is_delete (VSentinel "delete") = True
|
|
258
|
+
is_delete _ = False
|
|
259
|
+
|
|
260
|
+
-- | True when the value is a string equal to the given text.
|
|
261
|
+
vStrEq :: Value -> String -> Bool
|
|
262
|
+
vStrEq (VStr s) t = s == t
|
|
263
|
+
vStrEq _ _ = False
|
|
264
|
+
|
|
265
|
+
-- | JavaScript-style truthiness of a value.
|
|
266
|
+
vIsTrue :: Value -> Bool
|
|
267
|
+
vIsTrue (VBool True) = True
|
|
268
|
+
vIsTrue _ = False
|
|
269
|
+
|
|
270
|
+
-- | True for a string value.
|
|
271
|
+
isStr :: Value -> Bool
|
|
272
|
+
isStr (VStr _) = True
|
|
273
|
+
isStr _ = False
|
|
274
|
+
|
|
275
|
+
-- | Parse a string as an 'Int', or 'Nothing'.
|
|
276
|
+
readIntOpt :: String -> Maybe Int
|
|
277
|
+
readIntOpt s = readMaybe (dropPlus s)
|
|
278
|
+
where dropPlus ('+':r) = r
|
|
279
|
+
dropPlus x = x
|
|
280
|
+
|
|
281
|
+
-- | Return the list with the element at the given index replaced.
|
|
282
|
+
setAt :: Int -> a -> [a] -> [a]
|
|
283
|
+
setAt i v xs = [if j == i then v else x | (j, x) <- zip [0 ..] xs]
|
|
284
|
+
|
|
285
|
+
-- | Insert or update a key in an association list, keeping insertion order.
|
|
286
|
+
opPut :: String -> Value -> [(String, Value)] -> [(String, Value)]
|
|
287
|
+
opPut k v es =
|
|
288
|
+
if any ((== k) . fst) es
|
|
289
|
+
then map (\(k', v') -> if k' == k then (k, v) else (k', v')) es
|
|
290
|
+
else es ++ [(k, v)]
|
|
291
|
+
|
|
292
|
+
-- | Remove a key from an association list.
|
|
293
|
+
opDel :: String -> [(String, Value)] -> [(String, Value)]
|
|
294
|
+
opDel k = L.filter ((/= k) . fst)
|
|
295
|
+
|
|
296
|
+
-- | Monadic 'any': True when the predicate holds for some element.
|
|
297
|
+
anyM :: (a -> IO Bool) -> [a] -> IO Bool
|
|
298
|
+
anyM _ [] = return False
|
|
299
|
+
anyM f (x:xs) = do b <- f x; if b then return True else anyM f xs
|
|
300
|
+
|
|
301
|
+
-- | Short-circuiting monadic conjunction of a list of @IO Bool@s.
|
|
302
|
+
andM :: [IO Bool] -> IO Bool
|
|
303
|
+
andM [] = return True
|
|
304
|
+
andM (m:ms) = do b <- m; if b then andM ms else return False
|
|
305
|
+
|
|
306
|
+
-- | True when a 'Double' holds an exact integer value.
|
|
307
|
+
isIntegerF :: Double -> Bool
|
|
308
|
+
isIntegerF n = not (isNaN n) && not (isInfinite n) && n == fromIntegral (truncate n :: Integer)
|
|
309
|
+
|
|
310
|
+
-- | Render a 'Double' as JavaScript @String(n)@ does (integral values drop the trailing @.0@).
|
|
311
|
+
numToString :: Double -> String
|
|
312
|
+
numToString n
|
|
313
|
+
| isNaN n = "NaN"
|
|
314
|
+
| isIntegerF n && abs n < 1e16 = show (truncate n :: Integer)
|
|
315
|
+
| otherwise = shortest 1
|
|
316
|
+
where
|
|
317
|
+
shortest p
|
|
318
|
+
| p > 17 = printf "%.17g" n
|
|
319
|
+
| otherwise =
|
|
320
|
+
let s = printf ("%." ++ show (p :: Int) ++ "g") n :: String
|
|
321
|
+
in if (readMaybe s :: Maybe Double) == Just n then s else shortest (p + 1)
|
|
322
|
+
|
|
323
|
+
-- | Render @floor n@ as a JavaScript-style number string.
|
|
324
|
+
floorNumStr :: Double -> String
|
|
325
|
+
floorNumStr n = numToString (fromIntegral (floor n :: Integer))
|
|
326
|
+
|
|
327
|
+
-- JS `'' + v` / String(v) for keys and concatenation.
|
|
328
|
+
-- | JavaScript @String(v)@ for any value (in 'IO' because nodes are read).
|
|
329
|
+
jsString :: Value -> IO String
|
|
330
|
+
jsString v = case v of
|
|
331
|
+
VNoval -> return "undefined"
|
|
332
|
+
VNull -> return "null"
|
|
333
|
+
VBool b -> return (if b then "true" else "false")
|
|
334
|
+
VNum n -> return (numToString n)
|
|
335
|
+
VStr s -> return s
|
|
336
|
+
VFunc _ -> return "function"
|
|
337
|
+
VSentinel s -> return s
|
|
338
|
+
VMap _ -> return "[object Object]"
|
|
339
|
+
VList r -> do
|
|
340
|
+
elems <- readIORef r
|
|
341
|
+
parts <- mapM (\x -> case x of VNoval -> return ""; VNull -> return ""; _ -> jsString x) elems
|
|
342
|
+
return (intercalate "," parts)
|
|
343
|
+
|
|
344
|
+
-- pure String(v) for scalar values (the node cases never reach here)
|
|
345
|
+
-- | Pure @String(v)@ for scalar values (node cases never reach here).
|
|
346
|
+
jsstrPure :: Value -> String
|
|
347
|
+
jsstrPure v = case v of
|
|
348
|
+
VNoval -> "undefined"
|
|
349
|
+
VNull -> "null"
|
|
350
|
+
VBool b -> if b then "true" else "false"
|
|
351
|
+
VNum n -> numToString n
|
|
352
|
+
VStr s -> s
|
|
353
|
+
VFunc _ -> "function"
|
|
354
|
+
VSentinel s -> s
|
|
355
|
+
_ -> ""
|
|
356
|
+
|
|
357
|
+
-- | True when a string is a valid non-negative integer list index.
|
|
358
|
+
isIntKey :: String -> Bool
|
|
359
|
+
isIntKey s = not (null s) && all (\c -> (c >= '0' && c <= '9') || c == '-') s
|
|
360
|
+
|
|
361
|
+
-- | Count leading zero bits of a 32-bit word (JavaScript @Math.clz32@).
|
|
362
|
+
clz32 :: Int -> Int
|
|
363
|
+
clz32 n0 =
|
|
364
|
+
let n = n0 .&. 0xFFFFFFFF
|
|
365
|
+
in if n == 0 then 32 else go n 0
|
|
366
|
+
where
|
|
367
|
+
go n r = if (n .&. 0x80000000) /= 0 then r else go ((n `shiftL` 1) .&. 0xFFFFFFFF) (r + 1)
|
|
368
|
+
|
|
369
|
+
-- | Split a string on a delimiter character.
|
|
370
|
+
splitOn :: Char -> String -> [String]
|
|
371
|
+
splitOn c s = case break (== c) s of
|
|
372
|
+
(a, []) -> [a]
|
|
373
|
+
(a, _:rest) -> a : splitOn c rest
|
|
374
|
+
|
|
375
|
+
-- | True when the first string is a prefix of the second.
|
|
376
|
+
isPrefixOf' :: String -> String -> Bool
|
|
377
|
+
isPrefixOf' = isPrefixOf
|
|
378
|
+
|
|
379
|
+
-- | Replace every occurrence of a substring within a string.
|
|
380
|
+
replaceAll :: String -> String -> String -> String
|
|
381
|
+
replaceAll s find_ repl
|
|
382
|
+
| null find_ = s
|
|
383
|
+
| otherwise = go s
|
|
384
|
+
where
|
|
385
|
+
flen = length find_
|
|
386
|
+
go [] = []
|
|
387
|
+
go str@(c:rest) =
|
|
388
|
+
if find_ `isPrefixOf` str then repl ++ go (drop flen str) else c : go rest
|
|
389
|
+
|
|
390
|
+
-- ---------------------------------------------------------------------------
|
|
391
|
+
-- Minor utilities
|
|
392
|
+
-- ---------------------------------------------------------------------------
|
|
393
|
+
|
|
394
|
+
-- | True when the value is a node (map or list).
|
|
395
|
+
isnode :: Value -> Bool
|
|
396
|
+
isnode (VMap _) = True
|
|
397
|
+
isnode (VList _) = True
|
|
398
|
+
isnode _ = False
|
|
399
|
+
|
|
400
|
+
-- | True when the value is a map node.
|
|
401
|
+
ismap :: Value -> Bool
|
|
402
|
+
ismap (VMap _) = True
|
|
403
|
+
ismap _ = False
|
|
404
|
+
|
|
405
|
+
-- | True when the value is a list node.
|
|
406
|
+
islist :: Value -> Bool
|
|
407
|
+
islist (VList _) = True
|
|
408
|
+
islist _ = False
|
|
409
|
+
|
|
410
|
+
-- | True when the value is a function ('VFunc').
|
|
411
|
+
isfunc :: Value -> Bool
|
|
412
|
+
isfunc (VFunc _) = True
|
|
413
|
+
isfunc _ = False
|
|
414
|
+
|
|
415
|
+
-- | True when the value can serve as a key (non-empty string or a number).
|
|
416
|
+
iskey :: Value -> Bool
|
|
417
|
+
iskey (VStr s) = s /= ""
|
|
418
|
+
iskey (VNum _) = True
|
|
419
|
+
iskey _ = False
|
|
420
|
+
|
|
421
|
+
-- | True for empty\/absent values: noval, null, empty string, or an empty node.
|
|
422
|
+
isempty :: Value -> IO Bool
|
|
423
|
+
isempty v = case v of
|
|
424
|
+
VNoval -> return True
|
|
425
|
+
VNull -> return True
|
|
426
|
+
VStr s -> return (s == "")
|
|
427
|
+
VList r -> null <$> readIORef r
|
|
428
|
+
VMap m -> null <$> readIORef m
|
|
429
|
+
_ -> return False
|
|
430
|
+
|
|
431
|
+
-- | Return the first value unless it is nullish, otherwise the default.
|
|
432
|
+
getdef :: Value -> Value -> Value
|
|
433
|
+
getdef v alt = if isNoval v then alt else v
|
|
434
|
+
|
|
435
|
+
-- | The canonical integer type tag of a value.
|
|
436
|
+
typify :: Value -> Int
|
|
437
|
+
typify v = case v of
|
|
438
|
+
VNoval -> t_noval
|
|
439
|
+
VNull -> t_scalar .|. t_null
|
|
440
|
+
VBool _ -> t_scalar .|. t_boolean
|
|
441
|
+
VNum n -> if isNaN n then t_noval
|
|
442
|
+
else if isIntegerF n then t_scalar .|. t_number .|. t_integer
|
|
443
|
+
else t_scalar .|. t_number .|. t_decimal
|
|
444
|
+
VStr _ -> t_scalar .|. t_string
|
|
445
|
+
VFunc _ -> t_scalar .|. t_function
|
|
446
|
+
VList _ -> t_node .|. t_list
|
|
447
|
+
VMap _ -> t_node .|. t_map
|
|
448
|
+
VSentinel _ -> t_node .|. t_map
|
|
449
|
+
|
|
450
|
+
-- | The canonical type name for a type-tag index.
|
|
451
|
+
typename :: Int -> String
|
|
452
|
+
typename t =
|
|
453
|
+
let i = clz32 t
|
|
454
|
+
in if i >= 0 && i < length typenameTbl then typenameTbl !! i else head typenameTbl
|
|
455
|
+
|
|
456
|
+
-- | Number of entries in a node (0 for non-nodes).
|
|
457
|
+
size :: Value -> IO Int
|
|
458
|
+
size v = case v of
|
|
459
|
+
VList r -> length <$> readIORef r
|
|
460
|
+
VMap m -> length <$> readIORef m
|
|
461
|
+
VStr s -> return (length s)
|
|
462
|
+
VBool b -> return (if b then 1 else 0)
|
|
463
|
+
VNum n -> return (floor n)
|
|
464
|
+
_ -> return 0
|
|
465
|
+
|
|
466
|
+
-- | Coerce a value to its string-key form.
|
|
467
|
+
strkey :: Value -> String
|
|
468
|
+
strkey key = case key of
|
|
469
|
+
VNoval -> s_mt
|
|
470
|
+
VStr s -> s
|
|
471
|
+
VBool _ -> s_mt
|
|
472
|
+
VNum n -> if isIntegerF n then numToString n else floorNumStr n
|
|
473
|
+
_ -> s_mt
|
|
474
|
+
|
|
475
|
+
-- | Sorted map keys, or list indices as strings; @[]@ for non-nodes.
|
|
476
|
+
keysof :: Value -> IO [String]
|
|
477
|
+
keysof v = case v of
|
|
478
|
+
VMap m -> sort . map fst <$> readIORef m
|
|
479
|
+
VList r -> do elems <- readIORef r; return [show i | i <- [0 .. length elems - 1]]
|
|
480
|
+
_ -> return []
|
|
481
|
+
|
|
482
|
+
-- | Read a list element by numeric\/string key ('VNoval' when out of range).
|
|
483
|
+
listIndex :: IORef [Value] -> Value -> IO Value
|
|
484
|
+
listIndex r key = do
|
|
485
|
+
let ks = case key of VStr s -> s; VNum n -> numToString n; _ -> ""
|
|
486
|
+
elems <- readIORef r
|
|
487
|
+
case readIntOpt ks of
|
|
488
|
+
Just i | i >= 0 && i < length elems -> return (elems !! i)
|
|
489
|
+
_ -> return VNoval
|
|
490
|
+
|
|
491
|
+
-- | Read a node property by key, returning the alt value when absent.
|
|
492
|
+
getpropAlt :: Value -> Value -> Value -> IO Value
|
|
493
|
+
getpropAlt alt v key
|
|
494
|
+
| isNoval v || isNoval key = return alt
|
|
495
|
+
| otherwise = do
|
|
496
|
+
out <- case v of
|
|
497
|
+
VMap m -> do k <- jsString key; fromMaybe VNoval . lookup k <$> readIORef m
|
|
498
|
+
VList r -> listIndex r key
|
|
499
|
+
_ -> return VNoval
|
|
500
|
+
return (if isNullish out then alt else out)
|
|
501
|
+
|
|
502
|
+
-- | Read a node property by key ('VNoval' when absent).
|
|
503
|
+
getprop :: Value -> Value -> IO Value
|
|
504
|
+
getprop = getpropAlt VNoval
|
|
505
|
+
|
|
506
|
+
-- | Internal raw property reader that preserves 'VNull' literally.
|
|
507
|
+
lookup_ :: Value -> Value -> IO Value
|
|
508
|
+
lookup_ v key
|
|
509
|
+
| isNoval v || isNoval key = return VNoval
|
|
510
|
+
| otherwise = case v of
|
|
511
|
+
VMap m -> do k <- jsString key; fromMaybe VNoval . lookup k <$> readIORef m
|
|
512
|
+
VList r -> listIndex r key
|
|
513
|
+
_ -> return VNoval
|
|
514
|
+
|
|
515
|
+
-- | True when a node has a (non-nullish) value at the given key.
|
|
516
|
+
haskey :: Value -> Value -> IO Bool
|
|
517
|
+
haskey v key = (not . isNullish) <$> getprop v key
|
|
518
|
+
|
|
519
|
+
-- | Read a list element by key, returning the alt value when absent.
|
|
520
|
+
getelemAlt :: Value -> Value -> Value -> IO Value
|
|
521
|
+
getelemAlt alt v key
|
|
522
|
+
| isNoval v || isNoval key = return alt
|
|
523
|
+
| otherwise = do
|
|
524
|
+
out <- case v of
|
|
525
|
+
VList r -> do
|
|
526
|
+
let ks = case key of VStr s -> s; VNum n -> numToString n; _ -> ""
|
|
527
|
+
if isIntKey ks
|
|
528
|
+
then do
|
|
529
|
+
elems <- readIORef r
|
|
530
|
+
let len = length elems
|
|
531
|
+
case readIntOpt ks of
|
|
532
|
+
Just nk0 -> let nk = if nk0 < 0 then len + nk0 else nk0
|
|
533
|
+
in return (if nk >= 0 && nk < len then elems !! nk else VNoval)
|
|
534
|
+
Nothing -> return VNoval
|
|
535
|
+
else return VNoval
|
|
536
|
+
_ -> return VNoval
|
|
537
|
+
if isNullish out
|
|
538
|
+
then case alt of VFunc f -> f dummyInj VNoval "" VNoval; _ -> return alt
|
|
539
|
+
else return out
|
|
540
|
+
|
|
541
|
+
-- | Read a list element by key ('VNoval' when absent).
|
|
542
|
+
getelem :: Value -> Value -> IO Value
|
|
543
|
+
getelem = getelemAlt VNoval
|
|
544
|
+
|
|
545
|
+
-- | Internal string-keyed property reader.
|
|
546
|
+
getpropRaw :: Value -> String -> IO Value
|
|
547
|
+
getpropRaw v k = case v of
|
|
548
|
+
VMap m -> fromMaybe VNoval . lookup k <$> readIORef m
|
|
549
|
+
VList r -> do
|
|
550
|
+
elems <- readIORef r
|
|
551
|
+
case readIntOpt k of
|
|
552
|
+
Just i | i >= 0 && i < length elems -> return (elems !! i)
|
|
553
|
+
_ -> return VNoval
|
|
554
|
+
_ -> return VNoval
|
|
555
|
+
|
|
556
|
+
-- | Node entries as @(key, value)@ pairs — map entries or indexed list elements.
|
|
557
|
+
itemsPairs :: Value -> IO [(String, Value)]
|
|
558
|
+
itemsPairs v =
|
|
559
|
+
if not (isnode v) then return []
|
|
560
|
+
else do ks <- keysof v; mapM (\k -> (,) k <$> getpropRaw v k) ks
|
|
561
|
+
|
|
562
|
+
-- | Node entries as a list node of @[key, value]@ pairs.
|
|
563
|
+
items :: Value -> IO Value
|
|
564
|
+
items v = do
|
|
565
|
+
ps <- itemsPairs v
|
|
566
|
+
xs <- mapM (\(k, x) -> mkList [VStr k, x]) ps
|
|
567
|
+
mkList xs
|
|
568
|
+
|
|
569
|
+
-- | Map each node entry through a function, collecting the results into a list node.
|
|
570
|
+
itemsV :: Value -> ((String, Value) -> Value) -> IO Value
|
|
571
|
+
itemsV v f = do ps <- itemsPairs v; mkList (map f ps)
|
|
572
|
+
|
|
573
|
+
-- | Flatten nested lists up to the given depth.
|
|
574
|
+
flatten :: Int -> Value -> IO Value
|
|
575
|
+
flatten depth l =
|
|
576
|
+
if not (islist l) then return l
|
|
577
|
+
else do
|
|
578
|
+
its <- listItems l
|
|
579
|
+
out <- foldM go [] its
|
|
580
|
+
mkList out
|
|
581
|
+
where
|
|
582
|
+
go acc item =
|
|
583
|
+
if islist item && depth > 0
|
|
584
|
+
then do f <- flatten (depth - 1) item; fis <- listItems f; return (acc ++ fis)
|
|
585
|
+
else return (acc ++ [item])
|
|
586
|
+
|
|
587
|
+
-- | Keep the node entries satisfying the predicate (shadows 'Prelude.filter').
|
|
588
|
+
filter :: Value -> ((String, Value) -> Bool) -> IO Value
|
|
589
|
+
filter v check = do
|
|
590
|
+
ps <- itemsPairs v
|
|
591
|
+
mkList [x | (k, x) <- ps, check (k, x)]
|
|
592
|
+
|
|
593
|
+
-- | Set, or (with a nullish value) delete, a node property; returns the node.
|
|
594
|
+
setprop :: Value -> Value -> Value -> IO Value
|
|
595
|
+
setprop parent key v
|
|
596
|
+
| not (iskey key) = return parent
|
|
597
|
+
| otherwise = do
|
|
598
|
+
case parent of
|
|
599
|
+
VMap m -> do k <- jsString key; modifyIORef' m (opPut k v)
|
|
600
|
+
VList r -> do
|
|
601
|
+
let ks = case key of VStr s -> s; VNum n -> floorNumStr n; _ -> ""
|
|
602
|
+
case readIntOpt ks of
|
|
603
|
+
Nothing -> return ()
|
|
604
|
+
Just ki -> do
|
|
605
|
+
its <- readIORef r
|
|
606
|
+
let len = length its
|
|
607
|
+
if ki >= 0
|
|
608
|
+
then let ki' = if ki > len then len else ki
|
|
609
|
+
in if ki' >= len then writeIORef r (its ++ [v]) else writeIORef r (setAt ki' v its)
|
|
610
|
+
else writeIORef r (v : its)
|
|
611
|
+
_ -> return ()
|
|
612
|
+
return parent
|
|
613
|
+
|
|
614
|
+
-- | Delete a node property; returns the node.
|
|
615
|
+
delprop :: Value -> Value -> IO Value
|
|
616
|
+
delprop parent key
|
|
617
|
+
| not (iskey key) = return parent
|
|
618
|
+
| otherwise = do
|
|
619
|
+
case parent of
|
|
620
|
+
VMap m -> do k <- jsString key; modifyIORef' m (opDel k)
|
|
621
|
+
VList r -> do
|
|
622
|
+
let ks = case key of VStr s -> s; VNum n -> floorNumStr n; _ -> ""
|
|
623
|
+
case readIntOpt ks of
|
|
624
|
+
Just ki | ki >= 0 -> do
|
|
625
|
+
its <- readIORef r
|
|
626
|
+
when (ki < length its) $ writeIORef r [x | (j, x) <- zip [0 ..] its, j /= ki]
|
|
627
|
+
_ -> return ()
|
|
628
|
+
_ -> return ()
|
|
629
|
+
return parent
|
|
630
|
+
|
|
631
|
+
-- | Deep copy a value into fresh, independent nodes.
|
|
632
|
+
clone :: Value -> IO Value
|
|
633
|
+
clone v = case v of
|
|
634
|
+
VList r -> do its <- readIORef r; xs <- mapM clone its; mkList xs
|
|
635
|
+
VMap m -> do es <- readIORef m; es' <- mapM (\(k, x) -> (,) k <$> clone x) es; mkMap es'
|
|
636
|
+
_ -> return v
|
|
637
|
+
|
|
638
|
+
-- | Sub-list\/substring by start\/end with an inclusive-end flag.
|
|
639
|
+
sliceM :: Value -> Value -> Value -> Bool -> IO Value
|
|
640
|
+
sliceM v start stop mutate = case v of
|
|
641
|
+
VNum n -> do
|
|
642
|
+
let lo = case start of VNum s -> s; _ -> -(1 / 0)
|
|
643
|
+
hi = case stop of VNum e -> e - 1; _ -> 1 / 0
|
|
644
|
+
return (VNum (max lo (min n hi)))
|
|
645
|
+
_ | islist v || isStr v -> do
|
|
646
|
+
vlen <- size v
|
|
647
|
+
let start' = case (start, stop) of (VNoval, x) | not (isNoval x) -> VNum 0; _ -> start
|
|
648
|
+
case start' of
|
|
649
|
+
VNum sf -> do
|
|
650
|
+
let s0 = truncate sf :: Int
|
|
651
|
+
(s1, e1) =
|
|
652
|
+
if s0 < 0 then (0, let e = vlen + s0 in if e < 0 then 0 else e)
|
|
653
|
+
else case stop of
|
|
654
|
+
VNum ef -> let e = truncate ef :: Int
|
|
655
|
+
in if e < 0 then (s0, let e2 = vlen + e in if e2 < 0 then 0 else e2)
|
|
656
|
+
else if vlen < e then (s0, vlen) else (s0, e)
|
|
657
|
+
_ -> (s0, vlen)
|
|
658
|
+
s2 = if vlen < s1 then vlen else s1
|
|
659
|
+
if s2 > -1 && s2 <= e1 && e1 <= vlen
|
|
660
|
+
then case v of
|
|
661
|
+
VList r -> do its <- readIORef r
|
|
662
|
+
let sub = take (e1 - s2) (drop s2 its)
|
|
663
|
+
if mutate then writeIORef r sub >> return v else mkList sub
|
|
664
|
+
VStr str -> return (VStr (take (e1 - s2) (drop s2 str)))
|
|
665
|
+
_ -> return v
|
|
666
|
+
else case v of
|
|
667
|
+
VList r -> if mutate then writeIORef r [] >> return v else emptyList
|
|
668
|
+
VStr _ -> return (VStr "")
|
|
669
|
+
_ -> return v
|
|
670
|
+
_ -> return v
|
|
671
|
+
_ -> return v
|
|
672
|
+
|
|
673
|
+
-- | Sub-list\/substring over the half-open range @[start, end)@.
|
|
674
|
+
slice :: Value -> Value -> Value -> IO Value
|
|
675
|
+
slice v start stop = sliceM v start stop False
|
|
676
|
+
|
|
677
|
+
-- ----- regex helpers (uniform re_* API + in-tree Vregex) -----
|
|
678
|
+
|
|
679
|
+
-- | Coerce a value to the source text of a regular expression.
|
|
680
|
+
reStr :: Value -> IO String
|
|
681
|
+
reStr p = case p of VStr s -> return s; _ -> jsString p
|
|
682
|
+
|
|
683
|
+
-- | Compile a pattern value into a regex value.
|
|
684
|
+
re_compile :: Value -> IO Value
|
|
685
|
+
re_compile p = case p of VStr _ -> return p; _ -> VStr <$> jsString p
|
|
686
|
+
|
|
687
|
+
-- | True when the regex matches the subject.
|
|
688
|
+
re_test :: Value -> Value -> IO Value
|
|
689
|
+
re_test p input = do ps <- reStr p; is <- reStr input; return (VBool (Vregex.testStr ps is))
|
|
690
|
+
|
|
691
|
+
-- | First match of the regex in the subject.
|
|
692
|
+
re_find :: Value -> Value -> IO Value
|
|
693
|
+
re_find p input = do
|
|
694
|
+
ps <- reStr p
|
|
695
|
+
is <- reStr input
|
|
696
|
+
case Vregex.findBounds (Vregex.compile ps) is of
|
|
697
|
+
Just (s, e) -> mkList [VStr (take (e - s) (drop s is))]
|
|
698
|
+
Nothing -> return VNull
|
|
699
|
+
|
|
700
|
+
-- | All matches of the regex in the subject.
|
|
701
|
+
re_find_all :: Value -> Value -> IO Value
|
|
702
|
+
re_find_all _ _ = emptyList
|
|
703
|
+
|
|
704
|
+
-- | Replace regex matches within the subject.
|
|
705
|
+
re_replace :: Value -> Value -> Value -> IO Value
|
|
706
|
+
re_replace _ input _ = return input
|
|
707
|
+
|
|
708
|
+
-- | Escape a value for literal use in a regex.
|
|
709
|
+
re_escape :: Value -> IO Value
|
|
710
|
+
re_escape = escre
|
|
711
|
+
|
|
712
|
+
-- | Escape a string for literal use in a regular expression.
|
|
713
|
+
escre :: Value -> IO Value
|
|
714
|
+
escre s = do
|
|
715
|
+
str <- case s of VStr x -> return x; VNoval -> return s_mt; _ -> jsString s
|
|
716
|
+
return $ VStr $ concatMap (\c -> if c `elem` ".*+?^${}()|[]\\" then ['\\', c] else [c]) str
|
|
717
|
+
|
|
718
|
+
-- | Percent-encode a string for use in a URL.
|
|
719
|
+
escurl :: Value -> IO Value
|
|
720
|
+
escurl s = do
|
|
721
|
+
str <- case s of VStr x -> return x; VNoval -> return s_mt; _ -> jsString s
|
|
722
|
+
return $ VStr $ concatMap enc str
|
|
723
|
+
where
|
|
724
|
+
enc c = if unreserved c then [c] else '%' : (printf "%02X" (fromEnum c) :: String)
|
|
725
|
+
unreserved c = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')
|
|
726
|
+
|| (c >= '0' && c <= '9') || c `elem` "-_.!~*'()"
|
|
727
|
+
|
|
728
|
+
-- ----- json_encode / stringify / jsonify / pad / join / pathify -----
|
|
729
|
+
|
|
730
|
+
-- | Format an 'Int' as a zero-padded four-digit hex string.
|
|
731
|
+
pad4hex :: Int -> String
|
|
732
|
+
pad4hex n = let h = showHex n "" in replicate (4 - length h) '0' ++ h
|
|
733
|
+
|
|
734
|
+
-- | Core JSON encoder (sort-keys and optional indent) shared by 'stringify' \/ 'jsonify'.
|
|
735
|
+
jsonEncode :: Bool -> Maybe Int -> Value -> IO String
|
|
736
|
+
jsonEncode srt indent = \v -> enc v 0
|
|
737
|
+
where
|
|
738
|
+
esc s = '"' : concatMap escc s ++ "\""
|
|
739
|
+
escc c = case c of
|
|
740
|
+
'"' -> "\\\""
|
|
741
|
+
'\\' -> "\\\\"
|
|
742
|
+
'\n' -> "\\n"
|
|
743
|
+
'\r' -> "\\r"
|
|
744
|
+
'\t' -> "\\t"
|
|
745
|
+
_ | fromEnum c < 32 -> "\\u" ++ pad4hex (fromEnum c)
|
|
746
|
+
| otherwise -> [c]
|
|
747
|
+
enc val level = case val of
|
|
748
|
+
VNoval -> return "null"
|
|
749
|
+
VNull -> return "null"
|
|
750
|
+
VBool b -> return (if b then "true" else "false")
|
|
751
|
+
VNum n -> return (numToString n)
|
|
752
|
+
VStr s -> return (esc s)
|
|
753
|
+
VFunc _ -> return "null"
|
|
754
|
+
VSentinel _ -> return "null"
|
|
755
|
+
VList r -> do
|
|
756
|
+
its <- readIORef r
|
|
757
|
+
if null its then return "[]" else case indent of
|
|
758
|
+
Just ind -> do
|
|
759
|
+
let padStr = replicate (ind * (level + 1)) ' '
|
|
760
|
+
cpad = replicate (ind * level) ' '
|
|
761
|
+
parts <- mapM (\x -> (padStr ++) <$> enc x (level + 1)) its
|
|
762
|
+
return ("[\n" ++ intercalate ",\n" parts ++ "\n" ++ cpad ++ "]")
|
|
763
|
+
Nothing -> do
|
|
764
|
+
parts <- mapM (\x -> enc x (level + 1)) its
|
|
765
|
+
return ("[" ++ intercalate "," parts ++ "]")
|
|
766
|
+
VMap m -> do
|
|
767
|
+
es <- readIORef m
|
|
768
|
+
let ks0 = map fst es
|
|
769
|
+
ks = if srt then sort ks0 else ks0
|
|
770
|
+
if null ks then return "{}" else case indent of
|
|
771
|
+
Just ind -> do
|
|
772
|
+
let padStr = replicate (ind * (level + 1)) ' '
|
|
773
|
+
cpad = replicate (ind * level) ' '
|
|
774
|
+
parts <- mapM (\k -> do x <- maybe (return VNoval) return (lookup k es)
|
|
775
|
+
xs <- enc x (level + 1)
|
|
776
|
+
return (padStr ++ esc k ++ ": " ++ xs)) ks
|
|
777
|
+
return ("{\n" ++ intercalate ",\n" parts ++ "\n" ++ cpad ++ "}")
|
|
778
|
+
Nothing -> do
|
|
779
|
+
parts <- mapM (\k -> do x <- maybe (return VNoval) return (lookup k es)
|
|
780
|
+
xs <- enc x (level + 1)
|
|
781
|
+
return (esc k ++ ":" ++ xs)) ks
|
|
782
|
+
return ("{" ++ intercalate "," parts ++ "}")
|
|
783
|
+
|
|
784
|
+
-- | True when the value graph contains a reference cycle.
|
|
785
|
+
hasCycle :: Value -> IO Bool
|
|
786
|
+
hasCycle v0 = do
|
|
787
|
+
seen <- newIORef []
|
|
788
|
+
let sameNode (VList a) (VList b) = a == b
|
|
789
|
+
sameNode (VMap a) (VMap b) = a == b
|
|
790
|
+
sameNode _ _ = False
|
|
791
|
+
go v = case v of
|
|
792
|
+
VList r -> do
|
|
793
|
+
s <- readIORef seen
|
|
794
|
+
if any (sameNode v) s then return True
|
|
795
|
+
else do modifyIORef' seen (v :); xs <- readIORef r; anyM go xs
|
|
796
|
+
VMap m -> do
|
|
797
|
+
s <- readIORef seen
|
|
798
|
+
if any (sameNode v) s then return True
|
|
799
|
+
else do modifyIORef' seen (v :); es <- readIORef m; anyM (go . snd) es
|
|
800
|
+
_ -> return False
|
|
801
|
+
go v0
|
|
802
|
+
|
|
803
|
+
-- | Wrap a string in an ANSI 256-colour escape for pretty output.
|
|
804
|
+
prettyColor :: String -> String
|
|
805
|
+
prettyColor valstr =
|
|
806
|
+
let colors = [81, 118, 213, 39, 208, 201, 45, 190, 129, 51, 160, 121, 226, 33, 207, 69]
|
|
807
|
+
c = map (\n -> "\ESC[38;5;" ++ show (n :: Int) ++ "m") colors
|
|
808
|
+
clen = length c
|
|
809
|
+
r = "\ESC[0m"
|
|
810
|
+
step (d, o, t) ch
|
|
811
|
+
| ch == '{' || ch == '[' = let d2 = d + 1; o2 = c !! (d2 `mod` clen) in (d2, o2, t ++ o2 ++ [ch])
|
|
812
|
+
| ch == '}' || ch == ']' = let t2 = t ++ o ++ [ch]; d2 = d - 1; o2 = c !! (((d2 `mod` clen) + clen) `mod` clen) in (d2, o2, t2)
|
|
813
|
+
| otherwise = (d, o, t ++ o ++ [ch])
|
|
814
|
+
(_, _, res) = foldl step (0 :: Int, head c, head c) valstr
|
|
815
|
+
in res ++ r
|
|
816
|
+
|
|
817
|
+
-- | Compact JSON-ish rendering with sort and max-length options.
|
|
818
|
+
stringifyFull :: Value -> Value -> Bool -> IO String
|
|
819
|
+
stringifyFull v maxlen pretty = case v of
|
|
820
|
+
VNoval -> return (if pretty then "<>" else s_mt)
|
|
821
|
+
_ -> do
|
|
822
|
+
valstr <- case v of
|
|
823
|
+
VStr s -> return s
|
|
824
|
+
_ -> do
|
|
825
|
+
cyc <- hasCycle v
|
|
826
|
+
if cyc then return "__STRINGIFY_FAILED__"
|
|
827
|
+
else do s <- jsonEncode True Nothing v; return (L.filter (/= '"') s)
|
|
828
|
+
let valstr2 = case maxlen of
|
|
829
|
+
VNum m | m > -1 -> let mi = truncate m; l = length valstr
|
|
830
|
+
in if mi < l then take (max 0 (mi - 3)) valstr ++ "..." else valstr
|
|
831
|
+
_ -> valstr
|
|
832
|
+
if pretty then return (prettyColor valstr2) else return valstr2
|
|
833
|
+
|
|
834
|
+
-- | Compact, human-readable JSON-ish rendering of a value.
|
|
835
|
+
stringify :: Value -> IO String
|
|
836
|
+
stringify v = stringifyFull v VNoval False
|
|
837
|
+
|
|
838
|
+
-- | 'stringify' truncated to a maximum length.
|
|
839
|
+
stringifyMax :: Value -> Value -> IO String
|
|
840
|
+
stringifyMax v maxlen = stringifyFull v maxlen False
|
|
841
|
+
|
|
842
|
+
-- | Pretty, indented JSON rendering of a value.
|
|
843
|
+
jsonify :: Value -> Value -> IO String
|
|
844
|
+
jsonify v flags = case v of
|
|
845
|
+
VNoval -> return s_null
|
|
846
|
+
_ -> do
|
|
847
|
+
indentV <- getpropAlt (VNum 2) flags (VStr "indent")
|
|
848
|
+
let indent = case indentV of VNum n -> truncate n; _ -> 2
|
|
849
|
+
str <- if indent > 0 then jsonEncode False (Just indent) v else jsonEncode False Nothing v
|
|
850
|
+
offV <- getpropAlt (VNum 0) flags (VStr "offset")
|
|
851
|
+
let off = case offV of VNum n -> truncate n; _ -> 0
|
|
852
|
+
if off > 0
|
|
853
|
+
then case lines str of
|
|
854
|
+
(_:rest) -> return ("{\n" ++ intercalate "\n" (map (\l -> replicate off ' ' ++ l) rest))
|
|
855
|
+
[] -> return str
|
|
856
|
+
else return str
|
|
857
|
+
|
|
858
|
+
-- | Pad a value's string form to a width with a fill character.
|
|
859
|
+
pad :: Value -> Value -> Value -> IO String
|
|
860
|
+
pad s padding padchar = do
|
|
861
|
+
str <- case s of VStr x -> return x; VNull -> return "null"; _ -> stringify s
|
|
862
|
+
let p = case padding of VNum n -> truncate n; _ -> 44
|
|
863
|
+
pc = case padchar of VStr x -> take 1 (x ++ " "); _ -> " "
|
|
864
|
+
return $ if p > -1
|
|
865
|
+
then let n = p - length str in if n > 0 then str ++ concat (replicate n pc) else str
|
|
866
|
+
else let n = (-p) - length str in if n > 0 then concat (replicate n pc) ++ str else str
|
|
867
|
+
|
|
868
|
+
-- | Join a list's elements into a string with a separator.
|
|
869
|
+
join :: Value -> Value -> Bool -> IO String
|
|
870
|
+
join arr sep url =
|
|
871
|
+
if not (islist arr) then return s_mt
|
|
872
|
+
else do
|
|
873
|
+
sepdef <- case sep of VNoval -> return ","; VNull -> return ","; VStr s -> return s; _ -> jsString sep
|
|
874
|
+
let single = length sepdef == 1
|
|
875
|
+
sc = if single then head sepdef else ' '
|
|
876
|
+
stripTrailing = reverse . dropWhile (== sc) . reverse
|
|
877
|
+
stripLeading = dropWhile (== sc)
|
|
878
|
+
collapse str = build 0 str
|
|
879
|
+
where
|
|
880
|
+
nn = length str
|
|
881
|
+
build i s = case s of
|
|
882
|
+
[] -> []
|
|
883
|
+
(ch:_) | ch == sc ->
|
|
884
|
+
let run = takeWhile (== sc) s
|
|
885
|
+
j = i + length run
|
|
886
|
+
rest = drop (length run) s
|
|
887
|
+
in if i > 0 && j < nn then sc : build j rest else run ++ build j rest
|
|
888
|
+
_ -> let (seg, rest) = break (== sc) s in seg ++ build (i + length seg) rest
|
|
889
|
+
its <- listItems arr
|
|
890
|
+
let sarr = length its
|
|
891
|
+
process idx s0v = case s0v of
|
|
892
|
+
VStr s | s /= s_mt ->
|
|
893
|
+
let s1 = if single
|
|
894
|
+
then if url && idx == 0 then stripTrailing s
|
|
895
|
+
else let a = if idx > 0 then stripLeading s else s
|
|
896
|
+
b = if idx < sarr - 1 || not url then stripTrailing a else a
|
|
897
|
+
in collapse b
|
|
898
|
+
else s
|
|
899
|
+
in if s1 /= s_mt then [s1] else []
|
|
900
|
+
_ -> []
|
|
901
|
+
out = concat [process idx s0v | (idx, s0v) <- zip [0 ..] its]
|
|
902
|
+
return (intercalate sepdef out)
|
|
903
|
+
|
|
904
|
+
-- | Join path parts into a normalised URL.
|
|
905
|
+
joinurl :: Value -> IO String
|
|
906
|
+
joinurl arr = join arr (VStr "/") True
|
|
907
|
+
|
|
908
|
+
-- | Substring\/regex replacement over a value's string form.
|
|
909
|
+
replace :: Value -> Value -> Value -> IO String
|
|
910
|
+
replace s from_ to_ = do
|
|
911
|
+
let ts = typify s
|
|
912
|
+
rs <- if (t_string .&. ts) == 0 then stringify s
|
|
913
|
+
else if ((t_noval .|. t_null) .&. ts) > 0 then return s_mt
|
|
914
|
+
else stringify s
|
|
915
|
+
to_s <- case to_ of VStr x -> return x; _ -> jsString to_
|
|
916
|
+
case from_ of
|
|
917
|
+
VStr f | f /= "" -> return (replaceAll rs f to_s)
|
|
918
|
+
_ -> return rs
|
|
919
|
+
|
|
920
|
+
-- | Render a path value as a dotted string, with an absent-path marker option.
|
|
921
|
+
pathifyFull :: Value -> Value -> Value -> Bool -> IO String
|
|
922
|
+
pathifyFull v startin endin absent = do
|
|
923
|
+
mpath <- if islist v then Just <$> listItems v
|
|
924
|
+
else return (if iskey v then Just [v] else Nothing)
|
|
925
|
+
let start = case startin of VNum n -> if n > -1 then truncate n else 0; _ -> 0
|
|
926
|
+
endn = case endin of VNum n -> if n > -1 then truncate n else 0; _ -> 0
|
|
927
|
+
pstr <- case mpath of
|
|
928
|
+
Just p | start >= 0 -> do
|
|
929
|
+
let len = length p
|
|
930
|
+
e = max 0 (len - endn)
|
|
931
|
+
s = min start len
|
|
932
|
+
sub = if s <= e then take (e - s) (drop s p) else []
|
|
933
|
+
if null sub then return (Just "<root>")
|
|
934
|
+
else do
|
|
935
|
+
let fp = L.filter iskey sub
|
|
936
|
+
mapped = map (\pp -> case pp of
|
|
937
|
+
VNum n -> floorNumStr n
|
|
938
|
+
VStr x -> L.filter (/= '.') x
|
|
939
|
+
_ -> "") fp
|
|
940
|
+
return (Just (intercalate "." mapped))
|
|
941
|
+
_ -> return Nothing
|
|
942
|
+
case pstr of
|
|
943
|
+
Just s -> return s
|
|
944
|
+
Nothing -> do
|
|
945
|
+
tl <- if absent then return s_mt else do st <- stringifyMax v (VNum 47); return (s_cn ++ st)
|
|
946
|
+
return ("<unknown-path" ++ tl ++ ">")
|
|
947
|
+
|
|
948
|
+
-- | Render a path value as a human-readable dotted string.
|
|
949
|
+
pathify :: Value -> IO String
|
|
950
|
+
pathify v = pathifyFull v VNoval VNoval False
|
|
951
|
+
|
|
952
|
+
-- ---------------------------------------------------------------------------
|
|
953
|
+
-- walk / merge
|
|
954
|
+
-- ---------------------------------------------------------------------------
|
|
955
|
+
|
|
956
|
+
-- | A 'walk' callback: key, value, parent and path to a replacement value.
|
|
957
|
+
type WalkFn = Value -> Value -> Value -> Value -> IO Value
|
|
958
|
+
|
|
959
|
+
-- | Depth-first walk applying optional before\/after transforms at each node.
|
|
960
|
+
walk :: Maybe WalkFn -> Maybe WalkFn -> Value -> Value -> IO Value
|
|
961
|
+
walk before after md v = walkImpl before after md VNoval VNoval Nothing v
|
|
962
|
+
|
|
963
|
+
-- | Recursive worker behind 'walk' (carries parent, path and depth).
|
|
964
|
+
walkImpl :: Maybe WalkFn -> Maybe WalkFn -> Value -> Value -> Value -> Maybe Value -> Value -> IO Value
|
|
965
|
+
walkImpl before after md key parent mpath v = do
|
|
966
|
+
path <- maybe emptyList return mpath
|
|
967
|
+
depth <- size path
|
|
968
|
+
out0 <- case before of Nothing -> return v; Just f -> f key v parent path
|
|
969
|
+
let mdv = case md of VNum n -> if n >= 0 then truncate n else maxdepth; _ -> maxdepth
|
|
970
|
+
if mdv == 0 || (mdv > 0 && mdv <= depth)
|
|
971
|
+
then return out0
|
|
972
|
+
else do
|
|
973
|
+
when (isnode out0) $ do
|
|
974
|
+
prefix <- listItems path
|
|
975
|
+
ps <- itemsPairs out0
|
|
976
|
+
forM_ ps $ \(ckey, child) -> do
|
|
977
|
+
childpath <- mkList (prefix ++ [VStr ckey])
|
|
978
|
+
result <- walkImpl before after (VNum (fromIntegral mdv)) (VStr ckey) out0 (Just childpath) child
|
|
979
|
+
case out0 of
|
|
980
|
+
VMap m -> modifyIORef' m (opPut ckey result)
|
|
981
|
+
VList r -> modifyIORef' r (\xs -> [if i == (read ckey :: Int) then result else x | (i, x) <- zip [0 :: Int ..] xs])
|
|
982
|
+
_ -> return ()
|
|
983
|
+
case after of Nothing -> return out0; Just f -> f key out0 parent path
|
|
984
|
+
|
|
985
|
+
-- | Deep-merge the source node into the destination in place.
|
|
986
|
+
mergeD :: Value -> Value -> IO Value
|
|
987
|
+
mergeD objs maxd = do
|
|
988
|
+
let md = case maxd of VNum n -> if n < 0 then 0 else truncate n; _ -> 32
|
|
989
|
+
if not (islist objs) then return objs
|
|
990
|
+
else do
|
|
991
|
+
l <- listItems objs
|
|
992
|
+
let lenlist = length l
|
|
993
|
+
if lenlist == 0 then return VNoval
|
|
994
|
+
else if lenlist == 1 then return (head l)
|
|
995
|
+
else do
|
|
996
|
+
out0 <- do em <- emptyMap; getpropAlt em objs (VNum 0)
|
|
997
|
+
outRef <- newIORef out0
|
|
998
|
+
forM_ [1 .. lenlist - 1] $ \oi -> do
|
|
999
|
+
let obj = l !! oi
|
|
1000
|
+
if not (isnode obj) then writeIORef outRef obj
|
|
1001
|
+
else do
|
|
1002
|
+
o <- readIORef outRef
|
|
1003
|
+
cur <- newIORef [o]
|
|
1004
|
+
dst <- newIORef [o]
|
|
1005
|
+
let grow ref nn = do a <- readIORef ref; when (length a <= nn) (writeIORef ref (a ++ replicate (nn + 1 - length a) VNoval))
|
|
1006
|
+
before key vv _parent path = do
|
|
1007
|
+
pii <- size path
|
|
1008
|
+
if md <= pii then do
|
|
1009
|
+
grow cur pii
|
|
1010
|
+
modifyIORef' cur (setAt pii vv)
|
|
1011
|
+
when (pii > 0) $ do c <- readIORef cur; _ <- setprop (c !! (pii - 1)) key vv; return ()
|
|
1012
|
+
return VNoval
|
|
1013
|
+
else if not (isnode vv) then do
|
|
1014
|
+
grow cur pii; modifyIORef' cur (setAt pii vv); return vv
|
|
1015
|
+
else do
|
|
1016
|
+
grow dst pii; grow cur pii
|
|
1017
|
+
dpi <- if pii > 0 then do d <- readIORef dst; getprop (d !! (pii - 1)) key
|
|
1018
|
+
else do d <- readIORef dst; return (d !! pii)
|
|
1019
|
+
modifyIORef' dst (setAt pii dpi)
|
|
1020
|
+
let tval = dpi
|
|
1021
|
+
if isNullish tval then do
|
|
1022
|
+
nn <- if islist vv then emptyList else emptyMap
|
|
1023
|
+
modifyIORef' cur (setAt pii nn); return vv
|
|
1024
|
+
else if (islist vv && islist tval) || (ismap vv && ismap tval) then do
|
|
1025
|
+
modifyIORef' cur (setAt pii tval); return vv
|
|
1026
|
+
else do
|
|
1027
|
+
modifyIORef' cur (setAt pii vv); return VNoval
|
|
1028
|
+
after key vv _parent path = do
|
|
1029
|
+
ci <- size path
|
|
1030
|
+
if ci < 1 then do c <- readIORef cur; return (if not (null c) then head c else vv)
|
|
1031
|
+
else do
|
|
1032
|
+
c <- readIORef cur
|
|
1033
|
+
let target = if ci - 1 < length c then c !! (ci - 1) else VNoval
|
|
1034
|
+
value = if ci < length c then c !! ci else VNoval
|
|
1035
|
+
_ <- setprop target key value
|
|
1036
|
+
return value
|
|
1037
|
+
res <- walk (Just before) (Just after) VNoval obj
|
|
1038
|
+
writeIORef outRef res
|
|
1039
|
+
when (md == 0) $ do
|
|
1040
|
+
o <- getprop objs (VNum (fromIntegral (lenlist - 1)))
|
|
1041
|
+
nn <- if islist o then emptyList else if ismap o then emptyMap else return o
|
|
1042
|
+
writeIORef outRef nn
|
|
1043
|
+
readIORef outRef
|
|
1044
|
+
|
|
1045
|
+
-- | Deep-merge a list of nodes left-to-right (later values win); returns the merged node.
|
|
1046
|
+
merge :: Value -> IO Value
|
|
1047
|
+
merge objs = mergeD objs VNoval
|
|
1048
|
+
|
|
1049
|
+
-- ---------------------------------------------------------------------------
|
|
1050
|
+
-- getpath / setpath
|
|
1051
|
+
-- ---------------------------------------------------------------------------
|
|
1052
|
+
|
|
1053
|
+
-- | Accessors reading the @base@\/@dparent@\/@meta@\/@key@\/@dpath@ fields out of an 'InjArg'.
|
|
1054
|
+
iaBase, iaDparent, iaMeta, iaKey, iaDpath :: InjArg -> IO Value
|
|
1055
|
+
iaBase ia = case ia of IInj i -> readIORef (iBase i); IDef d -> return (dBase d); INone -> return VNoval
|
|
1056
|
+
iaDparent ia = case ia of IInj i -> readIORef (iDparent i); IDef d -> return (dDparent d); INone -> return VNoval
|
|
1057
|
+
iaMeta ia = case ia of IInj i -> readIORef (iMeta i); IDef d -> return (dMeta d); INone -> return VNoval
|
|
1058
|
+
iaKey ia = case ia of IInj i -> readIORef (iKey i); IDef d -> return (dKey d); INone -> return VNoval
|
|
1059
|
+
iaDpath ia = case ia of IInj i -> readIORef (iDpath i); IDef d -> return (dDpath d); INone -> return VNoval
|
|
1060
|
+
|
|
1061
|
+
-- | The custom injector handler carried by an 'InjArg', if any.
|
|
1062
|
+
iaHandler :: InjArg -> IO (Maybe Injector)
|
|
1063
|
+
iaHandler ia = case ia of IInj i -> Just <$> readIORef (iHandler i); IDef d -> return (dHandler d); INone -> return Nothing
|
|
1064
|
+
|
|
1065
|
+
-- | True unless the 'InjArg' is 'INone'.
|
|
1066
|
+
iaIsSome :: InjArg -> Bool
|
|
1067
|
+
iaIsSome INone = False
|
|
1068
|
+
iaIsSome _ = True
|
|
1069
|
+
|
|
1070
|
+
-- | Split a @meta$...@ style string into its @(prefix, name, suffix)@ parts.
|
|
1071
|
+
metaPathMatch :: String -> Maybe (String, String, String)
|
|
1072
|
+
metaPathMatch s = case break (== '$') s of
|
|
1073
|
+
(pre, '$':rest) | not (null pre) ->
|
|
1074
|
+
case rest of
|
|
1075
|
+
(op:after) | (op == '=' || op == '~') && not (null after) -> Just (pre, [op], after)
|
|
1076
|
+
_ -> Nothing
|
|
1077
|
+
_ -> Nothing
|
|
1078
|
+
|
|
1079
|
+
-- | Resolve a dotted\/list path against a store; the by-example @\`$...\`@ path reader.
|
|
1080
|
+
getpath :: InjArg -> Value -> Value -> IO Value
|
|
1081
|
+
getpath inj store path = do
|
|
1082
|
+
mpa <- case path of
|
|
1083
|
+
VList r -> Just <$> readIORef r
|
|
1084
|
+
VStr s -> return (Just (map VStr (splitOn '.' s)))
|
|
1085
|
+
VNum n -> return (Just [VStr (strkey (VNum n))])
|
|
1086
|
+
_ -> return Nothing
|
|
1087
|
+
case mpa of
|
|
1088
|
+
Nothing -> return VNoval
|
|
1089
|
+
Just pa0 -> do
|
|
1090
|
+
base <- iaBase inj
|
|
1091
|
+
dparent <- iaDparent inj
|
|
1092
|
+
injMeta <- iaMeta inj
|
|
1093
|
+
injKey <- iaKey inj
|
|
1094
|
+
dpath <- iaDpath inj
|
|
1095
|
+
src <- if iskey base then getpropAlt store store base else return store
|
|
1096
|
+
let numparts = length pa0
|
|
1097
|
+
paRef <- newIORef pa0
|
|
1098
|
+
vRef <- newIORef store
|
|
1099
|
+
let arrGet i = do pa <- readIORef paRef; return (if i >= 0 && i < length pa then pa !! i else VNoval)
|
|
1100
|
+
p0init <- arrGet 0
|
|
1101
|
+
if isNoval path || isNoval store || (numparts == 1 && vStrEq p0init s_mt) || numparts == 0
|
|
1102
|
+
then writeIORef vRef src
|
|
1103
|
+
else do
|
|
1104
|
+
when (numparts == 1) $ do p0 <- arrGet 0; gv <- getprop store p0; writeIORef vRef gv
|
|
1105
|
+
vcur <- readIORef vRef
|
|
1106
|
+
if isfunc vcur then return ()
|
|
1107
|
+
else do
|
|
1108
|
+
writeIORef vRef src
|
|
1109
|
+
p0 <- arrGet 0
|
|
1110
|
+
case p0 of
|
|
1111
|
+
VStr s0 -> case metaPathMatch s0 of
|
|
1112
|
+
Just (g1, _, g3) | not (isNoval injMeta) && iaIsSome inj -> do
|
|
1113
|
+
mv <- getprop injMeta (VStr g1); writeIORef vRef mv
|
|
1114
|
+
modifyIORef' paRef (setAt 0 (VStr g3))
|
|
1115
|
+
_ -> return ()
|
|
1116
|
+
_ -> return ()
|
|
1117
|
+
let countAsc p acc = do nxt <- arrGet (p + 1); if vStrEq nxt s_mt then countAsc (p + 1) (acc + 1) else return (acc, p)
|
|
1118
|
+
loop pii = do
|
|
1119
|
+
vc <- readIORef vRef
|
|
1120
|
+
if isNoval vc || pii >= numparts then return ()
|
|
1121
|
+
else do
|
|
1122
|
+
raw <- arrGet pii
|
|
1123
|
+
part0 <- case raw of
|
|
1124
|
+
VStr s | iaIsSome inj && s == s_dkey -> return (if not (isNoval injKey) then injKey else raw)
|
|
1125
|
+
VStr s | "$GET:" `isPrefixOf` s -> do sl <- sliceM (VStr s) (VNum 5) (VNum (-1)) False; gp <- getpath INone src sl; VStr <$> stringify gp
|
|
1126
|
+
VStr s | "$REF:" `isPrefixOf` s -> do sl <- sliceM (VStr s) (VNum 5) (VNum (-1)) False; sp <- getprop store (VStr s_dspec); gp <- getpath INone sp sl; VStr <$> stringify gp
|
|
1127
|
+
VStr s | iaIsSome inj && "$META:" `isPrefixOf` s -> do sl <- sliceM (VStr s) (VNum 6) (VNum (-1)) False; gp <- getpath INone injMeta sl; VStr <$> stringify gp
|
|
1128
|
+
_ -> return raw
|
|
1129
|
+
let part = case part0 of VStr s -> VStr (replaceAll s "$$" "$"); _ -> VStr (strkey part0)
|
|
1130
|
+
if vStrEq part s_mt then do
|
|
1131
|
+
(ascends0, pii2) <- countAsc pii 0
|
|
1132
|
+
if iaIsSome inj && ascends0 > 0 then do
|
|
1133
|
+
let ascends = if pii2 == numparts - 1 then ascends0 - 1 else ascends0
|
|
1134
|
+
if ascends == 0 then do writeIORef vRef dparent; loop (pii2 + 1)
|
|
1135
|
+
else do
|
|
1136
|
+
pa2 <- readIORef paRef
|
|
1137
|
+
let tailparts = drop (pii2 + 1) pa2
|
|
1138
|
+
sl <- sliceM dpath (VNum (fromIntegral (negate ascends))) VNoval False
|
|
1139
|
+
tl <- mkList tailparts
|
|
1140
|
+
inner <- mkList [sl, tl]
|
|
1141
|
+
fullpath <- flatten 1 inner
|
|
1142
|
+
dsz <- size dpath
|
|
1143
|
+
if ascends <= dsz then do gp <- getpath INone store fullpath; writeIORef vRef gp
|
|
1144
|
+
else writeIORef vRef VNoval
|
|
1145
|
+
else do writeIORef vRef dparent; loop (pii2 + 1)
|
|
1146
|
+
else do
|
|
1147
|
+
gp <- getprop vc part; writeIORef vRef gp; loop (pii + 1)
|
|
1148
|
+
loop 0
|
|
1149
|
+
mh <- iaHandler inj
|
|
1150
|
+
case mh of
|
|
1151
|
+
Just h | iaIsSome inj -> do
|
|
1152
|
+
refp <- pathify path
|
|
1153
|
+
vc <- readIORef vRef
|
|
1154
|
+
case inj of
|
|
1155
|
+
IInj i -> do r <- h i vc refp store; writeIORef vRef r
|
|
1156
|
+
_ -> do r <- h dummyInj vc refp store; writeIORef vRef r
|
|
1157
|
+
_ -> return ()
|
|
1158
|
+
readIORef vRef
|
|
1159
|
+
|
|
1160
|
+
-- | Set the value at a path within a node, creating intermediate nodes as needed.
|
|
1161
|
+
setpath :: Value -> Value -> Value -> IO Value
|
|
1162
|
+
setpath store path v = do
|
|
1163
|
+
let ptype = typify path
|
|
1164
|
+
parts <- if (t_list .&. ptype) > 0 then (listItems path >>= mkList)
|
|
1165
|
+
else if (t_string .&. ptype) > 0 then (case path of VStr s -> mkList (map VStr (splitOn '.' s)); _ -> emptyList)
|
|
1166
|
+
else if (t_number .&. ptype) > 0 then mkList [path]
|
|
1167
|
+
else return VNoval
|
|
1168
|
+
if isNoval parts then return VNoval
|
|
1169
|
+
else do
|
|
1170
|
+
numparts <- size parts
|
|
1171
|
+
parentRef <- newIORef store
|
|
1172
|
+
forM_ [0 .. numparts - 2] $ \pii -> do
|
|
1173
|
+
parent <- readIORef parentRef
|
|
1174
|
+
pkey <- getelem parts (VNum (fromIntegral pii))
|
|
1175
|
+
np0 <- getprop parent pkey
|
|
1176
|
+
np <- if not (isnode np0) then do
|
|
1177
|
+
nextpart <- getelem parts (VNum (fromIntegral (pii + 1)))
|
|
1178
|
+
nn <- if (t_number .&. typify nextpart) > 0 then emptyList else emptyMap
|
|
1179
|
+
_ <- setprop parent pkey nn; return nn
|
|
1180
|
+
else return np0
|
|
1181
|
+
writeIORef parentRef np
|
|
1182
|
+
parent <- readIORef parentRef
|
|
1183
|
+
lastkey <- getelem parts (VNum (-1))
|
|
1184
|
+
if is_delete v then delprop parent lastkey >> return parent
|
|
1185
|
+
else setprop parent lastkey v >> return parent
|
|
1186
|
+
|
|
1187
|
+
-- ---------------------------------------------------------------------------
|
|
1188
|
+
-- string-pattern helpers (RE2-subset-free)
|
|
1189
|
+
-- ---------------------------------------------------------------------------
|
|
1190
|
+
|
|
1191
|
+
-- | Recognise a whole-string @\`...\`@ injection and return its inner expression.
|
|
1192
|
+
injectionFull :: String -> Maybe String
|
|
1193
|
+
injectionFull s =
|
|
1194
|
+
let n = length s
|
|
1195
|
+
in if n >= 2 && head s == '`' && last s == '`'
|
|
1196
|
+
then let inner = take (n - 2) (drop 1 s)
|
|
1197
|
+
in if '`' `elem` inner then Nothing
|
|
1198
|
+
else if isDollarUpper inner then Just (takeDollarName inner) else Just inner
|
|
1199
|
+
else Nothing
|
|
1200
|
+
where
|
|
1201
|
+
upper c = c >= 'A' && c <= 'Z'
|
|
1202
|
+
digit c = c >= '0' && c <= '9'
|
|
1203
|
+
lengthLetters str j = if j < length str && upper (str !! j) then lengthLetters str (j + 1) else j
|
|
1204
|
+
lettersDigits str k = if k < length str && digit (str !! k) then lettersDigits str (k + 1) else k
|
|
1205
|
+
isDollarUpper inner =
|
|
1206
|
+
length inner > 1 && head inner == '$' &&
|
|
1207
|
+
let le = lengthLetters inner 1
|
|
1208
|
+
in le > 1 && lettersDigits inner le == length inner
|
|
1209
|
+
takeDollarName inner = take (lengthLetters inner 1) inner
|
|
1210
|
+
|
|
1211
|
+
-- | Replace each @\`...\`@ backtick injection inside a string via the given expander.
|
|
1212
|
+
injectionPartialReplace :: String -> (String -> IO String) -> IO String
|
|
1213
|
+
injectionPartialReplace s f = go s
|
|
1214
|
+
where
|
|
1215
|
+
go [] = return []
|
|
1216
|
+
go ('`':rest) = case break (== '`') rest of
|
|
1217
|
+
(inner, '`':rest2) -> do r <- f inner; rs <- go rest2; return (r ++ rs)
|
|
1218
|
+
-- no closing backtick: break's second element is empty here, so emit the
|
|
1219
|
+
-- literal '`' and carry on. A catch-all (not `(_, [])`) keeps GHC's
|
|
1220
|
+
-- exhaustiveness checker happy since it can't prove the suffix is empty.
|
|
1221
|
+
_ -> do rs <- go rest; return ('`' : rs)
|
|
1222
|
+
go (c:rest) = (c :) <$> go rest
|
|
1223
|
+
|
|
1224
|
+
-- | Rewrite @$NAME@ transform directives to their canonical spellings.
|
|
1225
|
+
replaceTransformNames :: String -> String
|
|
1226
|
+
replaceTransformNames = go
|
|
1227
|
+
where
|
|
1228
|
+
upper c = c >= 'A' && c <= 'Z'
|
|
1229
|
+
go [] = []
|
|
1230
|
+
go ('`':'$':rest) =
|
|
1231
|
+
let (letters, rest2) = span upper rest
|
|
1232
|
+
in case rest2 of
|
|
1233
|
+
('`':rest3) | not (null letters) -> map toLower letters ++ go rest3
|
|
1234
|
+
_ -> '`' : go ('$':rest)
|
|
1235
|
+
go (c:rest) = c : go rest
|
|
1236
|
+
|
|
1237
|
+
-- ---------------------------------------------------------------------------
|
|
1238
|
+
-- Injection state
|
|
1239
|
+
-- ---------------------------------------------------------------------------
|
|
1240
|
+
|
|
1241
|
+
-- | Create a fresh injection state ('Inj') for a value and store.
|
|
1242
|
+
newInj :: Value -> Value -> IO Inj
|
|
1243
|
+
newInj v parent = do
|
|
1244
|
+
keys <- mkList [VStr s_dtop]
|
|
1245
|
+
path <- mkList [VStr s_dtop]
|
|
1246
|
+
nodes <- mkList [parent]
|
|
1247
|
+
errs <- emptyList
|
|
1248
|
+
meta <- emptyMap
|
|
1249
|
+
dpath <- mkList [VStr s_dtop]
|
|
1250
|
+
Inj <$> newIORef m_val <*> newIORef False <*> newIORef 0
|
|
1251
|
+
<*> newIORef keys <*> newIORef (VStr s_dtop) <*> newIORef v
|
|
1252
|
+
<*> newIORef parent <*> newIORef path <*> newIORef nodes
|
|
1253
|
+
<*> newIORef injectHandler <*> newIORef errs <*> newIORef meta
|
|
1254
|
+
<*> newIORef VNoval <*> newIORef dpath <*> newIORef (VStr s_dtop)
|
|
1255
|
+
<*> newIORef Nothing <*> newIORef Nothing <*> newIORef VNoval
|
|
1256
|
+
|
|
1257
|
+
-- | Recurse the injection engine into a node's children.
|
|
1258
|
+
injDescend :: Inj -> IO Value
|
|
1259
|
+
injDescend inj = do
|
|
1260
|
+
meta <- readIORef (iMeta inj)
|
|
1261
|
+
case meta of
|
|
1262
|
+
VMap _ -> do
|
|
1263
|
+
d <- getpropRaw meta "__d"
|
|
1264
|
+
let dn = case d of VNum n -> n; _ -> 0
|
|
1265
|
+
_ <- setprop meta (VStr "__d") (VNum (dn + 1)); return ()
|
|
1266
|
+
_ -> return ()
|
|
1267
|
+
path <- readIORef (iPath inj)
|
|
1268
|
+
parentkey <- getelem path (VNum (-2))
|
|
1269
|
+
dparent <- readIORef (iDparent inj)
|
|
1270
|
+
if isNoval dparent then do
|
|
1271
|
+
dpath <- readIORef (iDpath inj)
|
|
1272
|
+
sz <- size dpath
|
|
1273
|
+
when (sz > 1) $ do its <- listItems dpath; nl <- mkList (its ++ [parentkey]); writeIORef (iDpath inj) nl
|
|
1274
|
+
else when (not (isNoval parentkey)) $ do
|
|
1275
|
+
dp <- getprop dparent parentkey; writeIORef (iDparent inj) dp
|
|
1276
|
+
dpath <- readIORef (iDpath inj)
|
|
1277
|
+
lastpart <- getelem dpath (VNum (-1))
|
|
1278
|
+
pk <- jsString parentkey
|
|
1279
|
+
if vStrEq lastpart ("$:" ++ pk)
|
|
1280
|
+
then do sl <- sliceM dpath (VNum (-1)) VNoval False; writeIORef (iDpath inj) sl
|
|
1281
|
+
else do its <- listItems dpath; nl <- mkList (its ++ [parentkey]); writeIORef (iDpath inj) nl
|
|
1282
|
+
readIORef (iDparent inj)
|
|
1283
|
+
|
|
1284
|
+
-- | Derive the child injection state for one entry of a node.
|
|
1285
|
+
injChild :: Inj -> Int -> Value -> IO Inj
|
|
1286
|
+
injChild inj keyi keys = do
|
|
1287
|
+
kv <- getelem keys (VNum (fromIntegral keyi))
|
|
1288
|
+
let key = strkey kv
|
|
1289
|
+
v <- readIORef (iIval inj)
|
|
1290
|
+
ival <- getprop v (VStr key)
|
|
1291
|
+
ipath <- readIORef (iPath inj); pitems <- listItems ipath; npath <- mkList (pitems ++ [VStr key])
|
|
1292
|
+
inodes <- readIORef (iNodes inj); nitems <- listItems inodes; nnodes <- mkList (nitems ++ [v])
|
|
1293
|
+
idpath <- readIORef (iDpath inj); ditems <- listItems idpath; ndpath <- mkList ditems
|
|
1294
|
+
mode <- readIORef (iMode inj); full <- readIORef (iFull inj); handler <- readIORef (iHandler inj)
|
|
1295
|
+
errs <- readIORef (iErrs inj); meta <- readIORef (iMeta inj); base <- readIORef (iBase inj)
|
|
1296
|
+
modify <- readIORef (iModify inj); dparent <- readIORef (iDparent inj); extra <- readIORef (iExtra inj)
|
|
1297
|
+
Inj <$> newIORef mode <*> newIORef full <*> newIORef keyi
|
|
1298
|
+
<*> newIORef keys <*> newIORef (VStr key) <*> newIORef ival
|
|
1299
|
+
<*> newIORef v <*> newIORef npath <*> newIORef nnodes
|
|
1300
|
+
<*> newIORef handler <*> newIORef errs <*> newIORef meta
|
|
1301
|
+
<*> newIORef dparent <*> newIORef ndpath <*> newIORef base
|
|
1302
|
+
<*> newIORef modify <*> newIORef (Just inj) <*> newIORef extra
|
|
1303
|
+
|
|
1304
|
+
-- | Write a value into an ancestor of the current injection target.
|
|
1305
|
+
injSetval :: Int -> Inj -> Value -> IO Value
|
|
1306
|
+
injSetval ancestor inj v = do
|
|
1307
|
+
(target, key) <- if ancestor < 2
|
|
1308
|
+
then do p <- readIORef (iParent inj); k <- readIORef (iKey inj); return (p, k)
|
|
1309
|
+
else do ns <- readIORef (iNodes inj); ps <- readIORef (iPath inj)
|
|
1310
|
+
t <- getelem ns (VNum (fromIntegral (negate ancestor)))
|
|
1311
|
+
k <- getelem ps (VNum (fromIntegral (negate ancestor)))
|
|
1312
|
+
return (t, k)
|
|
1313
|
+
if isNoval v then delprop target key else setprop target key v
|
|
1314
|
+
|
|
1315
|
+
-- | Write a value into the immediate parent of the injection target.
|
|
1316
|
+
injSetval1 :: Inj -> Value -> IO Value
|
|
1317
|
+
injSetval1 = injSetval 1
|
|
1318
|
+
|
|
1319
|
+
-- | Placeholder 'Inj' for the two corpus-unreached paths that need one (built with 'unsafePerformIO'; do not rely on its state).
|
|
1320
|
+
dummyInj :: Inj
|
|
1321
|
+
dummyInj = unsafePerformIO $ do
|
|
1322
|
+
parent <- mkMap [(s_dtop, VNoval)]
|
|
1323
|
+
newInj VNoval parent
|
|
1324
|
+
{-# NOINLINE dummyInj #-}
|
|
1325
|
+
|
|
1326
|
+
-- ---------------------------------------------------------------------------
|
|
1327
|
+
-- inject
|
|
1328
|
+
-- ---------------------------------------------------------------------------
|
|
1329
|
+
|
|
1330
|
+
-- | Run the injection engine: expand @\`...\`@ references in a spec against a store.
|
|
1331
|
+
inject :: InjArg -> Value -> Value -> IO Value
|
|
1332
|
+
inject injarg v store = do
|
|
1333
|
+
state <- case injarg of
|
|
1334
|
+
IInj i -> return i
|
|
1335
|
+
_ -> do
|
|
1336
|
+
parent <- mkMap [(s_dtop, v)]
|
|
1337
|
+
i <- newInj v parent
|
|
1338
|
+
writeIORef (iDparent i) store
|
|
1339
|
+
el <- emptyList
|
|
1340
|
+
errs <- getpropAlt el store (VStr s_derrs)
|
|
1341
|
+
writeIORef (iErrs i) errs
|
|
1342
|
+
meta <- readIORef (iMeta i)
|
|
1343
|
+
case meta of VMap _ -> setprop meta (VStr "__d") (VNum 0) >> return (); _ -> return ()
|
|
1344
|
+
case injarg of
|
|
1345
|
+
IDef d -> do
|
|
1346
|
+
case dModify d of Just _ -> writeIORef (iModify i) (dModify d); Nothing -> return ()
|
|
1347
|
+
when (not (isNoval (dExtra d))) $ writeIORef (iExtra i) (dExtra d)
|
|
1348
|
+
when (not (isNoval (dMeta d))) $ writeIORef (iMeta i) (dMeta d)
|
|
1349
|
+
case dHandler d of Just h -> writeIORef (iHandler i) h; Nothing -> return ()
|
|
1350
|
+
_ -> return ()
|
|
1351
|
+
return i
|
|
1352
|
+
_ <- injDescend state
|
|
1353
|
+
v' <- if isnode v then do
|
|
1354
|
+
nodekeys0 <- case v of
|
|
1355
|
+
VMap m -> do es <- readIORef m
|
|
1356
|
+
let ks = map fst es
|
|
1357
|
+
normal = sort (L.filter (notElem '$') ks)
|
|
1358
|
+
trans = sort (L.filter (elem '$') ks)
|
|
1359
|
+
return (normal ++ trans)
|
|
1360
|
+
VList r -> do its <- readIORef r; return [show i | i <- [0 .. length its - 1]]
|
|
1361
|
+
_ -> return []
|
|
1362
|
+
nkRef <- newIORef nodekeys0
|
|
1363
|
+
nkiRef <- newIORef 0
|
|
1364
|
+
let loop = do
|
|
1365
|
+
nki <- readIORef nkiRef
|
|
1366
|
+
nks <- readIORef nkRef
|
|
1367
|
+
if nki >= length nks then return ()
|
|
1368
|
+
else do
|
|
1369
|
+
keysv <- mkList (map VStr nks)
|
|
1370
|
+
childinj <- injChild state nki keysv
|
|
1371
|
+
nodekeyV <- readIORef (iKey childinj)
|
|
1372
|
+
writeIORef (iMode childinj) m_keypre
|
|
1373
|
+
nkstr <- jsString nodekeyV
|
|
1374
|
+
prekey <- injectstr nkstr store (Just childinj)
|
|
1375
|
+
ck <- readIORef (iKeys childinj); ckl <- listItems ck; ckls <- mapM jsString ckl
|
|
1376
|
+
writeIORef nkRef ckls
|
|
1377
|
+
when (not (isNoval prekey)) $ do
|
|
1378
|
+
iv <- getprop v prekey
|
|
1379
|
+
writeIORef (iIval childinj) iv
|
|
1380
|
+
writeIORef (iMode childinj) m_val
|
|
1381
|
+
_ <- inject (IInj childinj) iv store
|
|
1382
|
+
ck2 <- readIORef (iKeys childinj); ckl2 <- listItems ck2; ckls2 <- mapM jsString ckl2
|
|
1383
|
+
writeIORef nkRef ckls2
|
|
1384
|
+
writeIORef (iMode childinj) m_keypost
|
|
1385
|
+
_ <- injectstr nkstr store (Just childinj)
|
|
1386
|
+
ck3 <- readIORef (iKeys childinj); ckl3 <- listItems ck3; ckls3 <- mapM jsString ckl3
|
|
1387
|
+
writeIORef nkRef ckls3
|
|
1388
|
+
cki <- readIORef (iKeyi childinj)
|
|
1389
|
+
writeIORef nkiRef (cki + 1)
|
|
1390
|
+
loop
|
|
1391
|
+
loop
|
|
1392
|
+
return v
|
|
1393
|
+
else case v of
|
|
1394
|
+
VStr _ -> do
|
|
1395
|
+
writeIORef (iMode state) m_val
|
|
1396
|
+
sv <- jsString v
|
|
1397
|
+
nv <- injectstr sv store (Just state)
|
|
1398
|
+
when (not (is_skip nv)) $ injSetval1 state nv >> return ()
|
|
1399
|
+
return nv
|
|
1400
|
+
_ -> return v
|
|
1401
|
+
modify <- readIORef (iModify state)
|
|
1402
|
+
case modify of
|
|
1403
|
+
Just f | not (is_skip v') -> do
|
|
1404
|
+
mkey <- readIORef (iKey state); mparent <- readIORef (iParent state); mval <- getprop mparent mkey
|
|
1405
|
+
f mval mkey mparent state
|
|
1406
|
+
_ -> return ()
|
|
1407
|
+
writeIORef (iIval state) v'
|
|
1408
|
+
parentS <- readIORef (iParent state)
|
|
1409
|
+
lookup_ parentS (VStr s_dtop)
|
|
1410
|
+
|
|
1411
|
+
-- | Default injector handler dispatching @$@ directives during injection.
|
|
1412
|
+
injectHandler :: Injector
|
|
1413
|
+
injectHandler inj v refstr store = do
|
|
1414
|
+
let iscmd = isfunc v && (refstr == "" || s_ds `isPrefixOf` refstr)
|
|
1415
|
+
if iscmd then case v of VFunc f -> f inj v refstr store; _ -> return v
|
|
1416
|
+
else do
|
|
1417
|
+
mode <- readIORef (iMode inj); full <- readIORef (iFull inj)
|
|
1418
|
+
if mode == m_val && full then do _ <- injSetval1 inj v; return v else return v
|
|
1419
|
+
|
|
1420
|
+
-- | Expand the injections within a single string.
|
|
1421
|
+
injectstr :: String -> Value -> Maybe Inj -> IO Value
|
|
1422
|
+
injectstr v store injOpt =
|
|
1423
|
+
if v == s_mt then return (VStr s_mt)
|
|
1424
|
+
else case injectionFull v of
|
|
1425
|
+
Just pathref0 -> do
|
|
1426
|
+
case injOpt of Just i -> writeIORef (iFull i) True; Nothing -> return ()
|
|
1427
|
+
let pathref = if length pathref0 > 3 then replaceAll (replaceAll pathref0 "$BT" s_bt) "$DS" s_ds else pathref0
|
|
1428
|
+
ia = case injOpt of Just i -> IInj i; Nothing -> INone
|
|
1429
|
+
getpath ia store (VStr pathref)
|
|
1430
|
+
Nothing -> do
|
|
1431
|
+
out <- injectionPartialReplace v $ \ref0 -> do
|
|
1432
|
+
let refp = if length ref0 > 3 then replaceAll (replaceAll ref0 "$BT" s_bt) "$DS" s_ds else ref0
|
|
1433
|
+
case injOpt of Just i -> writeIORef (iFull i) False; Nothing -> return ()
|
|
1434
|
+
let ia = case injOpt of Just i -> IInj i; Nothing -> INone
|
|
1435
|
+
found <- getpath ia store (VStr refp)
|
|
1436
|
+
case found of
|
|
1437
|
+
VNoval -> return s_mt
|
|
1438
|
+
VStr s -> return (if s == "__NULL__" then "null" else s)
|
|
1439
|
+
VFunc _ -> return s_mt
|
|
1440
|
+
_ -> jsonEncode False Nothing found
|
|
1441
|
+
case injOpt of
|
|
1442
|
+
Just i -> do writeIORef (iFull i) True; h <- readIORef (iHandler i); h i (VStr out) v store
|
|
1443
|
+
Nothing -> return (VStr out)
|
|
1444
|
+
|
|
1445
|
+
-- ---------------------------------------------------------------------------
|
|
1446
|
+
-- transform commands
|
|
1447
|
+
-- ---------------------------------------------------------------------------
|
|
1448
|
+
|
|
1449
|
+
-- | @$DELETE@ transform: remove the target key.
|
|
1450
|
+
transformDelete :: Injector
|
|
1451
|
+
transformDelete inj _ _ _ = do p <- readIORef (iParent inj); k <- readIORef (iKey inj); _ <- delprop p k; return VNoval
|
|
1452
|
+
|
|
1453
|
+
-- | @$COPY@ transform: copy the same-named value from the data.
|
|
1454
|
+
transformCopy :: Injector
|
|
1455
|
+
transformCopy inj _ _ _ = do
|
|
1456
|
+
mode <- readIORef (iMode inj)
|
|
1457
|
+
if mode == m_keypre || mode == m_keypost then readIORef (iKey inj)
|
|
1458
|
+
else do dp <- readIORef (iDparent inj); k <- readIORef (iKey inj); out <- lookup_ dp k; _ <- injSetval1 inj out; return out
|
|
1459
|
+
|
|
1460
|
+
-- | @$KEY@ transform: inject the current key.
|
|
1461
|
+
transformKey :: Injector
|
|
1462
|
+
transformKey inj _ _ _ = do
|
|
1463
|
+
mode <- readIORef (iMode inj)
|
|
1464
|
+
if mode /= m_val then return VNoval
|
|
1465
|
+
else do
|
|
1466
|
+
p <- readIORef (iParent inj)
|
|
1467
|
+
keyspec <- lookup_ p (VStr s_bkey)
|
|
1468
|
+
if not (isNoval keyspec) then do _ <- delprop p (VStr s_bkey); dp <- readIORef (iDparent inj); getprop dp keyspec
|
|
1469
|
+
else do
|
|
1470
|
+
anno <- lookup_ p (VStr s_banno)
|
|
1471
|
+
fromanno <- lookup_ anno (VStr s_key)
|
|
1472
|
+
if not (isNoval fromanno) then return fromanno
|
|
1473
|
+
else do pa <- readIORef (iPath inj); getelem pa (VNum (-2))
|
|
1474
|
+
|
|
1475
|
+
-- | @\`$ANNO\`@ annotation transform.
|
|
1476
|
+
transformAnno :: Injector
|
|
1477
|
+
transformAnno inj _ _ _ = do p <- readIORef (iParent inj); _ <- delprop p (VStr s_banno); return VNoval
|
|
1478
|
+
|
|
1479
|
+
-- | @$MERGE@ transform: merge nodes into the target.
|
|
1480
|
+
transformMerge :: Injector
|
|
1481
|
+
transformMerge inj _ _ _ = do
|
|
1482
|
+
mode <- readIORef (iMode inj)
|
|
1483
|
+
if mode == m_keypre then readIORef (iKey inj)
|
|
1484
|
+
else if mode == m_keypost then do
|
|
1485
|
+
p <- readIORef (iParent inj); k <- readIORef (iKey inj)
|
|
1486
|
+
args0 <- getprop p k
|
|
1487
|
+
args <- if islist args0 then return args0 else mkList [args0]
|
|
1488
|
+
_ <- injSetval1 inj VNoval
|
|
1489
|
+
pc <- clone p
|
|
1490
|
+
l1 <- mkList [p]
|
|
1491
|
+
l3 <- mkList [pc]
|
|
1492
|
+
inner <- mkList [l1, args, l3]
|
|
1493
|
+
mergelist <- flatten 1 inner
|
|
1494
|
+
_ <- merge mergelist
|
|
1495
|
+
readIORef (iKey inj)
|
|
1496
|
+
else return VNoval
|
|
1497
|
+
|
|
1498
|
+
-- | @$EACH@ transform: expand a template across a collection.
|
|
1499
|
+
transformEach :: Injector
|
|
1500
|
+
transformEach inj _ _ store = do
|
|
1501
|
+
keys <- readIORef (iKeys inj)
|
|
1502
|
+
when (islist keys) $ do _ <- sliceM keys (VNum 0) (VNum 1) True; return ()
|
|
1503
|
+
mode <- readIORef (iMode inj)
|
|
1504
|
+
if mode /= m_val then return VNoval
|
|
1505
|
+
else do
|
|
1506
|
+
parent <- readIORef (iParent inj)
|
|
1507
|
+
psz <- size parent
|
|
1508
|
+
srcpath <- if psz > 1 then getelem parent (VNum 1) else return VNoval
|
|
1509
|
+
child_tm <- if psz > 2 then do e <- getelem parent (VNum 2); clone e else return VNoval
|
|
1510
|
+
base <- readIORef (iBase inj)
|
|
1511
|
+
srcstore <- getpropAlt store store base
|
|
1512
|
+
src <- getpath (IInj inj) srcstore srcpath
|
|
1513
|
+
path0 <- readIORef (iPath inj)
|
|
1514
|
+
tkey <- getelem path0 (VNum (-2))
|
|
1515
|
+
nodes <- readIORef (iNodes inj)
|
|
1516
|
+
target <- do t <- getelem nodes (VNum (-2)); if isNullish t then getelem nodes (VNum (-1)) else return t
|
|
1517
|
+
rvalRef <- newIORef =<< emptyList
|
|
1518
|
+
when (isnode src) $ do
|
|
1519
|
+
tvall <- case src of
|
|
1520
|
+
VList r -> do its <- readIORef r; mapM (\_ -> clone child_tm) its
|
|
1521
|
+
VMap m -> do es <- readIORef m
|
|
1522
|
+
mapM (\(k, _) -> do cc <- clone child_tm
|
|
1523
|
+
when (ismap cc) (do anno <- mkMap [(s_key, VStr k)]; _ <- setprop cc (VStr s_banno) anno; return ())
|
|
1524
|
+
return cc) es
|
|
1525
|
+
_ -> return []
|
|
1526
|
+
tvalv <- mkList tvall
|
|
1527
|
+
tcurrent <- case src of
|
|
1528
|
+
VMap m -> do es <- readIORef m; mkList (map snd es)
|
|
1529
|
+
VList r -> do its <- readIORef r; mkList its
|
|
1530
|
+
_ -> return src
|
|
1531
|
+
when (length tvall > 0) $ do
|
|
1532
|
+
path <- readIORef (iPath inj)
|
|
1533
|
+
ckey <- getelem path (VNum (-2))
|
|
1534
|
+
plist <- listItems path
|
|
1535
|
+
tpath <- mkList (if null plist then [] else take (length plist - 1) plist)
|
|
1536
|
+
dpathRef <- newIORef [VStr s_dtop]
|
|
1537
|
+
case srcpath of
|
|
1538
|
+
VStr sp | sp /= s_mt -> forM_ (splitOn '.' sp) (\pp -> when (pp /= s_mt) (modifyIORef' dpathRef (++ [VStr pp])))
|
|
1539
|
+
_ -> return ()
|
|
1540
|
+
cks <- jsString ckey
|
|
1541
|
+
when (not (isNoval ckey)) $ modifyIORef' dpathRef (++ [VStr ("$:" ++ cks)])
|
|
1542
|
+
tcur0 <- mkMap [(cks, tcurrent)]
|
|
1543
|
+
tcurRef <- newIORef tcur0
|
|
1544
|
+
tpsz <- size tpath
|
|
1545
|
+
when (tpsz > 1) $ do
|
|
1546
|
+
pkey <- getelemAlt (VStr s_dtop) path (VNum (-3))
|
|
1547
|
+
pks <- jsString pkey
|
|
1548
|
+
modifyIORef' dpathRef (++ [VStr ("$:" ++ pks)])
|
|
1549
|
+
tc <- readIORef tcurRef; ntc <- mkMap [(pks, tc)]; writeIORef tcurRef ntc
|
|
1550
|
+
ckeyList <- if not (isNoval ckey) then mkList [ckey] else emptyList
|
|
1551
|
+
tinj <- injChild inj 0 ckeyList
|
|
1552
|
+
writeIORef (iPath tinj) tpath
|
|
1553
|
+
nlist <- listItems nodes
|
|
1554
|
+
nn <- mkList (if null nlist then [] else take (length nlist - 1) nlist)
|
|
1555
|
+
writeIORef (iNodes tinj) nn
|
|
1556
|
+
tinjNodes <- readIORef (iNodes tinj); tnsz <- size tinjNodes
|
|
1557
|
+
tparent <- if tnsz > 0 then getelem tinjNodes (VNum (-1)) else return VNoval
|
|
1558
|
+
writeIORef (iParent tinj) tparent
|
|
1559
|
+
when (not (isNoval ckey) && not (isNoval tparent)) $ do _ <- setprop tparent ckey tvalv; return ()
|
|
1560
|
+
writeIORef (iIval tinj) tvalv
|
|
1561
|
+
dpv <- readIORef dpathRef; dpl <- mkList dpv; writeIORef (iDpath tinj) dpl
|
|
1562
|
+
tcur <- readIORef tcurRef; writeIORef (iDparent tinj) tcur
|
|
1563
|
+
_ <- inject (IInj tinj) tvalv store
|
|
1564
|
+
iv <- readIORef (iIval tinj); writeIORef rvalRef iv
|
|
1565
|
+
rval <- readIORef rvalRef
|
|
1566
|
+
_ <- setprop target tkey rval
|
|
1567
|
+
rsz <- size rval
|
|
1568
|
+
if islist rval && rsz > 0 then getelem rval (VNum 0) else return VNoval
|
|
1569
|
+
|
|
1570
|
+
-- | @$PACK@ transform: pack a collection into a keyed map.
|
|
1571
|
+
transformPack :: Injector
|
|
1572
|
+
transformPack inj _ _ store = do
|
|
1573
|
+
mode <- readIORef (iMode inj)
|
|
1574
|
+
k0 <- readIORef (iKey inj)
|
|
1575
|
+
if mode /= m_keypre || not (isStr k0) then return VNoval
|
|
1576
|
+
else do
|
|
1577
|
+
parent <- readIORef (iParent inj)
|
|
1578
|
+
nodes <- readIORef (iNodes inj)
|
|
1579
|
+
key <- readIORef (iKey inj)
|
|
1580
|
+
argsVal <- getprop parent key
|
|
1581
|
+
asz <- size argsVal
|
|
1582
|
+
if not (islist argsVal) || asz < 2 then return VNoval
|
|
1583
|
+
else do
|
|
1584
|
+
srcpath <- getelem argsVal (VNum 0)
|
|
1585
|
+
origchildspec <- getelem argsVal (VNum 1)
|
|
1586
|
+
path <- readIORef (iPath inj)
|
|
1587
|
+
tkey <- getelem path (VNum (-2))
|
|
1588
|
+
pathsize <- size path
|
|
1589
|
+
target <- do t <- getelem nodes (VNum (fromIntegral (pathsize - 2))); if isNullish t then getelem nodes (VNum (fromIntegral (pathsize - 1))) else return t
|
|
1590
|
+
base <- readIORef (iBase inj)
|
|
1591
|
+
srcstore <- getpropAlt store store base
|
|
1592
|
+
src0 <- getpath (IInj inj) srcstore srcpath
|
|
1593
|
+
src <- if not (islist src0)
|
|
1594
|
+
then if ismap src0 then do ps <- itemsPairs src0; xs <- mapM (\(k, node) -> do anno <- mkMap [(s_key, VStr k)]; _ <- setprop node (VStr s_banno) anno; return node) ps; mkList xs
|
|
1595
|
+
else return VNoval
|
|
1596
|
+
else return src0
|
|
1597
|
+
if isNoval src then return VNoval
|
|
1598
|
+
else do
|
|
1599
|
+
keypath <- getprop origchildspec (VStr s_bkey)
|
|
1600
|
+
childspec <- delprop origchildspec (VStr s_bkey)
|
|
1601
|
+
child <- getpropAlt childspec childspec (VStr s_bval)
|
|
1602
|
+
tval <- emptyMap
|
|
1603
|
+
srcPairs <- itemsPairs src
|
|
1604
|
+
forM_ srcPairs $ \(srckey, srcnode) -> do
|
|
1605
|
+
k <- if isNoval keypath then return (VStr srckey)
|
|
1606
|
+
else case keypath of
|
|
1607
|
+
VStr kp | s_bt `isPrefixOf` kp -> do em <- emptyMap; dt <- mkMap [(s_dtop, srcnode)]; ls <- mkList [em, store, dt]; mst <- mergeD ls (VNum 1); inject INone (VStr kp) mst
|
|
1608
|
+
_ -> getpath (IInj inj) srcnode keypath
|
|
1609
|
+
tchild <- clone child
|
|
1610
|
+
_ <- setprop tval k tchild
|
|
1611
|
+
anno <- getprop srcnode (VStr s_banno)
|
|
1612
|
+
if isNoval anno then delprop tchild (VStr s_banno) >> return () else setprop tchild (VStr s_banno) anno >> return ()
|
|
1613
|
+
rvalRef <- newIORef =<< emptyMap
|
|
1614
|
+
empty <- isempty tval
|
|
1615
|
+
when (not empty) $ do
|
|
1616
|
+
tsrc <- emptyMap
|
|
1617
|
+
srcItems <- listItems src
|
|
1618
|
+
forM_ (zip [0 ..] srcItems) $ \(i, node) -> do
|
|
1619
|
+
kn <- if isNoval keypath then return (vint i)
|
|
1620
|
+
else case keypath of
|
|
1621
|
+
VStr kp | s_bt `isPrefixOf` kp -> do em <- emptyMap; dt <- mkMap [(s_dtop, node)]; ls <- mkList [em, store, dt]; mst <- mergeD ls (VNum 1); inject INone (VStr kp) mst
|
|
1622
|
+
_ -> getpath (IInj inj) node keypath
|
|
1623
|
+
_ <- setprop tsrc kn node; return ()
|
|
1624
|
+
tpath <- sliceM path (VNum (-1)) VNoval False
|
|
1625
|
+
ckey <- getelem path (VNum (-2))
|
|
1626
|
+
dpathRef <- newIORef [VStr s_dtop]
|
|
1627
|
+
case srcpath of
|
|
1628
|
+
VStr sp -> forM_ (splitOn '.' sp) (\pp -> when (pp /= s_mt) (modifyIORef' dpathRef (++ [VStr pp])))
|
|
1629
|
+
_ -> return ()
|
|
1630
|
+
cks <- jsString ckey
|
|
1631
|
+
modifyIORef' dpathRef (++ [VStr ("$:" ++ cks)])
|
|
1632
|
+
tcur0 <- mkMap [(cks, tsrc)]
|
|
1633
|
+
tcurRef <- newIORef tcur0
|
|
1634
|
+
tpsz <- size tpath
|
|
1635
|
+
when (tpsz > 1) $ do
|
|
1636
|
+
pkey <- getelemAlt (VStr s_dtop) path (VNum (-3))
|
|
1637
|
+
pks <- jsString pkey
|
|
1638
|
+
modifyIORef' dpathRef (++ [VStr ("$:" ++ pks)])
|
|
1639
|
+
tc <- readIORef tcurRef; ntc <- mkMap [(pks, tc)]; writeIORef tcurRef ntc
|
|
1640
|
+
ckl <- mkList [ckey]
|
|
1641
|
+
tinj <- injChild inj 0 ckl
|
|
1642
|
+
writeIORef (iPath tinj) tpath
|
|
1643
|
+
nn <- sliceM nodes (VNum (-1)) VNoval False
|
|
1644
|
+
writeIORef (iNodes tinj) nn
|
|
1645
|
+
tnodes <- readIORef (iNodes tinj); tparent <- getelem tnodes (VNum (-1))
|
|
1646
|
+
writeIORef (iParent tinj) tparent
|
|
1647
|
+
writeIORef (iIval tinj) tval
|
|
1648
|
+
dpv <- readIORef dpathRef; dpl <- mkList dpv; writeIORef (iDpath tinj) dpl
|
|
1649
|
+
tcur <- readIORef tcurRef; writeIORef (iDparent tinj) tcur
|
|
1650
|
+
_ <- inject (IInj tinj) tval store
|
|
1651
|
+
iv <- readIORef (iIval tinj); writeIORef rvalRef iv
|
|
1652
|
+
rval <- readIORef rvalRef
|
|
1653
|
+
_ <- setprop target tkey rval
|
|
1654
|
+
return VNoval
|
|
1655
|
+
|
|
1656
|
+
-- | @$REF@ transform: resolve a reference within the store.
|
|
1657
|
+
transformRef :: Injector
|
|
1658
|
+
transformRef inj v _ store = do
|
|
1659
|
+
mode <- readIORef (iMode inj)
|
|
1660
|
+
if mode /= m_val then return VNoval
|
|
1661
|
+
else do
|
|
1662
|
+
nodes <- readIORef (iNodes inj)
|
|
1663
|
+
parent <- readIORef (iParent inj)
|
|
1664
|
+
refpath <- lookup_ parent (VNum 1)
|
|
1665
|
+
keys <- readIORef (iKeys inj); ksz <- size keys; writeIORef (iKeyi inj) ksz
|
|
1666
|
+
specFunc <- getprop store (VStr s_dspec)
|
|
1667
|
+
case specFunc of
|
|
1668
|
+
VFunc f -> do
|
|
1669
|
+
spec <- f inj VNoval "" VNoval
|
|
1670
|
+
refv <- getpath INone spec refpath
|
|
1671
|
+
hasSubRef <- newIORef False
|
|
1672
|
+
when (isnode refv) $ do _ <- walk (Just (\_ v2 _ _ -> do when (vStrEq v2 "`$REF`") (writeIORef hasSubRef True); return v2)) Nothing VNoval refv; return ()
|
|
1673
|
+
tref <- clone refv
|
|
1674
|
+
ipath <- readIORef (iPath inj); ipsz <- size ipath
|
|
1675
|
+
cpath <- sliceM ipath (VNum 0) (VNum (fromIntegral (ipsz - 3))) False
|
|
1676
|
+
tpath <- sliceM ipath (VNum 0) (VNum (fromIntegral (ipsz - 1))) False
|
|
1677
|
+
tcur <- getpath INone store cpath
|
|
1678
|
+
tval <- getpath INone store tpath
|
|
1679
|
+
rvalRef <- newIORef VNoval
|
|
1680
|
+
hasSub <- readIORef hasSubRef
|
|
1681
|
+
when (not (isNoval refv) && (not hasSub || not (isNoval tval))) $ do
|
|
1682
|
+
lastT <- getelem tpath (VNum (-1)); cl <- mkList [lastT]
|
|
1683
|
+
cs <- injChild inj 0 cl
|
|
1684
|
+
writeIORef (iPath cs) tpath
|
|
1685
|
+
inodes <- readIORef (iNodes inj); insz <- size inodes
|
|
1686
|
+
nn <- sliceM inodes (VNum 0) (VNum (fromIntegral (insz - 1))) False
|
|
1687
|
+
writeIORef (iNodes cs) nn
|
|
1688
|
+
parent2 <- getelem nodes (VNum (-2)); writeIORef (iParent cs) parent2
|
|
1689
|
+
writeIORef (iIval cs) tref
|
|
1690
|
+
writeIORef (iDparent cs) tcur
|
|
1691
|
+
_ <- inject (IInj cs) tref store
|
|
1692
|
+
iv <- readIORef (iIval cs); writeIORef rvalRef iv
|
|
1693
|
+
rval <- readIORef rvalRef
|
|
1694
|
+
_ <- injSetval 2 inj rval
|
|
1695
|
+
prior <- readIORef (iPrior inj)
|
|
1696
|
+
case prior of
|
|
1697
|
+
Just p -> when (islist parent) $ do pk <- readIORef (iKeyi p); writeIORef (iKeyi p) (pk - 1)
|
|
1698
|
+
Nothing -> return ()
|
|
1699
|
+
return v
|
|
1700
|
+
_ -> return VNoval
|
|
1701
|
+
|
|
1702
|
+
-- ---------------------------------------------------------------------------
|
|
1703
|
+
-- formatters / transform_format / transform_apply / transform
|
|
1704
|
+
-- ---------------------------------------------------------------------------
|
|
1705
|
+
|
|
1706
|
+
-- | @String(v)@ used by the transform formatters (@null@ prints as @"null"@).
|
|
1707
|
+
jsstr :: Value -> IO String
|
|
1708
|
+
jsstr v = case v of
|
|
1709
|
+
VNull -> return "null"
|
|
1710
|
+
VBool b -> return (if b then "true" else "false")
|
|
1711
|
+
_ -> jsString v
|
|
1712
|
+
|
|
1713
|
+
-- | Parse a string as a 'Double', defaulting to 0.
|
|
1714
|
+
readDoubleOr0 :: String -> Double
|
|
1715
|
+
readDoubleOr0 s = fromMaybe 0 (readMaybe s :: Maybe Double)
|
|
1716
|
+
|
|
1717
|
+
-- | A @$FORMAT@ value formatter.
|
|
1718
|
+
type Formatter = Value -> Value -> IO Value
|
|
1719
|
+
|
|
1720
|
+
-- | Table of named @$FORMAT@ value formatters.
|
|
1721
|
+
formatterTbl :: [(String, Formatter)]
|
|
1722
|
+
formatterTbl =
|
|
1723
|
+
[ ("identity", \_ v -> return v)
|
|
1724
|
+
, ("upper", \_ v -> if isnode v then return v else do s <- jsstr v; return (VStr (map toUpper s)))
|
|
1725
|
+
, ("lower", \_ v -> if isnode v then return v else do s <- jsstr v; return (VStr (map toLower s)))
|
|
1726
|
+
, ("string", \_ v -> if isnode v then return v else do s <- jsstr v; return (VStr s))
|
|
1727
|
+
, ("number", \_ v -> if isnode v then return v
|
|
1728
|
+
else do s <- jsstr v; let n = readDoubleOr0 s in return (VNum (if isNaN n then 0 else n)))
|
|
1729
|
+
, ("integer", \_ v -> if isnode v then return v
|
|
1730
|
+
else do s <- jsstr v; let n = readDoubleOr0 s in return (VNum (fromIntegral (truncate (if isNaN n then 0 else n) :: Integer))))
|
|
1731
|
+
, ("concat", \k v -> if isNoval k && islist v
|
|
1732
|
+
then do iv <- itemsV v (\(_, x) -> if isnode x then VStr s_mt else VStr (jsstrPure x)); s <- join iv (VStr s_mt) False; return (VStr s)
|
|
1733
|
+
else return v)
|
|
1734
|
+
]
|
|
1735
|
+
|
|
1736
|
+
-- | Decide whether a directive fires on the current key-pre\/key-post\/value pass.
|
|
1737
|
+
check_placement :: Int -> String -> Int -> Inj -> IO Bool
|
|
1738
|
+
check_placement modes ijname parenttypes inj = do
|
|
1739
|
+
modenum <- readIORef (iMode inj)
|
|
1740
|
+
if (modes .&. modenum) == 0 then do
|
|
1741
|
+
let allowed = L.filter (\m -> (modes .&. m) /= 0) [m_keypre, m_keypost, m_val]
|
|
1742
|
+
placements = intercalate "," (map (\m -> if m == m_val then "value" else "key") allowed)
|
|
1743
|
+
cur = if modenum == m_val then "value" else "key"
|
|
1744
|
+
errs <- readIORef (iErrs inj); esz <- size errs
|
|
1745
|
+
_ <- setprop errs (VNum (fromIntegral esz)) (VStr ("$" ++ ijname ++ ": invalid placement as " ++ cur ++ ", expected: " ++ placements ++ "."))
|
|
1746
|
+
return False
|
|
1747
|
+
else do
|
|
1748
|
+
ie <- isempty (VNum (fromIntegral parenttypes))
|
|
1749
|
+
if not ie then do
|
|
1750
|
+
p <- readIORef (iParent inj)
|
|
1751
|
+
let ptype = typify p
|
|
1752
|
+
if (parenttypes .&. ptype) == 0 then do
|
|
1753
|
+
errs <- readIORef (iErrs inj); esz <- size errs
|
|
1754
|
+
_ <- setprop errs (VNum (fromIntegral esz)) (VStr ("$" ++ ijname ++ ": invalid placement in parent " ++ typename ptype ++ ", expected: " ++ typename parenttypes ++ "."))
|
|
1755
|
+
return False
|
|
1756
|
+
else return True
|
|
1757
|
+
else return True
|
|
1758
|
+
|
|
1759
|
+
-- | Collect the argument values a custom injector declares it needs.
|
|
1760
|
+
injector_args :: [Int] -> Value -> IO [Value]
|
|
1761
|
+
injector_args argtypes args = do
|
|
1762
|
+
let numargs = length argtypes
|
|
1763
|
+
foundRef <- newIORef (replicate (1 + numargs) VNoval)
|
|
1764
|
+
let go [] = return ()
|
|
1765
|
+
go ((argi, at):rest) = do
|
|
1766
|
+
arg <- getelem args (VNum (fromIntegral argi))
|
|
1767
|
+
let argtype = typify arg
|
|
1768
|
+
if (at .&. argtype) == 0 then do
|
|
1769
|
+
s <- stringifyMax arg (VNum 22)
|
|
1770
|
+
modifyIORef' foundRef (setAt 0 (VStr ("invalid argument: " ++ s ++ " (" ++ typename argtype ++ " at position " ++ show (1 + argi) ++ ") is not of type: " ++ typename at ++ ".")))
|
|
1771
|
+
else do modifyIORef' foundRef (setAt (1 + argi) arg); go rest
|
|
1772
|
+
go (zip [0 ..] argtypes)
|
|
1773
|
+
readIORef foundRef
|
|
1774
|
+
|
|
1775
|
+
-- | Build the child injection state a custom injector operates on.
|
|
1776
|
+
inject_child :: Value -> Value -> Inj -> IO Inj
|
|
1777
|
+
inject_child child store inj = do
|
|
1778
|
+
prior <- readIORef (iPrior inj)
|
|
1779
|
+
cinjRef <- newIORef inj
|
|
1780
|
+
case prior of
|
|
1781
|
+
Just pr -> do
|
|
1782
|
+
pprior <- readIORef (iPrior pr)
|
|
1783
|
+
case pprior of
|
|
1784
|
+
Just pp -> do
|
|
1785
|
+
pkeyi <- readIORef (iKeyi pr); pkeys <- readIORef (iKeys pr)
|
|
1786
|
+
c <- injChild pp pkeyi pkeys
|
|
1787
|
+
writeIORef (iIval c) child
|
|
1788
|
+
cp <- readIORef (iParent c); prk <- readIORef (iKey pr); _ <- setprop cp prk child
|
|
1789
|
+
writeIORef cinjRef c
|
|
1790
|
+
Nothing -> do
|
|
1791
|
+
ikeyi <- readIORef (iKeyi inj); ikeys <- readIORef (iKeys inj)
|
|
1792
|
+
c <- injChild pr ikeyi ikeys
|
|
1793
|
+
writeIORef (iIval c) child
|
|
1794
|
+
cp <- readIORef (iParent c); ik <- readIORef (iKey inj); _ <- setprop cp ik child
|
|
1795
|
+
writeIORef cinjRef c
|
|
1796
|
+
Nothing -> return ()
|
|
1797
|
+
cinj <- readIORef cinjRef
|
|
1798
|
+
_ <- inject (IInj cinj) child store
|
|
1799
|
+
return cinj
|
|
1800
|
+
|
|
1801
|
+
-- | @$FORMAT@ transform: format a value via a named formatter.
|
|
1802
|
+
transformFormat :: Injector
|
|
1803
|
+
transformFormat inj _ _ store = do
|
|
1804
|
+
keys <- readIORef (iKeys inj); _ <- sliceM keys (VNum 0) (VNum 1) True
|
|
1805
|
+
mode <- readIORef (iMode inj)
|
|
1806
|
+
if mode /= m_val then return VNoval
|
|
1807
|
+
else do
|
|
1808
|
+
parent <- readIORef (iParent inj)
|
|
1809
|
+
name <- lookup_ parent (VNum 1)
|
|
1810
|
+
child <- lookup_ parent (VNum 2)
|
|
1811
|
+
path <- readIORef (iPath inj)
|
|
1812
|
+
tkey <- getelem path (VNum (-2))
|
|
1813
|
+
nodes <- readIORef (iNodes inj)
|
|
1814
|
+
target <- do t <- getelem nodes (VNum (-2)); if isNullish t then getelem nodes (VNum (-1)) else return t
|
|
1815
|
+
cinj <- inject_child child store inj
|
|
1816
|
+
resolved <- readIORef (iIval cinj)
|
|
1817
|
+
nameKey <- jsString name
|
|
1818
|
+
let formatter = if (t_function .&. typify name) > 0
|
|
1819
|
+
then Just (\k vv -> case name of { VFunc f -> do { ks <- jsString k; f dummyInj vv ks VNoval }; _ -> return vv })
|
|
1820
|
+
else lookup nameKey formatterTbl
|
|
1821
|
+
case formatter of
|
|
1822
|
+
Nothing -> do errs <- readIORef (iErrs inj); esz <- size errs; _ <- setprop errs (VNum (fromIntegral esz)) (VStr ("$FORMAT: unknown format: " ++ nameKey ++ ".")); return VNoval
|
|
1823
|
+
Just f -> do
|
|
1824
|
+
out <- walk (Just (\k vv _ _ -> f k vv)) Nothing VNoval resolved
|
|
1825
|
+
_ <- setprop target tkey out
|
|
1826
|
+
return out
|
|
1827
|
+
|
|
1828
|
+
-- | @$APPLY@ transform: apply a named transform.
|
|
1829
|
+
transformApply :: Injector
|
|
1830
|
+
transformApply inj _ _ store = do
|
|
1831
|
+
ok <- check_placement m_val "APPLY" t_list inj
|
|
1832
|
+
if not ok then return VNoval
|
|
1833
|
+
else do
|
|
1834
|
+
parent <- readIORef (iParent inj)
|
|
1835
|
+
sl <- sliceM parent (VNum 1) VNoval False
|
|
1836
|
+
res <- injector_args [t_function, t_any] sl
|
|
1837
|
+
let err = res !! 0
|
|
1838
|
+
applyFn = res !! 1
|
|
1839
|
+
child = if length res > 2 then res !! 2 else VNoval
|
|
1840
|
+
if not (isNoval err) then do errs <- readIORef (iErrs inj); esz <- size errs; es <- jsString err; _ <- setprop errs (VNum (fromIntegral esz)) (VStr ("$APPLY: " ++ es)); return VNoval
|
|
1841
|
+
else do
|
|
1842
|
+
path <- readIORef (iPath inj); tkey <- getelem path (VNum (-2))
|
|
1843
|
+
nodes <- readIORef (iNodes inj); target <- do t <- getelem nodes (VNum (-2)); if isNullish t then getelem nodes (VNum (-1)) else return t
|
|
1844
|
+
cinj <- inject_child child store inj
|
|
1845
|
+
resolved <- readIORef (iIval cinj)
|
|
1846
|
+
out <- case applyFn of VFunc f -> f cinj resolved "" store; _ -> return VNoval
|
|
1847
|
+
_ <- setprop target tkey out
|
|
1848
|
+
return out
|
|
1849
|
+
|
|
1850
|
+
-- | The default 'InjDef' used when the public API is called with 'INone'.
|
|
1851
|
+
defaultInjDef :: Value -> InjDef
|
|
1852
|
+
defaultInjDef errs = InjDef
|
|
1853
|
+
{ dMeta = VNoval, dExtra = VNoval, dErrs = errs, dModify = Nothing, dHandler = Nothing
|
|
1854
|
+
, dBase = VNoval, dDparent = VNoval, dDpath = VNoval, dKey = VNoval }
|
|
1855
|
+
|
|
1856
|
+
-- | Run the transform engine: build output from a spec mirroring the shape, pulling from data via @\`...\`@.
|
|
1857
|
+
transform :: InjArg -> Value -> Value -> IO Value
|
|
1858
|
+
transform injarg dat spec0 = do
|
|
1859
|
+
let origspec = spec0
|
|
1860
|
+
spec <- clone spec0
|
|
1861
|
+
let extra = case injarg of IDef d -> dExtra d; _ -> VNoval
|
|
1862
|
+
collect = case injarg of IDef d -> not (isNoval (dErrs d)); _ -> False
|
|
1863
|
+
errs <- case injarg of IDef d | collect -> return (dErrs d); _ -> emptyList
|
|
1864
|
+
extraTransforms <- emptyMap
|
|
1865
|
+
extraData <- emptyMap
|
|
1866
|
+
when (not (isNoval extra)) $ do
|
|
1867
|
+
ps <- itemsPairs extra
|
|
1868
|
+
forM_ ps $ \(k, vv) -> if s_ds `isPrefixOf` k then setprop extraTransforms (VStr k) vv >> return () else setprop extraData (VStr k) vv >> return ()
|
|
1869
|
+
edEmpty <- isempty extraData
|
|
1870
|
+
ec <- if edEmpty then return VNoval else clone extraData
|
|
1871
|
+
dc <- clone dat
|
|
1872
|
+
ls <- mkList [ec, dc]
|
|
1873
|
+
dataClone <- merge ls
|
|
1874
|
+
store <- emptyMap
|
|
1875
|
+
let put k vv = setprop store (VStr k) vv >> return ()
|
|
1876
|
+
put s_dtop dataClone
|
|
1877
|
+
put s_dspec (VFunc (\_ _ _ _ -> return origspec))
|
|
1878
|
+
put "$BT" (VFunc (\_ _ _ _ -> return (VStr s_bt)))
|
|
1879
|
+
put "$DS" (VFunc (\_ _ _ _ -> return (VStr s_ds)))
|
|
1880
|
+
put "$WHEN" (VFunc (\_ _ _ _ -> return (VStr "1970-01-01T00:00:00.000Z")))
|
|
1881
|
+
put "$DELETE" (VFunc transformDelete)
|
|
1882
|
+
put "$COPY" (VFunc transformCopy)
|
|
1883
|
+
put "$KEY" (VFunc transformKey)
|
|
1884
|
+
put "$ANNO" (VFunc transformAnno)
|
|
1885
|
+
put "$MERGE" (VFunc transformMerge)
|
|
1886
|
+
put "$EACH" (VFunc transformEach)
|
|
1887
|
+
put "$PACK" (VFunc transformPack)
|
|
1888
|
+
put "$REF" (VFunc transformRef)
|
|
1889
|
+
put "$FORMAT" (VFunc transformFormat)
|
|
1890
|
+
put "$APPLY" (VFunc transformApply)
|
|
1891
|
+
etPairs <- itemsPairs extraTransforms
|
|
1892
|
+
forM_ etPairs $ \(k, vv) -> put k vv
|
|
1893
|
+
put s_derrs errs
|
|
1894
|
+
let idef0 = defaultInjDef errs
|
|
1895
|
+
idef = case injarg of
|
|
1896
|
+
IDef d -> idef0 { dMeta = dMeta d, dModify = dModify d, dHandler = dHandler d, dBase = dBase d }
|
|
1897
|
+
_ -> idef0
|
|
1898
|
+
out <- inject (IDef idef) spec store
|
|
1899
|
+
esz <- size errs
|
|
1900
|
+
when (esz > 0 && not collect) $ do j <- join errs (VStr " | ") False; throwIO (StructError j)
|
|
1901
|
+
return out
|
|
1902
|
+
|
|
1903
|
+
-- ---------------------------------------------------------------------------
|
|
1904
|
+
-- validate
|
|
1905
|
+
-- ---------------------------------------------------------------------------
|
|
1906
|
+
|
|
1907
|
+
-- | Append a validation error message to the injection state.
|
|
1908
|
+
pushErr :: Inj -> String -> IO ()
|
|
1909
|
+
pushErr inj msg = do errs <- readIORef (iErrs inj); esz <- size errs; _ <- setprop errs (VNum (fromIntegral esz)) (VStr msg); return ()
|
|
1910
|
+
|
|
1911
|
+
-- | Format the standard "invalid type" validation error message.
|
|
1912
|
+
invalidTypeMsg :: Value -> String -> Int -> Value -> String -> IO String
|
|
1913
|
+
invalidTypeMsg path needtype vt v _whence = do
|
|
1914
|
+
vs <- if isNullish v then return "no value" else stringify v
|
|
1915
|
+
psz <- size path
|
|
1916
|
+
fieldPart <- if psz > 1 then do p <- pathifyFull path (VNum 1) VNoval False; return ("field " ++ p ++ " to be ") else return ""
|
|
1917
|
+
let typePart = if not (isNullish v) then typename vt ++ s_viz else ""
|
|
1918
|
+
return ("Expected " ++ fieldPart ++ needtype ++ ", but found " ++ typePart ++ vs ++ ".")
|
|
1919
|
+
|
|
1920
|
+
-- | @$STRING@ validation rule.
|
|
1921
|
+
validateString :: Injector
|
|
1922
|
+
validateString inj _ _ _ = do
|
|
1923
|
+
dp <- readIORef (iDparent inj); k <- readIORef (iKey inj)
|
|
1924
|
+
out <- lookup_ dp k
|
|
1925
|
+
let t = typify out
|
|
1926
|
+
if (t_string .&. t) == 0 then do path <- readIORef (iPath inj); m <- invalidTypeMsg path s_string t out "V1010"; pushErr inj m; return VNoval
|
|
1927
|
+
else if vStrEq out s_mt then do path <- readIORef (iPath inj); p <- pathifyFull path (VNum 1) VNoval False; pushErr inj ("Empty string at " ++ p); return VNoval
|
|
1928
|
+
else return out
|
|
1929
|
+
|
|
1930
|
+
-- | Type-checking validation rule (@$NUMBER@, @$BOOLEAN@, ...).
|
|
1931
|
+
validateType :: Injector
|
|
1932
|
+
validateType inj _ refstr _ = do
|
|
1933
|
+
let tname = if length refstr > 1 then map toLower (drop 1 refstr) else "any"
|
|
1934
|
+
idx = fromMaybe (-1) (findIndex (== tname) typenameTbl)
|
|
1935
|
+
typev0 = if idx >= 0 then shiftL 1 (31 - idx) else 0
|
|
1936
|
+
typev = if tname == s_nil then typev0 .|. t_null else typev0
|
|
1937
|
+
dp <- readIORef (iDparent inj); k <- readIORef (iKey inj)
|
|
1938
|
+
out <- lookup_ dp k
|
|
1939
|
+
let t = typify out
|
|
1940
|
+
if (t .&. typev) == 0 then do path <- readIORef (iPath inj); m <- invalidTypeMsg path tname t out "V1001"; pushErr inj m; return VNoval
|
|
1941
|
+
else return out
|
|
1942
|
+
|
|
1943
|
+
-- | @$ANY@ validation rule (accept any value).
|
|
1944
|
+
validateAny :: Injector
|
|
1945
|
+
validateAny inj _ _ _ = do dp <- readIORef (iDparent inj); k <- readIORef (iKey inj); lookup_ dp k
|
|
1946
|
+
|
|
1947
|
+
-- | @$CHILD@ validation rule (validate each child against a template).
|
|
1948
|
+
validateChild :: Injector
|
|
1949
|
+
validateChild inj _ _ _ = do
|
|
1950
|
+
parent <- readIORef (iParent inj); key <- readIORef (iKey inj); path <- readIORef (iPath inj); keys <- readIORef (iKeys inj)
|
|
1951
|
+
mode <- readIORef (iMode inj)
|
|
1952
|
+
if mode == m_keypre then do
|
|
1953
|
+
childtm <- getprop parent key
|
|
1954
|
+
pkey <- getelem path (VNum (-2))
|
|
1955
|
+
dp <- readIORef (iDparent inj)
|
|
1956
|
+
tval <- getprop dp pkey
|
|
1957
|
+
if isNoval tval then do
|
|
1958
|
+
em <- emptyMap; eks <- keysof em
|
|
1959
|
+
forM_ eks $ \ckey -> do cc <- clone childtm; _ <- setprop parent (VStr ckey) cc; ksz <- size keys; _ <- setprop keys (VNum (fromIntegral ksz)) (VStr ckey); return ()
|
|
1960
|
+
_ <- delprop parent key; return VNoval
|
|
1961
|
+
else if not (ismap tval) then do
|
|
1962
|
+
psz <- size path; sl <- sliceM path (VNum 0) (VNum (fromIntegral (psz - 1))) False
|
|
1963
|
+
m <- invalidTypeMsg sl s_object (typify tval) tval "V0220"; pushErr inj m; return VNoval
|
|
1964
|
+
else do
|
|
1965
|
+
tks <- keysof tval
|
|
1966
|
+
forM_ tks $ \ckey -> do cc <- clone childtm; _ <- setprop parent (VStr ckey) cc; ksz <- size keys; _ <- setprop keys (VNum (fromIntegral ksz)) (VStr ckey); return ()
|
|
1967
|
+
_ <- delprop parent key; return VNoval
|
|
1968
|
+
else if mode == m_val then do
|
|
1969
|
+
childtm <- getprop parent (VNum 1)
|
|
1970
|
+
if not (islist parent) then do pushErr inj "Invalid $CHILD as value"; return VNoval
|
|
1971
|
+
else do
|
|
1972
|
+
dp <- readIORef (iDparent inj)
|
|
1973
|
+
if isNoval dp then case parent of VList r -> writeIORef r [] >> return VNoval; _ -> return VNoval
|
|
1974
|
+
else if not (islist dp) then do
|
|
1975
|
+
psz <- size path; sl <- sliceM path (VNum 0) (VNum (fromIntegral (psz - 1))) False
|
|
1976
|
+
m <- invalidTypeMsg sl s_list (typify dp) dp "V0230"; pushErr inj m
|
|
1977
|
+
psz2 <- size parent; writeIORef (iKeyi inj) psz2; return dp
|
|
1978
|
+
else do
|
|
1979
|
+
ps <- itemsPairs dp
|
|
1980
|
+
forM_ ps $ \(k, _) -> do cc <- clone childtm; _ <- setprop parent (VStr k) cc; return ()
|
|
1981
|
+
n <- size dp
|
|
1982
|
+
case parent of { VList r -> do { a <- readIORef r; writeIORef r (take (min n (length a)) a) }; _ -> return () }
|
|
1983
|
+
writeIORef (iKeyi inj) 0
|
|
1984
|
+
getprop dp (VNum 0)
|
|
1985
|
+
else return VNoval
|
|
1986
|
+
|
|
1987
|
+
-- | @$ONE@ validation rule (value must match one of the alternatives).
|
|
1988
|
+
validateOne :: Injector
|
|
1989
|
+
validateOne inj _ _ store = do
|
|
1990
|
+
mode <- readIORef (iMode inj)
|
|
1991
|
+
if mode == m_val then do
|
|
1992
|
+
parent <- readIORef (iParent inj)
|
|
1993
|
+
keyi <- readIORef (iKeyi inj)
|
|
1994
|
+
if not (islist parent) || keyi /= 0 then do
|
|
1995
|
+
path <- readIORef (iPath inj); p <- pathifyFull path (VNum 1) (VNum 1) False
|
|
1996
|
+
pushErr inj ("The $ONE validator at field " ++ p ++ " must be the first element of an array."); return VNoval
|
|
1997
|
+
else do
|
|
1998
|
+
keys <- readIORef (iKeys inj); ksz <- size keys; writeIORef (iKeyi inj) ksz
|
|
1999
|
+
dp <- readIORef (iDparent inj); _ <- injSetval 2 inj dp
|
|
2000
|
+
path <- readIORef (iPath inj); psz <- size path; sl <- sliceM path (VNum 0) (VNum (fromIntegral (psz - 1))) False; writeIORef (iPath inj) sl
|
|
2001
|
+
np <- readIORef (iPath inj); nk <- getelem np (VNum (-1)); writeIORef (iKey inj) nk
|
|
2002
|
+
tvals <- sliceM parent (VNum 1) VNoval False
|
|
2003
|
+
tsz <- size tvals
|
|
2004
|
+
if tsz == 0 then do path2 <- readIORef (iPath inj); p <- pathifyFull path2 (VNum 1) (VNum 1) False; pushErr inj ("The $ONE validator at field " ++ p ++ " must have at least one argument."); return VNoval
|
|
2005
|
+
else do
|
|
2006
|
+
matchedRef <- newIORef False
|
|
2007
|
+
tvItems <- listItems tvals
|
|
2008
|
+
forM_ tvItems $ \tval -> do
|
|
2009
|
+
matched <- readIORef matchedRef
|
|
2010
|
+
when (not matched) $ do
|
|
2011
|
+
terrs <- emptyList
|
|
2012
|
+
em <- emptyMap; ls <- mkList [em, store]; vstore <- mergeD ls (VNum 1)
|
|
2013
|
+
dp2 <- readIORef (iDparent inj); _ <- setprop vstore (VStr s_dtop) dp2
|
|
2014
|
+
meta <- readIORef (iMeta inj)
|
|
2015
|
+
let idef = (defaultInjDef terrs) { dExtra = vstore, dMeta = meta }
|
|
2016
|
+
vcurrent <- validate (IDef idef) dp2 tval
|
|
2017
|
+
_ <- injSetval (-2) inj vcurrent
|
|
2018
|
+
tesz <- size terrs
|
|
2019
|
+
when (tesz == 0) $ writeIORef matchedRef True
|
|
2020
|
+
matched <- readIORef matchedRef
|
|
2021
|
+
when (not matched) $ do
|
|
2022
|
+
ps <- itemsPairs tvals
|
|
2023
|
+
descs <- mapM (\(_, x) -> stringify x) ps
|
|
2024
|
+
let valdesc = replaceTransformNames (intercalate ", " descs)
|
|
2025
|
+
path3 <- readIORef (iPath inj); dp3 <- readIORef (iDparent inj)
|
|
2026
|
+
m <- invalidTypeMsg path3 ((if tsz > 1 then "one of " else "") ++ valdesc) (typify dp3) dp3 "V0210"
|
|
2027
|
+
pushErr inj m
|
|
2028
|
+
return VNoval
|
|
2029
|
+
else return VNoval
|
|
2030
|
+
|
|
2031
|
+
-- | @\`$EXACT\`@ validation rule (value must equal exactly).
|
|
2032
|
+
validateExact :: Injector
|
|
2033
|
+
validateExact inj _ _ _ = do
|
|
2034
|
+
mode <- readIORef (iMode inj)
|
|
2035
|
+
if mode == m_val then do
|
|
2036
|
+
parent <- readIORef (iParent inj); keyi <- readIORef (iKeyi inj)
|
|
2037
|
+
if not (islist parent) || keyi /= 0 then do path <- readIORef (iPath inj); p <- pathifyFull path (VNum 1) (VNum 1) False; pushErr inj ("The $EXACT validator at field " ++ p ++ " must be the first element of an array."); return VNoval
|
|
2038
|
+
else do
|
|
2039
|
+
keys <- readIORef (iKeys inj); ksz <- size keys; writeIORef (iKeyi inj) ksz
|
|
2040
|
+
dp <- readIORef (iDparent inj); _ <- injSetval 2 inj dp
|
|
2041
|
+
path <- readIORef (iPath inj); psz <- size path; sl <- sliceM path (VNum 0) (VNum (fromIntegral (psz - 1))) False; writeIORef (iPath inj) sl
|
|
2042
|
+
np <- readIORef (iPath inj); nk <- getelem np (VNum (-1)); writeIORef (iKey inj) nk
|
|
2043
|
+
tvals <- sliceM parent (VNum 1) VNoval False
|
|
2044
|
+
tsz <- size tvals
|
|
2045
|
+
if tsz == 0 then do path2 <- readIORef (iPath inj); p <- pathifyFull path2 (VNum 1) (VNum 1) False; pushErr inj ("The $EXACT validator at field " ++ p ++ " must have at least one argument."); return VNoval
|
|
2046
|
+
else do
|
|
2047
|
+
matchedRef <- newIORef False
|
|
2048
|
+
tvItems <- listItems tvals
|
|
2049
|
+
dp2 <- readIORef (iDparent inj)
|
|
2050
|
+
forM_ tvItems $ \tval -> do matched <- readIORef matchedRef; when (not matched) $ do eqb <- veq tval dp2; when eqb (writeIORef matchedRef True)
|
|
2051
|
+
matched <- readIORef matchedRef
|
|
2052
|
+
when (not matched) $ do
|
|
2053
|
+
ps <- itemsPairs tvals
|
|
2054
|
+
descs <- mapM (\(_, x) -> stringify x) ps
|
|
2055
|
+
let valdesc = replaceTransformNames (intercalate ", " descs)
|
|
2056
|
+
path3 <- readIORef (iPath inj); psz3 <- size path3
|
|
2057
|
+
m <- invalidTypeMsg path3 ((if psz3 > 1 then "" else "value ") ++ "exactly equal to " ++ (if tsz == 1 then "" else "one of ") ++ valdesc) (typify dp2) dp2 "V0110"
|
|
2058
|
+
pushErr inj m
|
|
2059
|
+
return VNoval
|
|
2060
|
+
else do p <- readIORef (iParent inj); k <- readIORef (iKey inj); _ <- delprop p k; return VNoval
|
|
2061
|
+
|
|
2062
|
+
-- | Deep structural equality of two values.
|
|
2063
|
+
veq :: Value -> Value -> IO Bool
|
|
2064
|
+
veq a b = case (a, b) of
|
|
2065
|
+
(VNoval, VNoval) -> return True
|
|
2066
|
+
(VNull, VNull) -> return True
|
|
2067
|
+
(VBool x, VBool y) -> return (x == y)
|
|
2068
|
+
(VNum x, VNum y) -> return (x == y)
|
|
2069
|
+
(VStr x, VStr y) -> return (x == y)
|
|
2070
|
+
(VSentinel x, VSentinel y) -> return (x == y)
|
|
2071
|
+
(VList x, VList y) -> do xs <- readIORef x; ys <- readIORef y; if length xs /= length ys then return False else andM (zipWith veq xs ys)
|
|
2072
|
+
(VMap x, VMap y) -> do xs <- readIORef x; ys <- readIORef y; if length xs /= length ys then return False else andM (map (\(k, vv) -> case lookup k ys of Just w -> veq vv w; Nothing -> return False) xs)
|
|
2073
|
+
_ -> return False
|
|
2074
|
+
|
|
2075
|
+
-- | The 'ModifyFn' that runs shape validation as the transform mutates.
|
|
2076
|
+
validation :: ModifyFn
|
|
2077
|
+
validation pval key parent inj = do
|
|
2078
|
+
when (not (is_skip pval)) $ do
|
|
2079
|
+
meta <- readIORef (iMeta inj)
|
|
2080
|
+
exact <- getpropAlt (VBool False) meta (VStr s_bexact)
|
|
2081
|
+
dp <- readIORef (iDparent inj)
|
|
2082
|
+
cval <- getprop dp key
|
|
2083
|
+
let exactB = case exact of VBool True -> True; _ -> False
|
|
2084
|
+
when (not ((not exactB) && isNoval cval)) $ do
|
|
2085
|
+
let ptype = typify pval
|
|
2086
|
+
pjs <- jsString pval
|
|
2087
|
+
when (not ((t_string .&. ptype) > 0 && '$' `elem` pjs)) $ do
|
|
2088
|
+
let ctype = typify cval
|
|
2089
|
+
path <- readIORef (iPath inj)
|
|
2090
|
+
if ptype /= ctype && not (isNoval pval) then do m <- invalidTypeMsg path (typename ptype) ctype cval "V0010"; pushErr inj m
|
|
2091
|
+
else if ismap cval then
|
|
2092
|
+
if not (ismap pval) then do m <- invalidTypeMsg path (typename ptype) ctype cval "V0020"; pushErr inj m
|
|
2093
|
+
else do
|
|
2094
|
+
ckeys <- keysof cval
|
|
2095
|
+
pkeys <- keysof pval
|
|
2096
|
+
bopenV <- getprop pval (VStr s_bopen)
|
|
2097
|
+
if not (null pkeys) && not (vIsTrue bopenV) then do
|
|
2098
|
+
badkeys <- filterM (\ck -> do lk <- lookup_ pval (VStr ck); return (isNoval lk)) ckeys
|
|
2099
|
+
when (not (null badkeys)) $ do p <- pathifyFull path (VNum 1) VNoval False; pushErr inj ("Unexpected keys at field " ++ p ++ s_viz ++ intercalate ", " badkeys)
|
|
2100
|
+
else do
|
|
2101
|
+
ls <- mkList [pval, cval]; _ <- merge ls
|
|
2102
|
+
when (isnode pval) (delprop pval (VStr s_bopen) >> return ())
|
|
2103
|
+
else if islist cval then when (not (islist pval)) $ do m <- invalidTypeMsg path (typename ptype) ctype cval "V0030"; pushErr inj m
|
|
2104
|
+
else if exactB then do
|
|
2105
|
+
eqb <- veq cval pval
|
|
2106
|
+
when (not eqb) $ do
|
|
2107
|
+
psz <- size path
|
|
2108
|
+
pathmsg <- if psz > 1 then do p <- pathifyFull path (VNum 1) VNoval False; return ("at field " ++ p ++ ": ") else return ""
|
|
2109
|
+
cjs <- jsString cval; pjs2 <- jsString pval
|
|
2110
|
+
pushErr inj ("Value " ++ pathmsg ++ cjs ++ " should equal " ++ pjs2 ++ ".")
|
|
2111
|
+
else do _ <- setprop parent key cval; return ()
|
|
2112
|
+
|
|
2113
|
+
-- | Injector handler used while validating.
|
|
2114
|
+
validateHandler :: Injector
|
|
2115
|
+
validateHandler inj v refstr store = case metaPathMatch refstr of
|
|
2116
|
+
Just (_, g2, _) -> do
|
|
2117
|
+
if g2 == "=" then do l <- mkList [VStr s_bexact, v]; _ <- injSetval1 inj l; return () else do _ <- injSetval1 inj v; return ()
|
|
2118
|
+
writeIORef (iKeyi inj) (-1)
|
|
2119
|
+
return skip
|
|
2120
|
+
Nothing -> injectHandler inj v refstr store
|
|
2121
|
+
|
|
2122
|
+
-- | Validate data against a shape, collecting errors; returns the (possibly defaulted) value.
|
|
2123
|
+
validate :: InjArg -> Value -> Value -> IO Value
|
|
2124
|
+
validate injarg dat spec = do
|
|
2125
|
+
let extra = case injarg of IDef d -> dExtra d; _ -> VNoval
|
|
2126
|
+
collect = case injarg of IDef d -> not (isNoval (dErrs d)); _ -> False
|
|
2127
|
+
errs <- case injarg of IDef d | collect -> return (dErrs d); _ -> emptyList
|
|
2128
|
+
base <- emptyMap
|
|
2129
|
+
let put k vv = setprop base (VStr k) vv >> return ()
|
|
2130
|
+
forM_ ["$DELETE", "$COPY", "$KEY", "$META", "$MERGE", "$EACH", "$PACK"] (\k -> put k VNull)
|
|
2131
|
+
put "$STRING" (VFunc validateString)
|
|
2132
|
+
forM_ ["$NUMBER", "$INTEGER", "$DECIMAL", "$BOOLEAN", "$NULL", "$NIL", "$MAP", "$LIST", "$FUNCTION", "$INSTANCE"] (\k -> put k (VFunc validateType))
|
|
2133
|
+
put "$ANY" (VFunc validateAny)
|
|
2134
|
+
put "$CHILD" (VFunc validateChild)
|
|
2135
|
+
put "$ONE" (VFunc validateOne)
|
|
2136
|
+
put "$EXACT" (VFunc validateExact)
|
|
2137
|
+
extraMap <- if isNoval extra then emptyMap else return extra
|
|
2138
|
+
errMap <- mkMap [(s_derrs, errs)]
|
|
2139
|
+
ls <- mkList [base, extraMap, errMap]; store <- mergeD ls (VNum 1)
|
|
2140
|
+
meta <- case injarg of IDef d | not (isNoval (dMeta d)) -> return (dMeta d); _ -> emptyMap
|
|
2141
|
+
bex <- getpropAlt (VBool False) meta (VStr s_bexact); _ <- setprop meta (VStr s_bexact) bex
|
|
2142
|
+
let idef = (defaultInjDef errs) { dMeta = meta, dExtra = store, dModify = Just validation, dHandler = Just validateHandler }
|
|
2143
|
+
out <- transform (IDef idef) dat spec
|
|
2144
|
+
esz <- size errs
|
|
2145
|
+
when (esz > 0 && not collect) $ do j <- join errs (VStr " | ") False; throwIO (StructError j)
|
|
2146
|
+
return out
|
|
2147
|
+
|
|
2148
|
+
-- ---------------------------------------------------------------------------
|
|
2149
|
+
-- select
|
|
2150
|
+
-- ---------------------------------------------------------------------------
|
|
2151
|
+
|
|
2152
|
+
-- | @$AND@ query operator.
|
|
2153
|
+
selectAnd :: Injector
|
|
2154
|
+
selectAnd inj _ _ store = do
|
|
2155
|
+
mode <- readIORef (iMode inj)
|
|
2156
|
+
when (mode == m_keypre) $ do
|
|
2157
|
+
parent <- readIORef (iParent inj); key <- readIORef (iKey inj)
|
|
2158
|
+
terms <- getprop parent key
|
|
2159
|
+
path <- readIORef (iPath inj); ppath <- sliceM path (VNum (-1)) VNoval False
|
|
2160
|
+
point <- getpath INone store ppath
|
|
2161
|
+
em <- emptyMap; ls <- mkList [em, store]; vstore <- mergeD ls (VNum 1)
|
|
2162
|
+
_ <- setprop vstore (VStr s_dtop) point
|
|
2163
|
+
ps <- itemsPairs terms
|
|
2164
|
+
forM_ ps $ \(_, term) -> do
|
|
2165
|
+
terrs <- emptyList
|
|
2166
|
+
meta <- readIORef (iMeta inj)
|
|
2167
|
+
let idef = (defaultInjDef terrs) { dExtra = vstore, dMeta = meta }
|
|
2168
|
+
_ <- validate (IDef idef) point term
|
|
2169
|
+
tesz <- size terrs
|
|
2170
|
+
when (tesz /= 0) $ do pp <- pathify ppath; sp <- stringify point; st <- stringify terms; pushErr inj ("AND:" ++ pp ++ cross ++ sp ++ " fail:" ++ st)
|
|
2171
|
+
gkey <- getelem path (VNum (-2))
|
|
2172
|
+
nodes <- readIORef (iNodes inj); gp <- getelem nodes (VNum (-2))
|
|
2173
|
+
_ <- setprop gp gkey point; return ()
|
|
2174
|
+
return VNoval
|
|
2175
|
+
|
|
2176
|
+
-- | @$OR@ query operator.
|
|
2177
|
+
selectOr :: Injector
|
|
2178
|
+
selectOr inj _ _ store = do
|
|
2179
|
+
mode <- readIORef (iMode inj)
|
|
2180
|
+
when (mode == m_keypre) $ do
|
|
2181
|
+
parent <- readIORef (iParent inj); key <- readIORef (iKey inj)
|
|
2182
|
+
terms <- getprop parent key
|
|
2183
|
+
path <- readIORef (iPath inj); ppath <- sliceM path (VNum (-1)) VNoval False
|
|
2184
|
+
point <- getpath INone store ppath
|
|
2185
|
+
em <- emptyMap; ls <- mkList [em, store]; vstore <- mergeD ls (VNum 1)
|
|
2186
|
+
_ <- setprop vstore (VStr s_dtop) point
|
|
2187
|
+
doneRef <- newIORef False
|
|
2188
|
+
ps <- itemsPairs terms
|
|
2189
|
+
forM_ ps $ \(_, term) -> do
|
|
2190
|
+
done <- readIORef doneRef
|
|
2191
|
+
when (not done) $ do
|
|
2192
|
+
terrs <- emptyList
|
|
2193
|
+
meta <- readIORef (iMeta inj)
|
|
2194
|
+
let idef = (defaultInjDef terrs) { dExtra = vstore, dMeta = meta }
|
|
2195
|
+
_ <- validate (IDef idef) point term
|
|
2196
|
+
tesz <- size terrs
|
|
2197
|
+
when (tesz == 0) $ do
|
|
2198
|
+
gkey <- getelem path (VNum (-2))
|
|
2199
|
+
nodes <- readIORef (iNodes inj); gp <- getelem nodes (VNum (-2))
|
|
2200
|
+
_ <- setprop gp gkey point; writeIORef doneRef True
|
|
2201
|
+
done <- readIORef doneRef
|
|
2202
|
+
when (not done) $ do pp <- pathify ppath; sp <- stringify point; st <- stringify terms; pushErr inj ("OR:" ++ pp ++ cross ++ sp ++ " fail:" ++ st)
|
|
2203
|
+
return VNoval
|
|
2204
|
+
|
|
2205
|
+
-- | @$NOT@ query operator.
|
|
2206
|
+
selectNot :: Injector
|
|
2207
|
+
selectNot inj _ _ store = do
|
|
2208
|
+
mode <- readIORef (iMode inj)
|
|
2209
|
+
when (mode == m_keypre) $ do
|
|
2210
|
+
parent <- readIORef (iParent inj); key <- readIORef (iKey inj)
|
|
2211
|
+
term <- getprop parent key
|
|
2212
|
+
path <- readIORef (iPath inj); ppath <- sliceM path (VNum (-1)) VNoval False
|
|
2213
|
+
point <- getpath INone store ppath
|
|
2214
|
+
em <- emptyMap; ls <- mkList [em, store]; vstore <- mergeD ls (VNum 1)
|
|
2215
|
+
_ <- setprop vstore (VStr s_dtop) point
|
|
2216
|
+
terrs <- emptyList
|
|
2217
|
+
meta <- readIORef (iMeta inj)
|
|
2218
|
+
let idef = (defaultInjDef terrs) { dExtra = vstore, dMeta = meta }
|
|
2219
|
+
_ <- validate (IDef idef) point term
|
|
2220
|
+
tesz <- size terrs
|
|
2221
|
+
when (tesz == 0) $ do pp <- pathify ppath; sp <- stringify point; st <- stringify term; pushErr inj ("NOT:" ++ pp ++ cross ++ sp ++ " fail:" ++ st)
|
|
2222
|
+
gkey <- getelem path (VNum (-2))
|
|
2223
|
+
nodes <- readIORef (iNodes inj); gp <- getelem nodes (VNum (-2))
|
|
2224
|
+
_ <- setprop gp gkey point; return ()
|
|
2225
|
+
return VNoval
|
|
2226
|
+
|
|
2227
|
+
-- | Apply a numeric comparison to two values (False unless both are numbers).
|
|
2228
|
+
numCmp :: Value -> Value -> (Double -> Double -> Bool) -> Bool
|
|
2229
|
+
numCmp a b op = case (a, b) of (VNum x, VNum y) -> op x y; _ -> False
|
|
2230
|
+
|
|
2231
|
+
-- | The @$LT@\/@$GT@\/@$LTE@\/@$GTE@\/@$EQ@ comparison query operators.
|
|
2232
|
+
selectCmp :: Injector
|
|
2233
|
+
selectCmp inj _ refstr store = do
|
|
2234
|
+
mode <- readIORef (iMode inj)
|
|
2235
|
+
when (mode == m_keypre) $ do
|
|
2236
|
+
parent <- readIORef (iParent inj); key <- readIORef (iKey inj)
|
|
2237
|
+
term <- getprop parent key
|
|
2238
|
+
path <- readIORef (iPath inj); gkey <- getelem path (VNum (-2))
|
|
2239
|
+
ppath <- sliceM path (VNum (-1)) VNoval False
|
|
2240
|
+
point <- getpath INone store ppath
|
|
2241
|
+
pass <- case refstr of
|
|
2242
|
+
"$GT" -> return (numCmp point term (>))
|
|
2243
|
+
"$LT" -> return (numCmp point term (<))
|
|
2244
|
+
"$GTE" -> return (numCmp point term (>=))
|
|
2245
|
+
"$LTE" -> return (numCmp point term (<=))
|
|
2246
|
+
"$LIKE" -> case term of { VStr t -> do { sp <- stringify point; return (Vregex.testStr t sp) }; _ -> return False }
|
|
2247
|
+
_ -> return False
|
|
2248
|
+
if pass then do nodes <- readIORef (iNodes inj); gp <- getelem nodes (VNum (-2)); _ <- setprop gp gkey point; return ()
|
|
2249
|
+
else do pp <- pathify ppath; sp <- stringify point; st <- stringify term; pushErr inj ("CMP: " ++ pp ++ cross ++ sp ++ " fail:" ++ refstr ++ " " ++ st)
|
|
2250
|
+
return VNoval
|
|
2251
|
+
|
|
2252
|
+
-- | Query a data structure with a by-example selection expression.
|
|
2253
|
+
select :: Value -> Value -> IO Value
|
|
2254
|
+
select children0 query =
|
|
2255
|
+
if not (isnode children0) then emptyList
|
|
2256
|
+
else do
|
|
2257
|
+
children <- if ismap children0
|
|
2258
|
+
then do ps <- itemsPairs children0; xs <- mapM (\(k, n) -> do _ <- setprop n (VStr s_dkey) (VStr k); return n) ps; mkList xs
|
|
2259
|
+
else do its <- listItems children0; xs <- mapM (\(i, n) -> if ismap n then do _ <- setprop n (VStr s_dkey) (vint i); return n else return n) (zip [0 ..] its); mkList xs
|
|
2260
|
+
results <- emptyList
|
|
2261
|
+
extra <- emptyMap
|
|
2262
|
+
forM_ [("$AND", selectAnd), ("$OR", selectOr), ("$NOT", selectNot), ("$GT", selectCmp), ("$LT", selectCmp), ("$GTE", selectCmp), ("$LTE", selectCmp), ("$LIKE", selectCmp)] $ \(k, f) -> setprop extra (VStr k) (VFunc f) >> return ()
|
|
2263
|
+
q <- clone query
|
|
2264
|
+
_ <- walk (Just (\_ vv _ _ -> do when (ismap vv) (do bo <- getpropAlt (VBool True) vv (VStr s_bopen); _ <- setprop vv (VStr s_bopen) bo; return ()); return vv)) Nothing VNoval q
|
|
2265
|
+
citems <- listItems children
|
|
2266
|
+
forM_ citems $ \child -> do
|
|
2267
|
+
errs <- emptyList
|
|
2268
|
+
meta <- emptyMap; _ <- setprop meta (VStr s_bexact) (VBool True)
|
|
2269
|
+
qc <- clone q
|
|
2270
|
+
let idef = (defaultInjDef errs) { dMeta = meta, dExtra = extra }
|
|
2271
|
+
_ <- validate (IDef idef) child qc
|
|
2272
|
+
esz <- size errs
|
|
2273
|
+
when (esz == 0) $ do rsz <- size results; _ <- setprop results (VNum (fromIntegral rsz)) child; return ()
|
|
2274
|
+
return results
|
|
2275
|
+
|
|
2276
|
+
-- ---------------------------------------------------------------------------
|
|
2277
|
+
-- builders
|
|
2278
|
+
-- ---------------------------------------------------------------------------
|
|
2279
|
+
|
|
2280
|
+
-- | Build a map node from a flat @[k1, v1, k2, v2, ...]@ value list.
|
|
2281
|
+
jm :: [Value] -> IO Value
|
|
2282
|
+
jm kv = do
|
|
2283
|
+
m <- emptyMap
|
|
2284
|
+
let go [] = return ()
|
|
2285
|
+
go (k0:rest) = do
|
|
2286
|
+
k <- case k0 of VNull -> return "null"; VStr s -> return s; _ -> stringify k0
|
|
2287
|
+
let (vv, rest') = case rest of (x:xs) -> (x, xs); [] -> (VNull, [])
|
|
2288
|
+
_ <- setprop m (VStr k) vv
|
|
2289
|
+
go rest'
|
|
2290
|
+
go kv
|
|
2291
|
+
return m
|
|
2292
|
+
|
|
2293
|
+
-- | Build a list node from the given values.
|
|
2294
|
+
jt :: [Value] -> IO Value
|
|
2295
|
+
jt = mkList
|
|
2296
|
+
|
|
2297
|
+
-- | Alias for 'typename'.
|
|
2298
|
+
tn :: Int -> String
|
|
2299
|
+
tn = typename
|