@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
@@ -881,6 +881,124 @@ defmodule ProjectName.FeatureTest do
881
881
  end
882
882
  end
883
883
 
884
+ # The documented hasMore loop, one request per page.
885
+ defp paging_walk(reply, options \\ %{}) do
886
+ {server, calls} = FH.recording_server(fn n, _fd -> {reply.(n), nil} end)
887
+ h = harness([fspec("paging", options)], %{server: server})
888
+ paging = S.jm([])
889
+ ctrl = S.jm(["paging", paging])
890
+ FH.op(h, %{op: "list", path: "/w", ctrl: ctrl})
891
+
892
+ Enum.reduce_while(1..3, nil, fn _, _ ->
893
+ if S.getprop(paging, "hasMore") == true and S.size(calls) < 4 do
894
+ FH.op(h, %{op: "list", path: "/w", ctrl: ctrl})
895
+ {:cont, nil}
896
+ else
897
+ {:halt, nil}
898
+ end
899
+ end)
900
+
901
+ {for(i <- 0..(S.size(calls) - 1), do: call_url(calls, i)), paging}
902
+ end
903
+
904
+ test "paging body next that is not a URL is sent back as the cursor" do
905
+ if has?("paging") do
906
+ pages = ["c3", "c6", nil]
907
+ {urls, paging} = paging_walk(fn n -> FH.make_response(200, H.deep(%{"next" => Enum.at(pages, n - 1)})) end)
908
+ assert urls == ["http://api.test/w?page=1", "http://api.test/w?cursor=c3", "http://api.test/w?cursor=c6"]
909
+ assert S.getprop(paging, "hasMore") == false
910
+ end
911
+ end
912
+
913
+ test "paging body next URL is the next request" do
914
+ if has?("paging") do
915
+ pages = ["http://api.test/v2/w?cursor=c%2F3&limit=3", "/v2/w?cursor=c6", nil]
916
+ {urls, paging} = paging_walk(fn n -> FH.make_response(200, H.deep(%{"next" => Enum.at(pages, n - 1)})) end)
917
+
918
+ assert urls == [
919
+ "http://api.test/w?page=1",
920
+ "http://api.test/v2/w?cursor=c%2F3&limit=3",
921
+ "http://api.test/v2/w?cursor=c6"
922
+ ]
923
+
924
+ assert S.getprop(paging, "hasMore") == false
925
+ end
926
+ end
927
+
928
+ test "paging a query-only Link keeps the path" do
929
+ if has?("paging") do
930
+ links = ["</v1/items?page=2>; rel=\"next\"", "<?page=3>; rel=\"next\""]
931
+
932
+ {urls, _paging} =
933
+ paging_walk(fn n ->
934
+ case Enum.at(links, n - 1) do
935
+ nil -> FH.make_response(200, H.deep([]))
936
+ link -> FH.make_response(200, H.deep([]), H.deep(%{"link" => link}))
937
+ end
938
+ end)
939
+
940
+ assert urls == ["http://api.test/w?page=1", "http://api.test/v1/items?page=2", "http://api.test/v1/items?page=3"]
941
+ end
942
+ end
943
+
944
+ test "paging a path-relative Link resolves against the request" do
945
+ if has?("paging") do
946
+ links = ["</v1/items?page=2>; rel=\"next\"", "<more?page=3>; rel=\"next\""]
947
+
948
+ {urls, _paging} =
949
+ paging_walk(fn n ->
950
+ case Enum.at(links, n - 1) do
951
+ nil -> FH.make_response(200, H.deep([]))
952
+ link -> FH.make_response(200, H.deep([]), H.deep(%{"link" => link}))
953
+ end
954
+ end)
955
+
956
+ assert urls == ["http://api.test/w?page=1", "http://api.test/v1/items?page=2", "http://api.test/v1/more?page=3"]
957
+ end
958
+ end
959
+
960
+ test "paging Link next URL is the next request" do
961
+ if has?("paging") do
962
+ links = ["<http://api.test/w?after=b3>; rel=\"next\"", "</w?after=b6>; rel=\"next\""]
963
+
964
+ {urls, paging} =
965
+ paging_walk(fn n ->
966
+ case Enum.at(links, n - 1) do
967
+ nil -> FH.make_response(200, H.deep([]))
968
+ link -> FH.make_response(200, H.deep([]), H.deep(%{"link" => link}))
969
+ end
970
+ end)
971
+
972
+ assert urls == ["http://api.test/w?page=1", "http://api.test/w?after=b3", "http://api.test/w?after=b6"]
973
+ assert S.getprop(paging, "hasMore") == false
974
+ end
975
+ end
976
+
977
+ test "paging a link to another origin ends the walk" do
978
+ if has?("paging") do
979
+ {urls, paging} =
980
+ paging_walk(fn _n ->
981
+ FH.make_response(200, H.deep([]), H.deep(%{"link" => "<https://elsewhere.test/w?after=b3>; rel=\"next\""}))
982
+ end)
983
+
984
+ assert urls == ["http://api.test/w?page=1"]
985
+ assert S.getprop(paging, "hasMore") == false
986
+ assert S.getprop(paging, "foreign") == "https://elsewhere.test/w?after=b3"
987
+ end
988
+ end
989
+
990
+ test "paging next cursor sends a value starting with a slash as the cursor" do
991
+ if has?("paging") do
992
+ pages = ["/c3", nil]
993
+
994
+ {urls, paging} =
995
+ paging_walk(fn n -> FH.make_response(200, H.deep(%{"next" => Enum.at(pages, n - 1)})) end, %{"next" => "cursor"})
996
+
997
+ assert urls == ["http://api.test/w?page=1", "http://api.test/w?cursor=%2Fc3"]
998
+ assert S.getprop(paging, "hasMore") == false
999
+ end
1000
+ end
1001
+
884
1002
  test "paging non-list op is not paged" do
