@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.
- package/bin/voxgig-sdkgen +1 -1
- package/dist/action/check.js +15 -0
- package/dist/action/check.js.map +1 -1
- package/dist/action/copies.js +1 -0
- package/dist/action/copies.js.map +1 -1
- package/dist/action/doctor.d.ts +21 -2
- package/dist/action/doctor.js +166 -9
- package/dist/action/doctor.js.map +1 -1
- package/dist/action/package.js +9 -0
- package/dist/action/package.js.map +1 -1
- package/dist/action/remove.js +2 -1
- package/dist/action/remove.js.map +1 -1
- package/dist/action/target.d.ts +2 -1
- package/dist/action/target.js +50 -11
- package/dist/action/target.js.map +1 -1
- package/dist/cmp/AgentGuide.js +19 -8
- package/dist/cmp/AgentGuide.js.map +1 -1
- package/dist/cmp/AgentGuideContent.d.ts +6 -4
- package/dist/cmp/AgentGuideContent.js +51 -32
- package/dist/cmp/AgentGuideContent.js.map +1 -1
- package/dist/cmp/AgentGuideFeature.js +5 -3
- package/dist/cmp/AgentGuideFeature.js.map +1 -1
- package/dist/cmp/AgentGuideTop.js +84 -46
- package/dist/cmp/AgentGuideTop.js.map +1 -1
- package/dist/cmp/Changelog.js +12 -1
- package/dist/cmp/Changelog.js.map +1 -1
- package/dist/cmp/Deploy.js +22 -20
- package/dist/cmp/Deploy.js.map +1 -1
- package/dist/cmp/ExternalTarget.js +5 -5
- package/dist/cmp/ExternalTarget.js.map +1 -1
- package/dist/cmp/Feature.js +10 -3
- package/dist/cmp/Feature.js.map +1 -1
- package/dist/cmp/FeatureDocs.d.ts +6 -4
- package/dist/cmp/FeatureDocs.js +14 -39
- package/dist/cmp/FeatureDocs.js.map +1 -1
- package/dist/cmp/FeatureHook.d.ts +7 -1
- package/dist/cmp/FeatureHook.js +34 -1
- package/dist/cmp/FeatureHook.js.map +1 -1
- package/dist/cmp/PublishWorkflow.js +30 -6
- package/dist/cmp/PublishWorkflow.js.map +1 -1
- package/dist/cmp/ReadmeErrors.js +521 -18
- package/dist/cmp/ReadmeErrors.js.map +1 -1
- package/dist/cmp/ReadmeExplanation.js +280 -44
- package/dist/cmp/ReadmeExplanation.js.map +1 -1
- package/dist/cmp/ReadmeFeatures.js +16 -7
- package/dist/cmp/ReadmeFeatures.js.map +1 -1
- package/dist/cmp/ReadmeIntro.js +3 -2
- package/dist/cmp/ReadmeIntro.js.map +1 -1
- package/dist/cmp/ReadmeRefFeatures.js +34 -24
- package/dist/cmp/ReadmeRefFeatures.js.map +1 -1
- package/dist/cmp/ReadmeStation.js +11 -8
- package/dist/cmp/ReadmeStation.js.map +1 -1
- package/dist/cmp/ReadmeTop.js +472 -373
- package/dist/cmp/ReadmeTop.js.map +1 -1
- package/dist/cmp/ReadmeUnions.js +8 -2
- package/dist/cmp/ReadmeUnions.js.map +1 -1
- package/dist/cmp/Security.js +3 -2
- package/dist/cmp/Security.js.map +1 -1
- package/dist/helpers/applicability.d.ts +2 -1
- package/dist/helpers/applicability.js +26 -0
- package/dist/helpers/applicability.js.map +1 -1
- package/dist/helpers/copymerge.d.ts +3 -0
- package/dist/helpers/copymerge.js +43 -10
- package/dist/helpers/copymerge.js.map +1 -1
- package/dist/helpers/doccheck.d.ts +11 -0
- package/dist/helpers/doccheck.js +146 -0
- package/dist/helpers/doccheck.js.map +1 -0
- package/dist/helpers/doctext.d.ts +11 -0
- package/dist/helpers/doctext.js +84 -0
- package/dist/helpers/doctext.js.map +1 -0
- package/dist/helpers/exampleCall.d.ts +16 -0
- package/dist/helpers/exampleCall.js +334 -0
- package/dist/helpers/exampleCall.js.map +1 -0
- package/dist/helpers/exportnames.d.ts +4 -0
- package/dist/helpers/exportnames.js +35 -0
- package/dist/helpers/exportnames.js.map +1 -0
- package/dist/helpers/facts.d.ts +2 -1
- package/dist/helpers/facts.js +37 -2
- package/dist/helpers/facts.js.map +1 -1
- package/dist/helpers/modelcheck.d.ts +2 -1
- package/dist/helpers/modelcheck.js +13 -0
- package/dist/helpers/modelcheck.js.map +1 -1
- package/dist/helpers/opExample.d.ts +9 -2
- package/dist/helpers/opExample.js +22 -2
- package/dist/helpers/opExample.js.map +1 -1
- package/dist/helpers/opShape.d.ts +2 -1
- package/dist/helpers/opShape.js +12 -0
- package/dist/helpers/opShape.js.map +1 -1
- package/dist/helpers/packageMeta.js +21 -8
- package/dist/helpers/packageMeta.js.map +1 -1
- package/dist/helpers/semver.d.ts +2 -1
- package/dist/helpers/semver.js +7 -0
- package/dist/helpers/semver.js.map +1 -1
- package/dist/sdkgen.js +21 -2
- package/dist/sdkgen.js.map +1 -1
- package/dist/testkit.d.ts +1 -0
- package/dist/testkit.js +23 -19
- package/dist/testkit.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utility.js +2 -1
- package/dist/utility.js.map +1 -1
- package/model/fact.aontu +44 -0
- package/model/sdkgen.aontu +6 -2
- package/package.json +3 -1
- package/project/.sdk/src/cmp/c/ReadmeQuick_c.ts +1 -1
- package/project/.sdk/src/cmp/c/ReadmeTopQuick_c.ts +1 -1
- package/project/.sdk/src/cmp/clojure/ReadmeEntity_clojure.ts +12 -3
- package/project/.sdk/src/cmp/scala/ReadmeRef_scala.ts +4 -1
- package/project/.sdk/src/cmp/swift/ReadmeQuick_swift.ts +1 -0
- package/project/.sdk/src/cmp/swift/ReadmeRef_swift.ts +3 -0
- package/project/.sdk/src/cmp/swift/ReadmeTopQuick_swift.ts +2 -1
- package/project/.sdk/src/cmp/zig/ReadmeOptions_zig.ts +1 -1
- package/project/.sdk/src/cmp/zig/ReadmeQuick_zig.ts +2 -2
- package/project/.sdk/src/cmp/zig/ReadmeTopQuick_zig.ts +2 -2
- package/project/sdkgen-package.json +1 -1
- package/src/action/check.ts +21 -0
- package/src/action/copies.ts +2 -0
- package/src/action/doctor.ts +244 -13
- package/src/action/package.ts +10 -0
- package/src/action/remove.ts +2 -1
- package/src/action/target.ts +66 -15
- package/src/cmp/AgentGuide.ts +24 -10
- package/src/cmp/AgentGuideContent.ts +53 -32
- package/src/cmp/AgentGuideFeature.ts +6 -4
- package/src/cmp/AgentGuideTop.ts +108 -47
- package/src/cmp/Changelog.ts +13 -2
- package/src/cmp/Deploy.ts +23 -21
- package/src/cmp/ExternalTarget.ts +6 -6
- package/src/cmp/Feature.ts +11 -4
- package/src/cmp/FeatureDocs.ts +21 -40
- package/src/cmp/FeatureHook.ts +38 -1
- package/src/cmp/PublishWorkflow.ts +33 -7
- package/src/cmp/ReadmeErrors.ts +555 -25
- package/src/cmp/ReadmeExplanation.ts +316 -52
- package/src/cmp/ReadmeFeatures.ts +18 -8
- package/src/cmp/ReadmeIntro.ts +3 -2
- package/src/cmp/ReadmeRefFeatures.ts +39 -27
- package/src/cmp/ReadmeStation.ts +12 -14
- package/src/cmp/ReadmeTop.ts +528 -387
- package/src/cmp/ReadmeUnions.ts +10 -2
- package/src/cmp/Security.ts +3 -2
- package/src/helpers/applicability.ts +28 -0
- package/src/helpers/copymerge.ts +58 -10
- package/src/helpers/doccheck.ts +174 -0
- package/src/helpers/doctext.ts +113 -0
- package/src/helpers/exampleCall.ts +415 -0
- package/src/helpers/exportnames.ts +47 -0
- package/src/helpers/facts.ts +47 -2
- package/src/helpers/modelcheck.ts +16 -0
- package/src/helpers/opExample.ts +34 -2
- package/src/helpers/opShape.ts +13 -0
- package/src/helpers/packageMeta.ts +21 -8
- package/src/helpers/semver.ts +9 -0
- package/src/sdkgen.ts +27 -3
- package/src/testkit.ts +30 -20
- package/src/utility.ts +2 -1
package/src/cmp/ReadmeTop.ts
CHANGED
|
@@ -9,7 +9,8 @@ import {
|
|
|
9
9
|
|
|
10
10
|
import { credentialPlacement } from '../utility'
|
|
11
11
|
import { optionalComponent } from '../helpers/optional'
|
|
12
|
-
import { featureDocs } from './FeatureDocs'
|
|
12
|
+
import { featureDocs, codeList } from './FeatureDocs'
|
|
13
|
+
import { PIPELINE_STAGES, pipelineLength } from './FeatureHook'
|
|
13
14
|
import type { FeatureDoc } from './FeatureDocs'
|
|
14
15
|
|
|
15
16
|
import {
|
|
@@ -21,7 +22,9 @@ import type { ExampleLang, PrimaryCall } from '../helpers/opExample'
|
|
|
21
22
|
import { canonScalarKey } from '../helpers/canonType'
|
|
22
23
|
import { safeVarName, exampleVarName, jsKey } from '../helpers/naming'
|
|
23
24
|
import { modelText } from '../helpers/text'
|
|
25
|
+
import { fact } from '../helpers/facts'
|
|
24
26
|
import { isConsumer } from '../helpers/alongside'
|
|
27
|
+
import { copyMode, MERGE } from '../helpers/copymerge'
|
|
25
28
|
|
|
26
29
|
import {
|
|
27
30
|
installCommand as pkgInstall,
|
|
@@ -97,243 +100,186 @@ function entityExample(lang: ExampleLang, Name: string, call: PrimaryCall | null
|
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
|
|
100
|
-
const
|
|
101
|
-
const {
|
|
102
|
-
const { model } = ctx$
|
|
103
|
-
|
|
104
|
-
if (model.name && !model.Name) names(model, model.name)
|
|
105
|
-
|
|
106
|
-
const info = modelText(model)
|
|
107
|
-
const def = (model.main && model.main.def) || {}
|
|
108
|
-
|
|
109
|
-
const productName = info.title || `${model.Name} API`
|
|
110
|
-
|
|
111
|
-
const tagline = info.tagline
|
|
112
|
-
|| def.tagline
|
|
113
|
-
|| `${productName} client, generated from the OpenAPI spec.`
|
|
114
|
-
|
|
115
|
-
const aboutMd = info.about_md || ''
|
|
116
|
-
const homepage = info.homepage || ''
|
|
117
|
-
const docsUrl = info.docs_url || ''
|
|
118
|
-
const entityDesc = info.entity_desc || {}
|
|
119
|
-
|
|
120
|
-
const apiSummary = (info.summary || '').trim()
|
|
121
|
-
const apiWebsite = (info.website || '').trim()
|
|
122
|
-
const websiteLine = apiWebsite
|
|
123
|
-
? `Learn more about ${productName} at ` +
|
|
124
|
-
`[${apiWebsite.replace(/^https?:\/\//, '').replace(/\/$/, '')}](${apiWebsite}).`
|
|
125
|
-
: ''
|
|
126
|
-
|
|
127
|
-
// Attribution for API metadata sourced from a third-party catalogue (e.g.
|
|
128
|
-
// freepublicapis.com). Rendered only when the model carries an
|
|
129
|
-
// `info.meta_source` URL, so first-party SDKs never show it. The link points
|
|
130
|
-
// back to the catalogue that kindly supplied the metadata.
|
|
131
|
-
const metaSource = (info.meta_source || '').trim()
|
|
132
|
-
const metaSourceLine = metaSource
|
|
133
|
-
? `Metadata kindly supplied by ` +
|
|
134
|
-
`[${metaSource.replace(/^https?:\/\//, '').replace(/\/$/, '')}](${metaSource}).`
|
|
135
|
-
: ''
|
|
136
|
-
|
|
137
|
-
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
138
|
-
const target = getModelPath(model, `main.${KIT}.target`)
|
|
139
|
-
const feature = getModelPath(model, `main.${KIT}.feature`)
|
|
140
|
-
|
|
141
|
-
each(entity, (ent: any) => { if (!ent.Name) names(ent, ent.name) })
|
|
142
|
-
each(feature, (feat: any) => { if (!feat.Name) names(feat, feat.name) })
|
|
143
|
-
|
|
144
|
-
const activeEntities = each(entity).filter((e: any) => e.active !== false)
|
|
145
|
-
const activeTargets = each(target).filter((t: any) => t.active !== false)
|
|
146
|
-
|
|
147
|
-
const hasCli = activeTargets.some((t: any) => t.name === 'go-cli')
|
|
148
|
-
const hasMcp = activeTargets.some((t: any) => t.name === 'go-mcp')
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const docsOrder: string[] = (getModelPath(model, `main.${KIT}.config.docs_order`,
|
|
152
|
-
{ only_active: false, required: false }) as any) || []
|
|
153
|
-
|
|
154
|
-
const orderOf = (name: string): number => {
|
|
155
|
-
const i = docsOrder.indexOf(name)
|
|
156
|
-
if (i !== -1) return i
|
|
157
|
-
if (name === 'go-cli') return docsOrder.length + 1
|
|
158
|
-
if (name === 'go-mcp') return docsOrder.length + 2
|
|
159
|
-
return docsOrder.length
|
|
160
|
-
}
|
|
103
|
+
const ReadmeTopTitle = cmp(function ReadmeTopTitle(props: any) {
|
|
104
|
+
const { model, tagline, apiSummary, websiteLine, metaSourceLine } = props.s
|
|
161
105
|
|
|
162
|
-
|
|
163
|
-
.slice()
|
|
164
|
-
.sort((a: any, b: any) => orderOf(a.name) - orderOf(b.name))
|
|
165
|
-
|
|
166
|
-
const isCliOrMcp = (t: any) => t.name === 'go-cli' || t.name === 'go-mcp'
|
|
167
|
-
|
|
168
|
-
const sdkTargets = ordered.filter((t: any) => !isConsumer(t))
|
|
169
|
-
|
|
170
|
-
// The CLI and the MCP server have surfaces of their own below.
|
|
171
|
-
const consumerTargets = ordered.filter((t: any) => isConsumer(t) && !isCliOrMcp(t))
|
|
172
|
-
|
|
173
|
-
const docTargets = ordered.filter((t: any) => !isCliOrMcp(t))
|
|
174
|
-
|
|
175
|
-
const pkgTargets = activeTargets
|
|
176
|
-
.filter((t: any) => hasPackageName(model, t.name))
|
|
177
|
-
.sort((a: any, b: any) => orderOf(a.name) - orderOf(b.name))
|
|
178
|
-
|
|
179
|
-
const langList = sdkTargets.map((t: any) => t.title).join(', ')
|
|
180
|
-
const leadTarget = pickLeadTarget(sdkTargets)
|
|
181
|
-
|
|
182
|
-
File({ name: 'README.md' }, () => {
|
|
183
|
-
|
|
184
|
-
Content(`# ${model.Name} SDK
|
|
106
|
+
Content(`# ${model.Name} SDK
|
|
185
107
|
|
|
186
108
|
${tagline}
|
|
187
109
|
|
|
188
110
|
`)
|
|
189
|
-
|
|
190
|
-
|
|
111
|
+
if (apiSummary) {
|
|
112
|
+
Content(`${apiSummary}
|
|
191
113
|
|
|
192
114
|
`)
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
115
|
+
}
|
|
116
|
+
if (websiteLine) {
|
|
117
|
+
Content(`${websiteLine}
|
|
196
118
|
|
|
197
119
|
`)
|
|
198
|
-
|
|
199
|
-
|
|
120
|
+
}
|
|
121
|
+
Content(`${nonAffiliation(model)}
|
|
200
122
|
|
|
201
123
|
`)
|
|
202
|
-
|
|
203
|
-
|
|
124
|
+
if (isDefaultPublisher(model)) {
|
|
125
|
+
Content(`Learn more about Voxgig SDKs at [voxgig.com/sdk](${VOXGIG_SDK}).
|
|
204
126
|
|
|
205
127
|
`)
|
|
206
|
-
|
|
128
|
+
}
|
|
207
129
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
130
|
+
// THE GENERATED SITE, LINKED FROM THE TOP, because the repository was the
|
|
131
|
+
// one place it could not be found from. `docs_url` further down is the
|
|
132
|
+
// UPSTREAM API's documentation, not this, and a reader who lands on the
|
|
133
|
+
// repo rather than arriving from a link had no route to the site at all.
|
|
134
|
+
// Empty unless the project actually publishes one -- see docsSiteUrl.
|
|
135
|
+
const siteUrl = docsSiteUrl(model)
|
|
136
|
+
if (siteUrl) {
|
|
137
|
+
Content(`Full documentation for this SDK: [${siteUrl}](${siteUrl})
|
|
216
138
|
|
|
217
139
|
`)
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
140
|
+
}
|
|
141
|
+
if (metaSourceLine) {
|
|
142
|
+
Content(`${metaSourceLine}
|
|
221
143
|
|
|
222
144
|
`)
|
|
223
|
-
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
|
|
224
148
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
149
|
+
const ReadmeTopSurfaceLine = cmp(function ReadmeTopSurfaceLine(props: any) {
|
|
150
|
+
const { hasCli, hasMcp, sdkTargets, consumerTargets, langList } = props.s
|
|
151
|
+
|
|
152
|
+
if (sdkTargets.length > 1) {
|
|
153
|
+
const surfaces = []
|
|
154
|
+
surfaces.push(`${langList} SDKs`)
|
|
155
|
+
if (hasCli) surfaces.push('a CLI with an interactive REPL')
|
|
156
|
+
if (hasMcp) surfaces.push('an MCP server for AI agents')
|
|
157
|
+
consumerTargets.forEach((t: any) => surfaces.push(`the ${t.title} package`))
|
|
158
|
+
const surfaceList = surfaces.length > 1
|
|
159
|
+
? surfaces.slice(0, -1).join(', ') + ', and ' + surfaces[surfaces.length - 1]
|
|
160
|
+
: surfaces[0]
|
|
161
|
+
Content(`> ${surfaceList} — all generated from one OpenAPI spec by [@voxgig/sdkgen](${SDKGEN_REPO}).
|
|
235
162
|
|
|
236
163
|
`)
|
|
237
|
-
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
|
|
238
167
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
168
|
+
const ReadmeTopFeatureLine = cmp(function ReadmeTopFeatureLine(props: any) {
|
|
169
|
+
const { model } = props.s
|
|
170
|
+
|
|
171
|
+
// FEATURES BELONG BESIDE THE TARGETS. What an SDK can do is as much a
|
|
172
|
+
// reason to choose it as which language it is in, and a reader who has to
|
|
173
|
+
// scroll past every language section to discover that retries, caching and
|
|
174
|
+
// tracing are built in has already decided it is a thin HTTP wrapper.
|
|
175
|
+
// Named here, in one line, with the detail left to each target's README.
|
|
176
|
+
const features = featureDocs(model)
|
|
177
|
+
if (0 < features.length) {
|
|
178
|
+
const on = features.filter((f: FeatureDoc) => f.on).map((f: FeatureDoc) => f.name)
|
|
179
|
+
const state = 0 === on.length ? `opt-in,
|
|
180
|
+
> inactive until switched on, and configured per client.` : `configured per client.
|
|
181
|
+
> ${codeList(on)} ${1 === on.length ? 'runs' : 'run'} by default${on.length < features.length ?
|
|
182
|
+
'; the rest are opt-in, inactive until switched on' : ''}.`
|
|
183
|
+
Content(`> **Features:** ${features.map((f: FeatureDoc) => '`' + f.name + '`').join(', ')} — ${state} See the Features
|
|
248
184
|
> section of any SDK README below for what each one does.
|
|
249
185
|
|
|
250
186
|
`)
|
|
251
|
-
|
|
187
|
+
}
|
|
188
|
+
})
|
|
189
|
+
|
|
252
190
|
|
|
253
|
-
|
|
254
|
-
|
|
191
|
+
const ReadmeTopAbout = cmp(function ReadmeTopAbout(props: any) {
|
|
192
|
+
const { text, productName, aboutMd } = props.s
|
|
255
193
|
|
|
256
|
-
|
|
194
|
+
if (aboutMd) {
|
|
195
|
+
Content(`## About ${productName}
|
|
196
|
+
|
|
197
|
+
${aboutMd}
|
|
257
198
|
|
|
258
199
|
`)
|
|
259
|
-
|
|
260
|
-
|
|
200
|
+
} else if (text.desc.text) {
|
|
201
|
+
Content(`${text.desc.text}
|
|
261
202
|
|
|
262
203
|
`)
|
|
263
|
-
|
|
204
|
+
}
|
|
205
|
+
})
|
|
264
206
|
|
|
265
|
-
if (activeEntities.length > 0) {
|
|
266
|
-
const entNames = activeEntities.map((e: any) => e.Name)
|
|
267
|
-
const entCount = entNames.length
|
|
268
|
-
const entList = entCount > 1
|
|
269
|
-
? entNames.slice(0, -1).join(', ') + ' and ' + entNames[entNames.length - 1]
|
|
270
|
-
: entNames[0]
|
|
271
|
-
const NAME_INLINE_MAX = 6
|
|
272
|
-
const inlineNames = entCount <= NAME_INLINE_MAX
|
|
273
|
-
const surface = inlineNames
|
|
274
|
-
? `a small set of **semantic entities** — ${entList} —`
|
|
275
|
-
: `**${entCount} semantic entities**`
|
|
276
|
-
const seeEntities = inlineNames
|
|
277
|
-
? ''
|
|
278
|
-
: ' See the [Entities](#entities) table below for the full list.'
|
|
279
|
-
const exEnt = activeEntities[0]
|
|
280
|
-
const ex = exEnt.Name
|
|
281
|
-
const exLower = exampleVarName(ex.toLowerCase(), 'ts')
|
|
282
|
-
// The example call uses the entity's PRIMARY op — an op it actually
|
|
283
|
-
// exposes (prefer list -> the array, then load -> the record, else a
|
|
284
|
-
// create with its required fields). A create-only entity therefore never
|
|
285
|
-
// shows a phantom .list()/.load() that would not compile. If it exposes
|
|
286
|
-
// only remove (or nothing), the op line is omitted entirely.
|
|
287
|
-
const primaryOp = entityPrimaryOp(exEnt)
|
|
288
|
-
let exCall = ''
|
|
289
|
-
const exIdField = entityIdField(exEnt)
|
|
290
|
-
const exListArg = listMatchArg('ts', exEnt)
|
|
291
|
-
const exLoadArg = matchArg('ts', exEnt, 'load', exIdField,
|
|
292
|
-
idLiteral(exEnt, 'load', exIdField))
|
|
293
|
-
|
|
294
|
-
if ('list' === primaryOp) {
|
|
295
|
-
exCall = `const items = await client.${ex}().list(${exListArg})`
|
|
296
|
-
} else if ('load' === primaryOp) {
|
|
297
|
-
exCall = `const ${exLower} = await client.${ex}().load(${exLoadArg})`
|
|
298
|
-
} else if ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp) {
|
|
299
|
-
const exIdF = entityIdField(exEnt)
|
|
300
|
-
// Drop the id only when the request shape says it is OPTIONAL. It is
|
|
301
|
-
// server-assigned on a normal create, but an op whose id comes from a
|
|
302
|
-
// PATH PARAMETER requires it, and the typed CreateData then rejects a
|
|
303
|
-
// body without it. Same rule as dataArg in helpers/opExample.
|
|
304
|
-
const shapeItems = requestExampleItems(exEnt, primaryOp)
|
|
305
|
-
.filter((it: any) =>
|
|
306
|
-
(it.name !== exIdF && it.name !== 'id') || !it.optional)
|
|
307
|
-
const required = shapeItems.filter((it: any) => !it.optional)
|
|
308
|
-
const chosen = required.length ? required : shapeItems.slice(0, 3)
|
|
309
|
-
const bodyLines = chosen.map((it: any) => ` ${jsKey(it.name)}: ${tsExampleLiteral(it.type)},`)
|
|
310
|
-
const body = bodyLines.length ? `\n${bodyLines.join('\n')}\n` : ''
|
|
311
|
-
exCall = `const ${exLower} = await client.${ex}().${primaryOp}({${body}})`
|
|
312
|
-
}
|
|
313
|
-
const CANON_OPS = ['list', 'load', 'create', 'update', 'patch', 'remove']
|
|
314
|
-
const opSet = new Set<string>()
|
|
315
|
-
activeEntities.forEach((e: any) => Object.keys(e.op || {})
|
|
316
|
-
.forEach((o: string) => { if ((e.op as any)[o] && (e.op as any)[o].active !== false) opSet.add(o) }))
|
|
317
|
-
const opNames = CANON_OPS.filter((o) => opSet.has(o)).concat([...opSet].filter((o) => !CANON_OPS.includes(o)))
|
|
318
|
-
const opList = (opNames.length ? opNames : ['list', 'load']).map((o) => '`' + o + '`').join(', ')
|
|
319
|
-
|
|
320
|
-
// In the SDK's own language: ts when it has one, else the first the
|
|
321
|
-
// example helpers can write, else no example at all.
|
|
322
|
-
const lang = exampleLang(model, sdkTargets)
|
|
323
|
-
let snippet = ''
|
|
324
|
-
if ('ts' === lang) {
|
|
325
|
-
snippet = `const client = new ${model.Name}SDK()${exCall ? '\n' + exCall : ''}`
|
|
326
|
-
}
|
|
327
|
-
else if (null != lang) {
|
|
328
|
-
const call = ['list', 'load', 'create', 'update', 'patch'].includes(String(primaryOp))
|
|
329
|
-
? primaryOpCall(lang, ex, exampleVarName(ex.toLowerCase(), lang), primaryOp!, exIdField, exEnt)
|
|
330
|
-
: null
|
|
331
|
-
snippet = entityExample(lang, model.Name, call)
|
|
332
|
-
}
|
|
333
|
-
const exBlock = '' === snippet ? '.' :
|
|
334
|
-
`:\n\n\`\`\`${EXAMPLE_FENCE[lang!]}\n${snippet}\n\`\`\``
|
|
335
207
|
|
|
336
|
-
|
|
208
|
+
const ReadmeTopEntityModel = cmp(function ReadmeTopEntityModel(props: any) {
|
|
209
|
+
const { model, activeEntities, sdkTargets } = props.s
|
|
210
|
+
|
|
211
|
+
if (activeEntities.length > 0) {
|
|
212
|
+
const entNames = activeEntities.map((e: any) => e.Name)
|
|
213
|
+
const entCount = entNames.length
|
|
214
|
+
const entList = entCount > 1
|
|
215
|
+
? entNames.slice(0, -1).join(', ') + ' and ' + entNames[entNames.length - 1]
|
|
216
|
+
: entNames[0]
|
|
217
|
+
const NAME_INLINE_MAX = 6
|
|
218
|
+
const inlineNames = entCount <= NAME_INLINE_MAX
|
|
219
|
+
const surface = inlineNames
|
|
220
|
+
? `a small set of **semantic entities** — ${entList} —`
|
|
221
|
+
: `**${entCount} semantic entities**`
|
|
222
|
+
const seeEntities = inlineNames
|
|
223
|
+
? ''
|
|
224
|
+
: ' See the [Entities](#entities) table below for the full list.'
|
|
225
|
+
const exEnt = activeEntities[0]
|
|
226
|
+
const ex = exEnt.Name
|
|
227
|
+
const exLower = exampleVarName(ex.toLowerCase(), 'ts')
|
|
228
|
+
// The example call uses the entity's PRIMARY op — an op it actually
|
|
229
|
+
// exposes (prefer list -> the array, then load -> the record, else a
|
|
230
|
+
// create with its required fields). A create-only entity therefore never
|
|
231
|
+
// shows a phantom .list()/.load() that would not compile. If it exposes
|
|
232
|
+
// only remove (or nothing), the op line is omitted entirely.
|
|
233
|
+
const primaryOp = entityPrimaryOp(exEnt)
|
|
234
|
+
let exCall = ''
|
|
235
|
+
const exIdField = entityIdField(exEnt)
|
|
236
|
+
const exListArg = listMatchArg('ts', exEnt)
|
|
237
|
+
const exLoadArg = matchArg('ts', exEnt, 'load', exIdField,
|
|
238
|
+
idLiteral(exEnt, 'load', exIdField))
|
|
239
|
+
|
|
240
|
+
if ('list' === primaryOp) {
|
|
241
|
+
exCall = `const items = await client.${ex}().list(${exListArg})`
|
|
242
|
+
} else if ('load' === primaryOp) {
|
|
243
|
+
exCall = `const ${exLower} = await client.${ex}().load(${exLoadArg})`
|
|
244
|
+
} else if ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp) {
|
|
245
|
+
const exIdF = entityIdField(exEnt)
|
|
246
|
+
// Drop the id only when the request shape says it is OPTIONAL. It is
|
|
247
|
+
// server-assigned on a normal create, but an op whose id comes from a
|
|
248
|
+
// PATH PARAMETER requires it, and the typed CreateData then rejects a
|
|
249
|
+
// body without it. Same rule as dataArg in helpers/opExample.
|
|
250
|
+
const shapeItems = requestExampleItems(exEnt, primaryOp)
|
|
251
|
+
.filter((it: any) =>
|
|
252
|
+
(it.name !== exIdF && it.name !== 'id') || !it.optional)
|
|
253
|
+
const required = shapeItems.filter((it: any) => !it.optional)
|
|
254
|
+
const chosen = required.length ? required : shapeItems.slice(0, 3)
|
|
255
|
+
const bodyLines = chosen.map((it: any) => ` ${jsKey(it.name)}: ${tsExampleLiteral(it.type)},`)
|
|
256
|
+
const body = bodyLines.length ? `\n${bodyLines.join('\n')}\n` : ''
|
|
257
|
+
exCall = `const ${exLower} = await client.${ex}().${primaryOp}({${body}})`
|
|
258
|
+
}
|
|
259
|
+
const CANON_OPS = ['list', 'load', 'create', 'update', 'patch', 'remove']
|
|
260
|
+
const opSet = new Set<string>()
|
|
261
|
+
activeEntities.forEach((e: any) => Object.keys(e.op || {})
|
|
262
|
+
.forEach((o: string) => { if ((e.op as any)[o] && (e.op as any)[o].active !== false) opSet.add(o) }))
|
|
263
|
+
const opNames = CANON_OPS.filter((o) => opSet.has(o)).concat([...opSet].filter((o) => !CANON_OPS.includes(o)))
|
|
264
|
+
const opList = (opNames.length ? opNames : ['list', 'load']).map((o) => '`' + o + '`').join(', ')
|
|
265
|
+
|
|
266
|
+
// In the SDK's own language: ts when it has one, else the first the
|
|
267
|
+
// example helpers can write, else no example at all.
|
|
268
|
+
const lang = exampleLang(model, sdkTargets)
|
|
269
|
+
let snippet = ''
|
|
270
|
+
if ('ts' === lang) {
|
|
271
|
+
snippet = `const client = new ${model.Name}SDK()${exCall ? '\n' + exCall : ''}`
|
|
272
|
+
}
|
|
273
|
+
else if (null != lang) {
|
|
274
|
+
const call = ['list', 'load', 'create', 'update', 'patch'].includes(String(primaryOp))
|
|
275
|
+
? primaryOpCall(lang, ex, exampleVarName(ex.toLowerCase(), lang), primaryOp!, exIdField, exEnt)
|
|
276
|
+
: null
|
|
277
|
+
snippet = entityExample(lang, model.Name, call)
|
|
278
|
+
}
|
|
279
|
+
const exBlock = '' === snippet ? '.' :
|
|
280
|
+
`:\n\n\`\`\`${EXAMPLE_FENCE[lang!]}\n${snippet}\n\`\`\``
|
|
281
|
+
|
|
282
|
+
Content(`## Entities, not endpoints
|
|
337
283
|
|
|
338
284
|
This SDK exposes the API as ${surface} that you
|
|
339
285
|
call directly, instead of assembling URL paths and query strings.${seeEntities} Entities are
|
|
@@ -344,126 +290,152 @@ Thinking in entities keeps the mental model small — for people and AI agents a
|
|
|
344
290
|
rather than reasoning about raw HTTP routes and query parameters.
|
|
345
291
|
|
|
346
292
|
`)
|
|
347
|
-
|
|
293
|
+
}
|
|
294
|
+
})
|
|
348
295
|
|
|
349
|
-
|
|
350
|
-
|
|
296
|
+
|
|
297
|
+
const ReadmeTopTesting = cmp(function ReadmeTopTesting(props: any) {
|
|
298
|
+
const { ctx$, sdkTargets } = props.s
|
|
299
|
+
|
|
300
|
+
if (sdkTargets.length > 0) {
|
|
301
|
+
Content(`## Offline unit testing
|
|
351
302
|
|
|
352
303
|
Every SDK ships a built-in **test mode** that swaps the HTTP transport for
|
|
353
304
|
an in-memory mock, so your unit tests run fully offline — no server, no
|
|
354
305
|
network, and no credentials:
|
|
355
306
|
|
|
356
307
|
`)
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
308
|
+
sdkTargets.forEach((tgt: any) => {
|
|
309
|
+
const Test =
|
|
310
|
+
optionalComponent(ctx$, tgt, 'ReadmeTopTest')
|
|
311
|
+
if (Test) {
|
|
312
|
+
Content(`### ${tgt.title}
|
|
362
313
|
|
|
363
314
|
`)
|
|
364
|
-
|
|
365
|
-
|
|
315
|
+
Test['ReadmeTopTest']({ target: tgt })
|
|
316
|
+
Content(`
|
|
366
317
|
`)
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
318
|
+
}
|
|
319
|
+
})
|
|
320
|
+
}
|
|
321
|
+
})
|
|
322
|
+
|
|
370
323
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
324
|
+
const ReadmeTopPackages = cmp(function ReadmeTopPackages(props: any) {
|
|
325
|
+
const { model, pkgTargets } = props.s
|
|
326
|
+
|
|
327
|
+
// 3. Packages — real published package name + install command per
|
|
328
|
+
// ecosystem. A package that is NOT yet live on its registry (the fleet
|
|
329
|
+
// default: 'pending') must NOT advertise a `npm install ...` that 404s —
|
|
330
|
+
// its Install cell links to the target README's install section instead,
|
|
331
|
+
// as do go-cli and go-mcp, which the Go proxy cannot install.
|
|
332
|
+
if (pkgTargets.length > 0) {
|
|
333
|
+
Content(`## Packages
|
|
378
334
|
|
|
379
335
|
| Language | Package | Install |
|
|
380
336
|
| --- | --- | --- |
|
|
381
337
|
`)
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
338
|
+
pkgTargets.forEach((tgt: any) => {
|
|
339
|
+
const state = registryState(model, tgt.name)
|
|
340
|
+
let cell: string
|
|
341
|
+
if ('active' === state) {
|
|
342
|
+
const cmd = installCommand(tgt, model)
|
|
343
|
+
cell = cmd
|
|
344
|
+
? '`' + cmd + '`'
|
|
345
|
+
: `see [${tgt.name}/README.md](${tgt.name}/README.md#install)`
|
|
346
|
+
} else if ('tag' === state) {
|
|
347
|
+
const cmd = vendorCommand(model, tgt.name)
|
|
348
|
+
cell = cmd
|
|
349
|
+
? '`' + cmd + '`'
|
|
350
|
+
: `build from source — [${tgt.name}/README.md](${tgt.name}/README.md)`
|
|
351
|
+
} else {
|
|
352
|
+
// The target README always gives a route that works without a
|
|
353
|
+
// tag, which a repository may not have.
|
|
354
|
+
cell = `publish pending — [install from source](${tgt.name}/README.md#install)`
|
|
355
|
+
}
|
|
356
|
+
Content(`| ${tgt.title} | \`${packageName(model, tgt.name)}\` | ${cell} |
|
|
357
|
+
`)
|
|
358
|
+
})
|
|
359
|
+
Content(`
|
|
403
360
|
`)
|
|
404
|
-
|
|
361
|
+
}
|
|
362
|
+
})
|
|
363
|
+
|
|
405
364
|
|
|
406
|
-
|
|
407
|
-
|
|
365
|
+
const ReadmeTopQuickstart = cmp(function ReadmeTopQuickstart(props: any) {
|
|
366
|
+
const { model, ctx$, leadTarget } = props.s
|
|
367
|
+
|
|
368
|
+
if (leadTarget) {
|
|
369
|
+
Content(`## Quickstart
|
|
408
370
|
|
|
409
371
|
### ${leadTarget.title}
|
|
410
372
|
|
|
411
373
|
`)
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
374
|
+
const LeadQuick =
|
|
375
|
+
optionalComponent(ctx$, leadTarget, 'ReadmeTopQuick')
|
|
376
|
+
if (LeadQuick) {
|
|
377
|
+
LeadQuick['ReadmeTopQuick']({ target: leadTarget })
|
|
378
|
+
}
|
|
379
|
+
const placement = credentialPlacement(model)
|
|
380
|
+
Content(`
|
|
419
381
|
${'' === placement ? '' : placement + '\n\n'}See the [${leadTarget.title} README](${leadTarget.name}/README.md) for the full guide.
|
|
420
382
|
|
|
421
383
|
`)
|
|
422
|
-
|
|
384
|
+
}
|
|
385
|
+
})
|
|
423
386
|
|
|
424
|
-
|
|
425
|
-
|
|
387
|
+
|
|
388
|
+
const ReadmeTopSurfaces = cmp(function ReadmeTopSurfaces(props: any) {
|
|
389
|
+
const { hasCli, hasMcp, sdkTargets, consumerTargets, langList } = props.s
|
|
390
|
+
|
|
391
|
+
if (sdkTargets.length > 0 || hasCli || hasMcp || consumerTargets.length > 0) {
|
|
392
|
+
Content(`## Surfaces
|
|
426
393
|
|
|
427
394
|
| Surface | Path |
|
|
428
395
|
| --- | --- |
|
|
429
396
|
`)
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
397
|
+
if (sdkTargets.length > 0) {
|
|
398
|
+
const paths = sdkTargets.map((t: any) => `\`${t.name}/\``).join(' ')
|
|
399
|
+
Content(`| **SDK** (${langList}) | ${paths} |
|
|
433
400
|
`)
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
401
|
+
}
|
|
402
|
+
if (hasCli) {
|
|
403
|
+
Content(`| **CLI** | \`go-cli/\` |
|
|
437
404
|
`)
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
405
|
+
}
|
|
406
|
+
if (hasMcp) {
|
|
407
|
+
Content(`| **MCP server** | \`go-mcp/\` |
|
|
441
408
|
`)
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
409
|
+
}
|
|
410
|
+
consumerTargets.forEach((t: any) => {
|
|
411
|
+
Content(`| **${t.title}** | \`${t.name}/\` |
|
|
445
412
|
`)
|
|
446
|
-
|
|
447
|
-
|
|
413
|
+
})
|
|
414
|
+
Content(`
|
|
448
415
|
`)
|
|
449
|
-
|
|
416
|
+
}
|
|
417
|
+
})
|
|
450
418
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
419
|
+
|
|
420
|
+
const ReadmeTopMcp = cmp(function ReadmeTopMcp(props: any) {
|
|
421
|
+
const { model, hasMcp } = props.s
|
|
422
|
+
|
|
423
|
+
if (hasMcp) {
|
|
424
|
+
const mcpOps = mcpTools(model).map((tool) => tool.op)
|
|
425
|
+
const mcpWrite = true === model.main?.[KIT]?.target?.['go-mcp']?.tool?.write
|
|
426
|
+
const toggle = "`main: kit: target: 'go-mcp': tool: write: true`"
|
|
427
|
+
const opText = mcpOps.length < 2 ? mcpOps.join('') :
|
|
428
|
+
mcpOps.slice(0, -1).join(', ') + ' and ' + mcpOps[mcpOps.length - 1]
|
|
429
|
+
// What the server reads and writes is what it registers, not the flag.
|
|
430
|
+
const reads = mcpOps.some((op) => MCP_WRITE_OPS.includes(op)) ? '' : mcpWrite ?
|
|
431
|
+
' It only reads, as no entity has a create, update, patch or remove a plain call runs.' :
|
|
432
|
+
` It only reads: create, update, patch and remove become tools when the SDK's model sets
|
|
461
433
|
${toggle}.`
|
|
462
|
-
|
|
434
|
+
Content(0 === mcpOps.length ? `## Use it from an AI agent (MCP)
|
|
463
435
|
|
|
464
436
|
The generated MCP server has no tools for this SDK: no entity has a list or
|
|
465
437
|
load a plain call runs${mcpWrite ? ', or a create, update, patch or remove' :
|
|
466
|
-
|
|
438
|
+
`, and create, update, patch and remove are off until the SDK's model sets
|
|
467
439
|
${toggle}`}.
|
|
468
440
|
|
|
469
441
|
` : `## Use it from an AI agent (MCP)
|
|
@@ -489,10 +461,15 @@ Then add it to your agent's MCP config (Claude Desktop, Cursor, etc.):
|
|
|
489
461
|
\`\`\`
|
|
490
462
|
|
|
491
463
|
`)
|
|
492
|
-
|
|
464
|
+
}
|
|
465
|
+
})
|
|
493
466
|
|
|
494
|
-
|
|
495
|
-
|
|
467
|
+
|
|
468
|
+
const ReadmeTopEntities = cmp(function ReadmeTopEntities(props: any) {
|
|
469
|
+
const { activeEntities } = props.s
|
|
470
|
+
|
|
471
|
+
if (activeEntities.length > 0) {
|
|
472
|
+
Content(`## Entities
|
|
496
473
|
|
|
497
474
|
The API exposes ${activeEntities.length === 1 ? 'one entity' : activeEntities.length + ' entities'}:
|
|
498
475
|
|
|
@@ -500,48 +477,56 @@ The API exposes ${activeEntities.length === 1 ? 'one entity' : activeEntities.le
|
|
|
500
477
|
| --- | --- | --- |
|
|
501
478
|
`)
|
|
502
479
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
480
|
+
activeEntities.map((ent: any) => {
|
|
481
|
+
const ops = ent.op || {}
|
|
482
|
+
const opNames = Object.keys(ops).filter((o: string) => (ops as any)[o]?.active !== false)
|
|
483
|
+
const entdesc = fact(ent, 'desc').cell ||
|
|
484
|
+
`The ${ent.Name} entity${opNames.length ? ' (' + opNames.join(', ') + ')' : ''}.`
|
|
485
|
+
const path = entityPath(ent)
|
|
486
|
+
Content(`| **${ent.Name}** | ${entdesc} | \`${path}\` |
|
|
510
487
|
`)
|
|
511
|
-
|
|
488
|
+
})
|
|
512
489
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
490
|
+
const opUnion = new Set<string>()
|
|
491
|
+
activeEntities.forEach((e: any) => Object.keys(e.op || {})
|
|
492
|
+
.forEach((o: string) => { if ((e.op as any)[o]?.active !== false) opUnion.add(o) }))
|
|
493
|
+
const opAvail = ['load', 'list', 'create', 'update', 'patch', 'remove'].filter((o) => opUnion.has(o))
|
|
494
|
+
const opBold = (opAvail.length ? opAvail : ['load', 'list']).map((o) => '**' + o + '**').join(', ')
|
|
495
|
+
Content(`
|
|
519
496
|
The operations available across these entities are ${opBold} — see each entity's
|
|
520
497
|
own list above for exactly which it supports.
|
|
521
498
|
|
|
522
499
|
`)
|
|
523
|
-
|
|
500
|
+
}
|
|
501
|
+
})
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
const ReadmeTopOtherLanguages = cmp(function ReadmeTopOtherLanguages(props: any) {
|
|
505
|
+
const { ctx$, sdkTargets, leadTarget } = props.s
|
|
524
506
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
507
|
+
const otherTargets = sdkTargets.filter((t: any) => leadTarget && t.name !== leadTarget.name)
|
|
508
|
+
if (otherTargets.length > 0) {
|
|
509
|
+
Content(`## Quickstart in other languages
|
|
528
510
|
|
|
529
511
|
`)
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
512
|
+
otherTargets.forEach((tgt: any) => {
|
|
513
|
+
const Quick =
|
|
514
|
+
optionalComponent(ctx$, tgt, 'ReadmeTopQuick')
|
|
515
|
+
if (Quick) {
|
|
516
|
+
Content(`### ${tgt.title}
|
|
535
517
|
|
|
536
518
|
`)
|
|
537
|
-
|
|
538
|
-
|
|
519
|
+
Quick['ReadmeTopQuick']({ target: tgt })
|
|
520
|
+
Content(`
|
|
539
521
|
`)
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
522
|
+
}
|
|
523
|
+
})
|
|
524
|
+
}
|
|
525
|
+
})
|
|
543
526
|
|
|
544
|
-
|
|
527
|
+
|
|
528
|
+
const ReadmeTopDirect = cmp(function ReadmeTopDirect() {
|
|
529
|
+
Content(`## Direct and prepare
|
|
545
530
|
|
|
546
531
|
For endpoints the entity model doesn't cover, use the low-level methods:
|
|
547
532
|
|
|
@@ -552,8 +537,13 @@ Both accept a map with \`path\`, \`method\`, \`params\`, \`query\`,
|
|
|
552
537
|
\`headers\`, and \`body\`. See the [How-to guides](#how-to-guides) below.
|
|
553
538
|
|
|
554
539
|
`)
|
|
540
|
+
})
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
const ReadmeTopHowtoGuides = cmp(function ReadmeTopHowtoGuides(props: any) {
|
|
544
|
+
const { ctx$, sdkTargets } = props.s
|
|
555
545
|
|
|
556
|
-
|
|
546
|
+
Content(`## How-to guides
|
|
557
547
|
|
|
558
548
|
### Make a direct API call
|
|
559
549
|
|
|
@@ -561,70 +551,79 @@ When the entity interface does not cover an endpoint, use \`direct\`:
|
|
|
561
551
|
|
|
562
552
|
`)
|
|
563
553
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
554
|
+
sdkTargets.forEach((tgt: any) => {
|
|
555
|
+
const Howto =
|
|
556
|
+
optionalComponent(ctx$, tgt, 'ReadmeTopHowto')
|
|
557
|
+
if (Howto) {
|
|
558
|
+
Howto['ReadmeTopHowto']({ target: tgt })
|
|
559
|
+
}
|
|
560
|
+
})
|
|
561
|
+
})
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
const ReadmeTopAdvanced = cmp(function ReadmeTopAdvanced(props: any) {
|
|
565
|
+
const { feature } = props.s
|
|
571
566
|
|
|
572
|
-
|
|
567
|
+
Content(`## Advanced
|
|
573
568
|
|
|
574
569
|
> Everyday use only needs the sections above. This explains the internals
|
|
575
570
|
> behind every call — relevant when writing custom features.
|
|
576
571
|
|
|
577
|
-
Every
|
|
572
|
+
Every entity operation runs the same ${pipelineLength()}-stage pipeline:
|
|
578
573
|
|
|
579
|
-
1. **
|
|
580
|
-
2. **Spec** — build the HTTP specification (URL, method, headers, body).
|
|
581
|
-
3. **Request** — send the HTTP request.
|
|
582
|
-
4. **Response** — receive and parse the response.
|
|
583
|
-
5. **Result** — extract the result data for the caller.
|
|
574
|
+
${PIPELINE_STAGES.map((s, i) => (i + 1) + '. **' + s.name + '** — ' + s.purpose).join('\n')}
|
|
584
575
|
|
|
585
|
-
A feature hook fires
|
|
586
|
-
\`
|
|
576
|
+
A feature hook fires before each stage (e.g. \`${PIPELINE_STAGES[0].hook}\`, \`${PIPELINE_STAGES[1].hook}\`,
|
|
577
|
+
\`${PIPELINE_STAGES[2].hook}\`), so features can inspect or modify the pipeline without
|
|
587
578
|
forking the SDK.
|
|
588
579
|
|
|
589
|
-
### Features
|
|
590
|
-
|
|
591
580
|
`)
|
|
592
581
|
|
|
593
|
-
|
|
582
|
+
const active = each(feature).filter((feat: any) => feat.active)
|
|
583
|
+
if (0 < active.length) {
|
|
584
|
+
Content(`### Features
|
|
585
|
+
|
|
586
|
+
| Feature | Purpose |
|
|
594
587
|
| --- | --- |
|
|
595
588
|
`)
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
const purpose = feat.title || feat.Name || feat.name
|
|
589
|
+
for (const feat of active) {
|
|
590
|
+
const purpose = fact(feat, 'title').cell || feat.Name || feat.name
|
|
599
591
|
Content(`| **${feat.Name || feat.name}Feature** | ${purpose} |
|
|
600
592
|
`)
|
|
601
|
-
}
|
|
602
|
-
|
|
593
|
+
}
|
|
603
594
|
Content(`
|
|
604
|
-
|
|
595
|
+
`)
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
Content(`Pass custom features via the \`extend\` option at construction time.
|
|
605
599
|
|
|
606
600
|
`)
|
|
601
|
+
})
|
|
607
602
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
603
|
+
|
|
604
|
+
const ReadmeTopCustomizing = cmp(function ReadmeTopCustomizing(props: any) {
|
|
605
|
+
const { model, sdkTargets, docTargets } = props.s
|
|
606
|
+
|
|
607
|
+
// 11c. Customization: model-driven declarations, in-repo templates and
|
|
608
|
+
// components, regeneration that overwrites, customising in `.sdk`, and a
|
|
609
|
+
// map of which paths are the project's to edit. Every SDK repo carries
|
|
610
|
+
// its own generator, so this belongs in every README. A repository that
|
|
611
|
+
// regenerates `.sdk` in full says so, since its copies do not merge.
|
|
612
|
+
const mapTarget = sdkTargets[0] || docTargets[0]
|
|
613
|
+
const targetDir = mapTarget ? `\`<target>/\`, such as \`${mapTarget.name}/\`` : `\`<target>/\``
|
|
614
|
+
const merging = MERGE === copyMode(model.main?.[KIT]?.copies)
|
|
615
|
+
const mergeNote = merging ?
|
|
616
|
+
`An add merges toolchain updates into the
|
|
618
617
|
edited copies, and \`voxgig-sdkgen doctor\` reports any drift from what a
|
|
619
618
|
resync would write.` :
|
|
620
|
-
|
|
619
|
+
`This repository regenerates \`.sdk\` in full
|
|
621
620
|
(\`main: kit: copies: 'overwrite'\`): set it to \`'merge'\` before
|
|
622
621
|
customising, so that an add merges toolchain updates into the edited
|
|
623
622
|
copies.`
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
623
|
+
const copiesRow = merging ?
|
|
624
|
+
`Yes. They are this project's copies, and \`target add\` merges toolchain updates into your edits.` :
|
|
625
|
+
`Only after setting \`copies\` to \`'merge'\`. This repository regenerates them in full.`
|
|
626
|
+
Content(`## Customizing this SDK
|
|
628
627
|
|
|
629
628
|
This repository contains its own generator (\`.sdk/\`), so the SDK is
|
|
630
629
|
customizable without forking any upstream tool:
|
|
@@ -681,23 +680,31 @@ How-to: [customize and propagate templates](https://github.com/voxgig/sdkgen/blo
|
|
|
681
680
|
The full story: [voxgig.com/sdk/custom](https://voxgig.com/sdk/custom).
|
|
682
681
|
|
|
683
682
|
`)
|
|
683
|
+
})
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
const ReadmeTopPerLanguage = cmp(function ReadmeTopPerLanguage(props: any) {
|
|
687
|
+
const { docTargets } = props.s
|
|
684
688
|
|
|
685
|
-
|
|
686
|
-
|
|
689
|
+
if (docTargets.length > 0) {
|
|
690
|
+
Content(`## Per-language documentation
|
|
687
691
|
|
|
688
692
|
`)
|
|
689
|
-
|
|
690
|
-
|
|
693
|
+
docTargets.forEach((tgt: any) => {
|
|
694
|
+
Content(`- [${tgt.title}](${tgt.name}/README.md)
|
|
691
695
|
`)
|
|
692
|
-
|
|
693
|
-
|
|
696
|
+
})
|
|
697
|
+
Content(`
|
|
694
698
|
`)
|
|
695
|
-
|
|
699
|
+
}
|
|
700
|
+
})
|
|
701
|
+
|
|
696
702
|
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
703
|
+
const ReadmeTopUpstream = cmp(function ReadmeTopUpstream(props: any) {
|
|
704
|
+
const { text } = props.s
|
|
705
|
+
const upstream = text.upstream
|
|
706
|
+
const docs = text.docs_url
|
|
707
|
+
Content(`## Upstream API
|
|
701
708
|
|
|
702
709
|
This SDK is generated from the upstream OpenAPI specification. It is an
|
|
703
710
|
unofficial client and is not affiliated with the API provider.
|
|
@@ -706,37 +713,171 @@ The OpenAPI spec(s) this SDK was generated from are kept in the
|
|
|
706
713
|
[\`.sdk/def/\`](.sdk/def/) folder.
|
|
707
714
|
|
|
708
715
|
`)
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
716
|
+
if (upstream.raw) {
|
|
717
|
+
// A per-tenant server URL carries an OpenAPI server variable —
|
|
718
|
+
// `https://{instance}.dreamapply.com/api` — and is the right thing to
|
|
719
|
+
// SHOW, because it tells the reader the host is theirs to fill in. It is
|
|
720
|
+
// not a thing to LINK: the braces are not a resolvable address, so a
|
|
721
|
+
// markdown link renders as clickable and dead. Show it as code instead.
|
|
722
|
+
const templated = /[{}]/.test(upstream.raw)
|
|
723
|
+
Content(templated
|
|
724
|
+
? `- Upstream API: ${upstream.code}
|
|
718
725
|
`
|
|
719
|
-
|
|
726
|
+
: `- Upstream API: [${upstream.inline}](${upstream.link})
|
|
720
727
|
`)
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
728
|
+
}
|
|
729
|
+
if (docs.raw && docs.raw !== upstream.raw) {
|
|
730
|
+
Content(`- Documentation: [${docs.inline}](${docs.link})
|
|
724
731
|
`)
|
|
725
|
-
|
|
726
|
-
|
|
732
|
+
}
|
|
733
|
+
Content(`
|
|
727
734
|
`)
|
|
735
|
+
})
|
|
736
|
+
|
|
728
737
|
|
|
729
|
-
|
|
738
|
+
const ReadmeTopSecurity = cmp(function ReadmeTopSecurity(props: any) {
|
|
739
|
+
const { model } = props.s
|
|
740
|
+
|
|
741
|
+
Content(`## Security
|
|
730
742
|
|
|
731
743
|
Please report security issues ${securityContact(model)}. See [SECURITY.md](SECURITY.md).
|
|
732
744
|
Do not open public issues for suspected vulnerabilities.
|
|
733
745
|
|
|
734
746
|
`)
|
|
747
|
+
})
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
const ReadmeTopFooter = cmp(function ReadmeTopFooter(props: any) {
|
|
751
|
+
const { productName } = props.s
|
|
735
752
|
|
|
736
|
-
|
|
753
|
+
Content(`---
|
|
737
754
|
|
|
738
755
|
Generated from the ${productName} OpenAPI spec by [@voxgig/sdkgen](${SDKGEN_REPO}).
|
|
739
756
|
`)
|
|
757
|
+
})
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
const ReadmeTop = cmp(function ReadmeTop(props: any) {
|
|
761
|
+
const { ctx$ } = props
|
|
762
|
+
const { model } = ctx$
|
|
763
|
+
|
|
764
|
+
if (model.name && !model.Name) names(model, model.name)
|
|
765
|
+
|
|
766
|
+
const info = modelText(model)
|
|
767
|
+
const def = (model.main && model.main.def) || {}
|
|
768
|
+
|
|
769
|
+
const text = fact(model.main[KIT], 'text')
|
|
770
|
+
|
|
771
|
+
const productName = text.title.inline || `${model.Name} API`
|
|
772
|
+
|
|
773
|
+
const tagline = text.tagline.inline
|
|
774
|
+
|| `${productName} client, generated from the OpenAPI spec.`
|
|
775
|
+
|
|
776
|
+
const aboutMd = text.about_md.text
|
|
777
|
+
|
|
778
|
+
const apiSummary = text.summary.inline
|
|
779
|
+
const websiteLine = text.website.raw
|
|
780
|
+
? `Learn more about ${productName} at [${text.website.label}](${text.website.link}).`
|
|
781
|
+
: ''
|
|
782
|
+
|
|
783
|
+
// Attribution for API metadata sourced from a third-party catalogue (e.g.
|
|
784
|
+
// freepublicapis.com). Rendered only when the model carries an
|
|
785
|
+
// `info.meta_source` URL, so first-party SDKs never show it. The link points
|
|
786
|
+
// back to the catalogue that kindly supplied the metadata.
|
|
787
|
+
const metaSourceLine = text.meta_source.raw
|
|
788
|
+
? `Metadata kindly supplied by [${text.meta_source.label}](${text.meta_source.link}).`
|
|
789
|
+
: ''
|
|
790
|
+
|
|
791
|
+
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
792
|
+
const target = getModelPath(model, `main.${KIT}.target`)
|
|
793
|
+
const feature = getModelPath(model, `main.${KIT}.feature`)
|
|
794
|
+
|
|
795
|
+
each(entity, (ent: any) => { if (!ent.Name) names(ent, ent.name) })
|
|
796
|
+
each(feature, (feat: any) => { if (!feat.Name) names(feat, feat.name) })
|
|
797
|
+
|
|
798
|
+
const activeEntities = each(entity).filter((e: any) => e.active !== false)
|
|
799
|
+
const activeTargets = each(target).filter((t: any) => t.active !== false)
|
|
800
|
+
|
|
801
|
+
const hasCli = activeTargets.some((t: any) => t.name === 'go-cli')
|
|
802
|
+
const hasMcp = activeTargets.some((t: any) => t.name === 'go-mcp')
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
const docsOrder: string[] = (getModelPath(model, `main.${KIT}.config.docs_order`,
|
|
806
|
+
{ only_active: false, required: false }) as any) || []
|
|
807
|
+
|
|
808
|
+
const orderOf = (name: string): number => {
|
|
809
|
+
const i = docsOrder.indexOf(name)
|
|
810
|
+
if (i !== -1) return i
|
|
811
|
+
if (name === 'go-cli') return docsOrder.length + 1
|
|
812
|
+
if (name === 'go-mcp') return docsOrder.length + 2
|
|
813
|
+
return docsOrder.length
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
const ordered = activeTargets
|
|
817
|
+
.slice()
|
|
818
|
+
.sort((a: any, b: any) => orderOf(a.name) - orderOf(b.name))
|
|
819
|
+
|
|
820
|
+
const isCliOrMcp = (t: any) => t.name === 'go-cli' || t.name === 'go-mcp'
|
|
821
|
+
|
|
822
|
+
const sdkTargets = ordered.filter((t: any) => !isConsumer(t))
|
|
823
|
+
|
|
824
|
+
// The CLI and the MCP server have surfaces of their own below.
|
|
825
|
+
const consumerTargets = ordered.filter((t: any) => isConsumer(t) && !isCliOrMcp(t))
|
|
826
|
+
|
|
827
|
+
const docTargets = ordered.filter((t: any) => !isCliOrMcp(t))
|
|
828
|
+
|
|
829
|
+
const pkgTargets = activeTargets
|
|
830
|
+
.filter((t: any) => hasPackageName(model, t.name))
|
|
831
|
+
.sort((a: any, b: any) => orderOf(a.name) - orderOf(b.name))
|
|
832
|
+
|
|
833
|
+
const langList = sdkTargets.map((t: any) => t.title).join(', ')
|
|
834
|
+
const leadTarget = pickLeadTarget(sdkTargets)
|
|
835
|
+
|
|
836
|
+
const s = {
|
|
837
|
+
model,
|
|
838
|
+
ctx$,
|
|
839
|
+
info,
|
|
840
|
+
def,
|
|
841
|
+
text,
|
|
842
|
+
productName,
|
|
843
|
+
tagline,
|
|
844
|
+
aboutMd,
|
|
845
|
+
apiSummary,
|
|
846
|
+
websiteLine,
|
|
847
|
+
metaSourceLine,
|
|
848
|
+
feature,
|
|
849
|
+
activeEntities,
|
|
850
|
+
hasCli,
|
|
851
|
+
hasMcp,
|
|
852
|
+
sdkTargets,
|
|
853
|
+
consumerTargets,
|
|
854
|
+
docTargets,
|
|
855
|
+
pkgTargets,
|
|
856
|
+
langList,
|
|
857
|
+
leadTarget,
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
File({ name: 'README.md' }, () => {
|
|
861
|
+
ReadmeTopTitle({ s })
|
|
862
|
+
ReadmeTopSurfaceLine({ s })
|
|
863
|
+
ReadmeTopFeatureLine({ s })
|
|
864
|
+
ReadmeTopAbout({ s })
|
|
865
|
+
ReadmeTopEntityModel({ s })
|
|
866
|
+
ReadmeTopTesting({ s })
|
|
867
|
+
ReadmeTopPackages({ s })
|
|
868
|
+
ReadmeTopQuickstart({ s })
|
|
869
|
+
ReadmeTopSurfaces({ s })
|
|
870
|
+
ReadmeTopMcp({ s })
|
|
871
|
+
ReadmeTopEntities({ s })
|
|
872
|
+
ReadmeTopOtherLanguages({ s })
|
|
873
|
+
ReadmeTopDirect({ s })
|
|
874
|
+
ReadmeTopHowtoGuides({ s })
|
|
875
|
+
ReadmeTopAdvanced({ s })
|
|
876
|
+
ReadmeTopCustomizing({ s })
|
|
877
|
+
ReadmeTopPerLanguage({ s })
|
|
878
|
+
ReadmeTopUpstream({ s })
|
|
879
|
+
ReadmeTopSecurity({ s })
|
|
880
|
+
ReadmeTopFooter({ s })
|
|
740
881
|
})
|
|
741
882
|
})
|
|
742
883
|
|