@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
@@ -21,7 +21,7 @@ import KOTLINPACKAGE.feature.secrets.sekreto.SekretoError
21
21
  import KOTLINPACKAGE.feature.secrets.sekreto.envkey
22
22
  import KOTLINPACKAGE.feature.secrets.sekreto.specof
23
23
  import KOTLINPACKAGE.feature.secrets.sekreto.Json as SekJson
24
- import KOTLINPACKAGE.utility.defaultHttpFetch
24
+ import KOTLINPACKAGE.utility.fetcher
25
25
  import KOTLINPACKAGE.utility.resolveLocation
26
26
  import KOTLINPACKAGE.utility.struct.Struct
27
27
 
@@ -83,6 +83,7 @@ private const val REDIRECT_MAX = 5
83
83
  class SecretsFeature : BaseFeature("secrets", "0.1.0", true) {
84
84
 
85
85
  private var client: SdkClient? = null
86
+ private var rootctx: Context? = null
86
87
 
87
88
  // Every value this feature resolves or buys is a secret the SDK handles,
88
89
  // and none arrives under an option key the intake registration saw.
@@ -170,6 +171,7 @@ class SecretsFeature : BaseFeature("secrets", "0.1.0", true) {
170
171
  // Sync by feature contract: build the chain, never look anything up here.
171
172
  override fun init(ctx: Context, options: MutableMap<String, Any?>) {
172
173
  this.client = ctx.client
174
+ this.rootctx = ctx
173
175
  this.fopts = options
174
176
  this.liveopts = ctx.options ?: linkedMapOf()
175
177
  this.active = FeatureOptions.foptBool(options, "active", false)
@@ -704,27 +706,15 @@ class SecretsFeature : BaseFeature("secrets", "0.1.0", true) {
704
706
  "body" to body,
705
707
  // Never followed by the client: a redirect would carry the refresh token on.
706
708
  "redirect" to "manual",
709
+ // Its own bound, in milliseconds: the timeout feature's wrapper is above it.
710
+ "timeout" to 30000,
707
711
  )
708
712
 
709
- // Deliberately NOT the SDK transport. The transport is what this feature
710
- // wraps, and sending the token request back through it would recurse on
711
- // the first expiry - and would route the exchange through the test mock,
712
- // which knows nothing about it. utility/Fetcher.kt's defaultHttpFetch is
713
- // the SAME raw HTTP path the SDK uses, taken BELOW the mode/test gate,
714
- // so the ordinary case needs no custom transport; a supplied
715
- // system.fetch is honoured so a test can intercept the purchase.
716
- var sysFetch = Struct.getpath(options, listOf("system", "fetch"))
717
- if (sysFetch === Struct.UNDEF) {
718
- sysFetch = null
719
- }
720
-
721
- val ask = { at: String ->
722
- if (sysFetch is BiFunction<*, *, *>) {
723
- (sysFetch as BiFunction<String, MutableMap<String, Any?>, Any?>).apply(at, fetchdef)
724
- } else {
725
- defaultHttpFetch(at, fetchdef)
726
- }
727
- }
713
+ // The SDK's own transport, beneath every feature's wrapper: it holds the
714
+ // test feature's block and the GET-only guard, and the wrapped one would
715
+ // recurse on the first expiry.
716
+ val rctx = this.rootctx!!
717
+ val ask = { at: String -> fetcher(rctx, at, fetchdef) }
728
718
 
729
719
  var res: Any? = ask(url)
730
720
 
@@ -31,7 +31,11 @@ class StreamingFeature : BaseFeature("streaming", "0.0.1", true) {
31
31
  if (!this.active || !streamable(ctx)) {
32
32
  return
33
33
  }
34
+ // A failed result keeps no stream, so the entity's stream raises its error.
34
35
  val result = ctx.result ?: return
36
+ if (result.err != null) {
37
+ return
38
+ }
35
39
 
36
40
  result.streaming = true
37
41
  result.stream = Supplier { iterate(result) }
@@ -1,5 +1,6 @@
1
1
  package KOTLINPACKAGE.feature
2
2
 
3
+ import java.security.SecureRandom
3
4
  import java.util.function.Consumer
4
5
  import java.util.function.Function
5
6
 
@@ -16,7 +17,6 @@ class TelemetryFeature : BaseFeature("telemetry", "0.0.1", true) {
16
17
 
17
18
  private var client: SdkClient? = null
18
19
  private var options: MutableMap<String, Any?>? = null
19
- private var seq = 0
20
20
 
21
21
  // Activity tracking (mirrors the ts client._telemetry record).
22
22
  var spans: MutableList<MutableMap<String, Any?>> = mutableListOf()
@@ -26,7 +26,6 @@ class TelemetryFeature : BaseFeature("telemetry", "0.0.1", true) {
26
26
  this.client = ctx.client
27
27
  this.options = options
28
28
  this.active = FeatureOptions.foptBool(options, "active", false)
29
- this.seq = 0
30
29
  }
31
30
 
32
31
  override fun prePoint(ctx: Context) {
@@ -105,17 +104,20 @@ class TelemetryFeature : BaseFeature("telemetry", "0.0.1", true) {
105
104
  if (ig is Function<*, *>) {
106
105
  return (ig as Function<String, String>).apply(kind)
107
106
  }
108
- // Deterministic-ish sequential id; unique within a client instance.
109
- this.seq++
110
- val n = StringBuilder(String.format("%04x", this.seq))
111
- val prefix = if ("trace" == kind) "t" else "s"
112
- while (n.length < 16) {
113
- n.append("0")
114
- }
115
- return prefix + n
107
+ return randomHex(if ("trace" == kind) 16 else 8)
108
+ }
109
+
110
+ // W3C trace context: lowercase hex from the platform's random source, never all zeros.
111
+ private fun randomHex(bytes: Int): String {
112
+ val buf = ByteArray(bytes)
113
+ do {
114
+ RANDOM.nextBytes(buf)
115
+ } while (buf.all { it.toInt() == 0 })
116
+ return buf.joinToString("") { String.format("%02x", it.toInt() and 0xff) }
116
117
  }
117
118
 
118
119
  companion object {
119
120
  private const val TELEMETRY_SPAN_KEY = "telemetry_span"
121
+ private val RANDOM = SecureRandom()
120
122
  }
121
123
  }
@@ -125,21 +125,9 @@ class TestFeature : BaseFeature("test", "0.0.1", true) {
125
125
  return out
126
126
  }
127
127
 
128
- // For single-entity ops (load, remove) with an empty explicit match, fall
129
- // back to the id the entity client already knows from a prior create/load.
130
- private fun resolveMatch(ctx: Context, explicit: MutableMap<String, Any?>?): MutableMap<String, Any?> {
131
- if (explicit != null && explicit.isNotEmpty()) {
132
- return explicit
133
- }
134
- for (src in listOf(ctx.match, ctx.data)) {
135
- val v = Struct.getprop(src, "id", null)
136
- if (v != null && "__UNDEFINED__" != v) {
137
- val out = linkedMapOf<String, Any?>()
138
- out["id"] = v
139
- return out
140
- }
141
- }
142
- return linkedMapOf()
128
+ private fun held(src: Map<String, Any?>?, key: String): Boolean {
129
+ val v = if (src == null) null else Struct.getprop(src, key, null)
130
+ return v != null && "__UNDEFINED__" != v
143
131
  }
144
132
 
145
133
  private fun serve(ctx: Context, entity: MutableMap<String, Any?>): Any? {
@@ -151,7 +139,7 @@ class TestFeature : BaseFeature("test", "0.0.1", true) {
151
139
 
152
140
  when (op.name) {
153
141
  "load" -> {
154
- val args = buildArgs(ctx, op, resolveMatch(ctx, ctx.reqmatch))
142
+ val args = buildArgs(ctx, op, ctx.reqmatch)
155
143
  val found = Struct.select(entmap, args)
156
144
  val ent = Struct.getelem(found, 0, null)
157
145
  if (ent == null) {
@@ -171,25 +159,8 @@ class TestFeature : BaseFeature("test", "0.0.1", true) {
171
159
  return respond(ctx, 200, out, null)
172
160
  }
173
161
  "update", "patch" -> {
174
- // Match the existing entity by id only (or its alias).
175
- var updateMatch: MutableMap<String, Any?> = linkedMapOf()
176
162
  val reqdata = ctx.reqdata
177
- if (reqdata.containsKey("id")) {
178
- updateMatch["id"] = reqdata["id"]
179
- }
180
- val alias = op.alias
181
- if (alias != null) {
182
- val aliasIdRaw = Struct.getprop(alias, "id")
183
- if (aliasIdRaw is String) {
184
- if (reqdata.containsKey(aliasIdRaw)) {
185
- updateMatch[aliasIdRaw] = reqdata[aliasIdRaw]
186
- }
187
- }
188
- }
189
- if (updateMatch.isEmpty()) {
190
- updateMatch = resolveMatch(ctx, linkedMapOf())
191
- }
192
- val args = buildArgs(ctx, op, updateMatch)
163
+ val args = buildArgs(ctx, op, record(reqdata))
193
164
  val found = Struct.select(entmap, args)
194
165
  val ent = Struct.getelem(found, 0, null)
195
166
  if (ent == null) {
@@ -204,7 +175,7 @@ class TestFeature : BaseFeature("test", "0.0.1", true) {
204
175
  return respond(ctx, 200, out, null)
205
176
  }
206
177
  "remove" -> {
207
- val args = buildArgs(ctx, op, resolveMatch(ctx, ctx.reqmatch))
178
+ val args = buildArgs(ctx, op, ctx.reqmatch)
208
179
  val found = Struct.select(entmap, args)
209
180
  val ent = Struct.getelem(found, 0, null)
210
181
  // Remove only the first matched entity. If nothing matches, no-op.
@@ -360,23 +331,49 @@ class TestFeature : BaseFeature("test", "0.0.1", true) {
360
331
  val qand = Struct.jt()
361
332
  val q = Struct.jm("`\$AND`", qand)
362
333
 
363
- if (args != null) {
364
- for (key in Struct.keysof(args)) {
365
- val isId = "id" == key
366
- val selected = Struct.select(reqd, key)
367
- val isReqd = !Struct.isempty(selected)
334
+ val entityName = if (ctx.entity == null) "" else ctx.entity!!.name
335
+ val idfrom = Struct.getpath(ctx.config, listOf("entity", entityName, "id", "from"))
368
336
 
369
- if (isId || isReqd) {
370
- val v = ctx.utility!!.param(ctx, key)
371
- val ka = Struct.getprop(op.alias, key)
337
+ val names = if (args == null) mutableListOf() else Struct.keysof(args).toMutableList()
372
338
 
373
- val qor = Struct.jt(Struct.jm(key, v))
374
- if (ka is String) {
375
- qor.add(Struct.jm(ka, v))
376
- }
339
+ // With no id in the call, the entity's held id (or composite parts) stands in.
340
+ if (args == null || args["id"] == null) {
341
+ val declared = Struct.getpath(ctx.config, listOf("entity", entityName, "id", "parts"))
342
+ val parts: List<Any?> = if (declared is List<*>) declared else if ("list" == opname) listOf() else listOf("id")
343
+ for (part in parts) {
344
+ val pname = part.toString()
345
+ if (!names.contains(pname) && (held(ctx.match, pname) || held(ctx.data, pname))) {
346
+ names.add(pname)
347
+ }
348
+ }
349
+ }
350
+
351
+ for (key in names) {
352
+ val isId = "id" == key
353
+ val selected = Struct.select(reqd, key)
354
+ val isReqd = !Struct.isempty(selected)
377
355
 
378
- qand.add(Struct.jm("`\$OR`", qor))
356
+ if (isId || isReqd) {
357
+ val v = ctx.utility!!.param(ctx, key)
358
+ val ka = Struct.getprop(op.alias, key)
359
+
360
+ val qor = Struct.jt(Struct.jm(key, v))
361
+ if (ka is String) {
362
+ qor.add(Struct.jm(ka, v))
379
363
  }
364
+
365
+ // An alternative, never a replacement: a seed keeping the parameter
366
+ // flat is still found.
367
+ val kf = Struct.getprop(idfrom, key)
368
+ if (kf is String && key != kf) {
369
+ var nest: Any? = v
370
+ for (seg in kf.split(".").reversed()) {
371
+ nest = Struct.jm(seg, nest)
372
+ }
373
+ qor.add(nest)
374
+ }
375
+
376
+ qand.add(Struct.jm("`\$OR`", qor))
380
377
  }
381
378
  }
382
379
 
@@ -453,6 +453,65 @@ class FeatureTest {
453
453
  assertEquals(3, rec.calls.size, "expected 3 calls")
454
454
  }
455
455
 
456
+ @Test
457
+ fun cache_keysOnRequestHeaders() {
458
+ assumeFeatures("cache")
459
+ val rec = FhRecorder()
460
+ val h = fhMake(rec::fetch, fhF(CacheFeature(), fhMap("ttl", 10000)))
461
+ h.op(fhOp("load").path("/w/1").headers(fhMap("x-tenant", "tenant-a")))
462
+ h.op(fhOp("load").path("/w/1").headers(fhMap("X-Tenant", "tenant-b")))
463
+ assertEquals(2, rec.calls.size, "a second tenant was served the first tenant's entry")
464
+ h.op(fhOp("load").path("/w/1").headers(fhMap("x-tenant", "tenant-b")))
465
+ assertEquals(2, rec.calls.size, "the same headers did not share an entry")
466
+ }
467
+
468
+ @Test
469
+ fun cache_aWriteDropsItsCollection() {
470
+ assumeFeatures("cache")
471
+ val rec = FhRecorder()
472
+ val f = CacheFeature()
473
+ val h = fhMake(rec::fetch, fhF(f, fhMap("ttl", 10000)))
474
+ val paths = listOf("/w/1", "/w", "/w/1/part", "/other/1", "/w/2")
475
+ for (p in paths) {
476
+ h.op(fhOp("load").path(p))
477
+ }
478
+ h.op(fhOp("update").method("PUT").path("/w/1"))
479
+ for (p in paths) {
480
+ h.op(fhOp("load").path(p))
481
+ }
482
+ assertEquals(9, rec.calls.size, "expected the collection refetched and /other cached")
483
+ assertEquals(2, f.hit, "expected /other served from cache")
484
+ }
485
+
486
+ @Test
487
+ fun cache_cacheControlPreventsStoring() {
488
+ assumeFeatures("cache")
489
+ for (control in listOf("no-store", "private", "No-Cache", "max-age=60, private")) {
490
+ val rec = FhRecorder()
491
+ rec.reply = { _, _ -> fhResponse(200, fhMap("ok", true), fhMap("Cache-Control", control)) }
492
+ val h = fhMake(rec::fetch, fhF(CacheFeature(), fhMap("ttl", 10000)))
493
+ h.op(fhOp("load").path("/w"))
494
+ h.op(fhOp("load").path("/w"))
495
+ assertEquals(2, rec.calls.size, "$control was stored")
496
+ }
497
+ }
498
+
499
+ @Test
500
+ fun cache_maxAgeCapsTheTtl() {
501
+ assumeFeatures("cache")
502
+ val clock = FhClock()
503
+ val rec = FhRecorder()
504
+ rec.reply = { _, _ -> fhResponse(200, fhMap("ok", true), fhMap("cache-control", "max-age=1")) }
505
+ val h = fhMake(rec::fetch, fhF(CacheFeature(), fhMap("ttl", 10000, "now", nowFn(clock))))
506
+ h.op(fhOp("load").path("/w"))
507
+ clock.advance(500)
508
+ h.op(fhOp("load").path("/w"))
509
+ assertEquals(1, rec.calls.size, "expected a hit inside max-age")
510
+ clock.advance(600)
511
+ h.op(fhOp("load").path("/w"))
512
+ assertEquals(2, rec.calls.size, "expected max-age=1 to expire the entry before the ttl")
513
+ }
514
+
456
515
  @Test
457
516
  fun cache_inactiveDoesNotWrap() {
458
517
  assumeFeatures("cache")
@@ -867,6 +926,97 @@ class FeatureTest {
867
926
  assertEquals(true, res.result!!.paging!!["hasMore"], "expected hasMore")
868
927
  }
869
928
 
929
+ // The documented hasMore loop, one request per page.
930
+ private fun pagingWalk(
931
+ options: MutableMap<String, Any?>? = null,
932
+ reply: (Int) -> Any?,
933
+ ): Pair<List<String>, MutableMap<String, Any?>> {
934
+ val rec = FhRecorder()
935
+ rec.reply = { n, _ -> reply(n) }
936
+ val h = fhMake(rec::fetch, fhF(PagingFeature(), options))
937
+ val paging = linkedMapOf<String, Any?>()
938
+ val ctrl = fhMap("paging", paging)
939
+ h.op(fhOp("list").path("/w").ctrl(ctrl))
940
+ while (paging["hasMore"] == true && rec.calls.size < 4) {
941
+ h.op(fhOp("list").path("/w").ctrl(ctrl))
942
+ }
943
+ return Pair(rec.calls.indices.map { rec.url(it) }, paging)
944
+ }
945
+
946
+ @Test
947
+ fun paging_bodyNextIsSentAsTheCursor() {
948
+ assumeFeatures("paging")
949
+ val pages = listOf("c3", "c6", null)
950
+ val (urls, paging) = pagingWalk { n -> fhResponse(200, fhMap("next", pages[n - 1]), null) }
951
+ assertEquals(listOf("http://api.test/w?page=1", "http://api.test/w?cursor=c3",
952
+ "http://api.test/w?cursor=c6"), urls)
953
+ assertEquals(false, paging["hasMore"])
954
+ }
955
+
956
+ @Test
957
+ fun paging_bodyNextUrlIsTheNextRequest() {
958
+ assumeFeatures("paging")
959
+ val pages = listOf("http://api.test/v2/w?cursor=c%2F3&limit=3", "/v2/w?cursor=c6", null)
960
+ val (urls, paging) = pagingWalk { n -> fhResponse(200, fhMap("next", pages[n - 1]), null) }
961
+ assertEquals(listOf("http://api.test/w?page=1", "http://api.test/v2/w?cursor=c%2F3&limit=3",
962
+ "http://api.test/v2/w?cursor=c6"), urls)
963
+ assertEquals(false, paging["hasMore"])
964
+ }
965
+
966
+ @Test
967
+ fun paging_linkNextUrlIsTheNextRequest() {
968
+ assumeFeatures("paging")
969
+ val links = listOf("<http://api.test/w?after=b3>; rel=\"next\"", "</w?after=b6>; rel=\"next\"")
970
+ val (urls, paging) = pagingWalk { n ->
971
+ fhResponse(200, mutableListOf<Any?>(), if (n <= links.size) fhMap("link", links[n - 1]) else null)
972
+ }
973
+ assertEquals(listOf("http://api.test/w?page=1", "http://api.test/w?after=b3",
974
+ "http://api.test/w?after=b6"), urls)
975
+ assertEquals(false, paging["hasMore"])
976
+ }
977
+
978
+ @Test
979
+ fun paging_queryOnlyLinkKeepsThePath() {
980
+ assumeFeatures("paging")
981
+ val links = listOf("</v1/items?page=2>; rel=\"next\"", "<?page=3>; rel=\"next\"")
982
+ val (urls, _) = pagingWalk { n ->
983
+ fhResponse(200, mutableListOf<Any?>(), if (n <= links.size) fhMap("link", links[n - 1]) else null)
984
+ }
985
+ assertEquals(listOf("http://api.test/w?page=1", "http://api.test/v1/items?page=2",
986
+ "http://api.test/v1/items?page=3"), urls)
987
+ }
988
+
989
+ @Test
990
+ fun paging_pathRelativeLinkResolvesAgainstTheRequest() {
991
+ assumeFeatures("paging")
992
+ val links = listOf("</v1/items?page=2>; rel=\"next\"", "<more?page=3>; rel=\"next\"")
993
+ val (urls, _) = pagingWalk { n ->
994
+ fhResponse(200, mutableListOf<Any?>(), if (n <= links.size) fhMap("link", links[n - 1]) else null)
995
+ }
996
+ assertEquals(listOf("http://api.test/w?page=1", "http://api.test/v1/items?page=2",
997
+ "http://api.test/v1/more?page=3"), urls)
998
+ }
999
+
1000
+ @Test
1001
+ fun paging_foreignLinkEndsTheWalk() {
1002
+ assumeFeatures("paging")
1003
+ val (urls, paging) = pagingWalk { _ ->
1004
+ fhResponse(200, mutableListOf<Any?>(), fhMap("link", "<https://elsewhere.test/w?after=b3>; rel=\"next\""))
1005
+ }
1006
+ assertEquals(listOf("http://api.test/w?page=1"), urls)
1007
+ assertEquals(false, paging["hasMore"])
1008
+ assertEquals("https://elsewhere.test/w?after=b3", paging["foreign"])
1009
+ }
1010
+
1011
+ @Test
1012
+ fun paging_cursorModeSendsASlashCursor() {
1013
+ assumeFeatures("paging")
1014
+ val pages = listOf("/c3", null)
1015
+ val (urls, paging) = pagingWalk(fhMap("next", "cursor")) { n -> fhResponse(200, fhMap("next", pages[n - 1]), null) }
1016
+ assertEquals(listOf("http://api.test/w?page=1", "http://api.test/w?cursor=%2Fc3"), urls)
1017
+ assertEquals(false, paging["hasMore"])
1018
+ }
1019
+
870
1020
  @Test
871
1021
  fun paging_nonListNotPaged() {
872
1022
  assumeFeatures("paging")
@@ -920,6 +1070,29 @@ class FeatureTest {
920
1070
  assertEquals(listOf(listOf(1, 2), listOf(3, 4), listOf(5)), batches, "expected chunked batches")
921
1071
  }
922
1072
 
1073
+ @Test
1074
+ fun streaming_failedResultIsNotStreamed() {
1075
+ assumeFeatures("streaming")
1076
+ val rec = FhRecorder()
1077
+ rec.reply = { _, _ -> fhResponse(503, mutableListOf<Any?>(), null) }
1078
+ val f = StreamingFeature()
1079
+ val h = fhMake(rec::fetch, fhF(f, null))
1080
+ val res = h.op(fhOp("list").path("/w"))
1081
+ assertFalse(res.result!!.streaming, "a failed result must keep no stream")
1082
+ assertNull(res.result!!.stream, "a failed result must keep no stream fn")
1083
+ assertEquals(0, f.opened, "expected no opened streams")
1084
+ }
1085
+
1086
+ @Test
1087
+ fun streaming_emptyListStreamsNothing() {
1088
+ assumeFeatures("streaming")
1089
+ val rec = FhRecorder()
1090
+ rec.reply = { _, _ -> fhResponse(200, mutableListOf<Any?>(), null) }
1091
+ val h = fhMake(rec::fetch, fhF(StreamingFeature(), null))
1092
+ val res = h.op(fhOp("list").path("/w"))
1093
+ assertFalse(res.result!!.stream!!.get().hasNext(), "an empty list streams nothing")
1094
+ }
1095
+
923
1096
  @Test
924
1097
  fun streaming_nonListNotStreamed() {
925
1098
  assumeFeatures("streaming")
@@ -40,7 +40,7 @@ private class BinaryBody(val live: List<Any>, val type: String?, val sized: Bool
40
40
  fun holds(v: Any): Boolean = live.any { it === v || (v is String && v == it) }
41
41
  }
42
42
 
43
- // The derived clean block: built by makeOptions from the raw input, grown by
43
+ // The clean registry: built by makeOptions from the raw input, grown by
44
44
  // cleanAdd for as long as the client lives (features register later).
45
45
  class CleanConfig(
46
46
  val active: Boolean,
@@ -95,12 +95,12 @@ fun makeCleanConfig(cleanopts: Any?): CleanConfig {
95
95
  )
96
96
  }
97
97
 
98
- // A context without options (makeError accepts a bare one) still masks by
98
+ // A context without a registry (makeError accepts a bare one) still masks by
99
99
  // the schema defaults.
100
100
  private fun cleanConfig(ctx: Context?): CleanConfig {
101
- val derived = Helpers.toMapAny(ctx?.options?.get("__derived__"))?.get("clean")
102
- if (derived is CleanConfig) {
103
- return derived
101
+ val cfg = ctx?.cleancfg
102
+ if (cfg is CleanConfig) {
103
+ return cfg
104
104
  }
105
105
  return makeCleanConfig(Schema.optspec["clean"])
106
106
  }
@@ -206,6 +206,10 @@ private fun fetchOnce(fullurl: String, fetchdef: MutableMap<String, Any?>): Muta
206
206
  } catch (e: RuntimeException) {
207
207
  throw RuntimeException("fetch: invalid url: $fullurl", e)
208
208
  }
209
+ // A bound in milliseconds, for a caller beneath the timeout feature.
210
+ (fetchdef["timeout"] as? Number)?.toLong()?.takeIf { it > 0 }?.let {
211
+ reqb.timeout(java.time.Duration.ofMillis(it))
212
+ }
209
213
 
210
214
  var hasUA = false
211
215
  val headersRaw = fetchdef["headers"]
@@ -101,6 +101,8 @@ fun makeOptions(ctx: Context): MutableMap<String, Any?> {
101
101
  opts["feature"] = fmap
102
102
  }
103
103
 
104
+ featureDefaults(config["feature"], opts["feature"])?.let { opts["feature"] = it }
105
+
104
106
  // THE OPTION SPEC IS GENERATED, NOT WRITTEN HERE.
105
107
  //
106
108
  // Built from the model: `main.kit.optspec` for the standard options, plus
@@ -129,17 +131,17 @@ fun makeOptions(ctx: Context): MutableMap<String, Any?> {
129
131
  mergeList.add(Struct.clone(cfgopts))
130
132
  mergeList.add(opts)
131
133
  val merged = Struct.merge(mergeList)
134
+ val callbacks = holdCallbacks(merged, optspec)
132
135
 
133
- val vopts = linkedMapOf<String, Any?>()
134
- vopts["errs"] = mutableListOf<Any?>()
135
136
  val validated = try {
136
- Struct.validate(merged, optspec, vopts)
137
+ Struct.validate(merged, optspec)
137
138
  } catch (err: RuntimeException) {
138
139
  // A rejection quotes the value it rejected.
139
140
  throw SdkError("options_invalid",
140
141
  cleanWith(cleancfg, err.message ?: err.toString()) as String, ctx)
141
142
  }
142
143
  opts = validated as MutableMap<String, Any?>
144
+ restoreCallbacks(opts, callbacks)
143
145
 
144
146
  // Restore the suppression the optspec default would otherwise erase.
145
147
  if (authSuppressed) {
@@ -181,21 +183,23 @@ fun makeOptions(ctx: Context): MutableMap<String, Any?> {
181
183
  }
182
184
  }
183
185
 
184
- // Resolve the feature add-order: an explicit list order (above) wins;
185
- // otherwise order the map test-first, then the remaining names sorted, so
186
- // the outcome is deterministic and `test` is always the base transport.
187
- if (featureorder.isEmpty()) {
186
+ // Resolve the feature add-order: an explicit list order (above) wins, and
187
+ // the names it leaves out follow it test-first, then sorted, so the outcome
188
+ // is deterministic and `test` is the base transport of a map.
189
+ run {
188
190
  val fmap = Helpers.toMapAny(opts["feature"])
189
- val names = (fmap?.keys?.toMutableList() ?: mutableListOf()).also { it.sort() }
191
+ val names = (fmap?.keys?.filter { !featureorder.contains(it) }?.toMutableList()
192
+ ?: mutableListOf()).also { it.sort() }
193
+ val rest = mutableListOf<Any?>()
190
194
  if (names.contains("test")) {
191
- featureorder.add("test")
195
+ rest.add("test")
192
196
  for (n in names) {
193
197
  if ("test" != n) {
194
- featureorder.add(n)
198
+ rest.add(n)
195
199
  }
196
200
  }
197
201
  } else {
198
- featureorder.addAll(names)
202
+ rest.addAll(names)
199
203
  }
200
204
  // Station special case, mirroring test's: its transport wrap must
201
205
  // sit immediately outside the base transport (inside every other
@@ -203,18 +207,21 @@ fun makeOptions(ctx: Context): MutableMap<String, Any?> {
203
207
  // test - or first, when no test entry exists. Without this the
204
208
  // sorted default would init station last and wrap OUTSIDE the
205
209
  // recording features, turning its wire-truth events into fiction.
206
- val si = featureorder.indexOf("station")
210
+ val si = rest.indexOf("station")
207
211
  if (0 <= si) {
208
- featureorder.removeAt(si)
209
- featureorder.add(featureorder.indexOf("test") + 1, "station")
212
+ rest.removeAt(si)
213
+ rest.add(rest.indexOf("test") + 1, "station")
210
214
  }
215
+ featureorder.addAll(rest)
211
216
  }
212
217
 
213
218
  val derived = linkedMapOf<String, Any?>()
214
- derived["clean"] = cleancfg
215
219
  derived["featureorder"] = featureorder
216
220
  opts["__derived__"] = derived
217
221
 
222
+ // Beside the options, not in them: optionsMap hands them to callers.
223
+ ctx.cleancfg = cleancfg
224
+
218
225
  // Again over the merged result: the config's own defaults can carry one.
219
226
  registerSensitive(cleancfg, opts - "clean" - "__derived__")
220
227
 
@@ -222,6 +229,70 @@ fun makeOptions(ctx: Context): MutableMap<String, Any?> {
222
229
  }
223
230
 
224
231
 
232
+ // This struct port's `$FUNCTION` admits neither a Consumer nor most other JVM
233
+ // callbacks, so a callback in a slot the spec types as a function is held out
234
+ // of validation and put back; any other key is still validated.
235
+ internal fun holdCallbacks(opts: Any?, optspec: Map<String, Any?>): Map<Pair<String, String>, Any?> {
236
+ val held = linkedMapOf<Pair<String, String>, Any?>()
237
+ val fspecs = Helpers.toMapAny(optspec["feature"]) ?: return held
238
+ for ((name, fopts) in Helpers.toMapAny(Helpers.toMapAny(opts)?.get("feature")) ?: return held) {
239
+ val fm = Helpers.toMapAny(fopts) ?: continue
240
+ val fspec = specMap(fspecs[name]) ?: continue
241
+ for (key in fm.keys.filter { isFunctionSpec(fspec[it]) && isCallback(fm[it]) }) {
242
+ held[name to key] = fm.remove(key)
243
+ }
244
+ }
245
+ return held
246
+ }
247
+
248
+ private fun specMap(spec: Any?): Map<String, Any?>? {
249
+ if (spec is List<*>) {
250
+ val from = if ("`\$NOF`" == spec.firstOrNull()) 2 else 0
251
+ return spec.drop(from).firstOrNull { it is Map<*, *> }?.let { Helpers.toMapAny(it) }
252
+ }
253
+ return Helpers.toMapAny(spec)
254
+ }
255
+
256
+ private fun isFunctionSpec(spec: Any?): Boolean =
257
+ "`\$FUNCTION`" == spec || (spec is List<*> && spec.contains("`\$FUNCTION`"))
258
+
259
+ private fun isCallback(v: Any?): Boolean =
260
+ v is Function<*> || (null != v && v.javaClass.interfaces.any {
261
+ it.isAnnotationPresent(FunctionalInterface::class.java) || "java.util.function" == it.`package`?.name
262
+ })
263
+
264
+ internal fun restoreCallbacks(opts: MutableMap<String, Any?>, held: Map<Pair<String, String>, Any?>) {
265
+ val feature = Helpers.toMapAny(opts["feature"]) ?: return
266
+ for ((at, fn) in held) {
267
+ Helpers.toMapAny(feature[at.first])?.put(at.second, fn)
268
+ }
269
+ }
270
+
271
+
272
+ // The model's options for a feature sit beneath the caller's, key by key: a
273
+ // key the caller sets replaces the default whole, so a list is never merged.
274
+ @Suppress("UNCHECKED_CAST")
275
+ internal fun featureDefaults(cfgfeature: Any?, feature: Any?): MutableMap<String, Any?>? {
276
+ if (feature != null && feature !is Map<*, *>) {
277
+ return null
278
+ }
279
+ val out = linkedMapOf<String, Any?>()
280
+ (feature as? Map<String, Any?>)?.let { out.putAll(it) }
281
+ for ((name, fdef) in Helpers.toMapAny(cfgfeature) ?: emptyMap<String, Any?>()) {
282
+ val dflt = Helpers.toMapAny(Helpers.toMapAny(fdef)?.get("options")) ?: continue
283
+ val given = out[name]
284
+ if ((given == null && true != dflt["active"]) || (given != null && given !is Map<*, *>)) {
285
+ continue
286
+ }
287
+ val merged = linkedMapOf<String, Any?>()
288
+ merged.putAll(Struct.clone(dflt) as Map<String, Any?>)
289
+ (given as? Map<String, Any?>)?.let { merged.putAll(it) }
290
+ out[name] = merged
291
+ }
292
+ return out
293
+ }
294
+
295
+
225
296
  /**
226
297
  * Replaces one utility member from `options.utility`, matching the ts
227
298
  * reference: a key naming a real member REPLACES it, and any other key is
@@ -97,6 +97,12 @@ function Context.new(ctxmap, basectx)
97
97
  self.options = basectx.options
98
98
  end
99
99
 
100
+ -- The clean registry, beside the options rather than in them.
101
+ self.cleancfg = helpers.get_ctx_prop(ctxmap, "cleancfg")
102
+ if self.cleancfg == nil and basectx ~= nil then
103
+ self.cleancfg = basectx.cleancfg
104
+ end
105
+
100
106
  -- Entity
101
107
  local e = helpers.get_ctx_prop(ctxmap, "entity")
102
108
  if e ~= nil then