@voxgig/sdkgen 4.45.0 → 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 (156) 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 +5 -3
  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 +2 -1
  78. package/dist/helpers/facts.js +37 -2
  79. package/dist/helpers/facts.js.map +1 -1
  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/sdkgen.js +21 -2
  95. package/dist/sdkgen.js.map +1 -1
  96. package/dist/testkit.d.ts +1 -0
  97. package/dist/testkit.js +23 -19
  98. package/dist/testkit.js.map +1 -1
  99. package/dist/tsconfig.tsbuildinfo +1 -1
  100. package/dist/utility.js +2 -1
  101. package/dist/utility.js.map +1 -1
  102. package/model/fact.aontu +44 -0
  103. package/model/sdkgen.aontu +6 -2
  104. package/package.json +3 -1
  105. package/project/.sdk/src/cmp/c/ReadmeQuick_c.ts +1 -1
  106. package/project/.sdk/src/cmp/c/ReadmeTopQuick_c.ts +1 -1
  107. package/project/.sdk/src/cmp/clojure/ReadmeEntity_clojure.ts +12 -3
  108. package/project/.sdk/src/cmp/scala/ReadmeRef_scala.ts +4 -1
  109. package/project/.sdk/src/cmp/swift/ReadmeQuick_swift.ts +1 -0
  110. package/project/.sdk/src/cmp/swift/ReadmeRef_swift.ts +3 -0
  111. package/project/.sdk/src/cmp/swift/ReadmeTopQuick_swift.ts +2 -1
  112. package/project/.sdk/src/cmp/zig/ReadmeOptions_zig.ts +1 -1
  113. package/project/.sdk/src/cmp/zig/ReadmeQuick_zig.ts +2 -2
  114. package/project/.sdk/src/cmp/zig/ReadmeTopQuick_zig.ts +2 -2
  115. package/project/sdkgen-package.json +1 -1
  116. package/src/action/check.ts +21 -0
  117. package/src/action/copies.ts +2 -0
  118. package/src/action/doctor.ts +244 -13
  119. package/src/action/package.ts +10 -0
  120. package/src/action/remove.ts +2 -1
  121. package/src/action/target.ts +66 -15
  122. package/src/cmp/AgentGuide.ts +24 -10
  123. package/src/cmp/AgentGuideContent.ts +53 -32
  124. package/src/cmp/AgentGuideFeature.ts +6 -4
  125. package/src/cmp/AgentGuideTop.ts +108 -47
  126. package/src/cmp/Changelog.ts +13 -2
  127. package/src/cmp/Deploy.ts +23 -21
  128. package/src/cmp/ExternalTarget.ts +6 -6
  129. package/src/cmp/Feature.ts +11 -4
  130. package/src/cmp/FeatureDocs.ts +21 -40
  131. package/src/cmp/FeatureHook.ts +38 -1
  132. package/src/cmp/PublishWorkflow.ts +33 -7
  133. package/src/cmp/ReadmeErrors.ts +555 -25
  134. package/src/cmp/ReadmeExplanation.ts +316 -52
  135. package/src/cmp/ReadmeFeatures.ts +18 -8
  136. package/src/cmp/ReadmeIntro.ts +3 -2
  137. package/src/cmp/ReadmeRefFeatures.ts +39 -27
  138. package/src/cmp/ReadmeStation.ts +12 -14
  139. package/src/cmp/ReadmeTop.ts +528 -387
  140. package/src/cmp/ReadmeUnions.ts +10 -2
  141. package/src/cmp/Security.ts +3 -2
  142. package/src/helpers/applicability.ts +28 -0
  143. package/src/helpers/copymerge.ts +58 -10
  144. package/src/helpers/doccheck.ts +174 -0
  145. package/src/helpers/doctext.ts +113 -0
  146. package/src/helpers/exampleCall.ts +415 -0
  147. package/src/helpers/exportnames.ts +47 -0
  148. package/src/helpers/facts.ts +47 -2
  149. package/src/helpers/modelcheck.ts +16 -0
  150. package/src/helpers/opExample.ts +34 -2
  151. package/src/helpers/opShape.ts +13 -0
  152. package/src/helpers/packageMeta.ts +21 -8
  153. package/src/helpers/semver.ts +9 -0
  154. package/src/sdkgen.ts +27 -3
  155. package/src/testkit.ts +30 -20
  156. package/src/utility.ts +2 -1
@@ -1,4 +1,5 @@
1
1
  import { featureApplies } from '../helpers/applicability'
2
+ import { fact } from '../helpers/facts'
2
3
 
3
4
  import { each } from 'jostraca'
4
5
 
@@ -10,9 +11,13 @@ type FeatureDoc = {
10
11
  name: string
11
12
  Name: string
12
13
  title: string
14
+ titleCell: string
13
15
  transport: string
14
16
  wraps: boolean
15
- options: Array<{ name: string, value: string }>
17
+ on: boolean
18
+ // Active hooks, which a wrapping feature such as cost may also declare.
19
+ hooks: string[]
20
+ options: Array<{ name: string, code: string }>
16
21
 
17
22
  extras: Array<{ name: string, type: string }>
18
23
  }
