@voxgig/create-sdkgen 0.18.1 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/create-sdkgen.js +1 -1
  2. package/dist/create-sdkgen.js.map +1 -1
  3. package/dist/project/standard/CreateRoot.js +56 -12
  4. package/dist/project/standard/CreateRoot.js.map +1 -1
  5. package/dist/project/standard/ModelSdk.js +2 -2
  6. package/dist/project/standard/ModelSdk.js.map +1 -1
  7. package/package.json +3 -3
  8. package/project/standard/.sdk/model/.model-config/{model-config.aontu → model-config.aon} +1 -1
  9. package/project/standard/.sdk/model/{config.aontu → config.aon} +1 -1
  10. package/project/standard/.sdk/model/guide/guide.aon +8 -0
  11. package/project/standard/.sdk/model/{sdk.fragment.aontu → sdk.fragment.aon} +10 -10
  12. package/project/standard/.sdk/package.json +9 -9
  13. package/project/standard/.sdk/test/.model-config/model-config.aon +4 -0
  14. package/project/standard/.sdk/test/feature/cost.aon +190 -0
  15. package/project/standard/.sdk/test/feature/feature-test-index.aon +2 -0
  16. package/project/standard/.sdk/test/primary/primary-test-index.aon +30 -0
  17. package/project/standard/.sdk/test/struct/test.aon +25 -0
  18. package/project/standard/.sdk/test/test.aon +4 -0
  19. package/project/standard/.sdk/test/test.json +13965 -13422
  20. package/src/create-sdkgen.ts +1 -1
  21. package/src/project/standard/CreateRoot.ts +60 -12
  22. package/src/project/standard/ModelSdk.ts +2 -2
  23. package/project/standard/.sdk/model/guide/guide.aontu +0 -8
  24. package/project/standard/.sdk/test/.model-config/model-config.aontu +0 -4
  25. package/project/standard/.sdk/test/primary/primary-test-index.aontu +0 -30
  26. package/project/standard/.sdk/test/struct/test.aontu +0 -25
  27. package/project/standard/.sdk/test/test.aontu +0 -3
  28. /package/project/standard/.sdk/model/api/{api-info.aontu → api-info.aon} +0 -0
  29. /package/project/standard/.sdk/model/entity/{entity-index.aontu → entity-index.aon} +0 -0
  30. /package/project/standard/.sdk/model/feature/{feature-index.aontu → feature-index.aon} +0 -0
  31. /package/project/standard/.sdk/model/flow/{flow-index.aontu → flow-index.aon} +0 -0
  32. /package/project/standard/.sdk/model/target/{target-index.aontu → target-index.aon} +0 -0
  33. /package/project/standard/.sdk/test/primary/{clean.aontu → clean.aon} +0 -0
  34. /package/project/standard/.sdk/test/primary/{done.aontu → done.aon} +0 -0
  35. /package/project/standard/.sdk/test/primary/{featureAdd.aontu → featureAdd.aon} +0 -0
  36. /package/project/standard/.sdk/test/primary/{featureHook.aontu → featureHook.aon} +0 -0
  37. /package/project/standard/.sdk/test/primary/{featureInit.aontu → featureInit.aon} +0 -0
  38. /package/project/standard/.sdk/test/primary/{fetcher.aontu → fetcher.aon} +0 -0
  39. /package/project/standard/.sdk/test/primary/{makeContext.aontu → makeContext.aon} +0 -0
  40. /package/project/standard/.sdk/test/primary/{makeError.aontu → makeError.aon} +0 -0
  41. /package/project/standard/.sdk/test/primary/{makeFetchDef.aontu → makeFetchDef.aon} +0 -0
  42. /package/project/standard/.sdk/test/primary/{makeOptions.aontu → makeOptions.aon} +0 -0
  43. /package/project/standard/.sdk/test/primary/{makePoint.aontu → makePoint.aon} +0 -0
  44. /package/project/standard/.sdk/test/primary/{makeRequest.aontu → makeRequest.aon} +0 -0
  45. /package/project/standard/.sdk/test/primary/{makeResponse.aontu → makeResponse.aon} +0 -0
  46. /package/project/standard/.sdk/test/primary/{makeResult.aontu → makeResult.aon} +0 -0
  47. /package/project/standard/.sdk/test/primary/{makeSpec.aontu → makeSpec.aon} +0 -0
  48. /package/project/standard/.sdk/test/primary/{makeUrl.aontu → makeUrl.aon} +0 -0
  49. /package/project/standard/.sdk/test/primary/{operator.aontu → operator.aon} +0 -0
  50. /package/project/standard/.sdk/test/primary/{param.aontu → param.aon} +0 -0
  51. /package/project/standard/.sdk/test/primary/{prepareAuth.aontu → prepareAuth.aon} +0 -0
  52. /package/project/standard/.sdk/test/primary/{prepareBody.aontu → prepareBody.aon} +0 -0
  53. /package/project/standard/.sdk/test/primary/{prepareHeaders.aontu → prepareHeaders.aon} +0 -0
  54. /package/project/standard/.sdk/test/primary/{prepareMethod.aontu → prepareMethod.aon} +0 -0
  55. /package/project/standard/.sdk/test/primary/{prepareParams.aontu → prepareParams.aon} +0 -0
  56. /package/project/standard/.sdk/test/primary/{preparePath.aontu → preparePath.aon} +0 -0
  57. /package/project/standard/.sdk/test/primary/{prepareQuery.aontu → prepareQuery.aon} +0 -0
  58. /package/project/standard/.sdk/test/primary/{resultBasic.aontu → resultBasic.aon} +0 -0
  59. /package/project/standard/.sdk/test/primary/{resultBody.aontu → resultBody.aon} +0 -0
  60. /package/project/standard/.sdk/test/primary/{resultHeaders.aontu → resultHeaders.aon} +0 -0
  61. /package/project/standard/.sdk/test/primary/{transformRequest.aontu → transformRequest.aon} +0 -0
  62. /package/project/standard/.sdk/test/primary/{transformResponse.aontu → transformResponse.aon} +0 -0
  63. /package/project/standard/.sdk/test/struct/{getpath.aontu → getpath.aon} +0 -0
  64. /package/project/standard/.sdk/test/struct/{inject.aontu → inject.aon} +0 -0
  65. /package/project/standard/.sdk/test/struct/{merge.aontu → merge.aon} +0 -0
  66. /package/project/standard/.sdk/test/struct/{minor.aontu → minor.aon} +0 -0
  67. /package/project/standard/.sdk/test/struct/{select.aontu → select.aon} +0 -0
  68. /package/project/standard/.sdk/test/struct/{transform.aontu → transform.aon} +0 -0
  69. /package/project/standard/.sdk/test/struct/{validate.aontu → validate.aon} +0 -0
  70. /package/project/standard/.sdk/test/struct/{walk.aontu → walk.aon} +0 -0
