@voxgig/sdkgen 4.35.3 → 4.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/dist/cmp/ReadmeTop.js +1 -1
  3. package/dist/cmp/ReadmeTop.js.map +1 -1
  4. package/dist/helpers/opExample.d.ts +4 -1
  5. package/dist/helpers/opExample.js +11 -1
  6. package/dist/helpers/opExample.js.map +1 -1
  7. package/dist/helpers/opShape.d.ts +2 -1
  8. package/dist/helpers/opShape.js +53 -26
  9. package/dist/helpers/opShape.js.map +1 -1
  10. package/dist/helpers/pointPath.d.ts +2 -1
  11. package/dist/helpers/pointPath.js +17 -0
  12. package/dist/helpers/pointPath.js.map +1 -1
  13. package/dist/helpers/testPolicy.d.ts +48 -2
  14. package/dist/helpers/testPolicy.js +265 -0
  15. package/dist/helpers/testPolicy.js.map +1 -1
  16. package/dist/sdkgen.d.ts +7 -7
  17. package/dist/sdkgen.js +26 -4
  18. package/dist/sdkgen.js.map +1 -1
  19. package/dist/tsconfig.tsbuildinfo +1 -1
  20. package/package.json +1 -1
  21. package/project/.sdk/src/cmp/c/PrepareAuth_c.ts +10 -4
  22. package/project/.sdk/src/cmp/c/ReadmeEntity_c.ts +2 -2
  23. package/project/.sdk/src/cmp/c/ReadmeHowto_c.ts +2 -2
  24. package/project/.sdk/src/cmp/c/ReadmeQuick_c.ts +6 -5
  25. package/project/.sdk/src/cmp/c/ReadmeRef_c.ts +3 -3
  26. package/project/.sdk/src/cmp/c/ReadmeTopQuick_c.ts +2 -2
  27. package/project/.sdk/src/cmp/c/ReadmeTopTest_c.ts +2 -2
  28. package/project/.sdk/src/cmp/c/TestDirect_c.ts +2 -6
  29. package/project/.sdk/src/cmp/clojure/ReadmeEntity_clojure.ts +2 -2
  30. package/project/.sdk/src/cmp/clojure/ReadmeHowto_clojure.ts +2 -2
  31. package/project/.sdk/src/cmp/clojure/ReadmeQuick_clojure.ts +4 -4
  32. package/project/.sdk/src/cmp/clojure/ReadmeRef_clojure.ts +3 -3
  33. package/project/.sdk/src/cmp/clojure/ReadmeTopQuick_clojure.ts +2 -2
  34. package/project/.sdk/src/cmp/clojure/ReadmeTopTest_clojure.ts +2 -2
  35. package/project/.sdk/src/cmp/cpp/ReadmeEntity_cpp.ts +2 -2
  36. package/project/.sdk/src/cmp/cpp/ReadmeHowto_cpp.ts +2 -2
  37. package/project/.sdk/src/cmp/cpp/ReadmeQuick_cpp.ts +4 -4
  38. package/project/.sdk/src/cmp/cpp/ReadmeRef_cpp.ts +3 -3
  39. package/project/.sdk/src/cmp/cpp/ReadmeTopQuick_cpp.ts +2 -2
  40. package/project/.sdk/src/cmp/cpp/ReadmeTopTest_cpp.ts +2 -2
  41. package/project/.sdk/src/cmp/cpp/TestDirect_cpp.ts +2 -6
  42. package/project/.sdk/src/cmp/cpp/TestEntity_cpp.ts +51 -3
  43. package/project/.sdk/src/cmp/csharp/ReadmeEntity_csharp.ts +2 -2
  44. package/project/.sdk/src/cmp/csharp/ReadmeHowto_csharp.ts +2 -2
  45. package/project/.sdk/src/cmp/csharp/ReadmeQuick_csharp.ts +5 -5
  46. package/project/.sdk/src/cmp/csharp/ReadmeRef_csharp.ts +3 -3
  47. package/project/.sdk/src/cmp/csharp/ReadmeTopQuick_csharp.ts +3 -3
  48. package/project/.sdk/src/cmp/csharp/ReadmeTopTest_csharp.ts +2 -2
  49. package/project/.sdk/src/cmp/csharp/TestDirect_csharp.ts +41 -19
  50. package/project/.sdk/src/cmp/csharp/TestEntity_csharp.ts +105 -27
  51. package/project/.sdk/src/cmp/elixir/ReadmeEntity_elixir.ts +2 -2
  52. package/project/.sdk/src/cmp/elixir/ReadmeHowto_elixir.ts +2 -2
  53. package/project/.sdk/src/cmp/elixir/ReadmeQuick_elixir.ts +4 -4
  54. package/project/.sdk/src/cmp/elixir/ReadmeRef_elixir.ts +3 -3
  55. package/project/.sdk/src/cmp/elixir/ReadmeTopQuick_elixir.ts +2 -2
  56. package/project/.sdk/src/cmp/elixir/ReadmeTopTest_elixir.ts +2 -2
  57. package/project/.sdk/src/cmp/go/EntityOperation_go.ts +2 -2
  58. package/project/.sdk/src/cmp/go/Entity_go.ts +5 -4
  59. package/project/.sdk/src/cmp/go/MainEntity_go.ts +1 -1
  60. package/project/.sdk/src/cmp/go/Main_go.ts +9 -5
  61. package/project/.sdk/src/cmp/go/PrepareAuth_go.ts +24 -15
  62. package/project/.sdk/src/cmp/go/ReadmeEntity_go.ts +2 -2
  63. package/project/.sdk/src/cmp/go/ReadmeHowto_go.ts +2 -2
  64. package/project/.sdk/src/cmp/go/ReadmeModel_go.ts +3 -3
  65. package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +4 -4
  66. package/project/.sdk/src/cmp/go/ReadmeRef_go.ts +4 -4
  67. package/project/.sdk/src/cmp/go/ReadmeTopTest_go.ts +2 -2
  68. package/project/.sdk/src/cmp/go/TestDirect_go.ts +61 -26
  69. package/project/.sdk/src/cmp/go/TestEntity_go.ts +115 -32
  70. package/project/.sdk/src/cmp/go-cli/fragment/words.fragment.go +1 -1
  71. package/project/.sdk/src/cmp/go-mcp/fragment/tools.fragment.go +1 -1
  72. package/project/.sdk/src/cmp/java/ReadmeEntity_java.ts +2 -2
  73. package/project/.sdk/src/cmp/java/ReadmeHowto_java.ts +2 -2
  74. package/project/.sdk/src/cmp/java/ReadmeQuick_java.ts +5 -5
  75. package/project/.sdk/src/cmp/java/ReadmeRef_java.ts +3 -3
  76. package/project/.sdk/src/cmp/java/ReadmeTopQuick_java.ts +3 -3
  77. package/project/.sdk/src/cmp/java/ReadmeTopTest_java.ts +2 -2
  78. package/project/.sdk/src/cmp/java/TestDirect_java.ts +40 -20
  79. package/project/.sdk/src/cmp/java/TestEntity_java.ts +107 -26
  80. package/project/.sdk/src/cmp/js/ReadmeEntity_js.ts +2 -2
  81. package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +2 -2
  82. package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +4 -4
  83. package/project/.sdk/src/cmp/js/ReadmeRef_js.ts +3 -3
  84. package/project/.sdk/src/cmp/js/ReadmeTopTest_js.ts +2 -2
  85. package/project/.sdk/src/cmp/js/TestDirect_js.ts +68 -13
  86. package/project/.sdk/src/cmp/js/TestEntity_js.ts +46 -4
  87. package/project/.sdk/src/cmp/kotlin/ReadmeEntity_kotlin.ts +2 -2
  88. package/project/.sdk/src/cmp/kotlin/ReadmeHowto_kotlin.ts +2 -2
  89. package/project/.sdk/src/cmp/kotlin/ReadmeQuick_kotlin.ts +5 -5
  90. package/project/.sdk/src/cmp/kotlin/ReadmeRef_kotlin.ts +3 -3
  91. package/project/.sdk/src/cmp/kotlin/ReadmeTopQuick_kotlin.ts +3 -3
  92. package/project/.sdk/src/cmp/kotlin/ReadmeTopTest_kotlin.ts +2 -2
  93. package/project/.sdk/src/cmp/kotlin/TestDirect_kotlin.ts +41 -21
  94. package/project/.sdk/src/cmp/kotlin/TestEntity_kotlin.ts +99 -22
  95. package/project/.sdk/src/cmp/lua/ReadmeEntity_lua.ts +2 -2
  96. package/project/.sdk/src/cmp/lua/ReadmeHowto_lua.ts +2 -2
  97. package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +4 -4
  98. package/project/.sdk/src/cmp/lua/ReadmeRef_lua.ts +3 -3
  99. package/project/.sdk/src/cmp/lua/ReadmeTopQuick_lua.ts +3 -3
  100. package/project/.sdk/src/cmp/lua/ReadmeTopTest_lua.ts +2 -2
  101. package/project/.sdk/src/cmp/lua/TestDirect_lua.ts +40 -16
  102. package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +108 -30
  103. package/project/.sdk/src/cmp/ocaml/ReadmeEntity_ocaml.ts +2 -2
  104. package/project/.sdk/src/cmp/ocaml/ReadmeHowto_ocaml.ts +2 -2
  105. package/project/.sdk/src/cmp/ocaml/ReadmeQuick_ocaml.ts +4 -4
  106. package/project/.sdk/src/cmp/ocaml/ReadmeRef_ocaml.ts +3 -3
  107. package/project/.sdk/src/cmp/ocaml/ReadmeTopQuick_ocaml.ts +2 -2
  108. package/project/.sdk/src/cmp/ocaml/ReadmeTopTest_ocaml.ts +2 -2
  109. package/project/.sdk/src/cmp/perl/ReadmeEntity_perl.ts +2 -2
  110. package/project/.sdk/src/cmp/perl/ReadmeHowto_perl.ts +2 -2
  111. package/project/.sdk/src/cmp/perl/ReadmeQuick_perl.ts +4 -4
  112. package/project/.sdk/src/cmp/perl/ReadmeRef_perl.ts +3 -3
  113. package/project/.sdk/src/cmp/perl/ReadmeTopQuick_perl.ts +2 -2
  114. package/project/.sdk/src/cmp/perl/ReadmeTopTest_perl.ts +2 -2
  115. package/project/.sdk/src/cmp/perl/TestDirect_perl.ts +35 -16
  116. package/project/.sdk/src/cmp/perl/TestEntity_perl.ts +98 -22
  117. package/project/.sdk/src/cmp/php/ReadmeEntity_php.ts +2 -2
  118. package/project/.sdk/src/cmp/php/ReadmeHowto_php.ts +2 -2
  119. package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +4 -4
  120. package/project/.sdk/src/cmp/php/ReadmeRef_php.ts +3 -3
  121. package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +2 -2
  122. package/project/.sdk/src/cmp/php/ReadmeTopTest_php.ts +2 -2
  123. package/project/.sdk/src/cmp/php/TestDirect_php.ts +33 -16
  124. package/project/.sdk/src/cmp/php/TestEntity_php.ts +98 -29
  125. package/project/.sdk/src/cmp/py/ReadmeEntity_py.ts +2 -2
  126. package/project/.sdk/src/cmp/py/ReadmeHowto_py.ts +2 -2
  127. package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +4 -4
  128. package/project/.sdk/src/cmp/py/ReadmeRef_py.ts +3 -3
  129. package/project/.sdk/src/cmp/py/ReadmeTopQuick_py.ts +2 -2
  130. package/project/.sdk/src/cmp/py/ReadmeTopTest_py.ts +2 -2
  131. package/project/.sdk/src/cmp/py/TestDirect_py.ts +39 -16
  132. package/project/.sdk/src/cmp/py/TestEntity_py.ts +90 -27
  133. package/project/.sdk/src/cmp/rb/ReadmeEntity_rb.ts +2 -2
  134. package/project/.sdk/src/cmp/rb/ReadmeHowto_rb.ts +2 -2
  135. package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +4 -4
  136. package/project/.sdk/src/cmp/rb/ReadmeRef_rb.ts +3 -3
  137. package/project/.sdk/src/cmp/rb/ReadmeTopQuick_rb.ts +2 -2
  138. package/project/.sdk/src/cmp/rb/ReadmeTopTest_rb.ts +2 -2
  139. package/project/.sdk/src/cmp/rb/TestClean_rb.ts +1 -1
  140. package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +33 -16
  141. package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +90 -25
  142. package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +3 -3
  143. package/project/.sdk/src/cmp/rust/EntityOperation_rust.ts +1 -1
  144. package/project/.sdk/src/cmp/rust/Main_rust.ts +3 -1
  145. package/project/.sdk/src/cmp/rust/ReadmeEntity_rust.ts +2 -2
  146. package/project/.sdk/src/cmp/rust/ReadmeHowto_rust.ts +3 -3
  147. package/project/.sdk/src/cmp/rust/ReadmeModel_rust.ts +1 -1
  148. package/project/.sdk/src/cmp/rust/ReadmeQuick_rust.ts +5 -5
  149. package/project/.sdk/src/cmp/rust/ReadmeRef_rust.ts +4 -4
  150. package/project/.sdk/src/cmp/rust/ReadmeTopQuick_rust.ts +3 -3
  151. package/project/.sdk/src/cmp/rust/ReadmeTopTest_rust.ts +3 -3
  152. package/project/.sdk/src/cmp/rust/TestClean_rust.ts +1 -1
  153. package/project/.sdk/src/cmp/rust/TestDirect_rust.ts +40 -12
  154. package/project/.sdk/src/cmp/rust/TestEntity_rust.ts +109 -26
  155. package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +2 -2
  156. package/project/.sdk/src/cmp/scala/ReadmeEntity_scala.ts +2 -2
  157. package/project/.sdk/src/cmp/scala/ReadmeHowto_scala.ts +2 -2
  158. package/project/.sdk/src/cmp/scala/ReadmeQuick_scala.ts +5 -5
  159. package/project/.sdk/src/cmp/scala/ReadmeRef_scala.ts +3 -3
  160. package/project/.sdk/src/cmp/scala/ReadmeTopQuick_scala.ts +3 -3
  161. package/project/.sdk/src/cmp/scala/ReadmeTopTest_scala.ts +2 -2
  162. package/project/.sdk/src/cmp/scala/TestDirect_scala.ts +2 -6
  163. package/project/.sdk/src/cmp/scala/TestEntity_scala.ts +36 -7
  164. package/project/.sdk/src/cmp/swift/ReadmeEntity_swift.ts +2 -2
  165. package/project/.sdk/src/cmp/swift/ReadmeHowto_swift.ts +2 -2
  166. package/project/.sdk/src/cmp/swift/ReadmeQuick_swift.ts +5 -5
  167. package/project/.sdk/src/cmp/swift/ReadmeRef_swift.ts +3 -3
  168. package/project/.sdk/src/cmp/swift/ReadmeTopQuick_swift.ts +2 -2
  169. package/project/.sdk/src/cmp/swift/ReadmeTopTest_swift.ts +2 -2
  170. package/project/.sdk/src/cmp/ts/ReadmeEntity_ts.ts +2 -2
  171. package/project/.sdk/src/cmp/ts/ReadmeExamplesTest_ts.ts +49 -19
  172. package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +2 -2
  173. package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +4 -4
  174. package/project/.sdk/src/cmp/ts/ReadmeRef_ts.ts +3 -3
  175. package/project/.sdk/src/cmp/ts/ReadmeTopTest_ts.ts +3 -3
  176. package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +54 -23
  177. package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +49 -4
  178. package/project/.sdk/src/cmp/zig/ReadmeEntity_zig.ts +2 -2
  179. package/project/.sdk/src/cmp/zig/ReadmeHowto_zig.ts +2 -2
  180. package/project/.sdk/src/cmp/zig/ReadmeQuick_zig.ts +4 -4
  181. package/project/.sdk/src/cmp/zig/ReadmeRef_zig.ts +3 -3
  182. package/project/.sdk/src/cmp/zig/ReadmeTopQuick_zig.ts +2 -2
  183. package/project/.sdk/src/cmp/zig/ReadmeTopTest_zig.ts +2 -2
  184. package/project/.sdk/tm/c/core/sdk.h +2 -2
  185. package/project/.sdk/tm/c/tests/primary_utility_test.c +37 -0
  186. package/project/.sdk/tm/c/utility/fetcher.c +31 -1
  187. package/project/.sdk/tm/c/utility/make_url.c +6 -2
  188. package/project/.sdk/tm/clojure/src/sdk/core.clj +21 -3
  189. package/project/.sdk/tm/clojure/test/sdk/test/pipeline.clj +34 -0
  190. package/project/.sdk/tm/cpp/test/primary_utility_test.cpp +37 -0
  191. package/project/.sdk/tm/cpp/utility/pipeline.hpp +28 -2
  192. package/project/.sdk/tm/csharp/test/PrimaryUtilityTest.cs +40 -0
  193. package/project/.sdk/tm/csharp/utility/Fetcher.cs +27 -0
  194. package/project/.sdk/tm/csharp/utility/MakeUrl.cs +7 -2
  195. package/project/.sdk/tm/elixir/lib/projectname/utility.ex +30 -3
  196. package/project/.sdk/tm/elixir/test/pipeline_test.exs +23 -0
  197. package/project/.sdk/tm/go/core/helpers.go +1 -1
  198. package/project/.sdk/tm/go/core/types.go +9 -1
  199. package/project/.sdk/tm/go/test/feature_corpus_test.go +3 -4
  200. package/project/.sdk/tm/go/test/primary_utility_test.go +28 -0
  201. package/project/.sdk/tm/go/utility/fetcher.go +26 -0
  202. package/project/.sdk/tm/go/utility/make_url.go +5 -2
  203. package/project/.sdk/tm/java/test/FeatureCorpusTest.java +4 -5
  204. package/project/.sdk/tm/java/test/PrimaryUtilityTest.java +49 -0
  205. package/project/.sdk/tm/java/utility/Fetcher.java +24 -0
  206. package/project/.sdk/tm/java/utility/MakeUrl.java +6 -2
  207. package/project/.sdk/tm/js/src/utility/FetcherUtility.js +24 -0
  208. package/project/.sdk/tm/js/src/utility/MakeUrlUtility.js +6 -2
  209. package/project/.sdk/tm/js/test/feature/Corpus.test.js +7 -6
  210. package/project/.sdk/tm/js/test/live-entity.js +18 -6
  211. package/project/.sdk/tm/js/test/live-runner.js +15 -3
  212. package/project/.sdk/tm/js/test/utility/PrimaryUtility.test.js +25 -0
  213. package/project/.sdk/tm/kotlin/test/PrimaryUtilityTest.kt +48 -0
  214. package/project/.sdk/tm/kotlin/utility/Fetcher.kt +20 -0
  215. package/project/.sdk/tm/kotlin/utility/MakeSpecUrl.kt +6 -2
  216. package/project/.sdk/tm/lua/test/pipeline_test.lua +27 -0
  217. package/project/.sdk/tm/lua/test/primary_utility_test.lua +36 -0
  218. package/project/.sdk/tm/lua/utility/fetcher.lua +31 -0
  219. package/project/.sdk/tm/lua/utility/make_url.lua +6 -2
  220. package/project/.sdk/tm/ocaml/Makefile +5 -1
  221. package/project/.sdk/tm/ocaml/sdk_runtime.ml +36 -4
  222. package/project/.sdk/tm/ocaml/test/t_pipeline.ml +22 -0
  223. package/project/.sdk/tm/perl/t/primary_utility.t +22 -0
  224. package/project/.sdk/tm/perl/utility/fetcher.pm +18 -0
  225. package/project/.sdk/tm/perl/utility/make_url.pm +4 -2
  226. package/project/.sdk/tm/php/test/FeatureCorpusTest.php +6 -5
  227. package/project/.sdk/tm/php/test/PipelineTest.php +31 -7
  228. package/project/.sdk/tm/php/utility/Fetcher.php +34 -27
  229. package/project/.sdk/tm/php/utility/MakeOptions.php +2 -1
  230. package/project/.sdk/tm/php/utility/MakeUrl.php +6 -2
  231. package/project/.sdk/tm/py/pkg/utility/fetcher.py +23 -0
  232. package/project/.sdk/tm/py/pkg/utility/make_url.py +5 -2
  233. package/project/.sdk/tm/py/test/test_feature_corpus.py +5 -5
  234. package/project/.sdk/tm/py/test/test_primary_utility.py +21 -0
  235. package/project/.sdk/tm/rb/core/context.rb +1 -1
  236. package/project/.sdk/tm/rb/core/error.rb +20 -1
  237. package/project/.sdk/tm/rb/test/feature_corpus_test.rb +4 -5
  238. package/project/.sdk/tm/rb/test/feature_test.rb +2 -2
  239. package/project/.sdk/tm/rb/test/omni.rb +1 -1
  240. package/project/.sdk/tm/rb/test/pipeline_test.rb +19 -2
  241. package/project/.sdk/tm/rb/test/primary_utility_test.rb +28 -1
  242. package/project/.sdk/tm/rb/utility/fetcher.rb +20 -1
  243. package/project/.sdk/tm/rb/utility/make_error.rb +1 -1
  244. package/project/.sdk/tm/rb/utility/make_url.rb +4 -2
  245. package/project/.sdk/tm/rust/core/helpers.rs +1 -1
  246. package/project/.sdk/tm/rust/core/types.rs +2 -2
  247. package/project/.sdk/tm/rust/tests/primary_utility_test.rs +34 -0
  248. package/project/.sdk/tm/rust/utility/fetcher.rs +27 -0
  249. package/project/.sdk/tm/rust/utility/make_url.rs +7 -2
  250. package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +51 -1
  251. package/project/.sdk/tm/scala/utility/Fetcher.scala +16 -0
  252. package/project/.sdk/tm/scala/utility/Make.scala +6 -2
  253. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Fetcher.swift +24 -0
  254. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Make.swift +6 -2
  255. package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/PrimaryUtilityTest.swift +34 -0
  256. package/project/.sdk/tm/ts/src/utility/FetcherUtility.ts +24 -0
  257. package/project/.sdk/tm/ts/src/utility/MakeUrlUtility.ts +6 -2
  258. package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +7 -6
  259. package/project/.sdk/tm/ts/test/live-entity.ts +20 -5
  260. package/project/.sdk/tm/ts/test/live-runner.ts +17 -3
  261. package/project/.sdk/tm/ts/test/utility/PrimaryUtility.test.ts +25 -0
  262. package/project/.sdk/tm/zig/core/utility.zig +30 -3
  263. package/project/.sdk/tm/zig/test/primary_utility_test.zig +28 -0
  264. package/project/sdkgen-package.json +1 -1
  265. package/src/cmp/ReadmeTop.ts +3 -3
  266. package/src/helpers/opExample.ts +16 -1
  267. package/src/helpers/opShape.ts +64 -30
  268. package/src/helpers/pointPath.ts +19 -0
  269. package/src/helpers/testPolicy.ts +316 -2
  270. package/src/sdkgen.ts +37 -5
