@voxgig/create-sdkgen 0.23.0 → 0.25.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/dist/create-sdkgen.js +0 -20
- package/dist/create-sdkgen.js.map +1 -1
- package/dist/project/standard/CreateRoot.js +1 -103
- package/dist/project/standard/CreateRoot.js.map +1 -1
- package/package.json +3 -3
- package/project/standard/.sdk/admin/README.md +38 -3
- package/project/standard/.sdk/admin/check-drift.sh +97 -0
- package/project/standard/.sdk/model/config.aon +0 -5
- package/project/standard/.sdk/model/sdk.fragment.aon +1 -6
- package/project/standard/.sdk/package.json +6 -5
- package/project/standard/.sdk/src/BuildSDK.ts +5 -22
- package/project/standard/.sdk/src/Root.ts +0 -22
- package/project/standard/.sdk/src/Top.ts +0 -8
- package/project/standard/.sdk/test/feature/cost.aon +0 -43
- package/project/standard/.sdk/test/primary/clean.aon +0 -7
- package/project/standard/.sdk/test/primary/featureAdd.aon +0 -11
- package/project/standard/.sdk/test/primary/featureHook.aon +0 -10
- package/project/standard/.sdk/test/primary/featureInit.aon +0 -10
- package/project/standard/.sdk/test/primary/fetcher.aon +0 -10
- package/project/standard/.sdk/test/primary/makeFetchDef.aon +0 -10
- package/project/standard/.sdk/test/primary/makePoint.aon +0 -22
- package/project/standard/.sdk/test/primary/makeResult.aon +0 -14
- package/project/standard/.sdk/test/primary/prepareAuth.aon +0 -5
- package/project/standard/.sdk/test/primary/preparePath.aon +0 -7
- package/project/standard/.sdk/test/struct/nullsem.aon +2 -95
- package/project/standard/.sdk/test/struct/select.aon +79 -96
- package/src/create-sdkgen.ts +0 -35
- package/src/project/standard/CreateRoot.ts +1 -103
package/dist/create-sdkgen.js
CHANGED
|
@@ -47,8 +47,6 @@ const util_1 = require("@voxgig/util");
|
|
|
47
47
|
const package_json_1 = __importDefault(require("../package.json"));
|
|
48
48
|
const { names, Jostraca } = JostracaModule;
|
|
49
49
|
const SDK_FOLDER = '.sdk';
|
|
50
|
-
// TODO: CreateSdkGen opts and generate opts should be mostly the same, and
|
|
51
|
-
// generate should override
|
|
52
50
|
function CreateSdkGen(opts) {
|
|
53
51
|
const fs = opts.fs || Fs;
|
|
54
52
|
const debug = opts.debug;
|
|
@@ -94,12 +92,6 @@ function CreateSdkGen(opts) {
|
|
|
94
92
|
folder,
|
|
95
93
|
log: log.child({ cmp: 'jostraca' }),
|
|
96
94
|
meta: { spec },
|
|
97
|
-
// Overwrite the scaffolded project (.sdk components, templates, build
|
|
98
|
-
// config) rather than 3-way merge. The scaffold is toolchain-derived and
|
|
99
|
-
// not hand-edited; merging against a drifting .jostraca base keeps STALE
|
|
100
|
-
// components/templates on a toolchain bump (so a fix never propagates) and
|
|
101
|
-
// can inject <<<<<<< markers. See @voxgig/sdkgen
|
|
102
|
-
// docs/explanation/regeneration-overwrite.md.
|
|
103
95
|
existing: {
|
|
104
96
|
txt: {
|
|
105
97
|
write: true,
|
|
@@ -140,7 +132,6 @@ function CreateSdkGen(opts) {
|
|
|
140
132
|
return projectFolder;
|
|
141
133
|
}
|
|
142
134
|
projectFolder = node_path_1.default.resolve(node_path_1.default.join(__dirname, 'project', spec.project));
|
|
143
|
-
// TODO: support auto install project npm package (specific version) in a special cache folder
|
|
144
135
|
if (!fs.existsSync(projectFolder)) {
|
|
145
136
|
projectFolder = spec.project;
|
|
146
137
|
}
|
|
@@ -220,17 +211,6 @@ async function installNpm(spec, opts, model) {
|
|
|
220
211
|
log.info({ point: 'generate-install', note: 'running npm install in ' + cwd });
|
|
221
212
|
await runNpm(['install'], spawn_opts);
|
|
222
213
|
}
|
|
223
|
-
// `-t` / `-f` are INDEPENDENT of `--no-install`: the documented contract is
|
|
224
|
-
// that --no-install skips `npm install`, not that it drops the requested
|
|
225
|
-
// targets and features. Adding them is still valid without an install when
|
|
226
|
-
// the project already has its toolchain (re-scaffolding an existing folder
|
|
227
|
-
// is a supported flow — "if run against an existing folder generated files
|
|
228
|
-
// will be overwritten").
|
|
229
|
-
//
|
|
230
|
-
// They ARE npm run scripts that resolve @voxgig/sdkgen from node_modules, so
|
|
231
|
-
// without one they cannot work. Fail with an actionable message rather than
|
|
232
|
-
// the raw module-resolution error — and rather than silently skipping, which
|
|
233
|
-
// reports success while leaving config.aon without the requested entries.
|
|
234
214
|
const wanted = [
|
|
235
215
|
(spec.target ?? []).length ? '--target' : '',
|
|
236
216
|
(spec.feature ?? []).length ? '--feature' : '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-sdkgen.js","sourceRoot":"","sources":["../src/create-sdkgen.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"create-sdkgen.js","sourceRoot":"","sources":["../src/create-sdkgen.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA4UvD,YAAY;AA1Ud,MAAY,EAAE,oCAAe;AAC7B,MAAY,EAAE,oCAAe;AAC7B,0DAA4B;AAC5B,iDAAqC;AAErC,MAAY,cAAc,qCAAgB;AAE1C,uCAA4D;AAE5D,mEAAiC;AA8BjC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAA;AAG1C,MAAM,UAAU,GAAG,MAAM,CAAA;AAGzB,SAAS,YAAY,CAAC,IAA6B;IACjD,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,EAAE,CAAA;IAExB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;IACxB,MAAM,IAAI,GAAG,IAAA,iBAAU,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IACvC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAA;IAEzC,MAAM,QAAQ,GAAG,QAAQ,EAAE,CAAA;IAE3B,KAAK,UAAU,QAAQ,CAAC,IAAkB;QACxC,MAAM,KAA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,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;IACpB,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAEnC,GAAG,CAAC,IAAI,CAAC;QACP,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,UAAU;QAC5C,IAAI,EAAE,kBAAkB,GAAG,UAAU;KACtC,CAAC,CAAA;IAEF,MAAM,MAAM,CAAC,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,CAAC,EAAE,UAAU,CAAC,CAAA;AAC7D,CAAC;AAGD,KAAK,UAAU,eAAe,CAAC,IAAkB,EAAE,IAAS,EAAE,KAAU,EAAE,UAAe;IACvF,MAAM,OAAO,GAAI,IAAI,CAAC,OAAoB,CAAA;IAE1C,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;QAC5C,OAAM;IACR,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;IACpB,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAErC,GAAG,CAAC,IAAI,CAAC;QACP,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,WAAW;QAC/C,IAAI,EAAE,mBAAmB,GAAG,WAAW;KACxC,CAAC,CAAA;IAEF,MAAM,MAAM,CAAC,CAAC,KAAK,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,UAAU,CAAC,CAAA;AAC/D,CAAC"}
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.CreateRoot = void 0;
|
|
7
7
|
exports.sanitizeDefName = sanitizeDefName;
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
// import * as Fs from 'node:fs'
|
|
10
9
|
const jostraca_1 = require("jostraca");
|
|
11
10
|
const ModelSdk_1 = require("./ModelSdk");
|
|
12
11
|
const GITIGNORE_TOP = `# Local config / secrets
|
|
@@ -48,39 +47,6 @@ log/
|
|
|
48
47
|
# OS
|
|
49
48
|
.DS_Store
|
|
50
49
|
`;
|
|
51
|
-
// The guide overlay is the ONE model file the user owns.
|
|
52
|
-
//
|
|
53
|
-
// Everything else the scaffold writes is toolchain-derived and is deliberately
|
|
54
|
-
// OVERWRITTEN (see the `existing.txt.write` rationale in create-sdkgen.ts) so a
|
|
55
|
-
// toolchain fix propagates. `model/guide/guide.aon` is the exception: apidef
|
|
56
|
-
// unifies it OVER the heuristic classification, and it is where every
|
|
57
|
-
// documented customization lives — entity rename, hide, move, activate,
|
|
58
|
-
// per-path deactivation, method override, param rename, response transform.
|
|
59
|
-
// Copying the stub over it destroyed that work on every re-scaffold, and
|
|
60
|
-
// cedar-regen.sh re-scaffolds on every regen, so the loss was silent and
|
|
61
|
-
// repeated.
|
|
62
|
-
//
|
|
63
|
-
// It is excluded from the bulk Copy and merged instead (see mergeGuide).
|
|
64
|
-
// The PROJECT overlay: the second model file the user owns.
|
|
65
|
-
//
|
|
66
|
-
// `guide.aon` owns what the API looks like. This owns what the PROJECT is —
|
|
67
|
-
// publication values above all. The sdkgen schema tells you to declare those
|
|
68
|
-
// in `model/sdk.aon` "where they survive a resync", and that was simply not
|
|
69
|
-
// true: ModelSdk rewrites sdk.aon from its template on every scaffold, so a
|
|
70
|
-
// version or package name declared there vanished before the model was built,
|
|
71
|
-
// with no error. The cedar fleet ran for months with every manifest pinned at
|
|
72
|
-
// the schema default 0.0.1 while its git tags climbed past 0.1.1, and this is
|
|
73
|
-
// why.
|
|
74
|
-
//
|
|
75
|
-
// sdk.aon cannot simply be merged the way guide.aon is. Its template owns
|
|
76
|
-
// `name`, `origin` and especially `def` — the OpenAPI filename, which really
|
|
77
|
-
// does change (three cedar specs were renamed in one week). A "keep the user's
|
|
78
|
-
// file" merge would freeze `def` at a spec that no longer exists and break
|
|
79
|
-
// regeneration. So the template keeps sole ownership of sdk.aon, and the
|
|
80
|
-
// user gets a file of their own that sdk.aon includes.
|
|
81
|
-
//
|
|
82
|
-
// Written ONCE. If it exists, it is re-emitted byte-for-byte, so a
|
|
83
|
-
// re-scaffold is a no-op on it.
|
|
84
50
|
const PROJECT_FILE = 'project.aon';
|
|
85
51
|
const PROJECT_STUB = `# Project overlay — YOURS. The scaffold creates this file once and never
|
|
86
52
|
# overwrites it, unlike every other file it writes.
|
|
@@ -109,17 +75,6 @@ const PROJECT_STUB = `# Project overlay — YOURS. The scaffold creates this fil
|
|
|
109
75
|
`;
|
|
110
76
|
const GUIDE_FILE = 'guide.aon';
|
|
111
77
|
const GUIDE_REL = ['model', 'guide', GUIDE_FILE];
|
|
112
|
-
// Rename a user-owned overlay from its pre-2026-08 `.aontu` name to `.aon`.
|
|
113
|
-
//
|
|
114
|
-
// Both overlays are read-if-present and written-if-absent, which is exactly
|
|
115
|
-
// the shape that turns an extension rename into DATA LOSS rather than a
|
|
116
|
-
// rename: look for `guide.aon`, find nothing, write a fresh template over the
|
|
117
|
-
// top, and the user's entity renames, hides and overrides are still sitting
|
|
118
|
-
// in `guide.aontu` being ignored. 660 generated repos carry one.
|
|
119
|
-
//
|
|
120
|
-
// So the legacy file is moved to the new name BEFORE anything reads or writes
|
|
121
|
-
// it. Contents are untouched; only the name changes. Idempotent — once the
|
|
122
|
-
// `.aon` exists this does nothing, so a re-scaffold stays a no-op.
|
|
123
78
|
function migrateOverlay(fs, dir, name) {
|
|
124
79
|
const next = node_path_1.default.join(dir, name + '.aon');
|
|
125
80
|
const prev = node_path_1.default.join(dir, name + '.aontu');
|
|
@@ -127,15 +82,6 @@ function migrateOverlay(fs, dir, name) {
|
|
|
127
82
|
return;
|
|
128
83
|
}
|
|
129
84
|
try {
|
|
130
|
-
// RENAME THE FILE *AND* ITS INCLUDES. An overlay written before the
|
|
131
|
-
// rename includes the toolchain schemas by their old names —
|
|
132
|
-
// `@"@voxgig/apidef/model/guide.aontu"` — and apidef 8 no longer ships
|
|
133
|
-
// that file, so a migration that moved the file but kept its contents
|
|
134
|
-
// verbatim produced a project that could not resolve its own guide.
|
|
135
|
-
// mergeGuide cannot repair this either: it keeps the user's lines and
|
|
136
|
-
// only ADDS missing template includes, so the dead one would survive
|
|
137
|
-
// beside the new one. Only `@`-include extensions are touched; nothing
|
|
138
|
-
// else in the user's file is rewritten.
|
|
139
85
|
const src = String(fs.readFileSync(prev))
|
|
140
86
|
.replace(/(@['"][^'"]+)\.aontu(['"])/g, '$1.aon$2');
|
|
141
87
|
fs.writeFileSync(next, src);
|
|
@@ -146,34 +92,11 @@ function migrateOverlay(fs, dir, name) {
|
|
|
146
92
|
// template being written fresh, which is what would have happened anyway.
|
|
147
93
|
}
|
|
148
94
|
}
|
|
149
|
-
// Merge the guide template into an existing guide overlay.
|
|
150
|
-
//
|
|
151
|
-
// A guide is the template's `@`-includes plus whatever the user added. The
|
|
152
|
-
// includes are the only part the template OWNS, so the merge is: keep the
|
|
153
|
-
// user's file verbatim, and restore any include it is missing. When nothing
|
|
154
|
-
// is missing — the normal case — the file is returned byte-identical, so a
|
|
155
|
-
// re-scaffold is a no-op on it.
|
|
156
|
-
//
|
|
157
|
-
// Missing includes are restored at the TOP, not appended: `base-guide.aon`
|
|
158
|
-
// carries the heuristic classification that the user's overrides unify over,
|
|
159
|
-
// and the overlay reads correctly only when the includes precede it.
|
|
160
95
|
function mergeGuide(existing, template) {
|
|
161
96
|
if (null == existing) {
|
|
162
97
|
return template;
|
|
163
98
|
}
|
|
164
99
|
const isInclude = (line) => line.trim().startsWith('@');
|
|
165
|
-
// AN INCLUDE IS THE FILE IT NAMES, whichever way the `./` falls.
|
|
166
|
-
//
|
|
167
|
-
// The template gained a `./` when aontu 0.65 made a bare single-segment
|
|
168
|
-
// include name a PACKAGE (ADR-039). Every guide written before that says
|
|
169
|
-
// `@"base-guide.aon"`, and `guide.aon` is project-owned: the scaffold
|
|
170
|
-
// writes it once and never again, so those files stay as they are until
|
|
171
|
-
// something migrates them.
|
|
172
|
-
//
|
|
173
|
-
// Comparing the raw lines read the old spelling as a DIFFERENT include, so
|
|
174
|
-
// a re-scaffold restored one the file already had — leaving the guide
|
|
175
|
-
// including `base-guide.aon` twice, under two spellings, which is the one
|
|
176
|
-
// thing this merge exists to avoid.
|
|
177
100
|
const key = (line) => line.trim().replace(/^@"\.\//, '@"');
|
|
178
101
|
const have = new Set(existing.split('\n').map(key));
|
|
179
102
|
const missing = template.split('\n')
|
|
@@ -185,26 +108,10 @@ function mergeGuide(existing, template) {
|
|
|
185
108
|
}
|
|
186
109
|
return missing.join('\n') + '\n\n' + existing;
|
|
187
110
|
}
|
|
188
|
-
// The OpenAPI filename is inherited from the upstream API slug, and upstream
|
|
189
|
-
// slugs are not constrained: the freepublicapis corpus contains apostrophes
|
|
190
|
-
// (catherine-shulman's-quotes), accents (dólar-y-monedas, kölner-adressen),
|
|
191
|
-
// and '!' / '>' / '_'. That name is copied into .sdk/def/ AND written verbatim
|
|
192
|
-
// into a single-quoted aontu string in sdk.aon:
|
|
193
|
-
//
|
|
194
|
-
// def: 'catherine-shulman's-quotes_0.1.0.json'
|
|
195
|
-
// ^ terminates the string -> AontuError, no SDK
|
|
196
|
-
//
|
|
197
|
-
// Slugs are [a-z0-9-]; a filename additionally needs '.' and '_' for the
|
|
198
|
-
// version segment and extension, so those are kept — which also means every
|
|
199
|
-
// already-conforming name (including cedar's dotted gitlab-v4-swagger-2.0.yaml)
|
|
200
|
-
// is untouched and no repo churns. Everything else is folded to '-'.
|
|
201
111
|
function sanitizeDefName(filename) {
|
|
202
112
|
const clean = filename
|
|
203
|
-
.normalize('NFKD').replace(/[\u0300-\u036f]/g, '')
|
|
113
|
+
.normalize('NFKD').replace(/[\u0300-\u036f]/g, '')
|
|
204
114
|
.toLowerCase()
|
|
205
|
-
// Quotes are ELIDED, not folded to '-', so the filename agrees with the
|
|
206
|
-
// repo name apidef's sanitizeSlug derives from the same slug:
|
|
207
|
-
// catherine-shulman's-quotes -> catherine-shulmans-quotes(-sdk).
|
|
208
115
|
.replace(/['’"]/g, '')
|
|
209
116
|
.replace(/[^a-z0-9._-]+/g, '-')
|
|
210
117
|
.replace(/-+/g, '-')
|
|
@@ -215,24 +122,16 @@ function sanitizeDefName(filename) {
|
|
|
215
122
|
.replace(/^-|-$/g, '');
|
|
216
123
|
return '' === clean ? 'openapi.yml' : clean;
|
|
217
124
|
}
|
|
218
|
-
// TODO: rename to RootSdk
|
|
219
125
|
const CreateRoot = (0, jostraca_1.cmp)(function CreateRoot(props) {
|
|
220
126
|
const { ctx$, ctx$: { folder }, spec, model } = props;
|
|
221
127
|
const fs = ctx$.fs();
|
|
222
|
-
// TODO: move to @voxgig/util as duplicated
|
|
223
128
|
model.const = { name: model.name };
|
|
224
129
|
(0, jostraca_1.names)(model.const, model.name);
|
|
225
130
|
model.const.year = new Date().getFullYear();
|
|
226
|
-
// Scaffold is MIT-licensed (matches the emitted LICENSE and tm/LICENSE);
|
|
227
|
-
// set directly rather than via names() so the value stays 'MIT', not 'Mit'.
|
|
228
131
|
model.const.License = 'MIT';
|
|
229
132
|
ctx$.model = model;
|
|
230
133
|
(0, jostraca_1.Project)({ folder }, () => {
|
|
231
134
|
const from = node_path_1.default.resolve(node_path_1.default.join(__dirname, '..', '..', '..', 'project', 'standard'));
|
|
232
|
-
// console.log('FROM', from)
|
|
233
|
-
// Copy `exclude` matches the SOURCE-RELATIVE path exactly, so this names
|
|
234
|
-
// the one guide under the scaffold and nothing else. It is re-emitted,
|
|
235
|
-
// merged, in the model folder below.
|
|
236
135
|
const guideExclude = [spec.sdk_folder, ...GUIDE_REL].join('/');
|
|
237
136
|
(0, jostraca_1.Copy)({
|
|
238
137
|
from,
|
|
@@ -255,7 +154,6 @@ const CreateRoot = (0, jostraca_1.cmp)(function CreateRoot(props) {
|
|
|
255
154
|
(0, jostraca_1.Content)(GITIGNORE_SDK);
|
|
256
155
|
});
|
|
257
156
|
(0, jostraca_1.Folder)({ name: 'def' }, () => {
|
|
258
|
-
// TODO: file existence check should be jostraca util
|
|
259
157
|
if (fs.existsSync(origdef)) {
|
|
260
158
|
(0, jostraca_1.Copy)({ from: origdef, to: projdef });
|
|
261
159
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateRoot.js","sourceRoot":"","sources":["../../../src/project/standard/CreateRoot.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"CreateRoot.js","sourceRoot":"","sources":["../../../src/project/standard/CreateRoot.ts"],"names":[],"mappings":";;;;;;QA8PE,eAAe;AA5PjB,0DAA4B;AAE5B,uCAUiB;AAGjB,yCAAqC;AAGrC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;CAkBrB,CAAA;AAGD,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;CAmBrB,CAAA;AAGD,MAAM,YAAY,GAAG,aAAa,CAAA;AAClC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwBpB,CAAA;AAGD,MAAM,UAAU,GAAG,WAAW,CAAA;AAC9B,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;AAGhD,SAAS,cAAc,CAAC,EAAO,EAAE,GAAW,EAAE,IAAY;IACxD,MAAM,IAAI,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,GAAG,MAAM,CAAC,CAAA;IAC1C,MAAM,IAAI,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,GAAG,QAAQ,CAAC,CAAA;IAC5C,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,OAAM;IACR,CAAC;IACD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;aACtC,OAAO,CAAC,6BAA6B,EAAE,UAAU,CAAC,CAAA;QACrD,EAAE,CAAC,aAAa,CAAC,IAAI,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sdkgen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"main": "dist/create-sdkgen.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"types": "dist/create-sdkgen.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"pretest": "node build/check-tests.js",
|
|
24
|
-
"test": "node --enable-source-maps --test dist-test/**/*.test.js",
|
|
24
|
+
"test": "node tools/comment-gate.cjs && node --enable-source-maps --test dist-test/**/*.test.js",
|
|
25
25
|
"pretest-some": "node build/check-tests.js",
|
|
26
26
|
"test-some": "node --enable-source-maps --test-name-pattern=\"$npm_config_pattern\" --test dist-test/**/*.test.js",
|
|
27
27
|
"watch": "tsc --build src test -w",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@voxgig/util": "0.5.4",
|
|
59
|
-
"aontu": "0.
|
|
59
|
+
"aontu": ">=0.68",
|
|
60
60
|
"chokidar": "5.0.0",
|
|
61
61
|
"jostraca": "0.31.2",
|
|
62
62
|
"shape": ">=10"
|
|
@@ -14,6 +14,40 @@ builds or tests, contact package registries, fetch Git refs, or change files.
|
|
|
14
14
|
`--github` also reads recent workflow runs and Pages status through `gh`.
|
|
15
15
|
Install the `.sdk` dependencies before using it.
|
|
16
16
|
|
|
17
|
+
## Is the committed tree what the generator produces?
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
cd .sdk && npm run check-drift
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`check-drift.sh` answers a question nothing else asks. Generation has two
|
|
24
|
+
failure modes that are **completely silent** — neither breaks a build or a
|
|
25
|
+
test, and the only symptom is a tree that disagrees with the model:
|
|
26
|
+
|
|
27
|
+
- **Regeneration never DELETES.** A file the generator has stopped emitting
|
|
28
|
+
stays in the tree. Narrow the secrets plugin selection, drop a target,
|
|
29
|
+
rename an entity, and the superseded output is still committed. One SDK
|
|
30
|
+
carried seven orphaned provider clients in `scala/` and seven in `zig/`;
|
|
31
|
+
the scala ones surfaced only because a test cross-checks the tree against
|
|
32
|
+
the model, and zig's were caught by nothing.
|
|
33
|
+
- **`voxgig-model --no-config` writes a REDUCED model.** It skips the
|
|
34
|
+
`.model-config` build that registers the apidef and sdkgen actions, so
|
|
35
|
+
neither runs — and `model/sdk.json` is still written, now missing the name
|
|
36
|
+
case variants and `main.api` / `main.custom`. Use `npm run dry-generate`
|
|
37
|
+
to inspect a model without side effects, and never `--no-config` in
|
|
38
|
+
anything whose output might be committed.
|
|
39
|
+
|
|
40
|
+
The script deletes every target tree, regenerates, and reports what differs —
|
|
41
|
+
which is the only way to see output the generator no longer emits. It refuses
|
|
42
|
+
to run on a dirty tree, restores the target's own build artifacts and
|
|
43
|
+
lockfiles (which the generator never writes), and leaves the regenerated tree
|
|
44
|
+
in place so the diff can be read.
|
|
45
|
+
|
|
46
|
+
It **detects**; it does not prevent. Run it before a release, or after
|
|
47
|
+
changing the model or the toolchain. It is deliberately not in CI: it
|
|
48
|
+
regenerates every target, which is minutes of work and needs the `.sdk`
|
|
49
|
+
dependencies installed.
|
|
50
|
+
|
|
17
51
|
When a GitHub Pages edition and its CI workflow are enabled, docgen generates
|
|
18
52
|
`setup-github-pages.sh` here. Preview its changes, then configure Pages:
|
|
19
53
|
|
|
@@ -26,6 +60,7 @@ The setup script configures GitHub Actions as the publishing source. It does
|
|
|
26
60
|
not commit, push, merge, or deploy. Push the documentation workflow and project
|
|
27
61
|
changes to its configured deployment branch to publish the website.
|
|
28
62
|
|
|
29
|
-
The status launcher
|
|
30
|
-
sdkgen. Docgen owns the generated Pages setup
|
|
31
|
-
administration scripts beside them with
|
|
63
|
+
The status launcher and the drift check come from create-sdkgen; the status
|
|
64
|
+
reporting code comes from sdkgen. Docgen owns the generated Pages setup
|
|
65
|
+
script. Put project-specific administration scripts beside them with
|
|
66
|
+
different names.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Is the committed tree what the generator actually produces?
|
|
3
|
+
#
|
|
4
|
+
# BOTH FAILURE MODES THIS CATCHES ARE SILENT. Nothing breaks when generated
|
|
5
|
+
# output drifts from the model, so nothing reports it:
|
|
6
|
+
#
|
|
7
|
+
# - STALE OUTPUT. Regeneration never DELETES a file it has stopped
|
|
8
|
+
# emitting. Narrow the model's secrets plugin selection, drop a target,
|
|
9
|
+
# rename an entity - the superseded files stay in the tree. Seen in one
|
|
10
|
+
# SDK as seven orphaned provider clients in scala and seven in zig: the
|
|
11
|
+
# scala ones surfaced only because one test cross-checks the tree
|
|
12
|
+
# against the model, and zig's were caught by nothing at all.
|
|
13
|
+
#
|
|
14
|
+
# - MODEL DRIFT. The committed .sdk/model/sdk.json can go round a loop,
|
|
15
|
+
# gaining and losing the name case variants and main.api / main.custom
|
|
16
|
+
# depending on which command last wrote it. `voxgig-model --no-config`
|
|
17
|
+
# writes a REDUCED model - it skips the .model-config build that
|
|
18
|
+
# registers the apidef and sdkgen actions, so neither runs, and sdk.json
|
|
19
|
+
# is still written without what they contribute. The only symptom is a
|
|
20
|
+
# dirty tree after regenerating, which is easy to commit past. To
|
|
21
|
+
# inspect a model with no side effects: `npm run dry-generate`.
|
|
22
|
+
#
|
|
23
|
+
# THE TARGET TREES ARE DELETED FIRST, and that is the whole point. A plain
|
|
24
|
+
# regeneration cannot find stale output: the file is committed, generation
|
|
25
|
+
# leaves it alone, and `git status` is silent. Only forcing the generator to
|
|
26
|
+
# reproduce the tree from nothing shows what it no longer emits.
|
|
27
|
+
#
|
|
28
|
+
# This DETECTS, it does not prevent. Run it before a release, or after
|
|
29
|
+
# changing the model or the toolchain.
|
|
30
|
+
#
|
|
31
|
+
# Not wired into CI on purpose: it regenerates every target, which is
|
|
32
|
+
# minutes of work and needs the .sdk dependencies installed - too heavy for
|
|
33
|
+
# a per-push job, and it would only tell CI what one command finds here.
|
|
34
|
+
set -euo pipefail
|
|
35
|
+
|
|
36
|
+
sdk_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
37
|
+
root="$(cd -- "$sdk_dir/.." && pwd)"
|
|
38
|
+
cd "$root"
|
|
39
|
+
|
|
40
|
+
# What each target's OWN toolchain produces - a TypeScript build, a
|
|
41
|
+
# resolved lockfile - which the generator does not emit and must not be
|
|
42
|
+
# reported as stale. Everything else under a target directory is generated.
|
|
43
|
+
keep='(^|/)(dist|dist-test|node_modules)/|(^|/)(package-lock\.json|composer\.lock|go\.sum|Cargo\.lock|yarn\.lock)$'
|
|
44
|
+
|
|
45
|
+
# A dirty tree makes the answer meaningless - every uncommitted edit would
|
|
46
|
+
# read as drift - and this deletes directories, so it must not run over
|
|
47
|
+
# work that is not in git.
|
|
48
|
+
if [[ -n "$(git status --porcelain)" ]]; then
|
|
49
|
+
echo 'check-drift: the working tree has uncommitted changes.' >&2
|
|
50
|
+
echo 'Commit or stash them first: this deletes and regenerates every' >&2
|
|
51
|
+
echo 'target, and uncommitted work would be lost and read as drift.' >&2
|
|
52
|
+
exit 2
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
targets="$(node -e '
|
|
56
|
+
const m = require("./.sdk/model/sdk.json")
|
|
57
|
+
const t = (m.main && m.main.kit && m.main.kit.target) || {}
|
|
58
|
+
console.log(Object.keys(t).sort().join("\n"))
|
|
59
|
+
')"
|
|
60
|
+
|
|
61
|
+
echo 'check-drift: deleting and regenerating every target ...'
|
|
62
|
+
while IFS= read -r t; do
|
|
63
|
+
[[ -n "$t" && -d "$t" ]] && rm -rf -- "$t"
|
|
64
|
+
done <<< "$targets"
|
|
65
|
+
|
|
66
|
+
log="$(mktemp)"
|
|
67
|
+
trap 'rm -f "$log"' EXIT
|
|
68
|
+
if ! ( cd "$sdk_dir" && npm run generate ) >"$log" 2>&1; then
|
|
69
|
+
echo 'check-drift: generation FAILED. Restoring the tree.' >&2
|
|
70
|
+
cat "$log" >&2
|
|
71
|
+
git checkout -- . || true
|
|
72
|
+
exit 2
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
# Put back what the generator was never going to write.
|
|
76
|
+
git status --porcelain | awk '"D" == $1 { print $2 }' | grep -E "$keep" \
|
|
77
|
+
| while IFS= read -r f; do git checkout -- "$f"; done || true
|
|
78
|
+
|
|
79
|
+
drift="$(git status --porcelain)"
|
|
80
|
+
|
|
81
|
+
if [[ -z "$drift" ]]; then
|
|
82
|
+
echo 'check-drift: clean. The committed tree is what the generator produces.'
|
|
83
|
+
exit 0
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
echo >&2
|
|
87
|
+
echo 'check-drift: DRIFT. These differ from what the generator produces:' >&2
|
|
88
|
+
echo >&2
|
|
89
|
+
echo "$drift" >&2
|
|
90
|
+
echo >&2
|
|
91
|
+
echo 'D output the generator no longer emits - delete it.' >&2
|
|
92
|
+
echo 'M output that changed - commit it.' >&2
|
|
93
|
+
echo '?? output not committed - commit it.' >&2
|
|
94
|
+
echo >&2
|
|
95
|
+
echo 'The regenerated tree is left in place so the diff can be read.' >&2
|
|
96
|
+
echo 'Restore with: git checkout -- .' >&2
|
|
97
|
+
exit 1
|
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
main: kit: config: {
|
|
4
4
|
|
|
5
|
-
# The Authorization credential prefix is derived from the OpenAPI
|
|
6
|
-
# security scheme (see api/api-info.aon: main.kit.info.security,
|
|
7
|
-
# set by apidef) and defaults to 'Bearer' when the spec gives no
|
|
8
|
-
# signal. Uncomment to override per-SDK:
|
|
9
|
-
# auth: prefix: 'Bearer'
|
|
10
5
|
|
|
11
6
|
|
|
12
7
|
headers: {
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
@"@voxgig/sdkgen/model/sdkgen.aon"
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
# SDK Details.
|
|
8
7
|
name: 'NAME'
|
|
9
8
|
origin: 'voxgig-sdk'
|
|
10
9
|
def: 'DEF'
|
|
@@ -24,7 +23,7 @@ def: 'DEF'
|
|
|
24
23
|
|
|
25
24
|
# SDK Features.
|
|
26
25
|
@"feature/feature-index.aon"
|
|
27
|
-
|
|
26
|
+
|
|
28
27
|
|
|
29
28
|
# SDK Targets.
|
|
30
29
|
@"target/target-index.aon"
|
|
@@ -34,10 +33,6 @@ def: 'DEF'
|
|
|
34
33
|
@"flow/flow-index.aon"
|
|
35
34
|
|
|
36
35
|
|
|
37
|
-
# Project overlay — user-owned, created once and never overwritten.
|
|
38
|
-
#
|
|
39
|
-
# LAST, deliberately: it may refine main.kit.target.<t>, and a target can only
|
|
40
|
-
# be refined after target-index.aon has defined it.
|
|
41
36
|
@"./project.aon"
|
|
42
37
|
|
|
43
38
|
# Documentation editions. Settings belong in project.aon.
|
|
@@ -21,20 +21,21 @@
|
|
|
21
21
|
"add-edition": "voxgig-sdkgen edition add",
|
|
22
22
|
"text-qa": "cd .. && voxgig-docgen qa",
|
|
23
23
|
"postinstall": "node build/docgen.js",
|
|
24
|
-
"status": "bash admin/status.sh"
|
|
24
|
+
"status": "bash admin/status.sh",
|
|
25
|
+
"check-drift": "bash admin/check-drift.sh"
|
|
25
26
|
},
|
|
26
27
|
"author": "$$const.Name$$",
|
|
27
28
|
"license": "$$const.License$$",
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@types/node": ">=25.6",
|
|
30
31
|
"typescript": ">=6.0",
|
|
31
|
-
"@voxgig/apidef": ">=8.
|
|
32
|
+
"@voxgig/apidef": ">=8.12.1",
|
|
32
33
|
"@voxgig/model": ">=10.0",
|
|
33
|
-
"@voxgig/sdkgen": ">=4.
|
|
34
|
+
"@voxgig/sdkgen": ">=4.22.0",
|
|
34
35
|
"@voxgig/util": ">=0.5",
|
|
35
36
|
"@voxgig/struct": ">=0.2",
|
|
36
37
|
"jostraca": ">=0.33.1",
|
|
37
|
-
"aontu": ">=0.
|
|
38
|
-
"@voxgig/docgen": ">=0.
|
|
38
|
+
"aontu": ">=0.68",
|
|
39
|
+
"@voxgig/docgen": ">=0.23.0"
|
|
39
40
|
}
|
|
40
41
|
}
|
|
@@ -31,7 +31,6 @@ const BuildSDK = cmp(function BuildSDK(props: any) {
|
|
|
31
31
|
const ctx$ = props.ctx$
|
|
32
32
|
const model: Model = ctx$.model
|
|
33
33
|
|
|
34
|
-
// TODO: should come from ctx$ options
|
|
35
34
|
const sdkBuildFolder = '.sdk'
|
|
36
35
|
|
|
37
36
|
const entityMap: ModelEntity = getModelPath(model, `main.${KIT}.entity`)
|
|
@@ -77,13 +76,6 @@ function makeEntityTestData(_model: Model, entity: ModelEntity) {
|
|
|
77
76
|
const pathParams = collectEntityPathParams(entity)
|
|
78
77
|
|
|
79
78
|
const hasEntId = null != (entity as any).id
|
|
80
|
-
// Some entities don't declare a top-level `id` field but still need an
|
|
81
|
-
// `id` value in their fixture: any entity that has a non-list op (remove,
|
|
82
|
-
// update, load) will hit `data["id"]` in the generated test code. The
|
|
83
|
-
// test mock is lenient about extra/missing path params, so synthesising
|
|
84
|
-
// an `id` here keeps tests green for entities like
|
|
85
|
-
// `/{namespace}/{key}` (no `id` in URL) or `/{resource}/{id}`
|
|
86
|
-
// alongside the simple `{id}`-only case.
|
|
87
79
|
const needsFixtureId = hasEntId || entityHasMutatingOp(entity)
|
|
88
80
|
|
|
89
81
|
let i = 1
|
|
@@ -113,23 +105,20 @@ function makeEntityTestData(_model: Model, entity: ModelEntity) {
|
|
|
113
105
|
makeEntityTestFields(entity, i++, ent)
|
|
114
106
|
delete ent.id
|
|
115
107
|
|
|
116
|
-
//
|
|
108
|
+
// WHICH operations this entity exposes, not what the specification says
|
|
109
|
+
// about them. The facts are apidef's resolved definition, and copying them
|
|
110
|
+
// here made the test data a second copy of the model's own copy of them.
|
|
117
111
|
data.requests = {}
|
|
118
112
|
for (const op of Object.values(entity.op || {}) as any[]) for (const point of op.points || []) {
|
|
119
113
|
if (point.contract) data.requests[point.contract.id] = {
|
|
120
|
-
provenance: 'operation-contract',
|
|
114
|
+
provenance: 'operation-contract', version: point.contract.version,
|
|
115
|
+
source: point.contract.source,
|
|
121
116
|
}
|
|
122
117
|
}
|
|
123
118
|
return data
|
|
124
119
|
}
|
|
125
120
|
|
|
126
121
|
|
|
127
|
-
// Detect whether the entity has any op other than `list` (which doesn't
|
|
128
|
-
// take a per-item id). Used to decide whether the fixture needs a
|
|
129
|
-
// synthesised `id` — the test code for load/update/remove ops references
|
|
130
|
-
// `data["id"]` unconditionally in Python (and similarly in other strict
|
|
131
|
-
// languages), so the fixture must provide one even when the URL path
|
|
132
|
-
// params are named differently (e.g. `/{namespace}/{key}`).
|
|
133
122
|
function entityHasMutatingOp(entity: any): boolean {
|
|
134
123
|
const ops = entity?.op || {}
|
|
135
124
|
for (const opname of Object.keys(ops)) {
|
|
@@ -139,12 +128,6 @@ function entityHasMutatingOp(entity: any): boolean {
|
|
|
139
128
|
}
|
|
140
129
|
|
|
141
130
|
|
|
142
|
-
// Walk every op point on the entity, collect the names of path params, and
|
|
143
|
-
// pair each with its canonical idmap value. The canonical value mirrors the
|
|
144
|
-
// flow generator's path-param defaulting in apidef:
|
|
145
|
-
// `step.match[name] = name.replace(/_id$/,'') + '01'`
|
|
146
|
-
// Then setup.idmap maps that lower ref to upper: `company01 → COMPANY01`.
|
|
147
|
-
// So the value seeded into existing test data is the upper form: `COMPANY01`.
|
|
148
131
|
function collectEntityPathParams(entity: any): [string, string][] {
|
|
149
132
|
const out = new Map<string, string>()
|
|
150
133
|
const ops = entity?.op || {}
|