@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
@@ -100,24 +100,18 @@ fn acquire(track: *RatelimitTrack, options: Value) void {
100
100
  const rate = sup.fopt_num(options, "rate", 5.0);
101
101
  const burst = sup.fopt_num(options, "burst", rate);
102
102
 
103
- // Refill according to elapsed time.
103
+ // Refill, then reserve this call's token before any wait: a negative
104
+ // count is the calls already queued, so overlapping calls pace in turn.
104
105
  const now = sup.fopt_now(options);
105
106
  const elapsed = now - track.last;
106
107
  track.last = now;
107
- track.tokens = @min(burst, track.tokens + (@as(f64, @floatFromInt(elapsed)) / 1000.0) * rate);
108
+ track.tokens = @min(burst, track.tokens + (@as(f64, @floatFromInt(elapsed)) / 1000.0) * rate) - 1.0;
108
109
 
109
- if (track.tokens >= 1.0) {
110
- track.tokens -= 1.0;
111
- return;
112
- }
110
+ if (track.tokens >= 0.0) return;
113
111
 
114
- // Not enough tokens: wait for one to accrue, then consume it.
115
- const needed = 1.0 - track.tokens;
116
- const wait_ms = @as(i64, @intFromFloat(std.math.ceil((needed / rate) * 1000.0)));
112
+ const wait_ms = @as(i64, @intFromFloat(std.math.ceil((-track.tokens / rate) * 1000.0)));
117
113
  track.throttled += 1;
118
114
  track.wait_ms += wait_ms;
119
115
 
120
116
  if (wait_ms > 0) sup.fopt_sleep(options, wait_ms);
121
- track.last = sup.fopt_now(options);
122
- track.tokens = 0.0;
123
117
  }
