@voxgig/sdkgen 4.51.0 → 4.52.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 (289) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/dist/cmp/ReadmeExplanation.js +5 -2
  3. package/dist/cmp/ReadmeExplanation.js.map +1 -1
  4. package/dist/cmp/ReadmeFeatures.js +20 -6
  5. package/dist/cmp/ReadmeFeatures.js.map +1 -1
  6. package/dist/helpers/optspec.js +2 -2
  7. package/dist/helpers/optspec.js.map +1 -1
  8. package/dist/tsconfig.tsbuildinfo +1 -1
  9. package/model/sdkgen.aontu +1 -1
  10. package/package.json +1 -1
  11. package/project/.sdk/model/feature/audit.aontu +1 -1
  12. package/project/.sdk/model/feature/cache.aontu +1 -1
  13. package/project/.sdk/model/feature/clienttrack.aontu +1 -1
  14. package/project/.sdk/model/feature/cost.aontu +1 -1
  15. package/project/.sdk/model/feature/debug.aontu +1 -1
  16. package/project/.sdk/model/feature/idempotency.aontu +1 -1
  17. package/project/.sdk/model/feature/log.aontu +1 -1
  18. package/project/.sdk/model/feature/metrics.aontu +3 -1
  19. package/project/.sdk/model/feature/netsim.aontu +1 -1
  20. package/project/.sdk/model/feature/paging.aontu +4 -1
  21. package/project/.sdk/model/feature/proxy.aontu +1 -1
  22. package/project/.sdk/model/feature/ratelimit.aontu +3 -3
  23. package/project/.sdk/model/feature/rbac.aontu +1 -1
  24. package/project/.sdk/model/feature/retry.aontu +1 -1
  25. package/project/.sdk/model/feature/secrets.aontu +1 -1
  26. package/project/.sdk/model/feature/streaming.aontu +1 -1
  27. package/project/.sdk/model/feature/telemetry.aontu +2 -2
  28. package/project/.sdk/model/feature/test.aontu +1 -1
  29. package/project/.sdk/model/feature/timeout.aontu +1 -1
  30. package/project/.sdk/model/feature/validate.aontu +1 -1
  31. package/project/.sdk/src/cmp/c/TestClean_c.ts +12 -11
  32. package/project/.sdk/src/cmp/c/fragment/Entity.fragment.c +17 -10
  33. package/project/.sdk/src/cmp/clojure/fragment/Entity.fragment.clj +18 -1
  34. package/project/.sdk/src/cmp/cpp/TestClean_cpp.ts +2 -1
  35. package/project/.sdk/src/cmp/csharp/fragment/EntityBase.fragment.cs +30 -2
  36. package/project/.sdk/src/cmp/csharp/fragment/Main.fragment.cs +31 -12
  37. package/project/.sdk/src/cmp/elixir/TestClean_elixir.ts +2 -1
  38. package/project/.sdk/src/cmp/elixir/fragment/Main.fragment.ex +51 -15
  39. package/project/.sdk/src/cmp/elixir/fragment/Pipeline.fragment.ex +17 -0
  40. package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +42 -2
  41. package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +42 -14
  42. package/project/.sdk/src/cmp/java/TestClean_java.ts +9 -4
  43. package/project/.sdk/src/cmp/java/fragment/EntityBase.fragment.java +21 -0
  44. package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +13 -8
  45. package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +26 -2
  46. package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +8 -0
  47. package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +8 -0
  48. package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +8 -0
  49. package/project/.sdk/src/cmp/js/fragment/EntityPatchOp.fragment.js +8 -0
  50. package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +8 -0
  51. package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +8 -0
  52. package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +12 -5
  53. package/project/.sdk/src/cmp/kotlin/TestClean_kotlin.ts +9 -4
  54. package/project/.sdk/src/cmp/kotlin/fragment/EntityBase.fragment.kt +19 -0
  55. package/project/.sdk/src/cmp/lua/TestClean_lua.ts +2 -1
  56. package/project/.sdk/src/cmp/lua/fragment/Entity.fragment.lua +42 -5
  57. package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +44 -10
  58. package/project/.sdk/src/cmp/lua/utility_lua.ts +2 -1
  59. package/project/.sdk/src/cmp/ocaml/TestClean_ocaml.ts +2 -1
  60. package/project/.sdk/src/cmp/ocaml/fragment/RunOp.fragment.ml +36 -21
  61. package/project/.sdk/src/cmp/perl/TestClean_perl.ts +1 -1
  62. package/project/.sdk/src/cmp/perl/fragment/Entity.fragment.pm +21 -0
  63. package/project/.sdk/src/cmp/perl/fragment/Main.fragment.pm +31 -12
  64. package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +33 -4
  65. package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +13 -6
  66. package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +25 -2
  67. package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +26 -12
  68. package/project/.sdk/src/cmp/rb/TestClean_rb.ts +1 -1
  69. package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +23 -2
  70. package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +27 -11
  71. package/project/.sdk/src/cmp/rust/TestClean_rust.ts +14 -17
  72. package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +22 -2
  73. package/project/.sdk/src/cmp/scala/TestClean_scala.ts +11 -11
  74. package/project/.sdk/src/cmp/scala/fragment/EntityBase.fragment.scala +14 -0
  75. package/project/.sdk/src/cmp/swift/TestClean_swift.ts +11 -11
  76. package/project/.sdk/src/cmp/swift/fragment/EntityBase.fragment.swift +9 -0
  77. package/project/.sdk/src/cmp/swift/fragment/Main.fragment.swift +24 -10
  78. package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +13 -8
  79. package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +26 -2
  80. package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +8 -0
  81. package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +8 -0
  82. package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +8 -0
  83. package/project/.sdk/src/cmp/ts/fragment/EntityPatchOp.fragment.ts +8 -0
  84. package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +8 -0
  85. package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +8 -0
  86. package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +12 -5
  87. package/project/.sdk/src/cmp/zig/TestClean_zig.ts +11 -11
  88. package/project/.sdk/src/cmp/zig/fragment/Entity.fragment.zig +17 -10
  89. package/project/.sdk/src/cmp/zig/fragment/Main.fragment.zig +41 -6
  90. package/project/.sdk/tm/c/feature/metrics.c +7 -0
  91. package/project/.sdk/tm/c/feature/paging.c +231 -2
  92. package/project/.sdk/tm/c/feature/ratelimit.c +5 -9
  93. package/project/.sdk/tm/c/feature/retry.c +51 -4
  94. package/project/.sdk/tm/c/feature/streaming.c +2 -1
  95. package/project/.sdk/tm/c/feature/telemetry.c +19 -18
  96. package/project/.sdk/tm/c/feature/test.c +78 -54
  97. package/project/.sdk/tm/c/tests/feature_test.c +184 -0
  98. package/project/.sdk/tm/c/tests/primary_utility_test.c +2 -0
  99. package/project/.sdk/tm/c/utility/make_options.c +80 -9
  100. package/project/.sdk/tm/clojure/src/sdk/core.clj +31 -11
  101. package/project/.sdk/tm/clojure/src/sdk/features.clj +198 -70
  102. package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +70 -1
  103. package/project/.sdk/tm/cpp/core/types.hpp +137 -68
  104. package/project/.sdk/tm/cpp/feature/audit.hpp +6 -1
  105. package/project/.sdk/tm/cpp/feature/metrics.hpp +19 -0
  106. package/project/.sdk/tm/cpp/feature/paging.hpp +160 -2
  107. package/project/.sdk/tm/cpp/feature/ratelimit.hpp +18 -14
  108. package/project/.sdk/tm/cpp/feature/retry.hpp +46 -5
  109. package/project/.sdk/tm/cpp/feature/streaming.hpp +2 -1
  110. package/project/.sdk/tm/cpp/feature/telemetry.hpp +17 -10
  111. package/project/.sdk/tm/cpp/feature/test.hpp +63 -53
  112. package/project/.sdk/tm/cpp/test/feature_test.cpp +137 -0
  113. package/project/.sdk/tm/cpp/utility/pipeline.hpp +35 -5
  114. package/project/.sdk/tm/csharp/feature/AuditFeature.cs +8 -1
  115. package/project/.sdk/tm/csharp/feature/MetricsFeature.cs +23 -0
  116. package/project/.sdk/tm/csharp/feature/PagingFeature.cs +130 -3
  117. package/project/.sdk/tm/csharp/feature/RatelimitFeature.cs +26 -19
  118. package/project/.sdk/tm/csharp/feature/RetryFeature.cs +41 -7
  119. package/project/.sdk/tm/csharp/feature/StreamingFeature.cs +2 -1
  120. package/project/.sdk/tm/csharp/feature/TelemetryFeature.cs +11 -9
  121. package/project/.sdk/tm/csharp/feature/TestFeature.cs +55 -67
  122. package/project/.sdk/tm/csharp/test/FeatureTest.cs +162 -0
  123. package/project/.sdk/tm/csharp/utility/MakeOptions.cs +89 -12
  124. package/project/.sdk/tm/elixir/lib/projectname/feature/metrics.ex +13 -0
  125. package/project/.sdk/tm/elixir/lib/projectname/feature/paging.ex +110 -5
  126. package/project/.sdk/tm/elixir/lib/projectname/feature/ratelimit.ex +6 -12
  127. package/project/.sdk/tm/elixir/lib/projectname/feature/retry.ex +33 -9
  128. package/project/.sdk/tm/elixir/lib/projectname/feature/streaming.ex +2 -1
  129. package/project/.sdk/tm/elixir/lib/projectname/feature/telemetry.ex +7 -7
  130. package/project/.sdk/tm/elixir/lib/projectname/feature/test.ex +52 -48
  131. package/project/.sdk/tm/elixir/lib/projectname/utility.ex +59 -35
  132. package/project/.sdk/tm/elixir/test/feature_test.exs +137 -0
  133. package/project/.sdk/tm/go/feature/audit_feature.go +1 -3
  134. package/project/.sdk/tm/go/feature/base_feature.go +11 -0
  135. package/project/.sdk/tm/go/feature/metrics_feature.go +14 -0
  136. package/project/.sdk/tm/go/feature/paging_feature.go +108 -2
  137. package/project/.sdk/tm/go/feature/ratelimit_feature.go +19 -17
  138. package/project/.sdk/tm/go/feature/retry_feature.go +81 -9
  139. package/project/.sdk/tm/go/feature/streaming_feature.go +2 -1
  140. package/project/.sdk/tm/go/feature/telemetry_feature.go +18 -11
  141. package/project/.sdk/tm/go/feature/test_feature.go +65 -55
  142. package/project/.sdk/tm/go/test/feature_corpus_test.go +209 -28
  143. package/project/.sdk/tm/go/test/feature_test.go +32 -0
  144. package/project/.sdk/tm/go/utility/make_options.go +111 -6
  145. package/project/.sdk/tm/java/core/SdkClient.java +43 -14
  146. package/project/.sdk/tm/java/feature/AuditFeature.java +5 -1
  147. package/project/.sdk/tm/java/feature/MetricsFeature.java +31 -0
  148. package/project/.sdk/tm/java/feature/PagingFeature.java +156 -2
  149. package/project/.sdk/tm/java/feature/RatelimitFeature.java +15 -13
  150. package/project/.sdk/tm/java/feature/RetryFeature.java +33 -6
  151. package/project/.sdk/tm/java/feature/StreamingFeature.java +2 -1
  152. package/project/.sdk/tm/java/feature/TelemetryFeature.java +17 -9
  153. package/project/.sdk/tm/java/feature/TestFeature.java +50 -63
  154. package/project/.sdk/tm/java/test/FeatureCorpusTest.java +170 -17
  155. package/project/.sdk/tm/java/utility/MakeOptions.java +128 -14
  156. package/project/.sdk/tm/js/src/feature/metrics/MetricsFeature.js +8 -3
  157. package/project/.sdk/tm/js/src/feature/paging/PagingFeature.js +99 -1
  158. package/project/.sdk/tm/js/src/feature/ratelimit/RatelimitFeature.js +5 -9
  159. package/project/.sdk/tm/js/src/feature/retry/RetryFeature.js +25 -3
  160. package/project/.sdk/tm/js/src/feature/streaming/StreamingFeature.js +2 -1
  161. package/project/.sdk/tm/js/src/feature/telemetry/TelemetryFeature.js +11 -6
  162. package/project/.sdk/tm/js/src/feature/test/TestFeature.js +38 -1
  163. package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +55 -6
  164. package/project/.sdk/tm/js/test/feature/Corpus.test.js +95 -25
  165. package/project/.sdk/tm/js/test/feature.test.js +14 -1
  166. package/project/.sdk/tm/kotlin/core/SdkClient.kt +23 -10
  167. package/project/.sdk/tm/kotlin/feature/AuditFeature.kt +5 -1
  168. package/project/.sdk/tm/kotlin/feature/MetricsFeature.kt +22 -0
  169. package/project/.sdk/tm/kotlin/feature/PagingFeature.kt +125 -2
  170. package/project/.sdk/tm/kotlin/feature/RatelimitFeature.kt +16 -13
  171. package/project/.sdk/tm/kotlin/feature/RetryFeature.kt +36 -14
  172. package/project/.sdk/tm/kotlin/feature/StreamingFeature.kt +4 -0
  173. package/project/.sdk/tm/kotlin/feature/TelemetryFeature.kt +12 -10
  174. package/project/.sdk/tm/kotlin/feature/TestFeature.kt +45 -48
  175. package/project/.sdk/tm/kotlin/test/FeatureTest.kt +114 -0
  176. package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +83 -14
  177. package/project/.sdk/tm/lua/feature/debug_feature.lua +2 -3
  178. package/project/.sdk/tm/lua/feature/metrics_feature.lua +5 -0
  179. package/project/.sdk/tm/lua/feature/paging_feature.lua +143 -2
  180. package/project/.sdk/tm/lua/feature/ratelimit_feature.lua +5 -9
  181. package/project/.sdk/tm/lua/feature/retry_feature.lua +43 -5
  182. package/project/.sdk/tm/lua/feature/streaming_feature.lua +2 -1
  183. package/project/.sdk/tm/lua/feature/telemetry_feature.lua +18 -7
  184. package/project/.sdk/tm/lua/feature/test_feature.lua +60 -62
  185. package/project/.sdk/tm/lua/test/feature_test.lua +100 -3
  186. package/project/.sdk/tm/lua/utility/make_options.lua +55 -13
  187. package/project/.sdk/tm/ocaml/sdk_features.ml +286 -60
  188. package/project/.sdk/tm/ocaml/sdk_runtime.ml +34 -11
  189. package/project/.sdk/tm/ocaml/test/t_feature.ml +72 -1
  190. package/project/.sdk/tm/perl/feature/debug_feature.pm +2 -2
  191. package/project/.sdk/tm/perl/feature/metrics_feature.pm +5 -0
  192. package/project/.sdk/tm/perl/feature/paging_feature.pm +139 -2
  193. package/project/.sdk/tm/perl/feature/ratelimit_feature.pm +5 -11
  194. package/project/.sdk/tm/perl/feature/retry_feature.pm +22 -4
  195. package/project/.sdk/tm/perl/feature/streaming_feature.pm +2 -0
  196. package/project/.sdk/tm/perl/feature/telemetry_feature.pm +17 -8
  197. package/project/.sdk/tm/perl/feature/test_feature.pm +45 -50
  198. package/project/.sdk/tm/perl/t/feature.t +2 -2
  199. package/project/.sdk/tm/perl/t/feature_corpus.t +126 -23
  200. package/project/.sdk/tm/perl/utility/make_options.pm +33 -10
  201. package/project/.sdk/tm/php/feature/MetricsFeature.php +8 -0
  202. package/project/.sdk/tm/php/feature/PagingFeature.php +128 -1
  203. package/project/.sdk/tm/php/feature/RatelimitFeature.php +5 -9
  204. package/project/.sdk/tm/php/feature/RetryFeature.php +27 -3
  205. package/project/.sdk/tm/php/feature/StreamingFeature.php +2 -1
  206. package/project/.sdk/tm/php/feature/TelemetryFeature.php +10 -7
  207. package/project/.sdk/tm/php/feature/TestFeature.php +55 -47
  208. package/project/.sdk/tm/php/test/FeatureCorpusTest.php +151 -16
  209. package/project/.sdk/tm/php/utility/MakeOptions.php +40 -13
  210. package/project/.sdk/tm/py/pkg/feature/metrics_feature.py +7 -0
  211. package/project/.sdk/tm/py/pkg/feature/paging_feature.py +86 -1
  212. package/project/.sdk/tm/py/pkg/feature/ratelimit_feature.py +13 -16
  213. package/project/.sdk/tm/py/pkg/feature/retry_feature.py +31 -6
  214. package/project/.sdk/tm/py/pkg/feature/streaming_feature.py +2 -1
  215. package/project/.sdk/tm/py/pkg/feature/telemetry_feature.py +10 -6
  216. package/project/.sdk/tm/py/pkg/feature/test_feature.py +56 -53
  217. package/project/.sdk/tm/py/pkg/utility/make_options.py +68 -20
  218. package/project/.sdk/tm/py/test/test_feature.py +11 -1
  219. package/project/.sdk/tm/py/test/test_feature_corpus.py +111 -16
  220. package/project/.sdk/tm/py-data/pkg/fetch.py +6 -3
  221. package/project/.sdk/tm/py-data/test/test_fetch.py +7 -4
  222. package/project/.sdk/tm/rb/feature/debug_feature.rb +2 -2
  223. package/project/.sdk/tm/rb/feature/metrics_feature.rb +8 -0
  224. package/project/.sdk/tm/rb/feature/paging_feature.rb +87 -1
  225. package/project/.sdk/tm/rb/feature/ratelimit_feature.rb +12 -16
  226. package/project/.sdk/tm/rb/feature/retry_feature.rb +19 -3
  227. package/project/.sdk/tm/rb/feature/streaming_feature.rb +2 -1
  228. package/project/.sdk/tm/rb/feature/telemetry_feature.rb +11 -6
  229. package/project/.sdk/tm/rb/feature/test_feature.rb +42 -49
  230. package/project/.sdk/tm/rb/test/feature_corpus_test.rb +108 -24
  231. package/project/.sdk/tm/rb/test/feature_test.rb +1 -1
  232. package/project/.sdk/tm/rb/utility/make_options.rb +32 -11
  233. package/project/.sdk/tm/rust/feature/audit.rs +2 -2
  234. package/project/.sdk/tm/rust/feature/metrics.rs +24 -1
  235. package/project/.sdk/tm/rust/feature/paging.rs +189 -3
  236. package/project/.sdk/tm/rust/feature/ratelimit.rs +5 -10
  237. package/project/.sdk/tm/rust/feature/retry.rs +59 -6
  238. package/project/.sdk/tm/rust/feature/streaming.rs +3 -2
  239. package/project/.sdk/tm/rust/feature/support.rs +4 -0
  240. package/project/.sdk/tm/rust/feature/telemetry.rs +22 -11
  241. package/project/.sdk/tm/rust/feature/test.rs +63 -57
  242. package/project/.sdk/tm/rust/tests/feature_test.rs +174 -0
  243. package/project/.sdk/tm/rust/tests/primary_utility_test.rs +1 -0
  244. package/project/.sdk/tm/rust/utility/make_options.rs +122 -27
  245. package/project/.sdk/tm/scala/core/SdkClient.scala +45 -11
  246. package/project/.sdk/tm/scala/feature/AuditFeature.scala +6 -1
  247. package/project/.sdk/tm/scala/feature/MetricsFeature.scala +31 -1
  248. package/project/.sdk/tm/scala/feature/PagingFeature.scala +122 -2
  249. package/project/.sdk/tm/scala/feature/RatelimitFeature.scala +14 -11
  250. package/project/.sdk/tm/scala/feature/RetryFeature.scala +29 -7
  251. package/project/.sdk/tm/scala/feature/StreamingFeature.scala +2 -1
  252. package/project/.sdk/tm/scala/feature/TelemetryFeature.scala +12 -10
  253. package/project/.sdk/tm/scala/feature/TestFeature.scala +44 -44
  254. package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +41 -0
  255. package/project/.sdk/tm/scala/utility/Make.scala +96 -13
  256. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/AuditFeature.swift +3 -2
  257. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/MetricsFeature.swift +20 -0
  258. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/PagingFeature.swift +102 -2
  259. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/RatelimitFeature.swift +19 -13
  260. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/RetryFeature.swift +40 -5
  261. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/StreamingFeature.swift +2 -1
  262. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TelemetryFeature.swift +11 -9
  263. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TestFeature.swift +55 -49
  264. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +51 -13
  265. package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +111 -0
  266. package/project/.sdk/tm/ts/src/feature/metrics/MetricsFeature.ts +5 -0
  267. package/project/.sdk/tm/ts/src/feature/paging/PagingFeature.ts +99 -1
  268. package/project/.sdk/tm/ts/src/feature/ratelimit/RatelimitFeature.ts +5 -9
  269. package/project/.sdk/tm/ts/src/feature/retry/RetryFeature.ts +25 -3
  270. package/project/.sdk/tm/ts/src/feature/streaming/StreamingFeature.ts +2 -1
  271. package/project/.sdk/tm/ts/src/feature/telemetry/TelemetryFeature.ts +11 -6
  272. package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +8 -7
  273. package/project/.sdk/tm/ts/src/utility/MakeOptionsUtility.ts +57 -6
  274. package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +95 -25
  275. package/project/.sdk/tm/ts/test/feature.test.ts +14 -1
  276. package/project/.sdk/tm/zig/core/utility.zig +107 -8
  277. package/project/.sdk/tm/zig/feature/metrics.zig +19 -0
  278. package/project/.sdk/tm/zig/feature/paging.zig +172 -4
  279. package/project/.sdk/tm/zig/feature/ratelimit.zig +5 -11
  280. package/project/.sdk/tm/zig/feature/retry.zig +41 -3
  281. package/project/.sdk/tm/zig/feature/streaming.zig +2 -0
  282. package/project/.sdk/tm/zig/feature/telemetry.zig +15 -9
  283. package/project/.sdk/tm/zig/feature/test.zig +56 -40
  284. package/project/.sdk/tm/zig/test/feature_test.zig +109 -0
  285. package/project/.sdk/tm/zig/test/primary_utility_test.zig +2 -0
  286. package/project/sdkgen-package.json +1 -1
  287. package/src/cmp/ReadmeExplanation.ts +5 -2
  288. package/src/cmp/ReadmeFeatures.ts +21 -6
  289. package/src/helpers/optspec.ts +2 -2
