@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
@@ -99,7 +99,7 @@ public final class RetryFeature: BaseFeature {
99
99
 
100
100
  private func backoff(_ res: Value, _ attempt: Int, _ minDelay: Int, _ maxDelay: Int,
101
101
  _ factor: Double) -> Int {
102
- // Honour a server-provided Retry-After (seconds) when present.
102
+ // A server-provided Retry-After wins over the computed backoff.
103
103
  let (ra, has) = retryAfter(res)
104
104
  if has {
105
105
  return ra > maxDelay ? maxDelay : ra
@@ -118,11 +118,46 @@ public final class RetryFeature: BaseFeature {
118
118
  if !has {
119
119
  return (0, false)
120
120
  }
121
- let seconds = fparseInt(v, -1)
122
- if seconds < 0 {
123
- return (0, false)
121
+ let ms = RetryFeature.retryAfterMs(v, Int64(Date().timeIntervalSince1970 * 1000))
122
+ return ms < 0 ? (0, false) : (ms, true)
123
+ }
124
+
125
+ private static let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
126
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
127
+
128
+ private static let days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
129
+
130
+ // RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else -1.
131
+ static func retryAfterMs(_ value: String, _ now: Int64) -> Int {
132
+ let s = Array(value.trimmingCharacters(in: CharacterSet(charactersIn: " \t")).utf8)
133
+ let isDigit = { (c: UInt8) in c >= 48 && c <= 57 }
134
+ if !s.isEmpty && s.allSatisfy(isDigit) {
135
+ return s.count > 6 ? Int(Int32.max) : Int(String(decoding: s, as: UTF8.self))! * 1000
136
+ }
137
+ let text = { (from: Int, to: Int) in String(decoding: s[from..<to], as: UTF8.self) }
138
+ let num = { (from: Int, to: Int) -> Int in
139
+ s[from..<to].allSatisfy(isDigit) ? Int(text(from, to))! : -1
140
+ }
141
+ guard s.count == 29, text(3, 5) == ", ", s[7] == 32, s[11] == 32, s[16] == 32,
142
+ s[19] == 58, s[22] == 58, text(25, 29) == " GMT", days.contains(text(0, 3)),
143
+ let mi = months.firstIndex(of: text(8, 11)) else {
144
+ return -1
145
+ }
146
+ let (day, year, hour, min, sec) = (num(5, 7), num(12, 16), num(17, 19), num(20, 22), num(23, 25))
147
+ if day < 1 || day > 31 || year < 0 || hour < 0 || hour > 23 || min < 0 || min > 59 ||
148
+ sec < 0 || sec > 60 {
149
+ return -1
124
150
  }
125
- return (seconds * 1000, true)
151
+ var y = year
152
+ let m = mi + 1
153
+ if m <= 2 { y -= 1 }
154
+ let era = (y >= 0 ? y : y - 399) / 400
155
+ let yoe = y - era * 400
156
+ let doy = (153 * ((m + 9) % 12) + 2) / 5 + day - 1
157
+ let doe = yoe * 365 + yoe / 4 - yoe / 100 + doy
158
+ let epochDays = Int64(era * 146097 + doe - 719468)
159
+ let at = (((epochDays * 24 + Int64(hour)) * 60 + Int64(min)) * 60 + Int64(sec)) * 1000
160
+ return Int(Swift.min(Int64(Int32.max), Swift.max(0, at - now)))
126
161
  }
127
162
 
128
163
  private func sleepMs(_ ms: Int) {
@@ -72,6 +72,7 @@ import VoxgigPlugin
72
72
 
73
73
  public final class SecretsFeature: BaseFeature {
74
74
  private var client: ProjectNameSDK?
75
+ private var rootctx: Context?
75
76
  private var fopts: VMap?
76
77
 
77
78
  // The LIVE options map (the root context's options - the same instance
@@ -175,6 +176,7 @@ public final class SecretsFeature: BaseFeature {
175
176
  // Sync by feature contract: build the chain, never look anything up here.
176
177
  public override func initFeature(_ ctx: Context, _ options: VMap) {
177
178
  client = ctx.client
179
+ rootctx = ctx
178
180
  fopts = options
179
181
  liveopts = ctx.options ?? VMap()
180
182
  active = foptBool(options, "active", false)
@@ -652,21 +654,15 @@ public final class SecretsFeature: BaseFeature {
652
654
  fetchdef.entries["body"] = .string(body)
653
655
  // Never followed by the client: a redirect would carry the refresh token on.
654
656
  fetchdef.entries["redirect"] = .string("manual")
657
+ // Its own bound, in milliseconds: the timeout feature's wrapper is above it.
658
+ fetchdef.entries["timeout"] = .int(30000)
655
659
 
656
- // Deliberately NOT the SDK transport. The transport is what this feature
657
- // wraps, and sending the token request back through it would recurse on
658
- // the first expiry - and would route the exchange through the test mock,
659
- // which knows nothing about it. utility/Fetcher.swift's defaultHttpFetch
660
- // is the SAME raw HTTP path the SDK uses, taken BELOW the mode/test
661
- // gate, so the ordinary case needs no custom transport (and no
662
- // rawExchangeFetch twin, unlike go); a supplied system.fetch is honoured
663
- // so a test can intercept the purchase.
664
- let sysFetch = gpath(options, "system", "fetch")
660
+ // The SDK's own transport, beneath every feature's wrapper: it holds the
661
+ // test feature's block and the GET-only guard, and the wrapped one would
662
+ // recurse on the first expiry.
663
+ let rootctx = self.rootctx!
665
664
  func fetch(_ at: String) throws -> Value {
666
- if let fn = sysFetch.asNative as? SystemFetch {
667
- return fn(at, fetchdef)
668
- }
669
- return try defaultHttpFetch(at, fetchdef)
665
+ return try fetcherUtil(rootctx, at, fetchdef)
670
666
  }
671
667
 
672
668
  var res = try fetch(url)
@@ -31,7 +31,8 @@ public final class StreamingFeature: BaseFeature {
31
31
  if !active || !streamable(ctx) {
32
32
  return
33
33
  }
34
- guard let result = ctx.result else {
34
+ // A failed result keeps no stream, so the entity's stream raises its error.
35
+ guard let result = ctx.result, result.err == nil else {
35
36
  return
36
37
  }
37
38
 
@@ -12,7 +12,6 @@ import Foundation
12
12
  public final class TelemetryFeature: BaseFeature {
13
13
  private var client: ProjectNameSDK?
14
14
  private var options: VMap?
15
- private var seq = 0
16
15
 
17
16
  // Activity tracking (mirrors the ts client._telemetry record).
18
17
  public var spans: [VMap] = []
@@ -31,7 +30,6 @@ public final class TelemetryFeature: BaseFeature {
31
30
  client = ctx.client
32
31
  self.options = options
33
32
  active = foptBool(options, "active", false)
34
- seq = 0
35
33
  }
36
34
 
37
35
  public override func prePoint(_ ctx: Context) {
@@ -111,12 +109,16 @@ public final class TelemetryFeature: BaseFeature {
111
109
  if let idgen = gp(options, "idgen").asNative as? (String) -> String {
112
110
  return idgen(kind)
113
111
  }
114
- // Deterministic-ish sequential id; unique within a client instance.
115
- seq += 1
116
- var n = String(seq, radix: 16)
117
- while n.count < 4 { n = "0" + n }
118
- let prefix = kind == "trace" ? "t" : "s"
119
- while n.count < 16 { n += "0" }
120
- return prefix + n
112
+ return telemetryRandomHex(kind == "trace" ? 16 : 8)
121
113
  }
122
114
  }
115
+
116
+ // W3C trace context: lowercase hex from the platform's random source, never all zeros.
117
+ func telemetryRandomHex(_ bytes: Int) -> String {
118
+ var rng = SystemRandomNumberGenerator()
119
+ var buf = [UInt8](repeating: 0, count: bytes)
120
+ repeat {
121
+ for i in buf.indices { buf[i] = UInt8.random(in: 0...255, using: &rng) }
122
+ } while buf.allSatisfy { $0 == 0 }
123
+ return buf.map { String(format: "%02x", $0) }.joined()
124
+ }
@@ -64,19 +64,9 @@ private func testRespond(_ ctx: Context, _ status: Int, _ data: Value, _ extra:
64
64
  return .map(res)
65
65
  }
66
66
 
67
- // For single-entity ops with an empty explicit match, fall back to the id the
68
- // entity client already knows from a prior create/load.
69
- private func testResolveMatch(_ ctx2: Context, _ explicitMatch: VMap) -> VMap {
70
- if explicitMatch.entries.count > 0 { return explicitMatch }
71
- for src in [ctx2.match, ctx2.data] {
72
- let v = gp(src, "id")
73
- if !isNil(v) && v != .string("__UNDEFINED__") {
74
- let m = VMap()
75
- m.entries["id"] = v
76
- return m
77
- }
78
- }
79
- return VMap()
67
+ private func testHeld(_ src: VMap, _ key: String) -> Bool {
68
+ let v = gp(src, key)
69
+ return !isNil(v) && v != .string("__UNDEFINED__")
80
70
  }
81
71
 
82
72
  // The entity's declared identity field (`entity.id.field`), where it names
@@ -146,33 +136,60 @@ private func testBuildArgs(_ ctx: Context, _ op: Operation, _ args: VMap?) -> Va
146
136
  let q = VMap()
147
137
  q.entries["`$AND`"] = .list(qand)
148
138
 
149
- if let args = args {
150
- for key in keysof(.map(args)) {
151
- let isId = key == "id"
152
- let selected = select(reqd, .string(key))
153
- let isReqd = !isempty(selected)
154
-
155
- if isId || isReqd {
156
- let v = ctx.utility!.param(ctx, .string(key))
157
- let ka = gp(op.alias, key)
158
-
159
- let qor = VList()
160
- let qm1 = VMap()
161
- qm1.entries[key] = v
162
- qor.items.append(.map(qm1))
163
- if let kas = ka.asString {
164
- let qm2 = VMap()
165
- qm2.entries[kas] = v
166
- qor.items.append(.map(qm2))
167
- }
139
+ let entityName = ctx.entity!.getName()
140
+ let idfrom = getpath(cfg, jtp("entity", entityName, "id", "from"))
168
141
 
169
- let qorm = VMap()
170
- qorm.entries["`$OR`"] = .list(qor)
171
- qand.items.append(.map(qorm))
142
+ var names: [String] = args == nil ? [] : keysof(.map(args!))
143
+
144
+ // With no id in the call, the entity's held id (or composite parts) stands in.
145
+ if args == nil || isNil(gp(args!, "id")) {
146
+ let declared = getpath(cfg, jtp("entity", entityName, "id", "parts")).asList?.items
147
+ let parts: [Value] = declared ?? (opname == "list" ? [] : [.string("id")])
148
+ for part in parts {
149
+ let pname = part.asString ?? stringify(part)
150
+ if !names.contains(pname) && (testHeld(ctx.match, pname) || testHeld(ctx.data, pname)) {
151
+ names.append(pname)
172
152
  }
173
153
  }
174
154
  }
175
155
 
156
+ for key in names {
157
+ let isId = key == "id"
158
+ let selected = select(reqd, .string(key))
159
+ let isReqd = !isempty(selected)
160
+
161
+ if isId || isReqd {
162
+ let v = ctx.utility!.param(ctx, .string(key))
163
+ let ka = gp(op.alias, key)
164
+
165
+ let qor = VList()
166
+ let qm1 = VMap()
167
+ qm1.entries[key] = v
168
+ qor.items.append(.map(qm1))
169
+ if let kas = ka.asString {
170
+ let qm2 = VMap()
171
+ qm2.entries[kas] = v
172
+ qor.items.append(.map(qm2))
173
+ }
174
+
175
+ // An alternative, never a replacement: a seed keeping the parameter
176
+ // flat is still found.
177
+ if let kf = getprop(idfrom, .string(key)).asString, kf != key {
178
+ var nest: Value = v
179
+ for seg in kf.split(separator: ".").reversed() {
180
+ let m = VMap()
181
+ m.entries[String(seg)] = nest
182
+ nest = .map(m)
183
+ }
184
+ qor.items.append(nest)
185
+ }
186
+
187
+ let qorm = VMap()
188
+ qorm.entries["`$OR`"] = .list(qor)
189
+ qand.items.append(.map(qorm))
190
+ }
191
+ }
192
+
176
193
  if let explain = ctx.ctrl.explain {
177
194
  let tm = VMap()
178
195
  tm.entries["query"] = .map(q)
@@ -218,7 +235,7 @@ public final class TestFeature: BaseFeature {
218
235
  let entmap = gp(entity, op.entity).asMap ?? VMap()
219
236
 
220
237
  if op.name == "load" {
221
- let args = testBuildArgs(ctx2, op, testResolveMatch(ctx2, ctx2.reqmatch))
238
+ let args = testBuildArgs(ctx2, op, ctx2.reqmatch)
222
239
  let found = select(.map(entmap), args)
223
240
  let ent = getelem(found, .int(0))
224
241
  if isNil(ent) {
@@ -241,18 +258,7 @@ public final class TestFeature: BaseFeature {
241
258
  }
242
259
  return testRespond(ctx2, 200, clone(found), nil)
243
260
  } else if op.name == "update" || op.name == "patch" {
244
- var updateMatch = VMap()
245
- if let idv = ctx2.reqdata.entries["id"] {
246
- updateMatch.entries["id"] = idv
247
- }
248
- if let alias = op.alias, let aliasId = gp(alias, "id").asString,
249
- let av = ctx2.reqdata.entries[aliasId] {
250
- updateMatch.entries[aliasId] = av
251
- }
252
- if updateMatch.entries.count == 0 {
253
- updateMatch = testResolveMatch(ctx2, VMap())
254
- }
255
- let args = testBuildArgs(ctx2, op, updateMatch)
261
+ let args = testBuildArgs(ctx2, op, testRecord(ctx2.reqdata))
256
262
  let found = select(.map(entmap), args)
257
263
  let ent = getelem(found, .int(0))
258
264
  if isNil(ent) {
@@ -267,7 +273,7 @@ public final class TestFeature: BaseFeature {
267
273
  _ = try? delprop(ent, .string("$KEY"))
268
274
  return testRespond(ctx2, 200, clone(ent), nil)
269
275
  } else if op.name == "remove" {
270
- let args = testBuildArgs(ctx2, op, testResolveMatch(ctx2, ctx2.reqmatch))
276
+ let args = testBuildArgs(ctx2, op, ctx2.reqmatch)
271
277
  let found = select(.map(entmap), args)
272
278
  let ent = getelem(found, .int(0))
273
279
  if let entm2 = ent.asMap {
@@ -135,6 +135,10 @@ private func sendOnce(_ fullurl: String, _ fetchdef: VMap) throws -> Value {
135
135
 
136
136
  var req = URLRequest(url: url)
137
137
  req.httpMethod = gp(fetchdef, "method").asString ?? "GET"
138
+ // A bound in milliseconds, for a caller beneath the timeout feature.
139
+ if let ms = gp(fetchdef, "timeout").asDouble, ms > 0 {
140
+ req.timeoutInterval = ms / 1000
141
+ }
138
142
 
139
143
  let body = gp(fetchdef, "body")
140
144
  if let text = body.asString, text != "" {
@@ -69,8 +69,7 @@ func makeOptionsUtil(_ ctx: Context) -> VMap {
69
69
  }
70
70
  }
71
71
  let cleancfg = makeCleanConfig(merge(.list(cleanlayers)))
72
- let cleanctx = Context(
73
- ["options": vm(("__derived__", .map(vm(("clean", .nat(cleancfg))))))], nil)
72
+ let cleanctx = Context(["cleancfg": cleancfg], nil)
74
73
  cleanAddOptions(cleanctx, cleanOmit(opts, ["clean"]))
75
74
  let cleanvalues = cleanSplitValues(gpath(cfgopts, "clean", "values"))
76
75
  + cleanSplitValues(gpath(opts, "clean", "values"))
@@ -98,6 +97,10 @@ func makeOptionsUtil(_ ctx: Context) -> VMap {
98
97
  opts.entries["feature"] = .map(fmap)
99
98
  }
100
99
 
100
+ if let fdefaults = featureDefaults(gp(config, "feature"), opts.entries["feature"] ?? .noval) {
101
+ opts.entries["feature"] = .map(fdefaults)
102
+ }
103
+
101
104
  // THE OPTION SPEC IS GENERATED, NOT WRITTEN HERE.
102
105
  //
103
106
  // Built from the model: `main.kit.optspec` for the standard options, plus
@@ -120,7 +123,16 @@ func makeOptionsUtil(_ ctx: Context) -> VMap {
120
123
  // so without this one client's options (headers, server, ...) are written
121
124
  // into the shared config and inherited by every client built afterwards.
122
125
  let merged = merge(.list([.map(VMap()), clone(.map(cfgopts)), .map(opts)]))
123
- let validated = validateKept(merged, optspec)
126
+ let vinj = Injection(val: .noval, parent: .noval)
127
+ vinj.errs = VList()
128
+ let validated = (try? validate(merged, optspec, vinj)) ?? .noval
129
+ if !vinj.errs.items.isEmpty {
130
+ let verrs = vinj.errs
131
+ // The initializer cannot throw, so a construction error traps, as zig's panics.
132
+ let text = verrs.items.map { $0.asString ?? stringify($0) }.joined(separator: " | ")
133
+ fatalError(errMessage(ProjectNameError("options_invalid",
134
+ cleanUtil(cleanctx, .string("invalid options: " + text)).asString ?? "invalid options", nil)))
135
+ }
124
136
  let result = validated.asMap ?? VMap()
125
137
 
126
138
  // Restore the suppression the optspec default would otherwise erase.
@@ -149,17 +161,19 @@ func makeOptionsUtil(_ ctx: Context) -> VMap {
149
161
  }
150
162
  }
151
163
 
152
- // Resolve the feature add-order: an explicit list order (above) wins;
153
- // otherwise order the map test-first, then the remaining names sorted, so
154
- // the outcome is deterministic and `test` is always the base transport.
155
- if featureorder.isEmpty {
164
+ // Resolve the feature add-order: an explicit list order (above) wins, and
165
+ // the names it leaves out follow it test-first, then sorted, so the outcome
166
+ // is deterministic and `test` is the base transport of a map.
167
+ do {
156
168
  let fmap = gp(result, "feature").asMap ?? VMap()
157
- let names = fmap.entries.keys.sorted()
169
+ let given = Set(featureorder.compactMap { $0.asString })
170
+ let names = fmap.entries.keys.filter { !given.contains($0) }.sorted()
171
+ var rest: [Value] = []
158
172
  if names.contains("test") {
159
- featureorder.append(.string("test"))
160
- for n in names where n != "test" { featureorder.append(.string(n)) }
173
+ rest.append(.string("test"))
174
+ for n in names where n != "test" { rest.append(.string(n)) }
161
175
  } else {
162
- for n in names { featureorder.append(.string(n)) }
176
+ for n in names { rest.append(.string(n)) }
163
177
  }
164
178
 
165
179
  // Station special case, mirroring test's: its transport wrap must
@@ -168,24 +182,49 @@ func makeOptionsUtil(_ ctx: Context) -> VMap {
168
182
  // test - or first, when no test entry exists. Without this the
169
183
  // sorted default would init station last and wrap OUTSIDE the
170
184
  // recording features, turning its wire-truth events into fiction.
171
- if let si = featureorder.firstIndex(where: { $0.asString == "station" }) {
172
- featureorder.remove(at: si)
173
- let ti = featureorder.firstIndex(where: { $0.asString == "test" })
174
- featureorder.insert(.string("station"), at: (ti ?? -1) + 1)
185
+ if let si = rest.firstIndex(where: { $0.asString == "station" }) {
186
+ rest.remove(at: si)
187
+ let ti = rest.firstIndex(where: { $0.asString == "test" })
188
+ rest.insert(.string("station"), at: (ti ?? -1) + 1)
175
189
  }
190
+ featureorder.append(contentsOf: rest)
176
191
  }
177
192
 
178
193
  let derived = VMap()
179
- derived.entries["clean"] = .nat(cleancfg)
180
194
  derived.entries["featureorder"] = .list(VList(featureorder))
181
195
  result.entries["__derived__"] = .map(derived)
182
196
 
197
+ // Beside the options, not in them: optionsMap hands them to callers.
198
+ ctx.cleancfg = cleancfg
199
+
183
200
  // Again over the merged result: the config's own defaults can carry one.
184
- cleanAddOptions(Context(["options": result], nil), cleanOmit(result, ["clean", "__derived__"]))
201
+ cleanAddOptions(cleanctx, cleanOmit(result, ["clean", "__derived__"]))
185
202
 
186
203
  return result
187
204
  }
188
205
 
206
+ // The model's options for a feature sit beneath the caller's, key by key: a
207
+ // key the caller sets replaces the default whole, so a list is never merged.
208
+ private func featureDefaults(_ cfgfeature: Value, _ feature: Value) -> VMap? {
209
+ if !isNil(feature) && feature.asMap == nil {
210
+ return nil
211
+ }
212
+ let out = VMap()
213
+ for (k, v) in feature.asMap?.entries ?? [:] { out.entries[k] = v }
214
+ for (name, fdef) in cfgfeature.asMap?.entries ?? [:] {
215
+ guard let dflt = gp(fdef, "options").asMap else { continue }
216
+ let given = out.entries[name] ?? .noval
217
+ if (isNil(given) && gp(.map(dflt), "active") != .bool(true)) ||
218
+ (!isNil(given) && given.asMap == nil) {
219
+ continue
220
+ }
221
+ let merged = clone(.map(dflt)).asMap ?? VMap()
222
+ for (k, v) in given.asMap?.entries ?? [:] { merged.entries[k] = v }
223
+ out.entries[name] = .map(merged)
224
+ }
225
+ return out
226
+ }
227
+
189
228
  // A templated base URL takes each {name} from options.server. An empty value
190
229
  // cannot make a working URL, so it is an error, except in test mode, where it
191
230
  // becomes test-<name>.
@@ -134,9 +134,8 @@ func transformResponseUtil(_ ctx: Context) -> Value {
134
134
  // stays raw, so a hook can still read the header it must add to. See
135
135
  // docs/explanation/secret-redaction.md.
136
136
 
137
- // The derived clean block, MUTABLE after makeOptions since features register
138
- // values later. Carried as a native object under options.__derived__.clean,
139
- // which JSON.stringify prints as "<function>" rather than as the registry.
137
+ // The clean registry, MUTABLE after makeOptions since features register
138
+ // values later. Held on the context beside the options, never in them.
140
139
  // Nested in Utility, whose registry it is, so no entity type can collide
141
140
  // with it.
142
141
  extension Utility {
@@ -247,10 +246,10 @@ func makeCleanConfig(_ cleanopts: Value) -> Utility.CleanConfig {
247
246
  return cfg
248
247
  }
249
248
 
250
- // A context without options (makeError accepts a bare one) still masks by
249
+ // A context without a registry (makeError accepts a bare one) still masks by
251
250
  // the schema defaults.
252
251
  func cleanConfigOf(_ ctx: Context) -> Utility.CleanConfig {
253
- if let cfg = gpath(ctx.options, "__derived__", "clean").asNative as? Utility.CleanConfig {
252
+ if let cfg = ctx.cleancfg {
254
253
  return cfg
255
254
  }
256
255
  return makeCleanConfig(gp(SdkSchema.optspec, "clean"))
@@ -602,6 +602,61 @@ final class FeatureCacheTest: XCTestCase {
602
602
  _ = h.op(FhOpSpec(op: "load", path: "/x"))
603
603
  XCTAssertEqual(rec.calls.count, 2)
604
604
  }
605
+
606
+ func testKeysOnRequestHeaders() {
607
+ if Fh.skipWithout("cache") { return }
608
+ let rec = FhRecorder()
609
+ let h = Fh.make(rec.fetch, (CacheFeature(), vm(("ttl", .int(10000)))))
610
+ _ = h.op(FhOpSpec(op: "load", path: "/w/1", headers: vm(("x-tenant", .string("tenant-a")))))
611
+ _ = h.op(FhOpSpec(op: "load", path: "/w/1", headers: vm(("X-Tenant", .string("tenant-b")))))
612
+ XCTAssertEqual(rec.calls.count, 2, "a second tenant was served the first tenant's entry")
613
+ _ = h.op(FhOpSpec(op: "load", path: "/w/1", headers: vm(("x-tenant", .string("tenant-b")))))
614
+ XCTAssertEqual(rec.calls.count, 2, "the same headers did not share an entry")
615
+ }
616
+
617
+ func testAWriteDropsItsCollection() {
618
+ if Fh.skipWithout("cache") { return }
619
+ let rec = FhRecorder()
620
+ let f = CacheFeature()
621
+ let h = Fh.make(rec.fetch, (f, vm(("ttl", .int(10000)))))
622
+ let paths = ["/w/1", "/w", "/w/1/part", "/other/1", "/w/2"]
623
+ for p in paths { _ = h.op(FhOpSpec(op: "load", path: p)) }
624
+ _ = h.op(FhOpSpec(op: "update", method: "PUT", path: "/w/1"))
625
+ for p in paths { _ = h.op(FhOpSpec(op: "load", path: p)) }
626
+ XCTAssertEqual(rec.calls.count, 9)
627
+ XCTAssertEqual(f.hit, 2)
628
+ }
629
+
630
+ func testCacheControlPreventsStoring() {
631
+ if Fh.skipWithout("cache") { return }
632
+ for control in ["no-store", "private", "No-Cache", "max-age=60, private"] {
633
+ let rec = FhRecorder()
634
+ rec.reply = { _, _ in
635
+ Fh.response(200, mapv(("ok", .bool(true))), vm(("Cache-Control", .string(control))))
636
+ }
637
+ let h = Fh.make(rec.fetch, (CacheFeature(), vm(("ttl", .int(10000)))))
638
+ _ = h.op(FhOpSpec(op: "load", path: "/w"))
639
+ _ = h.op(FhOpSpec(op: "load", path: "/w"))
640
+ XCTAssertEqual(rec.calls.count, 2, control + " was stored")
641
+ }
642
+ }
643
+
644
+ func testMaxAgeCapsTheTtl() {
645
+ if Fh.skipWithout("cache") { return }
646
+ let clock = FhClock()
647
+ let rec = FhRecorder()
648
+ rec.reply = { _, _ in
649
+ Fh.response(200, mapv(("ok", .bool(true))), vm(("cache-control", .string("max-age=1"))))
650
+ }
651
+ let h = Fh.make(rec.fetch, (CacheFeature(), vm(("ttl", .int(10000)), ("now", .nat(clock.now)))))
652
+ _ = h.op(FhOpSpec(op: "load", path: "/w"))
653
+ clock.advance(500)
654
+ _ = h.op(FhOpSpec(op: "load", path: "/w"))
655
+ XCTAssertEqual(rec.calls.count, 1, "expected a hit inside max-age")
656
+ clock.advance(600)
657
+ _ = h.op(FhOpSpec(op: "load", path: "/w"))
658
+ XCTAssertEqual(rec.calls.count, 2, "expected max-age=1 to expire the entry before the ttl")
659
+ }
605
660
  }
606
661
 
607
662
  // --- idempotency -------------------------------------------------------------
@@ -993,6 +1048,96 @@ final class FeaturePagingTest: XCTestCase {
993
1048
  XCTAssertEqual(res.result!.paging!.entries["hasMore"], .bool(true))
994
1049
  }
995
1050
 
1051
+ // The documented hasMore loop, one request per page.
1052
+ private func walk(_ reply: @escaping (Int) -> Value, _ options: VMap? = nil) -> ([String], VMap) {
1053
+ let rec = FhRecorder()
1054
+ rec.reply = { n, _ in reply(n) }
1055
+ let h = Fh.make(rec.fetch, (PagingFeature(), options))
1056
+ let paging = VMap()
1057
+ let ctrl = vm(("paging", .map(paging)))
1058
+ _ = h.op(FhOpSpec(op: "list", path: "/w", ctrl: ctrl))
1059
+ while paging.entries["hasMore"] == .bool(true) && rec.calls.count < 4 {
1060
+ _ = h.op(FhOpSpec(op: "list", path: "/w", ctrl: ctrl))
1061
+ }
1062
+ return ((0..<rec.calls.count).map { rec.url($0) }, paging)
1063
+ }
1064
+
1065
+ func testBodyNextIsSentAsTheCursor() {
1066
+ if Fh.skipWithout("paging") { return }
1067
+ let pages: [Value] = [.string("c3"), .string("c6"), .null]
1068
+ let (urls, paging) = walk { n in Fh.response(200, mapv(("next", pages[n - 1])), nil) }
1069
+ XCTAssertEqual(urls, [
1070
+ "http://api.test/w?page=1", "http://api.test/w?cursor=c3", "http://api.test/w?cursor=c6",
1071
+ ])
1072
+ XCTAssertEqual(paging.entries["hasMore"], .bool(false))
1073
+ }
1074
+
1075
+ func testBodyNextUrlIsTheNextRequest() {
1076
+ if Fh.skipWithout("paging") { return }
1077
+ let pages: [Value] = [
1078
+ .string("http://api.test/v2/w?cursor=c%2F3&limit=3"), .string("/v2/w?cursor=c6"), .null,
1079
+ ]
1080
+ let (urls, paging) = walk { n in Fh.response(200, mapv(("next", pages[n - 1])), nil) }
1081
+ XCTAssertEqual(urls, [
1082
+ "http://api.test/w?page=1", "http://api.test/v2/w?cursor=c%2F3&limit=3",
1083
+ "http://api.test/v2/w?cursor=c6",
1084
+ ])
1085
+ XCTAssertEqual(paging.entries["hasMore"], .bool(false))
1086
+ }
1087
+
1088
+ func testLinkNextUrlIsTheNextRequest() {
1089
+ if Fh.skipWithout("paging") { return }
1090
+ let links = ["<http://api.test/w?after=b3>; rel=\"next\"", "</w?after=b6>; rel=\"next\""]
1091
+ let (urls, paging) = walk { n in
1092
+ Fh.response(200, .list([]), n <= links.count ? vm(("link", .string(links[n - 1]))) : nil)
1093
+ }
1094
+ XCTAssertEqual(urls, [
1095
+ "http://api.test/w?page=1", "http://api.test/w?after=b3", "http://api.test/w?after=b6",
1096
+ ])
1097
+ XCTAssertEqual(paging.entries["hasMore"], .bool(false))
1098
+ }
1099
+
1100
+ func testQueryOnlyLinkKeepsThePath() {
1101
+ if Fh.skipWithout("paging") { return }
1102
+ let links = ["</v1/items?page=2>; rel=\"next\"", "<?page=3>; rel=\"next\""]
1103
+ let (urls, _) = walk { n in
1104
+ Fh.response(200, .list([]), n <= links.count ? vm(("link", .string(links[n - 1]))) : nil)
1105
+ }
1106
+ XCTAssertEqual(urls, [
1107
+ "http://api.test/w?page=1", "http://api.test/v1/items?page=2", "http://api.test/v1/items?page=3",
1108
+ ])
1109
+ }
1110
+
1111
+ func testPathRelativeLinkResolvesAgainstTheRequest() {
1112
+ if Fh.skipWithout("paging") { return }
1113
+ let links = ["</v1/items?page=2>; rel=\"next\"", "<more?page=3>; rel=\"next\""]
1114
+ let (urls, _) = walk { n in
1115
+ Fh.response(200, .list([]), n <= links.count ? vm(("link", .string(links[n - 1]))) : nil)
1116
+ }
1117
+ XCTAssertEqual(urls, [
1118
+ "http://api.test/w?page=1", "http://api.test/v1/items?page=2", "http://api.test/v1/more?page=3",
1119
+ ])
1120
+ }
1121
+
1122
+ func testForeignLinkEndsTheWalk() {
1123
+ if Fh.skipWithout("paging") { return }
1124
+ let (urls, paging) = walk { _ in
1125
+ Fh.response(200, .list([]), vm(("link", .string("<https://elsewhere.test/w?after=b3>; rel=\"next\""))))
1126
+ }
1127
+ XCTAssertEqual(urls, ["http://api.test/w?page=1"])
1128
+ XCTAssertEqual(paging.entries["hasMore"], .bool(false))
1129
+ XCTAssertEqual(paging.entries["foreign"], .string("https://elsewhere.test/w?after=b3"))
1130
+ }
1131
+
1132
+ func testCursorModeSendsASlashCursor() {
1133
+ if Fh.skipWithout("paging") { return }
1134
+ let pages: [Value] = [.string("/c3"), .null]
1135
+ let (urls, paging) = walk({ n in Fh.response(200, mapv(("next", pages[n - 1])), nil) },
1136
+ vm(("next", .string("cursor"))))
1137
+ XCTAssertEqual(urls, ["http://api.test/w?page=1", "http://api.test/w?cursor=%2Fc3"])
1138
+ XCTAssertEqual(paging.entries["hasMore"], .bool(false))
1139
+ }
1140
+
996
1141
  func testNonListNotPaged() {
997
1142
  if Fh.skipWithout("paging") { return }
998
1143
  let rec = FhRecorder()
@@ -1039,6 +1184,27 @@ final class FeatureStreamingTest: XCTestCase {
1039
1184
  XCTAssertTrue(SdkRunner.deepEqual(.list(batches), want))
1040
1185
  }
1041
1186
 
1187
+ func testFailedResultIsNotStreamed() {
1188
+ if Fh.skipWithout("streaming") { return }
1189
+ let rec = FhRecorder()
1190
+ rec.reply = { _, _ in Fh.response(503, .list([]), nil) }
1191
+ let f = StreamingFeature()
1192
+ let h = Fh.make(rec.fetch, (f, nil))
1193
+ let res = h.op(FhOpSpec(op: "list", path: "/w"))
1194
+ XCTAssertFalse(res.ok)
1195
+ XCTAssertFalse(res.result!.streaming || res.result!.stream != nil, "a failed result must keep no stream")
1196
+ XCTAssertEqual(f.opened, 0)
1197
+ }
1198
+
1199
+ func testEmptyListStreamsNothing() {
1200
+ if Fh.skipWithout("streaming") { return }
1201
+ let rec = FhRecorder()
1202
+ rec.reply = { _, _ in Fh.response(200, .list([]), nil) }
1203
+ let h = Fh.make(rec.fetch, (StreamingFeature(), nil))
1204
+ let res = h.op(FhOpSpec(op: "list", path: "/w"))
1205
+ XCTAssertEqual(res.result!.stream!().count, 0)
1206
+ }
1207
+
1042
1208
  func testNonListNotStreamed() {
1043
1209
  if Fh.skipWithout("streaming") { return }
1044
1210
  let h = Fh.make(nil, (StreamingFeature(), nil))
@@ -40,6 +40,9 @@ class Context {
40
40
  entopts: Record<string, any>
41
41
  options: Record<string, any>
42
42
 
43
+ // The clean registry, which holds every registered credential in plain form.
44
+ cleancfg?: any
45
+
43
46
  opmap: Record<string, Operation>
44
47
 
45
48
  response?: Response
@@ -73,6 +76,7 @@ class Context {
73
76
  this.config = getprop(ctxmap, 'config', getprop(basectx, 'config'))
74
77
  this.entopts = getprop(ctxmap, 'entopts', getprop(basectx, 'entopts'))
75
78
  this.options = getprop(ctxmap, 'options', getprop(basectx, 'options'))
79
+ this.cleancfg = getprop(ctxmap, 'cleancfg', getprop(basectx, 'cleancfg'))
76
80
 
77
81
  this.entity = getprop(ctxmap, 'entity', getprop(basectx, 'entity'))
78
82
  this.shared = getprop(ctxmap, 'shared', getprop(basectx, 'shared'))