@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,21 +1,23 @@
1
1
  # ProjectName SDK cache feature
2
2
 
3
3
  from __future__ import annotations
4
+ import hashlib
5
+ import hmac
6
+ import re
7
+ import secrets
4
8
  import time
5
9
 
6
10
  from projectname_sdk.feature.base_feature import ProjectNameBaseFeature
7
11
  from projectname_sdk.utility.media import header_value, is_json_media
8
12
 
9
13
 
10
- # Response caching for safe (read) requests. Wraps the active transport and
11
- # serves a fresh cached snapshot instead of hitting the network when the
12
- # same method+URL was fetched within `ttl` ms (default 5000). Only
13
- # successful (2xx) responses to cacheable methods (default: GET) are
14
- # stored, keyed by method+URL. The cache is bounded (`max` entries, default
15
- # 256, oldest evicted first) and every hit/miss is recorded on
16
- # `client._cache` for inspection. Response bodies are snapshotted on
17
- # capture so both the current caller and later hits can read the JSON body
18
- # repeatedly.
14
+ SAFE_METHODS = ("GET", "HEAD")
15
+ UNSTORED = ("no-store", "private", "no-cache")
16
+ MAX_AGE = re.compile(r'^max-age\s*=\s*"?(\d+)"?$')
17
+
18
+
19
+ # Response caching for safe (read) requests, per client: see the features
20
+ # reference for the key, the write invalidation and the Cache-Control rules.
19
21
  class ProjectNameCacheFeature(ProjectNameBaseFeature):
20
22
  def __init__(self):
21
23
  super().__init__()
@@ -25,6 +27,7 @@ class ProjectNameCacheFeature(ProjectNameBaseFeature):
25
27
  self.client = None
26
28
  self.options = {}
27
29
  self.store = {}
30
+ self.secret = b""
28
31
 
29
32
  def init(self, ctx, options):
30
33
  self.client = ctx.client
@@ -39,6 +42,7 @@ class ProjectNameCacheFeature(ProjectNameBaseFeature):
39
42
  return
40
43
 
41
44
  self.store = {}
45
+ self.secret = secrets.token_bytes(32)
42
46
 
43
47
  utility = ctx.utility
44
48
  inner = utility.fetcher
@@ -55,9 +59,15 @@ class ProjectNameCacheFeature(ProjectNameBaseFeature):
55
59
  methods = self.options.get("methods") or ["GET"]
56
60
 
57
61
  if method not in methods:
58
- return inner(ctx, url, fetchdef)
62
+ if method in SAFE_METHODS:
63
+ return inner(ctx, url, fetchdef)
64
+ try:
65
+ return inner(ctx, url, fetchdef)
66
+ finally:
67
+ self._invalidate(url)
59
68
 
60
- key = method + " " + url
69
+ headers = fetchdef.get("headers") if isinstance(fetchdef, dict) else None
70
+ key = method + " " + url + " " + self._digest(headers)
61
71
  now = self._now()
62
72
  hit = self.store.get(key)
63
73
 
@@ -69,15 +79,36 @@ class ProjectNameCacheFeature(ProjectNameBaseFeature):
69
79
 
70
80
  if err is None and self._cacheable(res):
71
81
  snapshot = self._snapshot(res)
72
- ttl = 5000 if self.options.get("ttl") is None else self.options.get("ttl")
82
+ ttl = cache_lifetime(snapshot["headers"],
83
+ 5000 if self.options.get("ttl") is None else self.options.get("ttl"))
84
+ if ttl <= 0:
85
+ self._track("bypass")
86
+ return self._replay(snapshot), None
87
+ self.store.pop(key, None)
73
88
  self._evict()
74
- self.store[key] = {"expiry": now + ttl, "snapshot": snapshot}
89
+ self.store[key] = {"expiry": now + ttl, "scope": url_scope(url), "snapshot": snapshot}
75
90
  self._track("miss")
76
91
  return self._replay(snapshot), None
77
92
 
78
93
  self._track("bypass")
79
94
  return res, err
80
95
 
