@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
@@ -226,6 +226,7 @@ let make_context_impl (cs : ctxspec) (basectx : ctx option) : ctx =
226
226
  let options =
227
227
  match cs.cs_options with Some (Map _ as m) -> m
228
228
  | _ -> (match basectx with Some b -> b.c_options | None -> Noval) in
229
+ let cleancfg = match basectx with Some b -> b.c_cleancfg | None -> Noval in
229
230
  let entity =
230
231
  match cs.cs_entity with Some _ as e -> e
231
232
  | None -> (match basectx with Some b -> b.c_entity | None -> None) in
@@ -248,6 +249,7 @@ let make_context_impl (cs : ctxspec) (basectx : ctx option) : ctx =
248
249
  c_id = id; c_out = Hashtbl.create 8; c_ctrl = ctrl; c_meta = meta;
249
250
  c_client = client; c_utility = utility; c_op = new_operation (empty_map ());
250
251
  c_point = point; c_config = config; c_entopts = entopts; c_options = options;
252
+ c_cleancfg = cleancfg;
251
253
  c_opmap = opmap; c_response = response; c_result = result; c_spec = spec;
252
254
  c_data = data; c_reqdata = reqdata; c_match = mtch; c_reqmatch = reqmatch;
253
255
  c_entity = entity; c_shared = shared; c_scratch = Hashtbl.create 8;
@@ -302,9 +304,9 @@ let count_opt (v : value) (dflt : int) : int =
302
304
  | _ -> None in
303
305
  match n with Some n when n >= 0. -> int_of_float (Float.floor n) | _ -> dflt
304
306
 
305
- (* The derived clean block: a struct map so it lives in options.__derived__
306
- * and its `values` list stays MUTABLE after make_options - features
307
- * register what they resolve later. *)
307
+ (* The clean registry: a struct map held on the context as c_cleancfg, whose
308
+ * `values` list stays MUTABLE after make_options - features register what
309
+ * they resolve later. *)
308
310
  let make_clean_config (cleanopts : value) : value =
309
311
  jo [("active", Bool (getp cleanopts "active" <> Bool false));
310
312
  ("keys", ja (List.map (fun s -> Str s) (splitkeys (getp cleanopts "keys"))));
@@ -313,10 +315,10 @@ let make_clean_config (cleanopts : value) : value =
313
315
  ("hint", vint_of (count_opt (getp cleanopts "hint") 0));
314
316
  ("min", vint_of (max 1 (count_opt (getp cleanopts "min") 4)))]
315
317
 
316
- (* A context without options (make_error accepts a bare one) still masks by
317
- * the schema defaults. *)
318
+ (* A context without a registry (make_error accepts a bare one) still masks
319
+ * by the schema defaults. *)
318
320
  let clean_config (ctx : ctx) : value =
319
- match getpath_s ctx.c_options "__derived__.clean" with
321
+ match ctx.c_cleancfg with
320
322
  | Map _ as m -> m
321
323
  | _ -> make_clean_config (getp (Sdk_schema.opt_spec_value ()) "clean")
322
324
 
@@ -1713,6 +1715,30 @@ let secret_scan (opts : value) (names : string list) : value =
1713
1715
  | _, v -> setp out k v) (keysof opts);
1714
1716
  out
1715
1717
 
