@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
@@ -7,13 +7,16 @@ const types_1 = require("../types");
7
7
  const utility_1 = require("../utility");
8
8
  const optional_1 = require("../helpers/optional");
9
9
  const FeatureDocs_1 = require("./FeatureDocs");
10
+ const FeatureHook_1 = require("./FeatureHook");
10
11
  const opShape_1 = require("../helpers/opShape");
11
12
  const opExample_1 = require("../helpers/opExample");
12
13
  const mcpTools_1 = require("../helpers/mcpTools");
13
14
  const canonType_1 = require("../helpers/canonType");
14
15
  const naming_1 = require("../helpers/naming");
15
16
  const text_1 = require("../helpers/text");
17
+ const facts_1 = require("../helpers/facts");
16
18
  const alongside_1 = require("../helpers/alongside");
19
+ const copymerge_1 = require("../helpers/copymerge");
17
20
  const packageMeta_1 = require("../helpers/packageMeta");
18
21
  const SDKGEN_REPO = 'https://github.com/voxgig/sdkgen';
19
22
  const VOXGIG_SDK = 'https://voxgig.com/sdk/';
@@ -66,221 +69,173 @@ function entityExample(lang, Name, call) {
66
69
  default: return '';
67
70
  }
68
71
  }
69
- const ReadmeTop = (0, component_1.cmp)(function ReadmeTop(props) {
70
- const { ctx$ } = props;
71
- const { model } = ctx$;
72
- if (model.name && !model.Name)
73
- (0, jostraca_1.names)(model, model.name);
74
- const info = (0, text_1.modelText)(model);
75
- const def = (model.main && model.main.def) || {};
76
- const productName = info.title || `${model.Name} API`;
77
- const tagline = info.tagline
78
- || def.tagline
79
- || `${productName} client, generated from the OpenAPI spec.`;
80
- const aboutMd = info.about_md || '';
81
- const homepage = info.homepage || '';
82
- const docsUrl = info.docs_url || '';
83
- const entityDesc = info.entity_desc || {};
84
- const apiSummary = (info.summary || '').trim();
85
- const apiWebsite = (info.website || '').trim();
86
- const websiteLine = apiWebsite
87
- ? `Learn more about ${productName} at ` +
88
- `[${apiWebsite.replace(/^https?:\/\//, '').replace(/\/$/, '')}](${apiWebsite}).`
89
- : '';
90
- // Attribution for API metadata sourced from a third-party catalogue (e.g.
91
- // freepublicapis.com). Rendered only when the model carries an
92
- // `info.meta_source` URL, so first-party SDKs never show it. The link points
93
- // back to the catalogue that kindly supplied the metadata.
94
- const metaSource = (info.meta_source || '').trim();
95
- const metaSourceLine = metaSource
96
- ? `Metadata kindly supplied by ` +
97
- `[${metaSource.replace(/^https?:\/\//, '').replace(/\/$/, '')}](${metaSource}).`
98
- : '';
99
- const entity = (0, types_1.getModelPath)(model, `main.${types_1.KIT}.entity`);
100
- const target = (0, types_1.getModelPath)(model, `main.${types_1.KIT}.target`);
101
- const feature = (0, types_1.getModelPath)(model, `main.${types_1.KIT}.feature`);
102
- (0, jostraca_1.each)(entity, (ent) => { if (!ent.Name)
103
- (0, jostraca_1.names)(ent, ent.name); });
104
- (0, jostraca_1.each)(feature, (feat) => { if (!feat.Name)
105
- (0, jostraca_1.names)(feat, feat.name); });
106
- const activeEntities = (0, jostraca_1.each)(entity).filter((e) => e.active !== false);
107
- const activeTargets = (0, jostraca_1.each)(target).filter((t) => t.active !== false);
108
- const hasCli = activeTargets.some((t) => t.name === 'go-cli');
109
- const hasMcp = activeTargets.some((t) => t.name === 'go-mcp');
110
- const docsOrder = (0, types_1.getModelPath)(model, `main.${types_1.KIT}.config.docs_order`, { only_active: false, required: false }) || [];
111
- const orderOf = (name) => {
112
- const i = docsOrder.indexOf(name);
113
- if (i !== -1)
114
- return i;
115
- if (name === 'go-cli')
116
- return docsOrder.length + 1;
117
- if (name === 'go-mcp')
118
- return docsOrder.length + 2;
119
- return docsOrder.length;
120
- };
121
- const ordered = activeTargets
122
- .slice()
123
- .sort((a, b) => orderOf(a.name) - orderOf(b.name));
124
- const isCliOrMcp = (t) => t.name === 'go-cli' || t.name === 'go-mcp';
125
- const sdkTargets = ordered.filter((t) => !(0, alongside_1.isConsumer)(t));
126
- // The CLI and the MCP server have surfaces of their own below.
127
- const consumerTargets = ordered.filter((t) => (0, alongside_1.isConsumer)(t) && !isCliOrMcp(t));
128
- const docTargets = ordered.filter((t) => !isCliOrMcp(t));
129
- const pkgTargets = activeTargets
130
- .filter((t) => (0, packageMeta_1.hasPackageName)(model, t.name))
131
- .sort((a, b) => orderOf(a.name) - orderOf(b.name));
132
- const langList = sdkTargets.map((t) => t.title).join(', ');
133
- const leadTarget = pickLeadTarget(sdkTargets);
134
- (0, jostraca_1.File)({ name: 'README.md' }, () => {
135
- (0, jostraca_1.Content)(`# ${model.Name} SDK
72
+ const ReadmeTopTitle = (0, component_1.cmp)(function ReadmeTopTitle(props) {
73
+ const { model, tagline, apiSummary, websiteLine, metaSourceLine } = props.s;
74
+ (0, jostraca_1.Content)(`# ${model.Name} SDK
136
75
 
137
76
  ${tagline}
138
77
 
139
78
  `);
140
- if (apiSummary) {
141
- (0, jostraca_1.Content)(`${apiSummary}
79
+ if (apiSummary) {
80
+ (0, jostraca_1.Content)(`${apiSummary}
142
81
 
143
82
  `);
144
- }
145
- if (websiteLine) {
146
- (0, jostraca_1.Content)(`${websiteLine}
83
+ }
84
+ if (websiteLine) {
85
+ (0, jostraca_1.Content)(`${websiteLine}
147
86
 
148
87
  `);
149
- }
150
- (0, jostraca_1.Content)(`${(0, packageMeta_1.nonAffiliation)(model)}
88
+ }
89
+ (0, jostraca_1.Content)(`${(0, packageMeta_1.nonAffiliation)(model)}
151
90
 
152
91
  `);
153
- if ((0, packageMeta_1.isDefaultPublisher)(model)) {
154
- (0, jostraca_1.Content)(`Learn more about Voxgig SDKs at [voxgig.com/sdk](${VOXGIG_SDK}).
92
+ if ((0, packageMeta_1.isDefaultPublisher)(model)) {
93
+ (0, jostraca_1.Content)(`Learn more about Voxgig SDKs at [voxgig.com/sdk](${VOXGIG_SDK}).
155
94
 
156
95
  `);
157
- }
158
- // THE GENERATED SITE, LINKED FROM THE TOP, because the repository was the
159
- // one place it could not be found from. `docs_url` further down is the
160
- // UPSTREAM API's documentation, not this, and a reader who lands on the
161
- // repo rather than arriving from a link had no route to the site at all.
162
- // Empty unless the project actually publishes one -- see docsSiteUrl.
163
- const siteUrl = (0, packageMeta_1.docsSiteUrl)(model);
164
- if (siteUrl) {
165
- (0, jostraca_1.Content)(`Full documentation for this SDK: [${siteUrl}](${siteUrl})
96
+ }
97
+ // THE GENERATED SITE, LINKED FROM THE TOP, because the repository was the
98
+ // one place it could not be found from. `docs_url` further down is the
99
+ // UPSTREAM API's documentation, not this, and a reader who lands on the
100
+ // repo rather than arriving from a link had no route to the site at all.
101
+ // Empty unless the project actually publishes one -- see docsSiteUrl.
102
+ const siteUrl = (0, packageMeta_1.docsSiteUrl)(model);
103
+ if (siteUrl) {
104
+ (0, jostraca_1.Content)(`Full documentation for this SDK: [${siteUrl}](${siteUrl})
166
105
 
167
106
  `);
168
- }
169
- if (metaSourceLine) {
170
- (0, jostraca_1.Content)(`${metaSourceLine}
107
+ }
108
+ if (metaSourceLine) {
109
+ (0, jostraca_1.Content)(`${metaSourceLine}
171
110
 
172
111
  `);
173
- }
174
- if (sdkTargets.length > 1) {
175
- const surfaces = [];
176
- surfaces.push(`${langList} SDKs`);
177
- if (hasCli)
178
- surfaces.push('a CLI with an interactive REPL');
179
- if (hasMcp)
180
- surfaces.push('an MCP server for AI agents');
181
- consumerTargets.forEach((t) => surfaces.push(`the ${t.title} package`));
182
- const surfaceList = surfaces.length > 1
183
- ? surfaces.slice(0, -1).join(', ') + ', and ' + surfaces[surfaces.length - 1]
184
- : surfaces[0];
185
- (0, jostraca_1.Content)(`> ${surfaceList} — all generated from one OpenAPI spec by [@voxgig/sdkgen](${SDKGEN_REPO}).
112
+ }
113
+ });
114
+ const ReadmeTopSurfaceLine = (0, component_1.cmp)(function ReadmeTopSurfaceLine(props) {
115
+ const { hasCli, hasMcp, sdkTargets, consumerTargets, langList } = props.s;
116
+ if (sdkTargets.length > 1) {
117
+ const surfaces = [];
118
+ surfaces.push(`${langList} SDKs`);
119
+ if (hasCli)
120
+ surfaces.push('a CLI with an interactive REPL');
121
+ if (hasMcp)
122
+ surfaces.push('an MCP server for AI agents');
123
+ consumerTargets.forEach((t) => surfaces.push(`the ${t.title} package`));
124
+ const surfaceList = surfaces.length > 1
125
+ ? surfaces.slice(0, -1).join(', ') + ', and ' + surfaces[surfaces.length - 1]
126
+ : surfaces[0];
127
+ (0, jostraca_1.Content)(`> ${surfaceList} — all generated from one OpenAPI spec by [@voxgig/sdkgen](${SDKGEN_REPO}).
186
128
 
187
129
  `);
188
- }
189
- // FEATURES BELONG BESIDE THE TARGETS. What an SDK can do is as much a
190
- // reason to choose it as which language it is in, and a reader who has to
191
- // scroll past every language section to discover that retries, caching and
192
- // tracing are built in has already decided it is a thin HTTP wrapper.
193
- // Named here, in one line, with the detail left to each target's README.
194
- const features = (0, FeatureDocs_1.featureDocs)(model);
195
- if (0 < features.length) {
196
- (0, jostraca_1.Content)(`> **Features:** ${features.map((f) => '`' + f.name + '`').join(', ')} — opt-in,
197
- > inactive until switched on, and configured per client. See the Features
130
+ }
131
+ });
132
+ const ReadmeTopFeatureLine = (0, component_1.cmp)(function ReadmeTopFeatureLine(props) {
133
+ const { model } = props.s;
134
+ // FEATURES BELONG BESIDE THE TARGETS. What an SDK can do is as much a
135
+ // reason to choose it as which language it is in, and a reader who has to
136
+ // scroll past every language section to discover that retries, caching and
137
+ // tracing are built in has already decided it is a thin HTTP wrapper.
138
+ // Named here, in one line, with the detail left to each target's README.
139
+ const features = (0, FeatureDocs_1.featureDocs)(model);
140
+ if (0 < features.length) {
141
+ const on = features.filter((f) => f.on).map((f) => f.name);
142
+ const state = 0 === on.length ? `opt-in,
143
+ > inactive until switched on, and configured per client.` : `configured per client.
144
+ > ${(0, FeatureDocs_1.codeList)(on)} ${1 === on.length ? 'runs' : 'run'} by default${on.length < features.length ?
145
+ '; the rest are opt-in, inactive until switched on' : ''}.`;
146
+ (0, jostraca_1.Content)(`> **Features:** ${features.map((f) => '`' + f.name + '`').join(', ')} — ${state} See the Features
198
147
  > section of any SDK README below for what each one does.
199
148
 
200
149
  `);
201
- }
202
- if (aboutMd) {
203
- (0, jostraca_1.Content)(`## About ${productName}
150
+ }
151
+ });
152
+ const ReadmeTopAbout = (0, component_1.cmp)(function ReadmeTopAbout(props) {
153
+ const { text, productName, aboutMd } = props.s;
154
+ if (aboutMd) {
155
+ (0, jostraca_1.Content)(`## About ${productName}
204
156
 
205
- ${aboutMd.trim()}
157
+ ${aboutMd}
206
158
 
207
159
  `);
208
- }
209
- else if (def.desc) {
210
- (0, jostraca_1.Content)(`${def.desc}
160
+ }
161
+ else if (text.desc.text) {
162
+ (0, jostraca_1.Content)(`${text.desc.text}
211
163
 
212
164
  `);
165
+ }
166
+ });
167
+ const ReadmeTopEntityModel = (0, component_1.cmp)(function ReadmeTopEntityModel(props) {
168
+ const { model, activeEntities, sdkTargets } = props.s;
169
+ if (activeEntities.length > 0) {
170
+ const entNames = activeEntities.map((e) => e.Name);
171
+ const entCount = entNames.length;
172
+ const entList = entCount > 1
173
+ ? entNames.slice(0, -1).join(', ') + ' and ' + entNames[entNames.length - 1]
174
+ : entNames[0];
175
+ const NAME_INLINE_MAX = 6;
176
+ const inlineNames = entCount <= NAME_INLINE_MAX;
177
+ const surface = inlineNames
178
+ ? `a small set of **semantic entities** — ${entList} —`
179
+ : `**${entCount} semantic entities**`;
180
+ const seeEntities = inlineNames
181
+ ? ''
182
+ : ' See the [Entities](#entities) table below for the full list.';
183
+ const exEnt = activeEntities[0];
184
+ const ex = exEnt.Name;
185
+ const exLower = (0, naming_1.exampleVarName)(ex.toLowerCase(), 'ts');
186
+ // The example call uses the entity's PRIMARY op — an op it actually
187
+ // exposes (prefer list -> the array, then load -> the record, else a
188
+ // create with its required fields). A create-only entity therefore never
189
+ // shows a phantom .list()/.load() that would not compile. If it exposes
190
+ // only remove (or nothing), the op line is omitted entirely.
191
+ const primaryOp = (0, opShape_1.entityPrimaryOp)(exEnt);
192
+ let exCall = '';
193
+ const exIdField = (0, opShape_1.entityIdField)(exEnt);
194
+ const exListArg = (0, opExample_1.listMatchArg)('ts', exEnt);
195
+ const exLoadArg = (0, opExample_1.matchArg)('ts', exEnt, 'load', exIdField, (0, opExample_1.idLiteral)(exEnt, 'load', exIdField));
196
+ if ('list' === primaryOp) {
197
+ exCall = `const items = await client.${ex}().list(${exListArg})`;
213
198
  }
214
- if (activeEntities.length > 0) {
215
- const entNames = activeEntities.map((e) => e.Name);
216
- const entCount = entNames.length;
217
- const entList = entCount > 1
218
- ? entNames.slice(0, -1).join(', ') + ' and ' + entNames[entNames.length - 1]
219
- : entNames[0];
220
- const NAME_INLINE_MAX = 6;
221
- const inlineNames = entCount <= NAME_INLINE_MAX;
222
- const surface = inlineNames
223
- ? `a small set of **semantic entities** — ${entList} —`
224
- : `**${entCount} semantic entities**`;
225
- const seeEntities = inlineNames
226
- ? ''
227
- : ' See the [Entities](#entities) table below for the full list.';
228
- const exEnt = activeEntities[0];
229
- const ex = exEnt.Name;
230
- const exLower = (0, naming_1.exampleVarName)(ex.toLowerCase(), 'ts');
231
- // The example call uses the entity's PRIMARY op — an op it actually
232
- // exposes (prefer list -> the array, then load -> the record, else a
233
- // create with its required fields). A create-only entity therefore never
234
- // shows a phantom .list()/.load() that would not compile. If it exposes
235
- // only remove (or nothing), the op line is omitted entirely.
236
- const primaryOp = (0, opShape_1.entityPrimaryOp)(exEnt);
237
- let exCall = '';
238
- const exIdField = (0, opShape_1.entityIdField)(exEnt);
239
- const exListArg = (0, opExample_1.listMatchArg)('ts', exEnt);
240
- const exLoadArg = (0, opExample_1.matchArg)('ts', exEnt, 'load', exIdField, (0, opExample_1.idLiteral)(exEnt, 'load', exIdField));
241
- if ('list' === primaryOp) {
242
- exCall = `const items = await client.${ex}().list(${exListArg})`;
243
- }
244
- else if ('load' === primaryOp) {
245
- exCall = `const ${exLower} = await client.${ex}().load(${exLoadArg})`;
246
- }
247
- else if ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp) {
248
- const exIdF = (0, opShape_1.entityIdField)(exEnt);
249
- // Drop the id only when the request shape says it is OPTIONAL. It is
250
- // server-assigned on a normal create, but an op whose id comes from a
251
- // PATH PARAMETER requires it, and the typed CreateData then rejects a
252
- // body without it. Same rule as dataArg in helpers/opExample.
253
- const shapeItems = (0, opExample_1.requestExampleItems)(exEnt, primaryOp)
254
- .filter((it) => (it.name !== exIdF && it.name !== 'id') || !it.optional);
255
- const required = shapeItems.filter((it) => !it.optional);
256
- const chosen = required.length ? required : shapeItems.slice(0, 3);
257
- const bodyLines = chosen.map((it) => ` ${(0, naming_1.jsKey)(it.name)}: ${tsExampleLiteral(it.type)},`);
258
- const body = bodyLines.length ? `\n${bodyLines.join('\n')}\n` : '';
259
- exCall = `const ${exLower} = await client.${ex}().${primaryOp}({${body}})`;
260
- }
261
- const CANON_OPS = ['list', 'load', 'create', 'update', 'patch', 'remove'];
262
- const opSet = new Set();
263
- activeEntities.forEach((e) => Object.keys(e.op || {})
264
- .forEach((o) => { if (e.op[o] && e.op[o].active !== false)
265
- opSet.add(o); }));
266
- const opNames = CANON_OPS.filter((o) => opSet.has(o)).concat([...opSet].filter((o) => !CANON_OPS.includes(o)));
267
- const opList = (opNames.length ? opNames : ['list', 'load']).map((o) => '`' + o + '`').join(', ');
268
- // In the SDK's own language: ts when it has one, else the first the
269
- // example helpers can write, else no example at all.
270
- const lang = exampleLang(model, sdkTargets);
271
- let snippet = '';
272
- if ('ts' === lang) {
273
- snippet = `const client = new ${model.Name}SDK()${exCall ? '\n' + exCall : ''}`;
274
- }
275
- else if (null != lang) {
276
- const call = ['list', 'load', 'create', 'update', 'patch'].includes(String(primaryOp))
277
- ? (0, opExample_1.primaryOpCall)(lang, ex, (0, naming_1.exampleVarName)(ex.toLowerCase(), lang), primaryOp, exIdField, exEnt)
278
- : null;
279
- snippet = entityExample(lang, model.Name, call);
280
- }
281
- const exBlock = '' === snippet ? '.' :
282
- `:\n\n\`\`\`${EXAMPLE_FENCE[lang]}\n${snippet}\n\`\`\``;
283
- (0, jostraca_1.Content)(`## Entities, not endpoints
199
+ else if ('load' === primaryOp) {
200
+ exCall = `const ${exLower} = await client.${ex}().load(${exLoadArg})`;
201
+ }
202
+ else if ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp) {
203
+ const exIdF = (0, opShape_1.entityIdField)(exEnt);
204
+ // Drop the id only when the request shape says it is OPTIONAL. It is
205
+ // server-assigned on a normal create, but an op whose id comes from a
206
+ // PATH PARAMETER requires it, and the typed CreateData then rejects a
207
+ // body without it. Same rule as dataArg in helpers/opExample.
208
+ const shapeItems = (0, opExample_1.requestExampleItems)(exEnt, primaryOp)
209
+ .filter((it) => (it.name !== exIdF && it.name !== 'id') || !it.optional);
210
+ const required = shapeItems.filter((it) => !it.optional);
211
+ const chosen = required.length ? required : shapeItems.slice(0, 3);
212
+ const bodyLines = chosen.map((it) => ` ${(0, naming_1.jsKey)(it.name)}: ${tsExampleLiteral(it.type)},`);
213
+ const body = bodyLines.length ? `\n${bodyLines.join('\n')}\n` : '';
214
+ exCall = `const ${exLower} = await client.${ex}().${primaryOp}({${body}})`;
215
+ }
216
+ const CANON_OPS = ['list', 'load', 'create', 'update', 'patch', 'remove'];
217
+ const opSet = new Set();
218
+ activeEntities.forEach((e) => Object.keys(e.op || {})
219
+ .forEach((o) => { if (e.op[o] && e.op[o].active !== false)
220
+ opSet.add(o); }));
221
+ const opNames = CANON_OPS.filter((o) => opSet.has(o)).concat([...opSet].filter((o) => !CANON_OPS.includes(o)));
222
+ const opList = (opNames.length ? opNames : ['list', 'load']).map((o) => '`' + o + '`').join(', ');
223
+ // In the SDK's own language: ts when it has one, else the first the
224
+ // example helpers can write, else no example at all.
225
+ const lang = exampleLang(model, sdkTargets);
226
+ let snippet = '';
227
+ if ('ts' === lang) {
228
+ snippet = `const client = new ${model.Name}SDK()${exCall ? '\n' + exCall : ''}`;
229
+ }
230
+ else if (null != lang) {
231
+ const call = ['list', 'load', 'create', 'update', 'patch'].includes(String(primaryOp))
232
+ ? (0, opExample_1.primaryOpCall)(lang, ex, (0, naming_1.exampleVarName)(ex.toLowerCase(), lang), primaryOp, exIdField, exEnt)
233
+ : null;
234
+ snippet = entityExample(lang, model.Name, call);
235
+ }
236
+ const exBlock = '' === snippet ? '.' :
237
+ `:\n\n\`\`\`${EXAMPLE_FENCE[lang]}\n${snippet}\n\`\`\``;
238
+ (0, jostraca_1.Content)(`## Entities, not endpoints
284
239
 
285
240
  This SDK exposes the API as ${surface} that you
286
241
  call directly, instead of assembling URL paths and query strings.${seeEntities} Entities are
@@ -291,122 +246,137 @@ Thinking in entities keeps the mental model small — for people and AI agents a
291
246
  rather than reasoning about raw HTTP routes and query parameters.
292
247
 
293
248
  `);
294
- }
295
- if (sdkTargets.length > 0) {
296
- (0, jostraca_1.Content)(`## Offline unit testing
249
+ }
250
+ });
251
+ const ReadmeTopTesting = (0, component_1.cmp)(function ReadmeTopTesting(props) {
252
+ const { ctx$, sdkTargets } = props.s;
253
+ if (sdkTargets.length > 0) {
254
+ (0, jostraca_1.Content)(`## Offline unit testing
297
255
 
298
256
  Every SDK ships a built-in **test mode** that swaps the HTTP transport for
299
257
  an in-memory mock, so your unit tests run fully offline — no server, no
300
258
  network, and no credentials:
301
259
 
302
260
  `);
303
- sdkTargets.forEach((tgt) => {
304
- const Test = (0, optional_1.optionalComponent)(ctx$, tgt, 'ReadmeTopTest');
305
- if (Test) {
306
- (0, jostraca_1.Content)(`### ${tgt.title}
261
+ sdkTargets.forEach((tgt) => {
262
+ const Test = (0, optional_1.optionalComponent)(ctx$, tgt, 'ReadmeTopTest');
263
+ if (Test) {
264
+ (0, jostraca_1.Content)(`### ${tgt.title}
307
265
 
308
266
  `);
309
- Test['ReadmeTopTest']({ target: tgt });
310
- (0, jostraca_1.Content)(`
267
+ Test['ReadmeTopTest']({ target: tgt });
268
+ (0, jostraca_1.Content)(`
311
269
  `);
312
- }
313
- });
314
- }
315
- // 3. Packages — real published package name + install command per
316
- // ecosystem. A package that is NOT yet live on its registry (the fleet
317
- // default: 'pending') must NOT advertise a `npm install ...` that 404s —
318
- // its Install cell links to the target README's install section instead,
319
- // as do go-cli and go-mcp, which the Go proxy cannot install.
320
- if (pkgTargets.length > 0) {
321
- (0, jostraca_1.Content)(`## Packages
270
+ }
271
+ });
272
+ }
273
+ });
274
+ const ReadmeTopPackages = (0, component_1.cmp)(function ReadmeTopPackages(props) {
275
+ const { model, pkgTargets } = props.s;
276
+ // 3. Packages — real published package name + install command per
277
+ // ecosystem. A package that is NOT yet live on its registry (the fleet
278
+ // default: 'pending') must NOT advertise a `npm install ...` that 404s —
279
+ // its Install cell links to the target README's install section instead,
280
+ // as do go-cli and go-mcp, which the Go proxy cannot install.
281
+ if (pkgTargets.length > 0) {
282
+ (0, jostraca_1.Content)(`## Packages
322
283
 
323
284
  | Language | Package | Install |
324
285
  | --- | --- | --- |
325
286
  `);
326
- pkgTargets.forEach((tgt) => {
327
- const state = (0, packageMeta_1.registryState)(model, tgt.name);
328
- let cell;
329
- if ('active' === state) {
330
- const cmd = installCommand(tgt, model);
331
- if (!cmd)
332
- return;
333
- cell = '`' + cmd + '`';
334
- }
335
- else if ('tag' === state) {
336
- const cmd = (0, packageMeta_1.vendorCommand)(model, tgt.name);
337
- cell = cmd
338
- ? '`' + cmd + '`'
339
- : `build from source — [${tgt.name}/README.md](${tgt.name}/README.md)`;
340
- }
341
- else {
342
- // The target README always gives a route that works without a
343
- // tag, which a repository may not have.
344
- cell = `publish pending — [install from source](${tgt.name}/README.md#install)`;
345
- }
346
- (0, jostraca_1.Content)(`| ${tgt.title} | \`${(0, packageMeta_1.packageName)(model, tgt.name)}\` | ${cell} |
347
- `);
348
- });
349
- (0, jostraca_1.Content)(`
287
+ pkgTargets.forEach((tgt) => {
288
+ const state = (0, packageMeta_1.registryState)(model, tgt.name);
289
+ let cell;
290
+ if ('active' === state) {
291
+ const cmd = installCommand(tgt, model);
292
+ cell = cmd
293
+ ? '`' + cmd + '`'
294
+ : `see [${tgt.name}/README.md](${tgt.name}/README.md#install)`;
295
+ }
296
+ else if ('tag' === state) {
297
+ const cmd = (0, packageMeta_1.vendorCommand)(model, tgt.name);
298
+ cell = cmd
299
+ ? '`' + cmd + '`'
300
+ : `build from source — [${tgt.name}/README.md](${tgt.name}/README.md)`;
301
+ }
302
+ else {
303
+ // The target README always gives a route that works without a
304
+ // tag, which a repository may not have.
305
+ cell = `publish pending — [install from source](${tgt.name}/README.md#install)`;
306
+ }
307
+ (0, jostraca_1.Content)(`| ${tgt.title} | \`${(0, packageMeta_1.packageName)(model, tgt.name)}\` | ${cell} |
350
308
  `);
351
- }
352
- if (leadTarget) {
353
- (0, jostraca_1.Content)(`## Quickstart
309
+ });
310
+ (0, jostraca_1.Content)(`
311
+ `);
312
+ }
313
+ });
314
+ const ReadmeTopQuickstart = (0, component_1.cmp)(function ReadmeTopQuickstart(props) {
315
+ const { model, ctx$, leadTarget } = props.s;
316
+ if (leadTarget) {
317
+ (0, jostraca_1.Content)(`## Quickstart
354
318
 
355
319
  ### ${leadTarget.title}
356
320
 
357
321
  `);
358
- const LeadQuick = (0, optional_1.optionalComponent)(ctx$, leadTarget, 'ReadmeTopQuick');
359
- if (LeadQuick) {
360
- LeadQuick['ReadmeTopQuick']({ target: leadTarget });
361
- }
362
- const placement = (0, utility_1.credentialPlacement)(model);
363
- (0, jostraca_1.Content)(`
322
+ const LeadQuick = (0, optional_1.optionalComponent)(ctx$, leadTarget, 'ReadmeTopQuick');
323
+ if (LeadQuick) {
324
+ LeadQuick['ReadmeTopQuick']({ target: leadTarget });
325
+ }
326
+ const placement = (0, utility_1.credentialPlacement)(model);
327
+ (0, jostraca_1.Content)(`
364
328
  ${'' === placement ? '' : placement + '\n\n'}See the [${leadTarget.title} README](${leadTarget.name}/README.md) for the full guide.
365
329
 
366
330
  `);
367
- }
368
- if (sdkTargets.length > 0 || hasCli || hasMcp || consumerTargets.length > 0) {
369
- (0, jostraca_1.Content)(`## Surfaces
331
+ }
332
+ });
333
+ const ReadmeTopSurfaces = (0, component_1.cmp)(function ReadmeTopSurfaces(props) {
334
+ const { hasCli, hasMcp, sdkTargets, consumerTargets, langList } = props.s;
335
+ if (sdkTargets.length > 0 || hasCli || hasMcp || consumerTargets.length > 0) {
336
+ (0, jostraca_1.Content)(`## Surfaces
370
337
 
371
338
  | Surface | Path |
372
339
  | --- | --- |
373
340
  `);
374
- if (sdkTargets.length > 0) {
375
- const paths = sdkTargets.map((t) => `\`${t.name}/\``).join(' ');
376
- (0, jostraca_1.Content)(`| **SDK** (${langList}) | ${paths} |
341
+ if (sdkTargets.length > 0) {
342
+ const paths = sdkTargets.map((t) => `\`${t.name}/\``).join(' ');
343
+ (0, jostraca_1.Content)(`| **SDK** (${langList}) | ${paths} |
377
344
  `);
378
- }
379
- if (hasCli) {
380
- (0, jostraca_1.Content)(`| **CLI** | \`go-cli/\` |
345
+ }
346
+ if (hasCli) {
347
+ (0, jostraca_1.Content)(`| **CLI** | \`go-cli/\` |
381
348
  `);
382
- }
383
- if (hasMcp) {
384
- (0, jostraca_1.Content)(`| **MCP server** | \`go-mcp/\` |
349
+ }
350
+ if (hasMcp) {
351
+ (0, jostraca_1.Content)(`| **MCP server** | \`go-mcp/\` |
385
352
  `);
386
- }
387
- consumerTargets.forEach((t) => {
388
- (0, jostraca_1.Content)(`| **${t.title}** | \`${t.name}/\` |
353
+ }
354
+ consumerTargets.forEach((t) => {
355
+ (0, jostraca_1.Content)(`| **${t.title}** | \`${t.name}/\` |
389
356
  `);
390
- });
391
- (0, jostraca_1.Content)(`
357
+ });
358
+ (0, jostraca_1.Content)(`
392
359
  `);
393
- }
394
- if (hasMcp) {
395
- const mcpOps = (0, mcpTools_1.mcpTools)(model).map((tool) => tool.op);
396
- const mcpWrite = true === model.main?.[types_1.KIT]?.target?.['go-mcp']?.tool?.write;
397
- const toggle = "`main: kit: target: 'go-mcp': tool: write: true`";
398
- const opText = mcpOps.length < 2 ? mcpOps.join('') :
399
- mcpOps.slice(0, -1).join(', ') + ' and ' + mcpOps[mcpOps.length - 1];
400
- // What the server reads and writes is what it registers, not the flag.
401
- const reads = mcpOps.some((op) => mcpTools_1.MCP_WRITE_OPS.includes(op)) ? '' : mcpWrite ?
402
- ' It only reads, as no entity has a create, update, patch or remove a plain call runs.' :
403
- ` It only reads: create, update, patch and remove become tools when the SDK's model sets
360
+ }
361
+ });
362
+ const ReadmeTopMcp = (0, component_1.cmp)(function ReadmeTopMcp(props) {
363
+ const { model, hasMcp } = props.s;
364
+ if (hasMcp) {
365
+ const mcpOps = (0, mcpTools_1.mcpTools)(model).map((tool) => tool.op);
366
+ const mcpWrite = true === model.main?.[types_1.KIT]?.target?.['go-mcp']?.tool?.write;
367
+ const toggle = "`main: kit: target: 'go-mcp': tool: write: true`";
368
+ const opText = mcpOps.length < 2 ? mcpOps.join('') :
369
+ mcpOps.slice(0, -1).join(', ') + ' and ' + mcpOps[mcpOps.length - 1];
370
+ // What the server reads and writes is what it registers, not the flag.
371
+ const reads = mcpOps.some((op) => mcpTools_1.MCP_WRITE_OPS.includes(op)) ? '' : mcpWrite ?
372
+ ' It only reads, as no entity has a create, update, patch or remove a plain call runs.' :
373
+ ` It only reads: create, update, patch and remove become tools when the SDK's model sets
404
374
  ${toggle}.`;
405
- (0, jostraca_1.Content)(0 === mcpOps.length ? `## Use it from an AI agent (MCP)
375
+ (0, jostraca_1.Content)(0 === mcpOps.length ? `## Use it from an AI agent (MCP)
406
376
 
407
377
  The generated MCP server has no tools for this SDK: no entity has a list or
408
378
  load a plain call runs${mcpWrite ? ', or a create, update, patch or remove' :
409
- `, and create, update, patch and remove are off until the SDK's model sets
379
+ `, and create, update, patch and remove are off until the SDK's model sets
410
380
  ${toggle}`}.
411
381
 
412
382
  ` : `## Use it from an AI agent (MCP)
@@ -432,54 +402,62 @@ Then add it to your agent's MCP config (Claude Desktop, Cursor, etc.):
432
402
  \`\`\`
433
403
 
434
404
  `);
435
- }
436
- if (activeEntities.length > 0) {
437
- (0, jostraca_1.Content)(`## Entities
405
+ }
406
+ });
407
+ const ReadmeTopEntities = (0, component_1.cmp)(function ReadmeTopEntities(props) {
408
+ const { activeEntities } = props.s;
409
+ if (activeEntities.length > 0) {
410
+ (0, jostraca_1.Content)(`## Entities
438
411
 
439
412
  The API exposes ${activeEntities.length === 1 ? 'one entity' : activeEntities.length + ' entities'}:
440
413
 
441
414
  | Entity | Description | API path |
442
415
  | --- | --- | --- |
443
416
  `);
444
- activeEntities.map((ent) => {
445
- const ops = ent.op || {};
446
- const opNames = Object.keys(ops).filter((o) => ops[o]?.active !== false);
447
- const entdesc = entityDesc[ent.name] || ent.short || ent.desc ||
448
- `The ${ent.Name} entity${opNames.length ? ' (' + opNames.join(', ') + ')' : ''}.`;
449
- const path = (0, opShape_1.entityPath)(ent);
450
- (0, jostraca_1.Content)(`| **${ent.Name}** | ${entdesc} | \`${path}\` |
451
- `);
452
- });
453
- const opUnion = new Set();
454
- activeEntities.forEach((e) => Object.keys(e.op || {})
455
- .forEach((o) => { if (e.op[o]?.active !== false)
456
- opUnion.add(o); }));
457
- const opAvail = ['load', 'list', 'create', 'update', 'patch', 'remove'].filter((o) => opUnion.has(o));
458
- const opBold = (opAvail.length ? opAvail : ['load', 'list']).map((o) => '**' + o + '**').join(', ');
459
- (0, jostraca_1.Content)(`
417
+ activeEntities.map((ent) => {
418
+ const ops = ent.op || {};
419
+ const opNames = Object.keys(ops).filter((o) => ops[o]?.active !== false);
420
+ const entdesc = (0, facts_1.fact)(ent, 'desc').cell ||
421
+ `The ${ent.Name} entity${opNames.length ? ' (' + opNames.join(', ') + ')' : ''}.`;
422
+ const path = (0, opShape_1.entityPath)(ent);
423
+ (0, jostraca_1.Content)(`| **${ent.Name}** | ${entdesc} | \`${path}\` |
424
+ `);
425
+ });
426
+ const opUnion = new Set();
427
+ activeEntities.forEach((e) => Object.keys(e.op || {})
428
+ .forEach((o) => { if (e.op[o]?.active !== false)
429
+ opUnion.add(o); }));
430
+ const opAvail = ['load', 'list', 'create', 'update', 'patch', 'remove'].filter((o) => opUnion.has(o));
431
+ const opBold = (opAvail.length ? opAvail : ['load', 'list']).map((o) => '**' + o + '**').join(', ');
432
+ (0, jostraca_1.Content)(`
460
433
  The operations available across these entities are ${opBold} — see each entity's
461
434
  own list above for exactly which it supports.
462
435
 
463
436
  `);
464
- }
465
- const otherTargets = sdkTargets.filter((t) => leadTarget && t.name !== leadTarget.name);
466
- if (otherTargets.length > 0) {
467
- (0, jostraca_1.Content)(`## Quickstart in other languages
437
+ }
438
+ });
439
+ const ReadmeTopOtherLanguages = (0, component_1.cmp)(function ReadmeTopOtherLanguages(props) {
440
+ const { ctx$, sdkTargets, leadTarget } = props.s;
441
+ const otherTargets = sdkTargets.filter((t) => leadTarget && t.name !== leadTarget.name);
442
+ if (otherTargets.length > 0) {
443
+ (0, jostraca_1.Content)(`## Quickstart in other languages
468
444
 
469
445
  `);
470
- otherTargets.forEach((tgt) => {
471
- const Quick = (0, optional_1.optionalComponent)(ctx$, tgt, 'ReadmeTopQuick');
472
- if (Quick) {
473
- (0, jostraca_1.Content)(`### ${tgt.title}
446
+ otherTargets.forEach((tgt) => {
447
+ const Quick = (0, optional_1.optionalComponent)(ctx$, tgt, 'ReadmeTopQuick');
448
+ if (Quick) {
449
+ (0, jostraca_1.Content)(`### ${tgt.title}
474
450
 
475
451
  `);
476
- Quick['ReadmeTopQuick']({ target: tgt });
477
- (0, jostraca_1.Content)(`
452
+ Quick['ReadmeTopQuick']({ target: tgt });
453
+ (0, jostraca_1.Content)(`
478
454
  `);
479
- }
480
- });
481
- }
482
- (0, jostraca_1.Content)(`## Direct and prepare
455
+ }
456
+ });
457
+ }
458
+ });
459
+ const ReadmeTopDirect = (0, component_1.cmp)(function ReadmeTopDirect() {
460
+ (0, jostraca_1.Content)(`## Direct and prepare
483
461
 
484
462
  For endpoints the entity model doesn't cover, use the low-level methods:
485
463
 
@@ -490,73 +468,80 @@ Both accept a map with \`path\`, \`method\`, \`params\`, \`query\`,
490
468
  \`headers\`, and \`body\`. See the [How-to guides](#how-to-guides) below.
491
469
 
492
470
  `);
493
- (0, jostraca_1.Content)(`## How-to guides
471
+ });
472
+ const ReadmeTopHowtoGuides = (0, component_1.cmp)(function ReadmeTopHowtoGuides(props) {
473
+ const { ctx$, sdkTargets } = props.s;
474
+ (0, jostraca_1.Content)(`## How-to guides
494
475
 
495
476
  ### Make a direct API call
496
477
 
497
478
  When the entity interface does not cover an endpoint, use \`direct\`:
498
479
 
499
480
  `);
500
- sdkTargets.forEach((tgt) => {
501
- const Howto = (0, optional_1.optionalComponent)(ctx$, tgt, 'ReadmeTopHowto');
502
- if (Howto) {
503
- Howto['ReadmeTopHowto']({ target: tgt });
504
- }
505
- });
506
- (0, jostraca_1.Content)(`## Advanced
481
+ sdkTargets.forEach((tgt) => {
482
+ const Howto = (0, optional_1.optionalComponent)(ctx$, tgt, 'ReadmeTopHowto');
483
+ if (Howto) {
484
+ Howto['ReadmeTopHowto']({ target: tgt });
485
+ }
486
+ });
487
+ });
488
+ const ReadmeTopAdvanced = (0, component_1.cmp)(function ReadmeTopAdvanced(props) {
489
+ const { feature } = props.s;
490
+ (0, jostraca_1.Content)(`## Advanced
507
491
 
508
492
  > Everyday use only needs the sections above. This explains the internals
509
493
  > behind every call — relevant when writing custom features.
510
494
 
511
- Every SDK call runs the same five-stage pipeline:
495
+ Every entity operation runs the same ${(0, FeatureHook_1.pipelineLength)()}-stage pipeline:
512
496
 
513
- 1. **Point** — resolve the API endpoint from the operation definition.
514
- 2. **Spec** — build the HTTP specification (URL, method, headers, body).
515
- 3. **Request** — send the HTTP request.
516
- 4. **Response** — receive and parse the response.
517
- 5. **Result** — extract the result data for the caller.
497
+ ${FeatureHook_1.PIPELINE_STAGES.map((s, i) => (i + 1) + '. **' + s.name + '** — ' + s.purpose).join('\n')}
518
498
 
519
- A feature hook fires at each stage (e.g. \`PrePoint\`, \`PreSpec\`,
520
- \`PreRequest\`), so features can inspect or modify the pipeline without
499
+ A feature hook fires before each stage (e.g. \`${FeatureHook_1.PIPELINE_STAGES[0].hook}\`, \`${FeatureHook_1.PIPELINE_STAGES[1].hook}\`,
500
+ \`${FeatureHook_1.PIPELINE_STAGES[2].hook}\`), so features can inspect or modify the pipeline without
521
501
  forking the SDK.
522
502
 
523
- ### Features
524
-
525
503
  `);
526
- (0, jostraca_1.Content)(`| Feature | Purpose |
504
+ const active = (0, jostraca_1.each)(feature).filter((feat) => feat.active);
505
+ if (0 < active.length) {
506
+ (0, jostraca_1.Content)(`### Features
507
+
508
+ | Feature | Purpose |
527
509
  | --- | --- |
528
510
  `);
529
- (0, jostraca_1.each)(feature, (feat) => {
530
- if (!feat.active)
531
- return;
532
- const purpose = feat.title || feat.Name || feat.name;
511
+ for (const feat of active) {
512
+ const purpose = (0, facts_1.fact)(feat, 'title').cell || feat.Name || feat.name;
533
513
  (0, jostraca_1.Content)(`| **${feat.Name || feat.name}Feature** | ${purpose} |
534
514
  `);
535
- });
515
+ }
536
516
  (0, jostraca_1.Content)(`
537
- Pass custom features via the \`extend\` option at construction time.
538
-
539
- `);
540
- // 11c. Customization: model-driven declarations, in-repo templates and
541
- // components, regeneration that overwrites, customising in `.sdk`, and a
542
- // map of which paths are the project's to edit. Every SDK repo carries
543
- // its own generator, so this belongs in every README. A repository that
544
- // regenerates `.sdk` in full says so, since its copies do not merge.
545
- const mapTarget = sdkTargets[0] || docTargets[0];
546
- const targetDir = mapTarget ? `\`<target>/\`, such as \`${mapTarget.name}/\`` : `\`<target>/\``;
547
- const merging = 'overwrite' !== model.main?.kit?.copies;
548
- const mergeNote = merging ?
549
- `An add merges toolchain updates into the
517
+ `);
518
+ }
519
+ (0, jostraca_1.Content)(`Pass custom features via the \`extend\` option at construction time.
520
+
521
+ `);
522
+ });
523
+ const ReadmeTopCustomizing = (0, component_1.cmp)(function ReadmeTopCustomizing(props) {
524
+ const { model, sdkTargets, docTargets } = props.s;
525
+ // 11c. Customization: model-driven declarations, in-repo templates and
526
+ // components, regeneration that overwrites, customising in `.sdk`, and a
527
+ // map of which paths are the project's to edit. Every SDK repo carries
528
+ // its own generator, so this belongs in every README. A repository that
529
+ // regenerates `.sdk` in full says so, since its copies do not merge.
530
+ const mapTarget = sdkTargets[0] || docTargets[0];
531
+ const targetDir = mapTarget ? `\`<target>/\`, such as \`${mapTarget.name}/\`` : `\`<target>/\``;
532
+ const merging = copymerge_1.MERGE === (0, copymerge_1.copyMode)(model.main?.[types_1.KIT]?.copies);
533
+ const mergeNote = merging ?
534
+ `An add merges toolchain updates into the
550
535
  edited copies, and \`voxgig-sdkgen doctor\` reports any drift from what a
551
536
  resync would write.` :
552
- `This repository regenerates \`.sdk\` in full
537
+ `This repository regenerates \`.sdk\` in full
553
538
  (\`main: kit: copies: 'overwrite'\`): set it to \`'merge'\` before
554
539
  customising, so that an add merges toolchain updates into the edited
555
540
  copies.`;
556
- const copiesRow = merging ?
557
- `Yes. They are this project's copies, and \`target add\` merges toolchain updates into your edits.` :
558
- `Only after setting \`copies\` to \`'merge'\`. This repository regenerates them in full.`;
559
- (0, jostraca_1.Content)(`## Customizing this SDK
541
+ const copiesRow = merging ?
542
+ `Yes. They are this project's copies, and \`target add\` merges toolchain updates into your edits.` :
543
+ `Only after setting \`copies\` to \`'merge'\`. This repository regenerates them in full.`;
544
+ (0, jostraca_1.Content)(`## Customizing this SDK
560
545
 
561
546
  This repository contains its own generator (\`.sdk/\`), so the SDK is
562
547
  customizable without forking any upstream tool:
@@ -613,21 +598,26 @@ How-to: [customize and propagate templates](https://github.com/voxgig/sdkgen/blo
613
598
  The full story: [voxgig.com/sdk/custom](https://voxgig.com/sdk/custom).
614
599
 
615
600
  `);
616
- if (docTargets.length > 0) {
617
- (0, jostraca_1.Content)(`## Per-language documentation
601
+ });
602
+ const ReadmeTopPerLanguage = (0, component_1.cmp)(function ReadmeTopPerLanguage(props) {
603
+ const { docTargets } = props.s;
604
+ if (docTargets.length > 0) {
605
+ (0, jostraca_1.Content)(`## Per-language documentation
618
606
 
619
607
  `);
620
- docTargets.forEach((tgt) => {
621
- (0, jostraca_1.Content)(`- [${tgt.title}](${tgt.name}/README.md)
608
+ docTargets.forEach((tgt) => {
609
+ (0, jostraca_1.Content)(`- [${tgt.title}](${tgt.name}/README.md)
622
610
  `);
623
- });
624
- (0, jostraca_1.Content)(`
611
+ });
612
+ (0, jostraca_1.Content)(`
625
613
  `);
626
- }
627
- const upstreamUrl = (info.contact && info.contact.url)
628
- || (info.servers && info.servers[0] && info.servers[0].url)
629
- || homepage;
630
- (0, jostraca_1.Content)(`## Upstream API
614
+ }
615
+ });
616
+ const ReadmeTopUpstream = (0, component_1.cmp)(function ReadmeTopUpstream(props) {
617
+ const { text } = props.s;
618
+ const upstream = text.upstream;
619
+ const docs = text.docs_url;
620
+ (0, jostraca_1.Content)(`## Upstream API
631
621
 
632
622
  This SDK is generated from the upstream OpenAPI specification. It is an
633
623
  unofficial client and is not affiliated with the API provider.
@@ -636,35 +626,144 @@ The OpenAPI spec(s) this SDK was generated from are kept in the
636
626
  [\`.sdk/def/\`](.sdk/def/) folder.
637
627
 
638
628
  `);
639
- if (upstreamUrl) {
640
- // A per-tenant server URL carries an OpenAPI server variable —
641
- // `https://{instance}.dreamapply.com/api` — and is the right thing to
642
- // SHOW, because it tells the reader the host is theirs to fill in. It is
643
- // not a thing to LINK: the braces are not a resolvable address, so a
644
- // markdown link renders as clickable and dead. Show it as code instead.
645
- const templated = /[{}]/.test(upstreamUrl);
646
- (0, jostraca_1.Content)(templated
647
- ? `- Upstream API: \`${upstreamUrl}\`
629
+ if (upstream.raw) {
630
+ // A per-tenant server URL carries an OpenAPI server variable —
631
+ // `https://{instance}.dreamapply.com/api` — and is the right thing to
632
+ // SHOW, because it tells the reader the host is theirs to fill in. It is
633
+ // not a thing to LINK: the braces are not a resolvable address, so a
634
+ // markdown link renders as clickable and dead. Show it as code instead.
635
+ const templated = /[{}]/.test(upstream.raw);
636
+ (0, jostraca_1.Content)(templated
637
+ ? `- Upstream API: ${upstream.code}
648
638
  `
649
- : `- Upstream API: [${upstreamUrl}](${upstreamUrl})
639
+ : `- Upstream API: [${upstream.inline}](${upstream.link})
650
640
  `);
651
- }
652
- if (docsUrl && docsUrl !== upstreamUrl) {
653
- (0, jostraca_1.Content)(`- Documentation: [${docsUrl}](${docsUrl})
641
+ }
642
+ if (docs.raw && docs.raw !== upstream.raw) {
643
+ (0, jostraca_1.Content)(`- Documentation: [${docs.inline}](${docs.link})
654
644
  `);
655
- }
656
- (0, jostraca_1.Content)(`
645
+ }
646
+ (0, jostraca_1.Content)(`
657
647
  `);
658
- (0, jostraca_1.Content)(`## Security
648
+ });
649
+ const ReadmeTopSecurity = (0, component_1.cmp)(function ReadmeTopSecurity(props) {
650
+ const { model } = props.s;
651
+ (0, jostraca_1.Content)(`## Security
659
652
 
660
653
  Please report security issues ${(0, packageMeta_1.securityContact)(model)}. See [SECURITY.md](SECURITY.md).
661
654
  Do not open public issues for suspected vulnerabilities.
662
655
 
663
656
  `);
664
- (0, jostraca_1.Content)(`---
657
+ });
658
+ const ReadmeTopFooter = (0, component_1.cmp)(function ReadmeTopFooter(props) {
659
+ const { productName } = props.s;
660
+ (0, jostraca_1.Content)(`---
665
661
 
666
662
  Generated from the ${productName} OpenAPI spec by [@voxgig/sdkgen](${SDKGEN_REPO}).
667
663
  `);
664
+ });
665
+ const ReadmeTop = (0, component_1.cmp)(function ReadmeTop(props) {
666
+ const { ctx$ } = props;
667
+ const { model } = ctx$;
668
+ if (model.name && !model.Name)
669
+ (0, jostraca_1.names)(model, model.name);
670
+ const info = (0, text_1.modelText)(model);
671
+ const def = (model.main && model.main.def) || {};
672
+ const text = (0, facts_1.fact)(model.main[types_1.KIT], 'text');
673
+ const productName = text.title.inline || `${model.Name} API`;
674
+ const tagline = text.tagline.inline
675
+ || `${productName} client, generated from the OpenAPI spec.`;
676
+ const aboutMd = text.about_md.text;
677
+ const apiSummary = text.summary.inline;
678
+ const websiteLine = text.website.raw
679
+ ? `Learn more about ${productName} at [${text.website.label}](${text.website.link}).`
680
+ : '';
681
+ // Attribution for API metadata sourced from a third-party catalogue (e.g.
682
+ // freepublicapis.com). Rendered only when the model carries an
683
+ // `info.meta_source` URL, so first-party SDKs never show it. The link points
684
+ // back to the catalogue that kindly supplied the metadata.
685
+ const metaSourceLine = text.meta_source.raw
686
+ ? `Metadata kindly supplied by [${text.meta_source.label}](${text.meta_source.link}).`
687
+ : '';
688
+ const entity = (0, types_1.getModelPath)(model, `main.${types_1.KIT}.entity`);
689
+ const target = (0, types_1.getModelPath)(model, `main.${types_1.KIT}.target`);
690
+ const feature = (0, types_1.getModelPath)(model, `main.${types_1.KIT}.feature`);
691
+ (0, jostraca_1.each)(entity, (ent) => { if (!ent.Name)
692
+ (0, jostraca_1.names)(ent, ent.name); });
693
+ (0, jostraca_1.each)(feature, (feat) => { if (!feat.Name)
694
+ (0, jostraca_1.names)(feat, feat.name); });
695
+ const activeEntities = (0, jostraca_1.each)(entity).filter((e) => e.active !== false);
696
+ const activeTargets = (0, jostraca_1.each)(target).filter((t) => t.active !== false);
697
+ const hasCli = activeTargets.some((t) => t.name === 'go-cli');
698
+ const hasMcp = activeTargets.some((t) => t.name === 'go-mcp');
699
+ const docsOrder = (0, types_1.getModelPath)(model, `main.${types_1.KIT}.config.docs_order`, { only_active: false, required: false }) || [];
700
+ const orderOf = (name) => {
701
+ const i = docsOrder.indexOf(name);
702
+ if (i !== -1)
703
+ return i;
704
+ if (name === 'go-cli')
705
+ return docsOrder.length + 1;
706
+ if (name === 'go-mcp')
707
+ return docsOrder.length + 2;
708
+ return docsOrder.length;
709
+ };
710
+ const ordered = activeTargets
711
+ .slice()
712
+ .sort((a, b) => orderOf(a.name) - orderOf(b.name));
713
+ const isCliOrMcp = (t) => t.name === 'go-cli' || t.name === 'go-mcp';
714
+ const sdkTargets = ordered.filter((t) => !(0, alongside_1.isConsumer)(t));
715
+ // The CLI and the MCP server have surfaces of their own below.
716
+ const consumerTargets = ordered.filter((t) => (0, alongside_1.isConsumer)(t) && !isCliOrMcp(t));
717
+ const docTargets = ordered.filter((t) => !isCliOrMcp(t));
718
+ const pkgTargets = activeTargets
719
+ .filter((t) => (0, packageMeta_1.hasPackageName)(model, t.name))
720
+ .sort((a, b) => orderOf(a.name) - orderOf(b.name));
721
+ const langList = sdkTargets.map((t) => t.title).join(', ');
722
+ const leadTarget = pickLeadTarget(sdkTargets);
723
+ const s = {
724
+ model,
725
+ ctx$,
726
+ info,
727
+ def,
728
+ text,
729
+ productName,
730
+ tagline,
731
+ aboutMd,
732
+ apiSummary,
733
+ websiteLine,
734
+ metaSourceLine,
735
+ feature,
736
+ activeEntities,
737
+ hasCli,
738
+ hasMcp,
739
+ sdkTargets,
740
+ consumerTargets,
741
+ docTargets,
742
+ pkgTargets,
743
+ langList,
744
+ leadTarget,
745
+ };
746
+ (0, jostraca_1.File)({ name: 'README.md' }, () => {
747
+ ReadmeTopTitle({ s });
748
+ ReadmeTopSurfaceLine({ s });
749
+ ReadmeTopFeatureLine({ s });
750
+ ReadmeTopAbout({ s });
751
+ ReadmeTopEntityModel({ s });
752
+ ReadmeTopTesting({ s });
753
+ ReadmeTopPackages({ s });
754
+ ReadmeTopQuickstart({ s });
755
+ ReadmeTopSurfaces({ s });
756
+ ReadmeTopMcp({ s });
757
+ ReadmeTopEntities({ s });
758
+ ReadmeTopOtherLanguages({ s });
759
+ ReadmeTopDirect({ s });
760
+ ReadmeTopHowtoGuides({ s });
761
+ ReadmeTopAdvanced({ s });
762
+ ReadmeTopCustomizing({ s });
763
+ ReadmeTopPerLanguage({ s });
764
+ ReadmeTopUpstream({ s });
765
+ ReadmeTopSecurity({ s });
766
+ ReadmeTopFooter({ s });
668
767
  });
669
768
  });
670
769
  exports.ReadmeTop = ReadmeTop;