885
1003
  if has?("paging") do
886
1004
  {server, calls} = FH.recording_server()
@@ -918,6 +1036,25 @@ defmodule ProjectName.FeatureTest do
918
1036
  end
919
1037
  end
920
1038
 
1039
+ test "streaming keeps no stream on a failed result" do
1040
+ if has?("streaming") do
1041
+ {server, _calls} = FH.recording_server(fn _n, _fd -> {FH.make_response(503, H.deep([])), nil} end)
1042
+ h = harness([fspec("streaming")], %{server: server})
1043
+ res = FH.op(h, %{op: "list", path: "/w"})
1044
+ assert S.getprop(res.result, "stream") == nil
1045
+ assert S.getprop(res.result, "streaming") == nil
1046
+ end
1047
+ end
1048
+
1049
+ test "streaming an empty list streams nothing" do
1050
+ if has?("streaming") do
1051
+ {server, _calls} = FH.recording_server(fn _n, _fd -> {FH.make_response(200, H.deep([])), nil} end)
1052
+ h = harness([fspec("streaming")], %{server: server})
1053
+ res = FH.op(h, %{op: "list", path: "/w"})
1054
+ assert S.getprop(res.result, "stream").() == []
1055
+ end
1056
+ end
1057
+
921
1058
  test "streaming non-list op is not streamed" do
922
1059
  if has?("streaming") do
923
1060
  h = harness([fspec("streaming")])
@@ -96,7 +96,5 @@ func (f *AuditFeature) emit(ctx *core.Context, outcome string) {
96
96
  f.Records = f.Records[1:]
97
97
  }
98
98
 
99
- if sink, ok := f.options["sink"].(func(map[string]any)); ok {
100
- sink(record)
101
- }
99
+ fsink(f.options["sink"], record)
102
100
  }
@@ -38,6 +38,17 @@ func fclean(ctx *core.Context, record map[string]any) map[string]any {
38
38
  return record
39
39
  }
40
40
 
41
+ // A sink's panic or returned error never changes the operation's outcome.
42
+ func fsink(sink any, record map[string]any) {
43
+ defer func() { _ = recover() }()
44
+ switch fn := sink.(type) {
45
+ case func(map[string]any):
46
+ fn(record)
47
+ case func(map[string]any) error:
48
+ _ = fn(record)
49
+ }
50
+ }
51
+
41
52
  func (f *BaseFeature) GetVersion() string { return f.Version }
42
53
  func (f *BaseFeature) GetName() string { return f.Name }
43
54
  func (f *BaseFeature) GetActive() bool { return f.Active }