96
+ def _digest(self, headers):
97
+ pairs = []
98
+ if isinstance(headers, dict):
99
+ for name, val in headers.items():
100
+ if val is not None:
101
+ pairs.append((str(name).lower(), val if isinstance(val, str) else str(val)))
102
+ text = "".join(name + ":" + val + "\n" for name, val in sorted(pairs))
103
+ return hmac.new(self.secret, text.encode("utf-8"), hashlib.sha256).hexdigest()
104
+
105
+ def _invalidate(self, url):
106
+ path = url_scope(url)
107
+ collection = url_parent(path)
108
+ for key in [k for k, e in self.store.items()
109
+ if scope_under(e["scope"], path) or e["scope"] == collection]:
110
+ del self.store[key]
111
+
81
112
  # A body the transport could not read as JSON passes through, for the operation to report.
82
113
  def _cacheable(self, res):
83
114
  if not isinstance(res, dict) or res.get("unreadable") is True:
@@ -143,3 +174,38 @@ class ProjectNameCacheFeature(ProjectNameBaseFeature):
143
174
  track = {"hit": 0, "miss": 0, "bypass": 0}
144
175
  client._cache = track
145
176
  track[kind] += 1
177
+
178
+
179
+ # The configured ttl capped by the response's Cache-Control; zero when the
180
+ # response may not be stored.
181
+ def cache_lifetime(headers, ttl):
182
+ control = ""
183
+ for name, val in (headers or {}).items():
184
+ if str(name).lower() == "cache-control":
185
+ control = str(val)
186
+ life = ttl
187
+ for part in control.lower().split(","):
188
+ directive = part.strip()
189
+ if directive in UNSTORED:
190
+ return 0
191
+ age = MAX_AGE.match(directive)
192
+ if age is not None:
193
+ life = min(life, int(age.group(1)) * 1000)
194
+ return life
195
+
196
+
197
+ def url_scope(url):
198
+ return re.split(r"[?#]", str(url), maxsplit=1)[0].rstrip("/")
199
+
200
+
201
+ def url_parent(scope):
202
+ scheme = scope.find("://")
203
+ root = 0 if scheme < 0 else scope.find("/", scheme + 3)
204
+ if root < 0:
205
+ return scope
206
+ cut = scope.rfind("/")
207
+ return scope[:max(cut, root)]
208
+
209
+
210
+ def scope_under(scope, prefix):
211
+ return scope == prefix or scope.startswith(prefix + "/")
@@ -79,6 +79,13 @@ class ProjectNameMetricsFeature(ProjectNameBaseFeature):
79
79
  self._bump(metrics["total"], ok, dur)
80
80
  self._bump(op_bucket, ok, dur)
81
81
 
82
+ sink = self.options.get("sink")
83
+ if callable(sink):
84
+ try:
85
+ sink(ctx.utility.clean(ctx, metrics))
86
+ except Exception:
87
+ pass
88
+
82
89
  def _bump(self, bucket, ok, dur):
83
90
  bucket["count"] += 1
84
91
  bucket["ok" if ok else "err"] += 1
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  import re
5
+ from urllib.parse import unquote_plus, urljoin, urlsplit, urlunsplit
5
6
 
6
7
  from projectname_sdk.utility.voxgig_struct import voxgig_struct as vs
7
8
 
@@ -17,6 +18,71 @@ from projectname_sdk.feature.base_feature import ProjectNameBaseFeature
17
18
  # paging takes priority (used by auto-iteration). Parameter names
18
19
  # (`pageParam`/`limitParam`/`cursorParam`), `startPage` and page size
19
20
  # (`limit`) are configurable.
