@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
@@ -12,6 +12,7 @@
12
12
 
13
13
  #include <cstdio>
14
14
  #include <map>
15
+ #include <random>
15
16
  #include <string>
16
17
 
17
18
  #include "../core/types.hpp"
@@ -24,7 +25,6 @@ class TelemetryFeature : public BaseFeature {
24
25
  public:
25
26
  SdkClient* client = nullptr;
26
27
  Value options = Value::undef();
27
- int seq = 0;
28
28
 
29
29
  // Activity tracking (mirrors the ts client._telemetry record).
30
30
  Value spans = vlist();
@@ -36,7 +36,6 @@ public:
36
36
  client = ctx->client;
37
37
  options = options_;
38
38
  active = fopt::foptBool(options, "active", false);
39
- seq = 0;
40
39
  }
41
40
 
42
41
  void prePoint(CtxPtr ctx) override {
@@ -126,14 +125,22 @@ private:
126
125
  Value r = idgen.as_injector()(inj, vlist({Value(kind)}), std::string(""), Value::undef());
127
126
  return r.is_string() ? r.as_string() : Struct::stringify(r);
128
127
  }
129
- // Deterministic-ish sequential id; unique within a client instance.
130
- seq++;
131
- char buf[16];
132
- std::snprintf(buf, sizeof(buf), "%04x", seq);
133
- std::string n(buf);
134
- std::string prefix = (kind == "trace") ? "t" : "s";
135
- while (n.size() < 16) n.push_back('0');
136
- return prefix + n;
128
+ return randomHex(kind == "trace" ? 16 : 8);
129
+ }
130
+
131
+ // W3C trace context: lowercase hex from the platform's random source, never all zeros.
132
+ static std::string randomHex(size_t bytes) {
133
+ static std::random_device rd;
134
+ std::string out;
135
+ while (out.empty() || out.find_first_not_of('0') == std::string::npos) {
136
+ out.clear();
137
+ for (size_t i = 0; i < bytes; i++) {
138
+ char buf[3];
139
+ std::snprintf(buf, sizeof(buf), "%02x", (unsigned) (rd() & 0xff));
140
+ out += buf;
141
+ }
142
+ }
143
+ return out;
137
144
  }
138
145
  };
139
146
 
@@ -6,6 +6,7 @@
6
6
  #ifndef SDK_FEATURE_TEST_HPP
7
7
  #define SDK_FEATURE_TEST_HPP
8
8
 
9
+ #include <algorithm>
9
10
  #include <string>
10
11
  #include <vector>
11
12
 
@@ -147,20 +148,10 @@ private:
147
148
  return out;
148
149
  }
149
150
 