1718
+ (* The model's options for a feature sit beneath the caller's, key by key: a
1719
+ key the caller sets replaces the default whole, so a list is never merged. *)
1720
+ let feature_defaults (opts : value) (cfgfeature : value) : unit =
1721
+ let given = getp opts "feature" in
1722
+ let absent v = match v with Noval | Null -> true | _ -> false in
1723
+ match cfgfeature with
1724
+ | Map _ when absent given || (match given with Map _ -> true | _ -> false) ->
1725
+ let out = empty_map () in
1726
+ (match given with Map _ -> List.iter (fun k -> setp out k (getp given k)) (keysof given) | _ -> ());
1727
+ List.iter (fun name ->
1728
+ let dflt = getp (getp cfgfeature name) "options" in
1729
+ let fopts = getp out name in
1730
+ let wanted = match dflt, fopts with
1731
+ | Map _, Map _ -> true
1732
+ | Map _, v when absent v -> (match getp dflt "active" with Bool b -> b | _ -> false)
1733
+ | _ -> false in
1734
+ if wanted then begin
1735
+ let merged = clone dflt in
1736
+ (match fopts with Map _ -> List.iter (fun k -> setp merged k (getp fopts k)) (keysof fopts) | _ -> ());
1737
+ setp out name merged
1738
+ end) (keysof cfgfeature);
1739
+ setp opts "feature" out
1740
+ | _ -> ()
1741
+
1716
1742
  let make_options_util (ctx : ctx) : value =
1717
1743
  let options = match ctx.c_options with Noval -> empty_map () | v -> v in
1718
1744
  (match getp options "utility" with
@@ -1756,6 +1782,7 @@ let make_options_util (ctx : ctx) : value =
1756
1782
  | _ -> None in
1757
1783
  let config = match ctx.c_config with Map _ as m -> m | _ -> empty_map () in
1758
1784
  let cfgopts = match to_map (getp config "options") with Map _ as m -> m | _ -> empty_map () in
1785
+ feature_defaults opts (getp config "feature");
1759
1786
  (* THE OPTION SPEC IS GENERATED, NOT WRITTEN HERE.
1760
1787
 
1761
1788
  Built from the model: main.kit.optspec for the standard options, plus one
@@ -1776,7 +1803,7 @@ let make_options_util (ctx : ctx) : value =
1776
1803
  | Map _ -> List.iter (fun k -> setp cleanraw k (getp src k)) (keysof src)
1777
1804
  | _ -> ()) [getp optspec "clean"; getp cfgopts "clean"; getp opts "clean"];
1778
1805
  let cleancfg = make_clean_config cleanraw in
1779
- let cleanctx = { ctx with c_options = jo [("__derived__", jo [("clean", cleancfg)])] } in
1806
+ let cleanctx = { ctx with c_cleancfg = cleancfg } in
1780
1807
  clean_add_sensitive cleanctx (secret_scan opts ["clean"]);
1781
1808
  List.iter (fun src -> List.iter (clean_add_util cleanctx) (splitvalues (getpath_s src "clean.values")))
1782
1809
  [cfgopts; opts];
@@ -1845,23 +1872,22 @@ let make_options_util (ctx : ctx) : value =
1845
1872
  match getp opts "system" with
1846
1873
  | Map _ as sys -> setp sys "fetch" sys_fetch
1847
1874
  | _ -> setp opts "system" (jo [("fetch", sys_fetch)]));
1848
- (* Resolve the feature add-order: an explicit list order (above) wins;
1849
- otherwise order the map test-first, then the remaining names sorted, so
1850
- the outcome is deterministic and `test` is always the base transport. *)
1875
+ (* Resolve the feature add-order: an explicit list order (above) wins, and
1876
+ the names it leaves out follow it test-first, then sorted, so the outcome
1877
+ is deterministic and `test` is the base transport of a map. *)
1851
1878
  let feature_order =
1852
- match explicit_order with
1853
- | Some ord -> ord
1854
- | None ->
1855
- let fmap = match getp opts "feature" with Map _ as m -> m | _ -> empty_map () in
1856
- let names = keysof fmap in
1857
- if List.mem "test" names
1858
- then "test" :: List.filter (fun n -> n <> "test") names
1859
- else names in
1860
- let derived = jo [("clean", cleancfg);
1861
- ("featureorder", ja (List.map (fun s -> Str s) feature_order))] in
1879
+ let given = match explicit_order with Some ord -> ord | None -> [] in
1880
+ let fmap = match getp opts "feature" with Map _ as m -> m | _ -> empty_map () in
1881
+ let names = List.filter (fun n -> not (List.mem n given)) (keysof fmap) in
1882
+ given @ (if List.mem "test" names
1883
+ then "test" :: List.filter (fun n -> n <> "test") names
1884
+ else names) in
1885
+ let derived = jo [("featureorder", ja (List.map (fun s -> Str s) feature_order))] in
1862
1886
  setp opts "__derived__" derived;
