@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
@@ -14,6 +14,7 @@ class CacheFeature extends BaseFeature {
14
14
  _client?: ProjectNameSDK
15
15
  _options: any = {}
16
16
  _store: Map<string, any> = new Map()
17
+ _key?: Promise<any>
17
18
 
18
19
 
19
20
  init(ctx: Context, options: FeatureOptions): void | Promise<any> {
@@ -26,6 +27,7 @@ class CacheFeature extends BaseFeature {
26
27
  }
27
28
 
28
29
  this._store = new Map()
30
+ this._key = cacheKey()
29
31
 
30
32
  const self = this
31
33
  const utility = ctx.utility
@@ -42,10 +44,18 @@ class CacheFeature extends BaseFeature {
42
44
  const methods = this._options.methods || ['GET']
43
45
 
44
46
  if (methods.indexOf(method) < 0) {
45
- return inner(ctx, url, fetchdef)
47
+ if (SAFE_METHODS.indexOf(method) >= 0) {
48
+ return inner(ctx, url, fetchdef)
49
+ }
50
+ try {
51
+ return await inner(ctx, url, fetchdef)
52
+ }
53
+ finally {
54
+ this._invalidate(url)
55
+ }
46
56
  }
47
57
 
48
- const key = method + ' ' + url
58
+ const key = method + ' ' + url + ' ' + await this._digest(fetchdef && fetchdef.headers)
49
59
  const now = this._now()
50
60
  const hit = this._store.get(key)
51
61
 
@@ -72,9 +82,16 @@ class CacheFeature extends BaseFeature {
72
82
  return this._replay(snapshot)
73
83
  }
74
84
 
75
- const ttl = null == this._options.ttl ? 5000 : this._options.ttl
85
+ const ttl = cacheLifetime(snapshot.headers,
86
+ null == this._options.ttl ? 5000 : this._options.ttl)
87
+ if (ttl <= 0) {
88
+ this._track('bypass')
89
+ return this._replay(snapshot)
90
+ }
91
+
92
+ this._store.delete(key)
76
93
  this._evict()
77
- this._store.set(key, { expiry: now + ttl, snapshot })
94
+ this._store.set(key, { expiry: now + ttl, scope: urlScope(url), snapshot })
78
95
  this._track('miss')
79
96
  return this._replay(snapshot)
80
97
  }
@@ -84,6 +101,25 @@ class CacheFeature extends BaseFeature {
84
101
  }
85
102
 
86
103
 
104
+ async _digest(this: any, headers: any): Promise<string> {
105
+ const subtle = globalThis.crypto.subtle
106
+ const mac = await subtle.sign('HMAC', await this._key,
107
+ new TextEncoder().encode(headerText(headers)))
108
+ return Array.from(new Uint8Array(mac), (b: number) => b.toString(16).padStart(2, '0')).join('')
109
+ }
110
+
111
+
112
+ _invalidate(this: any, url: string) {
113
+ const path = urlScope(url)
114
+ const collection = urlParent(path)
115
+ for (const [key, entry] of this._store) {
116
+ if (scopeUnder(entry.scope, path) || entry.scope === collection) {
117
+ this._store.delete(key)
118
+ }
119
+ }
120
+ }
121
+
122
+
87
123
  _cacheable(this: any, res: any): boolean {
88
124
  if (null == res || res instanceof Error) {
89
125
  return false
@@ -182,6 +218,81 @@ class CacheFeature extends BaseFeature {
182
218
  }
183
219
 
184
220
 
221
+ const SAFE_METHODS = ['GET', 'HEAD']
222
+
223
+ const UNSTORED = ['no-store', 'private', 'no-cache']
224
+
225
+
226
+ // A fresh random secret per client: the key holds a digest of the headers,
227
+ // never a header value.
228
+ function cacheKey(): Promise<any> {
229
+ const crypto = globalThis.crypto
230
+ return crypto.subtle.importKey('raw', crypto.getRandomValues(new Uint8Array(32)),
231
+ { name: 'HMAC', hash: 'SHA-256' }, false, ['sign'])
232
+ }
233
+
234
+
235
+ function headerText(headers: any): string {
236
+ const pairs: string[][] = []
237
+ for (const name of Object.keys(headers || {})) {
238
+ if (null != headers[name]) {
239
+ pairs.push([name.toLowerCase(), String(headers[name])])
240
+ }
241
+ }
242
+ pairs.sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0)
243
+ return pairs.map((p) => p[0] + ':' + p[1] + '\n').join('')
244
+ }
245
+
246
+
247
+ // The configured ttl, capped by the response's Cache-Control; zero when the
248
+ // response may not be stored.
249
+ function cacheLifetime(headers: Record<string, any>, ttl: number): number {
250
+ let control = ''
251
+ for (const name of Object.keys(headers || {})) {
252
+ if ('cache-control' === name.toLowerCase()) {
253
+ control = String(headers[name])
254
+ }
255
+ }
256
+ let life = ttl
257
+ for (const part of control.toLowerCase().split(',')) {
258
+ const directive = part.trim()
259
+ if (UNSTORED.indexOf(directive) >= 0) {
260
+ return 0
261
+ }
262
+ const age = directive.match(/^max-age\s*=\s*"?(\d+)"?$/)
263
+ if (null != age) {
264
+ life = Math.min(life, Number(age[1]) * 1000)
265
+ }
266
+ }
267
+ return life
268
+ }
269
+
270
+
271
+ function urlScope(url: string): string {
272
+ let scope = String(url).split(/[?#]/)[0]
273
+ while (scope.endsWith('/')) {
274
+ scope = scope.slice(0, -1)
275
+ }
276
+ return scope
277
+ }
278
+
279
+
280
+ function urlParent(scope: string): string {
281
+ const scheme = scope.indexOf('://')
282
+ const root = scheme < 0 ? 0 : scope.indexOf('/', scheme + 3)
283
+ if (root < 0) {
284
+ return scope
285
+ }
286
+ const cut = scope.lastIndexOf('/')
287
+ return scope.slice(0, cut < root ? root : cut)
288
+ }
289
+
290
+
291
+ function scopeUnder(scope: string, prefix: string): boolean {
292
+ return scope === prefix || scope.startsWith(prefix + '/')
293
+ }
294
+
295
+
185
296
  export {
186
297
  CacheFeature
187
298
  }
@@ -29,8 +29,9 @@ class CostFeature extends BaseFeature {
29
29
  client._cost = {
30
30
  currency: this._options.currency || 'USD',
31
31
  total: { calls: 0, attempts: 0, amount: 0, reported: 0, estimated: 0 },
32
- ops: {},
33
- actors: {},
32
+ // Keyed by a caller's string, so no prototype to collide with.
33
+ ops: Object.create(null),
34
+ actors: Object.create(null),
34
35
  budget: { limit, spent: 0, remaining: limit, exceeded: false },
35
36
  last: undefined,
36
37
  }
@@ -25,7 +25,7 @@ class MetricsFeature extends BaseFeature {
25
25
  if (null == client._metrics) {
26
26
  client._metrics = {
27
27
  total: { count: 0, ok: 0, err: 0, totalMs: 0, maxMs: 0 },
28
- ops: {},
28
+ ops: Object.create(null),
29
29
  }
30
30
  }
31
31
  }
@@ -70,6 +70,11 @@ class MetricsFeature extends BaseFeature {
70
70
 
71
71
  this._bump(m.total, ok, dur)
72
72
  this._bump(op, ok, dur)
73
+
74
+ const sink = this._options.sink
75
+ if ('function' === typeof sink) {
76
+ try { sink(ctx.utility.clean(ctx, m)) } catch (_e) { }
77
+ }
73
78
  }
74
79
 
75
80
 
@@ -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) {
@@ -176,21 +197,98 @@ class PagingFeature extends BaseFeature {
176
197
  const afterVar = this._options.afterVar || 'after'
177
198
  const firstVar = this._options.firstVar || 'first'
178
199
 
179
- const declared: Record<string, boolean> = {}
200
+ const declared = new Set<string>()
180
201
  for (const v of ((point.graphql && point.graphql.vars) || [])) {
181
- declared[v.name] = true
202
+ declared.add(v.name)
182
203
  }
183
204
 
184
- if (null != paging.cursor && declared[afterVar]) {
205
+ if (null != paging.cursor && declared.has(afterVar)) {
185
206
  vars[afterVar] = paging.cursor
186
207
  }
187
208
 
188
209
  if (null != this._options.limit && null == vars[firstVar] &&
189
- declared[firstVar]) {
210
+ declared.has(firstVar)) {
190
211
  vars[firstVar] = this._options.limit
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
 
@@ -12,7 +12,7 @@ class RbacFeature extends BaseFeature {
12
12
 
13
13
  _client?: ProjectNameSDK
14
14
  _options: any = {}
15
- _granted: Record<string, boolean> = {}
15
+ _granted: Set<string> = new Set()
16
16
 
17
17
 
18
18
  init(ctx: Context, options: FeatureOptions): void | Promise<any> {
@@ -20,10 +20,10 @@ class RbacFeature extends BaseFeature {
20
20
  this._options = options || {}
21
21
  this.active = (options as any).active
22
22
 
23
- this._granted = {}
23
+ this._granted = new Set()
24
24
  const perms = this._options.permissions || []
25
25
  for (const p of perms) {
26
- this._granted[p] = true
26
+ this._granted.add(p)
27
27
  }
28
28
  }
29
29
 
@@ -41,7 +41,7 @@ class RbacFeature extends BaseFeature {
41
41
  return
42
42
  }
43
43
 
44
- if (this._granted['*'] || this._granted[required]) {
44
+ if (this._granted.has('*') || this._granted.has(required)) {
45
45
  this._track(ctx, required, true)
46
46
  return
47
47
  }
@@ -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
  }
@@ -1,6 +1,7 @@
1
1
  import type { Context, FeatureOptions } from '../../types'
2
2
 
3
3
  import { BaseFeature } from '../base/BaseFeature'
4
+ import { fetcher } from '../../utility/FetcherUtility'
4
5
  import { Sekreto, envkey } from './sekreto'
5
6
  // The plugin DEFINITIONS the model selected for this feature, emitted by
6
7
  // Config generically from the catalogue's active `plugin.def` entries.
@@ -261,9 +262,20 @@ class SecretsFeature extends BaseFeature {
261
262
  body: JSON.stringify({ [x.request]: this._refresh }),
262
263
  // Never followed by the client: a redirect would carry the refresh token on.
263
264
  redirect: 'manual',
265
+ // Its own bound: the timeout feature's wrapper is above it.
266
+ signal: AbortSignal.timeout(30000),
264
267
  }
265
268
 
266
- let res = await fetch(url, fetchdef)
269
+ // The SDK transport beneath every wrapper; its GET-only refusal fails the op.
270
+ const send = async (at: string) => {
271
+ const sent: any = await fetcher(this._client._rootctx, at, fetchdef)
272
+ if (sent instanceof Error) {
273
+ throw sent
274
+ }
275
+ return sent
276
+ }
277
+
278
+ let res = await send(url)
267
279
 
268
280
  // By option alone, and only while the exchange stays on its own origin.
269
281
  let at = url
@@ -273,7 +285,7 @@ class SecretsFeature extends BaseFeature {
273
285
  break
274
286
  }
275
287
  at = next
276
- res = await fetch(at, fetchdef)
288
+ res = await send(at)
277
289
  }
278
290
 
279
291
  const status = null == res ? 0 : res.status
@@ -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
  }
@@ -131,7 +131,8 @@ class ValidateFeature extends BaseFeature {
131
131
 
132
132
 
133
133
  _entitySpec(this: any, ctx: any): any {
134
- return this._spec[entname(ctx)]
134
+ const name = entname(ctx)
135
+ return Object.prototype.hasOwnProperty.call(this._spec, name) ? this._spec[name] : undefined
135
136
  }
136
137
 
137
138
 
@@ -67,7 +67,7 @@ function count(val: any, dflt: number): number {
67
67
  // A context without options (makeError accepts a bare one) still masks by
68
68
  // the schema defaults.
69
69
  function cleanConfig(ctx: any): CleanConfig {
70
- const derived = ctx?.options?.__derived__?.clean
70
+ const derived = ctx?.cleancfg
71
71
  if (null != derived) {
72
72
  return derived
73
73
  }