@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
@@ -50,6 +50,9 @@ class PagingFeature extends BaseFeature {
50
50
  if (null != paging.cursor) {
51
51
  spec.query[cursorParam] = paging.cursor
52
52
  }
53
+ else if ('string' === typeof paging.next && !this._foreign(paging.next, spec.base)) {
54
+ this._follow(spec, paging.next)
55
+ }
53
56
  else if (null == spec.query[pageParam]) {
54
57
  // A record written back by PreResult holds the page just fetched as
55
58
  // `page` and the one to fetch as `nextPage`, so nextPage wins.
@@ -85,6 +88,7 @@ class PagingFeature extends BaseFeature {
85
88
  nextPage: this._num(this._header(headers, 'x-next-page')),
86
89
  next: undefined,
87
90
  cursor: undefined,
91
+ foreign: undefined,
88
92
  hasMore: false,
89
93
  }
90
94
 
@@ -120,7 +124,10 @@ class PagingFeature extends BaseFeature {
120
124
  }
121
125
 
122
126
  if (body && 'object' === typeof body) {
123
- if (null != body.next) { paging.next = paging.next || body.next }
127
+ if (null != body.next) {
128
+ if (this._isLink(body.next)) { paging.next = paging.next || body.next }
129
+ else { paging.cursor = body.next }
130
+ }
124
131
  if (null != body.next_cursor) { paging.cursor = body.next_cursor }
125
132
  if (null != body.cursor) { paging.cursor = body.cursor }
126
133
  if (null != body.nextCursor) { paging.cursor = body.nextCursor }
@@ -138,6 +145,16 @@ class PagingFeature extends BaseFeature {
138
145
  }
139
146
  }
140
147
 
148
+ // A link to another origin is recorded, never followed, and ends the walk.
149
+ const base = null == ctx.spec ? ctx.options?.base : ctx.spec.base
150
+ if (null != paging.next) {
151
+ paging.next = this._resolve(paging.next, ctx.spec?.url)
152
+ }
153
+ if (null != paging.next && this._foreign(paging.next, base)) {
154
+ paging.foreign = paging.next
155
+ paging.next = undefined
156
+ }
157
+
141
158
  // Cursor presence only INFERS another page. When the server stated the
142
159
  // answer outright — relay's `hasNextPage: false`, or a body `hasMore` —
143
160
  // that wins: a final page normally carries both an end cursor and
@@ -148,6 +165,10 @@ class PagingFeature extends BaseFeature {
148
165
  null != paging.next || null != paging.cursor || null != paging.nextPage
149
166
  }
150
167
 
168
+ if (null != paging.foreign && null == paging.cursor && null == paging.nextPage) {
169
+ paging.hasMore = false
170
+ }
171
+
151
172
  result.paging = paging
152
173
 
153
174
  if (null != ctx.ctrl) {
@@ -191,6 +212,83 @@ class PagingFeature extends BaseFeature {
191
212
  }
192
213
  }
193
214
 
215
+ // Under the `next` option's default, a URL or an absolute path is a link and
216
+ // anything else a cursor; `cursor` and `url` pin the reading.
217
+ _isLink(this: any, next: any): boolean {
218
+ if ('string' !== typeof next) { return false }
219
+ const mode = this._options.next || 'auto'
220
+ return 'url' === mode ||
221
+ ('cursor' !== mode && ('' !== this._origin(next) || next.startsWith('/')))
222
+ }
223
+
224
+
225
+ _origin(this: any, text: any): string {
226
+ const m = /^[a-z][a-z0-9+.-]*:\/\/[^/?#]*/i.exec('string' === typeof text ? text : '')
227
+ return null == m ? '' : m[0].toLowerCase()
228
+ }
229
+
230
+
231
+ _foreign(this: any, link: any, base: any): boolean {
232
+ const origin = this._origin(link)
233
+ return '' !== origin && origin !== this._origin(base)
234
+ }
235
+
236
+
237
+ // RFC 3986 reference resolution against the URL of the request that
238
+ // returned the link. A link on that URL's origin comes back as its path and
239
+ // query; an absolute link is left as the server wrote it.
240
+ _resolve(this: any, link: string, url: any): string {
241
+ if ('string' !== typeof url || '' === url || /^[a-z][a-z0-9+.-]*:/i.test(link)) {
242
+ return link
243
+ }
244
+ const bare = '' === this._origin(url)
245
+ const holder = 'http://placeholder.invalid'
246
+ try {
247
+ const from = new URL(bare ? holder + (url.startsWith('/') ? '' : '/') + url : url)
248
+ const out = new URL(link, from)
249
+ return out.origin === from.origin ? out.pathname + out.search : out.href
250
+ }
251
+ catch (_e) {
252
+ return link
253
+ }
254
+ }
255
+
256
+
257
+ // The request goes to the link's path and query, on the SDK's own origin.
258
+ _follow(this: any, spec: any, next: string) {
259
+ const link = /^(?:[a-z][a-z0-9+.-]*:\/\/[^/?#]*)?([^?#]*)(?:\?([^#]*))?/i.exec(next) as any
260
+ const origin = /^[a-z][a-z0-9+.-]*:\/\/[^/?#]*/i.exec(String(spec.base || ''))
261
+
262
+ const query: Record<string, any> = {}
263
+ for (const pair of (link[2] || '').split('&')) {
264
+ if ('' === pair) { continue }
265
+ const at = pair.indexOf('=')
266
+ const key = at < 0 ? pair : pair.slice(0, at)
267
+ const val = at < 0 ? '' : pair.slice(at + 1)
268
+ query[this._unescape(key)] = this._unescape(val)
269
+ }
270
+ for (const key of (spec.authquery || [])) {
271
+ query[key] = spec.query[key]
272
+ }
273
+
274
+ spec.base = null == origin ? '' : origin[0]
275
+ spec.prefix = ''
276
+ spec.path = link[1]
277
+ spec.suffix = ''
278
+ spec.query = query
279
+ }
280
+
281
+
282
+ _unescape(this: any, text: string): string {
283
+ try {
284
+ return decodeURIComponent(text.replace(/\+/g, ' '))
285
+ }
286
+ catch (err) {
287
+ return text
288
+ }
289
+ }
290
+
291
+
194
292
  _isList(this: any, ctx: any): boolean {
195
293
  const ops = this._options.ops || ['list']
196
294
  return ops.indexOf(ctx.op && ctx.op.name) >= 0
@@ -44,24 +44,20 @@ class RatelimitFeature extends BaseFeature {
44
44
  const rate = this._options.rate || 5
45
45
  const burst = null == this._options.burst ? rate : this._options.burst
46
46
 
47
- // Refill according to elapsed time.
47
+ // Refill, then reserve this call's token before any wait: a negative
48
+ // count is the calls already queued, so overlapping calls pace in turn.
48
49
  const now = this._now()
49
50
  const elapsed = now - this._last
50
51
  this._last = now
51
- this._tokens = Math.min(burst, this._tokens + (elapsed / 1000) * rate)
52
+ this._tokens = Math.min(burst, this._tokens + (elapsed / 1000) * rate) - 1
52
53
 
53
- if (this._tokens >= 1) {
54
- this._tokens -= 1
54
+ if (this._tokens >= 0) {
55
55
  return
56
56
  }
57
57
 
58
- // Not enough tokens: wait for one to accrue, then consume it.
59
- const needed = 1 - this._tokens
60
- const waitMs = Math.ceil((needed / rate) * 1000)
58
+ const waitMs = Math.ceil((-this._tokens / rate) * 1000)
61
59
  this._track(ctx, waitMs)
62
60
  await this._sleep(waitMs, signal)
63
- this._last = this._now()
64
- this._tokens = 0
65
61
  }
66
62
 
67
63
 
@@ -102,7 +102,7 @@ class RetryFeature extends BaseFeature {
102
102
 
103
103
 
104
104
  _backoff(this: any, res: any, attempt: number, minDelay: number, maxDelay: number, factor: number): number {
105
- // Honour a server-provided Retry-After (seconds) when present.
105
+ // A server-provided Retry-After wins over the computed backoff.
106
106
  const ra = this._retryAfter(res)
107
107
  if (null != ra) {
108
108
  return Math.min(maxDelay, ra)
@@ -127,8 +127,7 @@ class RetryFeature extends BaseFeature {
127
127
  if (null == v) {
128
128
  return null
129
129
  }
130
- const n = Number(v)
131
- return isNaN(n) ? null : n * 1000
130
+ return retryAfterMs(String(v), Date.now())
132
131
  }
133
132
 
134
133
 
@@ -162,6 +161,29 @@ class RetryFeature extends BaseFeature {
162
161
  }
163
162
 
164
163
 
164
+ const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
165
+
166
+ const IMF_FIXDATE =
167
+ /^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) ([A-Z][a-z]{2}) (\d{4}) (\d{2}):(\d{2}):(\d{2}) GMT$/
168
+
169
+
170
+ // RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else null.
171
+ function retryAfterMs(value: string, now: number): number | null {
172
+ const s = value.replace(/^[ \t]+|[ \t]+$/g, '')
173
+ if (/^[0-9]+$/.test(s)) {
174
+ return Number(s) * 1000
175
+ }
176
+ const m = IMF_FIXDATE.exec(s)
177
+ const month = null == m ? -1 : MONTHS.indexOf(m[2])
178
+ if (null == m || month < 0 || +m[1] < 1 || 31 < +m[1] ||
179
+ 23 < +m[4] || 59 < +m[5] || 60 < +m[6]) {
180
+ return null
181
+ }
182
+ const at = Date.UTC(+m[3], month, +m[1], +m[4], +m[5], +m[6])
183
+ return Math.max(0, at - now)
184
+ }
185
+
186
+
165
187
  export {
166
188
  RetryFeature
167
189
  }
@@ -25,8 +25,9 @@ class StreamingFeature extends BaseFeature {
25
25
  if (!this._streamable(ctx)) {
26
26
  return
27
27
  }
28
+ // A failed result keeps no stream, so the entity's stream() raises its error.
28
29
  const result = ctx.result
29
- if (null == result) {
30
+ if (null == result || null != result.err) {
30
31
  return
31
32
  }
32
33
 
@@ -5,6 +5,16 @@ import type { ProjectNameSDK } from '../../ProjectNameSDK'
5
5
  import { BaseFeature } from '../base/BaseFeature'
6
6
 
7
7
 
8
+ // W3C trace context: lowercase hex from the platform's random source, never all zeros.
9
+ function randomHex(bytes: number): string {
10
+ const buf = new Uint8Array(bytes)
11
+ do {
12
+ globalThis.crypto.getRandomValues(buf)
13
+ } while (buf.every((b) => 0 === b))
14
+ return Array.from(buf, (b) => b.toString(16).padStart(2, '0')).join('')
15
+ }
16
+
17
+
8
18
  class TelemetryFeature extends BaseFeature {
9
19
  version = '0.0.1'
10
20
  name = 'telemetry'
@@ -13,7 +23,6 @@ class TelemetryFeature extends BaseFeature {
13
23
  _client?: ProjectNameSDK
14
24
  _options: any = {}
15
25
  _spans: WeakMap<object, any> = new WeakMap()
16
- _seq = 0
17
26
 
18
27
 
19
28
  init(ctx: Context, options: FeatureOptions): void | Promise<any> {
@@ -21,7 +30,6 @@ class TelemetryFeature extends BaseFeature {
21
30
  this._options = options || {}
22
31
  this.active = (options as any).active
23
32
  this._spans = new WeakMap()
24
- this._seq = 0
25
33
 
26
34
  const client: any = this._client
27
35
  if (null == client._telemetry) {
@@ -104,10 +112,7 @@ class TelemetryFeature extends BaseFeature {
104
112
  if ('function' === typeof idgen) {
105
113
  return idgen(kind)
106
114
  }
107
- // Deterministic-ish sequential id; unique within a client instance.
108
- this._seq++
109
- const n = this._seq.toString(16).padStart(4, '0')
110
- return (kind === 'trace' ? 't' : 's') + n.padEnd(16, '0')
115
+ return randomHex('trace' === kind ? 16 : 8)
111
116
  }
112
117
 
113
118
 
@@ -289,10 +289,7 @@ class TestFeature extends BaseFeature {
289
289
  return respond(404, undefined, { statusText: 'Unknown operation' })
290
290
  }
291
291
 
292
- // Optional network behaviour simulation over the mock transport. Enable
293
- // per test via `SDK.test({ net: { latency, failTimes, ... } })`. When
294
- // `net` is absent the mock behaves exactly as before (no wrapping), so
295
- // existing generated tests are unaffected.
292
+ // Network simulation over the mock, when `SDK.test({ net })` asks for it.
296
293
  const net = this._options.net
297
294
  ctx.utility.fetcher = (null == net) ? testFetcher : this.makeNetsim(net, testFetcher)
298
295
  }
@@ -416,13 +413,17 @@ class TestFeature extends BaseFeature {
416
413
  }
417
414
 
418
415
  const match = ctx.match || {}
416
+ const data = ctx.data || {}
419
417
  const names: any[] = [...keysof(args)]
420
418
 
419
+ // With no id in the call, the entity's held id (or composite parts) stands in.
421
420
  if (null == getprop(args, 'id')) {
422
- for (const part of (getpath(ctx.config, [
423
- 'entity', getprop(ctx.entity, 'name'), 'id', 'parts']) || [])) {
421
+ const parts = getpath(ctx.config, ['entity', getprop(ctx.entity, 'name'), 'id', 'parts']) ||
422
+ ('list' === opname ? [] : ['id'])
423
+ for (const part of parts) {
424
424
  const pname = String(part)
425
- if (!names.includes(pname) && null != getprop(match, pname)) {
425
+ if (!names.includes(pname) &&
426
+ (null != getprop(match, pname) || null != getprop(data, pname))) {
426
427
  names.push(pname)
427
428
  }
428
429
  }
@@ -45,6 +45,11 @@ function makeOptions(ctx: Context) {
45
45
  opts = { ...opts, feature: fmap }
46
46
  }
47
47
 
48
+ const fdefaults = featureDefaults(struct, config.feature, opts.feature)
49
+ if (fdefaults !== opts.feature) {
50
+ opts = { ...opts, feature: fdefaults }
51
+ }
52
+
48
53
  const customUtils = opts.utility || {}
49
54
  for (let [key, val] of items(customUtils)) {
50
55
  setprop(utility, key, val)
@@ -58,6 +63,7 @@ function makeOptions(ctx: Context) {
58
63
  opts = merge([{}, struct.clone(cfgopts), opts])
59
64
 
60
65
  try {
66
+ refuseStrayKeys(opts, optspec)
61
67
  opts = validate(opts, optspec)
62
68
  }
63
69
  catch (err: any) {
@@ -95,11 +101,12 @@ function makeOptions(ctx: Context) {
95
101
  })
96
102
  }
97
103
 
98
- // Resolve the feature add-order: an explicit array order (above) wins;
99
- // otherwise order the map test-first, then the remaining names sorted, so
100
- // the outcome is deterministic and `test` is always the base transport.
101
- if (0 === featureorder.length) {
102
- let names = Object.keys(opts.feature || {}).sort()
104
+ // Resolve the feature add-order: an explicit array order (above) wins, and
105
+ // the names it leaves out follow it test-first, then sorted, so the outcome
106
+ // is deterministic and `test` is the base transport of a map.
107
+ {
108
+ let names = Object.keys(opts.feature || {})
109
+ .filter((n: string) => !featureorder.includes(n)).sort()
103
110
  names = names.indexOf('test') < 0
104
111
  ? names
105
112
  : ['test'].concat(names.filter((n: string) => 'test' !== n))
@@ -108,7 +115,7 @@ function makeOptions(ctx: Context) {
108
115
  names.splice(si, 1)
109
116
  names.splice(names.indexOf('test') + 1, 0, 'station')
110
117
  }
111
- featureorder = names
118
+ featureorder = featureorder.concat(names)
112
119
  }
113
120
 
114
121
  opts.__derived__ = { featureorder }
@@ -122,6 +129,50 @@ function makeOptions(ctx: Context) {
122
129
  return opts
123
130
  }
124
131
 
132
+ // Before validate: the struct's own refusal prints the value without its
133
+ // functions, so a misspelled callback key would go unnamed.
134
+ function refuseStrayKeys(opts: any, optspec: any) {
135
+ const fspecs = optspec.feature || {}
136
+ for (const [name, fopts] of Object.entries<any>(opts.feature || {})) {
137
+ const spec = specMap(fspecs[name])
138
+ if (null == spec || spec['`$OPEN`'] || null == fopts || 'object' !== typeof fopts) {
139
+ continue
140
+ }
141
+ const stray = Object.keys(fopts)
142
+ .filter((k) => undefined !== fopts[k] && !Object.prototype.hasOwnProperty.call(spec, k))
143
+ if (0 < stray.length) {
144
+ throw new Error('Unexpected keys at field feature.' + name + ': ' + stray.join(', '))
145
+ }
146
+ }
147
+ }
148
+
149
+
150
+ function specMap(spec: any): any {
151
+ const alts = Array.isArray(spec) ? spec.slice('`$NOF`' === spec[0] ? 2 : 0) : [spec]
152
+ return alts.find((a: any) => null != a && 'object' === typeof a && !Array.isArray(a))
153
+ }
154
+
155
+
156
+ // The model's options for a feature sit beneath the caller's, key by key: a
157
+ // key the caller sets replaces the default whole, so a list is never merged.
158
+ function featureDefaults(struct: any, cfgfeature: any, feature: any): any {
159
+ const isMap = (b: any) => null != b && 'object' === typeof b && !Array.isArray(b)
160
+ if (null != feature && !isMap(feature)) {
161
+ return feature
162
+ }
163
+ const out: any = { ...(feature || {}) }
164
+ for (const name of Object.keys(cfgfeature || {})) {
165
+ const dflt = cfgfeature[name]?.options
166
+ const given = out[name]
167
+ if (!isMap(dflt) || (null == given && true !== dflt.active) ||
168
+ (null != given && !isMap(given))) {
169
+ continue
170
+ }
171
+ out[name] = { ...struct.clone(dflt), ...(given || {}) }
172
+ }
173
+ return null == feature && 0 === Object.keys(out).length ? feature : out
174
+ }
175
+
125
176
 
126
177
  // Registration skips entity blocks, and rbac's rules, keyed by entity and op names.
127
178
  function settings(opts: any): any {
@@ -29,11 +29,15 @@ type OpRef = {
29
29
 
30
30
  // A scripted transport built from a case's `res` list. Responses are consumed
31
31
  // in order and the last one repeats, so a case that does not care how many
32
- // attempts happen need only declare one.
33
- function scriptedFetcher(res: any[]) {
32
+ // attempts happen need only declare one. Each URL it is sent is kept in `sent`,
33
+ // and the time it was sent in `at`; a `cut` response is one whose body stops
34
+ // before its end.
35
+ function scriptedFetcher(res: any[], sent: string[] = [], at: number[] = []) {
34
36
  let n = -1
35
- return async function (_ctx: any, _url: string, _fetchdef: any) {
37
+ return async function (_ctx: any, url: string, _fetchdef: any) {
36
38
  n++
39
+ sent.push(url)
40
+ at.push(Date.now())
37
41
  const spec = res[n < res.length ? n : res.length - 1] || {}
38
42
 
39
43
  if (true === spec.throw) {
@@ -47,7 +51,10 @@ function scriptedFetcher(res: any[]) {
47
51
  status,
48
52
  statusText: status < 400 ? 'OK' : 'ERR',
49
53
  body: 'not-used',
50
- json: async () => (undefined === spec.body ? {} : spec.body),
54
+ json: async () => {
55
+ if (true === spec.cut) { throw new TypeError('terminated') }
56
+ return undefined === spec.body ? {} : spec.body
57
+ },
51
58
  headers: {
52
59
  get(key: string) {
53
60
  const lower = String(key).toLowerCase()
@@ -63,11 +70,11 @@ function scriptedFetcher(res: any[]) {
63
70
  }
64
71
 
65
72
 
66
- function makeClient(kase: any): any {
73
+ function makeClient(kase: any, sent: string[] = [], at: number[] = []): any {
67
74
  return new (SDK as any)({
68
75
  test: { active: true },
69
76
  feature: kase.feature,
70
- utility: { fetcher: scriptedFetcher(kase.res || [{ status: 200, body: {} }]) },
77
+ utility: { fetcher: scriptedFetcher(kase.res || [{ status: 200, body: {} }], sent, at) },
71
78
  })
72
79
  }
73
80
 
@@ -161,8 +168,9 @@ async function usableItem(entity: string): Promise<OpRef | undefined> {
161
168
 
162
169
 
163
170
  // A step may wait before its call, may add request headers for its call, and
164
- // may pass `args` as the operation's first argument.
165
- async function runStep(client: any, ref: OpRef, step: any) {
171
+ // may pass `args` as the operation's first argument. A `stream` step reads the
172
+ // operation through the entity's stream(), and `items` is how many it yields.
173
+ async function runStep(client: any, ref: OpRef, step: any, ctrl: any) {
166
174
  if (null != step.wait) {
167
175
  await new Promise((resolve) => setTimeout(resolve, step.wait))
168
176
  }
@@ -172,13 +180,52 @@ async function runStep(client: any, ref: OpRef, step: any) {
172
180
  options.headers = { ...(prior || {}), ...step.headers }
173
181
  }
174
182
  try {
175
- await client[ref.accessor]()[ref.op]({ ...(step.args || {}) }, step.ctrl || {})
183
+ if (true === step.stream) {
184
+ let items = 0
185
+ for await (const _item of client[ref.accessor]().stream(ref.op, { ...(step.args || {}) }, { ctrl })) {
186
+ items++
187
+ }
188
+ if (null != step.items) {
189
+ deepStrictEqual(items, step.items, `${ref.key}: items streamed`)
190
+ }
191
+ }
192
+ else {
193
+ await client[ref.accessor]()[ref.op]({ ...(step.args || {}) }, ctrl)
194
+ }
176
195
  }
177
196
  finally {
178
197
  options.headers = prior
179
198
  }
180
199
  }
181
200
 
201
+ // A step with `together: N` makes N overlapping calls; each call's error, or
202
+ // undefined, is returned.
203
+ async function runCalls(client: any, ref: OpRef, step: any, ctrl: any): Promise<any[]> {
204
+ const calls = Array.from({ length: null == step.together ? 1 : step.together },
205
+ () => runStep(client, ref, step, ctrl).then(() => undefined, (e: any) => e))
206
+ return Promise.all(calls)
207
+ }
208
+
209
+
210
+ // Each request a case expects, in order: its path, and its whole query. A
211
+ // path is compared without its leading slash, which an SDK with no base omits.
212
+ function checkSent(sent: string[], expect: any[], label: string) {
213
+ deepStrictEqual(sent.length, expect.length, `${label}: requests sent: ${sent.join(' | ')}`)
214
+ expect.forEach((want: any, i: number) => {
215
+ const url = new URL(sent[i], 'http://corpus.invalid')
216
+ if (null != want.path) {
217
+ deepStrictEqual(url.pathname.replace(/^\/+/, ''), want.path.replace(/^\/+/, ''),
218
+ `${label}: request ${i} path`)
219
+ }
220
+ if (null != want.query) {
221
+ const query: Record<string, string> = {}
222
+ url.searchParams.forEach((v, k) => { query[k] = v })
223
+ deepStrictEqual(query, want.query, `${label}: request ${i} query`)
224
+ }
225
+ })
226
+ }
227
+
228
+
182
229
  // Replace #OP1/#OP2 throughout a case, keys included.
183
230
  function resolve(node: any, tokens: Record<string, string>): any {
184
231
  if ('string' === typeof node) {
@@ -239,10 +286,26 @@ function subset(actual: any, expect: any, path: string) {
239
286
  }
240
287
  return
241
288
  }
289
+ if (Array.isArray(expect)) {
290
+ ok(Array.isArray(actual) && actual.length === expect.length,
291
+ `${path}: want ${expect.length} item(s), got ${JSON.stringify(actual)}`)
292
+ expect.forEach((e: any, i: number) => subset(actual[i], e, `${path}[${i}]`))
293
+ return
294
+ }
242
295
  deepStrictEqual(actual, expect, path)
243
296
  }
244
297
 
245
298
 
299
+ // The most requests the transport saw in any window of `ms`.
300
+ function busiest(sent: number[], ms: number): number {
301
+ let most = 0
302
+ for (let i = 0; i < sent.length; i++) {
303
+ most = Math.max(most, sent.filter((t) => sent[i] <= t && t < sent[i] + ms).length)
304
+ }
305
+ return most
306
+ }
307
+
308
+
246
309
  describe('FeatureCorpus', () => {
247
310
 
248
311
  let corpus: any
@@ -346,29 +409,36 @@ describe('FeatureCorpus', () => {
346
409
 
347
410
  // Every failing case is reported, not only the first.
348
411
  try {
349
- const client = makeClient(kase)
412
+ const sent: string[] = []
413
+ const at: number[] = []
414
+ const client = makeClient(kase, sent, at)
350
415
 
416
+ // A case-level ctrl is one control object every step shares.
351
417
  for (const step of (kase.op || [])) {
352
418
  const ref = byKey[step.op]
353
419
  ok(null != ref, `${kase.name}: no operation ${step.op}`)
354
- let err: any = undefined
355
- try {
356
- await runStep(client, ref, step)
357
- }
358
- catch (e: any) {
359
- err = e
360
- }
361
- if (null == step.err) {
362
- ok(undefined === err,
363
- `${kase.name}: ${step.op} failed unexpectedly: ${err?.message}`)
364
- continue
365
- }
366
- ok(undefined !== err, `${kase.name}: ${step.op} was expected to fail, and did not`)
367
- if ('string' === typeof step.err) {
368
- deepStrictEqual(err.code, step.err, `${kase.name}: wrong error code`)
420
+ for (const err of await runCalls(client, ref, step, step.ctrl || kase.ctrl || {})) {
421
+ if (null == step.err) {
422
+ ok(undefined === err,
423
+ `${kase.name}: ${step.op} failed unexpectedly: ${err?.message}`)
424
+ continue
425
+ }
426
+ ok(undefined !== err, `${kase.name}: ${step.op} was expected to fail, and did not`)
427
+ if ('string' === typeof step.err) {
428
+ deepStrictEqual(err.code, step.err, `${kase.name}: wrong error code`)
429
+ }
369
430
  }
370
431
  }
371
432
 
433
+ if (null != kase.pace) {
434
+ const most = busiest(at, kase.pace.ms)
435
+ ok(most <= kase.pace.max, `${kase.name}: ${most} requests within ${kase.pace.ms} ms, ` +
436
+ `want at most ${kase.pace.max}`)
437
+ }
438
+
439
+ if (null != kase.sent) {
440
+ checkSent(sent, kase.sent, kase.name)
441
+ }
372
442
  subset(client[`_${name}`], kase.out, `${kase.name}: _${name}`)
373
443
  deepStrictEqual(shared(), PRISTINE,
374
444
  `${kase.name}: the case wrote onto Object or Object.prototype`)
@@ -379,6 +379,17 @@ describe('feature', () => {
379
379
  strictEqual(m.total.err, 1)
380
380
  strictEqual(m.ops['widget.load'].count, 2)
381
381
  })
382
+
383
+ test('the sink gets the counters once per operation', async () => {
384
+ const seen: any[] = []
385
+ const h = makeClient({ features: [
386
+ { name: 'metrics', options: { sink: (m: any) => seen.push(m) } },
387
+ ] })
388
+ await h.op({ op: 'load' })
389
+ await h.op({ op: 'list' })
390
+ deepStrictEqual(seen.map((m) => m.total.count), [1, 2])
391
+ strictEqual(seen[1].ops['widget.list'].count, 1)
392
+ })
382
393
  })
383
394
 
384
395
 
@@ -732,7 +743,9 @@ describe('feature', () => {
732
743
  test('default id generation and no exporter', async () => {
733
744
  const h = makeClient({ features: [{ name: 'telemetry' }] })
734
745
  await h.op({ op: 'load' })
735
- ok(/^t/.test(h.client._telemetry.spans[0].traceId))
746
+ const span = h.client._telemetry.spans[0]
747
+ ok(/^[0-9a-f]{32}$/.test(span.traceId) && !/^0+$/.test(span.traceId), span.traceId)
748
+ ok(/^[0-9a-f]{16}$/.test(span.spanId) && !/^0+$/.test(span.spanId), span.spanId)
736
749
  })
737
750
  })
738
751