@@ -23,40 +28,6 @@ function isWrapping(feat: any): boolean {
23
28
  }
24
29
 
25
30
 
26
- // A struct.validate sentinel as a reader's word for it: '`$FUNCTION`' ->
27
- // 'function'. A union renders its members, so netsim's latency reads
28
- // 'number | map'. Anything unrecognised renders verbatim rather than being
29
- // dropped — a doc table that silently omits an option is the failure this
30
- // whole path exists to fix.
31
- function sentinelName(v: any): string {
32
- if (Array.isArray(v)) {
33
- const members = v.slice(1).map((m: any) => sentinelName(m))
34
- .filter((m: string) => 'one' !== m)
35
- return 0 === members.length ? 'any' : members.join(' | ')
36
- }
37
-
38
- if ('string' !== typeof v) {
39
- return 'any'
40
- }
41
-
42
- const bare = v.replace(/[`$]/g, '').trim().toLowerCase()
43
- return '' === bare ? 'any' : bare
44
- }
45
-
46
-
47
- function renderValue(v: any): string {
48
- if (null == v) { return '' }
49
- if (Array.isArray(v)) { return '[' + v.map((x) => renderValue(x)).join(', ') + ']' }
50
- if ('object' === typeof v) {
51
- const keys = Object.keys(v)
52
- return 0 === keys.length ? '{}' :
53
- '{' + keys.map((k) => k + ': ' + renderValue(v[k])).join(', ') + '}'
54
- }
55
- if ('string' === typeof v) { return `'${v}'` }
56
- return String(v)
57
- }
58
-
59
-
60
31
  function featureDocs(model: any, target?: any): FeatureDoc[] {
61
32
  const feature = getModelPath(model, `main.${KIT}.feature`)
62
33
 
@@ -67,20 +38,23 @@ function featureDocs(model: any, target?: any): FeatureDoc[] {
67
38
  const opts = (f.config && f.config.options) || {}
68
39
  const options = Object.keys(opts).sort().map((k) => ({
69
40
  name: k,
70
- value: renderValue(opts[k]),
41
+ code: fact(f, 'option')[k].value.codecell,
71
42
  }))
72
43
 
73
44
  const extra = (f.config && f.config.optspec) || {}
74
45
  const extras = Object.keys(extra)
75
46
  .filter((k) => null == opts[k])
76
47
  .sort()
77
- .map((k) => ({ name: k, type: sentinelName(extra[k]) }))
48
+ .map((k) => ({ name: k, type: fact(f, 'option')[k].type.cell }))
78
49
  return {
79
50
  name: f.name,
80
51
  Name: f.Name || f.name,
81
- title: f.title || '',
52
+ title: fact(f, 'title').inline,
53
+ titleCell: fact(f, 'title').cell,
82
54
  transport: f.transport || 'none',
83
55
  wraps: isWrapping(f),
56
+ on: true === fact(f, 'on'),
57
+ hooks: Object.keys(f.hook || {}).filter((h: string) => true === f.hook[h]?.active).sort(),
84
58
  options,
85
59
  extras,
86
60
  }
@@ -91,6 +65,14 @@ function featureDocs(model: any, target?: any): FeatureDoc[] {
91
65
 
92
66
 
93
67
 
68
+ // `a`, `a` and `b`, `a`, `b` and `c`.
69
+ function codeList(names: string[]): string {
70
+ const code = names.map((n: string) => '`' + n + '`')
71
+ return code.length < 2 ? code.join('') :
72
+ code.slice(0, -1).join(', ') + ' and ' + code[code.length - 1]
73
+ }
74
+
75
+
94
76
  const FIXED_ORDER_TARGETS = ['lean']
95
77
 
96
78
  function honoursActivationOrder(target: any): boolean {
@@ -100,8 +82,7 @@ function honoursActivationOrder(target: any): boolean {
100
82
 
101
83
  export {
102
84
  featureDocs,
103
- renderValue,
104
- sentinelName,
85
+ codeList,
105
86
  honoursActivationOrder,
106
87
  }
107
88
 
@@ -22,6 +22,43 @@ const FeatureHook = cmp(function FeatureHook(props: any, children: any) {
22
22
  })
23
23
 
24
24
 
25
+ // The stages every entity operation runs, in order; each fires its hook first.
26
+ const PIPELINE_STAGES: { name: string, hook: string, purpose: string }[] = [
27
+ {
28
+ name: 'Point', hook: 'PrePoint',
29
+ purpose: 'Resolves which API endpoint to call based on the operation name and entity configuration.',
30
+ },
31
+ {
32
+ name: 'Spec', hook: 'PreSpec',
33
+ purpose: 'Builds the HTTP spec — URL, method, headers, body — from the resolved point and the caller\'s parameters.',
34
+ },
35
+ {
36
+ name: 'Request', hook: 'PreRequest',
37
+ purpose: 'Sends the HTTP request. Features can intercept here to replace the transport.',
38
+ },
39
+ {
40
+ name: 'Response', hook: 'PreResponse',
41
+ purpose: 'Parses the raw HTTP response.',
42
+ },
43
+ {
44
+ name: 'Result', hook: 'PreResult',
45
+ purpose: 'Extracts the business data from the parsed response.',
46
+ },
47
+ {
48
+ name: 'Done', hook: 'PreDone',
49
+ purpose: 'Final stage before returning to the caller. Entity state (match, data) is updated here.',
50
+ },
51
+ ]
52
+
53
+ const COUNT_WORDS = ['no', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
54
+
55
+ function pipelineLength(): string {
56
+ return COUNT_WORDS[PIPELINE_STAGES.length] ?? String(PIPELINE_STAGES.length)
57
+ }
58
+
59
+
25
60
  export {
26
- FeatureHook
61
+ FeatureHook,
62
+ PIPELINE_STAGES,
63
+ pipelineLength,
27
64
  }
@@ -8,7 +8,7 @@ import {
8
8
  getModelPath
9
9
  } from '../types'
10
10
 
11
- import { hasPackageName, packageName, packageVersion, repoInfo } from '../helpers/packageMeta'
11
+ import { hasPackageName, packageName, packageVersion, registryState, repoInfo } from '../helpers/packageMeta'
12
12
 
13
13
  import { npmTrustScript } from '../admin/npm-trust'
14
14
 
@@ -28,7 +28,8 @@ const PublishWorkflow = cmp(function PublishWorkflow(props: any) {
28
28
  if (false === t.active) {
29
29
  return
30
30
  }
31
- if ('npm' === (t.publish?.registry?.name || '') && hasPackageName(model, t.name)) {
31
+ if ('npm' === (t.publish?.registry?.name || '') && hasPackageName(model, t.name) &&
32
+ 'inactive' !== registryState(model, t.name)) {
32
33
  npmTargets.push(t)
33
34
  }
34
35
  })
@@ -118,9 +119,11 @@ function publishWorkflow(
118
119
  # THE FILENAME IS PART OF THAT CONFIGURATION. Renaming this file breaks
119
120
  # publishing until the npm side is updated to match.
120
121
  #
121
- # BY DISPATCH, deliberately. The deploy Makefile publishes with a
122
+ ${'active' === registryState(model, name) ? `# BY DISPATCH, deliberately. The deploy Makefile publishes with a
122
123
  # vault-injected token; a tag-triggered workflow racing it would publish one
123
- # version by two mechanisms. Releasing is an act someone performs and
124
+ # version by two mechanisms.` : `# BY DISPATCH, deliberately. While the registry is pending, the deploy
125
+ # Makefile only cuts the git tag, and a tag-triggered workflow would turn
126
+ # every tag it cuts into a publish.`} Releasing is an act someone performs and
124
127
  # watches.
125
128
  #
126
129
  # THREE JOBS, BECAUSE THEY NEED DIFFERENT PRIVILEGES. A dependency lifecycle
@@ -369,9 +372,7 @@ publish credential, and attaches SLSA provenance as it goes.
369
372
  \`expect_sha\` is optional and worth using: it refuses if \`main\` moved between
370
373
  the commit you checked and the run resolving.
371
374
 
372
- It is a DISPATCH rather than a tag push because the root \`Makefile\` also
373
- publishes, with a vault-injected token. A tag-triggered workflow racing it
374
- would publish one version by two mechanisms.
375
+ ${dispatchReason(model, targets)}
375
376
 
376
377
  ## The release is tagged for you
377
378
 
@@ -438,6 +439,31 @@ publisher — a ref pushed with \`GITHUB_TOKEN\` starts no further workflow run.
438
439
  }
439
440
 
440
441
 
442
+ // The root Makefile publishes an active registry and only tags a pending one,
443
+ // so the reason a tag trigger is wrong differs between them.
444
+ function dispatchReason(model: any, targets: any[]): string {
445
+ const states = targets.map((t: any) => registryState(model, t.name))
446
+ const active = states.includes('active')
447
+ const pending = states.some((s: string) => 'active' !== s)
448
+ if (active && !pending) {
449
+ return 'It is a DISPATCH rather than a tag push because the root `Makefile` also\n' +
450
+ 'publishes, with a vault-injected token. A tag-triggered workflow racing it\n' +
451
+ 'would publish one version by two mechanisms.'
452
+ }
453
+ if (!active) {
454
+ return 'It is a DISPATCH rather than a tag push. While the registry is pending, the\n' +
455
+ 'root `Makefile` only cuts the git tag, and a tag-triggered workflow would\n' +
456
+ 'turn every tag it cuts into a publish.'
457
+ }
458
+ return 'It is a DISPATCH rather than a tag push. Where a registry is active, the\n' +
459
+ 'root `Makefile` also publishes, with a vault-injected token, and a\n' +
460
+ 'tag-triggered workflow racing it would publish one version by two\n' +
461
+ 'mechanisms. Where one is pending, the root `Makefile` only cuts the git\n' +
462
+ 'tag, and a tag-triggered workflow would turn every tag it cuts into a\n' +
463
+ 'publish.'
464
+ }
465
+
466
+
441
467
  export {
442
468
  PublishWorkflow
443
469
  }