@voxgig/sdkgen 4.50.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 (400) 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 +7 -5
  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/model/target/lua.aontu +6 -0
  32. package/project/.sdk/src/cmp/c/Config_c.ts +3 -134
  33. package/project/.sdk/src/cmp/c/TestClean_c.ts +26 -11
  34. package/project/.sdk/src/cmp/c/fragment/Entity.fragment.c +17 -10
  35. package/project/.sdk/src/cmp/clojure/TestClean_clojure.ts +10 -5
  36. package/project/.sdk/src/cmp/clojure/fragment/Entity.fragment.clj +18 -1
  37. package/project/.sdk/src/cmp/cpp/TestClean_cpp.ts +15 -1
  38. package/project/.sdk/src/cmp/csharp/TestClean_csharp.ts +9 -0
  39. package/project/.sdk/src/cmp/csharp/fragment/EntityBase.fragment.cs +30 -2
  40. package/project/.sdk/src/cmp/csharp/fragment/Main.fragment.cs +31 -12
  41. package/project/.sdk/src/cmp/elixir/TestClean_elixir.ts +13 -4
  42. package/project/.sdk/src/cmp/elixir/fragment/Main.fragment.ex +51 -15
  43. package/project/.sdk/src/cmp/elixir/fragment/Pipeline.fragment.ex +17 -0
  44. package/project/.sdk/src/cmp/go/TestClean_go.ts +39 -3
  45. package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +42 -2
  46. package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +42 -14
  47. package/project/.sdk/src/cmp/java/TestClean_java.ts +17 -4
  48. package/project/.sdk/src/cmp/java/fragment/EntityBase.fragment.java +21 -0
  49. package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +13 -8
  50. package/project/.sdk/src/cmp/js/TestClean_js.ts +13 -5
  51. package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +26 -2
  52. package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +8 -0
  53. package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +8 -0
  54. package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +8 -0
  55. package/project/.sdk/src/cmp/js/fragment/EntityPatchOp.fragment.js +8 -0
  56. package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +8 -0
  57. package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +8 -0
  58. package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +12 -5
  59. package/project/.sdk/src/cmp/kotlin/TestClean_kotlin.ts +31 -4
  60. package/project/.sdk/src/cmp/kotlin/fragment/EntityBase.fragment.kt +19 -0
  61. package/project/.sdk/src/cmp/lua/TestClean_lua.ts +14 -4
  62. package/project/.sdk/src/cmp/lua/fragment/Entity.fragment.lua +42 -5
  63. package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +44 -10
  64. package/project/.sdk/src/cmp/lua/utility_lua.ts +2 -1
  65. package/project/.sdk/src/cmp/ocaml/TestClean_ocaml.ts +20 -5
  66. package/project/.sdk/src/cmp/ocaml/fragment/RunOp.fragment.ml +36 -21
  67. package/project/.sdk/src/cmp/perl/TestClean_perl.ts +13 -4
  68. package/project/.sdk/src/cmp/perl/fragment/Entity.fragment.pm +21 -0
  69. package/project/.sdk/src/cmp/perl/fragment/Main.fragment.pm +31 -12
  70. package/project/.sdk/src/cmp/php/TestClean_php.ts +10 -3
  71. package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +33 -4
  72. package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +13 -6
  73. package/project/.sdk/src/cmp/py/TestClean_py.ts +10 -3
  74. package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +25 -2
  75. package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +26 -12
  76. package/project/.sdk/src/cmp/rb/TestClean_rb.ts +11 -4
  77. package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +23 -2
  78. package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +27 -11
  79. package/project/.sdk/src/cmp/rust/TestClean_rust.ts +24 -17
  80. package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +22 -2
  81. package/project/.sdk/src/cmp/scala/TestClean_scala.ts +45 -11
  82. package/project/.sdk/src/cmp/scala/fragment/EntityBase.fragment.scala +14 -0
  83. package/project/.sdk/src/cmp/swift/TestClean_swift.ts +31 -21
  84. package/project/.sdk/src/cmp/swift/fragment/EntityBase.fragment.swift +9 -0
  85. package/project/.sdk/src/cmp/swift/fragment/Main.fragment.swift +24 -10
  86. package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +13 -8
  87. package/project/.sdk/src/cmp/ts/TestClean_ts.ts +13 -5
  88. package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +26 -2
  89. package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +8 -0
  90. package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +8 -0
  91. package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +8 -0
  92. package/project/.sdk/src/cmp/ts/fragment/EntityPatchOp.fragment.ts +8 -0
  93. package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +8 -0
  94. package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +8 -0
  95. package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +12 -5
  96. package/project/.sdk/src/cmp/zig/TestClean_zig.ts +23 -11
  97. package/project/.sdk/src/cmp/zig/fragment/Entity.fragment.zig +17 -10
  98. package/project/.sdk/src/cmp/zig/fragment/Main.fragment.zig +41 -6
  99. package/project/.sdk/tm/c/core/context.c +1 -0
  100. package/project/.sdk/tm/c/core/sdk.h +7 -4
  101. package/project/.sdk/tm/c/feature/cache.c +243 -13
  102. package/project/.sdk/tm/c/feature/metrics.c +7 -0
  103. package/project/.sdk/tm/c/feature/paging.c +231 -2
  104. package/project/.sdk/tm/c/feature/ratelimit.c +5 -9
  105. package/project/.sdk/tm/c/feature/retry.c +51 -4
  106. package/project/.sdk/tm/c/feature/secrets.c +27 -38
  107. package/project/.sdk/tm/c/feature/streaming.c +2 -1
  108. package/project/.sdk/tm/c/feature/telemetry.c +19 -18
  109. package/project/.sdk/tm/c/feature/test.c +78 -54
  110. package/project/.sdk/tm/c/tests/feature_test.c +288 -0
  111. package/project/.sdk/tm/c/tests/primary_utility_test.c +2 -0
  112. package/project/.sdk/tm/c/utility/clean.c +26 -33
  113. package/project/.sdk/tm/c/utility/make_options.c +89 -17
  114. package/project/.sdk/tm/clojure/feature/secrets/sdk/feature/secrets.clj +14 -11
  115. package/project/.sdk/tm/clojure/src/sdk/client.clj +3 -1
  116. package/project/.sdk/tm/clojure/src/sdk/core.clj +50 -22
  117. package/project/.sdk/tm/clojure/src/sdk/features.clj +279 -80
  118. package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +103 -1
  119. package/project/.sdk/tm/clojure/test/sdk/test/pipeline.clj +1 -0
  120. package/project/.sdk/tm/cpp/Makefile +5 -0
  121. package/project/.sdk/tm/cpp/core/types.hpp +148 -72
  122. package/project/.sdk/tm/cpp/feature/audit.hpp +12 -8
  123. package/project/.sdk/tm/cpp/feature/cache.hpp +188 -9
  124. package/project/.sdk/tm/cpp/feature/metrics.hpp +19 -0
  125. package/project/.sdk/tm/cpp/feature/paging.hpp +160 -2
  126. package/project/.sdk/tm/cpp/feature/ratelimit.hpp +18 -14
  127. package/project/.sdk/tm/cpp/feature/retry.hpp +46 -5
  128. package/project/.sdk/tm/cpp/feature/secrets.hpp +12 -0
  129. package/project/.sdk/tm/cpp/feature/streaming.hpp +2 -1
  130. package/project/.sdk/tm/cpp/feature/telemetry.hpp +17 -10
  131. package/project/.sdk/tm/cpp/feature/test.hpp +63 -53
  132. package/project/.sdk/tm/cpp/test/feature_test.cpp +236 -0
  133. package/project/.sdk/tm/cpp/utility/pipeline.hpp +44 -12
  134. package/project/.sdk/tm/csharp/core/Context.cs +4 -0
  135. package/project/.sdk/tm/csharp/feature/AuditFeature.cs +8 -1
  136. package/project/.sdk/tm/csharp/feature/CacheFeature.cs +126 -12
  137. package/project/.sdk/tm/csharp/feature/MetricsFeature.cs +23 -0
  138. package/project/.sdk/tm/csharp/feature/PagingFeature.cs +130 -3
  139. package/project/.sdk/tm/csharp/feature/RatelimitFeature.cs +26 -19
  140. package/project/.sdk/tm/csharp/feature/RetryFeature.cs +41 -7
  141. package/project/.sdk/tm/csharp/feature/SecretsFeature.cs +9 -27
  142. package/project/.sdk/tm/csharp/feature/StreamingFeature.cs +2 -1
  143. package/project/.sdk/tm/csharp/feature/TelemetryFeature.cs +11 -9
  144. package/project/.sdk/tm/csharp/feature/TestFeature.cs +55 -67
  145. package/project/.sdk/tm/csharp/test/FeatureTest.cs +238 -0
  146. package/project/.sdk/tm/csharp/utility/Clean.cs +5 -10
  147. package/project/.sdk/tm/csharp/utility/Fetcher.cs +7 -1
  148. package/project/.sdk/tm/csharp/utility/MakeOptions.cs +94 -24
  149. package/project/.sdk/tm/elixir/lib/projectname/context.ex +2 -0
  150. package/project/.sdk/tm/elixir/lib/projectname/feature/cache.ex +146 -30
  151. package/project/.sdk/tm/elixir/lib/projectname/feature/metrics.ex +13 -0
  152. package/project/.sdk/tm/elixir/lib/projectname/feature/paging.ex +110 -5
  153. package/project/.sdk/tm/elixir/lib/projectname/feature/ratelimit.ex +6 -12
  154. package/project/.sdk/tm/elixir/lib/projectname/feature/retry.ex +33 -9
  155. package/project/.sdk/tm/elixir/lib/projectname/feature/secrets.ex +10 -56
  156. package/project/.sdk/tm/elixir/lib/projectname/feature/streaming.ex +2 -1
  157. package/project/.sdk/tm/elixir/lib/projectname/feature/telemetry.ex +7 -7
  158. package/project/.sdk/tm/elixir/lib/projectname/feature/test.ex +52 -48
  159. package/project/.sdk/tm/elixir/lib/projectname/utility.ex +77 -47
  160. package/project/.sdk/tm/elixir/test/feature_test.exs +198 -0
  161. package/project/.sdk/tm/go/core/context.go +6 -0
  162. package/project/.sdk/tm/go/feature/audit_feature.go +1 -3
  163. package/project/.sdk/tm/go/feature/base_feature.go +11 -0
  164. package/project/.sdk/tm/go/feature/cache_feature.go +131 -4
  165. package/project/.sdk/tm/go/feature/metrics_feature.go +14 -0
  166. package/project/.sdk/tm/go/feature/paging_feature.go +108 -2
  167. package/project/.sdk/tm/go/feature/ratelimit_feature.go +19 -17
  168. package/project/.sdk/tm/go/feature/retry_feature.go +81 -9
  169. package/project/.sdk/tm/go/feature/secrets_feature.go +17 -71
  170. package/project/.sdk/tm/go/feature/streaming_feature.go +2 -1
  171. package/project/.sdk/tm/go/feature/telemetry_feature.go +18 -11
  172. package/project/.sdk/tm/go/feature/test_feature.go +65 -55
  173. package/project/.sdk/tm/go/test/feature_corpus_test.go +357 -28
  174. package/project/.sdk/tm/go/test/feature_test.go +93 -0
  175. package/project/.sdk/tm/go/utility/clean.go +5 -7
  176. package/project/.sdk/tm/go/utility/fetcher.go +11 -0
  177. package/project/.sdk/tm/go/utility/make_options.go +116 -13
  178. package/project/.sdk/tm/java/core/Context.java +9 -0
  179. package/project/.sdk/tm/java/core/SdkClient.java +43 -14
  180. package/project/.sdk/tm/java/feature/AuditFeature.java +5 -1
  181. package/project/.sdk/tm/java/feature/CacheFeature.java +123 -17
  182. package/project/.sdk/tm/java/feature/MetricsFeature.java +31 -0
  183. package/project/.sdk/tm/java/feature/PagingFeature.java +156 -2
  184. package/project/.sdk/tm/java/feature/RatelimitFeature.java +15 -13
  185. package/project/.sdk/tm/java/feature/RetryFeature.java +33 -6
  186. package/project/.sdk/tm/java/feature/SecretsFeature.java +9 -92
  187. package/project/.sdk/tm/java/feature/StreamingFeature.java +2 -1
  188. package/project/.sdk/tm/java/feature/TelemetryFeature.java +17 -9
  189. package/project/.sdk/tm/java/feature/TestFeature.java +50 -63
  190. package/project/.sdk/tm/java/test/FeatureCorpusTest.java +309 -17
  191. package/project/.sdk/tm/java/test/FeatureTest.java +60 -0
  192. package/project/.sdk/tm/java/utility/Clean.java +6 -10
  193. package/project/.sdk/tm/java/utility/Fetcher.java +5 -1
  194. package/project/.sdk/tm/java/utility/MakeOptions.java +131 -15
  195. package/project/.sdk/tm/js/src/Context.js +4 -0
  196. package/project/.sdk/tm/js/src/feature/cache/CacheFeature.js +118 -11
  197. package/project/.sdk/tm/js/src/feature/cost/CostFeature.js +3 -2
  198. package/project/.sdk/tm/js/src/feature/metrics/MetricsFeature.js +9 -4
  199. package/project/.sdk/tm/js/src/feature/paging/PagingFeature.js +103 -5
  200. package/project/.sdk/tm/js/src/feature/ratelimit/RatelimitFeature.js +5 -9
  201. package/project/.sdk/tm/js/src/feature/rbac/RbacFeature.js +4 -4
  202. package/project/.sdk/tm/js/src/feature/retry/RetryFeature.js +25 -3
  203. package/project/.sdk/tm/js/src/feature/secrets/SecretsFeature.js +16 -6
  204. package/project/.sdk/tm/js/src/feature/streaming/StreamingFeature.js +2 -1
  205. package/project/.sdk/tm/js/src/feature/telemetry/TelemetryFeature.js +11 -6
  206. package/project/.sdk/tm/js/src/feature/test/TestFeature.js +38 -1
  207. package/project/.sdk/tm/js/src/feature/validate/ValidateFeature.js +2 -1
  208. package/project/.sdk/tm/js/src/utility/CleanUtility.js +1 -1
  209. package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +61 -12
  210. package/project/.sdk/tm/js/test/feature/Corpus.test.js +191 -23
  211. package/project/.sdk/tm/js/test/feature/harness.js +3 -3
  212. package/project/.sdk/tm/js/test/feature.test.js +14 -1
  213. package/project/.sdk/tm/js/test/pipeline.test.js +1 -1
  214. package/project/.sdk/tm/kotlin/core/Context.kt +3 -0
  215. package/project/.sdk/tm/kotlin/core/SdkClient.kt +23 -10
  216. package/project/.sdk/tm/kotlin/feature/AuditFeature.kt +5 -1
  217. package/project/.sdk/tm/kotlin/feature/CacheFeature.kt +102 -7
  218. package/project/.sdk/tm/kotlin/feature/MetricsFeature.kt +22 -0
  219. package/project/.sdk/tm/kotlin/feature/PagingFeature.kt +125 -2
  220. package/project/.sdk/tm/kotlin/feature/RatelimitFeature.kt +16 -13
  221. package/project/.sdk/tm/kotlin/feature/RetryFeature.kt +36 -14
  222. package/project/.sdk/tm/kotlin/feature/SecretsFeature.kt +10 -20
  223. package/project/.sdk/tm/kotlin/feature/StreamingFeature.kt +4 -0
  224. package/project/.sdk/tm/kotlin/feature/TelemetryFeature.kt +12 -10
  225. package/project/.sdk/tm/kotlin/feature/TestFeature.kt +45 -48
  226. package/project/.sdk/tm/kotlin/test/FeatureTest.kt +173 -0
  227. package/project/.sdk/tm/kotlin/utility/CoreUtil.kt +5 -5
  228. package/project/.sdk/tm/kotlin/utility/Fetcher.kt +4 -0
  229. package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +86 -15
  230. package/project/.sdk/tm/lua/core/context.lua +6 -0
  231. package/project/.sdk/tm/lua/feature/cache_feature.lua +212 -15
  232. package/project/.sdk/tm/lua/feature/debug_feature.lua +2 -3
  233. package/project/.sdk/tm/lua/feature/metrics_feature.lua +5 -0
  234. package/project/.sdk/tm/lua/feature/paging_feature.lua +143 -2
  235. package/project/.sdk/tm/lua/feature/ratelimit_feature.lua +5 -9
  236. package/project/.sdk/tm/lua/feature/retry_feature.lua +43 -5
  237. package/project/.sdk/tm/lua/feature/secrets_feature.lua +15 -80
  238. package/project/.sdk/tm/lua/feature/streaming_feature.lua +2 -1
  239. package/project/.sdk/tm/lua/feature/telemetry_feature.lua +18 -7
  240. package/project/.sdk/tm/lua/feature/test_feature.lua +60 -62
  241. package/project/.sdk/tm/lua/test/feature_test.lua +181 -3
  242. package/project/.sdk/tm/lua/utility/clean.lua +6 -9
  243. package/project/.sdk/tm/lua/utility/fetcher.lua +9 -0
  244. package/project/.sdk/tm/lua/utility/make_options.lua +60 -18
  245. package/project/.sdk/tm/ocaml/feature/secrets_feature.ml +21 -6
  246. package/project/.sdk/tm/ocaml/sdk_features.ml +392 -68
  247. package/project/.sdk/tm/ocaml/sdk_runtime.ml +47 -21
  248. package/project/.sdk/tm/ocaml/sdk_types.ml +2 -0
  249. package/project/.sdk/tm/ocaml/test/t_feature.ml +107 -2
  250. package/project/.sdk/tm/perl/core/context.pm +3 -0
  251. package/project/.sdk/tm/perl/feature/audit_feature.pm +4 -7
  252. package/project/.sdk/tm/perl/feature/cache_feature.pm +111 -15
  253. package/project/.sdk/tm/perl/feature/debug_feature.pm +2 -2
  254. package/project/.sdk/tm/perl/feature/metrics_feature.pm +5 -0
  255. package/project/.sdk/tm/perl/feature/paging_feature.pm +139 -2
  256. package/project/.sdk/tm/perl/feature/ratelimit_feature.pm +5 -11
  257. package/project/.sdk/tm/perl/feature/retry_feature.pm +22 -4
  258. package/project/.sdk/tm/perl/feature/secrets_feature.pm +13 -18
  259. package/project/.sdk/tm/perl/feature/streaming_feature.pm +2 -0
  260. package/project/.sdk/tm/perl/feature/telemetry_feature.pm +17 -8
  261. package/project/.sdk/tm/perl/feature/test_feature.pm +45 -50
  262. package/project/.sdk/tm/perl/t/feature.t +68 -2
  263. package/project/.sdk/tm/perl/t/feature_corpus.t +204 -25
  264. package/project/.sdk/tm/perl/utility/clean.pm +6 -8
  265. package/project/.sdk/tm/perl/utility/fetcher.pm +4 -0
  266. package/project/.sdk/tm/perl/utility/make_options.pm +38 -15
  267. package/project/.sdk/tm/php/core/Context.php +4 -0
  268. package/project/.sdk/tm/php/feature/CacheFeature.php +98 -13
  269. package/project/.sdk/tm/php/feature/MetricsFeature.php +8 -0
  270. package/project/.sdk/tm/php/feature/PagingFeature.php +128 -1
  271. package/project/.sdk/tm/php/feature/RatelimitFeature.php +5 -9
  272. package/project/.sdk/tm/php/feature/RetryFeature.php +27 -3
  273. package/project/.sdk/tm/php/feature/SecretsFeature.php +18 -15
  274. package/project/.sdk/tm/php/feature/StreamingFeature.php +2 -1
  275. package/project/.sdk/tm/php/feature/TelemetryFeature.php +10 -7
  276. package/project/.sdk/tm/php/feature/TestFeature.php +55 -47
  277. package/project/.sdk/tm/php/test/FeatureCorpusTest.php +262 -17
  278. package/project/.sdk/tm/php/test/FeatureTest.php +68 -0
  279. package/project/.sdk/tm/php/utility/Clean.php +3 -10
  280. package/project/.sdk/tm/php/utility/Fetcher.php +8 -3
  281. package/project/.sdk/tm/php/utility/MakeOptions.php +45 -20
  282. package/project/.sdk/tm/py/pkg/core/context.py +4 -0
  283. package/project/.sdk/tm/py/pkg/feature/cache_feature.py +79 -13
  284. package/project/.sdk/tm/py/pkg/feature/metrics_feature.py +7 -0
  285. package/project/.sdk/tm/py/pkg/feature/paging_feature.py +86 -1
  286. package/project/.sdk/tm/py/pkg/feature/ratelimit_feature.py +13 -16
  287. package/project/.sdk/tm/py/pkg/feature/retry_feature.py +31 -6
  288. package/project/.sdk/tm/py/pkg/feature/secrets_feature.py +15 -66
  289. package/project/.sdk/tm/py/pkg/feature/streaming_feature.py +2 -1
  290. package/project/.sdk/tm/py/pkg/feature/telemetry_feature.py +10 -6
  291. package/project/.sdk/tm/py/pkg/feature/test_feature.py +56 -53
  292. package/project/.sdk/tm/py/pkg/utility/clean.py +4 -10
  293. package/project/.sdk/tm/py/pkg/utility/make_options.py +77 -30
  294. package/project/.sdk/tm/py/test/feature/secrets/test_secrets.py +23 -9
  295. package/project/.sdk/tm/py/test/test_feature.py +61 -1
  296. package/project/.sdk/tm/py/test/test_feature_corpus.py +197 -17
  297. package/project/.sdk/tm/py-data/pkg/fetch.py +6 -3
  298. package/project/.sdk/tm/py-data/test/test_fetch.py +7 -4
  299. package/project/.sdk/tm/rb/core/context.rb +4 -1
  300. package/project/.sdk/tm/rb/feature/audit_feature.rb +6 -5
  301. package/project/.sdk/tm/rb/feature/cache_feature.rb +75 -11
  302. package/project/.sdk/tm/rb/feature/debug_feature.rb +2 -2
  303. package/project/.sdk/tm/rb/feature/metrics_feature.rb +8 -0
  304. package/project/.sdk/tm/rb/feature/paging_feature.rb +87 -1
  305. package/project/.sdk/tm/rb/feature/ratelimit_feature.rb +12 -16
  306. package/project/.sdk/tm/rb/feature/retry_feature.rb +19 -3
  307. package/project/.sdk/tm/rb/feature/secrets_feature.rb +9 -64
  308. package/project/.sdk/tm/rb/feature/streaming_feature.rb +2 -1
  309. package/project/.sdk/tm/rb/feature/telemetry_feature.rb +11 -6
  310. package/project/.sdk/tm/rb/feature/test_feature.rb +42 -49
  311. package/project/.sdk/tm/rb/test/feature_corpus_test.rb +191 -25
  312. package/project/.sdk/tm/rb/test/feature_test.rb +75 -1
  313. package/project/.sdk/tm/rb/utility/clean.rb +6 -7
  314. package/project/.sdk/tm/rb/utility/fetcher.rb +6 -0
  315. package/project/.sdk/tm/rb/utility/make_options.rb +37 -16
  316. package/project/.sdk/tm/rust/core/context.rs +8 -0
  317. package/project/.sdk/tm/rust/feature/audit.rs +2 -2
  318. package/project/.sdk/tm/rust/feature/cache.rs +120 -3
  319. package/project/.sdk/tm/rust/feature/metrics.rs +24 -1
  320. package/project/.sdk/tm/rust/feature/paging.rs +189 -3
  321. package/project/.sdk/tm/rust/feature/ratelimit.rs +5 -10
  322. package/project/.sdk/tm/rust/feature/retry.rs +59 -6
  323. package/project/.sdk/tm/rust/feature/secrets.rs +36 -98
  324. package/project/.sdk/tm/rust/feature/streaming.rs +3 -2
  325. package/project/.sdk/tm/rust/feature/support.rs +4 -0
  326. package/project/.sdk/tm/rust/feature/telemetry.rs +22 -11
  327. package/project/.sdk/tm/rust/feature/test.rs +63 -57
  328. package/project/.sdk/tm/rust/tests/feature/secrets/main.rs +3 -3
  329. package/project/.sdk/tm/rust/tests/feature_test.rs +274 -0
  330. package/project/.sdk/tm/rust/tests/primary_utility_test.rs +1 -0
  331. package/project/.sdk/tm/rust/utility/clean.rs +35 -43
  332. package/project/.sdk/tm/rust/utility/fetcher.rs +6 -0
  333. package/project/.sdk/tm/rust/utility/make_options.rs +130 -38
  334. package/project/.sdk/tm/scala/core/Context.scala +4 -0
  335. package/project/.sdk/tm/scala/core/SdkClient.scala +45 -11
  336. package/project/.sdk/tm/scala/feature/AuditFeature.scala +6 -1
  337. package/project/.sdk/tm/scala/feature/CacheFeature.scala +117 -11
  338. package/project/.sdk/tm/scala/feature/MetricsFeature.scala +31 -1
  339. package/project/.sdk/tm/scala/feature/PagingFeature.scala +122 -2
  340. package/project/.sdk/tm/scala/feature/RatelimitFeature.scala +14 -11
  341. package/project/.sdk/tm/scala/feature/RetryFeature.scala +29 -7
  342. package/project/.sdk/tm/scala/feature/SecretsFeature.scala +11 -24
  343. package/project/.sdk/tm/scala/feature/StreamingFeature.scala +2 -1
  344. package/project/.sdk/tm/scala/feature/TelemetryFeature.scala +12 -10
  345. package/project/.sdk/tm/scala/feature/TestFeature.scala +44 -44
  346. package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +69 -0
  347. package/project/.sdk/tm/scala/utility/Fetcher.scala +5 -0
  348. package/project/.sdk/tm/scala/utility/Make.scala +99 -14
  349. package/project/.sdk/tm/scala/utility/Misc.scala +5 -8
  350. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Context.swift +3 -0
  351. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/AuditFeature.swift +3 -2
  352. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/CacheFeature.swift +122 -11
  353. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/MetricsFeature.swift +20 -0
  354. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/PagingFeature.swift +102 -2
  355. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/RatelimitFeature.swift +19 -13
  356. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/RetryFeature.swift +40 -5
  357. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/SecretsFeature.swift +9 -13
  358. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/StreamingFeature.swift +2 -1
  359. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TelemetryFeature.swift +11 -9
  360. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TestFeature.swift +55 -49
  361. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Fetcher.swift +4 -0
  362. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +56 -17
  363. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/ResultUtil.swift +4 -5
  364. package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +166 -0
  365. package/project/.sdk/tm/ts/src/Context.ts +4 -0
  366. package/project/.sdk/tm/ts/src/feature/cache/CacheFeature.ts +115 -4
  367. package/project/.sdk/tm/ts/src/feature/cost/CostFeature.ts +3 -2
  368. package/project/.sdk/tm/ts/src/feature/metrics/MetricsFeature.ts +6 -1
  369. package/project/.sdk/tm/ts/src/feature/paging/PagingFeature.ts +103 -5
  370. package/project/.sdk/tm/ts/src/feature/ratelimit/RatelimitFeature.ts +5 -9
  371. package/project/.sdk/tm/ts/src/feature/rbac/RbacFeature.ts +4 -4
  372. package/project/.sdk/tm/ts/src/feature/retry/RetryFeature.ts +25 -3
  373. package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +14 -2
  374. package/project/.sdk/tm/ts/src/feature/streaming/StreamingFeature.ts +2 -1
  375. package/project/.sdk/tm/ts/src/feature/telemetry/TelemetryFeature.ts +11 -6
  376. package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +8 -7
  377. package/project/.sdk/tm/ts/src/feature/validate/ValidateFeature.ts +2 -1
  378. package/project/.sdk/tm/ts/src/utility/CleanUtility.ts +1 -1
  379. package/project/.sdk/tm/ts/src/utility/MakeOptionsUtility.ts +63 -12
  380. package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +192 -23
  381. package/project/.sdk/tm/ts/test/feature/harness.ts +3 -3
  382. package/project/.sdk/tm/ts/test/feature.test.ts +14 -1
  383. package/project/.sdk/tm/ts/test/pipeline.test.ts +1 -1
  384. package/project/.sdk/tm/zig/core/context.zig +5 -0
  385. package/project/.sdk/tm/zig/core/utility.zig +118 -17
  386. package/project/.sdk/tm/zig/feature/cache.zig +144 -13
  387. package/project/.sdk/tm/zig/feature/metrics.zig +19 -0
  388. package/project/.sdk/tm/zig/feature/paging.zig +172 -4
  389. package/project/.sdk/tm/zig/feature/ratelimit.zig +5 -11
  390. package/project/.sdk/tm/zig/feature/retry.zig +41 -3
  391. package/project/.sdk/tm/zig/feature/secrets.zig +6 -1
  392. package/project/.sdk/tm/zig/feature/streaming.zig +2 -0
  393. package/project/.sdk/tm/zig/feature/telemetry.zig +15 -9
  394. package/project/.sdk/tm/zig/feature/test.zig +56 -40
  395. package/project/.sdk/tm/zig/test/feature_test.zig +174 -0
  396. package/project/.sdk/tm/zig/test/primary_utility_test.zig +2 -0
  397. package/project/sdkgen-package.json +1 -1
  398. package/src/cmp/ReadmeExplanation.ts +5 -2
  399. package/src/cmp/ReadmeFeatures.ts +21 -6
  400. package/src/helpers/optspec.ts +2 -2