1887
+ (* Beside the options, not in them: options_map hands them to callers. *)
1888
+ ctx.c_cleancfg <- cleancfg;
1863
1889
  (* Again over the merged result: the config's own defaults can carry one. *)
1864
- clean_add_sensitive { ctx with c_options = opts } (secret_scan opts ["clean"; "__derived__"]);
1890
+ clean_add_sensitive cleanctx (secret_scan opts ["clean"; "__derived__"]);
1865
1891
  opts
1866
1892
 
1867
1893
  (* ------------------------------------------------------------------ *)
@@ -263,6 +263,8 @@ and ctx = {
263
263
  mutable c_config : value;
264
264
  mutable c_entopts : value;
265
265
  mutable c_options : value;
266
+ (* The clean registry, beside the options rather than in them. *)
267
+ mutable c_cleancfg : value;
266
268
  (* Shared by every context of one client, so by requests on other domains:
267
269
  * a map replaced whole, never changed in place. *)
268
270
  mutable c_opmap : operation OpMap.t Atomic.t;
@@ -215,7 +215,41 @@ let () =
215
215
  let (srv, calls) = recording_server () in
216
216
  let h = make_client ~server:srv [("cache", jo [("active", Bool false)])] in
217
217
  ignore (op h ~op:"load" ~path:"/x" ()); ignore (op h ~op:"load" ~path:"/x" ());
218
- check_int "calls" (List.length !calls) 2)
218
+ check_int "calls" (List.length !calls) 2);
219
+ test "cache.keys_on_request_headers" (fun () ->
220
+ let (srv, calls) = recording_server () in
221
+ let h = make_client ~server:srv [("cache", jo [("ttl", Num 10000.)])] in
222
+ ignore (op h ~op:"load" ~path:"/w/1" ~headers:[("x-tenant", Str "tenant-a")] ());
223
+ ignore (op h ~op:"load" ~path:"/w/1" ~headers:[("X-Tenant", Str "tenant-b")] ());
224
+ check_int "tenant calls" (List.length !calls) 2;
225
+ ignore (op h ~op:"load" ~path:"/w/1" ~headers:[("x-tenant", Str "tenant-b")] ());
226
+ check_int "same headers calls" (List.length !calls) 2);
227
+ test "cache.write_drops_collection" (fun () ->
228
+ let (srv, calls) = recording_server () in
229
+ let h = make_client ~server:srv [("cache", jo [("ttl", Num 10000.)])] in
230
+ let paths = ["/w/1"; "/w"; "/w/1/part"; "/other/1"; "/w/2"] in
231
+ List.iter (fun p -> ignore (op h ~op:"load" ~path:p ())) paths;
232
+ ignore (op h ~op:"update" ~method_:"PUT" ~path:"/w/1" ());
233
+ List.iter (fun p -> ignore (op h ~op:"load" ~path:p ())) paths;
234
+ check_int "calls" (List.length !calls) 9;
235
+ check_vnum "hit" (getp (track h "cache") "hit") 2.);
236
+ test "cache.control_prevents_storing" (fun () ->
237
+ List.iter (fun control ->
238
+ let (srv, calls) = recording_server
239
+ ~reply:(fun _ _ -> (make_response ~headers:[("Cache-Control", Str control)] 200 (jo [("ok", Bool true)]), None)) () in
240
+ let h = make_client ~server:srv [("cache", jo [("ttl", Num 10000.)])] in
241
+ ignore (op h ~op:"load" ~path:"/w" ()); ignore (op h ~op:"load" ~path:"/w" ());
242
+ check_int control (List.length !calls) 2)
243
+ ["no-store"; "private"; "No-Cache"; "max-age=60, private"]);
244
+ test "cache.max_age_caps_ttl" (fun () ->
245
+ let c = make_clock () in
246
+ let (srv, calls) = recording_server
247
+ ~reply:(fun _ _ -> (make_response ~headers:[("cache-control", Str "max-age=1")] 200 (jo [("ok", Bool true)]), None)) () in
248
+ let h = make_client ~server:srv [("cache", jo [("ttl", Num 10000.); ("now", clock_now_fn c)])] in
249
+ ignore (op h ~op:"load" ~path:"/w" ()); clock_advance c 500.; ignore (op h ~op:"load" ~path:"/w" ());
250
+ check_int "inside max-age" (List.length !calls) 1;
251
+ clock_advance c 600.; ignore (op h ~op:"load" ~path:"/w" ());
252
+ check_int "after max-age" (List.length !calls) 2)
219
253
  end;
