@voxgig/sdkgen 4.50.0 → 4.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (400) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/dist/cmp/ReadmeExplanation.js +5 -2
  3. package/dist/cmp/ReadmeExplanation.js.map +1 -1
  4. package/dist/cmp/ReadmeFeatures.js +20 -6
  5. package/dist/cmp/ReadmeFeatures.js.map +1 -1
  6. package/dist/helpers/optspec.js +2 -2
  7. package/dist/helpers/optspec.js.map +1 -1
  8. package/dist/tsconfig.tsbuildinfo +1 -1
  9. package/model/sdkgen.aontu +1 -1
  10. package/package.json +1 -1
  11. package/project/.sdk/model/feature/audit.aontu +1 -1
  12. package/project/.sdk/model/feature/cache.aontu +7 -5
  13. package/project/.sdk/model/feature/clienttrack.aontu +1 -1
  14. package/project/.sdk/model/feature/cost.aontu +1 -1
  15. package/project/.sdk/model/feature/debug.aontu +1 -1
  16. package/project/.sdk/model/feature/idempotency.aontu +1 -1
  17. package/project/.sdk/model/feature/log.aontu +1 -1
  18. package/project/.sdk/model/feature/metrics.aontu +3 -1
  19. package/project/.sdk/model/feature/netsim.aontu +1 -1
  20. package/project/.sdk/model/feature/paging.aontu +4 -1
  21. package/project/.sdk/model/feature/proxy.aontu +1 -1
  22. package/project/.sdk/model/feature/ratelimit.aontu +3 -3
  23. package/project/.sdk/model/feature/rbac.aontu +1 -1
  24. package/project/.sdk/model/feature/retry.aontu +1 -1
  25. package/project/.sdk/model/feature/secrets.aontu +1 -1
  26. package/project/.sdk/model/feature/streaming.aontu +1 -1
  27. package/project/.sdk/model/feature/telemetry.aontu +2 -2
  28. package/project/.sdk/model/feature/test.aontu +1 -1
  29. package/project/.sdk/model/feature/timeout.aontu +1 -1
  30. package/project/.sdk/model/feature/validate.aontu +1 -1
  31. package/project/.sdk/model/target/lua.aontu +6 -0
  32. package/project/.sdk/src/cmp/c/Config_c.ts +3 -134
  33. package/project/.sdk/src/cmp/c/TestClean_c.ts +26 -11
  34. package/project/.sdk/src/cmp/c/fragment/Entity.fragment.c +17 -10
  35. package/project/.sdk/src/cmp/clojure/TestClean_clojure.ts +10 -5
  36. package/project/.sdk/src/cmp/clojure/fragment/Entity.fragment.clj +18 -1
  37. package/project/.sdk/src/cmp/cpp/TestClean_cpp.ts +15 -1
  38. package/project/.sdk/src/cmp/csharp/TestClean_csharp.ts +9 -0
  39. package/project/.sdk/src/cmp/csharp/fragment/EntityBase.fragment.cs +30 -2
  40. package/project/.sdk/src/cmp/csharp/fragment/Main.fragment.cs +31 -12
  41. package/project/.sdk/src/cmp/elixir/TestClean_elixir.ts +13 -4
  42. package/project/.sdk/src/cmp/elixir/fragment/Main.fragment.ex +51 -15
  43. package/project/.sdk/src/cmp/elixir/fragment/Pipeline.fragment.ex +17 -0
  44. package/project/.sdk/src/cmp/go/TestClean_go.ts +39 -3
  45. package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +42 -2
  46. package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +42 -14
  47. package/project/.sdk/src/cmp/java/TestClean_java.ts +17 -4
  48. package/project/.sdk/src/cmp/java/fragment/EntityBase.fragment.java +21 -0
  49. package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +13 -8
  50. package/project/.sdk/src/cmp/js/TestClean_js.ts +13 -5
  51. package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +26 -2
  52. package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +8 -0
  53. package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +8 -0
  54. package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +8 -0
  55. package/project/.sdk/src/cmp/js/fragment/EntityPatchOp.fragment.js +8 -0
  56. package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +8 -0
  57. package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +8 -0
  58. package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +12 -5
  59. package/project/.sdk/src/cmp/kotlin/TestClean_kotlin.ts +31 -4
  60. package/project/.sdk/src/cmp/kotlin/fragment/EntityBase.fragment.kt +19 -0
  61. package/project/.sdk/src/cmp/lua/TestClean_lua.ts +14 -4
  62. package/project/.sdk/src/cmp/lua/fragment/Entity.fragment.lua +42 -5
  63. package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +44 -10
  64. package/project/.sdk/src/cmp/lua/utility_lua.ts +2 -1
  65. package/project/.sdk/src/cmp/ocaml/TestClean_ocaml.ts +20 -5
  66. package/project/.sdk/src/cmp/ocaml/fragment/RunOp.fragment.ml +36 -21
  67. package/project/.sdk/src/cmp/perl/TestClean_perl.ts +13 -4
  68. package/project/.sdk/src/cmp/perl/fragment/Entity.fragment.pm +21 -0
  69. package/project/.sdk/src/cmp/perl/fragment/Main.fragment.pm +31 -12
  70. package/project/.sdk/src/cmp/php/TestClean_php.ts +10 -3
  71. package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +33 -4
  72. package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +13 -6
  73. package/project/.sdk/src/cmp/py/TestClean_py.ts +10 -3
  74. package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +25 -2
  75. package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +26 -12
  76. package/project/.sdk/src/cmp/rb/TestClean_rb.ts +11 -4
  77. package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +23 -2
  78. package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +27 -11
  79. package/project/.sdk/src/cmp/rust/TestClean_rust.ts +24 -17
  80. package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +22 -2
  81. package/project/.sdk/src/cmp/scala/TestClean_scala.ts +45 -11
  82. package/project/.sdk/src/cmp/scala/fragment/EntityBase.fragment.scala +14 -0
  83. package/project/.sdk/src/cmp/swift/TestClean_swift.ts +31 -21
  84. package/project/.sdk/src/cmp/swift/fragment/EntityBase.fragment.swift +9 -0
  85. package/project/.sdk/src/cmp/swift/fragment/Main.fragment.swift +24 -10
  86. package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +13 -8
  87. package/project/.sdk/src/cmp/ts/TestClean_ts.ts +13 -5
  88. package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +26 -2
  89. package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +8 -0
  90. package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +8 -0
  91. package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +8 -0
  92. package/project/.sdk/src/cmp/ts/fragment/EntityPatchOp.fragment.ts +8 -0
  93. package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +8 -0
  94. package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +8 -0
  95. package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +12 -5
  96. package/project/.sdk/src/cmp/zig/TestClean_zig.ts +23 -11
  97. package/project/.sdk/src/cmp/zig/fragment/Entity.fragment.zig +17 -10
  98. package/project/.sdk/src/cmp/zig/fragment/Main.fragment.zig +41 -6
  99. package/project/.sdk/tm/c/core/context.c +1 -0
  100. package/project/.sdk/tm/c/core/sdk.h +7 -4
  101. package/project/.sdk/tm/c/feature/cache.c +243 -13
  102. package/project/.sdk/tm/c/feature/metrics.c +7 -0
  103. package/project/.sdk/tm/c/feature/paging.c +231 -2
  104. package/project/.sdk/tm/c/feature/ratelimit.c +5 -9
  105. package/project/.sdk/tm/c/feature/retry.c +51 -4
  106. package/project/.sdk/tm/c/feature/secrets.c +27 -38
  107. package/project/.sdk/tm/c/feature/streaming.c +2 -1
  108. package/project/.sdk/tm/c/feature/telemetry.c +19 -18
  109. package/project/.sdk/tm/c/feature/test.c +78 -54
  110. package/project/.sdk/tm/c/tests/feature_test.c +288 -0
  111. package/project/.sdk/tm/c/tests/primary_utility_test.c +2 -0
  112. package/project/.sdk/tm/c/utility/clean.c +26 -33
  113. package/project/.sdk/tm/c/utility/make_options.c +89 -17
  114. package/project/.sdk/tm/clojure/feature/secrets/sdk/feature/secrets.clj +14 -11
  115. package/project/.sdk/tm/clojure/src/sdk/client.clj +3 -1
  116. package/project/.sdk/tm/clojure/src/sdk/core.clj +50 -22
  117. package/project/.sdk/tm/clojure/src/sdk/features.clj +279 -80
  118. package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +103 -1
  119. package/project/.sdk/tm/clojure/test/sdk/test/pipeline.clj +1 -0
  120. package/project/.sdk/tm/cpp/Makefile +5 -0
  121. package/project/.sdk/tm/cpp/core/types.hpp +148 -72
  122. package/project/.sdk/tm/cpp/feature/audit.hpp +12 -8
  123. package/project/.sdk/tm/cpp/feature/cache.hpp +188 -9
  124. package/project/.sdk/tm/cpp/feature/metrics.hpp +19 -0
  125. package/project/.sdk/tm/cpp/feature/paging.hpp +160 -2
  126. package/project/.sdk/tm/cpp/feature/ratelimit.hpp +18 -14
  127. package/project/.sdk/tm/cpp/feature/retry.hpp +46 -5
  128. package/project/.sdk/tm/cpp/feature/secrets.hpp +12 -0
  129. package/project/.sdk/tm/cpp/feature/streaming.hpp +2 -1
  130. package/project/.sdk/tm/cpp/feature/telemetry.hpp +17 -10
  131. package/project/.sdk/tm/cpp/feature/test.hpp +63 -53
  132. package/project/.sdk/tm/cpp/test/feature_test.cpp +236 -0
  133. package/project/.sdk/tm/cpp/utility/pipeline.hpp +44 -12
  134. package/project/.sdk/tm/csharp/core/Context.cs +4 -0
  135. package/project/.sdk/tm/csharp/feature/AuditFeature.cs +8 -1
  136. package/project/.sdk/tm/csharp/feature/CacheFeature.cs +126 -12
  137. package/project/.sdk/tm/csharp/feature/MetricsFeature.cs +23 -0
  138. package/project/.sdk/tm/csharp/feature/PagingFeature.cs +130 -3
  139. package/project/.sdk/tm/csharp/feature/RatelimitFeature.cs +26 -19
  140. package/project/.sdk/tm/csharp/feature/RetryFeature.cs +41 -7
  141. package/project/.sdk/tm/csharp/feature/SecretsFeature.cs +9 -27
  142. package/project/.sdk/tm/csharp/feature/StreamingFeature.cs +2 -1
  143. package/project/.sdk/tm/csharp/feature/TelemetryFeature.cs +11 -9
  144. package/project/.sdk/tm/csharp/feature/TestFeature.cs +55 -67
  145. package/project/.sdk/tm/csharp/test/FeatureTest.cs +238 -0
  146. package/project/.sdk/tm/csharp/utility/Clean.cs +5 -10
  147. package/project/.sdk/tm/csharp/utility/Fetcher.cs +7 -1
  148. package/project/.sdk/tm/csharp/utility/MakeOptions.cs +94 -24
  149. package/project/.sdk/tm/elixir/lib/projectname/context.ex +2 -0
  150. package/project/.sdk/tm/elixir/lib/projectname/feature/cache.ex +146 -30
  151. package/project/.sdk/tm/elixir/lib/projectname/feature/metrics.ex +13 -0
  152. package/project/.sdk/tm/elixir/lib/projectname/feature/paging.ex +110 -5
  153. package/project/.sdk/tm/elixir/lib/projectname/feature/ratelimit.ex +6 -12
  154. package/project/.sdk/tm/elixir/lib/projectname/feature/retry.ex +33 -9
  155. package/project/.sdk/tm/elixir/lib/projectname/feature/secrets.ex +10 -56
  156. package/project/.sdk/tm/elixir/lib/projectname/feature/streaming.ex +2 -1
  157. package/project/.sdk/tm/elixir/lib/projectname/feature/telemetry.ex +7 -7
  158. package/project/.sdk/tm/elixir/lib/projectname/feature/test.ex +52 -48
  159. package/project/.sdk/tm/elixir/lib/projectname/utility.ex +77 -47
  160. package/project/.sdk/tm/elixir/test/feature_test.exs +198 -0
  161. package/project/.sdk/tm/go/core/context.go +6 -0
  162. package/project/.sdk/tm/go/feature/audit_feature.go +1 -3
  163. package/project/.sdk/tm/go/feature/base_feature.go +11 -0
  164. package/project/.sdk/tm/go/feature/cache_feature.go +131 -4
  165. package/project/.sdk/tm/go/feature/metrics_feature.go +14 -0
  166. package/project/.sdk/tm/go/feature/paging_feature.go +108 -2
  167. package/project/.sdk/tm/go/feature/ratelimit_feature.go +19 -17
  168. package/project/.sdk/tm/go/feature/retry_feature.go +81 -9
  169. package/project/.sdk/tm/go/feature/secrets_feature.go +17 -71
  170. package/project/.sdk/tm/go/feature/streaming_feature.go +2 -1
  171. package/project/.sdk/tm/go/feature/telemetry_feature.go +18 -11
  172. package/project/.sdk/tm/go/feature/test_feature.go +65 -55
  173. package/project/.sdk/tm/go/test/feature_corpus_test.go +357 -28
  174. package/project/.sdk/tm/go/test/feature_test.go +93 -0
  175. package/project/.sdk/tm/go/utility/clean.go +5 -7
  176. package/project/.sdk/tm/go/utility/fetcher.go +11 -0
  177. package/project/.sdk/tm/go/utility/make_options.go +116 -13
  178. package/project/.sdk/tm/java/core/Context.java +9 -0
  179. package/project/.sdk/tm/java/core/SdkClient.java +43 -14
  180. package/project/.sdk/tm/java/feature/AuditFeature.java +5 -1
  181. package/project/.sdk/tm/java/feature/CacheFeature.java +123 -17
  182. package/project/.sdk/tm/java/feature/MetricsFeature.java +31 -0
  183. package/project/.sdk/tm/java/feature/PagingFeature.java +156 -2
  184. package/project/.sdk/tm/java/feature/RatelimitFeature.java +15 -13
  185. package/project/.sdk/tm/java/feature/RetryFeature.java +33 -6
  186. package/project/.sdk/tm/java/feature/SecretsFeature.java +9 -92
  187. package/project/.sdk/tm/java/feature/StreamingFeature.java +2 -1
  188. package/project/.sdk/tm/java/feature/TelemetryFeature.java +17 -9
  189. package/project/.sdk/tm/java/feature/TestFeature.java +50 -63
  190. package/project/.sdk/tm/java/test/FeatureCorpusTest.java +309 -17
  191. package/project/.sdk/tm/java/test/FeatureTest.java +60 -0
  192. package/project/.sdk/tm/java/utility/Clean.java +6 -10
  193. package/project/.sdk/tm/java/utility/Fetcher.java +5 -1
  194. package/project/.sdk/tm/java/utility/MakeOptions.java +131 -15
  195. package/project/.sdk/tm/js/src/Context.js +4 -0
  196. package/project/.sdk/tm/js/src/feature/cache/CacheFeature.js +118 -11
  197. package/project/.sdk/tm/js/src/feature/cost/CostFeature.js +3 -2
  198. package/project/.sdk/tm/js/src/feature/metrics/MetricsFeature.js +9 -4
  199. package/project/.sdk/tm/js/src/feature/paging/PagingFeature.js +103 -5
  200. package/project/.sdk/tm/js/src/feature/ratelimit/RatelimitFeature.js +5 -9
  201. package/project/.sdk/tm/js/src/feature/rbac/RbacFeature.js +4 -4
  202. package/project/.sdk/tm/js/src/feature/retry/RetryFeature.js +25 -3
  203. package/project/.sdk/tm/js/src/feature/secrets/SecretsFeature.js +16 -6
  204. package/project/.sdk/tm/js/src/feature/streaming/StreamingFeature.js +2 -1
  205. package/project/.sdk/tm/js/src/feature/telemetry/TelemetryFeature.js +11 -6
  206. package/project/.sdk/tm/js/src/feature/test/TestFeature.js +38 -1
  207. package/project/.sdk/tm/js/src/feature/validate/ValidateFeature.js +2 -1
  208. package/project/.sdk/tm/js/src/utility/CleanUtility.js +1 -1
  209. package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +61 -12
  210. package/project/.sdk/tm/js/test/feature/Corpus.test.js +191 -23
  211. package/project/.sdk/tm/js/test/feature/harness.js +3 -3
  212. package/project/.sdk/tm/js/test/feature.test.js +14 -1
  213. package/project/.sdk/tm/js/test/pipeline.test.js +1 -1
  214. package/project/.sdk/tm/kotlin/core/Context.kt +3 -0
  215. package/project/.sdk/tm/kotlin/core/SdkClient.kt +23 -10
  216. package/project/.sdk/tm/kotlin/feature/AuditFeature.kt +5 -1
  217. package/project/.sdk/tm/kotlin/feature/CacheFeature.kt +102 -7
  218. package/project/.sdk/tm/kotlin/feature/MetricsFeature.kt +22 -0
  219. package/project/.sdk/tm/kotlin/feature/PagingFeature.kt +125 -2
  220. package/project/.sdk/tm/kotlin/feature/RatelimitFeature.kt +16 -13
  221. package/project/.sdk/tm/kotlin/feature/RetryFeature.kt +36 -14
  222. package/project/.sdk/tm/kotlin/feature/SecretsFeature.kt +10 -20
  223. package/project/.sdk/tm/kotlin/feature/StreamingFeature.kt +4 -0
  224. package/project/.sdk/tm/kotlin/feature/TelemetryFeature.kt +12 -10
  225. package/project/.sdk/tm/kotlin/feature/TestFeature.kt +45 -48
  226. package/project/.sdk/tm/kotlin/test/FeatureTest.kt +173 -0
  227. package/project/.sdk/tm/kotlin/utility/CoreUtil.kt +5 -5
  228. package/project/.sdk/tm/kotlin/utility/Fetcher.kt +4 -0
  229. package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +86 -15
  230. package/project/.sdk/tm/lua/core/context.lua +6 -0
  231. package/project/.sdk/tm/lua/feature/cache_feature.lua +212 -15
  232. package/project/.sdk/tm/lua/feature/debug_feature.lua +2 -3
  233. package/project/.sdk/tm/lua/feature/metrics_feature.lua +5 -0
  234. package/project/.sdk/tm/lua/feature/paging_feature.lua +143 -2
  235. package/project/.sdk/tm/lua/feature/ratelimit_feature.lua +5 -9
  236. package/project/.sdk/tm/lua/feature/retry_feature.lua +43 -5
  237. package/project/.sdk/tm/lua/feature/secrets_feature.lua +15 -80
  238. package/project/.sdk/tm/lua/feature/streaming_feature.lua +2 -1
  239. package/project/.sdk/tm/lua/feature/telemetry_feature.lua +18 -7
  240. package/project/.sdk/tm/lua/feature/test_feature.lua +60 -62
  241. package/project/.sdk/tm/lua/test/feature_test.lua +181 -3
  242. package/project/.sdk/tm/lua/utility/clean.lua +6 -9
  243. package/project/.sdk/tm/lua/utility/fetcher.lua +9 -0
  244. package/project/.sdk/tm/lua/utility/make_options.lua +60 -18
  245. package/project/.sdk/tm/ocaml/feature/secrets_feature.ml +21 -6
  246. package/project/.sdk/tm/ocaml/sdk_features.ml +392 -68
  247. package/project/.sdk/tm/ocaml/sdk_runtime.ml +47 -21
  248. package/project/.sdk/tm/ocaml/sdk_types.ml +2 -0
  249. package/project/.sdk/tm/ocaml/test/t_feature.ml +107 -2
  250. package/project/.sdk/tm/perl/core/context.pm +3 -0
  251. package/project/.sdk/tm/perl/feature/audit_feature.pm +4 -7
  252. package/project/.sdk/tm/perl/feature/cache_feature.pm +111 -15
  253. package/project/.sdk/tm/perl/feature/debug_feature.pm +2 -2
  254. package/project/.sdk/tm/perl/feature/metrics_feature.pm +5 -0
  255. package/project/.sdk/tm/perl/feature/paging_feature.pm +139 -2
  256. package/project/.sdk/tm/perl/feature/ratelimit_feature.pm +5 -11
  257. package/project/.sdk/tm/perl/feature/retry_feature.pm +22 -4
  258. package/project/.sdk/tm/perl/feature/secrets_feature.pm +13 -18
  259. package/project/.sdk/tm/perl/feature/streaming_feature.pm +2 -0
  260. package/project/.sdk/tm/perl/feature/telemetry_feature.pm +17 -8
  261. package/project/.sdk/tm/perl/feature/test_feature.pm +45 -50
  262. package/project/.sdk/tm/perl/t/feature.t +68 -2
  263. package/project/.sdk/tm/perl/t/feature_corpus.t +204 -25
  264. package/project/.sdk/tm/perl/utility/clean.pm +6 -8
  265. package/project/.sdk/tm/perl/utility/fetcher.pm +4 -0
  266. package/project/.sdk/tm/perl/utility/make_options.pm +38 -15
  267. package/project/.sdk/tm/php/core/Context.php +4 -0
  268. package/project/.sdk/tm/php/feature/CacheFeature.php +98 -13
  269. package/project/.sdk/tm/php/feature/MetricsFeature.php +8 -0
  270. package/project/.sdk/tm/php/feature/PagingFeature.php +128 -1
  271. package/project/.sdk/tm/php/feature/RatelimitFeature.php +5 -9
  272. package/project/.sdk/tm/php/feature/RetryFeature.php +27 -3
  273. package/project/.sdk/tm/php/feature/SecretsFeature.php +18 -15
  274. package/project/.sdk/tm/php/feature/StreamingFeature.php +2 -1
  275. package/project/.sdk/tm/php/feature/TelemetryFeature.php +10 -7
  276. package/project/.sdk/tm/php/feature/TestFeature.php +55 -47
  277. package/project/.sdk/tm/php/test/FeatureCorpusTest.php +262 -17
  278. package/project/.sdk/tm/php/test/FeatureTest.php +68 -0
  279. package/project/.sdk/tm/php/utility/Clean.php +3 -10
  280. package/project/.sdk/tm/php/utility/Fetcher.php +8 -3
  281. package/project/.sdk/tm/php/utility/MakeOptions.php +45 -20
  282. package/project/.sdk/tm/py/pkg/core/context.py +4 -0
  283. package/project/.sdk/tm/py/pkg/feature/cache_feature.py +79 -13
  284. package/project/.sdk/tm/py/pkg/feature/metrics_feature.py +7 -0
  285. package/project/.sdk/tm/py/pkg/feature/paging_feature.py +86 -1
  286. package/project/.sdk/tm/py/pkg/feature/ratelimit_feature.py +13 -16
  287. package/project/.sdk/tm/py/pkg/feature/retry_feature.py +31 -6
  288. package/project/.sdk/tm/py/pkg/feature/secrets_feature.py +15 -66
  289. package/project/.sdk/tm/py/pkg/feature/streaming_feature.py +2 -1
  290. package/project/.sdk/tm/py/pkg/feature/telemetry_feature.py +10 -6
  291. package/project/.sdk/tm/py/pkg/feature/test_feature.py +56 -53
  292. package/project/.sdk/tm/py/pkg/utility/clean.py +4 -10
  293. package/project/.sdk/tm/py/pkg/utility/make_options.py +77 -30
  294. package/project/.sdk/tm/py/test/feature/secrets/test_secrets.py +23 -9
  295. package/project/.sdk/tm/py/test/test_feature.py +61 -1
  296. package/project/.sdk/tm/py/test/test_feature_corpus.py +197 -17
  297. package/project/.sdk/tm/py-data/pkg/fetch.py +6 -3
  298. package/project/.sdk/tm/py-data/test/test_fetch.py +7 -4
  299. package/project/.sdk/tm/rb/core/context.rb +4 -1
  300. package/project/.sdk/tm/rb/feature/audit_feature.rb +6 -5
  301. package/project/.sdk/tm/rb/feature/cache_feature.rb +75 -11
  302. package/project/.sdk/tm/rb/feature/debug_feature.rb +2 -2
  303. package/project/.sdk/tm/rb/feature/metrics_feature.rb +8 -0
  304. package/project/.sdk/tm/rb/feature/paging_feature.rb +87 -1
  305. package/project/.sdk/tm/rb/feature/ratelimit_feature.rb +12 -16
  306. package/project/.sdk/tm/rb/feature/retry_feature.rb +19 -3
  307. package/project/.sdk/tm/rb/feature/secrets_feature.rb +9 -64
  308. package/project/.sdk/tm/rb/feature/streaming_feature.rb +2 -1
  309. package/project/.sdk/tm/rb/feature/telemetry_feature.rb +11 -6
  310. package/project/.sdk/tm/rb/feature/test_feature.rb +42 -49
  311. package/project/.sdk/tm/rb/test/feature_corpus_test.rb +191 -25
  312. package/project/.sdk/tm/rb/test/feature_test.rb +75 -1
  313. package/project/.sdk/tm/rb/utility/clean.rb +6 -7
  314. package/project/.sdk/tm/rb/utility/fetcher.rb +6 -0
  315. package/project/.sdk/tm/rb/utility/make_options.rb +37 -16
  316. package/project/.sdk/tm/rust/core/context.rs +8 -0
  317. package/project/.sdk/tm/rust/feature/audit.rs +2 -2
  318. package/project/.sdk/tm/rust/feature/cache.rs +120 -3
  319. package/project/.sdk/tm/rust/feature/metrics.rs +24 -1
  320. package/project/.sdk/tm/rust/feature/paging.rs +189 -3
  321. package/project/.sdk/tm/rust/feature/ratelimit.rs +5 -10
  322. package/project/.sdk/tm/rust/feature/retry.rs +59 -6
  323. package/project/.sdk/tm/rust/feature/secrets.rs +36 -98
  324. package/project/.sdk/tm/rust/feature/streaming.rs +3 -2
  325. package/project/.sdk/tm/rust/feature/support.rs +4 -0
  326. package/project/.sdk/tm/rust/feature/telemetry.rs +22 -11
  327. package/project/.sdk/tm/rust/feature/test.rs +63 -57
  328. package/project/.sdk/tm/rust/tests/feature/secrets/main.rs +3 -3
  329. package/project/.sdk/tm/rust/tests/feature_test.rs +274 -0
  330. package/project/.sdk/tm/rust/tests/primary_utility_test.rs +1 -0
  331. package/project/.sdk/tm/rust/utility/clean.rs +35 -43
  332. package/project/.sdk/tm/rust/utility/fetcher.rs +6 -0
  333. package/project/.sdk/tm/rust/utility/make_options.rs +130 -38
  334. package/project/.sdk/tm/scala/core/Context.scala +4 -0
  335. package/project/.sdk/tm/scala/core/SdkClient.scala +45 -11
  336. package/project/.sdk/tm/scala/feature/AuditFeature.scala +6 -1
  337. package/project/.sdk/tm/scala/feature/CacheFeature.scala +117 -11
  338. package/project/.sdk/tm/scala/feature/MetricsFeature.scala +31 -1
  339. package/project/.sdk/tm/scala/feature/PagingFeature.scala +122 -2
  340. package/project/.sdk/tm/scala/feature/RatelimitFeature.scala +14 -11
  341. package/project/.sdk/tm/scala/feature/RetryFeature.scala +29 -7
  342. package/project/.sdk/tm/scala/feature/SecretsFeature.scala +11 -24
  343. package/project/.sdk/tm/scala/feature/StreamingFeature.scala +2 -1
  344. package/project/.sdk/tm/scala/feature/TelemetryFeature.scala +12 -10
  345. package/project/.sdk/tm/scala/feature/TestFeature.scala +44 -44
  346. package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +69 -0
  347. package/project/.sdk/tm/scala/utility/Fetcher.scala +5 -0
  348. package/project/.sdk/tm/scala/utility/Make.scala +99 -14
  349. package/project/.sdk/tm/scala/utility/Misc.scala +5 -8
  350. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Context.swift +3 -0
  351. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/AuditFeature.swift +3 -2
  352. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/CacheFeature.swift +122 -11
  353. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/MetricsFeature.swift +20 -0
  354. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/PagingFeature.swift +102 -2
  355. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/RatelimitFeature.swift +19 -13
  356. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/RetryFeature.swift +40 -5
  357. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/SecretsFeature.swift +9 -13
  358. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/StreamingFeature.swift +2 -1
  359. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TelemetryFeature.swift +11 -9
  360. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TestFeature.swift +55 -49
  361. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Fetcher.swift +4 -0
  362. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +56 -17
  363. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/ResultUtil.swift +4 -5
  364. package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +166 -0
  365. package/project/.sdk/tm/ts/src/Context.ts +4 -0
  366. package/project/.sdk/tm/ts/src/feature/cache/CacheFeature.ts +115 -4
  367. package/project/.sdk/tm/ts/src/feature/cost/CostFeature.ts +3 -2
  368. package/project/.sdk/tm/ts/src/feature/metrics/MetricsFeature.ts +6 -1
  369. package/project/.sdk/tm/ts/src/feature/paging/PagingFeature.ts +103 -5
  370. package/project/.sdk/tm/ts/src/feature/ratelimit/RatelimitFeature.ts +5 -9
  371. package/project/.sdk/tm/ts/src/feature/rbac/RbacFeature.ts +4 -4
  372. package/project/.sdk/tm/ts/src/feature/retry/RetryFeature.ts +25 -3
  373. package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +14 -2
  374. package/project/.sdk/tm/ts/src/feature/streaming/StreamingFeature.ts +2 -1
  375. package/project/.sdk/tm/ts/src/feature/telemetry/TelemetryFeature.ts +11 -6
  376. package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +8 -7
  377. package/project/.sdk/tm/ts/src/feature/validate/ValidateFeature.ts +2 -1
  378. package/project/.sdk/tm/ts/src/utility/CleanUtility.ts +1 -1
  379. package/project/.sdk/tm/ts/src/utility/MakeOptionsUtility.ts +63 -12
  380. package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +192 -23
  381. package/project/.sdk/tm/ts/test/feature/harness.ts +3 -3
  382. package/project/.sdk/tm/ts/test/feature.test.ts +14 -1
  383. package/project/.sdk/tm/ts/test/pipeline.test.ts +1 -1
  384. package/project/.sdk/tm/zig/core/context.zig +5 -0
  385. package/project/.sdk/tm/zig/core/utility.zig +118 -17
  386. package/project/.sdk/tm/zig/feature/cache.zig +144 -13
  387. package/project/.sdk/tm/zig/feature/metrics.zig +19 -0
  388. package/project/.sdk/tm/zig/feature/paging.zig +172 -4
  389. package/project/.sdk/tm/zig/feature/ratelimit.zig +5 -11
  390. package/project/.sdk/tm/zig/feature/retry.zig +41 -3
  391. package/project/.sdk/tm/zig/feature/secrets.zig +6 -1
  392. package/project/.sdk/tm/zig/feature/streaming.zig +2 -0
  393. package/project/.sdk/tm/zig/feature/telemetry.zig +15 -9
  394. package/project/.sdk/tm/zig/feature/test.zig +56 -40
  395. package/project/.sdk/tm/zig/test/feature_test.zig +174 -0
  396. package/project/.sdk/tm/zig/test/primary_utility_test.zig +2 -0
  397. package/project/sdkgen-package.json +1 -1
  398. package/src/cmp/ReadmeExplanation.ts +5 -2
  399. package/src/cmp/ReadmeFeatures.ts +21 -6
  400. package/src/helpers/optspec.ts +2 -2