@@ -2,8 +2,39 @@
2
2
 
3
3
  local vs = require("utility.struct.struct")
4
4
  local json = require("dkjson")
5
+ local ProjectNameError = require("core.error")
6
+
7
+ local GETONLY_ENV = "VOXGIG_GETONLY_GUARD"
8
+
9
+ -- A GET-only live run refuses any other method before it is sent. The error
10
+ -- names the path alone: the query can carry a credential.
11
+ local function getonly_refusal(fullurl, method)
12
+ method = string.upper(tostring(method or ""))
13
+ if method == "" then
14
+ method = "GET"
15
+ end
16
+ if os.getenv(GETONLY_ENV) ~= "TRUE" or method == "GET" then
17
+ return nil
18
+ end
19
+ local rest = fullurl
20
+ local scheme = string.find(rest, "://", 1, true)
21
+ if scheme then
22
+ rest = string.gsub(string.sub(rest, scheme + 3), "^[^/?#]*", "")
23
+ end
24
+ local path = string.match(rest, "^[^?#]*")
25
+ if path == "" then
26
+ path = "/"
27
+ end
28
+ return ProjectNameError.new("fetch_getonly_block",
29
+ "[GET-ONLY GUARD] blocked " .. method .. " " .. path)
30
+ end
5
31
 
