@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
@@ -112,6 +112,7 @@ public abstract class EntityBase implements SdkEntity {
112
112
  // ctrl.throw is false).
113
113
  protected Object runOp(Context ctx, Runnable postDone) {
114
114
  Utility utility = this.utility;
115
+ boolean predone = false;
115
116
 
116
117
  try {
117
118
  // #PrePoint-Hook
@@ -139,6 +140,7 @@ public abstract class EntityBase implements SdkEntity {
139
140
  Object result = utility.makeResult.apply(ctx);
140
141
  ctx.out.put("result", result);
141
142
 
143
+ predone = true;
142
144
  // #PreDone-Hook
143
145
 
144
146
  postDone.run();
@@ -167,6 +169,25 @@ public abstract class EntityBase implements SdkEntity {
167
169
  catch (RuntimeException err) {
168
170
  return unexpected(ctx, err);
169
171
  }
172
+ finally {
173
+ // A refusal, a failed step or a throw left before PreDone.
174
+ if (!predone) {
175
+ lateDone(ctx);
176
+ }
177
+ }
178
+ }
179
+
180
+ // PreDone on an exit that left before it. What the hook throws leaves
181
+ // cleaned, in place of the error already on its way out.
182
+ private void lateDone(Context ctx) {
183
+ try {
184
+ this.utility.featureHook.apply(ctx, "PreDone");
185
+ }
186
+ catch (RuntimeException err) {
187
+ if (!Boolean.FALSE.equals(ctx.ctrl.throwing)) {
188
+ throw cleanError(ctx, err);
189
+ }
190
+ }
170
191
  }
171
192
 
172
193
  // The catch path. An error already finalised by makeError (e.g. via done)
@@ -168,21 +168,26 @@ const testClient = client.tester()
168
168
 
169
169
  ${stateSection}### Add custom middleware
170
170
 
171
- Pass features via the \`extend\` option:
171
+ Pass features via the \`extend\` option. A feature is an object with a
172
+ \`name\`, an \`init\` method, and a method named after each pipeline stage it
173
+ hooks. It is installed, and its hooks fire, only while it is active:
174
+ \`feature.<name>.active\` decides, and where the options do not set it, the
175
+ object's own \`active\` flag does:
172
176
 
173
177
  \`\`\`js
174
178
  const logger = {
175
- hooks: {
176
- PreRequest: (ctx) => {
177
- console.log('Requesting:', ctx.spec.method, ctx.spec.path)
178
- },
179
- PreResponse: (ctx) => {
180
- console.log('Status:', ctx.out.request?.status)
181
- },
179
+ name: 'logger',
180
+ init() {},
181
+ PreRequest(ctx) {
182
+ console.log('Requesting:', ctx.spec.method, ctx.spec.path)
183
+ },
184
+ PreResponse(ctx) {
185
+ console.log('Status:', ctx.out.request?.status)
182
186
  },
183
187
  }
184
188
 
185
189
  const client = new ${model.const.Name}SDK({${apikeyExtendField}
190
+ feature: { logger: { active: true } },
186
191
  extend: [logger],
187
192
  })
188
193
  \`\`\`
@@ -465,9 +465,10 @@ describe('clean', () => {
465
465
  // and is not changed by it.
466
466
  const util = makeSdk(SCENARIOS[0], sinks).utility()
467
467
  const cfgclean = { keys: 'zzsens', values: CANARY.config }
468
- const built = util.makeOptions({ utility: util, config: { options: { clean: cfgclean } },
469
- options: { clean: { values: CANARY.value } } })
470
- const seeded = util.clean({ options: built }, 'config ' + CANARY.config + ' caller ' + CANARY.value)
468
+ const built = { utility: util, config: { options: { clean: cfgclean } },
469
+ options: { clean: { values: CANARY.value } } }
470
+ built.options = util.makeOptions(built)
471
+ const seeded = util.clean(built, 'config ' + CANARY.config + ' caller ' + CANARY.value)
471
472
  sinks.push({ name: 'config-clean', text: seeded })
472
473
 
473
474
  // A feature's name is not a field name: only the sensitive names inside
@@ -480,7 +481,7 @@ describe('clean', () => {
480
481
  rbac: { active: false, rules: { 'zztoken.load': 'PLAINRULE-k7j5h3g1' } },
481
482
  test: { active: false, entity: { zztoken: { ZZTOKEN01: { note: 'PLAINRECORD-t5r3e1w9' } } } },
482
483
  }, entity: { zztoken: { alias: { zzkey: 'PLAINALIAS-m2n4b6v8' } } } })
483
- const fctx = { options: featured._options }
484
+ const fctx = featured._rootctx
484
485
 
485
486
  // The raw path returns its failure rather than throwing it, a
486
487
  // DOMException's included.
@@ -492,6 +493,13 @@ describe('clean', () => {
492
493
  ok(false === raw.ok && null != raw.err, 'a transport failure should fail direct()')
493
494
  sinks.push(...forms('direct', raw.err))
494
495
 
496
+ // The clean registry holds every credential in plain form, and is no option.
497
+ const held = construct({ apikey: CANARY.apikey }).options()
498
+ const optsjson = JSON.stringify(held)
499
+ equal(held.apikey, CANARY.apikey)
500
+ deepStrictEqual(leaks(optsjson.replace(JSON.stringify(CANARY.apikey), '')), [],
501
+ 'options() carries a credential beyond the option the caller set: ' + optsjson)
502
+
495
503
  const leaked = sinks
496
504
  .map((s) => ({ name: s.name, found: leaks(s.text) }))
497
505
  .filter((s) => 0 < s.found.length)
@@ -525,7 +533,7 @@ describe('clean', () => {
525
533
  equal(header(notfound.spec.headers, 'x-custom-token'), MASK)
526
534
 
527
535
  equal(seeded, 'config ' + MASK + ' caller ' + MASK)
528
- deepStrictEqual(util.clean({ options: built }, { my_zzsens: 'x', other: 'y' }), { my_zzsens: MASK, other: 'y' })
536
+ deepStrictEqual(util.clean(built, { my_zzsens: 'x', other: 'y' }), { my_zzsens: MASK, other: 'y' })
529
537
  deepStrictEqual(cfgclean, { keys: 'zzsens', values: CANARY.config })
530
538
 
531
539
  equal(featured.utility().clean(fctx, 'kind PLAINSETTING-q8w2e4r6'), 'kind PLAINSETTING-q8w2e4r6')
@@ -126,8 +126,15 @@ class ProjectNameEntityBase {
126
126
  ...(args || {}),
127
127
  }, this._entctx)
128
128
 
129
+ let predone = false
130
+
129
131
  try {
130
132
  const failed = await this._streamSteps(ctx)
133
+ if (null == failed) {
134
+ predone = true
135
+ const fres = featureHook(ctx, 'PreDone')
136
+ if (fres instanceof Promise) { await fres }
137
+ }
131
138
  const result = ctx.result
132
139
 
133
140
  // Inbound: prefer the streaming feature's incremental iterator; else
@@ -166,10 +173,15 @@ class ProjectNameEntityBase {
166
173
  const e = this._unexpected(ctx, err)
167
174
  if (e && true !== signal?.aborted) { throw e }
168
175
  }
176
+ finally {
177
+ if (!predone) {
178
+ await this._lateDone(ctx)
179
+ }
180
+ }
169
181
  }
170
182
 
171
183
 
172
- // The steps an operation runs, with their hooks; the first that fails
184
+ // The steps before PreDone, with their hooks; the first that fails
173
185
  // hands back its error.
174
186
  async _streamSteps(ctx) {
175
187
  const {
@@ -192,8 +204,20 @@ class ProjectNameEntityBase {
192
204
 
193
205
  fres = featureHook(ctx, 'PreResult'); if (fres instanceof Promise) { await fres }
194
206
  ctx.out.result = await makeResult(ctx); if (ctx.out.result instanceof Error) { return ctx.out.result }
207
+ }
208
+
195
209
 
196
- fres = featureHook(ctx, 'PreDone'); if (fres instanceof Promise) { await fres }
210
+ // PreDone on an exit that left before it. What the hook throws leaves
211
+ // cleaned, in place of the error already on its way out.
212
+ async _lateDone(ctx) {
213
+ try {
214
+ const fres = this._utility.featureHook(ctx, 'PreDone')
215
+ if (fres instanceof Promise) { await fres }
216
+ }
217
+ catch (err) {
218
+ const e = this._unexpected(ctx, err)
219
+ if (e) { throw e }
220
+ }
197
221
  }
198
222
 
199
223
 
@@ -26,6 +26,7 @@ class EntityOperation {
26
26
  } = utility
27
27
 
28
28
  let fres = undefined
29
+ let predone = false
29
30
 
30
31
  let ctx = makeContext({
31
32
  opname: 'create',
@@ -76,6 +77,7 @@ class EntityOperation {
76
77
  }
77
78
 
78
79
 
80
+ predone = true
79
81
  // #PreDone-Hook
80
82
 
81
83
  if (null != ctx.result) {
@@ -114,6 +116,12 @@ class EntityOperation {
114
116
  return undefined
115
117
  }
116
118
  }
119
+ finally {
120
+ // A refusal, a failed step or a throw left before PreDone.
121
+ if (!predone) {
122
+ await this._lateDone(ctx)
123
+ }
124
+ }
117
125
  }
118
126
 
119
127
  // EJECT-END
@@ -27,6 +27,7 @@ class EntityOperation {
27
27
  } = utility
28
28
 
29
29
  let fres = undefined
30
+ let predone = false
30
31
 
31
32
  let ctx = makeContext({
32
33
  opname: 'list',
@@ -77,6 +78,7 @@ class EntityOperation {
77
78
  }
78
79
 
79
80
 
81
+ predone = true
80
82
  // #PreDone-Hook
81
83
 
82
84
  if (null != ctx.result) {
@@ -108,6 +110,12 @@ class EntityOperation {
108
110
  return undefined
109
111
  }
110
112
  }
113
+ finally {
114
+ // A refusal, a failed step or a throw left before PreDone.
115
+ if (!predone) {
116
+ await this._lateDone(ctx)
117
+ }
118
+ }
111
119
  }
112
120
 
113
121
  // EJECT-END
@@ -27,6 +27,7 @@ class EntityOperation {
27
27
  } = utility
28
28
 
29
29
  let fres = undefined
30
+ let predone = false
30
31
 
31
32
  let ctx = makeContext({
32
33
  opname: 'load',
@@ -77,6 +78,7 @@ class EntityOperation {
77
78
  }
78
79
 
79
80
 
81
+ predone = true
80
82
  // #PreDone-Hook
81
83
 
82
84
  if (null != ctx.result) {
@@ -119,6 +121,12 @@ class EntityOperation {
119
121
  return undefined
120
122
  }
121
123
  }
124
+ finally {
125
+ // A refusal, a failed step or a throw left before PreDone.
126
+ if (!predone) {
127
+ await this._lateDone(ctx)
128
+ }
129
+ }
122
130
  }
123
131
 
124
132
  // EJECT-END
@@ -27,6 +27,7 @@ class EntityOperation {
27
27
  } = utility
28
28
 
29
29
  let fres = undefined
30
+ let predone = false
30
31
 
31
32
  let ctx = makeContext({
32
33
  opname: 'patch',
@@ -78,6 +79,7 @@ class EntityOperation {
78
79
  }
79
80
 
80
81
 
82
+ predone = true
81
83
  // #PreDone-Hook
82
84
 
83
85
  if (null != ctx.result) {
@@ -120,6 +122,12 @@ class EntityOperation {
120
122
  return undefined
121
123
  }
122
124
  }
125
+ finally {
126
+ // A refusal, a failed step or a throw left before PreDone.
127
+ if (!predone) {
128
+ await this._lateDone(ctx)
129
+ }
130
+ }
123
131
  }
124
132
 
125
133
  // EJECT-END
@@ -27,6 +27,7 @@ class EntityOperation {
27
27
  } = utility
28
28
 
29
29
  let fres = undefined
30
+ let predone = false
30
31
 
31
32
  let ctx = makeContext({
32
33
  opname: 'remove',
@@ -78,6 +79,7 @@ class EntityOperation {
78
79
  }
79
80
 
80
81
 
82
+ predone = true
81
83
  // #PreDone-Hook
82
84
 
83
85
  if (null != ctx.result) {
@@ -126,6 +128,12 @@ class EntityOperation {
126
128
  return undefined
127
129
  }
128
130
  }
131
+ finally {
132
+ // A refusal, a failed step or a throw left before PreDone.
133
+ if (!predone) {
134
+ await this._lateDone(ctx)
135
+ }
136
+ }
129
137
  }
130
138
 
131
139
  // EJECT-END
@@ -27,6 +27,7 @@ class EntityOperation {
27
27
  } = utility
28
28
 
29
29
  let fres = undefined
30
+ let predone = false
30
31
 
31
32
  let ctx = makeContext({
32
33
  opname: 'update',
@@ -78,6 +79,7 @@ class EntityOperation {
78
79
  }
79
80
 
80
81
 
82
+ predone = true
81
83
  // #PreDone-Hook
82
84
 
83
85
  if (null != ctx.result) {
@@ -120,6 +122,12 @@ class EntityOperation {
120
122
  return undefined
121
123
  }
122
124
  }
125
+ finally {
126
+ // A refusal, a failed step or a throw left before PreDone.
127
+ if (!predone) {
128
+ await this._lateDone(ctx)
129
+ }
130
+ }
123
131
  }
124
132
 
125
133
  // EJECT-END
@@ -67,23 +67,30 @@ class ProjectNameSDK {
67
67
  const extend = this._options.extend || []
68
68
 
69
69
  const featureorder = getpath(this._options, '__derived__.featureorder') || []
70
+ const placed = new Set()
70
71
  for (const fname of featureorder) {
71
72
  const fopts = this._options.feature[fname] || {}
72
73
  if (fopts.active) {
73
74
  // An active name with no generated class is legal when an
74
75
  // extend-supplied instance carries that name (station's adopt
75
- // path): the instance is added below, positioned by its own
76
- // __after__ entry, so skip it here rather than fail construction.
77
- if (!this._rootctx.config.hasFeature(fname) &&
78
- extend.some((f) => fname === f.name)) {
76
+ // path): the instance takes the slot the order gives its name.
77
+ const carried = this._rootctx.config.hasFeature(fname) ? undefined :
78
+ extend.find((f) => fname === f.name)
79
+ if (null != carried) {
80
+ placed.add(carried)
81
+ featureAdd(this._rootctx, carried)
79
82
  continue
80
83
  }
81
84
  featureAdd(this._rootctx, this._rootctx.config.makeFeature(fname))
82
85
  }
83
86
  }
84
87
 
88
+ // An extend feature is active by its option, else by its own flag.
85
89
  for (let f of extend) {
86
- featureAdd(this._rootctx, f)
90
+ const fa = this._options.feature[f.name]?.active
91
+ if (!placed.has(f) && (true === fa || (null == fa && true === f.active))) {
92
+ featureAdd(this._rootctx, f)
93
+ }
87
94
  }
88
95
 
89
96
  for (let f of this._features) {
@@ -190,6 +190,21 @@ class CleanTest {
190
190
  else -> v
191
191
  }
192
192
 
193
+ // Every string a value holds, private fields included, as a debugger shows them.
194
+ private fun dump(v: Any?, depth: Int = 0): String = when {
195
+ v == null || 12 < depth -> ""
196
+ v is String -> v
197
+ v is Map<*, *> -> v.entries.joinToString(" ", "{", "}") {
198
+ dump(it.key, depth + 1) + "=" + dump(it.value, depth + 1)
199
+ }
200
+ v is Iterable<*> -> v.joinToString(" ", "[", "]") { dump(it, depth + 1) }
201
+ v.javaClass.name.startsWith("java.") || v.javaClass.name.startsWith("kotlin.") -> v.toString()
202
+ else -> v.javaClass.declaredFields.filter { !Modifier.isStatic(it.modifiers) }
203
+ .joinToString(" ", "{", "}") { f ->
204
+ runCatching { f.trySetAccessible(); dump(f.get(v), depth + 1) }.getOrDefault("")
205
+ }
206
+ }
207
+
193
208
  private fun stack(err: Throwable): String {
194
209
  val sw = StringWriter()
195
210
  err.printStackTrace(PrintWriter(sw))
@@ -637,9 +652,13 @@ class CleanTest {
637
652
  sinks.addAll(surfaces("mistyped:rejected", e))
638
653
  }
639
654
 
640
- // A number is registered as the text a message quotes it in.
641
- val numeric = construct(linkedMapOf<String, Any?>("apikey" to 918273645))
642
- val numbered = numeric.getUtility().clean(numeric.getRootCtx(), "found 918273645")
655
+ // A number is registered as the text the refusal quotes it in.
656
+ val numbered = try {
657
+ ${SDK}(offline(linkedMapOf<String, Any?>("apikey" to 918273645)))
658
+ null
659
+ } catch (e: RuntimeException) {
660
+ e.message
661
+ }
643
662
 
644
663
  for (unexpected in listOf(false, true)) {
645
664
  val hooked = makeSdk(scenarios[0], sinks, null, ThrowFeature(unexpected))
@@ -684,6 +703,13 @@ class CleanTest {
684
703
  linkedMapOf<String, Any?>(canaryValue to 1, canaryHeader to 2, "plain" to 3))
685
704
  sinks.addAll(surfaces("named", named))
686
705
 
706
+ // The clean registry holds every credential in plain form, and is no option.
707
+ val held = construct(linkedMapOf<String, Any?>("apikey" to canaryApikey)).optionsMap()
708
+ val helddump = dump(held)
709
+ assertEquals(canaryApikey, held["apikey"])
710
+ assertEquals(listOf<String>(), leaks(helddump.replaceFirst(canaryApikey, "")),
711
+ "optionsMap carries a credential beyond the option the caller set: " + helddump)
712
+
687
713
  val leaked = sinks
688
714
  .map { Pair(it.name, leaks(it.text)) }
689
715
  .filter { it.second.isNotEmpty() }
@@ -693,7 +719,8 @@ class CleanTest {
693
719
  assertEquals(0, leaked.size, "credential leaked through: " +
694
720
  leaked.joinToString("; ") { it.first + " [" + it.second.joinToString(", ") + "]" })
695
721
 
696
- assertEquals("found " + mask, numbered)
722
+ assertTrue(null != numbered && numbered.contains(mask) && !numbered.contains("918273645"),
723
+ "a numeric credential: " + numbered)
697
724
  assertEquals(linkedMapOf<String, Any?>(mask to 1, mask + "#1" to 2, "plain" to 3), named)
698
725
 
699
726
  // The positive half: the slot the credential travelled in is masked,
@@ -85,6 +85,7 @@ abstract class EntityBase(nm: String, clientIn: SdkClient, entoptsIn: MutableMap
85
85
 
86
86
  protected fun runOp(ctx: Context, postDone: () -> Unit): Any? {
87
87
  val utility = this.utility
88
+ var predone = false
88
89
 
89
90
  try {
90
91
  // #PrePoint-Hook
@@ -112,6 +113,7 @@ abstract class EntityBase(nm: String, clientIn: SdkClient, entoptsIn: MutableMap
112
113
  val result = utility.makeResult(ctx)
113
114
  ctx.out["result"] = result
114
115
 
116
+ predone = true
115
117
  // #PreDone-Hook
116
118
 
117
119
  postDone()
@@ -138,6 +140,23 @@ abstract class EntityBase(nm: String, clientIn: SdkClient, entoptsIn: MutableMap
138
140
  return out
139
141
  } catch (err: RuntimeException) {
140
142
  return unexpected(ctx, err)
143
+ } finally {
144
+ // A refusal, a failed step or a throw left before PreDone.
145
+ if (!predone) {
146
+ lateDone(ctx)
147
+ }
148
+ }
149
+ }
150
+
151
+ // PreDone on an exit that left before it. What the hook throws leaves
152
+ // cleaned, in place of the error already on its way out.
153
+ private fun lateDone(ctx: Context) {
154
+ try {
155
+ this.utility.featureHook(ctx, "PreDone")
156
+ } catch (err: RuntimeException) {
157
+ if (ctx.ctrl.throwing != false) {
158
+ throw cleanError(ctx, err)
159
+ }
141
160
  }
142
161
  }
143
162
 
@@ -798,6 +798,15 @@ describe("clean", function()
798
798
  assert.are.same({ [MASK] = 1, [MASK .. "#1"] = 2, plain = 3 }, named)
799
799
  append(sinks, surfaces("named", named))
800
800
 
801
+ -- The clean registry holds every credential in plain form, and is no option.
802
+ local held = construct({ apikey = CANARY.apikey }):options_map()
803
+ local heldjson = tojson(held)
804
+ assert.are.equal(CANARY.apikey, held.apikey)
805
+ local at, upto = string.find(heldjson, CANARY.apikey, 1, true)
806
+ local heldrest = at and (heldjson:sub(1, at - 1) .. heldjson:sub(upto + 1)) or heldjson
807
+ assert.are.same({}, leaks(heldrest),
808
+ "options_map carries a credential beyond the option the caller set: " .. heldjson)
809
+
801
810
  local leaked = {}
802
811
  for _, s in ipairs(sinks) do
803
812
  local found = leaks(s.text)
@@ -880,7 +889,8 @@ describe("clean", function()
880
889
  local client = construct({
881
890
  apikey = CANARY.apikey,
882
891
  feature = {
883
- secrets = { active = false, name = "ZZNAME-feat123", token = "ZZTOKEN-feat456" },
892
+ secrets = { active = false, name = "ZZNAME-feat123",
893
+ providers = { { name = "static", token = "ZZTOKEN-feat456" } } },
884
894
  rbac = { active = false, rules = { ["zztoken.load"] = "PLAINRULE-k7j5h3g1" } },
885
895
  test = { active = false, entity = { zztoken = { ZZTOKEN01 = { note = "PLAINRECORD-t5r3e1w9" } } } },
886
896
  },
@@ -898,12 +908,12 @@ describe("clean", function()
898
908
  it("the generated config's own clean block is honoured", function()
899
909
  local utility = construct({}):get_utility()
900
910
  local config = { options = { clean = { keys = "zzsens", values = "CONFIG-SEEDED-1" } } }
901
- local opts = utility.make_options({
911
+ local ctx = {
902
912
  utility = utility,
903
913
  config = config,
904
914
  options = { clean = { values = "CALLER-SEEDED-2" } },
905
- })
906
- local ctx = { options = opts }
915
+ }
916
+ ctx.options = utility.make_options(ctx)
907
917
  assert.are.equal("a " .. MASK .. " b " .. MASK,
908
918
  utility.clean(ctx, "a CONFIG-SEEDED-1 b CALLER-SEEDED-2"))
909
919
  assert.are.same({ my_zzsens = MASK, other = "y" }, utility.clean(ctx, { my_zzsens = "x", other = "y" }))
@@ -165,8 +165,14 @@ function EntyClass:stream(action, args, callopts)
165
165
  return false
166
166
  end
167
167
 
168
+ local predone = false
169
+
168
170
  local co = coroutine.create(function()
169
171
  local failed = self:_stream_steps(ctx)
172
+ if failed == nil then
173
+ predone = true
174
+ utility.feature_hook(ctx, "PreDone")
175
+ end
170
176
  local result = ctx.result
171
177
 
172
178
  -- Inbound: prefer the streaming feature's incremental iterator; else fall
@@ -223,6 +229,10 @@ function EntyClass:stream(action, args, callopts)
223
229
  if ok then
224
230
  if coroutine.status(co) == "dead" then
225
231
  utility.clean_explain(ctx)
232
+ if not predone then
233
+ predone = true
234
+ item = self:_late_done(ctx) or item
235
+ end
226
236
  if item ~= nil then
227
237
  error(item, 0)
228
238
  end
@@ -239,6 +249,10 @@ function EntyClass:stream(action, args, callopts)
239
249
  item = hookerr
240
250
  end
241
251
  local err = self:_unexpected(ctx, item)
252
+ if not predone then
253
+ predone = true
254
+ err = self:_late_done(ctx) or err
255
+ end
242
256
  if err ~= nil then
243
257
  error(err, 0)
244
258
  end
@@ -247,7 +261,7 @@ function EntyClass:stream(action, args, callopts)
247
261
  end
248
262
 
249
263
 
250
- -- The steps an operation runs, with their hooks; the first that fails hands
264
+ -- The steps before PreDone, with their hooks; the first that fails hands
251
265
  -- back its error.
252
266
  function EntyClass:_stream_steps(ctx)
253
267
  local utility = self._utility
@@ -291,7 +305,6 @@ function EntyClass:_stream_steps(ctx)
291
305
  return err
292
306
  end
293
307
 
294
- utility.feature_hook(ctx, "PreDone")
295
308
  return nil
296
309
  end
297
310
 
@@ -313,8 +326,16 @@ end
313
326
  -- leaves cleaned, and so does the explain record it interrupted.
314
327
  function EntyClass:_run_op(ctx, post_done)
315
328
  local utility = self._utility
316
- local ok, out, err = pcall(self._run_steps, self, ctx, post_done)
329
+ local state = { predone = false }
330
+ local ok, out, err = pcall(self._run_steps, self, ctx, post_done, state)
317
331
  if ok then
332
+ -- A refusal or a failed step left before PreDone.
333
+ if not state.predone then
334
+ local lerr = self:_late_done(ctx)
335
+ if lerr ~= nil then
336
+ return nil, lerr
337
+ end
338
+ end
318
339
  return out, err
319
340
  end
320
341
 
@@ -328,7 +349,22 @@ function EntyClass:_run_op(ctx, post_done)
328
349
  if not hookok then
329
350
  out = hookerr
330
351
  end
331
- return nil, self:_unexpected(ctx, out)
352
+ local uerr = self:_unexpected(ctx, out)
353
+ if not state.predone then
354
+ uerr = self:_late_done(ctx) or uerr
355
+ end
356
+ return nil, uerr
357
+ end
358
+
359
+
360
+ -- PreDone on an exit that left before it. What the hook raises is the
361
+ -- error, cleaned, in place of the one already on its way out.
362
+ function EntyClass:_late_done(ctx)
363
+ local ok, hookerr = pcall(self._utility.feature_hook, ctx, "PreDone")
364
+ if ok then
365
+ return nil
366
+ end
367
+ return self:_unexpected(ctx, hookerr)
332
368
  end
333
369
 
334
370
 
@@ -353,7 +389,7 @@ function EntyClass:_unexpected(ctx, raised)
353
389
  end
354
390
 
355
391
 
356
- function EntyClass:_run_steps(ctx, post_done)
392
+ function EntyClass:_run_steps(ctx, post_done, state)
357
393
  local utility = self._utility
358
394
 
359
395
  -- #PrePoint-Hook
@@ -400,6 +436,7 @@ function EntyClass:_run_steps(ctx, post_done)
400
436
  return utility.make_error(ctx, err)
401
437
  end
402
438
 
439
+ state.predone = true
403
440
  -- #PreDone-Hook
404
441
 
405
442
  post_done()