@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
@@ -28,6 +28,7 @@ class EntityOperation {
28
28
  } = utility
29
29
 
30
30
  let fres: Promise<any> | undefined = undefined
31
+ let predone = false
31
32
 
32
33
  let ctx: Context = makeContext({
33
34
  opname: 'update',
@@ -79,6 +80,7 @@ class EntityOperation {
79
80
  }
80
81
 
81
82
 
83
+ predone = true
82
84
  // #PreDone-Hook
83
85
 
84
86
  if (null != ctx.result) {
@@ -118,6 +120,12 @@ class EntityOperation {
118
120
  return undefined as any
119
121
  }
120
122
  }
123
+ finally {
124
+ // A refusal, a failed step or a throw left before PreDone.
125
+ if (!predone) {
126
+ await this._lateDone(ctx)
127
+ }
128
+ }
121
129
  }
122
130
 
123
131
  // EJECT-END
@@ -73,23 +73,30 @@ class ProjectNameSDK {
73
73
  const extend = this._options.extend || []
74
74
 
75
75
  const featureorder = getpath(this._options, '__derived__.featureorder') || []
76
+ const placed = new Set()
76
77
  for (const fname of featureorder) {
77
78
  const fopts = this._options.feature[fname] || {}
78
79
  if (fopts.active) {
79
80
  // An active name with no generated class is legal when an
80
81
  // extend-supplied instance carries that name (station's adopt
81
- // path): the instance is added below, positioned by its own
82
- // __after__ entry, so skip it here rather than fail construction.
83
- if (!this._rootctx.config.hasFeature(fname) &&
84
- extend.some((f: any) => fname === f.name)) {
82
+ // path): the instance takes the slot the order gives its name.
83
+ const carried = this._rootctx.config.hasFeature(fname) ? undefined :
84
+ extend.find((f: any) => fname === f.name)
85
+ if (null != carried) {
86
+ placed.add(carried)
87
+ featureAdd(this._rootctx, carried)
85
88
  continue
86
89
  }
87
90
  featureAdd(this._rootctx, this._rootctx.config.makeFeature(fname))
88
91
  }
89
92
  }
90
93
 
94
+ // An extend feature is active by its option, else by its own flag.
91
95
  for (let f of extend) {
92
- featureAdd(this._rootctx, f)
96
+ const fa = this._options.feature[f.name]?.active
97
+ if (!placed.has(f) && (true === fa || (null == fa && true === f.active))) {
98
+ featureAdd(this._rootctx, f)
99
+ }
93
100
  }
94
101
 
95
102
  for (let f of this._features) {
@@ -709,18 +709,15 @@ test "clean: no credential leaves the SDK in any form" {
709
709
  _ = drive(makeSdkWith(.ok, &sinks, true, null, h.jo(&.{.{ "name", h.vstr("zzcred") }})),
710
710
  target, h.omap(), &sinks);
711
711
 
712
- // A credential mistyped as a map. The zig validator's failure is not
713
- // raised (make_options keeps its input), so what the constructor produced
714
- // is swept instead: a string quoting the value, cleaned the way a
715
- // validation message is.
716
- const mistyped = sdk.SDK.new(offline(h.jo(&.{
712
+ // A credential mistyped as a map is rejected by validation, whose message
713
+ // quotes the value it rejected.
714
+ switch (sdk.SDK.new(offline(h.jo(&.{
717
715
  .{ "apikey", h.jo(&.{.{ "value", h.vstr(CANARY_APIKEY) }}) },
718
716
  .{ "clean", h.jo(&.{.{ "values", h.vstr(CANARY_VALUE) }}) },
719
- }))).ok;
720
- sinks.push("mistyped:quoted", sdk.utilmod.clean_str_util(
721
- mistyped.get_root_ctx(),
722
- fmt("apikey: expected string, got {{\\"value\\":\\"{s}\\"}}", .{CANARY_APIKEY}),
723
- ));
717
+ })))) {
718
+ .ok => try testing.expect(false),
719
+ .err => |e| sinks.push("rejected", e.msg),
720
+ }
724
721
 
725
722
  // An error a feature hook raises, quoting the request, with explain on.
726
723
  const hooked = makeSdk(.ok, &sinks, true, ThrowFeature.make());
@@ -907,7 +904,10 @@ test "clean: a feature's name is read as a name" {
907
904
  .{ "secrets", h.jo(&.{
908
905
  .{ "active", h.vbool(false) },
909
906
  .{ "name", h.vstr("ZZNAME-feat123") },
910
- .{ "token", h.vstr("ZZTOKEN-feat456") },
907
+ .{ "providers", h.ja(&.{h.jo(&.{
908
+ .{ "name", h.vstr("static") },
909
+ .{ "token", h.vstr("ZZTOKEN-feat456") },
910
+ })}) },
911
911
  }) },
912
912
  .{ "rbac", h.jo(&.{
913
913
  .{ "active", h.vbool(false) },
@@ -112,32 +112,39 @@ pub const EntyClass = struct {
112
112
  return self.deleted;
113
113
  }
114
114
 
115
+ // A failed step leaves through make_error, then PreDone, which it skipped.
116
+ fn opFailed(self: *EntyClass, ctx: *Context) OpResult {
117
+ const res = self.opError(ctx);
118
+ self.utility.feature_hook(ctx, "PreDone");
119
+ return res;
120
+ }
121
+
115
122
  fn run_op(self: *EntyClass, ctx: *Context, post_done: *const fn (*EntyClass, *Context) void) OpResult {
116
123
  const utility = self.utility;
117
124
 
118
125
  // #PrePoint-Hook
119
126
 
120
- const point = utility.make_point(ctx) catch return self.opError(ctx);
127
+ const point = utility.make_point(ctx) catch return self.opFailed(ctx);
121
128
  ctx.out_set("point", OutVal{ .val = point });
122
129
 
123
130
  // #PreSpec-Hook
124
131
 
125
- const spec = utility.make_spec(ctx) catch return self.opError(ctx);
132
+ const spec = utility.make_spec(ctx) catch return self.opFailed(ctx);
126
133
  ctx.out_set("spec", OutVal{ .spec = spec });
127
134
 
128
135
  // #PreRequest-Hook
129
136
 
130
- const resp = utility.make_request(ctx) catch return self.opError(ctx);
137
+ const resp = utility.make_request(ctx) catch return self.opFailed(ctx);
131
138
  ctx.out_set("request", OutVal{ .response = resp });
132
139
 
133
140
  // #PreResponse-Hook
134
141
 
135
- const resp2 = utility.make_response(ctx) catch return self.opError(ctx);
142
+ const resp2 = utility.make_response(ctx) catch return self.opFailed(ctx);
136
143
  ctx.out_set("response", OutVal{ .response = resp2 });
137
144
 
138
145
  // #PreResult-Hook
139
146
 
140
- const result = utility.make_result(ctx) catch return self.opError(ctx);
147
+ const result = utility.make_result(ctx) catch return self.opFailed(ctx);
141
148
  ctx.out_set("result", OutVal{ .result = result });
142
149
 
143
150
  // #PreDone-Hook
@@ -207,23 +214,23 @@ pub const EntyClass = struct {
207
214
  // active streaming feature attaches result.stream on PreResult). A
208
215
  // failed step leaves through make_error, as an operation's does.
209
216
  utility.feature_hook(ctx, "PrePoint");
210
- const point = utility.make_point(ctx) catch return streamItems(self.opError(ctx));
217
+ const point = utility.make_point(ctx) catch return streamItems(self.opFailed(ctx));
211
218
  ctx.out_set("point", OutVal{ .val = point });
212
219
 
213
220
  utility.feature_hook(ctx, "PreSpec");
214
- const spec = utility.make_spec(ctx) catch return streamItems(self.opError(ctx));
221
+ const spec = utility.make_spec(ctx) catch return streamItems(self.opFailed(ctx));
215
222
  ctx.out_set("spec", OutVal{ .spec = spec });
216
223
 
217
224
  utility.feature_hook(ctx, "PreRequest");
218
- const resp = utility.make_request(ctx) catch return streamItems(self.opError(ctx));
225
+ const resp = utility.make_request(ctx) catch return streamItems(self.opFailed(ctx));
219
226
  ctx.out_set("request", OutVal{ .response = resp });
220
227
 
221
228
  utility.feature_hook(ctx, "PreResponse");
222
- const resp2 = utility.make_response(ctx) catch return streamItems(self.opError(ctx));
229
+ const resp2 = utility.make_response(ctx) catch return streamItems(self.opFailed(ctx));
223
230
  ctx.out_set("response", OutVal{ .response = resp2 });
224
231
 
225
232
  utility.feature_hook(ctx, "PreResult");
226
- const result = utility.make_result(ctx) catch return streamItems(self.opError(ctx));
233
+ const result = utility.make_result(ctx) catch return streamItems(self.opFailed(ctx));
227
234
  ctx.out_set("result", OutVal{ .result = result });
228
235
 
229
236
  utility.feature_hook(ctx, "PreDone");
@@ -102,26 +102,45 @@ pub const ProjectNameSDK = struct {
102
102
  // the transport wrapper chain.
103
103
  const feature_opts = h.to_map(h.getp(opts, "feature"));
104
104
  const feature_order = h.getpath(&.{ "__derived__", "featureorder" }, opts);
105
+ var placed: std.ArrayList([]const u8) = .empty;
105
106
  if (feature_opts == .object and feature_order == .array) {
106
107
  for (feature_order.array.data.items) |fname_v| {
107
108
  if (fname_v != .string) continue;
108
109
  const fname = fname_v.string;
109
- const fopts = h.getp(feature_opts, fname);
110
- if (fopts == .object) {
111
- if (h.get_bool(fopts, "active") orelse false) {
112
- sdk.sdkUtility.feature_add(rootctx, config.make_feature(fname));
110
+ if (!featureActive(feature_opts, fname)) continue;
111
+ const gen = config.make_feature(fname);
112
+ // An active name with no generated class is legal when an
113
+ // extend-supplied instance carries that name (station's adopt
114
+ // path): the instance takes the slot the order gives its name.
115
+ var carried: ?Feature = null;
116
+ if (!std.mem.eql(u8, gen.name(), fname)) {
117
+ for (extend) |f| {
118
+ if (std.mem.eql(u8, f.name(), fname)) {
119
+ carried = f;
120
+ break;
121
+ }
113
122
  }
114
123
  }
124
+ if (carried) |f| {
125
+ placed.append(h.A(), fname) catch {};
126
+ sdk.sdkUtility.feature_add(rootctx, f);
127
+ } else {
128
+ sdk.sdkUtility.feature_add(rootctx, gen);
129
+ }
115
130
  }
116
131
  }
117
132
 
118
- // Add extension features (see new_with).
133
+ // Add extension features (see new_with). An extend feature is
134
+ // active by its option, else by its own flag.
119
135
  for (extend) |f| {
120
136
  var present = false;
137
+ for (placed.items) |name| {
138
+ if (std.mem.eql(u8, name, f.name())) present = true;
139
+ }
121
140
  for (sdk.features.items) |have| {
122
141
  if (std.mem.eql(u8, have.name(), f.name())) present = true;
123
142
  }
124
- if (!present) sdk.sdkUtility.feature_add(rootctx, f);
143
+ if (!present and extActive(feature_opts, f)) sdk.sdkUtility.feature_add(rootctx, f);
125
144
  }
126
145
 
127
146
  // Initialize features.
@@ -134,6 +153,22 @@ pub const ProjectNameSDK = struct {
134
153
  return .{ .ok = sdk };
135
154
  }
136
155
 
156
+ fn featureActive(feature_opts: Value, fname: []const u8) bool {
157
+ if (feature_opts != .object) return false;
158
+ const fopts = h.getp(feature_opts, fname);
159
+ return fopts == .object and (h.get_bool(fopts, "active") orelse false);
160
+ }
161
+
162
+ fn extActive(feature_opts: Value, f: Feature) bool {
163
+ if (feature_opts == .object) {
164
+ const fopts = h.getp(feature_opts, f.name());
165
+ if (fopts == .object) {
166
+ if (h.get_bool(fopts, "active")) |b| return b;
167
+ }
168
+ }
169
+ return f.active();
170
+ }
171
+
137
172
  pub fn options_map(self: *ProjectNameSDK) Value {
138
173
  return h.clone(self.options);
139
174
  }
@@ -76,6 +76,8 @@ static char* dot_join(const char* a, const char* b) {
76
76
  return s;
77
77
  }
78
78
 
79
+ static voxgig_value* metrics_track(Feature* f);
80
+
79
81
  static void metrics_record(MetricsFeature* mf, Context* ctx, bool ok) {
80
82
  // Record once per operation: the missing start marker makes a second call
81
83
  // (PreDone followed by PreUnexpected on failure) a no-op.
@@ -97,6 +99,11 @@ static void metrics_record(MetricsFeature* mf, Context* ctx, bool ok) {
97
99
 
98
100
  bump(&mf->total, ok, dur);
99
101
  bump(ops_entry(mf, key), ok, dur);
102
+
103
+ voxgig_value* sink = getp(mf->options, "sink");
104
+ if (voxgig_is_func(sink)) {
105
+ call_vfn(sink, clean_util(ctx, metrics_track((Feature*)mf)));
106
+ }
100
107
  }
101
108
 
102
109
  static void metrics_pre_point(MetricsFeature* mf, Context* ctx) {
@@ -15,6 +15,7 @@
15
15
  #include <stdlib.h>
16
16
  #include <stdio.h>
17
17
  #include <string.h>
18
+ #include <strings.h>
18
19
 
19
20
  typedef struct {
20
21
  Feature base;
@@ -195,6 +196,208 @@ static void paging_graphql_pre_request(PagingFeature* pf, Context* ctx,
195
196
  }
196
197
  }
197
198
 
199
+ // The length of a URL's scheme and authority, or zero when it has none.
200
+ static size_t paging_origin_len(const char* text) {
201
+ if (!text || !isalpha((unsigned char)text[0])) return 0;
202
+ size_t i = 1;
203
+ while (isalnum((unsigned char)text[i]) || text[i] == '+' || text[i] == '.' || text[i] == '-') i++;
204
+ if (strncmp(text + i, "://", 3) != 0) return 0;
205
+ i += 3;
206
+ while (text[i] && text[i] != '/' && text[i] != '?' && text[i] != '#') i++;
207
+ return i;
208
+ }
209
+
210
+ // Under the `next` option's default, a URL or an absolute path is a link and
211
+ // anything else a cursor; `cursor` and `url` pin the reading.
212
+ static bool paging_is_link(voxgig_value* next, const char* mode) {
213
+ if (!voxgig_is_string(next)) return false;
214
+ if (strcmp(mode, "url") == 0) return true;
215
+ if (strcmp(mode, "cursor") == 0) return false;
216
+ const char* s = voxgig_as_string(next);
217
+ return paging_origin_len(s) > 0 || s[0] == '/';
218
+ }
219
+
220
+ static bool paging_foreign(const char* link, const char* base) {
221
+ size_t n = paging_origin_len(link);
222
+ if (n == 0) return false;
223
+ size_t b = paging_origin_len(base ? base : "");
224
+ return n != b || strncasecmp(link, base, n) != 0;
225
+ }
226
+
227
+ static char* paging_unescape(const char* text, size_t len) {
228
+ char* out = (char*)malloc(len + 1);
229
+ size_t o = 0;
230
+ for (size_t i = 0; i < len; i++) {
231
+ if (text[i] == '+') {
232
+ out[o++] = ' ';
233
+ } else if (text[i] == '%' && i + 2 < len &&
234
+ isxdigit((unsigned char)text[i + 1]) && isxdigit((unsigned char)text[i + 2])) {
235
+ char hex[3] = { text[i + 1], text[i + 2], 0 };
236
+ out[o++] = (char)strtol(hex, NULL, 16);
237
+ i += 2;
238
+ } else {
239
+ out[o++] = text[i];
240
+ }
241
+ }
242
+ out[o] = 0;
243
+ return out;
244
+ }
245
+
246
+ static void paging_set_str(char** slot, const char* text, size_t len) {
247
+ char* d = (char*)malloc(len + 1);
248
+ memcpy(d, text, len);
249
+ d[len] = 0;
250
+ free(*slot);
251
+ *slot = d;
252
+ }
253
+
254
+ static char* paging_copy(const char* text, size_t len) {
255
+ char* d = (char*)malloc(len + 1);
256
+ memcpy(d, text, len);
257
+ d[len] = 0;
258
+ return d;
259
+ }
260
+
261
+ static bool paging_has_scheme(const char* text) {
262
+ if (!isalpha((unsigned char)text[0])) return false;
263
+ size_t i = 1;
264
+ while (isalnum((unsigned char)text[i]) || text[i] == '+' || text[i] == '.' || text[i] == '-') i++;
265
+ return text[i] == ':';
266
+ }
267
+
268
+ typedef struct { const char* p; size_t n; } PagingSeg;
269
+
270
+ // RFC 3986 section 5.2.4.
271
+ static char* paging_remove_dots(const char* path) {
272
+ size_t len = strlen(path);
273
+ bool abs = path[0] == '/';
274
+ PagingSeg* segs = (PagingSeg*)malloc(sizeof(PagingSeg) * (len + 1));
275
+ size_t ns = 0;
276
+ const char* p = path + (abs ? 1 : 0);
277
+ for (;;) {
278
+ const char* e = strchr(p, '/');
279
+ size_t n = e ? (size_t)(e - p) : strlen(p);
280
+ bool dot = n == 1 && p[0] == '.';
281
+ bool dotdot = n == 2 && p[0] == '.' && p[1] == '.';
282
+ if (dot || dotdot) {
283
+ if (dotdot && ns > 0) ns--;
284
+ if (!e) segs[ns++] = (PagingSeg){ p, 0 };
285
+ } else {
286
+ segs[ns++] = (PagingSeg){ p, n };
287
+ }
288
+ if (!e) break;
289
+ p = e + 1;
290
+ }
291
+ char* out = (char*)malloc(len + 2);
292
+ size_t o = 0;
293
+ if (abs) out[o++] = '/';
294
+ for (size_t i = 0; i < ns; i++) {
295
+ if (i > 0) out[o++] = '/';
296
+ memcpy(out + o, segs[i].p, segs[i].n);
297
+ o += segs[i].n;
298
+ }
299
+ out[o] = 0;
300
+ free(segs);
301
+ return out;
302
+ }
303
+
304
+ // RFC 3986 reference resolution against the URL of the request that returned
305
+ // the link, by hand: C has no resolver. A link on that URL's origin comes back
306
+ // as its path and query; an absolute link is left as it is. The caller frees.
307
+ static char* paging_resolve(const char* link, const char* url) {
308
+ if (!url || !url[0] || paging_has_scheme(link)) return paging_copy(link, strlen(link));
309
+ size_t ln = strcspn(link, "#");
310
+ size_t on = paging_origin_len(url);
311
+ if (ln >= 2 && link[0] == '/' && link[1] == '/') {
312
+ size_t sn = on ? strcspn(url, ":") + 1 : 0;
313
+ char* out = (char*)malloc(sn + ln + 1);
314
+ memcpy(out, url, sn);
315
+ memcpy(out + sn, link, ln);
316
+ out[sn + ln] = 0;
317
+ return out;
318
+ }
319
+ const char* from = url + on;
320
+ size_t fn = strcspn(from, "#");
321
+ size_t bp = strcspn(from, "?#");
322
+ size_t rp = strcspn(link, "?#");
323
+ const char* q = NULL;
324
+ size_t qn = 0;
325
+ if (rp < ln) {
326
+ q = link + rp + 1;
327
+ qn = ln - rp - 1;
328
+ }
329
+ char* path;
330
+ if (rp == 0) {
331
+ path = paging_copy(from, bp);
332
+ if (!q && bp < fn) {
333
+ q = from + bp + 1;
334
+ qn = fn - bp - 1;
335
+ }
336
+ } else {
337
+ size_t dn = 0;
338
+ if (link[0] != '/') {
339
+ for (size_t k = bp; k > 0; k--) {
340
+ if (from[k - 1] == '/') {
341
+ dn = k;
342
+ break;
343
+ }
344
+ }
345
+ }
346
+ char* merged = (char*)malloc(dn + rp + 1);
347
+ memcpy(merged, from, dn);
348
+ memcpy(merged + dn, link, rp);
349
+ merged[dn + rp] = 0;
350
+ path = paging_remove_dots(merged);
351
+ free(merged);
352
+ }
353
+ size_t size = strlen(path) + qn + 3;
354
+ char* out = (char*)malloc(size);
355
+ snprintf(out, size, "%s%s%s%.*s", '/' == path[0] ? "" : "/", path, q ? "?" : "", (int)qn, q ? q : "");
356
+ free(path);
357
+ return out;
358
+ }
359
+
360
+ // The request goes to the link's path and query, on the SDK's own origin.
361
+ static void paging_follow(Spec* spec, const char* next) {
362
+ const char* rest = next + paging_origin_len(next);
363
+ size_t restlen = strcspn(rest, "#");
364
+ size_t pathlen = strcspn(rest, "?#");
365
+
366
+ voxgig_value* query = voxgig_new_map();
367
+ const char* q = rest + pathlen;
368
+ const char* end = rest + restlen;
369
+ if (q < end && *q == '?') q++;
370
+ while (q < end) {
371
+ size_t pairlen = 0;
372
+ while (q + pairlen < end && q[pairlen] != '&') pairlen++;
373
+ if (pairlen > 0) {
374
+ size_t keylen = 0;
375
+ while (keylen < pairlen && q[keylen] != '=') keylen++;
376
+ char* key = paging_unescape(q, keylen);
377
+ char* val = keylen < pairlen ? paging_unescape(q + keylen + 1, pairlen - keylen - 1)
378
+ : paging_unescape("", 0);
379
+ setp(query, key, v_str(val));
380
+ free(key);
381
+ free(val);
382
+ }
383
+ q += pairlen + 1;
384
+ }
385
+ if (v_is_list(spec->authquery)) {
386
+ voxgig_list* names = voxgig_as_list(spec->authquery);
387
+ for (size_t i = 0; i < names->len; i++) {
388
+ if (!voxgig_is_string(names->items[i])) continue;
389
+ const char* key = voxgig_as_string(names->items[i]);
390
+ setp(query, key, getp(spec->query, key));
391
+ }
392
+ }
393
+
394
+ paging_set_str(&spec->base, spec->base, paging_origin_len(spec->base));
395
+ paging_set_str(&spec->prefix, "", 0);
396
+ paging_set_str(&spec->path, rest, pathlen);
397
+ paging_set_str(&spec->suffix, "", 0);
398
+ spec->query = query;
399
+ }
400
+
198
401
  static void paging_pre_request(PagingFeature* pf, Context* ctx) {
199
402
  voxgig_value* options = pf->options;
200
403
  if (!pf->active || !is_list_op(options, ctx->op->name)) return;
@@ -223,8 +426,12 @@ static void paging_pre_request(PagingFeature* pf, Context* ctx) {
223
426
  }
224
427
 
225
428
  voxgig_value* cursor = getp(paging, "cursor");
429
+ voxgig_value* next = getp(paging, "next");
226
430
  if (!v_is_noval(cursor) && !v_is_null(cursor)) {
227
431
  setp(query, cursor_param, cursor);
432
+ } else if (voxgig_is_string(next) && !paging_foreign(voxgig_as_string(next), ctx->spec->base)) {
433
+ paging_follow(ctx->spec, voxgig_as_string(next));
434
+ query = ctx->spec->query;
228
435
  } else if (v_is_noval(getp(query, page_param))) {
229
436
  // A record written back by pre_result holds the page just fetched as
230
437
  // "page" and the one to fetch as "nextPage", so nextPage wins.
@@ -304,8 +511,12 @@ static void paging_pre_result(PagingFeature* pf, Context* ctx) {
304
511
  // Body-level signals; snake_case forms are read first so camelCase wins.
305
512
  if (voxgig_is_map(body)) {
306
513
  voxgig_value* next = getp(body, "next");
307
- if (!v_is_noval(next) && !v_is_null(next) && v_is_noval(getp(paging, "next"))) {
308
- setp(paging, "next", next);
514
+ if (!v_is_noval(next) && !v_is_null(next)) {
515
+ if (!paging_is_link(next, fopt_str(options, "next", "auto"))) {
516
+ setp(paging, "cursor", next);
517
+ } else if (v_is_noval(getp(paging, "next"))) {
518
+ setp(paging, "next", next);
519
+ }
309
520
  }
310
521
  voxgig_value* snake_cursor = getp(body, "next_cursor");
311
522
  if (!v_is_noval(snake_cursor) && !v_is_null(snake_cursor)) {
@@ -337,6 +548,19 @@ static void paging_pre_result(PagingFeature* pf, Context* ctx) {
337
548
  }
338
549
  }
339
550
 
551
+ // A link to another origin is recorded, never followed, and ends the walk.
552
+ const char* base = ctx->spec ? ctx->spec->base : get_str(ctx->options, "base");
553
+ if (ctx->spec && voxgig_is_string(getp(paging, "next"))) {
554
+ char* resolved = paging_resolve(voxgig_as_string(getp(paging, "next")), ctx->spec->url);
555
+ setp(paging, "next", v_str(resolved));
556
+ free(resolved);
557
+ }
558
+ voxgig_value* link = getp(paging, "next");
559
+ if (voxgig_is_string(link) && paging_foreign(voxgig_as_string(link), base)) {
560
+ setp(paging, "foreign", link);
561
+ setp(paging, "next", v_undef());
562
+ }
563
+
340
564
  // Cursor presence only INFERS another page. When the server stated the
341
565
  // answer outright — relay's `hasNextPage: false`, or a body `hasMore` —
342
566
  // that wins: a final page normally carries both an end cursor and
@@ -351,6 +575,11 @@ static void paging_pre_result(PagingFeature* pf, Context* ctx) {
351
575
  setp(paging, "hasMore", v_bool(true));
352
576
  }
353
577
 
578
+ if (!v_is_noval(getp(paging, "foreign")) && v_is_noval(getp(paging, "cursor")) &&
579
+ v_is_noval(getp(paging, "nextPage"))) {
580
+ setp(paging, "hasMore", v_bool(false));
581
+ }
582
+
354
583
  ctx->result->paging = paging;
355
584
  pf->last = paging;
356
585
 
@@ -38,29 +38,25 @@ static void acquire(RatelimitTrack* t, voxgig_value* options) {
38
38
  double rate = fopt_num(options, "rate", 5.0);
39
39
  double burst = fopt_num(options, "burst", rate);
40
40
 
41
- // Refill according to elapsed time.
41
+ // Refill, then reserve this call's token before any wait: a negative
42
+ // count is the calls already queued, so overlapping calls pace in turn.
42
43
  int64_t now = fopt_now_call(options);
43
44
  int64_t elapsed = now - t->last;
44
45
  t->last = now;
45
46
  double refilled = t->tokens + ((double)elapsed / 1000.0) * rate;
46
- t->tokens = burst < refilled ? burst : refilled; // burst.min(...)
47
+ t->tokens = (burst < refilled ? burst : refilled) - 1.0;
47
48
 
48
- if (t->tokens >= 1.0) {
49
- t->tokens -= 1.0;
49
+ if (t->tokens >= 0.0) {
50
50
  return;
51
51
  }
52
52
 
53
- // Not enough tokens: wait for one to accrue, then consume it.
54
- double needed = 1.0 - t->tokens;
55
- int64_t wait_ms = (int64_t)ceil((needed / rate) * 1000.0);
53
+ int64_t wait_ms = (int64_t)ceil((-t->tokens / rate) * 1000.0);
56
54
  t->throttled += 1;
57
55
  t->wait_ms += wait_ms;
58
56
 
59
57
  if (wait_ms > 0) {
60
58
  fopt_sleep_call(options, wait_ms);
61
59
  }
62
- t->last = fopt_now_call(options);
63
- t->tokens = 0.0;
64
60
  }
65
61
 
66
62
  static voxgig_value* ratelimit_fetch(Fetcher* self, Context* ctx, const char* url,
@@ -49,13 +49,60 @@ static bool retryable(voxgig_value* options, voxgig_value* out, PNError* e) {
49
49
  return false;
50
50
  }
51
51
 
52
+ static int64_t digits(const char* s, size_t from, size_t to) {
53
+ int64_t n = 0;
54
+ for (size_t i = from; i < to; i++) {
55
+ if (s[i] < '0' || s[i] > '9') return -1;
56
+ if (n < 1000000000000LL) n = n * 10 + (s[i] - '0');
57
+ }
58
+ return n;
59
+ }
60
+
61
+ // RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else false.
62
+ static bool retry_after_ms(const char* value, int64_t now, int64_t* out) {
63
+ while (*value == ' ' || *value == '\t') value++;
64
+ size_t len = strlen(value);
65
+ while (len > 0 && (value[len - 1] == ' ' || value[len - 1] == '\t')) len--;
66
+ if (len > 0 && len <= 9 && digits(value, 0, len) >= 0) {
67
+ *out = digits(value, 0, len) * 1000;
68
+ return true;
69
+ }
70
+ if (len > 9 && digits(value, 0, len) >= 0) {
71
+ *out = INT64_MAX / 2;
72
+ return true;
73
+ }
74
+ static const char* MONTHS = "JanFebMarAprMayJunJulAugSepOctNovDec";
75
+ static const char* DAYS = " Mon Tue Wed Thu Fri Sat Sun ";
76
+ char wd[6] = {' ', value[0], len > 1 ? value[1] : 0, len > 2 ? value[2] : 0, ' ', 0};
77
+ if (len != 29 || strncmp(value + 3, ", ", 2) != 0 || value[7] != ' ' || value[11] != ' ' ||
78
+ value[16] != ' ' || value[19] != ':' || value[22] != ':' ||
79
+ strncmp(value + 25, " GMT", 4) != 0 || strstr(DAYS, wd) == NULL) {
80
+ return false;
81
+ }
82
+ char mon[4] = {value[8], value[9], value[10], 0};
83
+ const char* at_mon = strstr(MONTHS, mon);
84
+ int64_t day = digits(value, 5, 7), year = digits(value, 12, 16), hour = digits(value, 17, 19),
85
+ min = digits(value, 20, 22), sec = digits(value, 23, 25);
86
+ if (at_mon == NULL || (at_mon - MONTHS) % 3 != 0 || day < 1 || day > 31 || year < 0 ||
87
+ hour < 0 || hour > 23 || min < 0 || min > 59 || sec < 0 || sec > 60) {
88
+ return false;
89
+ }
90
+ int64_t m = (at_mon - MONTHS) / 3 + 1;
91
+ int64_t y = m <= 2 ? year - 1 : year;
92
+ int64_t era = (y >= 0 ? y : y - 399) / 400;
93
+ int64_t yoe = y - era * 400;
94
+ int64_t doy = (153 * ((m + 9) % 12) + 2) / 5 + day - 1;
95
+ int64_t doe = yoe * 365 + yoe / 4 - yoe / 100 + doy;
96
+ int64_t days = era * 146097 + doe - 719468;
97
+ int64_t at = (((days * 24 + hour) * 60 + min) * 60 + sec) * 1000;
98
+ *out = at > now ? at - now : 0;
99
+ return true;
100
+ }
101
+
52
102
  static bool retry_after(voxgig_value* res, int64_t* out) {
53
103
  const char* v = fres_header(res, "retry-after");
54
104
  if (!v) return false;
55
- int64_t seconds = fparse_int(v, -1);
56
- if (seconds < 0) return false;
57
- *out = seconds * 1000;
58
- return true;
105
+ return retry_after_ms(v, now_ms(), out);
59
106
  }
60
107
 
61
108
  static int64_t backoff(voxgig_value* options, voxgig_value* out, PNError* e, int64_t attempt,
@@ -105,7 +105,8 @@ static void streaming_init(Feature* f, Context* ctx, voxgig_value* options) {
105
105
 
106
106
  static void streaming_pre_result(StreamingFeature* sf, Context* ctx) {
107
107
  if (!sf->active || !streamable_op(sf->options, ctx->op->name)) return;
108
- if (!ctx->result) return;
108
+ // A failed result keeps no stream, so the entity's stream raises its error.
109
+ if (!ctx->result || ctx->result->err) return;
109
110
 
110
111
  StreamUd* ud = (StreamUd*)calloc(1, sizeof(StreamUd));
111
112
  ud->options = sf->options;