@voxgig/sdkgen 4.51.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 (289) 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 +1 -1
  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/src/cmp/c/TestClean_c.ts +12 -11
  32. package/project/.sdk/src/cmp/c/fragment/Entity.fragment.c +17 -10
  33. package/project/.sdk/src/cmp/clojure/fragment/Entity.fragment.clj +18 -1
  34. package/project/.sdk/src/cmp/cpp/TestClean_cpp.ts +2 -1
  35. package/project/.sdk/src/cmp/csharp/fragment/EntityBase.fragment.cs +30 -2
  36. package/project/.sdk/src/cmp/csharp/fragment/Main.fragment.cs +31 -12
  37. package/project/.sdk/src/cmp/elixir/TestClean_elixir.ts +2 -1
  38. package/project/.sdk/src/cmp/elixir/fragment/Main.fragment.ex +51 -15
  39. package/project/.sdk/src/cmp/elixir/fragment/Pipeline.fragment.ex +17 -0
  40. package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +42 -2
  41. package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +42 -14
  42. package/project/.sdk/src/cmp/java/TestClean_java.ts +9 -4
  43. package/project/.sdk/src/cmp/java/fragment/EntityBase.fragment.java +21 -0
  44. package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +13 -8
  45. package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +26 -2
  46. package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +8 -0
  47. package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +8 -0
  48. package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +8 -0
  49. package/project/.sdk/src/cmp/js/fragment/EntityPatchOp.fragment.js +8 -0
  50. package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +8 -0
  51. package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +8 -0
  52. package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +12 -5
  53. package/project/.sdk/src/cmp/kotlin/TestClean_kotlin.ts +9 -4
  54. package/project/.sdk/src/cmp/kotlin/fragment/EntityBase.fragment.kt +19 -0
  55. package/project/.sdk/src/cmp/lua/TestClean_lua.ts +2 -1
  56. package/project/.sdk/src/cmp/lua/fragment/Entity.fragment.lua +42 -5
  57. package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +44 -10
  58. package/project/.sdk/src/cmp/lua/utility_lua.ts +2 -1
  59. package/project/.sdk/src/cmp/ocaml/TestClean_ocaml.ts +2 -1
  60. package/project/.sdk/src/cmp/ocaml/fragment/RunOp.fragment.ml +36 -21
  61. package/project/.sdk/src/cmp/perl/TestClean_perl.ts +1 -1
  62. package/project/.sdk/src/cmp/perl/fragment/Entity.fragment.pm +21 -0
  63. package/project/.sdk/src/cmp/perl/fragment/Main.fragment.pm +31 -12
  64. package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +33 -4
  65. package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +13 -6
  66. package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +25 -2
  67. package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +26 -12
  68. package/project/.sdk/src/cmp/rb/TestClean_rb.ts +1 -1
  69. package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +23 -2
  70. package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +27 -11
  71. package/project/.sdk/src/cmp/rust/TestClean_rust.ts +14 -17
  72. package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +22 -2
  73. package/project/.sdk/src/cmp/scala/TestClean_scala.ts +11 -11
  74. package/project/.sdk/src/cmp/scala/fragment/EntityBase.fragment.scala +14 -0
  75. package/project/.sdk/src/cmp/swift/TestClean_swift.ts +11 -11
  76. package/project/.sdk/src/cmp/swift/fragment/EntityBase.fragment.swift +9 -0
  77. package/project/.sdk/src/cmp/swift/fragment/Main.fragment.swift +24 -10
  78. package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +13 -8
  79. package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +26 -2
  80. package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +8 -0
  81. package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +8 -0
  82. package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +8 -0
  83. package/project/.sdk/src/cmp/ts/fragment/EntityPatchOp.fragment.ts +8 -0
  84. package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +8 -0
  85. package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +8 -0
  86. package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +12 -5
  87. package/project/.sdk/src/cmp/zig/TestClean_zig.ts +11 -11
  88. package/project/.sdk/src/cmp/zig/fragment/Entity.fragment.zig +17 -10
  89. package/project/.sdk/src/cmp/zig/fragment/Main.fragment.zig +41 -6
  90. package/project/.sdk/tm/c/feature/metrics.c +7 -0
  91. package/project/.sdk/tm/c/feature/paging.c +231 -2
  92. package/project/.sdk/tm/c/feature/ratelimit.c +5 -9
  93. package/project/.sdk/tm/c/feature/retry.c +51 -4
  94. package/project/.sdk/tm/c/feature/streaming.c +2 -1
  95. package/project/.sdk/tm/c/feature/telemetry.c +19 -18
  96. package/project/.sdk/tm/c/feature/test.c +78 -54
  97. package/project/.sdk/tm/c/tests/feature_test.c +184 -0
  98. package/project/.sdk/tm/c/tests/primary_utility_test.c +2 -0
  99. package/project/.sdk/tm/c/utility/make_options.c +80 -9
  100. package/project/.sdk/tm/clojure/src/sdk/core.clj +31 -11
  101. package/project/.sdk/tm/clojure/src/sdk/features.clj +198 -70
  102. package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +70 -1
  103. package/project/.sdk/tm/cpp/core/types.hpp +137 -68
  104. package/project/.sdk/tm/cpp/feature/audit.hpp +6 -1
  105. package/project/.sdk/tm/cpp/feature/metrics.hpp +19 -0
  106. package/project/.sdk/tm/cpp/feature/paging.hpp +160 -2
  107. package/project/.sdk/tm/cpp/feature/ratelimit.hpp +18 -14
  108. package/project/.sdk/tm/cpp/feature/retry.hpp +46 -5
  109. package/project/.sdk/tm/cpp/feature/streaming.hpp +2 -1
  110. package/project/.sdk/tm/cpp/feature/telemetry.hpp +17 -10
  111. package/project/.sdk/tm/cpp/feature/test.hpp +63 -53
  112. package/project/.sdk/tm/cpp/test/feature_test.cpp +137 -0
  113. package/project/.sdk/tm/cpp/utility/pipeline.hpp +35 -5
  114. package/project/.sdk/tm/csharp/feature/AuditFeature.cs +8 -1
  115. package/project/.sdk/tm/csharp/feature/MetricsFeature.cs +23 -0
  116. package/project/.sdk/tm/csharp/feature/PagingFeature.cs +130 -3
  117. package/project/.sdk/tm/csharp/feature/RatelimitFeature.cs +26 -19
  118. package/project/.sdk/tm/csharp/feature/RetryFeature.cs +41 -7
  119. package/project/.sdk/tm/csharp/feature/StreamingFeature.cs +2 -1
  120. package/project/.sdk/tm/csharp/feature/TelemetryFeature.cs +11 -9
  121. package/project/.sdk/tm/csharp/feature/TestFeature.cs +55 -67
  122. package/project/.sdk/tm/csharp/test/FeatureTest.cs +162 -0
  123. package/project/.sdk/tm/csharp/utility/MakeOptions.cs +89 -12
  124. package/project/.sdk/tm/elixir/lib/projectname/feature/metrics.ex +13 -0
  125. package/project/.sdk/tm/elixir/lib/projectname/feature/paging.ex +110 -5
  126. package/project/.sdk/tm/elixir/lib/projectname/feature/ratelimit.ex +6 -12
  127. package/project/.sdk/tm/elixir/lib/projectname/feature/retry.ex +33 -9
  128. package/project/.sdk/tm/elixir/lib/projectname/feature/streaming.ex +2 -1
  129. package/project/.sdk/tm/elixir/lib/projectname/feature/telemetry.ex +7 -7
  130. package/project/.sdk/tm/elixir/lib/projectname/feature/test.ex +52 -48
  131. package/project/.sdk/tm/elixir/lib/projectname/utility.ex +59 -35
  132. package/project/.sdk/tm/elixir/test/feature_test.exs +137 -0
  133. package/project/.sdk/tm/go/feature/audit_feature.go +1 -3
  134. package/project/.sdk/tm/go/feature/base_feature.go +11 -0
  135. package/project/.sdk/tm/go/feature/metrics_feature.go +14 -0
  136. package/project/.sdk/tm/go/feature/paging_feature.go +108 -2
  137. package/project/.sdk/tm/go/feature/ratelimit_feature.go +19 -17
  138. package/project/.sdk/tm/go/feature/retry_feature.go +81 -9
  139. package/project/.sdk/tm/go/feature/streaming_feature.go +2 -1
  140. package/project/.sdk/tm/go/feature/telemetry_feature.go +18 -11
  141. package/project/.sdk/tm/go/feature/test_feature.go +65 -55
  142. package/project/.sdk/tm/go/test/feature_corpus_test.go +209 -28
  143. package/project/.sdk/tm/go/test/feature_test.go +32 -0
  144. package/project/.sdk/tm/go/utility/make_options.go +111 -6
  145. package/project/.sdk/tm/java/core/SdkClient.java +43 -14
  146. package/project/.sdk/tm/java/feature/AuditFeature.java +5 -1
  147. package/project/.sdk/tm/java/feature/MetricsFeature.java +31 -0
  148. package/project/.sdk/tm/java/feature/PagingFeature.java +156 -2
  149. package/project/.sdk/tm/java/feature/RatelimitFeature.java +15 -13
  150. package/project/.sdk/tm/java/feature/RetryFeature.java +33 -6
  151. package/project/.sdk/tm/java/feature/StreamingFeature.java +2 -1
  152. package/project/.sdk/tm/java/feature/TelemetryFeature.java +17 -9
  153. package/project/.sdk/tm/java/feature/TestFeature.java +50 -63
  154. package/project/.sdk/tm/java/test/FeatureCorpusTest.java +170 -17
  155. package/project/.sdk/tm/java/utility/MakeOptions.java +128 -14
  156. package/project/.sdk/tm/js/src/feature/metrics/MetricsFeature.js +8 -3
  157. package/project/.sdk/tm/js/src/feature/paging/PagingFeature.js +99 -1
  158. package/project/.sdk/tm/js/src/feature/ratelimit/RatelimitFeature.js +5 -9
  159. package/project/.sdk/tm/js/src/feature/retry/RetryFeature.js +25 -3
  160. package/project/.sdk/tm/js/src/feature/streaming/StreamingFeature.js +2 -1
  161. package/project/.sdk/tm/js/src/feature/telemetry/TelemetryFeature.js +11 -6
  162. package/project/.sdk/tm/js/src/feature/test/TestFeature.js +38 -1
  163. package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +55 -6
  164. package/project/.sdk/tm/js/test/feature/Corpus.test.js +95 -25
  165. package/project/.sdk/tm/js/test/feature.test.js +14 -1
  166. package/project/.sdk/tm/kotlin/core/SdkClient.kt +23 -10
  167. package/project/.sdk/tm/kotlin/feature/AuditFeature.kt +5 -1
  168. package/project/.sdk/tm/kotlin/feature/MetricsFeature.kt +22 -0
  169. package/project/.sdk/tm/kotlin/feature/PagingFeature.kt +125 -2
  170. package/project/.sdk/tm/kotlin/feature/RatelimitFeature.kt +16 -13
  171. package/project/.sdk/tm/kotlin/feature/RetryFeature.kt +36 -14
  172. package/project/.sdk/tm/kotlin/feature/StreamingFeature.kt +4 -0
  173. package/project/.sdk/tm/kotlin/feature/TelemetryFeature.kt +12 -10
  174. package/project/.sdk/tm/kotlin/feature/TestFeature.kt +45 -48
  175. package/project/.sdk/tm/kotlin/test/FeatureTest.kt +114 -0
  176. package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +83 -14
  177. package/project/.sdk/tm/lua/feature/debug_feature.lua +2 -3
  178. package/project/.sdk/tm/lua/feature/metrics_feature.lua +5 -0
  179. package/project/.sdk/tm/lua/feature/paging_feature.lua +143 -2
  180. package/project/.sdk/tm/lua/feature/ratelimit_feature.lua +5 -9
  181. package/project/.sdk/tm/lua/feature/retry_feature.lua +43 -5
  182. package/project/.sdk/tm/lua/feature/streaming_feature.lua +2 -1
  183. package/project/.sdk/tm/lua/feature/telemetry_feature.lua +18 -7
  184. package/project/.sdk/tm/lua/feature/test_feature.lua +60 -62
  185. package/project/.sdk/tm/lua/test/feature_test.lua +100 -3
  186. package/project/.sdk/tm/lua/utility/make_options.lua +55 -13
  187. package/project/.sdk/tm/ocaml/sdk_features.ml +286 -60
  188. package/project/.sdk/tm/ocaml/sdk_runtime.ml +34 -11
  189. package/project/.sdk/tm/ocaml/test/t_feature.ml +72 -1
  190. package/project/.sdk/tm/perl/feature/debug_feature.pm +2 -2
  191. package/project/.sdk/tm/perl/feature/metrics_feature.pm +5 -0
  192. package/project/.sdk/tm/perl/feature/paging_feature.pm +139 -2
  193. package/project/.sdk/tm/perl/feature/ratelimit_feature.pm +5 -11
  194. package/project/.sdk/tm/perl/feature/retry_feature.pm +22 -4
  195. package/project/.sdk/tm/perl/feature/streaming_feature.pm +2 -0
  196. package/project/.sdk/tm/perl/feature/telemetry_feature.pm +17 -8
  197. package/project/.sdk/tm/perl/feature/test_feature.pm +45 -50
  198. package/project/.sdk/tm/perl/t/feature.t +2 -2
  199. package/project/.sdk/tm/perl/t/feature_corpus.t +126 -23
  200. package/project/.sdk/tm/perl/utility/make_options.pm +33 -10
  201. package/project/.sdk/tm/php/feature/MetricsFeature.php +8 -0
  202. package/project/.sdk/tm/php/feature/PagingFeature.php +128 -1
  203. package/project/.sdk/tm/php/feature/RatelimitFeature.php +5 -9
  204. package/project/.sdk/tm/php/feature/RetryFeature.php +27 -3
  205. package/project/.sdk/tm/php/feature/StreamingFeature.php +2 -1
  206. package/project/.sdk/tm/php/feature/TelemetryFeature.php +10 -7
  207. package/project/.sdk/tm/php/feature/TestFeature.php +55 -47
  208. package/project/.sdk/tm/php/test/FeatureCorpusTest.php +151 -16
  209. package/project/.sdk/tm/php/utility/MakeOptions.php +40 -13
  210. package/project/.sdk/tm/py/pkg/feature/metrics_feature.py +7 -0
  211. package/project/.sdk/tm/py/pkg/feature/paging_feature.py +86 -1
  212. package/project/.sdk/tm/py/pkg/feature/ratelimit_feature.py +13 -16
  213. package/project/.sdk/tm/py/pkg/feature/retry_feature.py +31 -6
  214. package/project/.sdk/tm/py/pkg/feature/streaming_feature.py +2 -1
  215. package/project/.sdk/tm/py/pkg/feature/telemetry_feature.py +10 -6
  216. package/project/.sdk/tm/py/pkg/feature/test_feature.py +56 -53
  217. package/project/.sdk/tm/py/pkg/utility/make_options.py +68 -20
  218. package/project/.sdk/tm/py/test/test_feature.py +11 -1
  219. package/project/.sdk/tm/py/test/test_feature_corpus.py +111 -16
  220. package/project/.sdk/tm/py-data/pkg/fetch.py +6 -3
  221. package/project/.sdk/tm/py-data/test/test_fetch.py +7 -4
  222. package/project/.sdk/tm/rb/feature/debug_feature.rb +2 -2
  223. package/project/.sdk/tm/rb/feature/metrics_feature.rb +8 -0
  224. package/project/.sdk/tm/rb/feature/paging_feature.rb +87 -1
  225. package/project/.sdk/tm/rb/feature/ratelimit_feature.rb +12 -16
  226. package/project/.sdk/tm/rb/feature/retry_feature.rb +19 -3
  227. package/project/.sdk/tm/rb/feature/streaming_feature.rb +2 -1
  228. package/project/.sdk/tm/rb/feature/telemetry_feature.rb +11 -6
  229. package/project/.sdk/tm/rb/feature/test_feature.rb +42 -49
  230. package/project/.sdk/tm/rb/test/feature_corpus_test.rb +108 -24
  231. package/project/.sdk/tm/rb/test/feature_test.rb +1 -1
  232. package/project/.sdk/tm/rb/utility/make_options.rb +32 -11
  233. package/project/.sdk/tm/rust/feature/audit.rs +2 -2
  234. package/project/.sdk/tm/rust/feature/metrics.rs +24 -1
  235. package/project/.sdk/tm/rust/feature/paging.rs +189 -3
  236. package/project/.sdk/tm/rust/feature/ratelimit.rs +5 -10
  237. package/project/.sdk/tm/rust/feature/retry.rs +59 -6
  238. package/project/.sdk/tm/rust/feature/streaming.rs +3 -2
  239. package/project/.sdk/tm/rust/feature/support.rs +4 -0
  240. package/project/.sdk/tm/rust/feature/telemetry.rs +22 -11
  241. package/project/.sdk/tm/rust/feature/test.rs +63 -57
  242. package/project/.sdk/tm/rust/tests/feature_test.rs +174 -0
  243. package/project/.sdk/tm/rust/tests/primary_utility_test.rs +1 -0
  244. package/project/.sdk/tm/rust/utility/make_options.rs +122 -27
  245. package/project/.sdk/tm/scala/core/SdkClient.scala +45 -11
  246. package/project/.sdk/tm/scala/feature/AuditFeature.scala +6 -1
  247. package/project/.sdk/tm/scala/feature/MetricsFeature.scala +31 -1
  248. package/project/.sdk/tm/scala/feature/PagingFeature.scala +122 -2
  249. package/project/.sdk/tm/scala/feature/RatelimitFeature.scala +14 -11
  250. package/project/.sdk/tm/scala/feature/RetryFeature.scala +29 -7
  251. package/project/.sdk/tm/scala/feature/StreamingFeature.scala +2 -1
  252. package/project/.sdk/tm/scala/feature/TelemetryFeature.scala +12 -10
  253. package/project/.sdk/tm/scala/feature/TestFeature.scala +44 -44
  254. package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +41 -0
  255. package/project/.sdk/tm/scala/utility/Make.scala +96 -13
  256. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/AuditFeature.swift +3 -2
  257. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/MetricsFeature.swift +20 -0
  258. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/PagingFeature.swift +102 -2
  259. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/RatelimitFeature.swift +19 -13
  260. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/RetryFeature.swift +40 -5
  261. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/StreamingFeature.swift +2 -1
  262. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TelemetryFeature.swift +11 -9
  263. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TestFeature.swift +55 -49
  264. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +51 -13
  265. package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +111 -0
  266. package/project/.sdk/tm/ts/src/feature/metrics/MetricsFeature.ts +5 -0
  267. package/project/.sdk/tm/ts/src/feature/paging/PagingFeature.ts +99 -1
  268. package/project/.sdk/tm/ts/src/feature/ratelimit/RatelimitFeature.ts +5 -9
  269. package/project/.sdk/tm/ts/src/feature/retry/RetryFeature.ts +25 -3
  270. package/project/.sdk/tm/ts/src/feature/streaming/StreamingFeature.ts +2 -1
  271. package/project/.sdk/tm/ts/src/feature/telemetry/TelemetryFeature.ts +11 -6
  272. package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +8 -7
  273. package/project/.sdk/tm/ts/src/utility/MakeOptionsUtility.ts +57 -6
  274. package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +95 -25
  275. package/project/.sdk/tm/ts/test/feature.test.ts +14 -1
  276. package/project/.sdk/tm/zig/core/utility.zig +107 -8
  277. package/project/.sdk/tm/zig/feature/metrics.zig +19 -0
  278. package/project/.sdk/tm/zig/feature/paging.zig +172 -4
  279. package/project/.sdk/tm/zig/feature/ratelimit.zig +5 -11
  280. package/project/.sdk/tm/zig/feature/retry.zig +41 -3
  281. package/project/.sdk/tm/zig/feature/streaming.zig +2 -0
  282. package/project/.sdk/tm/zig/feature/telemetry.zig +15 -9
  283. package/project/.sdk/tm/zig/feature/test.zig +56 -40
  284. package/project/.sdk/tm/zig/test/feature_test.zig +109 -0
  285. package/project/.sdk/tm/zig/test/primary_utility_test.zig +2 -0
  286. package/project/sdkgen-package.json +1 -1
  287. package/src/cmp/ReadmeExplanation.ts +5 -2
  288. package/src/cmp/ReadmeFeatures.ts +21 -6
  289. package/src/helpers/optspec.ts +2 -2