21
+ _ORIGIN = re.compile(r"^[a-z][a-z0-9+.-]*://[^/?#]*", re.IGNORECASE)
22
+
23
+
24
+ # Under the `next` option's default, a URL or an absolute path is a link and
25
+ # anything else a cursor; `cursor` and `url` pin the reading.
26
+ def _is_link(nxt, mode):
27
+ if not isinstance(nxt, str):
28
+ return False
29
+ return "url" == mode or ("cursor" != mode and (
30
+ _ORIGIN.match(nxt) is not None or nxt.startswith("/")))
31
+
32
+
33
+ def _origin(text):
34
+ m = _ORIGIN.match(text) if isinstance(text, str) else None
35
+ return m.group(0).lower() if m else ""
36
+
37
+
38
+ def _foreign(link, base):
39
+ origin = _origin(link)
40
+ return "" != origin and origin != _origin(base)
41
+
42
+
43
+ _SCHEME = re.compile(r"^[a-z][a-z0-9+.-]*:", re.IGNORECASE)
44
+
45
+
46
+ # RFC 3986 reference resolution against the URL of the request that
47
+ # returned the link. A link on that URL's origin comes back as its path and
48
+ # query; an absolute link is left as the server wrote it.
49
+ def _resolve(link, url):
50
+ if not isinstance(url, str) or "" == url or _SCHEME.match(link):
51
+ return link
52
+ try:
53
+ out = urlsplit(urljoin(url, link))
54
+ frm = urlsplit(url)
55
+ except ValueError:
56
+ return link
57
+ if (out.scheme, out.netloc) == (frm.scheme, frm.netloc):
58
+ return urlunsplit(("", "", out.path, out.query, ""))
59
+ return urlunsplit((out.scheme, out.netloc, out.path, out.query, ""))
60
+
61
+
62
+ # The request goes to the link's path and query, on the SDK's own origin.
63
+ def _follow(spec, nxt):
64
+ link = _ORIGIN.match(nxt)
65
+ rest = nxt[link.end():] if link else nxt
66
+ rest = rest.split("#", 1)[0]
67
+ path, _, rawquery = rest.partition("?")
68
+
69
+ query = {}
70
+ for pair in rawquery.split("&"):
71
+ if "" == pair:
72
+ continue
73
+ key, _, val = pair.partition("=")
74
+ query[unquote_plus(key)] = unquote_plus(val)
75
+ for key in (spec.authquery or []):
76
+ query[key] = spec.query.get(key)
77
+
78
+ origin = _ORIGIN.match(str(spec.base or ""))
79
+ spec.base = origin.group(0) if origin else ""
80
+ spec.prefix = ""
81
+ spec.path = path
82
+ spec.suffix = ""
83
+ spec.query = query
84
+
85
+
20
86
  class ProjectNamePagingFeature(ProjectNameBaseFeature):
21
87
  def __init__(self):
22
88
  super().__init__()
@@ -65,6 +131,8 @@ class ProjectNamePagingFeature(ProjectNameBaseFeature):
65
131
 
66
132
  if paging.get("cursor") is not None:
67
133
  spec.query[cursor_param] = paging["cursor"]
134
+ elif isinstance(paging.get("next"), str) and not _foreign(paging["next"], spec.base):
135
+ _follow(spec, paging["next"])
68
136
  elif spec.query.get(page_param) is None:
69
137
  # A record written back by PreResult holds the page just fetched
70
138
  # as "page" and the one to fetch as "nextPage", so nextPage wins.
@@ -129,6 +197,7 @@ class ProjectNamePagingFeature(ProjectNameBaseFeature):
129
197
  "nextPage": self._num(self._header(headers, "x-next-page")),
130
198
  "next": None,
131
199
  "cursor": None,
200
+ "foreign": None,
132
201
  "hasMore": False,
133
202
  }
134
203
 
@@ -173,7 +242,10 @@ class ProjectNamePagingFeature(ProjectNameBaseFeature):
173
242
  # Body-level signals; snake_case forms are read first so camelCase wins.
174
243
  if isinstance(body, dict):
175
244
  if body.get("next") is not None:
176
- paging["next"] = paging["next"] or body["next"]
245
+ if not _is_link(body["next"], self.options.get("next") or "auto"):
246
+ paging["cursor"] = body["next"]
247
+ else:
248
+ paging["next"] = paging["next"] or body["next"]
177
249
  if body.get("next_cursor") is not None:
178
250
  paging["cursor"] = body["next_cursor"]
179
251
  if body.get("cursor") is not None:
@@ -193,6 +265,15 @@ class ProjectNamePagingFeature(ProjectNameBaseFeature):
193
265
  paging["hasMore"] = body["hasMore"]
194
266
  explicit_more = True
195
267
 
268
+ # A link to another origin is recorded, never followed, and ends the walk.
269
+ spec = ctx.spec
270
+ base = spec.base if spec is not None else (ctx.options or {}).get("base")
271
+ if paging["next"] is not None and spec is not None:
272
+ paging["next"] = _resolve(paging["next"], getattr(spec, "url", None))
273
+ if paging["next"] is not None and _foreign(paging["next"], base):
274
+ paging["foreign"] = paging["next"]
275
+ paging["next"] = None
276
+
196
277
  # Cursor presence only INFERS another page. When the server stated
197
278
  # the answer outright — relay's `hasNextPage: false`, or a body
198
279
  # `hasMore` — that wins: a final page normally carries both an end
@@ -204,6 +285,10 @@ class ProjectNamePagingFeature(ProjectNameBaseFeature):
204
285
  or paging["cursor"] is not None