@@ -143,9 +143,47 @@ fn backoff(options: Value, res_opt: ?Value, attempt: i64, min_delay: i64, max_de
143
143
 
144
144
  fn retry_after(res: Value) ?i64 {
145
145
  const v = sup.fres_header(res, "retry-after") orelse return null;
146
- const seconds = sup.fparse_int(v, -1);
147
- if (seconds < 0) return null;
148
- return seconds * 1000;
146
+ return retry_after_ms(v, h.now_ms());
147
+ }
148
+
149
+ fn digits(s: []const u8) ?i64 {
150
+ if (s.len == 0) return null;
151
+ var n: i64 = 0;
152
+ for (s) |c| {
153
+ if (c < '0' or c > '9') return null;
154
+ if (n < 1_000_000_000_000) n = n * 10 + @as(i64, c - '0');
155
+ }
156
+ return n;
157
+ }
158
+
159
+ // RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else null.
160
+ pub fn retry_after_ms(value: []const u8, now: i64) ?i64 {
161
+ const s = std.mem.trim(u8, value, " \t");
162
+ if (digits(s)) |seconds| return seconds * 1000;
163
+ if (s.len != 29 or !std.mem.eql(u8, s[3..5], ", ") or s[7] != ' ' or s[11] != ' ' or
164
+ s[16] != ' ' or s[19] != ':' or s[22] != ':' or !std.mem.eql(u8, s[25..29], " GMT")) return null;
165
+ const days = [_][]const u8{ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
166
+ var known = false;
167
+ for (days) |d| {
168
+ if (std.mem.eql(u8, d, s[0..3])) known = true;
169
+ }
170
+ if (!known) return null;
171
+ const mi = std.mem.indexOf(u8, "JanFebMarAprMayJunJulAugSepOctNovDec", s[8..11]) orelse return null;
172
+ if (mi % 3 != 0) return null;
173
+ const day = digits(s[5..7]) orelse return null;
174
+ const year = digits(s[12..16]) orelse return null;
175
+ const hour = digits(s[17..19]) orelse return null;
176
+ const minute = digits(s[20..22]) orelse return null;
177
+ const sec = digits(s[23..25]) orelse return null;
178
+ if (day < 1 or day > 31 or hour > 23 or minute > 59 or sec > 60) return null;
179
+ const m: i64 = @as(i64, @intCast(mi / 3)) + 1;
180
+ const y = if (m <= 2) year - 1 else year;
181
+ const era = @divFloor(y, 400);
182
+ const yoe = y - era * 400;
183
+ const doy = @divTrunc(153 * @mod(m + 9, 12) + 2, 5) + day - 1;
184
+ const doe = yoe * 365 + @divTrunc(yoe, 4) - @divTrunc(yoe, 100) + doy;
185
+ const at = ((((era * 146097 + doe - 719468) * 24 + hour) * 60 + minute) * 60 + sec) * 1000;
186
+ return if (at > now) at - now else 0;
149
187
  }
150
188
 
151
189
  fn track_attempt_ok(track: *RetryTrack, attempt: i64, res: Value, wait: i64) void {
@@ -82,6 +82,7 @@ const h = @import("../core/helpers.zig");
82
82
  const mem = @import("../core/mem.zig");
83
83
  const err = @import("../core/error.zig");
84
84
  const types = @import("../core/types.zig");
85
+ const utility = @import("../core/utility.zig");
85
86
  const sup = @import("support.zig");
86
87
 
87
88
  // NAMED BUILD MODULES, not paths: the vendored trees under feature/secrets/
@@ -857,7 +858,11 @@ fn send(ctx: *Context, sysfetch: Value, url: []const u8, method: []const u8, bod
857
858
  }
858
859
  // No custom transport supplied - the ordinary case (make_options leaves
859
860
  // system.fetch unset, and the SDK's default transport has no HTTP
860
- // client). See raw_exchange_fetch.
861
+ // client). See raw_exchange_fetch. Not the SDK fetcher, as every other
862
+ // target does, for that reason: only its GET-only guard comes first.
863
+ if (utility.getonly_refusal(url, h.jo(&.{.{ "method", h.vstr(method) }}))) |msg| {
864
+ return ctx.fail("fetch_getonly_block", msg);
865
+ }
861
866
  return raw_exchange_fetch(ctx, url, method, body);
862
867
  }
863
868
 
@@ -47,7 +47,9 @@ pub const StreamingFeature = struct {
47
47
 
48
48
  fn pre_result(self: *StreamingFeature, ctx: *Context) void {
49
49
  if (!self.active or !self.streamable(ctx)) return;
50
+ // A failed result keeps no stream, so the entity's stream raises its error.
50
51
  const result = ctx.result orelse return;
52
+ if (result.err != null) return;
51
53
 
52
54
  // The stream producer captures the options plus the result it reads
53
55
  // resdata from. (Rust holds a weak Rc to avoid a reference cycle; with
@@ -25,7 +25,6 @@ pub const TelemetryFeature = struct {
25
25
  active: bool = true,
26
26
  add_opts: Value = .{ .null = {} },
27
27
  options: Value = .{ .null = {} },
28
- seq: i64 = 0,
29
28
 
30
29
  // Activity tracking (mirrors the ts client._telemetry record).
31
30
  spans: std.ArrayList(Value),
@@ -47,13 +46,7 @@ pub const TelemetryFeature = struct {
47
46
  const r = h.call_vfn(idgen, h.vstr(kind));
48
47
  if (r == .string) return r.string;
49
48
  }
50
- // Deterministic-ish sequential id; unique within a client instance.
51
- self.seq += 1;
52
- var buf: std.ArrayList(u8) = .empty;
53
- buf.print(h.A(), "{x:0>4}", .{@as(u64, @intCast(self.seq))}) catch {};
54
- while (buf.items.len < 16) buf.append(h.A(), '0') catch {};
55
- const prefix: []const u8 = if (std.mem.eql(u8, kind, "trace")) "t" else "s";
56
- return std.fmt.allocPrint(h.A(), "{s}{s}", .{ prefix, buf.items }) catch "";
49
+ return if (std.mem.eql(u8, kind, "trace")) random_hex(16) else random_hex(8);
57
50
  }
58
51
 
59
52
  fn close(self: *TelemetryFeature, ctx: *Context, ok: bool) void {
@@ -143,7 +136,6 @@ pub const TelemetryFeature = struct {
143
136
  const self = self_of(p);
144
137
  self.options = options;
145
138
  self.active = sup.fopt_bool(options, "active", false);
146
- self.seq = 0;
147
139
  }
148
140
  fn vdispatch(p: *anyopaque, name: []const u8, ctx: *Context) void {
149
141
  const self = self_of(p);
@@ -166,3 +158,17 @@ pub const TelemetryFeature = struct {
166
158
  .dispatch = vdispatch,
167
159
  };
168
160
  };
161
+
162
+ // W3C trace context: lowercase hex from the platform's random source, never all zeros.
163
+ fn random_hex(comptime nbytes: usize) []const u8 {
164
+ var buf: [nbytes]u8 = undefined;
165
+ while (true) {
166
+ h.IO().randomSecure(&buf) catch h.IO().random(&buf);
167
+ for (buf) |b| {
168
+ if (b != 0) {
169
+ const hex = std.fmt.bytesToHex(buf, .lower);
170
+ return h.A().dupe(u8, &hex) catch "";
171
+ }
172
+ }
173
+ }
174
+ }
@@ -183,16 +183,16 @@ fn respond(ctx: *Context, status: i64, data: Value, extra: []const h.Pair) Value
183
183
  return out;
184
184
  }
185
185
 
186
- fn resolve_match(ctx: *Context, explicit: Value) Value {
187
- if (h.sizeOf(explicit) > 0) return explicit;
188
- const srcs = [_]Value{ ctx.mtch, ctx.data };
189
- for (srcs) |src| {
190
- const v = h.getp(src, "id");
191
- if (!h.is_noval(v) and !h.veq(v, h.vstr("__UNDEFINED__"))) {
192
- return h.jo(&.{.{ "id", v }});
193
- }
186
+ fn held(src: Value, key: []const u8) bool {
187
+ const v = h.getp(src, key);
188
+ return !h.is_noval(v) and !h.veq(v, h.vstr("__UNDEFINED__"));
189
+ }
190
+
191
+ fn names_has(names: Value, key: []const u8) bool {
192
+ for (names.array.data.items) |n| {
193
+ if (n == .string and std.mem.eql(u8, n.string, key)) return true;
194
194
  }
195
- return h.omap();
195
+ return false;
196
196
  }
197
197
 
198
198
  fn point_terminal(p: Value) bool {
@@ -257,22 +257,51 @@ fn build_args(ctx: *Context, args: Value) Value {
257
257
  const qand = h.olist();
258
258
  const q = h.jo(&.{.{ "`$AND`", qand }});
259
259
 
260
- if (args == .object) {
261
- const keys = h.keysof_vec(args);
262
- for (keys) |key| {
263
- const is_id = std.mem.eql(u8, key, "id");
264
- const is_reqd = !h.is_empty(vs.select(h.A(), reqd_params, h.vstr(key)) catch h.olist()) or
265
- !h.is_empty(vs.select(h.A(), reqd_query, h.vstr(key)) catch h.olist());
260
+ const idfrom = h.getpath(&.{ "entity", entname, "id", "from" }, ctx.config);
266
261
 
267
- if (is_id or is_reqd) {
268
- const v = ctx.util().param(ctx, h.vstr(key));
269
- const ka = h.getp(op.alias, key);
262
+ const names = h.olist();
263
+ if (args == .object) {
264
+ for (h.keysof_vec(args)) |key| names.array.append(h.vstr(key)) catch {};
265
+ }
270
266
 
271
- const qor = h.ja(&.{h.jo(&.{.{ key, v }})});
272
- if (ka == .string) qor.array.append(h.jo(&.{.{ ka.string, v }})) catch {};
267
+ // With no id in the call, the entity's held id (or composite parts) stands in.
268
+ if (!held(args, "id")) {
269
+ var parts = h.getpath(&.{ "entity", entname, "id", "parts" }, ctx.config);
270
+ if (parts != .array) {
271
+ parts = if (std.mem.eql(u8, opname, "list")) h.olist() else h.ja(&.{h.vstr("id")});
272
+ }
273
+ for (parts.array.data.items) |part| {
274
+ if (part != .string) continue;
275
+ if (!names_has(names, part.string) and (held(ctx.mtch, part.string) or held(ctx.data, part.string))) {
276
+ names.array.append(part) catch {};
277
+ }
278
+ }
279
+ }
273
280
 
274
- qand.array.append(h.jo(&.{.{ "`$OR`", qor }})) catch {};
281
+ for (names.array.data.items) |name| {
282
+ const key = name.string;
283
+ const is_id = std.mem.eql(u8, key, "id");
284
+ const is_reqd = !h.is_empty(vs.select(h.A(), reqd_params, h.vstr(key)) catch h.olist()) or
285
+ !h.is_empty(vs.select(h.A(), reqd_query, h.vstr(key)) catch h.olist());
286
+
287
+ if (is_id or is_reqd) {
288
+ const v = ctx.util().param(ctx, h.vstr(key));
289
+ const ka = h.getp(op.alias, key);
290
+
291
+ const qor = h.ja(&.{h.jo(&.{.{ key, v }})});
292
+ if (ka == .string) qor.array.append(h.jo(&.{.{ ka.string, v }})) catch {};
293
+
294
+ // An alternative, never a replacement: a seed keeping the
295
+ // parameter flat is still found.
296
+ const kf = h.getp(idfrom, key);
297
+ if (kf == .string and !std.mem.eql(u8, kf.string, key)) {
298
+ var nest = v;
299
+ var segs = std.mem.splitBackwardsScalar(u8, kf.string, '.');
300
+ while (segs.next()) |seg| nest = h.jo(&.{.{ seg, nest }});
301
+ qor.array.append(nest) catch {};
275
302
  }
303
+
304
+ qand.array.append(h.jo(&.{.{ "`$OR`", qor }})) catch {};
276
305
  }
277
306
  }
278
307
 
@@ -299,8 +328,7 @@ fn test_fetch(entity: Value, ctx: *Context, _: []const u8, _: Value) err.E!Value
299
328
  };
300
329
 
301
330
  if (std.mem.eql(u8, op.name, "load")) {
302
- const m = resolve_match(ctx, ctx.reqmatch);
303
- const args = build_args(ctx, m);
331
+ const args = build_args(ctx, ctx.reqmatch);
304
332
  const found = vs.select(h.A(), entmap, args) catch h.olist();
305
333
  const ent = h.get_elem(found, h.vnum(0), h.vnull());
306
334
  if (h.is_noval(ent)) {
@@ -320,18 +348,10 @@ fn test_fetch(entity: Value, ctx: *Context, _: []const u8, _: Value) err.E!Value
320
348
  return respond(ctx, 200, h.clone(found), &.{});
321
349
  } else if (std.mem.eql(u8, op.name, "update") or std.mem.eql(u8, op.name, "patch")) {
322
350
  const reqdata = ctx.reqdata;
323
- var update_match = h.omap();
324
- if (reqdata == .object) {
325
- const idv = h.getp(reqdata, "id");
326
- if (!h.is_noval(idv)) h.setp(update_match, "id", idv);
327
- if (h.getp(op.alias, "id") == .string) {
328
- const alias_id = h.getp(op.alias, "id").string;
329
- const av = h.getp(reqdata, alias_id);
330
- if (!h.is_noval(av)) h.setp(update_match, alias_id, av);
331
- }
332
- }
333
- if (h.sizeOf(update_match) == 0) update_match = resolve_match(ctx, h.omap());
334
- const args = build_args(ctx, update_match);
351
+ // `$body` travels on the wire alone; the record is the rest.
352
+ const rec = if (reqdata == .object) h.clone(reqdata) else h.omap();
353
+ h.del_prop(rec, h.vstr("$body"));
354
+ const args = build_args(ctx, rec);
335
355
  const found = vs.select(h.A(), entmap, args) catch h.olist();
336
356
  var ent = h.get_elem(found, h.vnum(0), h.vnull());
337
357
  if (h.is_noval(ent)) {
@@ -339,16 +359,12 @@ fn test_fetch(entity: Value, ctx: *Context, _: []const u8, _: Value) err.E!Value
339
359
  return respond(ctx, 404, h.vnull(), &.{.{ "statusText", h.vstr("Not found") }});
340
360
  }
341
361
  if (ent == .object and reqdata == .object) {
342
- // `$body` travels on the wire alone; the record is the rest.
343
- const rec = h.clone(reqdata);
344
- h.del_prop(rec, h.vstr("$body"));
345
362
  ent = h.merge(h.ja(&.{ ent, rec }));
346
363
  }
347
364
  h.del_prop(ent, h.vstr("$KEY"));
348
365
  return respond(ctx, 200, h.clone(ent), &.{});
349
366
  } else if (std.mem.eql(u8, op.name, "remove")) {
350
- const m = resolve_match(ctx, ctx.reqmatch);
351
- const args = build_args(ctx, m);
367
+ const args = build_args(ctx, ctx.reqmatch);
352
368
  const found = vs.select(h.A(), entmap, args) catch h.olist();
353
369
  const ent = h.get_elem(found, h.vnum(0), h.vnull());
354
370
  if (ent == .object) {
@@ -40,6 +40,36 @@ fn replyPaging(_: i64, _: *sdk.Context, _: Value) fh.E!Value {
40
40
  }),
41
41
  );
42
42
  }
43
+ fn replyNextCursor(n: i64, _: *sdk.Context, _: Value) fh.E!Value {
44
+ const next = if (n == 1) h.vstr("c3") else if (n == 2) h.vstr("c6") else vnull();
45
+ return fh.fh_response(200, h.jo(&.{.{ "next", next }}), vnull());
46
+ }
47
+ fn replyNextUrl(n: i64, _: *sdk.Context, _: Value) fh.E!Value {
48
+ const next = if (n == 1) h.vstr("http://api.test/v2/w?cursor=c%2F3&limit=3") else if (n == 2) h.vstr("/v2/w?cursor=c6") else vnull();
49
+ return fh.fh_response(200, h.jo(&.{.{ "next", next }}), vnull());
50
+ }
51
+ fn replyLinkNext(n: i64, _: *sdk.Context, _: Value) fh.E!Value {
52
+ const headers = if (n == 1) h.jo(&.{.{ "link", h.vstr("<http://api.test/w?after=b3>; rel=\"next\"") }}) else if (n == 2) h.jo(&.{.{ "link", h.vstr("</w?after=b6>; rel=\"next\"") }}) else vnull();
53
+ return fh.fh_response(200, h.ja(&.{}), headers);
54
+ }
55
+ fn replyQueryOnlyLink(n: i64, _: *sdk.Context, _: Value) fh.E!Value {
56
+ const headers = if (n == 1) h.jo(&.{.{ "link", h.vstr("</v1/items?page=2>; rel=\"next\"") }}) else if (n == 2) h.jo(&.{.{ "link", h.vstr("<?page=3>; rel=\"next\"") }}) else vnull();
57
+ return fh.fh_response(200, h.ja(&.{}), headers);
58
+ }
59
+ fn replyPathRelativeLink(n: i64, _: *sdk.Context, _: Value) fh.E!Value {
60
+ const headers = if (n == 1) h.jo(&.{.{ "link", h.vstr("</v1/items?page=2>; rel=\"next\"") }}) else if (n == 2) h.jo(&.{.{ "link", h.vstr("<more?page=3>; rel=\"next\"") }}) else vnull();
61
+ return fh.fh_response(200, h.ja(&.{}), headers);
62
+ }
63
+ fn replyForeignLink(_: i64, _: *sdk.Context, _: Value) fh.E!Value {
64
+ return fh.fh_response(200, h.ja(&.{}), h.jo(&.{.{ "link", h.vstr("<https://elsewhere.test/w?after=b3>; rel=\"next\"") }}));
65
+ }
66
+ fn replySlashCursor(n: i64, _: *sdk.Context, _: Value) fh.E!Value {
67
+ const next = if (n == 1) h.vstr("/c3") else vnull();
68
+ return fh.fh_response(200, h.jo(&.{.{ "next", next }}), vnull());
69
+ }
70
+ fn replyEmptyList(_: i64, _: *sdk.Context, _: Value) fh.E!Value {
71
+ return fh.fh_response(200, h.ja(&.{}), vnull());
72
+ }
43
73
  fn replyCursor(_: i64, _: *sdk.Context, _: Value) fh.E!Value {
44
74
  return fh.fh_response(
45
75
  200,
@@ -488,6 +518,71 @@ test "feature cache: inactive does not wrap" {
488
518
  try testing.expect(rec.count() == 2);
489
519
  }
490
520
 
521
+ var cache_control: []const u8 = "";
522
+
523
+ fn replyControl(_: i64, _: *sdk.Context, _: Value) fh.E!Value {
524
+ return fh.fh_response(200, h.jo(&.{.{ "ok", h.vbool(true) }}), h.jo(&.{.{ "Cache-Control", h.vstr(cache_control) }}));
525
+ }
526
+
527
+ test "feature cache: keys on request headers" {
528
+ if (!fh.fh_present(&.{"cache"})) return;
529
+ const rec = fh.Recorder.new(null);
530
+ const f = sdk.CacheFeature.make();
531
+ const hh = fh.fh_make(rec.fetcher(), &.{.{ .feat = f, .options = h.jo(&.{.{ "ttl", h.vnum(10000) }}) }});
532
+ _ = hh.op(.{ .op = "load", .path = "/w/1", .headers = h.jo(&.{.{ "x-tenant", h.vstr("tenant-a") }}) });
533
+ _ = hh.op(.{ .op = "load", .path = "/w/1", .headers = h.jo(&.{.{ "X-Tenant", h.vstr("tenant-b") }}) });
534
+ try testing.expect(rec.count() == 2);
535
+ _ = hh.op(.{ .op = "load", .path = "/w/1", .headers = h.jo(&.{.{ "x-tenant", h.vstr("tenant-b") }}) });
536
+ try testing.expect(rec.count() == 2);
537
+ }
538
+
539
+ test "feature cache: a write drops its collection" {
540
+ if (!fh.fh_present(&.{"cache"})) return;
541
+ const rec = fh.Recorder.new(null);
542
+ const f = sdk.CacheFeature.make();
543
+ const cf: *sdk.CacheFeature = @ptrCast(@alignCast(f.ptr));
544
+ const hh = fh.fh_make(rec.fetcher(), &.{.{ .feat = f, .options = h.jo(&.{.{ "ttl", h.vnum(10000) }}) }});
545
+ const paths = [_][]const u8{ "/w/1", "/w", "/w/1/part", "/other/1", "/w/2" };
546
+ for (paths) |p| _ = hh.op(.{ .op = "load", .path = p });
547
+ _ = hh.op(.{ .op = "update", .method = "PUT", .path = "/w/1" });
548
+ for (paths) |p| _ = hh.op(.{ .op = "load", .path = p });
549
+ try testing.expect(rec.count() == 9);
550
+ try testing.expect(cf.track.hit == 2);
551
+ }
552
+
553
+ test "feature cache: Cache-Control prevents storing" {
554
+ if (!fh.fh_present(&.{"cache"})) return;
555
+ const controls = [_][]const u8{ "no-store", "private", "No-Cache", "max-age=60, private" };
556
+ for (controls) |control| {
557
+ cache_control = control;
558
+ const rec = fh.Recorder.new(replyControl);
559
+ const f = sdk.CacheFeature.make();
560
+ const hh = fh.fh_make(rec.fetcher(), &.{.{ .feat = f, .options = h.jo(&.{.{ "ttl", h.vnum(10000) }}) }});
561
+ _ = hh.op(.{ .op = "load", .path = "/w" });
562
+ _ = hh.op(.{ .op = "load", .path = "/w" });
563
+ try testing.expect(rec.count() == 2);
564
+ }
565
+ }
566
+
567
+ test "feature cache: max-age caps the ttl" {
568
+ if (!fh.fh_present(&.{"cache"})) return;
569
+ cache_control = "max-age=1";
570
+ const clock = fh.FhClock.new();
571
+ const rec = fh.Recorder.new(replyControl);
572
+ const f = sdk.CacheFeature.make();
573
+ const hh = fh.fh_make(rec.fetcher(), &.{.{ .feat = f, .options = h.jo(&.{
574
+ .{ "ttl", h.vnum(10000) },
575
+ .{ "now", clock.now_fn() },
576
+ }) }});
577
+ _ = hh.op(.{ .op = "load", .path = "/w" });
578
+ clock.advance(500);
579
+ _ = hh.op(.{ .op = "load", .path = "/w" });
580
+ try testing.expect(rec.count() == 1);
581
+ clock.advance(600);
582
+ _ = hh.op(.{ .op = "load", .path = "/w" });
583
+ try testing.expect(rec.count() == 2);
584
+ }
585
+
491
586
  // =====================================================================
492
587
  // idempotency
493
588
  // =====================================================================
@@ -952,6 +1047,63 @@ test "feature paging: body cursor and explicit cursor" {
952
1047
  try testing.expect(h.veq(h.getp(paging, "hasMore"), h.vbool(true)));
953
1048
  }
954
1049
 
1050
+ // The documented hasMore loop, one request per page.
1051
+ fn pagingWalk(reply: fh.ReplyFn, want: []const []const u8) !void {
1052
+ _ = try pagingWalkWith(reply, vnull(), want);
1053
+ }
1054
+
1055
+ fn pagingWalkWith(reply: fh.ReplyFn, options: Value, want: []const []const u8) !Value {
1056
+ const rec = fh.Recorder.new(reply);
1057
+ const f = sdk.PagingFeature.make();
1058
+ const hh = fh.fh_make(rec.fetcher(), &.{.{ .feat = f, .options = options }});
1059
+ const paging = h.omap();
1060
+ const ctrl = h.jo(&.{.{ "paging", paging }});
1061
+ _ = hh.op(.{ .op = "list", .path = "/w", .ctrl = ctrl });
1062
+ while (h.veq(h.getp(paging, "hasMore"), h.vbool(true)) and rec.calls.items.len < 4) {
1063
+ _ = hh.op(.{ .op = "list", .path = "/w", .ctrl = ctrl });
1064
+ }
1065
+ try testing.expectEqual(want.len, rec.calls.items.len);
1066
+ for (want, 0..) |url, i| try testing.expectEqualStrings(url, fh.rec_url(rec, i));
1067
+ try testing.expect(h.veq(h.getp(paging, "hasMore"), h.vbool(false)));
1068
+ return paging;
1069
+ }
1070
+
1071
+ test "feature paging: a link to another origin ends the walk" {
1072
+ if (!fh.fh_present(&.{"paging"})) return;
1073
+ const paging = try pagingWalkWith(replyForeignLink, vnull(), &.{"http://api.test/w?page=1"});
1074
+ try testing.expect(h.veq(h.getp(paging, "foreign"), h.vstr("https://elsewhere.test/w?after=b3")));
1075
+ }
1076
+
1077
+ test "feature paging: next cursor sends a value starting with a slash as the cursor" {
1078
+ if (!fh.fh_present(&.{"paging"})) return;
1079
+ _ = try pagingWalkWith(replySlashCursor, h.jo(&.{.{ "next", h.vstr("cursor") }}), &.{ "http://api.test/w?page=1", "http://api.test/w?cursor=%2Fc3" });
1080
+ }
1081
+
1082
+ test "feature paging: a body next is sent back as the cursor" {
1083
+ if (!fh.fh_present(&.{"paging"})) return;
1084
+ try pagingWalk(replyNextCursor, &.{ "http://api.test/w?page=1", "http://api.test/w?cursor=c3", "http://api.test/w?cursor=c6" });
1085
+ }
1086
+
1087
+ test "feature paging: a body next URL is the next request" {
1088
+ if (!fh.fh_present(&.{"paging"})) return;
1089
+ try pagingWalk(replyNextUrl, &.{ "http://api.test/w?page=1", "http://api.test/v2/w?cursor=c%2F3&limit=3", "http://api.test/v2/w?cursor=c6" });
1090
+ }
1091
+
1092
+ test "feature paging: a Link next URL is the next request" {
1093
+ if (!fh.fh_present(&.{"paging"})) return;
1094
+ try pagingWalk(replyLinkNext, &.{ "http://api.test/w?page=1", "http://api.test/w?after=b3", "http://api.test/w?after=b6" });
1095
+ }
1096
+
1097
+ test "feature paging: a query-only Link keeps the path" {
1098
+ if (!fh.fh_present(&.{"paging"})) return;
1099
+ try pagingWalk(replyQueryOnlyLink, &.{ "http://api.test/w?page=1", "http://api.test/v1/items?page=2", "http://api.test/v1/items?page=3" });
1100
+ }
1101
+
1102
+ test "feature paging: a path-relative Link resolves against the request" {
1103
+ if (!fh.fh_present(&.{"paging"})) return;
1104
+ try pagingWalk(replyPathRelativeLink, &.{ "http://api.test/w?page=1", "http://api.test/v1/items?page=2", "http://api.test/v1/more?page=3" });
1105
+ }
1106
+
955
1107
  test "feature paging: non-list not paged" {
956
1108
  if (!fh.fh_present(&.{"paging"})) return;
957
1109
  const rec = fh.Recorder.new(null);
@@ -1007,6 +1159,28 @@ test "feature streaming: batches with chunksize" {
1007
1159
  try testing.expect(h.veq(h.ja(batches), want));
1008
1160
  }
1009
1161
 
1162
+ test "feature streaming: a failed result keeps no stream" {
1163
+ if (!fh.fh_present(&.{"streaming"})) return;
1164
+ const rec = fh.Recorder.new(reply503);
1165
+ const f = sdk.StreamingFeature.make();
1166
+ const sf: *sdk.StreamingFeature = @ptrCast(@alignCast(f.ptr));
1167
+ const hh = fh.fh_make(rec.fetcher(), &.{.{ .feat = f, .options = vnull() }});
1168
+ const res = hh.op(.{ .op = "list", .path = "/w" });
1169
+ try testing.expect(!res.result.?.streaming);
1170
+ try testing.expect(res.result.?.stream == null);
1171
+ try testing.expect(sf.opened == 0);
1172
+ }
1173
+
1174
+ test "feature streaming: an empty list streams nothing" {
1175
+ if (!fh.fh_present(&.{"streaming"})) return;
1176
+ const rec = fh.Recorder.new(replyEmptyList);
1177
+ const f = sdk.StreamingFeature.make();
1178
+ const hh = fh.fh_make(rec.fetcher(), &.{.{ .feat = f, .options = vnull() }});
1179
+ const res = hh.op(.{ .op = "list", .path = "/w" });
1180
+ const sf = res.result.?.stream orelse unreachable;
1181
+ try testing.expectEqual(@as(usize, 0), sf.call(sf.ctx).len);
1182
+ }
1183
+
1010
1184
  test "feature streaming: non-list not streamed" {
1011
1185
  if (!fh.fh_present(&.{"streaming"})) return;
1012
1186
  const f = sdk.StreamingFeature.make();
@@ -116,6 +116,7 @@ test "primary utility exists" {
116
116
  try testing.expect(utility.prepare_headers(ctx) == .object);
117
117
  try testing.expect(util.prepare_query_util(ctx) == .object);
118
118
  try testing.expect(util.prepare_params_util(ctx) == .object);
119
+ ctx.options = h.omap();
119
120
  try testing.expect((try utility.make_options(ctx)) == .object);
120
121
  _ = utility.clean(ctx, h.vstr("x"));
121
122
  }
@@ -143,6 +144,7 @@ test "primary make_options basic" {
143
144
  const client = baseClient();
144
145
  const utility = client.get_utility();
145
146
  const ctx = makeTestCtx(client, utility);
147
+ ctx.options = h.omap();
146
148
  const opts = try utility.make_options(ctx);
147
149
  try testing.expect(opts == .object);
148
150
  try testing.expect(!h.is_noval(h.getp(opts, "base")));
@@ -3,7 +3,7 @@
3
3
  "package": 1
4
4
  },
5
5
  "name": "@voxgig/sdkgen",
6
- "version": "4.50.0",
6
+ "version": "4.52.0",
7
7
  "provides": {
8
8
  "target": [
9
9
  "c",
@@ -64,8 +64,11 @@ shows exactly what \`direct\` would send.
64
64
 
65
65
  const TS_EXPLAIN = (fence: string): LangExplain => ({
66
66
  featureKind: `Features are the extension mechanism. A feature is an object with a
67
- \`hooks\` map. Each hook key is a pipeline stage name, and the value is
68
- a function that receives the context.
67
+ \`name\`, an \`init\` method, and a method named after each pipeline stage
68
+ it hooks; each method receives the context. A feature passed in \`extend\`
69
+ is installed, and its hooks fire, only while it is active:
70
+ \`feature.<name>.active\` decides, and where the options do not set it, the
71
+ feature's own \`active\` flag does.
69
72
 
70
73
  `,
71
74
  entityState: ({ eName, eLower, op, arg, matchIdF, idLit }) => `Entity instances are stateful. After a successful \`${op}\`, the entity
@@ -81,12 +81,12 @@ ${f.title}.
81
81
 
82
82
  `)
83
83
 
84
- if (0 < f.options.length) {
84
+ if (0 < f.options.length || 0 < f.extras.length) {
85
85
  ReadmeFeatureOptions({ feature: f })
86
86
  }
87
87
 
88
88
  Content(`Set \`feature.${f.name}.active\` to enable it${
89
- 0 < f.options.length ? ', then override any of the options above' : ''}.
89
+ 0 < f.options.length || 0 < f.extras.length ? ', then override any of the options above' : ''}.
90
90
 
91
91
  `)
92
92
 
@@ -104,15 +104,30 @@ activated earlier.
104
104
  const ReadmeFeatureOptions = cmp(function ReadmeFeatureOptions(props: any) {
105
105
  const f: FeatureDoc = props.feature
106
106
 
107
- Content(`| Option | Default |
107
+ if (0 < f.options.length) {
108
+ Content(`| Option | Default |
108
109
  |---|---|
109
110
  `)
110
- for (const o of f.options) {
111
- Content(`| \`${o.name}\` | ${o.code} |
111
+ for (const o of f.options) {
112
+ Content(`| \`${o.name}\` | ${o.code} |
113
+ `)
114
+ }
115
+ Content(`
112
116
  `)
113
117
  }
114
- Content(`
118
+
119
+ // An option with no default still changes what the feature does.
120
+ if (0 < f.extras.length) {
121
+ Content(`| Option | Type |
122
+ |---|---|
115
123
  `)
124
+ for (const o of f.extras) {
125
+ Content(`| \`${o.name}\` | ${o.type} |
126
+ `)
127
+ }
128
+ Content(`
129
+ `)
130
+ }
116
131
  })
117
132
 
118
133
 
@@ -38,7 +38,7 @@ function featureOptionSpec(feat: any): Record<string, any> {
38
38
  const config = (feat && feat.config) || {}
39
39
  const spec: Record<string, any> = {}
40
40
 
41
- if (true !== config.strict) {
41
+ if (false === config.strict) {
42
42
  spec[S_OPEN] = true
43
43
  }
44
44
 
@@ -73,7 +73,7 @@ function optionSpec(model: any, targetname?: string): Record<string, any> {
73
73
  const feature: Record<string, any> = {
74
74
  [S_CHILD]: {
75
75
  [S_OPEN]: true,
76
- active: false,
76
+ active: optional(sentinel('BOOLEAN')),
77
77
  },
78
78
  }
79
79