@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,6 +1,13 @@
1
1
  package feature
2
2
 
3
3
  import (
4
+ "crypto/hmac"
5
+ "crypto/rand"
6
+ "crypto/sha256"
7
+ "encoding/hex"
8
+ "fmt"
9
+ "sort"
10
+ "strconv"
4
11
  "strings"
5
12
 
6
13
  "GOMODULE/core"
@@ -13,6 +20,7 @@ type CacheFeature struct {
13
20
  options map[string]any
14
21
  store map[string]*cacheEntry
15
22
  order []string
23
+ secret []byte
16
24
 
17
25
  // Activity tracking (mirrors the ts client._cache record).
18
26
  Hit int
@@ -22,6 +30,7 @@ type CacheFeature struct {
22
30
 
23
31
  type cacheEntry struct {
24
32
  expiry int64
33
+ scope string
25
34
  snapshot *cacheSnapshot
26
35
  }
27
36
 
@@ -53,6 +62,10 @@ func (f *CacheFeature) Init(ctx *core.Context, options map[string]any) {
53
62
 
54
63
  f.store = map[string]*cacheEntry{}
55
64
  f.order = []string{}
65
+ f.secret = make([]byte, 32)
66
+ if _, err := rand.Read(f.secret); err != nil {
67
+ panic(err)
68
+ }
56
69
 
57
70
  inner := ctx.Utility.Fetcher
58
71
 
@@ -81,10 +94,14 @@ func (f *CacheFeature) through(ctx *core.Context, url string, fetchdef map[strin
81
94
  }
82
95
  }
83
96
  if !cacheable {
84
- return inner(ctx, url, fetchdef)
97
+ res, err := inner(ctx, url, fetchdef)
98
+ if method != "GET" && method != "HEAD" {
99
+ f.invalidate(url)
100
+ }
101
+ return res, err
85
102
  }
86
103
 
87
- key := method + " " + url
104
+ key := method + " " + url + " " + f.digest(fetchdef["headers"])
88
105
  now := foptNow(f.options)()
89
106
 
90
107
  if hit, ok := f.store[key]; ok && hit.expiry > now {
@@ -96,9 +113,14 @@ func (f *CacheFeature) through(ctx *core.Context, url string, fetchdef map[strin
96
113
 
97
114
  if err == nil && f.storable(res) {
98
115
  snapshot := f.snapshot(res)
99
- ttl := foptInt(f.options, "ttl", 5000)
116
+ ttl := cacheLifetime(snapshot.headers, int64(foptInt(f.options, "ttl", 5000)))
117
+ if ttl <= 0 {
118
+ f.Bypass++
119
+ return f.replay(snapshot), nil
120
+ }
121
+ f.drop(key)
100
122
  f.evict()
101
- f.store[key] = &cacheEntry{expiry: now + int64(ttl), snapshot: snapshot}
123
+ f.store[key] = &cacheEntry{expiry: now + ttl, scope: cacheScope(url), snapshot: snapshot}
102
124
  f.order = append(f.order, key)
103
125
  f.Miss++
104
126
  return f.replay(snapshot), nil
@@ -108,6 +130,111 @@ func (f *CacheFeature) through(ctx *core.Context, url string, fetchdef map[strin
108
130
  return res, err
109
131
  }
110
132
 
133
+ func (f *CacheFeature) digest(headers any) string {
134
+ pairs := [][2]string{}
135
+ if hm, ok := headers.(map[string]any); ok {
136
+ for k, v := range hm {
137
+ if v != nil {
138
+ pairs = append(pairs, [2]string{strings.ToLower(k), fmt.Sprint(v)})
139
+ }
140
+ }
141
+ } else if hm, ok := headers.(map[string]string); ok {
142
+ for k, v := range hm {
143
+ pairs = append(pairs, [2]string{strings.ToLower(k), v})
144
+ }
145
+ }
146
+ sort.Slice(pairs, func(i, j int) bool {
147
+ if pairs[i][0] != pairs[j][0] {
148
+ return pairs[i][0] < pairs[j][0]
149
+ }
150
+ return pairs[i][1] < pairs[j][1]
151
+ })
152
+ mac := hmac.New(sha256.New, f.secret)
153
+ for _, p := range pairs {
154
+ mac.Write([]byte(p[0] + ":" + p[1] + "\n"))
155
+ }
156
+ return hex.EncodeToString(mac.Sum(nil))
157
+ }
158
+
159
+ func (f *CacheFeature) invalidate(url string) {
160
+ path := cacheScope(url)
161
+ collection := cacheParent(path)
162
+ for key, entry := range f.store {
163
+ if cacheUnder(entry.scope, path) || entry.scope == collection {
164
+ f.drop(key)
165
+ }
166
+ }
167
+ }
168
+
169
+ func (f *CacheFeature) drop(key string) {
170
+ if _, ok := f.store[key]; !ok {
171
+ return
172
+ }
173
+ delete(f.store, key)
174
+ for i, k := range f.order {
175
+ if k == key {
176
+ f.order = append(f.order[:i], f.order[i+1:]...)
177
+ break
178
+ }
179
+ }
180
+ }
181
+
182
+ // The configured ttl capped by the response's Cache-Control; zero when the
183
+ // response may not be stored.
184
+ func cacheLifetime(headers map[string]any, ttl int64) int64 {
185
+ control := ""
186
+ for k, v := range headers {
187
+ if strings.ToLower(k) == "cache-control" {
188
+ control = strings.ToLower(fmt.Sprint(v))
189
+ }
190
+ }
191
+ life := ttl
192
+ for _, part := range strings.Split(control, ",") {
193
+ directive := strings.TrimSpace(part)
194
+ switch directive {
195
+ case "no-store", "private", "no-cache":
196
+ return 0
197
+ }
198
+ if strings.HasPrefix(directive, "max-age") {
199
+ value := strings.TrimSpace(strings.TrimPrefix(directive, "max-age"))
200
+ if strings.HasPrefix(value, "=") {
201
+ value = strings.Trim(strings.TrimSpace(value[1:]), "\"")
202
+ if secs, err := strconv.ParseInt(value, 10, 64); err == nil && secs >= 0 && secs*1000 < life {
203
+ life = secs * 1000
204
+ }
205
+ }
206
+ }
207
+ }
208
+ return life
209
+ }
210
+
211
+ func cacheScope(url string) string {
212
+ if i := strings.IndexAny(url, "?#"); i >= 0 {
213
+ url = url[:i]
214
+ }
215
+ return strings.TrimRight(url, "/")
216
+ }
217
+
218
+ func cacheParent(scope string) string {
219
+ root := 0
220
+ if scheme := strings.Index(scope, "://"); scheme >= 0 {
221
+ root = strings.Index(scope[scheme+3:], "/")
222
+ if root < 0 {
223
+ return scope
224
+ }
225
+ root += scheme + 3
226
+ }
227
+ cut := strings.LastIndex(scope, "/")
228
+ if cut < root {
229
+ cut = root
230
+ }
231
+ return scope[:cut]
232
+ }
233
+
234
+ func cacheUnder(scope string, prefix string) bool {
235
+ return scope == prefix || strings.HasPrefix(scope, prefix+"/")
236
+ }
237
+
111
238
  // A body the transport could not read as JSON passes through, for the operation to report.
112
239
  // A body that declares another type than JSON passes by, unread.
113
240
  func (f *CacheFeature) storable(res any) bool {
@@ -90,6 +90,20 @@ func (f *MetricsFeature) record(ctx *core.Context, ok bool) {
90
90
 
91
91
  f.bump(f.Total, ok, dur)
92
92
  f.bump(op, ok, dur)
93
+
94
+ if f.options["sink"] != nil {
95
+ ops := map[string]any{}
96
+ for k, b := range f.Ops {
97
+ ops[k] = b.record()
98
+ }
99
+ fsink(f.options["sink"], fclean(ctx, map[string]any{"total": f.Total.record(), "ops": ops}))
100
+ }
101
+ }
102
+
103
+ func (b *MetricsBucket) record() map[string]any {
104
+ return map[string]any{
105
+ "count": b.Count, "ok": b.Ok, "err": b.Err, "totalMs": b.TotalMs, "maxMs": b.MaxMs,
106
+ }
93
107
  }
94
108
 
95
109
  func (f *MetricsFeature) bump(bucket *MetricsBucket, ok bool, dur int64) {
@@ -1,7 +1,9 @@
1
1
  package feature
2
2
 
3
3
  import (
4
+ "net/url"
4
5
  "regexp"
6
+ "strings"
5
7
 
6
8
  vs "github.com/voxgig/struct"
7
9
 
@@ -19,6 +21,85 @@ type PagingFeature struct {
19
21
 
20
22
  var pagingLinkNextRe = regexp.MustCompile(`(?i)<([^>]+)>\s*;\s*rel="?next"?`)
21
23
 
24
+ var pagingOriginRe = regexp.MustCompile(`(?i)^[a-z][a-z0-9+.-]*://[^/?#]*`)
25
+
26
+ // Under the `next` option's default, a URL or an absolute path is a link and
27
+ // anything else a cursor; `cursor` and `url` pin the reading.
28
+ func pagingIsLink(next any, mode string) bool {
29
+ s, ok := next.(string)
30
+ if !ok {
31
+ return false
32
+ }
33
+ return mode == "url" ||
34
+ (mode != "cursor" && (pagingOriginRe.MatchString(s) || strings.HasPrefix(s, "/")))
35
+ }
36
+
37
+ func pagingOrigin(text string) string {
38
+ return strings.ToLower(pagingOriginRe.FindString(text))
39
+ }
40
+
41
+ func pagingForeign(link string, base string) bool {
42
+ origin := pagingOrigin(link)
43
+ return origin != "" && origin != pagingOrigin(base)
44
+ }
45
+
46
+ var pagingSchemeRe = regexp.MustCompile(`(?i)^[a-z][a-z0-9+.-]*:`)
47
+
48
+ // RFC 3986 reference resolution against the URL of the request that
49
+ // returned the link. A link on that URL's origin comes back as its path and
50
+ // query; an absolute link is left as the server wrote it.
51
+ func pagingResolve(link string, requrl string) string {
52
+ if requrl == "" || pagingSchemeRe.MatchString(link) {
53
+ return link
54
+ }
55
+ from, err := url.Parse(requrl)
56
+ if err != nil {
57
+ return link
58
+ }
59
+ ref, err := url.Parse(link)
60
+ if err != nil {
61
+ return link
62
+ }
63
+ out := from.ResolveReference(ref)
64
+ if out.Scheme == from.Scheme && out.Host == from.Host {
65
+ out.Scheme, out.Host, out.User = "", "", nil
66
+ }
67
+ out.Fragment = ""
68
+ return out.String()
69
+ }
70
+
71
+ // The request goes to the link's path and query, on the SDK's own origin.
72
+ func pagingFollow(spec *core.Spec, next string) {
73
+ rest := strings.TrimPrefix(next, pagingOriginRe.FindString(next))
74
+ rest, _, _ = strings.Cut(rest, "#")
75
+ path, rawquery, _ := strings.Cut(rest, "?")
76
+
77
+ query := map[string]any{}
78
+ for _, pair := range strings.Split(rawquery, "&") {
79
+ if pair == "" {
80
+ continue
81
+ }
82
+ key, val, _ := strings.Cut(pair, "=")
83
+ query[pagingUnescape(key)] = pagingUnescape(val)
84
+ }
85
+ for _, key := range spec.AuthQuery {
86
+ query[key] = spec.Query[key]
87
+ }
88
+
89
+ spec.Base = pagingOriginRe.FindString(spec.Base)
90
+ spec.Prefix = ""
91
+ spec.Path = path
92
+ spec.Suffix = ""
93
+ spec.Query = query
94
+ }
95
+
96
+ func pagingUnescape(text string) string {
97
+ if out, err := url.QueryUnescape(text); err == nil {
98
+ return out
99
+ }
100
+ return text
101
+ }
102
+
22
103
  func NewPagingFeature() *PagingFeature {
23
104
  return &PagingFeature{
24
105
  BaseFeature: BaseFeature{
@@ -67,6 +148,8 @@ func (f *PagingFeature) PreRequest(ctx *core.Context) {
67
148
 
68
149
  if cursor, has := paging["cursor"]; has && cursor != nil {
69
150
  spec.Query[cursorParam] = cursor
151
+ } else if next, ok := paging["next"].(string); ok && !pagingForeign(next, spec.Base) {
152
+ pagingFollow(spec, next)
70
153
  } else if spec.Query[pageParam] == nil {
71
154
  // A record written back by PreResult holds the page just fetched as
72
155
  // "page" and the one to fetch as "nextPage", so nextPage wins.
@@ -184,8 +267,12 @@ func (f *PagingFeature) PreResult(ctx *core.Context) {
184
267
 
185
268
  // Body-level signals; snake_case forms are read first so camelCase wins.
186
269
  if bm, ok := body.(map[string]any); ok {
187
- if bm["next"] != nil && paging["next"] == nil {
188
- paging["next"] = bm["next"]
270
+ if bm["next"] != nil {
271
+ if !pagingIsLink(bm["next"], foptStr(f.options, "next", "auto")) {
272
+ paging["cursor"] = bm["next"]
273
+ } else if paging["next"] == nil {
274
+ paging["next"] = bm["next"]
275
+ }
189
276
  }
190
277
  if bm["next_cursor"] != nil {
191
278
  paging["cursor"] = bm["next_cursor"]
@@ -218,6 +305,21 @@ func (f *PagingFeature) PreResult(ctx *core.Context) {
218
305
  }
219
306
  }
220
307
 
308
+ // A link to another origin is recorded, never followed, and ends the walk.
309
+ base := ""
310
+ if ctx.Spec != nil {
311
+ base = ctx.Spec.Base
312
+ } else if b, ok := ctx.Options["base"].(string); ok {
313
+ base = b
314
+ }
315
+ if link, ok := paging["next"].(string); ok && ctx.Spec != nil {
316
+ paging["next"] = pagingResolve(link, ctx.Spec.Url)
317
+ }
318
+ if link, ok := paging["next"].(string); ok && pagingForeign(link, base) {
319
+ paging["foreign"] = link
320
+ delete(paging, "next")
321
+ }
322
+
221
323
  // Cursor presence only INFERS another page. When the server stated the
222
324
  // answer outright — relay's `hasNextPage: false`, or a body `hasMore` —
223
325
  // that wins: a final page normally carries both an end cursor and
@@ -228,6 +330,10 @@ func (f *PagingFeature) PreResult(ctx *core.Context) {
228
330
  paging["hasMore"] = true
229
331
  }
230
332
 
333
+ if paging["foreign"] != nil && paging["cursor"] == nil && paging["nextPage"] == nil {
334
+ paging["hasMore"] = false
335
+ }
336
+
231
337
  result.Paging = paging
232
338
  f.Last = paging
233
339
 
@@ -2,6 +2,7 @@ package feature
2
2
 
3
3
  import (
4
4
  "math"
5
+ "sync"
5
6
 
6
7
  "GOMODULE/core"
7
8
  )
@@ -10,6 +11,7 @@ type RatelimitFeature struct {
10
11
  BaseFeature
11
12
  client *core.ProjectNameSDK
12
13
  options map[string]any
14
+ mu sync.Mutex
13
15
  tokens float64
14
16
  last int64
15
17
 
@@ -51,32 +53,32 @@ func (f *RatelimitFeature) Init(ctx *core.Context, options map[string]any) {
51
53
  }
52
54
 
53
55
  func (f *RatelimitFeature) acquire() {
56
+ if waitMs := f.reserve(); waitMs > 0 {
57
+ foptSleep(f.options)(waitMs)
58
+ }
59
+ }
60
+
61
+ // reserve refills the bucket and takes this call's token under the lock,
62
+ // before any wait: a negative count is the calls already queued, so
63
+ // overlapping calls pace in turn.
64
+ func (f *RatelimitFeature) reserve() int {
54
65
  rate := foptNum(f.options, "rate", 5)
55
66
  burst := foptNum(f.options, "burst", rate)
56
67
 
57
- // Refill according to elapsed time.
68
+ f.mu.Lock()
69
+ defer f.mu.Unlock()
70
+
58
71
  now := foptNow(f.options)()
59
72
  elapsed := now - f.last
60
73
  f.last = now
61
- f.tokens = math.Min(burst, f.tokens+(float64(elapsed)/1000)*rate)
74
+ f.tokens = math.Min(burst, f.tokens+(float64(elapsed)/1000)*rate) - 1
62
75
 
63
- if f.tokens >= 1 {
64
- f.tokens -= 1
65
- return
76
+ if f.tokens >= 0 {
77
+ return 0
66
78
  }
67
79
 
68
- // Not enough tokens: wait for one to accrue, then consume it.
69
- needed := 1 - f.tokens
70
- waitMs := int(math.Ceil((needed / rate) * 1000))
71
- f.track(waitMs)
72
- if waitMs > 0 {
73
- foptSleep(f.options)(waitMs)
74
- }
75
- f.last = foptNow(f.options)()
76
- f.tokens = 0
77
- }
78
-
79
- func (f *RatelimitFeature) track(waitMs int) {
80
+ waitMs := int(math.Ceil((-f.tokens / rate) * 1000))
80
81
  f.Throttled++
81
82
  f.WaitMs += waitMs
83
+ return waitMs
82
84
  }
@@ -3,6 +3,9 @@ package feature
3
3
  import (
4
4
  "math"
5
5
  "math/rand"
6
+ "reflect"
7
+ "strings"
8
+ "time"
6
9
 
7
10
  "GOMODULE/core"
8
11
  )
@@ -80,11 +83,7 @@ func (f *RetryFeature) retryable(res any, err error) bool {
80
83
  if !ok {
81
84
  return false
82
85
  }
83
- statuses := foptList(f.options, "statuses")
84
- if statuses == nil {
85
- statuses = []any{408, 425, 429, 500, 502, 503, 504}
86
- }
87
- for _, s := range statuses {
86
+ for _, s := range f.statuses() {
88
87
  switch n := s.(type) {
89
88
  case int:
90
89
  if n == status {
@@ -103,8 +102,26 @@ func (f *RetryFeature) retryable(res any, err error) bool {
103
102
  return false
104
103
  }
105
104
 
105
+ // statuses is the option as given, of any slice type; only an absent or
106
+ // nil option takes the default, so an empty list retries no status.
107
+ func (f *RetryFeature) statuses() []any {
108
+ raw, has := f.options["statuses"]
109
+ if !has || raw == nil {
110
+ return []any{408, 425, 429, 500, 502, 503, 504}
111
+ }
112
+ v := reflect.ValueOf(raw)
113
+ if v.Kind() != reflect.Slice && v.Kind() != reflect.Array {
114
+ return []any{408, 425, 429, 500, 502, 503, 504}
115
+ }
116
+ out := make([]any, v.Len())
117
+ for i := range out {
118
+ out[i] = v.Index(i).Interface()
119
+ }
120
+ return out
121
+ }
122
+
106
123
  func (f *RetryFeature) backoff(res any, attempt int, minDelay int, maxDelay int, factor float64) int {
107
- // Honour a server-provided Retry-After (seconds) when present.
124
+ // A server-provided Retry-After wins over the computed backoff.
108
125
  if ra, ok := f.retryAfter(res); ok {
109
126
  if ra > maxDelay {
110
127
  return maxDelay
@@ -128,11 +145,66 @@ func (f *RetryFeature) retryAfter(res any) (int, bool) {
128
145
  if !ok {
129
146
  return 0, false
130
147
  }
131
- seconds := fparseInt(v, -1)
132
- if seconds < 0 {
148
+ return fretryAfterMs(v, time.Now().UnixMilli())
149
+ }
150
+
151
+ // fretryAfterMs reads Retry-After by RFC 9110: delay-seconds or an
152
+ // IMF-fixdate; anything else is not a delay.
153
+ func fretryAfterMs(value string, now int64) (int, bool) {
154
+ s := strings.Trim(value, " \t")
155
+ if s != "" && strings.Trim(s, "0123456789") == "" {
156
+ seconds := int64(0)
157
+ for _, c := range s {
158
+ if seconds < math.MaxInt32 {
159
+ seconds = seconds*10 + int64(c-'0')
160
+ }
161
+ }
162
+ if seconds > math.MaxInt32/1000 {
163
+ return math.MaxInt32, true
164
+ }
165
+ return int(seconds * 1000), true
166
+ }
167
+ at, ok := fimfFixdate(s)
168
+ if !ok {
169
+ return 0, false
170
+ }
171
+ if at <= now {
172
+ return 0, true
173
+ }
174
+ if at-now > math.MaxInt32 {
175
+ return math.MaxInt32, true
176
+ }
177
+ return int(at - now), true
178
+ }
179
+
180
+ // fimfFixdate parses "Sun, 06 Nov 1994 08:49:37 GMT" to epoch ms.
181
+ func fimfFixdate(s string) (int64, bool) {
182
+ if len(s) != 29 || s[3:5] != ", " || s[7] != ' ' || s[11] != ' ' || s[16] != ' ' ||
183
+ s[19] != ':' || s[22] != ':' || s[25:] != " GMT" ||
184
+ !strings.Contains(" Mon Tue Wed Thu Fri Sat Sun ", " "+s[0:3]+" ") {
185
+ return 0, false
186
+ }
187
+ month := strings.Index("JanFebMarAprMayJunJulAugSepOctNovDec", s[8:11])
188
+ if month < 0 || month%3 != 0 {
189
+ return 0, false
190
+ }
191
+ num := func(from, to int) int {
192
+ n := 0
193
+ for _, c := range s[from:to] {
194
+ if c < '0' || c > '9' {
195
+ return -1
196
+ }
197
+ n = n*10 + int(c-'0')
198
+ }
199
+ return n
200
+ }
201
+ day, year, hour, min, sec := num(5, 7), num(12, 16), num(17, 19), num(20, 22), num(23, 25)
202
+ if day < 1 || day > 31 || year < 0 || hour < 0 || hour > 23 || min < 0 || min > 59 ||
203
+ sec < 0 || sec > 60 {
133
204
  return 0, false
134
205
  }
135
- return seconds * 1000, true
206
+ at := time.Date(year, time.Month(month/3+1), day, hour, min, sec, 0, time.UTC)
207
+ return at.UnixMilli(), true
136
208
  }
137
209
 
138
210
  func (f *RetryFeature) sleep(ms int) {
@@ -4,22 +4,21 @@ import (
4
4
  "encoding/base64"
5
5
  "encoding/json"
6
6
  "fmt"
7
- "io"
8
- "net/http"
9
7
  neturl "net/url"
10
8
  "strconv"
11
9
  "strings"
12
10
  "sync"
13
- "time"
14
11
 
15
12
  "GOMODULE/core"
16
13
  plugin "GOMODULE/feature/secrets/plugin"
17
14
  sekreto "GOMODULE/feature/secrets/sekreto"
15
+ "GOMODULE/utility"
18
16
  )
19
17
 
20
18
  type SecretsFeature struct {
21
19
  BaseFeature
22
20
  client *core.ProjectNameSDK
21
+ rootctx *core.Context
23
22
  options map[string]any
24
23
 
25
24
  liveopts map[string]any
@@ -41,6 +40,9 @@ type SecretsFeature struct {
41
40
  cred string
42
41
  }
43
42
 
43
+ // Milliseconds the token purchase may take.
44
+ const secretsExchangeTimeout = 30000
45
+
44
46
  type secretsExchange struct {
45
47
  path string
46
48
  method string
@@ -82,6 +84,7 @@ func (f *SecretsFeature) Sekreto() *sekreto.Sekreto {
82
84
 
83
85
  func (f *SecretsFeature) Init(ctx *core.Context, options map[string]any) {
84
86
  f.client = ctx.Client
87
+ f.rootctx = ctx
85
88
  f.options = options
86
89
  f.liveopts = ctx.Options
87
90
  f.Active = foptBool(options, "active", false)
@@ -489,11 +492,15 @@ func (f *SecretsFeature) buyonce() (string, error) {
489
492
  base = strings.TrimRight(base, "/")
490
493
  url := base + "/" + strings.TrimLeft(x.path, "/")
491
494
 
492
- system, _ := options["system"].(map[string]any)
493
- fetch, _ := system["fetch"].(func(string, map[string]any) (map[string]any, error))
494
-
495
- if nil == fetch {
496
- fetch = rawExchangeFetch
495
+ // The SDK's own transport, beneath every feature's wrapper: it holds the
496
+ // test feature's block and the GET-only guard.
497
+ fetch := func(at string, fd map[string]any) (map[string]any, error) {
498
+ res, err := utility.Fetcher(f.rootctx, at, fd)
499
+ if nil != err {
500
+ return nil, err
501
+ }
502
+ out, _ := res.(map[string]any)
503
+ return out, nil
497
504
  }
498
505
 
499
506
  // The body is MARSHALLED, never concatenated: a refresh token (or a
@@ -510,6 +517,8 @@ func (f *SecretsFeature) buyonce() (string, error) {
510
517
  "body": string(bodybytes),
511
518
  // Never followed by the client: a redirect would carry the refresh token on.
512
519
  "redirect": "manual",
520
+ // Its own bound: the timeout feature's wrapper is above this call.
521
+ "timeout": secretsExchangeTimeout,
513
522
  }
514
523
 
515
524
  res, err := fetch(url, fetchdef)
@@ -603,66 +612,3 @@ func secretsOrigin(u *neturl.URL) string {
603
612
  }
604
613
  return scheme + "://" + strings.ToLower(u.Hostname()) + ":" + port
605
614
  }
606
-
607
- // rawExchangeFetch is the token-exchange transport of last resort: plain
608
- // net/http, same result shape the system.fetch seam promises ("status" +
609
- // "json"). It exists so an exchange works with ordinary SDK options -
610
- // requiring a custom transport for the COMMON case would reject every
611
- // live token purchase before a request was made.
612
- func rawExchangeFetch(fullurl string, fetchdef map[string]any) (map[string]any, error) {
613
- method, _ := fetchdef["method"].(string)
614
- if "" == method {
615
- method = "POST"
616
- }
617
-
618
- var body io.Reader
619
- if raw, is := fetchdef["body"].(string); is && "" != raw {
620
- body = strings.NewReader(raw)
621
- }
622
-
623
- req, err := http.NewRequest(method, fullurl, body)
624
- if nil != err {
625
- return nil, err
626
- }
627
- if headers, is := fetchdef["headers"].(map[string]any); is {
628
- for k, v := range headers {
629
- if vs, is := v.(string); is {
630
- req.Header.Set(k, vs)
631
- }
632
- }
633
- }
634
-
635
- client := &http.Client{
636
- Timeout: 30 * time.Second,
637
- CheckRedirect: func(req *http.Request, via []*http.Request) error {
638
- return http.ErrUseLastResponse
639
- },
640
- }
641
- res, err := client.Do(req)
642
- if nil != err {
643
- return nil, err
644
- }
645
- defer res.Body.Close()
646
-
647
- raw, err := io.ReadAll(res.Body)
648
- if nil != err {
649
- return nil, err
650
- }
651
-
652
- headers := map[string]any{}
653
- for k := range res.Header {
654
- headers[strings.ToLower(k)] = res.Header.Get(k)
655
- }
656
-
657
- return map[string]any{
658
- "status": res.StatusCode,
659
- "headers": headers,
660
- "json": func() any {
661
- var out any
662
- if nil != json.Unmarshal(raw, &out) {
663
- return nil
664
- }
665
- return out
666
- },
667
- }, nil
668
- }
@@ -33,8 +33,9 @@ func (f *StreamingFeature) PreResult(ctx *core.Context) {
33
33
  if !f.Active || !f.streamable(ctx) {
34
34
  return
35
35
  }
36
+ // A failed result keeps no stream, so the entity's Stream raises its error.
36
37
  result := ctx.Result
37
- if result == nil {
38
+ if result == nil || result.Err != nil {
38
39
  return
39
40
  }
40
41