@voxgig/sdkgen 4.45.0 → 4.47.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 (276) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/dist/action/check.js +73 -4
  3. package/dist/action/check.js.map +1 -1
  4. package/dist/action/copies.js +1 -0
  5. package/dist/action/copies.js.map +1 -1
  6. package/dist/action/doctor.d.ts +26 -2
  7. package/dist/action/doctor.js +208 -11
  8. package/dist/action/doctor.js.map +1 -1
  9. package/dist/action/package.d.ts +1 -1
  10. package/dist/action/package.js +15 -16
  11. package/dist/action/package.js.map +1 -1
  12. package/dist/action/remove.js +16 -4
  13. package/dist/action/remove.js.map +1 -1
  14. package/dist/action/resolve.d.ts +1 -0
  15. package/dist/action/resolve.js +10 -4
  16. package/dist/action/resolve.js.map +1 -1
  17. package/dist/action/target.d.ts +2 -1
  18. package/dist/action/target.js +50 -11
  19. package/dist/action/target.js.map +1 -1
  20. package/dist/admin/status.d.ts +7 -1
  21. package/dist/admin/status.js +34 -5
  22. package/dist/admin/status.js.map +1 -1
  23. package/dist/cmp/AgentGuide.js +46 -23
  24. package/dist/cmp/AgentGuide.js.map +1 -1
  25. package/dist/cmp/AgentGuideContent.d.ts +9 -7
  26. package/dist/cmp/AgentGuideContent.js +73 -43
  27. package/dist/cmp/AgentGuideContent.js.map +1 -1
  28. package/dist/cmp/AgentGuideFeature.js +19 -9
  29. package/dist/cmp/AgentGuideFeature.js.map +1 -1
  30. package/dist/cmp/AgentGuideTop.js +95 -49
  31. package/dist/cmp/AgentGuideTop.js.map +1 -1
  32. package/dist/cmp/Changelog.js +45 -4
  33. package/dist/cmp/Changelog.js.map +1 -1
  34. package/dist/cmp/Deploy.js +73 -35
  35. package/dist/cmp/Deploy.js.map +1 -1
  36. package/dist/cmp/Entity.js +1 -1
  37. package/dist/cmp/Entity.js.map +1 -1
  38. package/dist/cmp/ExternalTarget.js +10 -5
  39. package/dist/cmp/ExternalTarget.js.map +1 -1
  40. package/dist/cmp/Feature.js +12 -5
  41. package/dist/cmp/Feature.js.map +1 -1
  42. package/dist/cmp/FeatureDocs.d.ts +6 -4
  43. package/dist/cmp/FeatureDocs.js +14 -39
  44. package/dist/cmp/FeatureDocs.js.map +1 -1
  45. package/dist/cmp/FeatureHook.d.ts +7 -1
  46. package/dist/cmp/FeatureHook.js +34 -1
  47. package/dist/cmp/FeatureHook.js.map +1 -1
  48. package/dist/cmp/Main.js +1 -1
  49. package/dist/cmp/Main.js.map +1 -1
  50. package/dist/cmp/PublishWorkflow.js +89 -55
  51. package/dist/cmp/PublishWorkflow.js.map +1 -1
  52. package/dist/cmp/ReadmeErrors.js +521 -18
  53. package/dist/cmp/ReadmeErrors.js.map +1 -1
  54. package/dist/cmp/ReadmeExplanation.js +280 -44
  55. package/dist/cmp/ReadmeExplanation.js.map +1 -1
  56. package/dist/cmp/ReadmeFeatures.js +16 -7
  57. package/dist/cmp/ReadmeFeatures.js.map +1 -1
  58. package/dist/cmp/ReadmeIntro.js +4 -3
  59. package/dist/cmp/ReadmeIntro.js.map +1 -1
  60. package/dist/cmp/ReadmeModel.js +2 -2
  61. package/dist/cmp/ReadmeModel.js.map +1 -1
  62. package/dist/cmp/ReadmeRefFeatures.js +34 -24
  63. package/dist/cmp/ReadmeRefFeatures.js.map +1 -1
  64. package/dist/cmp/ReadmeStation.js +12 -9
  65. package/dist/cmp/ReadmeStation.js.map +1 -1
  66. package/dist/cmp/ReadmeTop.js +479 -382
  67. package/dist/cmp/ReadmeTop.js.map +1 -1
  68. package/dist/cmp/ReadmeUnions.js +8 -2
  69. package/dist/cmp/ReadmeUnions.js.map +1 -1
  70. package/dist/cmp/Registered.js +1 -1
  71. package/dist/cmp/Registered.js.map +1 -1
  72. package/dist/cmp/Security.js +26 -5
  73. package/dist/cmp/Security.js.map +1 -1
  74. package/dist/cmp/Test.js +1 -1
  75. package/dist/cmp/Test.js.map +1 -1
  76. package/dist/helpers/alongside.d.ts +2 -3
  77. package/dist/helpers/alongside.js +16 -15
  78. package/dist/helpers/alongside.js.map +1 -1
  79. package/dist/helpers/applicability.d.ts +3 -1
  80. package/dist/helpers/applicability.js +40 -1
  81. package/dist/helpers/applicability.js.map +1 -1
  82. package/dist/helpers/component.js +9 -1
  83. package/dist/helpers/component.js.map +1 -1
  84. package/dist/helpers/copymerge.d.ts +3 -0
  85. package/dist/helpers/copymerge.js +43 -10
  86. package/dist/helpers/copymerge.js.map +1 -1
  87. package/dist/helpers/definitionPlan.js +0 -1
  88. package/dist/helpers/definitionPlan.js.map +1 -1
  89. package/dist/helpers/doccheck.d.ts +11 -0
  90. package/dist/helpers/doccheck.js +146 -0
  91. package/dist/helpers/doccheck.js.map +1 -0
  92. package/dist/helpers/doctext.d.ts +11 -0
  93. package/dist/helpers/doctext.js +85 -0
  94. package/dist/helpers/doctext.js.map +1 -0
  95. package/dist/helpers/exampleCall.d.ts +16 -0
  96. package/dist/helpers/exampleCall.js +334 -0
  97. package/dist/helpers/exampleCall.js.map +1 -0
  98. package/dist/helpers/exportnames.d.ts +4 -0
  99. package/dist/helpers/exportnames.js +35 -0
  100. package/dist/helpers/exportnames.js.map +1 -0
  101. package/dist/helpers/facts.d.ts +2 -1
  102. package/dist/helpers/facts.js +210 -5
  103. package/dist/helpers/facts.js.map +1 -1
  104. package/dist/helpers/flowGuard.d.ts +1 -1
  105. package/dist/helpers/flowGuard.js +20 -7
  106. package/dist/helpers/flowGuard.js.map +1 -1
  107. package/dist/helpers/generated.d.ts +1 -0
  108. package/dist/helpers/generated.js +1 -1
  109. package/dist/helpers/generated.js.map +1 -1
  110. package/dist/helpers/graphqlPoint.d.ts +2 -1
  111. package/dist/helpers/graphqlPoint.js +17 -0
  112. package/dist/helpers/graphqlPoint.js.map +1 -1
  113. package/dist/helpers/guardModel.d.ts +2 -0
  114. package/dist/helpers/guardModel.js +41 -0
  115. package/dist/helpers/guardModel.js.map +1 -0
  116. package/dist/helpers/manifest.d.ts +2 -1
  117. package/dist/helpers/manifest.js +16 -0
  118. package/dist/helpers/manifest.js.map +1 -1
  119. package/dist/helpers/mcpTools.d.ts +2 -1
  120. package/dist/helpers/mcpTools.js +8 -1
  121. package/dist/helpers/mcpTools.js.map +1 -1
  122. package/dist/helpers/modelcheck.d.ts +2 -1
  123. package/dist/helpers/modelcheck.js +13 -0
  124. package/dist/helpers/modelcheck.js.map +1 -1
  125. package/dist/helpers/opExample.d.ts +9 -2
  126. package/dist/helpers/opExample.js +22 -2
  127. package/dist/helpers/opExample.js.map +1 -1
  128. package/dist/helpers/opShape.d.ts +2 -1
  129. package/dist/helpers/opShape.js +29 -17
  130. package/dist/helpers/opShape.js.map +1 -1
  131. package/dist/helpers/packageMeta.d.ts +6 -4
  132. package/dist/helpers/packageMeta.js +88 -53
  133. package/dist/helpers/packageMeta.js.map +1 -1
  134. package/dist/helpers/placement.d.ts +15 -0
  135. package/dist/helpers/placement.js +76 -0
  136. package/dist/helpers/placement.js.map +1 -0
  137. package/dist/helpers/semver.d.ts +3 -1
  138. package/dist/helpers/semver.js +28 -0
  139. package/dist/helpers/semver.js.map +1 -1
  140. package/dist/helpers/serverVars.js +3 -2
  141. package/dist/helpers/serverVars.js.map +1 -1
  142. package/dist/helpers/shipped.d.ts +2 -1
  143. package/dist/helpers/shipped.js +12 -0
  144. package/dist/helpers/shipped.js.map +1 -1
  145. package/dist/helpers/sourcestring.d.ts +3 -0
  146. package/dist/helpers/sourcestring.js +43 -0
  147. package/dist/helpers/sourcestring.js.map +1 -0
  148. package/dist/helpers/stdrep.d.ts +1 -1
  149. package/dist/helpers/stdrep.js +5 -1
  150. package/dist/helpers/stdrep.js.map +1 -1
  151. package/dist/helpers/surface.d.ts +7 -0
  152. package/dist/helpers/surface.js +69 -0
  153. package/dist/helpers/surface.js.map +1 -0
  154. package/dist/helpers/targetguard.d.ts +13 -0
  155. package/dist/helpers/targetguard.js +65 -0
  156. package/dist/helpers/targetguard.js.map +1 -0
  157. package/dist/helpers/text.d.ts +3 -1
  158. package/dist/helpers/text.js +16 -0
  159. package/dist/helpers/text.js.map +1 -1
  160. package/dist/helpers/textguard.d.ts +31 -0
  161. package/dist/helpers/textguard.js +157 -0
  162. package/dist/helpers/textguard.js.map +1 -0
  163. package/dist/helpers/title.d.ts +4 -0
  164. package/dist/helpers/title.js +52 -0
  165. package/dist/helpers/title.js.map +1 -0
  166. package/dist/sdkgen.d.ts +4 -6
  167. package/dist/sdkgen.js +72 -63
  168. package/dist/sdkgen.js.map +1 -1
  169. package/dist/testkit.d.ts +7 -2
  170. package/dist/testkit.js +27 -20
  171. package/dist/testkit.js.map +1 -1
  172. package/dist/tsconfig.tsbuildinfo +1 -1
  173. package/dist/utility.js +2 -1
  174. package/dist/utility.js.map +1 -1
  175. package/model/fact.aontu +150 -0
  176. package/model/sdkgen.aontu +15 -3
  177. package/package.json +3 -1
  178. package/project/.sdk/src/cmp/c/ReadmeQuick_c.ts +2 -2
  179. package/project/.sdk/src/cmp/c/ReadmeTopQuick_c.ts +1 -1
  180. package/project/.sdk/src/cmp/clojure/ReadmeEntity_clojure.ts +12 -3
  181. package/project/.sdk/src/cmp/clojure/ReadmeQuick_clojure.ts +1 -1
  182. package/project/.sdk/src/cmp/cpp/ReadmeQuick_cpp.ts +1 -1
  183. package/project/.sdk/src/cmp/csharp/ReadmeQuick_csharp.ts +1 -1
  184. package/project/.sdk/src/cmp/elixir/ReadmeQuick_elixir.ts +1 -1
  185. package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +1 -1
  186. package/project/.sdk/src/cmp/java/ReadmeQuick_java.ts +1 -1
  187. package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +1 -1
  188. package/project/.sdk/src/cmp/kotlin/ReadmeQuick_kotlin.ts +1 -1
  189. package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +1 -1
  190. package/project/.sdk/src/cmp/ocaml/ReadmeQuick_ocaml.ts +1 -1
  191. package/project/.sdk/src/cmp/perl/ReadmeQuick_perl.ts +1 -1
  192. package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +1 -1
  193. package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +1 -1
  194. package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +1 -1
  195. package/project/.sdk/src/cmp/rust/ReadmeQuick_rust.ts +1 -1
  196. package/project/.sdk/src/cmp/scala/ReadmeQuick_scala.ts +1 -1
  197. package/project/.sdk/src/cmp/scala/ReadmeRef_scala.ts +4 -1
  198. package/project/.sdk/src/cmp/swift/ReadmeQuick_swift.ts +2 -1
  199. package/project/.sdk/src/cmp/swift/ReadmeRef_swift.ts +3 -0
  200. package/project/.sdk/src/cmp/swift/ReadmeTopQuick_swift.ts +2 -1
  201. package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +1 -1
  202. package/project/.sdk/src/cmp/ts/TestDefinition_ts.ts +3 -1
  203. package/project/.sdk/src/cmp/zig/ReadmeOptions_zig.ts +1 -1
  204. package/project/.sdk/src/cmp/zig/ReadmeQuick_zig.ts +3 -3
  205. package/project/.sdk/src/cmp/zig/ReadmeTopQuick_zig.ts +2 -2
  206. package/project/.sdk/tm/ocaml/test/feature/secrets/t_secrets.ml +3 -1
  207. package/project/.sdk/tm/php/test/feature/secrets/SecretsTest.php +2 -1
  208. package/project/.sdk/tm/zig/test/feature/secrets/secrets_test.zig +11 -2
  209. package/project/sdkgen-package.json +1 -1
  210. package/src/action/check.ts +99 -4
  211. package/src/action/copies.ts +2 -0
  212. package/src/action/doctor.ts +304 -15
  213. package/src/action/package.ts +11 -13
  214. package/src/action/remove.ts +20 -5
  215. package/src/action/resolve.ts +11 -4
  216. package/src/action/target.ts +66 -15
  217. package/src/admin/status.ts +25 -5
  218. package/src/cmp/AgentGuide.ts +52 -25
  219. package/src/cmp/AgentGuideContent.ts +75 -43
  220. package/src/cmp/AgentGuideFeature.ts +21 -10
  221. package/src/cmp/AgentGuideTop.ts +119 -49
  222. package/src/cmp/Changelog.ts +56 -5
  223. package/src/cmp/Deploy.ts +81 -40
  224. package/src/cmp/Entity.ts +1 -1
  225. package/src/cmp/ExternalTarget.ts +12 -6
  226. package/src/cmp/Feature.ts +13 -6
  227. package/src/cmp/FeatureDocs.ts +21 -40
  228. package/src/cmp/FeatureHook.ts +38 -1
  229. package/src/cmp/Main.ts +1 -1
  230. package/src/cmp/PublishWorkflow.ts +94 -60
  231. package/src/cmp/ReadmeErrors.ts +555 -25
  232. package/src/cmp/ReadmeExplanation.ts +316 -52
  233. package/src/cmp/ReadmeFeatures.ts +18 -8
  234. package/src/cmp/ReadmeIntro.ts +4 -3
  235. package/src/cmp/ReadmeModel.ts +2 -2
  236. package/src/cmp/ReadmeRefFeatures.ts +39 -27
  237. package/src/cmp/ReadmeStation.ts +13 -16
  238. package/src/cmp/ReadmeTop.ts +538 -397
  239. package/src/cmp/ReadmeUnions.ts +10 -2
  240. package/src/cmp/Registered.ts +1 -1
  241. package/src/cmp/Security.ts +35 -7
  242. package/src/cmp/Test.ts +1 -1
  243. package/src/helpers/alongside.ts +16 -19
  244. package/src/helpers/applicability.ts +44 -1
  245. package/src/helpers/component.ts +11 -1
  246. package/src/helpers/copymerge.ts +58 -10
  247. package/src/helpers/definitionPlan.ts +0 -1
  248. package/src/helpers/doccheck.ts +174 -0
  249. package/src/helpers/doctext.ts +115 -0
  250. package/src/helpers/exampleCall.ts +415 -0
  251. package/src/helpers/exportnames.ts +47 -0
  252. package/src/helpers/facts.ts +259 -5
  253. package/src/helpers/flowGuard.ts +22 -7
  254. package/src/helpers/generated.ts +3 -1
  255. package/src/helpers/graphqlPoint.ts +20 -1
  256. package/src/helpers/guardModel.ts +50 -0
  257. package/src/helpers/manifest.ts +19 -0
  258. package/src/helpers/mcpTools.ts +11 -1
  259. package/src/helpers/modelcheck.ts +16 -0
  260. package/src/helpers/opExample.ts +34 -2
  261. package/src/helpers/opShape.ts +29 -16
  262. package/src/helpers/packageMeta.ts +89 -52
  263. package/src/helpers/placement.ts +114 -0
  264. package/src/helpers/semver.ts +35 -0
  265. package/src/helpers/serverVars.ts +4 -2
  266. package/src/helpers/shipped.ts +13 -0
  267. package/src/helpers/sourcestring.ts +47 -0
  268. package/src/helpers/stdrep.ts +6 -1
  269. package/src/helpers/surface.ts +82 -0
  270. package/src/helpers/targetguard.ts +91 -0
  271. package/src/helpers/text.ts +22 -0
  272. package/src/helpers/textguard.ts +208 -0
  273. package/src/helpers/title.ts +59 -0
  274. package/src/sdkgen.ts +82 -78
  275. package/src/testkit.ts +42 -20
  276. package/src/utility.ts +2 -1