6
32
  local function default_http_fetch(fullurl, fetchdef)
33
+ local refused = getonly_refusal(fullurl, fetchdef["method"])
34
+ if refused then
35
+ return nil, refused
36
+ end
37
+
7
38
  -- Use LuaSocket or similar for real HTTP requests.
8
39
  -- This is the default live implementation.
9
40
  local http_ok, http = pcall(require, "socket.http")
@@ -24,13 +24,17 @@ local function make_url_util(ctx)
24
24
  authquery[name] = true
25
25
  end
26
26
 
27
- -- A route the definition ends with a slash keeps it: a server such as a
28
- -- Django REST one redirects or refuses the route without it.
27
+ -- A route the definition ends with a slash keeps it, for a Django REST server,
28
+ -- and a host with no path takes /, or luasocket reads a query as the host.
29
29
  local orig = ctx.point ~= nil and vs.getprop(ctx.point, "orig") or nil
30
30
  if type(orig) == "string" and orig:sub(-1) == "/" and (spec.suffix == nil or spec.suffix == "")
31
31
  and url:sub(-1) ~= "/" then
32
32
  url = url .. "/"
33
33
  end
34
+ local authority = url:find("://", 1, true)
35
+ if authority ~= nil and 1 < authority and not url:find("[/?#]", authority + 3) then
36
+ url = url .. "/"
37
+ end
34
38
 