@@ -148,7 +148,15 @@ class ProjectNameTestFeature extends ProjectNameBaseFeature
148
148
  // filter that matches by exact-equality on each provided key,
149
149
  // with alias fallback. An empty match matches every entry, as an
150
150
  // empty `$AND` does in select; a non-empty miss matches nothing.
151
- $find_first = function (array $entmap, $match, $alias) {
151
+ // `id.from` places a part in a nested field: an alternative to the flat key.
152
+ $idfrom = \Voxgig\Struct\Struct::getpath($fctx->config, ['entity', $entname, 'id', 'from']);
153
+ $nested_match = function ($e, $k, $v) use ($idfrom) {
154
+ $kf = is_array($idfrom) ? ($idfrom[$k] ?? null) : null;
155
+ return is_string($kf) && $kf !== $k &&
156
+ \Voxgig\Struct\Struct::getpath($e, explode('.', $kf)) === $v;
157
+ };
158
+
159
+ $find_first = function (array $entmap, $match, $alias) use ($nested_match) {
152
160
  if (!is_array($match) || empty($match)) {
153
161
  foreach ($entmap as $e) {
154
162
  if (is_array($e)) return $e;
@@ -161,7 +169,7 @@ class ProjectNameTestFeature extends ProjectNameBaseFeature
161
169
  foreach ($match as $k => $v) {
162
170
  if ($v === null || $v === '__UNDEFINED__') continue;
163
171
  $ev = $e[$k] ?? null;
164
- if ($ev !== $v) {
172
+ if ($ev !== $v && !$nested_match($e, $k, $v)) {
165
173
  // Try alias key if any
166
174
  $ka = is_array($alias) ? ($alias[$k] ?? null) : null;
167
175
  $aliased = ($ka !== null) ? ($e[$ka] ?? null) : null;
@@ -176,7 +184,7 @@ class ProjectNameTestFeature extends ProjectNameBaseFeature
176
184
  return null;
177
185
  };
178
186
 
179
- $find_all = function (array $entmap, $match, $alias) use ($find_first) {
187
+ $find_all = function (array $entmap, $match, $alias) use ($nested_match) {
180
188
  if (!is_array($match) || empty($match)) {
181
189
  return array_values($entmap);
182
190
  }
@@ -187,7 +195,7 @@ class ProjectNameTestFeature extends ProjectNameBaseFeature
187
195
  foreach ($match as $k => $v) {
188
196
  if ($v === null || $v === '__UNDEFINED__') continue;
189
197
  $ev = $e[$k] ?? null;
190
- if ($ev !== $v) {
198
+ if ($ev !== $v && !$nested_match($e, $k, $v)) {
191
199
  $ka = is_array($alias) ? ($alias[$k] ?? null) : null;
192
200
  $aliased = ($ka !== null) ? ($e[$ka] ?? null) : null;
193
201
  if ($aliased !== $v) { $ok = false; break; }
@@ -217,25 +225,8 @@ class ProjectNameTestFeature extends ProjectNameBaseFeature
217
225
  return $flat;
218
226
  };
219
227
 
220
- // For single-entity ops (load, remove) with an empty explicit
221
- // match, fall back to the id the entity client already knows from a
222
- // prior create/load (carried in $fctx->match / $fctx->data). This
223
- // mirrors the TS mock where param() resolves the id from that
224
- // accumulated state — e.g. `create()` then `remove([])` removes the
225
- // just-created entity, not an arbitrary fixture.
226
- $resolve_match = function ($explicit) use ($fctx) {
227
- if (is_array($explicit) && !empty($explicit)) return $explicit;
228
- foreach ([$fctx->match, $fctx->data] as $src) {
229
- $arr = is_array($src) ? $src : (is_object($src) ? (array) $src : []);
230
- if (isset($arr['id']) && $arr['id'] !== null && $arr['id'] !== '__UNDEFINED__') {
231
- return ['id' => $arr['id']];
232
- }
233
- }
234
- return [];
235
- };
236
-
237
228
  if ($op->name === 'load') {
238
- $ent = $find_first($entmap, $query_match($resolve_match($fctx->reqmatch)), $alias);
229
+ $ent = $find_first($entmap, $query_match($fctx->reqmatch), $alias);
239
230
  if ($ent === null) {
240
231
  return $respond(404, null, ['statusText' => 'Not found']);
241
232
  }
@@ -254,27 +245,7 @@ class ProjectNameTestFeature extends ProjectNameBaseFeature
254
245
  return $respond(200, $out);
255
246
 
256
247
  } elseif ($op->name === 'update' || $op->name === 'patch') {
257
- // Match the existing entity by id only (or its alias). reqdata
258
- // also contains the new field values, which would otherwise
259
- // cause find_first to filter out the entity we want to update.
260
- // When reqdata has no id, fall back to the id the entity
261
- // client carries from a prior create/load (in $fctx->match /
262
- // $fctx->data), mirroring the TS mock where param(ctx,'id')
263
- // resolves from accumulated state.
264
- $update_match = [];
265
- if (is_array($fctx->reqdata)) {
266
- if (array_key_exists('id', $fctx->reqdata)) {
267
- $update_match['id'] = $fctx->reqdata['id'];
268
- }
269
- $id_alias = is_array($alias) ? ($alias['id'] ?? null) : null;
270
- if ($id_alias !== null && array_key_exists($id_alias, $fctx->reqdata)) {
271
- $update_match[$id_alias] = $fctx->reqdata[$id_alias];
272
- }
273
- }
274
- if (empty($update_match)) {
275
- $update_match = $resolve_match([]);
276
- }
277
- $ent = $find_first($entmap, $query_match($update_match), $alias);
248
+ $ent = $find_first($entmap, $query_match(self::record($fctx->reqdata)), $alias);
278
249
  if ($ent === null) {
279
250
  // update miss: 404, never another record
280
251
  return $respond(404, null, ['statusText' => 'Not found']);
@@ -292,7 +263,7 @@ class ProjectNameTestFeature extends ProjectNameBaseFeature
292
263
  return $respond(200, $out);
293
264
 
294
265
  } elseif ($op->name === 'remove') {
295
- $ent = $find_first($entmap, $query_match($resolve_match($fctx->reqmatch)), $alias);
266
+ $ent = $find_first($entmap, $query_match($fctx->reqmatch), $alias);
296
267
  // Remove only the first matched entity. If nothing matches,
297
268
  // succeed as a no-op rather than erroring.
298
269
  $id = is_array($ent) ? ($ent['id'] ?? null) : null;
@@ -421,9 +392,6 @@ class ProjectNameTestFeature extends ProjectNameBaseFeature
421
392
  // every entry — the TS test feature relies on this for empty-match
422
393
  // load against fixture entries.
423
394
  $keys = is_array($args) ? \Voxgig\Struct\Struct::keysof($args) : [];
424
- if (empty($keys)) {
425
- return ['$AND' => []];
426
- }
427
395
 
428
396
  $opname = is_object($op) ? ($op->name ?? null) : (\Voxgig\Struct\Struct::getprop($op, 'name'));
429
397
 
@@ -492,6 +460,28 @@ class ProjectNameTestFeature extends ProjectNameBaseFeature
492
460
  $alias = is_object($op) ? ($op->alias ?? null) : \Voxgig\Struct\Struct::getprop($op, 'alias');
493
461
  $qand = [];
494
462
 
463
+ $idpath = function ($leaf) use ($ctx, $entityName) {
464
+ return is_string($entityName) && isset($ctx->config)
465
+ ? \Voxgig\Struct\Struct::getpath($ctx->config, ['entity', $entityName, 'id', $leaf]) : null;
466
+ };
467
+
468
+ // With no id in the call, the entity's held id (or composite parts) stands in.
469
+ if (!is_array($args) || null === ($args['id'] ?? null)) {
470
+ $parts = $idpath('parts');
471
+ if (!is_array($parts)) {
472
+ $parts = 'list' === $opname ? [] : ['id'];
473
+ }
474
+ foreach ($parts as $part) {
475
+ $pname = (string) $part;
476
+ if (!in_array($pname, $keys, true) &&
477
+ (self::held($ctx->match, $pname) || self::held($ctx->data, $pname))) {
478
+ $keys[] = $pname;
479
+ }
480
+ }
481
+ }
482
+
483
+ $idfrom = $idpath('from');
484
+
495
485
  foreach ($keys as $k) {
496
486
  $is_id = ($k === 'id');
497
487
  $in_reqd = in_array($k, $reqd_names, true);
@@ -504,10 +494,28 @@ class ProjectNameTestFeature extends ProjectNameBaseFeature
504
494
  $qor[] = [$ka => $v];
505
495
  }
506
496
 
497
+ // An alternative, never a replacement: a seed keeping the
498
+ // parameter flat is still found.
499
+ $kf = is_array($idfrom) ? ($idfrom[$k] ?? null) : null;
500
+ if (is_string($kf) && $kf !== $k) {
501
+ $nest = $v;
502
+ foreach (array_reverse(explode('.', $kf)) as $seg) {
503
+ $nest = [$seg => $nest];
504
+ }
505
+ $qor[] = $nest;
506
+ }
507
+
507
508
  $qand[] = ['$OR' => $qor];
508
509
  }
509
510
  }
510
511
 
511
512
  return ['$AND' => $qand];
512
513
  }
514
+
515
+ private static function held($src, string $key): bool
516
+ {
517
+ $arr = is_array($src) ? $src : (is_object($src) ? (array) $src : []);
518
+ $v = $arr[$key] ?? null;
519
+ return null !== $v && '__UNDEFINED__' !== $v;
520
+ }
513
521
  }
@@ -49,13 +49,19 @@ class FeatureCorpusTest extends TestCase
49
49
  * Returns the shape the real fetcher returns: a [response, err] PAIR, with
50
50
  * the parsed body behind a `json` closure and `body` as the raw string. A
51
51
  * script that only set `body` would look like an empty result, which reads
52
- * as a feature defect rather than a mis-shaped script.
52
+ * as a feature defect rather than a mis-shaped script. Each URL it is sent
53
+ * is kept in `$sent`, and the time it was sent in `$at`; a `cut` response
54
+ * is one whose body stops before its end.
53
55
  */
54
- private static function scriptedFetcher($res): callable
56
+ private static function scriptedFetcher($res, ?array &$sent = null, ?array &$at = null): callable
55
57
  {
56
58
  $n = -1;
57
- return function ($ctx, $fullurl, $fetchdef) use ($res, &$n) {
59
+ $sent = $sent ?? [];
60
+ $at = $at ?? [];
61
+ return function ($ctx, $fullurl, $fetchdef) use ($res, &$n, &$sent, &$at) {
58
62
  $n++;
63
+ $sent[] = $fullurl;
64
+ $at[] = hrtime(true) / 1e6;
59
65
  $spec = [];
60
66
  if (is_array($res) && count($res) > 0) {
61
67
  $i = $n >= count($res) ? count($res) - 1 : $n;
@@ -69,6 +75,21 @@ class FeatureCorpusTest extends TestCase
69
75
  $status = isset($spec['status']) ? (int)$spec['status'] : 200;
70
76
  $body = $spec['body'] ?? [];
71
77
 
78
+ if (($spec['cut'] ?? null) === true) {
79
+ $raw = (string)json_encode($body);
80
+ return [
81
+ [
82
+ 'status' => $status,
83
+ 'statusText' => $status < 400 ? 'OK' : 'ERR',
84
+ 'headers' => (array)($spec['headers'] ?? []),
85
+ 'json' => function () { return null; },
86
+ 'body' => substr($raw, 0, intdiv(strlen($raw), 2)),
87
+ 'unreadable' => true,
88
+ ],
89
+ null,
90
+ ];
91
+ }
92
+
72
93
  return [
73
94
  [
74
95
  'status' => $status,
@@ -89,8 +110,10 @@ class FeatureCorpusTest extends TestCase
89
110
  * transport: 'base' and REPLACES the transport, so a client in test mode
90
111
  * would shadow the script.
91
112
  */
92
- private static function buildClient(array $kase)
113
+ private static function buildClient(array $kase, ?array &$sent = null, ?array &$at = null)
93
114
  {
115
+ $sent = $sent ?? [];
116
+ $at = $at ?? [];
94
117
  // 'test' here is the OPTION, not the `test` FEATURE. It says "this
95
118
  // client is not live", which is what makes a REQUIRED OpenAPI server
96
119
  // variable resolve to a deterministic test-<name> rather than throw
@@ -99,7 +122,7 @@ class FeatureCorpusTest extends TestCase
99
122
  // and would shadow it.
100
123
  $opts = [
101
124
  'test' => ['active' => true],
102
- 'utility' => ['fetcher' => self::scriptedFetcher($kase['res'] ?? null)],
125
+ 'utility' => ['fetcher' => self::scriptedFetcher($kase['res'] ?? null, $sent, $at)],
103
126
  ];
104
127
  if (isset($kase['feature'])) {
105
128
  $opts['feature'] = $kase['feature'];
@@ -245,13 +268,67 @@ class FeatureCorpusTest extends TestCase
245
268
  return null;
246
269
  }
247
270
 
248
- /** One step: it may wait, may add request headers, and may pass `args` as the first argument. */
271
+ /** Read one operation through the entity's stream(); how many it yields. */
272
+ private static function streamItems($client, array $op, array $ctrl, array $args): int
273
+ {
274
+ $acc = $op['accessor'];
275
+ $items = 0;
276
+ foreach ($client->$acc()->stream($op['op'], $args, ['ctrl' => $ctrl]) as $_item) {
277
+ $items++;
278
+ }
279
+ return $items;
280
+ }
281
+
282
+ /**
283
+ * Each request a case expects, in order: its path, and its whole query. A
284
+ * path is compared without its leading slash, which an SDK with no base
285
+ * omits.
286
+ */
287
+ private function checkSent(array $sent, array $expect, string $label): void
288
+ {
289
+ $this->assertCount(count($expect), $sent, "$label: requests sent: " . implode(' | ', $sent));
290
+ foreach ($expect as $i => $want) {
291
+ $url = parse_url($sent[$i]);
292
+ if (isset($want['path'])) {
293
+ $this->assertSame(ltrim($want['path'], '/'), ltrim($url['path'] ?? '', '/'),
294
+ "$label: request $i path");
295
+ }
296
+ if (isset($want['query'])) {
297
+ $query = [];
298
+ foreach (explode('&', $url['query'] ?? '') as $pair) {
299
+ if ($pair === '') {
300
+ continue;
301
+ }
302
+ $kv = explode('=', $pair, 2);
303
+ $query[urldecode($kv[0])] = urldecode($kv[1] ?? '');
304
+ }
305
+ ksort($query);
306
+ $wq = $want['query'];
307
+ ksort($wq);
308
+ $this->assertSame($wq, $query, "$label: request $i query");
309
+ }
310
+ }
311
+ }
312
+
313
+ /**
314
+ * One step: it may wait, may add request headers, and may pass `args` as
315
+ * the first argument. A `stream` step reads the operation through
316
+ * stream(), and `items` is how many it yields.
317
+ */
249
318
  private static function step($client, array $op, array $step, array $ctrl)
250
319
  {
251
320
  if (isset($step['wait'])) {
252
321
  usleep((int)($step['wait'] * 1000));
253
322
  }
254
323
  $args = is_array($step['args'] ?? null) ? $step['args'] : [];
324
+ if (($step['stream'] ?? null) === true) {
325
+ $items = self::streamItems($client, $op, $ctrl, $args);
326
+ if (isset($step['items']) && $items !== $step['items']) {
327
+ throw new \PHPUnit\Framework\AssertionFailedError(
328
+ "{$op['key']}: streamed $items item(s), want {$step['items']}");
329
+ }
330
+ return $items;
331
+ }
255
332
  if (!isset($step['headers'])) {
256
333
  return self::invoke($client, $op, $ctrl, $args);
257
334
  }
@@ -265,6 +342,34 @@ class FeatureCorpusTest extends TestCase
265
342
  }
266
343
 
267
344
  /** Replace #OPn throughout a case, keys included. */
345
+ /**
346
+ * A step with `together: N` is N calls. PHP runs one call at a time, so
347
+ * they go in turn; each call's throwable, or null, is returned.
348
+ */
349
+ private static function calls($client, array $op, array $step, array $ctrl): array
350
+ {
351
+ $errs = [];
352
+ for ($i = 0; $i < (int)($step['together'] ?? 1); $i++) {
353
+ try {
354
+ self::step($client, $op, $step, $ctrl);
355
+ $errs[] = null;
356
+ } catch (\Throwable $err) {
357
+ $errs[] = $err;
358
+ }
359
+ }
360
+ return $errs;
361
+ }
362
+
363
+ /** The most requests seen in any window of `ms`. */
364
+ private static function busiest(array $sent, float $ms): int
365
+ {
366
+ $most = 0;
367
+ foreach ($sent as $from) {
368
+ $most = max($most, count(array_filter($sent, fn ($t) => $from <= $t && $t < $from + $ms)));
369
+ }
370
+ return $most;
371
+ }
372
+
268
373
  private static function resolve($node, array $tokens)
269
374
  {
270
375
  if (is_string($node)) {
@@ -319,6 +424,15 @@ class FeatureCorpusTest extends TestCase
319
424
  return;
320
425
  }
321
426
 
427
+ if (is_array($expect)) {
428
+ $this->assertTrue(is_array($actual) && array_is_list($actual) && count($actual) === count($expect),
429
+ "$path: want " . count($expect) . ' item(s), got ' . var_export($actual, true));
430
+ foreach ($expect as $i => $want) {
431
+ $this->subset($actual[$i], $want, "{$path}[$i]");
432
+ }
433
+ return;
434
+ }
435
+
322
436
  if (is_int($expect) || is_float($expect)) {
323
437
  $this->assertTrue(is_int($actual) || is_float($actual),
324
438
  "$path: expected a number, got " . var_export($actual, true));
@@ -525,21 +639,32 @@ class FeatureCorpusTest extends TestCase
525
639
 
526
640
  // Every failing case is reported, not only the first.
527
641
  try {
528
- $client = self::buildClient($kase);
529
-
642
+ $sent = [];
643
+ $at = [];
644
+ $client = self::buildClient($kase, $sent, $at);
645
+
646
+ // A case-level ctrl is one control every step shares. PHP
647
+ // passes arrays by value, so the paging record is carried
648
+ // on by hand, as the features reference describes.
649
+ $shared = $kase['ctrl'] ?? null;
530
650
  foreach (($kase['op'] ?? []) as $step) {
531
651
  $op = $byKey[$step['op']] ?? null;
532
652
  $this->assertNotNull($op, "$label: no operation {$step['op']}");
533
- $ctrl = $step['ctrl'] ?? [];
653
+ if (is_array($shared) && isset($client->_paging['last'])) {
654
+ $shared['paging'] = $client->_paging['last'];
655
+ }
656
+ $ctrl = $step['ctrl'] ?? $shared ?? [];
534
657
  $wanterr = $step['err'] ?? null;
535
658
 
536
- try {
537
- self::step($client, $op, $step, $ctrl);
538
- $this->assertNull($wanterr,
539
- "$label: {$step['op']} was expected to fail, and did not");
540
- } catch (\PHPUnit\Framework\AssertionFailedError $e) {
541
- throw $e;
542
- } catch (\Throwable $err) {
659
+ foreach (self::calls($client, $op, $step, $ctrl) as $err) {
660
+ if (null === $err) {
661
+ $this->assertNull($wanterr,
662
+ "$label: {$step['op']} was expected to fail, and did not");
663
+ continue;
664
+ }
665
+ if ($err instanceof \PHPUnit\Framework\AssertionFailedError) {
666
+ throw $err;
667
+ }
543
668
  $this->assertNotNull($wanterr,
544
669
  "$label: {$step['op']} failed unexpectedly: " . $err->getMessage());
545
670
  if (is_string($wanterr)) {
@@ -557,6 +682,16 @@ class FeatureCorpusTest extends TestCase
557
682
  }
558
683
  }
559
684
 
685
+ if (isset($kase['pace'])) {
686
+ $most = self::busiest($at, (float)$kase['pace']['ms']);
687
+ $this->assertLessThanOrEqual($kase['pace']['max'], $most,
688
+ "$label: $most requests within {$kase['pace']['ms']} ms, "
689
+ . "want at most {$kase['pace']['max']}");
690
+ }
691
+
692
+ if (isset($kase['sent'])) {
693
+ $this->checkSent($sent, $kase['sent'], $label);
694
+ }
560
695
  $this->subset(self::record($client, $name), $kase['out'] ?? [],
561
696
  "$label: _$name");
562
697
  } catch (\Throwable $e) {
@@ -25,6 +25,26 @@ class ProjectNameMakeOptions
25
25
  return $val;
26
26
  }
27
27
 
28
+ // The model's options for a feature sit beneath the caller's, key by key: a
29
+ // key the caller sets replaces the default whole, so a list is never merged.
30
+ private static function feature_defaults(mixed $cfgfeature, mixed $feature): ?array
31
+ {
32
+ if (null !== $feature && !is_array($feature)) {
33
+ return null;
34
+ }
35
+ $out = $feature ?? [];
36
+ foreach (is_array($cfgfeature) ? $cfgfeature : [] as $name => $fdef) {
37
+ $dflt = is_array($fdef) ? ($fdef['options'] ?? null) : null;
38
+ $given = $out[$name] ?? null;
39
+ if (!is_array($dflt) || (null === $given && true !== ($dflt['active'] ?? null))
40
+ || (null !== $given && !is_array($given))) {
41
+ continue;
42
+ }
43
+ $out[$name] = array_merge(self::to_array_deep(\Voxgig\Struct\Struct::clone($dflt)), $given ?? []);
44
+ }
45
+ return $out;
46
+ }
47
+
28
48
  public static function call(ProjectNameContext $ctx): array
29
49
  {
30
50
  $options = $ctx->options ?? [];
@@ -188,6 +208,11 @@ class ProjectNameMakeOptions
188
208
  $opts['feature'] = $fmap;
189
209
  }
190
210
 
211
+ $fdefaults = self::feature_defaults($config['feature'] ?? null, $opts['feature'] ?? null);
212
+ if (null !== $fdefaults) {
213
+ $opts['feature'] = $fdefaults;
214
+ }
215
+
191
216
  // Empty [] would be treated as a list and clobber the map under merge;
192
217
  // substitute an empty stdClass to preserve map semantics.
193
218
  $cfgopts = ProjectNameHelpers::empty_maps($cfgopts, $optspec);
@@ -276,22 +301,23 @@ class ProjectNameMakeOptions
276
301
  $opts['system']['fetch'] = $sys_fetch;
277
302
  }
278
303
 
279
- // Resolve the feature add-order: an explicit list order (above) wins;
280
- // otherwise order the map test-first, then the remaining names sorted,
281
- // so the outcome is deterministic and `test` is always the base.
282
- if (count($featureorder) === 0) {
304
+ // Resolve the feature add-order: an explicit list order (above) wins, and
305
+ // the names it leaves out follow it test-first, then sorted, so the
306
+ // outcome is deterministic and `test` is the base transport of a map.
307
+ {
283
308
  $fmap = $opts['feature'] ?? null;
284
309
  $names = is_array($fmap)
285
- ? array_values(array_filter(array_keys($fmap), 'is_string'))
310
+ ? array_values(array_filter(array_keys($fmap), function ($n) use ($featureorder) {
311
+ return is_string($n) && !in_array($n, $featureorder, true);
312
+ }))
286
313
  : [];
287
314
  sort($names, SORT_STRING);
288
315
  if (in_array('test', $names, true)) {
289
- $rest = array_values(array_filter($names, function ($n) {
316
+ $rest = array_merge(['test'], array_values(array_filter($names, function ($n) {
290
317
  return $n !== 'test';
291
- }));
292
- $featureorder = array_merge(['test'], $rest);
318
+ })));
293
319
  } else {
294
- $featureorder = $names;
320
+ $rest = $names;
295
321
  }
296
322
  // Station special case, mirroring test's: its transport wrap must
297
323
  // sit immediately outside the base transport (inside every other
@@ -299,12 +325,13 @@ class ProjectNameMakeOptions
299
325
  // test - or first, when no test entry exists. Without this the
300
326
  // sorted default would init station last and wrap OUTSIDE the
301
327
  // recording features, turning its wire-truth events into fiction.
302
- $si = array_search('station', $featureorder, true);
328
+ $si = array_search('station', $rest, true);
303
329
  if (false !== $si) {
304
- array_splice($featureorder, $si, 1);
305
- $ti = array_search('test', $featureorder, true);
306
- array_splice($featureorder, false === $ti ? 0 : $ti + 1, 0, ['station']);
330
+ array_splice($rest, $si, 1);
331
+ $ti = array_search('test', $rest, true);
332
+ array_splice($rest, false === $ti ? 0 : $ti + 1, 0, ['station']);
307
333
  }
334
+ $featureorder = array_merge($featureorder, $rest);
308
335
  }
309
336
 
310
337
  // Again over the merged result: the config's own defaults can carry one.
@@ -79,6 +79,13 @@ class ProjectNameMetricsFeature(ProjectNameBaseFeature):
79
79
  self._bump(metrics["total"], ok, dur)
80
80
  self._bump(op_bucket, ok, dur)
81
81
 
82
+ sink = self.options.get("sink")
83
+ if callable(sink):
84
+ try:
85
+ sink(ctx.utility.clean(ctx, metrics))
86
+ except Exception:
87
+ pass
88
+
82
89
  def _bump(self, bucket, ok, dur):
83
90
  bucket["count"] += 1
84
91
  bucket["ok" if ok else "err"] += 1
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  import re
5
+ from urllib.parse import unquote_plus, urljoin, urlsplit, urlunsplit
5
6
 
6
7
  from projectname_sdk.utility.voxgig_struct import voxgig_struct as vs
7
8
 
@@ -17,6 +18,71 @@ from projectname_sdk.feature.base_feature import ProjectNameBaseFeature
17
18
  # paging takes priority (used by auto-iteration). Parameter names
18
19
  # (`pageParam`/`limitParam`/`cursorParam`), `startPage` and page size
19
20
  # (`limit`) are configurable.
21
+ _ORIGIN = re.compile(r"^[a-z][a-z0-9+.-]*://[^/?#]*", re.IGNORECASE)
22
+
23
+
24
+ # Under the `next` option's default, a URL or an absolute path is a link and
25
+ # anything else a cursor; `cursor` and `url` pin the reading.
26
+ def _is_link(nxt, mode):
27
+ if not isinstance(nxt, str):
28
+ return False
29
+ return "url" == mode or ("cursor" != mode and (
30
+ _ORIGIN.match(nxt) is not None or nxt.startswith("/")))
31
+
32
+
33
+ def _origin(text):
34
+ m = _ORIGIN.match(text) if isinstance(text, str) else None
35
+ return m.group(0).lower() if m else ""
36
+
37
+
38
+ def _foreign(link, base):
39
+ origin = _origin(link)
40
+ return "" != origin and origin != _origin(base)
41
+
42
+
43
+ _SCHEME = re.compile(r"^[a-z][a-z0-9+.-]*:", re.IGNORECASE)
44
+
45
+
46
+ # RFC 3986 reference resolution against the URL of the request that
47
+ # returned the link. A link on that URL's origin comes back as its path and
48
+ # query; an absolute link is left as the server wrote it.
49
+ def _resolve(link, url):
50
+ if not isinstance(url, str) or "" == url or _SCHEME.match(link):
51
+ return link
52
+ try:
53
+ out = urlsplit(urljoin(url, link))
54
+ frm = urlsplit(url)
55
+ except ValueError:
56
+ return link
57
+ if (out.scheme, out.netloc) == (frm.scheme, frm.netloc):
58
+ return urlunsplit(("", "", out.path, out.query, ""))
59
+ return urlunsplit((out.scheme, out.netloc, out.path, out.query, ""))
60
+
61
+
62
+ # The request goes to the link's path and query, on the SDK's own origin.
63
+ def _follow(spec, nxt):
64
+ link = _ORIGIN.match(nxt)
65
+ rest = nxt[link.end():] if link else nxt
66
+ rest = rest.split("#", 1)[0]
67
+ path, _, rawquery = rest.partition("?")
68
+
69
+ query = {}
70
+ for pair in rawquery.split("&"):
71
+ if "" == pair:
72
+ continue
73
+ key, _, val = pair.partition("=")
74
+ query[unquote_plus(key)] = unquote_plus(val)
75
+ for key in (spec.authquery or []):
76
+ query[key] = spec.query.get(key)
77
+
78
+ origin = _ORIGIN.match(str(spec.base or ""))
79
+ spec.base = origin.group(0) if origin else ""
80
+ spec.prefix = ""
81
+ spec.path = path
82
+ spec.suffix = ""
83
+ spec.query = query
84
+
85
+
20
86
  class ProjectNamePagingFeature(ProjectNameBaseFeature):
21
87
  def __init__(self):
22
88
  super().__init__()
@@ -65,6 +131,8 @@ class ProjectNamePagingFeature(ProjectNameBaseFeature):
65
131
 
66
132
  if paging.get("cursor") is not None:
67
133
  spec.query[cursor_param] = paging["cursor"]
134
+ elif isinstance(paging.get("next"), str) and not _foreign(paging["next"], spec.base):
135
+ _follow(spec, paging["next"])
68
136
  elif spec.query.get(page_param) is None:
69
137
  # A record written back by PreResult holds the page just fetched
70
138
  # as "page" and the one to fetch as "nextPage", so nextPage wins.
@@ -129,6 +197,7 @@ class ProjectNamePagingFeature(ProjectNameBaseFeature):
129
197
  "nextPage": self._num(self._header(headers, "x-next-page")),
130
198
  "next": None,
131
199
  "cursor": None,
200
+ "foreign": None,
132
201
  "hasMore": False,
133
202
  }
134
203
 
@@ -173,7 +242,10 @@ class ProjectNamePagingFeature(ProjectNameBaseFeature):
173
242
  # Body-level signals; snake_case forms are read first so camelCase wins.
174
243
  if isinstance(body, dict):
175
244
  if body.get("next") is not None:
176
- paging["next"] = paging["next"] or body["next"]
245
+ if not _is_link(body["next"], self.options.get("next") or "auto"):
246
+ paging["cursor"] = body["next"]
247
+ else:
248
+ paging["next"] = paging["next"] or body["next"]
177
249
  if body.get("next_cursor") is not None:
178
250
  paging["cursor"] = body["next_cursor"]
179
251
  if body.get("cursor") is not None:
@@ -193,6 +265,15 @@ class ProjectNamePagingFeature(ProjectNameBaseFeature):
193
265
  paging["hasMore"] = body["hasMore"]
194
266
  explicit_more = True
195
267
 
268
+ # A link to another origin is recorded, never followed, and ends the walk.
269
+ spec = ctx.spec
270
+ base = spec.base if spec is not None else (ctx.options or {}).get("base")
271
+ if paging["next"] is not None and spec is not None:
272
+ paging["next"] = _resolve(paging["next"], getattr(spec, "url", None))
273
+ if paging["next"] is not None and _foreign(paging["next"], base):
274
+ paging["foreign"] = paging["next"]
275
+ paging["next"] = None
276
+
196
277
  # Cursor presence only INFERS another page. When the server stated
197
278
  # the answer outright — relay's `hasNextPage: false`, or a body
198
279
  # `hasMore` — that wins: a final page normally carries both an end
@@ -204,6 +285,10 @@ class ProjectNamePagingFeature(ProjectNameBaseFeature):
204
285
  or paging["cursor"] is not None
205
286
  or paging["nextPage"] is not None)
206
287
 
288
+ if (paging["foreign"] is not None and paging["cursor"] is None
289
+ and paging["nextPage"] is None):
290
+ paging["hasMore"] = False
291
+
207
292
  result.paging = paging
208
293
 
209
294
  ctrl = ctx.ctrl