205
286
  or paging["nextPage"] is not None)
206
287
 
288
+ if (paging["foreign"] is not None and paging["cursor"] is None
289
+ and paging["nextPage"] is None):
290
+ paging["hasMore"] = False
291
+
207
292
  result.paging = paging
208
293
 
209
294
  ctrl = ctx.ctrl
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  import math
5
+ import threading
5
6
  import time
6
7
 
7
8
  from projectname_sdk.feature.base_feature import ProjectNameBaseFeature
@@ -24,6 +25,7 @@ class ProjectNameRatelimitFeature(ProjectNameBaseFeature):
24
25
  self.options = {}
25
26
  self.tokens = 0
26
27
  self.last = 0
28
+ self._lock = threading.Lock()
27
29
 
28
30
  def init(self, ctx, options):
29
31
  self.client = ctx.client
@@ -55,23 +57,18 @@ class ProjectNameRatelimitFeature(ProjectNameBaseFeature):
55
57
  rate = self.options.get("rate") or 5
56
58
  burst = rate if self.options.get("burst") is None else self.options.get("burst")
57
59
 
58
- # Refill according to elapsed time.
59
- now = self._now()
60
- elapsed = now - self.last
61
- self.last = now
62
- self.tokens = min(burst, self.tokens + (elapsed / 1000.0) * rate)
63
-
64
- if self.tokens >= 1:
65
- self.tokens -= 1
66
- return
67
-
68
- # Not enough tokens: wait for one to accrue, then consume it.
69
- needed = 1 - self.tokens
70
- wait_ms = int(math.ceil((needed / rate) * 1000))
71
- self._track(ctx, wait_ms)
60
+ # Refill, then reserve this call's token before any wait: a negative
61
+ # count is the calls already queued, so overlapping calls pace in turn.
62
+ with self._lock:
63
+ now = self._now()
64
+ elapsed = now - self.last
65
+ self.last = now
66
+ self.tokens = min(burst, self.tokens + (elapsed / 1000.0) * rate) - 1
67
+ if self.tokens >= 0:
68
+ return
69
+ wait_ms = int(math.ceil((-self.tokens / rate) * 1000))
70
+ self._track(ctx, wait_ms)
72
71
  self._sleep(wait_ms)
73
- self.last = self._now()
74
- self.tokens = 0
75
72
 
76
73
  def _now(self):
77
74
  now = self.options.get("now")
@@ -1,12 +1,38 @@
1
1
  # ProjectName SDK retry feature
2
2
 
3
3
  from __future__ import annotations
4
+ import calendar
4
5
  import random
6
+ import re
5
7
  import time
6
8
 
7
9
  from projectname_sdk.feature.base_feature import ProjectNameBaseFeature
8
10
 
9
11
 
12
+ _MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
13
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
14
+
15
+ _IMF_FIXDATE = re.compile(
16
+ r"(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), ([0-9]{2}) ([A-Z][a-z]{2}) ([0-9]{4}) "
17
+ r"([0-9]{2}):([0-9]{2}):([0-9]{2}) GMT")
18
+
19
+
20
+ # RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else None.
21
+ def retry_after_ms(value, now):
22
+ s = value.strip(" \t")
23
+ if re.fullmatch(r"[0-9]+", s):
24
+ return int(s) * 1000
25
+ m = _IMF_FIXDATE.fullmatch(s)
26
+ if m is None or m.group(2) not in _MONTHS:
27
+ return None
28
+ day, year, hour, minute, sec = (int(m.group(i)) for i in (1, 3, 4, 5, 6))
29
+ if day < 1 or day > 31 or hour > 23 or minute > 59 or sec > 60:
30
+ return None
31
+ month = _MONTHS.index(m.group(2)) + 1
32
+ at = calendar.timegm((year, month, day, hour, minute, sec, 0, 0, 0)) * 1000
33
+ return max(0, at - now)
34
+
35
+
10
36
  # Automatic retry of transient failures with exponential backoff and
11
37
  # jitter. Wraps the active transport so a single operation call may make
12
38
  # several HTTP attempts. A failure is retryable when the transport returns
@@ -80,11 +106,13 @@ class ProjectNameRetryFeature(ProjectNameBaseFeature):
80
106
  status = res.get("status") if isinstance(res, dict) else None
81
107
  if not isinstance(status, (int, float)) or isinstance(status, bool):
82
108
  return False