@@ -16,7 +16,9 @@ import { isControlSkipped } from './utility'
16
16
  // Generated from the API definition, not from the model this SDK was built
17
17
  // from: the route, the declared query parameters, the credential the security
18
18
  // scheme names, and the definition's own response example.
19
- const PLAN: any[] = ${JSON.stringify(plan, null, 2)}
19
+ // A JSON string, not an array literal: tsc types a literal as the union of its
20
+ // elements, and past about a thousand routes fails with TS2590.
21
+ const PLAN: any[] = JSON.parse(${JSON.stringify(JSON.stringify(plan))})
20
22
 
21
23
 
22
24
  describe('definition', () => {
@@ -26,7 +26,7 @@ const client = sdk.${model.Name}SDK.new(h.jo(&.{
26
26
 
27
27
  publishedOptions.map((option: any) => {
28
28
  if ('apikey' === option.name) {
29
- Content(` .{ "${option.name}", h.vstr(std.posix.getenv("${envName(model)}_APIKEY") orelse "") },
29
+ Content(` .{ "${option.name}", h.vstr(init.environ_map.get("${envName(model)}_APIKEY") orelse "") },
30
30
  `)
31
31
  }
32
32
  else {
@@ -30,7 +30,7 @@ const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
30
30
 
31
31
  const authActive = isAuthActive(model)
32
32
  const ctor = authActive
33
- ? `sdk.${model.const.Name}SDK.new(h.jo(&.{\n .{ "apikey", h.vstr(std.posix.getenv("${envName(model)}_APIKEY") orelse "") },\n}))`
33
+ ? `sdk.${model.const.Name}SDK.new(h.jo(&.{\n .{ "apikey", h.vstr(init.environ_map.get("${envName(model)}_APIKEY") orelse "") },\n}))`
34
34
  : `sdk.${model.const.Name}SDK.new(h.vnull())`
35
35
 
36
36
  // A type-correct zig expression constructing a voxgig struct Value.
@@ -51,7 +51,7 @@ const std = @import("std");
51
51
  const sdk = @import("sdk");
52
52
  const h = sdk.h;
53
53
 
54
- const client = ${ctor};
54
+ ${authActive ? '// init is the std.process.Init that main receives.\n' : ''}const client = ${ctor};
55
55
  \`\`\`
56
56
 
57
57
  `)
@@ -145,7 +145,7 @@ switch (client.${method}(h.vnull()).load(${loadArg}, h.vnull())) {
145
145
  // shape so the docs reference REAL writable fields.
146
146
  const examplePairs = (opname: string): string[] => {
147
147
  const items = requestExampleItems(exampleEntity, opname)
148
- .filter((it: any) => (it.name !== idF && it.name !== 'id') ||
148
+ .filter((it: any) => (it.name !== idF && (it.name !== 'id' || !it.optional)) ||
149
149
  ('create' === opname && !it.optional))
150
150
  const required = items.filter((it: any) => !it.optional)
151
151
  const optional = items.filter((it: any) => it.optional)
@@ -33,7 +33,7 @@ const ReadmeTopQuick = cmp(function ReadmeTopQuick(props: any) {
33
33
 
34
34
  const authActive = isAuthActive(model)
35
35
  const ctor = authActive
36
- ? `sdk.${model.const.Name}SDK.new(h.jo(&.{\n .{ "apikey", h.vstr(std.posix.getenv("${envName(model)}_APIKEY") orelse "") },\n}))`
36
+ ? `sdk.${model.const.Name}SDK.new(h.jo(&.{\n .{ "apikey", h.vstr(init.environ_map.get("${envName(model)}_APIKEY") orelse "") },\n}))`
37
37
  : `sdk.${model.const.Name}SDK.new(h.vnull())`
38
38
 
39
39
  Content(`\`\`\`zig
@@ -41,7 +41,7 @@ const std = @import("std");
41
41
  const sdk = @import("sdk");
42
42
  const h = sdk.h;
43
43
 
44
- const client = ${ctor};
44
+ ${authActive ? '// init is the std.process.Init that main receives.\n' : ''}const client = ${ctor};
45
45
 
46
46
  `)
47
47
 
@@ -300,7 +300,9 @@ let drive_entity (client : sdk_client) (r : recorder) : (unit, string) Stdlib.re
300
300
  (* An op the entity does not define, or a route the call
301
301
  * cannot fill, fails before the chain is consulted: keep
302
302
  * going. Anything else is the answer. *)
303
- if e.err_code = "unsupported_op" || e.err_code = "url_param_missing" then ops more
303
+ if List.mem e.err_code
304
+ ["unsupported_op"; "url_param_missing"; "point_no_match"; "point_action_required"]
305
+ then ops more
304
306
  else (out := Error e.err_msg)
305
307
  | exception e -> out := Error (Printexc.to_string e))
306
308
  in
@@ -294,7 +294,8 @@ class ProjectNameSecretsTest extends TestCase
294
294
  function (\Throwable $error) use (&$caught) {
295
295
  // A call whose route it cannot fill is refused before the
296
296
  // chain is consulted, so it is not the refusal under test.
297
- if ($error instanceof ProjectNameError && 'url_param_missing' !== $error->sdk_code) {
297
+ if ($error instanceof ProjectNameError &&
298
+ !in_array($error->sdk_code, ['url_param_missing', 'point_no_match', 'point_action_required'], true)) {
298
299
  $caught = $error;
299
300
  }
300
301
  });
@@ -54,6 +54,15 @@ fn vnull() Value {
54
54
  return Value{ .null = {} };
55
55
  }
56
56
 
57
+ // A route the call cannot fill is refused before the chain is consulted.
58
+ fn refusedBeforeChain(code: []const u8) bool {
59
+ const codes = [_][]const u8{ "url_param_missing", "point_no_match", "point_action_required" };
60
+ for (codes) |c| {
61
+ if (std.mem.eql(u8, code, c)) return true;
62
+ }
63
+ return false;
64
+ }
65
+
57
66
  // Every block runs only when the feature is in THIS SDK - build.zig lists
58
67
  // this file only then, so this is belt and braces rather than a gate.
59
68
  fn present() bool {
@@ -294,14 +303,14 @@ fn drive_entity(client: *sdk.SDK) Drive {
294
303
  if (h.getp(ops, "load") == .object) {
295
304
  const res = ent.load(h.jo(&.{.{ "id", h.vstr("s01") }}), vnull());
296
305
  switch (res) {
297
- .err => |e| if (!std.mem.eql(u8, e.code, "url_param_missing"))
306
+ .err => |e| if (!refusedBeforeChain(e.code))
298
307
  return .{ .ran = true, .ok = false, .msg = e.msg },
299
308
  .ok => return .{ .ran = true, .ok = true, .msg = "" },
300
309
  }
301
310
  } else if (h.getp(ops, "list") == .object) {
302
311
  const res = ent.list(h.omap(), vnull());
303
312
  switch (res) {
304
- .err => |e| if (!std.mem.eql(u8, e.code, "url_param_missing"))
313
+ .err => |e| if (!refusedBeforeChain(e.code))
305
314
  return .{ .ran = true, .ok = false, .msg = e.msg },
306
315
  .ok => return .{ .ran = true, .ok = true, .msg = "" },
307
316
  }
@@ -3,7 +3,7 @@
3
3
  "package": 1
4
4
  },
5
5
  "name": "@voxgig/sdkgen",
6
- "version": "4.45.0",
6
+ "version": "4.47.0",
7
7
  "provides": {
8
8
  "target": [
9
9
  "c",
@@ -1,6 +1,11 @@
1
1
  import { kindCollection } from '../helpers/kindCollection'
2
2
 
3
3
  import { unknownTags, TAGS } from '../helpers/applicability'
4
+ import { SURFACES, SURFACE_SINCE } from '../helpers/surface'
5
+ import { applyFacts, fact } from '../helpers/facts'
6
+ import { admitsBelow } from '../helpers/semver'
7
+ import { SDKGEN_VERSION } from '../helpers/shipped'
8
+ import { entityless, entitylessNote } from '../helpers/targetguard'
4
9
  import Path from 'node:path'
5
10
 
6
11
  import { KIT } from '../types'
@@ -14,6 +19,7 @@ import { SdkGenError } from '../utility'
14
19
 
15
20
  import {
16
21
  MANIFEST,
22
+ parityFinding,
17
23
  probePackage,
18
24
  validateManifest,
19
25
  } from '../helpers/manifest'
@@ -32,6 +38,7 @@ import {
32
38
  ANCHOR_RE,
33
39
  compileModel,
34
40
  publishOverrideProbe,
41
+ schemaHooks,
35
42
  slashComments,
36
43
  } from '../helpers/modelcheck'
37
44
 
@@ -189,7 +196,11 @@ function checkItems(fs: any, sdk: string, manifest?: Manifest): Finding[] {
189
196
  continue
190
197
  }
191
198
 
192
- found.push(...checkDefinition(fs, kind, name, file))
199
+ found.push(...checkDefinition(fs, kind, name, file, {
200
+ manifest: Path.join(sdk, '..', MANIFEST),
201
+ tier: manifest?.parity?.[name],
202
+ range: manifest?.engines?.sdkgen,
203
+ }))
193
204
  }
194
205
  }
195
206
 
@@ -197,8 +208,12 @@ function checkItems(fs: any, sdk: string, manifest?: Manifest): Finding[] {
197
208
  }
198
209
 
199
210
 
211
+ // What the manifest says about an item, for the checks that compare the two.
212
+ type Declared = { manifest: string, tier?: string, range?: string }
213
+
214
+
200
215
  function checkDefinition(
201
- fs: any, kind: string, name: string, file: string,
216
+ fs: any, kind: string, name: string, file: string, pkg?: Declared,
202
217
  ): Finding[] {
203
218
  const found: Finding[] = []
204
219
  const raw = String(fs.readFileSync(file, 'utf8'))
@@ -208,7 +223,7 @@ function checkDefinition(
208
223
  const legacyFile = isLegacyPath(file)
209
224
  const legacy = legacyFile || src !== raw
210
225
 
211
- const at = (level: 'error' | 'warn', point: string, note: string): Finding =>
226
+ const at = (level: 'error' | 'warn' | 'info', point: string, note: string): Finding =>
212
227
  ({ level, point, kind, name, file, note: file + ': ' + note })
213
228
 
214
229
  if (legacy) {
@@ -313,17 +328,78 @@ function checkDefinition(
313
328
 
314
329
  if ('target' === kind) {
315
330
  found.push(...checkTargetModel(checked, name, file, at))
331
+
332
+ if (0 === unified.errors.length && null != declared) {
333
+ found.push(...checkTargetSurface(unified.model, name, pkg, at))
334
+ }
335
+
336
+ const title = (declared as any)?.title
337
+ if (null != declared && ('string' !== typeof title || '' === title.trim())) {
338
+ found.push(at('warn', 'target-title-missing',
339
+ 'declares no `title` — the generated documents name this target by its ' +
340
+ "origin's label, else as `" + name + '`'))
341
+ }
316
342
  }
317
343
 
318
344
  if ('feature' === kind) {
319
345
  found.push(...checkFeatureModel(strict.model, name, at))
346
+ found.push(...checkFeatureHooks(strict.model, name, at))
320
347
  }
321
348
 
322
349
  return found
323
350
  }
324
351
 
325
352
 
326
- type At = (level: 'error' | 'warn', point: string, note: string) => Finding
353
+ type At = (level: 'error' | 'warn' | 'info', point: string, note: string) => Finding
354
+
355
+
356
+ // The surface the fact rules give the target, against its parity tier, and
357
+ // its declared word against the releases that read it. Generation reads a
358
+ // word it does not know as unknown, so no word fails it.
359
+ function checkTargetSurface(
360
+ model: any, name: string, pkg: Declared | undefined, at: At,
361
+ ): Finding[] {
362
+ let surface: string
363
+
364
+ try {
365
+ applyFacts(model)
366
+ surface = fact(model.main[KIT].target[name], 'surface')
367
+ }
368
+ catch (err: any) {
369
+ return [at('error', 'target-facts', 'the fact rules fail on this target alone: ' + err.message)]
370
+ }
371
+
372
+ const found: Finding[] = null == pkg?.tier ? [] :
373
+ parityFinding(pkg.manifest, name, pkg.tier, surface)
374
+
375
+ const target = model.main[KIT].target[name]
376
+ if (entityless(target)) {
377
+ found.push(at('error', 'target-entity-off', entitylessNote(name)))
378
+ }
379
+
380
+ const word = target.surface
381
+ if ('string' !== typeof word || '' === word) {
382
+ return found
383
+ }
384
+
385
+ const since = SURFACE_SINCE[word]
386
+ if (null == since) {
387
+ found.push(at('warn', 'target-surface-unknown',
388
+ 'declares surface `' + word + '`, which sdkgen ' + SDKGEN_VERSION +
389
+ ' does not know (' + SURFACES.join(', ') + '): generation reads it as unknown ' +
390
+ 'and names the target by its title. A release that introduces the word reads it, ' +
391
+ 'from that release on; otherwise it is a misspelling'))
392
+ }
393
+ else if (false !== admitsBelow(pkg?.range ?? '', since)) {
394
+ found.push(at('info', 'target-surface-since',
395
+ 'declares surface `' + word + '`, which sdkgen reads from ' + since + '; ' +
396
+ (null == pkg?.range ? 'the manifest declares no `engines.sdkgen`, so it' :
397
+ '`engines.sdkgen` `' + pkg.range + '`') +
398
+ ' admits older releases, which ignore the slot'))
399
+ }
400
+
401
+ return found
402
+ }
327
403
 
328
404
 
329
405
  // The publish-override probe: unify the target model with a project that sets
@@ -389,6 +465,25 @@ function checkFeatureModel(model: any, name: string, at: At): Finding[] {
389
465
  }
390
466
 
391
467
 
468
+ function checkFeatureHooks(model: any, name: string, at: At): Finding[] {
469
+ const hook = model?.main?.[KIT]?.feature?.[name]?.hook
470
+ if (null == hook || 'object' !== typeof hook) {
471
+ return []
472
+ }
473
+
474
+ const known = schemaHooks()
475
+ const unknown = Object.keys(hook).filter((h: string) => !known.includes(h)).sort()
476
+ if (0 === unknown.length) {
477
+ return []
478
+ }
479
+
480
+ return [at('error', 'feature-hook-unknown',
481
+ 'declares hook(s) the base schema does not list: ' + unknown.join(', ') +
482
+ ' — no pipeline fires them, so the feature never runs there. The hooks are: ' +
483
+ known.join(', '))]
484
+ }
485
+
486
+
392
487
  // The template trees: does a feature's declared coverage exist, and is
393
488
  // anything in a target's tree feature-shaped but invisible to the trim?
394
489
  function checkFeatureSource(
@@ -362,6 +362,8 @@ async function guardCopies<T>(
362
362
  basedir: BASE_DIR,
363
363
  conflictdir: CONFLICT_DIR,
364
364
  versions: gitVersions,
365
+ forget: (rels: string[]) => appendEntry(actx, 'keep',
366
+ { files: Object.fromEntries(rels.map((rel: string) => [rel, null])) }),
365
367
  error: (msg: string) => new SdkGenError(msg),
366
368
  }, (gfs: any) => run({ ...actx, fs: () => gfs, copyGuarded: true }))
367
369
  }