35
39
  local param_items = vs.items(spec.params)
36
40
  if param_items ~= nil then
@@ -142,11 +142,15 @@ test-primary: run_primary_corpus
142
142
  test-concurrency: run_concurrency_test
143
143
  ./run_concurrency_test
144
144
 
145
+ # The sdk suite sets the GET-only flag with Unix.putenv; a feature tier that
146
+ # links unix.cma already brings it.
147
+ SDK_UNIX = $(if $(filter unix.cma,$(FEATURE_LIB)),,unix.cma)
148
+
145
149
  # Every executable that links the RUNTIME links the gated feature tier with
146
150
  # it: library archives FIRST (an archive must precede the modules that use
147
151
  # it), stub objects and link flags LAST.
148
152
  run_sdk_test: $(SDK_TEST) $(FEATURE_OBJ)
149
- $(OCAMLC) $(INC) $(FEATURE_LIB) $(SDK_TEST) $(FEATURE_OBJ) $(FEATURE_LINK) -o run_sdk_test
153
+ $(OCAMLC) $(INC) -I +unix $(SDK_UNIX) $(FEATURE_LIB) $(SDK_TEST) $(FEATURE_OBJ) $(FEATURE_LINK) -o run_sdk_test
150
154
 
151
155
  run_omni_smoke: $(SMOKE_SRC)
152
156
  $(OCAMLC) $(INC) $(SMOKE_SRC) -o run_omni_smoke
@@ -1351,12 +1351,19 @@ let make_url_util (ctx : ctx) : (string * sdk_error option) =
1351
1351
  | _, None -> ("", Some (ctx_make_error ctx "url_no_result" "Expected context result property to be defined."))
1352
1352
  | Some spec, Some result ->
1353
1353
  let url = ref (join ~sep:(Str "/") ~url:true (ja [Str spec.sp_base; Str spec.sp_prefix; Str spec.sp_path; Str spec.sp_suffix])) in
1354
- (* A route the definition ends with a slash keeps it: a server such as a
1355
- * Django REST one redirects or refuses the route without it. *)
1354
+ (* A route the definition ends with a slash keeps it, for a Django REST server,
1355
+ * and a host with no path takes /, or luasocket reads a query as the host. *)
1356
1356
  let ends_slash s = String.length s > 0 && '/' = s.[String.length s - 1] in
1357
1357
  (match getp ctx.c_point "orig" with
1358
1358
  | Str o when ends_slash o && spec.sp_suffix = "" && not (ends_slash !url) -> url := !url ^ "/"
1359
1359
  | _ -> ());
1360
+ let ulen = String.length !url in
1361
+ let rec scheme_end i =
1362
+ if i + 3 > ulen then -1 else if String.sub !url i 3 = "://" then i else scheme_end (i + 1) in
1363
+ let authority = scheme_end 0 in
1364
+ if 0 < authority && not (String.exists (fun c -> c = '/' || c = '?' || c = '#')
1365
+ (String.sub !url (authority + 3) (ulen - authority - 3)))
1366
+ then url := !url ^ "/";
1360
1367
  let resmatch = empty_map () in
