@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
@@ -140,28 +140,8 @@ func (f *TestFeature) Init(ctx *core.Context, options map[string]any) {
140
140
  entmap = map[string]any{}
141
141
  }
142
142
 
143
- // For single-entity ops (load, remove) with an empty explicit match,
144
- // fall back to the id the entity client already knows from a prior
145
- // create/load (in ctx.Match / ctx.Data). Mirrors the TS mock where
146
- // param() resolves the id from that accumulated state.
147
- resolveMatch := func(explicit map[string]any) map[string]any {
148
- if len(explicit) > 0 {
149
- return explicit
150
- }
151
- for _, src := range []any{ctx.Match, ctx.Data} {
152
- if src == nil {
153
- continue
154
- }
155
- v := vs.GetProp(src, "id")
156
- if v != nil && v != "__UNDEFINED__" {
157
- return map[string]any{"id": v}
158
- }
159
- }
160
- return map[string]any{}
161
- }
162
-
163
143
  if op.Name == "load" {
164
- args := self.buildArgs(ctx, op, resolveMatch(ctx.Reqmatch))
144
+ args := self.buildArgs(ctx, op, ctx.Reqmatch)
165
145
  found := vs.Select(entmap, args)
166
146
  ent := vs.GetElem(found, 0)
167
147
  if ent == nil {
@@ -182,25 +162,7 @@ func (f *TestFeature) Init(ctx *core.Context, options map[string]any) {
182
162
  out := vs.Clone(found)
183
163
  return respond(200, out, nil), nil
184
164
  } else if op.Name == "update" || op.Name == "patch" {
185
- updateMatch := map[string]any{}
186
- if ctx.Reqdata != nil {
187
- if v, has := ctx.Reqdata["id"]; has {
188
- updateMatch["id"] = v
189
- }
190
- if op.Alias != nil {
191
- if aliasIdRaw := vs.GetProp(op.Alias, "id"); aliasIdRaw != nil {
192
- if aliasId, ok := aliasIdRaw.(string); ok {
193
- if v, has := ctx.Reqdata[aliasId]; has {
194
- updateMatch[aliasId] = v
195
- }
196
- }
197
- }
198
- }
199
- }
200
- if len(updateMatch) == 0 {
201
- updateMatch = resolveMatch(map[string]any{})
202
- }
203
- args := self.buildArgs(ctx, op, updateMatch)
165
+ args := self.buildArgs(ctx, op, testRecord(ctx.Reqdata))
204
166
  found := vs.Select(entmap, args)
205
167
  ent := vs.GetElem(found, 0)
206
168
  if ent == nil {
@@ -214,7 +176,7 @@ func (f *TestFeature) Init(ctx *core.Context, options map[string]any) {
214
176
  out := vs.Clone(ent)
215
177
  return respond(200, out, nil), nil
216
178
  } else if op.Name == "remove" {
217
- args := self.buildArgs(ctx, op, resolveMatch(ctx.Reqmatch))
179
+ args := self.buildArgs(ctx, op, ctx.Reqmatch)
218
180
  found := vs.Select(entmap, args)
219
181
  ent := vs.GetElem(found, 0)
220
182
  // Remove only the first matched entity. If nothing matches,
@@ -394,25 +356,49 @@ func (f *TestFeature) buildArgs(ctx *core.Context, op *core.Operation, args map[
394
356
  qand := []any{}
395
357
  q := map[string]any{"`$AND`": &qand}
396
358
 
397
- if args != nil {
398
- for _, key := range vs.KeysOf(args) {
399
- isId := key == "id"
400
- isReqd := !vs.IsEmpty(vs.Select(reqdFromParams, key)) ||
401
- !vs.IsEmpty(vs.Select(reqdFromQuery, key))
359
+ entityName := ctx.Entity.GetName()
360
+ idfrom, _ := vs.GetPath(ctx.Config, []any{"entity", entityName, "id", "from"}).(map[string]any)
402
361
 
403
- if isId || isReqd {
404
- v := ctx.Utility.Param(ctx, key)
405
- ka := vs.GetProp(op.Alias, key)
362
+ names := vs.KeysOf(args)
406
363
 
407
- qor := []any{map[string]any{key: v}}
408
- if ka != nil {
409
- if kas, ok := ka.(string); ok {
410
- qor = append(qor, map[string]any{kas: v})
411
- }
364
+ // With no id in the call, the entity's held id (or composite parts) stands in.
365
+ if vs.GetProp(args, "id") == nil {
366
+ parts, _ := vs.GetPath(ctx.Config, []any{"entity", entityName, "id", "parts"}).([]any)
367
+ if parts == nil && opname != "list" {
368
+ parts = []any{"id"}
369
+ }
370
+ for _, part := range parts {
371
+ pname := fmt.Sprint(part)
372
+ if !containsString(names, pname) &&
373
+ (heldValue(ctx.Match, pname) || heldValue(ctx.Data, pname)) {
374
+ names = append(names, pname)
375
+ }
376
+ }
377
+ }
378
+
379
+ for _, key := range names {
380
+ isId := key == "id"
381
+ isReqd := !vs.IsEmpty(vs.Select(reqdFromParams, key)) ||
382
+ !vs.IsEmpty(vs.Select(reqdFromQuery, key))
383
+
384
+ if isId || isReqd {
385
+ v := ctx.Utility.Param(ctx, key)
386
+ ka := vs.GetProp(op.Alias, key)
387
+
388
+ qor := []any{map[string]any{key: v}}
389
+ if ka != nil {
390
+ if kas, ok := ka.(string); ok {
391
+ qor = append(qor, map[string]any{kas: v})
412
392
  }
393
+ }
413
394
 
414
- qand = append(qand, map[string]any{"`$OR`": qor})
395
+ // An alternative, never a replacement: a seed keeping the
396
+ // parameter flat is still found.
397
+ if kf, ok := idfrom[key].(string); ok && kf != key {
398
+ qor = append(qor, nestPath(kf, v))
415
399
  }
400
+
401
+ qand = append(qand, map[string]any{"`$OR`": qor})
416
402
  }
417
403
  }
418
404
 
@@ -425,3 +411,27 @@ func (f *TestFeature) buildArgs(ctx *core.Context, op *core.Operation, args map[
425
411
 
426
412
  return q
427
413
  }
414
+
415
+ func containsString(list []string, s string) bool {
416
+ for _, item := range list {
417
+ if item == s {
418
+ return true
419
+ }
420
+ }
421
+ return false
422
+ }
423
+
424
+ func heldValue(src map[string]any, key string) bool {
425
+ v := vs.GetProp(src, key)
426
+ return v != nil && v != "__UNDEFINED__"
427
+ }
428
+
429
+ // The value under a dotted record path, as a nested map.
430
+ func nestPath(path string, value any) map[string]any {
431
+ keys := strings.Split(path, ".")
432
+ out := map[string]any{keys[len(keys)-1]: value}
433
+ for i := len(keys) - 2; 0 <= i; i-- {
434
+ out = map[string]any{keys[i]: out}
435
+ }
436
+ return out
437
+ }
@@ -5,9 +5,11 @@ import (
5
5
  "encoding/json"
6
6
  "errors"
7
7
  "fmt"
8
+ "net/url"
8
9
  "reflect"
9
10
  "sort"
10
11
  "strings"
12
+ "sync"
11
13
  "testing"
12
14
  "time"
13
15
 
@@ -30,14 +32,21 @@ type fcOp struct {
30
32
 
31
33
  // fcFetcher builds a scripted transport from a case's `res` list. Responses
32
34
  // are consumed in order and the last one repeats, so a case that does not
33
- // care how many attempts happen need only declare one.
34
- func fcFetcher(res []any) sdk.FetcherFunc {
35
+ // care how many attempts happen need only declare one. Each URL it is sent is
36
+ // kept in sent, with the time it was sent; a `cut` response is one whose body
37
+ // stops before its end.
38
+ func fcFetcher(res []any, sent *fcSent) sdk.FetcherFunc {
35
39
  n := -1
36
40
  return func(ctx *sdk.Context, fullurl string, fetchdef map[string]any) (any, error) {
41
+ sent.mu.Lock()
37
42
  n++
43
+ at := n
44
+ sent.at = append(sent.at, time.Now().UnixMilli())
45
+ sent.url = append(sent.url, fullurl)
46
+ sent.mu.Unlock()
38
47
  var spec map[string]any
39
48
  if len(res) > 0 {
40
- i := n
49
+ i := at
41
50
  if i >= len(res) {
42
51
  i = len(res) - 1
43
52
  }
@@ -79,6 +88,17 @@ func fcFetcher(res []any) sdk.FetcherFunc {
79
88
  // than a mis-shaped script.
80
89
  raw, _ := json.Marshal(body)
81
90
 
91
+ if cut, _ := spec["cut"].(bool); cut {
92
+ return map[string]any{
93
+ "status": status,
94
+ "statusText": statusText,
95
+ "headers": headers,
96
+ "json": (func() any)(func() any { return nil }),
97
+ "body": string(raw[:len(raw)/2]),
98
+ "unreadable": true,
99
+ }, nil
100
+ }
101
+
82
102
  return map[string]any{
83
103
  "status": status,
84
104
  "statusText": statusText,
@@ -89,11 +109,39 @@ func fcFetcher(res []any) sdk.FetcherFunc {
89
109
  }
90
110
  }
91
111
 
112
+ // fcSent records each request the transport saw, and when.
113
+ type fcSent struct {
114
+ mu sync.Mutex
115
+ at []int64
116
+ url []string
117
+ }
118
+
119
+ // fcBusiest is the most requests seen in any window of ms.
120
+ func (sent *fcSent) fcBusiest(ms int64) int {
121
+ most := 0
122
+ for _, from := range sent.at {
123
+ n := 0
124
+ for _, t := range sent.at {
125
+ if from <= t && t < from+ms {
126
+ n++
127
+ }
128
+ }
129
+ if n > most {
130
+ most = n
131
+ }
132
+ }
133
+ return most
134
+ }
135
+
92
136
  func fcClient(kase map[string]any) *sdk.ProjectNameSDK {
137
+ return fcClientSent(kase, &fcSent{})
138
+ }
139
+
140
+ func fcClientSent(kase map[string]any, sent *fcSent) *sdk.ProjectNameSDK {
93
141
  res, _ := kase["res"].([]any)
94
142
  opts := map[string]any{
95
143
  "test": map[string]any{"active": true},
96
- "utility": map[string]any{"fetcher": fcFetcher(res)},
144
+ "utility": map[string]any{"fetcher": fcFetcher(res, sent)},
97
145
  }
98
146
  if f, ok := kase["feature"]; ok {
99
147
  opts["feature"] = f
@@ -300,8 +348,83 @@ func fcItemArgs() map[string]any {
300
348
  return map[string]any{"id": "corpus-item"}
301
349
  }
302
350
 
351
+ // fcStreamArgs reads one operation through the entity's Stream, and reports
352
+ // how many items it yielded before it ended or failed.
353
+ func fcStreamArgs(client *sdk.ProjectNameSDK, op fcOp, args map[string]any, ctrl map[string]any) (int, error) {
354
+ cv := reflect.ValueOf(client)
355
+ ct := cv.Type()
356
+ mapType := reflect.TypeOf(map[string]any{})
357
+
358
+ for i := 0; i < ct.NumMethod(); i++ {
359
+ mt := ct.Method(i).Type
360
+ if mt.NumIn() != 2 || mt.NumOut() != 1 || mt.In(1) != mapType {
361
+ continue
362
+ }
363
+ ent := cv.Method(i).Call([]reflect.Value{reflect.ValueOf(map[string]any(nil))})[0]
364
+ gn := ent.MethodByName("GetName")
365
+ if !gn.IsValid() || gn.Type().NumIn() != 0 || gn.Type().NumOut() != 1 ||
366
+ gn.Type().Out(0).Kind() != reflect.String {
367
+ continue
368
+ }
369
+ if gn.Call(nil)[0].String() != op.accessor {
370
+ continue
371
+ }
372
+ streamer, ok := ent.Interface().(interface {
373
+ Stream(string, map[string]any, map[string]any) <-chan sdk.StreamItem
374
+ })
375
+ if !ok {
376
+ return 0, fmt.Errorf("no Stream on entity %s", op.accessor)
377
+ }
378
+ items := 0
379
+ for item := range streamer.Stream(strings.ToLower(op.method), args,
380
+ map[string]any{"ctrl": ctrl}) {
381
+ if item.Err != nil {
382
+ return items, item.Err
383
+ }
384
+ items++
385
+ }
386
+ return items, nil
387
+ }
388
+ return 0, fmt.Errorf("no entity accessor for %s", op.accessor)
389
+ }
390
+
391
+ // fcCheckSent checks each request a case expects, in order: its path, and its
392
+ // whole query. A path is compared without its leading slash, which an SDK
393
+ // with no base omits.
394
+ func fcCheckSent(t *testing.T, sent []string, expect []any, label string) {
395
+ t.Helper()
396
+ if len(sent) != len(expect) {
397
+ t.Errorf("%s: %d request(s) sent, want %d: %s", label, len(sent), len(expect),
398
+ strings.Join(sent, " | "))
399
+ return
400
+ }
401
+ for i, raw := range expect {
402
+ want, _ := raw.(map[string]any)
403
+ u, err := url.Parse(sent[i])
404
+ if err != nil {
405
+ t.Errorf("%s: request %d: %v", label, i, err)
406
+ continue
407
+ }
408
+ if path, ok := want["path"].(string); ok &&
409
+ strings.TrimLeft(u.Path, "/") != strings.TrimLeft(path, "/") {
410
+ t.Errorf("%s: request %d path: got %q, want %q", label, i, u.Path, path)
411
+ }
412
+ if wq, ok := want["query"].(map[string]any); ok {
413
+ got := map[string]any{}
414
+ for k, v := range u.Query() {
415
+ got[k] = v[len(v)-1]
416
+ }
417
+ if fmt.Sprintf("%v", got) != fmt.Sprintf("%v", wq) {
418
+ t.Errorf("%s: request %d query: got %v, want %v", label, i, got, wq)
419
+ }
420
+ }
421
+ }
422
+ }
423
+
303
424
  // fcStep runs one step: it may wait before its call, may add request headers
304
- // for its call, and may pass `args` as the operation's first argument.
425
+ // for its call, and may pass `args` as the operation's first argument. A
426
+ // `stream` step reads the operation through Stream, and `items` is how many it
427
+ // yields.
305
428
  func fcStep(client *sdk.ProjectNameSDK, op fcOp, step map[string]any, ctrl map[string]any) error {
306
429
  if wait, ok := fcNum(step["wait"]); ok {
307
430
  time.Sleep(time.Duration(wait) * time.Millisecond)
@@ -331,9 +454,36 @@ func fcStep(client *sdk.ProjectNameSDK, op fcOp, step map[string]any, ctrl map[s
331
454
  if args == nil {
332
455
  args = map[string]any{}
333
456
  }
457
+ if stream, _ := step["stream"].(bool); stream {
458
+ items, err := fcStreamArgs(client, op, args, ctrl)
459
+ if want, ok := fcNum(step["items"]); ok && err == nil && float64(items) != want {
460
+ return fmt.Errorf("%s: streamed %d item(s), want %v", op.key, items, want)
461
+ }
462
+ return err
463
+ }
334
464
  return fcInvokeArgs(client, op, args, ctrl)
335
465
  }
336
466
 
467
+ // fcCalls runs a step once, or with `together: N` as N overlapping calls,
468
+ // and returns each call's error.
469
+ func fcCalls(client *sdk.ProjectNameSDK, op fcOp, step map[string]any, ctrl map[string]any) []error {
470
+ n := 1
471
+ if together, ok := fcNum(step["together"]); ok {
472
+ n = int(together)
473
+ }
474
+ errs := make([]error, n)
475
+ var wg sync.WaitGroup
476
+ for i := 0; i < n; i++ {
477
+ wg.Add(1)
478
+ go func(i int) {
479
+ defer wg.Done()
480
+ errs[i] = fcStep(client, op, step, ctrl)
481
+ }(i)
482
+ }
483
+ wg.Wait()
484
+ return errs
485
+ }
486
+
337
487
  // fcResolve replaces #OPn throughout a case, keys included.
338
488
  func fcResolve(node any, tokens map[string]string) any {
339
489
  switch v := node.(type) {
@@ -418,6 +568,18 @@ func fcSubset(t *testing.T, actual any, expect any, path string) {
418
568
  return
419
569
  }
420
570
 
571
+ if el, ok := expect.([]any); ok {
572
+ av := reflect.ValueOf(actual)
573
+ if actual == nil || (av.Kind() != reflect.Slice && av.Kind() != reflect.Array) || av.Len() != len(el) {
574
+ t.Errorf("%s: want %d item(s), got %v", path, len(el), actual)
575
+ return
576
+ }
577
+ for i, want := range el {
578
+ fcSubset(t, av.Index(i).Interface(), want, fmt.Sprintf("%s[%d]", path, i))
579
+ }
580
+ return
581
+ }
582
+
421
583
  if wn, ok := fcNum(expect); ok {
422
584
  gn, ok := fcNum(actual)
423
585
  if !ok {
@@ -648,9 +810,13 @@ func TestFeatureCorpus(t *testing.T) {
648
810
  }
649
811
  }
650
812
 
651
- client := fcClient(resolved)
813
+ sent := &fcSent{}
814
+ client := fcClientSent(resolved, sent)
652
815
  label, _ := resolved["name"].(string)
653
816
 
817
+ // A case-level ctrl is one control object every step shares.
818
+ shared, _ := resolved["ctrl"].(map[string]any)
819
+
654
820
  steps, _ := resolved["op"].([]any)
655
821
  for _, rawstep := range steps {
656
822
  step, _ := rawstep.(map[string]any)
@@ -664,40 +830,55 @@ func TestFeatureCorpus(t *testing.T) {
664
830
  continue
665
831
  }
666
832
  ctrl := map[string]any{}
833
+ if shared != nil {
834
+ ctrl = shared
835
+ }
667
836
  if c, ok := step["ctrl"].(map[string]any); ok {
668
837
  ctrl = c
669
838
  }
670
839
 
671
- err := fcStep(client, op, step, ctrl)
672
840
  wanterr, haserr := step["err"]
673
841
 
674
- if !haserr {
675
- if err != nil {
676
- t.Errorf("%s: %s failed unexpectedly: %v", label, opkey, err)
842
+ for _, err := range fcCalls(client, op, step, ctrl) {
843
+ if !haserr {
844
+ if err != nil {
845
+ t.Errorf("%s: %s failed unexpectedly: %v", label, opkey, err)
846
+ }
847
+ continue
677
848
  }
678
- continue
679
- }
680
- if err == nil {
681
- t.Errorf("%s: %s was expected to fail, and did not", label, opkey)
682
- continue
683
- }
684
- if code, ok := wanterr.(string); ok {
685
- // The CODE, not the message. The message is prefixed
686
- // and humanised by makeError, so matching its text
687
- // would pass on any error that happened to mention
688
- // the word.
689
- got := ""
690
- var sdkerr *sdk.ProjectNameError
691
- if errors.As(err, &sdkerr) {
692
- got = sdkerr.Code
849
+ if err == nil {
850
+ t.Errorf("%s: %s was expected to fail, and did not", label, opkey)
851
+ continue
693
852
  }
694
- if got != code {
695
- t.Errorf("%s: wrong error code: got %q (%v), want %q",
696
- label, got, err, code)
853
+ if code, ok := wanterr.(string); ok {
854
+ // The CODE, not the message. The message is prefixed
855
+ // and humanised by makeError, so matching its text
856
+ // would pass on any error that happened to mention
857
+ // the word.
858
+ got := ""
859
+ var sdkerr *sdk.ProjectNameError
860
+ if errors.As(err, &sdkerr) {
861
+ got = sdkerr.Code
862
+ }
863
+ if got != code {
864
+ t.Errorf("%s: wrong error code: got %q (%v), want %q",
865
+ label, got, err, code)
866
+ }
697
867
  }
698
868
  }
699
869
  }
700
870
 
871
+ if pace, ok := resolved["pace"].(map[string]any); ok {
872
+ ms, _ := fcNum(pace["ms"])
873
+ max, _ := fcNum(pace["max"])
874
+ if most := sent.fcBusiest(int64(ms)); most > int(max) {
875
+ t.Errorf("%s: %d requests within %v ms, want at most %v", label, most, ms, max)
876
+ }
877
+ }
878
+
879
+ if expect, ok := resolved["sent"].([]any); ok {
880
+ fcCheckSent(t, sent.url, expect, label)
881
+ }
701
882
  fcSubset(t, fcRecord(client, name), resolved["out"], label+": _"+name)
702
883
  ran++
703
884
  }
@@ -3,6 +3,7 @@ package sdktest
3
3
  import (
4
4
  "encoding/json"
5
5
  "errors"
6
+ "fmt"
6
7
  "os"
7
8
  "reflect"
8
9
  "regexp"
@@ -879,6 +880,23 @@ func TestFeatureMetrics(t *testing.T) {
879
880
  }
880
881
  })
881
882
 
883
+ t.Run("sink-gets-counters-once-per-op", func(t *testing.T) {
884
+ var seen []map[string]any
885
+ f := feat.NewMetricsFeature()
886
+ h := fhMake(nil, fhF(f, map[string]any{
887
+ "sink": (func(map[string]any))(func(m map[string]any) { seen = append(seen, m) }),
888
+ }))
889
+ h.op(fhOpSpec{op: "load"})
890
+ h.op(fhOpSpec{op: "list"})
891
+ if len(seen) != 2 {
892
+ t.Fatalf("expected 2 sink calls, got %d", len(seen))
893
+ }
894
+ total, _ := seen[1]["total"].(map[string]any)
895
+ if fmt.Sprint(total["count"]) != "2" {
896
+ t.Errorf("expected count 2 at the second call, got %v", total["count"])
897
+ }
898
+ })
899
+
882
900
  t.Run("injected-clock", func(t *testing.T) {
883
901
  clock := &fhClock{}
884
902
  f := feat.NewMetricsFeature()
@@ -962,6 +980,20 @@ func TestFeatureTelemetry(t *testing.T) {
962
980
  }
963
981
  })
964
982
 
983
+ t.Run("default-ids-are-w3c", func(t *testing.T) {
984
+ f := feat.NewTelemetryFeature()
985
+ h := fhMake(nil, fhF(f, nil))
986
+ h.op(fhOpSpec{op: "load"})
987
+ trace, _ := f.Spans[0]["traceId"].(string)
988
+ span, _ := f.Spans[0]["spanId"].(string)
989
+ if !regexp.MustCompile(`^[0-9a-f]{32}$`).MatchString(trace) || strings.Trim(trace, "0") == "" {
990
+ t.Errorf("trace id is not W3C: %q", trace)
991
+ }
992
+ if !regexp.MustCompile(`^[0-9a-f]{16}$`).MatchString(span) || strings.Trim(span, "0") == "" {
993
+ t.Errorf("span id is not W3C: %q", span)
994
+ }
995
+ })
996
+
965
997
  t.Run("inactive-records-nothing", func(t *testing.T) {
966
998
  f := feat.NewTelemetryFeature()
967
999
  h := fhMake(nil, fhF(f, map[string]any{"active": false}))
@@ -2,6 +2,7 @@ package utility
2
2
 
3
3
  import (
4
4
  "encoding/json"
5
+ "errors"
5
6
  "regexp"
6
7
  "sort"
7
8
  "strings"
@@ -119,6 +120,10 @@ func makeOptionsUtil(ctx *core.Context) (map[string]any, error) {
119
120
  opts["feature"] = fmap
120
121
  }
121
122
 
123
+ if fm, ok := featureDefaults(core.ToMapAny(config["feature"]), opts["feature"]); ok {
124
+ opts["feature"] = fm
125
+ }
126
+
122
127
  optspec := core.OPTSPEC
123
128
 
124
129
  // Preserve system.fetch before merge/validate.
@@ -138,7 +143,15 @@ func makeOptionsUtil(ctx *core.Context) (map[string]any, error) {
138
143
  // UseNumber() are otherwise judged by a rule nothing else applies.
139
144
  canonNumbers(merged)
140
145
 
141
- validated, _ := vs.Validate(merged, optspec)
146
+ verr := refuseStrayKeys(merged, optspec)
147
+ var validated any
148
+ if verr == nil {
149
+ validated, verr = vs.Validate(merged, optspec)
150
+ }
151
+ if verr != nil {
152
+ return nil, cleanUtil(cleanctx,
153
+ core.NewProjectNameError("options_invalid", verr.Error(), nil)).(*core.ProjectNameError)
154
+ }
142
155
  opts = validated.(map[string]any)
143
156
 
144
157
  // Restore the suppression the optspec default would otherwise erase.
@@ -193,14 +206,20 @@ func makeOptionsUtil(ctx *core.Context) (map[string]any, error) {
193
206
  }
194
207
  }
195
208
 
196
- // Resolve the feature add-order: an explicit array order (above) wins;
197
- // otherwise order the map test-first, then the remaining names sorted, so
198
- // the outcome is deterministic and `test` is always the base transport.
199
- if len(featureorder) == 0 {
209
+ // Resolve the feature add-order: an explicit array order (above) wins, and
210
+ // the names it leaves out follow it test-first, then sorted, so the outcome
211
+ // is deterministic and `test` is the base transport of a map.
212
+ {
213
+ given := map[string]bool{}
214
+ for _, n := range featureorder {
215
+ given[n.(string)] = true
216
+ }
200
217
  fmap := core.ToMapAny(opts["feature"])
201
218
  names := make([]string, 0, len(fmap))
202
219
  for k := range fmap {
203
- names = append(names, k)
220
+ if !given[k] {
221
+ names = append(names, k)
222
+ }
204
223
  }
205
224
  sort.Strings(names)
206
225
  hasTest := false
@@ -255,6 +274,40 @@ func makeOptionsUtil(ctx *core.Context) (map[string]any, error) {
255
274
  return opts, nil
256
275
  }
257
276
 
277
+ // The model's options for a feature sit beneath the caller's, key by key: a
278
+ // key the caller sets replaces the default whole, so a list is never merged.
279
+ func featureDefaults(cfgfeature map[string]any, feature any) (map[string]any, bool) {
280
+ out := map[string]any{}
281
+ if feature != nil {
282
+ fm, ok := feature.(map[string]any)
283
+ if !ok {
284
+ return nil, false
285
+ }
286
+ for k, v := range fm {
287
+ out[k] = v
288
+ }
289
+ }
290
+ for name, fdef := range cfgfeature {
291
+ dflt := core.ToMapAny(core.ToMapAny(fdef)["options"])
292
+ given, named := out[name]
293
+ if dflt == nil || (!named && dflt["active"] != true) {
294
+ continue
295
+ }
296
+ gm := map[string]any{}
297
+ if named && given != nil {
298
+ if gm, _ = given.(map[string]any); gm == nil {
299
+ continue
300
+ }
301
+ }
302
+ merged := vs.Clone(dflt).(map[string]any)
303
+ for k, v := range gm {
304
+ merged[k] = v
305
+ }
306
+ out[name] = merged
307
+ }
308
+ return out, true
309
+ }
310
+
258
311
  // A feature's name is not a field name: only the sensitive names inside its
259
312
  // settings count, so `secrets` does not make every setting a secret. Entity
260
313
  // blocks (per-entity settings, seeded records) hold no credential, and nor do
@@ -301,3 +354,55 @@ func cleanOmit(m map[string]any, keys ...string) map[string]any {
301
354
  }
302
355
  return out
303
356
  }
357
+
358
+
359
+ // Before validate: the struct's own refusal prints the value without its
360
+ // functions, so a misspelled callback key would go unnamed.
361
+ func refuseStrayKeys(opts any, optspec map[string]any) error {
362
+ fspecs, _ := optspec["feature"].(map[string]any)
363
+ feature, _ := vs.GetProp(opts, "feature").(map[string]any)
364
+ for _, name := range sortedKeys(feature) {
365
+ fopts, ok := feature[name].(map[string]any)
366
+ spec := specMap(fspecs[name])
367
+ if !ok || spec == nil || spec["`$OPEN`"] != nil {
368
+ continue
369
+ }
370
+ stray := []string{}
371
+ for _, k := range sortedKeys(fopts) {
372
+ if _, has := spec[k]; !has {
373
+ stray = append(stray, k)
374
+ }
375
+ }
376
+ if 0 < len(stray) {
377
+ return errors.New("Unexpected keys at field feature." + name + ": " + strings.Join(stray, ", "))
378
+ }
379
+ }
380
+ return nil
381
+ }
382
+
383
+ func specMap(spec any) map[string]any {
384
+ alts, ok := spec.([]any)
385
+ if !ok {
386
+ m, _ := spec.(map[string]any)
387
+ return m
388
+ }
389
+ from := 0
390
+ if 0 < len(alts) && "`$NOF`" == alts[0] {
391
+ from = 2
392
+ }
393
+ for i := from; i < len(alts); i++ {
394
+ if m, ok := alts[i].(map[string]any); ok {
395
+ return m
396
+ }
397
+ }
398
+ return nil
399
+ }
400
+
401
+ func sortedKeys(m map[string]any) []string {
402
+ keys := make([]string, 0, len(m))
403
+ for k := range m {
404
+ keys = append(keys, k)
405
+ }
406
+ sort.Strings(keys)
407
+ return keys
408
+ }