@voxgig/sdkgen 4.51.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 (289) 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 +1 -1
  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/src/cmp/c/TestClean_c.ts +12 -11
  32. package/project/.sdk/src/cmp/c/fragment/Entity.fragment.c +17 -10
  33. package/project/.sdk/src/cmp/clojure/fragment/Entity.fragment.clj +18 -1
  34. package/project/.sdk/src/cmp/cpp/TestClean_cpp.ts +2 -1
  35. package/project/.sdk/src/cmp/csharp/fragment/EntityBase.fragment.cs +30 -2
  36. package/project/.sdk/src/cmp/csharp/fragment/Main.fragment.cs +31 -12
  37. package/project/.sdk/src/cmp/elixir/TestClean_elixir.ts +2 -1
  38. package/project/.sdk/src/cmp/elixir/fragment/Main.fragment.ex +51 -15
  39. package/project/.sdk/src/cmp/elixir/fragment/Pipeline.fragment.ex +17 -0
  40. package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +42 -2
  41. package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +42 -14
  42. package/project/.sdk/src/cmp/java/TestClean_java.ts +9 -4
  43. package/project/.sdk/src/cmp/java/fragment/EntityBase.fragment.java +21 -0
  44. package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +13 -8
  45. package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +26 -2
  46. package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +8 -0
  47. package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +8 -0
  48. package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +8 -0
  49. package/project/.sdk/src/cmp/js/fragment/EntityPatchOp.fragment.js +8 -0
  50. package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +8 -0
  51. package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +8 -0
  52. package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +12 -5
  53. package/project/.sdk/src/cmp/kotlin/TestClean_kotlin.ts +9 -4
  54. package/project/.sdk/src/cmp/kotlin/fragment/EntityBase.fragment.kt +19 -0
  55. package/project/.sdk/src/cmp/lua/TestClean_lua.ts +2 -1
  56. package/project/.sdk/src/cmp/lua/fragment/Entity.fragment.lua +42 -5
  57. package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +44 -10
  58. package/project/.sdk/src/cmp/lua/utility_lua.ts +2 -1
  59. package/project/.sdk/src/cmp/ocaml/TestClean_ocaml.ts +2 -1
  60. package/project/.sdk/src/cmp/ocaml/fragment/RunOp.fragment.ml +36 -21
  61. package/project/.sdk/src/cmp/perl/TestClean_perl.ts +1 -1
  62. package/project/.sdk/src/cmp/perl/fragment/Entity.fragment.pm +21 -0
  63. package/project/.sdk/src/cmp/perl/fragment/Main.fragment.pm +31 -12
  64. package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +33 -4
  65. package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +13 -6
  66. package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +25 -2
  67. package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +26 -12
  68. package/project/.sdk/src/cmp/rb/TestClean_rb.ts +1 -1
  69. package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +23 -2
  70. package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +27 -11
  71. package/project/.sdk/src/cmp/rust/TestClean_rust.ts +14 -17
  72. package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +22 -2
  73. package/project/.sdk/src/cmp/scala/TestClean_scala.ts +11 -11
  74. package/project/.sdk/src/cmp/scala/fragment/EntityBase.fragment.scala +14 -0
  75. package/project/.sdk/src/cmp/swift/TestClean_swift.ts +11 -11
  76. package/project/.sdk/src/cmp/swift/fragment/EntityBase.fragment.swift +9 -0
  77. package/project/.sdk/src/cmp/swift/fragment/Main.fragment.swift +24 -10
  78. package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +13 -8
  79. package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +26 -2
  80. package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +8 -0
  81. package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +8 -0
  82. package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +8 -0
  83. package/project/.sdk/src/cmp/ts/fragment/EntityPatchOp.fragment.ts +8 -0
  84. package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +8 -0
  85. package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +8 -0
  86. package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +12 -5
  87. package/project/.sdk/src/cmp/zig/TestClean_zig.ts +11 -11
  88. package/project/.sdk/src/cmp/zig/fragment/Entity.fragment.zig +17 -10
  89. package/project/.sdk/src/cmp/zig/fragment/Main.fragment.zig +41 -6
  90. package/project/.sdk/tm/c/feature/metrics.c +7 -0
  91. package/project/.sdk/tm/c/feature/paging.c +231 -2
  92. package/project/.sdk/tm/c/feature/ratelimit.c +5 -9
  93. package/project/.sdk/tm/c/feature/retry.c +51 -4
  94. package/project/.sdk/tm/c/feature/streaming.c +2 -1
  95. package/project/.sdk/tm/c/feature/telemetry.c +19 -18
  96. package/project/.sdk/tm/c/feature/test.c +78 -54
  97. package/project/.sdk/tm/c/tests/feature_test.c +184 -0
  98. package/project/.sdk/tm/c/tests/primary_utility_test.c +2 -0
  99. package/project/.sdk/tm/c/utility/make_options.c +80 -9
  100. package/project/.sdk/tm/clojure/src/sdk/core.clj +31 -11
  101. package/project/.sdk/tm/clojure/src/sdk/features.clj +198 -70
  102. package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +70 -1
  103. package/project/.sdk/tm/cpp/core/types.hpp +137 -68
  104. package/project/.sdk/tm/cpp/feature/audit.hpp +6 -1
  105. package/project/.sdk/tm/cpp/feature/metrics.hpp +19 -0
  106. package/project/.sdk/tm/cpp/feature/paging.hpp +160 -2
  107. package/project/.sdk/tm/cpp/feature/ratelimit.hpp +18 -14
  108. package/project/.sdk/tm/cpp/feature/retry.hpp +46 -5
  109. package/project/.sdk/tm/cpp/feature/streaming.hpp +2 -1
  110. package/project/.sdk/tm/cpp/feature/telemetry.hpp +17 -10
  111. package/project/.sdk/tm/cpp/feature/test.hpp +63 -53
  112. package/project/.sdk/tm/cpp/test/feature_test.cpp +137 -0
  113. package/project/.sdk/tm/cpp/utility/pipeline.hpp +35 -5
  114. package/project/.sdk/tm/csharp/feature/AuditFeature.cs +8 -1
  115. package/project/.sdk/tm/csharp/feature/MetricsFeature.cs +23 -0
  116. package/project/.sdk/tm/csharp/feature/PagingFeature.cs +130 -3
  117. package/project/.sdk/tm/csharp/feature/RatelimitFeature.cs +26 -19
  118. package/project/.sdk/tm/csharp/feature/RetryFeature.cs +41 -7
  119. package/project/.sdk/tm/csharp/feature/StreamingFeature.cs +2 -1
  120. package/project/.sdk/tm/csharp/feature/TelemetryFeature.cs +11 -9
  121. package/project/.sdk/tm/csharp/feature/TestFeature.cs +55 -67
  122. package/project/.sdk/tm/csharp/test/FeatureTest.cs +162 -0
  123. package/project/.sdk/tm/csharp/utility/MakeOptions.cs +89 -12
  124. package/project/.sdk/tm/elixir/lib/projectname/feature/metrics.ex +13 -0
  125. package/project/.sdk/tm/elixir/lib/projectname/feature/paging.ex +110 -5
  126. package/project/.sdk/tm/elixir/lib/projectname/feature/ratelimit.ex +6 -12
  127. package/project/.sdk/tm/elixir/lib/projectname/feature/retry.ex +33 -9
  128. package/project/.sdk/tm/elixir/lib/projectname/feature/streaming.ex +2 -1
  129. package/project/.sdk/tm/elixir/lib/projectname/feature/telemetry.ex +7 -7
  130. package/project/.sdk/tm/elixir/lib/projectname/feature/test.ex +52 -48
  131. package/project/.sdk/tm/elixir/lib/projectname/utility.ex +59 -35
  132. package/project/.sdk/tm/elixir/test/feature_test.exs +137 -0
  133. package/project/.sdk/tm/go/feature/audit_feature.go +1 -3
  134. package/project/.sdk/tm/go/feature/base_feature.go +11 -0
  135. package/project/.sdk/tm/go/feature/metrics_feature.go +14 -0
  136. package/project/.sdk/tm/go/feature/paging_feature.go +108 -2
  137. package/project/.sdk/tm/go/feature/ratelimit_feature.go +19 -17
  138. package/project/.sdk/tm/go/feature/retry_feature.go +81 -9
  139. package/project/.sdk/tm/go/feature/streaming_feature.go +2 -1
  140. package/project/.sdk/tm/go/feature/telemetry_feature.go +18 -11
  141. package/project/.sdk/tm/go/feature/test_feature.go +65 -55
  142. package/project/.sdk/tm/go/test/feature_corpus_test.go +209 -28
  143. package/project/.sdk/tm/go/test/feature_test.go +32 -0
  144. package/project/.sdk/tm/go/utility/make_options.go +111 -6
  145. package/project/.sdk/tm/java/core/SdkClient.java +43 -14
  146. package/project/.sdk/tm/java/feature/AuditFeature.java +5 -1
  147. package/project/.sdk/tm/java/feature/MetricsFeature.java +31 -0
  148. package/project/.sdk/tm/java/feature/PagingFeature.java +156 -2
  149. package/project/.sdk/tm/java/feature/RatelimitFeature.java +15 -13
  150. package/project/.sdk/tm/java/feature/RetryFeature.java +33 -6
  151. package/project/.sdk/tm/java/feature/StreamingFeature.java +2 -1
  152. package/project/.sdk/tm/java/feature/TelemetryFeature.java +17 -9
  153. package/project/.sdk/tm/java/feature/TestFeature.java +50 -63
  154. package/project/.sdk/tm/java/test/FeatureCorpusTest.java +170 -17
  155. package/project/.sdk/tm/java/utility/MakeOptions.java +128 -14
  156. package/project/.sdk/tm/js/src/feature/metrics/MetricsFeature.js +8 -3
  157. package/project/.sdk/tm/js/src/feature/paging/PagingFeature.js +99 -1
  158. package/project/.sdk/tm/js/src/feature/ratelimit/RatelimitFeature.js +5 -9
  159. package/project/.sdk/tm/js/src/feature/retry/RetryFeature.js +25 -3
  160. package/project/.sdk/tm/js/src/feature/streaming/StreamingFeature.js +2 -1
  161. package/project/.sdk/tm/js/src/feature/telemetry/TelemetryFeature.js +11 -6
  162. package/project/.sdk/tm/js/src/feature/test/TestFeature.js +38 -1
  163. package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +55 -6
  164. package/project/.sdk/tm/js/test/feature/Corpus.test.js +95 -25
  165. package/project/.sdk/tm/js/test/feature.test.js +14 -1
  166. package/project/.sdk/tm/kotlin/core/SdkClient.kt +23 -10
  167. package/project/.sdk/tm/kotlin/feature/AuditFeature.kt +5 -1
  168. package/project/.sdk/tm/kotlin/feature/MetricsFeature.kt +22 -0
  169. package/project/.sdk/tm/kotlin/feature/PagingFeature.kt +125 -2
  170. package/project/.sdk/tm/kotlin/feature/RatelimitFeature.kt +16 -13
  171. package/project/.sdk/tm/kotlin/feature/RetryFeature.kt +36 -14
  172. package/project/.sdk/tm/kotlin/feature/StreamingFeature.kt +4 -0
  173. package/project/.sdk/tm/kotlin/feature/TelemetryFeature.kt +12 -10
  174. package/project/.sdk/tm/kotlin/feature/TestFeature.kt +45 -48
  175. package/project/.sdk/tm/kotlin/test/FeatureTest.kt +114 -0
  176. package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +83 -14
  177. package/project/.sdk/tm/lua/feature/debug_feature.lua +2 -3
  178. package/project/.sdk/tm/lua/feature/metrics_feature.lua +5 -0
  179. package/project/.sdk/tm/lua/feature/paging_feature.lua +143 -2
  180. package/project/.sdk/tm/lua/feature/ratelimit_feature.lua +5 -9
  181. package/project/.sdk/tm/lua/feature/retry_feature.lua +43 -5
  182. package/project/.sdk/tm/lua/feature/streaming_feature.lua +2 -1
  183. package/project/.sdk/tm/lua/feature/telemetry_feature.lua +18 -7
  184. package/project/.sdk/tm/lua/feature/test_feature.lua +60 -62
  185. package/project/.sdk/tm/lua/test/feature_test.lua +100 -3
  186. package/project/.sdk/tm/lua/utility/make_options.lua +55 -13
  187. package/project/.sdk/tm/ocaml/sdk_features.ml +286 -60
  188. package/project/.sdk/tm/ocaml/sdk_runtime.ml +34 -11
  189. package/project/.sdk/tm/ocaml/test/t_feature.ml +72 -1
  190. package/project/.sdk/tm/perl/feature/debug_feature.pm +2 -2
  191. package/project/.sdk/tm/perl/feature/metrics_feature.pm +5 -0
  192. package/project/.sdk/tm/perl/feature/paging_feature.pm +139 -2
  193. package/project/.sdk/tm/perl/feature/ratelimit_feature.pm +5 -11
  194. package/project/.sdk/tm/perl/feature/retry_feature.pm +22 -4
  195. package/project/.sdk/tm/perl/feature/streaming_feature.pm +2 -0
  196. package/project/.sdk/tm/perl/feature/telemetry_feature.pm +17 -8
  197. package/project/.sdk/tm/perl/feature/test_feature.pm +45 -50
  198. package/project/.sdk/tm/perl/t/feature.t +2 -2
  199. package/project/.sdk/tm/perl/t/feature_corpus.t +126 -23
  200. package/project/.sdk/tm/perl/utility/make_options.pm +33 -10
  201. package/project/.sdk/tm/php/feature/MetricsFeature.php +8 -0
  202. package/project/.sdk/tm/php/feature/PagingFeature.php +128 -1
  203. package/project/.sdk/tm/php/feature/RatelimitFeature.php +5 -9
  204. package/project/.sdk/tm/php/feature/RetryFeature.php +27 -3
  205. package/project/.sdk/tm/php/feature/StreamingFeature.php +2 -1
  206. package/project/.sdk/tm/php/feature/TelemetryFeature.php +10 -7
  207. package/project/.sdk/tm/php/feature/TestFeature.php +55 -47
  208. package/project/.sdk/tm/php/test/FeatureCorpusTest.php +151 -16
  209. package/project/.sdk/tm/php/utility/MakeOptions.php +40 -13
  210. package/project/.sdk/tm/py/pkg/feature/metrics_feature.py +7 -0
  211. package/project/.sdk/tm/py/pkg/feature/paging_feature.py +86 -1
  212. package/project/.sdk/tm/py/pkg/feature/ratelimit_feature.py +13 -16
  213. package/project/.sdk/tm/py/pkg/feature/retry_feature.py +31 -6
  214. package/project/.sdk/tm/py/pkg/feature/streaming_feature.py +2 -1
  215. package/project/.sdk/tm/py/pkg/feature/telemetry_feature.py +10 -6
  216. package/project/.sdk/tm/py/pkg/feature/test_feature.py +56 -53
  217. package/project/.sdk/tm/py/pkg/utility/make_options.py +68 -20
  218. package/project/.sdk/tm/py/test/test_feature.py +11 -1
  219. package/project/.sdk/tm/py/test/test_feature_corpus.py +111 -16
  220. package/project/.sdk/tm/py-data/pkg/fetch.py +6 -3
  221. package/project/.sdk/tm/py-data/test/test_fetch.py +7 -4
  222. package/project/.sdk/tm/rb/feature/debug_feature.rb +2 -2
  223. package/project/.sdk/tm/rb/feature/metrics_feature.rb +8 -0
  224. package/project/.sdk/tm/rb/feature/paging_feature.rb +87 -1
  225. package/project/.sdk/tm/rb/feature/ratelimit_feature.rb +12 -16
  226. package/project/.sdk/tm/rb/feature/retry_feature.rb +19 -3
  227. package/project/.sdk/tm/rb/feature/streaming_feature.rb +2 -1
  228. package/project/.sdk/tm/rb/feature/telemetry_feature.rb +11 -6
  229. package/project/.sdk/tm/rb/feature/test_feature.rb +42 -49
  230. package/project/.sdk/tm/rb/test/feature_corpus_test.rb +108 -24
  231. package/project/.sdk/tm/rb/test/feature_test.rb +1 -1
  232. package/project/.sdk/tm/rb/utility/make_options.rb +32 -11
  233. package/project/.sdk/tm/rust/feature/audit.rs +2 -2
  234. package/project/.sdk/tm/rust/feature/metrics.rs +24 -1
  235. package/project/.sdk/tm/rust/feature/paging.rs +189 -3
  236. package/project/.sdk/tm/rust/feature/ratelimit.rs +5 -10
  237. package/project/.sdk/tm/rust/feature/retry.rs +59 -6
  238. package/project/.sdk/tm/rust/feature/streaming.rs +3 -2
  239. package/project/.sdk/tm/rust/feature/support.rs +4 -0
  240. package/project/.sdk/tm/rust/feature/telemetry.rs +22 -11
  241. package/project/.sdk/tm/rust/feature/test.rs +63 -57
  242. package/project/.sdk/tm/rust/tests/feature_test.rs +174 -0
  243. package/project/.sdk/tm/rust/tests/primary_utility_test.rs +1 -0
  244. package/project/.sdk/tm/rust/utility/make_options.rs +122 -27
  245. package/project/.sdk/tm/scala/core/SdkClient.scala +45 -11
  246. package/project/.sdk/tm/scala/feature/AuditFeature.scala +6 -1
  247. package/project/.sdk/tm/scala/feature/MetricsFeature.scala +31 -1
  248. package/project/.sdk/tm/scala/feature/PagingFeature.scala +122 -2
  249. package/project/.sdk/tm/scala/feature/RatelimitFeature.scala +14 -11
  250. package/project/.sdk/tm/scala/feature/RetryFeature.scala +29 -7
  251. package/project/.sdk/tm/scala/feature/StreamingFeature.scala +2 -1
  252. package/project/.sdk/tm/scala/feature/TelemetryFeature.scala +12 -10
  253. package/project/.sdk/tm/scala/feature/TestFeature.scala +44 -44
  254. package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +41 -0
  255. package/project/.sdk/tm/scala/utility/Make.scala +96 -13
  256. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/AuditFeature.swift +3 -2
  257. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/MetricsFeature.swift +20 -0
  258. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/PagingFeature.swift +102 -2
  259. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/RatelimitFeature.swift +19 -13
  260. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/RetryFeature.swift +40 -5
  261. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/StreamingFeature.swift +2 -1
  262. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TelemetryFeature.swift +11 -9
  263. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TestFeature.swift +55 -49
  264. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +51 -13
  265. package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +111 -0
  266. package/project/.sdk/tm/ts/src/feature/metrics/MetricsFeature.ts +5 -0
  267. package/project/.sdk/tm/ts/src/feature/paging/PagingFeature.ts +99 -1
  268. package/project/.sdk/tm/ts/src/feature/ratelimit/RatelimitFeature.ts +5 -9
  269. package/project/.sdk/tm/ts/src/feature/retry/RetryFeature.ts +25 -3
  270. package/project/.sdk/tm/ts/src/feature/streaming/StreamingFeature.ts +2 -1
  271. package/project/.sdk/tm/ts/src/feature/telemetry/TelemetryFeature.ts +11 -6
  272. package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +8 -7
  273. package/project/.sdk/tm/ts/src/utility/MakeOptionsUtility.ts +57 -6
  274. package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +95 -25
  275. package/project/.sdk/tm/ts/test/feature.test.ts +14 -1
  276. package/project/.sdk/tm/zig/core/utility.zig +107 -8
  277. package/project/.sdk/tm/zig/feature/metrics.zig +19 -0
  278. package/project/.sdk/tm/zig/feature/paging.zig +172 -4
  279. package/project/.sdk/tm/zig/feature/ratelimit.zig +5 -11
  280. package/project/.sdk/tm/zig/feature/retry.zig +41 -3
  281. package/project/.sdk/tm/zig/feature/streaming.zig +2 -0
  282. package/project/.sdk/tm/zig/feature/telemetry.zig +15 -9
  283. package/project/.sdk/tm/zig/feature/test.zig +56 -40
  284. package/project/.sdk/tm/zig/test/feature_test.zig +109 -0
  285. package/project/.sdk/tm/zig/test/primary_utility_test.zig +2 -0
  286. package/project/sdkgen-package.json +1 -1
  287. package/src/cmp/ReadmeExplanation.ts +5 -2
  288. package/src/cmp/ReadmeFeatures.ts +21 -6
  289. package/src/helpers/optspec.ts +2 -2