@@ -90,6 +90,20 @@ func (f *MetricsFeature) record(ctx *core.Context, ok bool) {
90
90
 
91
91
  f.bump(f.Total, ok, dur)
92
92
  f.bump(op, ok, dur)
93
+
94
+ if f.options["sink"] != nil {
95
+ ops := map[string]any{}
96
+ for k, b := range f.Ops {
97
+ ops[k] = b.record()
98
+ }
99
+ fsink(f.options["sink"], fclean(ctx, map[string]any{"total": f.Total.record(), "ops": ops}))
100
+ }
101
+ }
102
+
103
+ func (b *MetricsBucket) record() map[string]any {
104
+ return map[string]any{
105
+ "count": b.Count, "ok": b.Ok, "err": b.Err, "totalMs": b.TotalMs, "maxMs": b.MaxMs,
106
+ }
93
107
  }
94
108
 
95
109
  func (f *MetricsFeature) bump(bucket *MetricsBucket, ok bool, dur int64) {
@@ -1,7 +1,9 @@
1
1
  package feature
2
2
 
3
3
  import (
4
+ "net/url"
4
5
  "regexp"
6
+ "strings"
5
7
 
6
8
  vs "github.com/voxgig/struct"
7
9
 
@@ -19,6 +21,85 @@ type PagingFeature struct {
19
21
 
20
22
  var pagingLinkNextRe = regexp.MustCompile(`(?i)<([^>]+)>\s*;\s*rel="?next"?`)
21
23
 
24
+ var pagingOriginRe = regexp.MustCompile(`(?i)^[a-z][a-z0-9+.-]*://[^/?#]*`)
25
+
26
+ // Under the `next` option's default, a URL or an absolute path is a link and
27
+ // anything else a cursor; `cursor` and `url` pin the reading.
28
+ func pagingIsLink(next any, mode string) bool {
29
+ s, ok := next.(string)
30
+ if !ok {
31
+ return false
32
+ }
33
+ return mode == "url" ||
34
+ (mode != "cursor" && (pagingOriginRe.MatchString(s) || strings.HasPrefix(s, "/")))
35
+ }
36
+
37
+ func pagingOrigin(text string) string {
38
+ return strings.ToLower(pagingOriginRe.FindString(text))
39
+ }
40
+
41
+ func pagingForeign(link string, base string) bool {
42
+ origin := pagingOrigin(link)
43
+ return origin != "" && origin != pagingOrigin(base)
44
+ }
45
+
46
+ var pagingSchemeRe = regexp.MustCompile(`(?i)^[a-z][a-z0-9+.-]*:`)
47
+
48
+ // RFC 3986 reference resolution against the URL of the request that
49
+ // returned the link. A link on that URL's origin comes back as its path and
50
+ // query; an absolute link is left as the server wrote it.
51
+ func pagingResolve(link string, requrl string) string {
52
+ if requrl == "" || pagingSchemeRe.MatchString(link) {
53
+ return link
54
+ }
55
+ from, err := url.Parse(requrl)
56
+ if err != nil {
57
+ return link
58
+ }
59
+ ref, err := url.Parse(link)
60
+ if err != nil {
61
+ return link
62
+ }
63
+ out := from.ResolveReference(ref)
64
+ if out.Scheme == from.Scheme && out.Host == from.Host {
65
+ out.Scheme, out.Host, out.User = "", "", nil
66
+ }
67
+ out.Fragment = ""
68
+ return out.String()
69
+ }
70
+
71
+ // The request goes to the link's path and query, on the SDK's own origin.
72
+ func pagingFollow(spec *core.Spec, next string) {
73
+ rest := strings.TrimPrefix(next, pagingOriginRe.FindString(next))
74
+ rest, _, _ = strings.Cut(rest, "#")
75
+ path, rawquery, _ := strings.Cut(rest, "?")
76
+
77
+ query := map[string]any{}
78
+ for _, pair := range strings.Split(rawquery, "&") {
79
+ if pair == "" {
80
+ continue
81
+ }
82
+ key, val, _ := strings.Cut(pair, "=")
83
+ query[pagingUnescape(key)] = pagingUnescape(val)
84
+ }
85
+ for _, key := range spec.AuthQuery {
86
+ query[key] = spec.Query[key]
87
+ }
88
+
89
+ spec.Base = pagingOriginRe.FindString(spec.Base)
90
+ spec.Prefix = ""
91
+ spec.Path = path
92
+ spec.Suffix = ""
93
+ spec.Query = query
94
+ }
95
+
96
+ func pagingUnescape(text string) string {
97
+ if out, err := url.QueryUnescape(text); err == nil {
98
+ return out
99
+ }
100
+ return text
101
+ }
102
+
22
103
  func NewPagingFeature() *PagingFeature {
23
104
  return &PagingFeature{
24
105
  BaseFeature: BaseFeature{
@@ -67,6 +148,8 @@ func (f *PagingFeature) PreRequest(ctx *core.Context) {
67
148
 
68
149
  if cursor, has := paging["cursor"]; has && cursor != nil {
69
150
  spec.Query[cursorParam] = cursor
151
+ } else if next, ok := paging["next"].(string); ok && !pagingForeign(next, spec.Base) {
152
+ pagingFollow(spec, next)
70
153
  } else if spec.Query[pageParam] == nil {
71
154
  // A record written back by PreResult holds the page just fetched as
72
155
  // "page" and the one to fetch as "nextPage", so nextPage wins.
@@ -184,8 +267,12 @@ func (f *PagingFeature) PreResult(ctx *core.Context) {
184
267
 
185
268
  // Body-level signals; snake_case forms are read first so camelCase wins.
186
269
  if bm, ok := body.(map[string]any); ok {
187
- if bm["next"] != nil && paging["next"] == nil {
188
- paging["next"] = bm["next"]
270
+ if bm["next"] != nil {
271
+ if !pagingIsLink(bm["next"], foptStr(f.options, "next", "auto")) {
272
+ paging["cursor"] = bm["next"]
273
+ } else if paging["next"] == nil {
274
+ paging["next"] = bm["next"]
275
+ }
189
276
  }
190
277
  if bm["next_cursor"] != nil {
191
278
  paging["cursor"] = bm["next_cursor"]
@@ -218,6 +305,21 @@ func (f *PagingFeature) PreResult(ctx *core.Context) {
218
305
  }
219
306
  }
220
307
 
308
+ // A link to another origin is recorded, never followed, and ends the walk.
309
+ base := ""
310
+ if ctx.Spec != nil {
311
+ base = ctx.Spec.Base
312
+ } else if b, ok := ctx.Options["base"].(string); ok {
313
+ base = b
314
+ }
315
+ if link, ok := paging["next"].(string); ok && ctx.Spec != nil {
316
+ paging["next"] = pagingResolve(link, ctx.Spec.Url)
317
+ }
318
+ if link, ok := paging["next"].(string); ok && pagingForeign(link, base) {
319
+ paging["foreign"] = link
320
+ delete(paging, "next")
321
+ }
322
+
221
323
  // Cursor presence only INFERS another page. When the server stated the
222
324
  // answer outright — relay's `hasNextPage: false`, or a body `hasMore` —
223
325
  // that wins: a final page normally carries both an end cursor and
@@ -228,6 +330,10 @@ func (f *PagingFeature) PreResult(ctx *core.Context) {
228
330
  paging["hasMore"] = true
229
331
  }
230
332
 
333
+ if paging["foreign"] != nil && paging["cursor"] == nil && paging["nextPage"] == nil {
334
+ paging["hasMore"] = false
335
+ }
336
+
231
337
  result.Paging = paging
232
338
  f.Last = paging
233
339
 
@@ -2,6 +2,7 @@ package feature
2
2
 
3
3
  import (
4
4
  "math"
5
+ "sync"
5
6
 
6
7
  "GOMODULE/core"
7
8
  )
@@ -10,6 +11,7 @@ type RatelimitFeature struct {
10
11
  BaseFeature
11
12
  client *core.ProjectNameSDK
12
13
  options map[string]any
14
+ mu sync.Mutex
13
15
  tokens float64
14
16
  last int64
15
17
 
@@ -51,32 +53,32 @@ func (f *RatelimitFeature) Init(ctx *core.Context, options map[string]any) {
51
53
  }
52
54
 
53
55
  func (f *RatelimitFeature) acquire() {
56
+ if waitMs := f.reserve(); waitMs > 0 {
57
+ foptSleep(f.options)(waitMs)
58
+ }
59
+ }
60
+
61
+ // reserve refills the bucket and takes this call's token under the lock,
62
+ // before any wait: a negative count is the calls already queued, so
63
+ // overlapping calls pace in turn.
64
+ func (f *RatelimitFeature) reserve() int {
54
65
  rate := foptNum(f.options, "rate", 5)
55
66
  burst := foptNum(f.options, "burst", rate)
56
67
 
57
- // Refill according to elapsed time.
68
+ f.mu.Lock()
69
+ defer f.mu.Unlock()
70
+
58
71
  now := foptNow(f.options)()
59
72
  elapsed := now - f.last
60
73
  f.last = now
61
- f.tokens = math.Min(burst, f.tokens+(float64(elapsed)/1000)*rate)
74
+ f.tokens = math.Min(burst, f.tokens+(float64(elapsed)/1000)*rate) - 1
62
75
 
63
- if f.tokens >= 1 {
64
- f.tokens -= 1
65
- return
76
+ if f.tokens >= 0 {
77
+ return 0
66
78
  }
67
79
 
68
- // Not enough tokens: wait for one to accrue, then consume it.
69
- needed := 1 - f.tokens
70
- waitMs := int(math.Ceil((needed / rate) * 1000))
71
- f.track(waitMs)
72
- if waitMs > 0 {
73
- foptSleep(f.options)(waitMs)
74
- }
75
- f.last = foptNow(f.options)()
76
- f.tokens = 0
77
- }
78
-
79
- func (f *RatelimitFeature) track(waitMs int) {
80
+ waitMs := int(math.Ceil((-f.tokens / rate) * 1000))
80
81
  f.Throttled++
81
82
  f.WaitMs += waitMs
83
+ return waitMs
82
84
  }
@@ -3,6 +3,9 @@ package feature
3
3
  import (
4
4
  "math"
5
5
  "math/rand"
6
+ "reflect"
7
+ "strings"
8
+ "time"
6
9
 
7
10
  "GOMODULE/core"
8
11
  )
@@ -80,11 +83,7 @@ func (f *RetryFeature) retryable(res any, err error) bool {
80
83
  if !ok {
81
84
  return false
82
85
  }
83
- statuses := foptList(f.options, "statuses")
84
- if statuses == nil {
85
- statuses = []any{408, 425, 429, 500, 502, 503, 504}
86
- }
87
- for _, s := range statuses {
86
+ for _, s := range f.statuses() {
88
87
  switch n := s.(type) {
89
88
  case int:
90
89
  if n == status {
@@ -103,8 +102,26 @@ func (f *RetryFeature) retryable(res any, err error) bool {
103
102
  return false
104
103
  }
105
104
 
105
+ // statuses is the option as given, of any slice type; only an absent or
106
+ // nil option takes the default, so an empty list retries no status.
107
+ func (f *RetryFeature) statuses() []any {
108
+ raw, has := f.options["statuses"]
109
+ if !has || raw == nil {
110
+ return []any{408, 425, 429, 500, 502, 503, 504}
111
+ }
112
+ v := reflect.ValueOf(raw)
113
+ if v.Kind() != reflect.Slice && v.Kind() != reflect.Array {
114
+ return []any{408, 425, 429, 500, 502, 503, 504}
115
+ }
116
+ out := make([]any, v.Len())
117
+ for i := range out {
118
+ out[i] = v.Index(i).Interface()
119
+ }
120
+ return out
121
+ }
122
+
106
123
  func (f *RetryFeature) backoff(res any, attempt int, minDelay int, maxDelay int, factor float64) int {
107
- // Honour a server-provided Retry-After (seconds) when present.
124
+ // A server-provided Retry-After wins over the computed backoff.
108
125
  if ra, ok := f.retryAfter(res); ok {
109
126
  if ra > maxDelay {
110
127
  return maxDelay
@@ -128,11 +145,66 @@ func (f *RetryFeature) retryAfter(res any) (int, bool) {
128
145
  if !ok {
129
146
  return 0, false
130
147
  }
131
- seconds := fparseInt(v, -1)
132
- if seconds < 0 {
148
+ return fretryAfterMs(v, time.Now().UnixMilli())
149
+ }
150
+
151
+ // fretryAfterMs reads Retry-After by RFC 9110: delay-seconds or an
152
+ // IMF-fixdate; anything else is not a delay.
153
+ func fretryAfterMs(value string, now int64) (int, bool) {
154
+ s := strings.Trim(value, " \t")
155
+ if s != "" && strings.Trim(s, "0123456789") == "" {
156
+ seconds := int64(0)
157
+ for _, c := range s {
158
+ if seconds < math.MaxInt32 {
159
+ seconds = seconds*10 + int64(c-'0')
160
+ }
161
+ }
162
+ if seconds > math.MaxInt32/1000 {
163
+ return math.MaxInt32, true
164
+ }
165
+ return int(seconds * 1000), true
166
+ }
167
+ at, ok := fimfFixdate(s)
168
+ if !ok {
169
+ return 0, false
170
+ }
171
+ if at <= now {
172
+ return 0, true
173
+ }
174
+ if at-now > math.MaxInt32 {
175
+ return math.MaxInt32, true
176
+ }
177
+ return int(at - now), true
178
+ }
179
+
180
+ // fimfFixdate parses "Sun, 06 Nov 1994 08:49:37 GMT" to epoch ms.
181
+ func fimfFixdate(s string) (int64, bool) {
182
+ if len(s) != 29 || s[3:5] != ", " || s[7] != ' ' || s[11] != ' ' || s[16] != ' ' ||
183
+ s[19] != ':' || s[22] != ':' || s[25:] != " GMT" ||
184
+ !strings.Contains(" Mon Tue Wed Thu Fri Sat Sun ", " "+s[0:3]+" ") {
185
+ return 0, false
186
+ }
187
+ month := strings.Index("JanFebMarAprMayJunJulAugSepOctNovDec", s[8:11])
188
+ if month < 0 || month%3 != 0 {
189
+ return 0, false
190
+ }
191
+ num := func(from, to int) int {
192
+ n := 0
193
+ for _, c := range s[from:to] {
194
+ if c < '0' || c > '9' {
195
+ return -1
196
+ }
197
+ n = n*10 + int(c-'0')
198
+ }
199
+ return n
200
+ }
201
+ day, year, hour, min, sec := num(5, 7), num(12, 16), num(17, 19), num(20, 22), num(23, 25)
202
+ if day < 1 || day > 31 || year < 0 || hour < 0 || hour > 23 || min < 0 || min > 59 ||
203
+ sec < 0 || sec > 60 {
133
204
  return 0, false
134
205
  }
135
- return seconds * 1000, true
206
+ at := time.Date(year, time.Month(month/3+1), day, hour, min, sec, 0, time.UTC)
207
+ return at.UnixMilli(), true
136
208
  }
137
209
 
138
210
  func (f *RetryFeature) sleep(ms int) {
@@ -33,8 +33,9 @@ func (f *StreamingFeature) PreResult(ctx *core.Context) {
33
33
  if !f.Active || !f.streamable(ctx) {
34
34
  return
35
35
  }
36
+ // A failed result keeps no stream, so the entity's Stream raises its error.
36
37
  result := ctx.Result
37
- if result == nil {
38
+ if result == nil || result.Err != nil {
38
39
  return
39
40
  }
40
41
 
@@ -1,7 +1,8 @@
1
1
  package feature
2
2
 
3
3
  import (
4
- "fmt"
4
+ "crypto/rand"
5
+ "encoding/hex"
5
6
 
6
7
  "GOMODULE/core"
7
8
  )
@@ -10,7 +11,6 @@ type TelemetryFeature struct {
10
11
  BaseFeature
11
12
  client *core.ProjectNameSDK
12
13
  options map[string]any
13
- seq int
14
14
 
15
15
  // Activity tracking (mirrors the ts client._telemetry record).
16
16
  Spans []map[string]any
@@ -33,7 +33,6 @@ func (f *TelemetryFeature) Init(ctx *core.Context, options map[string]any) {
33
33
  f.client = ctx.Client
34
34
  f.options = options
35
35
  f.Active = foptBool(options, "active", false)
36
- f.seq = 0
37
36
  }
38
37
 
39
38
  func (f *TelemetryFeature) PrePoint(ctx *core.Context) {
@@ -123,15 +122,23 @@ func (f *TelemetryFeature) id(kind string) string {
123
122
  if idgen, ok := f.options["idgen"].(func(string) string); ok {
124
123
  return idgen(kind)
125
124
  }
126
- // Deterministic-ish sequential id; unique within a client instance.
127
- f.seq++
128
- n := fmt.Sprintf("%04x", f.seq)
129
- prefix := "s"
130
125
  if kind == "trace" {
131
- prefix = "t"
126
+ return randomHex(16)
132
127
  }
133
- for len(n) < 16 {
134
- n += "0"
128
+ return randomHex(8)
129
+ }
130
+
131
+ // W3C trace context: lowercase hex from the platform's random source, never all zeros.
132
+ func randomHex(n int) string {
133
+ buf := make([]byte, n)
134
+ for {
135
+ if _, err := rand.Read(buf); err != nil {
136
+ panic(err)
137
+ }
138
+ for _, b := range buf {
139
+ if b != 0 {
140
+ return hex.EncodeToString(buf)
141
+ }
142
+ }
135
143
  }
136
- return prefix + n
137
144
  }