@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
@@ -1,18 +1,19 @@
1
- // Response caching for safe (read) requests (mirrors feature/cache.rs).
2
- // Wraps the active transport and serves a fresh cached snapshot instead of
3
- // hitting the network when the same method+URL was fetched within `ttl` ms
4
- // (default: 5000). Only successful (2xx) responses to cacheable methods
5
- // (default: GET) are stored, keyed by method+URL. The cache is bounded (`max`
6
- // entries, default 256, oldest evicted first) and every hit/miss/bypass is
7
- // counted. Bodies are snapshotted on capture so both the current caller and
8
- // later hits can re-read the JSON body repeatedly.
1
+ // Response caching for safe (read) requests, per client (mirrors
2
+ // feature/cache.rs): see the features reference for the key, the write
3
+ // invalidation and the Cache-Control rules.
4
+
5
+ // C has no HMAC: SipHash-2-4 under a random per-client key separates header
6
+ // sets within one store without holding a header value. It is not a
7
+ // cryptographic commitment.
9
8
 
10
9
  #include "sdk.h"
11
10
 
12
11
  #include <ctype.h>
12
+ #include <stdint.h>
13
13
  #include <stdio.h>
14
14
  #include <stdlib.h>
15
15
  #include <string.h>
16
+ #include <time.h>
16
17
 
