@voxgig/sdkgen 4.44.3 → 4.46.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 (161) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/dist/action/check.js +15 -0
  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 +21 -2
  7. package/dist/action/doctor.js +166 -9
  8. package/dist/action/doctor.js.map +1 -1
  9. package/dist/action/package.js +9 -0
  10. package/dist/action/package.js.map +1 -1
  11. package/dist/action/remove.js +2 -1
  12. package/dist/action/remove.js.map +1 -1
  13. package/dist/action/target.d.ts +2 -1
  14. package/dist/action/target.js +50 -11
  15. package/dist/action/target.js.map +1 -1
  16. package/dist/cmp/AgentGuide.js +19 -8
  17. package/dist/cmp/AgentGuide.js.map +1 -1
  18. package/dist/cmp/AgentGuideContent.d.ts +6 -4
  19. package/dist/cmp/AgentGuideContent.js +51 -32
  20. package/dist/cmp/AgentGuideContent.js.map +1 -1
  21. package/dist/cmp/AgentGuideFeature.js +7 -4
  22. package/dist/cmp/AgentGuideFeature.js.map +1 -1
  23. package/dist/cmp/AgentGuideTop.js +84 -46
  24. package/dist/cmp/AgentGuideTop.js.map +1 -1
  25. package/dist/cmp/Changelog.js +12 -1
  26. package/dist/cmp/Changelog.js.map +1 -1
  27. package/dist/cmp/Deploy.js +22 -20
  28. package/dist/cmp/Deploy.js.map +1 -1
  29. package/dist/cmp/ExternalTarget.js +5 -5
  30. package/dist/cmp/ExternalTarget.js.map +1 -1
  31. package/dist/cmp/Feature.js +10 -3
  32. package/dist/cmp/Feature.js.map +1 -1
  33. package/dist/cmp/FeatureDocs.d.ts +6 -4
  34. package/dist/cmp/FeatureDocs.js +14 -39
  35. package/dist/cmp/FeatureDocs.js.map +1 -1
  36. package/dist/cmp/FeatureHook.d.ts +7 -1
  37. package/dist/cmp/FeatureHook.js +34 -1
  38. package/dist/cmp/FeatureHook.js.map +1 -1
  39. package/dist/cmp/PublishWorkflow.js +30 -6
  40. package/dist/cmp/PublishWorkflow.js.map +1 -1
  41. package/dist/cmp/ReadmeErrors.js +521 -18
  42. package/dist/cmp/ReadmeErrors.js.map +1 -1
  43. package/dist/cmp/ReadmeExplanation.js +280 -44
  44. package/dist/cmp/ReadmeExplanation.js.map +1 -1
  45. package/dist/cmp/ReadmeFeatures.js +16 -7
  46. package/dist/cmp/ReadmeFeatures.js.map +1 -1
  47. package/dist/cmp/ReadmeIntro.js +3 -2
  48. package/dist/cmp/ReadmeIntro.js.map +1 -1
  49. package/dist/cmp/ReadmeRefFeatures.js +34 -24
  50. package/dist/cmp/ReadmeRefFeatures.js.map +1 -1
  51. package/dist/cmp/ReadmeStation.js +11 -8
  52. package/dist/cmp/ReadmeStation.js.map +1 -1
  53. package/dist/cmp/ReadmeTop.js +472 -373
  54. package/dist/cmp/ReadmeTop.js.map +1 -1
  55. package/dist/cmp/ReadmeUnions.js +8 -2
  56. package/dist/cmp/ReadmeUnions.js.map +1 -1
  57. package/dist/cmp/Security.js +3 -2
  58. package/dist/cmp/Security.js.map +1 -1
  59. package/dist/helpers/applicability.d.ts +2 -1
  60. package/dist/helpers/applicability.js +26 -0
  61. package/dist/helpers/applicability.js.map +1 -1
  62. package/dist/helpers/copymerge.d.ts +3 -0
  63. package/dist/helpers/copymerge.js +43 -10
  64. package/dist/helpers/copymerge.js.map +1 -1
  65. package/dist/helpers/doccheck.d.ts +11 -0
  66. package/dist/helpers/doccheck.js +146 -0
  67. package/dist/helpers/doccheck.js.map +1 -0
  68. package/dist/helpers/doctext.d.ts +11 -0
  69. package/dist/helpers/doctext.js +84 -0
  70. package/dist/helpers/doctext.js.map +1 -0
  71. package/dist/helpers/exampleCall.d.ts +16 -0
  72. package/dist/helpers/exampleCall.js +334 -0
  73. package/dist/helpers/exampleCall.js.map +1 -0
  74. package/dist/helpers/exportnames.d.ts +4 -0
  75. package/dist/helpers/exportnames.js +35 -0
  76. package/dist/helpers/exportnames.js.map +1 -0
  77. package/dist/helpers/facts.d.ts +4 -0
  78. package/dist/helpers/facts.js +92 -0
  79. package/dist/helpers/facts.js.map +1 -0
  80. package/dist/helpers/modelcheck.d.ts +2 -1
  81. package/dist/helpers/modelcheck.js +13 -0
  82. package/dist/helpers/modelcheck.js.map +1 -1
  83. package/dist/helpers/opExample.d.ts +9 -2
  84. package/dist/helpers/opExample.js +22 -2
  85. package/dist/helpers/opExample.js.map +1 -1
  86. package/dist/helpers/opShape.d.ts +2 -1
  87. package/dist/helpers/opShape.js +12 -0
  88. package/dist/helpers/opShape.js.map +1 -1
  89. package/dist/helpers/packageMeta.js +21 -8
  90. package/dist/helpers/packageMeta.js.map +1 -1
  91. package/dist/helpers/semver.d.ts +2 -1
  92. package/dist/helpers/semver.js +7 -0
  93. package/dist/helpers/semver.js.map +1 -1
  94. package/dist/helpers/shipped.d.ts +2 -1
  95. package/dist/helpers/shipped.js +4 -0
  96. package/dist/helpers/shipped.js.map +1 -1
  97. package/dist/sdkgen.d.ts +2 -1
  98. package/dist/sdkgen.js +29 -6
  99. package/dist/sdkgen.js.map +1 -1
  100. package/dist/testkit.d.ts +1 -0
  101. package/dist/testkit.js +23 -19
  102. package/dist/testkit.js.map +1 -1
  103. package/dist/tsconfig.tsbuildinfo +1 -1
  104. package/dist/utility.js +2 -1
  105. package/dist/utility.js.map +1 -1
  106. package/model/fact.aontu +59 -0
  107. package/model/sdkgen.aontu +6 -2
  108. package/package.json +3 -1
  109. package/project/.sdk/src/cmp/c/ReadmeQuick_c.ts +1 -1
  110. package/project/.sdk/src/cmp/c/ReadmeTopQuick_c.ts +1 -1
  111. package/project/.sdk/src/cmp/clojure/ReadmeEntity_clojure.ts +12 -3
  112. package/project/.sdk/src/cmp/scala/ReadmeRef_scala.ts +4 -1
  113. package/project/.sdk/src/cmp/swift/ReadmeQuick_swift.ts +1 -0
  114. package/project/.sdk/src/cmp/swift/ReadmeRef_swift.ts +3 -0
  115. package/project/.sdk/src/cmp/swift/ReadmeTopQuick_swift.ts +2 -1
  116. package/project/.sdk/src/cmp/zig/ReadmeOptions_zig.ts +1 -1
  117. package/project/.sdk/src/cmp/zig/ReadmeQuick_zig.ts +2 -2
  118. package/project/.sdk/src/cmp/zig/ReadmeTopQuick_zig.ts +2 -2
  119. package/project/sdkgen-package.json +1 -1
  120. package/src/action/check.ts +21 -0
  121. package/src/action/copies.ts +2 -0
  122. package/src/action/doctor.ts +244 -13
  123. package/src/action/package.ts +10 -0
  124. package/src/action/remove.ts +2 -1
  125. package/src/action/target.ts +66 -15
  126. package/src/cmp/AgentGuide.ts +24 -10
  127. package/src/cmp/AgentGuideContent.ts +53 -32
  128. package/src/cmp/AgentGuideFeature.ts +8 -5
  129. package/src/cmp/AgentGuideTop.ts +108 -47
  130. package/src/cmp/Changelog.ts +13 -2
  131. package/src/cmp/Deploy.ts +23 -21
  132. package/src/cmp/ExternalTarget.ts +6 -6
  133. package/src/cmp/Feature.ts +11 -4
  134. package/src/cmp/FeatureDocs.ts +21 -40
  135. package/src/cmp/FeatureHook.ts +38 -1
  136. package/src/cmp/PublishWorkflow.ts +33 -7
  137. package/src/cmp/ReadmeErrors.ts +555 -25
  138. package/src/cmp/ReadmeExplanation.ts +316 -52
  139. package/src/cmp/ReadmeFeatures.ts +18 -8
  140. package/src/cmp/ReadmeIntro.ts +3 -2
  141. package/src/cmp/ReadmeRefFeatures.ts +39 -27
  142. package/src/cmp/ReadmeStation.ts +12 -14
  143. package/src/cmp/ReadmeTop.ts +528 -387
  144. package/src/cmp/ReadmeUnions.ts +10 -2
  145. package/src/cmp/Security.ts +3 -2
  146. package/src/helpers/applicability.ts +28 -0
  147. package/src/helpers/copymerge.ts +58 -10
  148. package/src/helpers/doccheck.ts +174 -0
  149. package/src/helpers/doctext.ts +113 -0
  150. package/src/helpers/exampleCall.ts +415 -0
  151. package/src/helpers/exportnames.ts +47 -0
  152. package/src/helpers/facts.ts +119 -0
  153. package/src/helpers/modelcheck.ts +16 -0
  154. package/src/helpers/opExample.ts +34 -2
  155. package/src/helpers/opShape.ts +13 -0
  156. package/src/helpers/packageMeta.ts +21 -8
  157. package/src/helpers/semver.ts +9 -0
  158. package/src/helpers/shipped.ts +5 -0
  159. package/src/sdkgen.ts +31 -2
  160. package/src/testkit.ts +30 -20
  161. package/src/utility.ts +2 -1