83
- statuses = self.options.get("statuses") or [408, 425, 429, 500, 502, 503, 504]
109
+ statuses = self.options.get("statuses")
110
+ if statuses is None:
111
+ statuses = [408, 425, 429, 500, 502, 503, 504]
84
112
  return int(status) in statuses
85
113
 
86
114
  def _backoff(self, res, attempt, min_delay, max_delay, factor):
87
- # Honour a server-provided Retry-After (seconds) when present.
115
+ # A server-provided Retry-After wins over the computed backoff.
88
116
  ra = self._retry_after(res)
89
117
  if ra is not None:
90
118
  return min(max_delay, ra)
@@ -105,10 +133,7 @@ class ProjectNameRetryFeature(ProjectNameBaseFeature):
105
133
  break
106
134
  if val is None:
107
135
  return None
108
- try:
109
- return float(val) * 1000
110
- except (TypeError, ValueError):
111
- return None
136
+ return retry_after_ms(str(val), time.time() * 1000)
112
137
 
113
138
  def _sleep(self, ms):
114
139
  if ms is None or ms <= 0:
@@ -3,13 +3,13 @@
3
3
  from __future__ import annotations
4
4
  import base64
5
5
  import json
6
- import urllib.error
7
6
  import urllib.parse
8
- import urllib.request
9
7
 
10
8
  from projectname_sdk.utility.voxgig_struct import voxgig_struct as vs
11
9
  from projectname_sdk.feature.base_feature import ProjectNameBaseFeature
12
10
  from projectname_sdk.feature.secrets.voxgig_sekreto import Sekreto, envkey
11
+ from projectname_sdk.utility.fetcher import fetcher_util
12
+ from projectname_sdk.core.error import ProjectNameError
13
13
  # The plugin DEFINITIONS the model selected for this feature, emitted by
14
14
  # config generically from the catalogue's active `plugin.def` entries.
15
15
  # Upstream sekreto's contract since the registry was retired: a kind not
@@ -335,21 +335,14 @@ class ProjectNameSecretsFeature(ProjectNameBaseFeature):
335
335
  base = str(options.get("base") or "").rstrip("/")
336
336
  url = base + "/" + str(x["path"]).lstrip("/")
337
337
 
338
- fetch = vs.getpath(options, "system.fetch")
339
-
340
- if not callable(fetch):
341
- # No custom transport supplied - the ordinary case.
342
- # make_options leaves system.fetch unset, so the exchange
343
- # gets its own raw HTTP path (stdlib urllib, mirroring the ts
344
- # reference whose system.fetch is initialized from the
345
- # platform fetcher). Local and minimal on purpose: see the
346
- # NOT-the-SDK-transport note below.
347
- fetch = _raw_exchange_fetch
348
-
349
- # Deliberately NOT the SDK transport. The transport is what this
350
- # feature wraps, and sending the token request back through it
351
- # would recurse on the first 401 - and would route the exchange
352
- # through the test mock, which knows nothing about it.
338
+ # The SDK's own transport, beneath every feature's wrapper: it holds
339
+ # the test feature's block and the GET-only guard, and the wrapped
340
+ # one would recurse on the first 401.
341
+ rootctx = getattr(self._client, "_rootctx", None)
342
+
343
+ def fetch(at, fd):
344
+ return fetcher_util(rootctx, at, fd)
345
+
353
346
  fetchdef = {
354
347
  "method": x["method"],
355
348
  "headers": {"content-type": "application/json"},
@@ -357,6 +350,9 @@ class ProjectNameSecretsFeature(ProjectNameBaseFeature):
357
350
  # Never followed by the client: a redirect would carry the
358
351
  # refresh token on.
359
352
  "redirect": "manual",
353
+ # Seconds; its own bound, as the timeout feature's wrapper is
354
+ # above this call.
355
+ "timeout": 30,
360
356
  }
361
357
 
362
358
  res, err = fetch(url, fetchdef)
@@ -373,6 +369,8 @@ class ProjectNameSecretsFeature(ProjectNameBaseFeature):
373
369
  res, err = fetch(at, fetchdef)
374
370
  hops += 1
375
371
 
372
+ if isinstance(err, ProjectNameError):
373
+ raise err
376
374
  if err is not None:
377
375
  raise Exception(
378
376
  "secrets: token exchange failed: " + str(err) + " from " + url)
@@ -527,52 +525,3 @@ def _moved(url, at, res):
527
525
  except ValueError:
