@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
@@ -63,8 +63,8 @@ local json = require("dkjson")
63
63
  local helpers = require("core.helpers")
64
64
  local BaseFeature = require("feature.base_feature")
65
65
  local sekreto = require("feature.secrets.sekreto")
66
- local tls = require("utility.tls")
67
66
  local base64 = require("utility.clean").base64
67
+ local fetcher_util = require("utility.fetcher")
68
68
 
69
69
 
70
70
  local SecretsFeature = {}
@@ -469,6 +469,9 @@ function SecretsFeature:_transport(ctx, fullurl, fetchdef, inner)
469
469
  -- settled success is free, and with `cache = false` the chain is asked
470
470
  -- once per REQUEST, which is that option's meaning.
471
471
  local refused = self:_resolve()
472
+ if type(refused) == "table" and refused.is_sdk_error then
473
+ return nil, refused
474
+ end
472
475
  if refused ~= nil then
473
476
  return nil, ctx:make_error("secrets_refused", sekreto.errmessage(refused))
474
477
  end
@@ -637,77 +640,6 @@ function SecretsFeature:_buy()
637
640
  end
638
641
 
639
642
 
640
- -- The token-exchange transport of last resort: LuaSocket's http, answering
641
- -- the same shape the system.fetch seam promises (status + json). It exists
642
- -- so an exchange works with ordinary SDK options - requiring a custom
643
- -- transport for the COMMON case would reject every live token purchase
644
- -- before a request was made. Mirrors utility/fetcher.lua's own default
645
- -- (which is a local there, not exported); like it, this is HTTP through
646
- -- socket.http, and an https token endpoint needs luasec on the package path,
647
- -- which the rockspec does not require, and is verified as utility/tls says.
648
- local function raw_exchange_fetch(fullurl, fetchdef)
649
- local http_ok, http = pcall(require, "socket.http")
650
- local ltn12_ok, ltn12 = pcall(require, "ltn12")
651
- if not http_ok or not ltn12_ok then
652
- return nil, "HTTP library not available (install luasocket)"
653
- end
654
-
655
- local headers = {}
656
- for k, v in pairs(fetchdef["headers"] or {}) do
657
- if type(v) == "string" then
658
- headers[k] = v
659
- end
660
- end
661
-
662
- local body = fetchdef["body"]
663
- if type(body) ~= "string" then
664
- body = nil
665
- end
666
- if body ~= nil then
667
- headers["content-length"] = tostring(#body)
668
- end
669
-
670
- local create, refused = tls.create(fullurl)
671
- if refused ~= nil then
672
- return nil, refused
673
- end
674
-
675
- local chunks = {}
676
- local res, code, rawheaders = http.request({
677
- url = fullurl,
678
- method = fetchdef["method"] or "POST",
679
- headers = headers,
680
- source = body and ltn12.source.string(body) or nil,
681
- sink = ltn12.sink.table(chunks),
682
- create = create,
683
- redirect = false,
684
- })
685
-
686
- if not res then
687
- return nil, code
688
- end
689
-
690
- local raw = table.concat(chunks)
691
- local resheaders = {}
692
- for k, v in pairs(type(rawheaders) == "table" and rawheaders or {}) do
693
- resheaders[string.lower(k)] = v
694
- end
695
-
696
- return {
697
- status = code,
698
- headers = resheaders,
699
- json = function()
700
- if #raw == 0 then
701
- return nil
702
- end
703
- local decoded = json.decode(raw)
704
- return decoded
705
- end,
706
- body = raw,
707
- }, nil
708
- end
709
-
710
-
711
643
  function SecretsFeature:_buy_once()
712
644
  local x = self._exchange
713
645
 
@@ -728,14 +660,12 @@ function SecretsFeature:_buy_once()
728
660
  base = base:gsub("/+$", "")
729
661
  local url = base .. "/" .. (x.path:gsub("^/+", ""))
730
662
 
731
- -- Deliberately NOT the SDK transport. The transport is what this feature
732
- -- wraps, and sending the token request back through it would recurse on
733
- -- the first expiry - and would route the exchange through the test mock,
734
- -- which knows nothing about it. system.fetch, when the caller supplied
735
- -- one, is the raw seam beneath the transport and is honoured.
736
- local fetch = vs.getpath(options, "system.fetch")
737
- if type(fetch) ~= "function" then
738
- fetch = raw_exchange_fetch
663
+ -- The SDK's own transport, beneath every feature's wrapper: it holds the
664
+ -- test feature's block and the GET-only guard, and the wrapped one would
665
+ -- recurse on the first expiry.
666
+ local rootctx = self._rootctx
667
+ local fetch = function(at, fd)
668
+ return fetcher_util(rootctx, at, fd)
739
669
  end
740
670
 
741
671
  -- The body is ENCODED, never concatenated: a refresh token (or a
@@ -747,6 +677,8 @@ function SecretsFeature:_buy_once()
747
677
  body = json.encode({ [x.request] = self._refresh }),
748
678
  -- Never followed by the client: a redirect would carry the refresh token on.
749
679
  redirect = "manual",
680
+ -- Its own bound, in milliseconds: the timeout feature's wrapper is above it.
681
+ timeout = 30000,
750
682
  }
751
683
  local res, err = fetch(url, fetchdef)
752
684
 
@@ -761,6 +693,9 @@ function SecretsFeature:_buy_once()
761
693
  res, err = fetch(at, fetchdef)
762
694
  end
763
695
 
696
+ if type(err) == "table" and err.is_sdk_error then
697
+ return nil, err
698
+ end
764
699
  if err ~= nil then
765
700
  return nil, sekreto.SekretoError(
766
701
  "secrets: token exchange failed: " .. tostring(err) .. " from " .. url)
@@ -48,8 +48,9 @@ function StreamingFeature:PreResult(ctx)
48
48
  if not self:_streamable(ctx) then
49
49
  return
50
50
  end
51
+ -- A failed result keeps no stream, so the entity's stream raises its error.
51
52
  local result = ctx.result
52
- if result == nil then
53
+ if result == nil or result.err ~= nil then
53
54
  return
54
55
  end
55
56
 
@@ -28,7 +28,6 @@ function TelemetryFeature.new()
28
28
  self.options = nil
29
29
  -- Weak keys: an abandoned context must not leak its open span.
30
30
  self.spans = setmetatable({}, { __mode = "k" })
31
- self.seq = 0
32
31
  return self
33
32
  end
34
33
 
@@ -44,7 +43,6 @@ function TelemetryFeature:init(ctx, options)
44
43
  end
45
44
 
46
45
  self.spans = setmetatable({}, { __mode = "k" })
47
- self.seq = 0
48
46
 
49
47
  if not self.active then
50
48
  return
@@ -137,16 +135,29 @@ function TelemetryFeature:_close(ctx, ok)
137
135
  end
138
136
 
139
137
 
138
+ -- W3C trace context: lowercase hex from the platform's random source, never all
139
+ -- zeros. Where /dev/urandom cannot be read, math.random stands in.
140
+ local function random_hex(nbytes)
141
+ while true do
142
+ local f = io.open("/dev/urandom", "rb")
143
+ local buf = f and f:read(nbytes) or ""
144
+ if f then f:close() end
145
+ local hex = {}
146
+ for i = 1, nbytes do
147
+ local b = buf:byte(i) or math.random(0, 255)
148
+ hex[i] = string.format("%02x", b)
149
+ end
150
+ local out = table.concat(hex)
151
+ if out:find("[^0]") then return out end
152
+ end
153
+ end
154
+
140
155
  function TelemetryFeature:_id(kind)
141
156
  local idgen = self.options["idgen"]
142
157
  if type(idgen) == "function" then
143
158
  return idgen(kind)
144
159
  end
145
- -- Deterministic-ish sequential id; unique within a client instance.
146
- self.seq = self.seq + 1
147
- local n = string.format("%04x", self.seq)
148
- local prefix = kind == "trace" and "t" or "s"
149
- return prefix .. n .. string.rep("0", 12)
160
+ return random_hex(kind == "trace" and 16 or 8)
150
161
  end
151
162
 
152
163
 
@@ -147,27 +147,8 @@ function TestFeature:init(ctx, options)
147
147
  entmap = {}
148
148
  end
149
149
 
150
- -- For single-entity ops (load, remove) with an empty explicit match, fall
151
- -- back to the id the entity client already knows from a prior create/load
152
- -- (in fctx.match / fctx.data). Mirrors the TS mock where param() resolves
153
- -- the id from that accumulated state.
154
- local function resolve_match(explicit)
155
- if type(explicit) == "table" and next(explicit) ~= nil then
156
- return explicit
157
- end
158
- local function id_of(src)
159
- if src == nil then return nil end
160
- local v = vs.getprop(src, "id")
161
- if v ~= nil and v ~= "__UNDEFINED__" then return v end
162
- return nil
163
- end
164
- local v = id_of(fctx.match) or id_of(fctx.data)
165
- if v ~= nil then return { id = v } end
166
- return {}
167
- end
168
-
169
150
  if op.name == "load" then
170
- local args = test_self:build_args(fctx, op, resolve_match(fctx.reqmatch))
151
+ local args = test_self:build_args(fctx, op, fctx.reqmatch)
171
152
  local found = vs.select(entmap, args)
172
153
  local ent = vs.getelem(found, 0)
173
154
  if ent == nil then
@@ -192,26 +173,7 @@ function TestFeature:init(ctx, options)
192
173
  return respond(200, out, nil)
193
174
 
194
175
  elseif op.name == "update" or op.name == "patch" then
195
- -- Match the existing entity by id only (or its alias). reqdata also
196
- -- contains the new field values, which would otherwise cause select
197
- -- to filter out the entity we want to update. When reqdata has no id,
198
- -- fall back to the id the entity client carries from a prior
199
- -- create/load (in fctx.match / fctx.data), mirroring the TS mock
200
- -- where param(ctx,'id') resolves from accumulated state.
201
- local update_match = {}
202
- if type(fctx.reqdata) == "table" then
203
- if fctx.reqdata["id"] ~= nil then update_match["id"] = fctx.reqdata["id"] end
204
- if op.alias_map ~= nil then
205
- local alias_id = vs.getprop(op.alias_map, "id")
206
- if alias_id ~= nil and fctx.reqdata[alias_id] ~= nil then
207
- update_match[alias_id] = fctx.reqdata[alias_id]
208
- end
209
- end
210
- end
211
- if next(update_match) == nil then
212
- update_match = resolve_match({})
213
- end
214
- local args = test_self:build_args(fctx, op, update_match)
176
+ local args = test_self:build_args(fctx, op, record(fctx.reqdata))
215
177
  local found = vs.select(entmap, args)
216
178
  local ent = vs.getelem(found, 0)
217
179
  if ent == nil then
@@ -226,7 +188,7 @@ function TestFeature:init(ctx, options)
226
188
  return respond(200, out, nil)
227
189
 
228
190
  elseif op.name == "remove" then
229
- local args = test_self:build_args(fctx, op, resolve_match(fctx.reqmatch))
191
+ local args = test_self:build_args(fctx, op, fctx.reqmatch)
230
192
  local found = vs.select(entmap, args)
231
193
  local ent = vs.getelem(found, 0)
232
194
  -- Remove only the first matched entity. If nothing matches,
@@ -382,6 +344,12 @@ local function pick_point(points)
382
344
  return point
383
345
  end
384
346
 
347
+ local function held(src, key)
348
+ if src == nil then return false end
349
+ local v = vs.getprop(src, key)
350
+ return v ~= nil and v ~= "__UNDEFINED__"
351
+ end
352
+
385
353
  function TestFeature:build_args(ctx, op, args)
386
354
  local opname = op.name
387
355
 
@@ -400,32 +368,62 @@ function TestFeature:build_args(ctx, op, args)
400
368
  local qand = {}
401
369
  local q = { ["`$AND`"] = qand }
402
370
 
371
+ local ename = ctx.entity:get_name()
372
+ local idfrom = vs.getpath(ctx.config, "entity." .. ename .. ".id.from")
373
+
374
+ local names = {}
403
375
  if args ~= nil then
404
- local keys = vs.keysof(args)
405
- if keys ~= nil then
406
- for _, key in ipairs(keys) do
407
- local is_id = (key == "id")
408
- local is_reqd = not vs.isempty(vs.select(reqd_from_params, key))
409
- or not vs.isempty(vs.select(reqd_from_query, key))
410
-
411
- if is_id or is_reqd then
412
- local v = ctx.utility.param(ctx, key)
413
- local ka = nil
414
- if op.alias ~= nil then
415
- ka = vs.getprop(op.alias, key)
416
- end
417
-
418
- local qor = { { [key] = v } }
419
- if ka ~= nil and type(ka) == "string" then
420
- table.insert(qor, { [ka] = v })
421
- end
422
-
423
- table.insert(qand, { ["`$OR`"] = qor })
424
- end
376
+ for _, key in ipairs(vs.keysof(args) or {}) do table.insert(names, key) end
377
+ end
378
+
379
+ -- With no id in the call, the entity's held id (or composite parts) stands in.
380
+ if not held(args, "id") then
381
+ local parts = vs.getpath(ctx.config, "entity." .. ename .. ".id.parts")
382
+ if not vs.islist(parts) then
383
+ parts = (opname == "list") and {} or { "id" }
384
+ end
385
+ for _, part in ipairs(parts) do
386
+ local pname = tostring(part)
387
+ local seen = false
388
+ for _, n in ipairs(names) do seen = seen or n == pname end
389
+ if not seen and (held(ctx.match, pname) or held(ctx.data, pname)) then
390
+ table.insert(names, pname)
425
391
  end
426
392
  end
427
393
  end
428
394
 
395
+ for _, key in ipairs(names) do
396
+ local is_id = (key == "id")
397
+ local is_reqd = not vs.isempty(vs.select(reqd_from_params, key))
398
+ or not vs.isempty(vs.select(reqd_from_query, key))
399
+
400
+ if is_id or is_reqd then
401
+ local v = ctx.utility.param(ctx, key)
402
+ local ka = nil
403
+ if op.alias ~= nil then
404
+ ka = vs.getprop(op.alias, key)
405
+ end
406
+
407
+ local qor = { { [key] = v } }
408
+ if ka ~= nil and type(ka) == "string" then
409
+ table.insert(qor, { [ka] = v })
410
+ end
411
+
412
+ -- An alternative, never a replacement: a seed keeping the parameter
413
+ -- flat is still found.
414
+ local kf = idfrom ~= nil and vs.getprop(idfrom, key) or nil
415
+ if type(kf) == "string" and kf ~= key then
416
+ local segs = {}
417
+ for seg in string.gmatch(kf, "[^.]+") do table.insert(segs, seg) end
418
+ local nest = v
419
+ for i = #segs, 1, -1 do nest = { [segs[i]] = nest } end
420
+ table.insert(qor, nest)
421
+ end
422
+
423
+ table.insert(qand, { ["`$OR`"] = qor })
424
+ end
425
+ end
426
+
429
427
  q["`$AND`"] = qand
430
428
 
431
429
  if ctx.ctrl.explain ~= nil then
@@ -718,6 +718,87 @@ describe("feature", function()
718
718
  h.op({ op = "load", path = "/x" })
719
719
  assert.are.equal(2, #rec.calls)
720
720
  end)
721
+
722
+ -- The reference vectors of the SipHash paper: key 00..0f, message 00..len-1.
723
+ it("matches the SipHash reference vectors", function()
724
+ local CacheFeature = require("feature.cache_feature")
725
+ local bytes = {}
726
+ for i = 0, 63 do bytes[#bytes + 1] = string.char(i) end
727
+ local msg = table.concat(bytes)
728
+ local key = string.sub(msg, 1, 16)
729
+ for _, v in ipairs({
730
+ { 0, "726fdb47dd0e0e31" },
731
+ { 1, "74f839c593dc67fd" },
732
+ { 2, "0d6c8009d9a94f5a" },
733
+ { 3, "85676696d7fb7e2d" },
734
+ { 4, "cf2794e0277187b7" },
735
+ { 5, "18765564cd99a68d" },
736
+ { 6, "cbc9466e58fee3ce" },
737
+ { 7, "ab0200f58b01d137" },
738
+ { 8, "93f5f5799a932462" },
739
+ { 15, "a129ca6149be45e5" },
740
+ { 16, "3f2acc7f57c29bdb" },
741
+ { 63, "958a324ceb064572" },
742
+ }) do
743
+ assert.are.equal(v[2], string.format("%016x", CacheFeature._siphash24(key, string.sub(msg, 1, v[1]))))
744
+ end
745
+ end)
746
+
747
+ it("keys on the request headers", function()
748
+ local rec = recording_server()
749
+ local h = make_client({ features = {
750
+ { name = "cache", options = { ttl = 10000 } },
751
+ }, server = rec.server })
752
+ h.op({ op = "load", path = "/w/1", headers = { ["x-tenant"] = "tenant-a" } })
753
+ h.op({ op = "load", path = "/w/1", headers = { ["X-Tenant"] = "tenant-b" } })
754
+ assert.are.equal(2, #rec.calls)
755
+ h.op({ op = "load", path = "/w/1", headers = { ["x-tenant"] = "tenant-b" } })
756
+ assert.are.equal(2, #rec.calls)
757
+ end)
758
+
759
+ it("drops a write's collection", function()
760
+ local rec = recording_server()
761
+ local h = make_client({ features = {
762
+ { name = "cache", options = { ttl = 10000 } },
763
+ }, server = rec.server })
764
+ local paths = { "/w/1", "/w", "/w/1/part", "/other/1", "/w/2" }
765
+ for _, p in ipairs(paths) do h.op({ op = "load", path = p }) end
766
+ h.op({ op = "update", method = "PUT", path = "/w/1" })
767
+ for _, p in ipairs(paths) do h.op({ op = "load", path = p }) end
768
+ assert.are.equal(9, #rec.calls)
769
+ assert.are.equal(2, h.client._cache.hit)
770
+ end)
771
+
772
+ it("does not store what Cache-Control forbids", function()
773
+ for _, control in ipairs({ "no-store", "private", "No-Cache", "max-age=60, private" }) do
774
+ local rec = recording_server(function()
775
+ return make_response(200, { ok = true }, { ["Cache-Control"] = control })
776
+ end)
777
+ local h = make_client({ features = {
778
+ { name = "cache", options = { ttl = 10000 } },
779
+ }, server = rec.server })
780
+ h.op({ op = "load", path = "/w" })
781
+ h.op({ op = "load", path = "/w" })
782
+ assert.are.equal(2, #rec.calls, control)
783
+ end
784
+ end)
785
+
786
+ it("caps the ttl by max-age", function()
787
+ local clock = make_clock()
788
+ local rec = recording_server(function()
789
+ return make_response(200, { ok = true }, { ["cache-control"] = "max-age=1" })
790
+ end)
791
+ local h = make_client({ features = {
792
+ { name = "cache", options = { ttl = 10000, now = clock.now } },
793
+ }, server = rec.server })
794
+ h.op({ op = "load", path = "/w" })
795
+ clock.advance(500)
796
+ h.op({ op = "load", path = "/w" })
797
+ assert.are.equal(1, #rec.calls)
798
+ clock.advance(600)
799
+ h.op({ op = "load", path = "/w" })
800
+ assert.are.equal(2, #rec.calls)
801
+ end)
721
802
  end) end
722
803
 
723
804
 
@@ -909,7 +990,11 @@ describe("feature", function()
909
990
  it("default id generation and no exporter", function()
910
991
  local h = make_client({ features = { { name = "telemetry" } } })
911
992
  h.op({ op = "load" })
912
- assert.is_truthy(string.match(h.client._telemetry.spans[1].traceId, "^t"))
993
+ local span = h.client._telemetry.spans[1]
994
+ assert.is_truthy(string.match(span.traceId, "^" .. string.rep("[0-9a-f]", 32) .. "$"))
995
+ assert.is_truthy(string.match(span.traceId, "[^0]"))
996
+ assert.is_truthy(string.match(span.spanId, "^" .. string.rep("[0-9a-f]", 16) .. "$"))
997
+ assert.is_truthy(string.match(span.spanId, "[^0]"))
913
998
  end)
914
999
 
915
1000
  it("injected idgen + clock", function()
@@ -936,11 +1021,11 @@ describe("feature", function()
936
1021
  -- debug -----------------------------------------------------------------
937
1022
  if has_feature("debug") then describe("debug", function()
938
1023
 
939
- it("captures a redacted trace and honours on_entry + max", function()
1024
+ it("captures a redacted trace and honours onEntry + max", function()
940
1025
  local seen = {}
941
1026
  local h = make_client({ features = {
942
1027
  { name = "debug", options = {
943
- max = 1, on_entry = function(e) table.insert(seen, e) end } },
1028
+ max = 1, onEntry = function(e) table.insert(seen, e) end } },
944
1029
  } })
945
1030
  h.op({ op = "load", headers = { authorization = "Bearer secret" } })
946
1031
  h.op({ op = "list" })
@@ -1148,6 +1233,82 @@ describe("feature", function()
1148
1233
  assert.is_true(res.result.paging.hasMore)
1149
1234
  end)
1150
1235
 
1236
+ -- The documented hasMore loop, one request per page.
1237
+ local function walk(reply, options)
1238
+ local rec = recording_server(reply)
1239
+ local h = make_client({ features = { { name = "paging", options = options } }, server = rec.server })
1240
+ local paging = {}
1241
+ local ctrl = { paging = paging }
1242
+ h.op({ op = "list", path = "/w", ctrl = ctrl })
1243
+ while paging.hasMore == true and #rec.calls < 4 do
1244
+ h.op({ op = "list", path = "/w", ctrl = ctrl })
1245
+ end
1246
+ local urls = {}
1247
+ for i, call in ipairs(rec.calls) do urls[i] = call.url end
1248
+ return urls, paging
1249
+ end
1250
+
1251
+ it("a body next that is not a URL is sent back as the cursor", function()
1252
+ local pages = { "c3", "c6" }
1253
+ local urls, paging = walk(function(n) return make_response(200, { next = pages[n] }) end)
1254
+ assert.are.same({ "http://api.test/w?page=1", "http://api.test/w?cursor=c3",
1255
+ "http://api.test/w?cursor=c6" }, urls)
1256
+ assert.is_false(paging.hasMore)
1257
+ end)
1258
+
1259
+ it("a body next URL is the next request", function()
1260
+ local pages = { "http://api.test/v2/w?cursor=c%2F3&limit=3", "/v2/w?cursor=c6" }
1261
+ local urls, paging = walk(function(n) return make_response(200, { next = pages[n] }) end)
1262
+ assert.are.same({ "http://api.test/w?page=1", "http://api.test/v2/w?cursor=c%2F3&limit=3",
1263
+ "http://api.test/v2/w?cursor=c6" }, urls)
1264
+ assert.is_false(paging.hasMore)
1265
+ end)
1266
+
1267
+ it("a Link next URL is the next request", function()
1268
+ local links = { '<http://api.test/w?after=b3>; rel="next"', '</w?after=b6>; rel="next"' }
1269
+ local urls, paging = walk(function(n)
1270
+ return make_response(200, {}, links[n] and { link = links[n] } or nil)
1271
+ end)
1272
+ assert.are.same({ "http://api.test/w?page=1", "http://api.test/w?after=b3",
1273
+ "http://api.test/w?after=b6" }, urls)
1274
+ assert.is_false(paging.hasMore)
1275
+ end)
1276
+
1277
+ it("a query-only Link keeps the path", function()
1278
+ local links = { '</v1/items?page=2>; rel="next"', '<?page=3>; rel="next"' }
1279
+ local urls = walk(function(n)
1280
+ return make_response(200, {}, links[n] and { link = links[n] } or nil)
1281
+ end)
1282
+ assert.are.same({ "http://api.test/w?page=1", "http://api.test/v1/items?page=2",
1283
+ "http://api.test/v1/items?page=3" }, urls)
1284
+ end)
1285
+
1286
+ it("a path-relative Link resolves against the request", function()
1287
+ local links = { '</v1/items?page=2>; rel="next"', '<more?page=3>; rel="next"' }
1288
+ local urls = walk(function(n)
1289
+ return make_response(200, {}, links[n] and { link = links[n] } or nil)
1290
+ end)
1291
+ assert.are.same({ "http://api.test/w?page=1", "http://api.test/v1/items?page=2",
1292
+ "http://api.test/v1/more?page=3" }, urls)
1293
+ end)
1294
+
1295
+ it("a link to another origin ends the walk", function()
1296
+ local urls, paging = walk(function()
1297
+ return make_response(200, {}, { link = '<https://elsewhere.test/w?after=b3>; rel="next"' })
1298
+ end)
1299
+ assert.are.same({ "http://api.test/w?page=1" }, urls)
1300
+ assert.is_false(paging.hasMore)
1301
+ assert.are.equal("https://elsewhere.test/w?after=b3", paging.foreign)
1302
+ end)
1303
+
1304
+ it("next cursor sends a value starting with a slash as the cursor", function()
1305
+ local pages = { "/c3" }
1306
+ local urls, paging = walk(function(n) return make_response(200, { next = pages[n] }) end,
1307
+ { next = "cursor" })
1308
+ assert.are.same({ "http://api.test/w?page=1", "http://api.test/w?cursor=%2Fc3" }, urls)
1309
+ assert.is_false(paging.hasMore)
1310
+ end)
1311
+
1151
1312
  it("non-list op is not paged", function()
1152
1313
  local rec = recording_server()
1153
1314
  local h = make_client({ features = {
@@ -1204,6 +1365,23 @@ describe("feature", function()
1204
1365
  assert.are.same({ { 1, 2 }, { 3, 4 }, { 5 } }, batches)
1205
1366
  end)
1206
1367
 
1368
+ it("a failed result keeps no stream", function()
1369
+ local rec = recording_server(function() return make_response(503, {}) end)
1370
+ local h = make_client({ features = { { name = "streaming" } }, server = rec.server })
1371
+ local res = h.op({ op = "list", path = "/w" })
1372
+ assert.is_nil(res.result.stream)
1373
+ assert.is_nil(res.result.streaming)
1374
+ end)
1375
+
1376
+ it("an empty list streams nothing", function()
1377
+ local rec = recording_server(function() return make_response(200, {}) end)
1378
+ local h = make_client({ features = { { name = "streaming" } }, server = rec.server })
1379
+ local res = h.op({ op = "list", path = "/w" })
1380
+ local seen = {}
1381
+ for item in res.result.stream() do table.insert(seen, item) end
1382
+ assert.are.same({}, seen)
1383
+ end)
1384
+
1207
1385
  it("non-list op is not streamed", function()
1208
1386
  local h = make_client({ features = { { name = "streaming" } } })
1209
1387
  local res = h.op({ op = "load" })
@@ -141,16 +141,13 @@ local function make_clean_config(cleanopts)
141
141
  end
142
142
 
143
143
 
144
- -- A context without options (make_error accepts a bare one) still masks by
145
- -- the schema defaults.
144
+ -- A context without a registry (make_error accepts a bare one) still masks
145
+ -- by the schema defaults.
146
146
  local function clean_config(ctx)
147
- if type(ctx) == "table" and type(ctx.options) == "table" then
148
- local derived = ctx.options["__derived__"]
149
- if type(derived) == "table" and type(derived.clean) == "table"
150
- and type(derived.clean.values) == "table"
151
- then
152
- return derived.clean
153
- end
147
+ if type(ctx) == "table" and type(ctx.cleancfg) == "table"
148
+ and type(ctx.cleancfg.values) == "table"
149
+ then
150
+ return ctx.cleancfg
154
151
  end
155
152
 
156
153
  local ok, schema = pcall(require, "schema")
@@ -267,6 +267,14 @@ local function send_once(fullurl, fetchdef)
267
267
  return nil, refused
268
268
  end
269
269
 
270
+ -- A bound in milliseconds, for a caller beneath the timeout feature;
271
+ -- luasocket reads its timeout from the module, so it is restored after.
272
+ local bound = fetchdef["timeout"]
273
+ local was = http.TIMEOUT
274
+ if type(bound) == "number" and bound > 0 then
275
+ http.TIMEOUT = bound / 1000
276
+ end
277
+
270
278
  local response_body = {}
271
279
  local res, code, response_headers = http.request({
272
280
  url = fullurl,
@@ -277,6 +285,7 @@ local function send_once(fullurl, fetchdef)
277
285
  redirect = false,
278
286
  create = create,
279
287
  })
288
+ http.TIMEOUT = was
280
289
 
281
290
  if not res then
282
291
  return nil, code