@@ -285,7 +285,7 @@ async function installNpm(spec: GenerateSpec, opts: any, model: any) {
285
285
  // They ARE npm run scripts that resolve @voxgig/sdkgen from node_modules, so
286
286
  // without one they cannot work. Fail with an actionable message rather than
287
287
  // the raw module-resolution error — and rather than silently skipping, which
288
- // reports success while leaving config.aontu without the requested entries.
288
+ // reports success while leaving config.aon without the requested entries.
289
289
  const wanted = [
290
290
  (spec.target ?? []).length ? '--target' : '',
291
291
  (spec.feature ?? []).length ? '--feature' : '',
@@ -66,7 +66,7 @@ log/
66
66
  //
67
67
  // Everything else the scaffold writes is toolchain-derived and is deliberately
68
68
  // OVERWRITTEN (see the `existing.txt.write` rationale in create-sdkgen.ts) so a
69
- // toolchain fix propagates. `model/guide/guide.aontu` is the exception: apidef
69
+ // toolchain fix propagates. `model/guide/guide.aon` is the exception: apidef
70
70
  // unifies it OVER the heuristic classification, and it is where every
71
71
  // documented customization lives — entity rename, hide, move, activate,
72
72
  // per-path deactivation, method override, param rename, response transform.
@@ -77,25 +77,25 @@ log/
77
77
  // It is excluded from the bulk Copy and merged instead (see mergeGuide).
78
78
  // The PROJECT overlay: the second model file the user owns.
79
79
  //
80
- // `guide.aontu` owns what the API looks like. This owns what the PROJECT is —
80
+ // `guide.aon` owns what the API looks like. This owns what the PROJECT is —
81
81
  // publication values above all. The sdkgen schema tells you to declare those
82
- // in `model/sdk.aontu` "where they survive a resync", and that was simply not
83
- // true: ModelSdk rewrites sdk.aontu from its template on every scaffold, so a
82
+ // in `model/sdk.aon` "where they survive a resync", and that was simply not
83
+ // true: ModelSdk rewrites sdk.aon from its template on every scaffold, so a
84
84
  // version or package name declared there vanished before the model was built,
85
85
  // with no error. The cedar fleet ran for months with every manifest pinned at
86
86
  // the schema default 0.0.1 while its git tags climbed past 0.1.1, and this is
87
87
  // why.
88
88
  //
89
- // sdk.aontu cannot simply be merged the way guide.aontu is. Its template owns
89
+ // sdk.aon cannot simply be merged the way guide.aon is. Its template owns
90
90
  // `name`, `origin` and especially `def` — the OpenAPI filename, which really
91
91
  // does change (three cedar specs were renamed in one week). A "keep the user's
92
92
  // file" merge would freeze `def` at a spec that no longer exists and break
93
- // regeneration. So the template keeps sole ownership of sdk.aontu, and the
94
- // user gets a file of their own that sdk.aontu includes.
93
+ // regeneration. So the template keeps sole ownership of sdk.aon, and the
94
+ // user gets a file of their own that sdk.aon includes.
95
95
  //
96
96
  // Written ONCE. If it exists, it is re-emitted byte-for-byte, so a
97
97
  // re-scaffold is a no-op on it.
98
- const PROJECT_FILE = 'project.aontu'
98
+ const PROJECT_FILE = 'project.aon'
99
99
  const PROJECT_STUB = `# Project overlay — YOURS. The scaffold creates this file once and never
100
100
  # overwrites it, unlike every other file it writes.
101
101
  #
@@ -103,7 +103,7 @@ const PROJECT_STUB = `# Project overlay — YOURS. The scaffold creates this fil
103
103
  # regenerated so that toolchain fixes propagate. Put anything here that is a
104
104
  # decision about THIS project rather than a fact about the API.
105
105
  #
106
- # Included LAST by sdk.aontu, after target/target-index.aontu, because a key
106
+ # Included LAST by sdk.aon, after target/target-index.aon, because a key
107
107
  # under main.kit.target.<t> can only refine a target that has already been
108
108
  # defined. Declared earlier, the model build fails with "Cannot unify value:
109
109
  # nil with value: string / key ext value was: nil", which names nothing that
@@ -123,10 +123,49 @@ const PROJECT_STUB = `# Project overlay — YOURS. The scaffold creates this fil
123
123
  `
124
124
 
125
125
 
126
- const GUIDE_FILE = 'guide.aontu'
126
+ const GUIDE_FILE = 'guide.aon'
127
127
  const GUIDE_REL = ['model', 'guide', GUIDE_FILE]
128
128
 
129
129
 
130
+ // Rename a user-owned overlay from its pre-2026-08 `.aontu` name to `.aon`.
131
+ //
132
+ // Both overlays are read-if-present and written-if-absent, which is exactly
133
+ // the shape that turns an extension rename into DATA LOSS rather than a
134
+ // rename: look for `guide.aon`, find nothing, write a fresh template over the
135
+ // top, and the user's entity renames, hides and overrides are still sitting
136
+ // in `guide.aontu` being ignored. 660 generated repos carry one.
137
+ //
138
+ // So the legacy file is moved to the new name BEFORE anything reads or writes
139
+ // it. Contents are untouched; only the name changes. Idempotent — once the
140
+ // `.aon` exists this does nothing, so a re-scaffold stays a no-op.
141
+ function migrateOverlay(fs: any, dir: string, name: string): void {
142
+ const next = Path.join(dir, name + '.aon')
143
+ const prev = Path.join(dir, name + '.aontu')
144
+ if (fs.existsSync(next) || !fs.existsSync(prev)) {
145
+ return
146
+ }
147
+ try {
148
+ // RENAME THE FILE *AND* ITS INCLUDES. An overlay written before the
149
+ // rename includes the toolchain schemas by their old names —
150
+ // `@"@voxgig/apidef/model/guide.aontu"` — and apidef 8 no longer ships
151
+ // that file, so a migration that moved the file but kept its contents
152
+ // verbatim produced a project that could not resolve its own guide.
153
+ // mergeGuide cannot repair this either: it keeps the user's lines and
154
+ // only ADDS missing template includes, so the dead one would survive
155
+ // beside the new one. Only `@`-include extensions are touched; nothing
156
+ // else in the user's file is rewritten.
157
+ const src = String(fs.readFileSync(prev))
158
+ .replace(/(@['"][^'"]+)\.aontu(['"])/g, '$1.aon$2')
159
+ fs.writeFileSync(next, src)
160
+ fs.unlinkSync(prev)
161
+ }
162
+ catch (_err: any) {
163
+ // A failed migration must not fail the scaffold: the worst case is the
164
+ // template being written fresh, which is what would have happened anyway.
165
+ }
166
+ }
167
+
168
+
130
169
  // Merge the guide template into an existing guide overlay.
131
170
  //
132
171
  // A guide is the template's `@`-includes plus whatever the user added. The
@@ -135,7 +174,7 @@ const GUIDE_REL = ['model', 'guide', GUIDE_FILE]
135
174
  // is missing — the normal case — the file is returned byte-identical, so a
136
175
  // re-scaffold is a no-op on it.
137
176
  //
138
- // Missing includes are restored at the TOP, not appended: `base-guide.aontu`
177
+ // Missing includes are restored at the TOP, not appended: `base-guide.aon`
139
178
  // carries the heuristic classification that the user's overrides unify over,
140
179
  // and the overlay reads correctly only when the includes precede it.
141
180
  function mergeGuide(existing: string | null, template: string): string {
@@ -163,7 +202,7 @@ function mergeGuide(existing: string | null, template: string): string {
163
202
  // slugs are not constrained: the freepublicapis corpus contains apostrophes
164
203
  // (catherine-shulman's-quotes), accents (dólar-y-monedas, kölner-adressen),
165
204
  // and '!' / '>' / '_'. That name is copied into .sdk/def/ AND written verbatim
166
- // into a single-quoted aontu string in sdk.aontu:
205
+ // into a single-quoted aontu string in sdk.aon:
167
206
  //
168
207
  // def: 'catherine-shulman's-quotes_0.1.0.json'
169
208
  // ^ terminates the string -> AontuError, no SDK
@@ -255,6 +294,11 @@ const CreateRoot = cmp(function CreateRoot(props: any) {
255
294
  // special case in the component tree.
256
295
  const projectPath =
257
296
  Path.join(folder, spec.sdk_folder, 'model', PROJECT_FILE)
297
+
298
+ // Same hazard, worse symptom: this file carries the release version,
299
+ // so an ignored project.aontu silently resets every generated manifest
300
+ // to the sdkgen default 0.0.1 — the exact bug fixed earlier this week.
301
+ migrateOverlay(fs, Path.dirname(projectPath), 'project')
258
302
  const existingProject =
259
303
  fs.existsSync(projectPath) ? fs.readFileSync(projectPath, 'utf8') : null
260
304
 
@@ -269,6 +313,10 @@ const CreateRoot = cmp(function CreateRoot(props: any) {
269
313
  const guideTemplate =
270
314
  fs.readFileSync(Path.join(from, spec.sdk_folder, ...GUIDE_REL), 'utf8')
271
315
  const guidePath = Path.join(folder, spec.sdk_folder, ...GUIDE_REL)
316
+
317
+ // Before the merge looks for it — otherwise a project whose guide is
318
+ // still named .aontu reads as having no overlay at all.
319
+ migrateOverlay(fs, Path.dirname(guidePath), 'guide')
272
320
  const existingGuide =
273
321
  fs.existsSync(guidePath) ? fs.readFileSync(guidePath, 'utf8') : null
274
322
 
@@ -17,9 +17,9 @@ const ModelSdk = cmp(function ModelSdk(props: any) {
17
17
  const from =
18
18
  Path.resolve(Path.join(__dirname, '..', '..', '..', 'project', 'standard'))
19
19
 
20
- File({ name: 'sdk.aontu' }, () => {
20
+ File({ name: 'sdk.aon' }, () => {
21
21
  Fragment({
22
- from: Path.join(from, spec.sdk_folder, 'model', 'sdk.fragment.aontu'),
22
+ from: Path.join(from, spec.sdk_folder, 'model', 'sdk.fragment.aon'),
23
23
  replace: {
24
24
  ProjectName: spec.name,
25
25
  NAME: spec.name,
@@ -1,8 +0,0 @@
1
- # Guide
2
-
3
- @"@voxgig/apidef/model/guide.aontu"
4
-
5
- @"base-guide.aontu"
6
-
7
-
8
-
@@ -1,4 +0,0 @@
1
-
2
- @"@voxgig/model/model/.model-config/model-config.aontu"
3
-
4
- sys: model: builders: {}
@@ -1,30 +0,0 @@
1
- primary: clean: @"clean.aontu"
2
- primary: done: @"done.aontu"
3
- primary: featureAdd: @"featureAdd.aontu"
4
- primary: featureHook: @"featureHook.aontu"
5
- primary: featureInit: @"featureInit.aontu"
6
- primary: fetcher: @"fetcher.aontu"
7
- primary: makeContext: @"makeContext.aontu"
8
- primary: makeError: @"makeError.aontu"
9
- primary: makeFetchDef: @"makeFetchDef.aontu"
10
- primary: makeOptions: @"makeOptions.aontu"
11
- primary: makeRequest: @"makeRequest.aontu"
12
- primary: makeResponse: @"makeResponse.aontu"
13
- primary: makeResult: @"makeResult.aontu"
14
- primary: makeSpec: @"makeSpec.aontu"
15
- primary: makePoint: @"makePoint.aontu"
16
- primary: makeUrl: @"makeUrl.aontu"
17
- primary: operator: @"operator.aontu"
18
- primary: param: @"param.aontu"
19
- primary: prepareAuth: @"prepareAuth.aontu"
20
- primary: prepareBody: @"prepareBody.aontu"
21
- primary: prepareHeaders: @"prepareHeaders.aontu"
22
- primary: prepareMethod: @"prepareMethod.aontu"
23
- primary: prepareParams: @"prepareParams.aontu"
24
- primary: preparePath: @"preparePath.aontu"
25
- primary: prepareQuery: @"prepareQuery.aontu"
26
- primary: resultBasic: @"resultBasic.aontu"
27
- primary: resultBody: @"resultBody.aontu"
28
- primary: resultHeaders: @"resultHeaders.aontu"
29
- primary: transformRequest: @"transformRequest.aontu"
30
- primary: transformResponse: @"transformResponse.aontu"
@@ -1,25 +0,0 @@
1
-
2
- struct: &: {
3
- name: .$KEY
4
- set: []
5
- }
6
-
7
- struct: minor: @"minor.aontu"
8
- struct: getpath: @"getpath.aontu"
9
- struct: inject: @"inject.aontu"
10
- struct: merge: @"merge.aontu"
11
- struct: transform: @"transform.aontu"
12
- struct: walk: @"walk.aontu"
13
- struct: validate: @"validate.aontu"
14
- struct: select: @"select.aontu"
15
-
16
- primary: check: {
17
- DEF: {
18
- client:a:test:options:foo:1
19
- }
20
- basic: set: [
21
- { ctx:meta:bar:BAR0, out:zed:ZED_BAR0 }
22
- { ctx:meta:bar:BAR1, client:a, out:zed:ZED1_BAR1 }
23
- ]
24
- }
25
-
@@ -1,3 +0,0 @@
1
-
2
- @"struct/test.aontu"
3
- @"primary/primary-test-index.aontu"