528
526
  return None
529
527
  return nxt if same else None
530
-
531
-
532
- class _NoRedirect(urllib.request.HTTPRedirectHandler):
533
- def redirect_request(self, req, fp, code, msg, headers, newurl):
534
- return None
535
-
536
-
537
- # A 3xx then surfaces as HTTPError, the exchange's own failed answer.
538
- _NO_REDIRECT = urllib.request.build_opener(_NoRedirect)
539
-
540
-
541
- def _raw_exchange_fetch(fullurl, fetchdef):
542
- """Token-exchange transport of last resort: stdlib urllib, answering
543
- the same (res, err) shape the system.fetch seam promises. Exists so an
544
- exchange works with ordinary SDK options - requiring a custom
545
- transport for the COMMON case would reject every live token purchase
546
- before a request was made."""
547
- try:
548
- body = fetchdef.get("body")
549
- data = body.encode("utf-8") if isinstance(body, str) and body else None
550
- req = urllib.request.Request(
551
- fullurl,
552
- data=data,
553
- method=str(fetchdef.get("method") or "POST"),
554
- )
555
- for k, v in (fetchdef.get("headers") or {}).items():
556
- if isinstance(v, str):
557
- req.add_header(k, v)
558
- with _NO_REDIRECT.open(req, timeout=30) as res:
559
- raw = res.read()
560
- status = res.status
561
- headers = {k.lower(): v for k, v in res.headers.items()}
562
-
563
- def _json():
564
- try:
565
- return json.loads(raw.decode("utf-8"))
566
- except Exception:
567
- return None
568
-
569
- return {"status": status, "headers": headers, "json": _json}, None
570
- except urllib.error.HTTPError as e:
571
- # A non-2xx answer IS a response: hand back its status so the
572
- # caller reports "token exchange failed: <status>" rather than a
573
- # transport error.
574
- headers = {k.lower(): v for k, v in (e.headers or {}).items()}
575
- return {"status": e.code, "headers": headers,
576
- "json": lambda: None}, None
577
- except Exception as e:
578
- return None, e
@@ -36,8 +36,9 @@ class ProjectNameStreamingFeature(ProjectNameBaseFeature):
36
36
  return
37
37
  if not self._streamable(ctx):
38
38
  return
39
+ # A failed result keeps no stream, so the entity's stream() raises its error.
39
40
  result = ctx.result
40
- if result is None:
41
+ if result is None or result.err is not None:
41
42
  return
42
43
 
43
44
  result.streaming = True
@@ -1,6 +1,7 @@
1
1
  # ProjectName SDK telemetry feature
2
2
 
3
3
  from __future__ import annotations
4
+ import os
4
5
  import time
5
6
 
6
7
  from projectname_sdk.feature.base_feature import ProjectNameBaseFeature
@@ -21,7 +22,6 @@ class ProjectNameTelemetryFeature(ProjectNameBaseFeature):
21
22
  self.active = True
22
23
  self.client = None
23
24
  self.options = {}
24
- self.seq = 0
25
25
 
26
26
  def init(self, ctx, options):
27
27
  self.client = ctx.client
@@ -32,7 +32,6 @@ class ProjectNameTelemetryFeature(ProjectNameBaseFeature):
32
32
  else:
33
33
  self.active = False
34
34
 
35
- self.seq = 0
36
35
 
37
36
  client = self.client
38
37
  if getattr(client, "_telemetry", None) is None:
@@ -119,13 +118,18 @@ class ProjectNameTelemetryFeature(ProjectNameBaseFeature):
119
118
  idgen = self.options.get("idgen")
120
119
  if callable(idgen):
121
120
  return idgen(kind)
122
- # Deterministic-ish sequential id; unique within a client instance.
123
- self.seq += 1
124
- n = format(self.seq, "04x")
125
- return ("t" if kind == "trace" else "s") + n.ljust(16, "0")
121
+ return _random_hex(16 if kind == "trace" else 8)
126
122
 
127
123
  def _now(self):
128
124
  now = self.options.get("now")
129
125
  if callable(now):
130
126
  return now()
131
127
  return time.time() * 1000
128
+
129
+
130
+ # W3C trace context: lowercase hex from the platform's random source, never all zeros.
131
+ def _random_hex(nbytes):
132
+ while True:
133
+ buf = os.urandom(nbytes)
134
+ if any(buf):
135
+ return buf.hex()