@@ -106,7 +106,7 @@ class RetryFeature extends BaseFeature {
106
106
 
107
107
 
108
108
  _backoff(res, attempt, minDelay, maxDelay, factor) {
109
- // Honour a server-provided Retry-After (seconds) when present.
109
+ // A server-provided Retry-After wins over the computed backoff.
110
110
  const ra = this._retryAfter(res)
111
111
  if (null != ra) {
112
112
  return Math.min(maxDelay, ra)
@@ -131,8 +131,7 @@ class RetryFeature extends BaseFeature {
131
131
  if (null == v) {
132
132
  return null
133
133
  }
134
- const n = Number(v)
135
- return isNaN(n) ? null : n * 1000
134
+ return retryAfterMs(String(v), Date.now())
136
135
  }
137
136
 
138
137
 
@@ -166,6 +165,29 @@ class RetryFeature extends BaseFeature {
166
165
  }
167
166
 
168
167
 
168
+ const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
169
+
170
+ const IMF_FIXDATE =
171
+ /^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) ([A-Z][a-z]{2}) (\d{4}) (\d{2}):(\d{2}):(\d{2}) GMT$/
172
+
173
+
174
+ // RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else null.
175
+ function retryAfterMs(value, now) {
176
+ const s = value.replace(/^[ \t]+|[ \t]+$/g, '')
177
+ if (/^[0-9]+$/.test(s)) {
178
+ return Number(s) * 1000
179
+ }
180
+ const m = IMF_FIXDATE.exec(s)
181
+ const month = null == m ? -1 : MONTHS.indexOf(m[2])
182
+ if (null == m || month < 0 || +m[1] < 1 || 31 < +m[1] ||
183
+ 23 < +m[4] || 59 < +m[5] || 60 < +m[6]) {
184
+ return null
185
+ }
186
+ const at = Date.UTC(+m[3], month, +m[1], +m[4], +m[5], +m[6])
187
+ return Math.max(0, at - now)
188
+ }
189
+
190
+
169
191
  module.exports = {
170
192
  RetryFeature
171
193
  }
@@ -1,5 +1,6 @@
1
1
 
2
2
  const { BaseFeature } = require('../base/BaseFeature')
3
+ const { fetcher } = require('../../utility/FetcherUtility')
3
4
  const { Sekreto, envkey } = require('./sekreto')
4
5
 
5
6
 
@@ -367,19 +368,28 @@ class SecretsFeature extends BaseFeature {
367
368
  throw new Error('secrets: no fetch implementation for the token exchange')
368
369
  }
369
370
 
370
- // Deliberately NOT the SDK transport. The transport is what this
371
- // feature wraps, and sending the token request back through it would
372
- // recurse on the first 401 — and would route the exchange through the
373
- // test mock, which knows nothing about it.
374
371
  const fetchdef = {
375
372
  method: x.method,
376
373
  headers: { 'content-type': 'application/json' },
377
374
  body: JSON.stringify({ [x.request]: this._refresh }),
378
375
  // Never followed by the client: a redirect would carry the refresh token on.
379
376
  redirect: 'manual',
377
+ // Its own bound: the timeout feature's wrapper is above it.
378
+ signal: AbortSignal.timeout(30000),
380
379
  }
381
380
 
382
- let res = await fetch(url, fetchdef)
381
+ // The SDK's own transport, beneath every feature's wrapper: the wrapped
382
+ // one would recurse on the first 401 and reach the test mock. It applies
383
+ // the GET-only guard, and its refusal is the operation's error.
384
+ const send = async (at) => {
385
+ const sent = await fetcher(this._client._rootctx, at, fetchdef)
386
+ if (sent instanceof Error) {
387
+ throw sent
388
+ }
389
+ return sent
390
+ }
391
+
392
+ let res = await send(url)
383
393
 
384
394
  // By option alone, and only while the exchange stays on its own origin.
385
395
  let at = url
@@ -389,7 +399,7 @@ class SecretsFeature extends BaseFeature {
389
399
  break
390
400
  }
391
401
  at = next
392
- res = await fetch(at, fetchdef)
402
+ res = await send(at)
393
403
  }
394
404
 
395
405
  const status = null == res ? 0 : res.status
@@ -30,8 +30,9 @@ class StreamingFeature extends BaseFeature {
30
30
  if (!this._streamable(ctx)) {
31
31
  return
32
32
  }
33
+ // A failed result keeps no stream, so the entity's stream() raises its error.
33
34
  const result = ctx.result
34
- if (null == result) {
35
+ if (null == result || null != result.err) {
35
36
  return
36
37
  }
37
38
 
@@ -3,6 +3,16 @@
3
3
  const { BaseFeature } = require('../base/BaseFeature')
4
4
 
5
5
 
6
+ // W3C trace context: lowercase hex from the platform's random source, never all zeros.
7
+ function randomHex(bytes) {
8
+ const buf = new Uint8Array(bytes)
9
+ do {
10
+ globalThis.crypto.getRandomValues(buf)
11
+ } while (buf.every((b) => 0 === b))
12
+ return Array.from(buf, (b) => b.toString(16).padStart(2, '0')).join('')
13
+ }
14
+
15
+
6
16
  // Distributed-tracing telemetry. Opens a span per operation (PrePoint),
7
17
  // propagates trace context to the server as W3C `traceparent` plus
8
18
  // `X-Trace-Id` / `X-Span-Id` headers (PreRequest), and closes the span on
@@ -18,7 +28,6 @@ class TelemetryFeature extends BaseFeature {
18
28
  _client
19
29
  _options = {}
20
30
  _spans = new WeakMap()
21
- _seq = 0
22
31
 
23
32
 
24
33
  init(ctx, options) {
@@ -26,7 +35,6 @@ class TelemetryFeature extends BaseFeature {
26
35
  this._options = options || {}
27
36
  this.active = options.active
28
37
  this._spans = new WeakMap()
29
- this._seq = 0
30
38
 
31
39
  const client = this._client
32
40
  if (null == client._telemetry) {
@@ -109,10 +117,7 @@ class TelemetryFeature extends BaseFeature {
109
117
  if ('function' === typeof idgen) {
110
118
  return idgen(kind)
111
119
  }
112
- // Deterministic-ish sequential id; unique within a client instance.
113
- this._seq++
114
- const n = this._seq.toString(16).padStart(4, '0')
115
- return (kind === 'trace' ? 't' : 's') + n.padEnd(16, '0')
120
+ return randomHex('trace' === kind ? 16 : 8)
116
121
  }
117
122
 
118
123
 
@@ -343,7 +343,36 @@ class TestFeature extends BaseFeature {
343
343
  const qand = []
344
344
  const q = { '`$AND`': qand }
345
345
 
346
- for (let k of keysof(args)) {
346
+ const idfrom = getpath(ctx.config, [
347
+ 'entity', getprop(ctx.entity, 'name'), 'id', 'from']) || {}
348
+
349
+ const nest = (path, value) => {
350
+ const keys = String(path).split('.')
351
+ let out = value
352
+ for (let i = keys.length - 1; 0 <= i; i--) {
353
+ out = { [keys[i]]: out }
354
+ }
355
+ return out
356
+ }
357
+
358
+ const match = ctx.match || {}
359
+ const data = ctx.data || {}
360
+ const names = [...keysof(args)]
361
+
362
+ // With no id in the call, the entity's held id (or composite parts) stands in.
363
+ if (null == getprop(args, 'id')) {
364
+ const parts = getpath(ctx.config, ['entity', getprop(ctx.entity, 'name'), 'id', 'parts']) ||
365
+ ('list' === opname ? [] : ['id'])
366
+ for (const part of parts) {
367
+ const pname = String(part)
368
+ if (!names.includes(pname) &&
369
+ (null != getprop(match, pname) || null != getprop(data, pname))) {
370
+ names.push(pname)
371
+ }
372
+ }
373
+ }
374
+
375
+ for (let k of names) {
347
376
  if ('id' === k || !isempty(select(reqd, k))) {
348
377
  const v = param(ctx, k)
349
378
  const ka = getprop(op.alias, k)
@@ -353,6 +382,14 @@ class TestFeature extends BaseFeature {
353
382
  qor.push({ [ka]: v })
354
383
  }
355
384
 
385
+ // An ALTERNATIVE, never a replacement: the parameter name still
386
+ // matches a record that happens to carry it flat, so a seed written
387
+ // either way is found. `$OR` is what makes that safe.
388
+ const kf = getprop(idfrom, k)
389
+ if (null != kf && k !== kf) {
390
+ qor.push(nest(kf, v))
391
+ }
392
+
356
393
  qor = { '`$OR`': qor }
357
394
 
358
395
  qand.push(qor)
@@ -202,7 +202,8 @@ class ValidateFeature extends BaseFeature {
202
202
 
203
203
 
204
204
  _entitySpec(ctx) {
205
- return this._spec[entname(ctx)]
205
+ const name = entname(ctx)
206
+ return Object.prototype.hasOwnProperty.call(this._spec, name) ? this._spec[name] : undefined
206
207
  }
207
208
 
208
209
 
@@ -54,7 +54,7 @@ function count(val, dflt) {
54
54
  // is reached with a bare one) falls back to the schema defaults, so nothing
55
55
  // leaves raw for want of a constructor.
56
56
  function cleanConfig(ctx) {
57
- const derived = ctx?.options?.__derived__?.clean
57
+ const derived = ctx?.cleancfg
58
58
  if (null != derived) {
59
59
  return derived
60
60
  }
@@ -43,7 +43,7 @@ function makeOptions(ctx) {
43
43
  const layer = (b) => null != b && 'object' === typeof b && !Array.isArray(b) ? b : {}
44
44
  const cleancfg = makeCleanConfig(merge([{}, OPTSPEC.clean,
45
45
  struct.clone(layer(cfgopts.clean)), layer(opts.clean)]))
46
- const cleanctx = { options: { __derived__: { clean: cleancfg } } }
46
+ const cleanctx = { cleancfg }
47
47
  cleanAddSensitive(cleanctx, settings(opts))
48
48
  for (const raw of [...splitvalues(cfgopts.clean?.values), ...splitvalues(opts.clean?.values)]) {
49
49
  cleanAdd(cleanctx, raw)
@@ -68,6 +68,11 @@ function makeOptions(ctx) {
68
68
  opts = { ...opts, feature: fmap }
69
69
  }
70
70
 
71
+ const fdefaults = featureDefaults(struct, config.feature, opts.feature)
72
+ if (fdefaults !== opts.feature) {
73
+ opts = { ...opts, feature: fdefaults }
74
+ }
75
+
71
76
  const customUtils = opts.utility || {}
72
77
  for (let [key, val] of items(customUtils)) {
73
78
  setprop(utility, key, val)
@@ -94,6 +99,7 @@ function makeOptions(ctx) {
94
99
  opts = merge([{}, struct.clone(cfgopts), opts])
95
100
 
96
101
  try {
102
+ refuseStrayKeys(opts, optspec)
97
103
  opts = validate(opts, optspec)
98
104
  }
99
105
  catch (err) {
@@ -142,11 +148,12 @@ function makeOptions(ctx) {
142
148
  })
143
149
  }
144
150
 
145
- // Resolve the feature add-order: an explicit array order (above) wins;
146
- // otherwise order the map test-first, then the remaining names sorted, so
147
- // the outcome is deterministic and `test` is always the base transport.
148
- if (0 === featureorder.length) {
149
- let names = Object.keys(opts.feature || {}).sort()
151
+ // Resolve the feature add-order: an explicit array order (above) wins, and
152
+ // the names it leaves out follow it test-first, then sorted, so the outcome
153
+ // is deterministic and `test` is the base transport of a map.
154
+ {
155
+ let names = Object.keys(opts.feature || {})
156
+ .filter((n) => !featureorder.includes(n)).sort()
150
157
  names = names.indexOf('test') < 0
151
158
  ? names
152
159
  : ['test'].concat(names.filter((n) => 'test' !== n))
@@ -161,20 +168,62 @@ function makeOptions(ctx) {
161
168
  names.splice(si, 1)
162
169
  names.splice(names.indexOf('test') + 1, 0, 'station')
163
170
  }
164
- featureorder = names
171
+ featureorder = featureorder.concat(names)
165
172
  }
166
173
 
167
- opts.__derived__ = {
168
- clean: cleancfg,
169
- featureorder,
170
- }
174
+ opts.__derived__ = { featureorder }
175
+
176
+ // Beside the options, not in them: options() hands them to callers.
177
+ ctx.cleancfg = cleancfg
171
178
 
172
179
  // Again over the merged result: the config's own defaults can carry one.
173
- cleanAddSensitive({ options: opts }, settings(opts))
180
+ cleanAddSensitive(cleanctx, settings(opts))
174
181
 
175
182
  return opts
176
183
  }
177
184
 
185
+ // Before validate: the struct's own refusal prints the value without its
186
+ // functions, so a misspelled callback key would go unnamed.
187
+ function refuseStrayKeys(opts, optspec) {
188
+ const fspecs = optspec.feature || {}
189
+ for (const [name, fopts] of Object.entries(opts.feature || {})) {
190
+ const spec = specMap(fspecs[name])
191
+ if (null == spec || spec['`$OPEN`'] || null == fopts || 'object' !== typeof fopts) {
192
+ continue
193
+ }
194
+ const stray = Object.keys(fopts)
195
+ .filter((k) => undefined !== fopts[k] && !Object.prototype.hasOwnProperty.call(spec, k))
196
+ if (0 < stray.length) {
197
+ throw new Error('Unexpected keys at field feature.' + name + ': ' + stray.join(', '))
198
+ }
199
+ }
200
+ }
201
+
202
+ function specMap(spec) {
203
+ const alts = Array.isArray(spec) ? spec.slice('`$NOF`' === spec[0] ? 2 : 0) : [spec]
204
+ return alts.find((a) => null != a && 'object' === typeof a && !Array.isArray(a))
205
+ }
206
+
207
+ // The model's options for a feature sit beneath the caller's, key by key: a
208
+ // key the caller sets replaces the default whole, so a list is never merged.
209
+ function featureDefaults(struct, cfgfeature, feature) {
210
+ const isMap = (b) => null != b && 'object' === typeof b && !Array.isArray(b)
211
+ if (null != feature && !isMap(feature)) {
212
+ return feature
213
+ }
214
+ const out = { ...(feature || {}) }
215
+ for (const name of Object.keys(cfgfeature || {})) {
216
+ const dflt = cfgfeature[name]?.options
217
+ const given = out[name]
218
+ if (!isMap(dflt) || (null == given && true !== dflt.active) ||
219
+ (null != given && !isMap(given))) {
220
+ continue
221
+ }
222
+ out[name] = { ...struct.clone(dflt), ...(given || {}) }
223
+ }
224
+ return null == feature && 0 === Object.keys(out).length ? feature : out
225
+ }
226
+
178
227
  // Registration skips entity blocks, and rbac's rules, keyed by entity and op names.
179
228
  function settings(opts) {
180
229
  const plain = (b, name) => null != b && 'object' === typeof b && !Array.isArray(b)
@@ -49,11 +49,15 @@ const FEATURES = Object.keys((() => {
49
49
 
50
50
  // A scripted transport built from a case's `res` list. Responses are consumed
51
51
  // in order and the last one repeats, so a case that does not care how many
52
- // attempts happen need only declare one.
53
- function scriptedFetcher(res) {
52
+ // attempts happen need only declare one. Each URL it is sent is kept in `sent`,
53
+ // and the time it was sent in `at`; a `cut` response is one whose body stops
54
+ // before its end.
55
+ function scriptedFetcher(res, sent = [], at = []) {
54
56
  let n = -1
55
- return async function (_ctx, _url, _fetchdef) {
57
+ return async function (_ctx, url, _fetchdef) {
56
58
  n++
59
+ sent.push(url)
60
+ at.push(Date.now())
57
61
  const spec = res[n < res.length ? n : res.length - 1] || {}
58
62
 
59
63
  if (true === spec.throw) {
@@ -67,7 +71,10 @@ function scriptedFetcher(res) {
67
71
  status,
68
72
  statusText: status < 400 ? 'OK' : 'ERR',
69
73
  body: 'not-used',
70
- json: async () => (undefined === spec.body ? {} : spec.body),
74
+ json: async () => {
75
+ if (true === spec.cut) { throw new TypeError('terminated') }
76
+ return undefined === spec.body ? {} : spec.body
77
+ },
71
78
  headers: {
72
79
  get(key) {
73
80
  const lower = String(key).toLowerCase()
@@ -83,7 +90,7 @@ function scriptedFetcher(res) {
83
90
  }
84
91
 
85
92
 
86
- function makeClient(kase) {
93
+ function makeClient(kase, sent = [], at = []) {
87
94
  // `test: { active: true }` is the OPTION, not the `test` FEATURE.
88
95
  //
89
96
  // It says "this client is not live", which is what makes a REQUIRED
@@ -95,7 +102,7 @@ function makeClient(kase) {
95
102
  return new SDK({
96
103
  test: { active: true },
97
104
  feature: kase.feature,
98
- utility: { fetcher: scriptedFetcher(kase.res || [{ status: 200, body: {} }]) },
105
+ utility: { fetcher: scriptedFetcher(kase.res || [{ status: 200, body: {} }], sent, at) },
99
106
  })
100
107
  }
101
108
 
@@ -156,6 +163,106 @@ async function usableOps(want) {
156
163
  }
157
164
 
158
165
 
166
+
167
+ const READ_OPS = ['list', 'load']
168
+ const WRITE_OPS = ['create', 'update', 'patch', 'remove']
169
+
170
+
171
+ // A read and a write of one entity (#READ, #WRITE), each driven as usableOps
172
+ // drives an op; #ITEM is a write of the same entity driven with ITEM_ARGS.
173
+ async function usablePair() {
174
+ const found = {}
175
+ for (const cand of candidates(makeClient({}))) {
176
+ const role = READ_OPS.includes(cand.op) ? 'read' : WRITE_OPS.includes(cand.op) ? 'write' : ''
177
+ const seen = found[cand.entity] = found[cand.entity] || {}
178
+ if ('' === role || null != seen[role]) { continue }
179
+ try {
180
+ await makeClient({})[cand.accessor]()[cand.op]({}, {})
181
+ }
182
+ catch (e) { continue }
183
+ seen[role] = cand
184
+ if (null != seen.read && null != seen.write) {
185
+ return { read: seen.read, write: seen.write, item: await usableItem(cand.entity) }
186
+ }
187
+ }
188
+ return undefined
189
+ }
190
+
191
+
192
+ const ITEM_ARGS = { id: 'corpus-item' }
193
+
194
+ async function usableItem(entity) {
195
+ for (const cand of candidates(makeClient({}))) {
196
+ if (entity !== cand.entity || !['update', 'patch', 'remove'].includes(cand.op)) { continue }
197
+ try {
198
+ await makeClient({})[cand.accessor]()[cand.op]({ ...ITEM_ARGS }, {})
199
+ return cand
200
+ }
201
+ catch (e) { continue }
202
+ }
203
+ return undefined
204
+ }
205
+
206
+
207
+ // A step may wait before its call, may add request headers for its call, and
208
+ // may pass `args` as the operation's first argument. A `stream` step reads the
209
+ // operation through the entity's stream(), and `items` is how many it yields.
210
+ async function runStep(client, ref, step, ctrl) {
211
+ if (null != step.wait) {
212
+ await new Promise((resolve) => setTimeout(resolve, step.wait))
213
+ }
214
+ const options = client._rootctx.options
215
+ const prior = options.headers
216
+ if (null != step.headers) {
217
+ options.headers = { ...(prior || {}), ...step.headers }
218
+ }
219
+ try {
220
+ if (true === step.stream) {
221
+ let items = 0
222
+ for await (const _item of client[ref.accessor]().stream(ref.op, { ...(step.args || {}) }, { ctrl })) {
223
+ items++
224
+ }
225
+ if (null != step.items) {
226
+ deepStrictEqual(items, step.items, `${ref.key}: items streamed`)
227
+ }
228
+ }
229
+ else {
230
+ await client[ref.accessor]()[ref.op]({ ...(step.args || {}) }, ctrl)
231
+ }
232
+ }
233
+ finally {
234
+ options.headers = prior
235
+ }
236
+ }
237
+
238
+ // A step with `together: N` makes N overlapping calls; each call's error, or
239
+ // undefined, is returned.
240
+ async function runCalls(client, ref, step, ctrl) {
241
+ const calls = Array.from({ length: null == step.together ? 1 : step.together },
242
+ () => runStep(client, ref, step, ctrl).then(() => undefined, (e) => e))
243
+ return Promise.all(calls)
244
+ }
245
+
246
+
247
+ // Each request a case expects, in order: its path, and its whole query. A
248
+ // path is compared without its leading slash, which an SDK with no base omits.
249
+ function checkSent(sent, expect, label) {
250
+ deepStrictEqual(sent.length, expect.length, `${label}: requests sent: ${sent.join(' | ')}`)
251
+ expect.forEach((want, i) => {
252
+ const url = new URL(sent[i], 'http://corpus.invalid')
253
+ if (null != want.path) {
254
+ deepStrictEqual(url.pathname.replace(/^\/+/, ''), want.path.replace(/^\/+/, ''),
255
+ `${label}: request ${i} path`)
256
+ }
257
+ if (null != want.query) {
258
+ const query = {}
259
+ url.searchParams.forEach((v, k) => { query[k] = v })
260
+ deepStrictEqual(query, want.query, `${label}: request ${i} query`)
261
+ }
262
+ })
263
+ }
264
+
265
+
159
266
  // Replace #OP1/#OP2 throughout a case, keys included.
160
267
  function resolve(node, tokens) {
161
268
  if ('string' === typeof node) {
@@ -169,7 +276,9 @@ function resolve(node, tokens) {
169
276
  if (null != node && 'object' === typeof node) {
170
277
  const out = {}
171
278
  for (const k of Object.keys(node)) {
172
- out[resolve(k, tokens)] = resolve(node[k], tokens)
279
+ Object.defineProperty(out, resolve(k, tokens), {
280
+ value: resolve(node[k], tokens), enumerable: true, writable: true, configurable: true,
281
+ })
173
282
  }
174
283
  return out
175
284
  }
@@ -177,6 +286,15 @@ function resolve(node, tokens) {
177
286
  }
178
287
 
179
288
 
289
+ // No case may write onto the shared prototypes, as a `__proto__` key can.
290
+ function shared() {
291
+ return [Object.prototype, Object]
292
+ .map((o) => Object.getOwnPropertyNames(o).sort().join(',')).join(' | ')
293
+ }
294
+
295
+ const PRISTINE = shared()
296
+
297
+
180
298
  // Which #OPn tokens a case uses. A case wanting more operations than this SDK
181
299
  // has is skipped rather than failed.
182
300
  function tokensUsed(kase) {
@@ -205,15 +323,32 @@ function subset(actual, expect, path) {
205
323
  }
206
324
  return
207
325
  }
326
+ if (Array.isArray(expect)) {
327
+ ok(Array.isArray(actual) && actual.length === expect.length,
328
+ `${path}: want ${expect.length} item(s), got ${JSON.stringify(actual)}`)
329
+ expect.forEach((e, i) => subset(actual[i], e, `${path}[${i}]`))
330
+ return
331
+ }
208
332
  deepStrictEqual(actual, expect, path)
209
333
  }
210
334
 
211
335
 
336
+ // The most requests the transport saw in any window of `ms`.
337
+ function busiest(sent, ms) {
338
+ let most = 0
339
+ for (let i = 0; i < sent.length; i++) {
340
+ most = Math.max(most, sent.filter((t) => sent[i] <= t && t < sent[i] + ms).length)
341
+ }
342
+ return most
343
+ }
344
+
345
+
212
346
  describe('FeatureCorpus', () => {
213
347
 
214
348
  let corpus
215
349
  let ops = []
216
350
  let byKey = {}
351
+ let pair
217
352
 
218
353
 
219
354
  before(async () => {
@@ -221,6 +356,10 @@ describe('FeatureCorpus', () => {
221
356
  ops = await usableOps(2)
222
357
  byKey = {}
223
358
  for (const o of ops) { byKey[o.key] = o }
359
+ pair = await usablePair()
360
+ for (const o of pair ? [pair.read, pair.write, pair.item] : []) {
361
+ if (null != o) { byKey[o.key] = o }
362
+ }
224
363
  })
225
364
 
226
365
 
@@ -285,6 +424,20 @@ describe('FeatureCorpus', () => {
285
424
  continue
286
425
  }
287
426
 
427
+ const paired = /#(READ|WRITE|ITEM|OTHER)\b/.test(JSON.stringify(raw))
428
+ if (paired && null == pair) {
429
+ t.diagnostic(`skip "${raw.name}": needs a read and a write of one entity, this SDK offers none`)
430
+ continue
431
+ }
432
+ const other = null == pair ? undefined :
433
+ ops.find((o) => o.entity !== pair.read.entity)
434
+ const lacking = [['#ITEM', pair?.item], ['#OTHER', other]]
435
+ .find(([tok, op]) => null == op && new RegExp(tok + '\\b').test(JSON.stringify(raw)))
436
+ if (null != lacking) {
437
+ t.diagnostic(`skip "${raw.name}": needs ${lacking[0]}, which this SDK cannot drive`)
438
+ continue
439
+ }
440
+
288
441
  const missing = missingFeature(probe, raw)
289
442
  if (null != missing) {
290
443
  t.diagnostic(`skip "${raw.name}": needs the ${missing} feature, ` +
@@ -294,36 +447,51 @@ describe('FeatureCorpus', () => {
294
447
 
295
448
  const tokens = {}
296
449
  for (let i = 0; i < need; i++) { tokens['#OP' + (i + 1)] = ops[i].key }
450
+ if (paired && null != pair) {
451
+ tokens['#READ'] = pair.read.key
452
+ tokens['#WRITE'] = pair.write.key
453
+ if (null != pair.item) { tokens['#ITEM'] = pair.item.key }
454
+ if (null != other) { tokens['#OTHER'] = other.key }
455
+ }
297
456
 
298
457
  const kase = resolve(raw, tokens)
299
458
  ran++
300
459
 
301
460
  // Every failing case is reported, not only the first.
302
461
  try {
303
- const client = makeClient(kase)
462
+ const sent = []
463
+ const at = []
464
+ const client = makeClient(kase, sent, at)
304
465
 
466
+ // A case-level ctrl is one control object every step shares.
305
467
  for (const step of (kase.op || [])) {
306
468
  const ref = byKey[step.op]
307
469
  ok(null != ref, `${kase.name}: no operation ${step.op}`)
308
- let err = undefined
309
- try {
310
- await client[ref.accessor]()[ref.op]({}, step.ctrl || {})
311
- }
312
- catch (e) {
313
- err = e
314
- }
315
- if (null == step.err) {
316
- ok(undefined === err,
317
- `${kase.name}: ${step.op} failed unexpectedly: ${err?.message}`)
318
- continue
319
- }
320
- ok(undefined !== err, `${kase.name}: ${step.op} was expected to fail, and did not`)
321
- if ('string' === typeof step.err) {
322
- deepStrictEqual(err.code, step.err, `${kase.name}: wrong error code`)
470
+ for (const err of await runCalls(client, ref, step, step.ctrl || kase.ctrl || {})) {
471
+ if (null == step.err) {
472
+ ok(undefined === err,
473
+ `${kase.name}: ${step.op} failed unexpectedly: ${err?.message}`)
474
+ continue
475
+ }
476
+ ok(undefined !== err, `${kase.name}: ${step.op} was expected to fail, and did not`)
477
+ if ('string' === typeof step.err) {
478
+ deepStrictEqual(err.code, step.err, `${kase.name}: wrong error code`)
479
+ }
323
480
  }
324
481
  }
325
482
 
483
+ if (null != kase.pace) {
484
+ const most = busiest(at, kase.pace.ms)
485
+ ok(most <= kase.pace.max, `${kase.name}: ${most} requests within ${kase.pace.ms} ms, ` +
486
+ `want at most ${kase.pace.max}`)
487
+ }
488
+
489
+ if (null != kase.sent) {
490
+ checkSent(sent, kase.sent, kase.name)
491
+ }
326
492
  subset(client[`_${name}`], kase.out, `${kase.name}: _${name}`)
493
+ deepStrictEqual(shared(), PRISTINE,
494
+ `${kase.name}: the case wrote onto Object or Object.prototype`)
327
495
  }
328
496
  catch (err) {
329
497
  const msg = String(err?.message ?? err)
@@ -92,9 +92,8 @@ function makeClient(spec) {
92
92
 
93
93
  // One clean registry per client, as makeOptions gives a real one, so a value
94
94
  // a feature registers with cleanAdd is masked by every clean after it.
95
- const derived = stdutil.makeOptions({
96
- utility, options: { feature: { test: { active: true } } }, config: {},
97
- }).__derived__
95
+ const regctx = { utility, options: { feature: { test: { active: true } } }, config: {} }
96
+ const derived = stdutil.makeOptions(regctx).__derived__
98
97
 
99
98
  const client = {
100
99
  _mode: spec.mode || 'test',
@@ -120,6 +119,7 @@ function makeClient(spec) {
120
119
  client,
121
120
  utility,
122
121
  options: client._options,
122
+ cleancfg: regctx.cleancfg,
123
123
  out: {},
124
124
  ctrl: over.ctrl || {},
125
125
  meta: {},