@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
package/src/sdkgen.ts CHANGED
@@ -24,6 +24,9 @@ import { SdkGenError, requirePath, isAuthActive, resolveAuthPrefix, resolveAuthI
24
24
  import { Main } from './cmp/Main'
25
25
  import { featureApplies, targetFeatures, featureTags, unknownTags, TAGS } from './helpers/applicability'
26
26
  import { ExternalTarget } from './cmp/ExternalTarget'
27
+ import { readOverride, runOutput } from './helpers/placement'
28
+ import { refuseBrokenTargets } from './helpers/targetguard'
29
+ import type { ExternalOverride } from './helpers/placement'
27
30
 
28
31
  import { KIT, resolvedSpec } from '@voxgig/apidef'
29
32
  import { Deploy } from './cmp/Deploy'
@@ -65,7 +68,10 @@ import { getMatchEntries } from './helpers/getMatchEntries'
65
68
  import { collectDeps } from './helpers/collectDeps'
66
69
  import { guardModelNames } from './helpers/modelNames'
67
70
  import { guardFlowSteps } from './helpers/flowGuard'
68
- import { applyFacts, fact } from './helpers/facts'
71
+ import { guardModel } from './helpers/guardModel'
72
+ import { sourceString } from './helpers/sourcestring'
73
+ import { applyFacts, fact, refuseRootPlan } from './helpers/facts'
74
+ import { docFindings } from './helpers/doccheck'
69
75
  import { claimedFiles, pruneGenerated } from './helpers/generated'
70
76
  import { cmp as labelledCmp } from './helpers/component'
71
77
  import type { DepEntry } from './helpers/collectDeps'
@@ -229,13 +235,6 @@ type SdkGenOptions = {
229
235
  }
230
236
 
231
237
 
232
- type ExternalOverride = {
233
- path?: string
234
- sdkrel?: string
235
- enclosing?: boolean
236
- }
237
-
238
-
239
238
  const { Jostraca } = JostracaModule
240
239
 
241
240
 
@@ -321,20 +320,20 @@ function SdkGen(opts: SdkGenOptions) {
321
320
  log.info({ point: 'generate-start', start, note: opts.dryrun ? '** DRY RUN **' : '' })
322
321
  log.debug({ point: 'generate-spec', spec })
323
322
 
324
- // BEFORE ANYTHING READS A NAME. A digit-leading name, or a pair of names
325
- // that meet once case is ignored, yields identifiers or files no target
326
- // can hold, and the consumer's own Root.ts re-derives those names per
327
- // target — so the only correction that survives is one made to the model
328
- // itself, before Root runs. See helpers/modelNames.
329
- guardModelNames(model, log)
330
- warnUngeneratedOps(model, log, targetOrigins(model))
331
-
332
- // A flow step whose call the runtime would refuse is switched off, so no
333
- // generated test makes it; see helpers/flowGuard.
334
- guardFlowSteps(model, log)
323
+ // BEFORE ANYTHING READS A NAME: the consumer's own Root.ts re-derives the
324
+ // names per target, so only a correction made to the model itself
325
+ // survives. A flow step whose call the runtime would refuse is switched
326
+ // off too. See helpers/modelNames and helpers/flowGuard.
327
+ guardModel(model, log)
335
328
 
336
329
  applyFacts(model)
337
330
 
331
+ // A target that would generate an SDK broken at build or run time is a
332
+ // named error, so no document is gated on its state; see helpers/targetguard.
333
+ refuseBrokenTargets(model)
334
+
335
+ warnUngeneratedOps(model, log, targetOrigins(model))
336
+
338
337
  let Root = spec.root
339
338
 
340
339
  if (null == Root && null != config?.root) {
@@ -370,7 +369,8 @@ function SdkGen(opts: SdkGenOptions) {
370
369
  // generator, so an outdated copy would otherwise be used without a word.
371
370
  await warnCopies(root, model)
372
371
 
373
- const externalOverride = resolveExternalOverride(opts, log)
372
+ const externalOverride = resolveExternalOverride(
373
+ opts, log, Object.keys(model?.main?.[KIT]?.target || {}))
374
374
  // Snapshot the decision before preflight. In particular, do not check a
375
375
  // missing optional destination once for safety and AGAIN before writing:
376
376
  // if it appeared between those checks, the pass could write into content
@@ -380,15 +380,25 @@ function SdkGen(opts: SdkGenOptions) {
380
380
  .map((ext) => ({ ...ext, skip: externalSkipReason(ext, fs) }))
381
381
 
382
382
  checkExternalFolders(external, root, fs)
383
+ refuseRootPlan(model, external.map((ext) => ext.name))
384
+
385
+ // A run override moves a target for this run only, so the committed files
386
+ // keep describing the declared layout: the Root keeps the target, and the
387
+ // components that write the target's own files skip it.
388
+ const declaredOut = external.filter((ext) =>
389
+ '' !== String(model.main[KIT][ext.kind]?.[ext.name]?.output?.path ?? ''))
390
+ const relocated = external.filter((ext) => !declaredOut.includes(ext)).map((ext) => ext.name)
391
+ warnStale(fs, log, root, external.filter((ext) => relocated.includes(ext.name)))
383
392
 
384
393
  const tree: { root?: any } = {}
385
- const jres = await jostraca.generate(jopts, keepingTree(
386
- () => Root({ model: 0 === external.length ? model : withoutExternal(model, external) }), tree))
394
+ const jres = await jostraca.generate({ ...jopts, meta: { ...jopts.meta, relocated } }, keepingTree(
395
+ () => Root({ model: 0 === declaredOut.length ? model : withoutExternal(model, declaredOut) }), tree))
387
396
 
388
397
  showChanges(jopts.log, 'generate-result', jres, Path.dirname(process.cwd()))
398
+ checkDocs(tree.root, folder)
389
399
  pruneGenerated({
390
400
  fs, log, project: root, out: root, jres, claims: claimedFiles(tree.root, folder),
391
- dryrun: !!opts.dryrun,
401
+ dryrun: !!opts.dryrun, keep: relocated.map((name: string) => name + '/'),
392
402
  })
393
403
 
394
404
  // Docgen owns editions, destinations, templates, text QA and deployment.
@@ -404,7 +414,7 @@ function SdkGen(opts: SdkGenOptions) {
404
414
  const gone = false === ext.target.output?.create && !fs.existsSync(ext.folder)
405
415
 
406
416
  if (null != ext.skip || gone) {
407
- log.info({
417
+ log[ext.active ? 'warn' : 'info']({
408
418
  point: 'generate-external-skip', target: ext.name, folder: ext.folder,
409
419
  note: ext.skip ?? (ext.name + ' output folder disappeared after ' +
410
420
  'preflight and output.create=false, not generated')
@@ -433,6 +443,7 @@ function SdkGen(opts: SdkGenOptions) {
433
443
  }), etree))
434
444
 
435
445
  showChanges(jopts.log, 'generate-result', eres, Path.dirname(process.cwd()))
446
+ checkDocs(etree.root, ext.folder)
436
447
  pruneGenerated({
437
448
  fs, log, project: root, out: ext.folder, jres: eres,
438
449
  claims: claimedFiles(etree.root, ext.folder),
@@ -446,6 +457,15 @@ function SdkGen(opts: SdkGenOptions) {
446
457
  }
447
458
 
448
459
 
460
+ // A warning, never a failure: the text that breaks a link or a table may be
461
+ // the spec's, which the project cannot edit.
462
+ function checkDocs(tree: any, out: string) {
463
+ for (const f of docFindings(tree, out, (path: string) => fs.existsSync(path), !!opts.dryrun)) {
464
+ log.warn({ point: f.point, file: f.file, line: f.line, note: f.note })
465
+ }
466
+ }
467
+
468
+
449
469
  // A warning, never a failure: a difference may be a deliberate edit, and a
450
470
  // check that cannot run must not stop a build.
451
471
  async function warnCopies(root: string, model: any) {
@@ -557,6 +577,10 @@ function SdkGen(opts: SdkGenOptions) {
557
577
 
558
578
  model.const = projectConst(model)
559
579
 
580
+ // The model a generate prepares, without the notices, which belong to it.
581
+ guardModel(model)
582
+ applyFacts(model)
583
+
560
584
  return {
561
585
  model,
562
586
  url: path,
@@ -694,52 +718,22 @@ type ExternalPlan = ExternalSpec & {
694
718
 
695
719
 
696
720
  function resolveExternalOverride(
697
- opts: SdkGenOptions, log: any,
721
+ opts: SdkGenOptions, log: any, targets: string[],
698
722
  ): Record<string, ExternalOverride> {
699
- const declared = opts.external || {}
700
- const raw = process.env.SDKGEN_EXTERNAL
701
-
702
- if (null == raw || '' === raw.trim()) {
703
- return declared
704
- }
705
-
706
- let parsed: any
707
-
708
- try {
709
- parsed = JSON.parse(raw)
710
- }
711
- catch (err: any) {
712
- throw new SdkGenError(
713
- 'SDKGEN_EXTERNAL is not valid JSON: ' + (err?.message || err) +
714
- '\n Expected an object keyed by item name, for example:' +
715
- '\n {"seneca-provider":{"path":"../..","sdkrel":".sdksrc/acme-sdk","enclosing":true}}' +
716
- '\n Got: ' + raw.slice(0, 200))
717
- }
718
-
719
- if (null == parsed || 'object' !== typeof parsed || Array.isArray(parsed)) {
720
- throw new SdkGenError(
721
- 'SDKGEN_EXTERNAL must be a JSON OBJECT keyed by item name, for example:' +
722
- '\n {"seneca-provider":{"path":"../..","sdkrel":".sdksrc/acme-sdk","enclosing":true}}' +
723
- '\n Got: ' + raw.slice(0, 200))
724
- }
725
-
726
- const merged: Record<string, ExternalOverride> = { ...declared }
727
-
728
- for (const name of Object.keys(parsed)) {
729
- merged[name] = { ...(declared[name] || {}), ...(parsed[name] || {}) }
730
- }
723
+ const { override, named } = readOverride(opts.external, process.env.SDKGEN_EXTERNAL, targets)
731
724
 
732
725
  // LOUDLY. Generation writing somewhere other than the model says is
733
726
  // exactly the thing whose only previous trace was one INFO line naming a
734
727
  // resolved folder, and that cost a silent green run that emitted nothing.
735
- const named = Object.keys(parsed).sort()
736
- log.info({
737
- point: 'external-override',
738
- items: named.join(','),
739
- note: 'SDKGEN_EXTERNAL overrides the output of: ' + named.join(', '),
740
- })
728
+ if (0 < named.length) {
729
+ log.info({
730
+ point: 'external-override',
731
+ items: named.join(','),
732
+ note: 'SDKGEN_EXTERNAL overrides the output of: ' + named.join(', '),
733
+ })
734
+ }
741
735
 
742
- return merged
736
+ return override
743
737
  }
744
738
 
745
739
 
@@ -757,20 +751,9 @@ function externalItems(
757
751
  // Overrides are keyed by installed target name.
758
752
  const ov = override[name] || {}
759
753
 
760
- // A SHALLOW CLONE, so the override never writes back into the model.
761
- // The in-tree pass still reads it, and `target add` still round-trips
762
- // it to disk; an override is for THIS RUN. Nothing compares these by
763
- // identity — withoutExternal keys by kind:name.
764
- const output = { ...(items[name]?.output || {}) }
765
-
766
- if (null != ov.path && '' !== ov.path) {
767
- output.path = ov.path
768
- // The override relocates this run's output, root placement included.
769
- delete output.root
770
- }
771
- if (null != ov.sdkrel && '' !== ov.sdkrel) {
772
- output.sdkrel = ov.sdkrel
773
- }
754
+ // A copy, so the override never writes back into the model: the
755
+ // in-tree pass still reads it, and `target add` round-trips it to disk.
756
+ const output = runOutput(items[name]?.output, ov)
774
757
 
775
758
  return { kind, name, target: { ...items[name], output }, ov }
776
759
  })
@@ -794,6 +777,21 @@ function externalItems(
794
777
  }
795
778
 
796
779
 
780
+ // A target this run writes elsewhere leaves its earlier in-tree output as it was.
781
+ function warnStale(fs: any, log: any, root: string, moved: ExternalSpec[]): void {
782
+ for (const ext of moved) {
783
+ const folder = Path.join(root, ext.name)
784
+ if (fs.existsSync(folder)) {
785
+ log.warn({
786
+ point: 'generate-external-stale', target: ext.name, folder,
787
+ note: ext.name + '/ holds an earlier in-tree generation, and this run writes ' +
788
+ ext.name + ' to ' + ext.folder + ': the in-tree copy is left as it was, and is stale'
789
+ })
790
+ }
791
+ }
792
+ }
793
+
794
+
797
795
  function externalSkipReason(ext: ExternalSpec, fs: any): string | null {
798
796
  if (!ext.active) {
799
797
  return ext.name + ' inactive, not generated'
@@ -960,6 +958,10 @@ function withoutExternal(
960
958
  kit[kind] = kept
961
959
  }
962
960
 
961
+ if (Array.isArray(kit.fact?.active)) {
962
+ kit.fact = { ...kit.fact, active: kit.fact.active.filter((name: string) => !drop.has('target:' + name)) }
963
+ }
964
+
963
965
  return {
964
966
  ...model,
965
967
  main: { ...model.main, [KIT]: kit },
@@ -1193,6 +1195,8 @@ export {
1193
1195
  entityCollection,
1194
1196
  guardModelNames,
1195
1197
  guardFlowSteps,
1198
+ guardModel,
1199
+ sourceString,
1196
1200
  applyFacts,
1197
1201
  fact,
1198
1202
  projectConst,
package/src/testkit.ts CHANGED
@@ -14,6 +14,11 @@ import { ACTION_MAP } from './action/dispatch'
14
14
 
15
15
  import { KIT } from './types'
16
16
 
17
+ import type { ExternalOverride } from './helpers/placement'
18
+
19
+ import { textGuard } from './helpers/textguard'
20
+ import type { TextFinding, TextGuardOptions } from './helpers/textguard'
21
+
17
22
 
18
23
  // This package's own root — `<...>/node_modules/@voxgig/sdkgen` for a
19
24
  // consumer, or the checkout when sdkgen tests itself. Computed from this
@@ -394,9 +399,17 @@ type GenerateOptions = {
394
399
 
395
400
  root?: any
396
401
 
402
+ // The root documents (README, AGENTS.md, LICENSE and the rest), written as
403
+ // the standard Root writes them when the model's top phase is on. Off by
404
+ // default, so a package's suite sees only its targets' files.
405
+ top?: boolean
406
+
397
407
  allowPlaceholder?: (path: string, token: string) => boolean
398
408
 
399
409
  outside?: string[]
410
+
411
+ // Generate's `external` option: SDKGEN_EXTERNAL for this call alone.
412
+ external?: Record<string, ExternalOverride>
400
413
  }
401
414
 
402
415
 
@@ -439,6 +452,7 @@ async function generateInto(
439
452
  folder: consumer.root,
440
453
  root: '',
441
454
  pino: consumer.log,
455
+ external: opts.external,
442
456
  })
443
457
 
444
458
  const prevcwd = process.cwd()
@@ -448,7 +462,7 @@ async function generateInto(
448
462
  try {
449
463
  res = await sdkgen.generate({
450
464
  model: opts.model,
451
- root: opts.root ?? defaultRoot(),
465
+ root: opts.root ?? defaultRoot({ top: opts.top }),
452
466
  })
453
467
  }
454
468
  finally {
@@ -562,10 +576,11 @@ function layeredFs(mem: any): any {
562
576
  }
563
577
 
564
578
 
565
- function defaultRoot(): any {
579
+ function defaultRoot(opts: { top?: boolean } = {}): any {
566
580
  const { cmp, each, names, Project, Folder } = require('jostraca')
567
581
  const {
568
- Main, Entity, Feature, Test, Readme, AgentGuide, SdkGenError,
582
+ Main, Entity, Feature, Test, Readme, AgentGuide, fact,
583
+ ReadmeTop, AgentGuideTop, License, Security, Changelog, Deploy, PublishWorkflow,
569
584
  } = require('./sdkgen')
570
585
 
571
586
  return cmp(function Root(props: any) {
@@ -580,27 +595,31 @@ function defaultRoot(): any {
580
595
  ctx$.stdrep = ctx$.stdrep || {}
581
596
  names(ctx$.stdrep, model.Name, 'Project' + 'Name')
582
597
 
583
- const target = model.main[KIT].target || {}
584
- const feature = model.main[KIT].feature || {}
585
- const entity = model.main[KIT].entity || {}
598
+ const kit = model.main[KIT]
599
+ const target = kit.target || {}
600
+ const feature = kit.feature || {}
601
+ const entity = kit.entity || {}
586
602
 
587
603
  const active = each(target).filter((t: any) => t && false !== t.active)
588
604
 
589
- const atRoot = active.filter((t: any) => true === t.output?.root)
590
- if (1 < atRoot.length) {
591
- throw new SdkGenError('Only one target can be generated at the ' +
592
- 'project root: ' + atRoot.map((t: any) => t.name).join(', '))
593
- }
594
-
595
605
  Project({}, () => {
606
+ if (true === opts.top && fact(kit, 'top')) {
607
+ ReadmeTop({})
608
+ AgentGuideTop({})
609
+ License({})
610
+ Security({})
611
+ Changelog({})
612
+ Deploy({})
613
+ PublishWorkflow({})
614
+ }
615
+
596
616
  active.map((t: any) => {
597
617
  names(t, t.name)
598
618
 
599
- const phase = t.phase || {}
600
- const on = (n: string) => false !== (phase[n] && phase[n].active)
619
+ const phase = fact(t, 'phase')
601
620
 
602
621
  const phases = () => {
603
- if (on('entity')) {
622
+ if (phase.entity) {
604
623
  each(entity)
605
624
  .filter((e: any) => e && false !== e.active)
606
625
  .map((e: any) => {
@@ -609,7 +628,7 @@ function defaultRoot(): any {
609
628
  })
610
629
  }
611
630
 
612
- if (on('feature')) {
631
+ if (phase.feature) {
613
632
  each(feature)
614
633
  .filter((f: any) => f && f.active)
615
634
  .map((f: any) => {
@@ -620,12 +639,12 @@ function defaultRoot(): any {
620
639
 
621
640
  Main({ target: t })
622
641
 
623
- if (on('readme')) Readme({ target: t })
624
- if (on('agentguide')) AgentGuide({ target: t })
625
- if (on('test')) Test({ target: t })
642
+ if (phase.readme) Readme({ target: t })
643
+ if (phase.agentguide) AgentGuide({ target: t })
644
+ if (phase.test) Test({ target: t })
626
645
  }
627
646
 
628
- if (true === t.output?.root) {
647
+ if ('root' === fact(t, 'place')) {
629
648
  phases()
630
649
  }
631
650
  else {
@@ -650,6 +669,8 @@ export type {
650
669
  StageOptions,
651
670
  GenerateOptions,
652
671
  GenerateResult,
672
+ TextFinding,
673
+ TextGuardOptions,
653
674
  }
654
675
 
655
676
  export {
@@ -659,4 +680,5 @@ export {
659
680
  stageConsumer,
660
681
  generateInto,
661
682
  manifestParity,
683
+ textGuard,
662
684
  }
package/src/utility.ts CHANGED
@@ -335,7 +335,8 @@ function configDefinition(model: any, targetname?: string): { def: any, json: st
335
335
 
336
336
  const authActive = isAuthActive(model)
337
337
  const authPrefix = resolveAuthPrefix(model)
338
- const authBasic = isHttpBasicAuth(model)
338
+ // PrepareAuth composes Basic only in the header; elsewhere nothing reads the flag.
339
+ const authBasic = isHttpBasicAuth(model) && 'header' === resolveAuthIn(model)
339
340
 
340
341
  let baseUrl = ''
341
342
  try { baseUrl = getModelPath(model, `main.${KIT}.info.servers.0.url`) } catch (_e) { }