@@ -20,6 +20,7 @@ use FindBin;
20
20
  use lib "$FindBin::Bin/../lib";
21
21
  use Cwd ();
22
22
  use Scalar::Util ();
23
+ use Time::HiRes ();
23
24
 
24
25
  use ProjectNameSDK;
25
26
 
@@ -66,13 +67,19 @@ ok(defined $CORPUS->{feature}, 'the corpus carries a feature section');
66
67
  # Returns the shape the real fetcher returns: a (response, err) PAIR, with the
67
68
  # parsed body behind a `json` coderef and `body` as the raw string. A script
68
69
  # that only set `body` would look like an empty result, which reads as a
69
- # feature defect rather than a mis-shaped script.
70
+ # feature defect rather than a mis-shaped script. Each URL it is sent is kept
71
+ # in `$sent`, and the time it was sent in `$at`; a `cut` response is one whose
72
+ # body stops before its end.
70
73
  sub scripted_fetcher {
71
- my ($res) = @_;
74
+ my ($res, $sent, $at) = @_;
75
+ $sent ||= [];
76
+ $at ||= [];
72
77
  my $n = -1;
73
78
  return sub {
74
79
  my ($ctx, $fullurl, $fetchdef) = @_;
75
80
  $n++;
81
+ push @$sent, $fullurl;
82
+ push @$at, Time::HiRes::time() * 1000;
76
83
  my $spec = {};
77
84
  if (ref $res eq 'ARRAY' && @$res) {
78
85
  my $i = $n >= scalar(@$res) ? scalar(@$res) - 1 : $n;
@@ -86,6 +93,18 @@ sub scripted_fetcher {
86
93
  my $status = defined $spec->{status} ? int($spec->{status}) : 200;
87
94
  my $body = defined $spec->{body} ? $spec->{body} : {};
88
95
 
96
+ if ($spec->{cut}) {
97
+ my $raw = Voxgig::Struct::stringify($body);
98
+ return ({
99
+ 'status' => $status,
100
+ 'statusText' => ($status < 400 ? 'OK' : 'ERR'),
101
+ 'headers' => { %{ $spec->{headers} || {} } },
102
+ 'json' => sub { undef },
103
+ 'body' => substr($raw, 0, int(length($raw) / 2)),
104
+ 'unreadable' => 1,
105
+ }, undef);
106
+ }
107
+
89
108
  return ({
90
109
  'status' => $status,
91
110
  'statusText' => ($status < 400 ? 'OK' : 'ERR'),
@@ -104,10 +123,10 @@ sub scripted_fetcher {
104
123
  # would shadow the script. The `test` OPTION installs no transport: it says
105
124
  # the client is not live, so a required server variable becomes test-<name>.
106
125
  sub build_client {
107
- my ($kase) = @_;
126
+ my ($kase, $sent, $at) = @_;
108
127
  my $opts = {
109
128
  'test' => { 'active' => 1 },
110
- 'utility' => { 'fetcher' => scripted_fetcher($kase->{res}) },
129
+ 'utility' => { 'fetcher' => scripted_fetcher($kase->{res}, $sent, $at) },
111
130
  };
112
131
  $opts->{feature} = $kase->{feature} if defined $kase->{feature};
113
132
  return ProjectNameSDK->new($opts);
@@ -162,11 +181,25 @@ sub candidates {
162
181
 
163
182
 
164
183
  sub invoke {
165
- my ($client, $op, $ctrl) = @_;
184
+ my ($client, $op, $ctrl, $args) = @_;
166
185
  my $acc = $op->{accessor};
167
186
  my $fn = $op->{op};
168
187
  my $ent = $client->$acc();
169
- return $ent->$fn({}, $ctrl);
188
+ return $ent->$fn({ %{ $args || {} } }, $ctrl);
189
+ }
190
+
191
+
192
+ my %ITEM_ARGS = (id => 'corpus-item');
193
+
194
+ # A write of one entity (#ITEM) that completes when driven with %ITEM_ARGS.
195
+ sub usable_item {
196
+ my ($accessor) = @_;
197
+ for my $cand (candidates(build_client({}))) {
198
+ next unless $cand->{accessor} eq $accessor && grep { $_ eq $cand->{op} } qw(update patch remove);
199
+ next unless eval { invoke(build_client({}), $cand, {}, \%ITEM_ARGS); 1 };
200
+ return $cand;
201
+ }
202
+ return undef;
170
203
  }
171
204
 
172
205
 
@@ -212,6 +245,86 @@ sub resolve {
212
245
  }
213
246
 
214
247
 
248
+ # A read and a write of one entity (#READ, #WRITE), each driven as usable_ops
249
+ # drives an op.
250
+ sub usable_pair {
251
+ my %found;
252
+ for my $cand (candidates(build_client({}))) {
253
+ my $role = (grep { $_ eq $cand->{op} } qw(list load)) ? 'read'
254
+ : (grep { $_ eq $cand->{op} } qw(create update patch remove)) ? 'write' : undef;
255
+ next unless defined $role;
256
+ my $seen = $found{ $cand->{accessor} } ||= {};
257
+ next if $seen->{$role};
258
+ next unless eval { invoke(build_client({}), $cand, {}); 1 };
259
+ $seen->{$role} = $cand;
260
+ return $seen if $seen->{read} && $seen->{write};
261
+ }
262
+ return undef;
263
+ }
264
+
265
+
266
+ # Read one operation through the entity's stream; how many it yields.
267
+ sub stream_items {
268
+ my ($client, $op, $ctrl, $args) = @_;
269
+ my $acc = $op->{accessor};
270
+ my $next = $client->$acc()->stream($op->{op}, { %{ $args || {} } }, { ctrl => $ctrl });
271
+ my $items = 0;
272
+ $items++ while defined $next->();
273
+ return $items;
274
+ }
275
+
276
+
277
+ # Each request a case expects, in order: its path, and its whole query. A path
278
+ # is compared without its leading slash, which an SDK with no base omits.
279
+ sub check_sent {
280
+ my ($sent, $expect, $label) = @_;
281
+ is(scalar(@$sent), scalar(@$expect), "$label: requests sent")
282
+ or diag(join(' | ', @$sent));
283
+ for my $i (0 .. $#$expect) {
284
+ my $want = $expect->[$i];
285
+ my ($path, $rawquery) = split /\?/, ($sent->[$i] // '') =~ s{\A[a-z][a-z0-9+.-]*://[^/?#]*}{}ir, 2;
286
+ if (defined $want->{path}) {
287
+ is($path =~ s{\A/+}{}r, $want->{path} =~ s{\A/+}{}r, "$label: request $i path");
288
+ }
289
+ if (defined $want->{query}) {
290
+ my %query;
291
+ for my $pair (split /&/, $rawquery // '') {
292
+ my ($k, $v) = map { my $t = $_ // ''; $t =~ tr/+/ /; $t =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/ge; $t }
293
+ split /=/, $pair, 2;
294
+ $query{$k} = $v;
295
+ }
296
+ is_deeply(\%query, $want->{query}, "$label: request $i query");
297
+ }
298
+ }
299
+ return;
300
+ }
301
+
302
+
303
+ # One step: it may wait before its call, may add request headers for its
304
+ # call, and may pass `args` as the operation's first argument. A `stream` step
305
+ # reads the operation through stream, and `items` is how many it yields.
306
+ sub step_call {
307
+ my ($client, $op, $step, $ctrl) = @_;
308
+ Time::HiRes::sleep($step->{wait} / 1000) if defined $step->{wait};
309
+ my $args = Voxgig::Struct::ismap($step->{args}) ? $step->{args} : {};
310
+ if ($step->{stream}) {
311
+ my $items = stream_items($client, $op, $ctrl, $args);
312
+ is($items, $step->{items}, "$op->{key}: items streamed") if defined $step->{items};
313
+ return $items;
314
+ }
315
+ return invoke($client, $op, $ctrl, $args) unless Voxgig::Struct::ismap($step->{headers});
316
+ my $options = $client->{options};
317
+ my $had = exists $options->{headers};
318
+ my $prior = $options->{headers};
319
+ $options->{headers} = { %{ $prior || {} }, %{ $step->{headers} } };
320
+ my $ok = eval { invoke($client, $op, $ctrl, $args); 1 };
321
+ my $err = $@;
322
+ if ($had) { $options->{headers} = $prior } else { delete $options->{headers} }
323
+ die $err unless $ok;
324
+ return;
325
+ }
326
+
327
+
215
328
  # The highest #OPn a case mentions.
216
329
  sub tokens_used {
217
330
  my ($kase) = @_;
@@ -234,6 +347,31 @@ sub member {
234
347
  }
235
348
 
236
349
 
350
+ # A step with `together: N` is N calls. Perl runs one call at a time, so
351
+ # they go in turn; each call's error, or undef, is returned.
352
+ sub calls {
353
+ my ($client, $op, $step, $ctrl) = @_;
354
+ my @errs;
355
+ for (1 .. ($step->{together} || 1)) {
356
+ my $ok = eval { step_call($client, $op, $step, $ctrl); 1 };
357
+ push @errs, $ok ? undef : ($@ || 'failed');
358
+ }
359
+ return @errs;
360
+ }
361
+
362
+
363
+ # The most requests seen in any window of `ms`.
364
+ sub busiest {
365
+ my ($sent, $ms) = @_;
366
+ my $most = 0;
367
+ for my $from (@$sent) {
368
+ my $n = grep { $from <= $_ && $_ < $from + $ms } @$sent;
369
+ $most = $n if $n > $most;
370
+ }
371
+ return $most;
372
+ }
373
+
374
+
237
375
  # Assert that `actual` contains `expect`, recursively. Cases assert only the
238
376
  # fields they are about, so a full deep comparison would force every case to
239
377
  # restate the whole record.
@@ -249,6 +387,13 @@ sub subset {
249
387
  return;
250
388
  }
251
389
 
390
+ if (ref $expect eq 'ARRAY') {
391
+ ok(ref $actual eq 'ARRAY' && scalar(@$actual) == scalar(@$expect),
392
+ "$path has " . scalar(@$expect) . ' item(s)') or return;
393
+ subset($actual->[$_], $expect->[$_], "$path\[$_\]") for 0 .. $#$expect;
394
+ return;
395
+ }
396
+
252
397
  # JSON true/false parse to a blessed Voxgig::Struct::Bool, and perl's own
253
398
  # booleans are a bare 1 or ''. Compare truth, not spelling: stringified,
254
399
  # those two are 'true' and '1' and would never match.
@@ -304,6 +449,9 @@ sub missing_feature {
304
449
 
305
450
 
306
451
  my @ops = usable_ops(2);
452
+ my $pair = usable_pair();
453
+ my $item = $pair ? usable_item($pair->{read}{accessor}) : undef;
454
+ my ($other) = $pair ? grep { $_->{accessor} ne $pair->{read}{accessor} } @ops : ();
307
455
 
308
456
  # At least one operation, or every case would skip and this file would report
309
457
  # green having run nothing.
@@ -333,7 +481,7 @@ for my $name (sort keys %{ $CORPUS->{feature} || {} }) {
333
481
  next;
334
482
  }
335
483
 
336
- my %by_key = map { $_->{key} => $_ } @ops;
484
+ my %by_key = map { $_->{key} => $_ } @ops, ($pair ? values %$pair : ()), ($item ? $item : ());
337
485
 
338
486
  my $ran = 0;
339
487
  for my $raw (@$cases) {
@@ -344,6 +492,21 @@ for my $name (sort keys %{ $CORPUS->{feature} || {} }) {
344
492
  next;
345
493
  }
346
494
 
495
+ my $paired = Voxgig::Struct::stringify($raw) =~ /#(READ|WRITE|ITEM|OTHER)\b/;
496
+ if ($paired && !$pair) {
497
+ diag(sprintf('skip "%s": needs a read and a write of one entity, this SDK offers none',
498
+ $raw->{name} // ''));
499
+ next;
500
+ }
501
+ my ($lacking) = grep {
502
+ my ($tok, $found) = @$_;
503
+ $paired && !$found && Voxgig::Struct::stringify($raw) =~ /\Q$tok\E\b/
504
+ } (['#ITEM', $item], ['#OTHER', $other]);
505
+ if ($lacking) {
506
+ diag(sprintf('skip "%s": needs %s, which this SDK cannot drive', $raw->{name} // '', $lacking->[0]));
507
+ next;
508
+ }
509
+
347
510
  my $missing = missing_feature($raw, \%have);
348
511
  if (defined $missing) {
349
512
  diag(sprintf('skip "%s": needs the %s feature, which this SDK does not generate',
@@ -355,40 +518,56 @@ for my $name (sort keys %{ $CORPUS->{feature} || {} }) {
355
518
  for my $i (0 .. $need - 1) {
356
519
  $tokens{ '#OP' . ($i + 1) } = $ops[$i]{key};
357
520
  }
521
+ if ($paired) {
522
+ $tokens{'#READ'} = $pair->{read}{key};
523
+ $tokens{'#WRITE'} = $pair->{write}{key};
524
+ $tokens{'#ITEM'} = $item->{key} if $item;
525
+ $tokens{'#OTHER'} = $other->{key} if $other;
526
+ }
358
527
  my $kase = resolve($raw, \%tokens);
359
528
  my $label = $kase->{name} || '';
360
529
  $ran++;
361
530
 
362
531
  # Every failing case is reported, not only the first.
363
532
  my $done = eval {
364
- my $client = build_client($kase);
533
+ my $sent = [];
534
+ my @at;
535
+ my $client = build_client($kase, $sent, \@at);
365
536
 
537
+ # A case-level ctrl is one control object every step shares.
538
+ my $shared = $kase->{ctrl};
366
539
  for my $step (@{ $kase->{op} || [] }) {
367
540
  my $op = $by_key{ $step->{op} };
368
541
  ok(defined $op, "$label: operation $step->{op} is known") or next;
369
- my $ctrl = $step->{ctrl} || {};
542
+ my $ctrl = $step->{ctrl} || $shared || {};
370
543
  my $wanterr = $step->{err};
371
544
 
372
- my $ok = eval { invoke($client, $op, $ctrl); 1 };
373
- my $err = $@;
374
-
375
- if (!defined $wanterr) {
376
- ok($ok, "$label: $step->{op} succeeded")
377
- or diag("failed unexpectedly: $err");
378
- next;
545
+ for my $err (calls($client, $op, $step, $ctrl)) {
546
+ if (!defined $wanterr) {
547
+ ok(!defined $err, "$label: $step->{op} succeeded")
548
+ or diag("failed unexpectedly: $err");
549
+ next;
550
+ }
551
+
552
+ ok(defined $err, "$label: $step->{op} failed as expected") or next;
553
+
554
+ if (!ref $wanterr) {
555
+ # The CODE, not the message: make_error prefixes and humanises the
556
+ # text, so matching it would pass on any error mentioning the word.
557
+ my $code = (Scalar::Util::blessed($err) && $err->can('code'))
558
+ ? $err->code : undef;
559
+ is($code, $wanterr, "$label: error code");
560
+ }
379
561
  }
562
+ }
380
563
 
381
- ok(!$ok, "$label: $step->{op} failed as expected") or next;
382
-
383
- if (!ref $wanterr) {
384
- # The CODE, not the message: make_error prefixes and humanises the
385
- # text, so matching it would pass on any error mentioning the word.
386
- my $code = (Scalar::Util::blessed($err) && $err->can('code'))
387
- ? $err->code : undef;
388
- is($code, $wanterr, "$label: error code");
389
- }
564
+ if (my $pace = $kase->{pace}) {
565
+ my $most = busiest(\@at, $pace->{ms});
566
+ ok($most <= $pace->{max},
567
+ "$label: $most requests within $pace->{ms} ms, want at most $pace->{max}");
390
568
  }
391
569
 
570
+ check_sent($sent, $kase->{sent}, $label) if defined $kase->{sent};
392
571
  subset(record($client, $name), $kase->{out}, "$label: _$name");
393
572
  1;
394
573
  };
@@ -69,16 +69,14 @@ sub count {
69
69
  return $n < 0 ? $dflt : $n;
70
70
  }
71
71
 
72
- # The derived block make_options builds; a context without options
73
- # (make_error is reached with a bare one) falls back to the schema
74
- # defaults, so nothing leaves raw for want of a constructor. A plain hash
75
- # stands in for a context before one exists (make_options).
72
+ # The registry make_options builds; a context without one (make_error is
73
+ # reached with a bare one) falls back to the schema defaults, so nothing
74
+ # leaves raw for want of a constructor. A plain hash stands in for a context
75
+ # before one exists (make_options).
76
76
  sub config {
77
77
  my ($ctx) = @_;
78
- my $opts = (defined $ctx && ref $ctx && (Scalar::Util::reftype($ctx) // '') eq 'HASH')
79
- ? $ctx->{options} : undef;
80
- my $derived = Voxgig::Struct::ismap($opts) ? $opts->{__derived__} : undef;
81
- my $cfg = Voxgig::Struct::ismap($derived) ? $derived->{clean} : undef;
78
+ my $cfg = (defined $ctx && ref $ctx && (Scalar::Util::reftype($ctx) // '') eq 'HASH')
79
+ ? $ctx->{cleancfg} : undef;
82
80
  return $cfg if Voxgig::Struct::ismap($cfg) && Voxgig::Struct::islist($cfg->{values});
83
81
  return make_config(ProjectNameSchema::optspec()->{clean});
84
82
  }
@@ -162,6 +162,10 @@ sub _send_once {
162
162
  $new_args{http_proxy} = $new_args{https_proxy} = "$fetchdef->{proxy}"
163
163
  if defined $fetchdef->{proxy} && !ref $fetchdef->{proxy}
164
164
  && length $fetchdef->{proxy};
165
+ # A bound in milliseconds, for a caller beneath the timeout feature.
166
+ $new_args{timeout} = $fetchdef->{timeout} / 1000
167
+ if defined $fetchdef->{timeout} && !ref $fetchdef->{timeout}
168
+ && $fetchdef->{timeout} =~ /\A\d+(?:\.\d+)?\z/ && $fetchdef->{timeout} > 0;
165
169
 
166
170
  # A request that got no answer fails the operation.
167
171
  my $res = eval { _http_client(%new_args)->request($method, $fullurl, $opts) };
@@ -18,6 +18,24 @@ package ProjectNameUtilities;
18
18
 
19
19
  our %REGISTRY;
20
20
 
21
+ # The model's options for a feature sit beneath the caller's, key by key: a
22
+ # key the caller sets replaces the default whole, so a list is never merged.
23
+ sub feature_defaults {
24
+ my ($cfgfeature, $feature) = @_;
25
+ return undef if defined $feature && !Voxgig::Struct::ismap($feature);
26
+ my %out = %{ $feature || {} };
27
+ my $cfg = Voxgig::Struct::ismap($cfgfeature) ? $cfgfeature : {};
28
+ for my $name (keys %$cfg) {
29
+ my $dflt = Voxgig::Struct::ismap($cfg->{$name}) ? $cfg->{$name}{options} : undef;
30
+ my $given = $out{$name};
31
+ next unless Voxgig::Struct::ismap($dflt);
32
+ next if !defined $given && !ProjectNameHelpers::is_true($dflt->{active});
33
+ next if defined $given && !Voxgig::Struct::ismap($given);
34
+ $out{$name} = { %{ Voxgig::Struct::clone($dflt) }, %{ $given || {} } };
35
+ }
36
+ return \%out;
37
+ }
38
+
21
39
  $REGISTRY{make_options} = sub {
22
40
  my ($ctx) = @_;
23
41
  my $options = $ctx->{options} || {};
@@ -102,7 +120,7 @@ $REGISTRY{make_options} = sub {
102
120
  (Voxgig::Struct::clone(ProjectNameSchema::optspec()->{clean}),
103
121
  Voxgig::Struct::clone($cfgopts->{clean}), $opts->{clean}),
104
122
  ]));
105
- my $cleanctx = { 'options' => { '__derived__' => { 'clean' => $cleancfg } } };
123
+ my $cleanctx = { 'cleancfg' => $cleancfg };
106
124
  my %rawscan = %$opts;
107
125
  delete $rawscan{clean};
108
126
  ProjectNameCleanSupport::add_options($cleanctx, \%rawscan);
@@ -134,6 +152,9 @@ $REGISTRY{make_options} = sub {
134
152
  $opts->{feature} = \%fmap;
135
153
  }
136
154
 
155
+ my $fdefaults = ProjectNameUtilities::feature_defaults($config->{feature}, $opts->{feature});
156
+ $opts->{feature} = $fdefaults if defined $fdefaults;
157
+
137
158
  # THE OPTION SPEC IS GENERATED, NOT WRITTEN HERE.
138
159
  #
139
160
  # Built from the model: `main.kit.optspec` for the standard options, plus one
@@ -208,14 +229,15 @@ $REGISTRY{make_options} = sub {
208
229
  $opts->{base} = $resolved;
209
230
  }
210
231
 
211
- # Resolve the feature add-order: an explicit array order (above) wins;
212
- # otherwise order the map test-first, then the remaining names sorted, so
213
- # the outcome is deterministic and `test` is always the base transport.
214
- if (!@featureorder) {
232
+ # Resolve the feature add-order: an explicit array order (above) wins, and
233
+ # the names it leaves out follow it test-first, then sorted, so the outcome
234
+ # is deterministic and `test` is the base transport of a map.
235
+ {
215
236
  my $fmap = ProjectNameHelpers::to_map(
216
237
  ProjectNameHelpers::gp($opts, 'feature')) || {};
217
- my @names = sort keys %$fmap;
218
- @featureorder = (grep { 'test' eq $_ } @names)
238
+ my %given = map { $_ => 1 } @featureorder;
239
+ my @names = sort grep { !$given{$_} } keys %$fmap;
240
+ my @rest = (grep { 'test' eq $_ } @names)
219
241
  ? ('test', grep { 'test' ne $_ } @names)
220
242
  : @names;
221
243
 
@@ -225,18 +247,19 @@ $REGISTRY{make_options} = sub {
225
247
  # test - or first, when no test entry exists. Without this the
226
248
  # sorted default would init station last and wrap OUTSIDE the
227
249
  # recording features, turning its wire-truth events into fiction.
228
- my ($si) = grep { 'station' eq $featureorder[$_] } 0 .. $#featureorder;
250
+ my ($si) = grep { 'station' eq $rest[$_] } 0 .. $#rest;
229
251
  if (defined $si) {
230
- splice @featureorder, $si, 1;
231
- my ($ti) = grep { 'test' eq $featureorder[$_] } 0 .. $#featureorder;
232
- splice @featureorder, (defined $ti ? $ti + 1 : 0), 0, 'station';
252
+ splice @rest, $si, 1;
253
+ my ($ti) = grep { 'test' eq $rest[$_] } 0 .. $#rest;
254
+ splice @rest, (defined $ti ? $ti + 1 : 0), 0, 'station';
233
255
  }
256
+ push @featureorder, @rest;
234
257
  }
235
258
 
236
- $opts->{__derived__} = {
237
- 'clean' => $cleancfg,
238
- 'featureorder' => \@featureorder,
239
- };
259
+ $opts->{__derived__} = { 'featureorder' => \@featureorder };
260
+
261
+ # Beside the options, not in them: options_map hands them to callers.
262
+ $ctx->{cleancfg} = $cleancfg;
240
263
 
241
264
  # Again over the merged result: the config's own defaults can carry one.
242
265
  # The extend instances are live objects, not option data.
@@ -22,6 +22,8 @@ class ProjectNameContext implements \JsonSerializable
22
22
  public ?array $config;
23
23
  public ?array $entopts;
24
24
  public ?array $options;
25
+ // The clean registry, beside the options rather than in them.
26
+ public ?\stdClass $cleancfg = null;
25
27
  public mixed $entity;
26
28
  public ?array $shared;
27
29
  public array $opmap;
@@ -77,6 +79,8 @@ class ProjectNameContext implements \JsonSerializable
77
79
 
78
80
  $o = ProjectNameHelpers::get_ctx_prop($ctxmap, 'options');
79
81
  $this->options = is_array($o) ? $o : ($basectx ? $basectx->options : null);
82
+ $cc = ProjectNameHelpers::get_ctx_prop($ctxmap, 'cleancfg');
83
+ $this->cleancfg = $cc instanceof \stdClass ? $cc : ($basectx ? $basectx->cleancfg : null);
80
84
 
81
85
  $e = ProjectNameHelpers::get_ctx_prop($ctxmap, 'entity');
82
86
  $this->entity = $e ?? ($basectx ? $basectx->entity : null);
@@ -6,20 +6,18 @@ declare(strict_types=1);
6
6
  require_once __DIR__ . '/BaseFeature.php';
7
7
  require_once __DIR__ . '/../utility/Media.php';
8
8
 
9
- // Response caching for safe (read) requests. Wraps the active transport and
10
- // serves a fresh cached snapshot instead of hitting the network when the
11
- // same method+URL was fetched within `ttl` ms (default 5000). Only
12
- // successful (2xx) responses to cacheable methods (default: GET) are
13
- // stored, keyed by method+URL. The cache is bounded (`max` entries, default
14
- // 256, oldest evicted first) and every hit/miss/bypass is recorded on
15
- // `client->_cache` for inspection. Snapshots replay through a fresh `json`
16
- // closure so both the current caller and later hits can read the body
17
- // repeatedly. Mirrors ts/src/feature/cache/CacheFeature.ts.
9
+ // Response caching for safe (read) requests, per client: see the features
10
+ // reference for the key, the write invalidation and the Cache-Control rules.
11
+ // Mirrors ts/src/feature/cache/CacheFeature.ts.
18
12
  class ProjectNameCacheFeature extends ProjectNameBaseFeature
19
13
  {
14
+ private const SAFE_METHODS = ['GET', 'HEAD'];
15
+ private const UNSTORED = ['no-store', 'private', 'no-cache'];
16
+
20
17
  private mixed $client;
21
18
  private ?array $options;
22
19
  private array $store;
20
+ private string $secret = '';
23
21
 
24
22
  public function __construct()
25
23
  {
@@ -43,6 +41,7 @@ class ProjectNameCacheFeature extends ProjectNameBaseFeature
43
41
  }
44
42
 
45
43
  $this->store = [];
44
+ $this->secret = random_bytes(32);
46
45
 
47
46
  $utility = $ctx->utility;
48
47
  $inner = $utility->fetcher;
@@ -58,10 +57,17 @@ class ProjectNameCacheFeature extends ProjectNameBaseFeature
58
57
  $methods = $this->options['methods'] ?? ['GET'];
59
58
 
60
59
  if (!is_array($methods) || !in_array($method, $methods, true)) {
61
- return $inner($ctx, $url, $fetchdef);
60
+ if (in_array($method, self::SAFE_METHODS, true)) {
61
+ return $inner($ctx, $url, $fetchdef);
62
+ }
63
+ try {
64
+ return $inner($ctx, $url, $fetchdef);
65
+ } finally {
66
+ $this->_invalidate($url);
67
+ }
62
68
  }
63
69
 
64
- $key = $method . ' ' . $url;
70
+ $key = $method . ' ' . $url . ' ' . $this->_digest($fetchdef['headers'] ?? null);
65
71
  $now = $this->_now();
66
72
  $hit = $this->store[$key] ?? null;
67
73
 
@@ -80,9 +86,15 @@ class ProjectNameCacheFeature extends ProjectNameBaseFeature
80
86
 
81
87
  if ($this->_cacheable($res, $err)) {
82
88
  $snapshot = $this->_snapshot($res);
83
- $ttl = is_numeric($this->options['ttl'] ?? null) ? (float)$this->options['ttl'] : 5000.0;
89
+ $ttl = self::lifetime($snapshot['headers'],
90
+ is_numeric($this->options['ttl'] ?? null) ? (float)$this->options['ttl'] : 5000.0);
91
+ if ($ttl <= 0) {
92
+ $this->_track('bypass');
93
+ return [$this->_replay($snapshot), null];
94
+ }
95
+ unset($this->store[$key]);
84
96
  $this->_evict();
85
- $this->store[$key] = ['expiry' => $now + $ttl, 'snapshot' => $snapshot];
97
+ $this->store[$key] = ['expiry' => $now + $ttl, 'scope' => self::scope($url), 'snapshot' => $snapshot];
86
98
  $this->_track('miss');
87
99
  return [$this->_replay($snapshot), null];
88
100
  }
@@ -91,6 +103,79 @@ class ProjectNameCacheFeature extends ProjectNameBaseFeature
91
103
  return [$res, $err];
92
104
  }
93
105
 
106
+ private function _digest(mixed $headers): string
107
+ {
108
+ $pairs = [];
109
+ if (is_array($headers)) {
110
+ foreach ($headers as $name => $val) {
111
+ if ($val !== null) {
112
+ $pairs[] = [strtolower((string)$name), is_scalar($val) ? (string)$val : json_encode($val)];
113
+ }
114
+ }
115
+ }
116
+ usort($pairs, fn($a, $b) => strcmp($a[0], $b[0]) ?: strcmp($a[1], $b[1]));
117
+ $text = '';
118
+ foreach ($pairs as [$name, $val]) {
119
+ $text .= $name . ':' . $val . "\n";
120
+ }
121
+ return hash_hmac('sha256', $text, $this->secret);
122
+ }
123
+
124
+ private function _invalidate(string $url): void
125
+ {
126
+ $path = self::scope($url);
127
+ $collection = self::parent($path);
128
+ foreach ($this->store as $key => $entry) {
129
+ if (self::under($entry['scope'], $path) || $entry['scope'] === $collection) {
130
+ unset($this->store[$key]);
131
+ }
132
+ }
133
+ }
134
+
135
+ // The configured ttl capped by the response's Cache-Control; zero when
136
+ // the response may not be stored.
137
+ private static function lifetime(array $headers, float $ttl): float
138
+ {
139
+ $control = '';
140
+ foreach ($headers as $name => $val) {
141
+ if (strtolower((string)$name) === 'cache-control') {
142
+ $control = strtolower((string)$val);
143
+ }
144
+ }
145
+ $life = $ttl;
146
+ foreach (explode(',', $control) as $part) {
147
+ $directive = trim($part);
148
+ if (in_array($directive, self::UNSTORED, true)) {
149
+ return 0.0;
150
+ }
151
+ if (preg_match('/^max-age\s*=\s*"?(\d+)"?$/', $directive, $age)) {
152
+ $life = min($life, (float)$age[1] * 1000.0);
153
+ }
154
+ }
155
+ return $life;
156
+ }
157
+
158
+ private static function scope(string $url): string
159
+ {
160
+ return rtrim(preg_split('/[?#]/', $url, 2)[0], '/');
161
+ }
162
+
163
+ private static function parent(string $scope): string
164
+ {
165
+ $scheme = strpos($scope, '://');
166
+ $root = $scheme === false ? 0 : strpos($scope, '/', $scheme + 3);
167
+ if ($root === false) {
168
+ return $scope;
169
+ }
170
+ $cut = strrpos($scope, '/');
171
+ return substr($scope, 0, max($cut === false ? 0 : $cut, $root));
172
+ }
173
+
174
+ private static function under(string $scope, string $prefix): bool
175
+ {
176
+ return $scope === $prefix || str_starts_with($scope, $prefix . '/');
177
+ }
178
+
94
179
  private function _cacheable(mixed $res, mixed $err): bool
95
180
  {
96
181
  // A body the transport could not read as JSON passes through, for the operation to report.
@@ -99,6 +99,14 @@ class ProjectNameMetricsFeature extends ProjectNameBaseFeature
99
99
 
100
100
  $this->_bump($client->_metrics['total'], $ok, $dur);
101
101
  $this->_bump($client->_metrics['ops'][$key], $ok, $dur);
102
+
103
+ $sink = $this->options['sink'] ?? null;
104
+ if (is_callable($sink)) {
105
+ try {
106
+ $sink(($ctx->utility->clean)($ctx, $client->_metrics));
107
+ } catch (\Throwable $e) {
108
+ }
109
+ }
102
110
  }
103
111
 
104
112
  private function _bump(array &$bucket, bool $ok, float $dur): void