@@ -51,25 +51,38 @@ abstract class SdkClient(sdkopts: MutableMap<String, Any?>?) {
51
51
  // must be added before them to sit at the base of the chain.
52
52
  val featureOpts = Helpers.toMapAny(Struct.getprop(this.options, "feature"))
53
53
  ?: linkedMapOf()
54
+ fun active(fname: String?): Boolean =
55
+ Helpers.toMapAny(Struct.getprop(featureOpts, fname))?.get("active") == true
56
+ val extend = (Struct.getprop(this.options, "extend") as? List<*>)
57
+ ?.filterIsInstance<Feature>() ?: listOf()
58
+ val placed = mutableListOf<Feature>()
54
59
  val featureOrder = Struct.getpath(this.options, listOf("__derived__", "featureorder"))
55
60
  if (featureOrder is List<*>) {
56
61
  for (fnameObj in featureOrder) {
57
62
  val fname = fnameObj as? String
58
- val fopts = Helpers.toMapAny(Struct.getprop(featureOpts, fname))
59
- if (fname != null && fopts != null && fopts["active"] == true) {
60
- val f = Config.makeFeature(fname)
63
+ if (fname == null || !active(fname)) {
64
+ continue
65
+ }
66
+ val f = Config.makeFeature(fname)
67
+ // An active name with no generated class is legal when an
68
+ // extend-supplied instance carries that name (station's adopt
69
+ // path): the instance takes the slot the order gives its name.
70
+ val carried = if (f.name == fname) null else extend.firstOrNull { it.name == fname }
71
+ if (carried != null) {
72
+ placed.add(carried)
73
+ this.util.featureAdd(this.rootctx, carried)
74
+ } else {
61
75
  this.util.featureAdd(this.rootctx, f)
62
76
  }
63
77
  }
64
78
  }
65
79
 
66
- // Add extension features.
67
- val extend = Struct.getprop(this.options, "extend")
68
- if (extend is List<*>) {
69
- for (f in extend) {
70
- if (f is Feature) {
71
- this.util.featureAdd(this.rootctx, f)
72
- }
80
+ // An extend feature is active by its option, else by its own flag.
81
+ for (f in extend) {
82
+ val fa = Helpers.toMapAny(Struct.getprop(featureOpts, f.name))?.get("active")
83
+ val on = if (fa is Boolean) fa else f.active
84
+ if (placed.none { it === f } && on) {
85
+ this.util.featureAdd(this.rootctx, f)
73
86
  }
74
87
  }
75
88
 
@@ -88,7 +88,11 @@ class AuditFeature : BaseFeature("audit", "0.0.1", true) {
88
88
 
89
89
  val sink = this.options?.get("sink")
90
90
  if (sink is Consumer<*>) {
91
- (sink as Consumer<MutableMap<String, Any?>>).accept(record)
91
+ // A failing sink never changes the operation's outcome.
92
+ try {
93
+ (sink as Consumer<MutableMap<String, Any?>>).accept(record)
94
+ } catch (e: Exception) {
95
+ }
92
96
  }
93
97
  }
94
98
 
@@ -1,6 +1,9 @@
1
1
  package KOTLINPACKAGE.feature
2
2
 
3
+ import java.util.function.Consumer
4
+
3
5
  import KOTLINPACKAGE.core.Context
6
+ import KOTLINPACKAGE.core.Helpers
4
7
  import KOTLINPACKAGE.core.SdkClient
5
8
 
6
9
  // Statistics capture. Records per-operation counters and latency for every
@@ -21,6 +24,9 @@ class MetricsFeature : BaseFeature("metrics", "0.0.1", true) {
21
24
  var err = 0
22
25
  var totalMs = 0L
23
26
  var maxMs = 0L
27
+
28
+ fun record(): MutableMap<String, Any?> =
29
+ linkedMapOf("count" to count, "ok" to ok, "err" to err, "totalMs" to totalMs, "maxMs" to maxMs)
24
30
  }
25
31
 
26
32
  override fun init(ctx: Context, options: MutableMap<String, Any?>) {
@@ -75,6 +81,22 @@ class MetricsFeature : BaseFeature("metrics", "0.0.1", true) {
75
81
 
76
82
  bump(this.total, ok, dur)
77
83
  bump(op, ok, dur)
84
+
85
+ val sink = this.options?.get("sink")
86
+ if (sink is Consumer<*>) {
87
+ val ops = linkedMapOf<String, Any?>()
88
+ for ((k, b) in this.ops) {
89
+ ops[k] = b.record()
90
+ }
91
+ val raw: MutableMap<String, Any?> = linkedMapOf("total" to this.total.record(), "ops" to ops)
92
+ @Suppress("UNCHECKED_CAST")
93
+ val counters = Helpers.toMapAny(ctx.utility?.clean?.invoke(ctx, raw)) ?: raw
94
+ // A failing sink never changes the operation's outcome.
95
+ try {
96
+ (sink as Consumer<MutableMap<String, Any?>>).accept(counters)
97
+ } catch (e: Exception) {
98
+ }
99
+ }
78
100
  }
79
101
 
80
102
  private fun bump(bucket: MetricsBucket, ok: Boolean, dur: Long) {
@@ -51,8 +51,11 @@ class PagingFeature : BaseFeature("paging", "0.0.1", true) {
51
51
  }
52
52
 
53
53
  val cursor = paging["cursor"]
54
+ val next = paging["next"]
54
55
  if (cursor != null) {
55
56
  spec.query[cursorParam] = cursor
57
+ } else if (next is String && !foreign(next, spec.base)) {
58
+ follow(spec, next)
56
59
  } else if (spec.query[pageParam] == null) {
57
60
  // A record written back by preResult holds the page just fetched as
58
61
  // "page" and the one to fetch as "nextPage", so nextPage wins.
@@ -172,8 +175,12 @@ class PagingFeature : BaseFeature("paging", "0.0.1", true) {
172
175
  // Body-level signals; snake_case forms are read first so camelCase wins.
173
176
  if (body is MutableMap<*, *>) {
174
177
  val bm = body as MutableMap<String, Any?>
175
- if (bm["next"] != null && paging["next"] == null) {
176
- paging["next"] = bm["next"]
178
+ if (bm["next"] != null) {
179
+ if (!isLink(bm["next"], FeatureOptions.foptStr(this.options, "next", "auto"))) {
180
+ paging["cursor"] = bm["next"]
181
+ } else if (paging["next"] == null) {
182
+ paging["next"] = bm["next"]
183
+ }
177
184
  }
178
185
  if (bm["next_cursor"] != null) {
179
186
  paging["cursor"] = bm["next_cursor"]
@@ -202,6 +209,19 @@ class PagingFeature : BaseFeature("paging", "0.0.1", true) {
202
209
  }
203
210
  }
204
211
 
212
+ // A link to another origin is recorded, never followed, and ends the walk.
213
+ val base = ctx.spec?.base ?: (ctx.options?.get("base") as? String) ?: ""
214
+ val spec = ctx.spec
215
+ var nextLink = paging["next"]
216
+ if (nextLink is String && spec != null) {
217
+ nextLink = resolve(nextLink, spec.url)
218
+ paging["next"] = nextLink
219
+ }
220
+ if (nextLink is String && foreign(nextLink, base)) {
221
+ paging["foreign"] = nextLink
222
+ paging.remove("next")
223
+ }
224
+
205
225
  // Cursor presence only INFERS another page. When the server stated the
206
226
  // answer outright — relay's `hasNextPage: false`, or a body `hasMore` —
207
227
  // that wins: a final page normally carries both an end cursor and
@@ -213,6 +233,10 @@ class PagingFeature : BaseFeature("paging", "0.0.1", true) {
213
233
  paging["hasMore"] = true
214
234
  }
215
235
 
236
+ if (paging["foreign"] != null && paging["cursor"] == null && paging["nextPage"] == null) {
237
+ paging["hasMore"] = false
238
+ }
239
+
216
240
  result.paging = paging
217
241
  this.last = paging
218
242
 
@@ -262,5 +286,104 @@ class PagingFeature : BaseFeature("paging", "0.0.1", true) {
262
286
  companion object {
263
287
  private val LINK_NEXT_RE: Pattern =
264
288
  Pattern.compile("<([^>]+)>\\s*;\\s*rel=\"?next\"?", Pattern.CASE_INSENSITIVE)
289
+
290
+ private val ORIGIN_RE: Pattern =
291
+ Pattern.compile("^[a-z][a-z0-9+.-]*://[^/?#]*", Pattern.CASE_INSENSITIVE)
292
+
293
+ private fun originOf(text: String): String {
294
+ val m = ORIGIN_RE.matcher(text)
295
+ return if (m.find()) m.group() else ""
296
+ }
297
+
298
+ // Under the `next` option's default, a URL or an absolute path is a link
299
+ // and anything else a cursor; `cursor` and `url` pin the reading.
300
+ fun isLink(next: Any?, mode: String): Boolean =
301
+ next is String && (mode == "url" ||
302
+ (mode != "cursor" && (originOf(next).isNotEmpty() || next.startsWith("/"))))
303
+
304
+ fun foreign(link: String, base: String?): Boolean {
305
+ val origin = originOf(link).lowercase()
306
+ return origin.isNotEmpty() && origin != originOf(base ?: "").lowercase()
307
+ }
308
+
309
+ private val SCHEME_RE: Pattern = Pattern.compile("^[a-z][a-z0-9+.-]*:", Pattern.CASE_INSENSITIVE)
310
+
311
+ // RFC 3986 reference resolution against the URL of the request that
312
+ // returned the link, by hand: java.net.URI resolves a query-only reference
313
+ // by RFC 2396 and drops the last path segment. A link on that URL's origin
314
+ // comes back as its path and query; an absolute link is left as it is.
315
+ fun resolve(link0: String, url: String?): String {
316
+ if (url.isNullOrEmpty() || SCHEME_RE.matcher(link0).find()) return link0
317
+ val link = link0.substringBefore('#')
318
+ val origin = originOf(url)
319
+ if (link.startsWith("//")) {
320
+ return if (origin.isEmpty()) link else origin.substringBefore(':') + ":" + link
321
+ }
322
+ val from = url.substring(origin.length).substringBefore('#')
323
+ val bpath = from.substringBefore('?')
324
+ val rpath = link.substringBefore('?')
325
+ val query: String?
326
+ val path: String
327
+ if (rpath.isEmpty()) {
328
+ path = bpath
329
+ query = if (link.contains('?')) link.substringAfter('?')
330
+ else if (from.contains('?')) from.substringAfter('?') else null
331
+ } else {
332
+ query = if (link.contains('?')) link.substringAfter('?') else null
333
+ val merged = if (rpath.startsWith("/")) rpath
334
+ else bpath.substring(0, bpath.lastIndexOf('/') + 1) + rpath
335
+ path = removeDots(merged)
336
+ }
337
+ val rooted = if (path.startsWith("/")) path else "/$path"
338
+ return if (query == null) rooted else "$rooted?$query"
339
+ }
340
+
341
+ // RFC 3986 section 5.2.4.
342
+ fun removeDots(path: String): String {
343
+ val abs = path.startsWith("/")
344
+ val segs = path.split("/")
345
+ val out = mutableListOf<String>()
346
+ for (i in (if (abs) 1 else 0) until segs.size) {
347
+ val seg = segs[i]
348
+ if (seg == "." || seg == "..") {
349
+ if (seg == ".." && out.isNotEmpty()) out.removeAt(out.size - 1)
350
+ if (i == segs.size - 1) out.add("")
351
+ } else {
352
+ out.add(seg)
353
+ }
354
+ }
355
+ return (if (abs) "/" else "") + out.joinToString("/")
356
+ }
357
+
358
+ // The request goes to the link's path and query, on the SDK's own origin.
359
+ fun follow(spec: KOTLINPACKAGE.core.Spec, next: String) {
360
+ val link = next.substring(originOf(next).length).substringBefore('#')
361
+ val path = link.substringBefore('?')
362
+ val rawquery = if (link.contains('?')) link.substringAfter('?') else ""
363
+
364
+ val query: MutableMap<String, Any?> = linkedMapOf()
365
+ for (pair in rawquery.split('&')) {
366
+ if (pair.isEmpty()) continue
367
+ val key = pair.substringBefore('=')
368
+ val value = if (pair.contains('=')) pair.substringAfter('=') else ""
369
+ query[unescape(key)] = unescape(value)
370
+ }
371
+ for (key in spec.authquery) {
372
+ query[key] = spec.query[key]
373
+ }
374
+
375
+ spec.base = originOf(spec.base)
376
+ spec.prefix = ""
377
+ spec.path = path
378
+ spec.suffix = ""
379
+ spec.query = query
380
+ }
381
+
382
+ private fun unescape(text: String): String =
383
+ try {
384
+ java.net.URLDecoder.decode(text, Charsets.UTF_8)
385
+ } catch (e: IllegalArgumentException) {
386
+ text
387
+ }
265
388
  }
266
389
  }
@@ -45,29 +45,32 @@ class RatelimitFeature : BaseFeature("ratelimit", "0.0.1", true) {
45
45
  }
46
46
 
47
47
  private fun acquire() {
48
+ val wait = reserve()
49
+ if (wait > 0) {
50
+ FeatureOptions.foptSleep(this.options).accept(wait)
51
+ }
52
+ }
53
+
54
+ // Refill, then reserve this call's token before any wait, under the lock:
55
+ // a negative count is the calls already queued, so overlapping calls pace
56
+ // in turn.
57
+ @Synchronized
58
+ private fun reserve(): Int {
48
59
  val rate = FeatureOptions.foptNum(this.options, "rate", 5.0)
49
60
  val burst = FeatureOptions.foptNum(this.options, "burst", rate)
50
61
 
51
- // Refill according to elapsed time.
52
62
  val now = FeatureOptions.foptNow(this.options).getAsLong()
53
63
  val elapsed = now - this.last
54
64
  this.last = now
55
- this.tokens = min(burst, this.tokens + (elapsed / 1000.0) * rate)
65
+ this.tokens = min(burst, this.tokens + (elapsed / 1000.0) * rate) - 1
56
66
 
57
- if (this.tokens >= 1) {
58
- this.tokens -= 1
59
- return
67
+ if (this.tokens >= 0) {
68
+ return 0
60
69
  }
61
70
 
62
- // Not enough tokens: wait for one to accrue, then consume it.
63
- val needed = 1 - this.tokens
64
- val wait = ceil((needed / rate) * 1000).toInt()
71
+ val wait = ceil((-this.tokens / rate) * 1000).toInt()
65
72
  track(wait)
66
- if (wait > 0) {
67
- FeatureOptions.foptSleep(this.options).accept(wait)
68
- }
69
- this.last = FeatureOptions.foptNow(this.options).getAsLong()
70
- this.tokens = 0.0
73
+ return wait
71
74
  }
72
75
 
73
76
  private fun track(wait: Int) {
@@ -76,10 +76,9 @@ class RetryFeature : BaseFeature("retry", "0.0.1", true) {
76
76
  if (status < 0) {
77
77
  return false
78
78
  }
79
- var statuses: List<Any?>? = FeatureOptions.foptList(this.options, "statuses")
80
- if (statuses == null) {
81
- statuses = listOf(408, 425, 429, 500, 502, 503, 504)
82
- }
79
+ // Any list as given, read-only ones included; only absent or null is unset.
80
+ val statuses = this.options?.get("statuses") as? List<*>
81
+ ?: listOf(408, 425, 429, 500, 502, 503, 504)
83
82
  for (s in statuses) {
84
83
  if (s is Number && s.toInt() == status) {
85
84
  return true
@@ -89,7 +88,7 @@ class RetryFeature : BaseFeature("retry", "0.0.1", true) {
89
88
  }
90
89
 
91
90
  private fun backoff(res: Any?, attempt: Int, minDelay: Int, maxDelay: Int, factor: Double): Int {
92
- // Honour a server-provided Retry-After (seconds) when present.
91
+ // A server-provided Retry-After wins over the computed backoff.
93
92
  val ra = retryAfter(res)
94
93
  if (ra >= 0) {
95
94
  return minOf(ra, maxDelay)
@@ -103,16 +102,39 @@ class RetryFeature : BaseFeature("retry", "0.0.1", true) {
103
102
  return minOf(wait, maxDelay)
104
103
  }
105
104
 
106
- private fun retryAfter(res: Any?): Int {
107
- val v = FeatureOptions.fresHeader(res, "retry-after")
108
- if ("" == v) {
109
- return -1
110
- }
111
- val seconds = FeatureOptions.fparseInt(v, -1)
112
- if (seconds < 0) {
113
- return -1
105
+ private fun retryAfter(res: Any?): Int =
106
+ retryAfterMs(FeatureOptions.fresHeader(res, "retry-after"), System.currentTimeMillis())
107
+
108
+ companion object {
109
+ private const val MONTHS = "JanFebMarAprMayJunJulAugSepOctNovDec"
110
+
111
+ private val IMF_FIXDATE = Regex(
112
+ "(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), ([0-9]{2}) ([A-Z][a-z]{2}) ([0-9]{4}) " +
113
+ "([0-9]{2}):([0-9]{2}):([0-9]{2}) GMT")
114
+
115
+ // RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else -1.
116
+ fun retryAfterMs(value: String, now: Long): Int {
117
+ val s = value.trim(' ', '\t')
118
+ if (s.isNotEmpty() && s.all { it in '0'..'9' }) {
119
+ return if (s.length > 6) Int.MAX_VALUE else s.toInt() * 1000
120
+ }
121
+ val m = IMF_FIXDATE.matchEntire(s) ?: return -1
122
+ val g = m.groupValues
123
+ val month = MONTHS.indexOf(g[2])
124
+ if (month < 0 || month % 3 != 0) {
125
+ return -1
126
+ }
127
+ val sec = g[6].toInt()
128
+ return try {
129
+ val at = java.time.LocalDateTime.of(g[3].toInt(), month / 3 + 1, g[1].toInt(),
130
+ g[4].toInt(), g[5].toInt(), minOf(sec, 59))
131
+ .toEpochSecond(java.time.ZoneOffset.UTC) * 1000 + (if (sec > 59) 1000 else 0)
132
+ minOf(Int.MAX_VALUE.toLong(), maxOf(0L, at - now)).toInt()
133
+ }
134
+ catch (e: java.time.DateTimeException) {
135
+ -1
136
+ }
114
137
  }
115
- return seconds * 1000
116
138
  }
117
139
 
118
140
  private fun sleep(ms: Int) {
@@ -31,7 +31,11 @@ class StreamingFeature : BaseFeature("streaming", "0.0.1", true) {
31
31
  if (!this.active || !streamable(ctx)) {
32
32
  return
33
33
  }
34
+ // A failed result keeps no stream, so the entity's stream raises its error.
34
35
  val result = ctx.result ?: return
36
+ if (result.err != null) {
37
+ return
38
+ }
35
39
 
36
40
  result.streaming = true
37
41
  result.stream = Supplier { iterate(result) }
@@ -1,5 +1,6 @@
1
1
  package KOTLINPACKAGE.feature
2
2
 
3
+ import java.security.SecureRandom
3
4
  import java.util.function.Consumer
4
5
  import java.util.function.Function
5
6
 
@@ -16,7 +17,6 @@ class TelemetryFeature : BaseFeature("telemetry", "0.0.1", true) {
16
17
 
17
18
  private var client: SdkClient? = null
18
19
  private var options: MutableMap<String, Any?>? = null
19
- private var seq = 0
20
20
 
21
21
  // Activity tracking (mirrors the ts client._telemetry record).
22
22
  var spans: MutableList<MutableMap<String, Any?>> = mutableListOf()
@@ -26,7 +26,6 @@ class TelemetryFeature : BaseFeature("telemetry", "0.0.1", true) {
26
26
  this.client = ctx.client
27
27
  this.options = options
28
28
  this.active = FeatureOptions.foptBool(options, "active", false)
29
- this.seq = 0
30
29
  }
31
30
 
32
31
  override fun prePoint(ctx: Context) {
@@ -105,17 +104,20 @@ class TelemetryFeature : BaseFeature("telemetry", "0.0.1", true) {
105
104
  if (ig is Function<*, *>) {
106
105
  return (ig as Function<String, String>).apply(kind)
107
106
  }
108
- // Deterministic-ish sequential id; unique within a client instance.
109
- this.seq++
110
- val n = StringBuilder(String.format("%04x", this.seq))
111
- val prefix = if ("trace" == kind) "t" else "s"
112
- while (n.length < 16) {
113
- n.append("0")
114
- }
115
- return prefix + n
107
+ return randomHex(if ("trace" == kind) 16 else 8)
108
+ }
109
+
110
+ // W3C trace context: lowercase hex from the platform's random source, never all zeros.
111
+ private fun randomHex(bytes: Int): String {
112
+ val buf = ByteArray(bytes)
113
+ do {
114
+ RANDOM.nextBytes(buf)
115
+ } while (buf.all { it.toInt() == 0 })
116
+ return buf.joinToString("") { String.format("%02x", it.toInt() and 0xff) }
116
117
  }
117
118
 
118
119
  companion object {
119
120
  private const val TELEMETRY_SPAN_KEY = "telemetry_span"
121
+ private val RANDOM = SecureRandom()
120
122
  }
121
123
  }
@@ -125,21 +125,9 @@ class TestFeature : BaseFeature("test", "0.0.1", true) {
125
125
  return out
126
126
  }
127
127
 
128
- // For single-entity ops (load, remove) with an empty explicit match, fall
129
- // back to the id the entity client already knows from a prior create/load.
130
- private fun resolveMatch(ctx: Context, explicit: MutableMap<String, Any?>?): MutableMap<String, Any?> {
131
- if (explicit != null && explicit.isNotEmpty()) {
132
- return explicit
133
- }
134
- for (src in listOf(ctx.match, ctx.data)) {
135
- val v = Struct.getprop(src, "id", null)
136
- if (v != null && "__UNDEFINED__" != v) {
137
- val out = linkedMapOf<String, Any?>()
138
- out["id"] = v
139
- return out
140
- }
141
- }
142
- return linkedMapOf()
128
+ private fun held(src: Map<String, Any?>?, key: String): Boolean {
129
+ val v = if (src == null) null else Struct.getprop(src, key, null)
130
+ return v != null && "__UNDEFINED__" != v
143
131
  }
144
132
 
145
133
  private fun serve(ctx: Context, entity: MutableMap<String, Any?>): Any? {
@@ -151,7 +139,7 @@ class TestFeature : BaseFeature("test", "0.0.1", true) {
151
139
 
152
140
  when (op.name) {
153
141
  "load" -> {
154
- val args = buildArgs(ctx, op, resolveMatch(ctx, ctx.reqmatch))
142
+ val args = buildArgs(ctx, op, ctx.reqmatch)
155
143
  val found = Struct.select(entmap, args)
156
144
  val ent = Struct.getelem(found, 0, null)
157
145
  if (ent == null) {
@@ -171,25 +159,8 @@ class TestFeature : BaseFeature("test", "0.0.1", true) {
171
159
  return respond(ctx, 200, out, null)
172
160
  }
173
161
  "update", "patch" -> {
174
- // Match the existing entity by id only (or its alias).
175
- var updateMatch: MutableMap<String, Any?> = linkedMapOf()
176
162
  val reqdata = ctx.reqdata
177
- if (reqdata.containsKey("id")) {
178
- updateMatch["id"] = reqdata["id"]
179
- }
180
- val alias = op.alias
181
- if (alias != null) {
182
- val aliasIdRaw = Struct.getprop(alias, "id")
183
- if (aliasIdRaw is String) {
184
- if (reqdata.containsKey(aliasIdRaw)) {
185
- updateMatch[aliasIdRaw] = reqdata[aliasIdRaw]
186
- }
187
- }
188
- }
189
- if (updateMatch.isEmpty()) {
190
- updateMatch = resolveMatch(ctx, linkedMapOf())
191
- }
192
- val args = buildArgs(ctx, op, updateMatch)
163
+ val args = buildArgs(ctx, op, record(reqdata))
193
164
  val found = Struct.select(entmap, args)
194
165
  val ent = Struct.getelem(found, 0, null)
195
166
  if (ent == null) {
@@ -204,7 +175,7 @@ class TestFeature : BaseFeature("test", "0.0.1", true) {
204
175
  return respond(ctx, 200, out, null)
205
176
  }
206
177
  "remove" -> {
207
- val args = buildArgs(ctx, op, resolveMatch(ctx, ctx.reqmatch))
178
+ val args = buildArgs(ctx, op, ctx.reqmatch)
208
179
  val found = Struct.select(entmap, args)
209
180
  val ent = Struct.getelem(found, 0, null)
210
181
  // Remove only the first matched entity. If nothing matches, no-op.
@@ -360,23 +331,49 @@ class TestFeature : BaseFeature("test", "0.0.1", true) {
360
331
  val qand = Struct.jt()
361
332
  val q = Struct.jm("`\$AND`", qand)
362
333
 
363
- if (args != null) {
364
- for (key in Struct.keysof(args)) {
365
- val isId = "id" == key
366
- val selected = Struct.select(reqd, key)
367
- val isReqd = !Struct.isempty(selected)
334
+ val entityName = if (ctx.entity == null) "" else ctx.entity!!.name
335
+ val idfrom = Struct.getpath(ctx.config, listOf("entity", entityName, "id", "from"))
368
336
 
369
- if (isId || isReqd) {
370
- val v = ctx.utility!!.param(ctx, key)
371
- val ka = Struct.getprop(op.alias, key)
337
+ val names = if (args == null) mutableListOf() else Struct.keysof(args).toMutableList()
372
338
 
373
- val qor = Struct.jt(Struct.jm(key, v))
374
- if (ka is String) {
375
- qor.add(Struct.jm(ka, v))
376
- }
339
+ // With no id in the call, the entity's held id (or composite parts) stands in.
340
+ if (args == null || args["id"] == null) {
341
+ val declared = Struct.getpath(ctx.config, listOf("entity", entityName, "id", "parts"))
342
+ val parts: List<Any?> = if (declared is List<*>) declared else if ("list" == opname) listOf() else listOf("id")
343
+ for (part in parts) {
344
+ val pname = part.toString()
345
+ if (!names.contains(pname) && (held(ctx.match, pname) || held(ctx.data, pname))) {
346
+ names.add(pname)
347
+ }
348
+ }
349
+ }
350
+
351
+ for (key in names) {
352
+ val isId = "id" == key
353
+ val selected = Struct.select(reqd, key)
354
+ val isReqd = !Struct.isempty(selected)
377
355
 
378
- qand.add(Struct.jm("`\$OR`", qor))
356
+ if (isId || isReqd) {
357
+ val v = ctx.utility!!.param(ctx, key)
358
+ val ka = Struct.getprop(op.alias, key)
359
+
360
+ val qor = Struct.jt(Struct.jm(key, v))
361
+ if (ka is String) {
362
+ qor.add(Struct.jm(ka, v))
379
363
  }
364
+
365
+ // An alternative, never a replacement: a seed keeping the parameter
366
+ // flat is still found.
367
+ val kf = Struct.getprop(idfrom, key)
368
+ if (kf is String && key != kf) {
369
+ var nest: Any? = v
370
+ for (seg in kf.split(".").reversed()) {
371
+ nest = Struct.jm(seg, nest)
372
+ }
373
+ qor.add(nest)
374
+ }
375
+
376
+ qand.add(Struct.jm("`\$OR`", qor))
380
377
  }
381
378
  }
382
379