1361
1368
  List.iter (fun key ->
1362
1369
  let v = getp spec.sp_params key in
@@ -1522,6 +1529,28 @@ let make_result_util (ctx : ctx) : (result option * sdk_error option) =
1522
1529
 
1523
1530
  (* ----- fetcher (innermost transport) ----- *)
1524
1531
 
1532
+ (* A GET-only live run refuses any other method before it is sent. The error
1533
+ * names the path alone: the query can carry a credential. *)
1534
+ let getonly_refusal (ctx : ctx) (fullurl : string) (fetchdef : value) : sdk_error option =
1535
+ let meth = match get_str fetchdef "method" with
1536
+ | Some m when m <> "" -> String.uppercase_ascii m
1537
+ | _ -> "GET" in
1538
+ if Sys.getenv_opt "VOXGIG_GETONLY_GUARD" <> Some "TRUE" || meth = "GET" then None
1539
+ else begin
1540
+ let index_from s i pred =
1541
+ let rec go j = if j >= String.length s || pred s.[j] then j else go (j + 1) in go i in
1542
+ let n = String.length fullurl in
1543
+ let rec scheme i = if i + 3 > n then None
1544
+ else if String.sub fullurl i 3 = "://" then Some (i + 3) else scheme (i + 1) in
1545
+ let start = match scheme 0 with
1546
+ | Some a -> index_from fullurl a (fun c -> c = '/' || c = '?' || c = '#')
1547
+ | None -> 0 in
1548
+ let stop = index_from fullurl start (fun c -> c = '?' || c = '#') in
1549
+ let path = if stop = start then "/" else String.sub fullurl start (stop - start) in
1550
+ Some (ctx_make_error ctx "fetch_getonly_block"
1551
+ ("[GET-ONLY GUARD] blocked " ^ meth ^ " " ^ path))
1552
+ end
1553
+
1525
1554
  let fetcher_util (ctx : ctx) (fullurl : string) (fetchdef : value) : (value * sdk_error option) =
1526
1555
  let client = cc ctx in
1527
1556
  if client.cl_mode <> "live" then
@@ -1543,8 +1572,11 @@ let fetcher_util (ctx : ctx) (fullurl : string) (fetchdef : value) : (value * sd
1543
1572
  | Noval | Null ->
1544
1573
  (* No live HTTP transport is bundled (dependency-free build); tests
1545
1574
  * run against the test-feature mock or a system.fetch injection. *)
1546
- (Noval, Some (ctx_make_error ctx "fetch_no_transport"
1547
- "No live HTTP transport in this build; provide options.system.fetch."))
1575
+ (match getonly_refusal ctx fullurl fetchdef with
1576
+ | Some refused -> (Noval, Some refused)
1577
+ | None ->
1578
+ (Noval, Some (ctx_make_error ctx "fetch_no_transport"
1579
+ "No live HTTP transport in this build; provide options.system.fetch.")))
1548
1580
  | _ -> (Noval, Some (ctx_make_error ctx "fetch_invalid" "system.fetch is not a valid function"))
1549
1581
  end
1550
1582
 
@@ -227,6 +227,28 @@ let () =
227
227
  | (Some r, None) -> (match r.rs_err with Some e -> check_str "code" e.err_code "request_no_response" | None -> failwith "expected resp err")
228
228
  | _ -> failwith "unexpected");
229
229
 
230
+ (* Nothing listens on port 9; this target has no transport of its own, so
231
+ * a request the guard let through fails as fetch_no_transport. *)
232
+ test "fetcher.getonly_guard" (fun () ->
233
+ let cl = Sdk_client.make (jo [("base", Str "http://127.0.0.1:9")]) in
234
+ let ctx = mk_ctx cl "create" in
235
+ let url = "http://127.0.0.1:9/planet/p1?apikey=GUARDKEY01" in
236
+ let def m = jo [("method", Str m); ("headers", empty_map ())] in
237
+ let prior = Option.value (Sys.getenv_opt "VOXGIG_GETONLY_GUARD") ~default:"" in
238
+ Unix.putenv "VOXGIG_GETONLY_GUARD" "TRUE";
239
+ let refused = cl.cl_utility.u_fetcher ctx url (def "POST") in
240
+ let sent = cl.cl_utility.u_fetcher ctx url (def "GET") in
241
+ Unix.putenv "VOXGIG_GETONLY_GUARD" prior;
242
+ (match refused with
243
+ | (_, Some e) ->
244
+ check_str "code" e.err_code "fetch_getonly_block";
245
+ check "path" (substr_contains e.err_msg "[GET-ONLY GUARD] blocked POST /planet/p1");
246
+ check "query" (not (substr_contains e.err_msg "GUARDKEY01"))
247
+ | _ -> failwith "expected the POST to be refused");
248
+ match sent with
249
+ | (_, Some e) -> check_str "get" e.err_code "fetch_no_transport"
250
+ | _ -> failwith "expected the GET to pass the guard");
251
+
230
252
  test "make_fetch_def.guards_spec" (fun () ->
231
253
  let cl = client () in
232
254
  let ctx = mk_ctx cl "load" in
@@ -430,6 +430,28 @@ runsection('makeError', sub {
430
430
  like("$err", qr/blocked/, 'fetcher blocked: error contains "blocked"');
431
431
  }
432
432
 
433
+ # Nothing listens on port 9: a request the guard let through fails there.
434
+ {
435
+ my $live_client = ProjectNameSDK->new({ 'base' => 'http://127.0.0.1:9' });
436
+ my $live_utility = $live_client->get_utility;
437
+ my $ctx = $live_utility->{make_context}->({
438
+ 'opname' => 'create',
439
+ 'client' => $live_client,
440
+ 'utility' => $live_utility,
441
+ }, undef);
442
+ my $url = 'http://127.0.0.1:9/planet/p1?apikey=GUARDKEY01';
443
+ local $ENV{VOXGIG_GETONLY_GUARD} = 'TRUE';
444
+
445
+ my (undef, $err) = $live_utility->{fetcher}->($ctx, $url, { 'method' => 'POST', 'headers' => {} });
446
+ is(ref $err && $err->{code}, 'fetch_getonly_block', 'fetcher getonly: a POST is refused');
447
+ like($err->{msg}, qr{\[GET-ONLY GUARD\] blocked POST /planet/p1}, 'fetcher getonly: names the path');
448
+ unlike($err->{msg}, qr/GUARDKEY01/, 'fetcher getonly: leaves out the query');
449
+
450
+ my (undef, $geterr) = $live_utility->{fetcher}->($ctx, $url, { 'method' => 'GET', 'headers' => {} });
451
+ ok(defined $geterr && !(ref $geterr && 'fetch_getonly_block' eq ($geterr->{code} // '')),
452
+ 'fetcher getonly: a GET reaches the closed port');
453
+ }
454
+
433
455
 
434
456
  # === makeContext ===
435
457
 
@@ -12,6 +12,7 @@ my $__dir;
12
12
  BEGIN { $__dir = File::Basename::dirname(Cwd::abs_path(__FILE__)) }
13
13
  require(Cwd::abs_path("$__dir/../lib/Voxgig/Struct.pm"));
14
14
  require(Cwd::abs_path("$__dir/../core/helpers.pm"));
15
+ require(Cwd::abs_path("$__dir/../core/error.pm"));
15
16
 
16
17
  package ProjectNameUtilities;
17
18
 
@@ -27,11 +28,28 @@ sub _http_client {
27
28
  return $HTTP_CLIENTS{$key} //= HTTP::Tiny->new(%new_args);
28
29
  }
29
30
 
31
+ our $GETONLY_ENV = 'VOXGIG_GETONLY_GUARD';
32
+
33
+ # A GET-only live run refuses any other method before it is sent. The error
34
+ # names the path alone: the query can carry a credential.
35
+ sub getonly_refusal {
36
+ my ($fullurl, $method) = @_;
37
+ return undef if ($ENV{$GETONLY_ENV} // '') ne 'TRUE' || 'GET' eq $method;
38
+ my $rest = "$fullurl";
39
+ $rest =~ s{\A[^:/?#]*://[^/?#]*}{};
40
+ my ($path) = $rest =~ m{\A([^?#]*)};
41
+ $path = '/' if '' eq $path;
42
+ return ProjectNameError->new('fetch_getonly_block',
43
+ "[GET-ONLY GUARD] blocked $method $path");
44
+ }
45
+
30
46
  our $DefaultHttpFetch = sub {
31
47
  my ($fullurl, $fetchdef) = @_;
32
48
  $fetchdef = {} unless defined $fetchdef;
33
49
 
34
50
  my $method = uc(defined $fetchdef->{method} ? "$fetchdef->{method}" : 'GET');
51
+ my $refused = getonly_refusal($fullurl, $method);
52
+ return (undef, $refused) if $refused;
35
53
  my $body = $fetchdef->{body};
36
54
  my $headers = Voxgig::Struct::ismap($fetchdef->{headers}) ? $fetchdef->{headers} : {};
37
55
 
@@ -32,11 +32,13 @@ $REGISTRY{make_url} = sub {
32
32
  # Sent with the request, never recorded as the entity's match.
33
33
  my %authquery = map { $_ => 1 } @{ $spec->{authquery} || [] };
34
34
 
35
- # A route the definition ends with a slash keeps it: a server such as a
36
- # Django REST one redirects or refuses the route without it.
35
+ # A route the definition ends with a slash keeps it, for a Django REST server,
36
+ # and a host with no path takes /, or luasocket reads a query as the host.
37
37
  my $orig = $ctx->{point} ? ProjectNameHelpers::gp($ctx->{point}, 'orig') : undef;
38
38
  $url .= '/' if defined $orig && !ref $orig && $orig =~ m{/\z}
39
39
  && !(defined $spec->{suffix} && '' ne $spec->{suffix}) && $url !~ m{/\z};
40
+ my $authority = index($url, '://');
41
+ $url .= '/' if 0 < $authority && substr($url, $authority + 3) !~ m{[/?#]};
40
42
 
41
43
  my $param_items = Voxgig::Struct::items($spec->{params});
42
44
  if ($param_items) {
@@ -336,13 +336,14 @@ class FeatureCorpusTest extends TestCase
336
336
  $this->assertNotNull(self::corpus()['feature']);
337
337
  }
338
338
 
339
- // At least one operation, or every case would skip and this suite would
340
- // report green having run nothing.
339
+ // With every operation needing an argument there is nothing to drive:
340
+ // skip and say so, as the clean test does, rather than fail.
341
341
  public function testSdkHasAnOperationTheCorpusCanDrive(): void
342
342
  {
343
- $this->assertNotEmpty(self::usableOps(2),
344
- 'no declared operation completed against a plain 200 - the corpus '
345
- . 'cannot exercise a feature without one');
343
+ if (empty(self::usableOps(2))) {
344
+ $this->markTestSkipped('no declared operation completes against a plain 200 with no arguments (each needs a path parameter or a body); nothing for the corpus to drive');
345
+ }
346
+ $this->assertNotEmpty(self::usableOps(2));
346
347
  }
347
348
 
348
349
  public function testFeatureCorpus(): void
@@ -511,17 +511,24 @@ class PipelineTest extends TestCase
511
511
  }
512
512
 
513
513
 
514
- // The guard writes to STDERR, so it is read from a child process.
514
+ // The guard writes to STDERR, so it is read from a child process. Nothing
515
+ // listens on port 9: a request the guard let through fails there.
515
516
  public function test_get_only_guard_prints_no_query_credential(): void
516
517
  {
517
- if (!function_exists('curl_init') || !function_exists('proc_open')) {
518
- $this->markTestSkipped('the GET-only guard sits on the cURL transport');
518
+ if (!function_exists('proc_open')) {
519
+ $this->markTestSkipped('the guard is read from a child process');
519
520
  }
520
521
  $sdk = realpath(__DIR__ . '/../projectname_sdk.php');
521
522
  $code = 'require ' . var_export($sdk, true) . ';'
522
- . ' [, $err] = ProjectNameFetcher::defaultHttpFetch('
523
- . '"http://127.0.0.1:9/planet/p1?apikey=GUARDKEY01&x=1", ["method" => "POST"]);'
524
- . ' echo $err;';
523
+ . ' $client = new ProjectNameSDK(["base" => "http://127.0.0.1:9"]);'
524
+ . ' $utility = $client->get_utility();'
525
+ . ' $ctx = ($utility->make_context)(["opname" => "create", "client" => $client,'
526
+ . ' "utility" => $utility], null);'
527
+ . ' $url = "http://127.0.0.1:9/planet/p1?apikey=GUARDKEY01&x=1";'
528
+ . ' [, $err] = ($utility->fetcher)($ctx, $url, ["method" => "POST"]);'
529
+ . ' echo $err->sdk_code, " ", $err->msg, "\n";'
530
+ . ' [, $geterr] = ($utility->fetcher)($ctx, $url, ["method" => "GET"]);'
531
+ . ' echo $geterr instanceof ProjectNameError ? $geterr->sdk_code : "sent";';
525
532
  $env = array_merge(getenv(), ['VOXGIG_GETONLY_GUARD' => 'TRUE']);
526
533
  $proc = proc_open([PHP_BINARY, '-r', $code],
527
534
  [1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes, null, $env);
@@ -532,11 +539,28 @@ class PipelineTest extends TestCase
532
539
  proc_close($proc);
533
540
 
534
541
  $this->assertStringContainsString('[GET-ONLY GUARD] blocked POST /planet/p1', $errout);
535
- $this->assertStringContainsString('blocked POST /planet/p1', $out);
542
+ $this->assertStringStartsWith('fetch_getonly_block [GET-ONLY GUARD] blocked POST /planet/p1', $out);
543
+ $this->assertStringEndsWith("\nsent", $out);
536
544
  $this->assertStringNotContainsString('GUARDKEY01', $errout);
537
545
  $this->assertStringNotContainsString('GUARDKEY01', $out);
538
546
  }
539
547
 
548
+ // The struct port's UNDEF sentinel is one object per process, and the
549
+ // struct corpus writes into it: no client may take it for a fetcher.
550
+ public function test_fetcher_without_system_fetch_uses_the_default_transport(): void
551
+ {
552
+ $sentinel = \Voxgig\Struct\Struct::undef();
553
+ $sentinel->pipelinetest = true;
554
+ try {
555
+ $client = new ProjectNameSDK(['base' => 'http://localhost:8080']);
556
+ $this->assertArrayNotHasKey('fetch', $client->options['system'] ?? []);
557
+ $this->assertNull(ProjectNameFetcher::systemFetch($client->options_map()));
558
+ $this->assertTrue(ProjectNameFetcher::usesDefault(self::ctx(['client' => $client])));
559
+ } finally {
560
+ unset($sentinel->pipelinetest);
561
+ }
562
+ }
563
+
540
564
  // --- make_fetch_def ----------------------------------------------------------
541
565
 
542
566
  public function test_make_fetch_def_guards_a_missing_spec(): void
@@ -3,6 +3,8 @@ declare(strict_types=1);
3
3
 
4
4
  // ProjectName SDK utility: fetcher
5
5
 
6
+ require_once __DIR__ . '/../core/Error.php';
7
+
6
8
  class ProjectNameFetcher
7
9
  {
8
10
  // Default User-Agent — many CDNs (notably Cloudflare) reject requests
@@ -28,9 +30,29 @@ class ProjectNameFetcher
28
30
  return self::$curl;
29
31
  }
30
32
 
33
+ public const GETONLY_ENV = 'VOXGIG_GETONLY_GUARD';
34
+
35
+ // A GET-only live run refuses any other method before it is sent, on
36
+ // either transport below. The path alone: the query can carry a
37
+ // credential, and nothing has cleaned this line.
38
+ public static function getOnlyRefusal(string $fullurl, string $method): ?ProjectNameError
39
+ {
40
+ if (getenv(self::GETONLY_ENV) !== 'TRUE' || $method === 'GET') {
41
+ return null;
42
+ }
43
+ $path = parse_url($fullurl, PHP_URL_PATH);
44
+ $path = is_string($path) && $path !== '' ? $path : '/';
45
+ fwrite(STDERR, "[GET-ONLY GUARD] blocked {$method} {$path}\n");
46
+ return new ProjectNameError('fetch_getonly_block', "[GET-ONLY GUARD] blocked {$method} {$path}");
47
+ }
48
+
31
49
  public static function defaultHttpFetch(string $fullurl, array $fetchdef): array
32
50
  {
33
51
  $method_str = strtoupper($fetchdef['method'] ?? 'GET');
52
+ $refused = self::getOnlyRefusal($fullurl, $method_str);
53
+ if (null !== $refused) {
54
+ return [null, $refused];
55
+ }
34
56
  $body_str = $fetchdef['body'] ?? null;
35
57
  if (is_resource($body_str)) {
36
58
  $body_str = stream_get_contents($body_str);
@@ -144,27 +166,6 @@ class ProjectNameFetcher
144
166
 
145
167
  private static function curlFetch(string $fullurl, string $method, $body_str, array $header_lines): array
146
168
  {
147
- // GET-only guard for live tests — set by pub-live-test. We respect
148
- // it here at the SDK level since cURL bypasses PHP stream wrappers
149
- // (so the wrapper-based guard wouldn't see this call).
150
- if (getenv('VOXGIG_GETONLY_GUARD') === 'TRUE' && $method !== 'GET') {
151
- // The path alone: the query can carry a credential, and nothing
152
- // has cleaned this line.
153
- $path = parse_url($fullurl, PHP_URL_PATH);
154
- $path = is_string($path) && $path !== '' ? $path : '/';
155
- fwrite(STDERR, "[GET-ONLY GUARD] blocked {$method} {$path}\n");
156
- return [
157
- [
158
- 'status' => 0,
159
- 'statusText' => 'Blocked',
160
- 'headers' => [],
161
- 'json' => function () { return null; },
162
- 'body' => '',
163
- ],
164
- "GET-only guard blocked {$method} {$path}",
165
- ];
166
- }
167
-
168
169
  $ch = self::curlHandle($fullurl);
169
170
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
170
171
  curl_setopt($ch, CURLOPT_HEADER, false);
@@ -256,12 +257,8 @@ class ProjectNameFetcher
256
257
  "Request blocked as test feature is active (URL was: \"{$fullurl}\")")];
257
258
  }
258
259
 
259
- $sys_fetch = \Voxgig\Struct\Struct::getpath($options, 'system.fetch');
260
+ $sys_fetch = self::systemFetch($options);
260
261
 
261
- // Treat null OR an empty stdClass/array as "no fetcher provided" and
262
- // fall through to the default HTTP fetcher. The options builder
263
- // sometimes materializes `system.fetch` as an empty stdClass even
264
- // when the user didn't set one — that's a placeholder, not a value.
265
262
  if (self::usesDefault($ctx)) {
266
263
  if (null !== $ctx->spec) {
267
264
  $ctx->spec->headers = self::sentHeaders($ctx->spec->headers);
@@ -275,9 +272,19 @@ class ProjectNameFetcher
275
272
  return [null, $ctx->make_error('fetch_invalid', 'system.fetch is not a valid function')];
276
273
  }
277
274
 
275
+ // getpath answers a missing path with the struct port's UNDEF sentinel:
276
+ // one stdClass for the whole process, which setprop writes into when it
277
+ // is handed as a parent. It must never be read, or kept, as a fetcher.
278
+ public static function systemFetch(mixed $options): mixed
279
+ {
280
+ $fetch = \Voxgig\Struct\Struct::getpath($options, 'system.fetch');
281
+ return $fetch === \Voxgig\Struct\Struct::undef() ? null : $fetch;
282
+ }
283
+
284
+ // An empty map or list for `system.fetch` names no fetcher either.
278
285
  public static function usesDefault(ProjectNameContext $ctx): bool
279
286
  {
280
- $sys_fetch = \Voxgig\Struct\Struct::getpath($ctx->client->options_map(), 'system.fetch');
287
+ $sys_fetch = self::systemFetch($ctx->client->options_map());
281
288
  $is_empty_obj = ($sys_fetch instanceof \stdClass) && empty(get_object_vars($sys_fetch));
282
289
  $is_empty_arr = is_array($sys_fetch) && empty($sys_fetch);
283
290
  return $sys_fetch === null || $is_empty_obj || $is_empty_arr;
@@ -42,6 +42,7 @@ class ProjectNameMakeOptions
42
42
  // dumped composer autoload.
43
43
  require_once __DIR__ . '/../schema.php';
44
44
  require_once __DIR__ . '/../core/Context.php';
45
+ require_once __DIR__ . '/Fetcher.php';
45
46
  $optspec = ProjectNameSchema::optspec();
46
47
 
47
48
  $config = $ctx->config ?? [];
@@ -107,7 +108,7 @@ class ProjectNameMakeOptions
107
108
  }
108
109
 
109
110
  // Preserve system.fetch before merge/validate.
110
- $sys_fetch = \Voxgig\Struct\Struct::getpath($options, 'system.fetch');
111
+ $sys_fetch = ProjectNameFetcher::systemFetch($options);
111
112
 
112
113
  // Feature INSTANCES supplied at construction (the station adopt path)
113
114
  // are consumed by the constructor's feature-add loop straight from the
@@ -23,12 +23,16 @@ class ProjectNameMakeUrl
23
23
  // Sent with the request, never recorded as the entity's match.
24
24
  $authquery = $spec->authquery ?? [];
25
25
 
26
- // A route the definition ends with a slash keeps it: a server such as
27
- // a Django REST one redirects or refuses the route without it.
26
+ // A route the definition ends with a slash keeps it, for a Django REST server,
27
+ // and a host with no path takes /, or luasocket reads a query as the host.
28
28
  $orig = $ctx->point ? \Voxgig\Struct\Struct::getprop($ctx->point, 'orig') : null;
29
29
  if (is_string($orig) && str_ends_with($orig, '/') && '' === $spec->suffix && !str_ends_with($url, '/')) {
30
30
  $url .= '/';
31
31
  }
32
+ $authority = strpos($url, '://');
33
+ if (is_int($authority) && 0 < $authority && false === strpbrk(substr($url, $authority + 3), '/?#')) {
34
+ $url .= '/';
35
+ }
32
36
 
33
37
  $param_items = \Voxgig\Struct\Struct::items($spec->params);
34
38
  if ($param_items) {
@@ -2,9 +2,12 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  import json
5
+ import os
6
+ import re
5
7
  import threading
6
8
  from http.cookiejar import DefaultCookiePolicy
7
9
  from projectname_sdk.utility.voxgig_struct import voxgig_struct as vs
10
+ from projectname_sdk.core.error import ProjectNameError
8
11
 
9
12
 
10
13
  # Default User-Agent — many CDNs (notably Cloudflare) reject requests with
@@ -43,8 +46,28 @@ def _request_data(body):
43
46
  return None
44
47
 
45
48
 
49
+ _GETONLY_ENV = "VOXGIG_GETONLY_GUARD"
50
+
51
+
52
+ # A GET-only live run refuses any other method before it is sent. The error
53
+ # names the path alone: the query can carry a credential.
54
+ def _getonly_refusal(fullurl, method):
55
+ method = str(method or "GET").upper()
56
+ if os.environ.get(_GETONLY_ENV) != "TRUE" or method == "GET":
57
+ return None
58
+ rest = fullurl
59
+ if "://" in rest:
60
+ rest = re.sub(r"^[^/?#]*", "", rest.split("://", 1)[1])
61
+ path = re.split(r"[?#]", rest, maxsplit=1)[0] or "/"
62
+ return ProjectNameError(
63
+ "fetch_getonly_block", "[GET-ONLY GUARD] blocked " + method + " " + path)
64
+
65
+
46
66
  def _default_http_fetch(fullurl, fetchdef):
47
67
  method = fetchdef.get("method", "GET")
68
+ refused = _getonly_refusal(fullurl, method)
69
+ if refused is not None:
70
+ return None, refused
48
71
  headers = fetchdef.get("headers", {})
49
72
 
50
73
  data = _request_data(fetchdef.get("body"))
@@ -26,12 +26,15 @@ def make_url_util(ctx):
26
26
  # Sent with the request, never recorded as the entity's match.
27
27
  authquery = getattr(spec, "authquery", None) or []
28
28
 
29
- # A route the definition ends with a slash keeps it: a server such as a
30
- # Django REST one redirects or refuses the route without it.
29
+ # A route the definition ends with a slash keeps it, for a Django REST server,
30
+ # and a host with no path takes /, or luasocket reads a query as the host.
31
31
  orig = vs.getprop(ctx.point, "orig") if ctx.point is not None else None
32
32
  if isinstance(orig, str) and orig.endswith("/") and not spec.suffix \
33
33
  and not url.endswith("/"):
34
34
  url += "/"
35
+ authority = url.find("://")
36
+ if 0 < authority and not any(c in url[authority + 3:] for c in "/?#"):
37
+ url += "/"
35
38
 
36
39
  param_items = vs.items(spec.params)
37
40
  if param_items is not None:
@@ -288,11 +288,11 @@ class TestFeatureCorpus:
288
288
  ".sdk/test/feature/) to run these cases")
289
289
 
290
290
  def test_sdk_has_an_operation_the_corpus_can_drive(self):
291
- # At least one operation, or every case below would skip and this
292
- # would report green having run nothing.
293
- assert len(_usable_ops(2)) > 0, \
294
- "no declared operation completed against a plain 200 - the " \
295
- "corpus cannot exercise a feature without one"
291
+ # With every operation needing an argument there is nothing to drive:
292
+ # skip and say so, as the clean test does, rather than fail.
293
+ if not _usable_ops(2):
294
+ pytest.skip("no declared operation completes against a plain 200 with no arguments (each needs a path parameter or a body); nothing for the corpus to drive")
295
+ assert len(_usable_ops(2)) > 0
296
296
 
297
297
  @pytest.mark.parametrize("name", FEATURE_CORPUS_NAMES)
298
298
  def test_feature(self, name):
@@ -379,6 +379,27 @@ class TestPrimaryUtility:
379
379
  assert err is not None
380
380
  assert "blocked" in str(err).lower()
381
381
 
382
+ # Nothing listens on port 9: a request the guard let through fails there.
383
+ def test_fetcher_getonly_guard(self, monkeypatch):
384
+ live_client = ProjectNameSDK({"base": "http://127.0.0.1:9"})
385
+ live_utility = live_client._utility
386
+ ctx = live_utility.make_context({
387
+ "opname": "create",
388
+ "client": live_client,
389
+ "utility": live_utility,
390
+ }, None)
391
+ url = "http://127.0.0.1:9/planet/p1?apikey=GUARDKEY01"
392
+ monkeypatch.setenv("VOXGIG_GETONLY_GUARD", "TRUE")
393
+
394
+ _, err = live_utility.fetcher(ctx, url, {"method": "POST", "headers": {}})
395
+ assert isinstance(err, ProjectNameError)
396
+ assert err.code == "fetch_getonly_block"
397
+ assert "[GET-ONLY GUARD] blocked POST /planet/p1" in err.msg
398
+ assert "GUARDKEY01" not in err.msg
399
+
400
+ _, err = live_utility.fetcher(ctx, url, {"method": "GET", "headers": {}})
401
+ assert err is not None and not isinstance(err, ProjectNameError)
402
+
382
403
  def test_make_context_basic(self):
383
404
  def subject(vin):
384
405
  if not isinstance(vin, dict):
@@ -115,7 +115,7 @@ class ProjectNameContext
115
115
  end
116
116
 
117
117
  def make_error(code, msg)
118
- ProjectNameError.new(code, msg, self)
118
+ ProjectNameError.new(msg, code: code, ctx: self)
119
119
  end
120
120
 
121
121
  # The serialised context leaves the pipeline (a logger, an error dump), so
@@ -5,7 +5,9 @@ require 'json'
5
5
  class ProjectNameError < StandardError
6
6
  attr_accessor :is_sdk_error, :sdk, :code, :msg, :ctx, :result, :spec, :status
7
7
 
8
- def initialize(code = "", msg = "", ctx = nil)
8
+ # The message is the one positional argument, as for any Ruby exception, so
9
+ # `e.class.new(e.message)` rebuilds an error that still says what failed.
10
+ def initialize(msg = "", code: "", ctx: nil)
9
11
  super(msg)
10
12
  @is_sdk_error = true
11
13
  @sdk = "ProjectName"
@@ -61,4 +63,21 @@ class ProjectNameError < StandardError
61
63
  def to_json(*args)
62
64
  to_h.to_json(*args)
63
65
  end
66
+
67
+ # Marshal leaves the context out too: it holds procs, and minitest replaces
68
+ # an error Marshal refuses. An exception cannot take marshal_load, hence
69
+ # _dump and _load.
70
+ def _dump(_level)
71
+ Marshal.dump(to_h.merge("backtrace" => backtrace))
72
+ end
73
+
74
+ def self._load(data)
75
+ record = Marshal.load(data)
76
+ err = new(record["message"], code: record["code"])
77
+ err.status = record["status"]
78
+ err.result = record["result"]
79
+ err.spec = record["spec"]
80
+ err.set_backtrace(record["backtrace"]) unless record["backtrace"].nil?
81
+ err
82
+ end
64
83
  end