17
18
  typedef struct {
18
19
  // string-keyed store (voxgig_map, insertion-ordered) mapping
@@ -20,6 +21,7 @@ typedef struct {
20
21
  voxgig_value* store;
21
22
  // FIFO insertion order of keys (may contain duplicates, mirrors rust Vec).
22
23
  voxgig_value* order;
24
+ uint8_t secret[16];
23
25
 
24
26
  // Activity tracking (mirrors the ts client._cache record).
25
27
  int64_t hit;
@@ -86,6 +88,218 @@ static bool option_list_match(voxgig_value* options, const char* key,
86
88
  return false;
87
89
  }
88
90
 
91
+ #define SIP_ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b))))
92
+ #define SIP_ROUND(v0, v1, v2, v3) do { \
93
+ v0 += v1; v1 = SIP_ROTL(v1, 13); v1 ^= v0; v0 = SIP_ROTL(v0, 32); \
94
+ v2 += v3; v3 = SIP_ROTL(v3, 16); v3 ^= v2; \
95
+ v0 += v3; v3 = SIP_ROTL(v3, 21); v3 ^= v0; \
96
+ v2 += v1; v1 = SIP_ROTL(v1, 17); v1 ^= v2; v2 = SIP_ROTL(v2, 32); } while (0)
97
+
98
+ static uint64_t sip_le64(const uint8_t* p) {
99
+ uint64_t v = 0;
100
+ for (int i = 7; i >= 0; i--) v = (v << 8) | p[i];
101
+ return v;
102
+ }
103
+
104
+ uint64_t feature_cache_siphash24(const uint8_t key[16], const uint8_t* in, size_t len) {
105
+ uint64_t k0 = sip_le64(key), k1 = sip_le64(key + 8);
106
+ uint64_t v0 = 0x736f6d6570736575ULL ^ k0, v1 = 0x646f72616e646f6dULL ^ k1;
107
+ uint64_t v2 = 0x6c7967656e657261ULL ^ k0, v3 = 0x7465646279746573ULL ^ k1;
108
+ size_t full = len - (len % 8);
109
+ for (size_t i = 0; i < full; i += 8) {
110
+ uint64_t m = sip_le64(in + i);
111
+ v3 ^= m;
112
+ SIP_ROUND(v0, v1, v2, v3);
113
+ SIP_ROUND(v0, v1, v2, v3);
114
+ v0 ^= m;
115
+ }
116
+ uint64_t b = ((uint64_t)len) << 56;
117
+ for (size_t i = 0; i < len % 8; i++) b |= ((uint64_t)in[full + i]) << (8 * i);
118
+ v3 ^= b;
119
+ SIP_ROUND(v0, v1, v2, v3);
120
+ SIP_ROUND(v0, v1, v2, v3);
121
+ v0 ^= b;
122
+ v2 ^= 0xff;
123
+ for (int i = 0; i < 4; i++) SIP_ROUND(v0, v1, v2, v3);
124
+ return v0 ^ v1 ^ v2 ^ v3;
125
+ }
126
+
127
+ // The system's random source where it has one; otherwise rand(), which is
128
+ // not a cryptographic generator.
129
+ static void cache_secret(uint8_t out[16]) {
130
+ size_t got = 0;
131
+ FILE* f = fopen("/dev/urandom", "rb");
132
+ if (f) {
133
+ got = fread(out, 1, 16, f);
134
+ fclose(f);
135
+ }
136
+ uint64_t mix = (uint64_t)time(NULL) ^ (uint64_t)(uintptr_t)out;
137
+ for (size_t i = got; i < 16; i++) out[i] = (uint8_t)((rand() ^ (int)(mix >> (i % 8 * 8))) & 0xff);
138
+ }
139
+
140
+ static char* header_text(voxgig_value* v) {
141
+ char b[64];
142
+ if (voxgig_is_string(v)) return strdup(voxgig_as_string(v));
143
+ if (voxgig_is_int(v)) {
144
+ snprintf(b, sizeof(b), "%lld", (long long)voxgig_as_int(v));
145
+ return strdup(b);
146
+ }
147
+ if (voxgig_is_double(v)) {
148
+ double d = voxgig_as_double(v);
149
+ if (d == (double)(long long)d) snprintf(b, sizeof(b), "%lld", (long long)d);
150
+ else snprintf(b, sizeof(b), "%g", d);
151
+ return strdup(b);
152
+ }
153
+ if (voxgig_is_bool(v)) return strdup(voxgig_as_bool(v) ? "true" : "false");
154
+ return NULL;
155
+ }
156
+
157
+ typedef struct {
158
+ char* name;
159
+ char* value;
160
+ } HeaderPair;
161
+
162
+ static int pair_cmp(const void* a, const void* b) {
163
+ const HeaderPair* x = (const HeaderPair*)a;
164
+ const HeaderPair* y = (const HeaderPair*)b;
165
+ int c = strcmp(x->name, y->name);
166
+ return c != 0 ? c : strcmp(x->value, y->value);
167
+ }
168
+
169
+ static char* digest(const uint8_t secret[16], voxgig_value* headers) {
170
+ size_t n = 0, total = 0;
171
+ HeaderPair* pairs = NULL;
172
+ if (voxgig_is_map(headers)) {
173
+ voxgig_map* hm = voxgig_as_map(headers);
174
+ pairs = (HeaderPair*)calloc(hm->len + 1, sizeof(HeaderPair));
175
+ for (size_t i = 0; i < hm->len; i++) {
176
+ char* value = header_text(hm->entries[i].value);
177
+ if (!value) continue;
178
+ pairs[n].name = str_lower(hm->entries[i].key);
179
+ pairs[n].value = value;
180
+ total += strlen(pairs[n].name) + strlen(value) + 2;
181
+ n++;
182
+ }
183
+ qsort(pairs, n, sizeof(HeaderPair), pair_cmp);
184
+ }
185
+ char* text = (char*)calloc(total + 1, 1);
186
+ size_t at = 0;
187
+ for (size_t i = 0; i < n; i++) {
188
+ at += (size_t)sprintf(text + at, "%s:%s\n", pairs[i].name, pairs[i].value);
189
+ free(pairs[i].name);
190
+ free(pairs[i].value);
191
+ }
192
+ free(pairs);
193
+ char* hex = (char*)malloc(17);
194
+ snprintf(hex, 17, "%016llx", (unsigned long long)feature_cache_siphash24(secret, (const uint8_t*)text, at));
195
+ free(text);
196
+ return hex;
197
+ }
198
+
199
+ static char* url_scope(const char* url) {
200
+ size_t n = strcspn(url, "?#");
201
+ while (n > 0 && url[n - 1] == '/') n--;
202
+ char* r = (char*)malloc(n + 1);
203
+ memcpy(r, url, n);
204
+ r[n] = '\0';
205
+ return r;
206
+ }
207
+
208
+ static char* url_parent(const char* scope) {
209
+ const char* scheme = strstr(scope, "://");
210
+ size_t root = 0;
211
+ if (scheme) {
212
+ const char* slash = strchr(scheme + 3, '/');
213
+ if (!slash) return strdup(scope);
214
+ root = (size_t)(slash - scope);
215
+ }
216
+ const char* last = strrchr(scope, '/');
217
+ size_t cut = last ? (size_t)(last - scope) : 0;
218
+ if (cut < root) cut = root;
219
+ char* r = (char*)malloc(cut + 1);
220
+ memcpy(r, scope, cut);
221
+ r[cut] = '\0';
222
+ return r;
223
+ }
224
+
225
+ static bool scope_under(const char* scope, const char* prefix) {
226
+ size_t n = strlen(prefix);
227
+ return strncmp(scope, prefix, n) == 0 && (scope[n] == '\0' || scope[n] == '/');
228
+ }
229
+
230
+ static void drop_entry(CacheTrack* t, const char* key) {
231
+ voxgig_list* order = voxgig_as_list(t->order);
232
+ for (size_t i = order->len; i > 0; i--) {
233
+ if (strcmp(voxgig_as_string(order->items[i - 1]), key) == 0) voxgig_list_erase(order, i - 1);
234
+ }
235
+ voxgig_map_erase(voxgig_as_map(t->store), key);
236
+ }
237
+
238
+ static void invalidate(CacheTrack* t, const char* url) {
239
+ char* path = url_scope(url);
240
+ char* collection = url_parent(path);
241
+ voxgig_map* store = voxgig_as_map(t->store);
242
+ for (size_t i = store->len; i > 0; i--) {
243
+ const char* scope = get_str(store->entries[i - 1].value, "scope");
244
+ if (scope && (scope_under(scope, path) || strcmp(scope, collection) == 0)) {
245
+ char* key = strdup(store->entries[i - 1].key);
246
+ drop_entry(t, key);
247
+ free(key);
248
+ }
249
+ }
250
+ free(collection);
251
+ free(path);
252
+ }
253
+
254
+ // The configured ttl capped by the response's Cache-Control; zero when the
255
+ // response may not be stored.
256
+ static int64_t lifetime(voxgig_value* headers, int64_t ttl) {
257
+ char* control = NULL;
258
+ if (voxgig_is_map(headers)) {
259
+ voxgig_map* hm = voxgig_as_map(headers);
260
+ for (size_t i = 0; i < hm->len; i++) {
261
+ if (strcasecmp(hm->entries[i].key, "cache-control") == 0) {
262
+ free(control);
263
+ char* raw = header_text(hm->entries[i].value);
264
+ control = raw ? str_lower(raw) : NULL;
265
+ free(raw);
266
+ }
267
+ }
268
+ }
269
+ int64_t life = ttl;
270
+ if (!control) return life;
271
+ for (char* part = control; part; ) {
272
+ char* comma = strchr(part, ',');
273
+ if (comma) *comma = '\0';
274
+ char* next = comma ? comma + 1 : NULL;
275
+ while (isspace((unsigned char)*part)) part++;
276
+ size_t n = strlen(part);
277
+ while (n > 0 && isspace((unsigned char)part[n - 1])) part[--n] = '\0';
278
+ if (strcmp(part, "no-store") == 0 || strcmp(part, "private") == 0 ||
279
+ strcmp(part, "no-cache") == 0) {
280
+ free(control);
281
+ return 0;
282
+ }
283
+ if (strncmp(part, "max-age", 7) == 0) {
284
+ char* v = part + 7;
285
+ while (isspace((unsigned char)*v)) v++;
286
+ if (*v != '=') { part = next; continue; }
287
+ v++;
288
+ while (isspace((unsigned char)*v)) v++;
289
+ if (*v == '"') v++;
290
+ char* end = v;
291
+ while (isdigit((unsigned char)*end)) end++;
292
+ if (end != v && end - v < 16 && (*end == '\0' || (*end == '"' && end[1] == '\0'))) {
293
+ int64_t secs = (int64_t)strtoll(v, NULL, 10);
294
+ if (secs * 1000 < life) life = secs * 1000;
295
+ }
296
+ }
297
+ part = next;
298
+ }
299
+ free(control);
300
+ return life;
301
+ }
302
+
89
303
  // A body the transport could not read as JSON passes through, for the operation to report.
90
304
  static bool storable(voxgig_value* res) {
91
305
  int64_t status;
@@ -182,13 +396,18 @@ static voxgig_value* through(Fetcher* self, Context* ctx, const char* url,
182
396
  static const char* MDEF[] = {"GET"};
183
397
  bool cacheable = option_list_match(options, "methods", method, MDEF, 1, true);
184
398
  if (!cacheable) {
399
+ bool safe = strcmp(method, "GET") == 0 || strcmp(method, "HEAD") == 0;
185
400
  free(method);
186
- return st->inner->fn(st->inner, ctx, url, fetchdef, err);
401
+ voxgig_value* passed = st->inner->fn(st->inner, ctx, url, fetchdef, err);
402
+ if (!safe) invalidate(track, url);
403
+ return passed;
187
404
  }
188
405
 
189
- size_t klen = strlen(method) + 1 + strlen(url) + 1;
406
+ char* hdigest = digest(track->secret, getp(fetchdef, "headers"));
407
+ size_t klen = strlen(method) + 1 + strlen(url) + 1 + strlen(hdigest) + 1;
190
408
  char* key = (char*)malloc(klen);
191
- snprintf(key, klen, "%s %s", method, url);
409
+ snprintf(key, klen, "%s %s %s", method, url, hdigest);
410
+ free(hdigest);
192
411
  free(method);
193
412
 
194
413
  int64_t now = fopt_now_call(options);
@@ -210,11 +429,21 @@ static voxgig_value* through(Fetcher* self, Context* ctx, const char* url,
210
429
 
211
430
  if (!e && storable(out) && json(out)) {
212
431
  voxgig_value* snap = snapshot(out);
213
- int64_t ttl = fopt_int(options, "ttl", 5000);
432
+ int64_t ttl = lifetime(getp(snap, "headers"), fopt_int(options, "ttl", 5000));
433
+ if (ttl <= 0) {
434
+ track->bypass += 1;
435
+ free(key);
436
+ *err = NULL;
437
+ return replay(snap);
438
+ }
439
+ drop_entry(track, key);
214
440
  evict(track, options);
215
- voxgig_value* newentry = cmap(2,
441
+ char* scope = url_scope(url);
442
+ voxgig_value* newentry = cmap(3,
216
443
  "expiry", v_num((double)(now + ttl)),
444
+ "scope", v_str(scope),
217
445
  "snap", snap);
446
+ free(scope);
218
447
  voxgig_map_set(voxgig_as_map(track->store), key, newentry);
219
448
  voxgig_list_push(voxgig_as_list(track->order), v_str(key));
220
449
  track->miss += 1;
@@ -244,6 +473,7 @@ static void cache_init(Feature* f, Context* ctx, voxgig_value* options) {
244
473
  st->inner = util->fetcher;
245
474
  st->options = options;
246
475
  st->track = cf->track;
476
+ cache_secret(cf->track->secret);
247
477
 
248
478
  Fetcher* wrapped = (Fetcher*)calloc(1, sizeof(Fetcher));
249
479
  wrapped->fn = through;
@@ -76,6 +76,8 @@ static char* dot_join(const char* a, const char* b) {
76
76
  return s;
77
77
  }
78
78
 
79
+ static voxgig_value* metrics_track(Feature* f);
80
+
79
81
  static void metrics_record(MetricsFeature* mf, Context* ctx, bool ok) {
80
82
  // Record once per operation: the missing start marker makes a second call
81
83
  // (PreDone followed by PreUnexpected on failure) a no-op.
@@ -97,6 +99,11 @@ static void metrics_record(MetricsFeature* mf, Context* ctx, bool ok) {
97
99
 
98
100
  bump(&mf->total, ok, dur);
99
101
  bump(ops_entry(mf, key), ok, dur);
102
+
103
+ voxgig_value* sink = getp(mf->options, "sink");
104
+ if (voxgig_is_func(sink)) {
105
+ call_vfn(sink, clean_util(ctx, metrics_track((Feature*)mf)));
106
+ }
100
107
  }
101
108
 
102
109
  static void metrics_pre_point(MetricsFeature* mf, Context* ctx) {
@@ -15,6 +15,7 @@
15
15
  #include <stdlib.h>
16
16
  #include <stdio.h>
17
17
  #include <string.h>
18
+ #include <strings.h>
18
19
 
19
20
  typedef struct {
20
21
  Feature base;
@@ -195,6 +196,208 @@ static void paging_graphql_pre_request(PagingFeature* pf, Context* ctx,
195
196
  }
196
197
  }
197
198
 
199
+ // The length of a URL's scheme and authority, or zero when it has none.
200
+ static size_t paging_origin_len(const char* text) {
201
+ if (!text || !isalpha((unsigned char)text[0])) return 0;
202
+ size_t i = 1;
203
+ while (isalnum((unsigned char)text[i]) || text[i] == '+' || text[i] == '.' || text[i] == '-') i++;
204
+ if (strncmp(text + i, "://", 3) != 0) return 0;
205
+ i += 3;
206
+ while (text[i] && text[i] != '/' && text[i] != '?' && text[i] != '#') i++;
207
+ return i;
208
+ }
209
+
210
+ // Under the `next` option's default, a URL or an absolute path is a link and
211
+ // anything else a cursor; `cursor` and `url` pin the reading.
212
+ static bool paging_is_link(voxgig_value* next, const char* mode) {
213
+ if (!voxgig_is_string(next)) return false;
214
+ if (strcmp(mode, "url") == 0) return true;
215
+ if (strcmp(mode, "cursor") == 0) return false;
216
+ const char* s = voxgig_as_string(next);
217
+ return paging_origin_len(s) > 0 || s[0] == '/';
218
+ }
219
+
220
+ static bool paging_foreign(const char* link, const char* base) {
221
+ size_t n = paging_origin_len(link);
222
+ if (n == 0) return false;
223
+ size_t b = paging_origin_len(base ? base : "");
224
+ return n != b || strncasecmp(link, base, n) != 0;
225
+ }
226
+
227
+ static char* paging_unescape(const char* text, size_t len) {
228
+ char* out = (char*)malloc(len + 1);
229
+ size_t o = 0;
230
+ for (size_t i = 0; i < len; i++) {
231
+ if (text[i] == '+') {
232
+ out[o++] = ' ';
233
+ } else if (text[i] == '%' && i + 2 < len &&
234
+ isxdigit((unsigned char)text[i + 1]) && isxdigit((unsigned char)text[i + 2])) {
235
+ char hex[3] = { text[i + 1], text[i + 2], 0 };
236
+ out[o++] = (char)strtol(hex, NULL, 16);
237
+ i += 2;
238
+ } else {
239
+ out[o++] = text[i];
240
+ }
241
+ }
242
+ out[o] = 0;
243
+ return out;
244
+ }
245
+
246
+ static void paging_set_str(char** slot, const char* text, size_t len) {
247
+ char* d = (char*)malloc(len + 1);
248
+ memcpy(d, text, len);
249
+ d[len] = 0;
250
+ free(*slot);
251
+ *slot = d;
252
+ }
253
+
254
+ static char* paging_copy(const char* text, size_t len) {
255
+ char* d = (char*)malloc(len + 1);
256
+ memcpy(d, text, len);
257
+ d[len] = 0;
258
+ return d;
259
+ }
260
+
261
+ static bool paging_has_scheme(const char* text) {
262
+ if (!isalpha((unsigned char)text[0])) return false;
263
+ size_t i = 1;
264
+ while (isalnum((unsigned char)text[i]) || text[i] == '+' || text[i] == '.' || text[i] == '-') i++;
265
+ return text[i] == ':';
266
+ }
267
+
268
+ typedef struct { const char* p; size_t n; } PagingSeg;
269
+
270
+ // RFC 3986 section 5.2.4.
271
+ static char* paging_remove_dots(const char* path) {
272
+ size_t len = strlen(path);
273
+ bool abs = path[0] == '/';
274
+ PagingSeg* segs = (PagingSeg*)malloc(sizeof(PagingSeg) * (len + 1));
275
+ size_t ns = 0;
276
+ const char* p = path + (abs ? 1 : 0);
277
+ for (;;) {
278
+ const char* e = strchr(p, '/');
279
+ size_t n = e ? (size_t)(e - p) : strlen(p);
280
+ bool dot = n == 1 && p[0] == '.';
281
+ bool dotdot = n == 2 && p[0] == '.' && p[1] == '.';
282
+ if (dot || dotdot) {
283
+ if (dotdot && ns > 0) ns--;
284
+ if (!e) segs[ns++] = (PagingSeg){ p, 0 };
285
+ } else {
286
+ segs[ns++] = (PagingSeg){ p, n };
287
+ }
288
+ if (!e) break;
289
+ p = e + 1;
290
+ }
291
+ char* out = (char*)malloc(len + 2);
292
+ size_t o = 0;
293
+ if (abs) out[o++] = '/';
294
+ for (size_t i = 0; i < ns; i++) {
295
+ if (i > 0) out[o++] = '/';
296
+ memcpy(out + o, segs[i].p, segs[i].n);
297
+ o += segs[i].n;
298
+ }
299
+ out[o] = 0;
300
+ free(segs);
301
+ return out;
302
+ }
303
+
304
+ // RFC 3986 reference resolution against the URL of the request that returned
305
+ // the link, by hand: C has no resolver. A link on that URL's origin comes back
306
+ // as its path and query; an absolute link is left as it is. The caller frees.
307
+ static char* paging_resolve(const char* link, const char* url) {
308
+ if (!url || !url[0] || paging_has_scheme(link)) return paging_copy(link, strlen(link));
309
+ size_t ln = strcspn(link, "#");
310
+ size_t on = paging_origin_len(url);
311
+ if (ln >= 2 && link[0] == '/' && link[1] == '/') {
312
+ size_t sn = on ? strcspn(url, ":") + 1 : 0;
313
+ char* out = (char*)malloc(sn + ln + 1);
314
+ memcpy(out, url, sn);
315
+ memcpy(out + sn, link, ln);
316
+ out[sn + ln] = 0;
317
+ return out;
318
+ }
319
+ const char* from = url + on;
320
+ size_t fn = strcspn(from, "#");
321
+ size_t bp = strcspn(from, "?#");
322
+ size_t rp = strcspn(link, "?#");
323
+ const char* q = NULL;
324
+ size_t qn = 0;
325
+ if (rp < ln) {
326
+ q = link + rp + 1;
327
+ qn = ln - rp - 1;
328
+ }
329
+ char* path;
330
+ if (rp == 0) {
331
+ path = paging_copy(from, bp);
332
+ if (!q && bp < fn) {
333
+ q = from + bp + 1;
334
+ qn = fn - bp - 1;
335
+ }
336
+ } else {
337
+ size_t dn = 0;
338
+ if (link[0] != '/') {
339
+ for (size_t k = bp; k > 0; k--) {
340
+ if (from[k - 1] == '/') {
341
+ dn = k;
342
+ break;
343
+ }
344
+ }
345
+ }
346
+ char* merged = (char*)malloc(dn + rp + 1);
347
+ memcpy(merged, from, dn);
348
+ memcpy(merged + dn, link, rp);
349
+ merged[dn + rp] = 0;
350
+ path = paging_remove_dots(merged);
351
+ free(merged);
352
+ }
353
+ size_t size = strlen(path) + qn + 3;
354
+ char* out = (char*)malloc(size);
355
+ snprintf(out, size, "%s%s%s%.*s", '/' == path[0] ? "" : "/", path, q ? "?" : "", (int)qn, q ? q : "");
356
+ free(path);
357
+ return out;
358
+ }
359
+
360
+ // The request goes to the link's path and query, on the SDK's own origin.
361
+ static void paging_follow(Spec* spec, const char* next) {
362
+ const char* rest = next + paging_origin_len(next);
363
+ size_t restlen = strcspn(rest, "#");
364
+ size_t pathlen = strcspn(rest, "?#");
365
+
366
+ voxgig_value* query = voxgig_new_map();
367
+ const char* q = rest + pathlen;
368
+ const char* end = rest + restlen;
369
+ if (q < end && *q == '?') q++;
370
+ while (q < end) {
371
+ size_t pairlen = 0;
372
+ while (q + pairlen < end && q[pairlen] != '&') pairlen++;
373
+ if (pairlen > 0) {
374
+ size_t keylen = 0;
375
+ while (keylen < pairlen && q[keylen] != '=') keylen++;
376
+ char* key = paging_unescape(q, keylen);
377
+ char* val = keylen < pairlen ? paging_unescape(q + keylen + 1, pairlen - keylen - 1)
378
+ : paging_unescape("", 0);
379
+ setp(query, key, v_str(val));
380
+ free(key);
381
+ free(val);
382
+ }
383
+ q += pairlen + 1;
384
+ }
385
+ if (v_is_list(spec->authquery)) {
386
+ voxgig_list* names = voxgig_as_list(spec->authquery);
387
+ for (size_t i = 0; i < names->len; i++) {
388
+ if (!voxgig_is_string(names->items[i])) continue;
389
+ const char* key = voxgig_as_string(names->items[i]);
390
+ setp(query, key, getp(spec->query, key));
391
+ }
392
+ }
393
+
394
+ paging_set_str(&spec->base, spec->base, paging_origin_len(spec->base));
395
+ paging_set_str(&spec->prefix, "", 0);
396
+ paging_set_str(&spec->path, rest, pathlen);
397
+ paging_set_str(&spec->suffix, "", 0);
398
+ spec->query = query;
399
+ }
400
+
198
401
  static void paging_pre_request(PagingFeature* pf, Context* ctx) {
199
402
  voxgig_value* options = pf->options;
200
403
  if (!pf->active || !is_list_op(options, ctx->op->name)) return;
@@ -223,8 +426,12 @@ static void paging_pre_request(PagingFeature* pf, Context* ctx) {
223
426
  }
224
427
 
225
428
  voxgig_value* cursor = getp(paging, "cursor");
429
+ voxgig_value* next = getp(paging, "next");
226
430
  if (!v_is_noval(cursor) && !v_is_null(cursor)) {
227
431
  setp(query, cursor_param, cursor);
432
+ } else if (voxgig_is_string(next) && !paging_foreign(voxgig_as_string(next), ctx->spec->base)) {
433
+ paging_follow(ctx->spec, voxgig_as_string(next));
434
+ query = ctx->spec->query;
228
435
  } else if (v_is_noval(getp(query, page_param))) {
229
436
  // A record written back by pre_result holds the page just fetched as
230
437
  // "page" and the one to fetch as "nextPage", so nextPage wins.
@@ -304,8 +511,12 @@ static void paging_pre_result(PagingFeature* pf, Context* ctx) {
304
511
  // Body-level signals; snake_case forms are read first so camelCase wins.
305
512
  if (voxgig_is_map(body)) {
306
513
  voxgig_value* next = getp(body, "next");
307
- if (!v_is_noval(next) && !v_is_null(next) && v_is_noval(getp(paging, "next"))) {
308
- setp(paging, "next", next);
514
+ if (!v_is_noval(next) && !v_is_null(next)) {
515
+ if (!paging_is_link(next, fopt_str(options, "next", "auto"))) {
516
+ setp(paging, "cursor", next);
517
+ } else if (v_is_noval(getp(paging, "next"))) {
518
+ setp(paging, "next", next);
519
+ }
309
520
  }
310
521
  voxgig_value* snake_cursor = getp(body, "next_cursor");
311
522
  if (!v_is_noval(snake_cursor) && !v_is_null(snake_cursor)) {
@@ -337,6 +548,19 @@ static void paging_pre_result(PagingFeature* pf, Context* ctx) {
337
548
  }
338
549
  }
339
550
 
551
+ // A link to another origin is recorded, never followed, and ends the walk.
552
+ const char* base = ctx->spec ? ctx->spec->base : get_str(ctx->options, "base");
553
+ if (ctx->spec && voxgig_is_string(getp(paging, "next"))) {
554
+ char* resolved = paging_resolve(voxgig_as_string(getp(paging, "next")), ctx->spec->url);
555
+ setp(paging, "next", v_str(resolved));
556
+ free(resolved);
557
+ }
558
+ voxgig_value* link = getp(paging, "next");
559
+ if (voxgig_is_string(link) && paging_foreign(voxgig_as_string(link), base)) {
560
+ setp(paging, "foreign", link);
561
+ setp(paging, "next", v_undef());
562
+ }
563
+
340
564
  // Cursor presence only INFERS another page. When the server stated the
341
565
  // answer outright — relay's `hasNextPage: false`, or a body `hasMore` —
342
566
  // that wins: a final page normally carries both an end cursor and
@@ -351,6 +575,11 @@ static void paging_pre_result(PagingFeature* pf, Context* ctx) {
351
575
  setp(paging, "hasMore", v_bool(true));
352
576
  }
353
577
 
578
+ if (!v_is_noval(getp(paging, "foreign")) && v_is_noval(getp(paging, "cursor")) &&
579
+ v_is_noval(getp(paging, "nextPage"))) {
580
+ setp(paging, "hasMore", v_bool(false));
581
+ }
582
+
354
583
  ctx->result->paging = paging;
355
584
  pf->last = paging;
356
585
 
@@ -38,29 +38,25 @@ static void acquire(RatelimitTrack* t, voxgig_value* options) {
38
38
  double rate = fopt_num(options, "rate", 5.0);
39
39
  double burst = fopt_num(options, "burst", rate);
40
40
 
41
- // Refill according to elapsed time.
41
+ // Refill, then reserve this call's token before any wait: a negative
42
+ // count is the calls already queued, so overlapping calls pace in turn.
42
43
  int64_t now = fopt_now_call(options);
43
44
  int64_t elapsed = now - t->last;
44
45
  t->last = now;
45
46
  double refilled = t->tokens + ((double)elapsed / 1000.0) * rate;
46
- t->tokens = burst < refilled ? burst : refilled; // burst.min(...)
47
+ t->tokens = (burst < refilled ? burst : refilled) - 1.0;
47
48
 
48
- if (t->tokens >= 1.0) {
49
- t->tokens -= 1.0;
49
+ if (t->tokens >= 0.0) {
50
50
  return;
51
51
  }
52
52
 
53
- // Not enough tokens: wait for one to accrue, then consume it.
54
- double needed = 1.0 - t->tokens;
55
- int64_t wait_ms = (int64_t)ceil((needed / rate) * 1000.0);
53
+ int64_t wait_ms = (int64_t)ceil((-t->tokens / rate) * 1000.0);
56
54
  t->throttled += 1;
57
55
  t->wait_ms += wait_ms;
58
56
 
59
57
  if (wait_ms > 0) {
60
58
  fopt_sleep_call(options, wait_ms);
61
59
  }
62
- t->last = fopt_now_call(options);
63
- t->tokens = 0.0;
64
60
  }
65
61
 
66
62
  static voxgig_value* ratelimit_fetch(Fetcher* self, Context* ctx, const char* url,