@@ -186,7 +186,7 @@ function seededList(lang: LiteralLang, ent: any, idF: string | null, key: string
186
186
 
187
187
 
188
188
  // An update or patch addressed only by id and route also changes a field.
189
- function dataArg(lang: LiteralLang, ent: any, op: string, idF: string | null): string {
189
+ function dataItems(ent: any, op: string, idF: string | null): any[] {
190
190
  const routed = new Set(opParams(ent?.op?.[op]).map((p: any) => p.n))
191
191
  const addresses = (it: any) => it.name === idF || it.name === 'id' || routed.has(it.name)
192
192
  const items = requestExampleItems(ent, op)
@@ -195,7 +195,12 @@ function dataArg(lang: LiteralLang, ent: any, op: string, idF: string | null): s
195
195
  const required = items.filter((it: any) => !it.optional)
196
196
  const changed = ('update' === op || 'patch' === op) && required.every(addresses) ?
197
197
  items.filter((it: any) => it.optional && !addresses(it)).slice(0, 1) : []
198
- const chosen = required.length ? [...required, ...changed] : items.slice(0, 3)
198
+ return required.length ? [...required, ...changed] : items.slice(0, 3)
199
+ }
200
+
201
+
202
+ function dataArg(lang: LiteralLang, ent: any, op: string, idF: string | null): string {
203
+ const chosen = dataItems(ent, op, idF)
199
204
  const pairs = chosen.map((it: any) => litPair(lang, it.name, litFor(lang, it.type)))
200
205
  switch (lang) {
201
206
  case 'php': return `[${pairs.join(', ')}]`
@@ -206,6 +211,30 @@ function dataArg(lang: LiteralLang, ent: any, op: string, idF: string | null): s
206
211
  }
207
212
 
208
213
 
214
+ type ArgItem = {
215
+ name: string
216
+ type: any
217
+ id: boolean
218
+ }
219
+
220
+
221
+ // The members a primary-op example sends: those matchArg, listMatchArg and
222
+ // dataArg write, each marked when it carries the entity's id.
223
+ function exampleArgItems(ent: any, op: string, idF: string | null): ArgItem[] {
224
+ const item = (it: any, id: boolean) => ({ name: it.name, type: it.type, id })
225
+ if ('list' === op) {
226
+ return requiredItems(ent, 'list').map((it: any) => item(it, false))
227
+ }
228
+ if ('load' === op || 'remove' === op) {
229
+ return requiredItems(ent, op).map((it: any) => item(it, it.name === idF))
230
+ }
231
+ if ('create' === op || 'update' === op || 'patch' === op) {
232
+ return dataItems(ent, op, idF).map((it: any) => item(it, false))
233
+ }
234
+ return []
235
+ }
236
+
237
+
209
238
  type PrimaryCall = {
210
239
  expr: string
211
240
  resultVar: string
@@ -275,6 +304,8 @@ export {
275
304
  listMatchArg,
276
305
  seededList,
277
306
  dataArg,
307
+ dataItems,
308
+ exampleArgItems,
278
309
  javaMap,
279
310
  javaMapOf,
280
311
  javaMapItems,
@@ -284,6 +315,7 @@ export {
284
315
  }
285
316
 
286
317
  export type {
318
+ ArgItem,
287
319
  ExampleLang,
288
320
  LiteralLang,
289
321
  PrimaryCall,
@@ -427,6 +427,18 @@ function introOps(model: any): string[] {
427
427
  }
428
428
 
429
429
 
430
+ // The operations the active entities have a generated method for, in
431
+ // canonical order; none when no entity has one.
432
+ function generatedOps(model: any): string[] {
433
+ const entity = getModelPath(model, `main.${KIT}.entity`, { required: false }) || {}
434
+ const found = new Set<string>()
435
+ for (const e of Object.values(entity) as any[]) {
436
+ for (const o of entityOps(e)) found.add(o)
437
+ }
438
+ return CANON_OP_ORDER.filter((o) => found.has(o))
439
+ }
440
+
441
+
430
442
  type UngeneratedOp = { entity: string, op: string, points: string[] }
431
443
 
432
444
 
@@ -792,6 +804,7 @@ export {
792
804
  entityRecordIdField,
793
805
  entityOps,
794
806
  introOps,
807
+ generatedOps,
795
808
  invalidRequest,
796
809
  entityPrimaryOp,
797
810
  pickExampleEntity,
@@ -171,11 +171,12 @@ function goPackageIdent(model: any, target: string): string {
171
171
  }
172
172
 
173
173
 
174
+ // A registry named `none` is no registry: c, cpp and zig declare it.
174
175
  function registryState(model: any, target: string): 'tag' | 'pending' | 'active' | 'inactive' {
175
176
  const eco = originName(model, target)
176
177
  if ('go' === eco || 'go-cli' === eco || 'go-mcp' === eco) return 'tag'
177
178
  const reg = model?.main?.[KIT]?.target?.[target]?.publish?.registry
178
- if (null == reg || '' === (reg.name || '')) return 'tag'
179
+ if (null == reg || '' === registryName(model, target)) return 'tag'
179
180
  if (true === reg.active) return 'active'
180
181
  const s = reg.state
181
182
  if ('active' === s || 'inactive' === s || 'pending' === s) return s
@@ -193,14 +194,14 @@ function isPublished(model: any, target: string): boolean {
193
194
  // for tag-only ports. Used in the "not yet on <registry>" pending message.
194
195
  function registryName(model: any, target: string): string {
195
196
  const reg = model?.main?.[KIT]?.target?.[target]?.publish?.registry
196
- return (reg && reg.name) ? String(reg.name) : ''
197
+ const name = (reg && reg.name) ? String(reg.name) : ''
198
+ return 'none' === name ? '' : name
197
199
  }
198
200
 
199
- // The vendor / git-tag install pointer for a NOT-yet-published target. For
200
- // go this is the canonical install (`go get <module>@latest`, which the Go
201
- // proxy resolves from the `go/vX.Y.Z` tag); go-cli and go-mcp get ''. For registry
202
- // ports it is a short "not yet on <registry> — install from the git tag"
203
- // pointer carrying the tags URL.
201
+ // The install route for a target not on a registry: `go get <module>@latest`
202
+ // for go, resolved by the proxy from the `go/vX.Y.Z` tag. go-cli, go-mcp and a
203
+ // port with no registry get '', and their README's build steps are the route.
204
+ // A declared registry gets a "not yet on <registry>" pointer to the git tag.
204
205
  function vendorCommand(model: any, target: string): string {
205
206
  const { tagsUrl } = repoInfo(model)
206
207
  switch (originName(model, target)) {
@@ -218,7 +219,7 @@ function vendorCommand(model: any, target: string): string {
218
219
  return ''
219
220
  default: {
220
221
  const reg = registryName(model, target)
221
- return `not yet on ${reg || 'the registry'} — install from the git tag: ${tagsUrl}`
222
+ return '' === reg ? '' : `not yet on ${reg} — install from the git tag: ${tagsUrl}`
222
223
  }
223
224
  }
224
225
  }
@@ -317,6 +318,18 @@ function installCommand(model: any, target: string): string {
317
318
  return `luarocks install ${packageName(model, target)}`
318
319
  case 'go':
319
320
  return `go get ${packageName(model, target)}`
321
+ case 'rust':
322
+ return `cargo add ${packageName(model, target)}`
323
+ case 'csharp':
324
+ return `dotnet add package ${packageName(model, target)}`
325
+ case 'perl':
326
+ return `cpanm ${packageName(model, target)}`
327
+ case 'ocaml':
328
+ return `opam install ${packageName(model, target)}`
329
+ // No package manager installs these: the release tag is the route.
330
+ case 'c':
331
+ case 'zig':
332
+ return `install from the git tag: ${repoInfo(model).tagsUrl}`
320
333
  default:
321
334
  return ''
322
335
  }
@@ -86,6 +86,14 @@ function satisfiesOne(version: Parts, comparator: string): boolean | undefined {
86
86
  }
87
87
 
88
88
 
89
+ // Undefined when either is not a plain version, so no order is claimed.
90
+ function compareVersions(a: string, b: string): number | undefined {
91
+ const pa = parseVersion(a)
92
+ const pb = parseVersion(b)
93
+ return null == pa || null == pb ? undefined : compare(pa, pb)
94
+ }
95
+
96
+
89
97
  // Does `version` satisfy `range`?
90
98
  //
91
99
  // `true` / `false` / `undefined` — see the note at the top: undefined means
@@ -149,4 +157,5 @@ function satisfies(version: string, range: string): boolean | undefined {
149
157
  export {
150
158
  satisfies,
151
159
  parseVersion,
160
+ compareVersions,
152
161
  }
@@ -19,8 +19,13 @@ function scaffoldFolder(): string {
19
19
  }
20
20
 
21
21
 
22
+ function factRulesFile(): string {
23
+ return Path.join(packageRoot(), 'model', 'fact.aontu')
24
+ }
25
+
22
26
  export {
23
27
  packageRoot,
24
28
  schemaFile,
25
29
  scaffoldFolder,
30
+ factRulesFile,
26
31
  }
package/src/sdkgen.ts CHANGED
@@ -65,6 +65,8 @@ import { getMatchEntries } from './helpers/getMatchEntries'
65
65
  import { collectDeps } from './helpers/collectDeps'
66
66
  import { guardModelNames } from './helpers/modelNames'
67
67
  import { guardFlowSteps } from './helpers/flowGuard'
68
+ import { applyFacts, fact, refuseRootPlan } from './helpers/facts'
69
+ import { docFindings } from './helpers/doccheck'
68
70
  import { claimedFiles, pruneGenerated } from './helpers/generated'
69
71
  import { cmp as labelledCmp } from './helpers/component'
70
72
  import type { DepEntry } from './helpers/collectDeps'
@@ -332,6 +334,8 @@ function SdkGen(opts: SdkGenOptions) {
332
334
  // generated test makes it; see helpers/flowGuard.
333
335
  guardFlowSteps(model, log)
334
336
 
337
+ applyFacts(model)
338
+
335
339
  let Root = spec.root
336
340
 
337
341
  if (null == Root && null != config?.root) {
@@ -367,7 +371,8 @@ function SdkGen(opts: SdkGenOptions) {
367
371
  // generator, so an outdated copy would otherwise be used without a word.
368
372
  await warnCopies(root, model)
369
373
 
370
- const externalOverride = resolveExternalOverride(opts, log)
374
+ const externalOverride = resolveExternalOverride(
375
+ opts, log, Object.keys(model?.main?.[KIT]?.target || {}))
371
376
  // Snapshot the decision before preflight. In particular, do not check a
372
377
  // missing optional destination once for safety and AGAIN before writing:
373
378
  // if it appeared between those checks, the pass could write into content
@@ -377,12 +382,14 @@ function SdkGen(opts: SdkGenOptions) {
377
382
  .map((ext) => ({ ...ext, skip: externalSkipReason(ext, fs) }))
378
383
 
379
384
  checkExternalFolders(external, root, fs)
385
+ refuseRootPlan(model, external.map((ext) => ext.name))
380
386
 
381
387
  const tree: { root?: any } = {}
382
388
  const jres = await jostraca.generate(jopts, keepingTree(
383
389
  () => Root({ model: 0 === external.length ? model : withoutExternal(model, external) }), tree))
384
390
 
385
391
  showChanges(jopts.log, 'generate-result', jres, Path.dirname(process.cwd()))
392
+ checkDocs(tree.root, folder)
386
393
  pruneGenerated({
387
394
  fs, log, project: root, out: root, jres, claims: claimedFiles(tree.root, folder),
388
395
  dryrun: !!opts.dryrun,
@@ -430,6 +437,7 @@ function SdkGen(opts: SdkGenOptions) {
430
437
  }), etree))
431
438
 
432
439
  showChanges(jopts.log, 'generate-result', eres, Path.dirname(process.cwd()))
440
+ checkDocs(etree.root, ext.folder)
433
441
  pruneGenerated({
434
442
  fs, log, project: root, out: ext.folder, jres: eres,
435
443
  claims: claimedFiles(etree.root, ext.folder),
@@ -443,6 +451,15 @@ function SdkGen(opts: SdkGenOptions) {
443
451
  }
444
452
 
445
453
 
454
+ // A warning, never a failure: the text that breaks a link or a table may be
455
+ // the spec's, which the project cannot edit.
456
+ function checkDocs(tree: any, out: string) {
457
+ for (const f of docFindings(tree, out, (path: string) => fs.existsSync(path), !!opts.dryrun)) {
458
+ log.warn({ point: f.point, file: f.file, line: f.line, note: f.note })
459
+ }
460
+ }
461
+
462
+
446
463
  // A warning, never a failure: a difference may be a deliberate edit, and a
447
464
  // check that cannot run must not stop a build.
448
465
  async function warnCopies(root: string, model: any) {
@@ -691,7 +708,7 @@ type ExternalPlan = ExternalSpec & {
691
708
 
692
709
 
693
710
  function resolveExternalOverride(
694
- opts: SdkGenOptions, log: any,
711
+ opts: SdkGenOptions, log: any, targets: string[],
695
712
  ): Record<string, ExternalOverride> {
696
713
  const declared = opts.external || {}
697
714
  const raw = process.env.SDKGEN_EXTERNAL
@@ -720,6 +737,16 @@ function resolveExternalOverride(
720
737
  '\n Got: ' + raw.slice(0, 200))
721
738
  }
722
739
 
740
+ // A misspelled name would otherwise change nothing and still be logged as
741
+ // an override.
742
+ const unknown = Object.keys(parsed).filter((name: string) => !targets.includes(name)).sort()
743
+ if (0 < unknown.length) {
744
+ throw new SdkGenError(
745
+ 'SDKGEN_EXTERNAL names ' + unknown.join(', ') + ', which ' +
746
+ (1 === unknown.length ? 'is not a target' : 'are not targets') + ' of this model' +
747
+ '\n Its targets are: ' + [...targets].sort().join(', '))
748
+ }
749
+
723
750
  const merged: Record<string, ExternalOverride> = { ...declared }
724
751
 
725
752
  for (const name of Object.keys(parsed)) {
@@ -1190,6 +1217,8 @@ export {
1190
1217
  entityCollection,
1191
1218
  guardModelNames,
1192
1219
  guardFlowSteps,
1220
+ applyFacts,
1221
+ fact,
1193
1222
  projectConst,
1194
1223
  isReservedName,
1195
1224
  safeVarName,
package/src/testkit.ts CHANGED
@@ -394,6 +394,11 @@ type GenerateOptions = {
394
394
 
395
395
  root?: any
396
396
 
397
+ // The root documents (README, AGENTS.md, LICENSE and the rest), written as
398
+ // the standard Root writes them when the model's top phase is on. Off by
399
+ // default, so a package's suite sees only its targets' files.
400
+ top?: boolean
401
+
397
402
  allowPlaceholder?: (path: string, token: string) => boolean
398
403
 
399
404
  outside?: string[]
@@ -448,7 +453,7 @@ async function generateInto(
448
453
  try {
449
454
  res = await sdkgen.generate({
450
455
  model: opts.model,
451
- root: opts.root ?? defaultRoot(),
456
+ root: opts.root ?? defaultRoot({ top: opts.top }),
452
457
  })
453
458
  }
454
459
  finally {
@@ -562,10 +567,11 @@ function layeredFs(mem: any): any {
562
567
  }
563
568
 
564
569
 
565
- function defaultRoot(): any {
570
+ function defaultRoot(opts: { top?: boolean } = {}): any {
566
571
  const { cmp, each, names, Project, Folder } = require('jostraca')
567
572
  const {
568
- Main, Entity, Feature, Test, Readme, AgentGuide, SdkGenError,
573
+ Main, Entity, Feature, Test, Readme, AgentGuide, fact,
574
+ ReadmeTop, AgentGuideTop, License, Security, Changelog, Deploy, PublishWorkflow,
569
575
  } = require('./sdkgen')
570
576
 
571
577
  return cmp(function Root(props: any) {
@@ -580,27 +586,31 @@ function defaultRoot(): any {
580
586
  ctx$.stdrep = ctx$.stdrep || {}
581
587
  names(ctx$.stdrep, model.Name, 'Project' + 'Name')
582
588
 
583
- const target = model.main[KIT].target || {}
584
- const feature = model.main[KIT].feature || {}
585
- const entity = model.main[KIT].entity || {}
589
+ const kit = model.main[KIT]
590
+ const target = kit.target || {}
591
+ const feature = kit.feature || {}
592
+ const entity = kit.entity || {}
586
593
 
587
594
  const active = each(target).filter((t: any) => t && false !== t.active)
588
595
 
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
596
  Project({}, () => {
597
+ if (true === opts.top && fact(kit, 'top')) {
598
+ ReadmeTop({})
599
+ AgentGuideTop({})
600
+ License({})
601
+ Security({})
602
+ Changelog({})
603
+ Deploy({})
604
+ PublishWorkflow({})
605
+ }
606
+
596
607
  active.map((t: any) => {
597
608
  names(t, t.name)
598
609
 
599
- const phase = t.phase || {}
600
- const on = (n: string) => false !== (phase[n] && phase[n].active)
610
+ const phase = fact(t, 'phase')
601
611
 
602
612
  const phases = () => {
603
- if (on('entity')) {
613
+ if (phase.entity) {
604
614
  each(entity)
605
615
  .filter((e: any) => e && false !== e.active)
606
616
  .map((e: any) => {
@@ -609,7 +619,7 @@ function defaultRoot(): any {
609
619
  })
610
620
  }
611
621
 
612
- if (on('feature')) {
622
+ if (phase.feature) {
613
623
  each(feature)
614
624
  .filter((f: any) => f && f.active)
615
625
  .map((f: any) => {
@@ -620,12 +630,12 @@ function defaultRoot(): any {
620
630
 
621
631
  Main({ target: t })
622
632
 
623
- if (on('readme')) Readme({ target: t })
624
- if (on('agentguide')) AgentGuide({ target: t })
625
- if (on('test')) Test({ target: t })
633
+ if (phase.readme) Readme({ target: t })
634
+ if (phase.agentguide) AgentGuide({ target: t })
635
+ if (phase.test) Test({ target: t })
626
636
  }
627
637
 
628
- if (true === t.output?.root) {
638
+ if ('root' === fact(t, 'place')) {
629
639
  phases()
630
640
  }
631
641
  else {
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) { }