150
- Value resolveMatch(CtxPtr ctx, const Value& explicitMatch) {
151
- if (explicitMatch.is_map() && !explicitMatch.as_map()->empty()) {
152
- return explicitMatch;
153
- }
154
- for (const Value& src : {ctx->match, ctx->data}) {
155
- if (!src.is_map()) continue;
156
- Value v = getp(src, "id", Value(nullptr));
157
- if (!v.is_null() && !(v.is_string() && v.as_string() == "__UNDEFINED__")) {
158
- Value out = vmap();
159
- map_put(out, "id", v);
160
- return out;
161
- }
162
- }
163
- return vmap();
151
+ static bool held(const Value& src, const std::string& key) {
152
+ if (!src.is_map()) return false;
153
+ Value v = getp(src, key, Value(nullptr));
154
+ return !is_nullish(v) && !(v.is_string() && v.as_string() == "__UNDEFINED__");
164
155
  }
165
156
 
166
157
  Value serve(CtxPtr ctx, const Value& entity) {
@@ -169,7 +160,7 @@ private:
169
160
  if (!entmap.is_map()) entmap = vmap();
170
161
 
171
162
  if (op->name == "load") {
172
- Value args = buildArgs(ctx, op, resolveMatch(ctx, ctx->reqmatch));
163
+ Value args = buildArgs(ctx, op, ctx->reqmatch);
173
164
  std::vector<Value> found = Struct::select(entmap, args);
174
165
  Value ent = found.empty() ? Value::undef() : found[0];
175
166
  if (is_nullish(ent)) return respond(ctx, 404, Value(nullptr), extra1("statusText", Value("Not found")));
@@ -187,40 +178,22 @@ private:
187
178
  Value out = Struct::clone(outlist);
188
179
  return respond(ctx, 200, out, Value::undef());
189
180
  } else if (op->name == "update" || op->name == "patch") {
190
- Value updateMatch = vmap();
191
- if (ctx->reqdata.is_map()) {
192
- if (map_contains(ctx->reqdata, "id")) {
193
- map_put(updateMatch, "id", getp(ctx->reqdata, "id"));
194
- }
195
- if (op->alias.is_map()) {
196
- Value aliasIdRaw = getp(op->alias, "id");
197
- if (aliasIdRaw.is_string()) {
198
- std::string aliasId = aliasIdRaw.as_string();
199
- if (map_contains(ctx->reqdata, aliasId)) {
200
- map_put(updateMatch, aliasId, getp(ctx->reqdata, aliasId));
201
- }
202
- }
203
- }
204
- }
205
- if (!updateMatch.is_map() || updateMatch.as_map()->empty()) {
206
- updateMatch = resolveMatch(ctx, vmap());
207
- }
208
- Value args = buildArgs(ctx, op, updateMatch);
181
+ // `$body` travels on the wire alone; the record is the rest.
182
+ Value rec = ctx->reqdata.is_map() ? Struct::clone(ctx->reqdata) : vmap();
183
+ Struct::delprop(rec, Value("$body"));
184
+ Value args = buildArgs(ctx, op, rec);
209
185
  std::vector<Value> found = Struct::select(entmap, args);
210
186
  Value ent = found.empty() ? Value::undef() : found[0];
211
187
  // update miss: 404, never another record
212
188
  if (is_nullish(ent)) return respond(ctx, 404, Value(nullptr), extra1("statusText", Value("Not found")));
213
189
  if (ent.is_map() && ctx->reqdata.is_map()) {
214
- // `$body` travels on the wire alone; the record is the rest.
215
- Value rec = Struct::clone(ctx->reqdata);
216
- Struct::delprop(rec, Value("$body"));
217
190
  Struct::merge(vlist({ent, rec}));
218
191
  }
219
192
  Struct::delprop(ent, Value("$KEY"));
220
193
  Value out = Struct::clone(ent);
221
194
  return respond(ctx, 200, out, Value::undef());
222
195
  } else if (op->name == "remove") {
223
- Value args = buildArgs(ctx, op, resolveMatch(ctx, ctx->reqmatch));
196
+ Value args = buildArgs(ctx, op, ctx->reqmatch);
224
197
  std::vector<Value> found = Struct::select(entmap, args);
225
198
  Value ent = found.empty() ? Value::undef() : found[0];
226
199
  if (ent.is_map()) {
@@ -361,24 +334,61 @@ private:
361
334
  Value qand = vlist();
362
335
  Value q = vmap({{"`$AND`", qand}});
363
336
 
337
+ std::string entityName = ctx->entity == nullptr ? std::string("") : ctx->entity->getName();
338
+ Value idfrom = Struct::getpath(ctx->config, {"entity", entityName, "id", "from"});
339
+
340
+ std::vector<std::string> names;
364
341
  if (args.is_map()) {
365
- for (const auto& key : Struct::keysof(args)) {
366
- bool isId = (key == "id");
367
- std::vector<Value> selected = Struct::select(reqd, Value(key));
368
- Value selv = vlist();
369
- for (auto& s : selected) selv.as_list()->push_back(s);
370
- bool isReqd = !Struct::isempty(selv);
371
-
372
- if (isId || isReqd) {
373
- Value v = ctx->utility->param(ctx, Value(key));
374
- Value ka = getp(op->alias, key);
375
-
376
- Value qor = vlist({vmap({{key, v}})});
377
- if (ka.is_string()) {
378
- qor.as_list()->push_back(vmap({{ka.as_string(), v}}));
342
+ for (const auto& key : Struct::keysof(args)) names.push_back(key);
343
+ }
344
+
345
+ // With no id in the call, the entity's held id (or composite parts) stands in.
346
+ if (!held(args, "id")) {
347
+ Value parts = Struct::getpath(ctx->config, {"entity", entityName, "id", "parts"});
348
+ if (!parts.is_list()) parts = opname == "list" ? vlist() : vlist({Value("id")});
349
+ for (const auto& part : *parts.as_list()) {
350
+ if (!part.is_string()) continue;
351
+ std::string pname = part.as_string();
352
+ if (std::find(names.begin(), names.end(), pname) == names.end() &&
353
+ (held(ctx->match, pname) || held(ctx->data, pname))) {
354
+ names.push_back(pname);
355
+ }
356
+ }
357
+ }
358
+
359
+ for (const auto& key : names) {
360
+ bool isId = (key == "id");
361
+ std::vector<Value> selected = Struct::select(reqd, Value(key));
362
+ Value selv = vlist();
363
+ for (auto& s : selected) selv.as_list()->push_back(s);
364
+ bool isReqd = !Struct::isempty(selv);
365
+
366
+ if (isId || isReqd) {
367
+ Value v = ctx->utility->param(ctx, Value(key));
368
+ Value ka = getp(op->alias, key);
369
+
370
+ Value qor = vlist({vmap({{key, v}})});
371
+ if (ka.is_string()) {
372
+ qor.as_list()->push_back(vmap({{ka.as_string(), v}}));
373
+ }
374
+
375
+ // An alternative, never a replacement: a seed keeping the parameter
376
+ // flat is still found.
377
+ Value kf = getp(idfrom, key);
378
+ if (kf.is_string() && kf.as_string() != key) {
379
+ Value nest = v;
380
+ std::string path = kf.as_string();
381
+ size_t end = path.size();
382
+ while (true) {
383
+ size_t dot = path.rfind('.', end == 0 ? 0 : end - 1);
384
+ size_t start = (dot == std::string::npos || dot >= end) ? 0 : dot + 1;
385
+ nest = vmap({{path.substr(start, end - start), nest}});
386
+ if (start == 0) break;
387
+ end = start - 1;
379
388
  }
380
- qand.as_list()->push_back(vmap({{"`$OR`", qor}}));
389
+ qor.as_list()->push_back(nest);
381
390
  }
391
+ qand.as_list()->push_back(vmap({{"`$OR`", qor}}));
382
392
  }
383
393
  }
384
394
 
@@ -430,6 +430,79 @@ static void cache_inactiveDoesNotWrap() {
430
430
  ASSERT_EQ((int)rec->calls.size(), 2, "expected 2 calls");
431
431
  }
432
432
 
433
+ // The reference vectors of the SipHash paper: key 00..0f, message 00..len-1.
434
+ static void cache_siphashMatchesTheReferenceVectors() {
435
+ if (!have({"cache"})) return;
436
+ const std::vector<std::pair<size_t, uint64_t>> vectors = {{0, 0x726fdb47dd0e0e31ULL}, {1, 0x74f839c593dc67fdULL}, {2, 0x0d6c8009d9a94f5aULL}, {3, 0x85676696d7fb7e2dULL}, {4, 0xcf2794e0277187b7ULL}, {5, 0x18765564cd99a68dULL}, {6, 0xcbc9466e58fee3ceULL}, {7, 0xab0200f58b01d137ULL}, {8, 0x93f5f5799a932462ULL}, {15, 0xa129ca6149be45e5ULL}, {16, 0x3f2acc7f57c29bdbULL}, {63, 0x958a324ceb064572ULL}};
437
+ uint8_t key[16];
438
+ for (int i = 0; i < 16; i++) key[i] = static_cast<uint8_t>(i);
439
+ std::string msg;
440
+ for (int i = 0; i < 64; i++) msg.push_back(static_cast<char>(i));
441
+ for (const auto& v : vectors) {
442
+ ASSERT_TRUE(CacheFeature::siphash24(key, msg.substr(0, v.first)) == v.second,
443
+ "siphash reference vector " + std::to_string(v.first));
444
+ }
445
+ }
446
+
447
+ static void cache_keysOnRequestHeaders() {
448
+ if (!have({"cache"})) return;
449
+ auto rec = std::make_shared<FhRecorder>();
450
+ FetcherFn server = [rec](CtxPtr c, const std::string& u, const Value& fd) { return rec->fetch(c, u, fd); };
451
+ auto h = fhMake(server, {FF(std::make_shared<CacheFeature>(), fhMap({{"ttl", Value(10000)}}))});
452
+ h->op(fhOp("load").setPath("/w/1").setHeaders(fhMap({{"x-tenant", Value("tenant-a")}})));
453
+ h->op(fhOp("load").setPath("/w/1").setHeaders(fhMap({{"X-Tenant", Value("tenant-b")}})));
454
+ ASSERT_EQ((int)rec->calls.size(), 2, "a second tenant was served the first tenant's entry");
455
+ h->op(fhOp("load").setPath("/w/1").setHeaders(fhMap({{"x-tenant", Value("tenant-b")}})));
456
+ ASSERT_EQ((int)rec->calls.size(), 2, "the same headers did not share an entry");
457
+ }
458
+
459
+ static void cache_aWriteDropsItsCollection() {
460
+ if (!have({"cache"})) return;
461
+ auto rec = std::make_shared<FhRecorder>();
462
+ FetcherFn server = [rec](CtxPtr c, const std::string& u, const Value& fd) { return rec->fetch(c, u, fd); };
463
+ auto f = std::make_shared<CacheFeature>();
464
+ auto h = fhMake(server, {FF(f, fhMap({{"ttl", Value(10000)}}))});
465
+ const char* paths[] = {"/w/1", "/w", "/w/1/part", "/other/1", "/w/2"};
466
+ for (const char* p : paths) h->op(fhOp("load").setPath(p));
467
+ h->op(fhOp("update").setMethod("PUT").setPath("/w/1"));
468
+ for (const char* p : paths) h->op(fhOp("load").setPath(p));
469
+ ASSERT_EQ((int)rec->calls.size(), 9, "expected the collection refetched and /other cached");
470
+ ASSERT_EQ(f->hit, 2, "expected /other served from cache");
471
+ }
472
+
473
+ static void cache_cacheControlPreventsStoring() {
474
+ if (!have({"cache"})) return;
475
+ for (std::string control : {"no-store", "private", "No-Cache", "max-age=60, private"}) {
476
+ auto rec = std::make_shared<FhRecorder>();
477
+ rec->reply = [control](int, const Value&) {
478
+ return fhResponse(200, fhMap({{"ok", Value(true)}}), fhMap({{"Cache-Control", Value(control)}}));
479
+ };
480
+ FetcherFn server = [rec](CtxPtr c, const std::string& u, const Value& fd) { return rec->fetch(c, u, fd); };
481
+ auto h = fhMake(server, {FF(std::make_shared<CacheFeature>(), fhMap({{"ttl", Value(10000)}}))});
482
+ h->op(fhOp("load").setPath("/w"));
483
+ h->op(fhOp("load").setPath("/w"));
484
+ ASSERT_EQ((int)rec->calls.size(), 2, control + " was stored");
485
+ }
486
+ }
487
+
488
+ static void cache_maxAgeCapsTheTtl() {
489
+ if (!have({"cache"})) return;
490
+ FhClock clock;
491
+ auto rec = std::make_shared<FhRecorder>();
492
+ rec->reply = [](int, const Value&) {
493
+ return fhResponse(200, fhMap({{"ok", Value(true)}}), fhMap({{"cache-control", Value("max-age=1")}}));
494
+ };
495
+ FetcherFn server = [rec](CtxPtr c, const std::string& u, const Value& fd) { return rec->fetch(c, u, fd); };
496
+ auto h = fhMake(server, {FF(std::make_shared<CacheFeature>(), fhMap({{"ttl", Value(10000)}, {"now", clock.nowFn()}}))});
497
+ h->op(fhOp("load").setPath("/w"));
498
+ clock.advance(500);
499
+ h->op(fhOp("load").setPath("/w"));
500
+ ASSERT_EQ((int)rec->calls.size(), 1, "expected a hit inside max-age");
501
+ clock.advance(600);
502
+ h->op(fhOp("load").setPath("/w"));
503
+ ASSERT_EQ((int)rec->calls.size(), 2, "expected max-age=1 to expire the entry before the ttl");
504
+ }
505
+
433
506
  // ============================ idempotency ==============================
434
507
 
435
508
  static void idempotency_addsKeyToMutatingOps() {
@@ -700,6 +773,26 @@ static void audit_inactiveRecordsNothing() {
700
773
  ASSERT_EQ((int)f->records.as_list()->size(), 0, "expected no records");
701
774
  }
702
775
 
776
+ static void audit_perCallMarkerEndsWithTheCall() {
777
+ if (!have({"audit", "netsim"})) return;
778
+ auto f = std::make_shared<AuditFeature>();
779
+ auto h = fhMake(nullptr, {
780
+ FF(std::make_shared<NetsimFeature>(), fhMap({{"failEvery", Value(2)}, {"failStatus", Value(500)}})),
781
+ FF(f, Value::undef())});
782
+ std::vector<std::weak_ptr<Context>> held;
783
+ for (int i = 0; i < 20; i++) {
784
+ auto res = h->op(fhOp("load").setPath("/w/" + std::to_string(i)));
785
+ ASSERT_TRUE(nullptr != res.ctx, "expected the call's context");
786
+ if (nullptr == res.ctx) return;
787
+ ASSERT_TRUE(res.ctx->out.extra.count("audit_seen") == 1, "expected the marker on the call's context");
788
+ held.push_back(res.ctx);
789
+ }
790
+ ASSERT_EQ((int)f->records.as_list()->size(), 20, "expected one record per call");
791
+ int alive = 0;
792
+ for (auto& w : held) if (!w.expired()) alive++;
793
+ ASSERT_EQ(alive, 0, "expected no context kept alive past its call");
794
+ }
795
+
703
796
  // ============================ one call, one id =========================
704
797
 
705
798
  static void telemetryDebugAudit_carryOneCallsContextId() {
@@ -806,6 +899,109 @@ static void paging_bodyCursorAndExplicitCursor() {
806
899
  ASSERT_EQ_VAL(getp(res.result->paging, "hasMore"), Value(true), "expected hasMore");
807
900
  }
808
901
 
902
+ // The documented hasMore loop, one request per page.
903
+ static std::vector<std::string> pagingWalk(std::function<Value(int)> reply, Value& paging,
904
+ Value options = Value::undef()) {
905
+ auto rec = std::make_shared<FhRecorder>();
906
+ rec->reply = [reply](int n, const Value&) { return reply(n); };
907
+ FetcherFn server = [rec](CtxPtr c, const std::string& u, const Value& fd) { return rec->fetch(c, u, fd); };
908
+ auto h = fhMake(server, {FF(std::make_shared<PagingFeature>(), options)});
909
+ paging = vmap();
910
+ Value ctrl = fhMap({{"paging", paging}});
911
+ h->op(fhOp("list").setPath("/w").setCtrl(ctrl));
912
+ while (getp(paging, "hasMore").is_bool() && getp(paging, "hasMore").as_bool() && rec->calls.size() < 4) {
913
+ h->op(fhOp("list").setPath("/w").setCtrl(ctrl));
914
+ }
915
+ std::vector<std::string> urls;
916
+ for (size_t i = 0; i < rec->calls.size(); i++) urls.push_back(rec->url((int)i));
917
+ return urls;
918
+ }
919
+
920
+ static void checkWalk(const std::vector<std::string>& urls, const Value& paging,
921
+ const std::vector<std::string>& want, const char* where) {
922
+ sdktest::expect_true(urls == want, where, "requests sent: " + (urls.empty() ? std::string() : urls.back()));
923
+ sdktest::expect_eq_val(getp(paging, "hasMore"), Value(false), where, "expected hasMore false");
924
+ std::printf("ran %s\n", where);
925
+ }
926
+
927
+ static void paging_bodyNextIsSentAsTheCursor() {
928
+ if (!have({"paging"})) return;
929
+ Value paging;
930
+ auto urls = pagingWalk([](int n) {
931
+ Value next = n == 1 ? Value("c3") : n == 2 ? Value("c6") : Value(nullptr);
932
+ return fhResponse(200, fhMap({{"next", next}}), Value::undef());
933
+ }, paging);
934
+ checkWalk(urls, paging, {"http://api.test/w?page=1", "http://api.test/w?cursor=c3",
935
+ "http://api.test/w?cursor=c6"}, __func__);
936
+ }
937
+
938
+ static void paging_bodyNextUrlIsTheNextRequest() {
939
+ if (!have({"paging"})) return;
940
+ Value paging;
941
+ auto urls = pagingWalk([](int n) {
942
+ Value next = n == 1 ? Value("http://api.test/v2/w?cursor=c%2F3&limit=3")
943
+ : n == 2 ? Value("/v2/w?cursor=c6") : Value(nullptr);
944
+ return fhResponse(200, fhMap({{"next", next}}), Value::undef());
945
+ }, paging);
946
+ checkWalk(urls, paging, {"http://api.test/w?page=1", "http://api.test/v2/w?cursor=c%2F3&limit=3",
947
+ "http://api.test/v2/w?cursor=c6"}, __func__);
948
+ }
949
+
950
+ static void paging_linkNextUrlIsTheNextRequest() {
951
+ if (!have({"paging"})) return;
952
+ Value paging;
953
+ auto urls = pagingWalk([](int n) {
954
+ Value headers = n == 1 ? fhMap({{"link", Value("<http://api.test/w?after=b3>; rel=\"next\"")}})
955
+ : n == 2 ? fhMap({{"link", Value("</w?after=b6>; rel=\"next\"")}}) : Value::undef();
956
+ return fhResponse(200, vlist(), headers);
957
+ }, paging);
958
+ checkWalk(urls, paging, {"http://api.test/w?page=1", "http://api.test/w?after=b3",
959
+ "http://api.test/w?after=b6"}, __func__);
960
+ }
961
+
962
+ static void paging_queryOnlyLinkKeepsThePath() {
963
+ if (!have({"paging"})) return;
964
+ Value paging;
965
+ auto urls = pagingWalk([](int n) {
966
+ Value headers = n == 1 ? fhMap({{"link", Value("</v1/items?page=2>; rel=\"next\"")}})
967
+ : n == 2 ? fhMap({{"link", Value("<?page=3>; rel=\"next\"")}}) : Value::undef();
968
+ return fhResponse(200, vlist(), headers);
969
+ }, paging);
970
+ checkWalk(urls, paging, {"http://api.test/w?page=1", "http://api.test/v1/items?page=2",
971
+ "http://api.test/v1/items?page=3"}, __func__);
972
+ }
973
+
974
+ static void paging_pathRelativeLinkResolvesAgainstTheRequest() {
975
+ if (!have({"paging"})) return;
976
+ Value paging;
977
+ auto urls = pagingWalk([](int n) {
978
+ Value headers = n == 1 ? fhMap({{"link", Value("</v1/items?page=2>; rel=\"next\"")}})
979
+ : n == 2 ? fhMap({{"link", Value("<more?page=3>; rel=\"next\"")}}) : Value::undef();
980
+ return fhResponse(200, vlist(), headers);
981
+ }, paging);
982
+ checkWalk(urls, paging, {"http://api.test/w?page=1", "http://api.test/v1/items?page=2",
983
+ "http://api.test/v1/more?page=3"}, __func__);
984
+ }
985
+
986
+ static void paging_foreignLinkEndsTheWalk() {
987
+ if (!have({"paging"})) return;
988
+ Value paging;
989
+ auto urls = pagingWalk([](int) {
990
+ return fhResponse(200, vlist(), fhMap({{"link", Value("<https://elsewhere.test/w?after=b3>; rel=\"next\"")}}));
991
+ }, paging);
992
+ checkWalk(urls, paging, {"http://api.test/w?page=1"}, __func__);
993
+ ASSERT_EQ_VAL(getp(paging, "foreign"), Value("https://elsewhere.test/w?after=b3"), "expected the foreign link");
994
+ }
995
+
996
+ static void paging_cursorModeSendsASlashCursor() {
997
+ if (!have({"paging"})) return;
998
+ Value paging;
999
+ auto urls = pagingWalk([](int n) {
1000
+ return fhResponse(200, fhMap({{"next", n == 1 ? Value("/c3") : Value(nullptr)}}), Value::undef());
1001
+ }, paging, fhMap({{"next", Value("cursor")}}));
1002
+ checkWalk(urls, paging, {"http://api.test/w?page=1", "http://api.test/w?cursor=%2Fc3"}, __func__);
1003
+ }
1004
+
809
1005
  static void paging_nonListNotPaged() {
810
1006
  if (!have({"paging"})) return;
811
1007
  auto rec = std::make_shared<FhRecorder>();
@@ -854,6 +1050,31 @@ static void streaming_batchesWithChunkSize() {
854
1050
  ASSERT_EQ_VAL(batches, expected, "expected chunked batches");
855
1051
  }
856
1052
 
1053
+ static void streaming_failedResultIsNotStreamed() {
1054
+ if (!have({"streaming"})) return;
1055
+ auto rec = std::make_shared<FhRecorder>();
1056
+ rec->reply = [](int, const Value&) { return fhResponse(503, vlist(), Value::undef()); };
1057
+ FetcherFn server = [rec](CtxPtr c, const std::string& u, const Value& fd) { return rec->fetch(c, u, fd); };
1058
+ auto f = std::make_shared<StreamingFeature>();
1059
+ auto h = fhMake(server, {FF(f, Value::undef())});
1060
+ FhOpResult res = h->op(fhOp("list").setPath("/w"));
1061
+ ASSERT_FALSE(res.result->streaming || (bool)res.result->stream, "a failed result must keep no stream");
1062
+ ASSERT_EQ(f->opened, 0, "expected no opened streams");
1063
+ std::printf("ran %s\n", __func__);
1064
+ }
1065
+
1066
+ static void streaming_emptyListStreamsNothing() {
1067
+ if (!have({"streaming"})) return;
1068
+ auto rec = std::make_shared<FhRecorder>();
1069
+ rec->reply = [](int, const Value&) { return fhResponse(200, vlist(), Value::undef()); };
1070
+ FetcherFn server = [rec](CtxPtr c, const std::string& u, const Value& fd) { return rec->fetch(c, u, fd); };
1071
+ auto h = fhMake(server, {FF(std::make_shared<StreamingFeature>(), Value::undef())});
1072
+ FhOpResult res = h->op(fhOp("list").setPath("/w"));
1073
+ ASSERT_TRUE((bool)res.result->stream, "an empty list still streams");
1074
+ if (res.result->stream) ASSERT_TRUE(res.result->stream().empty(), "an empty list streams nothing");
1075
+ std::printf("ran %s\n", __func__);
1076
+ }
1077
+
857
1078
  static void streaming_nonListNotStreamed() {
858
1079
  if (!have({"streaming"})) return;
859
1080
  auto h = fhMake(nullptr, {FF(std::make_shared<StreamingFeature>(), Value::undef())});
@@ -962,6 +1183,11 @@ int main() {
962
1183
  T_RUN(cache_refetchesAfterTtl);
963
1184
  T_RUN(cache_evictsOldestPastMax);
964
1185
  T_RUN(cache_inactiveDoesNotWrap);
1186
+ T_RUN(cache_keysOnRequestHeaders);
1187
+ T_RUN(cache_aWriteDropsItsCollection);
1188
+ T_RUN(cache_cacheControlPreventsStoring);
1189
+ T_RUN(cache_maxAgeCapsTheTtl);
1190
+ T_RUN(cache_siphashMatchesTheReferenceVectors);
965
1191
 
966
1192
  T_RUN(idempotency_addsKeyToMutatingOps);
967
1193
  T_RUN(idempotency_addsKeyByHttpMethod);
@@ -994,6 +1220,7 @@ int main() {
994
1220
  T_RUN(audit_defaultActorAnonymous);
995
1221
  T_RUN(audit_injectedClock);
996
1222
  T_RUN(audit_inactiveRecordsNothing);
1223
+ T_RUN(audit_perCallMarkerEndsWithTheCall);
997
1224
 
998
1225
  T_RUN(telemetryDebugAudit_carryOneCallsContextId);
999
1226
 
@@ -1006,10 +1233,19 @@ int main() {
1006
1233
  T_RUN(paging_bodyCursorAndExplicitCursor);
1007
1234
  T_RUN(paging_nonListNotPaged);
1008
1235
  T_RUN(paging_inactiveStampsNothing);
1236
+ T_RUN(paging_bodyNextIsSentAsTheCursor);
1237
+ T_RUN(paging_bodyNextUrlIsTheNextRequest);
1238
+ T_RUN(paging_linkNextUrlIsTheNextRequest);
1239
+ T_RUN(paging_queryOnlyLinkKeepsThePath);
1240
+ T_RUN(paging_pathRelativeLinkResolvesAgainstTheRequest);
1241
+ T_RUN(paging_foreignLinkEndsTheWalk);
1242
+ T_RUN(paging_cursorModeSendsASlashCursor);
1009
1243
 
1010
1244
  T_RUN(streaming_streamsListItems);
1011
1245
  T_RUN(streaming_batchesWithChunkSize);
1012
1246
  T_RUN(streaming_nonListNotStreamed);
1247
+ T_RUN(streaming_failedResultIsNotStreamed);
1248
+ T_RUN(streaming_emptyListStreamsNothing);
1013
1249
  T_RUN(streaming_inactiveIsNoop);
1014
1250
 
1015
1251
  T_RUN(proxy_routesThroughProxy);
@@ -67,9 +67,10 @@ inline CtxPtr makeContext(const CtxSpec& cs, CtxPtr basectx) {
67
67
  // sensitive KEY name is masked whatever it holds. Inside the pipeline data
68
68
  // stays raw, so a hook can still read the header it must add to.
69
69
  //
70
- // The configuration is the derived clean block makeOptions builds
71
- // (`options.__derived__.clean`): a plain map, so the registry list inside
72
- // it can be replaced after construction - features register later.
70
+ // The configuration is the clean registry makeOptions builds and holds on
71
+ // the context beside the options (`ctx->cleancfg`): a plain map, so the
72
+ // registry list inside it can be replaced after construction - features
73
+ // register later.
73
74
 
74
75
  constexpr int CLEAN_MAXDEPTH = 32;
75
76
 
@@ -159,12 +160,11 @@ inline Value makeCleanConfig(const Value& cleanopts) {
159
160
  return cfg;
160
161
  }
161
162
 
162
- // A context without options (makeError is reached with a bare one) falls
163
+ // A context without a registry (makeError is reached with a bare one) falls
163
164
  // back to the schema defaults, so nothing leaves raw for want of a
164
165
  // constructor.
165
166
  inline Value cleanConfig(CtxPtr ctx) {
166
- Value derived = ctx ? Struct::getpath(ctx->options, {"__derived__", "clean"}) : Value::undef();
167
- if (derived.is_map()) return derived;
167
+ if (ctx && ctx->cleancfg.is_map()) return ctx->cleancfg;
168
168
  return makeCleanConfig(getp(sharedOptspec(), "clean"));
169
169
  }
170
170
 
@@ -2151,6 +2151,33 @@ inline Value makeOptions(CtxPtr ctx) {
2151
2151
  }
2152
2152
  }
2153
2153
 
2154
+ // The model's options for a feature sit beneath the caller's, key by key: a
2155
+ // key the caller sets replaces the default whole, so a list is never merged.
2156
+ {
2157
+ Value cfgfeature = getp(config, "feature");
2158
+ Value given = mapget(opts, "feature");
2159
+ if (cfgfeature.is_map() && (given.is_map() || is_nullish(given))) {
2160
+ Value out = vmap();
2161
+ if (given.is_map()) {
2162
+ for (const auto& g : *given.as_map()) map_put(out, g.first, g.second);
2163
+ }
2164
+ for (const auto& c : *cfgfeature.as_map()) {
2165
+ Value dflt = getp(c.second, "options");
2166
+ Value fopts = mapget(out, c.first);
2167
+ if (!dflt.is_map() || (is_nullish(fopts) && !is_true(getp(dflt, "active"))) ||
2168
+ (!is_nullish(fopts) && !fopts.is_map())) {
2169
+ continue;
2170
+ }
2171
+ Value merged = Struct::clone(dflt);
2172
+ if (fopts.is_map()) {
2173
+ for (const auto& f : *fopts.as_map()) map_put(merged, f.first, f.second);
2174
+ }
2175
+ map_put(out, c.first, merged);
2176
+ }
2177
+ map_put(opts, "feature", out);
2178
+ }
2179
+ }
2180
+
2154
2181
  // A feature option given as null or no value is absent, as the ts reference
2155
2182
  // validates it. This port's validate refuses such a key of an open map
2156
2183
  // under `$ONE` ("Unexpected keys"), so it is dropped first.
@@ -2230,15 +2257,18 @@ inline Value makeOptions(CtxPtr ctx) {
2230
2257
  map_put(opts, "base", Value(resolveServerBase(baseV.as_string(), opts, config, ctx)));
2231
2258
  }
2232
2259
 
2233
- // Resolve the feature add-order: an explicit list order (above) wins;
2234
- // otherwise order the map test-first, then the remaining names sorted, so
2235
- // the outcome is deterministic and `test` is always the base transport.
2236
- if (featureOrder.empty()) {
2260
+ // Resolve the feature add-order: an explicit list order (above) wins, and
2261
+ // the names it leaves out follow it test-first, then sorted, so the outcome
2262
+ // is deterministic and `test` is the base transport of a map.
2263
+ {
2237
2264
  Value featureMap = Helpers::toMapAny(getp(opts, "feature"));
2238
2265
  if (featureMap.is_map()) {
2239
2266
  std::vector<std::string> names;
2240
2267
  for (const auto& item : Struct::items(featureMap)) {
2241
- names.push_back(as_str(pair_key(item)));
2268
+ std::string n = as_str(pair_key(item));
2269
+ if (std::find(featureOrder.begin(), featureOrder.end(), n) == featureOrder.end()) {
2270
+ names.push_back(n);
2271
+ }
2242
2272
  }
2243
2273
  std::sort(names.begin(), names.end());
2244
2274
  bool hasTest = std::find(names.begin(), names.end(), "test") != names.end();
@@ -2260,10 +2290,12 @@ inline Value makeOptions(CtxPtr ctx) {
2260
2290
  for (const auto& n : featureOrder) orderList.as_list()->push_back(Value(n));
2261
2291
 
2262
2292
  Value derived = vmap();
2263
- map_put(derived, "clean", derivedClean);
2264
2293
  map_put(derived, "featureorder", orderList);
2265
2294
  map_put(opts, "__derived__", derived);
2266
2295
 
2296
+ // Beside the options, not in them: optionsMap hands them to callers.
2297
+ ctx->cleancfg = derivedClean;
2298
+
2267
2299
  // Again over the merged result: the config's own defaults can carry one.
2268
2300
  cleanAddSensitiveCfg(derivedClean, optsWithout(opts, {"clean", "__derived__"}));
2269
2301
 
@@ -19,6 +19,8 @@ public class Context
19
19
  public Dictionary<string, object?>? Config;
20
20
  public Dictionary<string, object?>? Entopts;
21
21
  public Dictionary<string, object?>? Options;
22
+ // The clean registry, beside the options rather than in them.
23
+ public ProjectNameSdk.Util.CleanConfig? CleanCfg;
22
24
  public ConcurrentDictionary<string, Operation> Opmap = new();
23
25
  public Response? Response;
24
26
  public Result? Result;
@@ -125,6 +127,8 @@ public class Context
125
127
  {
126
128
  Options = basectx.Options;
127
129
  }
130
+ CleanCfg = Helpers.GetCtxProp(ctxmap, "cleancfg") as ProjectNameSdk.Util.CleanConfig
131
+ ?? basectx?.CleanCfg;
128
132
 
129
133
  // Entity
130
134
  if (Helpers.GetCtxProp(ctxmap, "entity") is IEntity ent)
@@ -111,7 +111,14 @@ public class AuditFeature : BaseFeature
111
111
 
112
112
  if (Opt(_options, "sink") is Action<Dictionary<string, object?>> sink)
113
113
  {
114
- sink(record);
114
+ // A failing sink never changes the operation's outcome.
115
+ try
116
+ {
117
+ sink(record);
118
+ }
119
+ catch (System.Exception)
120
+ {
121
+ }
115
122
  }
116
123
  }
117
124
  }