@@ -67,13 +67,19 @@ ok(defined $CORPUS->{feature}, 'the corpus carries a feature section');
67
67
  # Returns the shape the real fetcher returns: a (response, err) PAIR, with the
68
68
  # parsed body behind a `json` coderef and `body` as the raw string. A script
69
69
  # that only set `body` would look like an empty result, which reads as a
70
- # feature defect rather than a mis-shaped script.
70
+ # feature defect rather than a mis-shaped script. Each URL it is sent is kept
71
+ # in `$sent`, and the time it was sent in `$at`; a `cut` response is one whose
72
+ # body stops before its end.
71
73
  sub scripted_fetcher {
72
- my ($res) = @_;
74
+ my ($res, $sent, $at) = @_;
75
+ $sent ||= [];
76
+ $at ||= [];
73
77
  my $n = -1;
74
78
  return sub {
75
79
  my ($ctx, $fullurl, $fetchdef) = @_;
76
80
  $n++;
81
+ push @$sent, $fullurl;
82
+ push @$at, Time::HiRes::time() * 1000;
77
83
  my $spec = {};
78
84
  if (ref $res eq 'ARRAY' && @$res) {
79
85
  my $i = $n >= scalar(@$res) ? scalar(@$res) - 1 : $n;
@@ -87,6 +93,18 @@ sub scripted_fetcher {
87
93
  my $status = defined $spec->{status} ? int($spec->{status}) : 200;
88
94
  my $body = defined $spec->{body} ? $spec->{body} : {};
89
95
 
96
+ if ($spec->{cut}) {
97
+ my $raw = Voxgig::Struct::stringify($body);
98
+ return ({
99
+ 'status' => $status,
100
+ 'statusText' => ($status < 400 ? 'OK' : 'ERR'),
101
+ 'headers' => { %{ $spec->{headers} || {} } },
102
+ 'json' => sub { undef },
103
+ 'body' => substr($raw, 0, int(length($raw) / 2)),
104
+ 'unreadable' => 1,
105
+ }, undef);
106
+ }
107
+
90
108
  return ({
91
109
  'status' => $status,
92
110
  'statusText' => ($status < 400 ? 'OK' : 'ERR'),
@@ -105,10 +123,10 @@ sub scripted_fetcher {
105
123
  # would shadow the script. The `test` OPTION installs no transport: it says
106
124
  # the client is not live, so a required server variable becomes test-<name>.
107
125
  sub build_client {
108
- my ($kase) = @_;
126
+ my ($kase, $sent, $at) = @_;
109
127
  my $opts = {
110
128
  'test' => { 'active' => 1 },
111
- 'utility' => { 'fetcher' => scripted_fetcher($kase->{res}) },
129
+ 'utility' => { 'fetcher' => scripted_fetcher($kase->{res}, $sent, $at) },
112
130
  };
113
131
  $opts->{feature} = $kase->{feature} if defined $kase->{feature};
114
132
  return ProjectNameSDK->new($opts);
@@ -245,12 +263,55 @@ sub usable_pair {
245
263
  }
246
264
 
247
265
 
266
+ # Read one operation through the entity's stream; how many it yields.
267
+ sub stream_items {
268
+ my ($client, $op, $ctrl, $args) = @_;
269
+ my $acc = $op->{accessor};
270
+ my $next = $client->$acc()->stream($op->{op}, { %{ $args || {} } }, { ctrl => $ctrl });
271
+ my $items = 0;
272
+ $items++ while defined $next->();
273
+ return $items;
274
+ }
275
+
276
+
277
+ # Each request a case expects, in order: its path, and its whole query. A path
278
+ # is compared without its leading slash, which an SDK with no base omits.
279
+ sub check_sent {
280
+ my ($sent, $expect, $label) = @_;
281
+ is(scalar(@$sent), scalar(@$expect), "$label: requests sent")
282
+ or diag(join(' | ', @$sent));
283
+ for my $i (0 .. $#$expect) {
284
+ my $want = $expect->[$i];
285
+ my ($path, $rawquery) = split /\?/, ($sent->[$i] // '') =~ s{\A[a-z][a-z0-9+.-]*://[^/?#]*}{}ir, 2;
286
+ if (defined $want->{path}) {
287
+ is($path =~ s{\A/+}{}r, $want->{path} =~ s{\A/+}{}r, "$label: request $i path");
288
+ }
289
+ if (defined $want->{query}) {
290
+ my %query;
291
+ for my $pair (split /&/, $rawquery // '') {
292
+ my ($k, $v) = map { my $t = $_ // ''; $t =~ tr/+/ /; $t =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/ge; $t }
293
+ split /=/, $pair, 2;
294
+ $query{$k} = $v;
295
+ }
296
+ is_deeply(\%query, $want->{query}, "$label: request $i query");
297
+ }
298
+ }
299
+ return;
300
+ }
301
+
302
+
248
303
  # One step: it may wait before its call, may add request headers for its
249
- # call, and may pass `args` as the operation's first argument.
304
+ # call, and may pass `args` as the operation's first argument. A `stream` step
305
+ # reads the operation through stream, and `items` is how many it yields.
250
306
  sub step_call {
251
307
  my ($client, $op, $step, $ctrl) = @_;
252
308
  Time::HiRes::sleep($step->{wait} / 1000) if defined $step->{wait};
253
309
  my $args = Voxgig::Struct::ismap($step->{args}) ? $step->{args} : {};
310
+ if ($step->{stream}) {
311
+ my $items = stream_items($client, $op, $ctrl, $args);
312
+ is($items, $step->{items}, "$op->{key}: items streamed") if defined $step->{items};
313
+ return $items;
314
+ }
254
315
  return invoke($client, $op, $ctrl, $args) unless Voxgig::Struct::ismap($step->{headers});
255
316
  my $options = $client->{options};
256
317
  my $had = exists $options->{headers};
@@ -286,6 +347,31 @@ sub member {
286
347
  }
287
348
 
288
349
 
350
+ # A step with `together: N` is N calls. Perl runs one call at a time, so
351
+ # they go in turn; each call's error, or undef, is returned.
352
+ sub calls {
353
+ my ($client, $op, $step, $ctrl) = @_;
354
+ my @errs;
355
+ for (1 .. ($step->{together} || 1)) {
356
+ my $ok = eval { step_call($client, $op, $step, $ctrl); 1 };
357
+ push @errs, $ok ? undef : ($@ || 'failed');
358
+ }
359
+ return @errs;
360
+ }
361
+
362
+
363
+ # The most requests seen in any window of `ms`.
364
+ sub busiest {
365
+ my ($sent, $ms) = @_;
366
+ my $most = 0;
367
+ for my $from (@$sent) {
368
+ my $n = grep { $from <= $_ && $_ < $from + $ms } @$sent;
369
+ $most = $n if $n > $most;
370
+ }
371
+ return $most;
372
+ }
373
+
374
+
289
375
  # Assert that `actual` contains `expect`, recursively. Cases assert only the
290
376
  # fields they are about, so a full deep comparison would force every case to
291
377
  # restate the whole record.
@@ -301,6 +387,13 @@ sub subset {
301
387
  return;
302
388
  }
303
389
 
390
+ if (ref $expect eq 'ARRAY') {
391
+ ok(ref $actual eq 'ARRAY' && scalar(@$actual) == scalar(@$expect),
392
+ "$path has " . scalar(@$expect) . ' item(s)') or return;
393
+ subset($actual->[$_], $expect->[$_], "$path\[$_\]") for 0 .. $#$expect;
394
+ return;
395
+ }
396
+
304
397
  # JSON true/false parse to a blessed Voxgig::Struct::Bool, and perl's own
305
398
  # booleans are a bare 1 or ''. Compare truth, not spelling: stringified,
306
399
  # those two are 'true' and '1' and would never match.
@@ -437,34 +530,44 @@ for my $name (sort keys %{ $CORPUS->{feature} || {} }) {
437
530
 
438
531
  # Every failing case is reported, not only the first.
439
532
  my $done = eval {
440
- my $client = build_client($kase);
533
+ my $sent = [];
534
+ my @at;
535
+ my $client = build_client($kase, $sent, \@at);
441
536
 
537
+ # A case-level ctrl is one control object every step shares.
538
+ my $shared = $kase->{ctrl};
442
539
  for my $step (@{ $kase->{op} || [] }) {
443
540
  my $op = $by_key{ $step->{op} };
444
541
  ok(defined $op, "$label: operation $step->{op} is known") or next;
445
- my $ctrl = $step->{ctrl} || {};
542
+ my $ctrl = $step->{ctrl} || $shared || {};
446
543
  my $wanterr = $step->{err};
447
544
 
448
- my $ok = eval { step_call($client, $op, $step, $ctrl); 1 };
449
- my $err = $@;
450
-
451
- if (!defined $wanterr) {
452
- ok($ok, "$label: $step->{op} succeeded")
453
- or diag("failed unexpectedly: $err");
454
- next;
545
+ for my $err (calls($client, $op, $step, $ctrl)) {
546
+ if (!defined $wanterr) {
547
+ ok(!defined $err, "$label: $step->{op} succeeded")
548
+ or diag("failed unexpectedly: $err");
549
+ next;
550
+ }
551
+
552
+ ok(defined $err, "$label: $step->{op} failed as expected") or next;
553
+
554
+ if (!ref $wanterr) {
555
+ # The CODE, not the message: make_error prefixes and humanises the
556
+ # text, so matching it would pass on any error mentioning the word.
557
+ my $code = (Scalar::Util::blessed($err) && $err->can('code'))
558
+ ? $err->code : undef;
559
+ is($code, $wanterr, "$label: error code");
560
+ }
455
561
  }
562
+ }
456
563
 
457
- ok(!$ok, "$label: $step->{op} failed as expected") or next;
458
-
459
- if (!ref $wanterr) {
460
- # The CODE, not the message: make_error prefixes and humanises the
461
- # text, so matching it would pass on any error mentioning the word.
462
- my $code = (Scalar::Util::blessed($err) && $err->can('code'))
463
- ? $err->code : undef;
464
- is($code, $wanterr, "$label: error code");
465
- }
564
+ if (my $pace = $kase->{pace}) {
565
+ my $most = busiest(\@at, $pace->{ms});
566
+ ok($most <= $pace->{max},
567
+ "$label: $most requests within $pace->{ms} ms, want at most $pace->{max}");
466
568
  }
467
569
 
570
+ check_sent($sent, $kase->{sent}, $label) if defined $kase->{sent};
468
571
  subset(record($client, $name), $kase->{out}, "$label: _$name");
469
572
  1;
470
573
  };
@@ -18,6 +18,24 @@ package ProjectNameUtilities;
18
18
 
19
19
  our %REGISTRY;
20
20
 
21
+ # The model's options for a feature sit beneath the caller's, key by key: a
22
+ # key the caller sets replaces the default whole, so a list is never merged.
23
+ sub feature_defaults {
24
+ my ($cfgfeature, $feature) = @_;
25
+ return undef if defined $feature && !Voxgig::Struct::ismap($feature);
26
+ my %out = %{ $feature || {} };
27
+ my $cfg = Voxgig::Struct::ismap($cfgfeature) ? $cfgfeature : {};
28
+ for my $name (keys %$cfg) {
29
+ my $dflt = Voxgig::Struct::ismap($cfg->{$name}) ? $cfg->{$name}{options} : undef;
30
+ my $given = $out{$name};
31
+ next unless Voxgig::Struct::ismap($dflt);
32
+ next if !defined $given && !ProjectNameHelpers::is_true($dflt->{active});
33
+ next if defined $given && !Voxgig::Struct::ismap($given);
34
+ $out{$name} = { %{ Voxgig::Struct::clone($dflt) }, %{ $given || {} } };
35
+ }
36
+ return \%out;
37
+ }
38
+
21
39
  $REGISTRY{make_options} = sub {
22
40
  my ($ctx) = @_;
23
41
  my $options = $ctx->{options} || {};
@@ -134,6 +152,9 @@ $REGISTRY{make_options} = sub {
134
152
  $opts->{feature} = \%fmap;
135
153
  }
136
154
 
155
+ my $fdefaults = ProjectNameUtilities::feature_defaults($config->{feature}, $opts->{feature});
156
+ $opts->{feature} = $fdefaults if defined $fdefaults;
157
+
137
158
  # THE OPTION SPEC IS GENERATED, NOT WRITTEN HERE.
138
159
  #
139
160
  # Built from the model: `main.kit.optspec` for the standard options, plus one
@@ -208,14 +229,15 @@ $REGISTRY{make_options} = sub {
208
229
  $opts->{base} = $resolved;
209
230
  }
210
231
 
211
- # Resolve the feature add-order: an explicit array order (above) wins;
212
- # otherwise order the map test-first, then the remaining names sorted, so
213
- # the outcome is deterministic and `test` is always the base transport.
214
- if (!@featureorder) {
232
+ # Resolve the feature add-order: an explicit array order (above) wins, and
233
+ # the names it leaves out follow it test-first, then sorted, so the outcome
234
+ # is deterministic and `test` is the base transport of a map.
235
+ {
215
236
  my $fmap = ProjectNameHelpers::to_map(
216
237
  ProjectNameHelpers::gp($opts, 'feature')) || {};
217
- my @names = sort keys %$fmap;
218
- @featureorder = (grep { 'test' eq $_ } @names)
238
+ my %given = map { $_ => 1 } @featureorder;
239
+ my @names = sort grep { !$given{$_} } keys %$fmap;
240
+ my @rest = (grep { 'test' eq $_ } @names)
219
241
  ? ('test', grep { 'test' ne $_ } @names)
220
242
  : @names;
221
243
 
@@ -225,12 +247,13 @@ $REGISTRY{make_options} = sub {
225
247
  # test - or first, when no test entry exists. Without this the
226
248
  # sorted default would init station last and wrap OUTSIDE the
227
249
  # recording features, turning its wire-truth events into fiction.
228
- my ($si) = grep { 'station' eq $featureorder[$_] } 0 .. $#featureorder;
250
+ my ($si) = grep { 'station' eq $rest[$_] } 0 .. $#rest;
229
251
  if (defined $si) {
230
- splice @featureorder, $si, 1;
231
- my ($ti) = grep { 'test' eq $featureorder[$_] } 0 .. $#featureorder;
232
- splice @featureorder, (defined $ti ? $ti + 1 : 0), 0, 'station';
252
+ splice @rest, $si, 1;
253
+ my ($ti) = grep { 'test' eq $rest[$_] } 0 .. $#rest;
254
+ splice @rest, (defined $ti ? $ti + 1 : 0), 0, 'station';
233
255
  }
256
+ push @featureorder, @rest;
234
257
  }
235
258
 
236
259
  $opts->{__derived__} = { 'featureorder' => \@featureorder };
@@ -99,6 +99,14 @@ class ProjectNameMetricsFeature extends ProjectNameBaseFeature
99
99
 
100
100
  $this->_bump($client->_metrics['total'], $ok, $dur);
101
101
  $this->_bump($client->_metrics['ops'][$key], $ok, $dur);
102
+
103
+ $sink = $this->options['sink'] ?? null;
104
+ if (is_callable($sink)) {
105
+ try {
106
+ $sink(($ctx->utility->clean)($ctx, $client->_metrics));
107
+ } catch (\Throwable $e) {
108
+ }
109
+ }
102
110
  }
103
111
 
104
112
  private function _bump(array &$bucket, bool $ok, float $dur): void
@@ -68,6 +68,8 @@ class ProjectNamePagingFeature extends ProjectNameBaseFeature
68
68
 
69
69
  if (($paging['cursor'] ?? null) !== null) {
70
70
  $spec->query[$cursor_param] = $paging['cursor'];
71
+ } elseif (is_string($paging['next'] ?? null) && !self::_foreign($paging['next'], $spec->base)) {
72
+ self::_follow($spec, $paging['next']);
71
73
  } elseif (($spec->query[$page_param] ?? null) === null) {
72
74
  $start_page = is_numeric($this->options['startPage'] ?? null)
73
75
  ? $this->options['startPage'] : 1;
@@ -149,6 +151,7 @@ class ProjectNamePagingFeature extends ProjectNameBaseFeature
149
151
  'nextPage' => $this->_num($this->_header($headers, 'x-next-page')),
150
152
  'next' => null,
151
153
  'cursor' => null,
154
+ 'foreign' => null,
152
155
  'hasMore' => false,
153
156
  ];
154
157
 
@@ -199,7 +202,11 @@ class ProjectNamePagingFeature extends ProjectNameBaseFeature
199
202
  // Body-level signals; snake_case forms are read first so camelCase wins.
200
203
  if (is_array($body)) {
201
204
  if (($body['next'] ?? null) !== null) {
202
- $paging['next'] = $paging['next'] ?? $body['next'];
205
+ if (self::_is_link($body['next'], $this->options['next'] ?? 'auto')) {
206
+ $paging['next'] = $paging['next'] ?? $body['next'];
207
+ } else {
208
+ $paging['cursor'] = $body['next'];
209
+ }
203
210
  }
204
211
  if (($body['next_cursor'] ?? null) !== null) {
205
212
  $paging['cursor'] = $body['next_cursor'];
@@ -226,6 +233,16 @@ class ProjectNamePagingFeature extends ProjectNameBaseFeature
226
233
  }
227
234
  }
228
235
 
236
+ // A link to another origin is recorded, never followed, and ends the walk.
237
+ $base = $ctx->spec !== null ? $ctx->spec->base : ($ctx->options['base'] ?? '');
238
+ if (is_string($paging['next']) && $ctx->spec !== null) {
239
+ $paging['next'] = self::_resolve($paging['next'], $ctx->spec->url ?? '');
240
+ }
241
+ if ($paging['next'] !== null && self::_foreign($paging['next'], $base)) {
242
+ $paging['foreign'] = $paging['next'];
243
+ $paging['next'] = null;
244
+ }
245
+
229
246
  // Cursor presence only INFERS another page. When the server stated
230
247
  // the answer outright — relay's `hasNextPage: false`, or a body
231
248
  // `hasMore` — that wins: a final page normally carries both an end
@@ -238,6 +255,10 @@ class ProjectNamePagingFeature extends ProjectNameBaseFeature
238
255
  || $paging['nextPage'] !== null;
239
256
  }
240
257
 
258
+ if ($paging['foreign'] !== null && $paging['cursor'] === null && $paging['nextPage'] === null) {
259
+ $paging['hasMore'] = false;
260
+ }
261
+
241
262
  $result->paging = $paging;
242
263
 
243
264
  // PHP arrays are values, so the record lands on this call's Control
@@ -249,6 +270,112 @@ class ProjectNamePagingFeature extends ProjectNameBaseFeature
249
270
  $this->client->_paging = ['last' => $paging];
250
271
  }
251
272
 
273
+ private const ORIGIN = '~^[a-z][a-z0-9+.-]*://[^/?#]*~i';
274
+
275
+ // Under the `next` option's default, a URL or an absolute path is a link
276
+ // and anything else a cursor; `cursor` and `url` pin the reading.
277
+ private static function _is_link(mixed $next, mixed $mode): bool
278
+ {
279
+ if (!is_string($next)) {
280
+ return false;
281
+ }
282
+ return $mode === 'url' || ($mode !== 'cursor'
283
+ && (preg_match(self::ORIGIN, $next) === 1 || str_starts_with($next, '/')));
284
+ }
285
+
286
+ private static function _origin(mixed $text): string
287
+ {
288
+ return is_string($text) && preg_match(self::ORIGIN, $text, $m) === 1 ? strtolower($m[0]) : '';
289
+ }
290
+
291
+ private static function _foreign(mixed $link, mixed $base): bool
292
+ {
293
+ $origin = self::_origin($link);
294
+ return $origin !== '' && $origin !== self::_origin($base);
295
+ }
296
+
297
+ // RFC 3986 reference resolution against the URL of the request that
298
+ // returned the link, by hand: PHP has no resolver. A link on that URL's
299
+ // origin comes back as its path and query; an absolute link is left as
300
+ // the server wrote it.
301
+ private static function _resolve(string $link, mixed $url): string
302
+ {
303
+ if (!is_string($url) || $url === '' || preg_match('~^[a-z][a-z0-9+.-]*:~i', $link) === 1) {
304
+ return $link;
305
+ }
306
+ $link = explode('#', $link, 2)[0];
307
+ $origin = preg_match(self::ORIGIN, $url, $m) === 1 ? $m[0] : '';
308
+ if (str_starts_with($link, '//')) {
309
+ return $origin === '' ? $link : explode(':', $origin, 2)[0] . ':' . $link;
310
+ }
311
+ $from = explode('?', explode('#', substr($url, strlen($origin)), 2)[0], 2);
312
+ $ref = explode('?', $link, 2);
313
+ if ($ref[0] === '') {
314
+ $path = $from[0];
315
+ $query = count($ref) > 1 ? $ref[1] : ($from[1] ?? null);
316
+ } else {
317
+ $query = $ref[1] ?? null;
318
+ if (str_starts_with($ref[0], '/')) {
319
+ $path = $ref[0];
320
+ } else {
321
+ $k = strrpos($from[0], '/');
322
+ $path = ($k === false ? '' : substr($from[0], 0, $k + 1)) . $ref[0];
323
+ }
324
+ $path = self::_remove_dots($path);
325
+ }
326
+ if (!str_starts_with($path, '/')) {
327
+ $path = '/' . $path;
328
+ }
329
+ return $path . ($query === null ? '' : '?' . $query);
330
+ }
331
+
332
+ // RFC 3986 section 5.2.4.
333
+ private static function _remove_dots(string $path): string
334
+ {
335
+ $abs = str_starts_with($path, '/');
336
+ $segs = explode('/', $path);
337
+ $out = [];
338
+ for ($i = $abs ? 1 : 0, $n = count($segs); $i < $n; $i++) {
339
+ $seg = $segs[$i];
340
+ if ($seg === '.' || $seg === '..') {
341
+ if ($seg === '..') {
342
+ array_pop($out);
343
+ }
344
+ if ($i === $n - 1) {
345
+ $out[] = '';
346
+ }
347
+ } else {
348
+ $out[] = $seg;
349
+ }
350
+ }
351
+ return ($abs ? '/' : '') . implode('/', $out);
352
+ }
353
+
354
+ // The request goes to the link's path and query, on the SDK's own origin.
355
+ private static function _follow(ProjectNameSpec $spec, string $next): void
356
+ {
357
+ $rest = explode('#', (string)preg_replace(self::ORIGIN, '', $next), 2)[0];
358
+ $parts = explode('?', $rest, 2);
359
+
360
+ $query = [];
361
+ foreach (explode('&', $parts[1] ?? '') as $pair) {
362
+ if ($pair === '') {
363
+ continue;
364
+ }
365
+ $kv = explode('=', $pair, 2);
366
+ $query[urldecode($kv[0])] = urldecode($kv[1] ?? '');
367
+ }
368
+ foreach ($spec->authquery as $key) {
369
+ $query[$key] = $spec->query[$key] ?? null;
370
+ }
371
+
372
+ $spec->base = preg_match(self::ORIGIN, $spec->base, $m) === 1 ? $m[0] : '';
373
+ $spec->prefix = '';
374
+ $spec->path = $parts[0];
375
+ $spec->suffix = '';
376
+ $spec->query = $query;
377
+ }
378
+
252
379
  private function _is_list(ProjectNameContext $ctx): bool
253
380
  {
254
381
  $ops = $this->options['ops'] ?? ['list'];
@@ -62,24 +62,20 @@ class ProjectNameRatelimitFeature extends ProjectNameBaseFeature
62
62
  ? (float)$this->options['rate'] : 5.0;
63
63
  $burst = is_numeric($this->options['burst'] ?? null) ? (float)$this->options['burst'] : $rate;
64
64
 
65
- // Refill according to elapsed time.
65
+ // Refill, then reserve this call's token before any wait: a negative
66
+ // count is the calls already queued, so overlapping calls pace in turn.
66
67
  $now = $this->_now();
67
68
  $elapsed = $now - $this->last;
68
69
  $this->last = $now;
69
- $this->tokens = min($burst, $this->tokens + ($elapsed / 1000.0) * $rate);
70
+ $this->tokens = min($burst, $this->tokens + ($elapsed / 1000.0) * $rate) - 1;
70
71
 
71
- if ($this->tokens >= 1) {
72
- $this->tokens -= 1;
72
+ if ($this->tokens >= 0) {
73
73
  return;
74
74
  }
75
75
 
76
- // Not enough tokens: wait for one to accrue, then consume it.
77
- $needed = 1 - $this->tokens;
78
- $wait_ms = (float)ceil(($needed / $rate) * 1000.0);
76
+ $wait_ms = (float)ceil((-$this->tokens / $rate) * 1000.0);
79
77
  $this->_track($ctx, $wait_ms);
80
78
  $this->_sleep($wait_ms);
81
- $this->last = $this->_now();
82
- $this->tokens = 0.0;
83
79
  }
84
80
 
85
81
  private function _now(): float
@@ -98,7 +98,7 @@ class ProjectNameRetryFeature extends ProjectNameBaseFeature
98
98
 
99
99
  private function _backoff(mixed $res, int $attempt, float $min_delay, float $max_delay, float $factor): float
100
100
  {
101
- // Honour a server-provided Retry-After (seconds) when present.
101
+ // A server-provided Retry-After wins over the computed backoff.
102
102
  $ra = $this->_retry_after($res);
103
103
  if ($ra !== null) {
104
104
  return min($max_delay, $ra);
@@ -122,10 +122,34 @@ class ProjectNameRetryFeature extends ProjectNameBaseFeature
122
122
  break;
123
123
  }
124
124
  }
125
- if ($v === null || !is_numeric($v)) {
125
+ if ($v === null || !is_scalar($v)) {
126
126
  return null;
127
127
  }
128
- return (float)$v * 1000.0;
128
+ return self::retry_after_ms((string)$v, microtime(true) * 1000.0);
129
+ }
130
+
131
+ private const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
132
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
133
+
134
+ // RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else null.
135
+ public static function retry_after_ms(string $value, float $now): ?float
136
+ {
137
+ $s = trim($value, " \t");
138
+ if (preg_match('/^[0-9]+$/D', $s)) {
139
+ return (float)$s * 1000.0;
140
+ }
141
+ $re = '/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), ([0-9]{2}) ([A-Z][a-z]{2}) ([0-9]{4}) '
142
+ . '([0-9]{2}):([0-9]{2}):([0-9]{2}) GMT$/D';
143
+ if (!preg_match($re, $s, $m)) {
144
+ return null;
145
+ }
146
+ $month = array_search($m[2], self::MONTHS, true);
147
+ [$day, $year, $hour, $min, $sec] = [(int)$m[1], (int)$m[3], (int)$m[4], (int)$m[5], (int)$m[6]];
148
+ if ($month === false || $day < 1 || $day > 31 || $hour > 23 || $min > 59 || $sec > 60) {
149
+ return null;
150
+ }
151
+ $at = (float)gmmktime($hour, $min, $sec, $month + 1, $day, $year) * 1000.0;
152
+ return max(0.0, $at - $now);
129
153
  }
130
154
 
131
155
  private function _sleep(mixed $ms): void
@@ -40,8 +40,9 @@ class ProjectNameStreamingFeature extends ProjectNameBaseFeature
40
40
  if (!$this->active || !$this->_streamable($ctx)) {
41
41
  return;
42
42
  }
43
+ // A failed result keeps no stream, so the entity's stream() raises its error.
43
44
  $result = $ctx->result;
44
- if ($result === null) {
45
+ if ($result === null || $result->err !== null) {
45
46
  return;
46
47
  }
47
48
 
@@ -18,7 +18,6 @@ class ProjectNameTelemetryFeature extends ProjectNameBaseFeature
18
18
  private mixed $client;
19
19
  private ?array $options;
20
20
  private ?\WeakMap $spans;
21
- private int $seq;
22
21
 
23
22
  public function __construct()
24
23
  {
@@ -29,7 +28,6 @@ class ProjectNameTelemetryFeature extends ProjectNameBaseFeature
29
28
  $this->client = null;
30
29
  $this->options = null;
31
30
  $this->spans = null;
32
- $this->seq = 0;
33
31
  }
34
32
 
35
33
  public function init(ProjectNameContext $ctx, array $options): void
@@ -38,7 +36,6 @@ class ProjectNameTelemetryFeature extends ProjectNameBaseFeature
38
36
  $this->options = $options;
39
37
  $this->active = ($options['active'] ?? null) === true;
40
38
  $this->spans = new \WeakMap();
41
- $this->seq = 0;
42
39
 
43
40
  if (!$this->active) {
44
41
  return;
@@ -142,10 +139,16 @@ class ProjectNameTelemetryFeature extends ProjectNameBaseFeature
142
139
  if (is_callable($idgen)) {
143
140
  return (string)$idgen($kind);
144
141
  }
145
- // Deterministic-ish sequential id; unique within a client instance.
146
- $this->seq++;
147
- $n = str_pad(dechex($this->seq), 4, '0', STR_PAD_LEFT);
148
- return ($kind === 'trace' ? 't' : 's') . str_pad($n, 16, '0', STR_PAD_RIGHT);
142
+ return self::randomHex($kind === 'trace' ? 16 : 8);
143
+ }
144
+
145
+ // W3C trace context: lowercase hex from the platform's random source, never all zeros.
146
+ private static function randomHex(int $bytes): string
147
+ {
148
+ do {
149
+ $hex = bin2hex(random_bytes($bytes));
150
+ } while (strspn($hex, '0') === strlen($hex));
151
+ return $hex;
149
152
  }
150
153
 
151
154
  private function _now(): float