220
254
 
221
255
  (* ---------------- idempotency ---------------- *)
@@ -338,7 +372,8 @@ let () =
338
372
  let h = make_client [("telemetry", empty_map ())] in
339
373
  ignore (op h ~op:"load" ());
340
374
  let tid = vs_str (getp (getelem (getp (track h "telemetry") "spans") (Num 0.)) "traceId") in
341
- check "starts t" (String.length tid > 0 && tid.[0] = 't'));
375
+ let hex = String.for_all (fun c -> (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')) in
376
+ check "w3c trace id" (String.length tid = 32 && hex tid && String.exists (fun c -> c <> '0') tid));
342
377
  test "telemetry.inactive" (fun () ->
343
378
  let h = make_client [("telemetry", jo [("active", Bool false)])] in
344
379
  ignore (op h ~op:"load" ());
@@ -480,6 +515,62 @@ let () =
480
515
  let pg = match r.or_result with Some x -> x.rt_paging | None -> Noval in
481
516
  check_vstr "cursor" (getp pg "cursor") "abc";
482
517
  check "hasMore" (getp pg "hasMore" = Bool true));
518
+ (* The documented hasMore loop, one request per page. *)
519
+ let walk ?(options = empty_map ()) reply =
520
+ let (srv, calls) = recording_server ~reply:(fun n _ -> (reply n, None)) () in
521
+ let h = make_client ~server:srv [("paging", options)] in
522
+ let paging = empty_map () in
523
+ let ctrl = jo [("paging", paging)] in
524
+ ignore (op h ~op:"list" ~path:"/w" ~ctrl ());
525
+ while getp paging "hasMore" = Bool true && List.length !calls < 4 do
526
+ ignore (op h ~op:"list" ~path:"/w" ~ctrl ())
527
+ done;
528
+ (List.map (fun c -> vs_str (getp c "url")) !calls, paging) in
529
+ let nth_or l n d = if n >= 1 && n <= List.length l then List.nth l (n - 1) else d in
530
+ test "paging.body_next_is_the_cursor" (fun () ->
531
+ let (urls, pg) = walk (fun n -> make_response 200 (jo [("next", nth_or [Str "c3"; Str "c6"] n Null)])) in
532
+ check "requests" (urls = ["http://api.test/w?page=1"; "http://api.test/w?cursor=c3";
533
+ "http://api.test/w?cursor=c6"]);
534
+ check "hasMore" (getp pg "hasMore" = Bool false));
535
+ test "paging.body_next_url_is_the_next_request" (fun () ->
536
+ let (urls, pg) = walk (fun n -> make_response 200 (jo [("next", nth_or
537
+ [Str "http://api.test/v2/w?cursor=c%2F3&limit=3"; Str "/v2/w?cursor=c6"] n Null)])) in
538
+ check "requests" (urls = ["http://api.test/w?page=1"; "http://api.test/v2/w?cursor=c%2F3&limit=3";
539
+ "http://api.test/v2/w?cursor=c6"]);
540
+ check "hasMore" (getp pg "hasMore" = Bool false));
541
+ test "paging.link_next_url_is_the_next_request" (fun () ->
542
+ let links = ["<http://api.test/w?after=b3>; rel=\"next\""; "</w?after=b6>; rel=\"next\""] in
543
+ let (urls, pg) = walk (fun n ->
544
+ let headers = if n <= List.length links then [("link", Str (List.nth links (n - 1)))] else [] in
545
+ make_response ~headers 200 (ja [])) in
546
+ check "requests" (urls = ["http://api.test/w?page=1"; "http://api.test/w?after=b3";
547
+ "http://api.test/w?after=b6"]);
548
+ check "hasMore" (getp pg "hasMore" = Bool false));
549
+ test "paging.query_only_link_keeps_the_path" (fun () ->
550
+ let links = ["</v1/items?page=2>; rel=\"next\""; "<?page=3>; rel=\"next\""] in
551
+ let (urls, _) = walk (fun n ->
552
+ let headers = if n <= List.length links then [("link", Str (List.nth links (n - 1)))] else [] in
553
+ make_response ~headers 200 (ja [])) in
554
+ check "requests" (urls = ["http://api.test/w?page=1"; "http://api.test/v1/items?page=2";
555
+ "http://api.test/v1/items?page=3"]));
556
+ test "paging.path_relative_link_resolves_against_the_request" (fun () ->
557
+ let links = ["</v1/items?page=2>; rel=\"next\""; "<more?page=3>; rel=\"next\""] in
558
+ let (urls, _) = walk (fun n ->
559
+ let headers = if n <= List.length links then [("link", Str (List.nth links (n - 1)))] else [] in
560
+ make_response ~headers 200 (ja [])) in
561
+ check "requests" (urls = ["http://api.test/w?page=1"; "http://api.test/v1/items?page=2";
562
+ "http://api.test/v1/more?page=3"]));
563
+ test "paging.foreign_link_ends_the_walk" (fun () ->
564
+ let (urls, pg) = walk (fun _ ->
565
+ make_response ~headers:[("link", Str "<https://elsewhere.test/w?after=b3>; rel=\"next\"")] 200 (ja [])) in
566
+ check "requests" (urls = ["http://api.test/w?page=1"]);
567
+ check "hasMore" (getp pg "hasMore" = Bool false);
568
+ check_vstr "foreign" (getp pg "foreign") "https://elsewhere.test/w?after=b3");
569
+ test "paging.cursor_mode_sends_a_slash_cursor" (fun () ->
570
+ let (urls, pg) = walk ~options:(jo [("next", Str "cursor")])
571
+ (fun n -> make_response 200 (jo [("next", nth_or [Str "/c3"] n Null)])) in
572
+ check "requests" (urls = ["http://api.test/w?page=1"; "http://api.test/w?cursor=%2Fc3"]);
573
+ check "hasMore" (getp pg "hasMore" = Bool false));
483
574
  test "paging.non_list_not_paged" (fun () ->
484
575
  let (srv, calls) = recording_server () in
485
576
  let h = make_client ~server:srv [("paging", empty_map ())] in
@@ -513,6 +604,20 @@ let () =
513
604
  check "3 batches" (List.length batches = 3);
514
605
  check "b0" (veq (List.nth batches 0) (ja [Num 1.; Num 2.]));
515
606
  check "b2" (veq (List.nth batches 2) (ja [Num 5.])));
607
+ test "streaming.failed_result_not_streamed" (fun () ->
608
+ let (srv, _) = recording_server ~reply:(fun _ _ -> (make_response 503 (ja []), None)) () in
609
+ let h = make_client ~server:srv [("streaming", empty_map ())] in
610
+ let r = op h ~op:"list" ~path:"/w" () in
611
+ check "no stream" (match r.or_result with
612
+ | Some x -> not x.rt_streaming && x.rt_stream = None
613
+ | None -> true));
614
+ test "streaming.empty_list_streams_nothing" (fun () ->
615
+ let (srv, _) = recording_server ~reply:(fun _ _ -> (make_response 200 (ja []), None)) () in
616
+ let h = make_client ~server:srv [("streaming", empty_map ())] in
617
+ let r = op h ~op:"list" ~path:"/w" () in
618
+ check "empty" (match r.or_result with
619
+ | Some { rt_stream = Some f; _ } -> f () = []
620
+ | _ -> false));
516
621
  test "streaming.non_list_not_streamed" (fun () ->
517
622
  let h = make_client [("streaming", empty_map ())] in
518
623
  let r = op h ~op:"load" () in
@@ -65,6 +65,9 @@ sub new {
65
65
  my $o = $gcp->($ctxmap, 'options');
66
66
  $self->{options} = Voxgig::Struct::ismap($o) ? $o : ($basectx ? $basectx->{options} : undef);
67
67
 
68
+ # The clean registry, beside the options rather than in them.
69
+ $self->{cleancfg} = $gcp->($ctxmap, 'cleancfg') // ($basectx ? $basectx->{cleancfg} : undef);
70
+
68
71
  my $e = $gcp->($ctxmap, 'entity');
69
72
  $self->{entity} = defined $e ? $e : ($basectx ? $basectx->{entity} : undef);
70
73
 
@@ -14,7 +14,6 @@ use warnings;
14
14
 
15
15
  use File::Basename ();
16
16
  use Cwd ();
17
- use Scalar::Util ();
18
17
 
19
18
  my $__dir;
20
19
  BEGIN { $__dir = File::Basename::dirname(Cwd::abs_path(__FILE__)) }
@@ -36,7 +35,6 @@ sub new {
36
35
  $self->{client} = undef;
37
36
  $self->{options} = {};
38
37
  $self->{seq} = 0;
39
- $self->{seen} = {};
40
38
  return $self;
41
39
  }
42
40
 
@@ -46,7 +44,6 @@ sub init {
46
44
  $self->{options} = Voxgig::Struct::ismap($options) ? $options : {};
47
45
  $self->{active} = ProjectNameHelpers::is_true($self->{options}{active});
48
46
  $self->{seq} = 0;
49
- $self->{seen} = {};
50
47
 
51
48
  return unless $self->{active};
52
49
 
@@ -76,10 +73,10 @@ sub PreUnexpected {
76
73
  sub _emit {
77
74
  my ($self, $ctx, $outcome) = @_;
78
75
  # One record per operation (PreDone + a following PreUnexpected on a
79
- # non-2xx must not double-log).
80
- my $addr = Scalar::Util::refaddr($ctx);
81
- return if exists $self->{seen}{$addr};
82
- $self->{seen}{$addr} = 1;
76
+ # non-2xx must not double-log). The marker lives on the context: a table
77
+ # keyed by refaddr grows per call, and a reused address skips a call.
78
+ return if $ctx->{out}{audit_seen};
79
+ $ctx->{out}{audit_seen} = 1;
83
80
  $self->{seq} += 1;
84
81
 
85
82
  my $record = $ctx->{utility}{clean}->($ctx, {
@@ -1,12 +1,7 @@
1
1
  # ProjectName SDK cache feature
2
2
  #
3
- # Response caching for safe (read) requests. Wraps the active transport and
4
- # serves a fresh cached snapshot instead of hitting the network when the
5
- # same method+URL was fetched within "ttl" ms (default 5000). Only
6
- # successful (2xx) responses to cacheable methods (default: GET) are
7
- # stored, keyed by method+URL. The cache is bounded ("max" entries, default
8
- # 256, oldest evicted first) and every hit/miss/bypass is counted for
9
- # inspection. Replayed responses expose a re-readable "json" body.
3
+ # Response caching for safe (read) requests, per client: see the features
4
+ # reference for the key, the write invalidation and the Cache-Control rules.
10
5
 
11
6
  use strict;
12
7
  use warnings;
@@ -14,6 +9,7 @@ use warnings;
14
9
  use File::Basename ();
15
10
  use Cwd ();
16
11
  use Scalar::Util ();
12
+ use Digest::SHA ();
17
13
 
18
14
  my $__dir;
19
15
  BEGIN { $__dir = File::Basename::dirname(Cwd::abs_path(__FILE__)) }
@@ -52,6 +48,7 @@ sub init {
52
48
 
53
49
  $self->{store} = {};
54
50
  $self->{order} = [];
51
+ $self->{secret} = _cache_secret();
55
52
 
56
53
  my $feature = $self;
57
54
  my $utility = $ctx->{utility};
@@ -70,10 +67,18 @@ sub through {
70
67
  ? uc("$fetchdef->{method}") : 'GET';
71
68
  my $methods = $self->{options}{methods} || ['GET'];
72
69
 
73
- return $inner->($ctx, $url, $fetchdef)
74
- unless grep { uc("$_") eq $method } @$methods;
70
+ unless (grep { uc("$_") eq $method } @$methods) {
71
+ return $inner->($ctx, $url, $fetchdef) if $method eq 'GET' || $method eq 'HEAD';
72
+ my @out;
73
+ my $done = eval { @out = $inner->($ctx, $url, $fetchdef); 1 };
74
+ my $failure = $@;
75
+ $self->_invalidate($url);
76
+ die $failure unless $done;
77
+ return @out;
78
+ }
75
79
 
76
- my $key = "$method $url";
80
+ my $headers = Voxgig::Struct::ismap($fetchdef) ? $fetchdef->{headers} : undef;
81
+ my $key = "$method $url " . $self->_digest($headers);
77
82
  my $now = $self->_now;
78
83
  my $hit = $self->{store}{$key};
79
84
 
@@ -92,12 +97,17 @@ sub through {
92
97
 
93
98
  if (!defined $err && $self->_cacheable($res)) {
94
99
  my $snapshot = $self->_snapshot($res);
95
- my $ttl = defined $self->{options}{ttl} ? $self->{options}{ttl} : 5000;
96
- $self->_evict;
97
- if (!exists $self->{store}{$key}) {
98
- push @{ $self->{order} }, $key;
100
+ my $ttl = _cache_lifetime($snapshot->{headers},
101
+ defined $self->{options}{ttl} ? $self->{options}{ttl} : 5000);
102
+ if ($ttl <= 0) {
103
+ $self->_track('bypass');
104
+ return ($self->_replay($snapshot), undef);
99
105
  }
100
- $self->{store}{$key} = { 'expiry' => $now + $ttl, 'snapshot' => $snapshot };
106
+ $self->_drop($key);
107
+ $self->_evict;
108
+ push @{ $self->{order} }, $key;
109
+ $self->{store}{$key} = {
110
+ 'expiry' => $now + $ttl, 'scope' => _cache_scope($url), 'snapshot' => $snapshot };
101
111
  $self->_track('miss');
102
112
  return ($self->_replay($snapshot), undef);
103
113
  }
@@ -106,6 +116,92 @@ sub through {
106
116
  return ($res, $err);
107
117
  }
108
118
 
119
+ sub _digest {
120
+ my ($self, $headers) = @_;
121
+ my @pairs;
122
+ if (Voxgig::Struct::ismap($headers)) {
123
+ for my $name (keys %$headers) {
124
+ next unless defined $headers->{$name};
125
+ push @pairs, [lc($name), "$headers->{$name}"];
126
+ }
127
+ }
128
+ my $text = join('', map { "$_->[0]:$_->[1]\n" }
129
+ sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] } @pairs);
130
+ return Digest::SHA::hmac_sha256_hex($text, $self->{secret});
131
+ }
132
+
133
+ sub _invalidate {
134
+ my ($self, $url) = @_;
135
+ my $path = _cache_scope($url);
136
+ my $collection = _cache_parent($path);
137
+ for my $key (keys %{ $self->{store} }) {
138
+ my $scope = $self->{store}{$key}{scope};
139
+ $self->_drop($key) if _cache_under($scope, $path) || $scope eq $collection;
140
+ }
141
+ return;
142
+ }
143
+
144
+ sub _drop {
145
+ my ($self, $key) = @_;
146
+ return unless exists $self->{store}{$key};
147
+ delete $self->{store}{$key};
148
+ $self->{order} = [grep { $_ ne $key } @{ $self->{order} }];
149
+ return;
150
+ }
151
+
152
+ # The system's random source where it has one; otherwise Perl's own rand,
153
+ # which is not a cryptographic generator.
154
+ sub _cache_secret {
155
+ my $bytes = '';
156
+ if (open(my $fh, '<:raw', '/dev/urandom')) {
157
+ read($fh, $bytes, 32);
158
+ close($fh);
159
+ }
160
+ $bytes .= pack('N', int(rand(4294967296))) while length($bytes) < 32;
161
+ return $bytes;
162
+ }
163
+
164
+ # The configured ttl capped by the response's Cache-Control; zero when the
165
+ # response may not be stored.
166
+ sub _cache_lifetime {
167
+ my ($headers, $ttl) = @_;
168
+ my $control = '';
169
+ for my $name (keys %{ $headers || {} }) {
170
+ $control = lc("$headers->{$name}") if lc($name) eq 'cache-control';
171
+ }
172
+ my $life = $ttl;
173
+ for my $part (split /,/, $control) {
174
+ (my $directive = $part) =~ s/^\s+|\s+$//g;
175
+ return 0 if grep { $_ eq $directive } ('no-store', 'private', 'no-cache');
176
+ if ($directive =~ /^max-age\s*=\s*"?(\d+)"?$/) {
177
+ $life = $1 * 1000 if $1 * 1000 < $life;
178
+ }
179
+ }
180
+ return $life;
181
+ }
182
+
183
+ sub _cache_scope {
184
+ my ($url) = @_;
185
+ my ($scope) = split /[?#]/, "$url", 2;
186
+ $scope = '' unless defined $scope;
187
+ $scope =~ s{/+$}{};
188
+ return $scope;
189
+ }
190
+
191
+ sub _cache_parent {
192
+ my ($scope) = @_;
193
+ my $scheme = index($scope, '://');
194
+ my $root = $scheme < 0 ? 0 : index($scope, '/', $scheme + 3);
195
+ return $scope if $root < 0;
196
+ my $cut = rindex($scope, '/');
197
+ return substr($scope, 0, $cut < $root ? $root : $cut);
198
+ }
199
+
200
+ sub _cache_under {
201
+ my ($scope, $prefix) = @_;
202
+ return $scope eq $prefix || index($scope, "$prefix/") == 0;
203
+ }
204
+
109
205
  sub _cacheable {
110
206
  my ($self, $res) = @_;
111
207
  return 0 unless Voxgig::Struct::ismap($res);
@@ -5,7 +5,7 @@
5
5
  # timing. The SDK's own clean rules (clean.keys and every registered secret
6
6
  # value) apply to the whole entry, and the "redact" option ADDS header names
7
7
  # on top of them. An optional
8
- # "on_entry" callback receives each finished entry (e.g. to stream to a
8
+ # "onEntry" callback receives each finished entry (e.g. to stream to a
9
9
  # console). "max" caps the buffer (default 100). The clock is injectable
10
10
  # ("now", ms) for deterministic tests.
11
11
 
@@ -141,7 +141,7 @@ sub _finish {
141
141
  my $max = defined $self->{options}{max} ? $self->{options}{max} : 100;
142
142
  shift @$buf while @$buf > $max;
143
143
 
144
- my $on_entry = $self->{options}{on_entry};
144
+ my $on_entry = $self->{options}{onEntry};
145
145
  if (ref $on_entry eq 'CODE') {
146
146
  eval { $on_entry->($entry) };
147
147
  }
@@ -102,6 +102,11 @@ sub _record {
102
102
 
103
103
  $self->_bump($m->{total}, $ok, $dur);
104
104
  $self->_bump($op, $ok, $dur);
105
+
106
+ my $sink = $self->{options}{sink};
107
+ if (ref $sink eq 'CODE') {
108
+ eval { $sink->($ctx->{utility}{clean}->($ctx, $m)) };
109
+ }
105
110
  return;
106
111
  }
107
112