@voxgig/sdkgen 4.44.3 → 4.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +7 -4
- 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 +4 -0
- package/dist/helpers/facts.js +92 -0
- package/dist/helpers/facts.js.map +1 -0
- 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/helpers/shipped.d.ts +2 -1
- package/dist/helpers/shipped.js +4 -0
- package/dist/helpers/shipped.js.map +1 -1
- package/dist/sdkgen.d.ts +2 -1
- package/dist/sdkgen.js +29 -6
- 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 +59 -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 +8 -5
- 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 +119 -0
- 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/helpers/shipped.ts +5 -0
- package/src/sdkgen.ts +31 -2
- package/src/testkit.ts +30 -20
- package/src/utility.ts +2 -1
package/dist/cmp/ReadmeTop.js
CHANGED
|
@@ -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
|
|
70
|
-
const {
|
|
71
|
-
|
|
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
|
-
|
|
141
|
-
|
|
79
|
+
if (apiSummary) {
|
|
80
|
+
(0, jostraca_1.Content)(`${apiSummary}
|
|
142
81
|
|
|
143
82
|
`);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
83
|
+
}
|
|
84
|
+
if (websiteLine) {
|
|
85
|
+
(0, jostraca_1.Content)(`${websiteLine}
|
|
147
86
|
|
|
148
87
|
`);
|
|
149
|
-
|
|
150
|
-
|
|
88
|
+
}
|
|
89
|
+
(0, jostraca_1.Content)(`${(0, packageMeta_1.nonAffiliation)(model)}
|
|
151
90
|
|
|
152
91
|
`);
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
170
|
-
|
|
107
|
+
}
|
|
108
|
+
if (metaSourceLine) {
|
|
109
|
+
(0, jostraca_1.Content)(`${metaSourceLine}
|
|
171
110
|
|
|
172
111
|
`);
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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
|
-
|
|
203
|
-
|
|
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
|
|
157
|
+
${aboutMd}
|
|
206
158
|
|
|
207
159
|
`);
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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 (
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
const
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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
|
-
|
|
296
|
-
|
|
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
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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
|
-
|
|
310
|
-
|
|
267
|
+
Test['ReadmeTopTest']({ target: tgt });
|
|
268
|
+
(0, jostraca_1.Content)(`
|
|
311
269
|
`);
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
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
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
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
|
-
|
|
353
|
-
|
|
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
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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
|
-
|
|
369
|
-
|
|
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
|
-
|
|
375
|
-
|
|
376
|
-
|
|
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
|
-
|
|
380
|
-
|
|
345
|
+
}
|
|
346
|
+
if (hasCli) {
|
|
347
|
+
(0, jostraca_1.Content)(`| **CLI** | \`go-cli/\` |
|
|
381
348
|
`);
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
349
|
+
}
|
|
350
|
+
if (hasMcp) {
|
|
351
|
+
(0, jostraca_1.Content)(`| **MCP server** | \`go-mcp/\` |
|
|
385
352
|
`);
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
353
|
+
}
|
|
354
|
+
consumerTargets.forEach((t) => {
|
|
355
|
+
(0, jostraca_1.Content)(`| **${t.title}** | \`${t.name}/\` |
|
|
389
356
|
`);
|
|
390
|
-
|
|
391
|
-
|
|
357
|
+
});
|
|
358
|
+
(0, jostraca_1.Content)(`
|
|
392
359
|
`);
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
437
|
-
|
|
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
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
`);
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
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
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
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
|
-
|
|
477
|
-
|
|
452
|
+
Quick['ReadmeTopQuick']({ target: tgt });
|
|
453
|
+
(0, jostraca_1.Content)(`
|
|
478
454
|
`);
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
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
|
-
|
|
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
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
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
|
|
495
|
+
Every entity operation runs the same ${(0, FeatureHook_1.pipelineLength)()}-stage pipeline:
|
|
512
496
|
|
|
513
|
-
1. **
|
|
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
|
|
520
|
-
\`
|
|
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
|
-
|
|
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
|
-
|
|
530
|
-
|
|
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
|
-
|
|
538
|
-
|
|
539
|
-
`
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
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
|
-
|
|
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
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
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
|
-
|
|
617
|
-
|
|
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
|
-
|
|
621
|
-
|
|
608
|
+
docTargets.forEach((tgt) => {
|
|
609
|
+
(0, jostraca_1.Content)(`- [${tgt.title}](${tgt.name}/README.md)
|
|
622
610
|
`);
|
|
623
|
-
|
|
624
|
-
|
|
611
|
+
});
|
|
612
|
+
(0, jostraca_1.Content)(`
|
|
625
613
|
`);
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
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
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
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
|
-
|
|
639
|
+
: `- Upstream API: [${upstream.inline}](${upstream.link})
|
|
650
640
|
`);
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
641
|
+
}
|
|
642
|
+
if (docs.raw && docs.raw !== upstream.raw) {
|
|
643
|
+
(0, jostraca_1.Content)(`- Documentation: [${docs.inline}](${docs.link})
|
|
654
644
|
`);
|
|
655
|
-
|
|
656
|
-
|
|
645
|
+
}
|
|
646
|
+
(0, jostraca_1.Content)(`
|
|
657
647
|
`);
|
|
658
|
-
|
|
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
|
-
|
|
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;
|