@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
@@ -64,6 +64,9 @@ class PagingFeature extends BaseFeature("paging", "0.0.1", true) {
64
64
  val cursor = paging.get("cursor")
65
65
  if (cursor != null) {
66
66
  spec.query.put(cursorParam, cursor)
67
+ } else if (paging.get("next").isInstanceOf[String]
68
+ && !PagingFeature.foreign(paging.get("next").asInstanceOf[String], spec.base)) {
69
+ PagingFeature.follow(spec, paging.get("next").asInstanceOf[String])
67
70
  } else if (spec.query.get(pageParam) == null) {
68
71
  // A record written back by preResult holds the page just fetched as
69
72
  // "page" and the one to fetch as "nextPage", so nextPage wins.
@@ -199,8 +202,12 @@ class PagingFeature extends BaseFeature("paging", "0.0.1", true) {
199
202
  body match {
200
203
  case bm0: JMap[_, _] =>
201
204
  val bm = bm0.asInstanceOf[JMap[String, Object]]
202
- if (bm.get("next") != null && paging.get("next") == null) {
203
- paging.put("next", bm.get("next"))
205
+ if (bm.get("next") != null) {
206
+ if (!PagingFeature.isLink(bm.get("next"), FeatureOptions.foptStr(this.options, "next", "auto"))) {
207
+ paging.put("cursor", bm.get("next"))
208
+ } else if (paging.get("next") == null) {
209
+ paging.put("next", bm.get("next"))
210
+ }
204
211
  }
205
212
  if (bm.get("next_cursor") != null) {
206
213
  paging.put("cursor", bm.get("next_cursor"))
@@ -235,6 +242,22 @@ class PagingFeature extends BaseFeature("paging", "0.0.1", true) {
235
242
  case _ =>
236
243
  }
237
244
 
245
+ // A link to another origin is recorded, never followed, and ends the walk.
246
+ val base: String =
247
+ if (ctx.spec != null) ctx.spec.base
248
+ else if (ctx.options != null && ctx.options.get("base").isInstanceOf[String]) ctx.options.get("base").asInstanceOf[String]
249
+ else ""
250
+ paging.get("next") match {
251
+ case link: String if ctx.spec != null => paging.put("next", PagingFeature.resolve(link, ctx.spec.url))
252
+ case _ =>
253
+ }
254
+ paging.get("next") match {
255
+ case link: String if PagingFeature.foreign(link, base) =>
256
+ paging.put("foreign", link)
257
+ paging.remove("next")
258
+ case _ =>
259
+ }
260
+
238
261
  // Cursor presence only INFERS another page. When the server stated the
239
262
  // answer outright — relay's `hasNextPage: false`, or a body `hasMore` —
240
263
  // that wins: a final page normally carries both an end cursor and
@@ -246,6 +269,10 @@ class PagingFeature extends BaseFeature("paging", "0.0.1", true) {
246
269
  paging.put("hasMore", java.lang.Boolean.TRUE)
247
270
  }
248
271
 
272
+ if (paging.get("foreign") != null && paging.get("cursor") == null && paging.get("nextPage") == null) {
273
+ paging.put("hasMore", java.lang.Boolean.FALSE)
274
+ }
275
+
249
276
  result.paging = paging
250
277
  this.last = paging
251
278
 
@@ -306,3 +333,96 @@ class PagingFeature extends BaseFeature("paging", "0.0.1", true) {
306
333
  }
307
334
  }
308
335
  }
336
+
337
+
338
+ object PagingFeature {
339
+ private val Origin = Pattern.compile("^[a-z][a-z0-9+.-]*://[^/?#]*", Pattern.CASE_INSENSITIVE)
340
+
341
+ private def originOf(text: String): String = {
342
+ val m = Origin.matcher(text)
343
+ if (m.find()) m.group() else ""
344
+ }
345
+
346
+ // Under the `next` option's default, a URL or an absolute path is a link and
347
+ // anything else a cursor; `cursor` and `url` pin the reading.
348
+ def isLink(next: Object, mode: String): Boolean = next match {
349
+ case s: String => mode == "url" || (mode != "cursor" && (originOf(s).nonEmpty || s.startsWith("/")))
350
+ case _ => false
351
+ }
352
+
353
+ def foreign(link: String, base: String): Boolean = {
354
+ val origin = originOf(link).toLowerCase
355
+ origin.nonEmpty && origin != originOf(if (base == null) "" else base).toLowerCase
356
+ }
357
+
358
+ private val Scheme = Pattern.compile("^[a-z][a-z0-9+.-]*:", Pattern.CASE_INSENSITIVE)
359
+
360
+ // RFC 3986 reference resolution against the URL of the request that
361
+ // returned the link, by hand: java.net.URI resolves a query-only reference
362
+ // by RFC 2396 and drops the last path segment. A link on that URL's origin
363
+ // comes back as its path and query; an absolute link is left as it is.
364
+ def resolve(link0: String, url: String): String = {
365
+ if (url == null || url.isEmpty || Scheme.matcher(link0).find()) return link0
366
+ val link = link0.split("#", 2)(0)
367
+ val origin = originOf(url)
368
+ if (link.startsWith("//")) {
369
+ return if (origin.isEmpty) link else origin.split(":", 2)(0) + ":" + link
370
+ }
371
+ val from = url.substring(origin.length).split("#", 2)(0)
372
+ val bpath = from.split("\\?", 2)(0)
373
+ val rpath = link.split("\\?", 2)(0)
374
+ def after(s: String): Option[String] = { val k = s.indexOf('?'); if (k < 0) None else Some(s.substring(k + 1)) }
375
+ val (path, query) =
376
+ if (rpath.isEmpty) (bpath, after(link).orElse(after(from)))
377
+ else (removeDots(if (rpath.startsWith("/")) rpath else bpath.substring(0, bpath.lastIndexOf('/') + 1) + rpath),
378
+ after(link))
379
+ val rooted = if (path.startsWith("/")) path else "/" + path
380
+ query.fold(rooted)(q => rooted + "?" + q)
381
+ }
382
+
383
+ // RFC 3986 section 5.2.4.
384
+ def removeDots(path: String): String = {
385
+ val abs = path.startsWith("/")
386
+ val segs = path.split("/", -1)
387
+ val out = scala.collection.mutable.ArrayBuffer[String]()
388
+ for (i <- (if (abs) 1 else 0) until segs.length) {
389
+ val seg = segs(i)
390
+ if (seg == "." || seg == "..") {
391
+ if (seg == ".." && out.nonEmpty) out.remove(out.length - 1)
392
+ if (i == segs.length - 1) out += ""
393
+ } else {
394
+ out += seg
395
+ }
396
+ }
397
+ (if (abs) "/" else "") + out.mkString("/")
398
+ }
399
+
400
+ // The request goes to the link's path and query, on the SDK's own origin.
401
+ def follow(spec: SCALAPACKAGE.core.Spec, next: String): Unit = {
402
+ val link = next.substring(originOf(next).length).split("#", 2)(0)
403
+ val mark = link.indexOf('?')
404
+ val path = if (mark < 0) link else link.substring(0, mark)
405
+ val rawquery = if (mark < 0) "" else link.substring(mark + 1)
406
+
407
+ val query = new LinkedHashMap[String, Object]()
408
+ for (pair <- rawquery.split("&") if pair.nonEmpty) {
409
+ val eq = pair.indexOf('=')
410
+ val key = if (eq < 0) pair else pair.substring(0, eq)
411
+ val value = if (eq < 0) "" else pair.substring(eq + 1)
412
+ query.put(unescape(key), unescape(value))
413
+ }
414
+ if (spec.authquery != null) {
415
+ spec.authquery.forEach(key => query.put(key, spec.query.get(key)))
416
+ }
417
+
418
+ spec.base = originOf(if (spec.base == null) "" else spec.base)
419
+ spec.prefix = ""
420
+ spec.path = path
421
+ spec.suffix = ""
422
+ spec.query = query
423
+ }
424
+
425
+ private def unescape(text: String): String =
426
+ try java.net.URLDecoder.decode(text, java.nio.charset.StandardCharsets.UTF_8)
427
+ catch { case _: IllegalArgumentException => text }
428
+ }
@@ -30,25 +30,28 @@ class RatelimitFeature extends BaseFeature("ratelimit", "0.0.1", true) {
30
30
  }
31
31
 
32
32
  private def acquire(): Unit = {
33
+ val wait = reserve()
34
+ if (wait > 0) FeatureOptions.foptSleep(this.options).accept(wait)
35
+ }
36
+
37
+ // Refill, then reserve this call's token before any wait, under the lock:
38
+ // a negative count is the calls already queued, so overlapping calls pace
39
+ // in turn.
40
+ private def reserve(): Int = this.synchronized {
33
41
  val rate = FeatureOptions.foptNum(this.options, "rate", 5)
34
42
  val burst = FeatureOptions.foptNum(this.options, "burst", rate)
35
43
 
36
44
  val now = FeatureOptions.foptNow(this.options).getAsLong()
37
45
  val elapsed = now - this.last
38
46
  this.last = now
39
- this.tokens = Math.min(burst, this.tokens + (elapsed / 1000.0) * rate)
47
+ this.tokens = Math.min(burst, this.tokens + (elapsed / 1000.0) * rate) - 1
40
48
 
41
- if (this.tokens >= 1) {
42
- this.tokens -= 1
43
- return
49
+ if (this.tokens >= 0) 0
50
+ else {
51
+ val wait = Math.ceil((-this.tokens / rate) * 1000).toInt
52
+ track(wait)
53
+ wait
44
54
  }
45
-
46
- val needed = 1 - this.tokens
47
- val wait = Math.ceil((needed / rate) * 1000).toInt
48
- track(wait)
49
- if (wait > 0) FeatureOptions.foptSleep(this.options).accept(wait)
50
- this.last = FeatureOptions.foptNow(this.options).getAsLong()
51
- this.tokens = 0
52
55
  }
53
56
 
54
57
  private def track(wait: Int): Unit = {
@@ -78,13 +78,8 @@ class RetryFeature extends BaseFeature("retry", "0.0.1", true) {
78
78
  Math.min(wait, maxDelay)
79
79
  }
80
80
 
81
- private def retryAfter(res: Object): Int = {
82
- val v = FeatureOptions.fresHeader(res, "retry-after")
83
- if ("" == v) return -1
84
- val seconds = FeatureOptions.fparseInt(v, -1)
85
- if (seconds < 0) return -1
86
- seconds * 1000
87
- }
81
+ private def retryAfter(res: Object): Int =
82
+ RetryFeature.retryAfterMs(FeatureOptions.fresHeader(res, "retry-after"), System.currentTimeMillis())
88
83
 
89
84
  private def sleep(ms: Int): Unit = {
90
85
  if (ms <= 0) return
@@ -102,3 +97,30 @@ class RetryFeature extends BaseFeature("retry", "0.0.1", true) {
102
97
  this.retries.add(entry)
103
98
  }
104
99
  }
100
+
101
+
102
+ object RetryFeature {
103
+ private val Months = "JanFebMarAprMayJunJulAugSepOctNovDec"
104
+
105
+ private val ImfFixdate =
106
+ "(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), ([0-9]{2}) ([A-Z][a-z]{2}) ([0-9]{4}) ([0-9]{2}):([0-9]{2}):([0-9]{2}) GMT".r
107
+
108
+ // RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else -1.
109
+ def retryAfterMs(value: String, now: Long): Int = {
110
+ val s = value.replaceAll("^[ \\t]+|[ \\t]+$", "")
111
+ if (s.nonEmpty && s.forall(c => c >= '0' && c <= '9')) {
112
+ if (s.length > 6) Int.MaxValue else s.toInt * 1000
113
+ }
114
+ else s match {
115
+ case ImfFixdate(day, mon, year, hour, min, sec) if Months.indexOf(mon) % 3 == 0 =>
116
+ try {
117
+ val at = java.time.LocalDateTime.of(year.toInt, Months.indexOf(mon) / 3 + 1, day.toInt,
118
+ hour.toInt, min.toInt, Math.min(sec.toInt, 59))
119
+ .toEpochSecond(java.time.ZoneOffset.UTC) * 1000 + (if (sec.toInt > 59) 1000 else 0)
120
+ Math.min(Int.MaxValue.toLong, Math.max(0L, at - now)).toInt
121
+ }
122
+ catch { case _: java.time.DateTimeException => -1 }
123
+ case _ => -1
124
+ }
125
+ }
126
+ }
@@ -65,6 +65,7 @@ import voxgig.plugin.{Definition, VBool, VList, VMap, VNull, VNum, VStr, Value}
65
65
  class SecretsFeature extends BaseFeature("secrets", "0.1.0", true) {
66
66
 
67
67
  private var client: SdkClient = null
68
+ private var rootctx: Context = null
68
69
 
69
70
  // Every value this feature resolves or buys is a secret the SDK handles,
70
71
  // and none arrives under an option key the intake registration saw.
@@ -141,6 +142,7 @@ class SecretsFeature extends BaseFeature("secrets", "0.1.0", true) {
141
142
  // Sync by feature contract: build the chain, never look anything up here.
142
143
  override def init(ctx: Context, options: JMap[String, Object]): Unit = {
143
144
  this.client = ctx.client
145
+ this.rootctx = ctx
144
146
  this.liveopts = ctx.options
145
147
  this.active = FeatureOptions.foptBool(options, "active", false)
146
148
 
@@ -517,6 +519,8 @@ class SecretsFeature extends BaseFeature("secrets", "0.1.0", true) {
517
519
  fetchdef.put("body", Struct.jsonify(bodymap, flags))
518
520
  // Never followed by the client: a redirect would carry the refresh token on.
519
521
  fetchdef.put("redirect", "manual")
522
+ // Its own bound, in milliseconds: the timeout feature's wrapper is above it.
523
+ fetchdef.put("timeout", java.lang.Integer.valueOf(30000))
520
524
 
521
525
  var res = exchangefetch(url, fetchdef)
522
526
 
@@ -568,34 +572,17 @@ class SecretsFeature extends BaseFeature("secrets", "0.1.0", true) {
568
572
  token
569
573
  }
570
574
 
571
- // Deliberately NOT the SDK transport. The transport is what this feature
572
- // wraps, and sending the token request back through it would recurse on
573
- // the first expiry - and would route the exchange through the test mock,
574
- // which knows nothing about it. `system.fetch` when the caller supplied
575
- // one, else the platform fetcher directly: Fetcher.defaultHttpFetch
576
- // already answers in the {status, headers, json} shape the seam promises
577
- // and, unlike Fetcher.fetcher, is gated on neither mode nor the test
578
- // feature.
575
+ // The SDK's own transport, beneath every feature's wrapper: it holds the
576
+ // test feature's block and the GET-only guard, and the wrapped one would
577
+ // recurse on the first expiry.
579
578
  private def exchangefetch(
580
579
  url: String,
581
580
  fetchdef: JMap[String, Object],
582
- ): JMap[String, Object] = {
583
- var sysfetch: Object = null
584
- if (this.liveopts != null) {
585
- sysfetch = Struct.getpath(this.liveopts, java.util.List.of("system", "fetch"))
586
- if (sysfetch eq Struct.UNDEF) sysfetch = null
587
- }
588
-
589
- sysfetch match {
590
- case bf: BiFunction[_, _, _] =>
591
- bf.asInstanceOf[BiFunction[String, JMap[String, Object], Object]]
592
- .apply(url, fetchdef) match {
593
- case m: JMap[_, _] => m.asInstanceOf[JMap[String, Object]]
594
- case _ => null
595
- }
596
- case _ => Fetcher.defaultHttpFetch(url, fetchdef)
581
+ ): JMap[String, Object] =
582
+ Fetcher.fetcher(this.rootctx, url, fetchdef) match {
583
+ case m: JMap[_, _] => m.asInstanceOf[JMap[String, Object]]
584
+ case _ => null
597
585
  }
598
- }
599
586
 
600
587
  // Where a 307 or 308 points, when that is on the exchange's own origin. Any
601
588
  // other redirect would drop the body or leave the origin.
@@ -27,8 +27,9 @@ class StreamingFeature extends BaseFeature("streaming", "0.0.1", true) {
27
27
  if (!this.active || !streamable(ctx)) {
28
28
  return
29
29
  }
30
+ // A failed result keeps no stream, so the entity's stream raises its error.
30
31
  val result = ctx.result
31
- if (result == null) {
32
+ if (result == null || result.err != null) {
32
33
  return
33
34
  }
34
35
 
@@ -15,7 +15,6 @@ class TelemetryFeature extends BaseFeature("telemetry", "0.0.1", true) {
15
15
 
16
16
  private var client: SdkClient = null
17
17
  private var options: JMap[String, Object] = null
18
- private var seq: Int = 0
19
18
 
20
19
  // Activity tracking (mirrors the ts client._telemetry record).
21
20
  var spans: JList[JMap[String, Object]] = new ArrayList[JMap[String, Object]]()
@@ -27,7 +26,6 @@ class TelemetryFeature extends BaseFeature("telemetry", "0.0.1", true) {
27
26
  this.client = ctx.client
28
27
  this.options = options
29
28
  this.active = FeatureOptions.foptBool(options, "active", false)
30
- this.seq = 0
31
29
  }
32
30
 
33
31
  override def prePoint(ctx: Context): Unit = {
@@ -125,13 +123,17 @@ class TelemetryFeature extends BaseFeature("telemetry", "0.0.1", true) {
125
123
  return f.asInstanceOf[java.util.function.Function[String, String]].apply(kind)
126
124
  case _ =>
127
125
  }
128
- // Deterministic-ish sequential id; unique within a client instance.
129
- this.seq += 1
130
- val n = new StringBuilder(String.format("%04x", java.lang.Integer.valueOf(this.seq)))
131
- val prefix = if ("trace".equals(kind)) "t" else "s"
132
- while (n.length < 16) {
133
- n.append("0")
134
- }
135
- prefix + n.toString
126
+ TelemetryFeature.randomHex(if ("trace".equals(kind)) 16 else 8)
127
+ }
128
+ }
129
+
130
+ object TelemetryFeature {
131
+ private val RANDOM = new java.security.SecureRandom()
132
+
133
+ // W3C trace context: lowercase hex from the platform's random source, never all zeros.
134
+ def randomHex(bytes: Int): String = {
135
+ val buf = new Array[Byte](bytes)
136
+ while ({ RANDOM.nextBytes(buf); buf.forall(_ == 0) }) ()
137
+ buf.map(b => "%02x".format(b & 0xff)).mkString
136
138
  }
137
139
  }
@@ -127,23 +127,9 @@ class TestFeature extends BaseFeature("test", "0.0.1", true) {
127
127
  out
128
128
  }
129
129
 
130
- private def resolveMatch(ctx: Context, explicit: JMap[String, Object]): JMap[String, Object] = {
131
- if (explicit != null && !explicit.isEmpty) return explicit
132
- val srcs = Array(ctx.matchData, ctx.data)
133
- var i = 0
134
- while (i < srcs.length) {
135
- val src = srcs(i)
136
- if (src != null) {
137
- val v = Struct.getprop(src, "id", null)
138
- if (v != null && !("__UNDEFINED__" == v)) {
139
- val out = new LinkedHashMap[String, Object]()
140
- out.put("id", v)
141
- return out
142
- }
143
- }
144
- i += 1
145
- }
146
- new LinkedHashMap[String, Object]()
130
+ private def held(src: JMap[String, Object], key: String): Boolean = {
131
+ val v = if (src == null) null else Struct.getprop(src, key, null)
132
+ v != null && !("__UNDEFINED__" == v)
147
133
  }
148
134
 
149
135
  private def serve(ctx: Context, entity: JMap[String, Object]): Object = {
@@ -152,7 +138,7 @@ class TestFeature extends BaseFeature("test", "0.0.1", true) {
152
138
  if (entmap == null) entmap = new LinkedHashMap[String, Object]()
153
139
 
154
140
  if ("load" == op.name) {
155
- val args = buildArgs(ctx, op, resolveMatch(ctx, ctx.reqmatch))
141
+ val args = buildArgs(ctx, op, ctx.reqmatch)
156
142
  val found = Struct.select(entmap, args)
157
143
  val ent = Struct.getelem(found, java.lang.Integer.valueOf(0), null)
158
144
  if (ent == null) return respond(ctx, 404, null, extra("statusText", "Not found"))
@@ -168,18 +154,7 @@ class TestFeature extends BaseFeature("test", "0.0.1", true) {
168
154
  val out = Struct.clone(found)
169
155
  respond(ctx, 200, out, null)
170
156
  } else if ("update" == op.name || "patch" == op.name) {
171
- var updateMatch = new LinkedHashMap[String, Object]()
172
- if (ctx.reqdata != null) {
173
- if (ctx.reqdata.containsKey("id")) updateMatch.put("id", ctx.reqdata.get("id"))
174
- if (op.alias != null) {
175
- Struct.getprop(op.alias, "id") match {
176
- case aliasId: String if ctx.reqdata.containsKey(aliasId) => updateMatch.put(aliasId, ctx.reqdata.get(aliasId))
177
- case _ =>
178
- }
179
- }
180
- }
181
- if (updateMatch.isEmpty) updateMatch = resolveMatch(ctx, new LinkedHashMap[String, Object]()).asInstanceOf[LinkedHashMap[String, Object]]
182
- val args = buildArgs(ctx, op, updateMatch)
157
+ val args = buildArgs(ctx, op, record(ctx.reqdata))
183
158
  val found = Struct.select(entmap, args)
184
159
  val ent = Struct.getelem(found, java.lang.Integer.valueOf(0), null)
185
160
  // update miss: 404, never another record
@@ -189,7 +164,7 @@ class TestFeature extends BaseFeature("test", "0.0.1", true) {
189
164
  val out = Struct.clone(ent)
190
165
  respond(ctx, 200, out, null)
191
166
  } else if ("remove" == op.name) {
192
- val args = buildArgs(ctx, op, resolveMatch(ctx, ctx.reqmatch))
167
+ val args = buildArgs(ctx, op, ctx.reqmatch)
193
168
  val found = Struct.select(entmap, args)
194
169
  val ent = Struct.getelem(found, java.lang.Integer.valueOf(0), null)
195
170
  ent match {
@@ -332,23 +307,48 @@ class TestFeature extends BaseFeature("test", "0.0.1", true) {
332
307
  val qand = Struct.jt()
333
308
  val q = Struct.jm("`$AND`", qand)
334
309
 
335
- if (args != null) {
336
- val kit = Struct.keysof(args).iterator()
337
- while (kit.hasNext) {
338
- val key = kit.next()
339
- val isId = "id" == key
340
- val selected = Struct.select(reqd, key)
341
- val isReqd = !Struct.isempty(selected)
310
+ val entityName = if (ctx.entity == null) "" else ctx.entity.getName()
311
+ val idfrom = Struct.getpath(ctx.config, java.util.List.of("entity", entityName, "id", "from"))
342
312
 
343
- if (isId || isReqd) {
344
- val v = ctx.utility.param(ctx, key)
345
- val ka = Struct.getprop(op.alias, key)
313
+ val names = new java.util.ArrayList[String]()
314
+ if (args != null) names.addAll(Struct.keysof(args))
346
315
 
347
- val qor = Struct.jt(Struct.jm(key, v))
348
- ka match { case s: String => qor.add(Struct.jm(s, v)); case _ => }
316
+ // With no id in the call, the entity's held id (or composite parts) stands in.
317
+ if (args == null || args.get("id") == null) {
318
+ val parts: JList[Object] = Struct.getpath(ctx.config, java.util.List.of("entity", entityName, "id", "parts")) match {
319
+ case l: JList[?] => l.asInstanceOf[JList[Object]]
320
+ case _ => if ("list" == opname) java.util.List.of() else java.util.List.of("id")
321
+ }
322
+ val pit = parts.iterator()
323
+ while (pit.hasNext) {
324
+ val pname = String.valueOf(pit.next())
325
+ if (!names.contains(pname) && (held(ctx.matchData, pname) || held(ctx.data, pname))) names.add(pname)
326
+ }
327
+ }
349
328
 
350
- qand.add(Struct.jm("`$OR`", qor))
329
+ val kit = names.iterator()
330
+ while (kit.hasNext) {
331
+ val key = kit.next()
332
+ val isId = "id" == key
333
+ val selected = Struct.select(reqd, key)
334
+ val isReqd = !Struct.isempty(selected)
335
+
336
+ if (isId || isReqd) {
337
+ val v = ctx.utility.param(ctx, key)
338
+ val ka = Struct.getprop(op.alias, key)
339
+
340
+ val qor = Struct.jt(Struct.jm(key, v))
341
+ ka match { case s: String => qor.add(Struct.jm(s, v)); case _ => }
342
+
343
+ // An alternative, never a replacement: a seed keeping the parameter
344
+ // flat is still found.
345
+ Struct.getprop(idfrom, key) match {
346
+ case kf: String if kf != key =>
347
+ qor.add(kf.split("\\.").foldRight(v)((seg, acc) => Struct.jm(seg, acc)))
348
+ case _ =>
351
349
  }
350
+
351
+ qand.add(Struct.jm("`$OR`", qor))
352
352
  }
353
353
  }
354
354
 
@@ -428,6 +428,34 @@ object SdkTestMain {
428
428
  (sent.get(1).get("headers") eq b.ctx.response.headers),
429
429
  "the cache handed on a copy it had read")
430
430
  eqI("cache.notJson.bypass", 2, f.bypass) }
431
+ { val rec = new FhRecorder()
432
+ val h = fhMake((c, u, fd) => rec.fetch(c, u, fd), fhF(new CacheFeature(), om("ttl" -> I(10000))))
433
+ h.op(fhOp("load").withPath("/w/1").withHeaders(om("x-tenant" -> "tenant-a")))
434
+ h.op(fhOp("load").withPath("/w/1").withHeaders(om("X-Tenant" -> "tenant-b")))
435
+ eqI("cache.tenantHeader", 2, rec.calls.size())
436
+ h.op(fhOp("load").withPath("/w/1").withHeaders(om("x-tenant" -> "tenant-b")))
437
+ eqI("cache.sameHeaders", 2, rec.calls.size()) }
438
+ { val rec = new FhRecorder(); val f = new CacheFeature()
439
+ val h = fhMake((c, u, fd) => rec.fetch(c, u, fd), fhF(f, om("ttl" -> I(10000))))
440
+ val paths = Seq("/w/1", "/w", "/w/1/part", "/other/1", "/w/2")
441
+ paths.foreach(p => h.op(fhOp("load").withPath(p)))
442
+ h.op(fhOp("update").withMethod("PUT").withPath("/w/1"))
443
+ paths.foreach(p => h.op(fhOp("load").withPath(p)))
444
+ eqI("cache.writeDrops", 9, rec.calls.size()); eqI("cache.writeKeepsOther", 2, f.hit) }
445
+ for (control <- Seq("no-store", "private", "No-Cache", "max-age=60, private")) {
446
+ val rec = new FhRecorder()
447
+ rec.reply = (n, fd) => fhResponse(200, om("ok" -> B(true)), om("Cache-Control" -> control))
448
+ val h = fhMake((c, u, fd) => rec.fetch(c, u, fd), fhF(new CacheFeature(), om("ttl" -> I(10000))))
449
+ h.op(fhOp("load").withPath("/w")); h.op(fhOp("load").withPath("/w"))
450
+ eqI("cache.unstored " + control, 2, rec.calls.size())
451
+ }
452
+ { val clk = new FhClock(); val rec = new FhRecorder()
453
+ rec.reply = (n, fd) => fhResponse(200, om("ok" -> B(true)), om("cache-control" -> "max-age=1"))
454
+ val h = fhMake((c, u, fd) => rec.fetch(c, u, fd), fhF(new CacheFeature(), om("ttl" -> I(10000), "now" -> f0(clk.nowFn))))
455
+ h.op(fhOp("load").withPath("/w")); clk.advance(500); h.op(fhOp("load").withPath("/w"))
456
+ eqI("cache.insideMaxAge", 1, rec.calls.size())
457
+ clk.advance(600); h.op(fhOp("load").withPath("/w"))
458
+ eqI("cache.maxAge", 2, rec.calls.size()) }
431
459
  }
432
460
 
433
461
  private def testIdempotency(): Unit = {
@@ -603,6 +631,36 @@ object SdkTestMain {
603
631
  { val rec = new FhRecorder()
604
632
  val h = fhMake((c, u, fd) => rec.fetch(c, u, fd), fhF(new PagingFeature(), om("active" -> B(false))))
605
633
  h.op(fhOp("list").withPath("/w")); check("paging.inactive", !rec.url(0).contains("page="), "url=" + rec.url(0)) }
634
+
635
+ // The documented hasMore loop, one request per page.
636
+ def walk(name: String, reply: Int => JMap[String, Object], want: Seq[String],
637
+ options: JMap[String, Object] = null): JMap[String, Object] = {
638
+ val rec = new FhRecorder()
639
+ rec.reply = (n, fd) => reply(n.intValue)
640
+ val h = fhMake((c, u, fd) => rec.fetch(c, u, fd), fhF(new PagingFeature(), options))
641
+ val paging = om()
642
+ val ctrl = om("paging" -> paging)
643
+ h.op(fhOp("list").withPath("/w").withCtrl(ctrl))
644
+ while (B(true) == paging.get("hasMore") && rec.calls.size < 4) h.op(fhOp("list").withPath("/w").withCtrl(ctrl))
645
+ val urls = (0 until rec.calls.size).map(rec.url)
646
+ check(name, urls == want, "urls=" + urls.mkString(" | "))
647
+ eq(name + ".end", B(false), paging.get("hasMore"))
648
+ paging
649
+ }
650
+ walk("paging.bodyNextCursor", n => fhResponse(200, if (n <= 2) om("next" -> Seq("c3", "c6")(n - 1)) else om(), null),
651
+ Seq("http://api.test/w?page=1", "http://api.test/w?cursor=c3", "http://api.test/w?cursor=c6"))
652
+ walk("paging.bodyNextUrl", n => fhResponse(200,
653
+ if (n <= 2) om("next" -> Seq("http://api.test/v2/w?cursor=c%2F3&limit=3", "/v2/w?cursor=c6")(n - 1)) else om(), null),
654
+ Seq("http://api.test/w?page=1", "http://api.test/v2/w?cursor=c%2F3&limit=3", "http://api.test/v2/w?cursor=c6"))
655
+ walk("paging.linkNextUrl", n => fhResponse(200, jl(),
656
+ if (n <= 2) om("link" -> Seq("<http://api.test/w?after=b3>; rel=\"next\"", "</w?after=b6>; rel=\"next\"")(n - 1)) else null),
657
+ Seq("http://api.test/w?page=1", "http://api.test/w?after=b3", "http://api.test/w?after=b6"))
658
+ val foreign = walk("paging.foreignLink", n => fhResponse(200, jl(),
659
+ om("link" -> "<https://elsewhere.test/w?after=b3>; rel=\"next\"")),
660
+ Seq("http://api.test/w?page=1"))
661
+ eq("paging.foreignLink.kept", "https://elsewhere.test/w?after=b3", foreign.get("foreign"))
662
+ walk("paging.cursorMode", n => fhResponse(200, if (n == 1) om("next" -> "/c3") else om(), null),
663
+ Seq("http://api.test/w?page=1", "http://api.test/w?cursor=%2Fc3"), om("next" -> "cursor"))
606
664
  }
607
665
 
608
666
  private def testStreaming(): Unit = {
@@ -625,6 +683,17 @@ object SdkTestMain {
625
683
  { val f = new StreamingFeature()
626
684
  val h = fhMake(null, fhF(f, om("active" -> B(false))))
627
685
  val r = h.op(fhOp("list").withPath("/w")); check("streaming.inactive.nostream", !r.result.streaming, "inactive must not attach"); eqI("streaming.inactive.opened", 0, f.opened) }
686
+ { val rec = new FhRecorder(); val f = new StreamingFeature()
687
+ rec.reply = (n, fd) => fhResponse(503, jl(), null)
688
+ val h = fhMake((c, u, fd) => rec.fetch(c, u, fd), fhF(f, null))
689
+ val r = h.op(fhOp("list").withPath("/w"))
690
+ check("streaming.failed.nostream", !r.result.streaming && r.result.stream == null, "a failed result must keep no stream")
691
+ eqI("streaming.failed.opened", 0, f.opened) }
692
+ { val rec = new FhRecorder()
693
+ rec.reply = (n, fd) => fhResponse(200, jl(), null)
694
+ val h = fhMake((c, u, fd) => rec.fetch(c, u, fd), fhF(new StreamingFeature(), null))
695
+ val r = h.op(fhOp("list").withPath("/w"))
696
+ check("streaming.empty", r.result.stream != null && !r.result.stream.get().hasNext, "an empty list streams nothing") }
628
697
  }
629
698
 
630
699
  private def testProxy(): Unit = {
@@ -174,6 +174,11 @@ object Fetcher {
174
174
  val reqb =
175
175
  try HttpRequest.newBuilder(URI.create(fullurl)).method(method, bodyPublisher)
176
176
  catch { case e: RuntimeException => throw new RuntimeException("fetch: invalid url: " + fullurl, e) }
177
+ // A bound in milliseconds, for a caller beneath the timeout feature.
178
+ fetchdef.get("timeout") match {
179
+ case n: java.lang.Number if 0 < n.longValue() => reqb.timeout(java.time.Duration.ofMillis(n.longValue()))
180
+ case _ =>
181
+ }
177
182
 
178
183
  var hasUA = false
179
184
  fetchdef.get("headers") match {